mmshplugins/mmshwpadapterplugin/src/muswpadapter.cpp
changeset 22 496ad160a278
parent 0 f0cf47e981f9
equal deleted inserted replaced
15:ccd8e69b5392 22:496ad160a278
       
     1 /*
       
     2 * Copyright (c) 2006 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:  project specification
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // USER
       
    21 #include "muswpadapter.h"
       
    22 #include "muswpitem.h"
       
    23 #include "mussettings.h"
       
    24 #include "muslogger.h"
       
    25 
       
    26 // SYSTEM
       
    27 #include <muswpadapterresource.rsg>
       
    28 #include <CWPCharacteristic.h>
       
    29 #include <CWPParameter.h>
       
    30 #include <utf.h>
       
    31 #include <WPAdapterUtil.h>
       
    32 
       
    33 
       
    34 
       
    35 
       
    36 // CONSTANTS
       
    37 
       
    38 _LIT( KMusAppID, "w9017" );
       
    39 _LIT8( KSipAppID8, "w9010" );
       
    40 
       
    41 _LIT( KMusWpAdapterName, "muswpadapterresource" );
       
    42 
       
    43 _LIT( KMUsWpCharacteristicNameCapability, "CAPABILITY" );
       
    44 _LIT( KMUsWpCharacteristicNameActivation, "ACTIVATION" );
       
    45 
       
    46 _LIT( KMusWpParamNameEdgeDtm, "EDGEDTM" );
       
    47 _LIT( KMusWpParamNameInternetSignaling, "INTERNETSIGNALING" );
       
    48 _LIT( KMusWpParamNameQuery, "QUERY" );
       
    49 _LIT( KMusWpParamNameCondition, "CONDITION" );
       
    50 
       
    51 const TUint32 KMusWpNotSet = 0;
       
    52 
       
    53 
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // Symbian two-phased constructor.
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 CMusWpAdapter* CMusWpAdapter::NewL()
       
    60     {
       
    61     MUS_LOG( "mus: [MUSWP]  ->  CMusWpAdapter::NewL" )
       
    62     CMusWpAdapter* self = new( ELeave ) CMusWpAdapter;
       
    63     CleanupStack::PushL( self );
       
    64     self->ConstructL();
       
    65     CleanupStack::Pop( self );
       
    66     MUS_LOG( "mus: [MUSWP]  <- CMusWpAdapter::NewL" )
       
    67     return self;
       
    68     }
       
    69 
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // Destructor.
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 CMusWpAdapter::~CMusWpAdapter()
       
    76     {
       
    77     MUS_LOG( "mus: [MUSWP]  -> CMusWpAdapter::~CMusWpAdapter" )
       
    78     delete iAppID;
       
    79     delete iWpItem;
       
    80     delete iNewWpItem;
       
    81     delete iSummaryTitle;
       
    82     MUS_LOG( "mus: [MUSWP]  <- CMusWpAdapter::~CMusWpAdapter" )
       
    83     }
       
    84     
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // From base class CWAdapter. Definition of the pure virtual function.
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 TInt CMusWpAdapter::ItemCount() const
       
    91     {
       
    92     MUS_LOG( "mus: [MUSWP]  -> CMusWpAdapter::ItemCount()" )
       
    93     MUS_LOG( "mus: [MUSWP]  <- CMusWpAdapter::ItemCount()" )
       
    94     
       
    95     if ( iWpItem )
       
    96         {
       
    97         return 1;
       
    98         }
       
    99 
       
   100     return 0;
       
   101     }
       
   102 
       
   103 
       
   104 // -----------------------------------------------------------------------------
       
   105 // From base class CWAdapter. Definition of the pure virtual function.
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 const TDesC16& CMusWpAdapter::SummaryTitle( TInt /*aIndex*/ ) const
       
   109     {
       
   110     MUS_LOG( "mus: [MUSWP]  -> CMusWpAdapter::SummaryTitle()" )
       
   111     MUS_LOG( "mus: [MUSWP]  <- CMusWpAdapter::SummaryTitle()" )
       
   112     
       
   113     return *iSummaryTitle;
       
   114     }
       
   115 
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // From base class CWAdapter. Definition of the pure virtual function.
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 const TDesC16& CMusWpAdapter::SummaryText( TInt /*aIndex*/ ) const
       
   122     {
       
   123     MUS_LOG( "mus: [MUSWP]  -> CMusWpAdapter::SummaryText( ... )" )
       
   124     if( iWpItem )
       
   125         {
       
   126         return iWpItem->Name();   
       
   127         }
       
   128 
       
   129     MUS_LOG( "mus: [MUSWP]  <- CMusWpAdapter::SummaryText( ... )" )
       
   130     return *iSummaryTitle;
       
   131     }
       
   132 
       
   133 
       
   134 // -----------------------------------------------------------------------------
       
   135 // From base class CWAdapter. Definition of the pure virtual function.
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 void CMusWpAdapter::SaveL( TInt /*aItem*/ )
       
   139     {
       
   140     MUS_LOG( "mus: [MUSWP]  -> CMusWpAdapter::SaveL" )
       
   141     
       
   142     if ( iWpItem )
       
   143         {
       
   144         iWpItem->SaveL();
       
   145         }
       
   146         
       
   147     MUS_LOG( "mus: [MUSWP]  <- CMusWpAdapter::SaveL" )
       
   148     }
       
   149 
       
   150 
       
   151 // -----------------------------------------------------------------------------
       
   152 // From base class CWAdapter. Definition of the pure virtual function.
       
   153 // -----------------------------------------------------------------------------
       
   154 //
       
   155 TBool CMusWpAdapter::CanSetAsDefault( TInt /*aIndex*/ ) const
       
   156     {
       
   157     return EFalse;
       
   158     }
       
   159 
       
   160 
       
   161 // -----------------------------------------------------------------------------
       
   162 // From base class CWAdapter. Definition of the pure virtual function.
       
   163 // -----------------------------------------------------------------------------
       
   164 //
       
   165 void CMusWpAdapter::SetAsDefaultL( TInt /*aIndex*/ )
       
   166     {
       
   167     User::Leave( KErrNotSupported );
       
   168     }
       
   169 
       
   170 
       
   171 // -----------------------------------------------------------------------------
       
   172 // From base class CWAdapter. Definition of the pure virtual function.
       
   173 // -----------------------------------------------------------------------------
       
   174 //
       
   175 TInt CMusWpAdapter::DetailsL( TInt /*aItem*/, MWPPairVisitor& /*aVisitor */ )
       
   176     {
       
   177     return KErrNotSupported;
       
   178     }
       
   179 
       
   180 
       
   181 // -----------------------------------------------------------------------------
       
   182 // From base class CWPAdapter. Overrides the empty implementation of that class.
       
   183 // -----------------------------------------------------------------------------
       
   184 //
       
   185 void CMusWpAdapter::SettingsSavedL( const TDesC8& aAppIdOfSavingItem,
       
   186                                      const TDesC8& aAppRef,
       
   187                                      const TDesC8& aStorageIdValue )
       
   188     {
       
   189     MUS_LOG( "mus: [MUSWP]  -> CMusWpAdapter::SettingsSavedL" )    
       
   190 
       
   191     // If settings are saved by SIPAdapter...
       
   192     if ( aAppIdOfSavingItem == KSipAppID8 )
       
   193         {
       
   194         // ...and are ment for us...
       
   195         if ( iWpItem )
       
   196             {
       
   197             HBufC8* tmpValue = HBufC8::NewLC( 4*iWpItem->ToAppRef().Length() );
       
   198             TPtr8 ptrTmpValue( tmpValue->Des() );
       
   199             CnvUtfConverter::ConvertFromUnicodeToUtf8( ptrTmpValue, 
       
   200                                                        iWpItem->ToAppRef() );
       
   201             
       
   202             if ( aAppRef == *tmpValue )
       
   203                 {
       
   204                 MUS_LOG( "   CMusWpAdapter, Prepared to save setting" )
       
   205                 // ...prepare to save profile Id
       
   206                 TLex8 lex( aStorageIdValue );
       
   207                 User::LeaveIfError( lex.Val( iProfileId, EDecimal ) );
       
   208                 iProfileIdReceived = ETrue;
       
   209                 }
       
   210             
       
   211             CleanupStack::PopAndDestroy( tmpValue );
       
   212             }
       
   213         }    
       
   214     
       
   215     MUS_LOG( "mus: [MUSWP]  <- CMusWpAdapter::SettingsSavedL" )
       
   216     };
       
   217 
       
   218 
       
   219 // -----------------------------------------------------------------------------
       
   220 // From base class CWPAdapter. Overrides the empty implementation of that class.
       
   221 // -----------------------------------------------------------------------------
       
   222 //
       
   223 void CMusWpAdapter::SavingFinalizedL()
       
   224     {
       
   225     MUS_LOG( "mus: [MUSWP]  -> CMusWpAdapter::SavingFinalizedL" )
       
   226 
       
   227     if ( iProfileIdReceived )
       
   228         {
       
   229         MultimediaSharingSettings::SetSipProfileSettingL( 
       
   230                                         static_cast<TInt>(iProfileId) );
       
   231         }
       
   232         
       
   233     MUS_LOG( "mus: [MUSWP]  <- CMusWpAdapter::SavingFinalizedL" )
       
   234     }
       
   235 
       
   236 
       
   237 // -----------------------------------------------------------------------------
       
   238 // From base class CWPAdapter, which derives this from MWPVisitor.
       
   239 // Definition of the pure virtual function.
       
   240 // -----------------------------------------------------------------------------
       
   241 //
       
   242 void CMusWpAdapter::VisitL( CWPCharacteristic& aCharacteristic )
       
   243     {
       
   244     MUS_LOG( "mus: [MUSWP]  -> CMusWpAdapter::VisitL (Characteristic)" )
       
   245     switch ( aCharacteristic.Type() )
       
   246         {
       
   247         case KWPApplication:
       
   248             {
       
   249             iNewWpItem = CMusWpItem::NewL();
       
   250            
       
   251             aCharacteristic.AcceptL( *this );
       
   252             
       
   253             // If Mus settings, store information
       
   254             if( iAppID && *iAppID == KMusAppID )
       
   255                 {
       
   256                 MUS_LOG( "   CMusWpAdapter, Mus Settings found" )
       
   257                 delete iWpItem;
       
   258                 iWpItem = iNewWpItem;
       
   259                 }
       
   260             else
       
   261                 {
       
   262                 delete iNewWpItem;
       
   263                 }
       
   264                 
       
   265             iNewWpItem = NULL;
       
   266             break;
       
   267             }
       
   268         case KWPNamedCharacteristic:
       
   269             {
       
   270             if ( iNewWpItem )
       
   271                 {
       
   272                 // We are inside APPLICATION-characteristic
       
   273                 if ( aCharacteristic.Name() == 
       
   274                         KMUsWpCharacteristicNameCapability() ||
       
   275                      aCharacteristic.Name() == 
       
   276                         KMUsWpCharacteristicNameActivation() )
       
   277                     {
       
   278                     aCharacteristic.AcceptL( *this );
       
   279                     }
       
   280                 }
       
   281             break;
       
   282             }
       
   283         default:
       
   284             {
       
   285             break;
       
   286             }
       
   287         }
       
   288     MUS_LOG( "mus: [MUSWP]  <- CMusWpAdapter::VisitL (Characteristic)" )
       
   289     }
       
   290 
       
   291 
       
   292 // -----------------------------------------------------------------------------
       
   293 // From base class CWPAdapter, which derives this from MWPVisitor.
       
   294 // Definition of the pure virtual function.
       
   295 // -----------------------------------------------------------------------------
       
   296 //
       
   297 void CMusWpAdapter::VisitL( CWPParameter& aParameter )
       
   298     {
       
   299     MUS_LOG( "mus: [MUSWP]  -> CMusWpAdapter::VisitL (Parameter)" )
       
   300     
       
   301     switch ( aParameter.ID() )
       
   302         {
       
   303         case EWPNamedParameter: // Name is used instead of ID
       
   304             {
       
   305             if ( aParameter.Name() == KMusWpParamNameEdgeDtm() )
       
   306                 {
       
   307                 iNewWpItem->SetEdgeDtmSupport( ETrue );
       
   308                 }
       
   309             else if ( aParameter.Name() == KMusWpParamNameInternetSignaling() )
       
   310                 {
       
   311                 iNewWpItem->SetForceInternetSignaling( ETrue );
       
   312                 }
       
   313             else if ( aParameter.Name() == KMusWpParamNameQuery() )
       
   314                 {
       
   315                 iNewWpItem->SetCapabilityQuery( aParameter.Value() );
       
   316                 }
       
   317             else if ( aParameter.Name() == KMusWpParamNameCondition() )
       
   318                 {
       
   319                 iNewWpItem->SetActivationCondition( aParameter.Value() );
       
   320                 }
       
   321             else
       
   322                 {
       
   323                 // To keep PC-Lint happy
       
   324                 }
       
   325             break;
       
   326             }
       
   327         case EWPParameterAppID: // APPLICATION/APPID
       
   328             {
       
   329 	        delete iAppID; 
       
   330 	        iAppID = NULL;
       
   331 	        iAppID = aParameter.Value().AllocL();
       
   332             break;
       
   333             }
       
   334         case EWPParameterProviderID: // APPLICATION/PROVIDER-ID
       
   335             {
       
   336             iNewWpItem->SetProviderIdL( aParameter.Value() );
       
   337             break;
       
   338             }
       
   339         case EWPParameterName: // APPLICATION/NAME
       
   340             {
       
   341             iNewWpItem->SetNameL( aParameter.Value() );
       
   342             break;
       
   343             }
       
   344         case EWPParameterToAppRef: // APPLICATION/TO-APPREF
       
   345             {
       
   346             iNewWpItem->SetToAppRefL( aParameter.Value() );
       
   347             break;
       
   348             }
       
   349 		default:
       
   350             {
       
   351 			break;
       
   352             }
       
   353         }
       
   354     
       
   355     MUS_LOG( "mus: [MUSWP]  <- CMusWpAdapter::VisitL (Parameter)" )
       
   356     }
       
   357 
       
   358 
       
   359 // -----------------------------------------------------------------------------
       
   360 // From base class CWPAdapter, which derives this from MWPVisitor.
       
   361 // Definition of the pure virtual function.
       
   362 // -----------------------------------------------------------------------------
       
   363 //
       
   364 void CMusWpAdapter::VisitLinkL(CWPCharacteristic& /*aLink*/ )
       
   365     {
       
   366     // NOP
       
   367     }
       
   368 
       
   369 
       
   370 // -----------------------------------------------------------------------------
       
   371 // C++ default constructor
       
   372 // -----------------------------------------------------------------------------
       
   373 //
       
   374 CMusWpAdapter::CMusWpAdapter() 
       
   375     :CWPAdapter(),
       
   376     iProfileIdReceived( EFalse ),
       
   377     iProfileId( KMusWpNotSet )
       
   378     {
       
   379     }
       
   380 
       
   381 
       
   382 // -----------------------------------------------------------------------------
       
   383 // Symbian 2nd phase constructor
       
   384 // -----------------------------------------------------------------------------
       
   385 //
       
   386 void CMusWpAdapter::ConstructL()
       
   387     {
       
   388     MUS_LOG( "mus: [MUSWP]  -> CMusWpAdapter::ConstructL" )
       
   389     
       
   390     TFileName fileName;
       
   391     Dll::FileName(fileName);
       
   392     
       
   393     iSummaryTitle = WPAdapterUtil::ReadHBufCL( fileName, 
       
   394                                                KMusWpAdapterName, 
       
   395                                                R_MUS_WP_SUMMARYTITLE );
       
   396 
       
   397     MUS_LOG( "mus: [MUSWP]  <- CMusWpAdapter::ConstructL" )
       
   398     }
       
   399 
       
   400 
       
   401 
       
   402 
       
   403 
       
   404