calendarui/controller/inc/calenstatetable.h
changeset 0 f979ecb2b13e
child 29 12af337248b1
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Calendar controller
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CALENSTATES_H
       
    20 #define CALENSTATES_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <calencommands.hrh>
       
    25 #include <calennotificationhandler.h>      // TCalenNotification
       
    26 
       
    27 // ENUMERATIONS
       
    28 // Enumeration of the various possible states that the controller can be
       
    29 // be in.
       
    30 enum TControllerState
       
    31     {
       
    32     EIdle                       = 1 << 0,
       
    33     EWaitingForInstanceView     = 1 << 1,
       
    34     EWaitingForEntryView        = 1 << 2,
       
    35     EConstructingNativeViews    = 1 << 3,
       
    36     EConstructingPlugins        = 1 << 4,
       
    37     EExiting                    = 1 << 5,
       
    38 
       
    39     ESending                    = 1 << 6,
       
    40     EDeleting                   = 1 << 7,
       
    41     EEditing                    = 1 << 8,
       
    42     EViewing                    = 1 << 9,
       
    43     ESaving                     = 1 << 10,
       
    44     EPrinting                   = 1 << 11,
       
    45     EDisplayingSettings         = 1 << 12,
       
    46     EDisplayingHelp             = 1 << 13
       
    47     };
       
    48 
       
    49 
       
    50 // Each command has an associated state table entry, ( which is a structure
       
    51 // than a class in order for it to be used as elements within a constant
       
    52 // array by removing the need for a constructor). The state table entry
       
    53 // contains details of what states it is valid to call the command in,
       
    54 // what the state should be changed to as the command is processed, and
       
    55 // what notifications will revert the controller to its previous state if
       
    56 // applicable.
       
    57 struct TStateTableEntry
       
    58     {
       
    59     // Bit field for what states the command it is valid to call the command
       
    60     TInt    iValidStates;
       
    61 
       
    62     // The state the contoller should be placed in after the command is called
       
    63     TControllerState    iNextState;
       
    64 
       
    65     // Bit field containing the notifications that will move the contoller to
       
    66     // its previous state if applicable.
       
    67     TInt    iCompleteNotification;
       
    68     };
       
    69 
       
    70 // CONSTANTS
       
    71 
       
    72 // Bitmask to represent any notifications
       
    73 const TInt KAnyCalenNotification = -1;
       
    74 
       
    75 const TInt KCalenNoNotification = 0;
       
    76 
       
    77 // Bitmask representing the four notifications that
       
    78 // may be received when the editor is closed.
       
    79 const TInt KCalenEditorClosedNotification = ECalenNotifyEntrySaved
       
    80                                             | ECalenNotifyEntryDeleted
       
    81                                             | ECalenNotifyInstanceDeleted
       
    82                                             | ECalenNotifyEntryClosed;
       
    83 
       
    84 // Bitmask represents completion of a delete command
       
    85 const TInt KCalenDeleteComplete = ECalenNotifyEntryDeleted 
       
    86                                             | ECalenNotifyDeleteFailed
       
    87                                             | ECalenNotifyMultipleEntriesDeleted;
       
    88 
       
    89 
       
    90 // State table entry that represents the controllers idle state
       
    91 const TStateTableEntry KControllerIdleState
       
    92                      = { EIdle, EIdle, KCalenNoNotification};
       
    93 
       
    94 // State table entry representing the controller state when the entry view is
       
    95 // being created asyncronously.
       
    96 const TStateTableEntry KControllerWaitingForEntryView
       
    97                 = { EIdle, EWaitingForEntryView, ECalenNotifyViewCreated  };
       
    98 
       
    99 // State table entry representing the controller state when the instance view is
       
   100 // being created asyncronously.
       
   101 const TStateTableEntry KControllerWaitingForInstanceView
       
   102                 = { EIdle, EWaitingForInstanceView, ECalenNotifyViewCreated };
       
   103 
       
   104 const TInt KCalenLaunchEditorStates 
       
   105                         = EIdle | EWaitingForInstanceView | EWaitingForEntryView;
       
   106 
       
   107 // State lookup table for view manager commands
       
   108 // It is assumed that all view commands return immediately, therefore they will not
       
   109 // change the state of the controller.
       
   110 const TStateTableEntry KStateTable[] =
       
   111     {
       
   112     /* ECalenMonthView */
       
   113     { EIdle , EIdle, KCalenNoNotification },
       
   114 
       
   115     /* ECalenWeekView */
       
   116     { EIdle , EIdle, KCalenNoNotification },
       
   117 
       
   118     /* ECalenDayView */
       
   119     { EIdle , EIdle, KCalenNoNotification },
       
   120 
       
   121     /* ECalenTodoView */
       
   122     { EIdle , EIdle, KCalenNoNotification },
       
   123 
       
   124     /* ECalenForwardsToDayView */
       
   125     { EIdle , EIdle, KCalenNoNotification },
       
   126     
       
   127     { EIdle , EIdle, KCalenNoNotification },
       
   128 
       
   129     /* ECalenNextView */
       
   130     { EIdle , EIdle, KCalenNoNotification },
       
   131 
       
   132     /* ECalenPrevView */
       
   133     { EIdle , EIdle, KCalenNoNotification },
       
   134 
       
   135     /* ECalenCancelViewCycling */
       
   136     { EIdle , EIdle, KCalenNoNotification },
       
   137 
       
   138     /* ECalenShowToolbar */
       
   139     { EIdle , EIdle, KCalenNoNotification },
       
   140 
       
   141     /* ECalenHideToolbar */
       
   142     { EIdle , EIdle, KCalenNoNotification },
       
   143 
       
   144     /* ECalenUpdateToolbar */
       
   145     { EIdle , EIdle, KCalenNoNotification },
       
   146 
       
   147     /* ECalenStartActiveStep */
       
   148     { EIdle , EIdle, KCalenNoNotification },
       
   149 
       
   150     /* ECalenGotoToday */
       
   151     { EIdle , EIdle, KCalenNoNotification },
       
   152 
       
   153     /* ECalenGotoDate */
       
   154     { EIdle , EIdle, KCalenNoNotification },
       
   155 
       
   156     // State lookup table for edit ui commands
       
   157 
       
   158     /* ECalenNewMeeting */
       
   159     { KCalenLaunchEditorStates , EEditing, KCalenEditorClosedNotification  },
       
   160 
       
   161     /* ECalenNewTodo */
       
   162     { KCalenLaunchEditorStates , EEditing, KCalenEditorClosedNotification },
       
   163 
       
   164     /* ECalenNewAnniv */
       
   165     { KCalenLaunchEditorStates , EEditing, KCalenEditorClosedNotification },
       
   166 
       
   167     /* ECalenNewDayNote */
       
   168     { KCalenLaunchEditorStates , EEditing, KCalenEditorClosedNotification },
       
   169 
       
   170     /* ECalenNewReminder */
       
   171     { KCalenLaunchEditorStates , EEditing, KCalenEditorClosedNotification },
       
   172 
       
   173     /* ECalenNewMeetingRequest */
       
   174     { KCalenLaunchEditorStates, EEditing, KCalenEditorClosedNotification },
       
   175 
       
   176     /* ECalenNewEntry */
       
   177     { KCalenLaunchEditorStates , EEditing, KCalenEditorClosedNotification },
       
   178 
       
   179     /* ECalenEditCurrentEntry */
       
   180     { EIdle , EEditing, KCalenEditorClosedNotification },
       
   181 
       
   182     /* ECalenEditSeries */
       
   183     { EIdle , EEditing, KCalenEditorClosedNotification },
       
   184 
       
   185     /* ECalenEditOccurrence */
       
   186     { EIdle , EEditing, KCalenEditorClosedNotification },
       
   187 
       
   188     /* ECalenViewCurrentEntry */
       
   189     { EIdle , EViewing, KCalenEditorClosedNotification },
       
   190 
       
   191     /* ECalenNotifyFocusChange */
       
   192     { EIdle , EIdle, KCalenNoNotification }, 
       
   193 
       
   194     /* ECalenCompleteTodo */
       
   195     { EIdle , EIdle, ECalenNotifyEntrySaved | ECalenNotifyCommandFailed }, 
       
   196 
       
   197     /* ECalenRestoreTodo */
       
   198     { EIdle , EIdle, ECalenNotifyEntrySaved | ECalenNotifyCommandFailed }, 
       
   199 
       
   200     /* ECalenSend */
       
   201     { EIdle | EViewing | EEditing, ESending, KAnyCalenNotification }, 
       
   202 
       
   203     // State lookup table for delete Ui commands
       
   204 
       
   205     /* ECalenDeleteCurrentEntry */
       
   206     { EIdle | EViewing | EEditing , EDeleting, KCalenDeleteComplete  },
       
   207 
       
   208     /* ECalenDeleteEntryWithoutQuery */
       
   209     { EIdle | EViewing | EEditing , EDeleting, KCalenDeleteComplete },
       
   210 
       
   211     /* ECalenDeleteSeries */
       
   212     { EIdle | EViewing | EEditing , EDeleting, KCalenDeleteComplete },
       
   213 
       
   214     /* ECalenDeleteOccurrence */
       
   215     { EIdle | EViewing | EEditing , EDeleting, KCalenDeleteComplete },
       
   216 
       
   217     /* ECalenDeleteSingleInstance */
       
   218     {EIdle | EViewing | EEditing , EDeleting, KCalenDeleteComplete  },
       
   219 
       
   220     /* ECalenDeleteSingleInstanceWithRepeatType */
       
   221     { EIdle | EViewing | EEditing , EDeleting, KCalenDeleteComplete },
       
   222 
       
   223     /* ECalenDeleteAllEntries */
       
   224     { EIdle , EDeleting, KCalenDeleteComplete },
       
   225 
       
   226     /* ECalenDeleteEntriesBeforeDate */
       
   227     { EIdle , EDeleting, KCalenDeleteComplete },
       
   228 
       
   229     /* ECalenShowSettings */
       
   230      { EIdle , EDisplayingSettings, ECalenNotifySettingsClosed }
       
   231     };
       
   232 
       
   233 // The number of commands in each of the state tables can be calculated from the size of the
       
   234 // table at compilation.
       
   235 const TInt KNumberCommands = sizeof( KStateTable ) / sizeof( TStateTableEntry );
       
   236 
       
   237 // A TFixedArray wrapper class has been typedef'ed for the four
       
   238 // lookup tables for out of bounds safety and readablity of
       
   239 // the code.
       
   240 typedef TFixedArray< TStateTableEntry, KNumberCommands > TStateTable;
       
   241 
       
   242 #endif // CALENCONTROLLERSTATES_H
       
   243 
       
   244 // End of file
       
   245