|
1 /* |
|
2 * Copyright (c) 2010 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 #include <hb/hbcore/hbtranslator.h> |
|
23 #include <hbicon.h> |
|
24 #include "sisxsilentinstallindicator.h" |
|
25 |
|
26 |
|
27 // ---------------------------------------------------------------------------- |
|
28 // SisxSilentInstallIndicator::SisxSilentInstallIndicator |
|
29 // @see sisxsilentinstallindicator.h |
|
30 // ---------------------------------------------------------------------------- |
|
31 SisxSilentInstallIndicator::SisxSilentInstallIndicator( |
|
32 const QString &indicatorType) : |
|
33 HbIndicatorInterface( |
|
34 indicatorType, |
|
35 HbIndicatorInterface::NotificationCategory, |
|
36 InteractionActivated), |
|
37 mUpdateValue(0), |
|
38 mIsInstallProcess(1) // Set installer mode as default. |
|
39 { |
|
40 } |
|
41 |
|
42 // ---------------------------------------------------------------------------- |
|
43 // SisxSilentInstallIndicator::~SisxSilentInstallIndicator |
|
44 // @see sisxsilentinstallindicator.h |
|
45 // ---------------------------------------------------------------------------- |
|
46 SisxSilentInstallIndicator::~SisxSilentInstallIndicator() |
|
47 { |
|
48 } |
|
49 |
|
50 // ---------------------------------------------------------------------------- |
|
51 // SisxSilentInstallIndicator::handleInteraction |
|
52 // @see sisxsilentinstallindicator.h |
|
53 // ---------------------------------------------------------------------------- |
|
54 bool SisxSilentInstallIndicator::handleInteraction(InteractionType type) |
|
55 { |
|
56 bool handled = false; |
|
57 |
|
58 if (type == InteractionActivated) |
|
59 { |
|
60 handled = true; |
|
61 emit deactivate(); |
|
62 } |
|
63 |
|
64 return handled; |
|
65 } |
|
66 |
|
67 // ---------------------------------------------------------------------------- |
|
68 // SisxSilentInstallIndicator::indicatorData |
|
69 // @see sisxsilentinstallindicator.h |
|
70 // ---------------------------------------------------------------------------- |
|
71 QVariant SisxSilentInstallIndicator::indicatorData(int role) const |
|
72 { |
|
73 switch(role) |
|
74 { |
|
75 case PrimaryTextRole: |
|
76 { |
|
77 // Set text to first line of indicator. |
|
78 QString text(""); |
|
79 // Check which mode is on. |
|
80 if ( mIsInstallProcess ) |
|
81 { |
|
82 text.append(QString("Installing")); |
|
83 } |
|
84 else |
|
85 { |
|
86 text.append(QString("Finalizing installations")); |
|
87 } |
|
88 return text; |
|
89 } |
|
90 case SecondaryTextRole: |
|
91 { |
|
92 // Set text to second line of indicator. |
|
93 QString text(""); |
|
94 text.append(QString("%1 %").arg(mUpdateValue)); |
|
95 return text; |
|
96 } |
|
97 case DecorationNameRole: |
|
98 case MonoDecorationNameRole: |
|
99 { |
|
100 // Get icon for the indicator. |
|
101 //TODO: this needs to be fixed. |
|
102 QString iconName("z:/resource/swidaemon/qtg_large_application.svg"); |
|
103 return iconName; |
|
104 } |
|
105 default: |
|
106 return QVariant(); |
|
107 } |
|
108 } |
|
109 |
|
110 // ---------------------------------------------------------------------------- |
|
111 // SisxSilentInstallIndicator::prepareDisplayName |
|
112 // @see sisxsilentinstallindicator.h |
|
113 // ---------------------------------------------------------------------------- |
|
114 bool SisxSilentInstallIndicator::handleClientRequest( RequestType type, |
|
115 const QVariant ¶meter) |
|
116 { |
|
117 bool handled(false); |
|
118 |
|
119 switch (type) |
|
120 { |
|
121 case RequestActivate: |
|
122 { |
|
123 // Read client percent value to float. |
|
124 mUpdateValue = parameter.toReal(); |
|
125 |
|
126 // If client send -1 insted of percent value (0-100) we need |
|
127 // to switch to uninstaller mode. |
|
128 if (mUpdateValue == -1) |
|
129 { |
|
130 mIsInstallProcess = false; |
|
131 mUpdateValue = 0; |
|
132 } |
|
133 emit dataChanged(); |
|
134 handled = true; |
|
135 } |
|
136 break; |
|
137 case RequestDeactivate: |
|
138 { |
|
139 emit deactivate(); |
|
140 } |
|
141 break; |
|
142 default: |
|
143 break; |
|
144 } |
|
145 |
|
146 return handled; |
|
147 } |
|
148 |
|
149 // EOF |