commonappservices/alarmserver/ConsoleAlarmAlertServer/Source/ConsoleAlarmAlertSession.cpp
changeset 0 2e3d3ce01487
child 2 7645e9ce10dc
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 1999-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 "ConsoleAlarmAlertSession.h"
       
    17 #include <e32svr.h>
       
    18 #include <asaltdefs.h>
       
    19 #include <test/consoleantestclient.h>
       
    20 #include "ConsoleAlarmAlertSession.h"
       
    21 #include "ConsoleAlarmAlertConsole.h"
       
    22 #include "ConsoleAlarmAlertLEDFlasher.h"
       
    23 #include "ConsoleAlarmAlertServer.h" //for inter-session communication
       
    24 
       
    25 const TInt KSlot0 = 0;
       
    26 const TInt KSlot1 = 1;
       
    27 const TInt KSlot2 = 2;
       
    28 
       
    29 
       
    30 // message -> string 
       
    31 
       
    32 static const TDesC& function_to_string(TInt function);
       
    33 
       
    34 CConsoleAlarmAlertSession::CConsoleAlarmAlertSession(CConsoleAlarmAlertServer* aServer)
       
    35 :	iServer(aServer), iInstructionSet(NULL), iInstructionSetFound(EFalse)
       
    36 	{
       
    37 	}
       
    38 
       
    39 CConsoleAlarmAlertSession::~CConsoleAlarmAlertSession()
       
    40 	{
       
    41 	CancelNotifications();
       
    42 	__FLOG_CLOSE;
       
    43 	
       
    44 	CConsoleAlarmAlertSession* session = iServer->WaitingSession();
       
    45 	session = NULL;
       
    46 	delete iSoundLEDFlasher;
       
    47 	delete iSoundCallbackTimer;
       
    48 	delete iConsole;
       
    49 	}
       
    50 
       
    51 void CConsoleAlarmAlertSession::ConstructL()
       
    52 	{
       
    53 	iSoundLEDFlasher = CConsoleAlarmAlertLEDFlasher::NewL();
       
    54 	iSoundCallbackTimer = CPeriodic::NewL(CActive::EPriorityIdle);
       
    55 	iConsole = new(ELeave) CConsoleAlarmAlertConsole(*this);
       
    56 	__FLOG_CONNECT;
       
    57 	__FLOG_CREATE(KLogFile, RFileFlogger::ELogModeAppend);
       
    58 	}
       
    59 
       
    60 CConsoleAlarmAlertSession* CConsoleAlarmAlertSession::NewL(CConsoleAlarmAlertServer* aServer)
       
    61 	{
       
    62 	CConsoleAlarmAlertSession* self = new(ELeave) CConsoleAlarmAlertSession(aServer);
       
    63 	CleanupStack::PushL(self);
       
    64 	self->ConstructL();
       
    65 	CleanupStack::Pop(self);
       
    66 	return self;
       
    67 	}
       
    68 
       
    69 TTime CConsoleAlarmAlertSession::DeferTime() const
       
    70 	{
       
    71 	return iDeferTime;
       
    72 	}
       
    73 
       
    74 void CConsoleAlarmAlertSession::Notify(TASAltAlertServerResponse aFlag)
       
    75 	{
       
    76 	if	(iHasMessage)
       
    77 		{
       
    78 		TPckgC<TAlarmId> pId(iAlarm.Id());
       
    79 		TRAPD(err, iMsgPtr.WriteL(KSlot0, pId));
       
    80 		
       
    81 		__ASSERT_ALWAYS(err == KErrNone, User::Invariant());
       
    82 		
       
    83 		iMsgPtr.Complete(aFlag);
       
    84 		iHasMessage = EFalse;
       
    85 		}
       
    86 	}
       
    87 
       
    88 void CConsoleAlarmAlertSession::Notify(TASAltAlertServerResponse aFlag, const TTime& aDeferTime)
       
    89 	{
       
    90 	if	(iHasMessage)
       
    91 		{	
       
    92 		TPckgC<TTime> time(aDeferTime);
       
    93 		TRAPD(err, iMsgPtr.WriteL(KSlot1, time));
       
    94 		__ASSERT_ALWAYS(err == KErrNone, User::Invariant());
       
    95 
       
    96 		Notify(aFlag);
       
    97 		}
       
    98 	}
       
    99 
       
   100 void CConsoleAlarmAlertSession::ServiceL(const RMessage2& aMessage)
       
   101 	{
       
   102 	_LIT(KMsgFmt, "CConsoleAlarmAlertSession::ServiceL: Message: %s (%i) (0x%x 0x%x 0x%x 0x%x)");
       
   103 
       
   104 	__FLOG_INFO7(KMsgFmt, function_to_string(aMessage.Function()).Ptr(), aMessage.Function(), 
       
   105 				aMessage.Int0(), aMessage.Int1(), aMessage.Int2(), aMessage.Int3());
       
   106 	
       
   107 	if (iServer->IsExtendedMode()) 
       
   108 		{
       
   109 		if (MultiDispatchL(aMessage)) 
       
   110 			{
       
   111 			aMessage.Complete(KErrNone);
       
   112 			}
       
   113 		return;
       
   114 		}
       
   115 	
       
   116 	iMsgComplete = ETrue;
       
   117 	const TInt function = aMessage.Function();
       
   118 	
       
   119 	//see if the server holds a set of instructions to be followed,
       
   120 	//rather than waiting for user input.
       
   121 	if(!iInstructionSetFound) //go look for it now.
       
   122 		{
       
   123 		//we will enter into this code only once
       
   124 		const CServer2* tmpServ = Server();
       
   125 		const CConsoleAlarmAlertServer* specific = reinterpret_cast<const CConsoleAlarmAlertServer*>(tmpServ);
       
   126 		iInstructionSet = const_cast<CConsoleAlarmAlertServer*>(specific)->ResponseArray();
       
   127 		iInstructionSetFound = ETrue;
       
   128 		}
       
   129 
       
   130 	//
       
   131 	switch(function)
       
   132 		{
       
   133 	case EASAltTestOpCodeSetExtendedMode:
       
   134 		iServer->SetExtendedMode(ETrue);
       
   135 		iMsgComplete = ETrue;
       
   136 		break;
       
   137 		
       
   138 	case EASAltOpCodeGetMaxAlarms:
       
   139 		CmdGetMaxAlarmsL(aMessage);
       
   140 		iMsgComplete = ETrue;
       
   141 		break;
       
   142 		
       
   143 	case EASAltOpCodeDeleteAlarm:
       
   144 	case EASAltOpCodeDeleteAlarmAll:
       
   145 	case EASAltOpCodeVisibleAll:
       
   146 	case EASAltOpCodeSetStateAll:
       
   147 		iMsgComplete = ETrue;
       
   148 		break;
       
   149 		
       
   150 		
       
   151     case EASAltOpCodeNotify:
       
   152     	{
       
   153 		__ASSERT_ALWAYS(!iHasMessage, User::Invariant());
       
   154 		iMsgComplete = EFalse;
       
   155 		iMsgPtr = aMessage;
       
   156 		iHasMessage = ETrue;
       
   157 		iServer->SetWaitingSession(this);
       
   158 		iServer->SetNotifyMessage(&iMsgPtr);
       
   159 		break;
       
   160 		}
       
   161 
       
   162     case EASAltOpCodeNotifyCancel:
       
   163 		if	(iHasMessage)
       
   164 			{
       
   165 			iHasMessage=EFalse;
       
   166 			iMsgPtr.Complete(KErrCancel);
       
   167 			iServer->SetNotifyMessage(NULL);
       
   168 			}
       
   169 		break;
       
   170 
       
   171 	case EASAltOpCodeVisible:
       
   172 		{
       
   173 		TBool isVisible = aMessage.Int0();
       
   174 		iConsole->SetVisibilityL(isVisible);
       
   175 		iServer->SetNotifying(isVisible);
       
   176 		break;
       
   177 		}
       
   178 
       
   179     case EASAltOpCodeSetState:
       
   180 		iConsole->SetAlertStateL(aMessage.Int0());
       
   181 		break;
       
   182 
       
   183     case EASAltOpCodeSetAlarm:
       
   184 		SetAlarmL(aMessage);
       
   185 		iConsole->iTimeInterval=0;
       
   186 		iConsole->UpdateDisplayL();
       
   187 		// Forces the Console to get response for the next alarm.
       
   188 		iConsole->CancelKey();
       
   189 		break;
       
   190 
       
   191 	case EASAltOpCodeGetUserTime:
       
   192 	case EASAltOpCodeGetEndQuietTime:
       
   193 		GetUserTimeL(aMessage);
       
   194 		break;
       
   195 
       
   196 	case EASAltOpCodeSetDeferTime:
       
   197 		SetDeferTimeL(aMessage);
       
   198 		iConsole->UpdateDisplayL();
       
   199 		break;
       
   200 
       
   201     case EASAltOpCodeLogon:
       
   202 		__ASSERT_ALWAYS(!iLoggedOn, User::Invariant());
       
   203 		iMsgComplete=EFalse;
       
   204 		iLoggedOn=ETrue;
       
   205 		break;
       
   206 
       
   207 	case EASAltOpCodeStartPlayingSound:
       
   208 		{
       
   209 		iSoundLEDFlasher->Start();
       
   210 		TCallBack callback(SoundPlaybackCallbackL, this);
       
   211 		iSoundCallbackTimer->Start(TTimeIntervalMicroSeconds32(0), TTimeIntervalMicroSeconds32(3000000), callback);
       
   212 		break;
       
   213 		}
       
   214 
       
   215 	case EASAltOpCodeStopPlayingSoundAll: // Fallthrough
       
   216 	case EASAltOpCodeStopPlayingSound:
       
   217 		iSoundLEDFlasher->Stop();
       
   218 		iSoundCallbackTimer->Cancel();
       
   219 		break;
       
   220 
       
   221 //Test code
       
   222 	case EASAltTestOpCodeAcknowledgeAlarm:
       
   223 		if (iServer->WaitingSession())
       
   224 			iServer->WaitingSession()->Notify(EASAltAlertServerResponseClear);
       
   225 		break;
       
   226 
       
   227 	case EASAltTestOpCodeGetAttachment:
       
   228 		{
       
   229 		if (iServer->Attachment() != NULL)
       
   230 			{
       
   231 			const TDes8& data = iServer->Attachment()->Des();
       
   232 			const TInt maxLength = static_cast<TInt>(aMessage.Int0());
       
   233 			if	(data.Size() > maxLength)
       
   234 				User::Panic(_L("Client's buffer is too short"), KErrOverflow);
       
   235 			else
       
   236 				{
       
   237 				if (data.Length() == 0)
       
   238 					{
       
   239 					_LIT8(KEmpty,"Empty");
       
   240 					aMessage.WriteL(KSlot1, KEmpty);
       
   241 					}
       
   242 				else
       
   243 					{
       
   244 					aMessage.WriteL(KSlot1, data);
       
   245 					}
       
   246 				iServer->SetAttachment(NULL);
       
   247 				}
       
   248 			}
       
   249 		}
       
   250 		break;
       
   251 
       
   252 	case EASAltTestOpCodeGetIsNotifying:
       
   253 		{
       
   254 		TPckgC<TBool> ret = iServer->IsNotifying();
       
   255 		aMessage.WriteL(KSlot0, ret);
       
   256 		break;
       
   257 		}
       
   258 
       
   259 	default:
       
   260 		User::Invariant();
       
   261 		break;
       
   262 		}
       
   263 
       
   264 	if	(iMsgComplete)
       
   265 		aMessage.Complete(KErrNone);
       
   266 	}
       
   267 
       
   268 TBool CConsoleAlarmAlertSession::CmdL()
       
   269 	{
       
   270 	return KErrNone;
       
   271 	}
       
   272 
       
   273 void CConsoleAlarmAlertSession::ServiceError(const RMessage2 &aMessage, TInt aError)
       
   274 	{
       
   275 	_LIT(KErrFmt, "CConsoleAlarmAlertSession::ServiceError: Message: %s (0x%x, 0x%x, 0x%x, 0x%x) Error: %i");
       
   276 	__FLOG_INFO7(KErrFmt, function_to_string(aMessage.Function()).Ptr(), 
       
   277 				aMessage.Int0(), aMessage.Int1(), aMessage.Int2(), aMessage.Int3(),
       
   278 				aError); 
       
   279 	}
       
   280 
       
   281 
       
   282 //
       
   283 //
       
   284 //
       
   285 
       
   286 
       
   287 //*************************************************************************************
       
   288 void CConsoleAlarmAlertSession::SetAlarmL(const RMessage2& aMessage)
       
   289 	{
       
   290 	TPckg<TASShdAlarm> pA(iAlarm);  
       
   291 	aMessage.ReadL(KSlot0, pA);
       
   292 	
       
   293 	   	//These lines will make sure the alert server is given the alarm in local time, if the alarm is set in local time (a floating alarm)
       
   294   	if (iAlarm.IsFloating())  				
       
   295   		{						
       
   296   			TTimeIntervalSeconds offset = User::UTCOffset();
       
   297   			if (iAlarm.NextDueTime() != Time::NullTTime())
       
   298   			    {
       
   299   			    iAlarm.NextDueTime() += offset;
       
   300   			    }
       
   301   			if (iAlarm.OriginalExpiryTime() != Time::NullTTime())
       
   302   			    {
       
   303   			    iAlarm.OriginalExpiryTime() += offset;
       
   304   			    } 		
       
   305   		}	
       
   306 	
       
   307 	
       
   308 	if	(iAlarm.HasAssociatedData())
       
   309 		{
       
   310 		//Storing the data in the server for the test session to read..
       
   311 		iAlarmAssociatedDataSize = aMessage.GetDesLengthL(2);
       
   312 		HBufC8* data = HBufC8::NewLC(iAlarmAssociatedDataSize);
       
   313 		TPtr8 pData(data->Des());
       
   314 		aMessage.ReadL(KSlot2, pData);
       
   315 		iServer->SetAttachment(data);  //Server takes an ownership
       
   316 		CleanupStack::Pop(data);
       
   317 		}
       
   318 	else
       
   319 		iAlarmAssociatedDataSize = 0;
       
   320 	}
       
   321 
       
   322 
       
   323 //*************************************************************************************
       
   324 void CConsoleAlarmAlertSession::GetUserTimeL(const RMessage2& aMessage)
       
   325 	{
       
   326 	TTime time;
       
   327 	time.UniversalTime();
       
   328 	time+=TTimeIntervalMinutes(iConsole->GetTimeInterval());
       
   329 	TPtrC8 pTime((TUint8 *)&time,sizeof(TTime));
       
   330 	aMessage.WriteL(KSlot0,pTime);
       
   331 	}
       
   332 
       
   333 
       
   334 //*************************************************************************************
       
   335 void CConsoleAlarmAlertSession::SetDeferTimeL(const RMessage2& aMessage)
       
   336 	{
       
   337 	TPckg<TTime> pTime(iDeferTime);
       
   338 	aMessage.ReadL(KSlot0, pTime);
       
   339 	}
       
   340 
       
   341 
       
   342 //*************************************************************************************
       
   343 TBool CConsoleAlarmAlertSession::SoundPlaybackCallbackL(TAny* /*aSelf*/)
       
   344 	{
       
   345 //	_LIT(KPlayingSound, "Playing sound");
       
   346 //	User::InfoPrint(KPlayingSound);
       
   347 	return ETrue;
       
   348 	}
       
   349 
       
   350 //**************************************************************************************
       
   351 TAny * CConsoleAlarmAlertSession::InstructionSet()
       
   352 	{
       
   353 	return iInstructionSet;
       
   354 	}
       
   355 	
       
   356 /**
       
   357 Completes the asynchronous EASAltTestOpCodeNotifyOnAlarm request.
       
   358 
       
   359 @param aAlarm, alarm received with the EASAltOpCodeSetAlarm message.
       
   360 @param aFullName, owner of the alarm.
       
   361 @param aData, any data attached with the EASAltOpCodeSetAlarm message.
       
   362 */
       
   363 
       
   364 void CConsoleAlarmAlertSession::NotifyAlarmL(const TASShdAlarm& aAlarm, const TFullName& aFullName, const TDes8& aData)
       
   365 	{
       
   366 	TPckgC<TASShdAlarm> pAlarm(aAlarm);
       
   367 	
       
   368 	iAlarmNotify.WriteL(KSlot0, pAlarm);
       
   369 	
       
   370 	if (iAlarmNotify.Int1() != 0) 
       
   371 		{
       
   372 		iAlarmNotify.WriteL(KSlot1, aFullName);
       
   373 		}
       
   374 	
       
   375 	if (aData.Length() <= iAlarmNotify.GetDesLength(KSlot2))
       
   376 		{
       
   377 		iAlarmNotify.WriteL(KSlot2, aData);
       
   378 		}
       
   379 		
       
   380 	iAlarmNotify.Complete(KErrNone);
       
   381 	}
       
   382 
       
   383 /**
       
   384 Completes the asynchronous EASAltTestOpCodeNotifyOnSoundStart request.
       
   385 
       
   386 @param aId, id of alarm received with the EASAltOpCodeStartPlayingSound message.
       
   387 @param aFilename, name of sound file to play.
       
   388 */
       
   389 
       
   390 void CConsoleAlarmAlertSession::NotifySoundStartL(const TAlarmId& aId, const TDesC& aFilename)
       
   391 	{
       
   392 	TPckgC<TAlarmId> pId(aId);
       
   393 	
       
   394 	iSoundStartNotify.WriteL(KSlot0, pId);
       
   395 	
       
   396 	if(aFilename.Length() <= iSoundStartNotify.GetDesLength(KSlot1))
       
   397 		{
       
   398 		iSoundStartNotify.WriteL(KSlot1, aFilename);
       
   399 		}
       
   400 	
       
   401 	iSoundStartNotify.Complete(KErrNone);
       
   402 	}
       
   403 
       
   404 /**
       
   405 Completes the asynchronous EASAltTestOpCodeNotifyOnSoundStop request.
       
   406 
       
   407 @param aId, id of alarm received with the EASAltOpCodeStopPlayingSound message.
       
   408 */
       
   409 
       
   410 void CConsoleAlarmAlertSession::NotifySoundStopL(const TAlarmId& aId)
       
   411 	{
       
   412 	TPckgC<TAlarmId> pId(aId);
       
   413 	
       
   414 	iSoundStopNotify.WriteL(KSlot0, pId);
       
   415 	iSoundStopNotify.Complete(KErrNone);
       
   416 	}
       
   417 
       
   418 /**
       
   419 Completes the asynchronous EASAltTestOpCodeNotifyOnVisible request.
       
   420 
       
   421 @param aId, id of alarm received with the EASAltOpCodeVisible message.
       
   422 @param aVisible, visible status received with the EASAltOpCodeVisible message.
       
   423 */
       
   424 
       
   425 void CConsoleAlarmAlertSession::NotifyVisibleL(const TAlarmId& aId, const TBool aVisible)
       
   426 	{
       
   427 	TPckgC<TAlarmId> pId(aId);
       
   428 	TPckgC<TBool> pVisible(aVisible);
       
   429 	
       
   430 	iVisibleNotify.WriteL(KSlot0, pId);
       
   431 	iVisibleNotify.WriteL(KSlot1, pVisible);
       
   432 	iVisibleNotify.Complete(KErrNone);
       
   433 	}
       
   434 
       
   435 /**
       
   436 Completes the asynchronous EASAltTestOpCodeNotifyOnState request.
       
   437 
       
   438 @param aId, id of alarm received with the EASAltOpCodeSetState message.
       
   439 @param aState, state received with the EASAltOpCodeSetState message.
       
   440 */
       
   441 
       
   442 void CConsoleAlarmAlertSession::NotifyStateL(const TAlarmId& aId, const TInt aState)
       
   443 	{
       
   444 	TPckgC<TAlarmId> pId(aId);
       
   445 	TPckgC<TInt> pState(aState);
       
   446 	
       
   447 	iStateNotify.WriteL(KSlot0, pId);
       
   448 	iStateNotify.WriteL(KSlot1, pState);
       
   449 	iStateNotify.Complete(KErrNone);
       
   450 	}
       
   451 
       
   452 /**
       
   453 Completes the asynchronous EASAltTestOpCodeNotifyOnDelete request.
       
   454 
       
   455 @param aId, id of alarm received with the EASAltOpCodeDelete message.
       
   456 */
       
   457 	
       
   458 void CConsoleAlarmAlertSession::NotifyDeleteL(const TAlarmId& aId)
       
   459 	{
       
   460 	TPckgC<TAlarmId> pId(aId);
       
   461 	
       
   462 	iDeleteNotify.WriteL(KSlot0, pId);
       
   463 	iDeleteNotify.Complete(KErrNone);
       
   464 	}
       
   465 
       
   466 /**
       
   467 When in multiple alarm mode this method handles the dispatching of messages.
       
   468 
       
   469 @param aMessage, the message to dispatch.
       
   470 @return ETrue if this message should be completed with KErrNone on return.
       
   471 		EFalse if this message shouldn't be completed on return.
       
   472 */
       
   473 
       
   474 TBool CConsoleAlarmAlertSession::MultiDispatchL(const RMessage2& aMessage)
       
   475 	{
       
   476 	TBool complete = ETrue;
       
   477 	
       
   478 	switch(aMessage.Function())
       
   479 		{
       
   480 	case EASAltOpCodeNotify:
       
   481 		iMsgPtr = aMessage;
       
   482 		iServer->SetNotifyMessage(&iMsgPtr);
       
   483 		complete = EFalse;	
       
   484 		break;
       
   485 
       
   486 	case EASAltOpCodeNotifyCancel:
       
   487 		iServer->NotifyMessage()->Complete(KErrCancel);
       
   488 		iServer->SetNotifyMessage(NULL);
       
   489 		complete = EFalse;
       
   490 		break;
       
   491 
       
   492 	case EASAltOpCodeVisible:
       
   493 		CmdVisibleL(aMessage);
       
   494 		break;
       
   495 
       
   496 	case EASAltOpCodeSetState:
       
   497 		CmdSetStateL(aMessage);
       
   498 		break;
       
   499 		
       
   500 	case EASAltOpCodeSetAlarm:
       
   501 		CmdSetAlarmL(aMessage);
       
   502 		break;
       
   503 		
       
   504 	case EASAltOpCodeSetDeferTime:
       
   505 		CmdSetDeferTimeL(aMessage);
       
   506 		break;
       
   507 
       
   508 	case EASAltOpCodeGetEndQuietTime:
       
   509 	case EASAltOpCodeGetUserTime:
       
   510 		CmdGetUserTimeL(aMessage);
       
   511 		break;
       
   512 
       
   513 	case EASAltOpCodeLogon:
       
   514 		complete = EFalse;	
       
   515 		break;
       
   516 
       
   517 	case EASAltOpCodeStartPlayingSound:
       
   518 		CmdStartPlayingSoundL(aMessage);
       
   519 		break;
       
   520 
       
   521 	case EASAltOpCodeStopPlayingSound:
       
   522 		CmdStopPlayingSoundL(aMessage);
       
   523 		break;
       
   524 		
       
   525 	case EASAltOpCodeVisibleAll:
       
   526 	case EASAltOpCodeSetStateAll:
       
   527 	case EASAltOpCodeStopPlayingSoundAll:
       
   528 		break;
       
   529 		
       
   530 	case EASAltOpCodeDeleteAlarm:
       
   531 	case EASAltOpCodeDeleteAlarmAll:
       
   532 		CmdDeleteAlarmL(aMessage);
       
   533 		break;
       
   534 		
       
   535 	case EASAltOpCodeGetMaxAlarms:
       
   536 		CmdGetMaxAlarmsL(aMessage);
       
   537 		break;
       
   538 	
       
   539 	case EASAltTestOpCodeUnsetExtendedMode:
       
   540 		iServer->SetExtendedMode(EFalse);
       
   541 		break;
       
   542 		
       
   543 	case EASAltTestOpCodeSetExtendedMode: // Already in extended mode
       
   544 		break;
       
   545 			
       
   546 	case EASAltTestOpCodeSetUserTime:
       
   547 		CmdSetUserTimeL(aMessage);
       
   548 		break;
       
   549 				
       
   550 	case EASAltTestOpCodeSetMaxAlarms:
       
   551 		CmdSetMaxAlarmsL(aMessage);
       
   552 		break;
       
   553 	
       
   554 	case EASAltTestOpCodeNotifyOnAlarm:
       
   555 		CmdNotifyOnAlarmL(aMessage);
       
   556 		complete = EFalse;
       
   557 		break;
       
   558 		
       
   559 	case EASAltTestOpCodeNotifyOnSoundStart:
       
   560 		CmdNotifyOnSoundStartL(aMessage);
       
   561 		complete = EFalse;
       
   562 		break;
       
   563 		
       
   564 	case EASAltTestOpCodeNotifyOnSoundStop:
       
   565 		CmdNotifyOnSoundStopL(aMessage);
       
   566 		complete = EFalse;
       
   567 		break;
       
   568 		
       
   569 	case EASAltTestOpCodeNotifyOnVisible:
       
   570 		CmdNotifyOnVisibleL(aMessage);
       
   571 		complete = EFalse;
       
   572 		break;
       
   573 		
       
   574 	case EASAltTestOpCodeNotifyOnState:
       
   575 		CmdNotifyOnStateL(aMessage);
       
   576 		complete = EFalse;
       
   577 		break;
       
   578 		
       
   579 	case EASAltTestOpCodeNotifyOnDelete:
       
   580 		CmdNotifyOnDeleteL(aMessage);
       
   581 		complete = EFalse;
       
   582 		break;
       
   583 		
       
   584 	case EASAltTestOpCodeResponseSnoozeAlarm:
       
   585 		CmdResponseSnoozeAlarmL(aMessage);
       
   586 		break;
       
   587 		
       
   588 	case EASAltTestOpCodeResponseSilenceAlarm:
       
   589 		CmdResponseSilenceAlarmL(aMessage);
       
   590 		break;
       
   591 		
       
   592 	case EASAltTestOpCodeResponseAcknowledgeAlarm:
       
   593 		CmdResponseAcknowledgeAlarmL(aMessage);
       
   594 		break;
       
   595 		
       
   596 	case EASAltTestOpCodeResponsePauseSound:
       
   597 		CmdResponsePauseSoundL(aMessage);
       
   598 		break;
       
   599 		
       
   600 	case EASAltTestOpCodeCancelNotifications:
       
   601 		CancelNotifications();
       
   602 		break;
       
   603 	
       
   604 	case EASAltTestOpCodeResponseAcknowledgeAll:
       
   605 		CmdResponseAcknowledgeAll();
       
   606 		break;
       
   607 		
       
   608 	default:
       
   609 		User::Panic(_L("Unsupported op-code sent!"), KErrNotSupported);
       
   610 		}
       
   611 		
       
   612 	return complete;
       
   613 	}
       
   614 
       
   615 /**
       
   616 Sets the user time of the Console Alarm Alert Server.
       
   617 
       
   618 @param aMessage message to dispatch.
       
   619 */
       
   620 
       
   621 void CConsoleAlarmAlertSession::CmdSetUserTimeL(const RMessage2& aMessage)
       
   622 	{
       
   623 	TTime time;
       
   624 	TPckg<TTime> pTime(time);
       
   625 	
       
   626 	aMessage.ReadL(KSlot0, pTime);
       
   627 	iServer->SetUserTime(time);
       
   628 	}
       
   629 
       
   630 /**
       
   631 Sets the max alarms value of the Console Alarm Alert Server.
       
   632 
       
   633 @param aMessage message to dispatch.
       
   634 */
       
   635 
       
   636 void CConsoleAlarmAlertSession::CmdSetMaxAlarmsL(const RMessage2& aMessage)
       
   637 	{
       
   638 	TInt maxAlarms;
       
   639 	TPckg<TInt> pMaxAlarms(maxAlarms);
       
   640 	
       
   641 	aMessage.ReadL(KSlot0, pMaxAlarms);
       
   642 	
       
   643 	_LIT(KSetMaxFmt, "SetMaxAlarms: %i");
       
   644 	__FLOG_INFO2(KSetMaxFmt, maxAlarms);
       
   645 	
       
   646 	iServer->SetMaxAlarms(maxAlarms);
       
   647 	}
       
   648 
       
   649 /**
       
   650 Adds the session to the list of alarm observers.
       
   651 
       
   652 @param aMessage message to be completed when the asynchronous request is to be completed.
       
   653 */
       
   654 
       
   655 void CConsoleAlarmAlertSession::CmdNotifyOnAlarmL(const RMessage2& aMessage)
       
   656 	{
       
   657 	if(!iAlarmNotify.IsNull())
       
   658 		{
       
   659 		aMessage.Complete(KErrInUse);
       
   660 		}
       
   661 
       
   662 	iAlarmNotify = aMessage;
       
   663 	iServer->AddObserverL(CConsoleAlarmAlertServer::EAlarmObserver, this);
       
   664 	}
       
   665 
       
   666 /**
       
   667 Adds the session to the list of sound start observers.
       
   668 
       
   669 @param aMessage message to be completed when the asynchronous request is to be completed.
       
   670 */
       
   671 
       
   672 void CConsoleAlarmAlertSession::CmdNotifyOnSoundStartL(const RMessage2& aMessage)
       
   673 	{
       
   674 	if(!iSoundStartNotify.IsNull())
       
   675 		{
       
   676 		aMessage.Complete(KErrInUse);
       
   677 		}
       
   678 
       
   679 	iSoundStartNotify = aMessage;
       
   680 	iServer->AddObserverL(CConsoleAlarmAlertServer::ESoundStartObserver, this);
       
   681 	}
       
   682 
       
   683 /**
       
   684 Adds the session to the list of sound stop observers.
       
   685 
       
   686 @param aMessage message to be completed when the asynchronous request is to be completed.
       
   687 */
       
   688 	
       
   689 void CConsoleAlarmAlertSession::CmdNotifyOnSoundStopL(const RMessage2& aMessage)
       
   690 	{
       
   691 	if(!iSoundStopNotify.IsNull())
       
   692 		{
       
   693 		aMessage.Complete(KErrInUse);
       
   694 		}
       
   695 
       
   696 	iSoundStopNotify = aMessage;
       
   697 	iServer->AddObserverL(CConsoleAlarmAlertServer::ESoundStopObserver, this);
       
   698 	}
       
   699 
       
   700 /**
       
   701 Adds the session to the list of visible observers.
       
   702 
       
   703 @param aMessage message to be completed when the asynchronous request is to be completed.
       
   704 */
       
   705 	
       
   706 void CConsoleAlarmAlertSession::CmdNotifyOnVisibleL(const RMessage2& aMessage)
       
   707 	{
       
   708 	if(!iVisibleNotify.IsNull())
       
   709 		{
       
   710 		aMessage.Complete(KErrInUse);
       
   711 		}
       
   712 
       
   713 	iVisibleNotify = aMessage;
       
   714 	iServer->AddObserverL(CConsoleAlarmAlertServer::EVisibleObserver, this);
       
   715 	}
       
   716 	
       
   717 /**
       
   718 Adds the session to the list of state observers.
       
   719 
       
   720 @param aMessage message to be completed when the asynchronous request is to be completed.
       
   721 */
       
   722 
       
   723 void CConsoleAlarmAlertSession::CmdNotifyOnStateL(const RMessage2& aMessage)
       
   724 	{
       
   725 	if(!iStateNotify.IsNull())
       
   726 		{
       
   727 		aMessage.Complete(KErrInUse);
       
   728 		}
       
   729 	
       
   730 	iStateNotify = aMessage;
       
   731 	iServer->AddObserverL(CConsoleAlarmAlertServer::EStateObserver, this);
       
   732 	}
       
   733 	
       
   734 void CConsoleAlarmAlertSession::CmdNotifyOnDeleteL(const RMessage2& aMessage)
       
   735 	{
       
   736 	if(!iDeleteNotify.IsNull())
       
   737 		{
       
   738 		aMessage.Complete(KErrInUse);
       
   739 		}
       
   740 		
       
   741 	iDeleteNotify = aMessage;
       
   742 	iServer->AddObserverL(CConsoleAlarmAlertServer::EDeleteObserver, this);
       
   743 	}
       
   744 	
       
   745 /**
       
   746 Completes the notify message with a EASAltAlertServerResponseSnooze response.
       
   747 
       
   748 @param aMessage message to dispatch.
       
   749 */
       
   750 
       
   751 void CConsoleAlarmAlertSession::CmdResponseSnoozeAlarmL(const RMessage2& aMessage)
       
   752 	{
       
   753 	if (iServer->NotifyMessage())
       
   754 		{
       
   755 		TTime time;
       
   756 		TPckg<TTime> pTime(time);
       
   757 		aMessage.ReadL(KSlot1, pTime);
       
   758 
       
   759 		iServer->NotifyMessage()->WriteL(KSlot0, TPckgC<TAlarmId>(aMessage.Int0()));
       
   760 		iServer->NotifyMessage()->WriteL(KSlot1, pTime);
       
   761 		iServer->NotifyMessage()->Complete(EASAltAlertServerResponseSnooze);
       
   762 		iServer->SetNotifyMessage(NULL);
       
   763 		}
       
   764 	}
       
   765 	
       
   766 /**
       
   767 Completes the notify message with a EASAltAlertServerResponseSilence response.
       
   768 
       
   769 @param aMessage message to dispatch.
       
   770 */
       
   771 
       
   772 void CConsoleAlarmAlertSession::CmdResponseSilenceAlarmL(const RMessage2& aMessage)
       
   773 	{
       
   774 	if (iServer->NotifyMessage())
       
   775 		{
       
   776 		iServer->NotifyMessage()->WriteL(KSlot0, TPckgC<TAlarmId>(aMessage.Int0()));
       
   777 		iServer->NotifyMessage()->Complete(EASAltAlertServerResponseSilence);
       
   778 		iServer->SetNotifyMessage(NULL);
       
   779 		}
       
   780 	}
       
   781 	
       
   782 /**
       
   783 Completes the notify message with a EASAltAlertServerResponseClear response.
       
   784 
       
   785 @param aMessage message to dispatch.
       
   786 */
       
   787 
       
   788 void CConsoleAlarmAlertSession::CmdResponseAcknowledgeAlarmL(const RMessage2& aMessage)
       
   789 	{
       
   790 	if (iServer->NotifyMessage())
       
   791 		{
       
   792 		iServer->NotifyMessage()->WriteL(KSlot0, TPckgC<TAlarmId>(aMessage.Int0()));
       
   793 		iServer->NotifyMessage()->Complete(EASAltAlertServerResponseClear);
       
   794 		iServer->SetNotifyMessage(NULL);
       
   795 		}
       
   796 	}
       
   797 	
       
   798 /**
       
   799 Completes the notify message with a EASAltAlertServerResponsePauseSound response.
       
   800 
       
   801 @param aMessage message to dispatch.
       
   802 */
       
   803 
       
   804 void CConsoleAlarmAlertSession::CmdResponsePauseSoundL(const RMessage2& aMessage)
       
   805 	{
       
   806 	if (iServer->NotifyMessage())
       
   807 		{
       
   808 		TTime time;
       
   809 		TPckg<TTime> pTime(time);
       
   810 		aMessage.ReadL(KSlot1, pTime);
       
   811 
       
   812 		iServer->NotifyMessage()->WriteL(KSlot0, TPckgC<TAlarmId>(aMessage.Int0()));
       
   813 		iServer->NotifyMessage()->WriteL(KSlot1, pTime);
       
   814 		iServer->NotifyMessage()->Complete(EASAltAlertServerResponsePauseSound);
       
   815 		iServer->SetNotifyMessage(NULL);
       
   816 		}
       
   817 	}
       
   818 
       
   819 /**
       
   820 Retrieves alarm, owner, any attached data and notifies all alarm observers.
       
   821 
       
   822 @param aMessage message to dispatch.
       
   823 */
       
   824 
       
   825 void CConsoleAlarmAlertSession::CmdSetAlarmL(const RMessage2& aMessage)
       
   826 	{
       
   827 	TASShdAlarm alarm;
       
   828 	TPckg<TASShdAlarm> pAlarm(alarm);
       
   829 	aMessage.ReadL(KSlot0, pAlarm);
       
   830 	
       
   831 	TFullName name;
       
   832 	aMessage.ReadL(KSlot1, name);
       
   833 	
       
   834 	HBufC8 *buf = HBufC8::NewLC(aMessage.GetDesLengthL(KSlot2));
       
   835 	TPtr8 data(buf->Des());
       
   836 	aMessage.ReadL(KSlot2, data);
       
   837 	
       
   838 	TBuf<KMaxAlarmMessageLength + 1> msg(alarm.Message());
       
   839 	_LIT(KSetAlarmFmt, "Alarm id: %i message: %s");
       
   840 	__FLOG_INFO3(KSetAlarmFmt, alarm.Id(), msg.PtrZ());
       
   841 	
       
   842 	iServer->NotifyAlarmObserversL(alarm, name, data);
       
   843 	
       
   844 	CleanupStack::PopAndDestroy(buf);
       
   845 	}
       
   846 	
       
   847 /**
       
   848 Notifies all state observers.
       
   849 
       
   850 @param aMessage message to dispatch.
       
   851 */
       
   852 
       
   853 void CConsoleAlarmAlertSession::CmdSetStateL(const RMessage2& aMessage)
       
   854 	{
       
   855 	iServer->NotifyStateObserversL(aMessage.Int1(), aMessage.Int0());
       
   856 	}
       
   857 	
       
   858 /**
       
   859 Notifies all visible observers.
       
   860 
       
   861 @param aMessage message to dispatch.
       
   862 */
       
   863 
       
   864 void CConsoleAlarmAlertSession::CmdVisibleL(const RMessage2& aMessage)
       
   865 	{
       
   866 	iServer->NotifyVisibleObserversL(aMessage.Int1(), aMessage.Int0());
       
   867 	}
       
   868 	
       
   869 /**
       
   870 Retrieves sound file name and notifies all sound start observers.
       
   871 
       
   872 @param aMessage message to dispatch.
       
   873 */
       
   874 
       
   875 void CConsoleAlarmAlertSession::CmdStartPlayingSoundL(const RMessage2& aMessage)
       
   876 	{
       
   877 	HBufC* buf = HBufC::NewLC(aMessage.GetDesLengthL(KSlot0) + 1);
       
   878 	TPtr data(buf->Des());
       
   879 	aMessage.ReadL(KSlot0, data);
       
   880 	
       
   881 	_LIT(KPlaySoundFmt, "Sound: %s");
       
   882 	__FLOG_INFO2(KPlaySoundFmt, data.PtrZ());
       
   883 	
       
   884 	iServer->NotifySoundStartObserversL(aMessage.Int1(), data);
       
   885 	
       
   886 	CleanupStack::PopAndDestroy(buf);
       
   887 	}
       
   888 
       
   889 /**
       
   890 Notifies all sound stop observers.
       
   891 
       
   892 @param aMessage message to dispatch.
       
   893 */
       
   894 
       
   895 void CConsoleAlarmAlertSession::CmdStopPlayingSoundL(const RMessage2& aMessage)
       
   896 	{
       
   897 	iServer->NotifySoundStopObserversL(aMessage.Int0());
       
   898 	}
       
   899 	
       
   900 /**
       
   901 Logs the received defer time.
       
   902 
       
   903 @param aMessage message to dispatch.
       
   904 */
       
   905 
       
   906 void CConsoleAlarmAlertSession::CmdSetDeferTimeL(const RMessage2& aMessage)
       
   907 	{
       
   908 	TTime time;
       
   909 	TPckg<TTime> pTime(time);
       
   910 	aMessage.ReadL(KSlot0, pTime);
       
   911 	
       
   912 	TBuf<32> buf;
       
   913 	time.FormatL(buf, _L("%Y:%M:%D - %H:%T:%S"));
       
   914 	_LIT(KDeferTimeFmt, "Set Defer Time: %s");
       
   915 	
       
   916 	__FLOG_INFO2(KDeferTimeFmt, buf.PtrZ());
       
   917 	}
       
   918 	
       
   919 /**
       
   920 Sends the Console Alarm Alert Server's user time.
       
   921 
       
   922 @param aMessage message to dispatch.
       
   923 */
       
   924 
       
   925 void CConsoleAlarmAlertSession::CmdGetUserTimeL(const RMessage2& aMessage)
       
   926 	{
       
   927 	TBuf<32> buf;
       
   928 	iServer->UserTime().FormatL(buf, _L("%Y:%M:%D - %H:%T:%S"));
       
   929 	_LIT(KGetUserTimeFmt, "Get User Time: %s");
       
   930 	
       
   931 	__FLOG_INFO2(KGetUserTimeFmt, buf.PtrZ());
       
   932 	
       
   933 	TPckgC<TTime> pTime(iServer->UserTime());
       
   934 	aMessage.WriteL(KSlot0, pTime);
       
   935 	}
       
   936 	
       
   937 /**
       
   938 Cancels all outstanding notifications.
       
   939 */	
       
   940 	
       
   941 void CConsoleAlarmAlertSession::CancelNotifications()
       
   942 	{
       
   943 	iServer->RemoveObserver(CConsoleAlarmAlertServer::EAlarmObserver, this);
       
   944 	iServer->RemoveObserver(CConsoleAlarmAlertServer::ESoundStopObserver, this);
       
   945 	iServer->RemoveObserver(CConsoleAlarmAlertServer::ESoundStartObserver, this);
       
   946 	iServer->RemoveObserver(CConsoleAlarmAlertServer::EVisibleObserver, this);
       
   947 	iServer->RemoveObserver(CConsoleAlarmAlertServer::EStateObserver, this);
       
   948 	iServer->RemoveObserver(CConsoleAlarmAlertServer::EDeleteObserver, this);
       
   949 
       
   950 	if(!iAlarmNotify.IsNull())
       
   951 		{
       
   952 		iAlarmNotify.Complete(KErrCancel);
       
   953 		}	
       
   954 	if(!iSoundStartNotify.IsNull())
       
   955 		{
       
   956 		iSoundStartNotify.Complete(KErrCancel);
       
   957 		}
       
   958 	if(!iSoundStopNotify.IsNull())
       
   959 		{
       
   960 		iSoundStopNotify.Complete(KErrCancel);
       
   961 		}
       
   962 	if(!iVisibleNotify.IsNull())
       
   963 		{
       
   964 		iVisibleNotify.Complete(KErrCancel);
       
   965 		}
       
   966 	if(!iStateNotify.IsNull())
       
   967 		{
       
   968 		iStateNotify.Complete(KErrCancel);
       
   969 		}
       
   970 	if(!iDeleteNotify.IsNull())
       
   971 		{
       
   972 		iDeleteNotify.Complete(KErrCancel);
       
   973 		}
       
   974 	}
       
   975 	
       
   976 /**
       
   977 Sends a EASAltAlertServerResponseClearAll to the Alarm Server.
       
   978 */	
       
   979 	
       
   980 void CConsoleAlarmAlertSession::CmdResponseAcknowledgeAll()
       
   981 	{
       
   982 	if (iServer->NotifyMessage())
       
   983 		{
       
   984 		iServer->NotifyMessage()->Complete(EASAltAlertServerResponseClearAll);
       
   985 		iServer->SetNotifyMessage(NULL);
       
   986 		}
       
   987 	}
       
   988 	
       
   989 void CConsoleAlarmAlertSession::CmdGetMaxAlarmsL(const RMessage2& aMessage)
       
   990 	{
       
   991 	TPckg<TInt> pMax(iServer->MaxAlarms());
       
   992 	aMessage.WriteL(KSlot0, pMax);
       
   993 	}
       
   994 	
       
   995 void CConsoleAlarmAlertSession::CmdDeleteAlarmL(const RMessage2& aMessage)
       
   996 	{
       
   997 	if (aMessage.Function() == EASAltOpCodeDeleteAlarmAll)
       
   998 		{
       
   999 		iServer->NotifyDeleteObserversL(KNullAlarmId);
       
  1000 		}
       
  1001 	else
       
  1002 		{
       
  1003 		iServer->NotifyDeleteObserversL(aMessage.Int0());
       
  1004 		}
       
  1005 	}
       
  1006 
       
  1007 // Op-codes are from TASAltTestOpCode in ConsoleANTestClient.h
       
  1008 
       
  1009 _LIT(KOpCode0, "EASAltOpCodeNotify\0");
       
  1010 _LIT(KOpCode1, "EASAltOpCodeVisible\0");
       
  1011 _LIT(KOpCode2, "EASAltOpCodeSetState\0");
       
  1012 _LIT(KOpCode3, "EASAltOpCodeSetAlarm\0");
       
  1013 _LIT(KOpCode4, "EASAltOpCodeSetDeferTime\0");
       
  1014 _LIT(KOpCode5, "EASAltOpCodeGetUserTime\0");
       
  1015 _LIT(KOpCode6, "EASAltOpCodeLogon\0");
       
  1016 _LIT(KOpCode7, "EASAltOpCodeStartPlayingSound\0");
       
  1017 _LIT(KOpCode8, "EASAltOpCodeStopPlayingSound\0");
       
  1018 _LIT(KOpCode9, "EASAltTestOpCodeAcknowledgeAlarm\0");
       
  1019 _LIT(KOpCode10, "EASAltOpCodeVisibleAll\0");
       
  1020 _LIT(KOpCode11, "EASAltOpCodeSetStateAll\0");
       
  1021 _LIT(KOpCode12, "EASAltOpCodeStopPlayingSoundAll\0");	
       
  1022 _LIT(KOpCode13, "EASAltOpCodeDeleteAlarm\0");
       
  1023 _LIT(KOpCode14, "EASAltOpCodeGetEndQuietTime\0");	
       
  1024 _LIT(KOpCode15, "EASAltOpCodeGetMaxAlarms\0");
       
  1025 _LIT(KOpCode16, "EASAltTestOpCodeGetAttachment\0");
       
  1026 _LIT(KOpCode17, "EASAltTestOpCodeGetIsNotifying\0");
       
  1027 _LIT(KOpCode18, "EASAltTestOpCodeSetExtendedMode\0");
       
  1028 _LIT(KOpCode19, "EASAltTestOpCodeUnsetExtendedMode\0");
       
  1029 _LIT(KOpCode20, "EASAltTestOpCodeSetUserTime\0");
       
  1030 _LIT(KOpCode21, "EASAltTestOpCodeSetMaxAlarms\0");
       
  1031 _LIT(KOpCode22, "EASAltTestOpCodeNotifyOnAlarm\0");
       
  1032 _LIT(KOpCode23, "EASAltTestOpCodeNotifyOnSoundStart\0");
       
  1033 _LIT(KOpCode24, "EASAltTestOpCodeNotifyOnSoundStop\0");
       
  1034 _LIT(KOpCode25, "EASAltTestOpCodeNotifyOnVisible\0");
       
  1035 _LIT(KOpCode26, "EASAltTestOpCodeNotifyOnState\0");
       
  1036 _LIT(KOpCode27, "EASAltTestOpCodeResponseSnoozeAlarm\0");
       
  1037 _LIT(KOpCode28, "EASAltTestOpCodeResponseSilenceAlarm\0");
       
  1038 _LIT(KOpCode29, "EASAltTestOpCodeResponseAcknowledgeAlarm\0");
       
  1039 _LIT(KOpCode30, "EASAltTestOpCodeResponsePauseSound\0");
       
  1040 _LIT(KOpCode31, "EASAltTestOpCodeCancelNotifications\0");
       
  1041 _LIT(KOpCode32, "EASAltTestOpCodeResponseAcknowledgeAll\0");
       
  1042 _LIT(KOpCode33, "EASAltTestOpCodeNotifyOnDelete\0");
       
  1043 _LIT(KOpCode34, "EASAltOpCodeNotifyCancel\0");
       
  1044 _LIT(KOpCode35, "EASAltOpCodeDeleteAlarmAll\0");
       
  1045 _LIT(KUnknown, "Unknown op-code\0");
       
  1046 
       
  1047 /**
       
  1048 Maps "op-codes" to textual description.
       
  1049 @param function, "op-code" to map.
       
  1050 @return textual description of "op-code".
       
  1051 */
       
  1052 
       
  1053 static const TDesC& function_to_string(TInt function)
       
  1054 	{
       
  1055 	switch(function)
       
  1056 		{
       
  1057 	case EASAltOpCodeNotify: 
       
  1058 		return KOpCode0;
       
  1059 	case EASAltOpCodeVisible: 
       
  1060 		return KOpCode1;
       
  1061 	case EASAltOpCodeSetState: 
       
  1062 		return KOpCode2;
       
  1063 	case EASAltOpCodeSetAlarm: 
       
  1064 		return KOpCode3;
       
  1065 	case EASAltOpCodeSetDeferTime: 
       
  1066 		return KOpCode4;
       
  1067 	case EASAltOpCodeGetUserTime: 
       
  1068 		return KOpCode5;
       
  1069 	case EASAltOpCodeLogon: 
       
  1070 		return KOpCode6;
       
  1071 	case EASAltOpCodeStartPlayingSound: 
       
  1072 		return KOpCode7;
       
  1073 	case EASAltOpCodeStopPlayingSound: 
       
  1074 		return KOpCode8;
       
  1075 	case EASAltTestOpCodeAcknowledgeAlarm: 
       
  1076 		return KOpCode9;
       
  1077 	case EASAltOpCodeVisibleAll:
       
  1078 		return KOpCode10;
       
  1079 	case EASAltOpCodeSetStateAll:
       
  1080 		return KOpCode11;
       
  1081 	case EASAltOpCodeStopPlayingSoundAll:
       
  1082 		return KOpCode12;	
       
  1083 	case EASAltOpCodeDeleteAlarm:
       
  1084 		return KOpCode13;
       
  1085 	case EASAltOpCodeGetEndQuietTime:
       
  1086 		return KOpCode14;
       
  1087 	case EASAltOpCodeGetMaxAlarms:
       
  1088 		return KOpCode15;	
       
  1089 	case EASAltTestOpCodeGetAttachment: 
       
  1090 		return KOpCode16;
       
  1091 	case EASAltTestOpCodeGetIsNotifying: 
       
  1092 		return KOpCode17;
       
  1093 	case EASAltTestOpCodeSetExtendedMode: 
       
  1094 		return KOpCode18;
       
  1095 	case EASAltTestOpCodeUnsetExtendedMode: 
       
  1096 		return KOpCode19;
       
  1097 	case EASAltTestOpCodeSetUserTime: 
       
  1098 		return KOpCode20;
       
  1099 	case EASAltTestOpCodeSetMaxAlarms: 
       
  1100 		return KOpCode21;
       
  1101 	case EASAltTestOpCodeNotifyOnAlarm: 
       
  1102 		return KOpCode22;
       
  1103 	case EASAltTestOpCodeNotifyOnSoundStart: 
       
  1104 		return KOpCode23;
       
  1105 	case EASAltTestOpCodeNotifyOnSoundStop: 
       
  1106 		return KOpCode24;
       
  1107 	case EASAltTestOpCodeNotifyOnVisible: 
       
  1108 		return KOpCode25;
       
  1109 	case EASAltTestOpCodeNotifyOnState: 
       
  1110 		return KOpCode26;
       
  1111 	case EASAltTestOpCodeResponseSnoozeAlarm: 
       
  1112 		return KOpCode27;
       
  1113 	case EASAltTestOpCodeResponseSilenceAlarm: 
       
  1114 		return KOpCode28;
       
  1115 	case EASAltTestOpCodeResponseAcknowledgeAlarm: 
       
  1116 		return KOpCode29;
       
  1117 	case EASAltTestOpCodeResponsePauseSound: 
       
  1118 		return KOpCode30;
       
  1119 	case EASAltTestOpCodeCancelNotifications:
       
  1120 		return KOpCode31;
       
  1121 	case EASAltTestOpCodeResponseAcknowledgeAll:
       
  1122 		return KOpCode32;
       
  1123 	case EASAltTestOpCodeNotifyOnDelete:
       
  1124 		return KOpCode33;
       
  1125 	case EASAltOpCodeNotifyCancel:
       
  1126 		return KOpCode34;
       
  1127 	case EASAltOpCodeDeleteAlarmAll:
       
  1128 		return KOpCode35;
       
  1129 	default:
       
  1130 		return KUnknown;
       
  1131 		}
       
  1132 	}
       
  1133