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