idlefw/plugins/sapidataplugin/src/sapidata.cpp
branchRCL_3
changeset 8 d0529222e3f0
parent 4 1a2a00e78665
child 11 bd874ee5e5e2
equal deleted inserted replaced
4:1a2a00e78665 8:d0529222e3f0
     1 /*
     1 /*
     2 * Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    13 *
    13 *
    14 * Description:  Homescreen Data plug-in publisher
    14 * Description:  Homescreen Data plug-in publisher
    15 *
    15 *
    16 */
    16 */
    17 
    17 
       
    18 // System includes
    18 #include <ecom/ecom.h>
    19 #include <ecom/ecom.h>
    19 #include <liwservicehandler.h>
    20 #include <liwservicehandler.h>
    20 #include <aipluginsettings.h>
    21 #include <aipluginsettings.h>
    21 #include <utf.h>
    22 #include <utf.h>
    22 
    23 
       
    24 // User includes
    23 #include "sapidata.h"
    25 #include "sapidata.h"
    24 #include "sapidatapluginconst.h"
    26 #include "sapidatapluginconst.h"
    25 #include "sapidataobserver.h"
    27 #include "sapidataobserver.h"
    26 #include "sapidataplugin.h"
    28 #include "sapidataplugin.h"
       
    29 
    27 // ======== MEMBER FUNCTIONS ========
    30 // ======== MEMBER FUNCTIONS ========
    28 	
    31 	
    29 // ---------------------------------------------------------------------------
    32 // ---------------------------------------------------------------------------
    30 // Symbian 2nd phase constructor can leave
    33 // Symbian 2nd phase constructor can leave
    31 // ---------------------------------------------------------------------------
    34 // ---------------------------------------------------------------------------
   114     {
   117     {
   115     delete iCommandName;
   118     delete iCommandName;
   116 	delete iPublisher;
   119 	delete iPublisher;
   117 	delete iContentType;
   120 	delete iContentType;
   118 	delete iContentId;
   121 	delete iContentId;
   119 
   122 	delete iStartupReason;
   120 	
   123 	
   121 	if(iPubObserver)
   124 	if(iPubObserver)
   122 		{
   125 		{
   123 		TRAP_IGNORE(iPubObserver->ReleaseL() );
   126 		TRAP_IGNORE(iPubObserver->ReleaseL() );
   124 		delete iPubObserver;
   127 		delete iPubObserver;
   247  
   250  
   248     iContentObserver = CSapiDataObserver::NewL( iInterface, this );   
   251     iContentObserver = CSapiDataObserver::NewL( iInterface, this );   
   249     iPubObserver = CSapiDataObserver::NewL( iInterface, this );
   252     iPubObserver = CSapiDataObserver::NewL( iInterface, this );
   250     }
   253     }
   251 
   254 
       
   255 // ---------------------------------------------------------------------------
       
   256 // SetContentIdL
       
   257 // ---------------------------------------------------------------------------
       
   258 //
   252 void CSapiData::SetContentIdL(const TDesC8& aId)
   259 void CSapiData::SetContentIdL(const TDesC8& aId)
   253 	{
   260 	{
   254 	iContentId = CnvUtfConverter::ConvertToUnicodeFromUtf8L(aId);
   261 	iContentId = CnvUtfConverter::ConvertToUnicodeFromUtf8L(aId);
   255 	}
   262 	}
       
   263 
       
   264 // ---------------------------------------------------------------------------
       
   265 // SetStartupReasonL
       
   266 // ---------------------------------------------------------------------------
       
   267 //
       
   268 void CSapiData::SetStartupReasonL(const TDesC& aStartupReason)
       
   269     {
       
   270     delete iStartupReason;
       
   271     iStartupReason = NULL;
       
   272     iStartupReason = aStartupReason.AllocL();
       
   273     ChangePublisherStatusL( aStartupReason );
       
   274     }
       
   275 
   256 // ---------------------------------------------------------------------------
   276 // ---------------------------------------------------------------------------
   257 // GetMenuItemsL
   277 // GetMenuItemsL
   258 // ---------------------------------------------------------------------------
   278 // ---------------------------------------------------------------------------
   259 //
   279 //
   260 void CSapiData::GetMenuItemsL()
   280 void CSapiData::GetMenuItemsL()
   700 // PublisherStatusL
   720 // PublisherStatusL
   701 // ---------------------------------------------------------------------------
   721 // ---------------------------------------------------------------------------
   702 //
   722 //
   703 void CSapiData::ChangePublisherStatusL(const TDesC& aStatus)
   723 void CSapiData::ChangePublisherStatusL(const TDesC& aStatus)
   704     {
   724     {
       
   725     if ( aStatus == KResume && iUpdateNeeded )
       
   726         {
       
   727         iPlugin->PublishL();
       
   728         iUpdateNeeded = EFalse;
       
   729         }
       
   730     
   705     CLiwGenericParamList* inParamList  = &iServiceHandler->InParamListL();
   731     CLiwGenericParamList* inParamList  = &iServiceHandler->InParamListL();
   706     CLiwGenericParamList* outParamList = &iServiceHandler->OutParamListL();
   732     CLiwGenericParamList* outParamList = &iServiceHandler->OutParamListL();
   707     HBufC8* triggerName = CnvUtfConverter::ConvertFromUnicodeToUtf8L(aStatus);
   733     HBufC8* triggerName = CnvUtfConverter::ConvertFromUnicodeToUtf8L(aStatus);
   708     CleanupStack::PushL( triggerName );
   734     CleanupStack::PushL( triggerName );
   709 
   735 
   730     inParamList->Reset();
   756     inParamList->Reset();
   731     outParamList->Reset();
   757     outParamList->Reset();
   732    }
   758    }
   733 
   759 
   734 // ---------------------------------------------------------------------------
   760 // ---------------------------------------------------------------------------
   735 // ResumeL
       
   736 // ---------------------------------------------------------------------------
       
   737 //
       
   738 void CSapiData::ResumeL()
       
   739     {
       
   740     if ( iUpdateNeeded )
       
   741      	{
       
   742      	iPlugin->PublishL();
       
   743      	iUpdateNeeded = EFalse;
       
   744      	}
       
   745     ChangePublisherStatusL( KResume );
       
   746     }
       
   747 
       
   748 // ---------------------------------------------------------------------------
       
   749 // SuspendL
       
   750 // ---------------------------------------------------------------------------
       
   751 //
       
   752 void CSapiData::SuspendL()
       
   753     {
       
   754     ChangePublisherStatusL( KSuspend );
       
   755     }
       
   756 
       
   757 // ---------------------------------------------------------------------------
       
   758 // ActivateL
       
   759 // ---------------------------------------------------------------------------
       
   760 //
       
   761 void CSapiData::ActivateL()
       
   762     {
       
   763     ChangePublisherStatusL( KActive );
       
   764     }
       
   765 
       
   766 // ---------------------------------------------------------------------------
       
   767 // DeActivateL
       
   768 // ---------------------------------------------------------------------------
       
   769 //
       
   770 void CSapiData::DeActivateL()
       
   771     {
       
   772     ChangePublisherStatusL( KDeActive );
       
   773     }
       
   774 
       
   775 // ---------------------------------------------------------------------------
       
   776 // OnLineL
       
   777 // ---------------------------------------------------------------------------
       
   778 //
       
   779 void CSapiData::OnLineL()
       
   780     {
       
   781     ChangePublisherStatusL( KOnLine );
       
   782     }
       
   783 
       
   784 // ---------------------------------------------------------------------------
       
   785 // offLineL
       
   786 // ---------------------------------------------------------------------------
       
   787 //
       
   788 void CSapiData::OffLineL()
       
   789     {
       
   790     ChangePublisherStatusL( KOffLine );
       
   791     }
       
   792 
       
   793 // ---------------------------------------------------------------------------
       
   794 // InActiveL
       
   795 // ---------------------------------------------------------------------------
       
   796 //
       
   797 void CSapiData::InActiveL()
       
   798     {
       
   799     ChangePublisherStatusL( KInActive );
       
   800     }
       
   801 
       
   802 // ---------------------------------------------------------------------------
       
   803 // UpdatePublisherStatusL
   761 // UpdatePublisherStatusL
   804 // ---------------------------------------------------------------------------
   762 // ---------------------------------------------------------------------------
   805 //
   763 //
   806 void CSapiData::UpdatePublisherStatusL( TDesC& aPublisher )
   764 void CSapiData::UpdatePublisherStatusL( TDesC& aPublisher )
   807 	{
   765 	{
   808 	 if ( aPublisher == iPublisher )
   766 	 if ( aPublisher == iPublisher )
   809 		 {
   767 		 {
   810 		 // Resend the plugin status to publisher
   768 		 // Resend the plugin status to publisher
   811 		 ActivateL();
   769          ChangePublisherStatusL( KActive );
       
   770          if( iStartupReason->Length() != 0 )
       
   771              {
       
   772              ChangePublisherStatusL( *iStartupReason );
       
   773              }
       
   774          
   812 		 if ( iPlugin->IsActive() )
   775 		 if ( iPlugin->IsActive() )
   813 			 {
   776 			 {
   814 			 ResumeL();
   777              ChangePublisherStatusL( KResume );
   815 			 }
   778 			 }
   816 		 else
   779 		 else
   817 			 {
   780 			 {
   818 			 SuspendL();
   781              ChangePublisherStatusL( KSuspend );
   819 			 }
   782 			 }
   820 		  // forward the network status if it uses.
   783 		  // forward the network status if it uses.
   821 		if ( iPlugin->NetworkStatus() == CSapiDataPlugin::EOnline )
   784 		if ( iPlugin->NetworkStatus() == CSapiDataPlugin::EOnline )
   822 			{
   785 			{
   823 			OnLineL();
   786             ChangePublisherStatusL( KOnLine );
   824 			}
   787 			}
   825 		else if ( iPlugin->NetworkStatus() == CSapiDataPlugin::EOffline )
   788 		else if ( iPlugin->NetworkStatus() == CSapiDataPlugin::EOffline )
   826 			{
   789 			{
   827 			OffLineL();
   790             ChangePublisherStatusL( KOffLine );
   828 			}
   791 			}
   829 		 }
   792 		 }
   830 	}
   793 	}
   831 
   794 
   832 // ---------------------------------------------------------------------------
   795 // ---------------------------------------------------------------------------