author | zautrix <zautrix> | 2004-10-13 05:15:03 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-13 05:15:03 (UTC) |
commit | f08cf9044213a60c87e2bf299665d13a335feff5 (patch) (unidiff) | |
tree | c9c0e8b0f7f7a48dcee8fbdd5b9a467985c78fdd /kabc | |
parent | 308bc78a3ab0d27718070a5ebdf3f019ac570c6b (diff) | |
download | kdepimpi-f08cf9044213a60c87e2bf299665d13a335feff5.zip kdepimpi-f08cf9044213a60c87e2bf299665d13a335feff5.tar.gz kdepimpi-f08cf9044213a60c87e2bf299665d13a335feff5.tar.bz2 |
fixed some newline probs
-rw-r--r-- | kabc/vcard/ContentLine.cpp | 1 | ||||
-rw-r--r-- | kabc/vcardformatimpl.cpp | 8 | ||||
-rw-r--r-- | kabc/vcardparser/vcardparser.cpp | 2 | ||||
-rw-r--r-- | kabc/vcardparser/vcardtool.cpp | 10 |
4 files changed, 11 insertions, 10 deletions
diff --git a/kabc/vcard/ContentLine.cpp b/kabc/vcard/ContentLine.cpp index f7e04a9..c368172 100644 --- a/kabc/vcard/ContentLine.cpp +++ b/kabc/vcard/ContentLine.cpp | |||
@@ -262,59 +262,60 @@ ContentLine::_parse() | |||
262 | case ValueDate: value_ = new DateValue; break; | 262 | case ValueDate: value_ = new DateValue; break; |
263 | case ValueTextList: value_ = new TextListValue;break; | 263 | case ValueTextList: value_ = new TextListValue;break; |
264 | case ValueGeo: value_ = new GeoValue; break; | 264 | case ValueGeo: value_ = new GeoValue; break; |
265 | case ValueText: | 265 | case ValueText: |
266 | case ValueUnknown: | 266 | case ValueUnknown: |
267 | default: value_ = new TextValue; break; | 267 | default: value_ = new TextValue; break; |
268 | } | 268 | } |
269 | 269 | ||
270 | *value_ = valuePart; | 270 | *value_ = valuePart; |
271 | } | 271 | } |
272 | 272 | ||
273 | void | 273 | void |
274 | ContentLine::_assemble() | 274 | ContentLine::_assemble() |
275 | { | 275 | { |
276 | vDebug("Assemble (argl) - my name is \"" + name_ + "\""); | 276 | vDebug("Assemble (argl) - my name is \"" + name_ + "\""); |
277 | strRep_.truncate(0); | 277 | strRep_.truncate(0); |
278 | 278 | ||
279 | QCString line; | 279 | QCString line; |
280 | 280 | ||
281 | if (!group_.isEmpty()) | 281 | if (!group_.isEmpty()) |
282 | line += group_ + '.'; | 282 | line += group_ + '.'; |
283 | 283 | ||
284 | line += name_; | 284 | line += name_; |
285 | 285 | ||
286 | vDebug("Adding parameters"); | 286 | vDebug("Adding parameters"); |
287 | ParamListIterator it(paramList_); | 287 | ParamListIterator it(paramList_); |
288 | 288 | ||
289 | for (; it.current(); ++it) | 289 | for (; it.current(); ++it) |
290 | line += ";" + it.current()->asString(); | 290 | line += ";" + it.current()->asString(); |
291 | 291 | ||
292 | vDebug("Adding value"); | 292 | vDebug("Adding value"); |
293 | if (value_ != 0) | 293 | if (value_ != 0) |
294 | line += ":" + value_->asString(); | 294 | line += ":" + value_->asString(); |
295 | else | 295 | else |
296 | vDebug("No value"); | 296 | vDebug("No value"); |
297 | 297 | ||
298 | // Quote newlines | 298 | // Quote newlines |
299 | line = line.replace( QRegExp( "\n" ), "\\n" ); | 299 | line = line.replace( QRegExp( "\n" ), "\\n" ); |
300 | 300 | ||
301 | // Fold lines longer than 72 chars | 301 | // Fold lines longer than 72 chars |
302 | const int maxLen = 72; | 302 | const int maxLen = 72; |
303 | uint cursor = 0; | 303 | uint cursor = 0; |
304 | while( line.length() > ( cursor + 1 ) * maxLen ) { | 304 | while( line.length() > ( cursor + 1 ) * maxLen ) { |
305 | strRep_ += line.mid( cursor * maxLen, maxLen ); | 305 | strRep_ += line.mid( cursor * maxLen, maxLen ); |
306 | strRep_ += "\r\n "; | 306 | strRep_ += "\r\n "; |
307 | ++cursor; | 307 | ++cursor; |
308 | } | 308 | } |
309 | strRep_ += line.mid( cursor * maxLen ); | 309 | strRep_ += line.mid( cursor * maxLen ); |
310 | //qDebug("ContentLine::_assemble()\n%s*****", strRep_.data()); | ||
310 | } | 311 | } |
311 | 312 | ||
312 | void | 313 | void |
313 | ContentLine::clear() | 314 | ContentLine::clear() |
314 | { | 315 | { |
315 | group_.truncate(0); | 316 | group_.truncate(0); |
316 | name_.truncate(0); | 317 | name_.truncate(0); |
317 | paramList_.clear(); | 318 | paramList_.clear(); |
318 | delete value_; | 319 | delete value_; |
319 | value_ = 0; | 320 | value_ = 0; |
320 | } | 321 | } |
diff --git a/kabc/vcardformatimpl.cpp b/kabc/vcardformatimpl.cpp index ede5773..c31af46 100644 --- a/kabc/vcardformatimpl.cpp +++ b/kabc/vcardformatimpl.cpp | |||
@@ -803,100 +803,100 @@ void VCardFormatImpl::addAgentValue( VCARD::VCard *vcard, const Agent &agent ) | |||
803 | writeToString( (*addr), vstr ); | 803 | writeToString( (*addr), vstr ); |
804 | 804 | ||
805 | qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct"); | 805 | qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct"); |
806 | /*US | 806 | /*US |
807 | vstr.replace( ":", "\\:" ); | 807 | vstr.replace( ":", "\\:" ); |
808 | vstr.replace( ",", "\\," ); | 808 | vstr.replace( ",", "\\," ); |
809 | vstr.replace( ";", "\\;" ); | 809 | vstr.replace( ";", "\\;" ); |
810 | vstr.replace( "\r\n", "\\n" ); | 810 | vstr.replace( "\r\n", "\\n" ); |
811 | */ | 811 | */ |
812 | vstr.replace( QRegExp(":"), "\\:" ); | 812 | vstr.replace( QRegExp(":"), "\\:" ); |
813 | vstr.replace( QRegExp(","), "\\," ); | 813 | vstr.replace( QRegExp(","), "\\," ); |
814 | vstr.replace( QRegExp(";"), "\\;" ); | 814 | vstr.replace( QRegExp(";"), "\\;" ); |
815 | vstr.replace( QRegExp("\r\n"), "\\n" ); | 815 | vstr.replace( QRegExp("\r\n"), "\\n" ); |
816 | 816 | ||
817 | cl.setValue( new TextValue( vstr.utf8() ) ); | 817 | cl.setValue( new TextValue( vstr.utf8() ) ); |
818 | } else | 818 | } else |
819 | return; | 819 | return; |
820 | } else { | 820 | } else { |
821 | cl.setValue( new TextValue( agent.url().utf8() ) ); | 821 | cl.setValue( new TextValue( agent.url().utf8() ) ); |
822 | params.append( new Param( "VALUE", "uri" ) ); | 822 | params.append( new Param( "VALUE", "uri" ) ); |
823 | } | 823 | } |
824 | 824 | ||
825 | cl.setParamList( params ); | 825 | cl.setParamList( params ); |
826 | vcard->add( cl ); | 826 | vcard->add( cl ); |
827 | } | 827 | } |
828 | 828 | ||
829 | Agent VCardFormatImpl::readAgentValue( VCARD::ContentLine *cl ) | 829 | Agent VCardFormatImpl::readAgentValue( VCARD::ContentLine *cl ) |
830 | { | 830 | { |
831 | Agent agent; | 831 | Agent agent; |
832 | bool isIntern = true; | 832 | bool isIntern = true; |
833 | TextValue *v = (TextValue *)cl->value(); | 833 | TextValue *v = (TextValue *)cl->value(); |
834 | 834 | ||
835 | ParamList params = cl->paramList(); | 835 | ParamList params = cl->paramList(); |
836 | ParamListIterator it( params ); | 836 | ParamListIterator it( params ); |
837 | for( ; it.current(); ++it ) { | 837 | for( ; it.current(); ++it ) { |
838 | if ( (*it)->name() == "VALUE" && (*it)->value() == "uri" ) | 838 | if ( (*it)->name() == "VALUE" && (*it)->value() == "uri" ) |
839 | isIntern = false; | 839 | isIntern = false; |
840 | } | 840 | } |
841 | 841 | ||
842 | if ( isIntern ) { | 842 | if ( isIntern ) { |
843 | QString vstr = QString::fromUtf8( v->asString() ); | 843 | QString vstr = QString::fromUtf8( v->asString() ); |
844 | qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct"); | 844 | qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct"); |
845 | /*US | 845 | /*US |
846 | vstr.replace( "\\n", "\r\n" ); | 846 | vstr.replace( "\\n", "\r\n" ); |
847 | vstr.replace( "\\:", ":" ); | 847 | vstr.replace( "\\:", ":" ); |
848 | vstr.replace( "\\,", "," ); | 848 | vstr.replace( "\\,", "," ); |
849 | vstr.replace( "\\;", ";" ); | 849 | vstr.replace( "\\;", ";" ); |
850 | */ | 850 | */ |
851 | vstr.replace( QRegExp("\\n"), "\r\n" ); | 851 | vstr.replace( QRegExp("\\\\n"), "\r\n" ); |
852 | vstr.replace( QRegExp("\\:"), ":" ); | 852 | vstr.replace( QRegExp("\\\\:"), ":" ); |
853 | vstr.replace( QRegExp("\\,"), "," ); | 853 | vstr.replace( QRegExp("\\\\,"), "," ); |
854 | vstr.replace( QRegExp("\\;"), ";" ); | 854 | vstr.replace( QRegExp("\\\\;"), ";" ); |
855 | 855 | ||
856 | Addressee *addr = new Addressee; | 856 | Addressee *addr = new Addressee; |
857 | readFromString( vstr, *addr ); | 857 | readFromString( vstr, *addr ); |
858 | agent.setAddressee( addr ); | 858 | agent.setAddressee( addr ); |
859 | } else { | 859 | } else { |
860 | agent.setUrl( QString::fromUtf8( v->asString() ) ); | 860 | agent.setUrl( QString::fromUtf8( v->asString() ) ); |
861 | } | 861 | } |
862 | 862 | ||
863 | return agent; | 863 | return agent; |
864 | } | 864 | } |
865 | 865 | ||
866 | void VCardFormatImpl::addPictureValue( VCARD::VCard *vcard, VCARD::EntityType type, const Picture &pic, const Addressee &addr, bool intern ) | 866 | void VCardFormatImpl::addPictureValue( VCARD::VCard *vcard, VCARD::EntityType type, const Picture &pic, const Addressee &addr, bool intern ) |
867 | { | 867 | { |
868 | ContentLine cl; | 868 | ContentLine cl; |
869 | cl.setName( EntityTypeToParamName( type ) ); | 869 | cl.setName( EntityTypeToParamName( type ) ); |
870 | 870 | ||
871 | if ( pic.isIntern() && pic.data().isNull() ) | 871 | if ( pic.isIntern() && pic.data().isNull() ) |
872 | return; | 872 | return; |
873 | 873 | ||
874 | if ( !pic.isIntern() && pic.url().isEmpty() ) | 874 | if ( !pic.isIntern() && pic.url().isEmpty() ) |
875 | return; | 875 | return; |
876 | 876 | ||
877 | ParamList params; | 877 | ParamList params; |
878 | if ( pic.isIntern() ) { | 878 | if ( pic.isIntern() ) { |
879 | QImage img = pic.data(); | 879 | QImage img = pic.data(); |
880 | if ( intern ) { // only for vCard export we really write the data inline | 880 | if ( intern ) { // only for vCard export we really write the data inline |
881 | QByteArray data; | 881 | QByteArray data; |
882 | QDataStream s( data, IO_WriteOnly ); | 882 | QDataStream s( data, IO_WriteOnly ); |
883 | s.setVersion( 4 ); // to produce valid png files | 883 | s.setVersion( 4 ); // to produce valid png files |
884 | s << img; | 884 | s << img; |
885 | cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) ); | 885 | cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) ); |
886 | 886 | ||
887 | } else { // save picture in cache | 887 | } else { // save picture in cache |
888 | QString dir; | 888 | QString dir; |
889 | if ( type == EntityPhoto ) | 889 | if ( type == EntityPhoto ) |
890 | dir = "photos"; | 890 | dir = "photos"; |
891 | if ( type == EntityLogo ) | 891 | if ( type == EntityLogo ) |
892 | dir = "logos"; | 892 | dir = "logos"; |
893 | 893 | ||
894 | img.save( locateLocal( "data", "kabc/" + dir + "/" + addr.uid() ), pic.type().utf8() ); | 894 | img.save( locateLocal( "data", "kabc/" + dir + "/" + addr.uid() ), pic.type().utf8() ); |
895 | cl.setValue( new TextValue( "<dummy>" ) ); | 895 | cl.setValue( new TextValue( "<dummy>" ) ); |
896 | } | 896 | } |
897 | params.append( new Param( "ENCODING", "b" ) ); | 897 | params.append( new Param( "ENCODING", "b" ) ); |
898 | if ( !pic.type().isEmpty() ) | 898 | if ( !pic.type().isEmpty() ) |
899 | params.append( new Param( "TYPE", pic.type().utf8() ) ); | 899 | params.append( new Param( "TYPE", pic.type().utf8() ) ); |
900 | } else { | 900 | } else { |
901 | 901 | ||
902 | cl.setValue( new TextValue( pic.url().utf8() ) ); | 902 | cl.setValue( new TextValue( pic.url().utf8() ) ); |
diff --git a/kabc/vcardparser/vcardparser.cpp b/kabc/vcardparser/vcardparser.cpp index 9ea084d..bec2a0c 100644 --- a/kabc/vcardparser/vcardparser.cpp +++ b/kabc/vcardparser/vcardparser.cpp | |||
@@ -68,97 +68,97 @@ VCard::List VCardParser::parseVCards( const QString& text ) | |||
68 | 68 | ||
69 | QStringList params = QStringList::split( ';', key ); | 69 | QStringList params = QStringList::split( ';', key ); |
70 | vCardLine.setIdentifier( params[0] ); | 70 | vCardLine.setIdentifier( params[0] ); |
71 | if ( params.count() > 1 ) { // find all parameters | 71 | if ( params.count() > 1 ) { // find all parameters |
72 | for ( uint i = 1; i < params.count(); ++i ) { | 72 | for ( uint i = 1; i < params.count(); ++i ) { |
73 | QStringList pair = QStringList::split( '=', params[i] ); | 73 | QStringList pair = QStringList::split( '=', params[i] ); |
74 | //US if ( pair.size() == 1 ) { | 74 | //US if ( pair.size() == 1 ) { |
75 | if ( pair.count() == 1 ) { | 75 | if ( pair.count() == 1 ) { |
76 | pair.prepend( "type" ); | 76 | pair.prepend( "type" ); |
77 | } | 77 | } |
78 | if ( pair[1].contains( ',' ) ) { // parameter in type=x,y,z format | 78 | if ( pair[1].contains( ',' ) ) { // parameter in type=x,y,z format |
79 | QStringList args = QStringList::split( ',', pair[ 1 ] ); | 79 | QStringList args = QStringList::split( ',', pair[ 1 ] ); |
80 | for ( uint j = 0; j < args.count(); ++j ) | 80 | for ( uint j = 0; j < args.count(); ++j ) |
81 | vCardLine.addParameter( pair[0].lower(), args[j] ); | 81 | vCardLine.addParameter( pair[0].lower(), args[j] ); |
82 | } else | 82 | } else |
83 | vCardLine.addParameter( pair[0].lower(), pair[1] ); | 83 | vCardLine.addParameter( pair[0].lower(), pair[1] ); |
84 | } | 84 | } |
85 | } | 85 | } |
86 | 86 | ||
87 | params = vCardLine.parameterList(); | 87 | params = vCardLine.parameterList(); |
88 | if ( params.contains( "encoding" ) ) { // have to decode the data | 88 | if ( params.contains( "encoding" ) ) { // have to decode the data |
89 | #if 0 | 89 | #if 0 |
90 | QByteArray input, output; | 90 | QByteArray input, output; |
91 | input = value.local8Bit(); | 91 | input = value.local8Bit(); |
92 | if ( vCardLine.parameter( "encoding" ).lower() == "b" ) | 92 | if ( vCardLine.parameter( "encoding" ).lower() == "b" ) |
93 | KCodecs::base64Decode( input, output ); | 93 | KCodecs::base64Decode( input, output ); |
94 | else if ( vCardLine.parameter( "encoding" ).lower() == "quoted-printable" ) | 94 | else if ( vCardLine.parameter( "encoding" ).lower() == "quoted-printable" ) |
95 | KCodecs::quotedPrintableDecode( input, output ); | 95 | KCodecs::quotedPrintableDecode( input, output ); |
96 | 96 | ||
97 | //qDebug("VCardParser::parseVCards has to be verified"); | 97 | //qDebug("VCardParser::parseVCards has to be verified"); |
98 | //US I am not sure if this is correct | 98 | //US I am not sure if this is correct |
99 | //US vCardLine.setValue( output ); | 99 | //US vCardLine.setValue( output ); |
100 | QCString cs(output); | 100 | QCString cs(output); |
101 | qDebug("len1 %d len2 %d ",input.size(), output.size( )); | 101 | qDebug("len1 %d len2 %d ",input.size(), output.size( )); |
102 | #endif | 102 | #endif |
103 | QCString cs = value.local8Bit(); | 103 | QCString cs = value.local8Bit(); |
104 | qDebug("****************************************** "); | 104 | qDebug("****************************************** "); |
105 | qDebug("************* WARNING ******************** "); | 105 | qDebug("************* WARNING ******************** "); |
106 | qDebug("****************************************** "); | 106 | qDebug("****************************************** "); |
107 | qDebug("Make sure, the decoding is done after"); | 107 | qDebug("Make sure, the decoding is done after"); |
108 | qDebug("QVariant conversion!"); | 108 | qDebug("QVariant conversion!"); |
109 | qDebug("Insert Line DECODING OKAY, where this is implemented"); | 109 | qDebug("Insert Line DECODING OKAY, where this is implemented"); |
110 | // use for decoding the above code! | 110 | // use for decoding the above code! |
111 | vCardLine.setValue( cs ); | 111 | vCardLine.setValue( cs ); |
112 | } else { | 112 | } else { |
113 | 113 | ||
114 | //qDebug("VCardParser::parseVCards has to be verified"); | 114 | //qDebug("VCardParser::parseVCards has to be verified"); |
115 | //US vCardLine.setValue( value.replace( "\\n", "\n" ) ); | 115 | //US vCardLine.setValue( value.replace( "\\n", "\n" ) ); |
116 | vCardLine.setValue( value.replace( QRegExp("\\n"), "\n" ) ); | 116 | vCardLine.setValue( value.replace( QRegExp("\\\\n"), "\n" ) ); |
117 | } | 117 | } |
118 | 118 | ||
119 | currentVCard.addLine( vCardLine ); | 119 | currentVCard.addLine( vCardLine ); |
120 | } | 120 | } |
121 | // we do not save the start and end tag as vcardline | 121 | // we do not save the start and end tag as vcardline |
122 | if ( (*it).lower().startsWith( "begin:vcard" ) ) { | 122 | if ( (*it).lower().startsWith( "begin:vcard" ) ) { |
123 | inVCard = true; | 123 | inVCard = true; |
124 | //qDebug("VCardParser::parseVCards has to be verified"); | 124 | //qDebug("VCardParser::parseVCards has to be verified"); |
125 | //US currentLine.setLength( 0 ); | 125 | //US currentLine.setLength( 0 ); |
126 | currentLine = ""; | 126 | currentLine = ""; |
127 | currentVCard.clear(); // flush vcard | 127 | currentVCard.clear(); // flush vcard |
128 | continue; | 128 | continue; |
129 | } | 129 | } |
130 | 130 | ||
131 | if ( (*it).lower().startsWith( "end:vcard" ) ) { | 131 | if ( (*it).lower().startsWith( "end:vcard" ) ) { |
132 | inVCard = false; | 132 | inVCard = false; |
133 | vCardList.append( currentVCard ); | 133 | vCardList.append( currentVCard ); |
134 | //qDebug("VCardParser::parseVCards has to be verified"); | 134 | //qDebug("VCardParser::parseVCards has to be verified"); |
135 | //US currentLine.setLength( 0 ); | 135 | //US currentLine.setLength( 0 ); |
136 | currentLine = ""; | 136 | currentLine = ""; |
137 | currentVCard.clear(); // flush vcard | 137 | currentVCard.clear(); // flush vcard |
138 | continue; | 138 | continue; |
139 | } | 139 | } |
140 | 140 | ||
141 | currentLine = (*it); | 141 | currentLine = (*it); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | 144 | ||
145 | return vCardList; | 145 | return vCardList; |
146 | } | 146 | } |
147 | 147 | ||
148 | QString VCardParser::createVCards( const VCard::List& list ) | 148 | QString VCardParser::createVCards( const VCard::List& list ) |
149 | { | 149 | { |
150 | QString text; | 150 | QString text; |
151 | QString textLine; | 151 | QString textLine; |
152 | QString encodingType; | 152 | QString encodingType; |
153 | QStringList idents; | 153 | QStringList idents; |
154 | QStringList params; | 154 | QStringList params; |
155 | QStringList values; | 155 | QStringList values; |
156 | QStringList::ConstIterator identIt; | 156 | QStringList::ConstIterator identIt; |
157 | QStringList::Iterator paramIt; | 157 | QStringList::Iterator paramIt; |
158 | QStringList::Iterator valueIt; | 158 | QStringList::Iterator valueIt; |
159 | 159 | ||
160 | VCardLine::List lines; | 160 | VCardLine::List lines; |
161 | VCardLine::List::Iterator lineIt; | 161 | VCardLine::List::Iterator lineIt; |
162 | VCard::List::ConstIterator cardIt; | 162 | VCard::List::ConstIterator cardIt; |
163 | 163 | ||
164 | bool hasEncoding; | 164 | bool hasEncoding; |
diff --git a/kabc/vcardparser/vcardtool.cpp b/kabc/vcardparser/vcardtool.cpp index 3fb212e..d1f823b 100644 --- a/kabc/vcardparser/vcardtool.cpp +++ b/kabc/vcardparser/vcardtool.cpp | |||
@@ -767,101 +767,101 @@ Secrecy VCardTool::parseSecrecy( const VCardLine &line ) | |||
767 | Secrecy secrecy; | 767 | Secrecy secrecy; |
768 | 768 | ||
769 | if ( line.value().asString().lower() == "public" ) | 769 | if ( line.value().asString().lower() == "public" ) |
770 | secrecy.setType( Secrecy::Public ); | 770 | secrecy.setType( Secrecy::Public ); |
771 | if ( line.value().asString().lower() == "private" ) | 771 | if ( line.value().asString().lower() == "private" ) |
772 | secrecy.setType( Secrecy::Private ); | 772 | secrecy.setType( Secrecy::Private ); |
773 | if ( line.value().asString().lower() == "confidential" ) | 773 | if ( line.value().asString().lower() == "confidential" ) |
774 | secrecy.setType( Secrecy::Confidential ); | 774 | secrecy.setType( Secrecy::Confidential ); |
775 | 775 | ||
776 | return secrecy; | 776 | return secrecy; |
777 | } | 777 | } |
778 | 778 | ||
779 | VCardLine VCardTool::createSecrecy( const Secrecy &secrecy ) | 779 | VCardLine VCardTool::createSecrecy( const Secrecy &secrecy ) |
780 | { | 780 | { |
781 | VCardLine line( "CLASS" ); | 781 | VCardLine line( "CLASS" ); |
782 | 782 | ||
783 | int type = secrecy.type(); | 783 | int type = secrecy.type(); |
784 | 784 | ||
785 | if ( type == Secrecy::Public ) | 785 | if ( type == Secrecy::Public ) |
786 | line.setValue( "PUBLIC" ); | 786 | line.setValue( "PUBLIC" ); |
787 | else if ( type == Secrecy::Private ) | 787 | else if ( type == Secrecy::Private ) |
788 | line.setValue( "PRIVATE" ); | 788 | line.setValue( "PRIVATE" ); |
789 | else if ( type == Secrecy::Confidential ) | 789 | else if ( type == Secrecy::Confidential ) |
790 | line.setValue( "CONFIDENTIAL" ); | 790 | line.setValue( "CONFIDENTIAL" ); |
791 | 791 | ||
792 | return line; | 792 | return line; |
793 | } | 793 | } |
794 | 794 | ||
795 | Agent VCardTool::parseAgent( const VCardLine &line ) | 795 | Agent VCardTool::parseAgent( const VCardLine &line ) |
796 | { | 796 | { |
797 | Agent agent; | 797 | Agent agent; |
798 | 798 | ||
799 | QStringList params = line.parameterList(); | 799 | QStringList params = line.parameterList(); |
800 | if ( params.contains( "value" ) ) { | 800 | if ( params.contains( "value" ) ) { |
801 | if ( line.parameter( "value" ).lower() == "uri" ) | 801 | if ( line.parameter( "value" ).lower() == "uri" ) |
802 | agent.setUrl( line.value().asString() ); | 802 | agent.setUrl( line.value().asString() ); |
803 | } else { | 803 | } else { |
804 | QString str = line.value().asString(); | 804 | QString str = line.value().asString(); |
805 | 805 | ||
806 | //US using the old implementation instead | 806 | //US using the old implementation instead |
807 | qDebug("VCardTool::parseAgent has to be verified"); | 807 | qDebug("VCardTool::parseAgent has to be verified"); |
808 | /*US | 808 | /*US |
809 | str.replace( "\\n", "\r\n" ); | 809 | str.replace( "\\n", "\r\n" ); |
810 | str.replace( "\\N", "\r\n" ); | 810 | str.replace( "\\N", "\r\n" ); |
811 | str.replace( "\\;", ";" ); | 811 | str.replace( "\\;", ";" ); |
812 | str.replace( "\\:", ":" ); | 812 | str.replace( "\\:", ":" ); |
813 | str.replace( "\\,", "," ); | 813 | str.replace( "\\,", "," ); |
814 | */ | 814 | */ |
815 | str.replace( QRegExp("\\n") , "\r\n" ); | 815 | str.replace( QRegExp("\\\\n") , "\r\n" ); |
816 | str.replace( QRegExp("\\N") , "\r\n" ); | 816 | str.replace( QRegExp("\\\\N") , "\r\n" ); |
817 | str.replace( QRegExp("\\;") , ";" ); | 817 | str.replace( QRegExp("\\\\;") , ";" ); |
818 | str.replace( QRegExp("\\:") , ":" ); | 818 | str.replace( QRegExp("\\\\:") , ":" ); |
819 | str.replace( QRegExp("\\,") , "," ); | 819 | str.replace( QRegExp("\\\\,") , "," ); |
820 | 820 | ||
821 | Addressee::List list = parseVCards( str ); | 821 | Addressee::List list = parseVCards( str ); |
822 | if ( list.count() > 0 ) { | 822 | if ( list.count() > 0 ) { |
823 | Addressee *addr = new Addressee; | 823 | Addressee *addr = new Addressee; |
824 | *addr = list[ 0 ]; | 824 | *addr = list[ 0 ]; |
825 | agent.setAddressee( addr ); | 825 | agent.setAddressee( addr ); |
826 | } | 826 | } |
827 | } | 827 | } |
828 | 828 | ||
829 | return agent; | 829 | return agent; |
830 | } | 830 | } |
831 | 831 | ||
832 | VCardLine VCardTool::createAgent( VCard::Version version, const Agent &agent ) | 832 | VCardLine VCardTool::createAgent( VCard::Version version, const Agent &agent ) |
833 | { | 833 | { |
834 | VCardLine line( "AGENT" ); | 834 | VCardLine line( "AGENT" ); |
835 | 835 | ||
836 | if ( agent.isIntern() ) { | 836 | if ( agent.isIntern() ) { |
837 | if ( agent.addressee() != 0 ) { | 837 | if ( agent.addressee() != 0 ) { |
838 | Addressee::List list; | 838 | Addressee::List list; |
839 | list.append( *agent.addressee() ); | 839 | list.append( *agent.addressee() ); |
840 | 840 | ||
841 | QString str = createVCards( list, version ); | 841 | QString str = createVCards( list, version ); |
842 | 842 | ||
843 | //US using the old implementation instead | 843 | //US using the old implementation instead |
844 | qDebug("VCardTool::createAgent has to be verified"); | 844 | qDebug("VCardTool::createAgent has to be verified"); |
845 | /*US | 845 | /*US |
846 | str.replace( "\r\n", "\\n" ); | 846 | str.replace( "\r\n", "\\n" ); |
847 | str.replace( ";", "\\;" ); | 847 | str.replace( ";", "\\;" ); |
848 | str.replace( ":", "\\:" ); | 848 | str.replace( ":", "\\:" ); |
849 | str.replace( ",", "\\," ); | 849 | str.replace( ",", "\\," ); |
850 | */ | 850 | */ |
851 | str.replace( QRegExp("\r\n"), "\\n" ); | 851 | str.replace( QRegExp("\r\n"), "\\n" ); |
852 | str.replace( QRegExp(";"), "\\;" ); | 852 | str.replace( QRegExp(";"), "\\;" ); |
853 | str.replace( QRegExp(":"), "\\:" ); | 853 | str.replace( QRegExp(":"), "\\:" ); |
854 | str.replace( QRegExp(","), "\\," ); | 854 | str.replace( QRegExp(","), "\\," ); |
855 | line.setValue( str ); | 855 | line.setValue( str ); |
856 | } | 856 | } |
857 | } else if ( !agent.url().isEmpty() ) { | 857 | } else if ( !agent.url().isEmpty() ) { |
858 | line.setValue( agent.url() ); | 858 | line.setValue( agent.url() ); |
859 | line.addParameter( "value", "URI" ); | 859 | line.addParameter( "value", "URI" ); |
860 | } | 860 | } |
861 | 861 | ||
862 | return line; | 862 | return line; |
863 | } | 863 | } |
864 | 864 | ||
865 | QStringList VCardTool::splitString( const QChar &sep, const QString &str ) | 865 | QStringList VCardTool::splitString( const QChar &sep, const QString &str ) |
866 | { | 866 | { |
867 | QStringList list; | 867 | QStringList list; |