examples/SFExamples/NotifierExample/NotifierTestConsole/NotifierTestConsole.cpp

00001 // NotifierTestConsole.cpp
00002 //
00003 // Copyright (C) Symbian Software Ltd 2007.  All rights reserved.
00004 
00005 // Demonstrates use of default notifiers and launch of custom notifier
00006 
00007 #include "CommonFramework.h"
00008 #include <e32math.h>
00009 
00010 #include <Notifier1Uids.h> //For UID of custom notifier
00011 
00012 //#include <aknglobalnote.h>  //For Avkon global notifier
00013 //#include <avkon.rsg>
00014 
00015 //
00016 // Common literal text
00017 //
00018 
00019 
00020 // Do the example
00021 LOCAL_C void doExampleL()
00022     {
00023     _LIT(KTxtDisplayInfoMsg,"Display InfoMessage \n");
00024     console->Printf(KTxtDisplayInfoMsg);
00025     //Single line message using Infoprint
00026     _LIT(KTxtMsg,"A message");
00027     User::InfoPrint(KTxtMsg);
00028     User::After(4000000);
00029     
00030     //Two line message using RNotifier. Note that as this is an asynchronous request
00031     //You might alternatively embed the handling in an Active object.
00032     _LIT(KTxtDisplayDefRnotifier,"Display default RNotifier \n");
00033         console->Printf(KTxtDisplayDefRnotifier);
00034     _LIT(KTxtLine1,"Title (first) line.");
00035     _LIT(KTxtLine2,"Second (message) line. Text wraps and scrolls");
00036     _LIT(KButt1,"Button1");
00037     _LIT(KButt2,"Button2");
00038     TInt whichbutton(-1);
00039     TRequestStatus stat;
00040     RNotifier notifier;
00041     User::LeaveIfError(notifier.Connect());
00042     notifier.Notify(KTxtLine1,KTxtLine2,KButt1,KButt2,whichbutton,stat);
00043     User::WaitForRequest(stat);
00044     if (whichbutton==0)
00045         {
00046         // first button selected
00047         }
00048     if (whichbutton==1)
00049         {
00050         // Second button selected
00051         }
00052     notifier.Close();
00053     
00054     //Display the custom notifier for 3 seconds, then change the text displayed
00055     //After a further 5 seconds, cancel the notifier.
00056     _LIT(KTxtDisplayCustomRnotifier,"Display custom notifier\n");
00057         console->Printf(KTxtDisplayCustomRnotifier);   
00058         
00059         RNotifier notifierSession;
00060         User::LeaveIfError(notifierSession.Connect());
00061         CleanupClosePushL(notifierSession);
00062         
00063         _LIT8(KNotifier1StartText,"Notifier1 Launched");
00064         TInt err = notifierSession.StartNotifier(KNotifier1Uid, KNotifier1StartText);
00065         
00066         User::LeaveIfError(err);
00067         User::After(3000000);
00068     _LIT(KTxtDisplayUpdateRnotifier,"Update custom notifier\n");
00069         console->Printf(KTxtDisplayUpdateRnotifier);    
00070         
00071         TBuf8<1> dummy;
00072         _LIT8(KNotifier1UpdateText,"Notifier1 Updated");
00073         notifierSession.UpdateNotifier(KNotifier1Uid, KNotifier1UpdateText, dummy);
00074         User::After(4000000);
00075         notifierSession.CancelNotifier(KNotifier1Uid);
00076         CleanupStack::PopAndDestroy(&notifierSession);
00077         }
00078 
00079         
00080 
00081 
00082 
00083         
00084         

Generated by  doxygen 1.6.2