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 #include <QTimer> |
|
18 #include <QKeyEvent> |
|
19 #include <hblineedit.h> |
|
20 #include <hbstringutil.h> |
|
21 #include "dialpadmailboxeventfilterbase.h" |
|
22 #include "dialpadsymbianwrapper.h" |
|
23 #include "dialpad.h" |
|
24 #include "qtphonesrvlog.h" |
|
25 |
|
26 #ifdef Q_OS_SYMBIAN |
|
27 #include <xqservicerequest.h> |
|
28 #include <xqserviceutil.h> |
|
29 #endif //Q_OS_SYMBIAN |
|
30 |
|
31 const int DialpadLongKeyPressButtonCount(3); |
|
32 static const int DialpadLongKeyPressSupportingButtons[DialpadLongKeyPressButtonCount] = |
|
33 { Qt::Key_1, Qt::Key_2, Qt::Key_NumberSign }; |
|
34 |
|
35 |
|
36 DialpadMailboxEventFilterBase::DialpadMailboxEventFilterBase(Dialpad* dialpad, QObject* parent) : |
|
37 QObject(parent), mDialpad(dialpad), mKeyEvent(NULL) |
|
38 { |
|
39 PHONE_TRACE; |
|
40 mLongPressTimer = new QTimer(this); |
|
41 mLongPressTimer->setSingleShot(true); |
|
42 connect(mLongPressTimer,SIGNAL(timeout()),this,SLOT(handleLongKeyPress())); |
|
43 mSymbianWrapper = new DialpadSymbianWrapper(this); |
|
44 } |
|
45 |
|
46 DialpadMailboxEventFilterBase::~DialpadMailboxEventFilterBase() |
|
47 { |
|
48 } |
|
49 |
|
50 bool DialpadMailboxEventFilterBase::checkIfSendEventAndConsumeEvent(const int pressedKey, const int eventType) |
|
51 { |
|
52 PHONE_TRACE4("pressedKey:", pressedKey, "eventType:", eventType); |
|
53 bool sendKeyHandled(false); |
|
54 // first check that pressed key is send key. |
|
55 if (pressedKey == Qt::Key_Yes || |
|
56 pressedKey == Qt::Key_Enter) { |
|
57 if (eventType == QEvent::KeyPress) { |
|
58 sendKeyHandled = handleCallButtonPress(); |
|
59 } else if ((eventType == QEvent::KeyRelease) && |
|
60 (!mDialpad->editor().text().isEmpty())) { |
|
61 sendKeyHandled = true; |
|
62 } |
|
63 } |
|
64 return sendKeyHandled; |
|
65 } |
|
66 |
|
67 bool DialpadMailboxEventFilterBase::isLongKeyPressSupported(const int key) |
|
68 { |
|
69 PHONE_TRACE2("key:", key); |
|
70 bool longKeySupport(false); |
|
71 // check if dialpad button is pressed. |
|
72 for (int i = 0; i < DialpadLongKeyPressButtonCount; i++) { |
|
73 if (key==DialpadLongKeyPressSupportingButtons[i]) { |
|
74 longKeySupport = true; |
|
75 // Save key code for handleCallButtonPress. |
|
76 mKeyEvent = key; |
|
77 } |
|
78 } |
|
79 return longKeySupport; |
|
80 } |
|
81 |
|
82 void DialpadMailboxEventFilterBase::clearEditor() |
|
83 { |
|
84 PHONE_TRACE; |
|
85 // Erase data from dialpad editor. |
|
86 mDialpad->editor().setText(QString("")); |
|
87 } |
|
88 |
|
89 void DialpadMailboxEventFilterBase::createCall(const QString &phoneNumber, bool createVideoCall) |
|
90 { |
|
91 PHONE_TRACE2("phoneNumber:", phoneNumber); |
|
92 #ifdef Q_OS_SYMBIAN |
|
93 if(createVideoCall) { |
|
94 XQServiceRequest snd("com.nokia.symbian.ICallDial","dialVideo(QString)", false); |
|
95 snd << phoneNumber; |
|
96 QVariant retValue; |
|
97 snd.send(retValue); |
|
98 } else { |
|
99 XQServiceRequest snd("com.nokia.symbian.ICallDial","dial(QString)", false); |
|
100 snd << phoneNumber; |
|
101 QVariant retValue; |
|
102 snd.send(retValue); |
|
103 } |
|
104 #endif // Q_OS_SYMBIAN |
|
105 } |
|