IMPSengine/engsrv/src/impssdatautils.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2003 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: Utils for IM data.
       
    15 *
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    <e32base.h>
       
    22 #include    "impskey.h"
       
    23 #include    "impssdatautils.h"
       
    24 #include    "impsdataaccessor.h"
       
    25 #include    "impsdigestbytes.h"
       
    26 #include    "impserrors.h"
       
    27 #include    "impsliterals.h"
       
    28 #include    "ImpsVariantAPI.h"
       
    29 #include    "impssrvutils.h"
       
    30 #include    "impsipcirwatcherapi.h"
       
    31 
       
    32 // CONSTANTS
       
    33 
       
    34 // UTF-8 MIB enum
       
    35 const TInt KImpsMIBeUTF8 = 106;
       
    36 
       
    37 // ================= MEMBER FUNCTIONS =======================
       
    38 
       
    39 // C++ default constructor can NOT contain any code, that
       
    40 // might leave.
       
    41 //
       
    42 TImpsSDataUtils::TImpsSDataUtils()
       
    43     {
       
    44     }
       
    45 
       
    46 
       
    47 
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // TImpsSDataUtils::SubGroupNoticeResponseL
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 TBool TImpsSDataUtils::SubGroupNoticeResponseL(
       
    54     MImpsKey* aKey,
       
    55     MImpsDataAccessor* aAc )
       
    56     {
       
    57     TDesC*  myPtr;
       
    58     TImpsSDataUtils::AddValuesFromArrayL(
       
    59         aKey,
       
    60         KTransContentElements,
       
    61         sizeof( KTransContentElements ) /
       
    62         sizeof( KTransContentElements[0] ) );
       
    63     aKey->AddL( CREATEKEY( EImpsKeySubscribeGroupNotice_Response, 0 ) );
       
    64     aKey->AddL( CREATEKEY( EImpsKeyValue, 0 ) );
       
    65     if ( aAc->RestoreDescL( aKey, myPtr ) )
       
    66         {
       
    67         if ( myPtr->Compare( KImpsTrue ) == 0 )
       
    68             {
       
    69             return ETrue;
       
    70             }
       
    71         }
       
    72     return EFalse;
       
    73     }
       
    74 
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // TImpsSDataUtils::SetMessageDeliveredIdL
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 void TImpsSDataUtils::SetMessageDeliveredIdL(
       
    81     MImpsKey* aKey,
       
    82     MImpsDataAccessor* aAc,
       
    83     const TDesC& aId )
       
    84     {
       
    85 
       
    86     aKey->Reset();
       
    87 
       
    88     TImpsSDataUtils::AddValuesFromArrayL(
       
    89         aKey,
       
    90         KTransContentElements,
       
    91         sizeof( KTransContentElements ) /
       
    92         sizeof( KTransContentElements[0] ) );
       
    93 
       
    94     aKey->AddL( CREATEKEY( EImpsKeyMessageDelivered, 0 ) );
       
    95     aKey->AddL( CREATEKEY( EImpsKeyMessageID, 0 ) );
       
    96     aAc->StoreDescL( aKey, aId );
       
    97 
       
    98     }
       
    99 
       
   100 // -----------------------------------------------------------------------------
       
   101 // TImpsSDataUtils::CreateLoginReqL
       
   102 // -----------------------------------------------------------------------------
       
   103 //
       
   104 void TImpsSDataUtils::CreateLoginReqL(
       
   105     MImpsKey* aKey,
       
   106     MImpsDataAccessor* aAc,
       
   107     const TDesC& aUserId,
       
   108     const TDesC& aClientId,
       
   109     const TDesC& aPwd,
       
   110     const TDesC& aCookie,
       
   111     TInt aTime )
       
   112     {
       
   113     aKey->Reset();
       
   114 
       
   115     TImpsSDataUtils::AddValuesFromArrayL(
       
   116         aKey,
       
   117         KTransContentElements,
       
   118         sizeof( KTransContentElements ) /
       
   119         sizeof( KTransContentElements[0] ) );
       
   120 
       
   121     aKey->AddL( CREATEKEY( EImpsKeyLogin_Request, 0 ) );
       
   122     aKey->AddL( CREATEKEY( EImpsKeyUserID, 0 ) );
       
   123     aAc->StoreDescL( aKey, aUserId );
       
   124 
       
   125     aKey->PopL( );
       
   126     TImpsSDataUtils::CreateClientIdL( aKey, aAc, aClientId );
       
   127 
       
   128     aKey->AddL( CREATEKEY( EImpsKeyPassword, 0 ) );
       
   129     aAc->StoreDescL( aKey, aPwd );
       
   130 
       
   131     aKey->ReplaceLastL( CREATEKEY( EImpsKeySessionCookie, 0 ) );
       
   132     aAc->StoreDescL( aKey, aCookie );
       
   133 
       
   134     aKey->ReplaceLastL( CREATEKEY( EImpsKeyTimeToLive, 0 ) );
       
   135     aAc->StoreIntegerL( aKey, aTime );
       
   136 
       
   137     }
       
   138 
       
   139 // -----------------------------------------------------------------------------
       
   140 // TImpsSDataUtils::CreateLoginReqPhaseOneL
       
   141 // -----------------------------------------------------------------------------
       
   142 //
       
   143 void TImpsSDataUtils::CreateLoginReqPhaseOneL(
       
   144     MImpsKey* aKey,
       
   145     MImpsDataAccessor* aAc,
       
   146     const TDesC& aUserId,
       
   147     const TDesC& aClientId,
       
   148     const TImpsDigestSchema aSchema,
       
   149     const TDesC& aCookie,
       
   150     TInt aTime )
       
   151     {
       
   152     if ( aUserId.Length() == 0 /*|| aClientId.Length() == 0 */
       
   153          || aCookie.Length() == 0 )
       
   154         {
       
   155         User::Leave( KImpsErrorValidate );
       
   156         }
       
   157 
       
   158     aKey->Reset();
       
   159 
       
   160     TImpsSDataUtils::AddValuesFromArrayL(
       
   161         aKey,
       
   162         KTransContentElements,
       
   163         sizeof( KTransContentElements ) /
       
   164         sizeof( KTransContentElements[0] ) );
       
   165 
       
   166     aKey->AddL( CREATEKEY( EImpsKeyLogin_Request, 0 ) );
       
   167     aKey->AddL( CREATEKEY( EImpsKeyUserID, 0 ) );
       
   168     aAc->StoreDescL( aKey, aUserId );
       
   169 
       
   170     aKey->PopL( );
       
   171     TImpsSDataUtils::CreateClientIdL( aKey, aAc, aClientId );
       
   172 
       
   173     aKey->AddL( CREATEKEY( EImpsKeyDigestSchema, 0 ) );
       
   174     aAc->StoreIntegerL( aKey, aSchema );
       
   175 
       
   176     aKey->ReplaceLastL( CREATEKEY( EImpsKeySessionCookie, 0 ) );
       
   177     aAc->StoreDescL( aKey, aCookie );
       
   178 
       
   179     aKey->ReplaceLastL( CREATEKEY( EImpsKeyTimeToLive, 0 ) );
       
   180     aAc->StoreIntegerL( aKey, aTime );
       
   181 
       
   182     }
       
   183 
       
   184 // -----------------------------------------------------------------------------
       
   185 // TImpsSDataUtils::CreateLoginReqPhaseTwoL
       
   186 // -----------------------------------------------------------------------------
       
   187 //
       
   188 void TImpsSDataUtils::CreateLoginReqPhaseTwoL(
       
   189     TBool aSendPwd,
       
   190     MImpsDataAccessor* aAc,
       
   191     const TDesC& /* aCSPSessionId */,
       
   192     const TDesC& aTid,
       
   193     const TDesC& aUserId,
       
   194     const TDesC& aClientId,
       
   195     const TDesC& aPwd,
       
   196     const TDesC8* aNonce,
       
   197     const TDesC& aCookie,
       
   198     TInt aTime,
       
   199     HBufC* aKey1,
       
   200     HBufC* aKey2 )
       
   201     {
       
   202     if ( aTid.Length() == 0 ||
       
   203          aUserId.Length() == 0 ||
       
   204          aPwd.Length() == 0 || !aNonce || aNonce->Length() == 0 ||
       
   205          aCookie.Length() == 0 )
       
   206         {
       
   207         User::Leave( KImpsErrorValidate );
       
   208         }
       
   209 
       
   210     CImpsKey* myKey = CImpsKey::NewLC();    // <<< myKey
       
   211     myKey->AddL( CREATEKEY( EImpsKeySession, 0 ) );
       
   212     aAc->StoreEmptyL( myKey );
       
   213     myKey->AddL( CREATEKEY( EImpsKeySessionDescriptor, 0 ) );
       
   214     aAc->StoreEmptyL( myKey );
       
   215     myKey->AddL( CREATEKEY( EImpsKeySessionType, 0 ) );
       
   216     aAc->StoreIntegerL( myKey, EImpsOutband );
       
   217     myKey->PopL( 2 );
       
   218 
       
   219     myKey->AddL( CREATEKEY( EImpsKeyTransaction, 0 ) );
       
   220     aAc->StoreEmptyL( myKey );
       
   221     myKey->AddL( CREATEKEY( EImpsKeyTransactionDescriptor, 0 ) );
       
   222     aAc->StoreEmptyL( myKey );
       
   223     myKey->AddL( CREATEKEY( EImpsKeyTransactionMode, 0 ) );
       
   224     aAc->StoreIntegerL( myKey, EImpsRequest );
       
   225     myKey->PopL( 1 );
       
   226     myKey->AddL( CREATEKEY( EImpsKeyTransactionID, 0 ) );
       
   227     aAc->StoreDescL( myKey, aTid );
       
   228     // poll missing
       
   229     myKey->PopL( 2 );
       
   230     myKey->AddL( CREATEKEY( EImpsKeyTransactionContent, 0 ) );
       
   231     aAc->StoreEmptyL( myKey );
       
   232     myKey->AddL( CREATEKEY( EImpsKeyLogin_Request, 0 ) );
       
   233     aAc->StoreEmptyL( myKey );
       
   234     myKey->AddL( CREATEKEY( EImpsKeyUserID, 0 ) );
       
   235     aAc->StoreDescL( myKey, aUserId );
       
   236     myKey->PopL( );
       
   237 
       
   238     TImpsSDataUtils::CreateClientIdL( myKey, aAc, aClientId );
       
   239 
       
   240     TImpsDigestSchema aSchema = EImpsMD5;
       
   241     TImpsDigestBytes db;    //lint !e1502 no nonstatic members there
       
   242     if ( aKey1 != NULL && aKey2 != NULL )
       
   243         {
       
   244         db.CreateAolDigestBytesL ( aAc, aSchema, aPwd, *aNonce, aClientId, aKey1, aKey2 );
       
   245         }
       
   246     else if ( aSendPwd )
       
   247         {
       
   248         myKey->AddL( CREATEKEY( EImpsKeyPassword, 0 ) );
       
   249         aAc->StoreDescL( myKey, aPwd );
       
   250         myKey->PopL( );
       
   251         }
       
   252     else
       
   253         {
       
   254         db.CreateDigestBytesL ( aAc, aSchema, aPwd, *aNonce );
       
   255         }
       
   256 
       
   257     myKey->AddL( CREATEKEY( EImpsKeySessionCookie, 0 ) );
       
   258     aAc->StoreDescL( myKey, aCookie );
       
   259 
       
   260     myKey->ReplaceLastL( CREATEKEY( EImpsKeyTimeToLive, 0 ) );
       
   261     aAc->StoreIntegerL( myKey, aTime );
       
   262 
       
   263     CleanupStack::PopAndDestroy( 1 ); // >>> myKey
       
   264 
       
   265     }
       
   266 
       
   267 
       
   268 // -----------------------------------------------------------------------------
       
   269 // TImpsSDataUtils::CreateServiceRequestL
       
   270 // Notice: the granularity of details is in feature level now.
       
   271 // This means that function and capability level details are hard coded now.
       
   272 // -----------------------------------------------------------------------------
       
   273 //
       
   274 void TImpsSDataUtils::CreateServiceRequestL(
       
   275     MImpsDataAccessor* aAc,
       
   276     TImpsServices& aServices,
       
   277     const TDesC& aSID,
       
   278     const TDesC& aTID,
       
   279     const TDesC& aCID,
       
   280     TBool aReactive )
       
   281     {
       
   282     TImpsSDataUtils::SetSessionIDL( aAc, aSID );
       
   283     TImpsSDataUtils::SetTransactionIDL( aAc, aTID );
       
   284 
       
   285     CImpsKey* myKey = CImpsKey::NewLC();   // <<< myKey
       
   286 
       
   287     TImpsSDataUtils::AddValuesFromArrayL(
       
   288         myKey,
       
   289         KClientServiceReqElements,
       
   290         sizeof( KClientServiceReqElements ) /
       
   291         sizeof( KClientServiceReqElements[0] ) );
       
   292 
       
   293     // Client id
       
   294     // WV 1.2 missing ClientId
       
   295     CImpsFields* f = aAc->GetImpsFields();
       
   296     if ( f->CspVersion() == EImpsCspVersion11 )
       
   297         {
       
   298         TImpsSDataUtils::CreateClientIdL(
       
   299             myKey,
       
   300             aAc,
       
   301             aCID );
       
   302         }
       
   303 
       
   304     // Do not ask AllFunctionsRequest
       
   305     myKey->AddL( CREATEKEY( EImpsKeyAllFunctionsRequest, 0 ) );
       
   306     aAc->StoreBooleanL( myKey, EFalse );
       
   307 
       
   308     // Functions and details are hard coded now.
       
   309     // Notice: update this if new features are available
       
   310     // This section must be in line with ReadConfig().
       
   311 
       
   312     myKey->ReplaceLastL( CREATEKEY( EImpsKeyFunctions, 0 ) );
       
   313     // WVCSPFeat
       
   314     myKey->AddL( CREATEKEY( EImpsKeyWVCSPFeat, 0 ) );
       
   315     // Check IM
       
   316     TImpsFeature* myFeat = aServices.Feature( EIMFeat );
       
   317     if ( myFeat->IsSupported() )
       
   318         {
       
   319         myKey->AddL( CREATEKEY( EImpsKeyIMFeat, 0 ) );
       
   320         aAc->StoreEmptyL( myKey );
       
   321         if ( myFeat->Function( EIMReceiveFunc ) )
       
   322             {
       
   323             myKey->AddL( CREATEKEY( EImpsKeyIMReceiveFunc, 0 ) );
       
   324             aAc->StoreEmptyL( myKey );
       
   325             if ( myFeat->Capability( KImpsServiceNEWM ) )
       
   326                 {
       
   327                 myKey->AddL( CREATEKEY( EImpsKeyNEWM, 0 ) );
       
   328                 aAc->StoreEmptyL( myKey );
       
   329                 myKey->PopL();
       
   330                 }
       
   331             myKey->ReplaceLastL( CREATEKEY( EImpsKeyIMAuthFunc, 0 ) );
       
   332             aAc->StoreEmptyL( myKey );
       
   333             }
       
   334         }
       
   335 
       
   336     // Group features
       
   337     myFeat = aServices.Feature( EGroupFeat );
       
   338     if ( myFeat->IsSupported() )
       
   339         {
       
   340         myKey->Reset();
       
   341         TImpsSDataUtils::AddValuesFromArrayL(
       
   342             myKey,
       
   343             KClientServiceReqElements,
       
   344             sizeof( KClientServiceReqElements ) /
       
   345             sizeof( KClientServiceReqElements[0] ) );
       
   346         myKey->AddL( CREATEKEY( EImpsKeyFunctions, 0 ) );
       
   347         myKey->AddL( CREATEKEY( EImpsKeyWVCSPFeat, 0 ) );
       
   348         myKey->AddL( CREATEKEY( EImpsKeyGroupFeat, 0 ) );
       
   349         aAc->StoreEmptyL( myKey );
       
   350         }
       
   351 
       
   352     // Presence features
       
   353     myFeat = aServices.Feature( EPresenceFeat );
       
   354     if ( myFeat->IsSupported() )
       
   355         {
       
   356         myKey->Reset();
       
   357         TImpsSDataUtils::AddValuesFromArrayL(
       
   358             myKey,
       
   359             KClientServiceReqElements,
       
   360             sizeof( KClientServiceReqElements ) /
       
   361             sizeof( KClientServiceReqElements[0] ) );
       
   362         myKey->AddL( CREATEKEY( EImpsKeyFunctions, 0 ) );
       
   363         myKey->AddL( CREATEKEY( EImpsKeyWVCSPFeat, 0 ) );
       
   364         myKey->AddL( CREATEKEY( EImpsKeyPresenceFeat, 0 ) );
       
   365 
       
   366         // If reactive authentication then the entire presence
       
   367         // is supported
       
   368         if ( !aReactive )
       
   369             {
       
   370             // These PRESENCE functions are supported if
       
   371             // not reactive authentication
       
   372             // PresenceDeliveryFunc
       
   373             myKey->AddL( CREATEKEY( EImpsKeyPresenceDeliverFunc, 0 ) );
       
   374             aAc->StoreEmptyL( myKey );
       
   375             // AttListFunc supported
       
   376             myKey->ReplaceLastL( CREATEKEY( EImpsKeyAttListFunc, 0 ) );
       
   377             aAc->StoreEmptyL( myKey );
       
   378             // Contact Lists
       
   379             myKey->ReplaceLastL( CREATEKEY( EImpsKeyContListFunc, 0 ) );
       
   380             aAc->StoreEmptyL( myKey );
       
   381             // Presence authentication
       
   382             myKey->ReplaceLastL( CREATEKEY( EImpsKeyPresenceAuthFunc, 0 ) );
       
   383             myKey->AddL( CREATEKEY( EImpsKeyGETWL, 0 ) );
       
   384             }
       
   385         // Add last presence element, either EImpsKeyPresenceFeat
       
   386         // or EImpsKeyGETWL
       
   387         aAc->StoreEmptyL( myKey );
       
   388         }
       
   389 
       
   390     // Fundamental features
       
   391     myFeat = aServices.Feature( EFundamentalFeat );
       
   392     if ( myFeat->IsSupported() )
       
   393         {
       
   394         myKey->Reset();
       
   395         TImpsSDataUtils::AddValuesFromArrayL(
       
   396             myKey,
       
   397             KClientServiceReqElements,
       
   398             sizeof( KClientServiceReqElements ) /
       
   399             sizeof( KClientServiceReqElements[0] ) );
       
   400         myKey->AddL( CREATEKEY( EImpsKeyFunctions, 0 ) );
       
   401         myKey->AddL( CREATEKEY( EImpsKeyWVCSPFeat, 0 ) );
       
   402         myKey->AddL( CREATEKEY( EImpsKeyFundamentalFeat, 0 ) );
       
   403         myKey->AddL( CREATEKEY( EImpsKeySearchFunc, 0 ) );
       
   404         aAc->StoreEmptyL( myKey );
       
   405         myKey->ReplaceLastL( CREATEKEY( EImpsKeyInviteFunc, 0 ) );
       
   406         aAc->StoreEmptyL( myKey );
       
   407         }
       
   408 
       
   409     // Add TImpsTransactionMode now
       
   410     myKey->Reset();
       
   411     TImpsSDataUtils::AddValuesFromArrayL(
       
   412         myKey,
       
   413         KTransModeElements,
       
   414         sizeof( KTransModeElements ) /
       
   415         sizeof( KTransModeElements[0] ) );
       
   416     aAc->StoreIntegerL( myKey, EImpsRequest );
       
   417 
       
   418     CleanupStack::PopAndDestroy( 1 ); // >>> myKey
       
   419 
       
   420     }
       
   421 
       
   422 // -----------------------------------------------------------------------------
       
   423 // TImpsSDataUtils::CreateClientCapabilityReqL
       
   424 // Notice: Many details are hard coded now.
       
   425 // Param aSettings cannot be null.
       
   426 // -----------------------------------------------------------------------------
       
   427 //
       
   428 void TImpsSDataUtils::CreateClientCapabilityReqL(
       
   429     MImpsDataAccessor* aAc,
       
   430     const TDesC& aSID,
       
   431     const TDesC& aTID,
       
   432     const TDesC& aCID,
       
   433     TInt aMultiTrans,
       
   434     TInt aPollTime,
       
   435     TImpsSrvSettings& aSettings )
       
   436     {
       
   437     TImpsSDataUtils::SetSessionIDL( aAc, aSID );
       
   438     TImpsSDataUtils::SetTransactionIDL( aAc, aTID );
       
   439     CImpsKey* myKey = CImpsKey::NewLC();   // <<< myKey
       
   440 
       
   441     const TImpsContent* myContent = KClientCapabilityReqElements;
       
   442     TImpsSDataUtils::AddValuesFromArrayL(
       
   443         myKey,
       
   444         myContent,
       
   445         sizeof( KClientCapabilityReqElements ) /
       
   446         sizeof( KClientCapabilityReqElements[0] ) );
       
   447 
       
   448     // Client id
       
   449     // WV 1.2 missing ClientId
       
   450     CImpsFields* f = aAc->GetImpsFields();
       
   451     if ( f->CspVersion() == EImpsCspVersion11 )
       
   452         {
       
   453         TImpsSDataUtils::CreateClientIdL(
       
   454             myKey,
       
   455             aAc,
       
   456             aCID );
       
   457         }
       
   458 
       
   459     // capabilitylist
       
   460     myKey->AddL( CREATEKEY( EImpsKeyCapabilityList, 0 ) );
       
   461 
       
   462     // client type
       
   463     myKey->AddL( CREATEKEY( EImpsKeyClientType, 0 ) );
       
   464     aAc->StoreIntegerL( myKey, EImpsMOBILE_PHONE );
       
   465     myKey->PopL();
       
   466 
       
   467     // Initial delivery method
       
   468     myKey->AddL( CREATEKEY( EImpsKeyInitialDeliveryMethod, 0 ) );
       
   469     aAc->StoreIntegerL( myKey, EImpsP );
       
   470     myKey->PopL();
       
   471 
       
   472     // Content types
       
   473     myKey->AddL( CREATEKEY( EImpsKeyAnyContent, 0 ) );
       
   474     aAc->StoreBooleanL( myKey, ETrue );
       
   475     myKey->ReplaceLastL( CREATEKEY( EImpsKeyAcceptedCharSet, 0 ) );
       
   476     aAc->StoreIntegerL( myKey, KImpsMIBeUTF8 );
       
   477     myKey->PopL();
       
   478 
       
   479     // accepted content length
       
   480     myKey->AddL( CREATEKEY( EImpsKeyAcceptedContentLength, 0 ) );
       
   481     aAc->StoreIntegerL( myKey, aSettings.MaximumMessageSize() );
       
   482     myKey->PopL();
       
   483 
       
   484     // accepted transfer encoding
       
   485     myKey->AddL( CREATEKEY( EImpsKeyAcceptedTransferEncoding, 0 ) );
       
   486     aAc->StoreIntegerL( myKey, EImpsBASE64 );
       
   487     myKey->PopL();
       
   488 
       
   489     // SupportedBearer
       
   490     myKey->AddL( CREATEKEY( EImpsKeySupportedBearer, 0 ) );
       
   491     aAc->StoreIntegerL( myKey, EImpsHTTP );
       
   492     myKey->PopL();
       
   493 
       
   494     // SupportedCIRMethods
       
   495     CImpsVariant* myVariant = CImpsVariant::NewLC( );
       
   496     TInt index( 0 );
       
   497     myKey->AddL( CREATEKEY( EImpsKeySupportedCIRMethod, index ) );
       
   498     // WAP SMS CIR
       
   499     if ( aSettings.SMSWAPCIR() )
       
   500         {
       
   501         index++;
       
   502         aAc->StoreIntegerL( myKey, EImpsWAPSMS );
       
   503         }
       
   504     // WAP UDP CIR
       
   505     if ( myVariant->IsFeatureSupportedL( EWAPUDP ) && aSettings.UDPWAPCIR() )
       
   506         {
       
   507         myKey->ReplaceLastL( CREATEKEY( EImpsKeySupportedCIRMethod, index++ ) );
       
   508         aAc->StoreIntegerL( myKey, EImpsWAPUDP );
       
   509         }
       
   510     // TCP standalone CIR
       
   511     if ( myVariant->IsFeatureSupportedL( EIpCirStandalone ) && aSettings.TCPSCIR() )
       
   512         {
       
   513         myKey->ReplaceLastL( CREATEKEY( EImpsKeySupportedCIRMethod, index++ ) );
       
   514         aAc->StoreIntegerL( myKey, EImpsSTCP );
       
   515         }
       
   516     // UDP standalone CIR
       
   517     if ( myVariant->IsFeatureSupportedL( EIpCirStandalone ) && aSettings.UDPSCIR() )
       
   518         {
       
   519         myKey->ReplaceLastL( CREATEKEY( EImpsKeySupportedCIRMethod, index++ ) );
       
   520         aAc->StoreIntegerL( myKey, EImpsSUDP );
       
   521         // Default KDefaultUDPPortNumber in the message due to CCAPAB-10
       
   522         myKey->ReplaceLastL( CREATEKEY( EImpsKeyUDPPort, 0 ) );
       
   523         aAc->StoreIntegerL( myKey, KDefaultUDPPortNumber );
       
   524         }
       
   525     CleanupStack::PopAndDestroy( ); // << myVariant
       
   526     myKey->PopL();
       
   527 
       
   528     // Multitrans
       
   529     myKey->AddL( CREATEKEY( EImpsKeyMultiTrans, 0 ) );
       
   530     aAc->StoreIntegerL( myKey, aMultiTrans );
       
   531     myKey->PopL();
       
   532 
       
   533     // Parser size
       
   534     myKey->AddL( CREATEKEY( EImpsKeyParserSize, 0 ) );
       
   535     aAc->StoreIntegerL( myKey, aSettings.MaximumParserSize() );
       
   536     myKey->PopL();
       
   537 
       
   538     // Poll min initial EImpsKeyServerPollMin
       
   539     myKey->AddL( CREATEKEY( EImpsKeyServerPollMin, 0 ) );
       
   540     aAc->StoreIntegerL( myKey, aPollTime );
       
   541 
       
   542     // Add TImpsTransactionMode now
       
   543     myKey->Reset();
       
   544     myContent = KTransModeElements;
       
   545     TImpsSDataUtils::AddValuesFromArrayL(
       
   546         myKey,
       
   547         myContent,
       
   548         sizeof( KTransModeElements ) /
       
   549         sizeof( KTransModeElements[0] ) );
       
   550     aAc->StoreIntegerL( myKey, EImpsRequest );
       
   551 
       
   552     CleanupStack::PopAndDestroy( 1 );   // >>> mKey
       
   553 
       
   554     }
       
   555 
       
   556 // -----------------------------------------------------------------------------
       
   557 // TImpsSDataUtils::GetKeepAliveL
       
   558 // -----------------------------------------------------------------------------
       
   559 //
       
   560 TBool TImpsSDataUtils::GetKeepAliveL(
       
   561     MImpsDataAccessor* aAc,
       
   562     TInt& aTime )
       
   563     {
       
   564     TInt time( 0 );
       
   565     CImpsKey* myk = CImpsKey::NewLC();    // <<< myk
       
   566     TImpsSDataUtils::AddValuesFromArrayL(
       
   567         myk,
       
   568         KTransContentElements,
       
   569         sizeof( KTransContentElements ) /
       
   570         sizeof( KTransContentElements[0] ) );
       
   571     myk->AddL( CREATEKEY( EImpsKeyKeepAlive_Response, 0 ) );
       
   572     // Check if this is KeepAliveResponse
       
   573     if ( aAc->CheckBranchExistenceL( myk ) )
       
   574         {
       
   575         myk->AddL( CREATEKEY( EImpsKeyKeepAliveTime, 0 ) );
       
   576         }
       
   577     else
       
   578         {
       
   579         // It should be LoginResponse
       
   580         myk->ReplaceLastL( CREATEKEY( EImpsKeyLogin_Response, 0 ) );
       
   581         myk->AddL( CREATEKEY( EImpsKeyKeepAliveTime, 0 ) );
       
   582         }
       
   583     if ( aAc->RestoreIntegerL( myk, time ) )
       
   584         {
       
   585         aTime = time;
       
   586         }
       
   587     CleanupStack::PopAndDestroy( 1 );   // >>> myk
       
   588     return ( aTime ? ETrue : EFalse );
       
   589     }
       
   590 
       
   591 // -----------------------------------------------------------------------------
       
   592 // TImpsSDataUtils::GetLoginSessionIDL
       
   593 // -----------------------------------------------------------------------------
       
   594 //
       
   595 void TImpsSDataUtils::GetLoginSessionIDL( MImpsDataAccessor* aAc, TPtrC& aID  )
       
   596     {
       
   597     TDesC* myPtr;
       
   598     CImpsKey* myKey = CImpsKey::NewLC();
       
   599     myKey->AddL( CREATEKEY( EImpsKeySession, 0 ) );
       
   600     myKey->AddL( CREATEKEY( EImpsKeyTransaction, 0 ) );
       
   601     myKey->AddL( CREATEKEY( EImpsKeyTransactionContent, 0 ) );
       
   602     myKey->AddL( CREATEKEY( EImpsKeyLogin_Response, 0 ) );
       
   603     myKey->AddL( CREATEKEY( EImpsKeySessionID, 0 ) );
       
   604     if ( aAc->RestoreDescL( myKey, myPtr ) )
       
   605         {
       
   606         aID.Set( *myPtr );
       
   607         }
       
   608     else
       
   609         {
       
   610         aID.Set( KNullDesC );
       
   611         }
       
   612     CleanupStack::PopAndDestroy( );  //myKey
       
   613     }
       
   614 
       
   615 // -----------------------------------------------------------------------------
       
   616 // TImpsSDataUtils::ContentDataTypeL
       
   617 // -----------------------------------------------------------------------------
       
   618 //
       
   619 void TImpsSDataUtils::ContentDataTypeL(
       
   620     MImpsDataAccessor* aAc,
       
   621     TPtrC& aContent )
       
   622     {
       
   623     TInt msgType = GetMessageTypeL( aAc );
       
   624     TDesC* myPtr;
       
   625     CImpsKey* myKey = CImpsKey::NewLC();
       
   626     aContent.Set( KNullDesC );
       
   627 
       
   628     switch ( msgType )
       
   629         {
       
   630         case EImpsNewMessage:
       
   631             {
       
   632             TImpsDataUtils::AddValuesFromArrayL(
       
   633                 myKey,
       
   634                 KNewMessageElements,
       
   635                 sizeof( KNewMessageElements ) /
       
   636                 sizeof( KNewMessageElements[0] ) );
       
   637             myKey->AddL( CREATEKEY( EImpsKeyMessageInfo, 0 ) );
       
   638             myKey->AddL( CREATEKEY( EImpsKeyContentType, 0 ) );
       
   639             if ( aAc->RestoreDescL( myKey, myPtr ) )
       
   640                 {
       
   641                 aContent.Set( *myPtr );
       
   642                 }
       
   643             break;
       
   644             }
       
   645         // Notice: Presence is not checked here
       
   646         default:
       
   647             break;
       
   648         };
       
   649 
       
   650     CleanupStack::PopAndDestroy( );  //myKey
       
   651     }
       
   652 
       
   653 
       
   654 // -----------------------------------------------------------------------------
       
   655 // TImpsSDataUtils::GetClientIDL
       
   656 // Only new message is supported now!
       
   657 // -----------------------------------------------------------------------------
       
   658 //
       
   659 void TImpsSDataUtils::GetApplicationIDL( MImpsDataAccessor* aAc, TPtrC& aID  )
       
   660     {
       
   661     TDesC* myPtr;
       
   662     CImpsKey* myKey = CImpsKey::NewLC();
       
   663     myKey->AddL( CREATEKEY( EImpsKeySession, 0 ) );
       
   664     myKey->AddL( CREATEKEY( EImpsKeyTransaction, 0 ) );
       
   665     myKey->AddL( CREATEKEY( EImpsKeyExtBlock, 0 ) );
       
   666     myKey->AddL( CREATEKEY( EImpsKeyAPIClient, 0 ) );
       
   667     if ( aAc->RestoreDescL( myKey, myPtr ) )
       
   668         {
       
   669         aID.Set( *myPtr );
       
   670         }
       
   671     else
       
   672         {
       
   673         aID.Set( KNullDesC );
       
   674         }
       
   675     CleanupStack::PopAndDestroy( );  //myKey
       
   676     }
       
   677 
       
   678 // -----------------------------------------------------------------------------
       
   679 // TImpsSDataUtils::GetCIRL
       
   680 // CIR error element exists in WV 1.2 and higher only
       
   681 // -----------------------------------------------------------------------------
       
   682 //
       
   683 TBool TImpsSDataUtils::GetCIRL( MImpsDataAccessor* aAc  )
       
   684     {
       
   685     TBool ret( EFalse );
       
   686     // first check that not WV 1.1 message
       
   687     CImpsFields* f = aAc->GetImpsFields();
       
   688     if ( f->CspVersion() == EImpsCspVersion11 )
       
   689         {
       
   690         return ret;
       
   691         }
       
   692 
       
   693     CImpsKey* myKey = CImpsKey::NewLC();
       
   694     TImpsDataUtils::AddValuesFromArrayL(
       
   695         myKey, KGetCIRElements,
       
   696         sizeof( KGetCIRElements ) / sizeof( KGetCIRElements[0] ) );
       
   697     aAc->RestoreBooleanL( myKey, ret );
       
   698 
       
   699     CleanupStack::PopAndDestroy( );  //myKey
       
   700     return ret;
       
   701     }
       
   702 
       
   703 // -----------------------------------------------------------------------------
       
   704 // TImpsSDataUtils::GetPureMessageTypeL
       
   705 // -----------------------------------------------------------------------------
       
   706 //
       
   707 TInt TImpsSDataUtils::GetPureMessageTypeL( MImpsDataAccessor* aAc )
       
   708     {
       
   709     CImpsKey* myKey = CImpsKey::NewLC();
       
   710     myKey->AddL( CREATEKEY( EImpsKeySession, 0 ) );
       
   711     myKey->AddL( CREATEKEY( EImpsKeyTransaction, 0 ) );
       
   712     myKey->AddL( CREATEKEY( EImpsKeyTransactionContent, 0 ) );
       
   713     myKey->AddL( CREATEKEY( EImpsKeyPureData, 0 ) );
       
   714     TInt enumi( 0 );
       
   715     TInt index( 0 );
       
   716     TImpsKeyType type( EImpsKeyTypeIM );
       
   717     // try to get the original message type
       
   718     if ( aAc->RestoreAlternativeL( myKey, enumi, index, type ) )
       
   719         {
       
   720         CleanupStack::PopAndDestroy( );  //myKey
       
   721         // if the message type is not stored correctly,
       
   722         // the default value is EImpsMessageNone
       
   723         if ( enumi == EImpsMessageNone )
       
   724             {
       
   725             return EImpsPureData;
       
   726             }
       
   727         return enumi;
       
   728         }
       
   729 
       
   730     CleanupStack::PopAndDestroy( );  //myKey
       
   731     return EImpsPureData;
       
   732 
       
   733     }
       
   734 //  End of File
       
   735