summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiedb/osqlitedriver.cpp6
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp661
2 files changed, 228 insertions, 439 deletions
diff --git a/libopie2/opiedb/osqlitedriver.cpp b/libopie2/opiedb/osqlitedriver.cpp
index b9a491e..92f89cf 100644
--- a/libopie2/opiedb/osqlitedriver.cpp
+++ b/libopie2/opiedb/osqlitedriver.cpp
@@ -77,152 +77,152 @@ void OSQLiteDriver::setUrl( const QString& url ) {
77 77
78 78
79void OSQLiteDriver::setOptions( const QStringList& ) { 79void OSQLiteDriver::setOptions( const QStringList& ) {
80} 80}
81 81
82/* 82/*
83 * Functions to patch a regex search into sqlite 83 * Functions to patch a regex search into sqlite
84 */ 84 */
85int sqliteRlikeCompare(const char *zPattern, const char *zString, sqregex *reg){ 85int sqliteRlikeCompare(const char *zPattern, const char *zString, sqregex *reg){
86 int res; 86 int res;
87 if (reg->regex_raw == NULL || (strcmp (zPattern, reg->regex_raw) != 0)){ 87 if (reg->regex_raw == NULL || (strcmp (zPattern, reg->regex_raw) != 0)){
88 if (reg->regex_raw != NULL) { 88 if (reg->regex_raw != NULL) {
89 free(reg->regex_raw); 89 free(reg->regex_raw);
90 regfree(&reg->regex_c); 90 regfree(&reg->regex_c);
91 } 91 }
92 reg->regex_raw = (char *)malloc(strlen(zPattern)+1); 92 reg->regex_raw = (char *)malloc(strlen(zPattern)+1);
93 strncpy(reg->regex_raw, zPattern, strlen(zPattern)+1); 93 strncpy(reg->regex_raw, zPattern, strlen(zPattern)+1);
94 res = regcomp(&reg->regex_c, zPattern, REG_EXTENDED); 94 res = regcomp(&reg->regex_c, zPattern, REG_EXTENDED);
95 if ( res != 0 ) { 95 if ( res != 0 ) {
96 printf("Regcomp failed with code %u on string %s\n",res,zPattern); 96 printf("Regcomp failed with code %u on string %s\n",res,zPattern);
97 free(reg->regex_raw); 97 free(reg->regex_raw);
98 reg->regex_raw=NULL; 98 reg->regex_raw=NULL;
99 return 0; 99 return 0;
100 } 100 }
101 } 101 }
102 res = (regexec(&reg->regex_c, zString, 0, NULL, 0)==0); 102 res = (regexec(&reg->regex_c, zString, 0, NULL, 0)==0);
103 return res; 103 return res;
104} 104}
105 105
106void rlikeFunc(sqlite_func *context, int arg, const char **argv){ 106void rlikeFunc(sqlite_func *context, int arg, const char **argv){
107 if( argv[0]==0 || argv[1]==0 ){ 107 if( argv[0]==0 || argv[1]==0 ){
108 printf("One of arguments Null!!\n"); 108 printf("One of arguments Null!!\n");
109 return; 109 return;
110 } 110 }
111 sqlite_set_result_int(context, 111 sqlite_set_result_int(context,
112 sqliteRlikeCompare((const char*)argv[0], 112 sqliteRlikeCompare((const char*)argv[0],
113 (const char*)argv[1], (sqregex *)sqlite_user_data(context) )); 113 (const char*)argv[1], (sqregex *)sqlite_user_data(context) ));
114} 114}
115 115
116/* 116/*
117 * try to open a db specified via setUrl 117 * try to open a db specified via setUrl
118 * and options 118 * and options
119 */ 119 */
120bool OSQLiteDriver::open() { 120bool OSQLiteDriver::open() {
121 char *error; 121 char *error;
122 122
123 odebug << "OSQLiteDriver::open: about to open" << oendl; 123 odebug << "OSQLiteDriver::open: about to open" << oendl;
124 m_sqlite = sqlite_open(m_url.local8Bit(), 124 m_sqlite = sqlite_open(m_url.local8Bit(),
125 0, 125 0,
126 &error ); 126 &error );
127 127
128 /* failed to open */ 128 /* failed to open */
129 if (m_sqlite == 0l ) { 129 if (m_sqlite == 0l ) {
130 // FIXME set the last error 130 // FIXME set the last error
131 owarn << "OSQLiteDriver::open: " << error << "" << oendl; 131 owarn << "OSQLiteDriver::open: " << error << "" << oendl;
132 free( error ); 132 free( error );
133 return false; 133 return false;
134 } 134 }
135 if (sqlite_create_function(m_sqlite,"rlike",2,rlikeFunc,&sqreg) != 0) 135 if (sqlite_create_function(m_sqlite,"rlike",2,rlikeFunc,&sqreg) != 0)
136 odebug << "Unable to create user defined function!" << oendl; 136 odebug << "Unable to create user defined function!" << oendl;
137 if (sqlite_function_type(m_sqlite,"rlike",SQLITE_NUMERIC) != 0) 137 if (sqlite_function_type(m_sqlite,"rlike",SQLITE_NUMERIC) != 0)
138 odebug << "Unable to set rlike function result type!" << oendl; 138 odebug << "Unable to set rlike function result type!" << oendl;
139 sqreg.regex_raw = NULL; 139 sqreg.regex_raw = NULL;
140 return true; 140 return true;
141} 141}
142 142
143 143
144/* close the db 144/* close the db
145 * sqlite closes them without 145 * sqlite closes them without
146 * telling failure or success 146 * telling failure or success
147 */ 147 */
148bool OSQLiteDriver::close() { 148bool OSQLiteDriver::close() {
149 if (m_sqlite ) 149 if (m_sqlite )
150 sqlite_close( m_sqlite ), m_sqlite=0l; 150 sqlite_close( m_sqlite ), m_sqlite=0l;
151 if (sqreg.regex_raw != NULL){ 151 if (sqreg.regex_raw != NULL){
152 odebug << "Freeing regex on close" << oendl; 152 odebug << "Freeing regex on close" << oendl;
153 free(sqreg.regex_raw); 153 free(sqreg.regex_raw);
154 sqreg.regex_raw=NULL; 154 sqreg.regex_raw=NULL;
155 regfree(&sqreg.regex_c); 155 regfree(&sqreg.regex_c);
156 } 156 }
157 return true; 157 return true;
158} 158}
159 159
160 160
161/* Query */ 161/* Query */
162OSQLResult OSQLiteDriver::query( OSQLQuery* qu) { 162OSQLResult OSQLiteDriver::query( OSQLQuery* qu) {
163 if ( !m_sqlite ) { 163 if ( !m_sqlite ) {
164 // FIXME set error code 164 // FIXME set error code
165 OSQLResult result( OSQLResult::Failure ); 165 OSQLResult result( OSQLResult::Failure );
166 return result; 166 return result;
167 } 167 }
168 Query query; 168 Query query;
169 query.driver = this; 169 query.driver = this;
170 char *err; 170 char *err;
171 /* SQLITE_OK 0 if return code > 0 == failure */ 171 /* SQLITE_OK 0 if return code > 0 == failure */
172 if ( sqlite_exec(m_sqlite, qu->query().utf8(),&call_back, &query, &err) > 0 ) { 172 if ( sqlite_exec(m_sqlite, qu->query().utf8(),&call_back, &query, &err) > 0 ) {
173 qWarning("OSQLiteDriver::query: Error while executing %s",err); 173 owarn << "OSQLiteDriver::query: Error while executing " << err << "" << oendl;
174 free(err ); 174 free( err );
175 // FixMe Errors 175 // FixMe Errors
176 } 176 }
177 177
178 OSQLResult result(OSQLResult::Success, 178 OSQLResult result(OSQLResult::Success,
179 query.items, 179 query.items,
180 query.errors ); 180 query.errors );
181 return result; 181 return result;
182} 182}
183 183
184 184
185OSQLTable::ValueList OSQLiteDriver::tables() const { 185OSQLTable::ValueList OSQLiteDriver::tables() const {
186 186
187} 187}
188 188
189 189
190OSQLError OSQLiteDriver::lastError() { 190OSQLError OSQLiteDriver::lastError() {
191 OSQLError error; 191 OSQLError error;
192 return error; 192 return error;
193}; 193};
194 194
195 195
196/* handle a callback add the row to the global 196/* handle a callback add the row to the global
197 * OSQLResultItem 197 * OSQLResultItem
198 */ 198 */
199int OSQLiteDriver::handleCallBack( int, char**, char** ) { 199int OSQLiteDriver::handleCallBack( int, char**, char** ) {
200 return 0; 200 return 0;
201} 201}
202 202
203 203
204/* callback_handler add the values to the list*/ 204/* callback_handler add the values to the list*/
205int OSQLiteDriver::call_back( void* voi, int argc, 205int OSQLiteDriver::call_back( void* voi, int argc,
206 char** argv, char** columns) { 206 char** argv, char** columns) {
207 Query* qu = (Query*)voi; 207 Query* qu = (Query*)voi;
208 208
209 //copy them over to a OSQLResultItem 209 //copy them over to a OSQLResultItem
210 QMap<QString, QString> tableString; 210 QMap<QString, QString> tableString;
211 QMap<int, QString> tableInt; 211 QMap<int, QString> tableInt;
212 for (int i = 0; i < argc; i++ ) { 212 for (int i = 0; i < argc; i++ ) {
213 213
214 tableInt.insert( i, QString::fromUtf8( argv[i] ) ); 214 tableInt.insert( i, QString::fromUtf8( argv[i] ) );
215 tableString.insert( QString::fromUtf8( columns[i] ), 215 tableString.insert( QString::fromUtf8( columns[i] ),
216 QString::fromUtf8( argv[i] ) ); 216 QString::fromUtf8( argv[i] ) );
217 } 217 }
218 OSQLResultItem item( tableString, tableInt ); 218 OSQLResultItem item( tableString, tableInt );
219 qu->items.append( item ); 219 qu->items.append( item );
220 220
221 return ((Query*)voi)->driver->handleCallBack( argc, 221 return ((Query*)voi)->driver->handleCallBack( argc,
222 argv, 222 argv,
223 columns ); 223 columns );
224 224
225 225
226} 226}
227 227
228}}} // namespace OPIE::DB::Internal 228}}} // namespace OPIE::DB::Internal
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
index caf3c6e..6b66814 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
@@ -1,749 +1,538 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29/* 29/*
30 * VCard Backend for the OPIE-Contact Database. 30 * VCard Backend for the OPIE-Contact Database.
31 */ 31 */
32 32
33 33
34#include "vobject_p.h" 34#include "vobject_p.h"
35 35
36/* OPIE */ 36/* OPIE */
37#include <opie2/ocontactaccessbackend_vcard.h> 37#include <opie2/ocontactaccessbackend_vcard.h>
38#include <opie2/odebug.h> 38#include <opie2/odebug.h>
39 39
40#include <qpe/timeconversion.h> 40#include <qpe/timeconversion.h>
41 41
42//FIXME: Hack to allow direct access to FILE* fh. Rewrite this! 42//FIXME: Hack to allow direct access to FILE* fh. Rewrite this!
43#define protected public 43#define protected public
44#include <qfile.h> 44#include <qfile.h>
45#undef protected 45#undef protected
46 46
47namespace Opie { 47namespace Opie {
48 48
49OPimContactAccessBackend_VCard::OPimContactAccessBackend_VCard ( const QString& , const QString& filename ): 49OPimContactAccessBackend_VCard::OPimContactAccessBackend_VCard ( const QString& , const QString& filename ):
50 m_dirty( false ), 50 m_dirty( false ),
51 m_file( filename ) 51 m_file( filename )
52{ 52{
53 load(); 53 load();
54} 54}
55 55
56 56
57bool OPimContactAccessBackend_VCard::load () 57bool OPimContactAccessBackend_VCard::load ()
58{ 58{
59 m_map.clear(); 59 m_map.clear();
60 m_dirty = false; 60 m_dirty = false;
61 61
62 VObject* obj = 0l; 62 VObject* obj = 0l;
63 63
64 if ( QFile::exists(m_file) ){ 64 if ( QFile::exists(m_file) ){
65 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); 65 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() );
66 if ( !obj ) 66 if ( !obj )
67 return false; 67 return false;
68 }else{ 68 }else{
69 owarn << "File \"" << m_file << "\" not found !" << oendl; 69 odebug << "File \"" << m_file << "\" not found !" << oendl;
70 return false; 70 return false;
71 } 71 }
72 72
73 while ( obj ) { 73 while ( obj ) {
74 OPimContact con = parseVObject( obj ); 74 OPimContact con = parseVObject( obj );
75 /* 75 /*
76 * if uid is 0 assign a new one 76 * if uid is 0 assign a new one
77 * this at least happens on 77 * this at least happens on
78 * Nokia6210 78 * Nokia6210
79 */ 79 */
80 if ( con.uid() == 0 ){ 80 if ( con.uid() == 0 ){
81 con.setUid( 1 ); 81 con.setUid( 1 );
82 owarn << "assigned new uid " << con.uid() << "" << oendl; 82 owarn << "assigned new uid " << con.uid() << "" << oendl;
83 } 83 }
84 84
85 m_map.insert( con.uid(), con ); 85 m_map.insert( con.uid(), con );
86 86
87 VObject *t = obj; 87 VObject *t = obj;
88 obj = nextVObjectInList(obj); 88 obj = nextVObjectInList(obj);
89 cleanVObject( t ); 89 cleanVObject( t );
90 } 90 }
91 91
92 return true; 92 return true;
93 93
94} 94}
95bool OPimContactAccessBackend_VCard::reload() 95bool OPimContactAccessBackend_VCard::reload()
96{ 96{
97 return load(); 97 return load();
98} 98}
99bool OPimContactAccessBackend_VCard::save() 99bool OPimContactAccessBackend_VCard::save()
100{ 100{
101 if (!m_dirty ) 101 if (!m_dirty )
102 return true; 102 return true;
103 103
104 QFile file( m_file ); 104 QFile file( m_file );
105 if (!file.open(IO_WriteOnly ) ) 105 if (!file.open(IO_WriteOnly ) )
106 return false; 106 return false;
107 107
108 VObject *obj; 108 VObject *obj;
109 obj = newVObject( VCCalProp ); 109 obj = newVObject( VCCalProp );
110 addPropValue( obj, VCVersionProp, "1.0" ); 110 addPropValue( obj, VCVersionProp, "1.0" );
111 111
112 VObject *vo; 112 VObject *vo;
113 for(QMap<int, OPimContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ 113 for(QMap<int, OPimContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){
114 vo = createVObject( *it ); 114 vo = createVObject( *it );
115 writeVObject( file.fh, vo ); //FIXME: HACK!!! 115 writeVObject( file.fh, vo ); //FIXME: HACK!!!
116 cleanVObject( vo ); 116 cleanVObject( vo );
117 } 117 }
118 cleanStrTbl(); 118 cleanStrTbl();
119 deleteVObject( obj ); 119 deleteVObject( obj );
120 120
121 m_dirty = false; 121 m_dirty = false;
122 return true; 122 return true;
123 123
124 124
125} 125}
126void OPimContactAccessBackend_VCard::clear () 126void OPimContactAccessBackend_VCard::clear ()
127{ 127{
128 m_map.clear(); 128 m_map.clear();
129 m_dirty = true; // ??? sure ? (se) 129 m_dirty = true; // ??? sure ? (se)
130} 130}
131 131
132bool OPimContactAccessBackend_VCard::add ( const OPimContact& newcontact ) 132bool OPimContactAccessBackend_VCard::add ( const OPimContact& newcontact )
133{ 133{
134 m_map.insert( newcontact.uid(), newcontact ); 134 m_map.insert( newcontact.uid(), newcontact );
135 m_dirty = true; 135 m_dirty = true;
136 return true; 136 return true;
137} 137}
138 138
139bool OPimContactAccessBackend_VCard::remove ( int uid ) 139bool OPimContactAccessBackend_VCard::remove ( int uid )
140{ 140{
141 m_map.remove( uid ); 141 m_map.remove( uid );
142 m_dirty = true; 142 m_dirty = true;
143 return true; 143 return true;
144} 144}
145 145
146bool OPimContactAccessBackend_VCard::replace ( const OPimContact &contact ) 146bool OPimContactAccessBackend_VCard::replace ( const OPimContact &contact )
147{ 147{
148 m_map.replace( contact.uid(), contact ); 148 m_map.replace( contact.uid(), contact );
149 m_dirty = true; 149 m_dirty = true;
150 return true; 150 return true;
151} 151}
152 152
153OPimContact OPimContactAccessBackend_VCard::find ( int uid ) const 153OPimContact OPimContactAccessBackend_VCard::find ( int uid ) const
154{ 154{
155 return m_map[uid]; 155 return m_map[uid];
156} 156}
157 157
158QArray<int> OPimContactAccessBackend_VCard::allRecords() const 158QArray<int> OPimContactAccessBackend_VCard::allRecords() const
159{ 159{
160 QArray<int> ar( m_map.count() ); 160 QArray<int> ar( m_map.count() );
161 QMap<int, OPimContact>::ConstIterator it; 161 QMap<int, OPimContact>::ConstIterator it;
162 int i = 0; 162 int i = 0;
163 for ( it = m_map.begin(); it != m_map.end(); ++it ) { 163 for ( it = m_map.begin(); it != m_map.end(); ++it ) {
164 ar[i] = it.key(); 164 ar[i] = it.key();
165 i++; 165 i++;
166 } 166 }
167 return ar; 167 return ar;
168} 168}
169 169
170// Not implemented 170// Not implemented
171QArray<int> OPimContactAccessBackend_VCard::queryByExample ( const OPimContact&, int, const QDateTime& ) 171QArray<int> OPimContactAccessBackend_VCard::queryByExample ( const OPimContact&, int, const QDateTime& )
172{ 172{
173 QArray<int> ar(0); 173 QArray<int> ar(0);
174 return ar; 174 return ar;
175} 175}
176 176
177// Not implemented 177// Not implemented
178QArray<int> OPimContactAccessBackend_VCard::matchRegexp( const QRegExp& ) const 178QArray<int> OPimContactAccessBackend_VCard::matchRegexp( const QRegExp& ) const
179{ 179{
180 QArray<int> ar(0); 180 QArray<int> ar(0);
181 return ar; 181 return ar;
182} 182}
183 183
184const uint OPimContactAccessBackend_VCard::querySettings() 184const uint OPimContactAccessBackend_VCard::querySettings()
185{ 185{
186 return 0; // No search possible 186 return 0; // No search possible
187} 187}
188 188
189bool OPimContactAccessBackend_VCard::hasQuerySettings (uint ) const 189bool OPimContactAccessBackend_VCard::hasQuerySettings (uint ) const
190{ 190{
191 return false; // No search possible, therefore all settings invalid ;) 191 return false; // No search possible, therefore all settings invalid ;)
192} 192}
193 193
194bool OPimContactAccessBackend_VCard::wasChangedExternally() 194bool OPimContactAccessBackend_VCard::wasChangedExternally()
195{ 195{
196 return false; // Don't expect concurrent access 196 return false; // Don't expect concurrent access
197} 197}
198 198
199// Not implemented 199// Not implemented
200QArray<int> OPimContactAccessBackend_VCard::sorted( bool , int, int, int ) 200QArray<int> OPimContactAccessBackend_VCard::sorted( bool , int, int, int )
201{ 201{
202 QArray<int> ar(0); 202 QArray<int> ar(0);
203 return ar; 203 return ar;
204} 204}
205 205
206// *** Private stuff *** 206// *** Private stuff ***
207 207
208 208
209OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj ) 209OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj )
210{ 210{
211 OPimContact c; 211 OPimContact c;
212 212
213<<<<<<< ocontactaccessbackend_vcard.cpp
214 VObjectIterator it;
215 initPropIterator( &it, obj );
216 while( moreIteration( &it ) ) {
217 VObject *o = nextVObject( &it );
218 QCString name = vObjectName( o );
219 QString value = QString::fromUtf8( vObjectStringZValue( o ) );
220 qDebug( "(1)Read: %s", QString( value ).latin1() );
221 if ( name == VCNameProp ) {
222 VObjectIterator nit;
223 initPropIterator( &nit, o );
224 while( moreIteration( &nit ) ) {
225 VObject *o = nextVObject( &nit );
226 QCString name = vObjectTypeInfo( o );
227 QString value = QString::fromUtf8( vObjectStringZValue( o ) );
228 qDebug( "(2)Read: %s", value.latin1() );
229 if ( name == VCNamePrefixesProp )
230 c.setTitle( value );
231 else if ( name == VCNameSuffixesProp )
232 c.setSuffix( value );
233 else if ( name == VCFamilyNameProp )
234 c.setLastName( value );
235 else if ( name == VCGivenNameProp )
236 c.setFirstName( value );
237 else if ( name == VCAdditionalNamesProp )
238 c.setMiddleName( value );
239 }
240 }
241 else if ( name == VCAdrProp ) {
242 bool work = TRUE; // default address is work address
243 QString street;
244 QString city;
245 QString region;
246 QString postal;
247 QString country;
248
249 VObjectIterator nit;
250 initPropIterator( &nit, o );
251 while( moreIteration( &nit ) ) {
252 VObject *o = nextVObject( &nit );
253 QCString name = vObjectName( o );
254 QString value = QString::fromUtf8( vObjectStringZValue( o ) );
255 if ( name == VCHomeProp )
256 work = FALSE;
257 else if ( name == VCWorkProp )
258 work = TRUE;
259 else if ( name == VCStreetAddressProp )
260 street = value;
261 else if ( name == VCCityProp )
262 city = value;
263 else if ( name == VCRegionProp )
264 region = value;
265 else if ( name == VCPostalCodeProp )
266 postal = value;
267 else if ( name == VCCountryNameProp )
268 country = value;
269 }
270 if ( work ) {
271 c.setBusinessStreet( street );
272 c.setBusinessCity( city );
273 c.setBusinessCountry( country );
274 c.setBusinessZip( postal );
275 c.setBusinessState( region );
276 } else {
277 c.setHomeStreet( street );
278 c.setHomeCity( city );
279 c.setHomeCountry( country );
280 c.setHomeZip( postal );
281 c.setHomeState( region );
282 }
283 }
284 else if ( name == VCTelephoneProp ) {
285 enum {
286 HOME = 0x01,
287 WORK = 0x02,
288 VOICE = 0x04,
289 CELL = 0x08,
290 FAX = 0x10,
291 PAGER = 0x20,
292 UNKNOWN = 0x80
293 };
294 int type = 0;
295
296 VObjectIterator nit;
297 initPropIterator( &nit, o );
298 while( moreIteration( &nit ) ) {
299 VObject *o = nextVObject( &nit );
300 QCString name = vObjectTypeInfo( o );
301 if ( name == VCHomeProp )
302 type |= HOME;
303 else if ( name == VCWorkProp )
304 type |= WORK;
305 else if ( name == VCVoiceProp )
306 type |= VOICE;
307 else if ( name == VCCellularProp )
308 type |= CELL;
309 else if ( name == VCFaxProp )
310 type |= FAX;
311 else if ( name == VCPagerProp )
312 type |= PAGER;
313 else if ( name == VCPreferredProp )
314 ;
315 else
316 type |= UNKNOWN;
317 }
318 if ( (type & UNKNOWN) != UNKNOWN ) {
319 if ( ( type & (HOME|WORK) ) == 0 ) // default
320 type |= HOME;
321 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default
322 type |= VOICE;
323
324 qWarning("value %s %d", value.data(), type );
325 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) )
326 c.setHomePhone( value );
327 if ( ( type & (FAX|HOME) ) == (FAX|HOME) )
328 c.setHomeFax( value );
329 if ( ( type & (CELL|HOME) ) == (CELL|HOME) )
330 c.setHomeMobile( value );
331 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) && (type & (CELL|WORK) ) != (CELL|WORK) )
332 c.setBusinessPhone( value );
333 if ( ( type & (FAX|WORK) ) == (FAX|WORK) )
334 c.setBusinessFax( value );
335 if ( ( type & (CELL|WORK) ) == (CELL|WORK) )
336 c.setBusinessMobile( value );
337 if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) )
338 c.setBusinessPager( value );
339 }
340 }
341 else if ( name == VCEmailAddressProp ) {
342 QString email = QString::fromUtf8( vObjectStringZValue( o ) );
343 bool valid = TRUE;
344 VObjectIterator nit;
345 initPropIterator( &nit, o );
346 while( moreIteration( &nit ) ) {
347 VObject *o = nextVObject( &nit );
348 QCString name = vObjectTypeInfo( o );
349 if ( name != VCInternetProp && name != VCHomeProp &&
350 name != VCWorkProp &&
351 name != VCPreferredProp )
352 // ### preffered should map to default email
353 valid = FALSE;
354 }
355 if ( valid ) {
356 c.insertEmail( email );
357 }
358 }
359 else if ( name == VCURLProp ) {
360 VObjectIterator nit;
361 initPropIterator( &nit, o );
362 while( moreIteration( &nit ) ) {
363 VObject *o = nextVObject( &nit );
364 QCString name = vObjectTypeInfo( o );
365 if ( name == VCHomeProp )
366 c.setHomeWebpage( value );
367 else if ( name == VCWorkProp )
368 c.setBusinessWebpage( value );
369 }
370 }
371 else if ( name == VCOrgProp ) {
372 VObjectIterator nit;
373 initPropIterator( &nit, o );
374 while( moreIteration( &nit ) ) {
375 VObject *o = nextVObject( &nit );
376 QCString name = vObjectName( o );
377 QString value = QString::fromUtf8( vObjectStringZValue( o ) );
378 if ( name == VCOrgNameProp )
379 c.setCompany( value );
380 else if ( name == VCOrgUnitProp )
381 c.setDepartment( value );
382 else if ( name == VCOrgUnit2Prop )
383 c.setOffice( value );
384 }
385 }
386 else if ( name == VCTitleProp ) {
387 c.setJobTitle( value );
388 }
389 else if ( name == "X-Qtopia-Profession" ) {
390 c.setProfession( value );
391 }
392 else if ( name == "X-Qtopia-Manager" ) {
393 c.setManager( value );
394 }
395 else if ( name == "X-Qtopia-Assistant" ) {
396 c.setAssistant( value );
397 }
398 else if ( name == "X-Qtopia-Spouse" ) {
399 c.setSpouse( value );
400 }
401 else if ( name == "X-Qtopia-Gender" ) {
402 c.setGender( value );
403 }
404 else if ( name == "X-Qtopia-Anniversary" ) {
405 c.setAnniversary( convVCardDateToDate( value ) );
406 }
407 else if ( name == "X-Qtopia-Nickname" ) {
408 c.setNickname( value );
409 }
410 else if ( name == "X-Qtopia-Children" ) {
411 c.setChildren( value );
412 }
413 else if ( name == VCBirthDateProp ) {
414 // Reading Birthdate regarding RFC 2425 (5.8.4)
415 c.setBirthday( convVCardDateToDate( value ) );
416
417 }
418 else if ( name == VCCommentProp ) {
419 c.setNotes( value );
420 }
421=======
422 VObjectIterator it; 213 VObjectIterator it;
423 initPropIterator( &it, obj ); 214 initPropIterator( &it, obj );
424 while( moreIteration( &it ) ) { 215 while( moreIteration( &it ) ) {
425 VObject *o = nextVObject( &it ); 216 VObject *o = nextVObject( &it );
426 QCString name = vObjectName( o ); 217 QCString name = vObjectName( o );
427 QCString value = vObjectStringZValue( o ); 218 QString value = QString::fromUtf8( vObjectStringZValue( o ) );
428 if ( name == VCNameProp ) { 219 odebug << "(1)Read: %s" << QString( value ).latin1() << oendl;
429 VObjectIterator nit; 220 if ( name == VCNameProp ) {
430 initPropIterator( &nit, o ); 221 VObjectIterator nit;
431 while( moreIteration( &nit ) ) { 222 initPropIterator( &nit, o );
432 VObject *o = nextVObject( &nit ); 223 while( moreIteration( &nit ) ) {
433 QCString name = vObjectTypeInfo( o ); 224 VObject *o = nextVObject( &nit );
434 QString value = vObjectStringZValue( o ); 225 QCString name = vObjectTypeInfo( o );
435 if ( name == VCNamePrefixesProp ) 226 QString value = QString::fromUtf8( vObjectStringZValue( o ) );
436 c.setTitle( value ); 227 odebug << "(2)Read: %s" << value.latin1() << oendl;
437 else if ( name == VCNameSuffixesProp ) 228 if ( name == VCNamePrefixesProp )
438 c.setSuffix( value ); 229 c.setTitle( value );
439 else if ( name == VCFamilyNameProp ) 230 else if ( name == VCNameSuffixesProp )
440 c.setLastName( value ); 231 c.setSuffix( value );
441 else if ( name == VCGivenNameProp ) 232 else if ( name == VCFamilyNameProp )
442 c.setFirstName( value ); 233 c.setLastName( value );
443 else if ( name == VCAdditionalNamesProp ) 234 else if ( name == VCGivenNameProp )
444 c.setMiddleName( value ); 235 c.setFirstName( value );
445 } 236 else if ( name == VCAdditionalNamesProp )
446 } 237 c.setMiddleName( value );
447 else if ( name == VCAdrProp ) { 238 }
448 bool work = TRUE; // default address is work address 239 }
449 QString street; 240 else if ( name == VCAdrProp ) {
450 QString city; 241 bool work = TRUE; // default address is work address
451 QString region; 242 QString street;
452 QString postal; 243 QString city;
453 QString country; 244 QString region;
454 245 QString postal;
455 VObjectIterator nit; 246 QString country;
456 initPropIterator( &nit, o ); 247
457 while( moreIteration( &nit ) ) { 248 VObjectIterator nit;
458 VObject *o = nextVObject( &nit ); 249 initPropIterator( &nit, o );
459 QCString name = vObjectName( o ); 250 while( moreIteration( &nit ) ) {
460 QString value = vObjectStringZValue( o ); 251 VObject *o = nextVObject( &nit );
461 if ( name == VCHomeProp ) 252 QCString name = vObjectName( o );
462 work = FALSE; 253 QString value = QString::fromUtf8( vObjectStringZValue( o ) );
463 else if ( name == VCWorkProp ) 254 if ( name == VCHomeProp )
464 work = TRUE; 255 work = FALSE;
465 else if ( name == VCStreetAddressProp ) 256 else if ( name == VCWorkProp )
466 street = value; 257 work = TRUE;
467 else if ( name == VCCityProp ) 258 else if ( name == VCStreetAddressProp )
468 city = value; 259 street = value;
469 else if ( name == VCRegionProp ) 260 else if ( name == VCCityProp )
470 region = value; 261 city = value;
471 else if ( name == VCPostalCodeProp ) 262 else if ( name == VCRegionProp )
472 postal = value; 263 region = value;
473 else if ( name == VCCountryNameProp ) 264 else if ( name == VCPostalCodeProp )
474 country = value; 265 postal = value;
475 } 266 else if ( name == VCCountryNameProp )
476 if ( work ) { 267 country = value;
477 c.setBusinessStreet( street ); 268 }
478 c.setBusinessCity( city ); 269 if ( work ) {
479 c.setBusinessCountry( country ); 270 c.setBusinessStreet( street );
480 c.setBusinessZip( postal ); 271 c.setBusinessCity( city );
481 c.setBusinessState( region ); 272 c.setBusinessCountry( country );
482 } else { 273 c.setBusinessZip( postal );
483 c.setHomeStreet( street ); 274 c.setBusinessState( region );
484 c.setHomeCity( city ); 275 } else {
485 c.setHomeCountry( country ); 276 c.setHomeStreet( street );
486 c.setHomeZip( postal ); 277 c.setHomeCity( city );
487 c.setHomeState( region ); 278 c.setHomeCountry( country );
488 } 279 c.setHomeZip( postal );
489 } 280 c.setHomeState( region );
490 else if ( name == VCTelephoneProp ) { 281 }
491 enum { 282 }
492 HOME = 0x01, 283 else if ( name == VCTelephoneProp ) {
493 WORK = 0x02, 284 enum {
494 VOICE = 0x04, 285 HOME = 0x01,
495 CELL = 0x08, 286 WORK = 0x02,
496 FAX = 0x10, 287 VOICE = 0x04,
497 PAGER = 0x20, 288 CELL = 0x08,
498 UNKNOWN = 0x80 289 FAX = 0x10,
499 }; 290 PAGER = 0x20,
500 int type = 0; 291 UNKNOWN = 0x80
501 292 };
502 VObjectIterator nit; 293 int type = 0;
503 initPropIterator( &nit, o ); 294
504 while( moreIteration( &nit ) ) { 295 VObjectIterator nit;
505 VObject *o = nextVObject( &nit ); 296 initPropIterator( &nit, o );
506 QCString name = vObjectTypeInfo( o ); 297 while( moreIteration( &nit ) ) {
507 if ( name == VCHomeProp ) 298 VObject *o = nextVObject( &nit );
508 type |= HOME; 299 QCString name = vObjectTypeInfo( o );
509 else if ( name == VCWorkProp ) 300 if ( name == VCHomeProp )
510 type |= WORK; 301 type |= HOME;
511 else if ( name == VCVoiceProp ) 302 else if ( name == VCWorkProp )
512 type |= VOICE; 303 type |= WORK;
513 else if ( name == VCCellularProp ) 304 else if ( name == VCVoiceProp )
514 type |= CELL; 305 type |= VOICE;
515 else if ( name == VCFaxProp ) 306 else if ( name == VCCellularProp )
516 type |= FAX; 307 type |= CELL;
517 else if ( name == VCPagerProp ) 308 else if ( name == VCFaxProp )
518 type |= PAGER; 309 type |= FAX;
519 else if ( name == VCPreferredProp ) 310 else if ( name == VCPagerProp )
520 ; 311 type |= PAGER;
521 else 312 else if ( name == VCPreferredProp )
522 type |= UNKNOWN; 313 ;
523 } 314 else
524 if ( (type & UNKNOWN) != UNKNOWN ) { 315 type |= UNKNOWN;
525 if ( ( type & (HOME|WORK) ) == 0 ) // default 316 }
526 type |= HOME; 317 if ( (type & UNKNOWN) != UNKNOWN ) {
527 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default 318 if ( ( type & (HOME|WORK) ) == 0 ) // default
528 type |= VOICE; 319 type |= HOME;
529 320 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default
530 owarn << "value " << value.data() << " " << type << "" << oendl; 321 type |= VOICE;
531 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) ) 322
532 c.setHomePhone( value ); 323 owarn << "value %s %d" << value.data() << type << oendl;
533 if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) 324 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) )
534 c.setHomeFax( value ); 325 c.setHomePhone( value );
535 if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) 326 if ( ( type & (FAX|HOME) ) == (FAX|HOME) )
536 c.setHomeMobile( value ); 327 c.setHomeFax( value );
537 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) && (type & (CELL|WORK) ) != (CELL|WORK) ) 328 if ( ( type & (CELL|HOME) ) == (CELL|HOME) )
538 c.setBusinessPhone( value ); 329 c.setHomeMobile( value );
539 if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) 330 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) && (type & (CELL|WORK) ) != (CELL|WORK) )
540 c.setBusinessFax( value ); 331 c.setBusinessPhone( value );
541 if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) 332 if ( ( type & (FAX|WORK) ) == (FAX|WORK) )
542 c.setBusinessMobile( value ); 333 c.setBusinessFax( value );
543 if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) 334 if ( ( type & (CELL|WORK) ) == (CELL|WORK) )
544 c.setBusinessPager( value ); 335 c.setBusinessMobile( value );
545 } 336 if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) )
546 } 337 c.setBusinessPager( value );
547 else if ( name == VCEmailAddressProp ) { 338 }
548 QString email = vObjectStringZValue( o ); 339 }
549 bool valid = TRUE; 340 else if ( name == VCEmailAddressProp ) {
550 VObjectIterator nit; 341 QString email = QString::fromUtf8( vObjectStringZValue( o ) );
551 initPropIterator( &nit, o ); 342 bool valid = TRUE;
552 while( moreIteration( &nit ) ) { 343 VObjectIterator nit;
553 VObject *o = nextVObject( &nit ); 344 initPropIterator( &nit, o );
554 QCString name = vObjectTypeInfo( o ); 345 while( moreIteration( &nit ) ) {
555 if ( name != VCInternetProp && name != VCHomeProp && 346 VObject *o = nextVObject( &nit );
556 name != VCWorkProp && 347 QCString name = vObjectTypeInfo( o );
557 name != VCPreferredProp ) 348 if ( name != VCInternetProp && name != VCHomeProp &&
558 // ### preffered should map to default email 349 name != VCWorkProp &&
559 valid = FALSE; 350 name != VCPreferredProp )
560 } 351 // ### preffered should map to default email
561 if ( valid ) { 352 valid = FALSE;
562 c.insertEmail( email ); 353 }
563 } 354 if ( valid ) {
564 } 355 c.insertEmail( email );
565 else if ( name == VCURLProp ) { 356 }
566 VObjectIterator nit; 357 }
567 initPropIterator( &nit, o ); 358 else if ( name == VCURLProp ) {
568 while( moreIteration( &nit ) ) { 359 VObjectIterator nit;
569 VObject *o = nextVObject( &nit ); 360 initPropIterator( &nit, o );
570 QCString name = vObjectTypeInfo( o ); 361 while( moreIteration( &nit ) ) {
571 if ( name == VCHomeProp ) 362 VObject *o = nextVObject( &nit );
572 c.setHomeWebpage( value ); 363 QCString name = vObjectTypeInfo( o );
573 else if ( name == VCWorkProp ) 364 if ( name == VCHomeProp )
574 c.setBusinessWebpage( value ); 365 c.setHomeWebpage( value );
575 } 366 else if ( name == VCWorkProp )
576 } 367 c.setBusinessWebpage( value );
577 else if ( name == VCOrgProp ) { 368 }
578 VObjectIterator nit; 369 }
579 initPropIterator( &nit, o ); 370 else if ( name == VCOrgProp ) {
580 while( moreIteration( &nit ) ) { 371 VObjectIterator nit;
581 VObject *o = nextVObject( &nit ); 372 initPropIterator( &nit, o );
582 QCString name = vObjectName( o ); 373 while( moreIteration( &nit ) ) {
583 QString value = vObjectStringZValue( o ); 374 VObject *o = nextVObject( &nit );
584 if ( name == VCOrgNameProp ) 375 QCString name = vObjectName( o );
585 c.setCompany( value ); 376 QString value = QString::fromUtf8( vObjectStringZValue( o ) );
586 else if ( name == VCOrgUnitProp ) 377 if ( name == VCOrgNameProp )
587 c.setDepartment( value ); 378 c.setCompany( value );
588 else if ( name == VCOrgUnit2Prop ) 379 else if ( name == VCOrgUnitProp )
589 c.setOffice( value ); 380 c.setDepartment( value );
590 } 381 else if ( name == VCOrgUnit2Prop )
591 } 382 c.setOffice( value );
592 else if ( name == VCTitleProp ) { 383 }
593 c.setJobTitle( value ); 384 }
594 } 385 else if ( name == VCTitleProp ) {
595 else if ( name == "X-Qtopia-Profession" ) { 386 c.setJobTitle( value );
596 c.setProfession( value ); 387 }
597 } 388 else if ( name == "X-Qtopia-Profession" ) {
598 else if ( name == "X-Qtopia-Manager" ) { 389 c.setProfession( value );
599 c.setManager( value ); 390 }
600 } 391 else if ( name == "X-Qtopia-Manager" ) {
601 else if ( name == "X-Qtopia-Assistant" ) { 392 c.setManager( value );
602 c.setAssistant( value ); 393 }
603 } 394 else if ( name == "X-Qtopia-Assistant" ) {
604 else if ( name == "X-Qtopia-Spouse" ) { 395 c.setAssistant( value );
605 c.setSpouse( value ); 396 }
606 } 397 else if ( name == "X-Qtopia-Spouse" ) {
607 else if ( name == "X-Qtopia-Gender" ) { 398 c.setSpouse( value );
608 c.setGender( value ); 399 }
609 } 400 else if ( name == "X-Qtopia-Gender" ) {
610 else if ( name == "X-Qtopia-Anniversary" ) { 401 c.setGender( value );
611 c.setAnniversary( convVCardDateToDate( value ) ); 402 }
612 } 403 else if ( name == "X-Qtopia-Anniversary" ) {
613 else if ( name == "X-Qtopia-Nickname" ) { 404 c.setAnniversary( convVCardDateToDate( value ) );
614 c.setNickname( value ); 405 }
615 } 406 else if ( name == "X-Qtopia-Nickname" ) {
616 else if ( name == "X-Qtopia-Children" ) { 407 c.setNickname( value );
617 c.setChildren( value ); 408 }
618 } 409 else if ( name == "X-Qtopia-Children" ) {
619 else if ( name == VCBirthDateProp ) { 410 c.setChildren( value );
620 // Reading Birthdate regarding RFC 2425 (5.8.4) 411 }
621 c.setBirthday( convVCardDateToDate( value ) ); 412 else if ( name == VCBirthDateProp ) {
622 413 // Reading Birthdate regarding RFC 2425 (5.8.4)
623 } 414 c.setBirthday( convVCardDateToDate( value ) );
624 else if ( name == VCCommentProp ) { 415
625 c.setNotes( value ); 416 }
626 } 417 else if ( name == VCCommentProp ) {
627>>>>>>> 1.15 418 c.setNotes( value );
419 }
628#if 0 420#if 0
629<<<<<<< ocontactaccessbackend_vcard.cpp 421 else {
630 else { 422 printf("Name: %s, value=%s\n", name.data(), QString::fromUtf8( vObjectStringZValue( o ) ) );
631 printf("Name: %s, value=%s\n", name.data(), QString::fromUtf8( vObjectStringZValue( o ) ) ); 423 VObjectIterator nit;
632 VObjectIterator nit; 424 initPropIterator( &nit, o );
633 initPropIterator( &nit, o ); 425 while( moreIteration( &nit ) ) {
634 while( moreIteration( &nit ) ) { 426 VObject *o = nextVObject( &nit );
635 VObject *o = nextVObject( &nit ); 427 QCString name = vObjectName( o );
636 QCString name = vObjectName( o ); 428 QString value = QString::fromUtf8( vObjectStringZValue( o ) );
637 QString value = QString::fromUtf8( vObjectStringZValue( o ) ); 429 printf(" subprop: %s = %s\n", name.data(), value.latin1() );
638 printf(" subprop: %s = %s\n", name.data(), value.latin1() ); 430 }
639 } 431 }
640 }
641=======
642 else { 432 else {
643 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); 433 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
644 VObjectIterator nit; 434 VObjectIterator nit;
645 initPropIterator( &nit, o ); 435 initPropIterator( &nit, o );
646 while( moreIteration( &nit ) ) { 436 while( moreIteration( &nit ) ) {
647 VObject *o = nextVObject( &nit ); 437 VObject *o = nextVObject( &nit );
648 QCString name = vObjectName( o ); 438 QCString name = vObjectName( o );
649 QString value = vObjectStringZValue( o ); 439 QString value = vObjectStringZValue( o );
650 printf(" subprop: %s = %s\n", name.data(), value.latin1() ); 440 printf(" subprop: %s = %s\n", name.data(), value.latin1() );
651 } 441 }
652 } 442 }
653>>>>>>> 1.15
654#endif 443#endif
655 } 444 }
656 c.setFileAs(); 445 c.setFileAs();
657 return c; 446 return c;
658} 447}
659 448
660 449
661VObject* OPimContactAccessBackend_VCard::createVObject( const OPimContact &c ) 450VObject* OPimContactAccessBackend_VCard::createVObject( const OPimContact &c )
662{ 451{
663 VObject *vcard = newVObject( VCCardProp ); 452 VObject *vcard = newVObject( VCCardProp );
664 safeAddPropValue( vcard, VCVersionProp, "2.1" ); 453 safeAddPropValue( vcard, VCVersionProp, "2.1" );
665 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); 454 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) );
666 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); 455 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) );
667 456
668 // full name 457 // full name
669 safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); 458 safeAddPropValue( vcard, VCFullNameProp, c.fullName() );
670 459
671 // name properties 460 // name properties
672 VObject *name = safeAddProp( vcard, VCNameProp ); 461 VObject *name = safeAddProp( vcard, VCNameProp );
673 safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); 462 safeAddPropValue( name, VCFamilyNameProp, c.lastName() );
674 safeAddPropValue( name, VCGivenNameProp, c.firstName() ); 463 safeAddPropValue( name, VCGivenNameProp, c.firstName() );
675 safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); 464 safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() );
676 safeAddPropValue( name, VCNamePrefixesProp, c.title() ); 465 safeAddPropValue( name, VCNamePrefixesProp, c.title() );
677 safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); 466 safeAddPropValue( name, VCNameSuffixesProp, c.suffix() );
678 467
679 // home properties 468 // home properties
680 VObject *home_adr= safeAddProp( vcard, VCAdrProp ); 469 VObject *home_adr= safeAddProp( vcard, VCAdrProp );
681 safeAddProp( home_adr, VCHomeProp ); 470 safeAddProp( home_adr, VCHomeProp );
682 safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); 471 safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() );
683 safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); 472 safeAddPropValue( home_adr, VCCityProp, c.homeCity() );
684 safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); 473 safeAddPropValue( home_adr, VCRegionProp, c.homeState() );
685 safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); 474 safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() );
686 safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); 475 safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() );
687 476
688 VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); 477 VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() );
689 safeAddProp( home_phone, VCHomeProp ); 478 safeAddProp( home_phone, VCHomeProp );
690 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); 479 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() );
691 safeAddProp( home_phone, VCHomeProp ); 480 safeAddProp( home_phone, VCHomeProp );
692 safeAddProp( home_phone, VCCellularProp ); 481 safeAddProp( home_phone, VCCellularProp );
693 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); 482 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() );
694 safeAddProp( home_phone, VCHomeProp ); 483 safeAddProp( home_phone, VCHomeProp );
695 safeAddProp( home_phone, VCFaxProp ); 484 safeAddProp( home_phone, VCFaxProp );
696 485
697 VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); 486 VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() );
698 safeAddProp( url, VCHomeProp ); 487 safeAddProp( url, VCHomeProp );
699 488
700 // work properties 489 // work properties
701 VObject *work_adr= safeAddProp( vcard, VCAdrProp ); 490 VObject *work_adr= safeAddProp( vcard, VCAdrProp );
702 safeAddProp( work_adr, VCWorkProp ); 491 safeAddProp( work_adr, VCWorkProp );
703 safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); 492 safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() );
704 safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); 493 safeAddPropValue( work_adr, VCCityProp, c.businessCity() );
705 safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); 494 safeAddPropValue( work_adr, VCRegionProp, c.businessState() );
706 safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); 495 safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() );
707 safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); 496 safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() );
708 497
709 VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); 498 VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() );
710 safeAddProp( work_phone, VCWorkProp ); 499 safeAddProp( work_phone, VCWorkProp );
711 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); 500 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() );
712 safeAddProp( work_phone, VCWorkProp ); 501 safeAddProp( work_phone, VCWorkProp );
713 safeAddProp( work_phone, VCCellularProp ); 502 safeAddProp( work_phone, VCCellularProp );
714 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); 503 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() );
715 safeAddProp( work_phone, VCWorkProp ); 504 safeAddProp( work_phone, VCWorkProp );
716 safeAddProp( work_phone, VCFaxProp ); 505 safeAddProp( work_phone, VCFaxProp );
717 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); 506 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() );
718 safeAddProp( work_phone, VCWorkProp ); 507 safeAddProp( work_phone, VCWorkProp );
719 safeAddProp( work_phone, VCPagerProp ); 508 safeAddProp( work_phone, VCPagerProp );
720 509
721 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); 510 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() );
722 safeAddProp( url, VCWorkProp ); 511 safeAddProp( url, VCWorkProp );
723 512
724 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); 513 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() );
725 safeAddProp( title, VCWorkProp ); 514 safeAddProp( title, VCWorkProp );
726 515
727 516
728 QStringList emails = c.emailList(); 517 QStringList emails = c.emailList();
729 // emails.prepend( c.defaultEmail() ); Fix for bugreport #1045 518 // emails.prepend( c.defaultEmail() ); Fix for bugreport #1045
730 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 519 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
731 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); 520 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it );
732 safeAddProp( email, VCInternetProp ); 521 safeAddProp( email, VCInternetProp );
733 } 522 }
734 523
735 safeAddPropValue( vcard, VCNoteProp, c.notes() ); 524 safeAddPropValue( vcard, VCNoteProp, c.notes() );
736 525
737 // Exporting Birthday regarding RFC 2425 (5.8.4) 526 // Exporting Birthday regarding RFC 2425 (5.8.4)
738 if ( c.birthday().isValid() ){ 527 if ( c.birthday().isValid() ){
739 owarn << "Exporting birthday as: " << convDateToVCardDate( c.birthday() ) << "" << oendl; 528 owarn << "Exporting birthday as: " << convDateToVCardDate( c.birthday() ) << "" << oendl;
740 safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) ); 529 safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) );
741 } 530 }
742 531
743 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { 532 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
744 VObject *org = safeAddProp( vcard, VCOrgProp ); 533 VObject *org = safeAddProp( vcard, VCOrgProp );
745 safeAddPropValue( org, VCOrgNameProp, c.company() ); 534 safeAddPropValue( org, VCOrgNameProp, c.company() );
746 safeAddPropValue( org, VCOrgUnitProp, c.department() ); 535 safeAddPropValue( org, VCOrgUnitProp, c.department() );
747 safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); 536 safeAddPropValue( org, VCOrgUnit2Prop, c.office() );
748 } 537 }
749 538