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