|
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: Listens Ecom events. Requests service update, |
|
15 * - if SendUI Ecom service count changes |
|
16 * - has changed since previous boot. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <e32property.h> |
|
25 #include <ecom.h> |
|
26 |
|
27 #include "senduiecomobserver.h" |
|
28 #include "SendUiPrivateCRKeys.h" |
|
29 #include "senduiproperty.h" |
|
30 #include "senduiwatcher.h" |
|
31 #include "centralrepository.h" |
|
32 #include <SendingServiceInterfaceUids.hrh> |
|
33 |
|
34 // ======== LOCAL FUNCTIONS ======== |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // NewL |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 CSendUiEcomObserver* CSendUiEcomObserver::NewL() |
|
41 { |
|
42 CSendUiEcomObserver* self = new ( ELeave ) CSendUiEcomObserver(); |
|
43 CleanupStack::PushL( self ); |
|
44 self->ConstructL( ); |
|
45 CleanupStack::Pop( self ); |
|
46 return self; |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // NewL |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 CSendUiEcomObserver::~CSendUiEcomObserver() |
|
54 { |
|
55 Cancel(); |
|
56 } |
|
57 // --------------------------------------------------------------------------- |
|
58 // ConstructL |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 void CSendUiEcomObserver::ConstructL() |
|
62 { |
|
63 CActiveScheduler::Add( this ); |
|
64 RunL(); |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // Constructor |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 CSendUiEcomObserver::CSendUiEcomObserver() |
|
72 : CActive( CActive::EPriorityStandard ), iEcomSession( REComSession::OpenL()) |
|
73 { |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // From class CActive |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 void CSendUiEcomObserver::DoCancel() |
|
81 { |
|
82 iEcomSession.CancelNotifyOnChange( iStatus ); |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------------------------- |
|
86 // From class CActive |
|
87 // --------------------------------------------------------------------------- |
|
88 // |
|
89 void CSendUiEcomObserver::RunL() |
|
90 { |
|
91 iEcomSession.NotifyOnChange( iStatus); |
|
92 CheckForUpdateL(); |
|
93 SetActive(); |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // CheckForUpdateL |
|
98 // Requests service list update if SendUI Ecom service count has changed. |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 void CSendUiEcomObserver::CheckForUpdateL() |
|
102 { |
|
103 RImplInfoPtrArray implInfoArray ; |
|
104 REComSession::ListImplementationsL( |
|
105 TUid::Uid( KSendUiSendingServiceInterface ),implInfoArray ); |
|
106 TInt newEcomCount = implInfoArray.Count(); |
|
107 implInfoArray.ResetAndDestroy(); |
|
108 |
|
109 CRepository* repository = CRepository::NewLC( KCRUidSendUi ); |
|
110 TInt oldEcomCount = -1; |
|
111 // request service list update if sendui ecom service count has change. |
|
112 if ( repository->Get( KKeySendUiServiceEcomCount, oldEcomCount ) != KErrNone |
|
113 || oldEcomCount != newEcomCount ) |
|
114 { |
|
115 repository->Set( KKeySendUiServiceEcomCount, newEcomCount ); |
|
116 User::LeaveIfError( |
|
117 RProperty::Set(KPSUidSendUiProperty, KSendUiUpdateRequest, KSendUiUpdateRequested ) ); |
|
118 } |
|
119 CleanupStack::PopAndDestroy( repository ); |
|
120 } |
|
121 |
|
122 // end of file |