cryptomgmtlibs/securityutils/source/secsettings/secsettingsserver/secsettingssession.cpp
changeset 31 5b5ca9f4f7b4
equal deleted inserted replaced
30:cf642210ecb7 31:5b5ca9f4f7b4
       
     1 /*
       
     2 * Copyright (c) 2009 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 the License "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: 
       
    15 * Implements CSecSettingsSession.	 See class and function definitions for
       
    16 * more information.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 /**
       
    22  @file
       
    23 */
       
    24 
       
    25 #include "secsettingsserver.h"
       
    26 #include <scs/ipcstream.h>
       
    27 #include <scs/nullstream.h>
       
    28 
       
    29 // For KErrSettingNotFound.
       
    30 #include<securityerr.h>
       
    31 
       
    32 // For CRepository class.
       
    33 #include <centralrepository.h>
       
    34 
       
    35 
       
    36 namespace SecuritySettingsServer
       
    37 {
       
    38 
       
    39 CSecSettingsSession* CSecSettingsSession::NewL(CSecSettingsServer &aServer)
       
    40 /**
       
    41 	Factory function allocates new instance of CSecSettingsSession.
       
    42 
       
    43 	@return					New, initialized instance of CSecSettingsSession
       
    44 							which is owned by the caller.
       
    45  */
       
    46 	{
       
    47 	CSecSettingsSession* self = new(ELeave) CSecSettingsSession(aServer);
       
    48 	CleanupStack::PushL(self);
       
    49 	self->ConstructL();			// CScsSession implementation
       
    50 	CleanupStack::Pop(self);
       
    51 	return self;
       
    52 	}
       
    53 
       
    54 CSecSettingsSession::CSecSettingsSession(CSecSettingsServer &aServer)
       
    55 /**
       
    56 	This private constructor prevents direct instantiation.
       
    57  */
       
    58  :	CScsSession(aServer)
       
    59 	{
       
    60 	}
       
    61 
       
    62 CSecSettingsSession::~CSecSettingsSession()
       
    63 	{
       
    64 	}
       
    65 
       
    66 TBool CSecSettingsSession::DoServiceL(TInt aFunction, const RMessage2& aMessage)
       
    67 /**
       
    68 	Implement CScsSession by handling the supplied message.
       
    69 
       
    70 	@param	aFunction		Function identifier for the repository operations.
       
    71 	@param	aMessage		Standard server-side handle to message.	 Not used.
       
    72  */
       
    73 	{
       
    74 
       
    75 	switch (aFunction)
       
    76 		{
       
    77 		case ESettingValue:
       
    78 			{								
       
    79 			// Create a CRepository object with the supplied UID.
       
    80 			CRepository* repository = CRepository::NewL(TUid::Uid(aMessage.Int0()));
       
    81 			TInt Value = 0;
       
    82 
       
    83 				
       
    84 			// Get the value of the setting whose key is supplied as the first argument. 
       
    85 			TInt result = repository->Get(aMessage.Int1(), Value);
       
    86 
       
    87 			delete repository;
       
    88 
       
    89 			if( result == KErrNotFound )
       
    90 			{
       
    91 				// Interpreting this as - setting not found.
       
    92 				User::Leave(KErrSettingNotFound);
       
    93 			}
       
    94 			else
       
    95 			{
       
    96 				User::LeaveIfError(result);
       
    97 			}
       
    98 			
       
    99 			TPckgBuf<TInt> Pkg(Value);
       
   100 			aMessage.WriteL(2, Pkg);
       
   101 
       
   102 			break;
       
   103 			}
       
   104 
       
   105 		default:
       
   106 			User::Leave(KErrNotSupported);
       
   107 		}
       
   108 
       
   109 	return ETrue;
       
   110 	}
       
   111 
       
   112 
       
   113 
       
   114 } // End of namespace SecuritySettingsServer
       
   115 // End of file