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 _LIT( KWidgetBitmap, "widget_bitmap" ); |
|
33 _LIT8( KWidgetId, "widget_id"); |
|
34 _LIT8( KBitmapHandle, "bitmap_handle"); |
|
35 _LIT8( KDelete, "Delete" ); |
|
36 _LIT( KWidgetUi, "widget_ui"); |
|
37 _LIT( KScreenshot, "screenshot"); |
32 |
38 |
33 _LIT8( KCPService, "Service.ContentPublishing" ); |
39 _LIT8( KCPService, "Service.ContentPublishing" ); |
34 _LIT8( KCPInterface, "IDataSource" ); |
40 _LIT8( KCPInterface, "IDataSource" ); |
35 |
41 |
36 _LIT8( KType, "type" ); |
42 _LIT8( KType, "type" ); |
555 |
561 |
556 outParam.Reset(); |
562 outParam.Reset(); |
557 inParam.Reset(); |
563 inParam.Reset(); |
558 iCpsInterface = msgInterface; |
564 iCpsInterface = msgInterface; |
559 } |
565 } |
|
566 |
|
567 |
|
568 // -------------------------------------------------------------------------- |
|
569 // CCpsPublisher::PublishScreenshotL |
|
570 // -------------------------------------------------------------------------- |
|
571 // |
|
572 void CCpsPublisher::PublishScreenshotL(const TDesC& aWidget, |
|
573 TInt aWidgetId, CFbsBitmap* aBmp) |
|
574 { |
|
575 StoreBitmapL(aWidgetId, aBmp); |
|
576 PublishScreenshotToCpsL(aWidget, aWidgetId, aBmp ? aBmp->Handle() : 0); |
|
577 } |
|
578 |
|
579 // -------------------------------------------------------------------------- |
|
580 // CCpsPublisher::ClearScreenshotL |
|
581 // -------------------------------------------------------------------------- |
|
582 // |
|
583 void CCpsPublisher::ClearScreenshotL(const TDesC& aWidget, |
|
584 TInt aWidgetId) |
|
585 { |
|
586 RemoveScreenshotFromCpsL(aWidget); |
|
587 RemoveBitmapL(aWidgetId); |
|
588 } |
|
589 |
|
590 // -------------------------------------------------------------------------- |
|
591 // CCpsPublisher::ClearScreenshotL |
|
592 // -------------------------------------------------------------------------- |
|
593 // |
|
594 void CCpsPublisher::StoreBitmapL(TInt aWidgetId, CFbsBitmap* aBmp) |
|
595 { |
|
596 CFbsBitmap** oldbmp = iScreenshots.Find( aWidgetId ); |
|
597 if ( oldbmp ) |
|
598 { |
|
599 delete *oldbmp; |
|
600 } |
|
601 if ( iScreenshots.Insert( aWidgetId, aBmp ) != KErrNone ) |
|
602 { |
|
603 delete aBmp; |
|
604 iScreenshots.Remove( aWidgetId ); |
|
605 } |
|
606 } |
|
607 |
|
608 // -------------------------------------------------------------------------- |
|
609 // CCpsPublisher::RemoveBitmapL |
|
610 // -------------------------------------------------------------------------- |
|
611 // |
|
612 void CCpsPublisher::RemoveBitmapL(TInt aWidgetId) |
|
613 { |
|
614 CFbsBitmap** bmp = iScreenshots.Find( aWidgetId ); |
|
615 if ( bmp ) |
|
616 { |
|
617 delete *bmp; |
|
618 iScreenshots.Remove( aWidgetId ); |
|
619 } |
|
620 } |
|
621 |
|
622 // -------------------------------------------------------------------------- |
|
623 // CCpsPublisher::PublishScreenshotToCpsL |
|
624 // -------------------------------------------------------------------------- |
|
625 // |
|
626 void CCpsPublisher::PublishScreenshotToCpsL(const TDesC& aWidget, |
|
627 TInt aWidgetId, TInt aBitmap) |
|
628 { |
|
629 CLiwGenericParamList& inparam = iServiceHandler->InParamListL(); |
|
630 CLiwGenericParamList& outparam = iServiceHandler->OutParamListL(); |
|
631 |
|
632 TLiwGenericParam cptype( KType, TLiwVariant( KCpData )); |
|
633 cptype.PushL(); |
|
634 |
|
635 inparam.AppendL( cptype ); |
|
636 |
|
637 CLiwDefaultMap* cpdatamap = CLiwDefaultMap::NewLC(); |
|
638 CLiwDefaultMap* map = CLiwDefaultMap::NewLC(); |
|
639 |
|
640 // Add bitmap handle to data map |
|
641 map->InsertL( KWidgetId, TLiwVariant( TInt32(aWidgetId) )); // key - aKey, value - map (stringsMap) |
|
642 map->InsertL( KBitmapHandle, TLiwVariant( TInt32(aBitmap) )); // key - aKey, value - map (stringsMap) |
|
643 |
|
644 // Create content data map |
|
645 cpdatamap->InsertL( KPublisherId, TLiwVariant( KWidgetUi )); |
|
646 cpdatamap->InsertL( KContentType, TLiwVariant( KScreenshot )); |
|
647 cpdatamap->InsertL( KContentId, TLiwVariant( aWidget )); |
|
648 cpdatamap->InsertL( KDataMap, TLiwVariant(map) ); |
|
649 |
|
650 TLiwGenericParam item( KItem, TLiwVariant( cpdatamap )); |
|
651 item.PushL(); |
|
652 |
|
653 inparam.AppendL( item ); |
|
654 |
|
655 iCpsInterface->ExecuteCmdL( KAdd , inparam, outparam); |
|
656 |
|
657 CleanupStack::PopAndDestroy( &item ); |
|
658 CleanupStack::PopAndDestroy( map ); |
|
659 CleanupStack::PopAndDestroy( cpdatamap ); |
|
660 CleanupStack::PopAndDestroy( &cptype ); |
|
661 |
|
662 outparam.Reset(); |
|
663 inparam.Reset(); |
|
664 } |
|
665 |
|
666 |
|
667 // -------------------------------------------------------------------------- |
|
668 // CCpsPublisher::PublishScreenshotToCpsL |
|
669 // -------------------------------------------------------------------------- |
|
670 // |
|
671 void CCpsPublisher::RemoveScreenshotFromCpsL(const TDesC& aWidget) |
|
672 { |
|
673 CLiwGenericParamList& inparam = iServiceHandler->InParamListL(); |
|
674 CLiwGenericParamList& outparam = iServiceHandler->OutParamListL(); |
|
675 |
|
676 CLiwDefaultMap* cpdatamap = CLiwDefaultMap::NewLC(); |
|
677 |
|
678 // Create content data map |
|
679 cpdatamap->InsertL( KPublisherId, TLiwVariant( KWidgetUi )); |
|
680 cpdatamap->InsertL( KContentType, TLiwVariant( KScreenshot )); |
|
681 cpdatamap->InsertL( KContentId, TLiwVariant( aWidget )); |
|
682 |
|
683 TLiwGenericParam item( KItem, TLiwVariant( cpdatamap )); |
|
684 item.PushL(); |
|
685 |
|
686 inparam.AppendL( item ); |
|
687 |
|
688 iCpsInterface->ExecuteCmdL( KDelete , inparam, outparam); |
|
689 |
|
690 CleanupStack::PopAndDestroy( &item ); |
|
691 CleanupStack::PopAndDestroy( cpdatamap ); |
|
692 |
|
693 outparam.Reset(); |
|
694 inparam.Reset(); |
|
695 } |
|
696 |
560 // END OF FILE |
697 // END OF FILE |
561 |
698 |
562 |
699 |
563 |
700 |