calendarui/server/CalenSvr/src/CalenSvrBootManager.cpp
changeset 0 f979ecb2b13e
child 60 96907930389d
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2004 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:  Provides asynchronus methods for the multistep boot sequence.
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 //debug
       
    21 #include "calendarui_debug.h"
       
    22 
       
    23 #include "CalenSvrBootManager.h"
       
    24 
       
    25 #include "CalenServer.h"
       
    26 #include <calenglobaldata.h>
       
    27 
       
    28 #include <featmgr.h>
       
    29 
       
    30 // LOCAL CONSTANTS AND MACROS
       
    31 
       
    32 enum TCalenSvrBootManagerPanic
       
    33     {
       
    34     EPanicInvalidState,
       
    35     EPanicRunError,
       
    36     EPanicCorruptedObserverDll,
       
    37     EPanicIncorrectObserverUID
       
    38     };
       
    39 
       
    40 static void Panic(TInt aReason)
       
    41     {
       
    42     TRACE_ENTRY_POINT;
       
    43     
       
    44     _LIT(KCategory, "CCalenServerBootHandler");
       
    45     User::Panic(KCategory, aReason);
       
    46     
       
    47     TRACE_EXIT_POINT;
       
    48     };
       
    49 
       
    50 
       
    51 // CLASS METHOD DECLARATIONS
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // ?classname::?member_function
       
    55 // ?implementation_description
       
    56 // (other items were commented in a header).
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 CCalenSvrBootManager* CCalenSvrBootManager::NewL(CCalenServer& aServer)
       
    60     {
       
    61     TRACE_ENTRY_POINT;
       
    62     
       
    63     CCalenSvrBootManager* self = new( ELeave )CCalenSvrBootManager( aServer );
       
    64     CleanupStack::PushL(self);
       
    65     self->ConstructL();
       
    66     CleanupStack::Pop(self);
       
    67     
       
    68     TRACE_EXIT_POINT;
       
    69     return self;
       
    70     }
       
    71 
       
    72 // -----------------------------------------------------------------------------
       
    73 // ?classname::?member_function
       
    74 // ?implementation_description
       
    75 // (other items were commented in a header).
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 CCalenSvrBootManager::CCalenSvrBootManager(CCalenServer& aServer)
       
    79     : CActive(0), iState(EStateInit), iServer(aServer)
       
    80     {
       
    81     TRACE_ENTRY_POINT;
       
    82     
       
    83     CActiveScheduler::Add(this);
       
    84     
       
    85     TRACE_EXIT_POINT;
       
    86     }
       
    87 
       
    88 // -----------------------------------------------------------------------------
       
    89 // ?classname::?member_function
       
    90 // ?implementation_description
       
    91 // (other items were commented in a header).
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 void CCalenSvrBootManager::ConstructL(void)
       
    95     {
       
    96     TRACE_ENTRY_POINT;
       
    97     
       
    98     Start();
       
    99     
       
   100     TRACE_EXIT_POINT;
       
   101     }
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // ?classname::?member_function
       
   105 // ?implementation_description
       
   106 // (other items were commented in a header).
       
   107 // -----------------------------------------------------------------------------
       
   108 //
       
   109 void CCalenSvrBootManager::Start()
       
   110     {
       
   111     TRACE_ENTRY_POINT;
       
   112     
       
   113     __ASSERT_ALWAYS(!IsActive(), User::Invariant());
       
   114     iState = EStateCreateAgendaFile;
       
   115     CompleteSelf();
       
   116     
       
   117     TRACE_EXIT_POINT;
       
   118     }
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // ?classname::?member_function
       
   122 // ?implementation_description
       
   123 // (other items were commented in a header).
       
   124 // -----------------------------------------------------------------------------
       
   125 //
       
   126 CCalenSvrBootManager::~CCalenSvrBootManager()
       
   127     {
       
   128     TRACE_ENTRY_POINT;
       
   129     
       
   130     Cancel(); // DoCancel destroy everything
       
   131     
       
   132     TRACE_EXIT_POINT;
       
   133     }
       
   134 
       
   135 // -----------------------------------------------------------------------------
       
   136 // ?classname::?member_function
       
   137 // ?implementation_description
       
   138 // (other items were commented in a header).
       
   139 // -----------------------------------------------------------------------------
       
   140 //
       
   141 void CCalenSvrBootManager::DoCancel()
       
   142     {
       
   143     TRACE_ENTRY_POINT;
       
   144     
       
   145     iState = EStateInit;
       
   146     
       
   147     TRACE_EXIT_POINT;
       
   148     }
       
   149 
       
   150 // -----------------------------------------------------------------------------
       
   151 // ?classname::?member_function
       
   152 // ?implementation_description
       
   153 // (other items were commented in a header).
       
   154 // -----------------------------------------------------------------------------
       
   155 //
       
   156 TInt CCalenSvrBootManager::RunError(TInt /*aError*/)
       
   157     {
       
   158     TRACE_ENTRY_POINT;
       
   159 
       
   160     // if database is corrupted or we run in to other troubles, we ignore them.
       
   161     iState = EStateReady;
       
   162     CompleteSelf();
       
   163     
       
   164     TRACE_EXIT_POINT;
       
   165     return KErrNone;
       
   166     }
       
   167 
       
   168 // -----------------------------------------------------------------------------
       
   169 // ?classname::?member_function
       
   170 // ?implementation_description
       
   171 // (other items were commented in a header).
       
   172 // -----------------------------------------------------------------------------
       
   173 //
       
   174 void CCalenSvrBootManager::RunL()
       
   175     {
       
   176     TRACE_ENTRY_POINT;
       
   177     
       
   178     switch (iState)
       
   179         {
       
   180         case EStateCreateAgendaFile:
       
   181             {
       
   182             CCalenGlobalData* gData  = CCalenGlobalData::Instance();
       
   183             if ( !gData  )
       
   184                 {
       
   185                 // Server doesn't need context change observer.
       
   186                 gData = CCalenGlobalData::NewL( *this, NULL );
       
   187                 }
       
   188                         
       
   189             CleanupReleasePushL( *gData );
       
   190             gData->CalSessionL();
       
   191             CleanupStack::PopAndDestroy( gData );
       
   192             iState = EStateReady;
       
   193             CompleteSelf();
       
   194             }
       
   195             break;
       
   196 
       
   197         case EStateReady:
       
   198             iServer.BootReadyL();
       
   199             break;
       
   200 
       
   201         default:
       
   202             Panic(EPanicInvalidState);
       
   203             break;
       
   204         }
       
   205     
       
   206     TRACE_EXIT_POINT;
       
   207     }
       
   208 
       
   209 // -----------------------------------------------------------------------------
       
   210 // ?classname::?member_function
       
   211 // ?implementation_description
       
   212 // (other items were commented in a header).
       
   213 // -----------------------------------------------------------------------------
       
   214 //
       
   215 void CCalenSvrBootManager::CompleteSelf()
       
   216     {
       
   217     TRACE_ENTRY_POINT;
       
   218 
       
   219     TRequestStatus* pStat = &iStatus;
       
   220     User::RequestComplete(pStat, KErrNone);
       
   221     SetActive();
       
   222     
       
   223     TRACE_EXIT_POINT;
       
   224     }
       
   225 
       
   226 // -----------------------------------------------------------------------------
       
   227 // CCalenSvrBootManager::Completed
       
   228 // Unused but needed as CCalenSvrBootManager needs
       
   229 // be derived from MCalProgressCallBack to call
       
   230 // CCalenGlobalData::NewL()
       
   231 // -----------------------------------------------------------------------------
       
   232 //    
       
   233 void CCalenSvrBootManager::Completed(TInt /*aError*/)
       
   234     {
       
   235     }
       
   236 
       
   237 // -----------------------------------------------------------------------------
       
   238 // CCalenSvrBootManager::NotifyProgress()
       
   239 // Unused but needed as CCalenSvrBootManager needs
       
   240 // be derived from MCalProgressCallBack to call
       
   241 // CCalenGlobalData::NewL()
       
   242 // -----------------------------------------------------------------------------
       
   243 //
       
   244 TBool CCalenSvrBootManager::NotifyProgress()
       
   245     {
       
   246     TRACE_ENTRY_POINT;
       
   247     
       
   248     return EFalse;
       
   249 
       
   250     TRACE_EXIT_POINT;
       
   251     }
       
   252 
       
   253 // -----------------------------------------------------------------------------
       
   254 // CCalenSvrBootManager::Progress
       
   255 // Unused but needed as CCalenSvrBootManager needs
       
   256 // be derived from MCalProgressCallBack to call
       
   257 // CCalenGlobalData::NewL()
       
   258 // -----------------------------------------------------------------------------
       
   259 //
       
   260 void CCalenSvrBootManager::Progress(TInt /*aPercentageCompleted*/)
       
   261     {
       
   262     TRACE_ENTRY_POINT;
       
   263     TRACE_EXIT_POINT;
       
   264     }
       
   265 
       
   266 // End of File