commonappservices/alarmserver/Test/unit/src/TEAlarmTestMANEventEntry.cpp
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 2005-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 "TEAlarmTestMANEventEntry.h"
       
    17 
       
    18 _LIT(KLitEvent, "EVENT");
       
    19 _LIT(KLitAction, "ACTION");
       
    20 _LIT(KLit02D, "%02d");
       
    21 _LIT(KLitA02D, " A%02d");
       
    22 _LIT(KLitColon, ":");
       
    23 _LIT(KLitS, " %S");
       
    24 _LIT(KLitFlags, " flags=0x%x");
       
    25 _LIT(KLitDSec, " %dsec");
       
    26 _LIT(KLitCompleted, " completed");
       
    27 _LIT(KLitForDMinutes, " for %d minutes");
       
    28 
       
    29 
       
    30 
       
    31 TEventEntry::TEventEntry(TEventType aEventType, TInt aError) :
       
    32 			iType(aEventType), 
       
    33 			iSequenceNumber(-1),
       
    34 		 	iAlarmIdx(KBogusAlarmIdx),
       
    35 		 	iAlarmId(KNullAlarmId),	
       
    36 		 	iAltSFlags(0),
       
    37 		 	iAlarmState(EAlarmStateInPreparation),
       
    38 		 	iPlaying(EFalse),
       
    39 		 	iVisible(EFalse),
       
    40 		 	iPeriod(0),
       
    41 		 	iError(KErrNone) 
       
    42 	{
       
    43 	if (iType==EException)  
       
    44 		{
       
    45 		iError = aError;
       
    46 		}
       
    47 	}
       
    48 	
       
    49 
       
    50 TBool TEventEntry::operator==(const TEventEntry& aEvent)
       
    51 	{
       
    52 	if ( iType!=aEvent.iType
       
    53 			|| iAlarmIdx!=aEvent.iAlarmIdx
       
    54 				|| (iType==EActionCheckState && iAlarmState!=aEvent.iAlarmState)
       
    55 				|| (aEvent.iType==EEventVisible && iVisible!=aEvent.iVisible) )
       
    56 					{
       
    57 					return EFalse;
       
    58 					}
       
    59 	return ETrue;
       
    60 	}
       
    61 
       
    62 	
       
    63 const TDesC& TEventEntry::TypeToStr()
       
    64 	{
       
    65 	switch (iType)
       
    66 		{
       
    67 		case EEventSetAlarm:
       
    68 				return KEventSetAlarm;
       
    69 		case EEventSetState:
       
    70 				return KEventSetState;
       
    71 		case EEventVisible:
       
    72 				return KEventVisible;
       
    73 		case EEventSoundStart:
       
    74 				return KEventSoundStart;
       
    75 		case EEventSoundStop:
       
    76 				return KEventSoundStop;
       
    77 		case EEventDelete:
       
    78 				return KEventDelete;
       
    79 		case EActionCheckState:	
       
    80 				return KActionCheckState; 
       
    81 		case EActionCheckStateOnly:
       
    82 				return KActionCheckStateOnly; 
       
    83 		case EActionSnooze:
       
    84 				return KActionSnooze; 
       
    85 		case EActionClear:
       
    86 				return KActionClear;
       
    87 		case EActionPauseSound:	
       
    88 				return KActionPauseSound;
       
    89 		case EActionSilence:	
       
    90 				return KActionSilence;
       
    91 		case EActionUserWait:
       
    92 				return KActionUserWait;
       
    93 		case EActionReconnectToAS:
       
    94 				return KActionReconnectToAS;				
       
    95 		case EActionAddAlarm:
       
    96 				return KActionAddAlarm;
       
    97 		case EActionDeleteAlarm:
       
    98 				return KActionDeleteAlarm;
       
    99 		case EException:
       
   100 				return KException;
       
   101 		case EUnknown:
       
   102 		default: 	
       
   103 				return KUnknown;
       
   104 		}
       
   105 	}
       
   106 
       
   107 
       
   108 void TEventEntry::ToStr(TDes& aStr)
       
   109 	{
       
   110 	if (IsEvent())  							// Event or Action
       
   111 		{
       
   112 		aStr.Append(KLitEvent);
       
   113 		}
       
   114 	else
       
   115 		{
       
   116 		aStr.Append(KLitAction);
       
   117 		}
       
   118 
       
   119 	if (iSequenceNumber>=0)
       
   120 		{
       
   121 		aStr.AppendFormat(KLit02D, iSequenceNumber);		
       
   122 		}
       
   123 
       
   124 	aStr.Append(KLitColon);
       
   125 
       
   126 	if (iType!=EActionUserWait)
       
   127 		{
       
   128 		aStr.AppendFormat(KLitA02D, iAlarmIdx);	// Alarm idx
       
   129 		}
       
   130 	
       
   131 	aStr.AppendFormat(KLitS, &TypeToStr());	// Event name
       
   132 
       
   133 
       
   134 	if (iType==EEventVisible)  			// Visibility
       
   135 		{
       
   136 		aStr.AppendFormat(KLitS, &BoolToStr(iVisible));
       
   137 		}
       
   138 	
       
   139 	if (iType==EEventSetState) 			// State flags
       
   140 		{
       
   141 		aStr.AppendFormat(KLitFlags, iAltSFlags);
       
   142 		}
       
   143 
       
   144 	if (iType==EActionUserWait)
       
   145 		{
       
   146 		aStr.AppendFormat(KLitDSec, iPeriod);
       
   147 		if (iAlarmIdx==KBogusAlarmIdx)  aStr.AppendFormat(KLitCompleted);
       
   148 		}
       
   149 		
       
   150 	if (iType==EActionSnooze || iType==EActionPauseSound)
       
   151 		{
       
   152 		aStr.AppendFormat(KLitForDMinutes, iPeriod/60);
       
   153 		}
       
   154 	}
       
   155