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 * STUB: EAPWIZARD: EAP method QT configuration |
|
16 * |
|
17 */ |
|
18 |
|
19 /* |
|
20 * %version: 3 % |
|
21 */ |
|
22 |
|
23 #include "eapqtconfig.h" |
|
24 #include <eapqtpluginhandle.h> |
|
25 #include "eapqtcertificateinfo.h" |
|
26 #include <QDebug> |
|
27 |
|
28 //---------------------------------------------------------------------------- |
|
29 // EapQtConfig |
|
30 //---------------------------------------------------------------------------- |
|
31 |
|
32 EapQtConfig::EapQtConfig() |
|
33 { |
|
34 } |
|
35 |
|
36 EapQtConfig::EapQtConfig(const EapQtConfig &other) |
|
37 { |
|
38 mSettings = other.mSettings; |
|
39 } |
|
40 |
|
41 EapQtConfig::~EapQtConfig() |
|
42 { |
|
43 // scoped pointer deleted automatically |
|
44 } |
|
45 |
|
46 QVariant EapQtConfig::value(SettingsId id) |
|
47 { |
|
48 // check for valid range, otherwise memory is consumed for no reason |
|
49 if(id >= SettingsIdLast) { |
|
50 qDebug("ERROR: EapQtConfig::value - invalid id!"); |
|
51 return QVariant::Invalid; |
|
52 } |
|
53 return mSettings[id]; |
|
54 } |
|
55 |
|
56 void EapQtConfig::setValue(SettingsId id, QVariant newValue) |
|
57 { |
|
58 // check for valid range, otherwise memory is consumed for no reason |
|
59 if(id < SettingsIdLast) { |
|
60 mSettings[id] = newValue; |
|
61 } else { |
|
62 qDebug("ERROR: EapQtConfig::setValue - invalid id!"); |
|
63 } |
|
64 return; |
|
65 } |
|
66 |
|
67 void EapQtConfig::clear() { |
|
68 mSettings.clear(); |
|
69 return; |
|
70 } |
|
71 |
|
72 QList<EapQtConfig::SettingsId> EapQtConfig::validate( |
|
73 QList<EapQtConfig::SettingsId> ids) |
|
74 { |
|
75 Q_UNUSED(ids); |
|
76 return QList<EapQtConfig::SettingsId>(); |
|
77 } |
|
78 |
|
79 bool EapQtConfig::operator==(const EapQtConfig & rhs ) const |
|
80 { |
|
81 bool ret = true; |
|
82 if (mSettings.size() != rhs.mSettings.size()) { |
|
83 qWarning("EapQtConfig::operator==(): size: expect %d, actual %d ", |
|
84 mSettings.size(), |
|
85 rhs.mSettings.size() ); |
|
86 ret = false; |
|
87 } |
|
88 QHashIterator<int, QVariant> i(mSettings); |
|
89 |
|
90 while (i.hasNext()) { |
|
91 i.next(); |
|
92 if (!rhs.mSettings.contains(i.key())){ |
|
93 qWarning("EapQtConfig::operator==(): key not found: %d", i.key()); |
|
94 ret = false; |
|
95 |
|
96 } |
|
97 if (i.key() == EapQtConfig::InnerType) { |
|
98 QList<QVariant> list1(mSettings[i.key()].toList()); |
|
99 QList<QVariant> list2(rhs.mSettings[i.key()].toList()); |
|
100 |
|
101 if (list1.length() != 1 || list1.length() != list2.length()){ |
|
102 qWarning("Invalid length in EapQtConfig::InnerType"); |
|
103 ret = false; |
|
104 } else { |
|
105 EapQtPluginHandle handle1 = list1.at(0).value<EapQtPluginHandle> (); |
|
106 EapQtPluginHandle handle2 = list2.at(0).value<EapQtPluginHandle> (); |
|
107 if (handle1.pluginId() != handle2.pluginId()){ |
|
108 qWarning("Outer: %d", handle1.pluginId()); |
|
109 qWarning("Outer: %d", handle2.pluginId()); |
|
110 ret = false; |
|
111 } |
|
112 } |
|
113 } |
|
114 else if (i.key() == EapQtConfig::OuterType) { |
|
115 EapQtPluginHandle handle = mSettings[i.key()].value<EapQtPluginHandle> (); |
|
116 EapQtPluginHandle handle2 = rhs.mSettings[i.key()].value<EapQtPluginHandle> (); |
|
117 if (handle.pluginId() != handle2.pluginId()){ |
|
118 qWarning("Outer: %d", handle.pluginId()); |
|
119 qWarning("Outer: %d", handle2.pluginId()); |
|
120 ret = false; |
|
121 } |
|
122 } |
|
123 else if (i.key() == EapQtConfig::AuthorityCertificate || |
|
124 i.key() == EapQtConfig::UserCertificate) { |
|
125 QList<QVariant> list1(mSettings[i.key()].toList()); |
|
126 QList<QVariant> list2(rhs.mSettings[i.key()].toList()); |
|
127 |
|
128 if (list1.length() != 1 || list1.length() != list2.length()) { |
|
129 qWarning("Invalid length Certs %d", i.key()); |
|
130 ret = false; |
|
131 } else { |
|
132 EapQtCertificateInfo cert1 = list1.at(0).value<EapQtCertificateInfo>(); |
|
133 EapQtCertificateInfo cert2 = list2.at(0).value<EapQtCertificateInfo>(); |
|
134 |
|
135 if (!(cert1 == cert2)) { |
|
136 ret = false; |
|
137 qWarning("Invalid certs %d", i.key()); |
|
138 } |
|
139 } |
|
140 } |
|
141 else { |
|
142 if (i.value() != rhs.mSettings[i.key()]){ |
|
143 qWarning("EapQtConfig::operator==(): values does not match %d", i.key()); |
|
144 qDebug() << "Expect: " << i.value(); |
|
145 qDebug() << "Actual: " << rhs.mSettings[i.key()]; |
|
146 ret = false; |
|
147 } |
|
148 } |
|
149 } |
|
150 return ret; |
|
151 } |
|
152 |
|
153 |
|