idlehomescreen/xmluicontroller/src/contentpublisher.cpp
branchRCL_3
changeset 9 f966699dea19
parent 1 5315654608de
equal deleted inserted replaced
5:c743ef5928ba 9:f966699dea19
    14 * Description:  Content Publishing Service interface.
    14 * Description:  Content Publishing Service interface.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include "contentpublisher.h"
    18 #include "contentpublisher.h"
    19 #include "globalqueryhandler.h"
       
    20 
    19 
    21 #include <liwservicehandler.h>
    20 #include <liwservicehandler.h>
    22 #include <liwvariant.h>
    21 #include <liwvariant.h>
    23 #include <liwgenericparam.h>
    22 #include <liwgenericparam.h>
    24 #include <AknQueryDialog.h>
       
    25 #include <ai3xmlui.rsg>
       
    26 #include "xmluicontroller.h"
    23 #include "xmluicontroller.h"
    27 #include <AknGlobalConfirmationQuery.h>
    24 #include "appui.h"
    28 #include <StringLoader.h> // StringLoader
    25 #include "onlineofflinehelper.h"
    29 
    26 
    30 using namespace AiXmlUiController;
    27 using namespace AiXmlUiController;
    31 
    28 
    32 _LIT8( KCPService, "Service.ContentPublishing" );
    29 _LIT8( KCPService, "Service.ContentPublishing" );
    33 _LIT8( KCPInterface, "IDataSource" );
    30 _LIT8( KCPInterface, "IDataSource" );
    43 _LIT(KAI3HSPublisher,"ai3homescreen");
    40 _LIT(KAI3HSPublisher,"ai3homescreen");
    44 _LIT(KContentType,"wideimage");
    41 _LIT(KContentType,"wideimage");
    45 
    42 
    46 _LIT8( KAPStatus, "apstatus");
    43 _LIT8( KAPStatus, "apstatus");
    47 _LIT(KNetwork, "network");
    44 _LIT(KNetwork, "network");
    48 
       
    49 _LIT( KDisConnected, "disconnected");
       
    50 _LIT( KConnected, "connected");
       
    51 
    45 
    52 _LIT(KPublisher16, "publisher");
    46 _LIT(KPublisher16, "publisher");
    53 
    47 
    54 
    48 
    55 _LIT8( KRequestNotification, "RequestNotification" );
    49 _LIT8( KRequestNotification, "RequestNotification" );
    60 _LIT8( KGetList, "GetList" );
    54 _LIT8( KGetList, "GetList" );
    61 _LIT8( KFilter,        "filter" );
    55 _LIT8( KFilter,        "filter" );
    62 _LIT8( KWidth, "width");
    56 _LIT8( KWidth, "width");
    63 _LIT8( KHeight, "height");
    57 _LIT8( KHeight, "height");
    64 _LIT8( KChangeInfo,    "change_info" );
    58 _LIT8( KChangeInfo,    "change_info" );
       
    59 
    65 // ============================ LOCAL FUNCTIONS ===============================
    60 // ============================ LOCAL FUNCTIONS ===============================
    66 
    61 
    67 
    62 
    68 static void DoResetAndDestroy( TAny* aPtr )
    63 static void DoResetAndDestroy( TAny* aPtr )
    69     {
    64     {
   103         {
    98         {
   104         iServiceHandler->Reset();
    99         iServiceHandler->Reset();
   105         delete iServiceHandler;
   100         delete iServiceHandler;
   106         iServiceHandler = NULL;
   101         iServiceHandler = NULL;
   107         }
   102         }
   108     delete iGlobalQueryHandler;
       
   109     delete iGlobalConfirmationQuery;    
       
   110     }
   103     }
   111 
   104 
   112 // -----------------------------------------------------------------------------
   105 // -----------------------------------------------------------------------------
   113 // C++ default constructor. Must not leave.
   106 // C++ default constructor. Must not leave.
   114 // -----------------------------------------------------------------------------
   107 // -----------------------------------------------------------------------------
   123 //
   116 //
   124 void CContentPublisher::ConstructL()
   117 void CContentPublisher::ConstructL()
   125     {
   118     {
   126     InitCpsInterfaceL();
   119     InitCpsInterfaceL();
   127     RegisterListenerL();
   120     RegisterListenerL();
   128     iGlobalQueryHandler = CGlobalQueryHandler::NewL(iUiController);
       
   129     iGlobalConfirmationQuery = CAknGlobalConfirmationQuery::NewL();
       
   130     
       
   131     }
   121     }
   132 
   122 
   133 // -----------------------------------------------------------------------------
   123 // -----------------------------------------------------------------------------
   134 // Publishes a given width and height to Content Publishing Service
   124 // Publishes a given width and height to Content Publishing Service
   135 // -----------------------------------------------------------------------------
   125 // -----------------------------------------------------------------------------
   385     }
   375     }
   386    return aErrorCode;
   376    return aErrorCode;
   387    }
   377    }
   388 
   378 
   389 void CContentPublisher::HandlePublisherInfoL( const TDesC& aPubInfo)
   379 void CContentPublisher::HandlePublisherInfoL( const TDesC& aPubInfo)
   390 	{
   380     {
   391 	//Currently HS will handle only network status update form publisher
   381     //Currently HS will handle only network status update form publisher
   392 	if ( aPubInfo == KNetwork )
   382     if ( aPubInfo == KNetwork )
   393 		{
   383         {
   394 		CLiwDefaultMap *outDataMap = CLiwDefaultMap::NewLC();
   384         _LIT( KOffline, "hs_offline" );
   395 		GetDataL( KAI3HSPublisher(), KPublisher16, KNetwork(), outDataMap );
   385         CLiwDefaultMap *outDataMap = CLiwDefaultMap::NewLC();
   396 		TLiwVariant variant;
   386         GetDataL( KAI3HSPublisher(), KPublisher16, KNetwork(), outDataMap );
   397 		variant.PushL();
   387         TLiwVariant variant;
   398 		if ( outDataMap->FindL(KAPStatus, variant))
   388         variant.PushL();
   399 			{
   389         if ( outDataMap->FindL(KAPStatus, variant))
   400 			HBufC16* netStatus = variant.AsDes().AllocLC();
   390             {
   401             if ( netStatus->Des() == KDisConnected() )
   391             iUiController.AppUi()->Helper()->HandleConnectionQueryL(variant.AsDes());
   402                 {
   392             }
   403                 ShowGlobalQueryL(R_QTN_HS_DISABLE_NETWORK, EFalse );
   393         CleanupStack::PopAndDestroy( &variant );
   404                 }
   394         CleanupStack::PopAndDestroy(outDataMap);
   405             else if ( netStatus->Des() == KConnected() )
       
   406                 {
       
   407                 ShowGlobalQueryL(R_QTN_HS_SWITCH_ONLINE, ETrue );
       
   408                 }
       
   409 			CleanupStack::PopAndDestroy( netStatus );
       
   410 			}
       
   411 		CleanupStack::PopAndDestroy( &variant );
       
   412 		CleanupStack::PopAndDestroy(outDataMap);
       
   413 		}
       
   414     }
       
   415 
       
   416 
       
   417 void CContentPublisher::ShowGlobalQueryL( TInt aResourceId, TBool aSetOnline )
       
   418     {
       
   419     if ( !iGlobalQueryHandler->IsActive() )
       
   420         {
       
   421         HBufC* confirmationText = StringLoader::LoadLC(aResourceId);
       
   422         iGlobalConfirmationQuery->ShowConfirmationQueryL(
       
   423                 iGlobalQueryHandler->iStatus,
       
   424             *confirmationText, 
       
   425             R_AVKON_SOFTKEYS_YES_NO);
       
   426         iGlobalQueryHandler->SetOnlineParamAndActivate(aSetOnline);
       
   427         CleanupStack::PopAndDestroy(); //confirmationText
       
   428         }
   395         }
   429     }
   396     }
   430 // END OF FILE
   397 // END OF FILE