phonebookengines/contactsmodel/cntsrv/src/CCntSession.Cpp
changeset 24 0ba2181d7c28
parent 0 e686773b3f54
equal deleted inserted replaced
0:e686773b3f54 24:0ba2181d7c28
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 /*
     2 // All rights reserved.
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 // This component and the accompanying materials are made available
     3 * All rights reserved.
     4 // under the terms of "Eclipse Public License v1.0"
     4 * This component and the accompanying materials are made available
     5 // which accompanies this distribution, and is available
     5 * under the terms of "Eclipse Public License v1.0"
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 * which accompanies this distribution, and is available
     7 //
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 // Initial Contributors:
     8 *
     9 // Nokia Corporation - initial contribution.
     9 * Initial Contributors:
    10 //
    10 * Nokia Corporation - initial contribution.
    11 // Contributors:
    11 *
    12 //
    12 * Contributors:
    13 // Description:
    13 *
    14 //
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
    15 
    18 
    16 /**
    19 /**
    17  @file
    20  @file
    18  @internalComponent
    21  @internalComponent
    19  @released
    22  @released
    20 */
    23 */
    21 
    24 
    22 #include "CCntSession.h"
    25 #include "ccntsession.h"
    23 #include "CCntDbManagerController.h"
    26 #include "ccntdbmanagercontroller.h"
    24 #include "CCntStateMachine.h"
    27 #include "ccntstatemachine.h"
    25 #include "CCntBackupRestoreAgent.h"
    28 #include "ccntbackuprestoreagent.h"
    26 #include "CCntPackager.h"
    29 #include "ccntpackager.h"
    27 #include "CViewSubSessions.h"
    30 #include "cviewsubsessions.h"
    28 #include "CCntIpcCodes.h"
    31 #include "ccntipccodes.h"
    29 #include "CCntRequest.h"
    32 #include "ccntrequest.h"
    30 #include "CCntEventQueue.h"
    33 #include "ccnteventqueue.h"
    31 #include <cntdef.h>  // for tcontactitemid.
    34 #include <cntdef.h>  // for tcontactitemid.
    32 #include "CIniFileManager.h"
    35 #include "cinifilemanager.h"
    33 #include "CntSpeedDials.h"
    36 #include "cntspeeddials.h"
    34 #include "cntviewprivate.h"
    37 #include "cntviewprivate.h"
    35 #include <cntviewstore.h>
    38 #include <cntviewstore.h>
    36 #include "CCntLogger.h"
    39 #include "ccntlogger.h"
    37 #include "CCntMsgHandler.h"
    40 #include "ccntmsghandler.h"
    38 #include "CCntItemMsgHandler.h"
    41 #include "ccntitemmsghandler.h"
    39 #include "CCntEventMsgHandler.h"
    42 #include "ccnteventmsghandler.h"
    40 #include "CCntTransactionMsgHandler.h"
    43 #include "ccnttransactionmsghandler.h"
    41 #include "CCntFileManagerMsgHandler.h"
    44 #include "ccntfilemanagermsghandler.h"
    42 #include "CCntPropertiesMsgHandler.h"
    45 #include "ccntpropertiesmsghandler.h"
    43 #include "CCntViewMsgHandler.h"
    46 #include "ccntviewmsghandler.h"
    44 
    47 
    45 
    48 
    46 #define KPhoneBookServerUid 0x102030A1
    49 #define KPhoneBookServerUid 0x102030A1  //Pbk2 server secureid
    47 
    50 
    48 extern void DebugLogIPC(const TDesC& aMethod, TInt aOpCode, TUint aSessionId, TInt aErrCode);
    51 extern void DebugLogIPC(const TDesC& aMethod, TInt aOpCode, TUint aSessionId, TInt aErrCode);
    49 
    52 
    50 
    53 
    51 CCntSession::CCntSession(CCntPackager& aPackager, TUint aSessionId)
    54 CCntSession::CCntSession(CCntPackager& aPackager, TUint aSessionId)
   155 Message handlers return KErrNotFound if op code is not handled. If KErrNotFound then op code is
   158 Message handlers return KErrNotFound if op code is not handled. If KErrNotFound then op code is
   156 delegated to the next handler. The last message handler leaves with KErrNotFound if op code not
   159 delegated to the next handler. The last message handler leaves with KErrNotFound if op code not
   157 handled. The leave is caught in the ServiceError() method.
   160 handled. The leave is caught in the ServiceError() method.
   158 */
   161 */
   159 void CCntSession::ServiceL(const RMessage2& aMessage)
   162 void CCntSession::ServiceL(const RMessage2& aMessage)
   160 	{
   163     {
   161 	#if defined(__PROFILE_DEBUG__)
   164     #if defined(__PROFILE_DEBUG__)
   162 		RDebug::Print(_L("[CNTMODEL] MTD: CCntSession::ServiceL"));
   165         RDebug::Print(_L("[CNTMODEL] MTD: CCntSession::ServiceL"));
   163 	#endif 
   166     #endif 
   164 		
   167         
   165 	// The most likely operation is a ContactItem CRUD operation.
   168     // The most likely operation is a ContactItem CRUD operation.
   166 	
   169     
   167      DEBUG_PRINT4(__VERBOSE_DEBUG__,_L("[CNTMODEL] IPC"), aMessage.Function(), iSessionId, KErrNone);
   170      DEBUG_PRINT4(__VERBOSE_DEBUG__,_L("[CNTMODEL] IPC"), aMessage.Function(), iSessionId, KErrNone);
   168 
   171 
   169 	TSecureId ClientSID = aMessage.SecureId();
   172     TSecureId ClientSID = aMessage.SecureId();
   170 	if (ClientSID == KPhoneBookServerUid && iManager)
   173     if (ClientSID == KPhoneBookServerUid && iManager)
   171 		{
   174         {
   172 		iManager->GetPersistenceLayer().ContactProperties().DisableSynchroniser(iSessionId);			
   175         iManager->GetPersistenceLayer().ContactProperties().DisableSynchroniser(iSessionId);            
   173 		}
   176         }
   174 		
   177         
   175 	// Delegate to message handlers.
   178     // Delegate to message handlers.
   176 	for (TInt index = 0; index < iMsgHandlerArray.Count(); index++) 
   179     for (TInt index = 0; index < iMsgHandlerArray.Count(); index++) 
   177 		{
   180         {
   178 		TInt retCode = iMsgHandlerArray[index]->HandleMessageL(aMessage);
   181         TInt retCode = iMsgHandlerArray[index]->HandleMessageL(aMessage);
   179 		
   182         
   180 		/** Message handled or if message handler returned KErrNotFound,
   183         /** Message handled or if message handler returned KErrNotFound,
   181 		delegate to next handler.
   184         delegate to next handler.
   182 		*/
   185         */
   183 		if(retCode == KErrNone)
   186         if(retCode == KErrNone)
   184 			{
   187             {
   185 			break;
   188             break;
   186 			}
   189             }
   187 		}
   190         }
   188 	}
   191     }
   189 
       
   190 
   192 
   191 /**
   193 /**
   192 We just complete the message with the error code.
   194 We just complete the message with the error code.
   193 */
   195 */
   194 void CCntSession::ServiceError(const RMessage2& aMessage, TInt aError)
   196 void CCntSession::ServiceError(const RMessage2& aMessage, TInt aError)