|
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 "phoneindicatorinterface.h" |
|
19 #include "phoneindicatorservicesendertask.h" |
|
20 #include "phoneindicators.h" |
|
21 |
|
22 #include <QTime> |
|
23 #include <QStringList> |
|
24 #include <QThreadPool> |
|
25 |
|
26 PhoneIndicatorInterface::PhoneIndicatorInterface( |
|
27 const QString &indicatorType, |
|
28 int typeIndex, |
|
29 Interaction interaction) : |
|
30 HbIndicatorInterface( indicatorType, HbIndicatorInterface::NotificationCategory, |
|
31 (interaction == InteractionNone) ? NoInteraction : InteractionActivated), |
|
32 m_typeIndex(typeIndex), |
|
33 m_interaction(interaction), |
|
34 m_primaryText(IndicatorInfos[typeIndex].primaryText), |
|
35 m_secondaryText(IndicatorInfos[typeIndex].secondaryText), |
|
36 m_icon(IndicatorInfos[typeIndex].icon) |
|
37 { |
|
38 } |
|
39 |
|
40 bool PhoneIndicatorInterface::handleInteraction(InteractionType type) |
|
41 { |
|
42 if (type == InteractionActivated) { |
|
43 switch (m_interaction) { |
|
44 case OpenMissedCallView: //fallthrough |
|
45 case OpenCallUi: //fallthrough |
|
46 case OpenDiverSettingsView: { |
|
47 // Launch services on the client side |
|
48 QVariantMap data; |
|
49 data.insert(QLatin1String("interaction"), m_interaction); |
|
50 emit userActivated(data); |
|
51 } |
|
52 break; |
|
53 case Deactivate: |
|
54 emit deactivate(); |
|
55 break; |
|
56 default: |
|
57 return false; |
|
58 } |
|
59 emit dataChanged(); |
|
60 } |
|
61 return false; |
|
62 } |
|
63 |
|
64 QVariant PhoneIndicatorInterface::indicatorData(int role) const |
|
65 { |
|
66 QVariantMap map = m_parameter.value<QVariantMap>(); |
|
67 |
|
68 if (role == PrimaryTextRole) { |
|
69 return map.value( (QVariant(PrimaryTextRole)).toString()).toString(); |
|
70 } else if (role == SecondaryTextRole ) { |
|
71 return map.value( (QVariant(SecondaryTextRole)).toString()).toString(); |
|
72 } else if (role == MonoDecorationNameRole) { |
|
73 return m_icon; |
|
74 } else if (role == DecorationNameRole) { |
|
75 return map.value( (QVariant(DecorationNameRole)).toString()).toString(); |
|
76 } |
|
77 return QVariant(); |
|
78 } |
|
79 |
|
80 bool PhoneIndicatorInterface::handleClientRequest(RequestType type, const QVariant ¶meter) |
|
81 { |
|
82 bool handled(false); |
|
83 switch (type) { |
|
84 case RequestActivate: |
|
85 if (m_parameter != parameter) { |
|
86 m_parameter = parameter; |
|
87 emit dataChanged(); |
|
88 } |
|
89 handled = true; |
|
90 break; |
|
91 default: |
|
92 m_parameter.clear(); |
|
93 } |
|
94 return handled; |
|
95 } |
|
96 |