author | hgs |
Fri, 15 Oct 2010 12:58:46 +0300 | |
changeset 78 | baacf668fe89 |
parent 76 | cfea66083b62 |
permissions | -rw-r--r-- |
37 | 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: Handles phone notes. |
|
15 |
*/ |
|
16 |
||
17 |
#include "phonenotecontroller.h" |
|
65 | 18 |
#include "phoneglobalnotes.h" |
37 | 19 |
#include "tphonecmdparamglobalnote.h" |
20 |
#include "tphonecmdparamquery.h" |
|
21 |
#include "phoneresourceadapter.h" |
|
22 |
#include "qtphonelog.h" |
|
23 |
#include <QSignalMapper> |
|
24 |
#include <QTimer> |
|
25 |
#include <hbmessagebox.h> |
|
26 |
#include <hbprogressdialog.h> |
|
27 |
#include <hbaction.h> |
|
28 |
#include <phoneappcommands.hrh> |
|
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
29 |
#include <hbstringutil.h> |
78 | 30 |
#include <xqsystemtoneservice.h> |
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
31 |
|
78 | 32 |
PhoneNoteController::PhoneNoteController(XQSystemToneService& toneservice, |
33 |
QObject *parent ) : |
|
65 | 34 |
QObject(parent), |
35 |
m_dtmfNote(0), |
|
36 |
m_queryNote(0) |
|
37 | 37 |
{ |
65 | 38 |
PHONE_TRACE |
37 | 39 |
m_signalMapper = new QSignalMapper(this); |
40 |
connect(m_signalMapper, SIGNAL(mapped(int)), this, SIGNAL(command (int))); |
|
78 | 41 |
m_globalNotes = new PhoneGlobalNotes(toneservice, this); |
65 | 42 |
connect(m_globalNotes, SIGNAL(command(int)), this, SIGNAL(command(int))); |
37 | 43 |
} |
44 |
||
45 |
PhoneNoteController::~PhoneNoteController() |
|
46 |
{ |
|
65 | 47 |
PHONE_TRACE |
37 | 48 |
} |
49 |
||
50 |
void PhoneNoteController::showGlobalNote(TPhoneCommandParam *commandParam) |
|
51 |
{ |
|
52 |
Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdGlobalNote); |
|
53 |
||
54 |
TPhoneCmdParamGlobalNote* globalNoteParam = |
|
55 |
static_cast<TPhoneCmdParamGlobalNote*>( commandParam ); |
|
56 |
||
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
57 |
if (globalNoteParam->NotificationDialog()) { |
65 | 58 |
m_globalNotes->showDeviceNotificationDialog(globalNoteParam); |
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
59 |
} else { |
65 | 60 |
m_globalNotes->showDeviceMessageBox(globalNoteParam); |
37 | 61 |
} |
62 |
||
63 |
} |
|
64 |
||
65 |
void PhoneNoteController::showNote(TPhoneCommandParam *commandParam) |
|
66 |
{ |
|
65 | 67 |
PHONE_TRACE |
37 | 68 |
TPhoneCmdParamNote* noteParam = static_cast<TPhoneCmdParamNote*>( |
69 |
commandParam ); |
|
70 |
||
71 |
if ( noteParam->Type() == EPhoneNoteDtmfSending ) { |
|
72 |
showDtmfNote(noteParam); |
|
73 |
} |
|
74 |
||
75 |
} |
|
76 |
||
77 |
void PhoneNoteController::showQuery(TPhoneCommandParam *commandParam) |
|
78 |
{ |
|
65 | 79 |
PHONE_TRACE |
37 | 80 |
TPhoneCmdParamQuery& params = *static_cast<TPhoneCmdParamQuery*>( commandParam ); |
81 |
||
82 |
if ( EPhoneQueryDialog == params.QueryType() && |
|
83 |
params.QueryPrompt().Length() ) { |
|
84 |
showDefaultQuery(¶ms); |
|
85 |
||
86 |
} else if ( EPhoneGlobalWaitNote == params.QueryType() ) { |
|
65 | 87 |
m_globalNotes->showGlobalWaitNote(¶ms); |
37 | 88 |
} |
89 |
} |
|
90 |
||
91 |
void PhoneNoteController::removeDtmfNote() |
|
92 |
{ |
|
65 | 93 |
PHONE_TRACE |
37 | 94 |
if (m_dtmfNote) { |
95 |
m_dtmfNote->close(); |
|
96 |
} |
|
97 |
} |
|
98 |
||
99 |
void PhoneNoteController::removeNote() |
|
100 |
{ |
|
65 | 101 |
PHONE_TRACE |
37 | 102 |
removeDtmfNote(); |
103 |
} |
|
104 |
||
105 |
void PhoneNoteController::removeQuery() |
|
106 |
{ |
|
65 | 107 |
PHONE_TRACE |
37 | 108 |
if (m_queryNote) { |
109 |
m_queryNote->close(); |
|
110 |
} |
|
111 |
} |
|
112 |
||
113 |
void PhoneNoteController::removeGlobalWaitNote() |
|
114 |
{ |
|
65 | 115 |
PHONE_TRACE |
116 |
m_globalNotes->removeGlobalWaitNote(); |
|
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
117 |
} |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
118 |
|
37 | 119 |
void PhoneNoteController::removeMappings() |
120 |
{ |
|
65 | 121 |
PHONE_TRACE |
37 | 122 |
foreach (HbAction *action, m_actions ) { |
123 |
m_signalMapper->removeMappings(action); |
|
124 |
} |
|
125 |
m_actions.clear(); |
|
126 |
||
127 |
if (m_dtmfNote) { |
|
128 |
m_dtmfNote->deleteLater(); |
|
129 |
m_dtmfNote = 0; |
|
130 |
} |
|
131 |
if (m_queryNote) { |
|
132 |
m_queryNote->deleteLater(); |
|
133 |
m_queryNote = 0; |
|
134 |
} |
|
135 |
} |
|
136 |
||
137 |
void PhoneNoteController::showDtmfNote(TPhoneCmdParamNote* noteParam) |
|
65 | 138 |
{ |
139 |
PHONE_TRACE |
|
37 | 140 |
if (m_dtmfNote) { |
141 |
m_dtmfNote->setText( QString::fromUtf16(noteParam->Text().Ptr(), |
|
142 |
noteParam->Text().Length()) ); |
|
143 |
m_dtmfNote->update(); |
|
144 |
} else { |
|
145 |
QList<HbAction*> hbactions = PhoneResourceAdapter::Instance()-> |
|
146 |
convertToHbActions(noteParam->ResourceId()); |
|
147 |
||
148 |
if (hbactions.count() > 0) { |
|
149 |
m_dtmfNote = new HbProgressDialog(HbProgressDialog::ProgressDialog); |
|
65 | 150 |
m_dtmfNote->setParent(this); |
37 | 151 |
m_dtmfNote->setText( QString::fromUtf16(noteParam->Text().Ptr(), |
152 |
noteParam->Text().Length()) ); |
|
153 |
||
154 |
QObject::connect(m_dtmfNote, SIGNAL(aboutToClose()), |
|
155 |
this, SLOT(removeMappings())); |
|
156 |
||
76 | 157 |
// Do not delete old actions, progress dialog has |
158 |
// the ownership for the actions. |
|
159 |
replaceDialogActions(m_dtmfNote, hbactions, false); |
|
37 | 160 |
|
161 |
m_dtmfNote->show(); |
|
162 |
} |
|
163 |
} |
|
164 |
} |
|
165 |
||
166 |
void PhoneNoteController::showDefaultQuery(TPhoneCmdParamQuery* params) |
|
65 | 167 |
{ |
168 |
PHONE_TRACE |
|
37 | 169 |
if (!m_queryNote) { |
170 |
QList<HbAction*> hbactions = PhoneResourceAdapter::Instance()-> |
|
171 |
convertToHbActions(params->QueryResourceId()); |
|
172 |
||
173 |
if (hbactions.count() > 0) { |
|
174 |
m_queryNote = new HbMessageBox(HbMessageBox::MessageTypeQuestion); |
|
65 | 175 |
m_queryNote->setParent(this); |
37 | 176 |
m_queryNote->setTimeout(HbPopup::NoTimeout); |
177 |
m_queryNote->setDismissPolicy(HbPopup::NoDismiss); |
|
178 |
m_queryNote->setText(QString::fromUtf16(params->QueryPrompt().Ptr(), |
|
179 |
params->QueryPrompt().Length())); |
|
180 |
||
181 |
QObject::connect(m_queryNote, SIGNAL(aboutToClose()), |
|
182 |
this, SLOT(removeMappings())); |
|
183 |
||
65 | 184 |
replaceDialogActions(m_queryNote, hbactions); |
37 | 185 |
|
186 |
m_queryNote->show(); |
|
187 |
} |
|
188 |
} |
|
189 |
} |
|
190 |
||
65 | 191 |
void PhoneNoteController::replaceDialogActions( |
76 | 192 |
HbDialog *dialog, |
193 |
QList<HbAction *> &actions, |
|
194 |
bool deleteOldActions) |
|
65 | 195 |
{ |
196 |
PHONE_TRACE |
|
197 |
// Remove default actions |
|
198 |
foreach (QAction *action, dialog->actions()) { |
|
199 |
dialog->removeAction(action); |
|
76 | 200 |
if (deleteOldActions) { |
201 |
delete action; |
|
202 |
} |
|
65 | 203 |
} |
204 |
||
205 |
// Add new actions |
|
206 |
foreach (HbAction *newAction, actions) { |
|
76 | 207 |
newAction->setParent(dialog); |
65 | 208 |
connect(newAction, SIGNAL(triggered()), m_signalMapper, SLOT(map())); |
209 |
m_signalMapper->setMapping(newAction, newAction->data().toInt()); |
|
210 |
m_actions.append(newAction); |
|
211 |
dialog->addAction(newAction); |
|
37 | 212 |
} |
213 |
} |
|
214 |