author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 20:54:53 +0300 | |
branch | RCL_3 |
changeset 21 | 9da50d567e3c |
parent 20 | f4a778e096c2 |
permissions | -rw-r--r-- |
20 | 1 |
/* |
2 |
* Copyright (c) 2007 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: The current extension does not provide a view. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
// INCLUDE FILES |
|
20 |
#include <eikmenup.h> |
|
21 |
||
22 |
#include <CMessageData.h> |
|
23 |
#include <sendui.h> |
|
24 |
#include <SendUiConsts.h> |
|
25 |
#include <TSendingCapabilities.h> |
|
26 |
#include <CSendingServiceInfo.h> |
|
27 |
||
28 |
#include <spsettings.h> |
|
29 |
#include <spentry.h> |
|
30 |
#include <spproperty.h> |
|
31 |
#include <spdefinitions.h> |
|
32 |
||
21
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
33 |
#include <logs.rsg> |
20 | 34 |
|
35 |
#include "MLogsEventGetter.h" |
|
36 |
#include "MLogsEvent.h" |
|
37 |
#include "MLogsEventData.h" |
|
38 |
#include "Logs.hrh" |
|
39 |
||
40 |
#include "clogsviewextension.h" |
|
41 |
#include "simpledebug.h" |
|
42 |
||
43 |
const TInt KArrayGranularity = 5; |
|
44 |
const TInt KServiceIdNotAvailable = 0; |
|
45 |
||
46 |
// ================= MEMBER FUNCTIONS ======================= |
|
47 |
||
48 |
// --------------------------------------------------------------------------- |
|
49 |
// NewL |
|
50 |
// --------------------------------------------------------------------------- |
|
51 |
// |
|
52 |
CLogsViewExtension* CLogsViewExtension::NewL() |
|
53 |
{ |
|
54 |
_LOG("CLogsViewExtension::NewL() - begin" ) |
|
55 |
CLogsViewExtension* self = CLogsViewExtension::NewLC(); |
|
56 |
CleanupStack::Pop( self ); |
|
57 |
_LOG("CLogsViewExtension::NewL() - end" ) |
|
58 |
return self; |
|
59 |
} |
|
60 |
||
61 |
||
62 |
// --------------------------------------------------------------------------- |
|
63 |
// NewLC |
|
64 |
// --------------------------------------------------------------------------- |
|
65 |
// |
|
66 |
CLogsViewExtension* CLogsViewExtension::NewLC() |
|
67 |
{ |
|
68 |
_LOG("CLogsViewExtension::NewLC() - begin" ) |
|
69 |
CLogsViewExtension* self = new( ELeave ) CLogsViewExtension; |
|
70 |
CleanupStack::PushL( self ); |
|
71 |
self->ConstructL(); |
|
72 |
_LOG("CLogsViewExtension::NewLC() - end" ) |
|
73 |
return self; |
|
74 |
} |
|
75 |
||
76 |
||
77 |
// --------------------------------------------------------------------------- |
|
78 |
// ConstructL |
|
79 |
// --------------------------------------------------------------------------- |
|
80 |
// |
|
81 |
void CLogsViewExtension::ConstructL() |
|
82 |
{ |
|
83 |
_LOG("CLogsViewExtension::ConstructL() - begin" ) |
|
84 |
iServiceList = |
|
85 |
new (ELeave) RPointerArray<CSendingServiceInfo>( KArrayGranularity ); |
|
86 |
iServiceProvidersToDim = |
|
87 |
new (ELeave) CArrayFixFlat<TUid>( KArrayGranularity ); |
|
88 |
||
89 |
//SP settings |
|
90 |
iSettings = CSPSettings::NewL(); |
|
91 |
//SP setting's entry |
|
92 |
iEntry = CSPEntry::NewL(); |
|
93 |
||
94 |
_LOG("CLogsViewExtension::ConstructL() - end" ) |
|
95 |
} |
|
96 |
||
97 |
||
98 |
// --------------------------------------------------------------------------- |
|
99 |
// Constructor |
|
100 |
// --------------------------------------------------------------------------- |
|
101 |
// |
|
102 |
CLogsViewExtension::CLogsViewExtension() : |
|
103 |
iSettings( NULL ), |
|
104 |
iEntry( NULL ), |
|
105 |
iSendUi( NULL ), |
|
106 |
iSendUiText( KNullDesC() ), |
|
107 |
iServiceId( 0 ), |
|
108 |
iContactLink( KNullDesC8() ) |
|
109 |
{ |
|
110 |
_LOG("CLogsViewExtension::CLogsViewExtension() - begin" ) |
|
111 |
_LOG("CLogsViewExtension::CLogsViewExtension() - end" ) |
|
112 |
} |
|
113 |
||
114 |
||
115 |
// --------------------------------------------------------------------------- |
|
116 |
// Destructor |
|
117 |
// --------------------------------------------------------------------------- |
|
118 |
// |
|
119 |
CLogsViewExtension::~CLogsViewExtension() |
|
120 |
{ |
|
121 |
_LOG("CLogsViewExtension::~CLogsViewExtension() - begin" ) |
|
122 |
||
123 |
if ( iServiceProvidersToDim->Count() ) |
|
124 |
{ |
|
125 |
iServiceProvidersToDim->Reset(); |
|
126 |
} |
|
127 |
delete iServiceProvidersToDim; |
|
128 |
||
129 |
if ( iServiceList->Count() ) |
|
130 |
{ |
|
131 |
iServiceList->Close(); |
|
132 |
} |
|
133 |
delete iServiceList; |
|
134 |
||
135 |
delete iEntry; |
|
136 |
delete iSettings; |
|
137 |
_LOG("CLogsViewExtension::~CLogsViewExtension() - end" ) |
|
138 |
} |
|
139 |
||
140 |
||
141 |
// --------------------------------------------------------------------------- |
|
142 |
// Releases this object and any resources it owns. |
|
143 |
// --------------------------------------------------------------------------- |
|
144 |
// |
|
145 |
void CLogsViewExtension::DoRelease() |
|
146 |
{ |
|
147 |
_LOG("CLogsViewExtension::DoRelease() - begin" ) |
|
148 |
delete this; |
|
149 |
_LOG("CLogsViewExtension::DoRelease() - end" ) |
|
150 |
} |
|
151 |
||
152 |
||
153 |
// --------------------------------------------------------------------------- |
|
154 |
// DynInitMenuPaneL |
|
155 |
// --------------------------------------------------------------------------- |
|
156 |
// |
|
157 |
void CLogsViewExtension::DynInitMenuPaneL |
|
158 |
( TInt aResourceId, CEikMenuPane* aMenuPane, |
|
159 |
const MLogsEventGetter* aEvent) |
|
160 |
{ |
|
161 |
_LOG("CLogsViewExtension::DynInitMenuPaneL() - begin") |
|
162 |
_LOGP("CLogsViewExtension::aResourceId =0x%x", aResourceId ) |
|
163 |
||
164 |
if ( aEvent && aMenuPane && iSendUi ) |
|
165 |
{ |
|
166 |
if ( R_COMMON_SEND_MESSAGE_SUBMENU == aResourceId && |
|
167 |
aEvent->Event()->LogsEventData() ) |
|
168 |
{ |
|
169 |
TPtrC8 tempPtr( KNullDesC8 ); |
|
170 |
// get service id |
|
171 |
||
172 |
// PC-lint errors: #1013, #1055 (in lines: 180,182) |
|
173 |
// Explanation:error message occurs because the 'DataField'function |
|
174 |
// is flagged by __VOIP and RD_VOIP_REL_2_2 flags; as long as the |
|
175 |
// entire logsserviceextension is flagged by __VOIP and |
|
176 |
// RD_VOIP_REL_2_2 as well this does not cause any problems |
|
177 |
||
178 |
TUint32 serviceId = aEvent->Event()->LogsEventData()->ServiceId(); |
|
179 |
//get contact link |
|
180 |
aEvent->Event()->LogsEventData()->GetContactLink( |
|
181 |
tempPtr ); |
|
182 |
//save contact link for later sending |
|
183 |
SetContactlink( tempPtr ); |
|
184 |
//save service id for later sending |
|
185 |
SetServiceId( serviceId ); |
|
186 |
//Validate |
|
187 |
if ( iServiceId && iContactLink.Length() ) |
|
188 |
{ |
|
189 |
_LOG("CLogsViewExtension::valid contact link & service id") |
|
190 |
TUid provideruid( KNullUid ); |
|
191 |
//get sendui service provider uid from SP settings |
|
192 |
TBool providerExists = GetServicePluginUidL( iServiceId, |
|
193 |
provideruid ); |
|
194 |
if ( providerExists ) |
|
195 |
{ |
|
196 |
//check if this provider is in availble sendui services |
|
197 |
TRAPD( error, VerifyServiceProviderL( provideruid , |
|
198 |
providerExists );); |
|
199 |
if ( KErrNone != error ) |
|
200 |
{ |
|
201 |
providerExists = EFalse; |
|
202 |
} |
|
203 |
} |
|
204 |
if ( providerExists ) |
|
205 |
{ |
|
206 |
_LOG("CLogsViewExtension::providerExists") |
|
207 |
SetProviderUid( provideruid ); |
|
208 |
// Check if send menu item already there |
|
209 |
TInt position( KErrNotFound ); |
|
210 |
if ( !aMenuPane->MenuItemExists( ELogsCmdMenuSendUi, position ) ) |
|
211 |
{ |
|
212 |
_LOG("CLogsViewExtension::Create send menu item") |
|
213 |
position = 0; |
|
214 |
TSendingCapabilities capabilities( 0, 0, 0 ); |
|
215 |
TRAPD( error, iSendUi->AddSendMenuItemL( |
|
216 |
*aMenuPane, |
|
217 |
position, |
|
218 |
ELogsCmdMenuSendUi, |
|
219 |
capabilities ); ); |
|
220 |
||
221 |
_LOGP("CLogsViewExtension::iSendUi->AddSendMenuItemL= %d", |
|
222 |
error ) |
|
223 |
||
224 |
if ( KErrNone == error ) |
|
225 |
{ |
|
226 |
//all ok, sent menu item text |
|
227 |
aMenuPane->SetItemTextL( ELogsCmdMenuSendUi, |
|
228 |
iSendUiText ); |
|
229 |
aMenuPane->SetItemSpecific( |
|
230 |
ELogsCmdMenuSendUi, ETrue ); |
|
231 |
_LOG("CLogsViewExtension::Create send menu item done") |
|
232 |
} |
|
233 |
} |
|
234 |
} |
|
235 |
} |
|
236 |
_LOG("CLogsViewExtension::done") |
|
237 |
} |
|
238 |
} |
|
239 |
_LOG("CLogsViewExtension::DynInitMenuPaneL() - end-----------" ) |
|
240 |
} |
|
241 |
||
242 |
||
243 |
// --------------------------------------------------------------------------- |
|
244 |
// HandleCommandL |
|
245 |
// --------------------------------------------------------------------------- |
|
246 |
// |
|
247 |
TBool CLogsViewExtension::HandleCommandL( TInt aCommandId ) |
|
248 |
{ |
|
249 |
_LOG("CLogsViewExtension::HandleCommandL() - begin" ) |
|
250 |
_LOGP("CLogsViewExtension::aCommandId =%x", aCommandId) |
|
251 |
_LOGP("provider UID =0x%x", iServiceProviderUid.iUid) |
|
252 |
_LOGP("iServiceId =%d", iServiceId) |
|
253 |
_LOGP("iContactLink.Length() =%d", iContactLink.Length() ) |
|
254 |
TBool handled( EFalse ); |
|
255 |
if ( ELogsCmdMenuSendUi == aCommandId && |
|
256 |
iServiceId && |
|
257 |
iContactLink.Length() && |
|
258 |
KNullUid != iServiceProviderUid ) |
|
259 |
{ |
|
260 |
_LOG("CLogsViewExtension::SendMessageL()" ) |
|
261 |
// start handling command |
|
262 |
TRAP_IGNORE( handled = SendMessageL(); ); |
|
263 |
||
264 |
//reset all |
|
265 |
iServiceId = 0; |
|
266 |
iContactLink.Set( KNullDesC8() ); |
|
267 |
iServiceProviderUid = KNullUid; |
|
268 |
iServiceList->Reset(); |
|
269 |
iServiceProvidersToDim->Reset(); |
|
270 |
} |
|
271 |
||
272 |
_LOG("CLogsViewExtension::HandleCommandL() - end" ) |
|
273 |
return handled; |
|
274 |
} |
|
275 |
||
276 |
// --------------------------------------------------------------------------- |
|
277 |
// VerifyServiceL |
|
278 |
// --------------------------------------------------------------------------- |
|
279 |
// |
|
280 |
void CLogsViewExtension::VerifyServiceProviderL( |
|
281 |
const TUid& aServiceProviderUid , |
|
282 |
TBool& aServiceProviderExists ) |
|
283 |
{ |
|
284 |
_LOG("CLogsViewExtension::VerifyServiceProviderL() - begin" ) |
|
285 |
aServiceProviderExists = EFalse; |
|
286 |
||
287 |
iServiceList->Reset(); |
|
288 |
iServiceProvidersToDim->Reset(); |
|
289 |
if ( !iSendUi ) |
|
290 |
{ |
|
291 |
User::Leave( KErrNotFound ); |
|
292 |
} |
|
293 |
||
294 |
// check if WLM Send IM plugin UID exists in service table |
|
295 |
// check if WLM Send IM plugin's service is found in available services |
|
296 |
||
297 |
//get available services |
|
298 |
iSendUi->AvailableServicesL( *iServiceList, KNullUid ); |
|
299 |
_LOGP("iServiceList->Count() =%d", iServiceList->Count() ) |
|
300 |
||
301 |
if ( iServiceList && iServiceList->Count() ) |
|
302 |
{ |
|
303 |
||
304 |
TUid serviceUid( KNullUid ); |
|
305 |
TUid serviceProviderUid( KNullUid ); |
|
306 |
||
307 |
for ( TInt i=0; i < iServiceList->Count(); i++ ) |
|
308 |
{ |
|
309 |
_LOGPP("service number =%d of %d", |
|
310 |
( i + 1 ), |
|
311 |
iServiceList->Count() ) |
|
312 |
||
313 |
serviceUid = (*iServiceList)[i]->ServiceId(); |
|
314 |
serviceProviderUid = (*iServiceList)[i]->ServiceProviderId(); |
|
315 |
||
316 |
_LOGP("service UID =0x%x", serviceUid.iUid) |
|
317 |
_LOGP("provider UID =0x%x", serviceProviderUid.iUid) |
|
318 |
_LOGDES( (*iServiceList)[i]->ServiceName() ); |
|
319 |
_LOGDES( (*iServiceList)[i]->ServiceMenuName() ); |
|
320 |
||
321 |
if ( aServiceProviderUid == serviceProviderUid ) |
|
322 |
{ |
|
323 |
_LOG("WLM SendUi provider exists") |
|
324 |
aServiceProviderExists = ETrue; |
|
325 |
} |
|
326 |
else |
|
327 |
{ |
|
328 |
_LOG("Append service to dimm list") |
|
329 |
iServiceProvidersToDim->AppendL( serviceProviderUid ); |
|
330 |
} |
|
331 |
} |
|
332 |
||
333 |
} |
|
334 |
||
335 |
_LOG("CLogsViewExtension::VerifyServiceProviderL() - end" ) |
|
336 |
} |
|
337 |
||
338 |
// --------------------------------------------------------------------------- |
|
339 |
// GetServicePluginUidL |
|
340 |
// --------------------------------------------------------------------------- |
|
341 |
// |
|
342 |
TBool CLogsViewExtension::GetServicePluginUidL( TInt aServiceId, |
|
343 |
TUid& aServiceProviderUid ) |
|
344 |
{ |
|
345 |
_LOG("CLogsViewExtension::GetServicePluginUidL() - begin" ) |
|
346 |
||
347 |
aServiceProviderUid = KNullUid; |
|
348 |
TBool serviceFound( EFalse ); |
|
349 |
||
350 |
// we have to reset the entry to ensure that we dont accidently reuse |
|
351 |
// properties of formerly fetched entries |
|
352 |
iEntry->Reset(); |
|
353 |
||
354 |
if ( iSettings && iEntry ) |
|
355 |
{ |
|
356 |
// find entry using service id |
|
357 |
TInt error( KErrNotFound ); |
|
358 |
TRAP( error, error = iSettings->FindEntryL( aServiceId , *iEntry ) ); |
|
359 |
if ( KErrNone == error ) |
|
360 |
{ |
|
361 |
_LOG("CLogsViewExtension::iSettings->FindEntryL" ) |
|
362 |
TServicePropertyName propertyName( EPropertySendFwImPluginId ); |
|
363 |
const CSPProperty* property = NULL; |
|
364 |
error = iEntry->GetProperty( property, propertyName ); |
|
365 |
if ( KErrNone == error && property ) |
|
366 |
{ |
|
367 |
_LOG("CLogsViewExtension::entry->GetProperty" ) |
|
368 |
TInt value( KErrNone ); |
|
369 |
||
370 |
if ( KErrNone == property->GetValue( value ) ) |
|
371 |
{ |
|
372 |
_LOGP("CLogsViewExtension::property->GetValue =0x%x", |
|
373 |
value ) |
|
374 |
//save it |
|
375 |
aServiceProviderUid.iUid = value; |
|
376 |
serviceFound = ETrue; |
|
377 |
_LOGP("CLogsViewExtension::aServiceProviderUid.iUid =0x%x", |
|
378 |
aServiceProviderUid.iUid) |
|
379 |
} |
|
380 |
} |
|
381 |
} |
|
382 |
} |
|
383 |
||
384 |
_LOG("CLogsViewExtension::GetServicePluginUidL() - end" ) |
|
385 |
return serviceFound; |
|
386 |
} |
|
387 |
||
388 |
// --------------------------------------------------------------------------- |
|
389 |
// SetSendUi |
|
390 |
// --------------------------------------------------------------------------- |
|
391 |
// |
|
392 |
void CLogsViewExtension::SetSendUi( CSendUi& aSendUi ) |
|
393 |
{ |
|
394 |
_LOG("CLogsViewExtension::SetSendUi() - begin" ) |
|
395 |
iSendUi = &aSendUi; |
|
396 |
_LOG("CLogsViewExtension::SetSendUi() - end" ) |
|
397 |
} |
|
398 |
||
399 |
||
400 |
// --------------------------------------------------------------------------- |
|
401 |
// SetSendUiText |
|
402 |
// --------------------------------------------------------------------------- |
|
403 |
// |
|
404 |
void CLogsViewExtension::SetSendUiText( const TDesC& aSendUiText ) |
|
405 |
{ |
|
406 |
_LOG("CLogsViewExtension::SetSendUiText() - begin" ) |
|
407 |
iSendUiText.Set(aSendUiText ); |
|
408 |
_LOG("CLogsViewExtension::SetSendUiText() - end" ) |
|
409 |
} |
|
410 |
||
411 |
// --------------------------------------------------------------------------- |
|
412 |
// SetContactlink |
|
413 |
// --------------------------------------------------------------------------- |
|
414 |
// |
|
415 |
void CLogsViewExtension::SetContactlink( const TDesC8& aContactLink ) |
|
416 |
{ |
|
417 |
_LOG("CLogsViewExtension::SetContactlink() - begin" ) |
|
418 |
iContactLink.Set( KNullDesC8 ); |
|
419 |
if ( aContactLink.Length() ) |
|
420 |
{ |
|
421 |
iContactLink.Set( aContactLink ); |
|
422 |
} |
|
423 |
_LOG("CLogsViewExtension::SetContactlink() - end" ) |
|
424 |
} |
|
425 |
||
426 |
// --------------------------------------------------------------------------- |
|
427 |
// SetServiceId |
|
428 |
// --------------------------------------------------------------------------- |
|
429 |
// |
|
430 |
void CLogsViewExtension::SetServiceId( const TUint32& aServiceId ) |
|
431 |
{ |
|
432 |
_LOG("CLogsViewExtension::SetServiceId() - begin" ) |
|
433 |
iServiceId = KServiceIdNotAvailable; |
|
434 |
if ( aServiceId ) |
|
435 |
{ |
|
436 |
iServiceId = aServiceId; |
|
437 |
} |
|
438 |
_LOG("CLogsViewExtension::SetServiceId() - end" ) |
|
439 |
} |
|
440 |
||
441 |
// --------------------------------------------------------------------------- |
|
442 |
// SetProviderUid |
|
443 |
// --------------------------------------------------------------------------- |
|
444 |
// |
|
445 |
void CLogsViewExtension::SetProviderUid( const TUid& aUid ) |
|
446 |
{ |
|
447 |
_LOG("CLogsViewExtension::SetProviderUid() - begin" ) |
|
448 |
iServiceProviderUid = aUid; |
|
449 |
_LOG("CLogsViewExtension::SetProviderUid() - end" ) |
|
450 |
} |
|
451 |
||
452 |
// ---------------------------------------------------------------------------- |
|
453 |
// SendMessageL |
|
454 |
// ---------------------------------------------------------------------------- |
|
455 |
// |
|
456 |
TBool CLogsViewExtension::SendMessageL() |
|
457 |
{ |
|
458 |
_LOG("CLogsViewExtension::SendMessageL - begin" ) |
|
459 |
TBool commandHandled( ETrue ); |
|
460 |
TInt error( KErrNone ); |
|
461 |
TSendingCapabilities capabilities( 0, 0, 0 ); |
|
462 |
CMessageData* messageData = CMessageData::NewL(); |
|
463 |
CleanupStack::PushL( messageData ); |
|
464 |
_LOG("CLogsViewExtension::SendMessageL iSendUi->ShowTypedQueryL") |
|
465 |
TUid selectedServiceUid( KNullUid ); |
|
466 |
selectedServiceUid = iSendUi->ShowTypedQueryL( CSendUi::ESendMenu, |
|
467 |
NULL, capabilities, iServiceProvidersToDim ); |
|
468 |
||
469 |
_LOGP("CLogsViewExtension::Selected service UID =0x%x", |
|
470 |
selectedServiceUid.iUid ) |
|
471 |
||
472 |
//check if user pressed cancel |
|
473 |
if ( KNullUid != selectedServiceUid ) |
|
474 |
{ |
|
475 |
//set opaque data |
|
476 |
TUid dataType; |
|
477 |
dataType.iUid = iServiceId; |
|
478 |
TRAP( error, messageData->SetOpaqueDataL( &iContactLink , dataType ) ); |
|
479 |
_LOGP("messageData->SetOpaqueDataL= %d", error) |
|
480 |
if ( KErrNone == error ) |
|
481 |
{ |
|
482 |
_LOG("CLogsViewExtension::SendMessageL...") |
|
483 |
_LOG("...iSendUi->CreateAndSendMessageL") |
|
484 |
iSendUi->CreateAndSendMessageL( selectedServiceUid, |
|
485 |
messageData, KNullUid, EFalse ); |
|
486 |
_LOG("CLogsViewExtension::iSendUi->CreateAndSendMessageL") |
|
487 |
} |
|
488 |
} |
|
489 |
||
490 |
CleanupStack::PopAndDestroy( messageData ); |
|
491 |
messageData = NULL; |
|
492 |
||
493 |
_LOG("CLogsViewExtension::SendMessageL - end" ) |
|
494 |
||
495 |
return commandHandled; |
|
496 |
} |
|
497 |
||
498 |
// End of File |