widgets/widgetapp/src/cpspublisher.cpp
changeset 16 a359256acfc6
parent 8 7c90e6132015
child 37 cb62a4f66ebe
equal deleted inserted replaced
13:10e98eab6f85 16:a359256acfc6
    44 _LIT8( KDataMap, "data_map" );
    44 _LIT8( KDataMap, "data_map" );
    45 
    45 
    46 _LIT8( KItem, "item" );
    46 _LIT8( KItem, "item" );
    47 _LIT8( KAdd, "Add" );
    47 _LIT8( KAdd, "Add" );
    48 
    48 
    49 _LIT(KP,"ai3templatedwidget");
    49 _LIT(KTemplateWidget,"ai3templatedwidget");
    50 _LIT(KCT,"wideimage");
       
    51 _LIT8( KImageKey, "image1");
    50 _LIT8( KImageKey, "image1");
    52 
    51 
    53 _LIT8( KMask, "_mask");
    52 _LIT8( KMask, "_mask");
    54 
    53 
    55 _LIT(KP1,"ai3homescreen");
    54 _LIT(KHomescreenId,"ai3homescreen");
    56 _LIT(KCT1,"wideimage");
    55 _LIT(KTemplateName,"wideimage");
    57 _LIT( KImageContainer, "image_container" );
    56 _LIT( KImageContainer, "image_container" );
    58 _LIT8( KWidth, "width");
    57 _LIT8( KWidth, "width");
    59 _LIT8( KHeight, "height");
    58 _LIT8( KHeight, "height");
       
    59 
       
    60 _LIT( KPublisherInfo, "publisher" );
       
    61 _LIT( KInfoType, "network" );
       
    62 _LIT( KDisConnected, "disconnected");
       
    63 _LIT( KConnected, "connected");
       
    64 _LIT8( KAPStatus, "apstatus");
       
    65 
    60 _LIT8( KFilter, "filter" );
    66 _LIT8( KFilter, "filter" );
    61 _LIT8( KResults,      "results");
    67 _LIT8( KResults,      "results");
    62 _LIT8( KOperation, "operation" );
    68 _LIT8( KOperation, "operation" );
    63 _LIT8( KRequestNotification, "RequestNotification" );
    69 _LIT8( KRequestNotification, "RequestNotification" );
    64 _LIT( KUpdate, "update" );
    70 _LIT( KUpdate, "update" );
    65 _LIT8( KChangeInfo, "change_info" );
    71 _LIT8( KChangeInfo, "change_info" );
       
    72 _LIT( KWRTPublisher, "wrt_publisher");
       
    73 
    66 const TInt KSkinGfxInnerRectShrink = 5;
    74 const TInt KSkinGfxInnerRectShrink = 5;
    67 
    75 
    68 static void DoResetAndDestroy( TAny* aPtr )
    76 static void DoResetAndDestroy( TAny* aPtr )
    69     {
    77     {
    70     __ASSERT_DEBUG( aPtr, User::Invariant() );
    78     __ASSERT_DEBUG( aPtr, User::Invariant() );
   169 
   177 
   170 CLiwDefaultMap* ElementSizeFilterLC()
   178 CLiwDefaultMap* ElementSizeFilterLC()
   171     {
   179     {
   172     //Create filter criteria for requested entries in form of LIW map:
   180     //Create filter criteria for requested entries in form of LIW map:
   173     CLiwDefaultMap* filter = CLiwDefaultMap::NewLC();
   181     CLiwDefaultMap* filter = CLiwDefaultMap::NewLC();
   174     filter->InsertL( KPublisherId, TLiwVariant( KP1 ));
   182     filter->InsertL( KPublisherId, TLiwVariant( KHomescreenId ));
   175     filter->InsertL( KContentType, TLiwVariant( KCT1 ));
   183     filter->InsertL( KContentType, TLiwVariant( KTemplateName ));
   176     filter->InsertL( KContentId, TLiwVariant( KImageContainer ));
   184     filter->InsertL( KContentId, TLiwVariant( KImageContainer ));
   177     return filter;
   185     return filter;
   178     }
   186     }
   179 
   187 
   180 void UpdateElementSizeL( CLiwDefaultMap *outDataMap, TSize& aSize )
   188 void UpdateElementSizeL( CLiwDefaultMap *outDataMap, TSize& aSize )
   210     RDebug::Printf("CCpsPublisher::EndConstructL");
   218     RDebug::Printf("CCpsPublisher::EndConstructL");
   211     }
   219     }
   212 
   220 
   213 TSize CCpsPublisher::BitmapSize()
   221 TSize CCpsPublisher::BitmapSize()
   214     {
   222     {
   215     return iSize;
   223     if( iSize.iHeight == 0 || iSize.iWidth == 0 )
   216     }
   224         {
   217 
   225         // TODO: This is a work around to fix the problem in 'Loading Content' feature.
   218 void CCpsPublisher::PublishBitmapL( CFbsBitmap& aBitmap, const TDesC& aBundleName )
   226         // Miniview does not have size when 'Loading Content' is showing.
   219     {
   227         return TSize(312, 82 );
       
   228         }
       
   229     else
       
   230         {
       
   231         return iSize;
       
   232         }
       
   233     }
       
   234 
       
   235 void CCpsPublisher::PublishBitmapL( CFbsBitmap& aBitmap, const TDesC& aBundleId )
       
   236     {
       
   237 #ifdef _DEBUG
       
   238     TSize bitmapSize = aBitmap.SizeInPixels();
       
   239     RDebug::Printf("CCpsPublisher::PublishBitmapL bitmap width %d height %d", bitmapSize.iWidth, bitmapSize.iHeight);
       
   240 #endif
       
   241     
   220     // Load the mask bitmap from skin
   242     // Load the mask bitmap from skin
   221     if( !iMaskBitmap ||
   243     if( !iMaskBitmap ||
   222         aBitmap.SizeInPixels() != iMaskBitmap->SizeInPixels())
   244         aBitmap.SizeInPixels() != iMaskBitmap->SizeInPixels())
   223         {
   245         {
   224         RDebug::Printf("CCpsPublisher::LoadMaskBitmapL");
   246         RDebug::Printf("CCpsPublisher::LoadMaskBitmapL");
   232     TInt maskHandle = KErrBadHandle;
   254     TInt maskHandle = KErrBadHandle;
   233     if( iMaskBitmap )
   255     if( iMaskBitmap )
   234         {
   256         {
   235         maskHandle = iMaskBitmap->Handle();
   257         maskHandle = iMaskBitmap->Handle();
   236         }    
   258         }    
   237     RDebug::Printf("CCpsPublisher::PublishBitmapL");
   259 #ifdef _DEBUG
   238     AddImageHandleL( KP() ,KCT(), aBundleName,
   260     RDebug::Printf("CCpsPublisher::PublishBitmapL, bitmap handle 0x%x", handle);
       
   261 #endif
       
   262     AddImageHandleL( aBundleId,
   239             handle, maskHandle, KImageKey() );
   263             handle, maskHandle, KImageKey() );
       
   264     }
       
   265 
       
   266 void CCpsPublisher::NetworkConnectionCancelledL()
       
   267     {
       
   268     CLiwGenericParamList& inparam = iServiceHandler->InParamListL();
       
   269     CLiwGenericParamList& outparam = iServiceHandler->OutParamListL();
       
   270 
       
   271     TLiwGenericParam type( KType, TLiwVariant( KCpData ));
       
   272     type.PushL();
       
   273     inparam.AppendL( type );
       
   274     
       
   275     CLiwDefaultMap* cpdatamap = CLiwDefaultMap::NewLC();
       
   276     CLiwDefaultMap* datamap = CLiwDefaultMap::NewLC();
       
   277     
       
   278     // Create content map
       
   279     cpdatamap->InsertL( KPublisherId, TLiwVariant( KHomescreenId ));
       
   280     cpdatamap->InsertL( KContentType, TLiwVariant( KPublisherInfo )); 
       
   281     cpdatamap->InsertL( KContentId, TLiwVariant( KInfoType ));
       
   282     // Create the data map
       
   283     datamap->InsertL( KAPStatus, TLiwVariant( KDisConnected ));
       
   284     cpdatamap->InsertL( KDataMap, TLiwVariant(datamap) );
       
   285     
       
   286     TLiwGenericParam item( KItem, TLiwVariant( cpdatamap ));     
       
   287     item.PushL(); 
       
   288        
       
   289     inparam.AppendL( item );
       
   290     
       
   291     iCpsInterface->ExecuteCmdL( KAdd , inparam, outparam);
       
   292 
       
   293     CleanupStack::PopAndDestroy( &item );
       
   294     CleanupStack::PopAndDestroy( datamap );
       
   295     CleanupStack::PopAndDestroy( cpdatamap );
       
   296     CleanupStack::PopAndDestroy( &type );
       
   297 
       
   298     outparam.Reset();
       
   299     inparam.Reset();
       
   300     }
       
   301 
       
   302 void CCpsPublisher::NetworkConnectionAllowedL()
       
   303     {
       
   304     CLiwGenericParamList& inparam = iServiceHandler->InParamListL();
       
   305     CLiwGenericParamList& outparam = iServiceHandler->OutParamListL();
       
   306 
       
   307     TLiwGenericParam type( KType, TLiwVariant( KCpData ));
       
   308     type.PushL();
       
   309     inparam.AppendL( type );
       
   310     
       
   311     CLiwDefaultMap* cpdatamap = CLiwDefaultMap::NewLC();
       
   312     CLiwDefaultMap* datamap = CLiwDefaultMap::NewLC();
       
   313     
       
   314     // Create content map
       
   315     cpdatamap->InsertL( KPublisherId, TLiwVariant( KHomescreenId ));
       
   316     cpdatamap->InsertL( KContentType, TLiwVariant( KPublisherInfo )); 
       
   317     cpdatamap->InsertL( KContentId, TLiwVariant( KInfoType ));
       
   318     // Create the data map
       
   319     datamap->InsertL( KAPStatus, TLiwVariant( KConnected ));
       
   320     cpdatamap->InsertL( KDataMap, TLiwVariant(datamap) );
       
   321     
       
   322     TLiwGenericParam item( KItem, TLiwVariant( cpdatamap ));     
       
   323     item.PushL(); 
       
   324        
       
   325     inparam.AppendL( item );
       
   326     
       
   327     iCpsInterface->ExecuteCmdL( KAdd , inparam, outparam);
       
   328 
       
   329     CleanupStack::PopAndDestroy( &item );
       
   330     CleanupStack::PopAndDestroy( datamap );
       
   331     CleanupStack::PopAndDestroy( cpdatamap );
       
   332     CleanupStack::PopAndDestroy( &type );
       
   333 
       
   334     outparam.Reset();
       
   335     inparam.Reset();
   240     }
   336     }
   241 
   337 
   242 void CCpsPublisher::GetBitmapSizeL()
   338 void CCpsPublisher::GetBitmapSizeL()
   243     {
   339     {
   244     CLiwDefaultMap *outDataMap = CLiwDefaultMap::NewLC();
   340     CLiwDefaultMap *outDataMap = CLiwDefaultMap::NewLC();
   320 
   416 
   321 // ---------------------------------------------------------------------------
   417 // ---------------------------------------------------------------------------
   322 // 
   418 // 
   323 // ---------------------------------------------------------------------------
   419 // ---------------------------------------------------------------------------
   324 // 
   420 // 
   325 void CCpsPublisher::AddImageHandleL( 
   421 void CCpsPublisher::AddImageHandleL( const TDesC& aBundleId, const TInt& aHandle,
   326         const TDesC& aPublisherId, const TDesC& aContentType, 
   422         const TInt& aMaskHandle, const TDesC8& aImageKey )
   327         const TDesC& aContentId, const TInt& aHandle, const TInt& aMaskHandle,
       
   328         const TDesC8& aImageKey )
       
   329     {
   423     {
   330     __UHEAP_MARK;
   424     __UHEAP_MARK;
   331     CLiwGenericParamList& inparam = iServiceHandler->InParamListL();
   425     CLiwGenericParamList& inparam = iServiceHandler->InParamListL();
   332     CLiwGenericParamList& outparam = iServiceHandler->OutParamListL();
   426     CLiwGenericParamList& outparam = iServiceHandler->OutParamListL();
   333 
   427 
   349     maskKeyPtr.Append(KMask);
   443     maskKeyPtr.Append(KMask);
   350     map->InsertL( maskKeyPtr,  TLiwVariant( aMaskHandle ));
   444     map->InsertL( maskKeyPtr,  TLiwVariant( aMaskHandle ));
   351     CleanupStack::PopAndDestroy( maskKey );
   445     CleanupStack::PopAndDestroy( maskKey );
   352 
   446 
   353     // Create content data map
   447     // Create content data map
   354     cpdatamap->InsertL( KPublisherId, TLiwVariant( aPublisherId ));
   448     cpdatamap->InsertL( KPublisherId, TLiwVariant( KWRTPublisher ));
   355     cpdatamap->InsertL( KContentType, TLiwVariant( aContentType )); 
   449     cpdatamap->InsertL( KContentType, TLiwVariant( KTemplateWidget )); 
   356     cpdatamap->InsertL( KContentId, TLiwVariant( aContentId ));
   450     cpdatamap->InsertL( KContentId, TLiwVariant( aBundleId ));
   357     cpdatamap->InsertL( KDataMap, TLiwVariant(map) );
   451     cpdatamap->InsertL( KDataMap, TLiwVariant(map) );
   358             
   452             
   359     TLiwGenericParam item( KItem, TLiwVariant( cpdatamap ));     
   453     TLiwGenericParam item( KItem, TLiwVariant( cpdatamap ));     
   360     item.PushL(); 
   454     item.PushL(); 
   361        
   455