|
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 <QApplication> |
|
19 #include <QKeyEvent> |
|
20 #include <QLabel> |
|
21 #include <QVBoxLayout> |
|
22 #include <QStackedWidget> |
|
23 #include <QImageReader> |
|
24 #include <QDebug> |
|
25 #include <QTimer> |
|
26 #include <QPushButton> |
|
27 #include <QLineEdit> |
|
28 #include <QListView> |
|
29 |
|
30 |
|
31 #include "serviceapp.h" |
|
32 #include <xqserviceutil.h> |
|
33 |
|
34 ServiceApp::ServiceApp(QWidget *parent, Qt::WFlags f) |
|
35 : QWidget(parent, f) |
|
36 { |
|
37 |
|
38 mService = new DialerService(this); |
|
39 /* Adjust the palette */ |
|
40 #if defined(Q_WS_S60) |
|
41 QPalette p = qApp->palette(); |
|
42 QColor color(80,20,20); |
|
43 QColor bg(20,20,20); |
|
44 p.setColor(QPalette::Highlight, color.lighter(200)); |
|
45 p.setColor(QPalette::Text, Qt::white); |
|
46 p.setColor(QPalette::Base, bg); |
|
47 p.setColor(QPalette::WindowText, Qt::white); |
|
48 p.setColor(QPalette::Window, bg); |
|
49 p.setColor(QPalette::ButtonText, Qt::white); |
|
50 p.setColor(QPalette::Button, color.lighter(150)); |
|
51 p.setColor(QPalette::Link, QColor(240,40,40)); |
|
52 |
|
53 qApp->setPalette(p); |
|
54 #endif |
|
55 |
|
56 QPushButton *quitButton = new QPushButton(tr("Quit")); |
|
57 connect(quitButton, SIGNAL(clicked()), this, SLOT(quit())); |
|
58 |
|
59 /* |
|
60 mEndCallButton = new QPushButton(tr("End Call")); |
|
61 mEndCallButton->setEnabled(false); |
|
62 connect(mEndCallButton, SIGNAL(clicked()), this, SLOT(endCall())); |
|
63 */ |
|
64 QString t = "SERVICE DIAL -> "; |
|
65 t = t + (XQServiceUtil::isEmbedded() ? " EMBEDDED" : " NOT EMBEDDED"); |
|
66 QLabel *title = new QLabel(t); |
|
67 |
|
68 mLabel = new QLabel(tr("PHONE")); |
|
69 mNumber = new QLabel(tr("******")); |
|
70 |
|
71 QVBoxLayout *vl = new QVBoxLayout; |
|
72 vl->setMargin(0); |
|
73 vl->setSpacing(0); |
|
74 |
|
75 vl->addWidget(title); |
|
76 vl->addWidget(mLabel); |
|
77 vl->addWidget(mNumber); |
|
78 vl->addWidget(quitButton); |
|
79 |
|
80 setLayout(vl); |
|
81 #if defined(Q_WS_X11) || defined(Q_WS_WIN) |
|
82 setFixedSize(QSize(360,640)); // nHD |
|
83 #elif defined(Q_WS_S60) |
|
84 showMaximized(); |
|
85 showFullScreen(); |
|
86 #endif |
|
87 // new DialerService(this); |
|
88 } |
|
89 |
|
90 |
|
91 ServiceApp::~ServiceApp() |
|
92 { |
|
93 } |
|
94 |
|
95 void ServiceApp::quit() |
|
96 { |
|
97 if (mService->asyncAnswer()) { |
|
98 connect(mService, SIGNAL(returnValueDelivered()), qApp, SLOT(quit())); |
|
99 mService->complete(mNumber->text()); |
|
100 } |
|
101 else { |
|
102 qApp->quit(); |
|
103 } |
|
104 } |
|
105 |
|
106 void ServiceApp::endCall() |
|
107 { |
|
108 //QVBoxLayout *vl = qobject_cast<QVBoxLayout *>(layout()) ; |
|
109 //vl->removeWidget(mEndCallButton); |
|
110 |
|
111 //XQServiceUtil::toBackground(true); |
|
112 } |
|
113 |
|
114 void ServiceApp::setLabelNumber(QString label,QString number) |
|
115 { |
|
116 //QVBoxLayout *vl = qobject_cast<QVBoxLayout *>(layout()) ; |
|
117 //vl->insertWidget(1,mEndCallButton); |
|
118 mLabel->setText(label); |
|
119 mNumber->setText(number); |
|
120 } |
|
121 |
|
122 |
|
123 DialerService::DialerService(ServiceApp* parent) |
|
124 : XQServiceProvider(QLatin1String("com.nokia.services.telephony"),parent),mServiceApp(parent) |
|
125 { |
|
126 publishAll(); |
|
127 } |
|
128 |
|
129 DialerService::~DialerService() |
|
130 { |
|
131 } |
|
132 |
|
133 void DialerService::complete(QString number) |
|
134 { |
|
135 completeRequest(0,number.toInt()); |
|
136 } |
|
137 |
|
138 void DialerService::dial(const QString& number) |
|
139 { |
|
140 qDebug() << "DialerService::dial (number):" << number; |
|
141 QString label = "PHONE dialing (number):" ; |
|
142 mServiceApp->setLabelNumber(label,number); |
|
143 } |
|
144 |
|
145 void DialerService::dial(const QString& number, int contactId) |
|
146 { |
|
147 qDebug() << "DialerService::dial to num:" << number << "contactId:" << contactId; |
|
148 QString label = "PHONE dialing (number+contact):" ; |
|
149 QString num; |
|
150 num.append( number ); |
|
151 num.append(" "); |
|
152 QString contactStr; |
|
153 contactStr.setNum(contactId); |
|
154 num.append( contactStr ); |
|
155 mServiceApp->setLabelNumber(label,num); |
|
156 } |
|
157 |
|
158 void DialerService::dialVideo(const QString& number) |
|
159 { |
|
160 qDebug() << "DialerService::dialVideo (number):" << number; |
|
161 QString label = "PHONE dialing video (number):" ; |
|
162 mServiceApp->setLabelNumber(label,number); |
|
163 } |
|
164 |
|
165 void DialerService::dialVideo(const QString& number, int contactId) |
|
166 { |
|
167 qDebug() << "DialerService::dialVideo to num:" << number << "contactId:" << contactId; |
|
168 QString label = "PHONE dialing video (number+contact):" ; |
|
169 QString num; |
|
170 num.append( number ); |
|
171 num.append(" "); |
|
172 QString contactStr; |
|
173 contactStr.setNum(contactId); |
|
174 num.append( contactStr ); |
|
175 mServiceApp->setLabelNumber(label,num); |
|
176 } |