callcontinuity/vccclientprovisioningadapter/src/wpvccadapter.cpp
changeset 0 a4daefaec16c
child 1 bfb1de3eac8e
equal deleted inserted replaced
-1:000000000000 0:a4daefaec16c
       
     1 /*
       
     2 * Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Handles Vcc settings in provisioning.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <e32base.h>
       
    21 #include <commdb.h>
       
    22 #include <CWPAdapter.h>
       
    23 #include <CWPCharacteristic.h>
       
    24 #include <CWPParameter.h>
       
    25 #include <utf.h>
       
    26 #include <wpvccadapterrsc.rsg>
       
    27 #include <crcseprofileentry.h>
       
    28 #include <crcseprofileregistry.h>
       
    29 #include <WPAdapterUtil.h>
       
    30 
       
    31 #include "wpvccadapter.h"
       
    32 #include "rubydebug.h"
       
    33 #include "vccspsettings.h"
       
    34 #include "wpvccadapteruids.h"
       
    35 #include <cch.h>
       
    36 #include "vccsettingsreader.h"
       
    37 #include <sipmanagedprofileregistry.h>
       
    38 #include <sipprofile.h>
       
    39 #include <spsettings.h>
       
    40 #include <spproperty.h>
       
    41 #include <cmmanagerext.h>
       
    42 #include <cmdestinationext.h>
       
    43 
       
    44 /** Name of *this adapter */
       
    45 _LIT( KVccResourceFileNameWithoutSuffix,  "wpvccadapterrsc" );
       
    46 
       
    47 /** Provisioning file format specific settings */
       
    48 // OMA Experimental values, registered by OMNA only for advisory purposes
       
    49 // range 0x4000 to 0x1FFFFF
       
    50 _LIT( KVccAppID,        "w9054" );        
       
    51 _LIT8( KVoIPAppID8,     "w9013" );  	  // OMA CP registration document for VoIP
       
    52 _LIT( KVdi,             "VDI" );          // 
       
    53 _LIT( KVdn,             "VDN" );          // 
       
    54 _LIT( KPreferredDomain, "PREF-DOMAIN" );  // 
       
    55 _LIT( KImmediateDT,     "IMMEDIATE-DOMAIN-TRANSFER" );   // 
       
    56 _LIT( KDtCsToPsAllowed, "DT-CS-TO-PS-ALLOWED" );      // 
       
    57 _LIT( KDtPsToCsAllowed, "DT-PS-TO-CS-ALLOWED" );     // 
       
    58 _LIT( KDtHeldwaitingCallsAllowed, "DT-HELD-WAITING-CALLS-ALLOWED" );     // 
       
    59 
       
    60 _LIT( KWlanHOTreshold, "WLAN-HO-THRESHOLD-VALUE" );
       
    61 _LIT( KWlanHOHysteresis, "WLAN-HO-HYSTERESIS-VALUE" );
       
    62 _LIT( KWlanHysteresisTimerLow, "WLAN-HYSTERESIS-TIMER-LOW" );
       
    63 _LIT( KWlanHysteresisTimerHigh, "WLAN-HYSTERESIS-TIMER-HIGH" );
       
    64 
       
    65 _LIT( KCSHOTreshold, "CS-HO-THRESHOLD-VALUE" );
       
    66 _LIT( KCSHOHysteresis, "CS-HO-HYSTERESIS-VALUE" );
       
    67 _LIT( KCSHysteresisTimerLow, "CS-HYSTERESIS-TIMER-LOW" );
       
    68 _LIT( KCSHysteresisTimerHigh, "CS-HYSTERESIS-TIMER-HIGH" );
       
    69 _LIT( KDtAllowedWhenCsOriginated, "DT-ALLOWED-WHEN-CS-ORIGINATED" );
       
    70 
       
    71 _LIT16( KDefaultName, "VCC application settings" );
       
    72 
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // ResetAndDestroyEntries
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 void ResetAndDestroyProfileEntries( TAny* anArray )
       
    79     {
       
    80 
       
    81     RPointerArray<CRCSEProfileEntry>* array =
       
    82         reinterpret_cast<RPointerArray<CRCSEProfileEntry>*>( anArray );
       
    83 
       
    84     if (array)
       
    85         {
       
    86         array->ResetAndDestroy();
       
    87         array->Close();
       
    88         }
       
    89     }
       
    90 
       
    91 // ======== MEMBER FUNCTIONS ========
       
    92 // ---------------------------------------------------------------------------
       
    93 // C++ constructor
       
    94 // ---------------------------------------------------------------------------
       
    95 //
       
    96 CWPVccAdapter::CWPVccAdapter() : CWPAdapter()
       
    97     {
       
    98     }
       
    99 
       
   100 // ---------------------------------------------------------------------------
       
   101 // Symbian 2nd phase constructor
       
   102 // ---------------------------------------------------------------------------
       
   103 //
       
   104 void CWPVccAdapter::ConstructL()
       
   105     {
       
   106     RUBY_DEBUG_BLOCKL( "CWPVccAdapter::ConstructL" );
       
   107     
       
   108     TFileName fileName;
       
   109     
       
   110     // ReadHBufCL needs the path where the resource file is.
       
   111     // Actually, the WPAdapterUtil only uses the drive part of the string
       
   112     // (which is normally "z:")
       
   113     // The resource file name must not contain the suffix since it is
       
   114     // added.
       
   115     
       
   116     Dll::FileName( fileName );
       
   117     
       
   118     iTitle = WPAdapterUtil::ReadHBufCL(
       
   119         fileName, KVccResourceFileNameWithoutSuffix, R_QTN_SM_HEAD_VCC );
       
   120      }
       
   121 
       
   122 // ---------------------------------------------------------------------------
       
   123 // Constructor
       
   124 // ---------------------------------------------------------------------------
       
   125 //
       
   126 CWPVccAdapter* CWPVccAdapter::NewL()
       
   127     {
       
   128     RUBY_DEBUG_BLOCKL( "CWPVccAdapter::NewL" );
       
   129     CWPVccAdapter* self = new( ELeave ) CWPVccAdapter;
       
   130     CleanupStack::PushL( self );
       
   131     self->ConstructL();
       
   132     CleanupStack::Pop( self );
       
   133     return self;
       
   134     }
       
   135 
       
   136 // ---------------------------------------------------------------------------
       
   137 // Destructor
       
   138 // ---------------------------------------------------------------------------
       
   139 //
       
   140 CWPVccAdapter::~CWPVccAdapter()
       
   141     {
       
   142     RUBY_DEBUG0( "CWPVccAdapter::~CWPVccAdapter() - ENTER" );
       
   143    
       
   144     iToAppReferences.Close();
       
   145     delete iTitle;
       
   146     delete iAppID;
       
   147     delete iVccItem;
       
   148     delete iNewVccItem;
       
   149  
       
   150     RUBY_DEBUG0( "CWPVccAdapter::~CWPVccAdapter() - EXIT" );
       
   151     }
       
   152 
       
   153 // ---------------------------------------------------------------------------
       
   154 // Not currently supported.
       
   155 // ---------------------------------------------------------------------------
       
   156 //
       
   157 TInt CWPVccAdapter::ContextExtension( MWPContextExtension*& /*aExtension*/ )
       
   158     {
       
   159     RUBY_DEBUG_BLOCK( "CWPVccAdapter::ContextExtension" );
       
   160     return KErrNotSupported;
       
   161     }
       
   162 
       
   163 // ---------------------------------------------------------------------------
       
   164 // Not currently supported.
       
   165 // ---------------------------------------------------------------------------
       
   166 //
       
   167 const TDesC8& CWPVccAdapter::SaveDataL( TInt /*aIndex*/ ) const
       
   168     {
       
   169     RUBY_DEBUG_BLOCK( "CWPVccAdapter::SaveDataL" );
       
   170     User::Leave( KErrNotSupported );
       
   171     // Nothing returned cause we leave.
       
   172     return KNullDesC8;
       
   173     }
       
   174 
       
   175 // ---------------------------------------------------------------------------
       
   176 // Not currently supported.
       
   177 // ---------------------------------------------------------------------------
       
   178 //
       
   179 void CWPVccAdapter::DeleteL( const TDesC8& /*aSaveData*/ )
       
   180     {
       
   181     RUBY_DEBUG_BLOCK( "CWPVccAdapter::DeleteL" );
       
   182     User::Leave( KErrNotSupported );
       
   183     }
       
   184 
       
   185 // ---------------------------------------------------------------------------
       
   186 // Returns UID of the adapter (*this).
       
   187 // ---------------------------------------------------------------------------
       
   188 //
       
   189 TUint32 CWPVccAdapter::Uid() const
       
   190     {
       
   191     RUBY_DEBUG_BLOCK( "CWPVccAdapter::Uid" );
       
   192     return KProvisioningVccAdapterImplementationUid; //iDtor_ID_Key.iUid;
       
   193     }
       
   194 
       
   195 // ---------------------------------------------------------------------------
       
   196 // Used to query for the detail information about the Vcc profile.
       
   197 // Not currently supported.
       
   198 // ---------------------------------------------------------------------------
       
   199 //
       
   200 TInt CWPVccAdapter::DetailsL( TInt, MWPPairVisitor& )
       
   201     {
       
   202     RUBY_DEBUG_BLOCK( "CWPVccAdapter::DetailsL" );
       
   203     return KErrNotSupported;
       
   204     }
       
   205 
       
   206 // ---------------------------------------------------------------------------
       
   207 // Returns the amount of Vcc data items (always 1 if data got, otherwise 0).
       
   208 // ---------------------------------------------------------------------------
       
   209 //
       
   210 TInt CWPVccAdapter::ItemCount() const
       
   211     {
       
   212     RUBY_DEBUG_BLOCK( "CWPVccAdapter::ItemCount" );
       
   213     return iVccItem ? 1 : 0;
       
   214     }
       
   215 
       
   216 // ---------------------------------------------------------------------------
       
   217 // Returns summary title of the Vcc profile received in configuration
       
   218 // message.
       
   219 // ---------------------------------------------------------------------------
       
   220 //
       
   221 const TDesC16& CWPVccAdapter::SummaryTitle( TInt /*aIndex*/ ) const
       
   222     {
       
   223     RUBY_DEBUG_BLOCK( "CWPVccAdapter::SummaryTitle" );
       
   224     return *iTitle;
       
   225     }
       
   226 
       
   227 // ---------------------------------------------------------------------------
       
   228 // Returns summary text of the Vcc profile received in configuration
       
   229 // message. Returns NULL descriptor if no settings received.
       
   230 // ---------------------------------------------------------------------------
       
   231 //
       
   232 const TDesC16& CWPVccAdapter::SummaryText( TInt /*aIndex*/ ) const
       
   233     {
       
   234     RUBY_DEBUG_BLOCK( "CWPVccAdapter::SummaryText" );
       
   235 
       
   236 	if ( iVccItem )
       
   237 	    {
       
   238 	    RUBY_DEBUG0( "-vccitem Name" );
       
   239 	    return iVccItem->ServiceName();
       
   240 	    }
       
   241     else
       
   242         {
       
   243   
       
   244         RUBY_DEBUG0( " - default text NO ITEM!" );
       
   245         return KDefaultName;
       
   246         }
       
   247     }
       
   248 
       
   249 // ---------------------------------------------------------------------------
       
   250 // Saves Vcc item (whole profile). If no settings are received, leaves with
       
   251 // errorcode KErrGeneral.
       
   252 // ---------------------------------------------------------------------------
       
   253 //
       
   254 void CWPVccAdapter::SaveL( TInt /*aIndex*/ )
       
   255     {
       
   256     RUBY_DEBUG_BLOCK( "CWPVccAdapter::SaveL" );
       
   257     
       
   258     TRAP_IGNORE( RemoveVCCSettingsL() );
       
   259     
       
   260 	// Lets do the saving when framework calls savingFinalisedL method
       
   261     }
       
   262 
       
   263 // ---------------------------------------------------------------------------
       
   264 // Tells if current profile can be set as a default profile. Since Vcc
       
   265 // currently supports only single profile, return value is always false.
       
   266 // ---------------------------------------------------------------------------
       
   267 //
       
   268 TBool CWPVccAdapter::CanSetAsDefault( TInt /*aIndex*/ ) const
       
   269     {
       
   270     RUBY_DEBUG_BLOCK( "CWPVccAdapter::CanSetAsDefault" );
       
   271     return EFalse;
       
   272     }
       
   273 
       
   274 // ---------------------------------------------------------------------------
       
   275 // Sets the Vcc item on place pointed by index given in parameter as default.
       
   276 // Since Vcc currently supports only single profile and CanSetAsDefault method
       
   277 // always returns false, this method should never be called. It is unsupported
       
   278 // and does nothing. Derivation of this method is done only to fulfill the
       
   279 // demands of s60 Coding conventions, Symbian OS, C++ and other entities
       
   280 // setting boundaries for specific software as *this.
       
   281 // ---------------------------------------------------------------------------
       
   282 //
       
   283 void CWPVccAdapter::SetAsDefaultL( TInt /*aIndex*/ )
       
   284     {
       
   285     RUBY_DEBUG_BLOCK( "CWPVccAdapter::SetAsDefaultL" );
       
   286     // This shouldn't be called because CanSetAsDefault
       
   287     // always returns EFalse
       
   288     User::Leave( KErrNotSupported );
       
   289     }
       
   290 
       
   291 // ---------------------------------------------------------------------------
       
   292 // This method is called by the provisioning framework to "visit" an adapter
       
   293 // plugin (*this). Plugin then checks if the visiting aCharacteristic are
       
   294 // of the particular type that this plugin wants to handle, and if so, it
       
   295 // invites the visitor deeper in to more intimate series of visits through
       
   296 // overloaded VisitL method with CWPParameter& visitor aboard.
       
   297 // Generally this plugin is interested in two type of visitors, one called
       
   298 // KWPApplication (carrying application level data), and other called
       
   299 // KWPNapDef (carrying data needed to establish new IAPs).
       
   300 // ---------------------------------------------------------------------------
       
   301 //
       
   302 void CWPVccAdapter::VisitL( CWPCharacteristic& aCharacteristic )
       
   303     {
       
   304     RUBY_DEBUG_BLOCK( "CWPVccAdapter::VisitL char" );
       
   305     
       
   306     switch ( aCharacteristic.Type() )
       
   307         {
       
   308         case KWPApplication:
       
   309             {
       
   310             RUBY_DEBUG0( " - KWPApplication create new item" );
       
   311             iNewVccItem = CVccSPSettings::NewL();
       
   312         
       
   313             iCurrentCharacteristicType = aCharacteristic.Type() ;
       
   314             aCharacteristic.AcceptL( *this );
       
   315         
       
   316             if( iAppID && *iAppID == KVccAppID )
       
   317                 {
       
   318                 RUBY_DEBUG0( "- VCC AppId used" );
       
   319                 delete iVccItem;
       
   320                 iVccItem = iNewVccItem;
       
   321                 }
       
   322             else
       
   323                 {
       
   324                 delete iNewVccItem;
       
   325                 }
       
   326             iNewVccItem = NULL;   
       
   327             }break;
       
   328         default:
       
   329             {
       
   330             }break;
       
   331         }
       
   332 
       
   333     }
       
   334 
       
   335 // ---------------------------------------------------------------------------
       
   336 // This "visit" method should be called by all params in CWPCharacteristic&
       
   337 // visitors invited welcome in VisitL( CWPCharacteristic& ) overload. The
       
   338 // information in visiting params are then stored to VccItem datastructure for
       
   339 // future use.
       
   340 // ---------------------------------------------------------------------------
       
   341 //
       
   342 void CWPVccAdapter::VisitL( CWPParameter& aParameter )
       
   343     {
       
   344     RUBY_DEBUG0( "VisitL param" );
       
   345     
       
   346     switch( aParameter.ID() )
       
   347         {
       
   348         case EWPParameterAppID:
       
   349             {
       
   350 	        RUBY_DEBUG0( "- got EWPParameterAppID");
       
   351             delete iAppID; 
       
   352 	        iAppID = NULL;
       
   353 	        iAppID = aParameter.Value().AllocL();
       
   354             
       
   355             
       
   356             }break;
       
   357         case EWPNamedParameter:
       
   358             {
       
   359             RUBY_DEBUG0( "- got EWPNamedParameter populate VCC item" );
       
   360             
       
   361             if( !iNewVccItem )
       
   362                 {
       
   363                 RUBY_DEBUG0( "- NO VCC item " );
       
   364                 return;
       
   365                 }
       
   366             
       
   367             TPtrC value( aParameter.Value() );
       
   368 
       
   369             if ( aParameter.Name().Compare( KVdi )  == KErrNone )
       
   370                 {
       
   371                 RUBY_DEBUG1( "- got VDI:%S" , 
       
   372                              &value );
       
   373                 iNewVccItem->SetVdiL( value );
       
   374                 }
       
   375             else if ( aParameter.Name().Compare( KVdn )  == KErrNone  )
       
   376                 {
       
   377                 RUBY_DEBUG1( "- got VDN:%S" ,
       
   378                              &value );
       
   379 #if defined( _DEBUG )                
       
   380                 TInt val = aParameter.Name().Compare( KVdn );
       
   381                 TBool valb (!val);
       
   382 #endif                
       
   383                 RUBY_DEBUG1( "- got val:%d", val );
       
   384                 RUBY_DEBUG1( "- got valb:%d", valb );
       
   385                 
       
   386                 iNewVccItem->SetVdnL( value );
       
   387                 }
       
   388             else if ( aParameter.Name().Compare( KPreferredDomain ) == KErrNone )
       
   389                 {
       
   390                 RUBY_DEBUG1( "- got Preferred Domain:%S" ,
       
   391                              &value );
       
   392                 iNewVccItem->SetPreferredDomainL( value );
       
   393                 }
       
   394             else if ( aParameter.Name().Compare( KImmediateDT )  == KErrNone  )
       
   395                 {
       
   396                 RUBY_DEBUG1( "- got Immediate DT:%S" , 
       
   397                             &value );
       
   398                 iNewVccItem->SetImmediateDtL( value );
       
   399                 }
       
   400             else if ( aParameter.Name().Compare( KDtCsToPsAllowed ) == KErrNone )
       
   401                 {
       
   402                 RUBY_DEBUG1( "- got DT from CS to PS allowed:%S" ,
       
   403                              &value );
       
   404                       
       
   405                 iNewVccItem->SetDtCsToPsAllowedL( value );
       
   406                 }
       
   407             else if ( aParameter.Name().Compare( KDtPsToCsAllowed ) == KErrNone )
       
   408                 {
       
   409                 RUBY_DEBUG1( "- got DT from CS to PS allowed:%S" ,
       
   410                              &value );
       
   411                       
       
   412                 iNewVccItem->SetDtPsToCsAllowedL( value );
       
   413                 }
       
   414             else if ( aParameter.Name().Compare( 
       
   415                             KDtHeldwaitingCallsAllowed )  == KErrNone )
       
   416                 {
       
   417                 RUBY_DEBUG1( "- got DT from CS to PS allowed:%S" ,
       
   418                              &value );
       
   419                       
       
   420                 iNewVccItem->SetDtHeldWaitingCallsAllowedL( value );
       
   421                 }
       
   422             else if ( aParameter.Name().Compare( 
       
   423                             KWlanHOTreshold )  == KErrNone )
       
   424                 {
       
   425                 RUBY_DEBUG1( "- got DT from WLAN HO Treshold value:%S" ,
       
   426                              &value );
       
   427                      
       
   428                 iNewVccItem->SetDtWlanHoTresholdL( value );
       
   429                 }
       
   430             else if ( aParameter.Name().Compare( 
       
   431                             KWlanHOHysteresis )  == KErrNone )
       
   432                 {
       
   433                 RUBY_DEBUG1( "- got DT from WLAN HO hysteresis value:%S" ,
       
   434                              &value );
       
   435                       
       
   436                 iNewVccItem->SetDtWlanHoHysteresisL( value );
       
   437                 }
       
   438             else if ( aParameter.Name().Compare( 
       
   439                             KWlanHysteresisTimerLow )  == KErrNone )
       
   440                 {
       
   441                 RUBY_DEBUG1( "- got DT from WLAN Hysteresis timer low:%S" ,
       
   442                              &value );
       
   443                       
       
   444                 iNewVccItem->SetDtWlanHoHysteresisTimerLowL( value );
       
   445                 }
       
   446             else if ( aParameter.Name().Compare( 
       
   447                             KWlanHysteresisTimerHigh )  == KErrNone )
       
   448                 {
       
   449                 RUBY_DEBUG1( "- got DT from WLAN Hysteresis timer high:%S" ,
       
   450                              &value );
       
   451                       
       
   452                 iNewVccItem->SetDtWlanHoHysteresisTimerHighL( value );
       
   453                 }
       
   454 
       
   455             else if ( aParameter.Name().Compare( 
       
   456                             KCSHOTreshold )  == KErrNone )
       
   457                 {
       
   458                 RUBY_DEBUG1( "- got DT from CS HO Treshold value:%S" ,
       
   459                              &value );
       
   460                      
       
   461                 iNewVccItem->SetDtCsHoTresholdL( value );
       
   462                 }
       
   463             else if ( aParameter.Name().Compare( 
       
   464                             KCSHOHysteresis )  == KErrNone )
       
   465                 {
       
   466                 RUBY_DEBUG1( "- got DT from CS HO hysteresis value:%S" ,
       
   467                              &value );
       
   468                       
       
   469                 iNewVccItem->SetDtCsHoHysteresisL( value );
       
   470                 }
       
   471             else if ( aParameter.Name().Compare( 
       
   472                             KCSHysteresisTimerLow )  == KErrNone )
       
   473                 {
       
   474                 RUBY_DEBUG1( "- got DT from CS Hysteresis timer low:%S" ,
       
   475                              &value );
       
   476                       
       
   477                 iNewVccItem->SetDtCsHoHysteresisTimerLowL( value );
       
   478                 }
       
   479             else if ( aParameter.Name().Compare( 
       
   480                             KCSHysteresisTimerHigh )  == KErrNone )
       
   481                 {
       
   482                 RUBY_DEBUG1( "- got DT from CS Hysteresis timer high:%S" ,
       
   483                              &value );
       
   484                       
       
   485                 iNewVccItem->SetDtCsHoHysteresisTimerHighL( value );
       
   486                 }
       
   487             else if( aParameter.Name().Compare( 
       
   488                         KDtAllowedWhenCsOriginated )  == KErrNone )
       
   489                 {
       
   490                 RUBY_DEBUG1( "- got DT allowed when CS originated:%S" ,
       
   491                                              &value );
       
   492                 iNewVccItem->SetDtAllowedWhenCsOriginated( value );
       
   493                 }
       
   494             else
       
   495                 {
       
   496                 RUBY_DEBUG0( "- no such VCC param" );    
       
   497                 }    
       
   498             break;
       
   499             }
       
   500         case EWPParameterProviderID: // APPLICATION/PROVIDER-ID
       
   501             {
       
   502             if( iNewVccItem != NULL )
       
   503                 {
       
   504                 RUBY_DEBUG0( "- got EWPParameterProviderID" );
       
   505                 
       
   506                 iNewVccItem->SetProviderIdL( aParameter.Value() );
       
   507                 
       
   508                 }
       
   509                 
       
   510             } break;
       
   511 
       
   512         case EWPParameterName: // APPLICATION/NAME
       
   513             {
       
   514             if( iNewVccItem != NULL )
       
   515                 {
       
   516                 RUBY_DEBUG0( "- got EWPParameterName" );
       
   517                 iNewVccItem->SetServiceNameL( aParameter.Value() );
       
   518 
       
   519                 }
       
   520 
       
   521             } break;
       
   522             
       
   523         case EWPParameterToAppRef:
       
   524             {
       
   525             RUBY_DEBUG1("-got EWPParameterToAppRef: %S", &aParameter.Value());
       
   526             iToAppReferences.Append(aParameter.Value());
       
   527             break;
       
   528             }
       
   529       default:
       
   530             {
       
   531             RUBY_DEBUG0( "- got unknown" );
       
   532         
       
   533             } break;
       
   534         }
       
   535     }
       
   536 
       
   537 // ---------------------------------------------------------------------------
       
   538 // This method is called when the provisioning framework finds a link to
       
   539 // special characteristic belonging to characteristics accepted by *this
       
   540 // plugin. The linked characteristics are stored to VccItem data structure
       
   541 // for future use in a need-to-store basis.
       
   542 // ---------------------------------------------------------------------------
       
   543 //
       
   544 void CWPVccAdapter::VisitLinkL( CWPCharacteristic& /*aLink*/ )
       
   545     {
       
   546     RUBY_DEBUG_BLOCK( "CWPVccAdapter::VisitLinkL" );
       
   547     User::Leave( KErrNotSupported );
       
   548     }
       
   549 
       
   550 
       
   551 // -----------------------------------------------------------------------------
       
   552 // CWPVccAdapter::::SettingsSavedL
       
   553 //
       
   554 // -----------------------------------------------------------------------------
       
   555 void CWPVccAdapter::SettingsSavedL(const TDesC8& aAppIdOfSavingItem,
       
   556                                                 const TDesC8& aAppRef, 
       
   557                                                 const TDesC8& aStorageIdValue)
       
   558     {
       
   559     RUBY_DEBUG_BLOCK( "CWPVccAdapter::SettingsSavedL" );
       
   560    
       
   561 #ifdef _DEBUG
       
   562     HBufC* tmp = HBufC::NewLC( aAppIdOfSavingItem.Length() );
       
   563     tmp->Des().Copy( aAppIdOfSavingItem );
       
   564     RUBY_DEBUG1( "aAppIdOfSavingItem = %S", &(*tmp) );
       
   565     CleanupStack::PopAndDestroy( tmp );
       
   566     
       
   567     tmp = HBufC::NewLC( aAppRef.Length() );
       
   568     tmp->Des().Copy( aAppRef );
       
   569     RUBY_DEBUG1( "aAppRef = %S", &(*tmp) );
       
   570     CleanupStack::PopAndDestroy( tmp );
       
   571     
       
   572     tmp = HBufC::NewLC( aStorageIdValue.Length() );
       
   573     tmp->Des().Copy( aStorageIdValue );
       
   574     RUBY_DEBUG1( "aStorageIdValue = %S", &(*tmp) );
       
   575     CleanupStack::PopAndDestroy( tmp );
       
   576 #endif
       
   577         
       
   578      // Check which application reference is being offered
       
   579      for(TInt j=0; j<iToAppReferences.Count(); j++)
       
   580             {
       
   581             const TDesC& toAppRef = iToAppReferences[j];
       
   582             HBufC* appRef16 = HBufC::NewLC(aAppRef.Length());
       
   583             appRef16->Des().Copy(aAppRef);
       
   584             
       
   585             RUBY_DEBUG1( "Checking toAppRef: %S", &toAppRef );
       
   586     
       
   587             
       
   588             if( toAppRef.Compare(*appRef16) == 0 )
       
   589                 {
       
   590     			RUBY_DEBUG0( "APPREF matched with TO-APPREF" );
       
   591                 
       
   592                 if( (aAppIdOfSavingItem.Compare( KVoIPAppID8 ) == 0) && iVccItem != NULL )
       
   593                 	{
       
   594             		TLex8 temp( aStorageIdValue );
       
   595             		User::LeaveIfError( temp.Val( iVoipProfileId ) );
       
   596                 	}
       
   597                 }
       
   598             else
       
   599             	{
       
   600             	RUBY_DEBUG0( "APPREF did not match with TO-APPREF" );
       
   601                 
       
   602             	}
       
   603                 
       
   604             CleanupStack::PopAndDestroy(appRef16);
       
   605             }
       
   606                 
       
   607     }
       
   608     
       
   609 // ---------------------------------------------------------------------------
       
   610 // CWPVoIPAdapter::SavingFinalizedL()
       
   611 //
       
   612 // ---------------------------------------------------------------------------
       
   613 //
       
   614 void CWPVccAdapter::SavingFinalizedL()
       
   615     {
       
   616     RUBY_DEBUG0( "CWPVccAdapter::SavingFinalizedL IN" );
       
   617     if ( iVccItem )
       
   618         {
       
   619         CRCSEProfileRegistry* cRCSEProfileRegistry = CRCSEProfileRegistry::NewLC(); // CS:1
       
   620         CRCSEProfileEntry* foundEntry = CRCSEProfileEntry::NewLC(); // CS:2
       
   621         cRCSEProfileRegistry->FindL( iVoipProfileId, *foundEntry );
       
   622         RUBY_DEBUG1( "SavingFinalizedL::ServiceId=%d", foundEntry->iServiceProviderId );
       
   623                                 
       
   624         iVccItem->SetVoipServiceIdL( foundEntry->iServiceProviderId );
       
   625         iVccItem->StoreL();
       
   626 
       
   627         CleanupStack::PopAndDestroy( foundEntry ); // CS:1
       
   628         CleanupStack::PopAndDestroy( cRCSEProfileRegistry ); // CS:0
       
   629         }
       
   630     
       
   631     //Remove SNAP
       
   632     TRAP_IGNORE(RemoveNetworkDestinationL() );
       
   633     
       
   634     RUBY_DEBUG0( "CWPVccAdapter::SavingFinalizedL OUT" );
       
   635     }
       
   636     
       
   637 // ---------------------------------------------------------------------------
       
   638 // CWPVccAdapter::RemoveVCCSettingsL()
       
   639 //
       
   640 // ---------------------------------------------------------------------------
       
   641 //
       
   642 void CWPVccAdapter::RemoveVCCSettingsL()
       
   643     {
       
   644     RUBY_DEBUG_BLOCK( "CWPVccAdapter::RemoveVCCSettingsL" );
       
   645     // Get the Voip service id. Get it always to if the SP
       
   646     // settings are changed, we get updated values.
       
   647     TInt VoIPServiceId(KErrNotFound);
       
   648     TRAPD(error, VoIPServiceId = VccSettingsReader::VoIPServiceIdL() );
       
   649     RUBY_DEBUG1( " -VoIP service id: %d", VoIPServiceId );  
       
   650     
       
   651     if ( error != KErrNone )
       
   652            {
       
   653            RUBY_DEBUG0( " -VoIP service not found - LEAVE" );
       
   654            User::Leave( KErrNotFound );
       
   655            }
       
   656      
       
   657     //Get current VCC enabled VoIP service name before saving new one
       
   658     //it will be used to delete the network destination
       
   659     
       
   660     CSPSettings* settings = CSPSettings::NewLC();
       
   661     CSPProperty* property = CSPProperty::NewLC();
       
   662     
       
   663     //Get VoIP service name store it
       
   664     error = settings->FindPropertyL( VoIPServiceId, EServiceName, *property );
       
   665       
       
   666     error = property->GetValue( iOldVoipServiceName );
       
   667     User::LeaveIfError( error );
       
   668     
       
   669      CleanupStack::PopAndDestroy( property );
       
   670      CleanupStack::PopAndDestroy( settings );
       
   671     
       
   672    
       
   673      CCchService* cchService;
       
   674       // Get the service 
       
   675      CCch* cch = CCch::NewL();
       
   676     //ownership not transfered so no need to delete
       
   677      cchService = cch->GetService( VoIPServiceId );
       
   678                 
       
   679      if( cchService )
       
   680          {
       
   681          RUBY_DEBUG0( " -Disable service" );
       
   682          (void) cchService->Disable( ECCHVoIPSub );
       
   683          }
       
   684      delete cch;
       
   685      
       
   686      
       
   687      // Get VoIP profile ID from VCC settings (use Service ID)
       
   688      // Convert Service Id to VoipProfileID
       
   689      CRCSEProfileRegistry* cRCSEProfileRegistry = CRCSEProfileRegistry::NewLC();
       
   690      RPointerArray<CRCSEProfileEntry> foundEntries;
       
   691      CleanupStack::PushL( TCleanupItem( ResetAndDestroyProfileEntries, &foundEntries ) );
       
   692 
       
   693      cRCSEProfileRegistry->FindByServiceIdL( VoIPServiceId, foundEntries );
       
   694      
       
   695      const TInt count( foundEntries.Count() );
       
   696      TSettingIds value;
       
   697  
       
   698      CSIPManagedProfileRegistry* SIPRegistry;
       
   699      SIPRegistry = CSIPManagedProfileRegistry::NewLC(*this);
       
   700 
       
   701      TInt err(0);
       
   702        
       
   703      //remove SIP settings
       
   704      if ( count > 0 )
       
   705         {
       
   706         // Check the existence of linked SIP profiles
       
   707            for ( TInt i( count-1 ); 0 <= i ; i-- )
       
   708                 {
       
   709                  value = foundEntries[0]->iIds[i];
       
   710              
       
   711                  if ( CRCSEProfileEntry::EProtocolSIP == value.iProfileType )
       
   712                      {
       
   713                      CSIPProfile* profile = NULL;
       
   714                      TRAP( err, profile = SIPRegistry->ProfileL( value.iProfileId ) );
       
   715                      if ( KErrNotFound == err )
       
   716                          {
       
   717                          delete profile;
       
   718                          profile = NULL;
       
   719                          RUBY_DEBUG0 ("SIP profile not found");
       
   720                          }
       
   721                      else
       
   722                          {
       
   723                          SIPRegistry->DestroyL(*profile);
       
   724                          RUBY_DEBUG0 ("Sip profile destroyed");
       
   725                          delete profile;
       
   726                          profile = NULL;
       
   727                          }
       
   728                   }
       
   729                }
       
   730       
       
   731          TInt voipId = foundEntries[0]->iId;
       
   732        
       
   733          // Remove VoIP settings
       
   734         cRCSEProfileRegistry->DeleteL(voipId);
       
   735         }
       
   736     CleanupStack::PopAndDestroy( SIPRegistry ); 
       
   737     CleanupStack::PopAndDestroy(); // foundEntries
       
   738     CleanupStack::PopAndDestroy( cRCSEProfileRegistry );
       
   739     }
       
   740 // ---------------------------------------------------------------------------
       
   741 // From MSIPProfileRegistryObserver
       
   742 // CWPVccAdapter::ProfileRegistryEventOccurred
       
   743 // SIP profile event
       
   744 // ---------------------------------------------------------------------------
       
   745 //
       
   746 void CWPVccAdapter::ProfileRegistryEventOccurred( 
       
   747     TUint32 /*aSIPProfileId*/,
       
   748     TEvent /*aEvent*/ )
       
   749     {
       
   750     RUBY_DEBUG0( "CWPVccAdapter::ProfileRegistryEventOccurred" );
       
   751     // Have to be implemented because MSIPProfileRegistryObserver
       
   752     // is passed to CSIPManagedProfileRegistry.
       
   753     }
       
   754 
       
   755 // ---------------------------------------------------------------------------
       
   756 // From MSIPProfileRegistryObserver
       
   757 // CWPVccAdapter::ProfileRegistryErrorOccured
       
   758 // An asynchronous error has occurred related to SIP profile
       
   759 // ---------------------------------------------------------------------------
       
   760 //
       
   761 void CWPVccAdapter::ProfileRegistryErrorOccurred( 
       
   762     TUint32  /*aProfileId*/,
       
   763     TInt /*aError*/ )
       
   764     {
       
   765     RUBY_DEBUG0( "CRCSEProfileRegistry::ProfileRegistryErrorOccurred" );
       
   766     // Have to be implemented because MSIPProfileRegistryObserver
       
   767     // is passed to CSIPManagedProfileRegistry.
       
   768     }
       
   769 
       
   770 // ---------------------------------------------------------------------------
       
   771 // CWPVccAdapter::RemoveNetworkDestinationL()
       
   772 //
       
   773 // ---------------------------------------------------------------------------
       
   774 //
       
   775 
       
   776 void CWPVccAdapter::RemoveNetworkDestinationL()
       
   777     {
       
   778     RUBY_DEBUG_BLOCK( "CWPVccAdapter::RemoveNetworkDestination" );
       
   779 
       
   780     //remove destination 
       
   781     RCmManagerExt cmManager;
       
   782     cmManager.OpenL();
       
   783     CleanupClosePushL(cmManager);
       
   784     
       
   785     RArray<TUint32> destinations;
       
   786     CleanupClosePushL(destinations);
       
   787     cmManager.AllDestinationsL(destinations);
       
   788    
       
   789     RCmDestinationExt destination;
       
   790     HBufC *destinationName;
       
   791     
       
   792     for( TInt i = 0; i < destinations.Count(); i++)
       
   793           {
       
   794            destination = cmManager.DestinationL(destinations[i]);
       
   795            CleanupClosePushL(destination);
       
   796            destinationName = destination.NameLC();
       
   797                           
       
   798            if (destinationName->Compare( iOldVoipServiceName ) == 0 )
       
   799                {
       
   800                CleanupStack::PopAndDestroy( destinationName ); // Ownership is transferred to item    
       
   801                destinationName = NULL;
       
   802                CleanupStack::Pop(); // destination
       
   803                destination.DeleteLD();
       
   804                RUBY_DEBUG0( "deleted network destination");
       
   805                }
       
   806            else
       
   807                {
       
   808                RUBY_DEBUG0("destination NOT found");
       
   809                CleanupStack::PopAndDestroy( destinationName ); // Ownership is transferred to item    
       
   810                destinationName = NULL;
       
   811                CleanupStack::PopAndDestroy(); // destination
       
   812                }
       
   813             
       
   814            }
       
   815         CleanupStack::PopAndDestroy(); // destinations
       
   816         CleanupStack::PopAndDestroy(); //cmManager  
       
   817     }