imservices/ossprotocoladaptation/src/cossprotocollogoutrequest.cpp
changeset 46 860cd8a5168c
parent 35 085f765766a0
equal deleted inserted replaced
35:085f765766a0 46:860cd8a5168c
     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:  Login Request to the Network Server.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "cossprotocollogoutrequest.h"
       
    20 #include <ximpprotocolconnectionhost.h>
       
    21 #include "mossprotocolconnectionmanager.h"
       
    22 #include "ossprotocolpluginlogger.h"
       
    23 #include "cossprotocolconnection.h"
       
    24 #include "cossprotocolconnectionmanager.h"
       
    25 #include <stdlib.h>
       
    26 #include "stringutils.h"
       
    27 #include <string.h>
       
    28 #include "msgliterals.h"
       
    29 #include "xmppparameters.h"
       
    30 #include "msg_enums.h"
       
    31 #include <ximpobjectfactory.h>
       
    32 
       
    33 
       
    34 
       
    35 // ======== MEMBER FUNCTIONS ========
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // COSSProtocolLogoutRequest::COSSProtocolLogoutRequest()
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 COSSProtocolLogoutRequest::COSSProtocolLogoutRequest (
       
    42     MOSSProtocolConnectionManager& aConnMan,
       
    43     TXIMPRequestId aRequestId ) :
       
    44 		CActive ( CActive::EPriorityStandard  ),
       
    45 		iRequestId ( aRequestId ),
       
    46 		iConnMan ( aConnMan )
       
    47 	{
       
    48 	LOGGER ( TXT ( "COSSProtocolLogoutRequest::COSSProtocolLogoutRequest Start" ) );
       
    49 	CActiveScheduler::Add ( this );
       
    50 	LOGGER ( TXT ( "COSSProtocolLogoutRequest::COSSProtocolLogoutRequest End" ) );
       
    51 	}
       
    52 
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // COSSProtocolLogoutRequest::ConstructL()
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 void COSSProtocolLogoutRequest::ConstructL()
       
    59 	{
       
    60 	LOGGER ( TXT ( "COSSProtocolLogoutRequest::COSSProtocolLogoutRequest Start-End" ) );
       
    61 	}
       
    62 
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // COSSProtocolLogoutRequest::NewL()
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 COSSProtocolLogoutRequest* COSSProtocolLogoutRequest::NewL (
       
    69     MOSSProtocolConnectionManager& aConnMan,
       
    70     TXIMPRequestId aRequestId )
       
    71 	{
       
    72 	LOGGER ( TXT ( "COSSProtocolLogoutRequest::NewL Start" ) );
       
    73 
       
    74 	COSSProtocolLogoutRequest* self =
       
    75 	    new ( ELeave ) COSSProtocolLogoutRequest ( aConnMan, aRequestId );
       
    76 	CleanupStack::PushL ( self );
       
    77 	self->ConstructL();
       
    78 	CleanupStack::Pop ( self );
       
    79 
       
    80 	LOGGER ( TXT ( "COSSProtocolLogoutRequest::NewL End" ) );
       
    81 	return self;
       
    82 	}
       
    83 
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // COSSProtocolLogoutRequest::NewLC()
       
    87 // ---------------------------------------------------------------------------
       
    88 //
       
    89 COSSProtocolLogoutRequest* COSSProtocolLogoutRequest::NewLC (
       
    90     MOSSProtocolConnectionManager& aConnMan,
       
    91     TXIMPRequestId aRequestId )
       
    92 	{
       
    93 	LOGGER ( TXT ( "COSSProtocolLogoutRequest::NewLC Start" ) );
       
    94 
       
    95 	COSSProtocolLogoutRequest* self =
       
    96 	    COSSProtocolLogoutRequest::NewL ( aConnMan, aRequestId );
       
    97 	CleanupStack::PushL ( self );
       
    98 
       
    99 	LOGGER ( TXT ( "COSSProtocolLogoutRequest::NewLC End" ) );
       
   100 	return self;
       
   101 	}
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // COSSProtocolLogoutRequest::~COSSProtocolLogoutRequest()
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 COSSProtocolLogoutRequest::~COSSProtocolLogoutRequest()
       
   108 	{
       
   109 	LOGGER ( TXT ( "::~COSSProtocolLogoutRequest Start" ) );
       
   110 	Cancel();
       
   111 	}
       
   112 
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // COSSProtocolLogoutRequest::DoCancel()
       
   116 // ---------------------------------------------------------------------------
       
   117 //
       
   118 void COSSProtocolLogoutRequest::DoCancel()
       
   119 	{
       
   120 	}
       
   121 
       
   122 
       
   123 // ---------------------------------------------------------------------------
       
   124 // COSSProtocolLogoutRequest::RunL()
       
   125 // ---------------------------------------------------------------------------
       
   126 //
       
   127 void COSSProtocolLogoutRequest::RunL()
       
   128 	{
       
   129 	LOGGER ( TXT ( "COSSProtocolLogoutRequest::RunL Start" ) );
       
   130 	message_hdr_resp* msg_struct = NULL;
       
   131 
       
   132 	User::LeaveIfError ( iStatus.Int() );
       
   133     char* pResponse = NULL;  
       
   134 	pResponse = iConnMan.DataHandler().ResponseL ( iSendId );
       
   135 	msg_struct = ( message_hdr_resp* )pResponse ;
       
   136 
       
   137 	if( !( msg_struct->response ) )
       
   138 		{
       
   139 		switch( msg_struct->error_type )
       
   140 			{
       
   141 
       
   142 			default:  //for all other error codes like ssl related are mapped to general error
       
   143 			   iConnMan.HandleToHost().HandleRequestCompleted ( iRequestId, KXIMPErrServiceGeneralError );
       
   144 			   break;       
       
   145 			}	
       
   146 		}
       
   147 	else
       
   148 		{
       
   149 		iConnMan.HandleToHost().HandleRequestCompleted ( iRequestId, KErrNone );
       
   150 		}
       
   151 
       
   152 	free( pResponse );
       
   153  
       
   154 
       
   155  	delete this;
       
   156 
       
   157 	LOGGER ( TXT ( "COSSProtocolLogoutRequest::RunL End" ) );
       
   158 	}
       
   159 
       
   160 
       
   161 // ---------------------------------------------------------------------------
       
   162 // COSSProtocolLogoutRequest::RunError()
       
   163 // ---------------------------------------------------------------------------
       
   164 //
       
   165 TInt COSSProtocolLogoutRequest::RunError ( TInt  aError )
       
   166 	{
       
   167 	LOGGER ( TXT ( "COSSProtocolLogoutRequest::RunError Start" ) );
       
   168 
       
   169 	iConnMan.HandleToHost().HandleRequestCompleted ( iRequestId, aError );
       
   170 
       
   171 	LOGGER ( TXT ( "COSSProtocolLogoutRequest::RunError - id:  %d" ), aError );
       
   172 
       
   173 	delete this;
       
   174 	LOGGER ( TXT ( "COSSProtocolLogoutRequest::RunError End" ) );
       
   175 	return KErrNone;
       
   176 	}
       
   177 
       
   178 
       
   179 // ---------------------------------------------------------------------------
       
   180 // COSSProtocolLogoutRequest::IssueLogoutRequestL()
       
   181 // ---------------------------------------------------------------------------
       
   182 //
       
   183 void COSSProtocolLogoutRequest::IssueLogoutRequestL()
       
   184 	{
       
   185 	LOGGER ( TXT ( "COSSProtocolLogoutRequest::IssueLogoutRequestL Start" ) );
       
   186 
       
   187 	message_hdr_req msgHdr = {0,};
       
   188 
       
   189 	msgHdr.message_type = ELogout_Request;
       
   190 
       
   191 	iSendId = iConnMan.DataHandler().SendDataL ( iStatus, ( char* ) &msgHdr, sizeof ( message_hdr_req ) );
       
   192 
       
   193 	// signal the scheduler
       
   194 	SetActive();
       
   195 
       
   196 	LOGGER ( TXT ( "COSSProtocolConnection::IssueLogoutRequestL() End" ) );
       
   197 	}
       
   198 
       
   199 
       
   200 // End of file