imservices/ossprotocoladaptation/src/waittimer.cpp
changeset 0 e6b17d312c8b
child 15 ca8de445a388
equal deleted inserted replaced
-1:000000000000 0:e6b17d312c8b
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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:  oss protocol plugin im features
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "waittimer.h"
       
    20 #include "cosssenddataoperation.h"
       
    21 #include "msgliterals.h"
       
    22 #include "msg_enums.h"
       
    23 #include <stdlib.h>
       
    24 #include "ossprotocloliterals.h"
       
    25 #include "stringutils.h"
       
    26 #include "ossadappanics.h"
       
    27 #include <glib/gprintf.h>
       
    28 #include <string.h>
       
    29 #include <sys/msg.h>
       
    30 #include "ossprotocolpluginlogger.h"
       
    31 #include <ximpobjectfactory.h>
       
    32 #include "mossprotocolconnectionmanager.h"
       
    33 #include "cossprotocolconnectionmanager.h"
       
    34 #include <ximpprotocolconnectionhost.h>
       
    35 #include <ximpstatus.h>
       
    36 #include <math.h>
       
    37 #include <avabilitytext.h>
       
    38 #include "ossprotocoladaptutils.h"
       
    39 // CONSTANTS
       
    40 const TInt KOpIdInitvalue = 1000;
       
    41 
       
    42 #define KTimerInterval 50000
       
    43 
       
    44 #define ONE_K_OPENC_FIX 1020
       
    45 // ======== MEMBER FUNCTIONS ========
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // CWaitTimer::COSSProtocolImFeatures()
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 CWaitTimer::CWaitTimer (MOSSProtocolConnectionManager& aConnMan) :
       
    52 		CActive ( EPriorityHigh ), // Standard priority
       
    53 		iOpidIterator ( KOpIdInitvalue ), iOpId ( 5 ),iConnMan ( aConnMan ),
       
    54 		iResponseMsgQCreated(EFalse),iServerDisconnected(EFalse),
       
    55 		iFetchingStep(EDataFetchingStep1) // -2 for fetching all three  types of contacts
       
    56 	{
       
    57 	CActiveScheduler::Add ( this ); // Add to scheduler
       
    58 	}
       
    59 
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // CWaitTimer::NewL()
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 CWaitTimer* CWaitTimer::NewL (MOSSProtocolConnectionManager& aConnMan)
       
    66 	{
       
    67 	CWaitTimer* self = new ( ELeave ) CWaitTimer (aConnMan);
       
    68 	CleanupStack::PushL ( self );
       
    69 	self->ConstructL ();
       
    70 	CleanupStack::Pop (); // self;
       
    71 	return self;
       
    72 	}
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // CWaitTimer::ConstructL()
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 void CWaitTimer::ConstructL()
       
    79 	{
       
    80 	User::LeaveIfError( iTimer.CreateLocal() );
       
    81 	}
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // CWaitTimer::~CWaitTimer()
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 CWaitTimer::~CWaitTimer()
       
    88 	{
       
    89 	LOGGER ( TXT ( "CWaitTimer::~CWaitTimer  start" ) );
       
    90 	TInt error = 0;
       
    91 	MsgQDelete ( REQUEST_QUEUE, &error );
       
    92 	MsgQDelete ( RESPONSE_QUEUE, &error );
       
    93     iIncomingData.ResetAndDestroy();
       
    94     iIncomingMsg.ResetAndDestroy();
       
    95     iIncomingPres.ResetAndDestroy();
       
    96 	iIncomingServerError.ResetAndDestroy();	
       
    97     iAddNotification.ResetAndDestroy();
       
    98 	if (iIncReqStatus)
       
    99         {
       
   100         User::RequestComplete( iIncReqStatus, KErrCancel );
       
   101         iIncReqStatus = NULL;
       
   102         }
       
   103  	if (iIncMsgReqStatus)
       
   104         {
       
   105         User::RequestComplete( iIncMsgReqStatus, KErrCancel );
       
   106         iIncMsgReqStatus = NULL;
       
   107         }     
       
   108     if (iIncPresReqStatus)
       
   109         {
       
   110         User::RequestComplete( iIncPresReqStatus, KErrCancel );
       
   111         iIncPresReqStatus = NULL;
       
   112         }        
       
   113     if (iIncAddReqStatus)
       
   114         {
       
   115         User::RequestComplete( iIncAddReqStatus, KErrCancel );
       
   116         iIncAddReqStatus = NULL;
       
   117         }        
       
   118     CancelContactsChangeListening();
       
   119 	Cancel (); // Cancel any request, if outstanding
       
   120 	iTimer.Close (); // Destroy the RTimer object
       
   121 	iOperations.ResetAndDestroy();
       
   122 	iSearchElements.ResetAndDestroy(); 
       
   123 	iContactChangeList.ResetAndDestroy();
       
   124 	LOGGER ( TXT ( "CWaitTimer::~CWaitTimer  end" ) );
       
   125 	
       
   126 	}
       
   127 
       
   128 // ---------------------------------------------------------------------------
       
   129 // CWaitTimer::DoCancel()
       
   130 // ---------------------------------------------------------------------------
       
   131 //
       
   132 void CWaitTimer::DoCancel()
       
   133 	{
       
   134 	iTimer.Cancel ();
       
   135 	}
       
   136 
       
   137 // ----------------------------------------------------------------------------
       
   138 // CWaitTimer::IncreaseOpId
       
   139 // ----------------------------------------------------------------------------
       
   140 void CWaitTimer::IncreaseOpId( )
       
   141 	{
       
   142 
       
   143 	iOpId++;
       
   144 
       
   145 	}
       
   146 
       
   147 
       
   148 // ----------------------------------------------------------------------------
       
   149 // CWaitTimer::GetOpId
       
   150 // ----------------------------------------------------------------------------
       
   151 TInt CWaitTimer::GetOpId( )
       
   152 	{
       
   153 
       
   154 	return iOpId;
       
   155 	}
       
   156 // ----------------------------------------------------------------------------
       
   157 // CWaitTimer::IsFetchingContinue
       
   158 // ----------------------------------------------------------------------------
       
   159 TInt CWaitTimer::IsFetchingContinue( )
       
   160 	{
       
   161 
       
   162 	return iFetchingContinue;
       
   163 
       
   164 	}
       
   165 
       
   166 // -----------------------------------------------------------------------------
       
   167 // CWaitTimer::SendDataL()
       
   168 // -----------------------------------------------------------------------------
       
   169 //
       
   170 TInt CWaitTimer::SendDataL ( TRequestStatus& aStatus, char* msg, TInt nBytes )
       
   171 	{
       
   172 	int result;
       
   173 	int err = 0;
       
   174 	int timeout = NO_WAIT;
       
   175 	LOGGER ( TXT ( "CWaitTimer::SendData  start" ) );
       
   176 	// allocate slot in array by adding NULL pointer and removing it
       
   177 	iOperations.AppendL ( NULL );
       
   178 	iOperations.Remove ( iOperations.Count() - 1 );
       
   179 	COssSendDataOperation* operation =
       
   180 	    COssSendDataOperation::NewLC();
       
   181 	operation->SetIds ( iOpId, iOpidIterator++ );
       
   182 	iOperations.Append ( operation );
       
   183 	CleanupStack::Pop ( operation ); // operation
       
   184 	// now it is safe to set request status
       
   185 	operation->SetRequestStatus ( aStatus );
       
   186 	aStatus = KRequestPending;
       
   187 	/* Try to Create queueOne
       
   188 	*/
       
   189     message_hdr_req* msgHdr = ( message_hdr_req* ) msg;
       
   190     result = MsgQCreate ( REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err );
       
   191     User::LeaveIfError ( result );
       
   192     /* Send Message to queueOne */
       
   193     if ( msgHdr->message_type == EUpdateOwnAvtar )
       
   194         {
       
   195         TInt header_size = sizeof( message_hdr_req );
       
   196         char* one_pdu = ( char* ) User::AllocLC ( ONE_K_OPENC_FIX );
       
   197         //run a loop for rest of the data and keep track of the case of nBytes being 
       
   198         //multiple of 1020 - sizeof(msghdr) and it being not
       
   199         //Amount of payload that can be sent
       
   200         TInt single_read = ONE_K_OPENC_FIX - header_size;
       
   201         //Data recieved from PublishOwnPresenceL has message header at begining
       
   202         TInt actual_data = nBytes - header_size;
       
   203         //No of packets needed to send the image data
       
   204         TInt total_packets = (TInt)ceil( ( double ) ( actual_data ) / single_read );
       
   205         //This offset moves thru the msg pointer
       
   206         TInt navigate_offset = header_size;
       
   207         message_hdr_req msg_hdr;
       
   208         memset( (void*)&msg_hdr, '\0', header_size );
       
   209         msg_hdr.message_type = EUpdateOwnAvtar;
       
   210         for ( TInt i = 0; i < total_packets; i++ )
       
   211             {
       
   212             //till the last packet size_tobe_sent will be ONE_K_OPENC_FIX
       
   213             //last packet data is actual_data % single_read if less than single_read else ONE_K_OPENC_FIX
       
   214             TInt size_tobe_sent = ( i < total_packets - 1 ) ? ONE_K_OPENC_FIX : 
       
   215             ( actual_data % single_read ? 
       
   216                 actual_data % single_read  + header_size : ONE_K_OPENC_FIX );
       
   217 
       
   218             if ( i < total_packets - 1 )
       
   219                 {
       
   220                 msg_hdr.continue_flag = 1;
       
   221                 }
       
   222             else 
       
   223                 {
       
   224                 msg_hdr.continue_flag = 0;
       
   225                 }
       
   226 
       
   227             //memcpy ( msg + header_size , msg + navigate_offset, size_tobe_sent - header_size );
       
   228             memcpy( one_pdu , &msg_hdr, header_size );
       
   229             memcpy( one_pdu + header_size, msg + navigate_offset, size_tobe_sent - header_size );
       
   230             result = MsgQSend ( REQUEST_QUEUE, one_pdu, size_tobe_sent, 
       
   231                     MSG_PRI_NORMAL, timeout, &err );
       
   232             User::LeaveIfError ( result );
       
   233             navigate_offset += single_read;
       
   234             }
       
   235         CleanupStack::PopAndDestroy( one_pdu );
       
   236         one_pdu = NULL;
       
   237         }
       
   238     else
       
   239         {
       
   240         result = MsgQSend ( REQUEST_QUEUE, msg, nBytes, MSG_PRI_NORMAL, timeout, &err );
       
   241 
       
   242         User::LeaveIfError ( result );
       
   243         }
       
   244 	LOGGER ( TXT ( "CWaitTimer::SendData  end" ) );
       
   245 
       
   246 	return iOpId;
       
   247 
       
   248 	}
       
   249 // -----------------------------------------------------------------------------
       
   250 // CWaitTimer::ListenConatcsChange()  //contacts
       
   251 // -----------------------------------------------------------------------------
       
   252 //
       
   253 void CWaitTimer::ListenContactsChange ( TRequestStatus& aStatus )
       
   254 	{
       
   255 	LOGGER ( TXT ( "CWaitTimer::ListenContactsChange Start" ) );
       
   256 
       
   257 	if ( !iContactsChangeStatus )
       
   258 		{
       
   259 		iContactsChangeStatus = &aStatus;
       
   260 		aStatus = KRequestPending;
       
   261 		}
       
   262 	LOGGER ( TXT ( "CWaitTimer::ListenContactsChange End" ) );	
       
   263 	}
       
   264 
       
   265 // -----------------------------------------------------------------------------
       
   266 // CWaitTimer::CancelListening()
       
   267 // -----------------------------------------------------------------------------
       
   268 //
       
   269 void CWaitTimer::CancelContactsChangeListening()
       
   270 	{
       
   271 	LOGGER ( TXT ( "CWaitTimer::CancelContactsChangeListening Start" ) );
       
   272 
       
   273 	if ( iContactsChangeStatus )
       
   274 		{
       
   275 		User::RequestComplete ( iContactsChangeStatus, KErrCancel );
       
   276 		iContactsChangeStatus = NULL;
       
   277 		}
       
   278 
       
   279 	LOGGER ( TXT ( "CWaitTimer::CancelContactsChangeListening End" ) );
       
   280 	}
       
   281 
       
   282 
       
   283 // -----------------------------------------------------------------------------
       
   284 // CWaitTimer::ListenIncomingData()  //contacts
       
   285 // -----------------------------------------------------------------------------
       
   286 //
       
   287 void CWaitTimer::ListenIncomingData ( TRequestStatus& aStatus )
       
   288 	{
       
   289 	LOGGER ( TXT ( "CWaitTimer::ListenIncomingData Start" ) );
       
   290 
       
   291 	if ( !iIncReqStatus )
       
   292 		{
       
   293 		iIncReqStatus = &aStatus;
       
   294 		aStatus = KRequestPending;
       
   295 		}
       
   296 	}
       
   297 
       
   298 // -----------------------------------------------------------------------------
       
   299 // CWaitTimer::IncomingDataCount()  //contacts
       
   300 // -----------------------------------------------------------------------------
       
   301 //
       
   302 TInt CWaitTimer::IncomingDataCount()
       
   303 	{
       
   304 	LOGGER ( TXT ( "CWaitTimer::IncomingDataCount Start" ) );
       
   305 
       
   306 	return iIncomingData.Count();
       
   307 	}
       
   308 // -----------------------------------------------------------------------------
       
   309 // CWaitTimer::SearchDataCount()  //Searched data
       
   310 // -----------------------------------------------------------------------------
       
   311 //
       
   312 TInt CWaitTimer::SearchDataCount()
       
   313 	{
       
   314 	return iSearchElements.Count();
       
   315 	}
       
   316 // -----------------------------------------------------------------------------
       
   317 // CWaitTimer::ContactsChangeResponseCount()  //Searched data
       
   318 // -----------------------------------------------------------------------------
       
   319 //
       
   320 TInt CWaitTimer::ContactsChangeResponseCount()
       
   321 	{
       
   322 	return iContactChangeList.Count();
       
   323 	}	
       
   324 // -----------------------------------------------------------------------------
       
   325 // CWaitTimer::CancelListening()
       
   326 // -----------------------------------------------------------------------------
       
   327 //
       
   328 void CWaitTimer::CancelListening()
       
   329 	{
       
   330 	LOGGER ( TXT ( "CWaitTimer::CancelListening Start" ) );
       
   331 
       
   332 	if ( iIncReqStatus )
       
   333 		{
       
   334 		User::RequestComplete ( iIncReqStatus, KErrCancel );
       
   335 		iIncReqStatus = NULL;
       
   336 		}
       
   337 
       
   338 	LOGGER ( TXT ( "CWaitTimer::CancelListening End" ) );
       
   339 	}
       
   340 
       
   341 // -----------------------------------------------------------------------------
       
   342 // CWaitTimer::ListenIncomingMsg()  // messages
       
   343 // -----------------------------------------------------------------------------
       
   344 //
       
   345 TInt CWaitTimer::ListenIncomingMsg ( TRequestStatus& aStatus )
       
   346 	{
       
   347 	LOGGER ( TXT ( "CWaitTimer::ListenIncomingMsg Start" ) );
       
   348 
       
   349 	if ( !iIncMsgReqStatus )
       
   350 		{
       
   351 		iIncMsgReqStatus = &aStatus;
       
   352 		aStatus = KRequestPending;
       
   353 		}
       
   354 
       
   355 	LOGGER ( TXT ( "CWaitTimer::ListenIncomingMsg End Count is %d" ), iIncomingMsg.Count() );
       
   356 
       
   357 	return iIncomingMsg.Count();
       
   358 	}
       
   359 
       
   360 // -----------------------------------------------------------------------------
       
   361 // CWaitTimer::ListenIncomingPresenceL()  // presence notifications
       
   362 // -----------------------------------------------------------------------------
       
   363 //
       
   364 TInt CWaitTimer::ListenIncomingPresence ( TRequestStatus& aStatus )
       
   365 	{
       
   366 	LOGGER ( TXT ( "CWaitTimer::ListenIncomingPresence Start" ) );
       
   367 
       
   368 	if ( !iIncPresReqStatus )
       
   369 		{
       
   370 		iIncPresReqStatus = &aStatus;
       
   371 		aStatus = KRequestPending;
       
   372 		}
       
   373 
       
   374 	LOGGER ( TXT ( "CWaitTimer::ListenIncomingPresence End Count is %d" ), iIncomingPres.Count() );
       
   375 
       
   376 	return iIncomingPres.Count();
       
   377 	}
       
   378 // -----------------------------------------------------------------------------
       
   379 // CWaitTimer::ListenAddNotification()  // Add contact notifications
       
   380 // -----------------------------------------------------------------------------
       
   381 //
       
   382 TInt CWaitTimer::ListenAddNotification ( TRequestStatus& aStatus )
       
   383 	{
       
   384 	LOGGER ( TXT ( "CWaitTimer::ListenAddNotification Start" ) );
       
   385 
       
   386 	if ( !iIncAddReqStatus )
       
   387 		{
       
   388 		iIncAddReqStatus = &aStatus;
       
   389 		aStatus = KRequestPending;
       
   390 		}
       
   391 
       
   392 	LOGGER ( TXT ( "CWaitTimer::ListenAddNotification End Count is %d" ), iAddNotification.Count() );
       
   393 
       
   394 	return iAddNotification.Count();
       
   395 	}	
       
   396 // -----------------------------------------------------------------------------
       
   397 // CWaitTimer::ListenIncomingServerError()  // presence notifications
       
   398 // -----------------------------------------------------------------------------
       
   399 //
       
   400 TInt CWaitTimer::ListenIncomingServerError ( TRequestStatus& aStatus )
       
   401 	{
       
   402 	LOGGER ( TXT ( "CWaitTimer::ListenIncomingServerError Start" ) );
       
   403 
       
   404 	if ( !iIncErrorReqStatus )
       
   405 		{
       
   406 		iIncErrorReqStatus = &aStatus;
       
   407 		aStatus = KRequestPending;
       
   408 		}
       
   409 
       
   410 	LOGGER ( TXT ( "CWaitTimer::ListenIncomingServerError End Count is %d" ), iIncomingServerError.Count() );
       
   411 
       
   412 	return iIncomingServerError.Count();
       
   413 	}
       
   414 // CWaitTimer::CancelListeningMsg()
       
   415 // -----------------------------------------------------------------------------
       
   416 //
       
   417 void CWaitTimer::CancelListeningMsg()
       
   418 	{
       
   419 	LOGGER ( TXT ( "CWaitTimer::CancelListening Start" ) );
       
   420 
       
   421 	if ( iIncMsgReqStatus )
       
   422 		{
       
   423 		User::RequestComplete ( iIncMsgReqStatus, KErrCancel );
       
   424 		iIncMsgReqStatus = NULL;
       
   425 		}
       
   426 
       
   427 	LOGGER ( TXT ( "CWaitTimer::CancelListening End" ) );
       
   428 	}
       
   429 // -----------------------------------------------------------------------------
       
   430 // CWaitTimer::CancelListeningPres()
       
   431 // -----------------------------------------------------------------------------
       
   432 //
       
   433 void CWaitTimer::CancelListeningPres()
       
   434 	{
       
   435 	LOGGER ( TXT ( "CWaitTimer::CancelListeningPres Start" ) );
       
   436 
       
   437 	if ( iIncPresReqStatus )
       
   438 		{
       
   439 		User::RequestComplete ( iIncPresReqStatus, KErrCancel );
       
   440 		iIncPresReqStatus = NULL;
       
   441 		}
       
   442 
       
   443 	LOGGER ( TXT ( "CWaitTimer::CancelListeningPres End" ) );
       
   444 	}
       
   445 // -----------------------------------------------------------------------------
       
   446 // CWaitTimer::CancelListeningAddNotication()
       
   447 // -----------------------------------------------------------------------------
       
   448 //
       
   449 void CWaitTimer::CancelListeningAddNotication()
       
   450 	{
       
   451 	LOGGER ( TXT ( "CWaitTimer::CancelListeningAddNotication Start" ) );
       
   452 
       
   453 	if ( iIncAddReqStatus )
       
   454 		{
       
   455 		User::RequestComplete ( iIncAddReqStatus, KErrCancel );
       
   456 		iIncAddReqStatus = NULL;
       
   457 		}
       
   458 
       
   459 	LOGGER ( TXT ( "CWaitTimer::CancelListeningAddNotication End" ) );
       
   460 	}
       
   461 // -----------------------------------------------------------------------------
       
   462 // CWaitTimer::CancelListeningServerErrors()
       
   463 // -----------------------------------------------------------------------------
       
   464 //
       
   465 void CWaitTimer::CancelListeningServerErrors()
       
   466 	{
       
   467 	LOGGER ( TXT ( "CWaitTimer::CancelListeningServerErrors Start" ) );
       
   468 
       
   469 	if ( iIncErrorReqStatus )
       
   470 		{
       
   471 		User::RequestComplete ( iIncErrorReqStatus, KErrCancel );
       
   472 		iIncErrorReqStatus = NULL;
       
   473 		}
       
   474 
       
   475 	LOGGER ( TXT ( "CWaitTimer::CancelListeningServerErrors End" ) );
       
   476 	}
       
   477 
       
   478 // -----------------------------------------------------------------------------
       
   479 // CWaitTimer::StartListeningL()
       
   480 // -----------------------------------------------------------------------------
       
   481 //
       
   482 
       
   483 void CWaitTimer::StartListeningL()
       
   484 	{
       
   485 	LOGGER ( TXT ( "CWaitTimer::StartListening Start" ) );
       
   486 //	Cancel (); // Cancel any request, just to be sure
       
   487 //	iProperty.Subscribe(iStatus);
       
   488 	iTimer.After ( iStatus, KTimerInterval );
       
   489 	SetActive (); // Tell scheduler a request is active
       
   490 	LOGGER ( TXT ( "CWaitTimer::StartListening End" ) );
       
   491 
       
   492 	}
       
   493 
       
   494 // -----------------------------------------------------------------------------
       
   495 // CWaitTimer::RunL()
       
   496 // -----------------------------------------------------------------------------
       
   497 //
       
   498 
       
   499 void CWaitTimer::RunL()
       
   500 	{
       
   501 
       
   502 	int timeout = IPC_NOWAIT; //TIME_OUT;
       
   503 	int err = 0;
       
   504 	int status = 0;
       
   505 	int size_msg = sizeof ( message_hdr_resp );
       
   506 	TBool msgreadcontinue = EFalse;
       
   507 	message_hdr_resp* msg_struct = NULL;
       
   508 	char* rmsg = NULL;
       
   509 	
       
   510 	if( !iResponseMsgQCreated )
       
   511 		{
       
   512 		status = MsgQCreate ( RESPONSE_QUEUE, MAX_MSG_Q_SIZE, MSG_Q_FIFO, &err );
       
   513 		iResponseMsgQCreated = ETrue;
       
   514 		}
       
   515 
       
   516 	if(-1 == status)
       
   517 		{
       
   518 		LOGGER ( TXT ( "CWaitTimer::leave " ) );  
       
   519 		User::Leave( status );
       
   520 		}	
       
   521     do
       
   522        {
       
   523         rmsg = ( char* ) User::AllocLC ( MAX_MSG_SIZE );
       
   524 
       
   525 	  // Receive Message from queueTwo
       
   526     
       
   527         status = MsgQReceive ( RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err );
       
   528         User::LeaveIfError ( err );
       
   529         //size should be atleast size of message_hdr_resp
       
   530         if( -1 == status )
       
   531             {
       
   532 		    CleanupStack::PopAndDestroy ( rmsg );
       
   533 		    }
       
   534 
       
   535         if ( status >= size_msg )
       
   536   		    {
       
   537   		    LOGGER ( TXT ( "CWaitTimer::MsgQReceive responce recvd" ) );
       
   538 		    msg_struct = ( message_hdr_resp* )rmsg ;
       
   539 		    LOGGER ( TXT ( "CWaitTimer::data recvd of type %d" ), msg_struct->hdr_req.message_type );
       
   540 		
       
   541 		    switch( msg_struct->hdr_req.message_type )
       
   542 			      {
       
   543 			      TInt operationindex;
       
   544 		          case EText_Message_Receive:
       
   545 				      {
       
   546 				      LOGGER ( TXT ( "CWaitTimer::EText_Message_Receive" ) );
       
   547 				      // complete prfw request
       
   548 				      iIncomingMsg.AppendL ( rmsg );
       
   549 				      if ( iIncMsgReqStatus )
       
   550 				          {
       
   551 				          User::RequestComplete ( iIncMsgReqStatus, KErrNone );
       
   552 				          iIncMsgReqStatus = NULL;
       
   553 				          }
       
   554 				      CleanupStack::Pop( rmsg );
       
   555 				      break;
       
   556 				      }
       
   557 		          case EPresenceNotification:
       
   558 		              {
       
   559 
       
   560         			  LOGGER ( TXT ( "CWaitTimer::EPresence_Notification_Received" ) );
       
   561             	      // complete prfw request
       
   562             		  //	iIncomingPres.AppendL ( rmsg );
       
   563             		  iIncomingPres.Insert (rmsg,0);
       
   564             		  if ( iIncPresReqStatus )
       
   565             		      {
       
   566             		      User::RequestComplete ( iIncPresReqStatus, KErrNone );
       
   567             		      iIncPresReqStatus = NULL;
       
   568             		      }
       
   569             		  CleanupStack::Pop( rmsg );
       
   570             		  break;
       
   571 		              }
       
   572 		          case ETrying_To_Add_Contact_Publish:
       
   573 		              {
       
   574 		              LOGGER ( TXT ( "CWaitTimer::ETrying_To_Add_Contact" ) );
       
   575 		              // complete prfw request
       
   576 		              iAddNotification.AppendL ( rmsg );
       
   577 		              if ( iIncAddReqStatus )
       
   578 		                  {
       
   579 		                  User::RequestComplete ( iIncAddReqStatus, KErrNone );
       
   580 		                  iIncAddReqStatus = NULL;
       
   581 		                  }
       
   582 		              CleanupStack::Pop( rmsg );
       
   583 		              break;
       
   584 		              }
       
   585 		        case ESubscribe_Remote_Pending:
       
   586 		        case ETrying_To_Add_Contact_Known:
       
   587 		            {
       
   588 		            LOGGER ( TXT ( "CWaitTimer::Sync of contacts state" ) );
       
   589 		            iContactChangeList.Append(rmsg);
       
   590 		            if ( iContactsChangeStatus )
       
   591 		                {
       
   592 		                User::RequestComplete ( iContactsChangeStatus, KErrNone );
       
   593 		                iContactsChangeStatus = NULL;
       
   594 		                }
       
   595 		            CleanupStack::Pop( rmsg );
       
   596 		            break;    
       
   597 		            }
       
   598 
       
   599 		        case ESubscribe_RP_Accepted:
       
   600 		            {
       
   601 		            CleanupStack::PopAndDestroy( rmsg );
       
   602 		            break;    
       
   603 		            }
       
   604 		       case EPublish_RP_Accepted:
       
   605 		            {
       
   606 		            CleanupStack::PopAndDestroy( rmsg );
       
   607 		            break;
       
   608 		            }	   
       
   609 		        case EPublish_Removed_Or_Rejected:
       
   610 		            {
       
   611 		            LOGGER ( TXT ( "CWaitTimer::Sync of contacts state" ) );
       
   612 		            iContactChangeList.Append(rmsg);
       
   613 		            if ( iContactsChangeStatus )
       
   614 		                {
       
   615 		                User::RequestComplete ( iContactsChangeStatus, KErrNone );
       
   616 		                iContactsChangeStatus = NULL;
       
   617 		                }
       
   618 		            CleanupStack::Pop( rmsg );
       
   619 		            break;    
       
   620 		            }
       
   621 		          case ESubscribe_Removed_Or_Rejected:
       
   622 		              {
       
   623 		              LOGGER ( TXT ( "CWaitTimer::Sync of contacts state" ) );
       
   624 		              iContactChangeList.Append(rmsg);
       
   625 		              if ( iContactsChangeStatus )
       
   626 		                  {
       
   627 		                  User::RequestComplete ( iContactsChangeStatus, KErrNone );
       
   628 		                  iContactsChangeStatus = NULL;
       
   629 		                  }
       
   630 		              CleanupStack::Pop( rmsg );
       
   631 		              break;	
       
   632 		              }
       
   633     			case ECurrent_Member_Contacts:
       
   634     				{
       
   635     				iFetchingContinue = EFalse;
       
   636     				// complete ximpfw request
       
   637     				iIncomingData.AppendL ( rmsg );
       
   638     				if(msg_struct->continue_flag == 1)
       
   639     					{
       
   640     					iFetchingContinue = ETrue;
       
   641     					}
       
   642     				else
       
   643     					{
       
   644     					iFetchingStep++ ;	// move to next step
       
   645     					}
       
   646 					
       
   647     				if ( iIncReqStatus && iFetchingStep == EDataFetchComplete )// complete request only if step is 1
       
   648     					{
       
   649     					User::RequestComplete ( iIncReqStatus, KErrNone );
       
   650     					iIncReqStatus = NULL;
       
   651     					}
       
   652     				CleanupStack::Pop( rmsg );	
       
   653     				break;	
       
   654     				}
       
   655     			case ELocal_Pending_Contacts:
       
   656     				{
       
   657     				LOGGER ( TXT ( "CWaitTimer::ELocal_Pending_Contacts" ) );
       
   658                     // complete prfw request
       
   659     				iAddNotification.AppendL ( rmsg );  
       
   660     				if ( iIncAddReqStatus )
       
   661     				    {
       
   662                         LOGGER ( TXT ( "CWaitTimer::ELocal_Pending_Contacts" ) );			                    
       
   663                         User::RequestComplete ( iIncAddReqStatus, KErrNone );
       
   664                         iIncAddReqStatus = NULL;
       
   665                         }
       
   666                     CleanupStack::Pop( rmsg );                
       
   667     				break;	
       
   668     				}
       
   669     			case ERemote_Pending_Contacts:
       
   670         			{
       
   671         			LOGGER ( TXT ( "CWaitTimer::ECurrent_Member_Contacts" ) );
       
   672         			iFetchingContinue = EFalse;
       
   673         			// complete ximpfw request
       
   674         			iIncomingData.AppendL ( rmsg );
       
   675         			PendingPresenceContactsL(rmsg);
       
   676         			if(msg_struct->continue_flag == 1)
       
   677         				{
       
   678         				iFetchingContinue = ETrue;
       
   679         				}
       
   680         			else
       
   681         				{
       
   682         				iFetchingStep++ ;	// move next step
       
   683         				}	
       
   684         			if ( iIncReqStatus && iFetchingStep == EDataFetchComplete) // complete request only if step is 1
       
   685         				{
       
   686         				User::RequestComplete ( iIncReqStatus, KErrNone );
       
   687         				iIncReqStatus = NULL;
       
   688         				}
       
   689         			CleanupStack::Pop( rmsg );
       
   690         			break;
       
   691         			}
       
   692     			case ESend_Error:
       
   693     				{
       
   694     				LOGGER ( TXT ( "CWaitTimer::ESend_Error" ) );
       
   695     				// complete ximpfw request
       
   696     				iIncomingServerError.AppendL ( rmsg );
       
   697     				if ( iIncErrorReqStatus )
       
   698     					{
       
   699     					User::RequestComplete ( iIncErrorReqStatus, KErrNone );
       
   700     					iIncErrorReqStatus = NULL;
       
   701     					}
       
   702     				CleanupStack::Pop( rmsg );
       
   703     				break;
       
   704     				}
       
   705     				
       
   706     			case EUserEndGprs: 
       
   707     			    LOGGER ( TXT ( "CWaitTimer::EUserCancelAccessPoint start" ) );
       
   708     			    
       
   709     			case EServer_DisConnect_Request:
       
   710     				{
       
   711     				iServerDisconnected = ETrue;
       
   712     				LOGGER ( TXT ( "CWaitTimer::EServer_DisConnect_Request start" ) );
       
   713     				CancelListeningMsg();
       
   714     				CancelListening();
       
   715     				CancelListeningPres();
       
   716     				CancelListeningAddNotication();
       
   717     				CancelListeningServerErrors();
       
   718                     CancelContactsChangeListening();
       
   719                 
       
   720     				MXIMPObjectFactory& prfwObjFact = iConnMan.HandleToHost().ObjectFactory();
       
   721     				MXIMPStatus* status = prfwObjFact.NewStatusLC();// status
       
   722     				status->SetResultCode( KErrDisconnected );
       
   723     				iConnMan.HandleToHost().HandleConnectionTerminated( status );
       
   724  					//IssueReleaseRequestL();//Release the connection
       
   725     				CleanupStack::PopAndDestroy(); // status
       
   726     				CleanupStack::Pop( rmsg );
       
   727     				LOGGER ( TXT ( "CWaitTimer::EServer_DisConnect_Request end" ) );
       
   728     				break;
       
   729     				}
       
   730     			case ESearch_State_Finished:
       
   731     				{
       
   732                     LOGGER ( TXT ( "CWaitTimer::ESearch_State_Finished" ) );
       
   733     				operationindex = ( FindOperationL ( iOpId, COssSendDataOperation::OperationId ) );
       
   734     
       
   735     				if ( operationindex != KErrNotFound )
       
   736     					{
       
   737     					LOGGER ( TXT ( "CWaitTimer::FindOperationL found" ) );
       
   738     					iOperations[ operationindex ]->SetResponse ( rmsg ); //ownership of rmsg is transferred
       
   739     					iOperations[ operationindex ]->CompletedOperation ( KErrNone );
       
   740     					}
       
   741     				CleanupStack::Pop( rmsg );	
       
   742     				break;	
       
   743     				}
       
   744     			case ESearch:
       
   745     				{
       
   746     				LOGGER ( TXT ( "CWaitTimer::ESearch" ) );
       
   747     				if ( msg_struct->response != 0 ) 
       
   748     					{
       
   749     					LOGGER ( TXT ( "CWaitTimer::ESearch : Result" ) );
       
   750                         char* pResponse = ( char* ) User::AllocLC ( status );
       
   751     					memset ( pResponse, '\0', status );
       
   752                         memcpy ( pResponse, rmsg, status );
       
   753     					iSearchElements.AppendL ( pResponse );
       
   754     				    CleanupStack::Pop( pResponse );
       
   755     		            CleanupStack::PopAndDestroy( rmsg );
       
   756     					}
       
   757     				else
       
   758     					{
       
   759     					LOGGER ( TXT ( "CWaitTimer::ESearch: ERROR !!" ) );
       
   760     					operationindex = ( FindOperationL ( iOpId, COssSendDataOperation::OperationId ) );
       
   761     					iOperations[ operationindex ]->SetResponse ( rmsg ); //ownership of rmsg is transferred
       
   762     				    iOperations[ operationindex ]->CompletedOperation ( KErrNotSupported );// for all errors
       
   763     				    CleanupStack::Pop( rmsg );
       
   764     				    // send  not supported, since the error mapping is  not done 	
       
   765     					}	
       
   766     				break;
       
   767     				}
       
   768     			case ESearch_Get_Keys:
       
   769     				{
       
   770     				
       
   771     				LOGGER ( TXT ( "CWaitTimer::ESearch_Get_Keys" ) );
       
   772     				operationindex = ( FindOperationL ( iOpId, COssSendDataOperation::OperationId ) );
       
   773     
       
   774     				if ( operationindex != KErrNotFound )
       
   775     					{
       
   776     					LOGGER ( TXT ( "CWaitTimer::FindOperationL found" ) );
       
   777     					iOperations[ operationindex ]->SetResponse ( rmsg ); //ownership of rmsg is transferred
       
   778     					iOperations[ operationindex ]->CompletedOperation ( KErrNone );
       
   779     					}
       
   780     				CleanupStack::Pop( rmsg );
       
   781     				LOGGER ( TXT ( "CWaitTimer::ESearch_Get_Keys end" ) );
       
   782     				break;
       
   783     				}
       
   784     			case ESearch_State_During :
       
   785     				{
       
   786     				LOGGER ( TXT ( "CWaitTimer::ESearch_State_During" ) );
       
   787     				iSearchElements.ResetAndDestroy();
       
   788     				CleanupStack::PopAndDestroy( rmsg );
       
   789     				LOGGER ( TXT ( "CWaitTimer::ESearch_State_During end" ) );
       
   790     				break;	
       
   791     				}
       
   792 			case EUpdateOwnAvtar :	
       
   793 			    {
       
   794                 LOGGER ( TXT ( "CWaitTimer::EUpdateOwnAvtar" ) );
       
   795                 operationindex = ( FindOperationL ( iOpId, COssSendDataOperation::OperationId ) );
       
   796 
       
   797                 if ( operationindex != KErrNotFound )
       
   798                     {
       
   799                     LOGGER ( TXT ( "CWaitTimer::FindOperationL found" ) );
       
   800 
       
   801                     iOperations[ operationindex ]->SetResponse ( rmsg ); //ownership of rmsg is transferred
       
   802                     iOperations[ operationindex ]->CompletedOperation ( KErrNone );
       
   803                     }
       
   804                 CleanupStack::Pop( rmsg );
       
   805                 break;
       
   806 			    }
       
   807     			default:
       
   808     					{
       
   809     					LOGGER ( TXT ( "CWaitTimer::default start" ) );
       
   810     					operationindex = ( FindOperationL ( iOpId, COssSendDataOperation::OperationId ) );
       
   811     
       
   812     					if ( operationindex != KErrNotFound )
       
   813     						{
       
   814     						LOGGER ( TXT ( "CWaitTimer::FindOperationL found" ) );
       
   815     
       
   816     						iOperations[ operationindex ]->SetResponse ( rmsg ); //ownership of rmsg is transferred
       
   817     						iOperations[ operationindex ]->CompletedOperation ( KErrNone );
       
   818     						}
       
   819     					CleanupStack::Pop( rmsg );
       
   820     					LOGGER ( TXT ( "CWaitTimer::default end" ) );
       
   821     					break;
       
   822     					}
       
   823 			      }
       
   824 
       
   825 		    TInt pendingMsgCount = MsgQCheck(RESPONSE_QUEUE, &err );
       
   826 		    if( pendingMsgCount > 0)
       
   827 		        {
       
   828 		        msgreadcontinue = ETrue;
       
   829 		        }
       
   830 		    else 
       
   831 		        {
       
   832 		        msgreadcontinue = EFalse;
       
   833 		        }
       
   834 		    LOGGER ( TXT ( "CWaitTimer::pendingMsgCount is %d" ), pendingMsgCount );   
       
   835   		    }
       
   836        }while( msgreadcontinue );
       
   837 		/*
       
   838 		// there is no pending message in msgqueue,
       
   839 		// set active and subscribe for incomming queue message
       
   840 		iProperty.Subscribe(iStatus);
       
   841 		SetActive(); // Tell scheduler a request is active	*/
       
   842 		
       
   843 		iTimer.After( iStatus, KTimerInterval );
       
   844 		SetActive();
       
   845 	}
       
   846 // -----------------------------------------------------------------------------
       
   847 // CWaitTimer::PendingPresenceContactsL()
       
   848 // -----------------------------------------------------------------------------
       
   849 //
       
   850 void CWaitTimer::PendingPresenceContactsL(char* aRmessage)
       
   851     {
       
   852     char* prmsg = NULL;
       
   853     prmsg = aRmessage;
       
   854     HBufC16 *contactName = NULL;
       
   855     HBufC* name = NULL;
       
   856     int len = 0;
       
   857     if( aRmessage )
       
   858         {
       
   859         prmsg += sizeof ( message_hdr_resp );
       
   860         MPresenceBuddyInfo2* buddyPresInfo = MPresenceBuddyInfo2::NewLC();
       
   861    
       
   862         MPresenceCacheWriter2* presenceCacheWriter = MPresenceCacheWriter2::CreateWriterL();
       
   863         CleanupDeletePushL(presenceCacheWriter);
       
   864         while(1)
       
   865             {
       
   866             len = strlen(prmsg) + 1;
       
   867             if (1 == len)
       
   868                 {
       
   869                 break;
       
   870                 }
       
   871             char* contact = prmsg;  
       
   872             prmsg += len;
       
   873 
       
   874             contactName = OssProtocolAdapUtils::ConvertCharToTUint16LC( contact );
       
   875             LOGGER ( TXT ( "CWaitTimer::PendingPresenceContacts:ContactName:%S " ), contactName );
       
   876 
       
   877             //  contacts.AppendL(contactName);
       
   878             name = HBufC::NewLC( contactName->Length() + iConnMan.ServiceName().Length() + KColon().Length() );
       
   879             TPtr namePtr( name->Des() );
       
   880             namePtr.Zero();
       
   881             namePtr.Append(iConnMan.ServiceName() ); // prepend service name
       
   882             namePtr.Append(KColon);
       
   883             namePtr.Append(contactName->Des() );
       
   884             buddyPresInfo->SetIdentityL(namePtr);
       
   885             LOGGER ( TXT ( "CPresenceNotificationHandler::ProcessIncomingDataL  :ContactName:%S " ), contactName ); 
       
   886     
       
   887             buddyPresInfo->SetAnyFieldL(KExtensionKey,KPendingRequestExtensionValue());
       
   888             CleanupStack::PopAndDestroy(2);//name,contactName
       
   889             name = NULL;
       
   890             contactName = NULL;
       
   891             // Writing into Presence Cache
       
   892             TInt cacheerror = presenceCacheWriter->WritePresenceL(buddyPresInfo);
       
   893             User::LeaveIfError ( cacheerror);
       
   894            
       
   895             } 
       
   896         CleanupStack::PopAndDestroy(2);//presenceCacheWriter,buddyPresInfo
       
   897 
       
   898         }
       
   899     }
       
   900 // -----------------------------------------------------------------------------
       
   901 // CWaitTimer::ResponseL()
       
   902 // -----------------------------------------------------------------------------
       
   903 //
       
   904 
       
   905 char* CWaitTimer::ResponseL ( TInt aTransId )
       
   906 	{
       
   907 	
       
   908 	if ( aTransId == 0 )   // for contact list
       
   909 		{
       
   910 		if ( iIncomingData.Count() == 0 )
       
   911 			{
       
   912 			User::Leave ( KErrNotFound );
       
   913 			}
       
   914 
       
   915 		// take first one from the array
       
   916 		char* buff = iIncomingData[ 0 ];
       
   917 
       
   918 		iIncomingData.Remove ( 0 );
       
   919 		iIncomingData.Compress();
       
   920 		return buff;
       
   921 		}
       
   922 
       
   923 	if ( aTransId == 1 )     //for receive message
       
   924 		{
       
   925 		if ( iIncomingMsg.Count() == 0 )
       
   926 			{
       
   927 			User::Leave ( KErrNotFound );
       
   928 			}
       
   929 
       
   930 		// take first one from the array
       
   931 		char* buff = iIncomingMsg[ 0 ];
       
   932 
       
   933 		iIncomingMsg.Remove ( 0 );
       
   934 
       
   935 		return buff;
       
   936 		}
       
   937 	if ( aTransId == 2 )     //for presence notifications
       
   938 		{
       
   939 		TInt pCount = iIncomingPres.Count();
       
   940 		
       
   941 		if ( pCount == 0 )
       
   942 			{
       
   943 			User::Leave ( KErrNotFound );
       
   944 			}
       
   945 
       
   946 		// take first one from the array
       
   947 		char* buff = iIncomingPres[ pCount-1 ];
       
   948 
       
   949 		iIncomingPres.Remove ( pCount-1 );
       
   950 		iIncomingPres.Compress();
       
   951 		return buff;
       
   952 		}
       
   953 	if ( aTransId == 3 )     //for send error
       
   954 		{
       
   955 		if ( iIncomingServerError.Count() == 0 )
       
   956 			{
       
   957 			User::Leave ( KErrNotFound );
       
   958 			}
       
   959 
       
   960 		// take first one from the array
       
   961 		char* buff = iIncomingServerError[ 0 ];
       
   962 
       
   963 		iIncomingServerError.Remove ( 0 );
       
   964 
       
   965 		return buff;
       
   966 		}
       
   967 	if ( aTransId == 4 )     //for Add notifications
       
   968 		{
       
   969 		if ( iAddNotification.Count() == 0 )
       
   970 			{
       
   971 			User::Leave ( KErrNotFound );
       
   972 			}
       
   973 
       
   974 		// take first one from the array
       
   975 		char* buff = iAddNotification[ 0 ];
       
   976 
       
   977 		iAddNotification.Remove ( 0 );
       
   978 
       
   979 		return buff;
       
   980 		}			
       
   981 	if( aTransId == 5 )	 // search results 
       
   982 		{
       
   983 	    // take first one from the array
       
   984 	    char*  buff=NULL;
       
   985 	    
       
   986 		if ( iSearchElements.Count() != 0 )
       
   987 			{
       
   988 		    buff = iSearchElements[ 0 ];
       
   989 			iSearchElements.Remove ( 0 );
       
   990 			iSearchElements.Compress();
       
   991 			}
       
   992        	else 
       
   993 	        {
       
   994 	       	TInt x ( FindOperationL ( 6, COssSendDataOperation::OperationId ) );
       
   995 			if( x != -1)
       
   996 				{	// is operation completed?
       
   997 				TRequestStatus* status = iOperations[ x ]->Status();
       
   998 
       
   999 				if ( status && ( *status == KRequestPending ) )
       
  1000 					{
       
  1001 					User::Leave ( KErrNotReady );
       
  1002 					}
       
  1003 				delete iOperations[ x ];
       
  1004 				iOperations.Remove ( x );
       
  1005 				}
       
  1006 	
       
  1007 	        }
       
  1008 	
       
  1009 		return buff; // return the  buffer 	
       
  1010 		}
       
  1011 	if ( aTransId == 200 )     //for contact sync
       
  1012 		{
       
  1013 		if ( iContactChangeList.Count() == 0 )
       
  1014 			{
       
  1015 			User::Leave ( KErrNotFound );
       
  1016 			}
       
  1017 
       
  1018 		// take first one from the array
       
  1019 		char* buff = iContactChangeList[ 0 ];
       
  1020 
       
  1021 		iContactChangeList.Remove ( 0 );
       
  1022         iContactChangeList.Compress();
       
  1023 		return buff;
       
  1024 		}			
       
  1025 	// try to find operation
       
  1026 	TInt x ( FindOperationL ( aTransId, COssSendDataOperation::OperationId ) );
       
  1027 
       
  1028 	// is operation completed?
       
  1029 	TRequestStatus* status = iOperations[ x ]->Status();
       
  1030 
       
  1031 	if ( status && ( *status == KRequestPending ) )
       
  1032 		{
       
  1033 		User::Leave ( KErrNotReady );
       
  1034 		}
       
  1035 
       
  1036 	char* buff = iOperations[ x ]->Response();
       
  1037 
       
  1038 	delete iOperations[ x ];
       
  1039 	iOperations.Remove ( x );
       
  1040 	return buff;
       
  1041 	}
       
  1042 
       
  1043 // -----------------------------------------------------------------------------
       
  1044 // CWaitTimer::RunError()
       
  1045 // -----------------------------------------------------------------------------
       
  1046 //
       
  1047 
       
  1048 TInt CWaitTimer::RunError ( TInt aError )
       
  1049 	{
       
  1050 	return aError;
       
  1051 	}
       
  1052 
       
  1053 // =============================================================================
       
  1054 // =============== New private Functions of the base class =====================
       
  1055 // =============================================================================
       
  1056 
       
  1057 // -----------------------------------------------------------------------------
       
  1058 // CWaitTimer::FindOperation()
       
  1059 // Find operation in array
       
  1060 // (other items were commented in a header).
       
  1061 // -----------------------------------------------------------------------------
       
  1062 //
       
  1063 TInt CWaitTimer::FindOperation (
       
  1064     TInt aOpId,
       
  1065     TInt ( COssSendDataOperation:: *aIdFunc ) () const ) const
       
  1066 	{
       
  1067 	LOGGER ( TXT ( "CWaitTimer::FindOperation Start" ) );
       
  1068 	TInt count ( iOperations.Count() );
       
  1069 
       
  1070 	for ( TInt x ( 0 ) ; x < count ; ++x )
       
  1071 		{
       
  1072 		if ( aOpId == ( ( *iOperations[ x ] ).*aIdFunc ) () )
       
  1073 			{
       
  1074 			LOGGER ( TXT ( "CWaitTimer::FindOperation Returns %d" ), x );
       
  1075 			return x;
       
  1076 			}
       
  1077 		}
       
  1078 
       
  1079 	LOGGER ( TXT ( "CWaitTimer::FindOperation End" ) );
       
  1080 
       
  1081 	return KErrNotFound;
       
  1082 	}
       
  1083 
       
  1084 // -----------------------------------------------------------------------------
       
  1085 // CWaitTimer::FindOperationL()
       
  1086 // Find operation in array, leave if not found
       
  1087 // (other items were commented in a header).
       
  1088 // -----------------------------------------------------------------------------
       
  1089 //
       
  1090 TInt CWaitTimer::FindOperationL (
       
  1091     TInt aOpId,
       
  1092     TInt ( COssSendDataOperation:: *aIdFunc ) () const ) const
       
  1093 	{
       
  1094 	LOGGER ( TXT ( "CWaitTimer::FindOperation Start" ) );
       
  1095 	TInt x ( FindOperation ( aOpId, aIdFunc ) );
       
  1096 
       
  1097 	LOGGER ( TXT ( "CWaitTimer::FindOperation End Returns %d" ), x );
       
  1098 
       
  1099 	return x;
       
  1100 	}
       
  1101 
       
  1102 // -----------------------------------------------------------------------------
       
  1103 // CWaitTimer::IssueReleaseRequestL()
       
  1104 // (other items were commented in a header).
       
  1105 // -----------------------------------------------------------------------------
       
  1106 //
       
  1107 void CWaitTimer::IssueReleaseRequestL()
       
  1108 	{
       
  1109 	LOGGER ( TXT ( "CWaitTimer::IssueReleaseRequestL Start" ) );
       
  1110 	int err = 0;
       
  1111 	int timeout = NO_WAIT;
       
  1112 	message_hdr_req *msgHdr = NULL;
       
  1113 	msgHdr = ( message_hdr_req* ) User::AllocLC(sizeof ( message_hdr_req ));
       
  1114 	memset ( msgHdr, '\0', sizeof ( message_hdr_req ) );
       
  1115 	msgHdr->message_type = EKill_Process;
       
  1116 	
       
  1117 	TInt nBytes = sizeof ( message_hdr_req );
       
  1118 
       
  1119 	MsgQCreate ( REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err );
       
  1120 	
       
  1121 	MsgQSend ( REQUEST_QUEUE, ( char* ) msgHdr , nBytes, MSG_PRI_NORMAL, timeout, &err );
       
  1122 	
       
  1123 	CleanupStack::PopAndDestroy ( msgHdr );
       
  1124 	
       
  1125 	LOGGER ( TXT ( "CWaitTimer::IssueReleaseRequestL end" ) );
       
  1126 
       
  1127 	}
       
  1128 // ---------------------------------------------------------------------------
       
  1129 // CWaitTimer::IsServerDisconnect()
       
  1130 // ---------------------------------------------------------------------------
       
  1131 //	
       
  1132 TBool CWaitTimer::IsServerDisconnect()
       
  1133 	{
       
  1134 	return iServerDisconnected;	
       
  1135 	}
       
  1136 // ---------------------------------------------------------------------------
       
  1137 // CWaitTimer::IsFetchContactsCompleted()
       
  1138 // ---------------------------------------------------------------------------
       
  1139 //  
       
  1140 TBool CWaitTimer::IsFetchContactsCompleted()
       
  1141     {
       
  1142     if(iFetchingStep == EDataFetchComplete)
       
  1143         {
       
  1144         return ETrue;
       
  1145         }
       
  1146     return EFalse;
       
  1147     }
       
  1148 
       
  1149 	
       
  1150 // End of file