|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "LcConfiguration.h" |
|
19 #include <stdio.h> |
|
20 |
|
21 // File name |
|
22 const char fileName[] = "c:\\data\\lcconfig.xml"; |
|
23 |
|
24 // XML configuration elements |
|
25 const char setupElement[] = "setup"; |
|
26 const char timerElement[] = "timer"; |
|
27 |
|
28 // XML configuration attriputes |
|
29 const char layoutAttr[] = "layout"; |
|
30 const char sessionNameAttr[] = "sessionname"; |
|
31 const char phoneNoAttr[] = "phoneno"; |
|
32 const char remoteAttr[] = "remote"; |
|
33 const char durationAttr[] = "duration"; |
|
34 |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // LcConfiguration::LcConfiguration |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 LcConfiguration::LcConfiguration() |
|
41 :mLayout(5), |
|
42 mSessionTitle(QString::fromAscii("Homer Simpson")), |
|
43 mRecipient(QString::fromAscii("sip:march@simpsons.com")), |
|
44 mPhoneNumber(QString::fromAscii("+35850898282")), |
|
45 mTimerDuration(4*1000) |
|
46 { |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // LcConfiguration::LcConfiguration |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 LcConfiguration::~LcConfiguration() |
|
54 { |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // TestResultXmlParser::parse |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 int LcConfiguration::parse() |
|
62 { |
|
63 QFile file(fileName); |
|
64 QXmlInputSource inputSource(&file); |
|
65 QXmlSimpleReader reader; |
|
66 reader.setContentHandler(this); |
|
67 return reader.parse(inputSource); |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // LcConfiguration::startElement |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 bool LcConfiguration::startElement( |
|
75 const QString& /*namespaceURI*/, |
|
76 const QString& /*localName*/, |
|
77 const QString& qName, |
|
78 const QXmlAttributes& atts) |
|
79 { |
|
80 if( qName == setupElement) { |
|
81 mLayout = atts.value(layoutAttr).toInt(); |
|
82 mSessionTitle = atts.value(sessionNameAttr); |
|
83 mRecipient = atts.value(phoneNoAttr); |
|
84 mPhoneNumber = atts.value(durationAttr); |
|
85 } |
|
86 else if (qName == timerElement) { |
|
87 mTimerDuration = atts.value(durationAttr).toInt()*1000;// ms to s |
|
88 } |
|
89 return true; |
|
90 } |
|
91 |
|
92 // End of File. |