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 "usbindicatorplugin.h" |
|
18 #include <QString> |
|
19 #include <QLocale> |
|
20 #include <QApplication> |
|
21 #include "usbindicator.h" |
|
22 #include "usbaddressedindicator.h" |
|
23 #include "usbmassstorageindicator.h" |
|
24 #include "usbdisconnectingindicator.h" |
|
25 #include "usbdebug.h" |
|
26 |
|
27 Q_EXPORT_PLUGIN(UsbIndicatorPlugin) |
|
28 |
|
29 /*! |
|
30 UsbIndicatorPlugin::UsbIndicatorPlugin |
|
31 */ |
|
32 UsbIndicatorPlugin::UsbIndicatorPlugin() : mError(0), mTranslatorLoaded(0) |
|
33 { |
|
34 } |
|
35 |
|
36 /*! |
|
37 UsbIndicatorPlugin::~UsbIndicatorPlugin |
|
38 */ |
|
39 UsbIndicatorPlugin::~UsbIndicatorPlugin() |
|
40 { |
|
41 if (mTranslatorLoaded) { |
|
42 QApplication::removeTranslator(&mTranslator); |
|
43 } |
|
44 } |
|
45 |
|
46 /*! |
|
47 UsbIndicatorPlugin::indicatorTypes |
|
48 Return notification types this plugin implements |
|
49 */ |
|
50 QStringList UsbIndicatorPlugin::indicatorTypes() const |
|
51 { |
|
52 myDebug() << ">>> UsbIndicatorPlugin::indicatorTypes"; |
|
53 QStringList types; |
|
54 types << ConnectedIndicator; |
|
55 types << AddressedIndicator; |
|
56 types << MassStorageIndicator; |
|
57 types << UsbDisconnectingIndicator; |
|
58 return types; |
|
59 } |
|
60 |
|
61 |
|
62 |
|
63 /*! |
|
64 UsbIndicatorPlugin::createIndicator |
|
65 Creates and returns the HbIndicatorInterface |
|
66 */ |
|
67 HbIndicatorInterface* UsbIndicatorPlugin::createIndicator(const QString &indicatorType) |
|
68 { |
|
69 myDebug() << ">>> UsbIndicatorPlugin::createIndicator"; |
|
70 if (!mTranslatorLoaded) { |
|
71 // add translator for application library |
|
72 QString locale = QLocale::system().name(); |
|
73 QString filename = QString("usbindimenu_") + locale; |
|
74 bool success = mTranslator.load(filename, QString("z:/resource/qt/translations")); |
|
75 QApplication::installTranslator(&mTranslator); |
|
76 mTranslatorLoaded = true; |
|
77 } |
|
78 |
|
79 HbIndicatorInterface *indicator = NULL; |
|
80 if (indicatorType == ConnectedIndicator) { |
|
81 indicator = new USBIndicator(indicatorType); |
|
82 } |
|
83 else if (indicatorType == AddressedIndicator) { |
|
84 indicator = new UsbAddressedIndicator(indicatorType); |
|
85 } |
|
86 else if (indicatorType == MassStorageIndicator) { |
|
87 indicator = new UsbMassStorageIndicator(indicatorType); |
|
88 } |
|
89 else if (indicatorType == UsbDisconnectingIndicator) { |
|
90 indicator = new USBDisconnectingIndicator(indicatorType); |
|
91 } |
|
92 myDebug() << "<<< UsbIndicatorPlugin::createIndicator"; |
|
93 return indicator; |
|
94 } |
|
95 |
|
96 |
|