atext/server/src/atextsession.cpp
branchRCL_3
changeset 22 9f17f914e828
parent 0 29b1cd4cb562
child 40 14e240312f6f
equal deleted inserted replaced
18:f8503e232b0c 22:9f17f914e828
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description: 
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #include <badesca.h>
    19 #include <badesca.h>
   197 // CATExtSession::CATExtSession
   197 // CATExtSession::CATExtSession
   198 // ---------------------------------------------------------------------------
   198 // ---------------------------------------------------------------------------
   199 //
   199 //
   200 CATExtSession::CATExtSession( CATExtSrv& aServer, const TVersion& aVersion ) :
   200 CATExtSession::CATExtSession( CATExtSrv& aServer, const TVersion& aVersion ) :
   201     iServer( aServer ),
   201     iServer( aServer ),
       
   202     iEComSession( NULL ),
   202     iListener( NULL ),
   203     iListener( NULL ),
   203     iMetadata( NULL ),
   204     iMetadata( NULL ),
   204     iVersion( aVersion )
   205     iVersion( aVersion )
   205     {
   206     {
   206     }
   207     }
   215     if ( iMetadata || iListener )
   216     if ( iMetadata || iListener )
   216         {
   217         {
   217         TRACE_FUNC_EXIT
   218         TRACE_FUNC_EXIT
   218         User::Leave( KErrGeneral );
   219         User::Leave( KErrGeneral );
   219         }
   220         }
   220     REComSession& ecomSession = REComSession::OpenL();
   221     iEComSession = &REComSession::OpenL();
   221     CleanupClosePushL( ecomSession );
       
   222     TPckgBuf<TUid> ifUidPckgBuf;
   222     TPckgBuf<TUid> ifUidPckgBuf;
   223     TInt retTemp = ReadStructFromMessage( ifUidPckgBuf,
   223     TInt retTemp = ReadStructFromMessage( ifUidPckgBuf,
   224                                           EATExtConnectParamUid,
   224                                           EATExtConnectParamUid,
   225                                           aMessage );
   225                                           aMessage );
   226     if ( retTemp != KErrNone )
   226     if ( retTemp != KErrNone )
   237         {
   237         {
   238         TRACE_FUNC_EXIT
   238         TRACE_FUNC_EXIT
   239         User::Leave( retTemp );
   239         User::Leave( retTemp );
   240         }
   240         }
   241     // Create listener
   241     // Create listener
   242     CATExtListen* listener = CATExtListen::NewLC( ecomSession, this );
   242     CATExtListen* listener = CATExtListen::NewLC( *iEComSession, this );
   243     listener->AddInterfaceUid( ifUidPckgBuf() );
   243     listener->AddInterfaceUid( ifUidPckgBuf() );
   244     // Create metadata. Pass iListener to add the UIDs
   244     // Create metadata. Pass iListener to add the UIDs
   245     CATExtMetadata* metadata = CATExtMetadata::NewLC( ecomSession,
   245     CATExtMetadata* metadata = CATExtMetadata::NewLC( *iEComSession,
   246                                                       listener,
   246                                                       listener,
   247                                                       *this );
   247                                                       *this );
   248     metadata->CreateImplementationMetadataL( ifUidPckgBuf(), connectionName );
   248     metadata->CreateImplementationMetadataL( ifUidPckgBuf(), connectionName );
   249     listener->IssueRequest();
   249     listener->IssueRequest();
   250     CleanupStack::Pop( metadata );
   250     CleanupStack::Pop( metadata );
   251     CleanupStack::Pop( listener );
   251     CleanupStack::Pop( listener );
   252     CleanupStack::PopAndDestroy( &connectionName );
   252     CleanupStack::PopAndDestroy( &connectionName );
   253     CleanupStack::Pop( &ecomSession );
       
   254     iEComSession = ecomSession;
       
   255     iListener = listener;
   253     iListener = listener;
   256     iMetadata = metadata;
   254     iMetadata = metadata;
   257     TRACE_FUNC_EXIT
   255     TRACE_FUNC_EXIT
   258     }
   256     }
   259 
   257 
   320         TRACE_FUNC_EXIT
   318         TRACE_FUNC_EXIT
   321         return retTemp;
   319         return retTemp;
   322         }
   320         }
   323     // Third, check a case where there is support but reply is not
   321     // Third, check a case where there is support but reply is not
   324     // expected. In this case "" must be returned to complete processing.
   322     // expected. In this case "" must be returned to complete processing.
       
   323     // Note: The EFalse setting is used only for normal mode.
   325     if ( !complInfo.iReplyExpected )
   324     if ( !complInfo.iReplyExpected )
   326         {
   325         {
   327         // Return ""
   326         // Return ""
   328         TRACE_INFO(( _L8("Command handled with support but no reply: return \"\"") ));
   327         TRACE_INFO(( _L8("Command handled with support but no reply: return \"\"") ));
   329         iMetadata->CompleteCommandMessage( NULL,
   328         iMetadata->CompleteCommandMessage( NULL,
   332                                            EReplyTypeOther,  // reply type from plugin
   331                                            EReplyTypeOther,  // reply type from plugin
   333                                            EFalse );         // no multipart
   332                                            EFalse );         // no multipart
   334         TRACE_FUNC_EXIT
   333         TRACE_FUNC_EXIT
   335         return retTemp;
   334         return retTemp;
   336         }
   335         }
   337     // The rest are for known command with reply. This case is handled in
   336     // The rest are for known command with reply or data in editor mode.
   338     // HandleCommand().
   337     // This case is handled in HandleCommand().
   339     TRACE_INFO(( _L8("Command handled: wait for asynchronous reply or do nothing") ));
   338     TRACE_INFO(( _L8("Command handled: wait for asynchronous reply or do nothing") ));
   340     TRACE_FUNC_EXIT
   339     TRACE_FUNC_EXIT
   341     return KErrNone;
   340     return KErrNone;
   342     }
   341     }
   343 
   342 
   894         }
   893         }
   895     delete iListener;
   894     delete iListener;
   896     iListener = NULL;
   895     iListener = NULL;
   897     delete iMetadata;
   896     delete iMetadata;
   898     iMetadata = NULL;
   897     iMetadata = NULL;
   899     iEComSession.Close();
   898     if ( iEComSession )
       
   899         {
       
   900         iEComSession->Close();
       
   901         }
   900     if ( !aSyncClose )
   902     if ( !aSyncClose )
   901         {
   903         {
   902         REComSession::FinalClose();
   904         REComSession::FinalClose();
   903         iServer.ClientClosed( *this );
   905         iServer.ClientClosed( *this );
   904         }
   906         }