author | hgs |
Mon, 04 Oct 2010 16:06:10 +0300 | |
changeset 76 | cfea66083b62 |
parent 65 | 2a5d4ab426d3 |
child 78 | baacf668fe89 |
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> |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
30 |
|
37 | 31 |
PhoneNoteController::PhoneNoteController(QObject *parent) : |
65 | 32 |
QObject(parent), |
33 |
m_dtmfNote(0), |
|
34 |
m_queryNote(0) |
|
37 | 35 |
{ |
65 | 36 |
PHONE_TRACE |
37 | 37 |
m_signalMapper = new QSignalMapper(this); |
38 |
connect(m_signalMapper, SIGNAL(mapped(int)), this, SIGNAL(command (int))); |
|
65 | 39 |
m_globalNotes = new PhoneGlobalNotes(this); |
40 |
connect(m_globalNotes, SIGNAL(command(int)), this, SIGNAL(command(int))); |
|
37 | 41 |
} |
42 |
||
43 |
PhoneNoteController::~PhoneNoteController() |
|
44 |
{ |
|
65 | 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()) { |
65 | 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 { |
65 | 58 |
m_globalNotes->showDeviceMessageBox(globalNoteParam); |
37 | 59 |
} |
60 |
||
61 |
} |
|
62 |
||
63 |
void PhoneNoteController::showNote(TPhoneCommandParam *commandParam) |
|
64 |
{ |
|
65 | 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 |
{ |
|
65 | 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() ) { |
|
65 | 85 |
m_globalNotes->showGlobalWaitNote(¶ms); |
37 | 86 |
} |
87 |
} |
|
88 |
||
89 |
void PhoneNoteController::removeDtmfNote() |
|
90 |
{ |
|
65 | 91 |
PHONE_TRACE |
37 | 92 |
if (m_dtmfNote) { |
93 |
m_dtmfNote->close(); |
|
94 |
} |
|
95 |
} |
|
96 |
||
97 |
void PhoneNoteController::removeNote() |
|
98 |
{ |
|
65 | 99 |
PHONE_TRACE |
37 | 100 |
removeDtmfNote(); |
101 |
} |
|
102 |
||
103 |
void PhoneNoteController::removeQuery() |
|
104 |
{ |
|
65 | 105 |
PHONE_TRACE |
37 | 106 |
if (m_queryNote) { |
107 |
m_queryNote->close(); |
|
108 |
} |
|
109 |
} |
|
110 |
||
111 |
void PhoneNoteController::removeGlobalWaitNote() |
|
112 |
{ |
|
65 | 113 |
PHONE_TRACE |
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 |
{ |
|
65 | 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) |
|
65 | 136 |
{ |
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); |
|
65 | 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 |
||
76 | 155 |
// Do not delete old actions, progress dialog has |
156 |
// the ownership for the actions. |
|
157 |
replaceDialogActions(m_dtmfNote, hbactions, false); |
|
37 | 158 |
|
159 |
m_dtmfNote->show(); |
|
160 |
} |
|
161 |
} |
|
162 |
} |
|
163 |
||
164 |
void PhoneNoteController::showDefaultQuery(TPhoneCmdParamQuery* params) |
|
65 | 165 |
{ |
166 |
PHONE_TRACE |
|
37 | 167 |
if (!m_queryNote) { |
168 |
QList<HbAction*> hbactions = PhoneResourceAdapter::Instance()-> |
|
169 |
convertToHbActions(params->QueryResourceId()); |
|
170 |
||
171 |
if (hbactions.count() > 0) { |
|
172 |
m_queryNote = new HbMessageBox(HbMessageBox::MessageTypeQuestion); |
|
65 | 173 |
m_queryNote->setParent(this); |
37 | 174 |
m_queryNote->setTimeout(HbPopup::NoTimeout); |
175 |
m_queryNote->setDismissPolicy(HbPopup::NoDismiss); |
|
176 |
m_queryNote->setText(QString::fromUtf16(params->QueryPrompt().Ptr(), |
|
177 |
params->QueryPrompt().Length())); |
|
178 |
||
179 |
QObject::connect(m_queryNote, SIGNAL(aboutToClose()), |
|
180 |
this, SLOT(removeMappings())); |
|
181 |
||
65 | 182 |
replaceDialogActions(m_queryNote, hbactions); |
37 | 183 |
|
184 |
m_queryNote->show(); |
|
185 |
} |
|
186 |
} |
|
187 |
} |
|
188 |
||
65 | 189 |
void PhoneNoteController::replaceDialogActions( |
76 | 190 |
HbDialog *dialog, |
191 |
QList<HbAction *> &actions, |
|
192 |
bool deleteOldActions) |
|
65 | 193 |
{ |
194 |
PHONE_TRACE |
|
195 |
// Remove default actions |
|
196 |
foreach (QAction *action, dialog->actions()) { |
|
197 |
dialog->removeAction(action); |
|
76 | 198 |
if (deleteOldActions) { |
199 |
delete action; |
|
200 |
} |
|
65 | 201 |
} |
202 |
||
203 |
// Add new actions |
|
204 |
foreach (HbAction *newAction, actions) { |
|
76 | 205 |
newAction->setParent(dialog); |
65 | 206 |
connect(newAction, SIGNAL(triggered()), m_signalMapper, SLOT(map())); |
207 |
m_signalMapper->setMapping(newAction, newAction->data().toInt()); |
|
208 |
m_actions.append(newAction); |
|
209 |
dialog->addAction(newAction); |
|
37 | 210 |
} |
211 |
} |
|
212 |