src/hbwidgets/devicedialogs/hbdevicenotificationdialogsymbian.cpp
changeset 5 627c4a0fd0e7
parent 2 06ff229162e9
child 21 4633027730f5
child 34 ed14f46c0e55
equal deleted inserted replaced
3:11d3954df52a 5:627c4a0fd0e7
    95 void CHbDeviceNotificationDialogSymbianPrivate::ShowL()
    95 void CHbDeviceNotificationDialogSymbianPrivate::ShowL()
    96     {
    96     {
    97     AddVariantL(KKeyTouchActivation, &iEnable, CHbSymbianVariant::EBool);
    97     AddVariantL(KKeyTouchActivation, &iEnable, CHbSymbianVariant::EBool);
    98     AddVariantL(KKeyTimeOut, &iTimeout, CHbSymbianVariant::EInt);
    98     AddVariantL(KKeyTimeOut, &iTimeout, CHbSymbianVariant::EInt);
    99     AddVariantL(KKeyTitleTextWrapping, &iWrap, CHbSymbianVariant::EInt);
    99     AddVariantL(KKeyTitleTextWrapping, &iWrap, CHbSymbianVariant::EInt);
   100     User::LeaveIfError(iDeviceDialog->Show(KPluginIdentifier, *iVariantMap, this));   
   100     TInt error = iDeviceDialog->Show(KPluginIdentifier, *iVariantMap, this);
       
   101     if (error != KErrNone) {
       
   102         User::Leave(error); // error can be positive or negative
       
   103     }
   101     }
   104     }
   102 
   105 
   103 void CHbDeviceNotificationDialogSymbianPrivate::UpdateL()
   106 void CHbDeviceNotificationDialogSymbianPrivate::UpdateL()
   104     {
   107     {
   105     AddVariantL(KKeyTouchActivation, &iEnable, CHbSymbianVariant::EBool);
   108     AddVariantL(KKeyTouchActivation, &iEnable, CHbSymbianVariant::EBool);
   106     AddVariantL(KKeyTimeOut, &iTimeout, CHbSymbianVariant::EInt);
   109     AddVariantL(KKeyTimeOut, &iTimeout, CHbSymbianVariant::EInt);
   107     AddVariantL(KKeyTitleTextWrapping, &iWrap, CHbSymbianVariant::EInt);
   110     AddVariantL(KKeyTitleTextWrapping, &iWrap, CHbSymbianVariant::EInt);
   108     User::LeaveIfError(iDeviceDialog->Update(*iVariantMap));
   111     TInt error = iDeviceDialog->Update(*iVariantMap);
       
   112     if (error != KErrNone) {
       
   113         User::Leave(error); // error can be positive or negative
       
   114     }
   109     }
   115     }
   110 
   116 
   111 void CHbDeviceNotificationDialogSymbianPrivate::Close()
   117 void CHbDeviceNotificationDialogSymbianPrivate::Close()
   112     {
   118     {
   113     iDeviceDialog->Cancel();
   119     iDeviceDialog->Cancel();
   194 
   200 
   195     For the content CHbDeviceNotificationDialogSymbian provides two rows of text, an image or an animation and for the usage
   201     For the content CHbDeviceNotificationDialogSymbian provides two rows of text, an image or an animation and for the usage
   196     same rules as for the HbDeviceNotificationDialog apply. Dialog is shown when show() is called. It is recommended that 
   202     same rules as for the HbDeviceNotificationDialog apply. Dialog is shown when show() is called. It is recommended that 
   197     the dialog data is initialized before calling ShowL() or UpdateL() methods, because those methods use interprocess communication.
   203     the dialog data is initialized before calling ShowL() or UpdateL() methods, because those methods use interprocess communication.
   198 
   204 
       
   205     Two timeout constants are provided for setting the dialog timeout: KHbShortNotificationDialogTimeout and 
       
   206     KHbLongNotificationDialogTimeout. The first is equivalent to HbPopup::ConfirmationNoteTimeout and the latter 
       
   207     is equivalent to HbPopup::StandardTimeout.
       
   208     
   199     \code
   209     \code
   200     Following code snippet creates a device notification dialog containing title, text and icon.
   210     Following code snippet creates a device notification dialog containing title, text and icon.
   201 
   211 
   202     _LIT(KDialogText, "Dialog text");
   212     _LIT(KDialogText, "Dialog text");
   203     _LIT(KDialogTitle, "Dialog title");
   213     _LIT(KDialogTitle, "Dialog title");
   232     \code
   242     \code
   233     _LIT(KDialogText, "Dialog text");
   243     _LIT(KDialogText, "Dialog text");
   234     _LIT(KDialogTitle, "Dialog title");
   244     _LIT(KDialogTitle, "Dialog title");
   235     _LIT(KDialogIcon, "note_info.svg");
   245     _LIT(KDialogIcon, "note_info.svg");
   236 
   246 
   237     iDialog = CHbDeviceNotificationDialogSymbian::NewL(this);
   247     class DialogObserver : public MHbDeviceNotificationDialogObserver
   238     iDialog->SetTextL(KDialogText);
   248     {
   239     iDialog->SetTitleL(KDialogTitle);
   249     public:
   240     iDialog->SetIconNameL(KDialogIcon);
   250         DialogObserver() {}
   241     iDialog->ShowL();
   251         ~DialogObserver() { delete iDialog; }
       
   252         void ShowDialog();
       
   253     ...
       
   254     private:
       
   255         virtual void NotificationDialogActivated(const CHbDeviceNotificationDialogSymbian* aDialog);
       
   256         virtual void NotificationDialogClosed(const CHbDeviceNotificationDialogSymbian* aDialog, TInt aCompletionCode);
       
   257     private:
       
   258         CHbDeviceNotificationDialogSymbian* iDialog;
       
   259     };
       
   260     
       
   261     void DialogObserver::NotificationDialogActivated(const CHbDeviceNotificationDialogSymbian* aDialog)
       
   262     {
       
   263         CEikonEnv::Static()->InfoMsg(_L("Device notification dialog activated"));
       
   264         delete aDialog;
       
   265         aDialog = 0;
       
   266     }
       
   267     
       
   268     void NotificationDialogClosed(const CHbDeviceNotificationDialogSymbian* aDialog, TInt aCompletionCode)
       
   269     {
       
   270         CEikonEnv::Static()->InfoMsg(_L("Device notification dialog deactivated"));
       
   271         delete aDialog;
       
   272         aDialog = 0;
       
   273     }
       
   274     
       
   275     void DialogObserver::ShowDialog()
       
   276     {
       
   277         iDialog = CHbDeviceNotificationDialogSymbian::NewL(this);
       
   278         iDialog->SetTextL(KDialogText);
       
   279         iDialog->SetTitleL(KDialogTitle);
       
   280         iDialog->SetIconNameL(KDialogIcon);
       
   281         iDialog->ShowL();
       
   282     }
   242     \endcode
   283     \endcode
   243     
   284     
   244     CHbDeviceNotificationDialogSymbian supports. 
   285     CHbDeviceNotificationDialogSymbian supports. 
   245     Supported formats are the following.
   286     Supported formats are the following.
   246 
   287 
   265 	
   306 	
   266 	Create CHbDeviceNotificationDialogSymbian in a way described before and
   307 	Create CHbDeviceNotificationDialogSymbian in a way described before and
   267 	set definition file and animation's logical name.
   308 	set definition file and animation's logical name.
   268 	
   309 	
   269 	_LIT(KAnimationDefinitionXML, "C:\animation.axml");	
   310 	_LIT(KAnimationDefinitionXML, "C:\animation.axml");	
   270 	_LITK(KLogicalIconName, "frame_anim_looping");
   311 	_LIT(KLogicalIconName, "frame_anim_looping");
   271 		
   312 		
   272 	iDialog->SetAnimationDefinitionL(KAnimationDefinitionXML);
   313 	iDialog->SetAnimationDefinitionL(KAnimationDefinitionXML);
   273 	iDialog->SetIconNameL(KIconName);
   314 	iDialog->SetIconNameL(KLogicalIconName);
   274 	iDialog->ShowL();		
   315 	iDialog->ShowL();		
   275 	\endcode
   316 	\endcode
   276 	\sa HbIconAnimationManager::addDefinitionFile
   317 	\sa HbIconAnimationManager::addDefinitionFile
   277 	\note Animation definition files must be stored to a place where they
   318 	\note Animation definition files must be stored to a place where they
   278 	can be accessed.    
   319 	can be accessed.    
   474 /*!
   515 /*!
   475     Set dialog timeout. Timeout is not set, if Show() or Update()
   516     Set dialog timeout. Timeout is not set, if Show() or Update()
   476     is not called.
   517     is not called.
   477     \param aTimeout - Set timeout for dialog.
   518     \param aTimeout - Set timeout for dialog.
   478 
   519 
   479     Default value is HbPopup::StandardTimeout (3000 ms).
   520     Default value is KHbLongNotificationDialogTimeout (3000 ms).
   480     \sa ShowL(), UpdateL()
   521     \sa ShowL(), UpdateL()
   481 */
   522 */
   482 EXPORT_C void CHbDeviceNotificationDialogSymbian::SetTimeout(TInt aTimeout)
   523 EXPORT_C void CHbDeviceNotificationDialogSymbian::SetTimeout(TInt aTimeout)
   483     {
   524     {
   484     d->iTimeout = aTimeout;
   525     d->iTimeout = aTimeout;