void UDPClientIP::FireConnectionClosed()
{
	try
	{
		if (SessionClosed)
			SessionClosed();
	} catch (std::exception& ex)
	{
		LOG_ERROR("FireConnectionClosed failed. error=" << ex.what());
	} catch (...)
	{
		LOG_ERROR("FireConnectionClosed failed. unknown error!");
	}
}
void CMsgImOutboxSend::RunL()
	{
	TInt status = iStatus.Int();

	if (status == KErrNone)
		{
		switch (iState)
			{
			case EStateUserPrompting:
				{
				StartConnectingL();
				break;
				}

			case EStateConnectingSession:
				{
				SessionConnectedL();
				break;
				}

			case EStateSendingFiles:
				{
				SentFiles();
				break;
				}

			case EStateClosingSession:
				{
				SessionClosed();
				break;
				}

			case EStateWaitingNewCarrier:
				{
				MigratedL();
				break;
				}

			case EStateMobilityError:
				{
				// A mobility error occurred while we were closing the session after
				// sending all the messages.
				// do nothing
				break;
				}

			default:
				{
				__ASSERT_DEBUG(EFalse, gPanic(EImsmUnexpectedState3));
				break;
				}
			}
		}
	else
		{
		switch (iState)
			{
			case EStateUserPrompting:
				{
				// do nothing
				break;
				}

			case EStateConnectingSession:
				{
				SessionConnectionFailed();
				break;
				}

			case EStateSendingFiles:
				{
				// closing Session with server 	
				SentFiles();
				break;
				}

			case EStateClosingSession:
				{
				// Failure to close a session can be ignored as it will have been
				// tidied up.
				// Continue by assuming the close was successful.
				SessionClosed();
				break;
				}

			case EStateMobilityError:
				{
				// do nothing
				break;
				}

			case EStateWaitingNewCarrier:
			default:
				{
				__ASSERT_DEBUG(EFalse, gPanic(EImsmUnexpectedState4));
				}
			}
		}

	// If we are not active then this means we should complete
	if (!IsActive())
		{
		if (iSession)
			{
			iProgress.iSendFileProgress = iSession->FileProgress();
			}
		else
			{
			iProgress.iSendFileProgress.iSessionState = EClosingSmtp;
			iProgress.iSendFileProgress.iBytesSent = 0;
			iProgress.iSendFileProgress.iBytesToSend = 0;
			}

		Complete(status);
		}
	}