-rw-r--r-- | kabc/vcardparser/vcard.h | 4 | ||||
-rw-r--r-- | kabc/vcardparser/vcardline.cpp | 6 | ||||
-rw-r--r-- | kabc/vcardparser/vcardline.h | 8 | ||||
-rw-r--r-- | kabc/vcardparser/vcardparser.cpp | 2 | ||||
-rw-r--r-- | kabc/vcardparser/vcardtool.cpp | 2 |
5 files changed, 12 insertions, 10 deletions
diff --git a/kabc/vcardparser/vcard.h b/kabc/vcardparser/vcard.h index 0bee441..85b50e4 100644 --- a/kabc/vcardparser/vcard.h +++ b/kabc/vcardparser/vcard.h | |||
@@ -1,66 +1,66 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #ifndef VCARDPARSER_VCARD_H | 21 | #ifndef VCARDPARSER_VCARD_H |
22 | #define VCARDPARSER_VCARD_H | 22 | #define VCARDPARSER_VCARD_H |
23 | 23 | ||
24 | #include "vcardline.h" | 24 | #include "vcardline.h" |
25 | #include <qmap.h> | 25 | #include <qmap.h> |
26 | #include <qstringlist.h> | 26 | #include <qstringlist.h> |
27 | #include <qvaluelist.h> | 27 | #include <q3valuelist.h> |
28 | 28 | ||
29 | namespace KABC { | 29 | namespace KABC { |
30 | 30 | ||
31 | class VCard | 31 | class VCard |
32 | { | 32 | { |
33 | public: | 33 | public: |
34 | typedef QValueList<VCard> List; | 34 | typedef Q3ValueList<VCard> List; |
35 | typedef QMap< QString, VCardLine::List > LineMap; | 35 | typedef QMap< QString, VCardLine::List > LineMap; |
36 | 36 | ||
37 | enum Version { v2_1, v3_0 }; | 37 | enum Version { v2_1, v3_0 }; |
38 | 38 | ||
39 | VCard(); | 39 | VCard(); |
40 | VCard( const VCard& ); | 40 | VCard( const VCard& ); |
41 | 41 | ||
42 | ~VCard(); | 42 | ~VCard(); |
43 | 43 | ||
44 | VCard& operator=( const VCard& ); | 44 | VCard& operator=( const VCard& ); |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * Removes all lines from the vCard. | 47 | * Removes all lines from the vCard. |
48 | */ | 48 | */ |
49 | void clear(); | 49 | void clear(); |
50 | 50 | ||
51 | /** | 51 | /** |
52 | * Returns a list of all identifiers that exists in the | 52 | * Returns a list of all identifiers that exists in the |
53 | * vCard. | 53 | * vCard. |
54 | */ | 54 | */ |
55 | QStringList identifiers() const; | 55 | QStringList identifiers() const; |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * Adds a VCardLine to the VCard | 58 | * Adds a VCardLine to the VCard |
59 | */ | 59 | */ |
60 | void addLine( const VCardLine& line ); | 60 | void addLine( const VCardLine& line ); |
61 | 61 | ||
62 | /** | 62 | /** |
63 | * Returns all lines of the vcard with a special identifier. | 63 | * Returns all lines of the vcard with a special identifier. |
64 | */ | 64 | */ |
65 | VCardLine::List lines( const QString& identifier ) const; | 65 | VCardLine::List lines( const QString& identifier ) const; |
66 | 66 | ||
diff --git a/kabc/vcardparser/vcardline.cpp b/kabc/vcardparser/vcardline.cpp index 8df2d32..c7254a0 100644 --- a/kabc/vcardparser/vcardline.cpp +++ b/kabc/vcardparser/vcardline.cpp | |||
@@ -1,121 +1,123 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include "vcardline.h" | 21 | #include "vcardline.h" |
22 | //Added by qt3to4: | ||
23 | #include <Q3CString> | ||
22 | 24 | ||
23 | using namespace KABC; | 25 | using namespace KABC; |
24 | 26 | ||
25 | class VCardLine::VCardLinePrivate | 27 | class VCardLine::VCardLinePrivate |
26 | { | 28 | { |
27 | public: | 29 | public: |
28 | QString mGroup; | 30 | QString mGroup; |
29 | }; | 31 | }; |
30 | 32 | ||
31 | VCardLine::VCardLine() | 33 | VCardLine::VCardLine() |
32 | : d( 0 ) | 34 | : d( 0 ) |
33 | { | 35 | { |
34 | } | 36 | } |
35 | 37 | ||
36 | VCardLine::VCardLine( const QString &identifier ) | 38 | VCardLine::VCardLine( const QString &identifier ) |
37 | : d( 0 ) | 39 | : d( 0 ) |
38 | { | 40 | { |
39 | mIdentifier = identifier; | 41 | mIdentifier = identifier; |
40 | } | 42 | } |
41 | 43 | ||
42 | VCardLine::VCardLine( const QString &identifier, const QString &value ) | 44 | VCardLine::VCardLine( const QString &identifier, const QString &value ) |
43 | : d( 0 ) | 45 | : d( 0 ) |
44 | { | 46 | { |
45 | mIdentifier = identifier; | 47 | mIdentifier = identifier; |
46 | mValue.assign( value.data(), value.length() ); | 48 | mValue = value; |
47 | } | 49 | } |
48 | 50 | ||
49 | VCardLine::VCardLine( const VCardLine& line ) | 51 | VCardLine::VCardLine( const VCardLine& line ) |
50 | : d( 0 ) | 52 | : d( 0 ) |
51 | { | 53 | { |
52 | mParamMap = line.mParamMap; | 54 | mParamMap = line.mParamMap; |
53 | mValue = line.mValue; | 55 | mValue = line.mValue; |
54 | mIdentifier = line.mIdentifier; | 56 | mIdentifier = line.mIdentifier; |
55 | } | 57 | } |
56 | 58 | ||
57 | VCardLine::~VCardLine() | 59 | VCardLine::~VCardLine() |
58 | { | 60 | { |
59 | delete d; | 61 | delete d; |
60 | d = 0; | 62 | d = 0; |
61 | } | 63 | } |
62 | 64 | ||
63 | VCardLine& VCardLine::operator=( const VCardLine& line ) | 65 | VCardLine& VCardLine::operator=( const VCardLine& line ) |
64 | { | 66 | { |
65 | if ( &line == this ) | 67 | if ( &line == this ) |
66 | return *this; | 68 | return *this; |
67 | 69 | ||
68 | mParamMap = line.mParamMap; | 70 | mParamMap = line.mParamMap; |
69 | mValue = line.mValue; | 71 | mValue = line.mValue; |
70 | mIdentifier = line.mIdentifier; | 72 | mIdentifier = line.mIdentifier; |
71 | 73 | ||
72 | return *this; | 74 | return *this; |
73 | } | 75 | } |
74 | 76 | ||
75 | void VCardLine::setIdentifier( const QString& identifier ) | 77 | void VCardLine::setIdentifier( const QString& identifier ) |
76 | { | 78 | { |
77 | mIdentifier = identifier; | 79 | mIdentifier = identifier; |
78 | } | 80 | } |
79 | 81 | ||
80 | QString VCardLine::identifier() const | 82 | QString VCardLine::identifier() const |
81 | { | 83 | { |
82 | return mIdentifier; | 84 | return mIdentifier; |
83 | } | 85 | } |
84 | 86 | ||
85 | void VCardLine::setValueString( const QString& value ) | 87 | void VCardLine::setValueString( const QString& value ) |
86 | { | 88 | { |
87 | setValueCString( value.utf8() ); | 89 | setValueCString( value.utf8() ); |
88 | } | 90 | } |
89 | void VCardLine::setValueCString( const QCString& value ) | 91 | void VCardLine::setValueCString( const Q3CString& value ) |
90 | { | 92 | { |
91 | mValue.duplicate( value.data(), value.length() ); | 93 | mValue.duplicate( value.data(), value.length() ); |
92 | } | 94 | } |
93 | 95 | ||
94 | void VCardLine::setValueBytes( const QByteArray& value ) | 96 | void VCardLine::setValueBytes( const QByteArray& value ) |
95 | { | 97 | { |
96 | mValue = value; | 98 | mValue = value; |
97 | } | 99 | } |
98 | 100 | ||
99 | QString VCardLine::valueString() const | 101 | QString VCardLine::valueString() const |
100 | { | 102 | { |
101 | return QString::fromUtf8( mValue.data(), mValue.size() ); | 103 | return QString::fromUtf8( mValue.data(), mValue.size() ); |
102 | } | 104 | } |
103 | 105 | ||
104 | QByteArray VCardLine::valueBytes() const | 106 | QByteArray VCardLine::valueBytes() const |
105 | { | 107 | { |
106 | return mValue; | 108 | return mValue; |
107 | } | 109 | } |
108 | 110 | ||
109 | void VCardLine::setGroup( const QString& group ) | 111 | void VCardLine::setGroup( const QString& group ) |
110 | { | 112 | { |
111 | if ( !d ) | 113 | if ( !d ) |
112 | d = new VCardLinePrivate(); | 114 | d = new VCardLinePrivate(); |
113 | 115 | ||
114 | d->mGroup = group; | 116 | d->mGroup = group; |
115 | } | 117 | } |
116 | 118 | ||
117 | QString VCardLine::group() const | 119 | QString VCardLine::group() const |
118 | { | 120 | { |
119 | if ( d ) | 121 | if ( d ) |
120 | return d->mGroup; | 122 | return d->mGroup; |
121 | else | 123 | else |
diff --git a/kabc/vcardparser/vcardline.h b/kabc/vcardparser/vcardline.h index 8dc9322..dc4bdec 100644 --- a/kabc/vcardparser/vcardline.h +++ b/kabc/vcardparser/vcardline.h | |||
@@ -1,94 +1,94 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #ifndef VCARDLINE_H | 21 | #ifndef VCARDLINE_H |
22 | #define VCARDLINE_H | 22 | #define VCARDLINE_H |
23 | 23 | ||
24 | #include <qstringlist.h> | 24 | #include <qstringlist.h> |
25 | #include <qvaluelist.h> | 25 | #include <q3valuelist.h> |
26 | #include <qcstring.h> | 26 | #include <q3cstring.h> |
27 | #include <qvariant.h> | 27 | #include <qvariant.h> |
28 | #include <qmap.h> | 28 | #include <qmap.h> |
29 | #include <qstring.h> | 29 | #include <qstring.h> |
30 | 30 | ||
31 | namespace KABC { | 31 | namespace KABC { |
32 | 32 | ||
33 | class VCardLine | 33 | class VCardLine |
34 | { | 34 | { |
35 | public: | 35 | public: |
36 | typedef QValueList<VCardLine> List; | 36 | typedef Q3ValueList<VCardLine> List; |
37 | typedef QMap<QString, QStringList> ParamMap; | 37 | typedef QMap<QString, QStringList> ParamMap; |
38 | 38 | ||
39 | VCardLine(); | 39 | VCardLine(); |
40 | VCardLine( const QString &identifier ); | 40 | VCardLine( const QString &identifier ); |
41 | VCardLine( const QString &identifier, const QString &value ); | 41 | VCardLine( const QString &identifier, const QString &value ); |
42 | VCardLine( const VCardLine& ); | 42 | VCardLine( const VCardLine& ); |
43 | 43 | ||
44 | ~VCardLine(); | 44 | ~VCardLine(); |
45 | 45 | ||
46 | VCardLine& operator=( const VCardLine& ); | 46 | VCardLine& operator=( const VCardLine& ); |
47 | 47 | ||
48 | /** | 48 | /** |
49 | * Sets the identifier of this line e.g. UID, FN, CLASS | 49 | * Sets the identifier of this line e.g. UID, FN, CLASS |
50 | */ | 50 | */ |
51 | void setIdentifier( const QString& identifier ); | 51 | void setIdentifier( const QString& identifier ); |
52 | 52 | ||
53 | /** | 53 | /** |
54 | * Returns the identifier of this line. | 54 | * Returns the identifier of this line. |
55 | */ | 55 | */ |
56 | QString identifier() const; | 56 | QString identifier() const; |
57 | 57 | ||
58 | /** | 58 | /** |
59 | * Sets the value of of this line. | 59 | * Sets the value of of this line. |
60 | */ | 60 | */ |
61 | void setValueString( const QString& value ); | 61 | void setValueString( const QString& value ); |
62 | void setValueCString( const QCString& value ); | 62 | void setValueCString( const Q3CString& value ); |
63 | void setValueBytes( const QByteArray& value ); | 63 | void setValueBytes( const QByteArray& value ); |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * Returns the value of this line. | 66 | * Returns the value of this line. |
67 | */ | 67 | */ |
68 | QString valueString() const; | 68 | QString valueString() const; |
69 | QByteArray valueBytes() const; | 69 | QByteArray valueBytes() const; |
70 | 70 | ||
71 | /** | 71 | /** |
72 | * Sets the group the line belongs to. | 72 | * Sets the group the line belongs to. |
73 | */ | 73 | */ |
74 | void setGroup( const QString& group ); | 74 | void setGroup( const QString& group ); |
75 | 75 | ||
76 | /** | 76 | /** |
77 | * Returns the group the line belongs to. | 77 | * Returns the group the line belongs to. |
78 | */ | 78 | */ |
79 | QString group() const; | 79 | QString group() const; |
80 | 80 | ||
81 | /** | 81 | /** |
82 | * Returns whether the line belongs to a group. | 82 | * Returns whether the line belongs to a group. |
83 | */ | 83 | */ |
84 | bool hasGroup() const; | 84 | bool hasGroup() const; |
85 | 85 | ||
86 | /** | 86 | /** |
87 | * Returns all parameters. | 87 | * Returns all parameters. |
88 | */ | 88 | */ |
89 | QStringList parameterList() const; | 89 | QStringList parameterList() const; |
90 | 90 | ||
91 | /** | 91 | /** |
92 | * Add a new parameter to the line. | 92 | * Add a new parameter to the line. |
93 | */ | 93 | */ |
94 | void addParameter( const QString& param, const QString& value ); | 94 | void addParameter( const QString& param, const QString& value ); |
diff --git a/kabc/vcardparser/vcardparser.cpp b/kabc/vcardparser/vcardparser.cpp index 11622a0..a319531 100644 --- a/kabc/vcardparser/vcardparser.cpp +++ b/kabc/vcardparser/vcardparser.cpp | |||
@@ -189,52 +189,52 @@ QString VCardParser::createVCards( const VCard::List& list ) | |||
189 | // iterate over the lines | 189 | // iterate over the lines |
190 | for ( lineIt = lines.begin(); lineIt != lines.end(); ++lineIt ) { | 190 | for ( lineIt = lines.begin(); lineIt != lines.end(); ++lineIt ) { |
191 | if ( !(*lineIt).valueString().isEmpty() ) { | 191 | if ( !(*lineIt).valueString().isEmpty() ) { |
192 | if ( (*lineIt).hasGroup() ) | 192 | if ( (*lineIt).hasGroup() ) |
193 | textLine = (*lineIt).group() + "." + (*lineIt).identifier(); | 193 | textLine = (*lineIt).group() + "." + (*lineIt).identifier(); |
194 | else | 194 | else |
195 | textLine = (*lineIt).identifier(); | 195 | textLine = (*lineIt).identifier(); |
196 | 196 | ||
197 | params = (*lineIt).parameterList(); | 197 | params = (*lineIt).parameterList(); |
198 | hasEncoding = false; | 198 | hasEncoding = false; |
199 | if ( params.count() > 0 ) { // we have parameters | 199 | if ( params.count() > 0 ) { // we have parameters |
200 | for ( paramIt = params.begin(); paramIt != params.end(); ++paramIt ) { | 200 | for ( paramIt = params.begin(); paramIt != params.end(); ++paramIt ) { |
201 | if ( (*paramIt) == "encoding" ) { | 201 | if ( (*paramIt) == "encoding" ) { |
202 | hasEncoding = true; | 202 | hasEncoding = true; |
203 | encodingType = (*lineIt).parameter( "encoding" ).lower(); | 203 | encodingType = (*lineIt).parameter( "encoding" ).lower(); |
204 | } | 204 | } |
205 | 205 | ||
206 | values = (*lineIt).parameters( *paramIt ); | 206 | values = (*lineIt).parameters( *paramIt ); |
207 | for ( valueIt = values.begin(); valueIt != values.end(); ++valueIt ) { | 207 | for ( valueIt = values.begin(); valueIt != values.end(); ++valueIt ) { |
208 | textLine.append( ";" + (*paramIt).upper() ); | 208 | textLine.append( ";" + (*paramIt).upper() ); |
209 | if ( !(*valueIt).isEmpty() ) | 209 | if ( !(*valueIt).isEmpty() ) |
210 | textLine.append( "=" + (*valueIt) ); | 210 | textLine.append( "=" + (*valueIt) ); |
211 | } | 211 | } |
212 | } | 212 | } |
213 | } | 213 | } |
214 | 214 | ||
215 | if ( hasEncoding ) { // have to encode the data | 215 | if ( hasEncoding ) { // have to encode the data |
216 | QByteArray input, output; | 216 | QByteArray input, output; |
217 | input = (*lineIt).valueBytes(); | 217 | input = (*lineIt).valueBytes(); |
218 | if ( encodingType == "b" ) | 218 | if ( encodingType == "b" ) |
219 | KCodecs::base64Encode( input, output ); | 219 | KCodecs::base64Encode( input, output ); |
220 | else if ( encodingType == "quoted-printable" ) | 220 | else if ( encodingType == "quoted-printable" ) |
221 | KCodecs::quotedPrintableEncode( input, output ); | 221 | KCodecs::quotedPrintableEncode( input, output, true ); |
222 | textLine.append( ":" + QString( output ) ); | 222 | textLine.append( ":" + QString( output ) ); |
223 | } else | 223 | } else |
224 | textLine.append( ":" + (*lineIt).valueString().replace( QRegExp("\n"), "\\n" ) ); | 224 | textLine.append( ":" + (*lineIt).valueString().replace( QRegExp("\n"), "\\n" ) ); |
225 | 225 | ||
226 | if ( textLine.length() > FOLD_WIDTH ) { // we have to fold the line | 226 | if ( textLine.length() > FOLD_WIDTH ) { // we have to fold the line |
227 | for ( uint i = 0; i <= ( textLine.length() / FOLD_WIDTH ); ++i ) | 227 | for ( uint i = 0; i <= ( textLine.length() / FOLD_WIDTH ); ++i ) |
228 | text.append( ( i == 0 ? "" : " " ) + textLine.mid( i * FOLD_WIDTH, FOLD_WIDTH ) + "\r\n" ); | 228 | text.append( ( i == 0 ? "" : " " ) + textLine.mid( i * FOLD_WIDTH, FOLD_WIDTH ) + "\r\n" ); |
229 | } else | 229 | } else |
230 | text.append( textLine + "\r\n" ); | 230 | text.append( textLine + "\r\n" ); |
231 | } | 231 | } |
232 | } | 232 | } |
233 | } | 233 | } |
234 | 234 | ||
235 | text.append( "END:VCARD\r\n" ); | 235 | text.append( "END:VCARD\r\n" ); |
236 | text.append( "\r\n" ); | 236 | text.append( "\r\n" ); |
237 | } | 237 | } |
238 | 238 | ||
239 | return text; | 239 | return text; |
240 | } | 240 | } |
diff --git a/kabc/vcardparser/vcardtool.cpp b/kabc/vcardparser/vcardtool.cpp index 204326e..435c3b0 100644 --- a/kabc/vcardparser/vcardtool.cpp +++ b/kabc/vcardparser/vcardtool.cpp | |||
@@ -623,65 +623,65 @@ QString VCardTool::createDateTime( const QDateTime &dateTime ) | |||
623 | } | 623 | } |
624 | 624 | ||
625 | return str; | 625 | return str; |
626 | } | 626 | } |
627 | 627 | ||
628 | Picture VCardTool::parsePicture( const VCardLine &line ) | 628 | Picture VCardTool::parsePicture( const VCardLine &line ) |
629 | { | 629 | { |
630 | Picture pic; | 630 | Picture pic; |
631 | 631 | ||
632 | const QStringList params = line.parameterList(); | 632 | const QStringList params = line.parameterList(); |
633 | if ( params.findIndex( "encoding" ) != -1 ) { | 633 | if ( params.findIndex( "encoding" ) != -1 ) { |
634 | QImage img; | 634 | QImage img; |
635 | img.loadFromData( line.valueBytes() ); | 635 | img.loadFromData( line.valueBytes() ); |
636 | pic.setData( img ); | 636 | pic.setData( img ); |
637 | } else if ( params.findIndex( "value" ) != -1 ) { | 637 | } else if ( params.findIndex( "value" ) != -1 ) { |
638 | if ( line.parameter( "value" ).lower() == "uri" ) | 638 | if ( line.parameter( "value" ).lower() == "uri" ) |
639 | pic.setUrl( line.valueString() ); | 639 | pic.setUrl( line.valueString() ); |
640 | } | 640 | } |
641 | 641 | ||
642 | if ( params.findIndex( "type" ) != -1 ) | 642 | if ( params.findIndex( "type" ) != -1 ) |
643 | pic.setType( line.parameter( "type" ) ); | 643 | pic.setType( line.parameter( "type" ) ); |
644 | 644 | ||
645 | return pic; | 645 | return pic; |
646 | } | 646 | } |
647 | 647 | ||
648 | VCardLine VCardTool::createPicture( const QString &identifier, const Picture &pic ) | 648 | VCardLine VCardTool::createPicture( const QString &identifier, const Picture &pic ) |
649 | { | 649 | { |
650 | VCardLine line( identifier ); | 650 | VCardLine line( identifier ); |
651 | 651 | ||
652 | if ( pic.isIntern() ) { | 652 | if ( pic.isIntern() ) { |
653 | if ( !pic.data().isNull() ) { | 653 | if ( !pic.data().isNull() ) { |
654 | QByteArray input; | 654 | QByteArray input; |
655 | QDataStream s( input, IO_WriteOnly ); | 655 | QDataStream s( &input, QIODevice::WriteOnly ); |
656 | s.setVersion( 4 ); | 656 | s.setVersion( 4 ); |
657 | s << pic.data(); | 657 | s << pic.data(); |
658 | line.setValueBytes( input ); | 658 | line.setValueBytes( input ); |
659 | line.addParameter( "encoding", "b" ); | 659 | line.addParameter( "encoding", "b" ); |
660 | line.addParameter( "type", "image/png" ); | 660 | line.addParameter( "type", "image/png" ); |
661 | } | 661 | } |
662 | } else if ( !pic.url().isEmpty() ) { | 662 | } else if ( !pic.url().isEmpty() ) { |
663 | QByteArray ba; | 663 | QByteArray ba; |
664 | line.setValueString( pic.url() ); | 664 | line.setValueString( pic.url() ); |
665 | line.addParameter( "value", "URI" ); | 665 | line.addParameter( "value", "URI" ); |
666 | } | 666 | } |
667 | 667 | ||
668 | return line; | 668 | return line; |
669 | } | 669 | } |
670 | 670 | ||
671 | Sound VCardTool::parseSound( const VCardLine &line ) | 671 | Sound VCardTool::parseSound( const VCardLine &line ) |
672 | { | 672 | { |
673 | Sound snd; | 673 | Sound snd; |
674 | 674 | ||
675 | const QStringList params = line.parameterList(); | 675 | const QStringList params = line.parameterList(); |
676 | if ( params.findIndex( "encoding" ) != -1 ) | 676 | if ( params.findIndex( "encoding" ) != -1 ) |
677 | snd.setData( line.valueBytes() ); | 677 | snd.setData( line.valueBytes() ); |
678 | else if ( params.findIndex( "value" ) != -1 ) { | 678 | else if ( params.findIndex( "value" ) != -1 ) { |
679 | if ( line.parameter( "value" ).lower() == "uri" ) | 679 | if ( line.parameter( "value" ).lower() == "uri" ) |
680 | snd.setUrl( line.valueString() ); | 680 | snd.setUrl( line.valueString() ); |
681 | } | 681 | } |
682 | 682 | ||
683 | /* TODO: support sound types | 683 | /* TODO: support sound types |
684 | if ( params.contains( "type" ) ) | 684 | if ( params.contains( "type" ) ) |
685 | snd.setType( line.parameter( "type" ) ); | 685 | snd.setType( line.parameter( "type" ) ); |
686 | */ | 686 | */ |
687 | 687 | ||