1 /* |
|
2 * Copyright (c) 2010 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 |
|
19 // INCLUDE FILES |
|
20 #include <hbinputeditorinterface.h> |
|
21 #include <hbaction.h> |
|
22 #include <hbinputstandardfilters.h> |
|
23 #include <hbinputfilter.h> |
|
24 #include <hbinputstate.h> |
|
25 #include <hbinputvkbhost.h> |
|
26 #include <hbapplication.h> |
|
27 #include <cphcltussdint.h> |
|
28 |
|
29 #include "tflogger.h" |
|
30 #include "ussdcomms.h" |
|
31 #include "ussdeditorquery.h" |
|
32 |
|
33 // CONSTANTS |
|
34 // The maximum number of editor lines method NumberOfEditorLines can return. |
|
35 const TInt KUssdMaxNumberOfEditorLines = 16; |
|
36 // The maximum length of editor lines. |
|
37 const TInt KUssdEditorMaxLength = 182; |
|
38 |
|
39 // ============================ MEMBER FUNCTIONS =============================== |
|
40 // ----------------------------------------------------------------------------- |
|
41 // UssdEditorQuery::UssdEditorQuery |
|
42 // Constructor. |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 UssdEditorQuery::UssdEditorQuery(CUssdComms &ussd, QGraphicsItem *parent) |
|
46 :HbInputDialog(parent), mComms(ussd) |
|
47 { |
|
48 TFLOGSTRING("USSDEDITOR: UssdEditorQuery::UssdEditorQuery IN") |
|
49 setPromptText(hbTrId("Reply")); |
|
50 |
|
51 if (lineEdit()){ |
|
52 // Set max length and rows |
|
53 lineEdit()->setMaxLength(KUssdEditorMaxLength); |
|
54 lineEdit()->setMaxRows(KUssdMaxNumberOfEditorLines); |
|
55 lineEdit()->setText(QString()); |
|
56 |
|
57 // 0-9, *, +, # |
|
58 HbEditorInterface interface(lineEdit()); |
|
59 interface.setFilter(HbPhoneNumberFilter::instance()); |
|
60 // TODO: cannot open keypad |
|
61 interface.vkbHost()->openKeypad(); |
|
62 |
|
63 mComms.appStarting(); |
|
64 // Disable Ok key by default |
|
65 primaryAction()->setEnabled(false); |
|
66 |
|
67 bool ret(false); |
|
68 ret = connect(primaryAction(), SIGNAL(triggered(bool)), |
|
69 this, SLOT(sendUssdString())); |
|
70 TFLOGSTRING2("USSDEDITOR: UssdEditorQuery::UssdEditorQuery \ |
|
71 connect send %d", ret); |
|
72 |
|
73 ret = connect(lineEdit(), SIGNAL(textChanged(QString)), |
|
74 this, SLOT(updateButtonVisible(QString))); |
|
75 TFLOGSTRING2("USSDEDITOR: UssdEditorQuery::UssdEditorQuery \ |
|
76 connect ok button %d", ret); |
|
77 |
|
78 // Connect cancel |
|
79 ret = connect(secondaryAction(), SIGNAL(triggered(bool)), |
|
80 this, SLOT(cancelUssdString())); |
|
81 TFLOGSTRING2("USSDEDITOR: UssdEditorQuery::UssdEditorQuery \ |
|
82 connect send %d", ret); |
|
83 } |
|
84 TFLOGSTRING("USSDEDITOR: UssdEditorQuery::UssdEditorQuery OUT") |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // UssdEditorQuery::~UssdEditorQuery |
|
89 // ~UssdEditorQuery. |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 UssdEditorQuery::~UssdEditorQuery() |
|
93 { |
|
94 TFLOGSTRING("USSDEDITOR: UssdEditorQuery::~UssdEditorQuery IN-OUT") |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // UssdEditorQuery::sendUssdString |
|
99 // sendUssdString. |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 void UssdEditorQuery::sendUssdString() |
|
103 { |
|
104 TFLOGSTRING("USSDEDITOR: UssdEditorQuery::sendUssdString IN"); |
|
105 if (lineEdit() && |
|
106 0 < lineEdit()->text().length() && |
|
107 KUssdEditorMaxLength >= lineEdit()->text().length()) { |
|
108 int ret = mComms.send(lineEdit()->text()); |
|
109 TFLOGSTRING2("USSDEDITOR: UssdEditorQuery::sendUssdString %d", ret); |
|
110 mComms.informExitReason(static_cast<int>(EPhCltSendCompleted)); |
|
111 } |
|
112 TFLOGSTRING("USSDEDITOR: UssdEditorQuery::sendUssdString OUT"); |
|
113 HbApplication::quit(); |
|
114 } |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // UssdEditorQuery::cancelUssdString |
|
118 // cancelUssdString. |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 void UssdEditorQuery::cancelUssdString() |
|
122 { |
|
123 TFLOGSTRING("USSDEDITOR: UssdEditorQuery::cancelUssdString IN-OUT"); |
|
124 mComms.informExitReason((EPhCltUserExit)); |
|
125 HbApplication::quit(); |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // UssdEditorQuery::updateButtonVisible |
|
130 // updateButtonVisible. |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 void UssdEditorQuery::updateButtonVisible( const QString &text ) |
|
134 { |
|
135 TFLOGSTRING("USSDEDITOR: UssdEditorQuery::updateButtonVisible IN"); |
|
136 if (text.length() > 0) { |
|
137 primaryAction()->setEnabled(true); |
|
138 } else { |
|
139 primaryAction()->setEnabled(false); |
|
140 } |
|
141 TFLOGSTRING("USSDEDITOR: UssdEditorQuery::updateOkButton OUT"); |
|
142 } |
|
143 |
|
144 // End of file |
|