meetingui/meetingrequestutils/src/CMRUtilsCalDbNormal.cpp
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2005 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: Implemenatation for meeting request utils calendar db normal   
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // ----------------------------------------------------------------------------
       
    21 // INCLUDE FILES
       
    22 // ----------------------------------------------------------------------------
       
    23 //
       
    24 #include "CMRUtilsCalDbNormal.h"
       
    25 #include <CalEntryView.h>
       
    26 #include <CalInstanceView.h>
       
    27 #include <CalEntry.h>
       
    28 #include <CalSession.h>
       
    29 #include <CalCommon.h>
       
    30 #include <CalUser.h>
       
    31 
       
    32 // CONSTANTS
       
    33 /// Unnamed namespace for local definitions
       
    34 namespace {
       
    35 
       
    36 enum TPanicCode
       
    37     {
       
    38     EPanicUnexpectedCalEngStatus = 1
       
    39     };
       
    40 
       
    41 _LIT( KPanicMsg, "CMRUtilsCalDbNormal" );
       
    42 
       
    43 void Panic( TPanicCode aReason )
       
    44     {
       
    45     User::Panic( KPanicMsg, aReason );
       
    46     }
       
    47     
       
    48 }  // namespace
       
    49 
       
    50 // ----------------------------------------------------------------------------
       
    51 // MEMBER FUNCTIONS
       
    52 // ----------------------------------------------------------------------------
       
    53 //
       
    54 
       
    55 // ----------------------------------------------------------------------------
       
    56 // CMRUtilsCalDbNormal::NewL
       
    57 // ----------------------------------------------------------------------------
       
    58 //
       
    59 CMRUtilsCalDbNormal* CMRUtilsCalDbNormal::NewL(
       
    60     CCalSession& aCalSession,
       
    61     MMRUtilsCalDbObserver& aDbObserver,
       
    62     MCalProgressCallBack& aCmdObserver )
       
    63 	{
       
    64 	CMRUtilsCalDbNormal* self =
       
    65 	    new( ELeave ) CMRUtilsCalDbNormal( aCalSession,
       
    66 	                                       aDbObserver,
       
    67 	                                       aCmdObserver );
       
    68 	CleanupStack::PushL( self );
       
    69 	self->ConstructL();
       
    70 	CleanupStack::Pop();
       
    71 	return self;
       
    72 	}
       
    73 
       
    74 // ----------------------------------------------------------------------------
       
    75 // CMRUtilsCalDbNormal::CMRUtilsCalDbNormal
       
    76 //
       
    77 // Constructor.
       
    78 // ----------------------------------------------------------------------------
       
    79 //
       
    80 CMRUtilsCalDbNormal::CMRUtilsCalDbNormal(
       
    81     CCalSession& aCalSession,
       
    82     MMRUtilsCalDbObserver& aDbObserver,
       
    83     MCalProgressCallBack& aCmdObserver )
       
    84     : CMRUtilsCalDbBase( aDbObserver, aCmdObserver )      
       
    85     {
       
    86     // This subclass of CMRUtilsCalDbBase doesn't own the session    
       
    87     iCalSession = &aCalSession;
       
    88     }
       
    89     
       
    90 // ----------------------------------------------------------------------------
       
    91 // CMRUtilsCalDbNormal::~CMRUtilsCalDbNormal
       
    92 //
       
    93 // Destructor.
       
    94 // ----------------------------------------------------------------------------
       
    95 //        
       
    96 CMRUtilsCalDbNormal::~CMRUtilsCalDbNormal()
       
    97     {   
       
    98     delete iCalEntryView;
       
    99     delete iCalInstanceView;
       
   100     }
       
   101     
       
   102 // ----------------------------------------------------------------------------
       
   103 // CMRUtilsCalDbNormal::ConstructL
       
   104 // ----------------------------------------------------------------------------
       
   105 //    
       
   106 void CMRUtilsCalDbNormal::ConstructL()
       
   107     {
       
   108     iCalEntryView = CCalEntryView::NewL( *iCalSession, *this );
       
   109     iDbStatus = MMRUtilsCalDbObserver::EInitEntryView;
       
   110     // See Completed() for continuation...    
       
   111     }
       
   112 
       
   113 // ----------------------------------------------------------------------------
       
   114 // CMRUtilsCalDbNormal::Completed
       
   115 // ----------------------------------------------------------------------------
       
   116 //    
       
   117 void CMRUtilsCalDbNormal::Completed( TInt aError )
       
   118     {        
       
   119     if ( aError == KErrNone )
       
   120         {        
       
   121         if ( iDbStatus == MMRUtilsCalDbObserver::EInitEntryView )
       
   122             { // Entry view successfully initialized, create instance view next
       
   123             
       
   124             TRAPD( err, iCalInstanceView =
       
   125                             CCalInstanceView::NewL( *iCalSession, *this ) );
       
   126             if ( err == KErrNone )
       
   127                 {  // Instance view initialization started:
       
   128                 iDbStatus = MMRUtilsCalDbObserver::EInitInstanceView;    
       
   129                 }
       
   130             else
       
   131                 { // Instance view creation failed, cal engine not usable:
       
   132                 iDbStatus = MMRUtilsCalDbObserver::EFinishedError;
       
   133                 }                                 
       
   134             }
       
   135         else
       
   136             { // Instance view successfully initialized
       
   137             __ASSERT_DEBUG( iDbStatus == MMRUtilsCalDbObserver::EInitInstanceView,
       
   138                             Panic( EPanicUnexpectedCalEngStatus ) );
       
   139             iDbStatus = MMRUtilsCalDbObserver::EFinishedOk;
       
   140             }
       
   141         }            
       
   142     else // aError != KErrNone
       
   143         { // Initialization error has occurred, cal engine not usable:
       
   144         iDbStatus = MMRUtilsCalDbObserver::EFinishedError;
       
   145         }
       
   146             
       
   147     // If either of the final states has been reached, then notify observer:            
       
   148     if ( iDbStatus == MMRUtilsCalDbObserver::EFinishedOk ||
       
   149          iDbStatus == MMRUtilsCalDbObserver::EFinishedError )
       
   150         {
       
   151         iDbObserver.HandleCalDbStatus( this, iDbStatus );            
       
   152         }
       
   153     }
       
   154 
       
   155 // End of file