mtpfws/mtpfw/src/cmtpconnection.cpp
branchRCL_3
changeset 20 4a793f564d72
parent 19 0aa8cc770c8a
child 21 74aa6861c87d
equal deleted inserted replaced
19:0aa8cc770c8a 20:4a793f564d72
    80 CMTPConnection::~CMTPConnection()
    80 CMTPConnection::~CMTPConnection()
    81     {
    81     {
    82     __FLOG(_L8("~CMTPConnection - Entry"));
    82     __FLOG(_L8("~CMTPConnection - Entry"));
    83     CloseAllSessions();
    83     CloseAllSessions();
    84     
    84     
    85 	//remove all events
    85     // Remove any events not associated 
    86     DequeueAllEvents();
    86     // with a session
    87 	
    87     TSglQueIter<CMTPEventLink> iter(iEventQ);
       
    88     iter.SetToFirst();
       
    89     CMTPEventLink* link = NULL;
       
    90     
       
    91     while ((link = iter++) != NULL)
       
    92     	{
       
    93     	delete link;
       
    94     	}
       
    95     
    88     iSessions.ResetAndDestroy();
    96     iSessions.ResetAndDestroy();
    89     
    97     
    90     if (iTransportConnection != NULL)
    98     if (iTransportConnection != NULL)
    91         {
    99         {
    92         iTransportConnection->Unbind(*this);
   100         iTransportConnection->Unbind(*this);
   657         }
   665         }
   658     // Dequeue first since the code below might leave.
   666     // Dequeue first since the code below might leave.
   659     DequeueEvent(iEventQ.First());       
   667     DequeueEvent(iEventQ.First());       
   660    	if (iPendingEventCount > 0)
   668    	if (iPendingEventCount > 0)
   661    		{
   669    		{
   662 		if (NULL != iTransportConnection)
   670    		// Forward the event to the transport connection layer.
   663 			{
   671    		__FLOG(_L8("Sending queued event"));
   664 			// Forward the event to the transport connection layer.
   672  	    iTransportConnection->SendEventL(iEventQ.First()->iEvent);
   665 			__FLOG(_L8("Sending queued event"));
       
   666 			iTransportConnection->SendEventL(iEventQ.First()->iEvent);
       
   667 			}
       
   668 		else
       
   669 			{
       
   670 			DequeueAllEvents();
       
   671 			}
       
   672    		}
   673    		}
   673     
   674     
   674     __FLOG(_L8("SendEventCompleteL - Exit"));
   675     __FLOG(_L8("SendEventCompleteL - Exit"));
   675     }
   676     }
   676 
   677 
  1043 		}
  1044 		}
  1044     
  1045     
  1045     __FLOG(_L8("RemoveEventsForSession - Exit"));
  1046     __FLOG(_L8("RemoveEventsForSession - Exit"));
  1046 	}
  1047 	}
  1047 
  1048 
  1048 void CMTPConnection::DequeueAllEvents()
       
  1049 	{
       
  1050 	TSglQueIter<CMTPEventLink> iter(iEventQ);
       
  1051     iter.SetToFirst();
       
  1052     CMTPEventLink* link = NULL;
       
  1053     
       
  1054     while ((link = iter++) != NULL)
       
  1055     	{
       
  1056     	delete link;
       
  1057     	}
       
  1058 	iPendingEventCount = 0;
       
  1059 	}
       
  1060 	
       
  1061 void CMTPConnection::DequeueEvent(CMTPEventLink* aLink)
  1049 void CMTPConnection::DequeueEvent(CMTPEventLink* aLink)
  1062 	{
  1050 	{
  1063 	iEventQ.Remove(*aLink);
  1051 	iEventQ.Remove(*aLink);
  1064 	delete aLink;
  1052 	delete aLink;
  1065 	--iPendingEventCount;	
  1053 	--iPendingEventCount;