homescreenpluginsrv/hspsmanager/client/hspsclient.cpp
changeset 0 79c6a41cd166
child 4 1a2a00e78665
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     2 * Copyright (c) 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:  Client-side API implementation of Installation and Maintenence
       
    15 *                Services of Application Management Service APIs. 
       
    16 *                See hspsThemeManagement.h.
       
    17 *
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 #include <e32svr.h>
       
    23 
       
    24 #include "hsps_builds_cfg.hrh"
       
    25 
       
    26 #include "hspsclient.h"
       
    27 #include "hspsodt.h"
       
    28 #include "hspsresult.h"
       
    29 #include "hspspluginidlist.h"
       
    30 #include "hspsdomdocument.h"
       
    31 
       
    32 #include <s32mem.h>
       
    33 #include <s32file.h>
       
    34 
       
    35 #ifdef HSPS_LOG_ACTIVE
       
    36 #include <hspslogbus.h>
       
    37 #endif
       
    38 
       
    39 // ========================= MEMBER FUNCTIONS ==================================
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // ChspsClient::NewL()
       
    43 // Two-phased constructor.
       
    44 // -----------------------------------------------------------------------------
       
    45 EXPORT_C ChspsClient* ChspsClient::NewL( MhspsThemeManagementServiceObserver& aObserver )
       
    46     {
       
    47     ChspsClient* self = NewLC( aObserver );
       
    48     CleanupStack::Pop( self );
       
    49     return( self ) ;
       
    50     }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // ChspsClient::NewLC()
       
    54 // Two-phased constructor.
       
    55 // -----------------------------------------------------------------------------
       
    56 EXPORT_C ChspsClient* ChspsClient::NewLC( MhspsThemeManagementServiceObserver& aObserver )
       
    57     {
       
    58     ChspsClient* self = new ( ELeave ) ChspsClient( aObserver );
       
    59     CleanupStack::PushL( self );
       
    60     self->ConstructL();
       
    61     return self;
       
    62     }
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // ChspsClient::ConstructL()
       
    66 // Symbian 2nd phase constructor can leave.
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 void ChspsClient::ConstructL()
       
    70     {
       
    71     User::LeaveIfError( iSession.Connect() );
       
    72     iOdt = ChspsODT::NewL();
       
    73     iResult = ChspsResult::NewL();
       
    74     }
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // ChspsClient::ChspsClient()
       
    78 // C++ default constructor can NOT contain any code, that might leave.
       
    79 // -----------------------------------------------------------------------------
       
    80 ChspsClient::ChspsClient( MhspsThemeManagementServiceObserver& aObserver)
       
    81 : CActive( EPriorityStandard ), iObserver( aObserver )
       
    82     {
       
    83     CActiveScheduler::Add( this );
       
    84     iCancelRequestMessage = (ThspsServiceRequestMessage)KErrNone;
       
    85     iODTMode = EFalse;
       
    86     iSubscription = EFalse;
       
    87     }
       
    88 
       
    89 // -----------------------------------------------------------------------------
       
    90 // ChspsClient::~ChspsClient()
       
    91 // Destructor.
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 ChspsClient::~ChspsClient()
       
    95     {
       
    96     Cancel(); // Causes call to DoCancel()
       
    97     iSession.Close();
       
    98     delete iOdt;
       
    99     delete iSearchMaskData;
       
   100     delete iSetMaskData;
       
   101     delete iResult;
       
   102     }
       
   103 
       
   104 
       
   105 // -----------------------------------------------------------------------------
       
   106 // ChspsClient::hspsInstallTheme
       
   107 // (other items were commented in a header).
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 EXPORT_C ThspsServiceCompletedMessage ChspsClient::hspsInstallTheme(const TDesC& aManifestFileName,
       
   111                                 ChspsODT& aHeader)
       
   112     {
       
   113     ThspsServiceCompletedMessage ret = EhspsInstallThemeFailed;
       
   114     TBuf8<KMaxHeaderDataLength8> headerData;
       
   115     TInt errorCode = KErrNone;
       
   116     iODTMode = ETrue;
       
   117     ret = (ThspsServiceCompletedMessage) iSession.InstallTheme( iResultData, aManifestFileName,
       
   118                                   headerData );
       
   119     UpdatehspsResult( iResultData );
       
   120     if ( ret == EhspsInstallThemeSuccess || ret == EhspsInstallPhaseSuccess )
       
   121     {
       
   122 
       
   123     TRAP( errorCode, aHeader.UnMarshalHeaderL(headerData) );
       
   124     if ( errorCode )
       
   125         {
       
   126         ret = EhspsInstallThemeFailed;
       
   127         
       
   128 #ifdef HSPS_LOG_ACTIVE
       
   129     if( iLogBus )
       
   130         {
       
   131         iLogBus->LogText( _L( "ChspsClient::hspsInstallTheme(): - failed, bad headerdata returned, system error %d." ),
       
   132                 errorCode );
       
   133         }
       
   134 #endif
       
   135     
       
   136         iResult->iSystemError = errorCode;
       
   137         iResult->iXuikonError = errorCode; 
       
   138         }
       
   139       }
       
   140     
       
   141     return ret;
       
   142     }
       
   143     
       
   144 // -----------------------------------------------------------------------------
       
   145 // ChspsClient::hspsInstallTheme
       
   146 // (other items were commented in a header).
       
   147 // -----------------------------------------------------------------------------
       
   148 //
       
   149 EXPORT_C ThspsServiceCompletedMessage ChspsClient::hspsInstallTheme(const TDesC& /*aManifestFileName*/
       
   150                                                                           , TDes8& /*aHeaderData*/)
       
   151     {
       
   152     return EhspsServiceNotSupported;
       
   153     }
       
   154 
       
   155 // -----------------------------------------------------------------------------
       
   156 // ChspsClient::hspsInstallNextPhaseL
       
   157 // (other items were commented in a header).
       
   158 // -----------------------------------------------------------------------------
       
   159 //
       
   160 EXPORT_C ThspsServiceCompletedMessage ChspsClient::hspsInstallNextPhaseL( ChspsODT& aHeader )
       
   161     {
       
   162     ThspsServiceCompletedMessage ret = EhspsServiceRequestError; 
       
   163     iResult->ResetData();
       
   164     if ( !IsActive() )
       
   165         {
       
   166         iODTMode = ETrue;
       
   167         iCancelRequestMessage = EhspsCancelInstallTheme;
       
   168         iHeader = &aHeader;
       
   169         iStatus = KRequestPending;
       
   170         SetActive();
       
   171         iSession.InstallNextPhase( iResultData, iHeaderData, iStatus );
       
   172         ret = EhspsServiceRequestSheduled;
       
   173         }
       
   174     else
       
   175         {
       
   176         ret = EhspsServiceRequestError; 
       
   177         }
       
   178     return ret;
       
   179     }    
       
   180     
       
   181 // -----------------------------------------------------------------------------
       
   182 // ChspsClient::hspsInstallNextPhaseL
       
   183 // (other items were commented in a header).
       
   184 // -----------------------------------------------------------------------------
       
   185 //
       
   186 EXPORT_C ThspsServiceCompletedMessage ChspsClient::hspsInstallNextPhaseL( TDes8& /*aHeaderData*/ )
       
   187     {
       
   188     return EhspsServiceNotSupported;
       
   189     }   
       
   190     
       
   191 // -----------------------------------------------------------------------------
       
   192 // ChspsClient::hspsCancelInstallTheme()
       
   193 // (other items were commented in a header).
       
   194 // -----------------------------------------------------------------------------
       
   195 //
       
   196 EXPORT_C ThspsServiceCompletedMessage ChspsClient::hspsCancelInstallTheme()
       
   197     {
       
   198     ThspsServiceCompletedMessage ret = EhspsServiceRequestError; 
       
   199     iResult->ResetData();
       
   200     if ( IsActive() )
       
   201         {
       
   202         Cancel();
       
   203         ret = EhspsServiceRequestCanceled;
       
   204         }
       
   205     else 
       
   206         {
       
   207         ret = EhspsServiceRequestError;
       
   208         }
       
   209     return ret;
       
   210     }    
       
   211     
       
   212 // -----------------------------------------------------------------------------
       
   213 // ChspsClient::hspsReinstallConf
       
   214 // (other items were commented in a header).
       
   215 // -----------------------------------------------------------------------------
       
   216 //
       
   217 EXPORT_C ThspsServiceCompletedMessage ChspsClient::hspsReinstallConf( 
       
   218     TInt aAppUid,
       
   219     TInt aConfUid )
       
   220     {
       
   221     ThspsServiceCompletedMessage ret = EhspsReinstallConfFailed;
       
   222     
       
   223     ThspsParamReinstallConf params;
       
   224     params.appUid = aAppUid;
       
   225     params.confUId = aConfUid;
       
   226     
       
   227     ret = ( ThspsServiceCompletedMessage )iSession.ReinstallConf( iResultData, params );
       
   228     
       
   229     UpdatehspsResult( iResultData );
       
   230     
       
   231     return ret;
       
   232     }
       
   233     
       
   234 // -----------------------------------------------------------------------------
       
   235 // ChspsClient::hspsGetListHeaders
       
   236 // (other items were commented in a header).
       
   237 // -----------------------------------------------------------------------------
       
   238 //
       
   239 EXPORT_C ThspsServiceCompletedMessage ChspsClient::hspsGetListHeaders( const ChspsODT& aSearchMask, 
       
   240                                 CArrayPtrFlat<ChspsODT>& aHeaderList )
       
   241     {
       
   242     ThspsServiceCompletedMessage ret = EhspsServiceRequestError; 
       
   243     TBuf8<KMaxHeaderDataLength8> headerData;
       
   244     TInt errorCode = 0;
       
   245     iHeaderList = &aHeaderList;
       
   246     if (iSearchMaskData)
       
   247         {
       
   248         delete iSearchMaskData;
       
   249         iSearchMaskData = NULL;
       
   250         }
       
   251     TRAP(errorCode, iSearchMaskData = aSearchMask.MarshalHeaderL());
       
   252     if (errorCode)
       
   253         {
       
   254         ret = EhspsServiceRequestError; 
       
   255         iResult->iSystemError = errorCode;
       
   256         iResult->iXuikonError = errorCode;
       
   257         }
       
   258     else
       
   259         {
       
   260         iODTMode = ETrue; 
       
   261         if ( IsActive() ) 
       
   262             {
       
   263             // cancel previous subscription first
       
   264             hspsCancelGetListHeaders();
       
   265             }        
       
   266         ret = (ThspsServiceCompletedMessage)iSession.GetListHeaders(iResultData, 
       
   267                                                              iSearchMaskData->Des(),headerData );
       
   268 
       
   269 #ifdef HSPS_LOG_ACTIVE
       
   270         if( iLogBus )
       
   271             {
       
   272             iLogBus->LogText( _L( "ChspsClient::hspsGetListHeaders(): - theme query sent for RootUid %d." ),
       
   273                     aSearchMask.RootUid() );
       
   274             }
       
   275 #endif
       
   276         
       
   277         UpdatehspsResult( iResultData );
       
   278         }
       
   279     return ret;
       
   280     } 
       
   281 
       
   282 
       
   283 // -----------------------------------------------------------------------------
       
   284 // ChspsClient::hspsGetListHeaders
       
   285 // (other items were commented in a header).
       
   286 // -----------------------------------------------------------------------------
       
   287 //
       
   288 EXPORT_C ThspsServiceCompletedMessage ChspsClient::hspsGetListHeaders(const TDesC8&  /*aSearchMaskData*/,
       
   289                             CArrayPtrSeg<HBufC8>& /*aHeaderDataList*/)
       
   290     {
       
   291     return EhspsServiceNotSupported;
       
   292     }
       
   293     
       
   294 // -----------------------------------------------------------------------------
       
   295 // ChspsClient::hspsGetNextHeader()
       
   296 // (other items were commented in a header).
       
   297 // -----------------------------------------------------------------------------
       
   298 //
       
   299 EXPORT_C ThspsServiceCompletedMessage ChspsClient::hspsGetNextHeader()
       
   300     {
       
   301     ThspsServiceCompletedMessage ret = EhspsServiceRequestError; 
       
   302     iResult->ResetData();
       
   303     if ( !IsActive() )
       
   304         {
       
   305         iCancelRequestMessage = EhspsCancelGetListHeaders;
       
   306         iStatus = KRequestPending;
       
   307         SetActive(); 
       
   308         iSession.GetNextHeader( iResultData, iHeaderData, iStatus );
       
   309         iSubscription = ETrue;
       
   310 
       
   311 #ifdef HSPS_LOG_ACTIVE
       
   312         if( iLogBus )
       
   313             {
       
   314             iLogBus->LogText( _L( "ChspsClient::hspsGetNextHeader(): - themes subscribed." ) );
       
   315             }
       
   316 #endif
       
   317     
       
   318         ret = EhspsServiceRequestSheduled;
       
   319         }
       
   320     else
       
   321         {
       
   322         ret = EhspsServiceRequestError; 
       
   323         }
       
   324     return ret;
       
   325     }    
       
   326     
       
   327 // -----------------------------------------------------------------------------
       
   328 // ChspsClient::hspsCancelGetListHeaders()
       
   329 // (other items were commented in a header).
       
   330 // -----------------------------------------------------------------------------
       
   331 //   
       
   332 EXPORT_C ThspsServiceCompletedMessage ChspsClient::hspsCancelGetListHeaders()
       
   333     {
       
   334     ThspsServiceCompletedMessage ret = EhspsServiceRequestError; 
       
   335     iResult->ResetData();
       
   336     if ( IsActive() )
       
   337         {
       
   338         iSubscription = EFalse;
       
   339         Cancel();
       
   340         ret = EhspsServiceRequestCanceled;
       
   341         }
       
   342     else 
       
   343         {
       
   344         ret = EhspsServiceRequestError;
       
   345         }
       
   346     return ret;
       
   347     }          
       
   348     
       
   349 
       
   350 // -----------------------------------------------------------------------------
       
   351 // ChspsClient::hspsSetActiveTheme
       
   352 // (other items were commented in a header).
       
   353 // -----------------------------------------------------------------------------
       
   354 //
       
   355 EXPORT_C ThspsServiceCompletedMessage ChspsClient::hspsSetActiveTheme(const ChspsODT& aSetMask,
       
   356                                   ChspsODT& aHeader)
       
   357     {
       
   358     TInt errorCode = 0;
       
   359     ThspsServiceCompletedMessage ret = EhspsSetActiveThemeFailed; 
       
   360     TBuf8<KMaxHeaderDataLength8> headerData;
       
   361     if (iSetMaskData)
       
   362         {
       
   363         delete iSetMaskData;
       
   364         iSetMaskData = NULL;
       
   365         }
       
   366     TRAP( errorCode, iSetMaskData = aSetMask.MarshalHeaderL() );
       
   367     if ( errorCode )
       
   368         {
       
   369         ret = EhspsServiceRequestError; 
       
   370         iResult->iSystemError = errorCode;
       
   371         iResult->iXuikonError = errorCode;       
       
   372         }
       
   373     else
       
   374         {
       
   375 #ifdef HSPS_LOG_ACTIVE
       
   376         if( iLogBus )
       
   377             {
       
   378             iLogBus->LogText( _L( "ChspsClient::hspsSetActiveTheme(): - requested for: AppUid = %d, ThemeUid = %d." ),
       
   379                     aSetMask.RootUid(),
       
   380                     aSetMask.ThemeUid() );
       
   381             }
       
   382 #endif
       
   383         
       
   384         ret = (ThspsServiceCompletedMessage)iSession.SetActiveTheme( iResultData, 
       
   385                                        iSetMaskData->Des(), headerData );
       
   386         if (ret == EhspsSetActiveThemeSuccess)
       
   387             {
       
   388             TRAP(errorCode, aHeader.UnMarshalHeaderL(headerData));
       
   389             if ( errorCode )
       
   390                 {
       
   391                 ret = EhspsServiceRequestError;
       
   392                 iResult->iSystemError = errorCode;
       
   393                 iResult->iXuikonError = errorCode; 
       
   394 
       
   395 #ifdef HSPS_LOG_ACTIVE
       
   396                 if( iLogBus )
       
   397                     {
       
   398                     iLogBus->LogText( _L( "ChspsClient::hspsSetActiveTheme(): - failed, bad ODT returned, system error %d." ),
       
   399                             errorCode );
       
   400                     }
       
   401 #endif
       
   402                 }
       
   403             else
       
   404                 {
       
   405 #ifdef HSPS_LOG_ACTIVE
       
   406                 if( iLogBus )
       
   407                     {
       
   408                     iLogBus->LogText( _L( "ChspsClient::hspsSetActiveTheme(): - activated for AppUid = %d, ThemeUid = %d." ),
       
   409                             aHeader.RootUid(),
       
   410                             aHeader.ThemeUid() );
       
   411                     }
       
   412 #endif
       
   413     
       
   414                 UpdatehspsResult( iResultData ); 
       
   415                 }
       
   416             }
       
   417         else
       
   418             {
       
   419             UpdatehspsResult( iResultData ); 
       
   420             } 
       
   421         }
       
   422     return ret;
       
   423     } 
       
   424     
       
   425 
       
   426 // -----------------------------------------------------------------------------
       
   427 // ChspsClient::hspsRestoreDefault
       
   428 // (other items were commented in a header).
       
   429 // -----------------------------------------------------------------------------
       
   430 //
       
   431 EXPORT_C ThspsServiceCompletedMessage ChspsClient::hspsRestoreDefault(const ChspsODT& aSetMask,
       
   432                                   ChspsODT& aHeader)
       
   433     {
       
   434     TInt errorCode = 0;
       
   435     ThspsServiceCompletedMessage ret = EhspsRestoreDefaultFailed; 
       
   436     TBuf8<KMaxHeaderDataLength8> headerData;
       
   437     if ( iSetMaskData )
       
   438         {
       
   439         delete iSetMaskData;
       
   440         iSetMaskData = NULL;
       
   441         } 
       
   442         
       
   443     TRAP( errorCode, iSetMaskData = aSetMask.MarshalHeaderL() );
       
   444     if ( errorCode )
       
   445         {
       
   446         ret = EhspsServiceRequestError; 
       
   447         iResult->iSystemError = errorCode;
       
   448         iResult->iXuikonError = errorCode; 
       
   449         }
       
   450     else
       
   451         {
       
   452         ret = ( ThspsServiceCompletedMessage )iSession.RestoreDefault( iResultData,
       
   453                                 iSetMaskData->Des(), headerData );
       
   454         if ( ret == EhspsRestoreDefaultSuccess )
       
   455             {
       
   456             TRAP( errorCode, aHeader.UnMarshalHeaderL( headerData ) );
       
   457             if ( errorCode )
       
   458                 {
       
   459                 ret = EhspsServiceRequestError;
       
   460                 iResult->iSystemError = errorCode;
       
   461                 iResult->iXuikonError = errorCode;           
       
   462                 }
       
   463             else
       
   464                 {
       
   465                 UpdatehspsResult( iResultData );
       
   466                 }
       
   467             }
       
   468         else
       
   469             {
       
   470             UpdatehspsResult( iResultData );
       
   471             }
       
   472         }
       
   473     return ret;
       
   474     } 
       
   475 
       
   476 // -----------------------------------------------------------------------------
       
   477 // ChspsClient::hspsSetRemoveThemeL
       
   478 // (other items were commented in a header).
       
   479 // -----------------------------------------------------------------------------
       
   480 //
       
   481 EXPORT_C ThspsServiceCompletedMessage ChspsClient::hspsRemoveThemeL(const ChspsODT& aSetMask)
       
   482     {
       
   483     TInt errorCode = 0;
       
   484     ThspsServiceCompletedMessage ret = EhspsRemoveThemeFailed; 
       
   485     if (iSetMaskData)
       
   486         {
       
   487         delete iSetMaskData;
       
   488         iSetMaskData = NULL;
       
   489         }      
       
   490     TRAP(errorCode, iSetMaskData = aSetMask.MarshalHeaderL());
       
   491     if (errorCode)
       
   492         {
       
   493         ret = EhspsServiceRequestError; 
       
   494         iResult->iSystemError = errorCode;
       
   495         iResult->iXuikonError = errorCode;                  
       
   496         }
       
   497     else
       
   498       {
       
   499       ret = (ThspsServiceCompletedMessage)iSession.RemoveTheme(iResultData, iSetMaskData->Des());
       
   500       UpdatehspsResult( iResultData );
       
   501       }
       
   502     return ret;
       
   503     } 
       
   504 
       
   505 
       
   506 // -----------------------------------------------------------------------------
       
   507 // ChspsClient::hspsSetActiveTheme
       
   508 // (other items were commented in a header).
       
   509 // -----------------------------------------------------------------------------
       
   510 //
       
   511 EXPORT_C ThspsServiceCompletedMessage ChspsClient::hspsSetActiveTheme(const TDesC8& /*aSetMaskData*/
       
   512                                                                       , TDes8& /*aHeaderData*/)
       
   513     {
       
   514     return EhspsServiceNotSupported;
       
   515     }
       
   516   
       
   517 
       
   518 // -----------------------------------------------------------------------------
       
   519 // ChspsRequestClient::GethspsResultL
       
   520 // ?implementation_description
       
   521 // (other items were commented in a header).
       
   522 // -----------------------------------------------------------------------------
       
   523 //
       
   524 EXPORT_C void ChspsClient::GethspsResult(ChspsResult& aResult)
       
   525     {
       
   526     aResult.iSystemError = iResult->iSystemError; 
       
   527     aResult.iXuikonError = iResult->iXuikonError; 
       
   528     aResult.iIntValue1 = iResult->iIntValue1;
       
   529     aResult.iIntValue2 = iResult->iIntValue2;  
       
   530     }  
       
   531              
       
   532 // -----------------------------------------------------------------------------
       
   533 // ChspsClient::hspsGetHeaders
       
   534 // (other items were commented in a header).
       
   535 // -----------------------------------------------------------------------------
       
   536 //
       
   537 EXPORT_C TInt ChspsClient::hspsGetHeaders( const ChspsODT& aSearchMask, 
       
   538                                 CArrayPtrFlat<ChspsODT>& aHeaderList )
       
   539     {
       
   540     iHeaderList = &aHeaderList;
       
   541     // Convert search mask ODT to binary stream
       
   542     if (iSearchMaskData)
       
   543         {
       
   544         delete iSearchMaskData;
       
   545         iSearchMaskData = NULL;
       
   546         }
       
   547     TRAPD( err, iSearchMaskData = aSearchMask.MarshalHeaderL() );
       
   548 
       
   549     if ( err == KErrNone )
       
   550         {
       
   551         // Get the header count
       
   552         ThspsServiceCompletedMessage ret = 
       
   553             ( ThspsServiceCompletedMessage )iSession.GetListHeaders(
       
   554                 iResultData, 
       
   555                 iSearchMaskData->Des(),
       
   556                 iHeaderData );
       
   557                 
       
   558         if ( ret == EhspsGetListHeadersSuccess )
       
   559             {
       
   560             // Header count > 0
       
   561             UpdatehspsResult( iResultData );
       
   562             TInt headerCount = iResult->iIntValue1;
       
   563             // Get headers
       
   564             for ( TInt i = 0; 
       
   565                   i < headerCount && err == KErrNone; 
       
   566                   i++ )
       
   567                 {
       
   568                 ret = ( ThspsServiceCompletedMessage )iSession.GetNextHeader( 
       
   569                     iResultData,
       
   570                     iHeaderData );
       
   571                 if ( ret == EhspsGetListHeadersUpdate )
       
   572                     {
       
   573                     TRAP( err, AppendHeaderListL( iHeaderData) );
       
   574                     }
       
   575                 else
       
   576                     {
       
   577                     // Request failed
       
   578                     err = KErrGeneral;
       
   579                     }
       
   580                 }
       
   581             }
       
   582         else if ( ret == EhspsGetListHeadersEmpty )
       
   583             {
       
   584             // Empty header list
       
   585             err = KErrNotFound;
       
   586             }
       
   587         else
       
   588             {
       
   589             // Header count request failed
       
   590             err = KErrGeneral;
       
   591             }
       
   592         }
       
   593 
       
   594     return err;
       
   595     } 
       
   596 
       
   597 // -----------------------------------------------------------------------------
       
   598 // ChspsClient::hspsAddPlugin
       
   599 // -----------------------------------------------------------------------------
       
   600 //
       
   601 EXPORT_C ThspsServiceCompletedMessage ChspsClient::hspsAddPlugin(
       
   602 		const TInt aAppUid,
       
   603 		const TInt aConfId,
       
   604 		const TInt aPluginUid,
       
   605 		const TInt aPosition,
       
   606 		TInt& aAddedPluginId )
       
   607     {
       
   608     ThspsServiceCompletedMessage ret = EhspsAddPluginFailed;
       
   609     
       
   610     if ( aAppUid > 0 && aPluginUid > 0 )    
       
   611         {        
       
   612         ThpsParamAddPlugin params;
       
   613         params.appUid = aAppUid;        
       
   614         params.configurationId = aConfId; 
       
   615         params.pluginUid = aPluginUid;
       
   616         params.positionIndex = aPosition;
       
   617         
       
   618         // Try adding the plugin configuration
       
   619         ret = ( ThspsServiceCompletedMessage )iSession.AddPlugin( iResultData, params, aAddedPluginId );
       
   620         
       
   621         // Get error codes from the server op.
       
   622         UpdatehspsResult( iResultData );                            
       
   623         }
       
   624 
       
   625     return ret;
       
   626     } 
       
   627 
       
   628 // -----------------------------------------------------------------------------
       
   629 // ChspsClient::hspsRemovePlugin
       
   630 // -----------------------------------------------------------------------------
       
   631 //
       
   632 EXPORT_C ThspsServiceCompletedMessage ChspsClient::hspsRemovePlugin(
       
   633 		const TInt aAppUid,        		
       
   634 		const TInt aPluginId )
       
   635 	{
       
   636 	ThspsServiceCompletedMessage ret = EhspsRemovePluginFailed;
       
   637 	    
       
   638     if ( aAppUid > 0 && aPluginId > 0 )    
       
   639         {        
       
   640         ThpsParamRemovePlugin params;
       
   641         params.appUid = aAppUid;                 
       
   642         params.pluginId = aPluginId;
       
   643                 
       
   644         // Try removing the plugin configuration instance
       
   645         ret = ( ThspsServiceCompletedMessage )iSession.RemovePlugin( iResultData, params );
       
   646         
       
   647         // Get error codes from the server op.
       
   648         UpdatehspsResult( iResultData );                            
       
   649         }
       
   650 
       
   651     return ret;
       
   652 	}
       
   653 
       
   654 // -----------------------------------------------------------------------------
       
   655 // ChspsClient::hspsSetActivePlugin
       
   656 // -----------------------------------------------------------------------------
       
   657 //
       
   658 EXPORT_C ThspsServiceCompletedMessage ChspsClient::hspsSetActivePlugin( const TInt aAppUid,
       
   659                                                                         const TInt aPluginId )
       
   660     {    
       
   661     ThspsServiceCompletedMessage ret = EhspsSetActivePluginFailed;
       
   662         
       
   663     if( aPluginId > 0 )    
       
   664         {        
       
   665         ThpsParamSetActivePlugin params;
       
   666         params.appUid = aAppUid;
       
   667         params.pluginId = aPluginId;
       
   668         
       
   669         // Try activation.
       
   670         ret = ( ThspsServiceCompletedMessage )iSession.SetActivePlugin( iResultData, params );
       
   671         
       
   672         // Get error codes from the server op.
       
   673         UpdatehspsResult( iResultData );                            
       
   674         }
       
   675 
       
   676     return ret;  
       
   677     }
       
   678 
       
   679 // -----------------------------------------------------------------------------
       
   680 // ChspsClient::hspsReplacePlugin
       
   681 // -----------------------------------------------------------------------------
       
   682 //
       
   683 EXPORT_C ThspsServiceCompletedMessage ChspsClient::hspsReplacePlugin(
       
   684         const TInt aAppUid,
       
   685         const TInt aPluginId,               
       
   686         const TInt aConfUid )
       
   687     {
       
   688     ThspsServiceCompletedMessage ret = EhspsReplacePluginFailed;
       
   689     
       
   690     if ( aPluginId > 0 && aConfUid > 0 )    
       
   691         {                        
       
   692         ThspsParamReplacePlugin params;
       
   693         params.appUid = aAppUid;
       
   694         params.pluginId = aPluginId;
       
   695         params.confUid = aConfUid;
       
   696         
       
   697         // Try adding the plugin configuration
       
   698         ret = ( ThspsServiceCompletedMessage )iSession.ReplacePlugin( iResultData, params );
       
   699         
       
   700         // Get error codes from the server op.
       
   701         UpdatehspsResult( iResultData );                            
       
   702         }
       
   703 
       
   704     return ret;
       
   705     } 
       
   706 
       
   707 // -----------------------------------------------------------------------------
       
   708 // ChspsClient::hspsSetPluginSettings
       
   709 // -----------------------------------------------------------------------------
       
   710 //
       
   711 EXPORT_C ThspsServiceCompletedMessage ChspsClient::hspsSetPluginSettings(
       
   712         const ChspsODT& aHeader, 
       
   713         const TInt aPluginId, 
       
   714         ChspsDomDocument& aDom,
       
   715         const TBool aPluginStoringStatus )
       
   716     {
       
   717     ThspsServiceCompletedMessage ret = EhspsSetPluginSettingsFailed;
       
   718     
       
   719     TInt errorCode = 0;    
       
   720     TBuf8<KMaxHeaderDataLength8> searchMaskData;
       
   721     HBufC8* temp = NULL;
       
   722     HBufC8* tempDom = NULL;
       
   723    
       
   724     TRAP( errorCode, temp = aHeader.MarshalHeaderL() );
       
   725     TRAP( errorCode, tempDom = aDom.MarshallL() );
       
   726     
       
   727     if( errorCode )
       
   728         {
       
   729         ret = EhspsServiceRequestError;
       
   730         iResult->iSystemError = errorCode;
       
   731         iResult->iXuikonError = errorCode;
       
   732         }
       
   733     else
       
   734         {
       
   735         searchMaskData = temp->Des();
       
   736         TPtr8 tempDomPtr = tempDom->Des();
       
   737         
       
   738         ThspsParamSetPluginSettings params;
       
   739         params.pluginId = aPluginId;
       
   740         params.storingStatus = aPluginStoringStatus;
       
   741                 
       
   742         
       
   743         // Try set settings of the plugin Id given in params
       
   744         ret = ( ThspsServiceCompletedMessage )iSession.SetPluginSettings( iResultData, searchMaskData, params, tempDomPtr );
       
   745         // Get error codes from the server op.
       
   746         UpdatehspsResult( iResultData );
       
   747         }
       
   748 
       
   749     delete tempDom;
       
   750     delete temp;
       
   751     return ret;
       
   752     }
       
   753 
       
   754 // -----------------------------------------------------------------------------
       
   755 // ChspsClient::hspsGetPluginDomL
       
   756 // -----------------------------------------------------------------------------
       
   757 //
       
   758 EXPORT_C ThspsServiceCompletedMessage ChspsClient::hspsGetPluginOdtL(
       
   759 		const TInt aAppUid,        		
       
   760 		const TInt aPluginUid,
       
   761 		ChspsODT* aPluginOdt )
       
   762 	{
       
   763 	ThspsServiceCompletedMessage ret = EhspsGetPluginOdtFailed;
       
   764     
       
   765     if ( aAppUid > 0 && aPluginUid > 0 )    
       
   766         {        
       
   767     	ThspsParamGetPluginOdt params;
       
   768     	params.appUid = aAppUid;
       
   769     	params.pluginUid = aPluginUid;
       
   770     	TPath odtPath;
       
   771     	
       
   772         ret = ( ThspsServiceCompletedMessage )iSession.GetPluginOdt( iResultData, params, odtPath );
       
   773         
       
   774         // Get error codes from the server op.
       
   775         UpdatehspsResult( iResultData );
       
   776         
       
   777         if( ret == EhspsGetPluginOdtSuccess )
       
   778              {
       
   779              // Streaming odt from file
       
   780              TInt success = StreamOdtL( odtPath, aAppUid, aPluginOdt );
       
   781 
       
   782              if( success != KErrNone )
       
   783             	 {
       
   784             	 ret = EhspsGetPluginOdtFailed;
       
   785             	 }
       
   786              }
       
   787         }	
       
   788 	return ret;
       
   789 	}
       
   790 
       
   791 // -----------------------------------------------------------------------------
       
   792 // ChspsClient::hspsMovePluginsL
       
   793 // -----------------------------------------------------------------------------
       
   794 //
       
   795 EXPORT_C ThspsServiceCompletedMessage ChspsClient::hspsMovePluginsL(
       
   796         		const TInt aAppUid,        
       
   797         		const TInt aConfId,
       
   798         		const CArrayFixFlat<TInt>& aPluginIdList )
       
   799 	{
       
   800 	ThspsServiceCompletedMessage ret = EhspsMovePluginsFailed;
       
   801 
       
   802     if ( aAppUid > 0 && aConfId > 0 && aPluginIdList.Count() )    
       
   803         {        
       
   804         ThpsParamMovePlugins params;
       
   805         params.appUid = aAppUid;           
       
   806         params.configurationId = aConfId;
       
   807         
       
   808         // Setup an array that can be externalized 
       
   809         const TInt KGranularity = 6;
       
   810         ChspsPluginIdList* idArray = new ( ELeave )ChspsPluginIdList( KGranularity );
       
   811         CleanupStack::PushL( idArray );                
       
   812         for( TInt idIndex=0; idIndex < aPluginIdList.Count(); idIndex++ )        	
       
   813         	{        	
       
   814         	idArray->AppendL( aPluginIdList.At(idIndex) );
       
   815         	}        
       
   816         
       
   817         // Externalize array into the params.pluginIdBuf descriptor                        
       
   818         RDesWriteStream writeBuf( params.pluginIdsBuf );
       
   819         CleanupClosePushL( writeBuf );
       
   820         TRAPD( errorCode, idArray->ExternalizeL( writeBuf ) );
       
   821         CleanupStack::PopAndDestroy( &writeBuf );
       
   822         
       
   823         if ( !errorCode )        	
       
   824         	{        	                                
       
   825 	        // Try updating of the plugins list
       
   826 	        ret = ( ThspsServiceCompletedMessage )iSession.MovePlugins( iResultData, params );
       
   827 	        
       
   828 	        // Get error codes from the server op.
       
   829             UpdatehspsResult( iResultData );
       
   830         	}
       
   831         
       
   832         CleanupStack::PopAndDestroy( idArray );                                           
       
   833         }
       
   834 
       
   835     return ret;
       
   836 	}
       
   837 
       
   838 // -----------------------------------------------------------------------------
       
   839 // ChspsClient::hspsSetConfState
       
   840 // -----------------------------------------------------------------------------
       
   841 //
       
   842 EXPORT_C ThspsServiceCompletedMessage ChspsClient::hspsSetConfState(
       
   843                 const TInt aAppUid,        
       
   844                 const TInt aConfId,
       
   845                 const ThspsConfigurationState aState,
       
   846                 const ThspsConfStateChangeFilter aFilter )
       
   847     {
       
   848     ThspsServiceCompletedMessage ret = EhspsSetConfStateFailed;
       
   849     
       
   850     ThspsParamSetConfState params;
       
   851     params.appUid = aAppUid;
       
   852     params.confId = aConfId;
       
   853     params.state = aState;
       
   854     params.filter = aFilter;
       
   855 
       
   856     ret = ( ThspsServiceCompletedMessage )iSession.SetConfState( iResultData, params );
       
   857     
       
   858     UpdatehspsResult( iResultData );
       
   859     
       
   860     return ret;
       
   861     }
       
   862 
       
   863 // -----------------------------------------------------------------------------
       
   864 // ChspsClient::hspsRestoreActiveAppConf
       
   865 // -----------------------------------------------------------------------------
       
   866 //
       
   867 EXPORT_C ThspsServiceCompletedMessage ChspsClient::hspsRestoreActiveAppConf(
       
   868     const TInt aAppUid,
       
   869     const TInt aConfUid )
       
   870     {
       
   871     ThspsServiceCompletedMessage ret = EhspsRestoreActiveAppConfFailed;
       
   872     
       
   873     ThspsParamRestoreActiveAppConf params;
       
   874     params.appUid = aAppUid;
       
   875     params.confUid = aConfUid;
       
   876 
       
   877     ret = ( ThspsServiceCompletedMessage )iSession.RestoreActiveAppConf( iResultData, params );
       
   878     
       
   879     UpdatehspsResult( iResultData );
       
   880     
       
   881     return ret;
       
   882     }
       
   883 // -----------------------------------------------------------------------------
       
   884 // ChspsClient::hspsPluginUpdateL
       
   885 // -----------------------------------------------------------------------------
       
   886 //
       
   887 EXPORT_C ThspsServiceCompletedMessage ChspsClient::hspsPluginUpdateL(
       
   888                 const ChspsODT& /*aPluginUid*/  )
       
   889     {
       
   890     return EhspsUpdatePluginFailed;
       
   891     }
       
   892 
       
   893 // -----------------------------------------------------------------------------
       
   894 // ChspsClient::SetLogBus
       
   895 // Set log bus.
       
   896 // -----------------------------------------------------------------------------
       
   897 #ifdef HSPS_LOG_ACTIVE
       
   898 EXPORT_C void ChspsClient::SetLogBus( void* aLogBus )
       
   899     {
       
   900     iLogBus = (ChspsLogBus*)aLogBus;
       
   901     }
       
   902 #else
       
   903 EXPORT_C void ChspsClient::SetLogBus( void* /*aLogBus*/ )
       
   904     {
       
   905     }
       
   906 #endif
       
   907 
       
   908 // -----------------------------------------------------------------------------
       
   909 // ChspsClient::UpdatehspsResult
       
   910 // (other items were commented in a header).
       
   911 // -----------------------------------------------------------------------------
       
   912 //
       
   913 void ChspsClient::UpdatehspsResult( TDesC8& aResultData )
       
   914     {
       
   915     TInt errorCode = KErrNone;
       
   916     if( aResultData.Length() )
       
   917         {
       
   918         RDesReadStream readBuf(iResultData);
       
   919         TRAP( errorCode, iResult->InternalizeL( readBuf ) );
       
   920         readBuf.Close();
       
   921         if( errorCode )
       
   922             {
       
   923             iResult->ResetData();
       
   924             }
       
   925         }
       
   926     else
       
   927         {
       
   928         iResult->ResetData();
       
   929         }
       
   930     }
       
   931   
       
   932 // -----------------------------------------------------------------------------
       
   933 // ChspsClient::AppendHeaderListL
       
   934 // (other items were commented in a header).
       
   935 // -----------------------------------------------------------------------------
       
   936 //
       
   937 void ChspsClient::AppendHeaderListL( TDesC8& aHeaderData )
       
   938     {
       
   939     ChspsODT* header = ChspsODT::NewL();
       
   940     CleanupStack::PushL( header );
       
   941     header->UnMarshalHeaderL( aHeaderData );
       
   942     iHeaderList->AppendL( header );
       
   943     CleanupStack::Pop( header );
       
   944     }
       
   945 
       
   946 // -----------------------------------------------------------------------------
       
   947 // ChspsClient::RunError
       
   948 // From CActive. Called when error occurred in asynchronous request
       
   949 // Notifies the observer
       
   950 // (other items were commented in a header).
       
   951 // -----------------------------------------------------------------------------
       
   952 //
       
   953 TInt ChspsClient::RunError( TInt aError )
       
   954     {
       
   955     iResult->iSystemError = aError;
       
   956     iResult->iXuikonError = aError;
       
   957     iObserver.HandlehspsClientMessage( EhspsServiceRequestError );
       
   958     return KErrNone;
       
   959     }  
       
   960      
       
   961      
       
   962 // -----------------------------------------------------------------------------
       
   963 // ChspsClient::RunL()
       
   964 // (other items were commented in a header).
       
   965 // -----------------------------------------------------------------------------
       
   966 //
       
   967 void ChspsClient::RunL()
       
   968     {
       
   969     TInt errorCode = KErrNone;
       
   970     switch ( iStatus.Int() )
       
   971         {
       
   972         // the server has completed the request, signalled the client
       
   973         // thread and the clients active scheduler runs the active object.
       
   974         // Now do something with it      
       
   975         case EhspsInstallThemeSuccess:
       
   976             // the request was successful and installation is completed
       
   977             if ( iODTMode )
       
   978                 {
       
   979                 TRAP( errorCode, iHeader->UnMarshalHeaderL(iHeaderData) );
       
   980                 if ( errorCode )
       
   981                     {
       
   982                     iResult->iSystemError = errorCode;
       
   983                     iResult->iXuikonError = errorCode; 
       
   984                     iObserver.HandlehspsClientMessage( EhspsServiceRequestError );
       
   985                     }
       
   986                 else
       
   987                     {
       
   988                     UpdatehspsResult( iResultData );
       
   989                     iObserver.HandlehspsClientMessage(EhspsInstallThemeSuccess);
       
   990                     }
       
   991                 }
       
   992             else
       
   993               {
       
   994               UpdatehspsResult( iResultData );
       
   995               iObserver.HandlehspsClientMessage(EhspsInstallThemeSuccess);
       
   996               }
       
   997                 
       
   998             break;         
       
   999     
       
  1000         case EhspsInstallPhaseSuccess:
       
  1001             // the request was successful
       
  1002             if ( iODTMode )
       
  1003                 {
       
  1004                 TRAP( errorCode, iHeader->UnMarshalHeaderL(iHeaderData));
       
  1005                 if ( errorCode )
       
  1006                     {
       
  1007                     iResult->iSystemError = errorCode;
       
  1008                     iResult->iXuikonError = errorCode;
       
  1009                     iObserver.HandlehspsClientMessage( EhspsServiceRequestError );
       
  1010                     }
       
  1011                 else
       
  1012                     {
       
  1013                     UpdatehspsResult( iResultData );
       
  1014                     iObserver.HandlehspsClientMessage(EhspsInstallPhaseSuccess); 
       
  1015                     // send request to install next phase
       
  1016                     hspsInstallNextPhaseL( *iHeader );
       
  1017                     } 
       
  1018                 }
       
  1019             else
       
  1020                 {
       
  1021                 UpdatehspsResult( iResultData );
       
  1022                 // send request to install next phase
       
  1023                 iObserver.HandlehspsClientMessage(EhspsInstallPhaseSuccess);
       
  1024                 hspsInstallNextPhaseL(iHeaderData);
       
  1025                 }
       
  1026             break;         
       
  1027     
       
  1028         case EhspsInstallThemeFailed:
       
  1029             // the request was unsuccessful
       
  1030             UpdatehspsResult( iResultData );
       
  1031             iObserver.HandlehspsClientMessage( EhspsInstallThemeFailed );
       
  1032             break ;
       
  1033         
       
  1034         case EhspsGetListHeadersUpdate:
       
  1035             if (iODTMode)
       
  1036                 {
       
  1037                 ChspsODT* odt = ChspsODT::NewL();
       
  1038                 CleanupStack::PushL( odt );
       
  1039                 odt->UnMarshalHeaderL(iHeaderData);
       
  1040                 iHeaderList->AppendL(odt);
       
  1041                 CleanupStack::Pop( odt );
       
  1042                 // inform observer  
       
  1043                 if (errorCode )
       
  1044                     {
       
  1045                     iResult->iSystemError = errorCode;
       
  1046                     iResult->iXuikonError = errorCode;
       
  1047                     iObserver.HandlehspsClientMessage( EhspsServiceRequestError );
       
  1048                     }
       
  1049                 else
       
  1050                     {
       
  1051                     UpdatehspsResult( iResultData );
       
  1052 
       
  1053 #ifdef HSPS_LOG_ACTIVE
       
  1054                     if( iLogBus )
       
  1055                         {
       
  1056                         iLogBus->LogText( _L( "ChspsClient::RunL(): - a theme header received. AppUid = %d, ThemeUid = %d." ),
       
  1057                                 odt->RootUid(),
       
  1058                                 odt->ThemeUid() );
       
  1059                         }
       
  1060 #endif
       
  1061                     
       
  1062                     iObserver.HandlehspsClientMessage( EhspsGetListHeadersUpdate );
       
  1063                     
       
  1064                     // request next
       
  1065                     hspsGetNextHeader();
       
  1066                     }
       
  1067                 }
       
  1068             else
       
  1069                 {
       
  1070                 HBufC8* hd = iHeaderData.AllocL();
       
  1071                 CleanupStack::PushL( hd );
       
  1072                 iHeaderDataList->AppendL(hd);
       
  1073                 CleanupStack::Pop( hd );
       
  1074                 
       
  1075                 // inform observer  
       
  1076                 if (errorCode )
       
  1077                     {
       
  1078                     iResult->iSystemError = errorCode;
       
  1079                     iResult->iXuikonError = errorCode;
       
  1080                     iObserver.HandlehspsClientMessage( EhspsServiceRequestError );
       
  1081                     }
       
  1082                 else
       
  1083                     {
       
  1084                     UpdatehspsResult( iResultData );
       
  1085                     iObserver.HandlehspsClientMessage( EhspsGetListHeadersUpdateData );
       
  1086                     // request next
       
  1087                     hspsGetNextHeader();
       
  1088                     } 
       
  1089                 }
       
  1090             break;     
       
  1091             
       
  1092         case EhspsGetListHeadersRestart:
       
  1093             // header list has changed radically
       
  1094             // resetting the list and start filling it again
       
  1095             if (iODTMode)
       
  1096                 {
       
  1097                 // resetting and start filling the header list again
       
  1098                 iHeaderList->ResetAndDestroy();
       
  1099                 ChspsODT* odt = ChspsODT::NewL();
       
  1100                 CleanupStack::PushL( odt );
       
  1101                 odt->UnMarshalHeaderL(iHeaderData);
       
  1102                 iHeaderList->AppendL(odt);
       
  1103                 CleanupStack::Pop( odt );
       
  1104                 
       
  1105                 // inform observer  
       
  1106                 if (errorCode )
       
  1107                     {
       
  1108                     iResult->iSystemError = errorCode;
       
  1109                     iResult->iXuikonError = errorCode;
       
  1110                     iObserver.HandlehspsClientMessage( EhspsServiceRequestError );
       
  1111                     }
       
  1112                 else
       
  1113                     {
       
  1114                     UpdatehspsResult( iResultData );
       
  1115 
       
  1116 #ifdef HSPS_LOG_ACTIVE
       
  1117                     if( iLogBus )
       
  1118                         {
       
  1119                         iLogBus->LogText( _L( "ChspsClient::RunL(): - list restarted." ) );
       
  1120                         }
       
  1121 #endif
       
  1122                     
       
  1123                     iObserver.HandlehspsClientMessage( EhspsGetListHeadersRestart );
       
  1124                     // request next
       
  1125                     hspsGetNextHeader();      
       
  1126                     }
       
  1127                 }             
       
  1128             else
       
  1129                 {
       
  1130                 // resetting and starting filling the header data list again
       
  1131                 iHeaderDataList->Reset(); 
       
  1132                 HBufC8* hd = iHeaderData.AllocL();
       
  1133                 CleanupStack::PushL( hd );
       
  1134                 iHeaderDataList->AppendL(hd);
       
  1135                 CleanupStack::Pop( hd );
       
  1136 
       
  1137                 // inform observer  
       
  1138                 if ( errorCode )
       
  1139                     {
       
  1140                     iResult->iSystemError = errorCode;
       
  1141                     iResult->iXuikonError = errorCode;
       
  1142                     iObserver.HandlehspsClientMessage( EhspsServiceRequestError );
       
  1143                     }
       
  1144                 else
       
  1145                     {
       
  1146                     UpdatehspsResult( iResultData );
       
  1147                     iObserver.HandlehspsClientMessage( EhspsGetListHeadersRestartData );   
       
  1148                     // request next
       
  1149                     hspsGetNextHeader();    
       
  1150                     } 
       
  1151                 }
       
  1152             break;     
       
  1153             
       
  1154         case EhspsGetListHeadersEmpty:
       
  1155             // header list is empty
       
  1156             UpdatehspsResult( iResultData );
       
  1157             if (iODTMode)
       
  1158                 {
       
  1159                 // resetting and start filling the header list again
       
  1160                 iHeaderList->ResetAndDestroy();
       
  1161                 
       
  1162 #ifdef HSPS_LOG_ACTIVE
       
  1163                 if( iLogBus )
       
  1164                     {
       
  1165                     iLogBus->LogText( _L( "ChspsClient::RunL(): - list empty." ) );
       
  1166                     }
       
  1167 #endif
       
  1168     
       
  1169                 // inform observer 
       
  1170                 iObserver.HandlehspsClientMessage(EhspsGetListHeadersEmpty);
       
  1171                 }
       
  1172             else
       
  1173                 {
       
  1174                 iHeaderDataList->Reset(); 
       
  1175                 // inform observer
       
  1176                 iObserver.HandlehspsClientMessage(EhspsGetListHeadersEmpty);    
       
  1177                 }
       
  1178             // requesting possible update
       
  1179             hspsGetNextHeader();   
       
  1180             break;
       
  1181        
       
  1182         case EhspsGetListHeadersFailed:
       
  1183             // service failure occurred
       
  1184             UpdatehspsResult( iResultData );
       
  1185             iObserver.HandlehspsClientMessage(EhspsGetListHeadersFailed);
       
  1186             break;
       
  1187                
       
  1188         case EhspsServiceRequestCanceled:
       
  1189             // the request was canceled
       
  1190             UpdatehspsResult( iResultData );
       
  1191             iObserver.HandlehspsClientMessage( EhspsServiceRequestCanceled );
       
  1192             break;
       
  1193         
       
  1194         case EhspsServiceNotSupported:
       
  1195             // the request was canceled
       
  1196             UpdatehspsResult( iResultData );
       
  1197             iObserver.HandlehspsClientMessage( EhspsServiceNotSupported );
       
  1198             break;          
       
  1199 
       
  1200         default:
       
  1201             UpdatehspsResult( iResultData );
       
  1202             iObserver.HandlehspsClientMessage( EhspsServiceRequestError ); 
       
  1203         }
       
  1204     }
       
  1205 
       
  1206 // -----------------------------------------------------------------------------
       
  1207 // ChspsClient::DoCancel()
       
  1208 // Cancels any outstanding operation.
       
  1209 // (other items were commented in a header).
       
  1210 // -----------------------------------------------------------------------------
       
  1211 //
       
  1212 void ChspsClient::DoCancel()
       
  1213     {
       
  1214     iSession.CancelRequest( (TInt) iCancelRequestMessage, iResultData );   
       
  1215     }
       
  1216 
       
  1217 // -----------------------------------------------------------------------------
       
  1218 // ChspsClient::StreamOdtL()
       
  1219 // (other items were commented in a header).
       
  1220 // -----------------------------------------------------------------------------
       
  1221 //
       
  1222 TInt ChspsClient::StreamOdtL( TDes& aPath, const TInt aAppUid, ChspsODT* aOdt )
       
  1223 	{
       
  1224 	TInt errorCode = KErrNotFound;
       
  1225 	RFile odtfile;
       
  1226 	ThspsConfiguration conf;
       
  1227 	conf.rootUid = aAppUid;
       
  1228 	// conf.themeUid is not needed in AccessResourceFile()
       
  1229 	TInt fileSubSessionHandle;
       
  1230 	
       
  1231 	// get fs handle
       
  1232 	TInt fileServerHandle = iSession.AccessResourceFile( 
       
  1233 			iResultData, 
       
  1234 			conf, 
       
  1235 			aPath, 
       
  1236 			fileSubSessionHandle );
       
  1237 
       
  1238 	// If we got valid handles
       
  1239 	if ( fileServerHandle > 0 && fileSubSessionHandle > 0 )
       
  1240 	    {
       
  1241 	    // Adopt the file
       
  1242 	    errorCode = odtfile.AdoptFromServer( fileServerHandle, fileSubSessionHandle );
       
  1243 	    }
       
  1244 
       
  1245 	if ( errorCode != KErrNone )
       
  1246 	    {
       
  1247 	    // Failure	    
       
  1248 	    iResult->iSystemError = errorCode;
       
  1249 	    iResult->iXuikonError = errorCode;
       
  1250 	    }
       
  1251 	else
       
  1252 	    {
       
  1253 	    // Success
       
  1254 	    UpdatehspsResult( iResultData );
       
  1255 
       
  1256 		CleanupClosePushL( odtfile );
       
  1257 		
       
  1258 		// set stream on file
       
  1259 		CFileStore* store = CDirectFileStore::FromLC( odtfile );
       
  1260 		RStoreReadStream instream;
       
  1261 		CleanupClosePushL( instream );
       
  1262 		
       
  1263 		instream.OpenLC( *store, store->Root() );
       
  1264 		
       
  1265 		// stream in the ODT
       
  1266 		instream >> *aOdt;
       
  1267 		
       
  1268 		TInt count = aOdt->DomDocument().DomNodeCount();
       
  1269 		
       
  1270 		// Destroy the stream object and close the instream
       
  1271 		#ifdef _DEBUG			
       
  1272 		CleanupStack::PopAndDestroy( 2, &instream );
       
  1273 		
       
  1274 		// Destroy the direct file store object (closes the file) 
       
  1275 		CleanupStack::PopAndDestroy( store );
       
  1276 		CleanupStack::PopAndDestroy();  // odtfile
       
  1277 		#else	   
       
  1278 		CleanupStack::PopAndDestroy(4);
       
  1279 		#endif
       
  1280 		
       
  1281 		errorCode = KErrNone;
       
  1282 	    }
       
  1283 
       
  1284 
       
  1285 	return errorCode;
       
  1286 	}
       
  1287 
       
  1288 // End of File