meetingrequestengines/mrmailboxutils/src/cmrutilssettingsmgr.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:  Provides class methods which takes care of meeting request related settings. 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDES
       
    21 
       
    22 #include "cmrutilssettingsmgr.h"
       
    23 #include <ICalInternalCRKeys.h>
       
    24 
       
    25 #include <msvids.h>
       
    26 #include <centralrepository.h>
       
    27 
       
    28 // CONSTANTS
       
    29 /// Unnamed namespace for local definitions
       
    30 namespace {
       
    31     
       
    32 }  // namespace
       
    33 
       
    34 // ========================= MEMBER FUNCTIONS ================================
       
    35 
       
    36 
       
    37 // ----------------------------------------------------------------------------
       
    38 // CMRUtilsSettingsMgr::NewL
       
    39 // Symbian two-phased constructor.
       
    40 // (other items were commented in a header).
       
    41 // ----------------------------------------------------------------------------
       
    42 //
       
    43 CMRUtilsSettingsMgr* CMRUtilsSettingsMgr::NewL()
       
    44 	{
       
    45 	CMRUtilsSettingsMgr* self = new( ELeave ) CMRUtilsSettingsMgr();
       
    46 	CleanupStack::PushL( self );
       
    47 	self->ConstructL();
       
    48 	CleanupStack::Pop();
       
    49 	return self;
       
    50 	}
       
    51 
       
    52 // ----------------------------------------------------------------------------
       
    53 // CMRUtilsSettingsMgr::CMRUtilsSettingsMgr
       
    54 // Default constructor
       
    55 // ----------------------------------------------------------------------------
       
    56 //
       
    57 CMRUtilsSettingsMgr::CMRUtilsSettingsMgr()
       
    58     {    
       
    59     }
       
    60     
       
    61 // ----------------------------------------------------------------------------
       
    62 // CMRUtilsSettingsMgr::~CMRUtilsSettingsMgr
       
    63 // Destructor.
       
    64 // ----------------------------------------------------------------------------
       
    65 //        
       
    66 CMRUtilsSettingsMgr::~CMRUtilsSettingsMgr()
       
    67     {   
       
    68     }
       
    69     
       
    70 // ----------------------------------------------------------------------------
       
    71 // CMRUtilsSettingsMgr::ConstructL
       
    72 // Symbian OS default constructor
       
    73 // ----------------------------------------------------------------------------
       
    74 //    
       
    75 void CMRUtilsSettingsMgr::ConstructL()
       
    76     {  
       
    77     }
       
    78 
       
    79 // ----------------------------------------------------------------------------
       
    80 // CMRUtilsSettingsMgr::GetDefaultMRMailBoxL
       
    81 // ----------------------------------------------------------------------------
       
    82 //    
       
    83 TInt CMRUtilsSettingsMgr::GetDefaultMRMailBoxL( TMsvId& aDefaultBox )
       
    84     {
       
    85     aDefaultBox = KMsvNullIndexEntryId;
       
    86     TInt value( 0 );
       
    87      
       
    88     //Create central repository
       
    89     CRepository* cenRep = CRepository::NewLC( KCrUidICalUi );
       
    90     
       
    91     //Get default meeting request mailbox id from CentRep
       
    92     TInt err = cenRep->Get( KDefaultMeetingReqMailbox, value ); 
       
    93     
       
    94     CleanupStack::PopAndDestroy(); // cenRep 
       
    95     
       
    96     //If some other error than KErrNotFound Leave
       
    97     if ( err != KErrNone && err != KErrNotFound )
       
    98         {
       
    99         User::LeaveIfError( err ); 
       
   100         }
       
   101     
       
   102     if ( value == KMsvNullIndexEntryId )
       
   103         {
       
   104         //No value for default mailbox was found
       
   105         return KErrNotFound;      
       
   106         }
       
   107     
       
   108     aDefaultBox = value; 
       
   109         
       
   110     return err;    
       
   111     }
       
   112 
       
   113 // ----------------------------------------------------------------------------
       
   114 // CMRUtilsSettingsMgr::SetDefaultMRMailBoxL
       
   115 // ----------------------------------------------------------------------------
       
   116 //                
       
   117 TInt CMRUtilsSettingsMgr::SetDefaultMRMailBoxL( TMsvId aDefaultBox )
       
   118     {
       
   119     //Create central repository
       
   120     CRepository* cenRep = CRepository::NewLC( KCrUidICalUi );
       
   121     
       
   122     //Set new default meeting request mailbox id to CentRep
       
   123     TInt err = cenRep->Set( KDefaultMeetingReqMailbox,
       
   124                             static_cast<TInt>( aDefaultBox ) );
       
   125     
       
   126     CleanupStack::PopAndDestroy(); // cenRep 
       
   127     
       
   128     User::LeaveIfError( err );
       
   129     
       
   130     return KErrNone;   
       
   131     }
       
   132 
       
   133 // End of file