|
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: Base class for URI Scheme parsers. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <QRegExp> |
|
19 #include <pevirtualengine.h> |
|
20 #include "urischemeparser.h" |
|
21 #include "qtphonelog.h" |
|
22 |
|
23 const QString KDtmfPauseChar = "p"; |
|
24 const QString KDtmfWaitChar = "w"; |
|
25 |
|
26 /*! |
|
27 UriSchemeParser::UriSchemeParser. |
|
28 */ |
|
29 UriSchemeParser::UriSchemeParser(QObject* parent) |
|
30 : |
|
31 QObject(parent) |
|
32 { |
|
33 PHONE_DEBUG("UriSchemeParser::UriSchemeParser"); |
|
34 } |
|
35 |
|
36 |
|
37 /*! |
|
38 UriSchemeParser::~UriSchemeParser. |
|
39 */ |
|
40 UriSchemeParser::~UriSchemeParser() |
|
41 { |
|
42 PHONE_DEBUG("UriSchemeParser::~UriSchemeParser"); |
|
43 } |
|
44 |
|
45 |
|
46 /*! |
|
47 UriSchemeParser::parsePhoneDialString. |
|
48 */ |
|
49 bool UriSchemeParser::parsePhoneDialString( |
|
50 const QString &dialString, |
|
51 QString &phoneNumber, |
|
52 QString &dtmfString) const |
|
53 { |
|
54 PHONE_DEBUG("UriSchemeParser::parsePhoneDialString"); |
|
55 |
|
56 bool parsingResult = false; |
|
57 |
|
58 int dialStringLength = dialString.length(); |
|
59 if ((dialStringLength <= 0) || |
|
60 (KPEPhoneNumberMaxLength < dialStringLength)) { |
|
61 parsingResult = false; |
|
62 phoneNumber.clear(); |
|
63 dtmfString.clear(); |
|
64 } else { |
|
65 parsingResult = true; |
|
66 QRegExp dtmfFindExp( |
|
67 QString("[") + KDtmfPauseChar + KDtmfWaitChar + QString("]")); |
|
68 int dtmfPostfixIndex = dialString.indexOf(dtmfFindExp); |
|
69 phoneNumber = dialString.left(dtmfPostfixIndex); |
|
70 if (0 <= dtmfPostfixIndex) { |
|
71 dtmfString = dialString.mid(dtmfPostfixIndex); |
|
72 } |
|
73 } |
|
74 |
|
75 return parsingResult; |
|
76 } |