idlefw/plugins/wrtdataplugin/src/wrtdata.cpp
branchRCL_3
changeset 15 a0713522ab97
parent 8 d0529222e3f0
child 16 b276298d5729
equal deleted inserted replaced
14:15e4dd19031c 15:a0713522ab97
    22 #include <liwservicehandler.h>
    22 #include <liwservicehandler.h>
    23 #include <aipluginsettings.h>
    23 #include <aipluginsettings.h>
    24 #include <apgcli.h>
    24 #include <apgcli.h>
    25 #include <apgicnfl.h> 
    25 #include <apgicnfl.h> 
    26 #include <bautils.h> 
    26 #include <bautils.h> 
       
    27 #include <aicpscommandbuffer.h>
    27 
    28 
    28 #include "wrtdata.h"
    29 #include "wrtdata.h"
    29 #include "wrtdatapluginconst.h"
    30 #include "wrtdatapluginconst.h"
    30 #include "wrtdataobserver.h"
    31 #include "wrtdataobserver.h"
    31 #include "wrtdataplugin.h"
    32 #include "wrtdataplugin.h"
    75     	delete iCommandName;
    76     	delete iCommandName;
    76     	iCommandName = NULL;
    77     	iCommandName = NULL;
    77     	}
    78     	}
    78     if(iObserver)
    79     if(iObserver)
    79         {
    80         {
    80         TRAP_IGNORE(iObserver->ReleaseL() );
       
    81         delete iObserver;
    81         delete iObserver;
    82         iObserver = NULL;
    82         iObserver = NULL;
    83         }
    83         }
    84     if( iInterface )
    84     if( iInterface )
    85          {
    85          {
       
    86          // This will also release all the registered observers
    86          iInterface->Close();
    87          iInterface->Close();
    87          iInterface = NULL;
    88          iInterface = NULL;
    88          }
    89          }
    89     if( iServiceHandler )
    90     if( iServiceHandler )
    90          {
    91          {
    98     	iContentId = NULL;
    99     	iContentId = NULL;
    99     	}
   100     	}
   100     iMenuItems.ResetAndDestroy();
   101     iMenuItems.ResetAndDestroy();
   101     iMenuTriggers.ResetAndDestroy();
   102     iMenuTriggers.ResetAndDestroy();
   102     // not owned
   103     // not owned
       
   104     iCpsExecute = NULL;
   103     iPlugin = NULL;
   105     iPlugin = NULL;
   104     }
   106     }
   105 
   107 
   106 // ---------------------------------------------------------------------------
   108 // ---------------------------------------------------------------------------
   107 // CWrtData::ConfigureL
   109 // CWrtData::ConfigureL
   230 // ---------------------------------------------------------------------------
   232 // ---------------------------------------------------------------------------
   231 //
   233 //
   232 void CWrtData::UpdatePublisherStatusL()
   234 void CWrtData::UpdatePublisherStatusL()
   233     {
   235     {
   234      // Resent the plugin status to publisher
   236      // Resent the plugin status to publisher
   235      ActivateL();
   237     CLiwDefaultList* actions= CLiwDefaultList::NewLC();
       
   238     actions->AppendL( TLiwVariant( KActive ));
   236      if ( iPlugin->IsActive() )
   239      if ( iPlugin->IsActive() )
   237          {
   240          {
   238          ResumeL();
   241          actions->AppendL( TLiwVariant( KResume ) );
   239          }
   242          }
   240      else
   243      else
   241          {
   244          {
   242          SuspendL();
   245          actions->AppendL( TLiwVariant( KSuspend ));
   243          }
   246          }
   244       // forward the network status if it uses.
   247       // forward the network status if it uses.
   245     if ( iPlugin->NetworkStatus() == CWrtDataPlugin::EOnline )
   248     if ( iPlugin->NetworkStatus() == CWrtDataPlugin::EOnline )
   246         {
   249         {
   247         OnLineL();
   250         actions->AppendL( TLiwVariant( KOnLine ));
   248         }
   251         }
   249     else if ( iPlugin->NetworkStatus() == CWrtDataPlugin::EOffline )
   252     else if ( iPlugin->NetworkStatus() == CWrtDataPlugin::EOffline )
   250         {
   253         {
   251         OffLineL();
   254         actions->AppendL( TLiwVariant(  KOffLine));
   252         }
   255         }
       
   256 
       
   257     ReSendNotificationL( actions );
       
   258     CleanupStack::PopAndDestroy( actions );
   253     }
   259     }
   254 
   260 
   255 // ---------------------------------------------------------------------------
   261 // ---------------------------------------------------------------------------
   256 // CWrtData::PublishDefaultImageL
   262 // CWrtData::PublishDefaultImageL
   257 // ---------------------------------------------------------------------------
   263 // ---------------------------------------------------------------------------
   452     {
   458     {
   453     return iPlugin->IsActive();
   459     return iPlugin->IsActive();
   454     }
   460     }
   455 
   461 
   456 // ---------------------------------------------------------------------------
   462 // ---------------------------------------------------------------------------
   457 // CWrtData::ActivateL
       
   458 // ---------------------------------------------------------------------------
       
   459 //
       
   460 void CWrtData::ActivateL()
       
   461     {
       
   462     ChangePublisherStatusL( KActive );
       
   463     }
       
   464 
       
   465 // ---------------------------------------------------------------------------
       
   466 // CWrtData::ResumeL
       
   467 // ---------------------------------------------------------------------------
       
   468 //
       
   469 void CWrtData::ResumeL()
       
   470     {
       
   471     ChangePublisherStatusL( KResume );
       
   472     }
       
   473 
       
   474 // ---------------------------------------------------------------------------
       
   475 // CWrtData::SuspendL
       
   476 // ---------------------------------------------------------------------------
       
   477 //
       
   478 void CWrtData::SuspendL()
       
   479     {
       
   480     ChangePublisherStatusL( KSuspend );
       
   481     }
       
   482 
       
   483 // ---------------------------------------------------------------------------
       
   484 // CWrtData::DeActivateL
       
   485 // ---------------------------------------------------------------------------
       
   486 //
       
   487 void CWrtData::DeActivateL()
       
   488     {
       
   489     ChangePublisherStatusL( KDeActive );
       
   490     }
       
   491 
       
   492 // ---------------------------------------------------------------------------
       
   493 // CWrtData::OnLineL
       
   494 // ---------------------------------------------------------------------------
       
   495 //
       
   496 void CWrtData::OnLineL()
       
   497     {
       
   498     ChangePublisherStatusL( KOnLine );
       
   499     }
       
   500 
       
   501 // ---------------------------------------------------------------------------
       
   502 // CWrtData::offLineL
       
   503 // ---------------------------------------------------------------------------
       
   504 //
       
   505 void CWrtData::OffLineL()
       
   506     {
       
   507     ChangePublisherStatusL( KOffLine );
       
   508     }
       
   509 
       
   510 // ---------------------------------------------------------------------------
       
   511 // CWrtData::CreateFilterL
   463 // CWrtData::CreateFilterL
   512 // ---------------------------------------------------------------------------
   464 // ---------------------------------------------------------------------------
   513 //
   465 //
   514 CLiwDefaultMap* CWrtData::CreateFilterLC()
   466 CLiwDefaultMap* CWrtData::CreateFilterLC()
   515     {
   467     {
   577         }
   529         }
   578     outParamList->Reset();
   530     outParamList->Reset();
   579     }
   531     }
   580 
   532 
   581 // ---------------------------------------------------------------------------
   533 // ---------------------------------------------------------------------------
   582 // CWrtData::PublisherStatusL
   534 // NotifyPublisherL
   583 // ---------------------------------------------------------------------------
   535 // ---------------------------------------------------------------------------
   584 //
   536 //
   585 void CWrtData::ChangePublisherStatusL(const TDesC& aStatus)
   537 void CWrtData::NotifyPublisherL(const TDesC8& aStatus)
   586     {
   538     {
   587     if( iContentId == NULL )
   539     if( iCpsExecute == NULL )
   588        {
   540         {
   589        return;
   541         User::Leave( KErrNotSupported );
   590        }
   542         }
   591    HBufC8* triggerName = HBufC8::NewLC(KWRTContentNameMaxLength);
   543     
   592    triggerName->Des().Copy(aStatus);
   544     CLiwDefaultMap* filter = CreateFilterLC();
   593    
   545     // Add execute command triggers. Idle framework will execute 
   594    CLiwGenericParamList* inParamList  = &iServiceHandler->InParamListL();
   546     iCpsExecute->AddCommand( iPluginId, KPubData, filter, aStatus );
   595    CLiwGenericParamList* outParamList = &iServiceHandler->OutParamListL();
   547     CleanupStack::PopAndDestroy( filter );
   596        
   548     }
   597    TLiwGenericParam type( KType, TLiwVariant( KPubData ) );
       
   598    inParamList->AppendL( type );
       
   599               
       
   600    CLiwDefaultMap* filter = CreateFilterLC();
       
   601    filter->InsertL(KActionTrigger, TLiwVariant(triggerName->Des()) );
       
   602    
       
   603    TLiwGenericParam item( KFilter, TLiwVariant( filter ));
       
   604    inParamList->AppendL( item );
       
   605    
       
   606    if(iInterface)
       
   607        {
       
   608        iInterface->ExecuteCmdL( KExecuteAction, *inParamList, *outParamList);
       
   609        }
       
   610    else
       
   611        {
       
   612        User::Leave( KErrNotSupported );
       
   613        }
       
   614    CleanupStack::PopAndDestroy( filter );
       
   615    
       
   616    inParamList->Reset();
       
   617    outParamList->Reset();
       
   618    CleanupStack::PopAndDestroy( triggerName );
       
   619    }
       
   620 
   549 
   621 // ---------------------------------------------------------------------------
   550 // ---------------------------------------------------------------------------
   622 // CWrtData::GetMenuItemsL
   551 // CWrtData::GetMenuItemsL
   623 // ---------------------------------------------------------------------------
   552 // ---------------------------------------------------------------------------
   624 //
   553 //
   784         }
   713         }
   785     CleanupStack::PopAndDestroy( sizeArray );
   714     CleanupStack::PopAndDestroy( sizeArray );
   786     CleanupStack::PopAndDestroy( &lsSession );
   715     CleanupStack::PopAndDestroy( &lsSession );
   787     }
   716     }
   788 
   717 
       
   718 
       
   719 // ---------------------------------------------------------------------------
       
   720 // ReSendNotificationL
       
   721 // ---------------------------------------------------------------------------
       
   722 //
       
   723 void CWrtData::ReSendNotificationL(CLiwDefaultList* aActionsList)
       
   724     {
       
   725     if( iInterface == NULL )
       
   726         {
       
   727         User::Leave( KErrNotSupported );
       
   728         }
       
   729     
       
   730     CLiwGenericParamList* inParamList  = &iServiceHandler->InParamListL();
       
   731     CLiwGenericParamList* outParamList = &iServiceHandler->OutParamListL();
       
   732 
       
   733     TLiwGenericParam type( KType, TLiwVariant( KPubData ) );
       
   734     inParamList->AppendL( type );
       
   735      
       
   736     CLiwDefaultMap* filter = CreateFilterLC();
       
   737     // add list of action triggers to execute
       
   738     filter->InsertL(KActionTrigger, TLiwVariant(aActionsList) );
       
   739     
       
   740     TLiwGenericParam item( KFilter, TLiwVariant( filter ));
       
   741     inParamList->AppendL( item );
       
   742     iInterface->ExecuteCmdL( KExecuteAction, *inParamList, *outParamList);
       
   743     CleanupStack::PopAndDestroy( filter );
       
   744     outParamList->Reset();
       
   745     inParamList->Reset();
       
   746 
       
   747     }
       
   748 
       
   749 // ---------------------------------------------------------------------------
       
   750 // SetCommandBuffer
       
   751 // ---------------------------------------------------------------------------
       
   752 //
       
   753 void CWrtData::SetCommandBuffer(TAny* aAny, const TDesC8& aNameSpace )
       
   754     {
       
   755     iPluginId.Copy(aNameSpace);
       
   756     iCpsExecute = reinterpret_cast <MAiCpsCommandBuffer* > ( aAny );
       
   757     }
       
   758 
       
   759 // End of file
       
   760