author | ulf69 <ulf69> | 2004-09-28 21:32:21 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-09-28 21:32:21 (UTC) |
commit | 551a0bb353c7ffff4b307956a7cc7a023bf36863 (patch) (unidiff) | |
tree | 99a2f40f6c510f8ea2f482d481f2051bd9f2227d | |
parent | 57c00cdf5002e90603e0e1cfb5ac5c2c8bf19fe7 (diff) | |
download | kdepimpi-551a0bb353c7ffff4b307956a7cc7a023bf36863.zip kdepimpi-551a0bb353c7ffff4b307956a7cc7a023bf36863.tar.gz kdepimpi-551a0bb353c7ffff4b307956a7cc7a023bf36863.tar.bz2 |
fixed a potential crash when loading adresses from any adressbook file.
-rw-r--r-- | kabc/vcard/ContentLine.cpp | 10 | ||||
-rw-r--r-- | kabc/vcard/VCardv.cpp | 12 | ||||
-rw-r--r-- | kabc/vcard/include/VCardDefines.h | 3 | ||||
-rw-r--r-- | kabc/vcardformatimpl.cpp | 2 |
4 files changed, 20 insertions, 7 deletions
diff --git a/kabc/vcard/ContentLine.cpp b/kabc/vcard/ContentLine.cpp index 0fb5b5d..f7e04a9 100644 --- a/kabc/vcard/ContentLine.cpp +++ b/kabc/vcard/ContentLine.cpp | |||
@@ -1,196 +1,202 @@ | |||
1 | /* | 1 | /* |
2 | libvcard - vCard parsing library for vCard version 3.0 | 2 | libvcard - vCard parsing library for vCard version 3.0 |
3 | 3 | ||
4 | Copyright (C) 1999 Rik Hemsley rik@kde.org | 4 | Copyright (C) 1999 Rik Hemsley rik@kde.org |
5 | 5 | ||
6 | Permission is hereby granted, free of charge, to any person obtaining a copy | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy |
7 | of this software and associated documentation files (the "Software"), to | 7 | of this software and associated documentation files (the "Software"), to |
8 | deal in the Software without restriction, including without limitation the | 8 | deal in the Software without restriction, including without limitation the |
9 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | 9 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
10 | sell copies of the Software, and to permit persons to whom the Software is | 10 | sell copies of the Software, and to permit persons to whom the Software is |
11 | furnished to do so, subject to the following conditions: | 11 | furnished to do so, subject to the following conditions: |
12 | 12 | ||
13 | The above copyright notice and this permission notice shall be included in | 13 | The above copyright notice and this permission notice shall be included in |
14 | all copies or substantial portions of the Software. | 14 | all copies or substantial portions of the Software. |
15 | 15 | ||
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
19 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | 19 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
20 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | 20 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qcstring.h> | 24 | #include <qcstring.h> |
25 | #include <qstrlist.h> | 25 | #include <qstrlist.h> |
26 | #include <qregexp.h> | 26 | #include <qregexp.h> |
27 | 27 | ||
28 | #include <kdebug.h> | 28 | #include <kdebug.h> |
29 | 29 | ||
30 | #include <VCardAdrParam.h> | 30 | #include <VCardAdrParam.h> |
31 | #include <VCardAgentParam.h> | 31 | #include <VCardAgentParam.h> |
32 | #include <VCardDateParam.h> | 32 | #include <VCardDateParam.h> |
33 | #include <VCardEmailParam.h> | 33 | #include <VCardEmailParam.h> |
34 | #include <VCardImageParam.h> | 34 | #include <VCardImageParam.h> |
35 | #include <VCardSourceParam.h> | 35 | #include <VCardSourceParam.h> |
36 | #include <VCardTelParam.h> | 36 | #include <VCardTelParam.h> |
37 | #include <VCardTextBinParam.h> | 37 | #include <VCardTextBinParam.h> |
38 | #include <VCardTextParam.h> | 38 | #include <VCardTextParam.h> |
39 | 39 | ||
40 | #include <VCardAdrValue.h> | 40 | #include <VCardAdrValue.h> |
41 | #include <VCardAgentValue.h> | 41 | #include <VCardAgentValue.h> |
42 | #include <VCardDateValue.h> | 42 | #include <VCardDateValue.h> |
43 | #include <VCardImageValue.h> | 43 | #include <VCardImageValue.h> |
44 | #include <VCardTextValue.h> | 44 | #include <VCardTextValue.h> |
45 | #include <VCardTextBinValue.h> | 45 | #include <VCardTextBinValue.h> |
46 | #include <VCardLangValue.h> | 46 | #include <VCardLangValue.h> |
47 | #include <VCardNValue.h> | 47 | #include <VCardNValue.h> |
48 | #include <VCardURIValue.h> | 48 | #include <VCardURIValue.h> |
49 | #include <VCardSoundValue.h> | 49 | #include <VCardSoundValue.h> |
50 | #include <VCardClassValue.h> | 50 | #include <VCardClassValue.h> |
51 | #include <VCardFloatValue.h> | 51 | #include <VCardFloatValue.h> |
52 | #include <VCardOrgValue.h> | 52 | #include <VCardOrgValue.h> |
53 | #include <VCardTelValue.h> | 53 | #include <VCardTelValue.h> |
54 | #include <VCardTextListValue.h> | 54 | #include <VCardTextListValue.h> |
55 | #include <VCardUTCValue.h> | 55 | #include <VCardUTCValue.h> |
56 | #include <VCardGeoValue.h> | 56 | #include <VCardGeoValue.h> |
57 | 57 | ||
58 | #include <VCardRToken.h> | 58 | #include <VCardRToken.h> |
59 | #include <VCardContentLine.h> | 59 | #include <VCardContentLine.h> |
60 | 60 | ||
61 | #include <VCardEntity.h> | 61 | #include <VCardEntity.h> |
62 | #include <VCardEnum.h> | 62 | #include <VCardEnum.h> |
63 | #include <VCardDefines.h> | 63 | #include <VCardDefines.h> |
64 | 64 | ||
65 | using namespace VCARD; | 65 | using namespace VCARD; |
66 | 66 | ||
67 | ContentLine::ContentLine() | 67 | ContentLine::ContentLine() |
68 | :Entity(), | 68 | :Entity(), |
69 | value_(0) | 69 | value_(0), |
70 | paramType_( ParamUnknown ), | ||
71 | valueType_( ValueUnknown ), | ||
72 | entityType_( EntityUnknown ) | ||
70 | { | 73 | { |
71 | paramList_.setAutoDelete( TRUE ); | 74 | paramList_.setAutoDelete( TRUE ); |
72 | } | 75 | } |
73 | 76 | ||
74 | ContentLine::ContentLine(const ContentLine & x) | 77 | ContentLine::ContentLine(const ContentLine & x) |
75 | :Entity(x), | 78 | :Entity(x), |
76 | group_ (x.group_), | 79 | group_ (x.group_), |
77 | name_ (x.name_), | 80 | name_ (x.name_), |
78 | /*US paramList_(x.paramList_),*/ | 81 | /*US paramList_(x.paramList_),*/ |
79 | value_(x.value_->clone()), | 82 | value_(x.value_->clone()), |
80 | paramType_(x.paramType_), | 83 | paramType_(x.paramType_), |
81 | valueType_(x.valueType_), | 84 | valueType_(x.valueType_), |
82 | entityType_(x.entityType_) | 85 | entityType_(x.entityType_) |
83 | { | 86 | { |
84 | paramList_.setAutoDelete( TRUE ); | 87 | paramList_.setAutoDelete( TRUE ); |
85 | 88 | ||
86 | 89 | ||
87 | ParamListIterator it(x.paramList_); | 90 | ParamListIterator it(x.paramList_); |
88 | for (; it.current(); ++it) | 91 | for (; it.current(); ++it) |
89 | { | 92 | { |
90 | Param *p = new Param; | 93 | Param *p = new Param; |
91 | p->setName( it.current()->name() ); | 94 | p->setName( it.current()->name() ); |
92 | p->setValue( it.current()->value() ); | 95 | p->setValue( it.current()->value() ); |
93 | paramList_.append(p); | 96 | paramList_.append(p); |
94 | } | 97 | } |
95 | 98 | ||
96 | } | 99 | } |
97 | 100 | ||
98 | ContentLine::ContentLine(const QCString & s) | 101 | ContentLine::ContentLine(const QCString & s) |
99 | :Entity(s), | 102 | :Entity(s), |
100 | value_(0) | 103 | value_(0), |
104 | paramType_( ParamUnknown ), | ||
105 | valueType_( ValueUnknown ), | ||
106 | entityType_( EntityUnknown ) | ||
101 | { | 107 | { |
102 | paramList_.setAutoDelete( TRUE ); | 108 | paramList_.setAutoDelete( TRUE ); |
103 | } | 109 | } |
104 | 110 | ||
105 | ContentLine & | 111 | ContentLine & |
106 | ContentLine::operator = (ContentLine & x) | 112 | ContentLine::operator = (ContentLine & x) |
107 | { | 113 | { |
108 | if (*this == x) return *this; | 114 | if (*this == x) return *this; |
109 | 115 | ||
110 | ParamListIterator it(x.paramList_); | 116 | ParamListIterator it(x.paramList_); |
111 | for (; it.current(); ++it) | 117 | for (; it.current(); ++it) |
112 | { | 118 | { |
113 | Param *p = new Param; | 119 | Param *p = new Param; |
114 | p->setName( it.current()->name() ); | 120 | p->setName( it.current()->name() ); |
115 | p->setValue( it.current()->value() ); | 121 | p->setValue( it.current()->value() ); |
116 | paramList_.append(p); | 122 | paramList_.append(p); |
117 | } | 123 | } |
118 | 124 | ||
119 | value_ = x.value_->clone(); | 125 | value_ = x.value_->clone(); |
120 | 126 | ||
121 | Entity::operator = (x); | 127 | Entity::operator = (x); |
122 | return *this; | 128 | return *this; |
123 | } | 129 | } |
124 | 130 | ||
125 | ContentLine & | 131 | ContentLine & |
126 | ContentLine::operator = (const QCString & s) | 132 | ContentLine::operator = (const QCString & s) |
127 | { | 133 | { |
128 | Entity::operator = (s); | 134 | Entity::operator = (s); |
129 | delete value_; | 135 | delete value_; |
130 | value_ = 0; | 136 | value_ = 0; |
131 | return *this; | 137 | return *this; |
132 | } | 138 | } |
133 | 139 | ||
134 | bool | 140 | bool |
135 | ContentLine::operator == (ContentLine & x) | 141 | ContentLine::operator == (ContentLine & x) |
136 | { | 142 | { |
137 | x.parse(); | 143 | x.parse(); |
138 | 144 | ||
139 | QPtrListIterator<Param> it(x.paramList()); | 145 | QPtrListIterator<Param> it(x.paramList()); |
140 | 146 | ||
141 | if (!paramList_.find(it.current())) | 147 | if (!paramList_.find(it.current())) |
142 | return false; | 148 | return false; |
143 | 149 | ||
144 | return true; | 150 | return true; |
145 | } | 151 | } |
146 | 152 | ||
147 | ContentLine::~ContentLine() | 153 | ContentLine::~ContentLine() |
148 | { | 154 | { |
149 | delete value_; | 155 | delete value_; |
150 | value_ = 0; | 156 | value_ = 0; |
151 | } | 157 | } |
152 | 158 | ||
153 | void | 159 | void |
154 | ContentLine::_parse() | 160 | ContentLine::_parse() |
155 | { | 161 | { |
156 | vDebug("parse"); | 162 | vDebug("parse"); |
157 | 163 | ||
158 | // Unqote newlines | 164 | // Unqote newlines |
159 | strRep_ = strRep_.replace( QRegExp( "\\\\n" ), "\n" ); | 165 | strRep_ = strRep_.replace( QRegExp( "\\\\n" ), "\n" ); |
160 | 166 | ||
161 | int split = strRep_.find(':'); | 167 | int split = strRep_.find(':'); |
162 | 168 | ||
163 | if (split == -1) { // invalid content line | 169 | if (split == -1) { // invalid content line |
164 | vDebug("No ':'"); | 170 | vDebug("No ':'"); |
165 | return; | 171 | return; |
166 | } | 172 | } |
167 | 173 | ||
168 | QCString firstPart(strRep_.left(split)); | 174 | QCString firstPart(strRep_.left(split)); |
169 | QCString valuePart(strRep_.mid(split + 1)); | 175 | QCString valuePart(strRep_.mid(split + 1)); |
170 | 176 | ||
171 | split = firstPart.find('.'); | 177 | split = firstPart.find('.'); |
172 | 178 | ||
173 | if (split != -1) { | 179 | if (split != -1) { |
174 | group_ = firstPart.left(split); | 180 | group_ = firstPart.left(split); |
175 | firstPart= firstPart.mid(split + 1); | 181 | firstPart= firstPart.mid(split + 1); |
176 | } | 182 | } |
177 | 183 | ||
178 | vDebug("Group == " + group_); | 184 | vDebug("Group == " + group_); |
179 | vDebug("firstPart == " + firstPart); | 185 | vDebug("firstPart == " + firstPart); |
180 | vDebug("valuePart == " + valuePart); | 186 | vDebug("valuePart == " + valuePart); |
181 | 187 | ||
182 | // Now we have the group, the name and param list together and the value. | 188 | // Now we have the group, the name and param list together and the value. |
183 | 189 | ||
184 | QStrList l; | 190 | QStrList l; |
185 | 191 | ||
186 | RTokenise(firstPart, ";", l); | 192 | RTokenise(firstPart, ";", l); |
187 | 193 | ||
188 | if (l.count() == 0) {// invalid - no name ! | 194 | if (l.count() == 0) {// invalid - no name ! |
189 | vDebug("No name for this content line !"); | 195 | vDebug("No name for this content line !"); |
190 | return; | 196 | return; |
191 | } | 197 | } |
192 | 198 | ||
193 | name_ = l.at(0); | 199 | name_ = l.at(0); |
194 | 200 | ||
195 | // Now we have the name, so the rest of 'l' is the params. | 201 | // Now we have the name, so the rest of 'l' is the params. |
196 | // Remove the name part. | 202 | // Remove the name part. |
diff --git a/kabc/vcard/VCardv.cpp b/kabc/vcard/VCardv.cpp index 391a69e..d19a004 100644 --- a/kabc/vcard/VCardv.cpp +++ b/kabc/vcard/VCardv.cpp | |||
@@ -95,199 +95,203 @@ VCard::~VCard() | |||
95 | 95 | ||
96 | void | 96 | void |
97 | VCard::_parse() | 97 | VCard::_parse() |
98 | { | 98 | { |
99 | vDebug("parse() called"); | 99 | vDebug("parse() called"); |
100 | QStrList l; | 100 | QStrList l; |
101 | 101 | ||
102 | RTokenise(strRep_, "\r\n", l); | 102 | RTokenise(strRep_, "\r\n", l); |
103 | 103 | ||
104 | if (l.count() < 3) { // Invalid VCARD ! | 104 | if (l.count() < 3) { // Invalid VCARD ! |
105 | vDebug("Invalid vcard"); | 105 | vDebug("Invalid vcard"); |
106 | return; | 106 | return; |
107 | } | 107 | } |
108 | 108 | ||
109 | // Get the first line | 109 | // Get the first line |
110 | QCString beginLine = QCString(l.at(0)).stripWhiteSpace(); | 110 | QCString beginLine = QCString(l.at(0)).stripWhiteSpace(); |
111 | 111 | ||
112 | vDebug("Begin line == \"" + beginLine + "\""); | 112 | vDebug("Begin line == \"" + beginLine + "\""); |
113 | 113 | ||
114 | // Remove extra blank lines | 114 | // Remove extra blank lines |
115 | while (QCString(l.last()).isEmpty()) | 115 | while (QCString(l.last()).isEmpty()) |
116 | l.remove(l.last()); | 116 | l.remove(l.last()); |
117 | 117 | ||
118 | // Now we know this is the last line | 118 | // Now we know this is the last line |
119 | QCString endLine = l.last(); | 119 | QCString endLine = l.last(); |
120 | 120 | ||
121 | // Trash the first and last lines as we have seen them. | 121 | // Trash the first and last lines as we have seen them. |
122 | l.remove(0u); | 122 | l.remove(0u); |
123 | l.remove(l.last()); | 123 | l.remove(l.last()); |
124 | 124 | ||
125 | /////////////////////////////////////////////////////////////// | 125 | /////////////////////////////////////////////////////////////// |
126 | // FIRST LINE | 126 | // FIRST LINE |
127 | 127 | ||
128 | int split = beginLine.find(':'); | 128 | int split = beginLine.find(':'); |
129 | 129 | ||
130 | if (split == -1) { // invalid, no BEGIN | 130 | if (split == -1) { // invalid, no BEGIN |
131 | vDebug("No split"); | 131 | vDebug("No split"); |
132 | return; | 132 | return; |
133 | } | 133 | } |
134 | 134 | ||
135 | QCString firstPart(beginLine.left(split)); | 135 | QCString firstPart(beginLine.left(split)); |
136 | QCString valuePart(beginLine.mid(split + 1)); | 136 | QCString valuePart(beginLine.mid(split + 1)); |
137 | 137 | ||
138 | split = firstPart.find('.'); | 138 | split = firstPart.find('.'); |
139 | 139 | ||
140 | if (split != -1) { | 140 | if (split != -1) { |
141 | group_ = firstPart.left(split); | 141 | group_ = firstPart.left(split); |
142 | firstPart= firstPart.right(firstPart.length() - split - 1); | 142 | firstPart= firstPart.right(firstPart.length() - split - 1); |
143 | } | 143 | } |
144 | 144 | ||
145 | if (qstrnicmp(firstPart, "BEGIN", 5) != 0) { // No BEGIN ! | 145 | if (qstrnicmp(firstPart, "BEGIN", 5) != 0) { // No BEGIN ! |
146 | vDebug("No BEGIN"); | 146 | vDebug("No BEGIN"); |
147 | return; | 147 | return; |
148 | } | 148 | } |
149 | 149 | ||
150 | if (qstrnicmp(valuePart, "VCARD", 5) != 0) { // Not a vcard ! | 150 | if (qstrnicmp(valuePart, "VCARD", 5) != 0) { // Not a vcard ! |
151 | vDebug("No VCARD"); | 151 | vDebug("No VCARD"); |
152 | return; | 152 | return; |
153 | } | 153 | } |
154 | 154 | ||
155 | /////////////////////////////////////////////////////////////// | 155 | /////////////////////////////////////////////////////////////// |
156 | // CONTENT LINES | 156 | // CONTENT LINES |
157 | // | 157 | // |
158 | vDebug("Content lines"); | 158 | vDebug("Content lines"); |
159 | 159 | ||
160 | // Handle folded lines. | 160 | // Handle folded lines. |
161 | 161 | ||
162 | QStrList refolded; | 162 | QStrList refolded; |
163 | 163 | ||
164 | QStrListIterator it(l); | 164 | QStrListIterator it(l); |
165 | 165 | ||
166 | QCString cur; | 166 | QCString cur; |
167 | 167 | ||
168 | for (; it.current(); ++it) { | 168 | for (; it.current(); ++it) { |
169 | 169 | ||
170 | cur = it.current(); | 170 | cur = it.current(); |
171 | 171 | ||
172 | ++it; | 172 | ++it; |
173 | 173 | ||
174 | while ( | 174 | while ( |
175 | it.current() && | 175 | it.current() && |
176 | it.current()[0] == ' '&& | 176 | it.current()[0] == ' '&& |
177 | strlen(it.current()) != 1) | 177 | strlen(it.current()) != 1) |
178 | { | 178 | { |
179 | cur += it.current() + 1; | 179 | cur += it.current() + 1; |
180 | ++it; | 180 | ++it; |
181 | } | 181 | } |
182 | 182 | ||
183 | --it; | 183 | --it; |
184 | 184 | ||
185 | refolded.append(cur); | 185 | refolded.append(cur); |
186 | } | 186 | } |
187 | 187 | ||
188 | QStrListIterator it2(refolded); | 188 | QStrListIterator it2(refolded); |
189 | 189 | ||
190 | for (; it2.current(); ++it2) { | 190 | for (; it2.current(); ++it2) { |
191 | 191 | vDebug("New contentline using \"" + QCString(it2.current()) + "\""); | |
192 | vDebug("New contentline using \"" + QCString(it2.current()) + "\""); | ||
193 | ContentLine * cl = new ContentLine(it2.current()); | 192 | ContentLine * cl = new ContentLine(it2.current()); |
194 | 193 | ||
195 | cl->parse(); | 194 | cl->parse(); |
196 | 195 | if (cl->value() == 0) | |
197 | contentLineList_.append(cl); | 196 | { |
197 | qDebug("Content line could not be parsed. Discarded: %s" + QCString(it2.current())); | ||
198 | delete cl; | ||
199 | } | ||
200 | else | ||
201 | contentLineList_.append(cl); | ||
198 | } | 202 | } |
199 | 203 | ||
200 | /////////////////////////////////////////////////////////////// | 204 | /////////////////////////////////////////////////////////////// |
201 | // LAST LINE | 205 | // LAST LINE |
202 | 206 | ||
203 | split = endLine.find(':'); | 207 | split = endLine.find(':'); |
204 | 208 | ||
205 | if (split == -1) // invalid, no END | 209 | if (split == -1) // invalid, no END |
206 | return; | 210 | return; |
207 | 211 | ||
208 | firstPart = endLine.left(split); | 212 | firstPart = endLine.left(split); |
209 | valuePart = endLine.right(firstPart.length() - split - 1); | 213 | valuePart = endLine.right(firstPart.length() - split - 1); |
210 | 214 | ||
211 | split = firstPart.find('.'); | 215 | split = firstPart.find('.'); |
212 | 216 | ||
213 | if (split != -1) { | 217 | if (split != -1) { |
214 | group_ = firstPart.left(split); | 218 | group_ = firstPart.left(split); |
215 | firstPart= firstPart.right(firstPart.length() - split - 1); | 219 | firstPart= firstPart.right(firstPart.length() - split - 1); |
216 | } | 220 | } |
217 | 221 | ||
218 | if (qstricmp(firstPart, "END") != 0) // No END ! | 222 | if (qstricmp(firstPart, "END") != 0) // No END ! |
219 | return; | 223 | return; |
220 | 224 | ||
221 | if (qstricmp(valuePart, "VCARD") != 0) // Not a vcard ! | 225 | if (qstricmp(valuePart, "VCARD") != 0) // Not a vcard ! |
222 | return; | 226 | return; |
223 | } | 227 | } |
224 | 228 | ||
225 | void | 229 | void |
226 | VCard::_assemble() | 230 | VCard::_assemble() |
227 | { | 231 | { |
228 | vDebug("Assembling vcard"); | 232 | vDebug("Assembling vcard"); |
229 | strRep_ = "BEGIN:VCARD\r\n"; | 233 | strRep_ = "BEGIN:VCARD\r\n"; |
230 | strRep_ += "VERSION:3.0\r\n"; | 234 | strRep_ += "VERSION:3.0\r\n"; |
231 | 235 | ||
232 | QPtrListIterator<ContentLine> it(contentLineList_); | 236 | QPtrListIterator<ContentLine> it(contentLineList_); |
233 | 237 | ||
234 | for (; it.current(); ++it) | 238 | for (; it.current(); ++it) |
235 | strRep_ += it.current()->asString() + "\r\n"; | 239 | strRep_ += it.current()->asString() + "\r\n"; |
236 | 240 | ||
237 | strRep_ += "END:VCARD\r\n"; | 241 | strRep_ += "END:VCARD\r\n"; |
238 | } | 242 | } |
239 | 243 | ||
240 | bool | 244 | bool |
241 | VCard::has(EntityType t) | 245 | VCard::has(EntityType t) |
242 | { | 246 | { |
243 | parse(); | 247 | parse(); |
244 | return contentLine(t) == 0 ? false : true; | 248 | return contentLine(t) == 0 ? false : true; |
245 | } | 249 | } |
246 | 250 | ||
247 | bool | 251 | bool |
248 | VCard::has(const QCString & s) | 252 | VCard::has(const QCString & s) |
249 | { | 253 | { |
250 | parse(); | 254 | parse(); |
251 | return contentLine(s) == 0 ? false : true; | 255 | return contentLine(s) == 0 ? false : true; |
252 | } | 256 | } |
253 | 257 | ||
254 | void | 258 | void |
255 | VCard::add(const ContentLine & cl) | 259 | VCard::add(const ContentLine & cl) |
256 | { | 260 | { |
257 | parse(); | 261 | parse(); |
258 | ContentLine * c = new ContentLine(cl); | 262 | ContentLine * c = new ContentLine(cl); |
259 | contentLineList_.append(c); | 263 | contentLineList_.append(c); |
260 | } | 264 | } |
261 | 265 | ||
262 | void | 266 | void |
263 | VCard::add(const QCString & s) | 267 | VCard::add(const QCString & s) |
264 | { | 268 | { |
265 | parse(); | 269 | parse(); |
266 | ContentLine * c = new ContentLine(s); | 270 | ContentLine * c = new ContentLine(s); |
267 | contentLineList_.append(c); | 271 | contentLineList_.append(c); |
268 | } | 272 | } |
269 | 273 | ||
270 | ContentLine * | 274 | ContentLine * |
271 | VCard::contentLine(EntityType t) | 275 | VCard::contentLine(EntityType t) |
272 | { | 276 | { |
273 | parse(); | 277 | parse(); |
274 | QPtrListIterator<ContentLine> it(contentLineList_); | 278 | QPtrListIterator<ContentLine> it(contentLineList_); |
275 | 279 | ||
276 | for (; it.current(); ++it) | 280 | for (; it.current(); ++it) |
277 | if (it.current()->entityType() == t) | 281 | if (it.current()->entityType() == t) |
278 | return it.current(); | 282 | return it.current(); |
279 | 283 | ||
280 | return 0; | 284 | return 0; |
281 | } | 285 | } |
282 | 286 | ||
283 | ContentLine * | 287 | ContentLine * |
284 | VCard::contentLine(const QCString & s) | 288 | VCard::contentLine(const QCString & s) |
285 | { | 289 | { |
286 | parse(); | 290 | parse(); |
287 | QPtrListIterator<ContentLine> it(contentLineList_); | 291 | QPtrListIterator<ContentLine> it(contentLineList_); |
288 | 292 | ||
289 | for (; it.current(); ++it) | 293 | for (; it.current(); ++it) |
290 | if (it.current()->entityType() == EntityNameToEntityType(s)) | 294 | if (it.current()->entityType() == EntityNameToEntityType(s)) |
291 | return it.current(); | 295 | return it.current(); |
292 | 296 | ||
293 | return 0; | 297 | return 0; |
diff --git a/kabc/vcard/include/VCardDefines.h b/kabc/vcard/include/VCardDefines.h index dd38ae2..557410f 100644 --- a/kabc/vcard/include/VCardDefines.h +++ b/kabc/vcard/include/VCardDefines.h | |||
@@ -1,52 +1,53 @@ | |||
1 | /* | 1 | /* |
2 | libvcard - vCard parsing library for vCard version 3.0 | 2 | libvcard - vCard parsing library for vCard version 3.0 |
3 | 3 | ||
4 | Copyright (C) 1998 Rik Hemsley rik@kde.org | 4 | Copyright (C) 1998 Rik Hemsley rik@kde.org |
5 | 5 | ||
6 | Permission is hereby granted, free of charge, to any person obtaining a copy | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy |
7 | of this software and associated documentation files (the "Software"), to | 7 | of this software and associated documentation files (the "Software"), to |
8 | deal in the Software without restriction, including without limitation the | 8 | deal in the Software without restriction, including without limitation the |
9 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | 9 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
10 | sell copies of the Software, and to permit persons to whom the Software is | 10 | sell copies of the Software, and to permit persons to whom the Software is |
11 | furnished to do so, subject to the following conditions: | 11 | furnished to do so, subject to the following conditions: |
12 | 12 | ||
13 | The above copyright notice and this permission notice shall be included in | 13 | The above copyright notice and this permission notice shall be included in |
14 | all copies or substantial portions of the Software. | 14 | all copies or substantial portions of the Software. |
15 | 15 | ||
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
19 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | 19 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
20 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | 20 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef VCARD_DEFINES_H | 24 | #ifndef VCARD_DEFINES_H |
25 | #define VCARD_DEFINES_H | 25 | #define VCARD_DEFINES_H |
26 | 26 | ||
27 | #include <kdebug.h> | 27 | #include <kdebug.h> |
28 | 28 | ||
29 | #ifdef VCARD_DEBUG | 29 | #ifdef VCARD_DEBUG |
30 | #define vDebug(a) kdDebug(5710) << a << endl; | 30 | //US #define vDebug(a) kdDebug(5710) << a << endl; |
31 | #define vDebug(a) qDebug(a); | ||
31 | #else | 32 | #else |
32 | #define vDebug(a) | 33 | #define vDebug(a) |
33 | #endif | 34 | #endif |
34 | 35 | ||
35 | #if 0 | 36 | #if 0 |
36 | #ifndef NDEBUG | 37 | #ifndef NDEBUG |
37 | #include <qcstring.h> | 38 | #include <qcstring.h> |
38 | #include <iostream> | 39 | #include <iostream> |
39 | #ifdef __GNUG__ | 40 | #ifdef __GNUG__ |
40 | # define vDebug(a) cerr << className() << ":" << __FUNCTION__ << " (" \ | 41 | # define vDebug(a) cerr << className() << ":" << __FUNCTION__ << " (" \ |
41 | << __LINE__ << "): " << QCString((a)).data() << endl; | 42 | << __LINE__ << "): " << QCString((a)).data() << endl; |
42 | #else | 43 | #else |
43 | # define vDebug(a) cerr << className() << ": " \ | 44 | # define vDebug(a) cerr << className() << ": " \ |
44 | << QCString((a)).data() << endl; | 45 | << QCString((a)).data() << endl; |
45 | #endif | 46 | #endif |
46 | #else | 47 | #else |
47 | #define vDebug(a) | 48 | #define vDebug(a) |
48 | #endif | 49 | #endif |
49 | #endif | 50 | #endif |
50 | 51 | ||
51 | #endif // Included this file | 52 | #endif // Included this file |
52 | 53 | ||
diff --git a/kabc/vcardformatimpl.cpp b/kabc/vcardformatimpl.cpp index 2d6eb3d..1bf2cde 100644 --- a/kabc/vcardformatimpl.cpp +++ b/kabc/vcardformatimpl.cpp | |||
@@ -168,192 +168,193 @@ bool VCardFormatImpl::loadAddressee( Addressee& addressee, VCard *v ) | |||
168 | break; | 168 | break; |
169 | 169 | ||
170 | case EntityLabel: | 170 | case EntityLabel: |
171 | // not yet supported by kabc | 171 | // not yet supported by kabc |
172 | break; | 172 | break; |
173 | 173 | ||
174 | case EntityMailer: | 174 | case EntityMailer: |
175 | addressee.setMailer( readTextValue( cl ) ); | 175 | addressee.setMailer( readTextValue( cl ) ); |
176 | break; | 176 | break; |
177 | 177 | ||
178 | case EntityTitle: | 178 | case EntityTitle: |
179 | addressee.setTitle( readTextValue( cl ) ); | 179 | addressee.setTitle( readTextValue( cl ) ); |
180 | break; | 180 | break; |
181 | 181 | ||
182 | case EntityRole: | 182 | case EntityRole: |
183 | addressee.setRole( readTextValue( cl ) ); | 183 | addressee.setRole( readTextValue( cl ) ); |
184 | break; | 184 | break; |
185 | 185 | ||
186 | case EntityOrganisation: | 186 | case EntityOrganisation: |
187 | addressee.setOrganization( readTextValue( cl ) ); | 187 | addressee.setOrganization( readTextValue( cl ) ); |
188 | break; | 188 | break; |
189 | 189 | ||
190 | case EntityNote: | 190 | case EntityNote: |
191 | addressee.setNote( readTextValue( cl ) ); | 191 | addressee.setNote( readTextValue( cl ) ); |
192 | break; | 192 | break; |
193 | 193 | ||
194 | case EntityProductID: | 194 | case EntityProductID: |
195 | addressee.setProductId( readTextValue( cl ) ); | 195 | addressee.setProductId( readTextValue( cl ) ); |
196 | break; | 196 | break; |
197 | 197 | ||
198 | case EntitySortString: | 198 | case EntitySortString: |
199 | addressee.setSortString( readTextValue( cl ) ); | 199 | addressee.setSortString( readTextValue( cl ) ); |
200 | break; | 200 | break; |
201 | 201 | ||
202 | case EntityN: | 202 | case EntityN: |
203 | readNValue( cl, addressee ); | 203 | readNValue( cl, addressee ); |
204 | break; | 204 | break; |
205 | 205 | ||
206 | case EntityAddress: | 206 | case EntityAddress: |
207 | addressee.insertAddress( readAddressValue( cl ) ); | 207 | addressee.insertAddress( readAddressValue( cl ) ); |
208 | break; | 208 | break; |
209 | 209 | ||
210 | case EntityTelephone: | 210 | case EntityTelephone: |
211 | addressee.insertPhoneNumber( readTelephoneValue( cl ) ); | 211 | addressee.insertPhoneNumber( readTelephoneValue( cl ) ); |
212 | break; | 212 | break; |
213 | 213 | ||
214 | case EntityCategories: | 214 | case EntityCategories: |
215 | addressee.setCategories( QStringList::split( ",", readTextValue( cl ) ) ); | 215 | addressee.setCategories( QStringList::split( ",", readTextValue( cl ) ) ); |
216 | break; | 216 | break; |
217 | 217 | ||
218 | case EntityBirthday: | 218 | case EntityBirthday: |
219 | addressee.setBirthday( readDateValue( cl ) ); | 219 | addressee.setBirthday( readDateValue( cl ) ); |
220 | break; | 220 | break; |
221 | 221 | ||
222 | case EntityRevision: | 222 | case EntityRevision: |
223 | addressee.setRevision( readDateTimeValue( cl ) ); | 223 | addressee.setRevision( readDateTimeValue( cl ) ); |
224 | break; | 224 | break; |
225 | 225 | ||
226 | case EntityGeo: | 226 | case EntityGeo: |
227 | addressee.setGeo( readGeoValue( cl ) ); | 227 | addressee.setGeo( readGeoValue( cl ) ); |
228 | break; | 228 | break; |
229 | 229 | ||
230 | case EntityTimeZone: | 230 | case EntityTimeZone: |
231 | addressee.setTimeZone( readUTCValue( cl ) ); | 231 | addressee.setTimeZone( readUTCValue( cl ) ); |
232 | break; | 232 | break; |
233 | 233 | ||
234 | case EntityVersion: | 234 | case EntityVersion: |
235 | break; | 235 | break; |
236 | 236 | ||
237 | case EntityClass: | 237 | case EntityClass: |
238 | addressee.setSecrecy( readClassValue( cl ) ); | 238 | addressee.setSecrecy( readClassValue( cl ) ); |
239 | break; | 239 | break; |
240 | 240 | ||
241 | case EntityKey: | 241 | case EntityKey: |
242 | addressee.insertKey( readKeyValue( cl ) ); | 242 | addressee.insertKey( readKeyValue( cl ) ); |
243 | break; | 243 | break; |
244 | 244 | ||
245 | case EntityPhoto: | 245 | case EntityPhoto: |
246 | addressee.setPhoto( readPictureValue( cl, EntityPhoto, addressee ) ); | 246 | addressee.setPhoto( readPictureValue( cl, EntityPhoto, addressee ) ); |
247 | break; | 247 | break; |
248 | 248 | ||
249 | case EntityLogo: | 249 | case EntityLogo: |
250 | addressee.setLogo( readPictureValue( cl, EntityLogo, addressee ) ); | 250 | addressee.setLogo( readPictureValue( cl, EntityLogo, addressee ) ); |
251 | break; | 251 | break; |
252 | 252 | ||
253 | case EntityAgent: | 253 | case EntityAgent: |
254 | addressee.setAgent( readAgentValue( cl ) ); | 254 | addressee.setAgent( readAgentValue( cl ) ); |
255 | break; | 255 | break; |
256 | 256 | ||
257 | case EntitySound: | 257 | case EntitySound: |
258 | addressee.setSound( readSoundValue( cl, addressee ) ); | 258 | addressee.setSound( readSoundValue( cl, addressee ) ); |
259 | break; | 259 | break; |
260 | 260 | ||
261 | default: | 261 | default: |
262 | kdDebug(5700) << "VCardFormat::load(): Unsupported entity: " | 262 | kdDebug(5700) << "VCardFormat::load(): Unsupported entity: " |
263 | << int( type ) << ": " << cl->asString() << endl; | 263 | << int( type ) << ": " << cl->asString() << endl; |
264 | qDebug("VCardFormat::load(): Unsupported entity: %i: %s ", int(type), (const char*)cl->asString()); | ||
264 | break; | 265 | break; |
265 | } | 266 | } |
266 | } | 267 | } |
267 | 268 | ||
268 | for( cl = contentLines.first(); cl; cl = contentLines.next() ) { | 269 | for( cl = contentLines.first(); cl; cl = contentLines.next() ) { |
269 | EntityType type = cl->entityType(); | 270 | EntityType type = cl->entityType(); |
270 | if ( type == EntityLabel ) { | 271 | if ( type == EntityLabel ) { |
271 | int type = readAddressParam( cl ); | 272 | int type = readAddressParam( cl ); |
272 | Address address = addressee.address( type ); | 273 | Address address = addressee.address( type ); |
273 | if ( address.isEmpty() ) | 274 | if ( address.isEmpty() ) |
274 | address.setType( type ); | 275 | address.setType( type ); |
275 | 276 | ||
276 | address.setLabel( QString::fromUtf8( cl->value()->asString() ) ); | 277 | address.setLabel( QString::fromUtf8( cl->value()->asString() ) ); |
277 | addressee.insertAddress( address ); | 278 | addressee.insertAddress( address ); |
278 | } | 279 | } |
279 | } | 280 | } |
280 | 281 | ||
281 | return true; | 282 | return true; |
282 | } | 283 | } |
283 | 284 | ||
284 | void VCardFormatImpl::saveAddressee( const Addressee &addressee, VCard *v, bool intern ) | 285 | void VCardFormatImpl::saveAddressee( const Addressee &addressee, VCard *v, bool intern ) |
285 | { | 286 | { |
286 | //US ContentLine cl; | 287 | //US ContentLine cl; |
287 | //US QString value; | 288 | //US QString value; |
288 | 289 | ||
289 | addTextValue( v, EntityName, addressee.name() ); | 290 | addTextValue( v, EntityName, addressee.name() ); |
290 | addTextValue( v, EntityUID, addressee.uid() ); | 291 | addTextValue( v, EntityUID, addressee.uid() ); |
291 | addTextValue( v, EntityFullName, addressee.formattedName() ); | 292 | addTextValue( v, EntityFullName, addressee.formattedName() ); |
292 | 293 | ||
293 | QStringList emails = addressee.emails(); | 294 | QStringList emails = addressee.emails(); |
294 | QStringList::ConstIterator it4; | 295 | QStringList::ConstIterator it4; |
295 | for( it4 = emails.begin(); it4 != emails.end(); ++it4 ) { | 296 | for( it4 = emails.begin(); it4 != emails.end(); ++it4 ) { |
296 | addTextValue( v, EntityEmail, *it4 ); | 297 | addTextValue( v, EntityEmail, *it4 ); |
297 | } | 298 | } |
298 | 299 | ||
299 | QStringList customs = addressee.customs(); | 300 | QStringList customs = addressee.customs(); |
300 | QStringList::ConstIterator it5; | 301 | QStringList::ConstIterator it5; |
301 | for( it5 = customs.begin(); it5 != customs.end(); ++it5 ) { | 302 | for( it5 = customs.begin(); it5 != customs.end(); ++it5 ) { |
302 | addCustomValue( v, *it5 ); | 303 | addCustomValue( v, *it5 ); |
303 | } | 304 | } |
304 | 305 | ||
305 | addTextValue( v, EntityURL, addressee.url().url() ); | 306 | addTextValue( v, EntityURL, addressee.url().url() ); |
306 | 307 | ||
307 | addNValue( v, addressee ); | 308 | addNValue( v, addressee ); |
308 | 309 | ||
309 | addTextValue( v, EntityNickname, addressee.nickName() ); | 310 | addTextValue( v, EntityNickname, addressee.nickName() ); |
310 | addTextValue( v, EntityMailer, addressee.mailer() ); | 311 | addTextValue( v, EntityMailer, addressee.mailer() ); |
311 | addTextValue( v, EntityTitle, addressee.title() ); | 312 | addTextValue( v, EntityTitle, addressee.title() ); |
312 | addTextValue( v, EntityRole, addressee.role() ); | 313 | addTextValue( v, EntityRole, addressee.role() ); |
313 | addTextValue( v, EntityOrganisation, addressee.organization() ); | 314 | addTextValue( v, EntityOrganisation, addressee.organization() ); |
314 | addTextValue( v, EntityNote, addressee.note() ); | 315 | addTextValue( v, EntityNote, addressee.note() ); |
315 | addTextValue( v, EntityProductID, addressee.productId() ); | 316 | addTextValue( v, EntityProductID, addressee.productId() ); |
316 | addTextValue( v, EntitySortString, addressee.sortString() ); | 317 | addTextValue( v, EntitySortString, addressee.sortString() ); |
317 | 318 | ||
318 | Address::List addresses = addressee.addresses(); | 319 | Address::List addresses = addressee.addresses(); |
319 | Address::List::ConstIterator it3; | 320 | Address::List::ConstIterator it3; |
320 | for( it3 = addresses.begin(); it3 != addresses.end(); ++it3 ) { | 321 | for( it3 = addresses.begin(); it3 != addresses.end(); ++it3 ) { |
321 | addAddressValue( v, *it3 ); | 322 | addAddressValue( v, *it3 ); |
322 | addLabelValue( v, *it3 ); | 323 | addLabelValue( v, *it3 ); |
323 | } | 324 | } |
324 | 325 | ||
325 | PhoneNumber::List phoneNumbers = addressee.phoneNumbers(); | 326 | PhoneNumber::List phoneNumbers = addressee.phoneNumbers(); |
326 | PhoneNumber::List::ConstIterator it2; | 327 | PhoneNumber::List::ConstIterator it2; |
327 | for( it2 = phoneNumbers.begin(); it2 != phoneNumbers.end(); ++it2 ) { | 328 | for( it2 = phoneNumbers.begin(); it2 != phoneNumbers.end(); ++it2 ) { |
328 | addTelephoneValue( v, *it2 ); | 329 | addTelephoneValue( v, *it2 ); |
329 | } | 330 | } |
330 | 331 | ||
331 | Key::List keys = addressee.keys(); | 332 | Key::List keys = addressee.keys(); |
332 | Key::List::ConstIterator it6; | 333 | Key::List::ConstIterator it6; |
333 | for( it6 = keys.begin(); it6 != keys.end(); ++it6 ) { | 334 | for( it6 = keys.begin(); it6 != keys.end(); ++it6 ) { |
334 | addKeyValue( v, *it6 ); | 335 | addKeyValue( v, *it6 ); |
335 | } | 336 | } |
336 | 337 | ||
337 | addTextValue( v, EntityCategories, addressee.categories().join(",") ); | 338 | addTextValue( v, EntityCategories, addressee.categories().join(",") ); |
338 | 339 | ||
339 | addDateValue( v, EntityBirthday, addressee.birthday().date() ); | 340 | addDateValue( v, EntityBirthday, addressee.birthday().date() ); |
340 | addDateTimeValue( v, EntityRevision, addressee.revision() ); | 341 | addDateTimeValue( v, EntityRevision, addressee.revision() ); |
341 | addGeoValue( v, addressee.geo() ); | 342 | addGeoValue( v, addressee.geo() ); |
342 | addUTCValue( v, addressee.timeZone() ); | 343 | addUTCValue( v, addressee.timeZone() ); |
343 | 344 | ||
344 | addClassValue( v, addressee.secrecy() ); | 345 | addClassValue( v, addressee.secrecy() ); |
345 | 346 | ||
346 | addPictureValue( v, EntityPhoto, addressee.photo(), addressee, intern ); | 347 | addPictureValue( v, EntityPhoto, addressee.photo(), addressee, intern ); |
347 | addPictureValue( v, EntityLogo, addressee.logo(), addressee, intern ); | 348 | addPictureValue( v, EntityLogo, addressee.logo(), addressee, intern ); |
348 | 349 | ||
349 | addAgentValue( v, addressee.agent() ); | 350 | addAgentValue( v, addressee.agent() ); |
350 | 351 | ||
351 | addSoundValue( v, addressee.sound(), addressee, intern ); | 352 | addSoundValue( v, addressee.sound(), addressee, intern ); |
352 | } | 353 | } |
353 | 354 | ||
354 | void VCardFormatImpl::addCustomValue( VCard *v, const QString &txt ) | 355 | void VCardFormatImpl::addCustomValue( VCard *v, const QString &txt ) |
355 | { | 356 | { |
356 | if ( txt.isEmpty() ) return; | 357 | if ( txt.isEmpty() ) return; |
357 | 358 | ||
358 | ContentLine cl; | 359 | ContentLine cl; |
359 | cl.setName( "X-" + txt.left( txt.find( ":" ) ).utf8() ); | 360 | cl.setName( "X-" + txt.left( txt.find( ":" ) ).utf8() ); |
@@ -546,192 +547,193 @@ void VCardFormatImpl::addNValue( VCard *vcard, const Addressee &a ) | |||
546 | { | 547 | { |
547 | ContentLine cl; | 548 | ContentLine cl; |
548 | cl.setName(EntityTypeToParamName( EntityN ) ); | 549 | cl.setName(EntityTypeToParamName( EntityN ) ); |
549 | NValue *v = new NValue; | 550 | NValue *v = new NValue; |
550 | v->setFamily( a.familyName().utf8() ); | 551 | v->setFamily( a.familyName().utf8() ); |
551 | v->setGiven( a.givenName().utf8() ); | 552 | v->setGiven( a.givenName().utf8() ); |
552 | v->setMiddle( a.additionalName().utf8() ); | 553 | v->setMiddle( a.additionalName().utf8() ); |
553 | v->setPrefix( a.prefix().utf8() ); | 554 | v->setPrefix( a.prefix().utf8() ); |
554 | v->setSuffix( a.suffix().utf8() ); | 555 | v->setSuffix( a.suffix().utf8() ); |
555 | 556 | ||
556 | cl.setValue( v ); | 557 | cl.setValue( v ); |
557 | vcard->add(cl); | 558 | vcard->add(cl); |
558 | } | 559 | } |
559 | 560 | ||
560 | void VCardFormatImpl::readNValue( ContentLine *cl, Addressee &a ) | 561 | void VCardFormatImpl::readNValue( ContentLine *cl, Addressee &a ) |
561 | { | 562 | { |
562 | NValue *v = (NValue *)cl->value(); | 563 | NValue *v = (NValue *)cl->value(); |
563 | a.setFamilyName( QString::fromUtf8( v->family() ) ); | 564 | a.setFamilyName( QString::fromUtf8( v->family() ) ); |
564 | a.setGivenName( QString::fromUtf8( v->given() ) ); | 565 | a.setGivenName( QString::fromUtf8( v->given() ) ); |
565 | a.setAdditionalName( QString::fromUtf8( v->middle() ) ); | 566 | a.setAdditionalName( QString::fromUtf8( v->middle() ) ); |
566 | a.setPrefix( QString::fromUtf8( v->prefix() ) ); | 567 | a.setPrefix( QString::fromUtf8( v->prefix() ) ); |
567 | a.setSuffix( QString::fromUtf8( v->suffix() ) ); | 568 | a.setSuffix( QString::fromUtf8( v->suffix() ) ); |
568 | } | 569 | } |
569 | 570 | ||
570 | void VCardFormatImpl::addTelephoneValue( VCard *v, const PhoneNumber &p ) | 571 | void VCardFormatImpl::addTelephoneValue( VCard *v, const PhoneNumber &p ) |
571 | { | 572 | { |
572 | if ( p.number().isEmpty() ) | 573 | if ( p.number().isEmpty() ) |
573 | return; | 574 | return; |
574 | 575 | ||
575 | ContentLine cl; | 576 | ContentLine cl; |
576 | cl.setName(EntityTypeToParamName(EntityTelephone)); | 577 | cl.setName(EntityTypeToParamName(EntityTelephone)); |
577 | cl.setValue(new TelValue( p.number().utf8() )); | 578 | cl.setValue(new TelValue( p.number().utf8() )); |
578 | 579 | ||
579 | ParamList params; | 580 | ParamList params; |
580 | if( p.type() & PhoneNumber::Home ) params.append( new Param( "TYPE", "home" ) ); | 581 | if( p.type() & PhoneNumber::Home ) params.append( new Param( "TYPE", "home" ) ); |
581 | if( p.type() & PhoneNumber::Work ) params.append( new Param( "TYPE", "work" ) ); | 582 | if( p.type() & PhoneNumber::Work ) params.append( new Param( "TYPE", "work" ) ); |
582 | if( p.type() & PhoneNumber::Msg ) params.append( new Param( "TYPE", "msg" ) ); | 583 | if( p.type() & PhoneNumber::Msg ) params.append( new Param( "TYPE", "msg" ) ); |
583 | if( p.type() & PhoneNumber::Pref ) params.append( new Param( "TYPE", "pref" ) ); | 584 | if( p.type() & PhoneNumber::Pref ) params.append( new Param( "TYPE", "pref" ) ); |
584 | if( p.type() & PhoneNumber::Voice ) params.append( new Param( "TYPE", "voice" ) ); | 585 | if( p.type() & PhoneNumber::Voice ) params.append( new Param( "TYPE", "voice" ) ); |
585 | if( p.type() & PhoneNumber::Fax ) params.append( new Param( "TYPE", "fax" ) ); | 586 | if( p.type() & PhoneNumber::Fax ) params.append( new Param( "TYPE", "fax" ) ); |
586 | if( p.type() & PhoneNumber::Cell ) params.append( new Param( "TYPE", "cell" ) ); | 587 | if( p.type() & PhoneNumber::Cell ) params.append( new Param( "TYPE", "cell" ) ); |
587 | if( p.type() & PhoneNumber::Video ) params.append( new Param( "TYPE", "video" ) ); | 588 | if( p.type() & PhoneNumber::Video ) params.append( new Param( "TYPE", "video" ) ); |
588 | if( p.type() & PhoneNumber::Bbs ) params.append( new Param( "TYPE", "bbs" ) ); | 589 | if( p.type() & PhoneNumber::Bbs ) params.append( new Param( "TYPE", "bbs" ) ); |
589 | if( p.type() & PhoneNumber::Modem ) params.append( new Param( "TYPE", "modem" ) ); | 590 | if( p.type() & PhoneNumber::Modem ) params.append( new Param( "TYPE", "modem" ) ); |
590 | if( p.type() & PhoneNumber::Car ) params.append( new Param( "TYPE", "car" ) ); | 591 | if( p.type() & PhoneNumber::Car ) params.append( new Param( "TYPE", "car" ) ); |
591 | if( p.type() & PhoneNumber::Isdn ) params.append( new Param( "TYPE", "isdn" ) ); | 592 | if( p.type() & PhoneNumber::Isdn ) params.append( new Param( "TYPE", "isdn" ) ); |
592 | if( p.type() & PhoneNumber::Pcs ) params.append( new Param( "TYPE", "pcs" ) ); | 593 | if( p.type() & PhoneNumber::Pcs ) params.append( new Param( "TYPE", "pcs" ) ); |
593 | if( p.type() & PhoneNumber::Pager ) params.append( new Param( "TYPE", "pager" ) ); | 594 | if( p.type() & PhoneNumber::Pager ) params.append( new Param( "TYPE", "pager" ) ); |
594 | if( p.type() & PhoneNumber::Sip ) params.append( new Param( "TYPE", "sip" ) ); | 595 | if( p.type() & PhoneNumber::Sip ) params.append( new Param( "TYPE", "sip" ) ); |
595 | cl.setParamList( params ); | 596 | cl.setParamList( params ); |
596 | 597 | ||
597 | v->add(cl); | 598 | v->add(cl); |
598 | } | 599 | } |
599 | 600 | ||
600 | PhoneNumber VCardFormatImpl::readTelephoneValue( ContentLine *cl ) | 601 | PhoneNumber VCardFormatImpl::readTelephoneValue( ContentLine *cl ) |
601 | { | 602 | { |
602 | PhoneNumber p; | 603 | PhoneNumber p; |
603 | TelValue *value = (TelValue *)cl->value(); | 604 | TelValue *value = (TelValue *)cl->value(); |
604 | p.setNumber( QString::fromUtf8( value->asString() ) ); | 605 | p.setNumber( QString::fromUtf8( value->asString() ) ); |
605 | 606 | ||
606 | int type = 0; | 607 | int type = 0; |
607 | ParamList params = cl->paramList(); | 608 | ParamList params = cl->paramList(); |
608 | ParamListIterator it( params ); | 609 | ParamListIterator it( params ); |
609 | QCString tmpStr; | 610 | QCString tmpStr; |
610 | for( ; it.current(); ++it ) { | 611 | for( ; it.current(); ++it ) { |
611 | if ( (*it)->name() == "TYPE" ) { | 612 | if ( (*it)->name() == "TYPE" ) { |
612 | tmpStr = (*it)->value().lower(); | 613 | tmpStr = (*it)->value().lower(); |
613 | if ( tmpStr == "home" ) type |= PhoneNumber::Home; | 614 | if ( tmpStr == "home" ) type |= PhoneNumber::Home; |
614 | else if ( tmpStr == "work" ) type |= PhoneNumber::Work; | 615 | else if ( tmpStr == "work" ) type |= PhoneNumber::Work; |
615 | else if ( tmpStr == "msg" ) type |= PhoneNumber::Msg; | 616 | else if ( tmpStr == "msg" ) type |= PhoneNumber::Msg; |
616 | else if ( tmpStr == "pref" ) type |= PhoneNumber::Pref; | 617 | else if ( tmpStr == "pref" ) type |= PhoneNumber::Pref; |
617 | else if ( tmpStr == "voice" ) type |= PhoneNumber::Voice; | 618 | else if ( tmpStr == "voice" ) type |= PhoneNumber::Voice; |
618 | else if ( tmpStr == "fax" ) type |= PhoneNumber::Fax; | 619 | else if ( tmpStr == "fax" ) type |= PhoneNumber::Fax; |
619 | else if ( tmpStr == "cell" ) type |= PhoneNumber::Cell; | 620 | else if ( tmpStr == "cell" ) type |= PhoneNumber::Cell; |
620 | else if ( tmpStr == "video" ) type |= PhoneNumber::Video; | 621 | else if ( tmpStr == "video" ) type |= PhoneNumber::Video; |
621 | else if ( tmpStr == "bbs" ) type |= PhoneNumber::Bbs; | 622 | else if ( tmpStr == "bbs" ) type |= PhoneNumber::Bbs; |
622 | else if ( tmpStr == "modem" ) type |= PhoneNumber::Modem; | 623 | else if ( tmpStr == "modem" ) type |= PhoneNumber::Modem; |
623 | else if ( tmpStr == "car" ) type |= PhoneNumber::Car; | 624 | else if ( tmpStr == "car" ) type |= PhoneNumber::Car; |
624 | else if ( tmpStr == "isdn" ) type |= PhoneNumber::Isdn; | 625 | else if ( tmpStr == "isdn" ) type |= PhoneNumber::Isdn; |
625 | else if ( tmpStr == "pcs" ) type |= PhoneNumber::Pcs; | 626 | else if ( tmpStr == "pcs" ) type |= PhoneNumber::Pcs; |
626 | else if ( tmpStr == "pager" ) type |= PhoneNumber::Pager; | 627 | else if ( tmpStr == "pager" ) type |= PhoneNumber::Pager; |
627 | else if ( tmpStr == "sip" ) type |= PhoneNumber::Sip; | 628 | else if ( tmpStr == "sip" ) type |= PhoneNumber::Sip; |
628 | } | 629 | } |
629 | } | 630 | } |
630 | p.setType( type ); | 631 | p.setType( type ); |
631 | 632 | ||
632 | return p; | 633 | return p; |
633 | } | 634 | } |
634 | 635 | ||
635 | QString VCardFormatImpl::readTextValue( ContentLine *cl ) | 636 | QString VCardFormatImpl::readTextValue( ContentLine *cl ) |
636 | { | 637 | { |
637 | VCARD::Value *value = cl->value(); | 638 | VCARD::Value *value = cl->value(); |
638 | if ( value ) { | 639 | if ( value ) { |
639 | return QString::fromUtf8( value->asString() ); | 640 | return QString::fromUtf8( value->asString() ); |
640 | } else { | 641 | } else { |
641 | kdDebug(5700) << "No value: " << cl->asString() << endl; | 642 | kdDebug(5700) << "No value: " << cl->asString() << endl; |
643 | qDebug("No value: %s", (const char*)(cl->asString())); | ||
642 | return QString::null; | 644 | return QString::null; |
643 | } | 645 | } |
644 | } | 646 | } |
645 | 647 | ||
646 | QDate VCardFormatImpl::readDateValue( ContentLine *cl ) | 648 | QDate VCardFormatImpl::readDateValue( ContentLine *cl ) |
647 | { | 649 | { |
648 | DateValue *dateValue = (DateValue *)cl->value(); | 650 | DateValue *dateValue = (DateValue *)cl->value(); |
649 | if ( dateValue ) | 651 | if ( dateValue ) |
650 | return dateValue->qdate(); | 652 | return dateValue->qdate(); |
651 | else | 653 | else |
652 | return QDate(); | 654 | return QDate(); |
653 | } | 655 | } |
654 | 656 | ||
655 | QDateTime VCardFormatImpl::readDateTimeValue( ContentLine *cl ) | 657 | QDateTime VCardFormatImpl::readDateTimeValue( ContentLine *cl ) |
656 | { | 658 | { |
657 | DateValue *dateValue = (DateValue *)cl->value(); | 659 | DateValue *dateValue = (DateValue *)cl->value(); |
658 | if ( dateValue ) | 660 | if ( dateValue ) |
659 | return dateValue->qdt(); | 661 | return dateValue->qdt(); |
660 | else | 662 | else |
661 | return QDateTime(); | 663 | return QDateTime(); |
662 | } | 664 | } |
663 | 665 | ||
664 | Geo VCardFormatImpl::readGeoValue( ContentLine *cl ) | 666 | Geo VCardFormatImpl::readGeoValue( ContentLine *cl ) |
665 | { | 667 | { |
666 | GeoValue *geoValue = (GeoValue *)cl->value(); | 668 | GeoValue *geoValue = (GeoValue *)cl->value(); |
667 | if ( geoValue ) { | 669 | if ( geoValue ) { |
668 | Geo geo( geoValue->latitude(), geoValue->longitude() ); | 670 | Geo geo( geoValue->latitude(), geoValue->longitude() ); |
669 | return geo; | 671 | return geo; |
670 | } else | 672 | } else |
671 | return Geo(); | 673 | return Geo(); |
672 | } | 674 | } |
673 | 675 | ||
674 | TimeZone VCardFormatImpl::readUTCValue( ContentLine *cl ) | 676 | TimeZone VCardFormatImpl::readUTCValue( ContentLine *cl ) |
675 | { | 677 | { |
676 | UTCValue *utcValue = (UTCValue *)cl->value(); | 678 | UTCValue *utcValue = (UTCValue *)cl->value(); |
677 | if ( utcValue ) { | 679 | if ( utcValue ) { |
678 | TimeZone tz; | 680 | TimeZone tz; |
679 | tz.setOffset(((utcValue->hour()*60)+utcValue->minute())*(utcValue->positive() ? 1 : -1)); | 681 | tz.setOffset(((utcValue->hour()*60)+utcValue->minute())*(utcValue->positive() ? 1 : -1)); |
680 | return tz; | 682 | return tz; |
681 | } else | 683 | } else |
682 | return TimeZone(); | 684 | return TimeZone(); |
683 | } | 685 | } |
684 | 686 | ||
685 | Secrecy VCardFormatImpl::readClassValue( ContentLine *cl ) | 687 | Secrecy VCardFormatImpl::readClassValue( ContentLine *cl ) |
686 | { | 688 | { |
687 | ClassValue *classValue = (ClassValue *)cl->value(); | 689 | ClassValue *classValue = (ClassValue *)cl->value(); |
688 | if ( classValue ) { | 690 | if ( classValue ) { |
689 | Secrecy secrecy; | 691 | Secrecy secrecy; |
690 | switch ( classValue->type() ) { | 692 | switch ( classValue->type() ) { |
691 | case ClassValue::Public: | 693 | case ClassValue::Public: |
692 | secrecy.setType( Secrecy::Public ); | 694 | secrecy.setType( Secrecy::Public ); |
693 | break; | 695 | break; |
694 | case ClassValue::Private: | 696 | case ClassValue::Private: |
695 | secrecy.setType( Secrecy::Private ); | 697 | secrecy.setType( Secrecy::Private ); |
696 | break; | 698 | break; |
697 | case ClassValue::Confidential: | 699 | case ClassValue::Confidential: |
698 | secrecy.setType( Secrecy::Confidential ); | 700 | secrecy.setType( Secrecy::Confidential ); |
699 | break; | 701 | break; |
700 | } | 702 | } |
701 | 703 | ||
702 | return secrecy; | 704 | return secrecy; |
703 | } else | 705 | } else |
704 | return Secrecy(); | 706 | return Secrecy(); |
705 | } | 707 | } |
706 | 708 | ||
707 | void VCardFormatImpl::addKeyValue( VCARD::VCard *vcard, const Key &key ) | 709 | void VCardFormatImpl::addKeyValue( VCARD::VCard *vcard, const Key &key ) |
708 | { | 710 | { |
709 | ContentLine cl; | 711 | ContentLine cl; |
710 | cl.setName( EntityTypeToParamName( EntityKey ) ); | 712 | cl.setName( EntityTypeToParamName( EntityKey ) ); |
711 | 713 | ||
712 | ParamList params; | 714 | ParamList params; |
713 | if ( key.isBinary() ) { | 715 | if ( key.isBinary() ) { |
714 | cl.setValue( new TextValue( KCodecs::base64Encode( key.binaryData() ) ) ); | 716 | cl.setValue( new TextValue( KCodecs::base64Encode( key.binaryData() ) ) ); |
715 | params.append( new Param( "ENCODING", "b" ) ); | 717 | params.append( new Param( "ENCODING", "b" ) ); |
716 | } else { | 718 | } else { |
717 | cl.setValue( new TextValue( key.textData().utf8() ) ); | 719 | cl.setValue( new TextValue( key.textData().utf8() ) ); |
718 | } | 720 | } |
719 | 721 | ||
720 | switch ( key.type() ) { | 722 | switch ( key.type() ) { |
721 | case Key::X509: | 723 | case Key::X509: |
722 | params.append( new Param( "TYPE", "X509" ) ); | 724 | params.append( new Param( "TYPE", "X509" ) ); |
723 | break; | 725 | break; |
724 | case Key::PGP: | 726 | case Key::PGP: |
725 | params.append( new Param( "TYPE", "PGP" ) ); | 727 | params.append( new Param( "TYPE", "PGP" ) ); |
726 | break; | 728 | break; |
727 | case Key::Custom: | 729 | case Key::Custom: |
728 | params.append( new Param( "TYPE", key.customTypeString().utf8() ) ); | 730 | params.append( new Param( "TYPE", key.customTypeString().utf8() ) ); |
729 | break; | 731 | break; |
730 | } | 732 | } |
731 | 733 | ||
732 | cl.setParamList( params ); | 734 | cl.setParamList( params ); |
733 | vcard->add( cl ); | 735 | vcard->add( cl ); |
734 | } | 736 | } |
735 | 737 | ||
736 | Key VCardFormatImpl::readKeyValue( VCARD::ContentLine *cl ) | 738 | Key VCardFormatImpl::readKeyValue( VCARD::ContentLine *cl ) |
737 | { | 739 | { |