calendarui/controller/inc/calencmdlineparser.h
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  command line parse utils
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __CALCMDLINEPARSER_H__
       
    21 #define __CALCMDLINEPARSER_H__
       
    22 
       
    23 
       
    24 //  INCLUDES
       
    25 #include <e32base.h>
       
    26 #include <calcommon.h>
       
    27 
       
    28 // DATA TYPES
       
    29 struct TCalenCmdParameters
       
    30     {
       
    31     TInt iCommandType;
       
    32     TUint32 iLocalUid;
       
    33     TInt iFlag;
       
    34     TBuf<256> iCalenFileName;
       
    35     TTime iTime;
       
    36     };
       
    37 
       
    38 
       
    39 // CONSTANTS
       
    40 _LIT( KComma, "," );
       
    41 _LIT( KSpace, " " );
       
    42 
       
    43 // Launch calendar to the Day view with todays date
       
    44 _LIT( KCommandDefault,               "TODAY" );
       
    45 
       
    46 // Command line format is:
       
    47 // CMD YEAR MONTH DAY HOUR MINUTE SECONDS MICROSECONDS
       
    48 // Date components MUST be specified in the above order
       
    49 // but date components are now optional
       
    50 // For example:
       
    51 // DAY 2006
       
    52 // Would open Calendar day view on 1st January 2006
       
    53 //
       
    54 // DAY 2006 03
       
    55 // Would open Calendar day view on the 1st March 2006
       
    56 //
       
    57 // DAY 2006 03 13
       
    58 // Would open Calendar day view on 13th March 2006
       
    59 _LIT( KCommandTime,                 "DATE");
       
    60 
       
    61 // Launch calendar from the command line to new entry editors
       
    62 _LIT( KCommandNewMeeting,           "NEW_MEETING" );
       
    63 _LIT( KCommandNewMeetingRequest,    "NEW_MEETING_REQUEST" );
       
    64 _LIT( KCommandNewAnniv,             "NEW_ANNIV" );
       
    65 _LIT( KCommandNewTodo,              "NEW_TODO" );
       
    66 _LIT( KCommandNewEntry,             "NEW_ENTRY" );
       
    67 
       
    68 // Launch Calendar from the command line using the Local UID of
       
    69 // an existing entry. The entry can be opened in either the editor or
       
    70 // the viewer.  Can be followed by time parameters to open a specific
       
    71 // instance of a repeating entry.
       
    72 _LIT( KCommandUid,                  "LUID" );
       
    73 _LIT( KCommandViewer,               "LUIDVIEWER" );
       
    74 _LIT( KCommandAlarmViewer,          "LUIDALARMVIEWER");
       
    75 _LIT( KCommandAlarmViewerNoSnooze,  "LUIDALARMVIEWER_NOSNOOZE");
       
    76 
       
    77 // Launch calendar from the command line to a specific view. Can be
       
    78 // followed by time parameters to open the view on a specific day
       
    79 _LIT( KCommandDefaultView,          "DEFAULT" );
       
    80 _LIT( KCommandDay,                  "DAY" );
       
    81 _LIT( KCommandWeek,                 "WEEK" );
       
    82 _LIT( KCommandMonth,                "MONTH" );
       
    83 _LIT( KCommandToDo,                 "TODO" );
       
    84 
       
    85 // CLASS DECLARATION
       
    86 
       
    87 /**
       
    88 * CCalCmdLineParser is used to parse and set commandlines for Calendar.
       
    89 * Command line will take parameters like Agenda Instance ID which will
       
    90 * make easy way to start calendar with some specific event active.
       
    91 */
       
    92 NONSHARABLE_CLASS( CCalenCmdLineParser ) : public CBase
       
    93     {
       
    94 public:
       
    95     // Assumed indexes of command line components in the string array
       
    96     enum TCalCmdParam
       
    97         {
       
    98         ECalCmdLineCmd,             // Command index
       
    99         ECalCmdLineUid,             // Local UID of an entry
       
   100         ECalCmdLineFlag,            // Flag index
       
   101         ECalCmdCalFileName,           // Calendar DB name
       
   102         ECalCmdLineYear,            // Year index (optional)
       
   103         ECalCmdLineMonth,           // Month index (optional)
       
   104         ECalCmdLineDay,             // Day index (optional)
       
   105         ECalCmdLineHour,            // Hour index (optional)
       
   106         ECalCmdLineMinute,          // Minute index (optional)
       
   107         ECalCmdLineSeconds,         // Second index (optional)
       
   108         ECalCmdLineMicroSeconds,    // Microsecond index (optional)
       
   109         ECalCmdMaxParamCount        // Maximum number of allowed parameters
       
   110         };
       
   111 
       
   112     // Calendar start up mode as determined by ECalCmdLineCmd
       
   113     // and optional date components
       
   114     enum TCalStartType
       
   115         {
       
   116         EStartTypeToday=2005,       // start in Day view using todays date
       
   117         EStartTypeUid,              // start by local uid to entry editor
       
   118         EStartTypeUidViewer,        // start by local uid to entry viewer
       
   119         EStartTypeUidAlarmViewer,   // start by local uid to entry viewer with alarm softkeys
       
   120         EStartTypeUidAlarmViewerNoSnooze,  // start by local uid to entry viewer without snooze key
       
   121         EStartTypeDate,             // start by date (requires at least 1 date component)
       
   122         EStartTypeDefault,          // start in default view
       
   123         EStartTypeDay,              // start in Day view
       
   124         EStartTypeToDo,             // start in Todo view
       
   125         EStartTypeWeek,             // start in Week view
       
   126         EStartTypeMonth,            // start in Month view
       
   127         EStartTypeNewMeeting,       // start new Meeting editor
       
   128         EStartTypeNewMeetingRequest,// start new Meeting request editor (if available)
       
   129         EStartTypeNewAnniv,         // start new Anniversary editor
       
   130         EStartTypeNewTodo,          // start new Todo editor
       
   131         };
       
   132 
       
   133 public:
       
   134     /**
       
   135      * Static constructor
       
   136      * @return new instance of CCalCmdLineParser
       
   137      **/
       
   138     static CCalenCmdLineParser* NewL();
       
   139 
       
   140     /**
       
   141      * parse commandline
       
   142      * @param aCommandLine is descriptor containing the command line to be parsed
       
   143      **/
       
   144     void ParseCommandLineL( const TDesC& aCommandLine );
       
   145 
       
   146     /**
       
   147      * @return the actual parameters
       
   148      **/
       
   149      TCalenCmdParameters CommandLineParameters();
       
   150 
       
   151     /**
       
   152      * Destructor
       
   153      **/
       
   154     virtual ~CCalenCmdLineParser();
       
   155 
       
   156 private:
       
   157     /**
       
   158      * Constructor
       
   159      **/
       
   160     CCalenCmdLineParser();
       
   161 
       
   162     /**
       
   163      * Add descriptor to the list
       
   164      * @param aString is the string to be added into the list
       
   165      **/
       
   166     void AddL( const TDesC& aString );
       
   167 
       
   168     /**
       
   169      * Return item at position
       
   170      * @param aIndex is the index of desired item
       
   171      * @return Pointer descriptor of desired line
       
   172      **/
       
   173     TPtr ItemL( TInt aIndex );
       
   174 
       
   175     /**
       
   176      * Parse given string to invidual list items
       
   177      * @param aString is the string to be parsed
       
   178      * @param aDelimiter is the delimiter used to parse lines<P>
       
   179      * Common delimiter is comma but can be also space etc.
       
   180      **/
       
   181     void ParseStringL( const TDesC& aString, const TDesC& aDelimiter );
       
   182 
       
   183     /**
       
   184      * Convert Descriptor to parameter type
       
   185      **/
       
   186     TInt DesToCmdParamTypeL( const TDesC& aCmdParamType );
       
   187 
       
   188     /**
       
   189      * Extract TTime from param strings.
       
   190      * @return A TTime object.
       
   191      **/
       
   192     TTime TimeFromParamsL( void );
       
   193 
       
   194 private:
       
   195     // Storage for the strings
       
   196     RPointerArray<HBufC> iStrings;
       
   197 
       
   198     // Command line
       
   199     HBufC* iCommandLine;
       
   200 
       
   201     // Storage for the strings
       
   202     TCalenCmdParameters iCmdLineParameters;
       
   203 
       
   204     };
       
   205 
       
   206 #endif // __CALCMDLINEPARSER_H__
       
   207 
       
   208 
       
   209 // End of File