Archived:Launching Calendar application in day view using Symbian C++

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Article Metadata
Platform(s): S60 3rd Edition and S60 3rd Edition, FP1
S60 3rd Edition FP1
S60 3rd Edition (initial release)
Created: User:Technical writer 1 (14 Sep 2007)
Last edited: hamishwillee (15 Jun 2012)


Launching Calendar application in day view


The following code example demonstrates how to launch the Calendar application in day view. The date will be specified with the aDate parameter. If aDate is NULL, Calendar will open the view in current date (today).

Capability requirements: SwEvent


 #include <w32std.h>    // RWsSession (ws32.lib)
 #include <apgtask.h>   // TApaTaskList,TApaTask (apgrfx.lib)
 #include <apgcli.h>    // RApaLsSession (apgrfx.lib)
 #include <apaid.h>     // TApaAppInfo (apparc.lib)
 #include <apacmdln.h>  // CApaCommandLine (apparc.lib)


   // UID of the Calendar Application:
   const TUid KCalendarAppUID = { 0x10005901 };
   // Format strings for constructing parameters passed to Calendar
   _LIT( KCalCmdTODAY, "TODAY" ); 
   _LIT( KCalCmdDATE, "DATE " );
   _LIT( KCmdTimeFormat, "%F%Y %M %D %H %T %S %C" );
   #define KCalTimeParamMaxLen 36


   void LaunchCalendarL( const TTime* aDate )
     TBuf<KCalTimeParamMaxLen> paramsBuf( KCalCmdTODAY );
     // if a specific date is given, construct command line parameters
     // using "DATE YYYY MM DD HH MM SS MMMMMM" format
     if( aDate )         
       aDate->FormatL( paramsBuf, KCmdTimeFormat() );
       paramsBuf.Insert( 0, KCalCmdDATE );
     // package the parameters, so it can be passed
     // as an 8-bit descriptor
     TPckg< TBuf16<KCalTimeParamMaxLen> > paramsPkg( paramsBuf );
     // Check if the Calendar is already running
     TApaTaskList taskList( iCoeEnv->WsSession() );
     TApaTask task = taskList.FindApp( KCalendarAppUID );
     if( task.Exists() )  // Calendar already open
       TInt ret = task.SendMessage( KNullUid, paramsPkg ); // requires SwEvent       
     else  // Launch Calendar in day view
       TApaAppInfo appInfo;
       RApaLsSession lsSession;
       CleanupClosePushL( lsSession );
       if( lsSession.GetAppInfo( appInfo, KCalendarAppUID ) == KErrNone )
         // Construct a CApaCommandLine instance and start Calendar
         CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
         cmdLine->SetExecutableNameL( appInfo.iFullName );
         cmdLine->SetCommandL( EApaCommandRun );
         cmdLine->SetTailEndL( paramsPkg );
         lsSession.StartApp( *cmdLine );
         CleanupStack::PopAndDestroy( cmdLine );
       CleanupStack::PopAndDestroy();  // close lsSession
This page was last modified on 15 June 2012, at 04:02.
38 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.