sysstatemgmt/systemstatemgr/sus/src/susadaptionsession.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2008-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 #include "susadaptionserver.h"
       
    17 #include "susadaptionsession.h"
       
    18 #include "susadaptionclisrv.h"
       
    19 #include "ssmdebug.h"
       
    20 
       
    21 CSsmAdaptationSession::~CSsmAdaptationSession()
       
    22 	{
       
    23 	AdaptionServer()->RemovePriorityClient(this);
       
    24 	}
       
    25 
       
    26 CSsmAdaptationSession::CSsmAdaptationSession()
       
    27 	{
       
    28 	}
       
    29 
       
    30 CSsmAdaptationSession* CSsmAdaptationSession::NewL()
       
    31 	{	
       
    32 	CSsmAdaptationSession* session = new(ELeave) CSsmAdaptationSession();
       
    33 	return session;
       
    34 	}
       
    35 
       
    36 void CSsmAdaptationSession::ServiceL(const RMessage2& aMessage)
       
    37 	{
       
    38 	switch (aMessage.Function())
       
    39 		{
       
    40 
       
    41 		case ERequestCoopSysStateChange:
       
    42 			{
       
    43 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: ERequestCoopSysStateChange "));
       
    44 		 	AdaptionServer()->DoRequestCoopSysStateChangeL(aMessage);
       
    45 			break;	
       
    46 			} 
       
    47 		case ERequestCoopSysSelfTest:
       
    48 			{
       
    49 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: ERequestCoopSysSelfTest "));
       
    50 			AdaptionServer()->DoRequestCoopSysSelfTestL(aMessage);
       
    51 			break;	
       
    52 			} 			
       
    53 		case ERequestCoopSysPerformRestartActions:
       
    54 			{
       
    55 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: ERequestCoopSysPerformRestartActions "));
       
    56 			AdaptionServer()->DoRequestCoopSysPerformRestartActionsL(aMessage);
       
    57 			break;	
       
    58 			} 
       
    59 		case ERequestCoopSysPerformShutdownActions:
       
    60 			{
       
    61 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: ERequestCoopSysPerformShutdownActions "));
       
    62 			AdaptionServer()->DoRequestCoopSysPerformShutdownActionsL(aMessage);
       
    63 			break;	
       
    64 			} 
       
    65 		case ERequestCoopSysPerformRfsActions:
       
    66 			{
       
    67 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: ERequestCoopSysPerformRfsActions "));
       
    68 			AdaptionServer()->DoRequestCoopSysPerformRfsActionsL(aMessage);
       
    69 			break;	
       
    70 			} 
       
    71 		case ERequestCoopSysCancel:
       
    72 			{
       
    73 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: ERequestCoopSysCancel "));
       
    74 			AdaptionServer()->DoRequestCoopSysCancelL(aMessage);
       
    75 			break; 	
       
    76 			} 
       
    77 		case ENotifyCoopSysEvent:
       
    78 			{
       
    79 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: ENotifyCoopSysEvent "));
       
    80 			AdaptionServer()->DoNotifyCoopSysEventL(aMessage);
       
    81 			break;	
       
    82 			} 
       
    83 		case ENotifyCoopSysCancel:
       
    84 			{
       
    85 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: ENotifyCoopSysCancel "));
       
    86 			AdaptionServer()->DoNotifyCoopSysEventCancelL(aMessage);
       
    87 			break;	
       
    88 			} 
       
    89 		case EGetLastCoopSysEvent:
       
    90 			{
       
    91 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: EGetLastCoopSysEvent "));
       
    92 			AdaptionServer()->DoGetLastCoopSysEventL(aMessage);
       
    93 			break;	
       
    94 			} 
       
    95 		case EGetSimOwned:
       
    96 			{
       
    97 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: EGetSimOwned "));
       
    98 			AdaptionServer()->DoGetSimOwnedL(aMessage);
       
    99 			break;	
       
   100 			}
       
   101 		case EGetSimCancel:
       
   102 			{
       
   103 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: EGetSimCancel "));
       
   104 			AdaptionServer()->DoGetSimCancelL(aMessage);
       
   105 			break;	
       
   106 			} 
       
   107 		case ENotifySimEvent:
       
   108 			{
       
   109 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: ENotifySimEvent "));
       
   110 			AdaptionServer()->DoNotifySimEventL(aMessage);
       
   111 			break;	
       
   112 			} 
       
   113 		case ENotifySimCancel:
       
   114 			{
       
   115 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: ENotifySimCancel "));
       
   116 			AdaptionServer()->DoNotifySimCancelL(aMessage);
       
   117 			break;	
       
   118 			}
       
   119 		case EGetLastSimEvent:
       
   120 			{
       
   121 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: EGetLastSimEvent"));
       
   122 			AdaptionServer()->DoGetLastSimEventL(aMessage);
       
   123 			break;	
       
   124 			} 
       
   125 		case EValidateRtc:
       
   126 			{
       
   127 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: EValidateRtc "));
       
   128 			AdaptionServer()->DoValidateRtcL(aMessage);
       
   129 			break;	
       
   130 			}
       
   131 		case ESetWakeupAlarm:
       
   132 			{
       
   133 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: ESetWakeupAlarm "));
       
   134 			AdaptionServer()->DoSetWakeupAlarmL(aMessage);
       
   135 			break;	
       
   136 			}
       
   137 		case EUnsetWakeupAlarm:
       
   138 			{
       
   139 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: EUnsetWakeupAlarm "));
       
   140 			AdaptionServer()->DoUnsetWakeupAlarmL(aMessage);
       
   141 			break;	
       
   142 			}
       
   143 		case ERtcCancel:
       
   144 			{
       
   145 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: ERtcCancel "));
       
   146 			AdaptionServer()->DoRtcCancelL(aMessage);
       
   147 			break;	
       
   148 			}
       
   149 		case ESecurityStateChange:
       
   150 			{
       
   151 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: ESecurityStateChange "));
       
   152 			AdaptionServer()->DoSecurityStateChangeL(aMessage);
       
   153 			break;	
       
   154 			}
       
   155 		case EGetGlobalStartupMode:
       
   156 			{
       
   157 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: EGetGlobalStartupMode "));
       
   158 			AdaptionServer()->DoGetGlobalStartupModeL(aMessage);
       
   159 			break;	
       
   160 			}
       
   161 		case EPrepareSimLanguages:
       
   162 			{
       
   163 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: EPrepareSimLanguages "));
       
   164 			AdaptionServer()->DoPrepareSimLanguagesL(aMessage);
       
   165 			break;	
       
   166 			}
       
   167 		case EMiscCancel:
       
   168 			{
       
   169 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: EMiscCancel "));
       
   170 			AdaptionServer()->DoMiscAdaptationCancelL(aMessage);
       
   171 			break;	
       
   172 			}			
       
   173 		case EGetHiddenReset:
       
   174 			{
       
   175 		 	DEBUGPRINT1(_L("CSsmAdaptationSession - opcode: EGetHiddenReset"));
       
   176 			AdaptionServer()->DoMiscAdaptationHiddenResetL(aMessage);
       
   177 			break;
       
   178 			}
       
   179 		case EGetSimLanguagesArray:
       
   180 			{
       
   181 		 	DEBUGPRINT1(_L("CSsmAdaptationSession - opcode: EGetSimLanguagesArray"));
       
   182 			AdaptionServer()->DoGetSimLanguagesArrayL(aMessage);
       
   183 			aMessage.Complete(KErrNone);
       
   184 			break;
       
   185 			}
       
   186 		case EActivateRfForEmergencyCall:
       
   187 			{
       
   188 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: EActivateRfForEmergencyCall "));
       
   189 			AdaptionServer()->DoActivateRfForEmergencyCallL(aMessage);
       
   190 			break;	
       
   191 			}
       
   192 		case EDeactivateRfForEmergencyCall:
       
   193 			{
       
   194 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: EDeactivateRfForEmergencyCall "));
       
   195 			AdaptionServer()->DoDeactivateRfForEmergencyCallL(aMessage);
       
   196 			break;	
       
   197 			}
       
   198 		case EEmergencyCallRfCancel:
       
   199 			{
       
   200 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: EEmergencyCallRfCancel "));
       
   201 			AdaptionServer()->DoEmergencyCallRfCancelL(aMessage);
       
   202 			break;	
       
   203 			}
       
   204 		case EDebugMarkHeap:
       
   205 			{
       
   206 #ifdef _DEBUG
       
   207 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: EDebugMarkHeap."));
       
   208 			__UHEAP_MARK;
       
   209 			DEBUGPRINT2(_L("CSsmAdaptationSession - Mark Heap: Alloc Cells- %d"), User::CountAllocCells());
       
   210 #endif
       
   211 			aMessage.Complete(KErrNone);
       
   212 			break;
       
   213 			}
       
   214 		case EDebugMarkHeapEnd:
       
   215 			{
       
   216 #ifdef _DEBUG
       
   217 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: EDebugMarkHeapEnd."));
       
   218 			DEBUGPRINT2(_L("CSsmAdaptationSession - Mark Heap End: Alloc Cells- %d"), User::CountAllocCells());
       
   219 			__UHEAP_MARKEND;
       
   220 #endif
       
   221 			aMessage.Complete(KErrNone);
       
   222 			break;
       
   223 			}
       
   224 		case EDebugCleanupAdaptations:
       
   225 			{
       
   226 #ifdef _DEBUG
       
   227 		 	DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: EDebugCleanupAdaptations."));
       
   228 			AdaptionServer()->UnloadAdaptationsAndObservers();
       
   229 #endif
       
   230 			aMessage.Complete(KErrNone);
       
   231 			break;
       
   232 			}
       
   233         case ESetAsPriorityClient:
       
   234             {
       
   235             DEBUGPRINT1(_L ("CSsmAdaptationSession - opcode: ESetAsPriorityClient."));
       
   236             TInt err = AdaptionServer()->SetAsPriorityClientL(this);
       
   237             aMessage.Complete(err);
       
   238             break;
       
   239             }
       
   240         case EDebugSetHeapFailure:
       
   241             {
       
   242 #ifdef _DEBUG
       
   243             DEBUGPRINT2(_L("CSsmAdaptationSession - EDebugSetHeapFailure: Value of Failure Rate: %d."), aMessage.Int0());
       
   244             __UHEAP_SETFAIL(RAllocator::EDeterministic,aMessage.Int0());
       
   245 #endif
       
   246             aMessage.Complete(KErrNone);
       
   247             break;
       
   248             }
       
   249         case EDebugUnSetHeapFailure:
       
   250             {
       
   251 #ifdef _DEBUG
       
   252             DEBUGPRINT1(_L("CSsmAdaptationSession - EDebugUnSetHeapFailure"));
       
   253             __UHEAP_TOTAL_RESET;
       
   254 #endif
       
   255             aMessage.Complete(KErrNone);
       
   256             break;
       
   257             }
       
   258 		default:
       
   259 			{
       
   260 			aMessage.Complete (KErrNotSupported);
       
   261 			break;
       
   262 			}
       
   263 		}
       
   264 	}
       
   265  
       
   266 
       
   267 void CSsmAdaptationSession::ServiceError(const RMessage2 &aMessage, TInt aError)
       
   268 	{
       
   269 	DEBUGPRINT2(_L ("CSsmAdaptationSession: ServiceError %d"), aError);
       
   270 	aMessage.Complete (aError);
       
   271 	}
       
   272 
       
   273 /**
       
   274  Returns a pointer to the server object
       
   275  */
       
   276 CSsmAdaptationServer* CSsmAdaptationSession::AdaptionServer() const
       
   277 	{
       
   278 	return static_cast<CSsmAdaptationServer*> (const_cast<CServer2*> (Server()));
       
   279 	}
       
   280