-rw-r--r-- | kabc/vcard/VCardv.cpp | 4 |
1 files changed, 0 insertions, 4 deletions
diff --git a/kabc/vcard/VCardv.cpp b/kabc/vcard/VCardv.cpp index 3f0a5e5..391a69e 100644 --- a/kabc/vcard/VCardv.cpp +++ b/kabc/vcard/VCardv.cpp | |||
@@ -1,164 +1,160 @@ | |||
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 | #include <qcstring.h> | 24 | #include <qcstring.h> |
25 | #include <qstrlist.h> | 25 | #include <qstrlist.h> |
26 | 26 | ||
27 | #include <VCardEntity.h> | 27 | #include <VCardEntity.h> |
28 | #include <VCardVCard.h> | 28 | #include <VCardVCard.h> |
29 | #include <VCardContentLine.h> | 29 | #include <VCardContentLine.h> |
30 | #include <VCardRToken.h> | 30 | #include <VCardRToken.h> |
31 | 31 | ||
32 | #include <VCardDefines.h> | 32 | #include <VCardDefines.h> |
33 | 33 | ||
34 | using namespace VCARD; | 34 | using namespace VCARD; |
35 | 35 | ||
36 | VCard::VCard() | 36 | VCard::VCard() |
37 | :Entity() | 37 | :Entity() |
38 | { | 38 | { |
39 | contentLineList_.setAutoDelete( TRUE ); | 39 | contentLineList_.setAutoDelete( TRUE ); |
40 | } | 40 | } |
41 | 41 | ||
42 | VCard::VCard(const VCard & x) | 42 | VCard::VCard(const VCard & x) |
43 | :Entity(x), | 43 | :Entity(x), |
44 | group_(x.group_) | 44 | group_(x.group_) |
45 | { | 45 | { |
46 | contentLineList_.setAutoDelete( TRUE ); | 46 | contentLineList_.setAutoDelete( TRUE ); |
47 | //US | ||
48 | qDebug("VCard::VCard"); | ||
49 | 47 | ||
50 | QPtrListIterator<ContentLine> it(x.contentLineList_); | 48 | QPtrListIterator<ContentLine> it(x.contentLineList_); |
51 | for (; it.current(); ++it) { | 49 | for (; it.current(); ++it) { |
52 | ContentLine * c = new ContentLine(*it.current()); | 50 | ContentLine * c = new ContentLine(*it.current()); |
53 | contentLineList_.append(c); | 51 | contentLineList_.append(c); |
54 | } | 52 | } |
55 | 53 | ||
56 | } | 54 | } |
57 | 55 | ||
58 | VCard::VCard(const QCString & s) | 56 | VCard::VCard(const QCString & s) |
59 | :Entity(s) | 57 | :Entity(s) |
60 | { | 58 | { |
61 | contentLineList_.setAutoDelete( TRUE ); | 59 | contentLineList_.setAutoDelete( TRUE ); |
62 | } | 60 | } |
63 | 61 | ||
64 | VCard & | 62 | VCard & |
65 | VCard::operator = (VCard & x) | 63 | VCard::operator = (VCard & x) |
66 | { | 64 | { |
67 | //US | ||
68 | qDebug("VCard::operator ="); | ||
69 | if (*this == x) return *this; | 65 | if (*this == x) return *this; |
70 | 66 | ||
71 | group_ = x.group(); | 67 | group_ = x.group(); |
72 | QPtrListIterator<ContentLine> it(x.contentLineList_); | 68 | QPtrListIterator<ContentLine> it(x.contentLineList_); |
73 | for (; it.current(); ++it) { | 69 | for (; it.current(); ++it) { |
74 | ContentLine * c = new ContentLine(*it.current()); | 70 | ContentLine * c = new ContentLine(*it.current()); |
75 | contentLineList_.append(c); | 71 | contentLineList_.append(c); |
76 | } | 72 | } |
77 | 73 | ||
78 | Entity::operator = (x); | 74 | Entity::operator = (x); |
79 | return *this; | 75 | return *this; |
80 | } | 76 | } |
81 | 77 | ||
82 | VCard & | 78 | VCard & |
83 | VCard::operator = (const QCString & s) | 79 | VCard::operator = (const QCString & s) |
84 | { | 80 | { |
85 | Entity::operator = (s); | 81 | Entity::operator = (s); |
86 | return *this; | 82 | return *this; |
87 | } | 83 | } |
88 | 84 | ||
89 | bool | 85 | bool |
90 | VCard::operator == (VCard & x) | 86 | VCard::operator == (VCard & x) |
91 | { | 87 | { |
92 | x.parse(); | 88 | x.parse(); |
93 | return false; | 89 | return false; |
94 | } | 90 | } |
95 | 91 | ||
96 | VCard::~VCard() | 92 | VCard::~VCard() |
97 | { | 93 | { |
98 | } | 94 | } |
99 | 95 | ||
100 | void | 96 | void |
101 | VCard::_parse() | 97 | VCard::_parse() |
102 | { | 98 | { |
103 | vDebug("parse() called"); | 99 | vDebug("parse() called"); |
104 | QStrList l; | 100 | QStrList l; |
105 | 101 | ||
106 | RTokenise(strRep_, "\r\n", l); | 102 | RTokenise(strRep_, "\r\n", l); |
107 | 103 | ||
108 | if (l.count() < 3) { // Invalid VCARD ! | 104 | if (l.count() < 3) { // Invalid VCARD ! |
109 | vDebug("Invalid vcard"); | 105 | vDebug("Invalid vcard"); |
110 | return; | 106 | return; |
111 | } | 107 | } |
112 | 108 | ||
113 | // Get the first line | 109 | // Get the first line |
114 | QCString beginLine = QCString(l.at(0)).stripWhiteSpace(); | 110 | QCString beginLine = QCString(l.at(0)).stripWhiteSpace(); |
115 | 111 | ||
116 | vDebug("Begin line == \"" + beginLine + "\""); | 112 | vDebug("Begin line == \"" + beginLine + "\""); |
117 | 113 | ||
118 | // Remove extra blank lines | 114 | // Remove extra blank lines |
119 | while (QCString(l.last()).isEmpty()) | 115 | while (QCString(l.last()).isEmpty()) |
120 | l.remove(l.last()); | 116 | l.remove(l.last()); |
121 | 117 | ||
122 | // Now we know this is the last line | 118 | // Now we know this is the last line |
123 | QCString endLine = l.last(); | 119 | QCString endLine = l.last(); |
124 | 120 | ||
125 | // Trash the first and last lines as we have seen them. | 121 | // Trash the first and last lines as we have seen them. |
126 | l.remove(0u); | 122 | l.remove(0u); |
127 | l.remove(l.last()); | 123 | l.remove(l.last()); |
128 | 124 | ||
129 | /////////////////////////////////////////////////////////////// | 125 | /////////////////////////////////////////////////////////////// |
130 | // FIRST LINE | 126 | // FIRST LINE |
131 | 127 | ||
132 | int split = beginLine.find(':'); | 128 | int split = beginLine.find(':'); |
133 | 129 | ||
134 | if (split == -1) { // invalid, no BEGIN | 130 | if (split == -1) { // invalid, no BEGIN |
135 | vDebug("No split"); | 131 | vDebug("No split"); |
136 | return; | 132 | return; |
137 | } | 133 | } |
138 | 134 | ||
139 | QCString firstPart(beginLine.left(split)); | 135 | QCString firstPart(beginLine.left(split)); |
140 | QCString valuePart(beginLine.mid(split + 1)); | 136 | QCString valuePart(beginLine.mid(split + 1)); |
141 | 137 | ||
142 | split = firstPart.find('.'); | 138 | split = firstPart.find('.'); |
143 | 139 | ||
144 | if (split != -1) { | 140 | if (split != -1) { |
145 | group_ = firstPart.left(split); | 141 | group_ = firstPart.left(split); |
146 | firstPart= firstPart.right(firstPart.length() - split - 1); | 142 | firstPart= firstPart.right(firstPart.length() - split - 1); |
147 | } | 143 | } |
148 | 144 | ||
149 | if (qstrnicmp(firstPart, "BEGIN", 5) != 0) { // No BEGIN ! | 145 | if (qstrnicmp(firstPart, "BEGIN", 5) != 0) { // No BEGIN ! |
150 | vDebug("No BEGIN"); | 146 | vDebug("No BEGIN"); |
151 | return; | 147 | return; |
152 | } | 148 | } |
153 | 149 | ||
154 | if (qstrnicmp(valuePart, "VCARD", 5) != 0) { // Not a vcard ! | 150 | if (qstrnicmp(valuePart, "VCARD", 5) != 0) { // Not a vcard ! |
155 | vDebug("No VCARD"); | 151 | vDebug("No VCARD"); |
156 | return; | 152 | return; |
157 | } | 153 | } |
158 | 154 | ||
159 | /////////////////////////////////////////////////////////////// | 155 | /////////////////////////////////////////////////////////////// |
160 | // CONTENT LINES | 156 | // CONTENT LINES |
161 | // | 157 | // |
162 | vDebug("Content lines"); | 158 | vDebug("Content lines"); |
163 | 159 | ||
164 | // Handle folded lines. | 160 | // Handle folded lines. |