calendarui/application/src/CalenApp.cpp
changeset 0 f979ecb2b13e
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 Application
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // Debug
       
    21 #include "calendarui_debug.h"           // Calendar debug macros
       
    22 
       
    23 // Include files
       
    24 #include "CalenApp.h"                   // CCalenApplication
       
    25 #include "CalenDoc.h"                   // CCalenDocument
       
    26 #include "CalenUid.h"                    // KUidCalendar
       
    27 
       
    28 #include <e32property.h>            // RProperty
       
    29 #include <sbdefs.h>                     // Backup / Restore keys
       
    30 #include <eikstart.h>                   // EikStart::RunApplication
       
    31 
       
    32 // Namespaces
       
    33 using namespace conn;                   // Backup / Restore namespace
       
    34 
       
    35 // ----------------------------------------------------------------------------
       
    36 // CCalenApplication::PhoneIsInBackupOrRestoreMode()
       
    37 // Check if phone is in backup/restore mode
       
    38 // ----------------------------------------------------------------------------
       
    39 //
       
    40 TBool PhoneIsInBackupOrRestoreMode()
       
    41     {
       
    42     TRACE_ENTRY_POINT;
       
    43     
       
    44     TBool backupOrRestore = EFalse;
       
    45     
       
    46     // Get the back-up restore key, return EFalse if we can't get the key
       
    47     TInt keyVal = 0;
       
    48     const TInt error = RProperty::Get(  KUidSystemCategory, 
       
    49                                         KUidBackupRestoreKey, keyVal );
       
    50     if( error == KErrNone )
       
    51         {
       
    52         const TBURPartType partType = 
       
    53                 static_cast< TBURPartType >( keyVal & KBURPartTypeMask );
       
    54                 
       
    55         if ( keyVal != 0 )
       
    56             {
       
    57             switch( partType )
       
    58                 {
       
    59                 case EBURUnset:
       
    60                 case EBURNormal:
       
    61                     break;
       
    62                     
       
    63                 case EBURBackupFull:
       
    64                 case EBURBackupPartial:
       
    65                 case EBURRestoreFull:
       
    66                 case EBURRestorePartial:
       
    67                     backupOrRestore = ETrue;
       
    68                     break;
       
    69 
       
    70                 default:
       
    71                     break;                
       
    72                 }
       
    73             }
       
    74         }
       
    75 
       
    76     TRACE_EXIT_POINT;
       
    77     return backupOrRestore;
       
    78     }
       
    79 
       
    80 // ----------------------------------------------------------------------------
       
    81 // CCalenApplication::CreateDocumentL()
       
    82 // Creates CCalenDocument object
       
    83 // ----------------------------------------------------------------------------
       
    84 //
       
    85 CApaDocument* CCalenApplication::CreateDocumentL()
       
    86     {
       
    87     TRACE_ENTRY_POINT;
       
    88     
       
    89     CCalenDocument* document = CCalenDocument::NewL(*this);
       
    90     
       
    91     TRACE_EXIT_POINT;
       
    92     return(document);
       
    93     }
       
    94 
       
    95 // ----------------------------------------------------------------------------
       
    96 // CCalenApplication::AppDllUid()
       
    97 // Returns application UID
       
    98 // ----------------------------------------------------------------------------
       
    99 //
       
   100 TUid  CCalenApplication::AppDllUid() const
       
   101     {
       
   102     TRACE_ENTRY_POINT;
       
   103     
       
   104     TRACE_EXIT_POINT;
       
   105     return KUidCalendar;
       
   106     }
       
   107 
       
   108 // ----------------------------------------------------------------------------
       
   109 // CCalenApplication::NewApplication()
       
   110 // Creates a new instance of the Calendar Application
       
   111 // ----------------------------------------------------------------------------
       
   112 //
       
   113 LOCAL_C CApaApplication* NewApplication()
       
   114     {
       
   115     TRACE_ENTRY_POINT;
       
   116 
       
   117     TRACE_EXIT_POINT;
       
   118     return new CCalenApplication;
       
   119     }
       
   120 
       
   121 // ----------------------------------------------------------------------------
       
   122 // CCalenApplication::E32Main()
       
   123 // Application entry point
       
   124 // ----------------------------------------------------------------------------
       
   125 //
       
   126 GLDEF_C TInt E32Main()
       
   127     {
       
   128     TRACE_ENTRY_POINT;
       
   129     
       
   130     // If backup or restore is already ongoing, we must not start up
       
   131     // since it would create a connection to Calendar DB during backup/restore
       
   132     // which is not the desired behaviour
       
   133     if( PhoneIsInBackupOrRestoreMode() )
       
   134         {
       
   135         TRACE_EXIT_POINT;
       
   136         return KErrNone;
       
   137         }
       
   138     
       
   139     TRACE_EXIT_POINT;
       
   140     return EikStart::RunApplication( NewApplication );
       
   141     }
       
   142 
       
   143 //  End of File