23
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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: implementation for CVIMPSTCmdFactory
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include "cvimpstcmdfactory.h"
|
|
21 |
#include "cvimpstprocessarray.h"
|
|
22 |
#include "cvimpstcmdcca.h"
|
|
23 |
#include "cvimpstcmdlogin.h"
|
|
24 |
#include "cvimpstcmdlogout.h"
|
|
25 |
#include "cvimpstcmdcancellogin.h"
|
|
26 |
|
|
27 |
#include "uiservicetabtracer.h"
|
|
28 |
|
|
29 |
#include "mvimpstcmdobserver.h"
|
|
30 |
#include "mvimpstengine.h"
|
|
31 |
#include "tvimpstconsts.h"
|
|
32 |
#include "cvimpststoragemanagerfactory.h"
|
|
33 |
#include "cvimpstcmdaddcontact.h"
|
|
34 |
#include "cvimpstcmddeletecontact.h"
|
|
35 |
#include "tvimpstconsts.h"
|
|
36 |
#include "cvimpstcmdchangeownstatus.h"
|
|
37 |
#include "cvimpstcmdchangeownmessage.h"
|
|
38 |
#include "cvimpstcmdsearch.h"
|
|
39 |
#include "cvimstcmdfriendrequest.h"
|
|
40 |
#include "cvimpstcmdchangeownavtar.h"
|
|
41 |
#include "cvimpstcmdcloseconversation.h"
|
|
42 |
#include "cvimpstcmdaddtopbk.h"
|
|
43 |
#include "cvimpstcmdprocessselectedcontact.h"
|
|
44 |
#include "cvimpstcmdblockcontact.h"
|
|
45 |
#include "cvimpstcmdunblockcontact.h"
|
|
46 |
#include "cvimpstcmdfetchblockedlist.h"
|
|
47 |
|
|
48 |
|
|
49 |
// ================= MEMBER FUNCTIONS =======================
|
|
50 |
|
|
51 |
|
|
52 |
// --------------------------------------------------------------------------
|
|
53 |
// CVIMPSTCmdFactory::CVIMPSTCmdFactory
|
|
54 |
// --------------------------------------------------------------------------
|
|
55 |
//
|
|
56 |
CVIMPSTCmdFactory::CVIMPSTCmdFactory(MVIMPSTEngine& aEngine) :
|
|
57 |
iEngine(aEngine)
|
|
58 |
{
|
|
59 |
}
|
|
60 |
|
|
61 |
|
|
62 |
// --------------------------------------------------------------------------
|
|
63 |
// CVIMPSTCmdFactory::ConstructL
|
|
64 |
// --------------------------------------------------------------------------
|
|
65 |
//
|
|
66 |
void CVIMPSTCmdFactory::ConstructL()
|
|
67 |
{
|
|
68 |
TRACER_AUTO;
|
|
69 |
TUint32 serviceId = iEngine.ServiceId();
|
|
70 |
|
|
71 |
//Make sure we initialise the Storage view for this service
|
|
72 |
HBufC* storeName = HBufC::NewLC( KVIMPSTUISPSMaxPropertyLength );
|
|
73 |
|
|
74 |
TPtr storeNamePtr( storeName->Des() );
|
|
75 |
|
|
76 |
iEngine.ContactStoreIdL(storeNamePtr);
|
|
77 |
|
|
78 |
CVIMPSTStorageManagerFactory::InitialiseViewL(serviceId, *storeName, iEngine.ServiceName());
|
|
79 |
|
|
80 |
CleanupStack::PopAndDestroy(); //storeName
|
|
81 |
|
|
82 |
iEngine.IntializeStorageL();
|
|
83 |
|
|
84 |
|
|
85 |
//create the array process
|
|
86 |
iArrayProcess = CVIMPSTProcessArray::NewL( iEngine );
|
|
87 |
|
|
88 |
iEngine.RegisterServiceSessionObserverL(this);
|
|
89 |
|
|
90 |
}
|
|
91 |
|
|
92 |
|
|
93 |
// --------------------------------------------------------------------------
|
|
94 |
// CVIMPSTCmdFactory::NewL
|
|
95 |
// --------------------------------------------------------------------------
|
|
96 |
//
|
|
97 |
CVIMPSTCmdFactory* CVIMPSTCmdFactory::NewL(MVIMPSTEngine& aEngine)
|
|
98 |
{
|
|
99 |
CVIMPSTCmdFactory* self = new (ELeave) CVIMPSTCmdFactory(aEngine);
|
|
100 |
CleanupStack::PushL(self);
|
|
101 |
self->ConstructL();
|
|
102 |
CleanupStack::Pop(self);
|
|
103 |
return self;
|
|
104 |
}
|
|
105 |
|
|
106 |
|
|
107 |
// --------------------------------------------------------------------------
|
|
108 |
// CVIMPSTCmdFactory::~CVIMPSTCmdFactory
|
|
109 |
// --------------------------------------------------------------------------
|
|
110 |
//
|
|
111 |
CVIMPSTCmdFactory::~CVIMPSTCmdFactory()
|
|
112 |
{
|
|
113 |
TRACER_AUTO;
|
|
114 |
iEngine.UnIntializeStorage();
|
|
115 |
iEngine.UnRegisterServiceSessionObserver(this);
|
|
116 |
|
|
117 |
iObservers.Reset();
|
|
118 |
iObservers.Close();
|
|
119 |
|
|
120 |
delete iArrayProcess;
|
|
121 |
iArrayProcess = NULL;
|
|
122 |
|
|
123 |
}
|
|
124 |
|
|
125 |
|
|
126 |
// --------------------------------------------------------------------------
|
|
127 |
// CVIMPSTCmdFactory::CreateCommandForIdL
|
|
128 |
// --------------------------------------------------------------------------
|
|
129 |
//
|
|
130 |
MVIMPSTCmd* CVIMPSTCmdFactory::CreateCommandForIdL(
|
|
131 |
TImCommandId aCommandId,TAny* aData /*NULL*/)
|
|
132 |
{
|
|
133 |
TRACER_AUTO;
|
|
134 |
MVIMPSTCmd* commd = NULL;
|
|
135 |
|
|
136 |
//Instantiate appropriate command
|
|
137 |
switch ( aCommandId )
|
|
138 |
{
|
|
139 |
case ELoginService:
|
|
140 |
{
|
|
141 |
commd = CVIMPSTCmdLogin::NewL(aCommandId,*(TUint32*)aData, iEngine);
|
|
142 |
break;
|
|
143 |
}
|
|
144 |
|
|
145 |
case ELogoutService:
|
|
146 |
{
|
|
147 |
commd = CVIMPSTCmdLogout::NewL(aCommandId,*(TUint32*)aData, iEngine);
|
|
148 |
break;
|
|
149 |
}
|
|
150 |
case ELaunchCCA:
|
|
151 |
{
|
|
152 |
commd = CVIMPSTCmdCCA::NewL(aCommandId,
|
|
153 |
(*(TLaunchCCAData*)aData).iIndex,
|
|
154 |
(*(TLaunchCCAData*)aData).iConnection,
|
|
155 |
*iArrayProcess,
|
|
156 |
iEngine );
|
|
157 |
break;
|
|
158 |
|
|
159 |
}
|
|
160 |
case EAddContact:
|
|
161 |
{
|
|
162 |
commd = CVIMPSTCmdAddContact::NewL(aCommandId,*(TDesC*) aData, iEngine);
|
|
163 |
break;
|
|
164 |
|
|
165 |
}
|
|
166 |
case EDeleteContact:
|
|
167 |
{
|
|
168 |
commd = CVIMPSTCmdDeleteContact::NewL(aCommandId,*(MVPbkContactLink**) aData, iEngine);
|
|
169 |
break;
|
|
170 |
|
|
171 |
}
|
|
172 |
case EChangeOwnStatus:
|
|
173 |
{
|
|
174 |
commd = CVIMPSTCmdChangeOwnStatus::NewL(aCommandId,*(TStatusAndStatusText*) aData, iEngine);
|
|
175 |
break;
|
|
176 |
|
|
177 |
}
|
|
178 |
case EChangeOwnMessage:
|
|
179 |
{
|
|
180 |
commd = CVIMPSTCmdChangeOwnMessage::NewL(aCommandId,*(TStatusAndStatusText*) aData, iEngine);
|
|
181 |
break;
|
|
182 |
|
|
183 |
}
|
|
184 |
case ESearch:
|
|
185 |
{
|
|
186 |
commd = CVIMPSTCmdSearch::NewL(aCommandId,*(RArray<TVIMPSTSearchKeyData>*) aData, iEngine);
|
|
187 |
break;
|
|
188 |
|
|
189 |
}
|
|
190 |
case EFriendAccpeted:
|
|
191 |
case EFriendRejected:
|
|
192 |
{
|
|
193 |
commd = CVIMPSTCmdFriendRequest::NewL(aCommandId,*(TDesC*) aData, iEngine);
|
|
194 |
break;
|
|
195 |
}
|
|
196 |
case EChangeOwnAvtar:
|
|
197 |
{
|
|
198 |
commd = CVIMPSTCmdChangeOwnAvtar::NewL(aCommandId,*(TAvatarData*) aData, iEngine);
|
|
199 |
break;
|
|
200 |
}
|
|
201 |
case ECloseConversation:
|
|
202 |
{
|
|
203 |
commd = CVIMPSTCmdCloseConversation::NewL(aCommandId,*(TDesC*) aData, iEngine);
|
|
204 |
break;
|
|
205 |
}
|
|
206 |
|
|
207 |
case EAddToPbk:
|
|
208 |
{
|
|
209 |
commd = CVIMPSTCmdAddToPbk::NewL(aCommandId,*(MVIMPSTStorageContact*) aData, iEngine);
|
|
210 |
break;
|
|
211 |
}
|
|
212 |
case ECancelLogin:
|
|
213 |
{
|
|
214 |
commd = CVIMPSTCmdCancelLogin::NewL(aCommandId ,iEngine);
|
|
215 |
break;
|
|
216 |
}
|
|
217 |
case ECmdProcessAcceptedContactNew:
|
|
218 |
case ECmdProcessSelectedContactNew:
|
|
219 |
case ECmdProcessAcceptedContactExist:
|
|
220 |
case ECmdProcessSelectedContactExist:
|
|
221 |
{
|
|
222 |
commd = CVIMPSTCmdProcessSelectedContact::NewL( aCommandId, *(TVPbkSelectedData*)aData, iEngine );
|
|
223 |
break;
|
|
224 |
}
|
|
225 |
case ECmdBlockContact:
|
|
226 |
{
|
|
227 |
commd = CVIMPSTCmdBlockContact::NewL(aCommandId,*(TDesC*) aData, *iArrayProcess , iEngine);
|
|
228 |
break;
|
|
229 |
|
|
230 |
}
|
|
231 |
case ECmdUnBlockContact:
|
|
232 |
{
|
|
233 |
commd = CVIMPSTCmdUnBlockContact::NewL(aCommandId,*(TDesC*) aData, iEngine);
|
|
234 |
break;
|
|
235 |
|
|
236 |
}
|
|
237 |
case EFetchBlockedList:
|
|
238 |
{
|
|
239 |
commd = CVIMPSTCmdFetchBlockedContactList::NewL(aCommandId, iEngine);
|
|
240 |
break;
|
|
241 |
}
|
|
242 |
default:
|
|
243 |
{
|
|
244 |
break;
|
|
245 |
}
|
|
246 |
|
|
247 |
}
|
|
248 |
|
|
249 |
return commd;
|
|
250 |
|
|
251 |
}
|
|
252 |
|
|
253 |
// --------------------------------------------------------------------------
|
|
254 |
// CVIMPSTCmdFactory::HandleServiceEventL
|
|
255 |
// --------------------------------------------------------------------------
|
|
256 |
//
|
|
257 |
void CVIMPSTCmdFactory::HandleServiceEventL
|
|
258 |
( TVIMPSTEnums::TVIMPSTRegistrationState aState,TInt aServiceError )
|
|
259 |
{
|
|
260 |
TRACER_AUTO;
|
|
261 |
// need not to store update complete state
|
|
262 |
iArrayProcess->SetLoginStateL( aState );
|
|
263 |
for( TInt index( 0 ); index < iObservers.Count(); ++index )
|
|
264 |
{
|
|
265 |
iObservers[index]->HandleCommandEventL(aState,aServiceError);
|
|
266 |
}
|
|
267 |
|
|
268 |
}
|
|
269 |
// --------------------------------------------------------------------------
|
|
270 |
// CVIMPSTCmdFactory::AddObserver
|
|
271 |
// --------------------------------------------------------------------------
|
|
272 |
//
|
|
273 |
void CVIMPSTCmdFactory::AddObserverL(MVIMPSTCmdObserver* aObserver)
|
|
274 |
{
|
|
275 |
if( iObservers.Find( aObserver ) == KErrNotFound )
|
|
276 |
{
|
|
277 |
User::LeaveIfError( iObservers.Append( aObserver ) );
|
|
278 |
}
|
|
279 |
|
|
280 |
}
|
|
281 |
// --------------------------------------------------------------------------
|
|
282 |
// CVIMPSTCmdFactory::RemoveObserver
|
|
283 |
// --------------------------------------------------------------------------
|
|
284 |
//
|
|
285 |
void CVIMPSTCmdFactory::RemoveObserver(MVIMPSTCmdObserver* aObserver)
|
|
286 |
{
|
|
287 |
|
|
288 |
TInt index( iObservers.Find( aObserver) );
|
|
289 |
|
|
290 |
if( index != KErrNotFound )
|
|
291 |
{
|
|
292 |
iObservers.Remove( index );
|
|
293 |
}
|
|
294 |
|
|
295 |
}
|
|
296 |
|
|
297 |
|
|
298 |
// --------------------------------------------------------------------------
|
|
299 |
// CVIMPSTCmdFactory::GetProcessInterface
|
|
300 |
// --------------------------------------------------------------------------
|
|
301 |
//
|
|
302 |
MVIMPSTProcessArray& CVIMPSTCmdFactory::GetProcessInterface()
|
|
303 |
{
|
|
304 |
return *iArrayProcess;
|
|
305 |
}
|
|
306 |
// End of File
|
|
307 |
|