commonappservices/alarmserver/Server/Include/ASSrvSession.h
changeset 0 2e3d3ce01487
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 #ifndef __ASSRVSESSION_H__
       
    17 #define __ASSRVSESSION_H__
       
    18 
       
    19 // System includes
       
    20 #include <e32base.h>
       
    21 #include <babitflags.h>
       
    22 
       
    23 // User includes
       
    24 #include "ASSrvAlarm.h"
       
    25 #include "ASSrvAnyEventObserver.h"
       
    26 #include "ASSrvSessionCollection.h"
       
    27 #include "ASSrvAlarmQueueObserver.h"
       
    28 
       
    29 // Constants
       
    30 const TInt KAlarmServerMaxNumberOfChangeEventsToBuffer = 10;
       
    31 
       
    32 // Classes referenced
       
    33 class CASSrvServerWideData;
       
    34 class CASSrvSessionEngine;
       
    35 
       
    36 // Enumerations
       
    37 
       
    38 
       
    39 //
       
    40 // ----> CASSrvSession (header)
       
    41 //
       
    42 /**
       
    43  * This class acts as a simple wrapper around the IPC client-server framework,
       
    44  * and drives a real underlying engine, which is actually responsible for all the
       
    45  * server-wide object manipulation. This allows the server functionality to be
       
    46  * tested in isolation from the client API, providing better test coverage.
       
    47  */
       
    48 class CASSrvSession : public CSession2, public MASSrvAnyEventObserver, public MASSrvSession
       
    49 	{
       
    50 //
       
    51 public:										// STATIC CONSTRUCT / DESTRUCT
       
    52 //
       
    53 	static CASSrvSession*					NewL(CASSrvServerWideData& aServerWideData);
       
    54 	~CASSrvSession();
       
    55 
       
    56 //
       
    57 private:									// INTERNAL CONSTRUCT
       
    58 //
       
    59 	CASSrvSession(CASSrvServerWideData& aServerWideData);
       
    60 	void									ConstructL();
       
    61 
       
    62 //
       
    63 public:										// CALLED FROM CASSrvServer dtor
       
    64 //
       
    65 
       
    66 	void									HandleServerDestruction();
       
    67 
       
    68 //
       
    69 private:									// FROM MASSrvAnyEventObserver
       
    70 //
       
    71 
       
    72 	void									MASSrvAnyEventHandleChange(TAlarmChangeEvent aEvent, TAlarmId aAlarmId);
       
    73 
       
    74 //
       
    75 public:										// FROM MASSrvSession
       
    76 //
       
    77 
       
    78 	TASSrvSessionId							MASSrvSessionId() const;
       
    79 
       
    80 	void									MASSrvSessionFullName(TDes& aDes) const;
       
    81 
       
    82 //
       
    83 private:									// FROM CSession2
       
    84 //
       
    85 	void									ServiceL(const RMessage2& aMessage);
       
    86 
       
    87 //
       
    88 private:									// INTERNAL
       
    89 //
       
    90 	TBool									DoServiceL();
       
    91 
       
    92 //
       
    93 private:									// CMD - ALARM SPECIFIC FUNCTIONALITY
       
    94 //
       
    95 	TBool									CmdAlarmAddL();
       
    96 	TBool									CmdAlarmAddWithNotificationL();
       
    97 	TBool									CmdAlarmNotificationCancelAndDeQueueL();
       
    98 	TBool									CmdGetAlarmDetailsL();
       
    99 	TBool									CmdAlarmDeleteL();
       
   100 	TBool									CmdGetAlarmCategoryL();
       
   101 	TBool									CmdGetAlarmOwnerL();
       
   102 	TBool									CmdSetAlarmStatusL();
       
   103 	TBool                                   CmdSetAlarmStatusForCalendarFileL();
       
   104 	TBool									CmdGetAlarmStatusL();
       
   105 	TBool									CmdSetAlarmDayOrTimedL();
       
   106 	TBool									CmdGetAlarmDayOrTimedL();
       
   107 	TBool									CmdGetAlarmCharacteristicsL();
       
   108 	TBool									CmdSetAlarmCharacteristicsL();
       
   109 #ifdef SYMBIAN_SYSTEM_STATE_MANAGEMENT
       
   110 	TBool									CmdSetWakeupL();
       
   111 #endif
       
   112 #ifdef SYMBIAN_ALARM_REPEAT_EXTENSIONS
       
   113 	TBool									CmdGetAlarmDaysL();
       
   114 	TBool									CmdSetAlarmDaysL();	
       
   115 	TBool 									CmdSetContinuousL();
       
   116 	TBool									CmdContinuousL();
       
   117 #endif
       
   118 	TBool									CmdSetClientDataL();
       
   119 	TBool									CmdOrphanAlarmL();
       
   120 
       
   121 
       
   122 //
       
   123 private:									// CMD - ALARM DATA FUNCTIONALITY
       
   124 //
       
   125 	TBool									CmdAlarmDataAttachL();
       
   126 	TBool									CmdAlarmDataDetachL();
       
   127 	TBool									CmdAlarmDataSizeL();
       
   128 	TBool									CmdGetAlarmDataL();
       
   129 
       
   130 //
       
   131 private:									// CMD - CATEGORY-SPECIFIC FUNCTIONALITY
       
   132 //
       
   133 	TBool									CmdSetAlarmStatusByCategoryL();
       
   134 	TBool									CmdGetAlarmCountForCategoryL();
       
   135 	TBool									CmdAlarmDeleteAllByCategoryL();
       
   136 	TBool                                   CmdAlarmDeleteByCalendarFileL();
       
   137 	TBool									CmdAlarmDeleteByCategoryL();
       
   138  	TBool									CmdGetAvailableCategoryListL();
       
   139 	TBool									CmdGetAlarmIdListForCategoryL();
       
   140 
       
   141 //
       
   142 private:									// CMD - MISC FUNCTIONALITY
       
   143 //
       
   144 	TBool									CmdAlarmCountByStateL();
       
   145 	TBool									CmdGetAlarmIdListByStateL();
       
   146 	TBool									CmdGetAlarmIdListL();
       
   147 	TBool									CmdGetNextDueAlarmIdL();
       
   148 	TBool									CmdNumberOfActiveAlarmsInQueueL();
       
   149 
       
   150 //
       
   151 private:									// CMD - SOUND CONTROL
       
   152 //
       
   153 	TBool									CmdSetAlarmSoundStateL();
       
   154 	TBool									CmdGetAlarmSoundStateL();
       
   155 	TBool									CmdSetAlarmSoundsSilentUntilL();
       
   156 	TBool									CmdSetAlarmSoundsSilentForL();
       
   157 	TBool									CmdGetAlarmSoundsSilentUntilL();
       
   158 	TBool									CmdCancelAlarmSilenceL();
       
   159 	TBool									CmdGetAlarmSoundsTemporarilySilencedL();
       
   160 	TBool									CmdSetAlarmPlayIntervalsL();
       
   161 	TBool									CmdGetAlarmPlayIntervalsL();
       
   162 
       
   163 //
       
   164 private:									// CMD - CHANGE NOTIFICATION
       
   165 //
       
   166 	TBool									CmdNotifyChangeL();
       
   167 	TBool									CmdNotifyChangeCancelL();
       
   168 
       
   169 //
       
   170 private:									// CMD - DEBUG ONLY
       
   171 //
       
   172 	TBool									CmdDbgShutDownServerL();
       
   173 	TBool									CmdDbgFailAllocL();
       
   174 	TBool									CmdDbgPreventUserNotifyL();
       
   175 	TBool									CmdDbgSnoozeAlarmL();
       
   176 	TBool 									CmdDbgSetEnvChgHandling();
       
   177 
       
   178 //
       
   179 private:									// CMD - FROM MASShdAlarmInfoProvider
       
   180 //
       
   181 	TBool									CmdInfoAlarmCountL();
       
   182 	TBool									CmdInfoAlarmByIndexL();
       
   183 
       
   184 //
       
   185 private:									// CMD - MISC
       
   186 //
       
   187 	TBool									CmdFetchTransferBufferL();
       
   188 
       
   189 //
       
   190 private:									// MISCELLANEOUS
       
   191 //
       
   192 
       
   193 	void									RequestExpiryNotificationL(TASSrvAlarm& aAlarm);
       
   194 	void									AlarmDataAttachL(TASSrvAlarm& aAlarm);
       
   195 
       
   196 
       
   197 //
       
   198 private:									// INTERNAL FLAGS
       
   199 //
       
   200 
       
   201 	/**
       
   202 	 * Flags for this session
       
   203 	 */
       
   204 	enum TAlarmSessionFlags
       
   205 		{
       
   206 		/**
       
   207 		 * Indicates that the client has an outstanding notification request
       
   208 		 */
       
   209 		EAlarmSessionFlagsNotifyPending		= 0
       
   210 		};
       
   211 
       
   212 //
       
   213 private:									// INTERNAL METHODS
       
   214 //
       
   215 
       
   216 	/**
       
   217 	 * Access the server wide data
       
   218 	 */
       
   219 	inline CASSrvServerWideData&			ServerData() const { return iServerWideData; }
       
   220 
       
   221 	/**
       
   222 	 * Access the transfer buffer
       
   223 	 */
       
   224 	inline CBufBase&						TransferBuffer() const { return *iTransferBuffer; }
       
   225 
       
   226 	void									StreamAlarmIdsToTransferBufferL(RArray<TAlarmId>& aArray);
       
   227 
       
   228 	void									CompleteChangeNotificationMessage(TInt aCompletionCode, TAlarmId aAlarmId);
       
   229 
       
   230 	inline const RMessage2&					Message() const { return *iMessage; }
       
   231 	
       
   232 	void 									ConvertFromUtcToLocal(TASShdAlarm& aAlarm) const;
       
   233 	void 									ConvertFromLocalToUtc(TASShdAlarm& aAlarm) const;
       
   234 
       
   235 //
       
   236 private:									// INTERNAL CLASSES
       
   237 //
       
   238 
       
   239 	//
       
   240 	// ----> TASSrvBufferredEvent (header)
       
   241 	//
       
   242 	/**
       
   243 	 * A collection class which associates an Alarm Id with a specific event.
       
   244 	 * This class is used to group notification events.
       
   245 	 */
       
   246 	class TASSrvBufferredEvent
       
   247 		{
       
   248 	//
       
   249 	public:									// CONSTRUCT
       
   250 	//
       
   251 		inline TASSrvBufferredEvent(TInt aCode, TAlarmId aId) : iCode(aCode), iAlarmId(aId) { }
       
   252 	
       
   253 	//
       
   254 	public:									// ACCESS
       
   255 	//
       
   256 		inline TInt							Code() const { return iCode; }
       
   257 		inline TAlarmId						AlarmId() const { return iAlarmId; }
       
   258 
       
   259 	//
       
   260 	private:								// MEMBER DATA
       
   261 	//
       
   262 		TInt								iCode;
       
   263 		TAlarmId							iAlarmId;
       
   264 		};
       
   265 
       
   266 //
       
   267 private:									// MEMBER DATA
       
   268 //
       
   269 
       
   270 	/**
       
   271 	 * The server wide data handle
       
   272 	 */
       
   273 	CASSrvServerWideData&					iServerWideData;
       
   274 
       
   275 	/**
       
   276 	 * General flags used by this class
       
   277 	 */
       
   278 	TBitFlags								iFlags;
       
   279 
       
   280 	/**
       
   281 	 * For outstanding change notification events. This is NOT used for
       
   282 	 * specific alarm expiry notifications.
       
   283 	 */
       
   284 	RMessage2								iAlarmQueueChangeNotificationMessage;
       
   285 
       
   286 	/**
       
   287 	 * A change event buffer - so that clients don't miss events. 
       
   288 	 */
       
   289 	RArray<TASSrvBufferredEvent>			iChangeEventBuffer;
       
   290 
       
   291 	/**
       
   292 	 * A temporary heap-based alarm object, which is written to by the client-side
       
   293 	 * when data needs to be passed from client to server (or vice-versa). Saves
       
   294 	 * creating lots of temporary TASSrvAlarm objects on the stack.
       
   295 	 */
       
   296 	TASSrvAlarm							iAlarmSink;
       
   297 
       
   298 	/**
       
   299 	 * Used to transfer collections of objects between server and client.
       
   300 	 */
       
   301 	CBufBase*								iTransferBuffer;
       
   302 
       
   303 	/**
       
   304 	 * Manipulates the actual alarm server objects
       
   305 	 */
       
   306 	CASSrvSessionEngine*					iSessionEngine;
       
   307 
       
   308 	const RMessage2*						iMessage;
       
   309 	};
       
   310 
       
   311 #endif