|
1 /* |
|
2 * Copyright (c) 2006 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: SIMPLE Protocol implementation for Presence Framework |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include <e32std.h> |
|
22 |
|
23 #include <presenceinfo.h> |
|
24 |
|
25 #include <ximpserviceinfo.h> |
|
26 #include <ximpbase.h> |
|
27 #include <ximpidentity.h> |
|
28 #include <ximpprotocolconnectionhost.h> |
|
29 |
|
30 #include <simplefactory.h> |
|
31 #include <msimpleconnection.h> |
|
32 #include <msimpleconnectionobserver.h> |
|
33 #include <pressettingsapi.h> |
|
34 |
|
35 #include "simplepluginsession.h" |
|
36 #include "simpleplugindebugutils.h" |
|
37 #include "msimplepluginconnectionobs.h" |
|
38 |
|
39 |
|
40 // ======== MEMBER FUNCTIONS ======== |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // CSimplePluginSession::CSimplePluginSession() |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 CSimplePluginSession::CSimplePluginSession( MSimplePluginConnectionObs& aObs) |
|
47 : // CActive( CActive::EPriorityStandard ) , |
|
48 iObs(aObs), iType( MSimplePluginConnectionObs::ENoReq ), iConnected( EFalse ) |
|
49 { |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // CSimplePluginSession::ConstructL() |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 void CSimplePluginSession::ConstructL( |
|
57 const MXIMPServiceInfo& aService ) |
|
58 { |
|
59 // iIap is needed only |
|
60 iIap = aService.IapId(); |
|
61 |
|
62 iConnection = TSimpleFactory::NewConnectionL( *this ); |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // CSimplePluginSession::NewL() |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 CSimplePluginSession* CSimplePluginSession::NewL( |
|
70 const MXIMPServiceInfo& aServiceInfo, |
|
71 MSimplePluginConnectionObs& aObs ) |
|
72 { |
|
73 CSimplePluginSession* self = new( ELeave ) CSimplePluginSession( aObs ); |
|
74 CleanupStack::PushL( self ); |
|
75 self->ConstructL( aServiceInfo ); |
|
76 CleanupStack::Pop( self ); |
|
77 return self; |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // CSimplePluginSession::~CSimplePluginSession() |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 CSimplePluginSession::~CSimplePluginSession() |
|
85 { |
|
86 delete iUserId8; |
|
87 delete iDomain; |
|
88 if ( iConnection ) |
|
89 { |
|
90 iConnection->Close(); |
|
91 } |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------------------------- |
|
95 // CSimplePluginSession::SimpleConnection() |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 MSimpleConnection* CSimplePluginSession::SimpleConnection( ) |
|
99 { |
|
100 return iConnection; |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // CSimplePluginSession::XdmSettingsId() |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 TInt CSimplePluginSession::XdmSettingsId( ) |
|
108 { |
|
109 return iXdmSetting; |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // CSimplePluginSession::CurrentDomain() |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 TPtrC16 CSimplePluginSession::CurrentDomain( ) |
|
117 { |
|
118 return iDomain ? iDomain->Des() : TPtrC16(); |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // CSimplePluginSession::OpenSessionL() |
|
123 // Notice: MXIMPServiceInfo::IapId supported only |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 void CSimplePluginSession::OpenSessionL() |
|
127 { |
|
128 TPresSettingsSet mySet; |
|
129 |
|
130 #ifdef _DEBUG |
|
131 |
|
132 PluginLogger::Log(_L("PluginSession: OpenSessionL") ); |
|
133 |
|
134 RArray<TInt> setIds; |
|
135 CDesCArray* carr = PresSettingsApi::GetAllSetsNamesLC( setIds ); |
|
136 TInt myCount = setIds.Count(); |
|
137 for (TInt i=0; i<myCount; i++) |
|
138 { |
|
139 |
|
140 TBuf<500> buffer2; buffer2.Copy(carr->MdcaPoint(i)); |
|
141 PluginLogger::Log(_L("PluginSession: ID:%d = %S"), setIds[i], &buffer2); |
|
142 } |
|
143 setIds.Reset(); |
|
144 CleanupStack::PopAndDestroy( carr ); |
|
145 #endif |
|
146 |
|
147 iConnected = EFalse; |
|
148 |
|
149 User::LeaveIfError( PresSettingsApi::SettingsSetL( iIap, mySet )); |
|
150 iXdmSetting = mySet.iXDMSetting; |
|
151 |
|
152 iDomain = mySet.iDomainSyntax.AllocL(); |
|
153 |
|
154 // SIP register |
|
155 iOpId = iConnection->LoginL( iIap ); |
|
156 iType = MSimplePluginConnectionObs::EOpenSess; |
|
157 } |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // CSimplePluginSession::OpenSessionL() |
|
161 // Notice: Multiple connections support to be done. |
|
162 // --------------------------------------------------------------------------- |
|
163 // |
|
164 void CSimplePluginSession::OpenSessionL( TInt aSettingsId ) |
|
165 { |
|
166 iIap = aSettingsId; |
|
167 OpenSessionL(); |
|
168 } |
|
169 |
|
170 // --------------------------------------------------------------------------- |
|
171 // CSimplePluginSession::ConnectionStatusL() |
|
172 // --------------------------------------------------------------------------- |
|
173 // |
|
174 void CSimplePluginSession::ConnectionStatusL( MSimpleConnection::TSimpleState aState ) |
|
175 { |
|
176 #ifdef _DEBUG |
|
177 PluginLogger::Log(_L("PluginSession: ConnectionStatusL %d"), aState ); |
|
178 #endif |
|
179 |
|
180 if ( (aState == MSimpleConnection::EInactive || aState == MSimpleConnection::EUnavailable ) && |
|
181 iConnected ) |
|
182 { |
|
183 #ifdef _DEBUG |
|
184 PluginLogger::Log( |
|
185 _L("PluginSession: ConnectionStatusL callback HandleConnectionTerminated") ); |
|
186 #endif |
|
187 iConnected = EFalse; |
|
188 iObs.Host()->HandleConnectionTerminated( NULL ); |
|
189 } |
|
190 } |
|
191 |
|
192 // --------------------------------------------------------------------------- |
|
193 // CSimplePluginSession::RequestCompleteL() |
|
194 // --------------------------------------------------------------------------- |
|
195 // |
|
196 void CSimplePluginSession::RequestCompleteL( TInt /*aOpId*/, TInt aStatus ) |
|
197 { |
|
198 MSimplePluginConnectionObs::TReqType current = iType; |
|
199 iType = MSimplePluginConnectionObs::ENoReq; |
|
200 if ( !aStatus ) |
|
201 { |
|
202 iConnected = ETrue; |
|
203 } |
|
204 iObs.CompleteReq( current, aStatus ); |
|
205 } |
|
206 |
|
207 // --------------------------------------------------------------------------- |
|
208 // CSimplePluginSession::CurrentSipPresentity() |
|
209 // --------------------------------------------------------------------------- |
|
210 // |
|
211 TPtrC8 CSimplePluginSession::CurrentSipPresentity() |
|
212 { |
|
213 // Get from Simple engine |
|
214 delete iUserId8; |
|
215 iUserId8 = NULL; |
|
216 TRAP_IGNORE( iUserId8 = iConnection->CurrentSIPIdentityL().AllocL() ); |
|
217 return iUserId8 ? iUserId8->Des() : TPtrC8(); |
|
218 } |
|
219 |
|
220 |
|
221 |
|
222 // End of file |
|
223 |