mmsharing/livecommsui/lcui/tsrc/mustester/Stubs/mceclientstub/src/mceinsession.cpp
branchRCL_3
changeset 33 bc78a40cd63c
parent 32 73a1feb507fb
child 35 6c57ef9392d2
equal deleted inserted replaced
32:73a1feb507fb 33:bc78a40cd63c
     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 "mceinsession.h"
       
    20 #include "mcemanager.h"
       
    21 
       
    22 
       
    23 
       
    24 // CONSTANTS
       
    25 const TUint32 KMceMinAcceptable = 200;
       
    26 const TUint32 KMceMaxAcceptable = 299;
       
    27 const TUint32 KMceMinError = 300;
       
    28 const TUint32 KMceMaxError = 699;
       
    29 const TUint32 KMceRinging = 180;
       
    30 _LIT8( KMcePhraseRinging, "Ringing" );
       
    31 
       
    32 // ============================ MEMBER FUNCTIONS ===============================
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // CMceInSession::NewL
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 CMceInSession* CMceInSession::NewL( RReadStream& /*aReadStream*/,
       
    39             						CMceManager& aManager,
       
    40             						TUint32 aProfileId )
       
    41     {
       
    42     CMceInSession* self = new (ELeave) CMceInSession( &aManager, aProfileId );    
       
    43     CleanupStack::PushL( self );
       
    44     self->ConstructL( KNullDesC8, KNullDesC8 );
       
    45     CleanupStack::Pop(self);
       
    46     return self;
       
    47         
       
    48     }
       
    49 
       
    50 // -----------------------------------------------------------------------------
       
    51 // CMceInSession::NewL
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 
       
    55 EXPORT_C CMceInSession* CMceInSession::NewL()
       
    56     {
       
    57     CMceInSession* self = new (ELeave) CMceInSession( NULL, 0 );
       
    58     CleanupStack::PushL( self );
       
    59     self->ConstructL( KNullDesC8, KNullDesC8 );
       
    60     CleanupStack::Pop( self );
       
    61     return self;
       
    62     }
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // CMceInSession::~CMceInSession
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 EXPORT_C CMceInSession::~CMceInSession()
       
    69     {
       
    70     }
       
    71 
       
    72 // -----------------------------------------------------------------------------
       
    73 // CMceInSession::RingL
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 EXPORT_C void CMceInSession::RingL( CDesC8Array* aHeaders,
       
    77 					 		 		HBufC8* aContentType,
       
    78 					 		 		HBufC8* aContent )
       
    79     {
       
    80     User::LeaveIfError( 
       
    81         ( aContentType && aContent ) || !( aContentType || aContent ) ? 
       
    82         KErrNone : KErrArgument );
       
    83       
       
    84     delete aHeaders;
       
    85     delete aContentType;
       
    86     delete aContent;
       
    87     
       
    88     iRingingCalled = ETrue;
       
    89     }
       
    90     
       
    91 // -----------------------------------------------------------------------------
       
    92 // CMceInSession::AcceptL
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 EXPORT_C void CMceInSession::AcceptL()
       
    96     {
       
    97     iState = CMceSession::EAnswering;
       
    98     }
       
    99 
       
   100 // -----------------------------------------------------------------------------
       
   101 // CMceInSession::AcceptL
       
   102 // -----------------------------------------------------------------------------
       
   103 //
       
   104 EXPORT_C void CMceInSession::AcceptL(  const TDesC8& /*aReason*/,
       
   105         	           			        TUint32 /*aCode*/,
       
   106         	           			        CDesC8Array* aHeaders,
       
   107         					 		    HBufC8* aContentType,
       
   108         					 		    HBufC8* aContent )
       
   109     {
       
   110     iState = CMceSession::EAnswering;
       
   111     
       
   112     delete aHeaders;
       
   113     delete aContentType;
       
   114     delete aContent;
       
   115     }
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // CMceInSession::RejectL
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 EXPORT_C void CMceInSession::RejectL()
       
   122     {
       
   123     if ( iFailWithCode != KErrNone )
       
   124         {
       
   125         TInt failureCode = iFailWithCode;
       
   126         iFailWithCode = KErrNone;
       
   127         User::Leave( failureCode );
       
   128         }
       
   129         
       
   130     iState = CMceSession::ETerminated;
       
   131     }
       
   132 
       
   133 // -----------------------------------------------------------------------------
       
   134 // CMceInSession::RejectL
       
   135 // -----------------------------------------------------------------------------
       
   136 //
       
   137 EXPORT_C void CMceInSession::RejectL( const TDesC8& aReason,
       
   138             		                  TUint32 aCode,
       
   139             		                  CDesC8Array* aHeaders,
       
   140 					                  HBufC8* aContentType,
       
   141 					                  HBufC8* aContent )
       
   142     {
       
   143     
       
   144     User::LeaveIfError( 
       
   145         ( aContentType && aContent ) || !( aContentType || aContent ) ? 
       
   146         KErrNone : KErrArgument );
       
   147     User::LeaveIfError( aCode >= KMceMinError && aCode <= KMceMaxError ?
       
   148         KErrNone : KErrArgument );
       
   149 
       
   150     RejectL();
       
   151 
       
   152     iReasonPhrase = aReason;
       
   153     iReasonCode = aCode;
       
   154 
       
   155     delete aHeaders;
       
   156     delete aContentType;
       
   157     delete aContent;
       
   158     }
       
   159 
       
   160 // -----------------------------------------------------------------------------
       
   161 // CMceInSession::CMceInSession
       
   162 // -----------------------------------------------------------------------------
       
   163 //
       
   164 CMceInSession::CMceInSession( CMceManager* aManager, TUint32 aProfileId )
       
   165     : CMceSession( aManager, aProfileId )
       
   166     {
       
   167     }
       
   168 
       
   169 
       
   170 // -----------------------------------------------------------------------------
       
   171 // CMceInSession::ConstructL
       
   172 // -----------------------------------------------------------------------------
       
   173 //
       
   174 void CMceInSession::ConstructL( const TDesC8& aOriginator, const TDesC8& aRecipient )
       
   175     {
       
   176     
       
   177     delete iOriginator;
       
   178     iOriginator = 0;
       
   179     iOriginator = aOriginator.AllocL();
       
   180     
       
   181     delete iRecipient;
       
   182     iRecipient = 0;
       
   183     iRecipient = aRecipient.AllocL();
       
   184     
       
   185     CMceSession::ConstructL();
       
   186     
       
   187     iState = EIncoming;
       
   188     }
       
   189 
       
   190 // -----------------------------------------------------------------------------
       
   191 // Stub constructor
       
   192 // -----------------------------------------------------------------------------
       
   193 //
       
   194 EXPORT_C CMceInSession* CMceInSession::NewL( CMceManager& aManager,
       
   195                                              const TDesC8& aOriginator )
       
   196     {
       
   197     CMceInSession* self = new (ELeave) CMceInSession( &aManager, 0 );
       
   198     CleanupStack::PushL( self );
       
   199     self->ConstructL( aOriginator, KNullDesC8 );
       
   200     CleanupStack::Pop( self );
       
   201     return self;
       
   202     }