imservices/ossprotocoladaptation/inc/waittimer.h
branchRCL_3
changeset 14 7797b2f86d2b
parent 13 b6f2a363adf7
child 16 cfe5eb8bb9ca
equal deleted inserted replaced
13:b6f2a363adf7 14:7797b2f86d2b
     1 /*
       
     2 * Copyright (c) 2005 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 "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:  Header for Waittimer.h.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef WAITTIMER_H
       
    19 #define WAITTIMER_H
       
    20 
       
    21 #include <e32base.h> // For CActive, link against: euser.lib
       
    22 #include <e32std.h>  // For RTimer, link against: euser.lib
       
    23 #include <e32property.h>
       
    24 // FORWARD DECLARATIONS
       
    25 
       
    26 class COssSendDataOperation;
       
    27 class COSSProtocolConnectionManager;
       
    28 class MOSSProtocolConnectionManager;
       
    29 class MXIMPProtocolConnectionHost;
       
    30 
       
    31 enum TDataFetchSteps
       
    32 	{
       
    33 	EDataFetchingStep1 = -1, // three	
       
    34 	EDataFetchingStep2 ,	 // -1
       
    35 //	EDataFetchingStep3,		//  0
       
    36 	EDataFetchComplete		// 1 done
       
    37 	};
       
    38 
       
    39 /**
       
    40  * CWaitTimer implementation.
       
    41  * Responsible for sending filled message queue and
       
    42  * reading response message queue when it is updated
       
    43  * keep track of updation of message queue
       
    44  */
       
    45 class CWaitTimer : public CActive
       
    46 	{
       
    47 
       
    48 	public:
       
    49 		// Cancel and destroy
       
    50 		~CWaitTimer();
       
    51 
       
    52 		// Two-phased constructor.
       
    53 		static CWaitTimer* NewL (MOSSProtocolConnectionManager& aConnMan);
       
    54 
       
    55 
       
    56 	public: // New functions
       
    57 		/**
       
    58 		 *  Function for making the initial request
       
    59 		 */
       
    60 		TInt SendDataL ( TRequestStatus& aStatus, char* msg, TInt nBytes );
       
    61         /**
       
    62 		 *  Get response data based on the transaction id
       
    63 		 */
       
    64 		char* ResponseL ( TInt aTransId );
       
    65 		/**
       
    66 		 *  start listening on the queue to keep track of the queue updation
       
    67 		 */
       
    68 		void StartListeningL();
       
    69 		/**
       
    70 		 *  Increase operation id
       
    71 		 */
       
    72 		void IncreaseOpId();
       
    73 		/**
       
    74 		 *  Get operation id
       
    75 		 */
       
    76 		TInt GetOpId();
       
    77 		/**
       
    78 		 *  Listen Incoming data
       
    79 		 */
       
    80 
       
    81 		void ListenIncomingData ( TRequestStatus& aStatus );
       
    82 
       
    83 		/**
       
    84 		 *  Listen Incoming data count
       
    85 		 */
       
    86 
       
    87 		TInt IncomingDataCount();
       
    88 		/**
       
    89 		 *  Returns searched data count
       
    90 		 */	
       
    91 		TInt SearchDataCount();
       
    92 		
       
    93 		/**
       
    94 		 *  Returns ContactsChange Response Count
       
    95 		 */	
       
    96 		TInt ContactsChangeResponseCount();
       
    97 		
       
    98 		/** 
       
    99 		 *Listen Incoming message
       
   100      	 */
       
   101 		TInt ListenIncomingMsg ( TRequestStatus& aStatus );
       
   102 		/**
       
   103 		 *  Cancel incoming data listening
       
   104 		 */
       
   105 		void CancelListening();
       
   106 
       
   107 		/**
       
   108 		 *  Listen Incoming message listening
       
   109 		 */
       
   110 		void CancelListeningMsg();
       
   111 		/**
       
   112 		 * returns fetchingcontinue flag
       
   113 		 */
       
   114         TBool IsFetchingContinue();
       
   115 
       
   116 		/**
       
   117 		 *  Listen Incoming Presence notifications
       
   118          */
       
   119 		TInt ListenIncomingPresence ( TRequestStatus& aStatus );
       
   120 		/**
       
   121 		 *  Cancel Incoming presence listening
       
   122 		 */
       
   123 		void CancelListeningPres();
       
   124 		/**
       
   125 		 *  Listen Incoming Added contact notifications
       
   126          */
       
   127 		TInt ListenAddNotification ( TRequestStatus& aStatus );
       
   128 		/**
       
   129 		 *  Cancel listening Incoming Added contact notifications
       
   130 		 */
       
   131 		void CancelListeningAddNotication();
       
   132 		/**
       
   133 		 *  Listen Incoming network server Error notifications
       
   134          */
       
   135 		TInt ListenIncomingServerError ( TRequestStatus& aStatus );
       
   136 		/**
       
   137 		 *  Cancel Incoming server error listening
       
   138 		 */
       
   139 		void CancelListeningServerErrors();
       
   140 		
       
   141 		/**
       
   142 		 *  issue the releasing reuest and exit
       
   143 		 */
       
   144 		void IssueReleaseRequestL();
       
   145 		
       
   146 		/**
       
   147 		 *  return ETrue if server disconnect has happen
       
   148 		 */
       
   149 		TBool IsServerDisconnect();
       
   150 		/**
       
   151 		 *  Listen any contacts change events
       
   152          */
       
   153 		void ListenContactsChange( TRequestStatus& aStatus );
       
   154 		
       
   155 		/**
       
   156 		 *  Cancel any contacts change events listening
       
   157 		 */
       
   158 		void CancelContactsChangeListening();
       
   159 		/**
       
   160 		 *  ETrue.if fetching contacts is completed
       
   161 		 */
       
   162 		TBool IsFetchContactsCompleted();
       
   163 		
       
   164 	private:
       
   165 		/**
       
   166 		 *  C++ constructor
       
   167 		 */
       
   168 		CWaitTimer ( MOSSProtocolConnectionManager& aConnMan );
       
   169 
       
   170 		/**
       
   171 		 *  Second-phase constructor
       
   172 		 */
       
   173 		void ConstructL();
       
   174 
       
   175 	private: // From CActive
       
   176 	
       
   177 		/**
       
   178 		 *  Handles recieved message queue data.
       
   179 		 */
       
   180 		void RunL();
       
   181 
       
   182 		/**
       
   183 		 *  How to cancel me
       
   184 		 */
       
   185 		void DoCancel();
       
   186 		/**
       
   187 		 * Override to handle leaves from RunL(). Default implementation causes
       
   188 		 * the active scheduler to panic.
       
   189 		 */
       
   190 		TInt RunError ( TInt aError );
       
   191 
       
   192 	private: // new private functions
       
   193 
       
   194 		/**
       
   195 		 *  Find operationl
       
   196 		 *
       
   197 		 *  @return index in array
       
   198 		 */
       
   199 		TInt FindOperation ( TInt aOpId, TInt ( COssSendDataOperation:: *aIdFunc ) () const ) const;
       
   200 		TInt FindOperationL ( TInt aOpId, TInt ( COssSendDataOperation:: *aIdFunc ) () const ) const;
       
   201 		/**
       
   202 		 * set presence as pending into the presence cache
       
   203 		 * for the remote pending contacts
       
   204 		 * @param armsg: message to parse to get remote contacts
       
   205 		 */
       
   206 		void PendingPresenceContactsL(char* aRmessage);      
       
   207 	private:
       
   208 	    /**
       
   209 		 *  State of the active object
       
   210 		 */
       
   211 		TInt iState;  
       
   212 		/**
       
   213 		 *  Request status
       
   214 		 */
       
   215 		TRequestStatus*             iStatus1;
       
   216 		/**
       
   217 		 *  Send data operations
       
   218 		 * Own
       
   219 		 * Elements OWNed
       
   220 		 */
       
   221 		RPointerArray<COssSendDataOperation>   iOperations;
       
   222 		/**
       
   223 		 *  Logs Id iteration
       
   224 		 */
       
   225 		TInt                                    iOpidIterator;
       
   226 		/**
       
   227 		 *  Id iteration
       
   228 		 */
       
   229 		TInt                                    iOpId;
       
   230 
       
   231 		/**
       
   232 		 *  Max number of active requests
       
   233 		 */
       
   234 		TInt                                    iMaxActive;
       
   235 
       
   236 		/**
       
   237 		 *  Incoming data queue
       
   238 		 *  OWN
       
   239 		 */
       
   240 		RPointerArray<char>                   iIncomingData;
       
   241 		/**
       
   242 		 *  Incoming message queue
       
   243 		 *  OWN
       
   244 		 */
       
   245 		RPointerArray<char>                   iIncomingMsg;
       
   246 		/**
       
   247 		 *  Incoming presence information queue
       
   248 		 *  OWN
       
   249 		 */
       
   250 		RPointerArray<char>                   iIncomingPres;
       
   251 		/**
       
   252 		 *  Incoming server error queue
       
   253 		 *  OWN
       
   254 		 */
       
   255 		RPointerArray<char>                   iIncomingServerError;
       
   256 		/**
       
   257 		 *  Incoming add notifications queue
       
   258 		 *  OWN
       
   259 		 */
       
   260 		RPointerArray<char>                   iAddNotification;
       
   261 		/**
       
   262 		 *  Incoming search elements queue
       
   263 		 *  OWN
       
   264 		 */
       
   265 		RPointerArray<char>                   iSearchElements;
       
   266 		/**
       
   267 		 *  Incoming conatct change queue
       
   268 		 *  OWN
       
   269 		 */
       
   270 		RPointerArray<char>                   iContactChangeList;
       
   271 		/**
       
   272 		 *  data Request Status
       
   273 		 *  OWN
       
   274 		 */
       
   275 		TRequestStatus*       iIncReqStatus;
       
   276 		/**
       
   277 		 *   Message Request Status
       
   278 		 *  OWN
       
   279 		 */
       
   280 		TRequestStatus*       iIncMsgReqStatus;
       
   281 		/**
       
   282 		 *  Presence Request Status
       
   283 		 *  OWN
       
   284 		 */
       
   285 		TRequestStatus*       iIncPresReqStatus;
       
   286 		/**
       
   287 		 *  Error Request Status
       
   288 		 *  OWN
       
   289 		 */
       
   290 		TRequestStatus*       iIncErrorReqStatus;
       
   291 		/**
       
   292 		 *  Add Request Status
       
   293 		 *  OWN
       
   294 		 */
       
   295 		TRequestStatus*       iIncAddReqStatus;
       
   296 		/**
       
   297 		 *  Contacts Change Request Status
       
   298 		 *  OWN
       
   299 		 */
       
   300 		TRequestStatus*       iContactsChangeStatus;
       
   301 		
       
   302 		/**
       
   303 		 *  Id which is used to do logs more human readable
       
   304 		 *  OWN
       
   305 		 */
       
   306 		TInt                                    iConnectionLogsId;
       
   307 		
       
   308 	    
       
   309         /**
       
   310 		 *  flag for checking fetching is done
       
   311 		 */
       
   312 	    TBool                                iFetchingContinue;	
       
   313 	    
       
   314 	    /**
       
   315 		 *  connection manager
       
   316 		 */
       
   317 		MOSSProtocolConnectionManager& iConnMan;
       
   318 		/**
       
   319 		 *  Flag to denote whether Msg Queue was created
       
   320 		 * this will help us in reusing the created msgqueue
       
   321 		 */
       
   322 		TBool 									iResponseMsgQCreated ;
       
   323 		/**
       
   324 		 *  ETrue if server disconnect has happen 
       
   325 		 */
       
   326 		TBool iServerDisconnected;
       
   327 		/**
       
   328 		 *  timer to trigger message queue uptation checking
       
   329 		 */
       
   330 		RTimer iTimer;
       
   331 		/**
       
   332 		 *  stores fetching steps
       
   333 		 */ 
       
   334 		TInt iFetchingStep;
       
   335 	};
       
   336 
       
   337 #endif // WAITTIMER_H