src/hbwidgets/devicedialogs/hbdevicenotificationdialogsymbian.cpp
changeset 34 ed14f46c0e55
parent 5 627c4a0fd0e7
equal deleted inserted replaced
31:7516d6d86cf5 34:ed14f46c0e55
    35 _LIT(KKeyActivated, "result");
    35 _LIT(KKeyActivated, "result");
    36 _LIT(KKeyActivatedValue, "activated");
    36 _LIT(KKeyActivatedValue, "activated");
    37 _LIT(KPluginIdentifier, "com.nokia.hb.devicenotificationdialog/1.0");
    37 _LIT(KPluginIdentifier, "com.nokia.hb.devicenotificationdialog/1.0");
    38 _LIT(KKeyTitleTextWrapping, "titleTextWrapping");
    38 _LIT(KKeyTitleTextWrapping, "titleTextWrapping");
    39 _LIT(KKeyAnimationDefinition, "animationDefinition");
    39 _LIT(KKeyAnimationDefinition, "animationDefinition");
       
    40 _LIT(KKeyShowLevel, "showLevel");
    40 
    41 
    41 NONSHARABLE_CLASS(CHbDeviceNotificationDialogSymbianPrivate) : public CBase,
    42 NONSHARABLE_CLASS(CHbDeviceNotificationDialogSymbianPrivate) : public CBase,
    42                                                   public MHbDeviceDialogObserver
    43                                                   public MHbDeviceDialogObserver
    43 {
    44 {
       
    45 public:
       
    46     struct TIntProperty{
       
    47         TInt iValue;
       
    48         TBool iChanged;
       
    49     };
       
    50 
    44 public:
    51 public:
    45     CHbDeviceNotificationDialogSymbianPrivate();
    52     CHbDeviceNotificationDialogSymbianPrivate();
    46     virtual ~CHbDeviceNotificationDialogSymbianPrivate();
    53     virtual ~CHbDeviceNotificationDialogSymbianPrivate();
    47     
    54     
    48 public:
    55 public:
    64     MHbDeviceNotificationDialogObserver* iObserver;
    71     MHbDeviceNotificationDialogObserver* iObserver;
    65     CHbDeviceDialogSymbian *iDeviceDialog;
    72     CHbDeviceDialogSymbian *iDeviceDialog;
    66     CHbSymbianVariantMap* iVariantMap;
    73     CHbSymbianVariantMap* iVariantMap;
    67     CHbDeviceNotificationDialogSymbian* q; 
    74     CHbDeviceNotificationDialogSymbian* q; 
    68     
    75     
    69     TBool iEnable;
    76     TIntProperty iEnable;
    70     TInt iTimeout;
    77     TIntProperty iTimeout;
    71     CHbDeviceNotificationDialogSymbian::TextWrapping iWrap;
    78     TIntProperty iShowLevel;
       
    79     TIntProperty iWrap;
    72 };
    80 };
    73 
    81 
    74 CHbDeviceNotificationDialogSymbianPrivate::CHbDeviceNotificationDialogSymbianPrivate()
    82 CHbDeviceNotificationDialogSymbianPrivate::CHbDeviceNotificationDialogSymbianPrivate()
    75     { 
    83     {
       
    84     iTimeout.iValue = 3000; // HbPopup::StandardTimeout
    76     }
    85     }
    77 
    86 
    78 CHbDeviceNotificationDialogSymbianPrivate::~CHbDeviceNotificationDialogSymbianPrivate()
    87 CHbDeviceNotificationDialogSymbianPrivate::~CHbDeviceNotificationDialogSymbianPrivate()
    79     {
    88     {
    80     if (!iObserver && q->Timeout() != 0) {
    89     if (!iObserver && q->Timeout() != 0) {
    81         iDeviceDialog->SetObserver(NULL);
    90         if (iDeviceDialog) {
       
    91             iDeviceDialog->SetObserver(NULL);
    82         }
    92         }
    83     
    93     }
       
    94 
    84     delete iDeviceDialog;
    95     delete iDeviceDialog;
    85     delete iVariantMap;
    96     delete iVariantMap;
    86     }
    97     }
    87 
    98 
    88 void CHbDeviceNotificationDialogSymbianPrivate::ConstructL(CHbDeviceNotificationDialogSymbian* aDialog)
    99 void CHbDeviceNotificationDialogSymbianPrivate::ConstructL(CHbDeviceNotificationDialogSymbian* aDialog)
    92     iVariantMap = CHbSymbianVariantMap::NewL(); 
   103     iVariantMap = CHbSymbianVariantMap::NewL(); 
    93     }
   104     }
    94 
   105 
    95 void CHbDeviceNotificationDialogSymbianPrivate::ShowL()
   106 void CHbDeviceNotificationDialogSymbianPrivate::ShowL()
    96     {
   107     {
    97     AddVariantL(KKeyTouchActivation, &iEnable, CHbSymbianVariant::EBool);
   108     if (iEnable.iChanged) {
    98     AddVariantL(KKeyTimeOut, &iTimeout, CHbSymbianVariant::EInt);
   109         AddVariantL(KKeyTouchActivation, &iEnable.iValue, CHbSymbianVariant::EBool);
    99     AddVariantL(KKeyTitleTextWrapping, &iWrap, CHbSymbianVariant::EInt);
   110     }
       
   111     if (iTimeout.iChanged) {
       
   112         AddVariantL(KKeyTimeOut, &iTimeout.iValue, CHbSymbianVariant::EInt);
       
   113     }
       
   114     if (iWrap.iChanged) {
       
   115         AddVariantL(KKeyTitleTextWrapping, &iWrap.iValue, CHbSymbianVariant::EInt);
       
   116     }
       
   117     if (iShowLevel.iChanged) {
       
   118         AddVariantL(KKeyShowLevel, &iShowLevel.iValue, CHbSymbianVariant::EInt);
       
   119     }
       
   120 
   100     TInt error = iDeviceDialog->Show(KPluginIdentifier, *iVariantMap, this);
   121     TInt error = iDeviceDialog->Show(KPluginIdentifier, *iVariantMap, this);
   101     if (error != KErrNone) {
   122     if (error != KErrNone) {
   102         User::Leave(error); // error can be positive or negative
   123         User::Leave(error); // error can be positive or negative
   103     }
   124     }
   104     }
   125     }
   105 
   126 
   106 void CHbDeviceNotificationDialogSymbianPrivate::UpdateL()
   127 void CHbDeviceNotificationDialogSymbianPrivate::UpdateL()
   107     {
   128     {
   108     AddVariantL(KKeyTouchActivation, &iEnable, CHbSymbianVariant::EBool);
   129     if (iEnable.iChanged) {
   109     AddVariantL(KKeyTimeOut, &iTimeout, CHbSymbianVariant::EInt);
   130         AddVariantL(KKeyTouchActivation, &iEnable, CHbSymbianVariant::EBool);
   110     AddVariantL(KKeyTitleTextWrapping, &iWrap, CHbSymbianVariant::EInt);
   131     }
       
   132     if (iTimeout.iChanged) {
       
   133         AddVariantL(KKeyTimeOut, &iTimeout, CHbSymbianVariant::EInt);
       
   134     }
       
   135     if (iWrap.iChanged) {
       
   136         AddVariantL(KKeyTitleTextWrapping, &iWrap, CHbSymbianVariant::EInt);
       
   137     }
   111     TInt error = iDeviceDialog->Update(*iVariantMap);
   138     TInt error = iDeviceDialog->Update(*iVariantMap);
   112     if (error != KErrNone) {
   139     if (error != KErrNone) {
   113         User::Leave(error); // error can be positive or negative
   140         User::Leave(error); // error can be positive or negative
   114     }
   141     }
   115     }
   142     }
   158         // Observer callback may delete this object. Don't touch it after.
   185         // Observer callback may delete this object. Don't touch it after.
   159         iObserver->NotificationDialogClosed(q, aCompletionCode);
   186         iObserver->NotificationDialogClosed(q, aCompletionCode);
   160         }
   187         }
   161     }
   188     }
   162 
   189 
       
   190 // Set dialog show level
       
   191 void SetShowLevel(CHbDeviceNotificationDialogSymbianPrivate *aDialog, TInt aLevel)
       
   192 {
       
   193     aDialog->iShowLevel.iValue = aLevel;
       
   194     aDialog->iShowLevel.iChanged = ETrue;
       
   195 }
       
   196 
   163 /*!
   197 /*!
   164     \class MHbDeviceNotificationDialogObserver
   198     \class MHbDeviceNotificationDialogObserver
   165     \brief MHbDeviceNotificationDialogObserver is an observer interface for observing CHbDeviceNotificationDialogSymbian.
   199     \brief MHbDeviceNotificationDialogObserver is an observer interface for observing CHbDeviceNotificationDialogSymbian.
   166 */
   200 */
   167 
       
   168 /*!
   201 /*!
   169     \fn void MHbDeviceNotificationDialogObserver::NotificationDialogActivated(const CHbDeviceNotificationDialogSymbian* aDialog) = 0;
   202     \fn void MHbDeviceNotificationDialogObserver::NotificationDialogActivated(const CHbDeviceNotificationDialogSymbian* aDialog) = 0;
   170 
   203 
   171     This callback is called when notification dialog is activated.
   204     This callback is called when notification dialog is activated.
   172     \a aDialog - Pointer to dialog instance which received activation event.
   205     \a aDialog is a pointer to a dialog instance which received activation event.
   173 */
   206 
   174 
   207     \sa CHbDeviceNotificationDialogSymbian::EnableTouchActivation()
       
   208 */
   175 /*!
   209 /*!
   176    \fn void MHbDeviceNotificationDialogObserver::NotificationDialogClosed(const CHbDeviceNotificationDialogSymbian* aDialog, TInt aCompletionCode) = 0;
   210    \fn void MHbDeviceNotificationDialogObserver::NotificationDialogClosed(const CHbDeviceNotificationDialogSymbian* aDialog, TInt aCompletionCode) = 0;
   177 
   211 
   178     This callback is called when notification dialog is closed.
   212     This callback is called when notification dialog has closed.
   179     \a aDialog - Pointer to dialog instance which received closed event.
   213     \a aDialog is a pointer to a dialog instance which received closed event.
   180     \a aCompletionCode - Result of the dialog completion.
   214     \a aCompletionCode can be either Symbian error code or device dialog error code.
   181 */
   215 */
   182 
   216 
   183 /*!
   217 /*!
   184    \fn void MHbDeviceNotificationDialogObserver::NotificationDialogError(const CHbDeviceNotificationDialogSymbian* aDialog, TInt aError) = 0;
   218     \stable
   185 
   219     \hbwidgets
   186     This callback is called when an error has occured.
   220 
   187     \a aDialog - Pointer to dialog instance which received closed event.
       
   188     \a aError - Error code.
       
   189 */
       
   190 
       
   191 /*!
       
   192     \class CHbDeviceNotificationDialogSymbian
   221     \class CHbDeviceNotificationDialogSymbian
   193     \brief CHbDeviceNotificationDialogSymbian is a Symbian implementation of HbDeviceNotificationDialog.
   222     \brief CHbDeviceNotificationDialogSymbian is a Symbian implementation of HbDeviceNotificationDialog.
   194 
   223 
   195     It is a client interface for s60 native application to show a non-modal dialog on top of applications when
   224     <b>This class is Symbian only. Not available on other platforms.</b>
   196     HbDeviceNotificationDialog can not be used.
   225 
   197 
   226     CHbDeviceNotificationDialogSymbian is intended for use by servers that don't run Qt event loop
   198     CHbDeviceNotificationDialogSymbian provides similar interface and functionality as HbDeviceNotificationDialog.
   227     and cannot use HbDeviceNotificationDialog.
   199     Main difference is that signals are replaced by an observer interface CHbDeviceNotificationDialogSymbianObserver.
   228 
   200 
   229     See HbDeviceNotificationDialog documentation to find out more about device notification
   201     For the content CHbDeviceNotificationDialogSymbian provides two rows of text, an image or an animation and for the usage
   230     dialogs.
   202     same rules as for the HbDeviceNotificationDialog apply. Dialog is shown when show() is called. It is recommended that 
   231 
   203     the dialog data is initialized before calling ShowL() or UpdateL() methods, because those methods use interprocess communication.
   232     CHbDeviceNotificationDialogSymbian provides similar interface and functionality as
   204 
   233     HbDeviceNotificationDialog. Main difference is that signals are replaced by an observer
   205     Two timeout constants are provided for setting the dialog timeout: KHbShortNotificationDialogTimeout and 
   234     interface CHbDeviceNotificationDialogSymbianObserver.
   206     KHbLongNotificationDialogTimeout. The first is equivalent to HbPopup::ConfirmationNoteTimeout and the latter 
   235 
   207     is equivalent to HbPopup::StandardTimeout.
   236     An asynchronous ShowL() method launches a dialog. Device dialog framework decides when the
   208     
   237     dialog is actually shown. There may be a delay untill dialog appears on display. Close()
       
   238     closes a dialog.
       
   239 
       
   240     After dialog has been lauched, properties may be updated by setters and calling UpdateL().
       
   241     It is recommended that dialog properties are set before calling ShowL() as updating them after
       
   242     causes interprocess communication.
       
   243 
       
   244     If there is no need to update or receive activation from a launched dialog,
       
   245     CHbDeviceNotificationDialogSymbian object can be deleted after ShowL() returns. Device
       
   246     dialog framework takes care of displaying the dialog.
       
   247 
       
   248     For maintaining consistent look and feel, two timeout constants are provided for setting
       
   249     dialog timeout: KHbShortNotificationDialogTimeout and KHbLongNotificationDialogTimeout.
       
   250     The first one is equivalent to HbPopup::ConfirmationNoteTimeout and the latter 
       
   251     to HbPopup::StandardTimeout.
       
   252 
   209     \code
   253     \code
   210     Following code snippet creates a device notification dialog containing title, text and icon.
   254     Following code snippet creates a device notification dialog containing title, text and icon.
   211 
   255 
   212     _LIT(KDialogText, "Dialog text");
   256     _LIT(KDialogText, "Dialog text");
   213     _LIT(KDialogTitle, "Dialog title");
   257     _LIT(KDialogTitle, "Dialog title");
   214     _LIT(KDialogIcon, "note_info.svg");
   258     _LIT(KDialogIcon, "qtg_large_info");
   215 
   259 
   216     CHbDeviceNotificationDialogSymbian* dialog = CHbDeviceNotificationDialogSymbian::NewL();
   260     CHbDeviceNotificationDialogSymbian* dialog = CHbDeviceNotificationDialogSymbian::NewL();
   217     CleanupStack::PushL(dialog);
   261     CleanupStack::PushL(dialog);
   218     dialog->SetTextL(KDialogText);
   262     dialog->SetTextL(KDialogText);
   219     dialog->SetTitleL(KDialogTitle);
   263     dialog->SetTitleL(KDialogTitle);
   220     dialog->SetIconNameL(KDialogIcon);
   264     dialog->SetIconNameL(KDialogIcon);
   221     dialog->Show();
   265     dialog->ShowL();
   222     CleanupStack::PopAndDestroy(dialog);
   266     CleanupStack::PopAndDestroy(dialog);
   223     \endcode
   267     \endcode
   224 
   268 
   225     or equivalent dialog can be created using one of the provided convenience methods:
   269     or equivalent dialog can be created using one of the provided convenience methods:
   226 
   270 
   227     \code
   271     \code
   228     _LIT(KDialogText, "Dialog text");
   272     _LIT(KDialogText, "Dialog text");
   229     _LIT(KDialogTitle, "Dialog title");
   273     _LIT(KDialogTitle, "Dialog title");
   230     _LIT(KDialogIcon, "note_info.svg");
   274     _LIT(KDialogIcon, "qtg_large_info");
   231     
   275     
   232     CHbDeviceNotificationDialogSymbian::Notification(KDialogIcon, KDialogText, KDialogTitle);
   276     CHbDeviceNotificationDialogSymbian::Notification(KDialogIcon, KDialogText, KDialogTitle);
   233     \endcode
   277     \endcode
   234 
   278 
   235     When using convenience methods, it is not possible to receive user interaction events, because the 
   279     When using convenience methods, it is not possible to receive user interaction events,
   236     HbDeviceNotificationDialog instance is destroyed when the call returns. Ownership and handling of the
   280     because the HbDeviceNotificationDialog instance is destroyed when the call returns.
   237     dialog is transferred to HbDeviceDialog framework. Also dialog can not be closed nor updated.
   281 
   238 
   282     Below is an example of receiving user interaction events from device notification dialog.
   239     Below is an example of receiving user interaction events from device notification dialog. With following example 
   283     With following example user is able to receive activated and close events.
   240     user is able to receive activated and close events. Note that dialog is cancelled, if it goes out of scope.
   284     Note that in this case the dialog is closed by device dialog framework if
       
   285     CHbDeviceNotificationDialogSymbian object is deleted.
   241 
   286 
   242     \code
   287     \code
   243     _LIT(KDialogText, "Dialog text");
   288     _LIT(KDialogText, "Dialog text");
   244     _LIT(KDialogTitle, "Dialog title");
   289     _LIT(KDialogTitle, "Dialog title");
   245     _LIT(KDialogIcon, "note_info.svg");
   290     _LIT(KDialogIcon, "qtg_large_info");
   246 
   291 
   247     class DialogObserver : public MHbDeviceNotificationDialogObserver
   292     class DialogObserver : public MHbDeviceNotificationDialogObserver
   248     {
   293     {
   249     public:
   294     public:
   250         DialogObserver() {}
   295         DialogObserver() {}
   279         iDialog->SetTitleL(KDialogTitle);
   324         iDialog->SetTitleL(KDialogTitle);
   280         iDialog->SetIconNameL(KDialogIcon);
   325         iDialog->SetIconNameL(KDialogIcon);
   281         iDialog->ShowL();
   326         iDialog->ShowL();
   282     }
   327     }
   283     \endcode
   328     \endcode
   284     
   329 
   285     CHbDeviceNotificationDialogSymbian supports. 
   330     Following example sets an icon animation into a notification dialog.
   286     Supported formats are the following.
   331         
   287 
   332     \code
   288     - GIF (.gif)
   333     Create an animation definition file.    
   289     - MNG (.mng)
   334     
   290 	- Frame animations
   335     <animations>
   291 	
   336         <icon name="frame_anim_looping" playmode="loop">
   292 	There is a built-in support for GIF and MNG animations. 
   337             <frame duration="100">c:\icon1.svg</frame>
   293 	
   338             <frame duration="200">c:\icon2.svg</frame>
   294 	Frame animations can be created by following way:
   339             <frame duration="300">c:\icon3.svg</frame>
   295 		
   340         </icon>
   296 	\code
   341     </animations>   
   297 	Create an animation definition file.	
   342     
   298 	
   343     Create CHbDeviceNotificationDialogSymbian in a way described before and
   299 	<animations>
   344     set definition file and animation's logical name.
   300 		<icon name="frame_anim_looping" playmode="loop">
   345     
   301 			<frame duration="100">c:\icon1.svg</frame>
   346     _LIT(KAnimationDefinitionXML, "C:\animation.axml"); 
   302 			<frame duration="200">c:\icon2.svg</frame>
   347     _LIT(KLogicalIconName, "frame_anim_looping");
   303 			<frame duration="300">c:\icon3.svg</frame>
   348         
   304 		</icon>
   349     iDialog->SetAnimationDefinitionL(KAnimationDefinitionXML);
   305 	</animations>	
   350     iDialog->SetIconNameL(KLogicalIconName);
   306 	
   351     iDialog->ShowL();       
   307 	Create CHbDeviceNotificationDialogSymbian in a way described before and
   352     \endcode
   308 	set definition file and animation's logical name.
   353 
   309 	
   354     \sa HbDeviceNotificationDialog, MHbDeviceNotificationDialogObserver 
   310 	_LIT(KAnimationDefinitionXML, "C:\animation.axml");	
   355 */
   311 	_LIT(KLogicalIconName, "frame_anim_looping");
   356 
   312 		
   357 /*!
   313 	iDialog->SetAnimationDefinitionL(KAnimationDefinitionXML);
   358     \enum CHbDeviceNotificationDialogSymbian::TextWrapping
   314 	iDialog->SetIconNameL(KLogicalIconName);
   359     Title text wrapping.
   315 	iDialog->ShowL();		
   360 
   316 	\endcode
   361     \sa Hb::TextWrapping
   317 	\sa HbIconAnimationManager::addDefinitionFile
   362 */
   318 	\note Animation definition files must be stored to a place where they
   363 /*!
   319 	can be accessed.    
   364     \var CHbDeviceNotificationDialogSymbian::TextWrapping CHbDeviceNotificationDialogSymbian::TextNoWrap
   320     
   365     No wrapping.
   321     \stable
   366 */
   322     \hbwidgets
   367 /*!
   323 */
   368     \var CHbDeviceNotificationDialogSymbian::TextWrapping CHbDeviceNotificationDialogSymbian::TextWordWrap
   324 
   369     Word wrapping.
   325 /*!
   370 */
   326     Symbian two phase constructor. Returns a pointer to CHbDeviceNotificationDialogSymbian instance.
   371 /*!
   327     \a aObserver Pointer to the observer.
   372     \var CHbDeviceNotificationDialogSymbian::TextWrapping CHbDeviceNotificationDialogSymbian::TextWrapAnywhere
       
   373     Wrap anywhere.
       
   374 */
       
   375 
       
   376 /*!
       
   377     Constructs a new CHbDeviceNotificationDialog and returns a pointer it.
       
   378     \a aObserver is a pointer to event observer or 0 if no observer.
   328 */
   379 */
   329 EXPORT_C CHbDeviceNotificationDialogSymbian* CHbDeviceNotificationDialogSymbian::NewL(
   380 EXPORT_C CHbDeviceNotificationDialogSymbian* CHbDeviceNotificationDialogSymbian::NewL(
   330     MHbDeviceNotificationDialogObserver* aObserver)
   381     MHbDeviceNotificationDialogObserver* aObserver)
   331     {
   382     {
   332     CHbDeviceNotificationDialogSymbian* self = new (ELeave) CHbDeviceNotificationDialogSymbian();
   383     CHbDeviceNotificationDialogSymbian* self = new (ELeave) CHbDeviceNotificationDialogSymbian();
   335     CleanupStack::Pop(self);
   386     CleanupStack::Pop(self);
   336     return self;
   387     return self;
   337     }
   388     }
   338 
   389 
   339 /*!
   390 /*!
   340     Destructor.
   391     Destructs CHbDeviceNotificationDialogSymbian. The notification launched by ShowL()
       
   392     is closed if observer is set. If there is no observer, it is
       
   393     left executing and closes itself by timeout.
   341 */
   394 */
   342 EXPORT_C CHbDeviceNotificationDialogSymbian::~CHbDeviceNotificationDialogSymbian()
   395 EXPORT_C CHbDeviceNotificationDialogSymbian::~CHbDeviceNotificationDialogSymbian()
   343     {
   396     {
   344     delete d;
   397     delete d;
   345     }
   398     }
   346 
   399 
   347 /*!
   400 /*!
   348     Convenience method for showing notification dialog with icon and title.
   401     Convenience method for showing notification dialog with icon and title.
   349     \param aIconName - path and name of the icon shown on dialog.
   402 
   350     \param aTitle - title shown on dialog.
   403     \param aIconName Path and name of the icon to show on dialog.
       
   404     \param aTitle Title text.
   351 */
   405 */
   352 EXPORT_C void CHbDeviceNotificationDialogSymbian::NotificationL(const TDesC& aIconName, const TDesC& aTitle)
   406 EXPORT_C void CHbDeviceNotificationDialogSymbian::NotificationL(const TDesC& aIconName, const TDesC& aTitle)
   353     {
   407     {
   354     CHbDeviceNotificationDialogSymbian* self = CHbDeviceNotificationDialogSymbian::NewL();
   408     CHbDeviceNotificationDialogSymbian* self = CHbDeviceNotificationDialogSymbian::NewL();
   355     CleanupStack::PushL(self);
   409     CleanupStack::PushL(self);
   359     CleanupStack::PopAndDestroy(self);
   413     CleanupStack::PopAndDestroy(self);
   360     }
   414     }
   361 
   415 
   362 /*!
   416 /*!
   363     Convenience method for showing notification dialog with icon, text and title.
   417     Convenience method for showing notification dialog with icon, text and title.
   364     \param aIconName - path and name of the icon shown on dialog.
   418 
   365     \param aText - text shown on dialog.
   419     \param aIconName Path and name of icon to show on dialog.
   366     \param aTitle - title shown on dialog.
   420     \param aText Dialog text.
       
   421     \param aTitle Title text.
   367 */
   422 */
   368 EXPORT_C void CHbDeviceNotificationDialogSymbian::NotificationL(const TDesC &aIconName, const TDesC& aText, const TDesC& aTitle)
   423 EXPORT_C void CHbDeviceNotificationDialogSymbian::NotificationL(const TDesC &aIconName, const TDesC& aText, const TDesC& aTitle)
   369     {
   424     {
   370     CHbDeviceNotificationDialogSymbian* self = CHbDeviceNotificationDialogSymbian::NewL();
   425     CHbDeviceNotificationDialogSymbian* self = CHbDeviceNotificationDialogSymbian::NewL();
   371     CleanupStack::PushL(self);
   426     CleanupStack::PushL(self);
   375     self->ShowL();
   430     self->ShowL();
   376     CleanupStack::PopAndDestroy(self);
   431     CleanupStack::PopAndDestroy(self);
   377     }
   432     }
   378 
   433 
   379 /*!
   434 /*!
   380     Sets message box icon name or animation logical name. The dialog gets updated when method is called.
   435     Sets dialog icon name or animation logical name.
   381 
   436 
   382     \param aIconName Icon name. Icon can be from Hb resources or themes. Or can be a file in
   437     \param aIconName Icon name. Icon can be from Hb resources or themes. Or can be a file in
   383     a file system.
   438     a file system.
   384 
   439 
   385     \sa IconName()
   440     \sa IconName(), ShowL(), UpdateL()
   386 */
   441 */
   387 EXPORT_C void CHbDeviceNotificationDialogSymbian::SetIconNameL(const TDesC& aIconName)
   442 EXPORT_C void CHbDeviceNotificationDialogSymbian::SetIconNameL(const TDesC& aIconName)
   388     {
   443     {
   389     d->AddVariantL(KKeyIconName, &aIconName, CHbSymbianVariant::EDes);
   444     d->AddVariantL(KKeyIconName, &aIconName, CHbSymbianVariant::EDes);
   390     }
   445     }
   391 
   446 
   392 
   447 
   393 /*!
   448 /*!
   394     Get name and path of the icon shown on dialog or animation's logical name. 
   449     Returns icon or animation name. Default is empty.
   395     If not set, returns empty iconName.
       
   396 
   450 
   397     \sa SetIconNameL
   451     \sa SetIconNameL
   398 */
   452 */
   399 EXPORT_C const TPtrC CHbDeviceNotificationDialogSymbian::IconName() const
   453 EXPORT_C const TPtrC CHbDeviceNotificationDialogSymbian::IconName() const
   400     {    
   454     {    
   405         }
   459         }
   406     return TPtrC(KNullDesC());    
   460     return TPtrC(KNullDesC());    
   407     }
   461     }
   408 
   462 
   409 /*!
   463 /*!
   410     Sets notification dialog's animation definition name.  The dialogs get updated next when time ShowL() or UpdateL()
   464     Sets dialog animation definition file name.
   411     is called.
   465 
   412 
   466     Supported icon animation formats are following:
   413     \param aAnimationDefinition Animation definition file name. Definition can be from Hb resources or themes. 
   467     - GIF (.gif)
   414     Or can be a file in a file system.
   468     - MNG (.mng)
   415 
   469     - Frame animations
   416     \sa AnimationDefinition()
   470 
       
   471     \param aAnimationDefinition Animation definition file name. Definition can be from Hb resources or themes.
       
   472     Or can be a file in a file system. The definition must be stored to a place where it can be accessed by
       
   473     device dialog service.
       
   474 
       
   475     \sa AnimationDefinition() SetIconNameL() HbIconAnimationManager::addDefinitionFile(), ShowL(), UpdateL()
   417 */
   476 */
   418 EXPORT_C void CHbDeviceNotificationDialogSymbian::SetAnimationDefinitionL(const TDesC& aAnimationDefinition)
   477 EXPORT_C void CHbDeviceNotificationDialogSymbian::SetAnimationDefinitionL(const TDesC& aAnimationDefinition)
   419 {
   478 {
   420 	d->AddVariantL(KKeyAnimationDefinition, &aAnimationDefinition, CHbSymbianVariant::EDes);
   479     d->AddVariantL(KKeyAnimationDefinition, &aAnimationDefinition, CHbSymbianVariant::EDes);
   421 }
   480 }
   422 
   481 
   423 /*!
   482 /*!
   424     Returns an animation definition set for a dialog. If not set, return string.
   483     Returns dialog animation definition file name.
   425 
   484 
   426     \sa SetAnimationDefinitionL()
   485     \sa SetAnimationDefinitionL()
   427 */
   486 */
   428 EXPORT_C TPtrC CHbDeviceNotificationDialogSymbian::AnimationDefinition() const
   487 EXPORT_C TPtrC CHbDeviceNotificationDialogSymbian::AnimationDefinition() const
   429 {
   488 {
   435     return TPtrC(KNullDesC());
   494     return TPtrC(KNullDesC());
   436 }
   495 }
   437 
   496 
   438 
   497 
   439 /*!
   498 /*!
   440     Set and update text on dialog. Text is not set, if Show() or Update()
   499     Sets dialog text.
   441     is not called.
   500 
   442     \param aText - text shown on dialog.
   501     \param aText Dialog text.
   443     \sa ShowL(), UpdateL()
   502 
       
   503     \sa Text(), ShowL(), UpdateL()
   444 */
   504 */
   445 EXPORT_C void CHbDeviceNotificationDialogSymbian::SetTextL(const TDesC& aText)
   505 EXPORT_C void CHbDeviceNotificationDialogSymbian::SetTextL(const TDesC& aText)
   446     {
   506     {
   447     d->AddVariantL(KKeyText, &aText, CHbSymbianVariant::EDes);
   507     d->AddVariantL(KKeyText, &aText, CHbSymbianVariant::EDes);
   448     }
   508     }
   449 
   509 
   450 /*!
   510 /*!
   451     Get text shown on dialog. If not set, returns empty string.
   511     Returns dialog text.
   452 
   512 
   453     \sa SetTextL()
   513     \sa SetTextL()
   454 */
   514 */
   455 EXPORT_C const TPtrC CHbDeviceNotificationDialogSymbian::Text() const
   515 EXPORT_C const TPtrC CHbDeviceNotificationDialogSymbian::Text() const
   456     {
   516     {
   461         }
   521         }
   462     return TPtrC(KNullDesC());    
   522     return TPtrC(KNullDesC());    
   463     }    
   523     }    
   464 
   524 
   465 /*!
   525 /*!
   466     Set and update title on dialog. Title is not set, if Show() or Update()
   526     Sets title text.
   467     is not called.
   527 
   468     \param title - aTitle shown on dialog.
   528     \param aTitle Title text.
   469     \sa ShowL(), UpdateL()
   529 
       
   530     \sa Title(), ShowL(), UpdateL()
   470 */
   531 */
   471 EXPORT_C void CHbDeviceNotificationDialogSymbian::SetTitleL(const TDesC& aTitle)
   532 EXPORT_C void CHbDeviceNotificationDialogSymbian::SetTitleL(const TDesC& aTitle)
   472     {
   533     {
   473     d->AddVariantL(KKeyTitle, &aTitle, CHbSymbianVariant::EDes);
   534     d->AddVariantL(KKeyTitle, &aTitle, CHbSymbianVariant::EDes);
   474     }
   535     }
   475 
   536 
   476 /*!
   537 /*!
   477     Get title shown on dialog. If not set, returns empty string.
   538     Returns title text.
   478 
   539 
   479     \sa SetTitleL()
   540     \sa SetTitleL()
   480 */
   541 */
   481 EXPORT_C const TPtrC CHbDeviceNotificationDialogSymbian::Title() const
   542 EXPORT_C const TPtrC CHbDeviceNotificationDialogSymbian::Title() const
   482     {
   543     {
   488         }
   549         }
   489     return TPtrC(KNullDesC());
   550     return TPtrC(KNullDesC());
   490     }
   551     }
   491     
   552     
   492 /*!
   553 /*!
   493     Enable user interaction on dialog. Setting is not set, if Show() or Update()
   554     Enables user interaction on dialog.
   494     is not called.
   555 
   495     \param aEnable - When enabled, activation event is notified via observer interface.
   556     \param aEnable True enables activation event notification via observer interface.
   496 
   557 
   497     Default value is false.
   558     \sa IsTouchActivating(), ShowL(), UpdateL(), MCHbDeviceNotificationDialogSymbianObserver
   498     \sa ShowL(), UpdateL(), MCHbDeviceNotificationDialogSymbianObserver.
       
   499 */
   559 */
   500 EXPORT_C void CHbDeviceNotificationDialogSymbian::EnableTouchActivation(TBool aEnable)
   560 EXPORT_C void CHbDeviceNotificationDialogSymbian::EnableTouchActivation(TBool aEnable)
   501     {
   561     {
   502     d->iEnable = aEnable;    
   562     d->iEnable.iValue = aEnable;
   503     }
   563     d->iEnable.iChanged = ETrue;
   504 
   564     }
   505 /*!
   565 
   506     Get touch activation setting.
   566 /*!
       
   567     Returns touch activation setting.  Default value is false.
   507 
   568 
   508     \sa EnableTouchActivation()
   569     \sa EnableTouchActivation()
   509 */
   570 */
   510 EXPORT_C TBool CHbDeviceNotificationDialogSymbian::IsTouchActivating() const
   571 EXPORT_C TBool CHbDeviceNotificationDialogSymbian::IsTouchActivating() const
   511     {        
   572     {        
   512     return d->iEnable; 
   573     return d->iEnable.iValue; 
   513     }
   574     }
   514 
   575 
   515 /*!
   576 /*!
   516     Set dialog timeout. Timeout is not set, if Show() or Update()
   577     Set dialog timeout. 
   517     is not called.
   578 
   518     \param aTimeout - Set timeout for dialog.
   579     \param aTimeout Dialog timeout in milliseconds.
   519 
   580 
   520     Default value is KHbLongNotificationDialogTimeout (3000 ms).
   581     \sa Timeout(), ShowL(), UpdateL()
   521     \sa ShowL(), UpdateL()
       
   522 */
   582 */
   523 EXPORT_C void CHbDeviceNotificationDialogSymbian::SetTimeout(TInt aTimeout)
   583 EXPORT_C void CHbDeviceNotificationDialogSymbian::SetTimeout(TInt aTimeout)
   524     {
   584     {
   525     d->iTimeout = aTimeout;
   585     d->iTimeout.iValue = aTimeout;
   526     }
   586     d->iTimeout.iChanged = ETrue;
   527 
   587     }
   528 /*!
   588 
   529     Get timeout setting.
   589 /*!
       
   590     Returns timeout. Default value is KHbLongNotificationDialogTimeout (3000 ms).
   530 
   591 
   531     \sa SetTimeout()
   592     \sa SetTimeout()
   532 */
   593 */
   533 EXPORT_C TInt CHbDeviceNotificationDialogSymbian::Timeout() const
   594 EXPORT_C TInt CHbDeviceNotificationDialogSymbian::Timeout() const
   534     {    
   595     {    
   535     return d->iTimeout;
   596     return d->iTimeout.iValue;
   536     }
   597     }
   537 
   598 
   538 /*!
   599 /*!
   539     Set dialog title text wrapping. Text wrapping is not set, if Show() or Update()
   600     Sets title text wrapping. The title can wrap only if there is no text for the dialog.
   540     is not called.
   601     The title can wrap to a maximum of two lines. SetTextL() also changes title text wrapping.
   541     \param aWrapping - Defines title text wrapping.
   602 
   542 
   603 
   543     Default value is CHbDeviceNotificationDialogSymbian::TextNoWrap.
   604     \param aWrapping Title text wrapping.
   544     \sa ShowL(), UpdateL()
   605 
       
   606     \sa TitleTextWrapping(), SetTextL(), ShowL(), UpdateL()
   545 */
   607 */
   546 EXPORT_C void CHbDeviceNotificationDialogSymbian::SetTitleTextWrapping(
   608 EXPORT_C void CHbDeviceNotificationDialogSymbian::SetTitleTextWrapping(
   547     TextWrapping aWrapping)
   609     TextWrapping aWrapping)
   548     {
   610     {
   549     d->iWrap = aWrapping;    
   611     d->iWrap.iValue = aWrapping;
   550     }
   612     d->iWrap.iChanged = ETrue;
   551 
   613     }
   552 /*!
   614 
   553     Get title text wrapping setting.
   615 /*!
       
   616     Returns title text wrapping.
       
   617 
       
   618     The title can wrap only if dialog text is empty. The title can wrap to a maximum of two lines.
       
   619     The default is CHbDeviceNotificationDialogSymbian::TextWordWrap.
   554 
   620 
   555     \sa SetTitleTextWrapping()
   621     \sa SetTitleTextWrapping()
   556 */
   622 */
   557 EXPORT_C CHbDeviceNotificationDialogSymbian::TextWrapping CHbDeviceNotificationDialogSymbian::TitleTextWrapping() const
   623 EXPORT_C CHbDeviceNotificationDialogSymbian::TextWrapping CHbDeviceNotificationDialogSymbian::TitleTextWrapping() const
   558     {    
   624     {
   559     return d->iWrap;
   625     if (d->iWrap.iChanged) {
   560     }
   626         return static_cast<TextWrapping>(d->iWrap.iValue);
   561     
   627     } else {
   562 /*!
   628         return Text().Length() == 0 ? TextWordWrap : TextNoWrap;
   563     Show the dialog.
   629     }
   564     \code
   630     }
   565     // example to show dialog.
   631     
   566     iNotificationDialog->SetTitleL("Dialog title text");
   632 /*!
   567     iNotificationDialog->ShowL();
   633     Shows a notification dialog and returns immediately without waiting for it to close.
   568     \endcode
   634     Closing of the dialog and tapping of dialog is indicated by MHbDeviceNotificationDialogObserver
       
   635     callback interface. Dialog can be updated while showing by property setters and then calling
       
   636     UpdateL().
       
   637 
       
   638     \sa UpdateL(), Close(), MHbDeviceNotificationDialogObserver
   569 */
   639 */
   570 EXPORT_C void CHbDeviceNotificationDialogSymbian::ShowL()
   640 EXPORT_C void CHbDeviceNotificationDialogSymbian::ShowL()
   571     {
   641     {
   572     d->ShowL();
   642     d->ShowL();
   573     }
   643     }
   574 
   644 
   575 /*!
   645 /*!
   576     Update the dialog. Show must be called before update can be used.
   646     Updates changed properties to a showing notification dialog via interprocess
   577     \code
   647     communication. Has no effect if ShowL() has not been called or the dialog has
   578     // example to update already showing dialog.
   648     closed already.
   579     iNotificationDialog->SetTitleL("Update title");
   649 
   580     iNotificationDialog->UpdateL();
   650     \sa ShowL()
   581     \endcode
       
   582 */
   651 */
   583 
   652 
   584 EXPORT_C void CHbDeviceNotificationDialogSymbian::UpdateL()
   653 EXPORT_C void CHbDeviceNotificationDialogSymbian::UpdateL()
   585     {
   654     {
   586     d->UpdateL();
   655     d->UpdateL();
   587     }
   656     }
   588 
   657 
   589 /*!
   658 /*!
   590     Close the dialog. Method has no effect if convenience methods
   659     Closes a device notification dialog.
   591     are used to show device notification dialog.
       
   592 */
   660 */
   593 EXPORT_C void CHbDeviceNotificationDialogSymbian::Close()
   661 EXPORT_C void CHbDeviceNotificationDialogSymbian::Close()
   594     {
   662     {
   595     d->Close();
   663     d->Close();
   596     }
   664     }
   597 
   665 
   598 /*!
   666 /*!
   599     Constructor. 
   667     Constructs CHbDeviceNotificationDialogSymbian.
   600 */
   668 */
   601 CHbDeviceNotificationDialogSymbian::CHbDeviceNotificationDialogSymbian()
   669 CHbDeviceNotificationDialogSymbian::CHbDeviceNotificationDialogSymbian()
   602     {
   670     {
   603     }
   671     }
   604 
   672 
   609     MHbDeviceNotificationDialogObserver* aObserver)
   677     MHbDeviceNotificationDialogObserver* aObserver)
   610     {
   678     {
   611     d = new (ELeave) CHbDeviceNotificationDialogSymbianPrivate;
   679     d = new (ELeave) CHbDeviceNotificationDialogSymbianPrivate;
   612     d->ConstructL(this);
   680     d->ConstructL(this);
   613     d->iObserver = aObserver;
   681     d->iObserver = aObserver;
   614     EnableTouchActivation(EFalse);
   682     }
   615     SetTimeout(KHbLongNotificationDialogTimeout);
       
   616     SetTitleTextWrapping(CHbDeviceNotificationDialogSymbian::TextWordWrap);
       
   617     }