|
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 <QGraphicsLinearLayout> |
|
19 #include <QScopedPointer> |
|
20 #include <QDebug> |
|
21 |
|
22 #include <hbmessagebox.h> |
|
23 #include <hblabel.h> |
|
24 #include <hbpushbutton.h> |
|
25 #include <hblineedit.h> |
|
26 #include <hbcombobox.h> |
|
27 #include <hbcheckbox.h> |
|
28 #include <xqappmgr.h> |
|
29 #include <xqaiwrequest.h> |
|
30 #include <logsservices.h> |
|
31 |
|
32 #include "logsservicetesterwidget.h" |
|
33 #include "logsservicetesterappcloser.h" |
|
34 #include "logsdefs.h" |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 LogsServiceTesterWidget::LogsServiceTesterWidget(QGraphicsItem *parent ) : |
|
41 HbWidget(parent), |
|
42 mViewIndex(0), |
|
43 mShowDialpad(false), |
|
44 mDialpadText(QString()) |
|
45 { |
|
46 qDebug() << "[LOGS_TESTER]-> LogsServiceTesterWidget::LogsServiceTesterWidget()"; |
|
47 mAppCloser = new LogsServiceTesterAppCloser(this); |
|
48 connect(mAppCloser, SIGNAL(closed()), this, SLOT(dialerClosed()), |
|
49 Qt::QueuedConnection); |
|
50 connect(mAppCloser, SIGNAL(closeError(int)), this, SLOT(dialerCloseError(int)), |
|
51 Qt::QueuedConnection); |
|
52 |
|
53 HbLabel* comboLabel = new HbLabel("Select logs view:"); |
|
54 |
|
55 mComboBox = new HbComboBox(); |
|
56 mComboBox->addItem( "Recent view", QVariant(LogsServices::ViewAll)); |
|
57 mComboBox->addItem( "Received view", QVariant(LogsServices::ViewReceived)); |
|
58 mComboBox->addItem( "Called view", QVariant(LogsServices::ViewCalled)); |
|
59 mComboBox->addItem( "Missed view", QVariant(LogsServices::ViewMissed)); |
|
60 |
|
61 mCheckBox = new HbCheckBox("Show dialpad"); |
|
62 |
|
63 HbLabel* editorLabel = new HbLabel("Launch dialpad with number:"); |
|
64 mEditor = new HbLineEdit(); |
|
65 mEditor->setInputMethodHints(Qt::ImhPreferNumbers); |
|
66 |
|
67 HbPushButton* newService = new HbPushButton("Start Dialer via new service name"); |
|
68 newService->setPreferredHeight(60); |
|
69 connect(newService, SIGNAL(clicked()), this, SLOT(startNewService())); |
|
70 |
|
71 HbPushButton* oldService = new HbPushButton("Start Dialer via old service name"); |
|
72 oldService->setPreferredHeight(60); |
|
73 connect(oldService, SIGNAL(clicked()), this, SLOT(startOldService())); |
|
74 |
|
75 HbPushButton* killDialer = new HbPushButton("Kill Dialer"); |
|
76 killDialer->setPreferredHeight(60); |
|
77 connect(killDialer, SIGNAL(clicked()), mAppCloser, SLOT(closeDialerApp())); |
|
78 |
|
79 QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical); |
|
80 layout->addItem(comboLabel); |
|
81 layout->addItem(mComboBox); |
|
82 layout->addItem(mCheckBox); |
|
83 layout->addItem(editorLabel); |
|
84 layout->addItem(mEditor); |
|
85 layout->addItem(newService); |
|
86 layout->addItem(oldService); |
|
87 layout->addItem(killDialer); |
|
88 setLayout(layout); |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 LogsServiceTesterWidget:: ~LogsServiceTesterWidget() |
|
96 { |
|
97 qDebug() << "[LOGS_TESTER] <-> LogsServiceTesterWidget::~LogsServiceTesterWidget()"; |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 void LogsServiceTesterWidget::fetchData() |
|
105 { |
|
106 qDebug() << "[LOGS_TESTER] LogsServiceTesterWidget::fetchData()"; |
|
107 int index = mComboBox->currentIndex()>0 ? mComboBox->currentIndex() : 0; |
|
108 mViewIndex = mComboBox->itemData(index).toInt(); |
|
109 qDebug() << "[LOGS_TESTER] viewIndex: " << mViewIndex; |
|
110 |
|
111 mShowDialpad = (mCheckBox->checkState() == Qt::Checked) ? true : false; |
|
112 qDebug() << "[LOGS_TESTER] showDialpad: " << mShowDialpad; |
|
113 |
|
114 mDialpadText = mEditor->text(); |
|
115 qDebug() << "[LOGS_TESTER] dialpadText: " << mDialpadText; |
|
116 } |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 void LogsServiceTesterWidget::startNewService() |
|
123 { |
|
124 qDebug() << "[LOGS_TESTER] -> LogsServiceTesterWidget::startNewService()"; |
|
125 fetchData(); |
|
126 |
|
127 XQApplicationManager appMgr; |
|
128 QScopedPointer<XQAiwRequest> request(appMgr.create( QLatin1String(logsServiceName), |
|
129 QLatin1String(logsInterfaceName), |
|
130 QLatin1String(logsOperationName), |
|
131 false)); |
|
132 if (!request.isNull()) { |
|
133 int retValue = -1; |
|
134 QList<QVariant> arglist; |
|
135 QVariantMap map; |
|
136 map.insert(logsViewIndexParam, QVariant(mViewIndex)); |
|
137 map.insert(logsShowDialpadParam, QVariant(mShowDialpad)); |
|
138 map.insert(logsDialpadTextParam, QVariant(mDialpadText)); |
|
139 |
|
140 arglist.append(QVariant(map)); |
|
141 request->setArguments(arglist); |
|
142 QVariant ret(retValue); |
|
143 |
|
144 request->send(ret); |
|
145 } |
|
146 qDebug() << "[LOGS_TESTER] <- LogsServiceTesterWidget::startNewService()"; |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 void LogsServiceTesterWidget::startOldService() |
|
154 { |
|
155 qDebug() << "[LOGS_TESTER] -> LogsServiceTesterWidget::startOldService()"; |
|
156 fetchData(); |
|
157 LogsServices::start( (LogsServices::LogsView)mViewIndex, mShowDialpad, mDialpadText ); |
|
158 qDebug() << "[LOGS_TESTER] <- LogsServiceTesterWidget::startOldService()"; |
|
159 } |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 void LogsServiceTesterWidget::dialerClosed() |
|
166 { |
|
167 HbMessageBox::information("Dialer closed"); |
|
168 } |
|
169 |
|
170 // ----------------------------------------------------------------------------- |
|
171 // |
|
172 // ----------------------------------------------------------------------------- |
|
173 // |
|
174 void LogsServiceTesterWidget::dialerCloseError(int error) |
|
175 { |
|
176 QString errorMsg; |
|
177 if (error == LogsServiceTesterAppCloser::ErrorAppNotRunning) { |
|
178 errorMsg = QString("Dialer not running"); |
|
179 } else if (error == LogsServiceTesterAppCloser::ErrorClosingOngoing) { |
|
180 errorMsg = QString("Dialer closing is already ongoing"); |
|
181 } else if (error == LogsServiceTesterAppCloser::ErrorClosingTimeout) { |
|
182 errorMsg = QString("Dialer closing timeout"); |
|
183 } else { |
|
184 errorMsg = QString("Dialer closing error: %1").arg(error); |
|
185 } |
|
186 HbMessageBox::warning(errorMsg); |
|
187 } |