1 /* |
|
2 * Copyright (c) 2009 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 #include <w32std.h> |
|
19 #include <apgtask.h> |
|
20 #include <apacmdln.h> |
|
21 #include <xqservicerequest.h> |
|
22 |
|
23 #include <hb/hbcore/hbtranslator.h> |
|
24 |
|
25 #include <hbicon.h> |
|
26 |
|
27 #include "bgcindicator.h" |
|
28 |
|
29 //---------------------------------------------------------------------- |
|
30 |
|
31 |
|
32 // ---------------------------------------------------------------------------- |
|
33 // BgcIndicator::BgcIndicator |
|
34 // @see bgcindicator.h |
|
35 // ---------------------------------------------------------------------------- |
|
36 BgcIndicator::BgcIndicator(const QString &indicatorType) : |
|
37 HbIndicatorInterface(indicatorType, |
|
38 HbIndicatorInterface::NotificationCategory, |
|
39 InteractionActivated), |
|
40 mNrOfUpdates(0) |
|
41 { |
|
42 } |
|
43 |
|
44 // ---------------------------------------------------------------------------- |
|
45 // BgcIndicator::~BgcIndicator |
|
46 // @see bgcindicator.h |
|
47 // ---------------------------------------------------------------------------- |
|
48 BgcIndicator::~BgcIndicator() |
|
49 { |
|
50 } |
|
51 |
|
52 // ---------------------------------------------------------------------------- |
|
53 // BgcIndicator::handleInteraction |
|
54 // @see bgcindicator.h |
|
55 // ---------------------------------------------------------------------------- |
|
56 bool BgcIndicator::handleInteraction(InteractionType type) |
|
57 { |
|
58 bool handled = false; |
|
59 |
|
60 if (type == InteractionActivated) |
|
61 { |
|
62 TRAPD( err, StartIaupdateL() ); |
|
63 if ( err != KErrNone ) |
|
64 { |
|
65 // nothing to do |
|
66 } |
|
67 handled = true; |
|
68 |
|
69 emit deactivate(); |
|
70 } |
|
71 return handled; |
|
72 } |
|
73 |
|
74 // ---------------------------------------------------------------------------- |
|
75 // BgcIndicator::indicatorData |
|
76 // @see bgcindicator.h |
|
77 // ---------------------------------------------------------------------------- |
|
78 QVariant BgcIndicator::indicatorData(int role) const |
|
79 { |
|
80 // use iaupdate's translate file |
|
81 // loc: HbTranslator trans("z:\\resource\\iaupdate\\","Text_Map_Swupdate_"); |
|
82 |
|
83 switch(role) |
|
84 { |
|
85 case PrimaryTextRole: |
|
86 { |
|
87 QString text(""); |
|
88 if ( mNrOfUpdates == 0 ) |
|
89 { |
|
90 // First time case |
|
91 // loc: text.append(hbTrId("txt_software_dblist_update_checking")); |
|
92 text.append(QString("Update checking")); |
|
93 } |
|
94 else if ( mNrOfUpdates == 1 ) |
|
95 { |
|
96 // one update available |
|
97 // loc: text.append(hbTrId("txt_software_dblist_update_available")); |
|
98 text.append(QString("Update available")); |
|
99 } |
|
100 else |
|
101 { |
|
102 // several updates available |
|
103 // loc: text.append(hbTrId("txt_software_dblist_updates_available")); |
|
104 text.append(QString("Updates available")); |
|
105 } |
|
106 return text; |
|
107 } |
|
108 case SecondaryTextRole: |
|
109 { |
|
110 QString text(""); |
|
111 if ( mNrOfUpdates == 0 ) |
|
112 { |
|
113 // First time case |
|
114 // loc: QString text(hbTrId("txt_software_dblist_val_not_activated")); |
|
115 text.append(QString("Not activated")); |
|
116 } |
|
117 else if ( mNrOfUpdates == 1 ) |
|
118 { |
|
119 // one update available |
|
120 // loc: QString text(hbTrId("txt_software_dblist_1_val_ln_update")); |
|
121 text.append(QString("%Ln updates").arg(mNrOfUpdates)); |
|
122 } |
|
123 else |
|
124 { |
|
125 // several updates available |
|
126 // loc: QString text(hbTrId("txt_software_dblist_1_val_ln_update")); |
|
127 text.append(QString("%%Ln updates").arg(mNrOfUpdates)); |
|
128 } |
|
129 return text; |
|
130 } |
|
131 case DecorationNameRole: |
|
132 case MonoDecorationNameRole: |
|
133 { |
|
134 QString iconName(""); |
|
135 return iconName; |
|
136 } |
|
137 default: |
|
138 return QVariant(); |
|
139 } |
|
140 } |
|
141 |
|
142 // ---------------------------------------------------------------------------- |
|
143 // BgcIndicator::prepareDisplayName |
|
144 // @see bgcindicator.h |
|
145 // ---------------------------------------------------------------------------- |
|
146 bool BgcIndicator::handleClientRequest( RequestType type, |
|
147 const QVariant ¶meter) |
|
148 { |
|
149 bool handled(false); |
|
150 switch (type) { |
|
151 case RequestActivate: |
|
152 { |
|
153 mNrOfUpdates = parameter.toInt(); |
|
154 emit dataChanged(); |
|
155 handled = true; |
|
156 } |
|
157 break; |
|
158 case RequestDeactivate: |
|
159 { |
|
160 emit deactivate(); |
|
161 } |
|
162 break; |
|
163 default: |
|
164 break; |
|
165 } |
|
166 |
|
167 return handled; |
|
168 } |
|
169 |
|
170 // ---------------------------------------------------------- |
|
171 // BgcIndicator::StartIaupdateL() |
|
172 // ---------------------------------------------------------- |
|
173 void BgcIndicator::StartIaupdateL() const |
|
174 { |
|
175 |
|
176 const TUint KIADUpdateLauncherUid( 0x2001FE2F ); |
|
177 _LIT(KIAUpdateLauncherExe, "iaupdatelauncher.exe" ); |
|
178 _LIT8( KRefreshFromNetworkDenied, "1" ); |
|
179 |
|
180 RWsSession ws; |
|
181 User::LeaveIfError( ws.Connect() == KErrNone ); |
|
182 TApaTaskList tasklist(ws); |
|
183 TApaTask task = tasklist.FindApp( TUid::Uid( KIADUpdateLauncherUid ) ); |
|
184 if ( task.Exists() ) |
|
185 { |
|
186 task.BringToForeground(); |
|
187 ws.Close(); |
|
188 } |
|
189 else |
|
190 { |
|
191 ws.Close(); |
|
192 RProcess process; |
|
193 CleanupClosePushL( process ); |
|
194 User::LeaveIfError( |
|
195 process.Create( KIAUpdateLauncherExe, KNullDesC ) ); |
|
196 |
|
197 CApaCommandLine* commandLine = CApaCommandLine::NewLC(); |
|
198 commandLine->SetDocumentNameL( KNullDesC ); |
|
199 commandLine->SetExecutableNameL( _L("iaupdatelauncher.exe") ); |
|
200 commandLine->SetTailEndL( KRefreshFromNetworkDenied ); |
|
201 commandLine->SetProcessEnvironmentL( process ); |
|
202 CleanupStack::PopAndDestroy( commandLine ); |
|
203 |
|
204 process.Resume(); |
|
205 CleanupStack::PopAndDestroy( &process ); |
|
206 } |
|
207 } |
|
208 |
|