callcontinuity/vccclientprovisioningadapter/src/wpvccadapter.cpp
branchRCL_3
changeset 22 d38647835c2e
equal deleted inserted replaced
21:f742655b05bf 22:d38647835c2e
       
     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     
       
   548     RUBY_DEBUG0("Do nothing");
       
   549     }
       
   550 
       
   551 
       
   552 // -----------------------------------------------------------------------------
       
   553 // CWPVccAdapter::::SettingsSavedL
       
   554 //
       
   555 // -----------------------------------------------------------------------------
       
   556 void CWPVccAdapter::SettingsSavedL(const TDesC8& aAppIdOfSavingItem,
       
   557                                                 const TDesC8& aAppRef, 
       
   558                                                 const TDesC8& aStorageIdValue)
       
   559     {
       
   560     RUBY_DEBUG_BLOCK( "CWPVccAdapter::SettingsSavedL" );
       
   561    
       
   562 #ifdef _DEBUG
       
   563     HBufC* tmp = HBufC::NewLC( aAppIdOfSavingItem.Length() );
       
   564     tmp->Des().Copy( aAppIdOfSavingItem );
       
   565     RUBY_DEBUG1( "aAppIdOfSavingItem = %S", &(*tmp) );
       
   566     CleanupStack::PopAndDestroy( tmp );
       
   567     
       
   568     tmp = HBufC::NewLC( aAppRef.Length() );
       
   569     tmp->Des().Copy( aAppRef );
       
   570     RUBY_DEBUG1( "aAppRef = %S", &(*tmp) );
       
   571     CleanupStack::PopAndDestroy( tmp );
       
   572     
       
   573     tmp = HBufC::NewLC( aStorageIdValue.Length() );
       
   574     tmp->Des().Copy( aStorageIdValue );
       
   575     RUBY_DEBUG1( "aStorageIdValue = %S", &(*tmp) );
       
   576     CleanupStack::PopAndDestroy( tmp );
       
   577 #endif
       
   578         
       
   579      // Check which application reference is being offered
       
   580      for(TInt j=0; j<iToAppReferences.Count(); j++)
       
   581             {
       
   582             const TDesC& toAppRef = iToAppReferences[j];
       
   583             HBufC* appRef16 = HBufC::NewLC(aAppRef.Length());
       
   584             appRef16->Des().Copy(aAppRef);
       
   585             
       
   586             RUBY_DEBUG1( "Checking toAppRef: %S", &toAppRef );
       
   587     
       
   588             
       
   589             if( toAppRef.Compare(*appRef16) == 0 )
       
   590                 {
       
   591     			RUBY_DEBUG0( "APPREF matched with TO-APPREF" );
       
   592                 
       
   593                 if( (aAppIdOfSavingItem.Compare( KVoIPAppID8 ) == 0) && iVccItem != NULL )
       
   594                 	{
       
   595             		TLex8 temp( aStorageIdValue );
       
   596             		User::LeaveIfError( temp.Val( iVoipProfileId ) );
       
   597                 	}
       
   598                 }
       
   599             else
       
   600             	{
       
   601             	RUBY_DEBUG0( "APPREF did not match with TO-APPREF" );
       
   602                 
       
   603             	}
       
   604                 
       
   605             CleanupStack::PopAndDestroy(appRef16);
       
   606             }
       
   607                 
       
   608     }
       
   609     
       
   610 // ---------------------------------------------------------------------------
       
   611 // CWPVoIPAdapter::SavingFinalizedL()
       
   612 //
       
   613 // ---------------------------------------------------------------------------
       
   614 //
       
   615 void CWPVccAdapter::SavingFinalizedL()
       
   616     {
       
   617     RUBY_DEBUG0( "CWPVccAdapter::SavingFinalizedL IN" );
       
   618     if ( iVccItem )
       
   619         {
       
   620         CRCSEProfileRegistry* cRCSEProfileRegistry = CRCSEProfileRegistry::NewLC(); // CS:1
       
   621         CRCSEProfileEntry* foundEntry = CRCSEProfileEntry::NewLC(); // CS:2
       
   622         cRCSEProfileRegistry->FindL( iVoipProfileId, *foundEntry );
       
   623         RUBY_DEBUG1( "SavingFinalizedL::ServiceId=%d", foundEntry->iServiceProviderId );
       
   624                                 
       
   625         iVccItem->SetVoipServiceIdL( foundEntry->iServiceProviderId );
       
   626         iVccItem->StoreL();
       
   627 
       
   628         CleanupStack::PopAndDestroy( foundEntry ); // CS:1
       
   629         CleanupStack::PopAndDestroy( cRCSEProfileRegistry ); // CS:0
       
   630         }
       
   631     
       
   632     //Remove SNAP
       
   633     TRAP_IGNORE(RemoveNetworkDestinationL() );
       
   634     
       
   635     RUBY_DEBUG0( "CWPVccAdapter::SavingFinalizedL OUT" );
       
   636     }
       
   637     
       
   638 // ---------------------------------------------------------------------------
       
   639 // CWPVccAdapter::RemoveVCCSettingsL()
       
   640 //
       
   641 // ---------------------------------------------------------------------------
       
   642 //
       
   643 void CWPVccAdapter::RemoveVCCSettingsL()
       
   644     {
       
   645     RUBY_DEBUG_BLOCK( "CWPVccAdapter::RemoveVCCSettingsL" );
       
   646     // Get the Voip service id. Get it always to if the SP
       
   647     // settings are changed, we get updated values.
       
   648     TInt VoIPServiceId(KErrNotFound);
       
   649     TRAPD(error, VoIPServiceId = VccSettingsReader::VoIPServiceIdL() );
       
   650     RUBY_DEBUG1( " -VoIP service id: %d", VoIPServiceId );  
       
   651     
       
   652     if ( error != KErrNone )
       
   653            {
       
   654            RUBY_DEBUG0( " -VoIP service not found - LEAVE" );
       
   655            User::Leave( KErrNotFound );
       
   656            }
       
   657      
       
   658     //Get current VCC enabled VoIP service name before saving new one
       
   659     //it will be used to delete the network destination
       
   660     
       
   661     CSPSettings* settings = CSPSettings::NewLC();
       
   662     CSPProperty* property = CSPProperty::NewLC();
       
   663     
       
   664     //Get VoIP service name store it
       
   665     error = settings->FindPropertyL( VoIPServiceId, EServiceName, *property );
       
   666       
       
   667     error = property->GetValue( iOldVoipServiceName );
       
   668     User::LeaveIfError( error );
       
   669     
       
   670      CleanupStack::PopAndDestroy( property );
       
   671      CleanupStack::PopAndDestroy( settings );
       
   672     
       
   673    
       
   674      CCchService* cchService;
       
   675       // Get the service 
       
   676      CCch* cch = CCch::NewL();
       
   677     //ownership not transfered so no need to delete
       
   678      cchService = cch->GetService( VoIPServiceId );
       
   679                 
       
   680      if( cchService )
       
   681          {
       
   682          RUBY_DEBUG0( " -Disable service" );
       
   683          (void) cchService->Disable( ECCHVoIPSub );
       
   684          }
       
   685      delete cch;
       
   686      
       
   687      
       
   688      // Get VoIP profile ID from VCC settings (use Service ID)
       
   689      // Convert Service Id to VoipProfileID
       
   690      CRCSEProfileRegistry* cRCSEProfileRegistry = CRCSEProfileRegistry::NewLC();
       
   691      RPointerArray<CRCSEProfileEntry> foundEntries;
       
   692      CleanupStack::PushL( TCleanupItem( ResetAndDestroyProfileEntries, &foundEntries ) );
       
   693 
       
   694      cRCSEProfileRegistry->FindByServiceIdL( VoIPServiceId, foundEntries );
       
   695      
       
   696      const TInt count( foundEntries.Count() );
       
   697      TSettingIds value;
       
   698  
       
   699      CSIPManagedProfileRegistry* SIPRegistry;
       
   700      SIPRegistry = CSIPManagedProfileRegistry::NewLC(*this);
       
   701 
       
   702      TInt err(0);
       
   703        
       
   704      //remove SIP settings
       
   705      if ( count > 0 )
       
   706         {
       
   707         // Check the existence of linked SIP profiles
       
   708            for ( TInt i( count-1 ); 0 <= i ; i-- )
       
   709                 {
       
   710                  value = foundEntries[0]->iIds[i];
       
   711              
       
   712                  if ( CRCSEProfileEntry::EProtocolSIP == value.iProfileType )
       
   713                      {
       
   714                      CSIPProfile* profile = NULL;
       
   715                      TRAP( err, profile = SIPRegistry->ProfileL( value.iProfileId ) );
       
   716                      if ( KErrNotFound == err )
       
   717                          {
       
   718                          delete profile;
       
   719                          profile = NULL;
       
   720                          RUBY_DEBUG0 ("SIP profile not found");
       
   721                          }
       
   722                      else
       
   723                          {
       
   724                          SIPRegistry->DestroyL(*profile);
       
   725                          RUBY_DEBUG0 ("Sip profile destroyed");
       
   726                          delete profile;
       
   727                          profile = NULL;
       
   728                          }
       
   729                   }
       
   730                }
       
   731       
       
   732          TInt voipId = foundEntries[0]->iId;
       
   733        
       
   734          // Remove VoIP settings
       
   735         cRCSEProfileRegistry->DeleteL(voipId);
       
   736         }
       
   737     CleanupStack::PopAndDestroy( SIPRegistry ); 
       
   738     CleanupStack::PopAndDestroy(); // foundEntries
       
   739     CleanupStack::PopAndDestroy( cRCSEProfileRegistry );
       
   740     }
       
   741 // ---------------------------------------------------------------------------
       
   742 // From MSIPProfileRegistryObserver
       
   743 // CWPVccAdapter::ProfileRegistryEventOccurred
       
   744 // SIP profile event
       
   745 // ---------------------------------------------------------------------------
       
   746 //
       
   747 void CWPVccAdapter::ProfileRegistryEventOccurred( 
       
   748     TUint32 /*aSIPProfileId*/,
       
   749     TEvent /*aEvent*/ )
       
   750     {
       
   751     RUBY_DEBUG0( "CWPVccAdapter::ProfileRegistryEventOccurred" );
       
   752     // Have to be implemented because MSIPProfileRegistryObserver
       
   753     // is passed to CSIPManagedProfileRegistry.
       
   754     }
       
   755 
       
   756 // ---------------------------------------------------------------------------
       
   757 // From MSIPProfileRegistryObserver
       
   758 // CWPVccAdapter::ProfileRegistryErrorOccured
       
   759 // An asynchronous error has occurred related to SIP profile
       
   760 // ---------------------------------------------------------------------------
       
   761 //
       
   762 void CWPVccAdapter::ProfileRegistryErrorOccurred( 
       
   763     TUint32  /*aProfileId*/,
       
   764     TInt /*aError*/ )
       
   765     {
       
   766     RUBY_DEBUG0( "CRCSEProfileRegistry::ProfileRegistryErrorOccurred" );
       
   767     // Have to be implemented because MSIPProfileRegistryObserver
       
   768     // is passed to CSIPManagedProfileRegistry.
       
   769     }
       
   770 
       
   771 // ---------------------------------------------------------------------------
       
   772 // CWPVccAdapter::RemoveNetworkDestinationL()
       
   773 //
       
   774 // ---------------------------------------------------------------------------
       
   775 //
       
   776 
       
   777 void CWPVccAdapter::RemoveNetworkDestinationL()
       
   778     {
       
   779     RUBY_DEBUG_BLOCK( "CWPVccAdapter::RemoveNetworkDestination" );
       
   780 
       
   781     //remove destination 
       
   782     RCmManagerExt cmManager;
       
   783     cmManager.OpenL();
       
   784     CleanupClosePushL(cmManager);
       
   785     
       
   786     RArray<TUint32> destinations;
       
   787     CleanupClosePushL(destinations);
       
   788     cmManager.AllDestinationsL(destinations);
       
   789    
       
   790     RCmDestinationExt destination;
       
   791     HBufC *destinationName;
       
   792     
       
   793     for( TInt i = 0; i < destinations.Count(); i++)
       
   794           {
       
   795            destination = cmManager.DestinationL(destinations[i]);
       
   796            CleanupClosePushL(destination);
       
   797            destinationName = destination.NameLC();
       
   798                           
       
   799            if (destinationName->Compare( iOldVoipServiceName ) == 0 )
       
   800                {
       
   801                CleanupStack::PopAndDestroy( destinationName ); // Ownership is transferred to item    
       
   802                destinationName = NULL;
       
   803                CleanupStack::Pop(); // destination
       
   804                destination.DeleteLD();
       
   805                RUBY_DEBUG0( "deleted network destination");
       
   806                }
       
   807            else
       
   808                {
       
   809                RUBY_DEBUG0("destination NOT found");
       
   810                CleanupStack::PopAndDestroy( destinationName ); // Ownership is transferred to item    
       
   811                destinationName = NULL;
       
   812                CleanupStack::PopAndDestroy(); // destination
       
   813                }
       
   814             
       
   815            }
       
   816         CleanupStack::PopAndDestroy(); // destinations
       
   817         CleanupStack::PopAndDestroy(); //cmManager  
       
   818     }