widgets/widgetapp/src/cpspublisher.cpp
branchRCL_3
changeset 93 79859ed3eea9
parent 92 e1bea15f9a39
child 94 919f36ff910f
equal deleted inserted replaced
92:e1bea15f9a39 93:79859ed3eea9
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #include "cpspublisher.h"
    19 #include "cpspublisher.h"
    20 
    20 
    21 #include <LiwServiceHandler.h>
    21 #include <liwservicehandler.h>
    22 #include <LiwVariant.h>
    22 #include <liwvariant.h>
    23 #include <LiwGenericParam.h>
    23 #include <liwgenericparam.h>
    24 #include <Liwcommon.h>
    24 #include <liwcommon.h>
    25 #include <liwcommon.hrh>
    25 #include <liwcommon.hrh>
    26 #include <AknsFrameBackgroundControlContext.h>
    26 #include <AknsFrameBackgroundControlContext.h>
    27 #include <fbs.h>
    27 #include <fbs.h>
    28 #include <aknsdrawutils.h> 
    28 #include <AknsDrawUtils.h> 
    29 
    29 
    30 
    30 
    31 // TODO use global definitions!
    31 // TODO use global definitions!
    32 _LIT8( KWidgetId, "widget_id");
       
    33 _LIT8( KBitmapHandle, "bitmap_handle");
       
    34 _LIT8( KDelete, "Delete" );
       
    35 _LIT( KWidgetUi, "widget_ui");
       
    36 _LIT( KScreenshot, "screenshot");
       
    37 
    32 
    38 _LIT8( KCPService, "Service.ContentPublishing" );
    33 _LIT8( KCPService, "Service.ContentPublishing" );
    39 _LIT8( KCPInterface, "IDataSource" );
    34 _LIT8( KCPInterface, "IDataSource" );
    40 
    35 
    41 _LIT8( KType, "type" );
    36 _LIT8( KType, "type" );
    75 _LIT( KUpdate, "update" );
    70 _LIT( KUpdate, "update" );
    76 _LIT8( KChangeInfo, "change_info" );
    71 _LIT8( KChangeInfo, "change_info" );
    77 _LIT( KWRTPublisher, "wrt_publisher");
    72 _LIT( KWRTPublisher, "wrt_publisher");
    78 
    73 
    79 const TInt KSkinGfxInnerRectShrink = 5;
    74 const TInt KSkinGfxInnerRectShrink = 5;
    80 const TUint KDisablePersist = 0x1000;
       
    81 
    75 
    82 static void DoResetAndDestroy( TAny* aPtr )
    76 static void DoResetAndDestroy( TAny* aPtr )
    83     {
    77     {
    84     __ASSERT_DEBUG( aPtr, User::Invariant() );
    78     __ASSERT_DEBUG( aPtr, User::Invariant() );
    85     reinterpret_cast< RCriteriaArray* >( aPtr )->ResetAndDestroy();
    79     reinterpret_cast< RCriteriaArray* >( aPtr )->ResetAndDestroy();
   459     TLiwGenericParam item( KItem, TLiwVariant( cpdatamap ));     
   453     TLiwGenericParam item( KItem, TLiwVariant( cpdatamap ));     
   460     item.PushL(); 
   454     item.PushL(); 
   461        
   455        
   462     inparam.AppendL( item );
   456     inparam.AppendL( item );
   463     
   457     
   464     iCpsInterface->ExecuteCmdL( KAdd , inparam, outparam, KDisablePersist);
   458     iCpsInterface->ExecuteCmdL( KAdd , inparam, outparam);
   465     
   459     
   466  
   460  
   467     CleanupStack::PopAndDestroy(); // item
   461     CleanupStack::PopAndDestroy(); // item
   468     CleanupStack::PopAndDestroy( map );
   462     CleanupStack::PopAndDestroy( map );
   469     CleanupStack::PopAndDestroy( cpdatamap );
   463     CleanupStack::PopAndDestroy( cpdatamap );
   560     
   554     
   561     outParam.Reset();
   555     outParam.Reset();
   562     inParam.Reset();    
   556     inParam.Reset();    
   563     iCpsInterface = msgInterface;
   557     iCpsInterface = msgInterface;
   564     }
   558     }
   565     
       
   566     
       
   567     // --------------------------------------------------------------------------
       
   568 // CCpsPublisher::PublishScreenshotL
       
   569 // --------------------------------------------------------------------------
       
   570 //
       
   571 void CCpsPublisher::PublishScreenshotL(const TDesC& aWidget,
       
   572         TInt aWidgetId, CFbsBitmap* aBmp)
       
   573     {
       
   574     StoreBitmapL(aWidgetId, aBmp);
       
   575     PublishScreenshotToCpsL(aWidget, aWidgetId, aBmp ? aBmp->Handle() : 0);
       
   576     }
       
   577 
       
   578 // --------------------------------------------------------------------------
       
   579 // CCpsPublisher::ClearScreenshotL
       
   580 // --------------------------------------------------------------------------
       
   581 //
       
   582 void CCpsPublisher::ClearScreenshotL(const TDesC& aWidget,
       
   583         TInt aWidgetId)
       
   584     {
       
   585     RemoveScreenshotFromCpsL(aWidget);
       
   586     RemoveBitmapL(aWidgetId);
       
   587     }
       
   588 
       
   589 // --------------------------------------------------------------------------
       
   590 // CCpsPublisher::ClearScreenshotL
       
   591 // --------------------------------------------------------------------------
       
   592 //
       
   593 void CCpsPublisher::StoreBitmapL(TInt aWidgetId, CFbsBitmap* aBmp)
       
   594     {
       
   595     CFbsBitmap** oldbmp = iScreenshots.Find( aWidgetId );
       
   596     if ( oldbmp )
       
   597         {
       
   598         delete *oldbmp;
       
   599         }
       
   600     if ( iScreenshots.Insert( aWidgetId, aBmp ) != KErrNone )
       
   601         {
       
   602         delete aBmp;
       
   603         iScreenshots.Remove( aWidgetId );
       
   604         }
       
   605     }
       
   606 
       
   607 // --------------------------------------------------------------------------
       
   608 // CCpsPublisher::RemoveBitmapL
       
   609 // --------------------------------------------------------------------------
       
   610 //
       
   611 void CCpsPublisher::RemoveBitmapL(TInt aWidgetId)
       
   612     {
       
   613     CFbsBitmap** bmp = iScreenshots.Find( aWidgetId );
       
   614     if ( bmp )
       
   615         {
       
   616         delete *bmp;
       
   617         iScreenshots.Remove( aWidgetId );
       
   618         }
       
   619     }
       
   620 
       
   621 // --------------------------------------------------------------------------
       
   622 // CCpsPublisher::PublishScreenshotToCpsL
       
   623 // --------------------------------------------------------------------------
       
   624 //
       
   625 void CCpsPublisher::PublishScreenshotToCpsL(const TDesC& aWidget,
       
   626         TInt aWidgetId, TInt aBitmap)
       
   627     {
       
   628     CLiwGenericParamList& inparam = iServiceHandler->InParamListL();
       
   629     CLiwGenericParamList& outparam = iServiceHandler->OutParamListL();
       
   630 
       
   631     TLiwGenericParam cptype( KType, TLiwVariant( KCpData ));
       
   632     cptype.PushL();
       
   633     
       
   634     inparam.AppendL( cptype );
       
   635     
       
   636     CLiwDefaultMap* cpdatamap = CLiwDefaultMap::NewLC();
       
   637     CLiwDefaultMap* map = CLiwDefaultMap::NewLC();
       
   638     
       
   639     // Add bitmap handle to data map
       
   640     map->InsertL( KWidgetId,  TLiwVariant( TInt32(aWidgetId) )); // key - aKey, value - map (stringsMap)
       
   641     map->InsertL( KBitmapHandle,  TLiwVariant( TInt32(aBitmap) )); // key - aKey, value - map (stringsMap)
       
   642 
       
   643     // Create content data map
       
   644     cpdatamap->InsertL( KPublisherId, TLiwVariant( KWidgetUi ));
       
   645     cpdatamap->InsertL( KContentType, TLiwVariant( KScreenshot )); 
       
   646     cpdatamap->InsertL( KContentId, TLiwVariant( aWidget ));
       
   647     cpdatamap->InsertL( KDataMap, TLiwVariant(map) );
       
   648             
       
   649     TLiwGenericParam item( KItem, TLiwVariant( cpdatamap ));     
       
   650     item.PushL(); 
       
   651        
       
   652     inparam.AppendL( item );
       
   653     
       
   654     iCpsInterface->ExecuteCmdL( KAdd , inparam, outparam);
       
   655  
       
   656     CleanupStack::PopAndDestroy( &item );
       
   657     CleanupStack::PopAndDestroy( map );
       
   658     CleanupStack::PopAndDestroy( cpdatamap );
       
   659     CleanupStack::PopAndDestroy( &cptype );
       
   660 
       
   661     outparam.Reset();
       
   662     inparam.Reset();
       
   663     }
       
   664 
       
   665 
       
   666 // --------------------------------------------------------------------------
       
   667 // CCpsPublisher::PublishScreenshotToCpsL
       
   668 // --------------------------------------------------------------------------
       
   669 //
       
   670 void CCpsPublisher::RemoveScreenshotFromCpsL(const TDesC& aWidget)
       
   671     {
       
   672     CLiwGenericParamList& inparam = iServiceHandler->InParamListL();
       
   673     CLiwGenericParamList& outparam = iServiceHandler->OutParamListL();
       
   674     
       
   675     TLiwGenericParam cptype( KType, TLiwVariant( KCpData ));
       
   676     cptype.PushL();
       
   677 
       
   678     inparam.AppendL( cptype );
       
   679 
       
   680     CLiwDefaultMap* cpdatamap = CLiwDefaultMap::NewLC();
       
   681     
       
   682     // Create content data map
       
   683     cpdatamap->InsertL( KPublisherId, TLiwVariant( KWidgetUi ));
       
   684     cpdatamap->InsertL( KContentType, TLiwVariant( KScreenshot )); 
       
   685     cpdatamap->InsertL( KContentId, TLiwVariant( aWidget ));
       
   686             
       
   687     TLiwGenericParam item( KItem, TLiwVariant( cpdatamap ));     
       
   688     item.PushL(); 
       
   689        
       
   690     inparam.AppendL( item );
       
   691     
       
   692     iCpsInterface->ExecuteCmdL( KDelete , inparam, outparam);
       
   693  
       
   694     CleanupStack::PopAndDestroy( &item );
       
   695     CleanupStack::PopAndDestroy( cpdatamap );
       
   696     CleanupStack::PopAndDestroy( &cptype );
       
   697 
       
   698     outparam.Reset();
       
   699     inparam.Reset();
       
   700     }
       
   701 
       
   702 // END OF FILE
   559 // END OF FILE
   703 
   560 
   704 
   561 
   705 
   562