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 #include "usbindicator.h" |
|
18 #include <QVariant> |
|
19 #include <e32uid.h> |
|
20 #include <apadef.h> |
|
21 #include "usbdebug.h" |
|
22 |
|
23 const QString TextIdPrefix = ("txt_usb_dblist_usb_connected_val_"); |
|
24 /*! |
|
25 USBIndicator::USBIndicator |
|
26 */ |
|
27 USBIndicator::USBIndicator(const QString &indicatorType) : |
|
28 HbIndicatorInterface(indicatorType, |
|
29 HbIndicatorInterface::SettingCategory, |
|
30 InteractionActivated) |
|
31 { |
|
32 } |
|
33 |
|
34 /*! |
|
35 USBIndicator::~USBIndicator |
|
36 */ |
|
37 USBIndicator::~USBIndicator() |
|
38 { |
|
39 } |
|
40 |
|
41 |
|
42 /*! |
|
43 USBIndicator::handleInteraction |
|
44 */ |
|
45 bool USBIndicator::handleInteraction(InteractionType type) |
|
46 { |
|
47 myDebug() << ">>> USBIndicator::handleInteraction"; |
|
48 bool handled = false; |
|
49 TUidType uidtype(KExecutableImageUid, TUid::Uid(0x00), |
|
50 TUid::Uid(KUSBUIUid)); |
|
51 if (type == InteractionActivated) { |
|
52 RProcess usbUiProcess; |
|
53 TInt result = usbUiProcess.Create(KUSBExe(), KNullDesC, uidtype); |
|
54 if (result == KErrNone) { |
|
55 usbUiProcess.Resume(); |
|
56 } |
|
57 usbUiProcess.Close(); |
|
58 handled = true; |
|
59 } |
|
60 myDebug() << "<<< USBIndicator::handleInteraction"; |
|
61 return handled; |
|
62 } |
|
63 |
|
64 /*! |
|
65 USBIndicator::indicatorData |
|
66 returns the data and icon that needs to be displayed in the universal pop up and indicator menu |
|
67 */ |
|
68 QVariant USBIndicator::indicatorData(int role) const |
|
69 { |
|
70 myDebug() << ">>> USBIndicator::indicatorData, role is " << role; |
|
71 switch(role) { |
|
72 case PrimaryTextRole: |
|
73 { |
|
74 QString text = QString(hbTrId("txt_usb_dblist_usb_connected")); |
|
75 return text; |
|
76 } |
|
77 case SecondaryTextRole: |
|
78 { |
|
79 return mSecDisplayName; |
|
80 } |
|
81 case DecorationNameRole: |
|
82 { |
|
83 QString iconName(KUsbIconFile); |
|
84 return iconName; |
|
85 } |
|
86 default: |
|
87 return QVariant(); |
|
88 } |
|
89 } |
|
90 |
|
91 /*! |
|
92 USBIndicator::handleClientRequest |
|
93 handles client's activate and deactivate request |
|
94 */ |
|
95 bool USBIndicator::handleClientRequest( RequestType type, |
|
96 const QVariant ¶meter) |
|
97 { |
|
98 myDebug() << ">>> USBIndicator::handleClientRequest"; |
|
99 switch (type) { |
|
100 case RequestActivate: |
|
101 { |
|
102 QString friendlyName = parameter.toString(); |
|
103 friendlyName.replace( QChar(' '), QChar('_') ); |
|
104 QString textId = TextIdPrefix + friendlyName; |
|
105 mSecDisplayName = hbTrId(textId.toAscii()); |
|
106 emit dataChanged(); |
|
107 } |
|
108 break; |
|
109 default: |
|
110 mSecDisplayName.clear(); |
|
111 emit deactivate(); |
|
112 break; |
|
113 } |
|
114 //request always handled |
|
115 myDebug() << "<<< USBIndicator::handleClientRequest"; |
|
116 return true; |
|
117 } |
|