phonebookengines/contactsmodel/cntsrv/src/CCntPropertiesMsgHandler.cpp
branchRCL_3
changeset 63 f4a778e096c2
parent 0 e686773b3f54
child 24 0ba2181d7c28
equal deleted inserted replaced
62:5b6f26637ad3 63:f4a778e096c2
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalComponent
       
    19  @released
       
    20 */
       
    21 
       
    22 #include "CCntMsgHandler.h"
       
    23 #include "CCntMsgHandlerFptr.h"
       
    24 #include "CCntPropertiesMsgHandler.h"
       
    25 
       
    26 #include "CCntServer.h"
       
    27 #include "CCntIpcCodes.h"
       
    28 #include "CCntRequest.h"
       
    29 #include "CCntDbManager.h"
       
    30 #include "CCntStateMachine.h"
       
    31 #include "CCntPackager.h"
       
    32 
       
    33 const TInt KCntPropertiesIpcCodes[] =
       
    34 	{
       
    35 	ECntChangeViewDef,
       
    36 	ECntMachineID,
       
    37 	ECntFileUniqueId,
       
    38 	ECntOverrideMachineID,
       
    39 	ECntReCreateTemplate,
       
    40 	ECntGetPrefTemplateId,
       
    41 	ECntSetPrefTemplateId,
       
    42 	ECntOpsTimeOut,
       
    43 	ECntICCTemplateId,
       
    44 	ECntPhonebookGroupId
       
    45 	};
       
    46 	
       
    47 CCntPropertiesMsgHandler* CCntPropertiesMsgHandler::NewLC(CCntSession& aSession)
       
    48 	{
       
    49 	CCntPropertiesMsgHandler* CntPropertiesMsgHandler = new (ELeave) CCntPropertiesMsgHandler(aSession);
       
    50 	CleanupStack::PushL(CntPropertiesMsgHandler);
       
    51 	return CntPropertiesMsgHandler;
       
    52 	}
       
    53 	
       
    54 
       
    55 CCntPropertiesMsgHandler::CCntPropertiesMsgHandler(CCntSession& aSession)
       
    56 :CCntMsgHandler(aSession)
       
    57 	{	
       
    58 	}
       
    59 	
       
    60 CCntPropertiesMsgHandler::~CCntPropertiesMsgHandler()
       
    61 	{
       
    62 	}
       
    63 	
       
    64 /**
       
    65 Delegates the incoming op code to a message handling method.
       
    66 
       
    67 First checks if this class services the op code, it then uses the lookup table and finds 
       
    68 function pointer(to message handling method) mapped to the incoming message function (op code)
       
    69 and finally delegates the message to handling method.
       
    70 
       
    71 It returns KErrNotFound if op code not handled.
       
    72 */
       
    73 TInt CCntPropertiesMsgHandler::HandleMessageL(const RMessage2& aMessage)
       
    74 	{
       
    75 	MsgHandlerFptr func_ptr = LookupHandlerMethodL(aMessage.Function(), KCntPropertiesIpcCodes, sizeof(KCntPropertiesIpcCodes)/sizeof(TInt));
       
    76 	
       
    77 	if(func_ptr)
       
    78 		{
       
    79 		PropertiesMsgHandlerFptr mem_func_ptr = static_cast<PropertiesMsgHandlerFptr>(func_ptr);
       
    80 		(this->*mem_func_ptr)(aMessage);
       
    81 		return (KErrNone);
       
    82 		}
       
    83 	
       
    84 	return (KErrNotFound);
       
    85 	}
       
    86 	
       
    87 /** 
       
    88 Sets the default view definition.  The default view definition is used in calls
       
    89 to ReadContactL(), ReadContactLC() and ReadContactAndAgentL() when no view
       
    90 definition is explicitly specified.
       
    91 
       
    92 @param aMessage.Ptr0() View definition (from client).
       
    93 */
       
    94 void CCntPropertiesMsgHandler::ChangeCntViewDefL(const RMessage2& aMessage)
       
    95 	{
       
    96 	// Destroy any existing view definition.
       
    97 	delete iView;
       
    98 	iView = NULL;
       
    99 	
       
   100 	iPackager.SetBufferFromMessageL(aMessage);
       
   101 	iView = iPackager.UnpackCntViewDefLC();
       
   102 	CleanupStack::Pop(iView);
       
   103 
       
   104 	aMessage.Complete(KErrNone);
       
   105 	}
       
   106 
       
   107 /**
       
   108 Message handling methods.
       
   109 
       
   110 Properties contains all logic to handle client-side get/set operation on
       
   111 server-side objects and variables.  These objects and variables are used
       
   112 throughout the server and Persistence Layer.
       
   113 */
       
   114 void CCntPropertiesMsgHandler::ChangeViewDefL(const RMessage2& aMessage)
       
   115 	{
       
   116 	ChangeCntViewDefL(aMessage);
       
   117 	}
       
   118 
       
   119 void CCntPropertiesMsgHandler::MachineIdL(const RMessage2& aMessage)
       
   120 	{
       
   121 	// Maps to RCntModel::MachineId().
       
   122 	
       
   123 	CheckForManagerL();
       
   124 	TPckg<TInt64> pckg(iManager->GetPersistenceLayer().ContactProperties().MachineIdL());
       
   125 	aMessage.WriteL(0,pckg);
       
   126 	aMessage.Complete(KErrNone);
       
   127 	}
       
   128 	
       
   129 void CCntPropertiesMsgHandler::FileUniqueIdL(const RMessage2& aMessage)
       
   130 	{
       
   131 	// Maps to RCntModel::FileUidL().
       
   132 	
       
   133 	CheckForManagerL();
       
   134 	aMessage.WriteL(0, iManager->GetPersistenceLayer().ContactProperties().UniqueIdL());
       
   135 	aMessage.Complete(KErrNone);
       
   136 	}
       
   137 	
       
   138 void CCntPropertiesMsgHandler::OverrideMachineIdL(const RMessage2& aMessage)
       
   139 	{
       
   140 	// Maps to RCntModel::OverrideMachineUniqueId().
       
   141 	
       
   142 	CheckForManagerL();
       
   143 	#if defined(_DEBUG)
       
   144 	TInt64 machineId;
       
   145 	TPckg<TInt64> package(machineId);
       
   146 	aMessage.ReadL(0, package);
       
   147 	iManager->GetPersistenceLayer().ContactProperties().SetMachineIdL(machineId);
       
   148 	#endif			
       
   149 	aMessage.Complete(KErrNone);
       
   150 	}
       
   151 	
       
   152 void CCntPropertiesMsgHandler::ReCreateTemplateL(const RMessage2& aMessage)
       
   153 	{
       
   154 	// Maps to RCntModel::ReCreateTemplate().
       
   155 	CheckForManagerL();
       
   156 	iManager->RecreateSystemTemplateL();
       
   157 	aMessage.Complete(KErrNone);
       
   158 	}
       
   159 	
       
   160 void CCntPropertiesMsgHandler::GetPrefTemplateIdL(const RMessage2& aMessage)
       
   161 	{
       
   162 	CheckForManagerL();
       
   163 	aMessage.Complete(iManager->GetPersistenceLayer().ContactProperties().CardTemplatePrefIdL());
       
   164 	}
       
   165 	
       
   166 void CCntPropertiesMsgHandler::SetPrefTemplateIdL(const RMessage2& aMessage)
       
   167 	{
       
   168 	CheckForManagerL();
       
   169 	TContactItemId newCardTemplatePrefId = aMessage.Int0();
       
   170 	iManager->SetCardTemplatePrefIdL(newCardTemplatePrefId, iSessionId);
       
   171 	aMessage.Complete(KErrNone);
       
   172 	}
       
   173 	
       
   174 void CCntPropertiesMsgHandler::OpsTimeOut(const RMessage2& aMessage)
       
   175 	{
       
   176 	iTimeOut = aMessage.Int0();
       
   177 	aMessage.Complete(KErrNone);
       
   178 	}
       
   179 	
       
   180 void CCntPropertiesMsgHandler::ICCTemplateIdL(const RMessage2& aMessage)
       
   181 	{
       
   182 	CheckForManagerL();
       
   183 	const TUid phonebookUid(TUid::Uid(aMessage.Int0()));
       
   184 	aMessage.Complete(iManager->GetPersistenceLayer().ContactProperties().ICCTemplateIdL(phonebookUid, iSessionId));
       
   185 	}
       
   186 	
       
   187 void CCntPropertiesMsgHandler::PhonebookGroupIdL(const RMessage2& aMessage)
       
   188 	{
       
   189 	CheckForManagerL();
       
   190 	aMessage.Complete(iManager->GetPersistenceLayer().ContactProperties().PhonebookGroupIdL(iSessionId));
       
   191 	}
       
   192