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