tsrc/mceclientstub/src/mceoutsession.cpp
changeset 22 496ad160a278
equal deleted inserted replaced
15:ccd8e69b5392 22:496ad160a278
       
     1 /*
       
     2 * Copyright (c) 2005 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <sipprofile.h>
       
    20 #include "mceoutsession.h"
       
    21 #include "mcemediastream.h"
       
    22 #include "mcemanager.h"
       
    23 
       
    24 
       
    25 // ============================ MEMBER FUNCTIONS ===============================
       
    26 
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // CMceOutSession::NewL
       
    30 // -----------------------------------------------------------------------------
       
    31 //
       
    32 EXPORT_C CMceOutSession* CMceOutSession::NewL(
       
    33                         CMceManager& aManager,
       
    34                         CSIPProfile& aProfile,
       
    35                         const TDesC8& aRecipient,
       
    36 						HBufC8* aOriginator )
       
    37     {
       
    38     // Check that profile has been registered
       
    39     TBool profileRegistered = EFalse;   
       
    40         
       
    41     aProfile.GetParameter( KSIPProfileRegistered, profileRegistered  );  
       
    42     __ASSERT_ALWAYS( profileRegistered, User::Leave( KErrCouldNotConnect ) );        
       
    43     
       
    44     CMceOutSession* self = new (ELeave) CMceOutSession( &aManager, 0 );
       
    45     CleanupStack::PushL( self );
       
    46     self->ConstructL( aRecipient, aOriginator );
       
    47     CleanupStack::Pop( self );
       
    48     return self;
       
    49     }
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CMceOutSession::NewL
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 EXPORT_C CMceOutSession* CMceOutSession::NewL( CMceEvent& /*aEvent*/ )
       
    56     {
       
    57     return NULL;
       
    58     }
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 // CMceOutSession::NewL
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 EXPORT_C CMceOutSession* CMceOutSession::NewL( CMceRefer& /*aRefer*/ )
       
    65     {
       
    66     return NULL;
       
    67     }
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // CMceOutSession::NewL
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 EXPORT_C CMceOutSession* CMceOutSession::NewL()
       
    74     {
       
    75     return new( ELeave )CMceOutSession( NULL, 0 );
       
    76     }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CMceOutSession::~CMceOutSession
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 EXPORT_C CMceOutSession::~CMceOutSession()
       
    83     {
       
    84     }
       
    85 
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // CMceOutSession::EstablishL
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 EXPORT_C void CMceOutSession::EstablishL(
       
    92                         TUint32 aTimeout,
       
    93                         CDesC8Array* aHeaders, 
       
    94                         HBufC8* aContentType,
       
    95                         HBufC8* aContent,
       
    96                         CDesC8Array* aContentHeaders ) 
       
    97     {
       
    98     User::LeaveIfError( State() == EIdle ? KErrNone : KErrNotReady );
       
    99     User::LeaveIfError( 
       
   100         ( aContentType && aContent ) || 
       
   101        !( aContentType || aContent || aContentHeaders ) ? 
       
   102         KErrNone : KErrArgument );
       
   103     
       
   104     if ( iFailWithCode != KErrNone )
       
   105         {
       
   106         TInt failCode = iFailWithCode;
       
   107         iFailWithCode = KErrNone;
       
   108         User::Leave( failCode );
       
   109         }
       
   110     
       
   111     iTimeout = aTimeout;
       
   112 
       
   113     //start establishing the session
       
   114 
       
   115     delete iHeaders;
       
   116     iHeaders = aHeaders;
       
   117     delete aContentType;
       
   118     delete aContent;
       
   119     delete aContentHeaders;
       
   120 
       
   121 	iState = CMceSession::EOffering; 
       
   122     }
       
   123 
       
   124 
       
   125 // -----------------------------------------------------------------------------
       
   126 // CMceOutSession::AddStreamL
       
   127 // -----------------------------------------------------------------------------
       
   128 //
       
   129 EXPORT_C void CMceOutSession::AddStreamL( CMceMediaStream* aMediaStream )
       
   130     {
       
   131     if ( iManager )
       
   132         {
       
   133         //initialize stream (to get supported codecs)
       
   134         aMediaStream->InitializeL( iManager );
       
   135         }
       
   136     else
       
   137         {
       
   138         //internalizing => no initialize yet
       
   139         }
       
   140     
       
   141     CMceSession::AddStreamL( aMediaStream );
       
   142     }
       
   143 
       
   144 
       
   145 // -----------------------------------------------------------------------------
       
   146 // CMceOutSession::CancelL
       
   147 // -----------------------------------------------------------------------------
       
   148 //
       
   149 EXPORT_C void CMceOutSession::CancelL()
       
   150     {
       
   151     User::LeaveIfError( State() != EIdle ? KErrNone : KErrNotReady );
       
   152     
       
   153 	iState = CMceSession::ECancelling;
       
   154 	
       
   155     }
       
   156     
       
   157 
       
   158 // -----------------------------------------------------------------------------
       
   159 // CMceOutSession::CMceOutSession
       
   160 // -----------------------------------------------------------------------------
       
   161 //
       
   162 CMceOutSession::CMceOutSession( CMceManager* aManager, TUint32 aProfileId ) 
       
   163     : CMceSession( aManager, aProfileId )
       
   164     {
       
   165     //NOP
       
   166     }
       
   167 
       
   168 // -----------------------------------------------------------------------------
       
   169 // CMceOutSession::ConstructL
       
   170 // -----------------------------------------------------------------------------
       
   171 //
       
   172 void CMceOutSession::ConstructL( const TDesC8& aRecipient, HBufC8* aOriginator )
       
   173     {
       
   174     delete iRecipient;
       
   175     iRecipient = NULL;
       
   176     iRecipient = aRecipient.AllocL();
       
   177 
       
   178     delete iOriginator;
       
   179     iOriginator = NULL;
       
   180     if ( aOriginator )
       
   181         {
       
   182         iOriginator = aOriginator->AllocL();
       
   183         delete aOriginator;    
       
   184         }
       
   185         
       
   186     CMceSession::ConstructL();
       
   187     }