summaryrefslogtreecommitdiff
authoreilers <eilers>2002-10-28 13:41:31 (UTC)
committer eilers <eilers>2002-10-28 13:41:31 (UTC)
commitd033fbaff92f1e8e89a96c69dadda068cf3177cd (patch) (unidiff)
treed23b6ee600ef7ac095a2ae191ac63436386351f6
parent54b9d51694242a1f2e0c1898b05c56114827ca10 (diff)
downloadopie-d033fbaff92f1e8e89a96c69dadda068cf3177cd.zip
opie-d033fbaff92f1e8e89a96c69dadda068cf3177cd.tar.gz
opie-d033fbaff92f1e8e89a96c69dadda068cf3177cd.tar.bz2
Vcard now exports date in correct format (Regarding RFC 2425).
Vcard now imports birthday..
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontact.cpp30
-rw-r--r--libopie/pim/ocontact.h5
-rw-r--r--libopie2/opiepim/ocontact.cpp30
-rw-r--r--libopie2/opiepim/ocontact.h5
4 files changed, 62 insertions, 8 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp
index 21fc088..734f5a2 100644
--- a/libopie/pim/ocontact.cpp
+++ b/libopie/pim/ocontact.cpp
@@ -1101,75 +1101,96 @@ static VObject *createVObject( const OContact &c )
1101 safeAddProp( work_phone, VCCellularProp ); 1101 safeAddProp( work_phone, VCCellularProp );
1102 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); 1102 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() );
1103 safeAddProp( work_phone, VCWorkProp ); 1103 safeAddProp( work_phone, VCWorkProp );
1104 safeAddProp( work_phone, VCFaxProp ); 1104 safeAddProp( work_phone, VCFaxProp );
1105 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); 1105 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() );
1106 safeAddProp( work_phone, VCWorkProp ); 1106 safeAddProp( work_phone, VCWorkProp );
1107 safeAddProp( work_phone, VCPagerProp ); 1107 safeAddProp( work_phone, VCPagerProp );
1108 1108
1109 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); 1109 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() );
1110 safeAddProp( url, VCWorkProp ); 1110 safeAddProp( url, VCWorkProp );
1111 1111
1112 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); 1112 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() );
1113 safeAddProp( title, VCWorkProp ); 1113 safeAddProp( title, VCWorkProp );
1114 1114
1115 1115
1116 QStringList emails = c.emailList(); 1116 QStringList emails = c.emailList();
1117 emails.prepend( c.defaultEmail() ); 1117 emails.prepend( c.defaultEmail() );
1118 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 1118 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
1119 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); 1119 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it );
1120 safeAddProp( email, VCInternetProp ); 1120 safeAddProp( email, VCInternetProp );
1121 } 1121 }
1122 1122
1123 safeAddPropValue( vcard, VCNoteProp, c.notes() ); 1123 safeAddPropValue( vcard, VCNoteProp, c.notes() );
1124 1124
1125 safeAddPropValue( vcard, VCBirthDateProp, TimeConversion::toString( c.birthday() ) ); 1125 // Exporting Birthday regarding RFC 2425 (5.8.4)
1126 if ( !c.birthday().isNull() ){
1127 QString birthd_rfc2425 = c.birthday().year() + QString( "-" ) + c.birthday().month() + QString( "-" ) + c.birthday().day();
1128 qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1());
1129 safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() );
1130 }
1126 1131
1127 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { 1132 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
1128 VObject *org = safeAddProp( vcard, VCOrgProp ); 1133 VObject *org = safeAddProp( vcard, VCOrgProp );
1129 safeAddPropValue( org, VCOrgNameProp, c.company() ); 1134 safeAddPropValue( org, VCOrgNameProp, c.company() );
1130 safeAddPropValue( org, VCOrgUnitProp, c.department() ); 1135 safeAddPropValue( org, VCOrgUnitProp, c.department() );
1131 safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); 1136 safeAddPropValue( org, VCOrgUnit2Prop, c.office() );
1132 } 1137 }
1133 1138
1134 // some values we have to export as custom fields 1139 // some values we have to export as custom fields
1135 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); 1140 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() );
1136 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); 1141 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() );
1137 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); 1142 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() );
1138 1143
1139 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); 1144 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() );
1140 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); 1145 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() );
1141 safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) ); 1146 safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) );
1142 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); 1147 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() );
1143 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); 1148 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() );
1144 1149
1145 return vcard; 1150 return vcard;
1146} 1151}
1147 1152
1148 1153
1149/*! 1154/*!
1150 \internal 1155 \internal
1151*/ 1156*/
1157static QDate convVCardDateToDate( const QString& datestr )
1158{
1159 int monthPos = datestr.find('-');
1160 int dayPos = datestr.find('-', monthPos+1 );
1161 if ( monthPos == -1 || dayPos == -1 ) {
1162 qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos );
1163 return QDate();
1164 }
1165 int y = datestr.left( monthPos ).toInt();
1166 int m = datestr.mid( monthPos+1, dayPos - monthPos - 1 ).toInt();
1167 int d = datestr.mid( dayPos+1 ).toInt();
1168 QDate date ( y,m,d );
1169 qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos);
1170 return date;
1171}
1172
1152static OContact parseVObject( VObject *obj ) 1173static OContact parseVObject( VObject *obj )
1153{ 1174{
1154 OContact c; 1175 OContact c;
1155 1176
1156 VObjectIterator it; 1177 VObjectIterator it;
1157 initPropIterator( &it, obj ); 1178 initPropIterator( &it, obj );
1158 while( moreIteration( &it ) ) { 1179 while( moreIteration( &it ) ) {
1159 VObject *o = nextVObject( &it ); 1180 VObject *o = nextVObject( &it );
1160 QCString name = vObjectName( o ); 1181 QCString name = vObjectName( o );
1161 QCString value = vObjectStringZValue( o ); 1182 QCString value = vObjectStringZValue( o );
1162 if ( name == VCNameProp ) { 1183 if ( name == VCNameProp ) {
1163 VObjectIterator nit; 1184 VObjectIterator nit;
1164 initPropIterator( &nit, o ); 1185 initPropIterator( &nit, o );
1165 while( moreIteration( &nit ) ) { 1186 while( moreIteration( &nit ) ) {
1166 VObject *o = nextVObject( &nit ); 1187 VObject *o = nextVObject( &nit );
1167 QCString name = vObjectTypeInfo( o ); 1188 QCString name = vObjectTypeInfo( o );
1168 QString value = vObjectStringZValue( o ); 1189 QString value = vObjectStringZValue( o );
1169 if ( name == VCNamePrefixesProp ) 1190 if ( name == VCNamePrefixesProp )
1170 c.setTitle( value ); 1191 c.setTitle( value );
1171 else if ( name == VCNameSuffixesProp ) 1192 else if ( name == VCNameSuffixesProp )
1172 c.setSuffix( value ); 1193 c.setSuffix( value );
1173 else if ( name == VCFamilyNameProp ) 1194 else if ( name == VCFamilyNameProp )
1174 c.setLastName( value ); 1195 c.setLastName( value );
1175 else if ( name == VCGivenNameProp ) 1196 else if ( name == VCGivenNameProp )
@@ -1327,51 +1348,55 @@ static OContact parseVObject( VObject *obj )
1327 } 1348 }
1328 else if ( name == "X-Qtopia-Profession" ) { 1349 else if ( name == "X-Qtopia-Profession" ) {
1329 c.setProfession( value ); 1350 c.setProfession( value );
1330 } 1351 }
1331 else if ( name == "X-Qtopia-Manager" ) { 1352 else if ( name == "X-Qtopia-Manager" ) {
1332 c.setManager( value ); 1353 c.setManager( value );
1333 } 1354 }
1334 else if ( name == "X-Qtopia-Assistant" ) { 1355 else if ( name == "X-Qtopia-Assistant" ) {
1335 c.setAssistant( value ); 1356 c.setAssistant( value );
1336 } 1357 }
1337 else if ( name == "X-Qtopia-Spouse" ) { 1358 else if ( name == "X-Qtopia-Spouse" ) {
1338 c.setSpouse( value ); 1359 c.setSpouse( value );
1339 } 1360 }
1340 else if ( name == "X-Qtopia-Gender" ) { 1361 else if ( name == "X-Qtopia-Gender" ) {
1341 c.setGender( value ); 1362 c.setGender( value );
1342 } 1363 }
1343 else if ( name == "X-Qtopia-Anniversary" ) { 1364 else if ( name == "X-Qtopia-Anniversary" ) {
1344 c.setAnniversary( TimeConversion::fromString( value ) ); 1365 c.setAnniversary( TimeConversion::fromString( value ) );
1345 } 1366 }
1346 else if ( name == "X-Qtopia-Nickname" ) { 1367 else if ( name == "X-Qtopia-Nickname" ) {
1347 c.setNickname( value ); 1368 c.setNickname( value );
1348 } 1369 }
1349 else if ( name == "X-Qtopia-Children" ) { 1370 else if ( name == "X-Qtopia-Children" ) {
1350 c.setChildren( value ); 1371 c.setChildren( value );
1372 }
1373 else if ( name == VCBirthDateProp ) {
1374 // Reading Birthdate regarding RFC 2425 (5.8.4)
1375 c.setBirthday( convVCardDateToDate( value ) );
1376
1351 } 1377 }
1352 1378
1353
1354#if 0 1379#if 0
1355 else { 1380 else {
1356 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); 1381 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
1357 VObjectIterator nit; 1382 VObjectIterator nit;
1358 initPropIterator( &nit, o ); 1383 initPropIterator( &nit, o );
1359 while( moreIteration( &nit ) ) { 1384 while( moreIteration( &nit ) ) {
1360 VObject *o = nextVObject( &nit ); 1385 VObject *o = nextVObject( &nit );
1361 QCString name = vObjectName( o ); 1386 QCString name = vObjectName( o );
1362 QString value = vObjectStringZValue( o ); 1387 QString value = vObjectStringZValue( o );
1363 printf(" subprop: %s = %s\n", name.data(), value.latin1() ); 1388 printf(" subprop: %s = %s\n", name.data(), value.latin1() );
1364 } 1389 }
1365 } 1390 }
1366#endif 1391#endif
1367 } 1392 }
1368 c.setFileAs(); 1393 c.setFileAs();
1369 return c; 1394 return c;
1370} 1395}
1371 1396
1372/*! 1397/*!
1373 Writes the list of \a contacts as a set of VCards to the file \a filename. 1398 Writes the list of \a contacts as a set of VCards to the file \a filename.
1374*/ 1399*/
1375void OContact::writeVCard( const QString &filename, const QValueList<OContact> &contacts) 1400void OContact::writeVCard( const QString &filename, const QValueList<OContact> &contacts)
1376{ 1401{
1377 QFileDirect f( filename.utf8().data() ); 1402 QFileDirect f( filename.utf8().data() );
@@ -1586,24 +1611,25 @@ void OContact::removeEmail( const QString &v )
1586 } 1611 }
1587} 1612}
1588void OContact::clearEmails() 1613void OContact::clearEmails()
1589{ 1614{
1590 mMap.remove( Qtopia::DefaultEmail ); 1615 mMap.remove( Qtopia::DefaultEmail );
1591 mMap.remove( Qtopia::Emails ); 1616 mMap.remove( Qtopia::Emails );
1592} 1617}
1593void OContact::setDefaultEmail( const QString &v ) 1618void OContact::setDefaultEmail( const QString &v )
1594{ 1619{
1595 QString e = v.simplifyWhiteSpace(); 1620 QString e = v.simplifyWhiteSpace();
1596 1621
1597 //qDebug("OContact::setDefaultEmail %s", e.latin1()); 1622 //qDebug("OContact::setDefaultEmail %s", e.latin1());
1598 replace( Qtopia::DefaultEmail, e ); 1623 replace( Qtopia::DefaultEmail, e );
1599 1624
1600 if ( !e.isEmpty() ) 1625 if ( !e.isEmpty() )
1601 insertEmail( e ); 1626 insertEmail( e );
1602 1627
1603} 1628}
1604 1629
1605void OContact::insertEmails( const QStringList &v ) 1630void OContact::insertEmails( const QStringList &v )
1606{ 1631{
1607 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) 1632 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
1608 insertEmail( *it ); 1633 insertEmail( *it );
1609} 1634}
1635
diff --git a/libopie/pim/ocontact.h b/libopie/pim/ocontact.h
index 9e83150..382ab94 100644
--- a/libopie/pim/ocontact.h
+++ b/libopie/pim/ocontact.h
@@ -192,54 +192,55 @@ public:
192 192
193 static QStringList fields(); 193 static QStringList fields();
194 static QStringList trfields(); 194 static QStringList trfields();
195 static QStringList untrfields(); 195 static QStringList untrfields();
196 196
197 QString toRichText() const; 197 QString toRichText() const;
198 QMap<int, QString> toMap() const; 198 QMap<int, QString> toMap() const;
199 QString field( int key ) const { return find( key ); } 199 QString field( int key ) const { return find( key ); }
200 200
201 201
202 // journaling... 202 // journaling...
203 void saveJournal( journal_action action, const QString &key = QString::null ); 203 void saveJournal( journal_action action, const QString &key = QString::null );
204 void save( QString &buf ) const; 204 void save( QString &buf ) const;
205 205
206 void setUid( int i ) 206 void setUid( int i )
207{ Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); } 207{ Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); }
208 208
209 QString toShortText()const; 209 QString toShortText()const;
210 QString OContact::type()const; 210 QString OContact::type()const;
211 QMap<QString,QString> OContact::toExtraMap() const; 211 QMap<QString,QString> OContact::toExtraMap() const;
212 class QString OContact::recordField(int) const; 212 class QString OContact::recordField(int) const;
213 213
214 // Why private ? (eilers,se) 214 // Why private ? (eilers,se)
215 QString emailSeparator() const { return " "; } 215 QString emailSeparator() const { return " "; }
216 // the emails should be seperated by a comma 216 // the emails should be seperated by a comma
217 void setEmails( const QString &v ); 217 void setEmails( const QString &v );
218 QString emails() const { return find( Qtopia::Emails ); } 218 QString emails() const { return find( Qtopia::Emails ); }
219 219
220 220
221private: 221private:
222 friend class AbEditor; 222 friend class AbEditor;
223 friend class AbTable; 223 friend class AbTable;
224 friend class AddressBookAccessPrivate; 224 friend class AddressBookAccessPrivate;
225 friend class XMLIO; 225 friend class XMLIO;
226 226
227
228 void insert( int key, const QString &value ); 227 void insert( int key, const QString &value );
229 void replace( int key, const QString &value ); 228 void replace( int key, const QString &value );
230 QString find( int key ) const; 229 QString find( int key ) const;
231 230
232 QString displayAddress( const QString &street, 231 QString displayAddress( const QString &street,
233 const QString &city, 232 const QString &city,
234 const QString &state, 233 const QString &state,
235 const QString &zip, 234 const QString &zip,
236 const QString &country ) const; 235 const QString &country ) const;
237 236
238 Qtopia::UidGen &uidGen() { return sUidGen; } 237 Qtopia::UidGen &uidGen() { return sUidGen; }
238
239
239 static Qtopia::UidGen sUidGen; 240 static Qtopia::UidGen sUidGen;
240 QMap<int, QString> mMap; 241 QMap<int, QString> mMap;
241 ContactPrivate *d; 242 ContactPrivate *d;
242}; 243};
243 244
244 245
245#endif 246#endif
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp
index 21fc088..734f5a2 100644
--- a/libopie2/opiepim/ocontact.cpp
+++ b/libopie2/opiepim/ocontact.cpp
@@ -1101,75 +1101,96 @@ static VObject *createVObject( const OContact &c )
1101 safeAddProp( work_phone, VCCellularProp ); 1101 safeAddProp( work_phone, VCCellularProp );
1102 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); 1102 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() );
1103 safeAddProp( work_phone, VCWorkProp ); 1103 safeAddProp( work_phone, VCWorkProp );
1104 safeAddProp( work_phone, VCFaxProp ); 1104 safeAddProp( work_phone, VCFaxProp );
1105 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); 1105 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() );
1106 safeAddProp( work_phone, VCWorkProp ); 1106 safeAddProp( work_phone, VCWorkProp );
1107 safeAddProp( work_phone, VCPagerProp ); 1107 safeAddProp( work_phone, VCPagerProp );
1108 1108
1109 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); 1109 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() );
1110 safeAddProp( url, VCWorkProp ); 1110 safeAddProp( url, VCWorkProp );
1111 1111
1112 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); 1112 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() );
1113 safeAddProp( title, VCWorkProp ); 1113 safeAddProp( title, VCWorkProp );
1114 1114
1115 1115
1116 QStringList emails = c.emailList(); 1116 QStringList emails = c.emailList();
1117 emails.prepend( c.defaultEmail() ); 1117 emails.prepend( c.defaultEmail() );
1118 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 1118 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
1119 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); 1119 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it );
1120 safeAddProp( email, VCInternetProp ); 1120 safeAddProp( email, VCInternetProp );
1121 } 1121 }
1122 1122
1123 safeAddPropValue( vcard, VCNoteProp, c.notes() ); 1123 safeAddPropValue( vcard, VCNoteProp, c.notes() );
1124 1124
1125 safeAddPropValue( vcard, VCBirthDateProp, TimeConversion::toString( c.birthday() ) ); 1125 // Exporting Birthday regarding RFC 2425 (5.8.4)
1126 if ( !c.birthday().isNull() ){
1127 QString birthd_rfc2425 = c.birthday().year() + QString( "-" ) + c.birthday().month() + QString( "-" ) + c.birthday().day();
1128 qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1());
1129 safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() );
1130 }
1126 1131
1127 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { 1132 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
1128 VObject *org = safeAddProp( vcard, VCOrgProp ); 1133 VObject *org = safeAddProp( vcard, VCOrgProp );
1129 safeAddPropValue( org, VCOrgNameProp, c.company() ); 1134 safeAddPropValue( org, VCOrgNameProp, c.company() );
1130 safeAddPropValue( org, VCOrgUnitProp, c.department() ); 1135 safeAddPropValue( org, VCOrgUnitProp, c.department() );
1131 safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); 1136 safeAddPropValue( org, VCOrgUnit2Prop, c.office() );
1132 } 1137 }
1133 1138
1134 // some values we have to export as custom fields 1139 // some values we have to export as custom fields
1135 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); 1140 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() );
1136 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); 1141 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() );
1137 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); 1142 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() );
1138 1143
1139 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); 1144 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() );
1140 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); 1145 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() );
1141 safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) ); 1146 safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) );
1142 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); 1147 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() );
1143 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); 1148 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() );
1144 1149
1145 return vcard; 1150 return vcard;
1146} 1151}
1147 1152
1148 1153
1149/*! 1154/*!
1150 \internal 1155 \internal
1151*/ 1156*/
1157static QDate convVCardDateToDate( const QString& datestr )
1158{
1159 int monthPos = datestr.find('-');
1160 int dayPos = datestr.find('-', monthPos+1 );
1161 if ( monthPos == -1 || dayPos == -1 ) {
1162 qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos );
1163 return QDate();
1164 }
1165 int y = datestr.left( monthPos ).toInt();
1166 int m = datestr.mid( monthPos+1, dayPos - monthPos - 1 ).toInt();
1167 int d = datestr.mid( dayPos+1 ).toInt();
1168 QDate date ( y,m,d );
1169 qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos);
1170 return date;
1171}
1172
1152static OContact parseVObject( VObject *obj ) 1173static OContact parseVObject( VObject *obj )
1153{ 1174{
1154 OContact c; 1175 OContact c;
1155 1176
1156 VObjectIterator it; 1177 VObjectIterator it;
1157 initPropIterator( &it, obj ); 1178 initPropIterator( &it, obj );
1158 while( moreIteration( &it ) ) { 1179 while( moreIteration( &it ) ) {
1159 VObject *o = nextVObject( &it ); 1180 VObject *o = nextVObject( &it );
1160 QCString name = vObjectName( o ); 1181 QCString name = vObjectName( o );
1161 QCString value = vObjectStringZValue( o ); 1182 QCString value = vObjectStringZValue( o );
1162 if ( name == VCNameProp ) { 1183 if ( name == VCNameProp ) {
1163 VObjectIterator nit; 1184 VObjectIterator nit;
1164 initPropIterator( &nit, o ); 1185 initPropIterator( &nit, o );
1165 while( moreIteration( &nit ) ) { 1186 while( moreIteration( &nit ) ) {
1166 VObject *o = nextVObject( &nit ); 1187 VObject *o = nextVObject( &nit );
1167 QCString name = vObjectTypeInfo( o ); 1188 QCString name = vObjectTypeInfo( o );
1168 QString value = vObjectStringZValue( o ); 1189 QString value = vObjectStringZValue( o );
1169 if ( name == VCNamePrefixesProp ) 1190 if ( name == VCNamePrefixesProp )
1170 c.setTitle( value ); 1191 c.setTitle( value );
1171 else if ( name == VCNameSuffixesProp ) 1192 else if ( name == VCNameSuffixesProp )
1172 c.setSuffix( value ); 1193 c.setSuffix( value );
1173 else if ( name == VCFamilyNameProp ) 1194 else if ( name == VCFamilyNameProp )
1174 c.setLastName( value ); 1195 c.setLastName( value );
1175 else if ( name == VCGivenNameProp ) 1196 else if ( name == VCGivenNameProp )
@@ -1327,51 +1348,55 @@ static OContact parseVObject( VObject *obj )
1327 } 1348 }
1328 else if ( name == "X-Qtopia-Profession" ) { 1349 else if ( name == "X-Qtopia-Profession" ) {
1329 c.setProfession( value ); 1350 c.setProfession( value );
1330 } 1351 }
1331 else if ( name == "X-Qtopia-Manager" ) { 1352 else if ( name == "X-Qtopia-Manager" ) {
1332 c.setManager( value ); 1353 c.setManager( value );
1333 } 1354 }
1334 else if ( name == "X-Qtopia-Assistant" ) { 1355 else if ( name == "X-Qtopia-Assistant" ) {
1335 c.setAssistant( value ); 1356 c.setAssistant( value );
1336 } 1357 }
1337 else if ( name == "X-Qtopia-Spouse" ) { 1358 else if ( name == "X-Qtopia-Spouse" ) {
1338 c.setSpouse( value ); 1359 c.setSpouse( value );
1339 } 1360 }
1340 else if ( name == "X-Qtopia-Gender" ) { 1361 else if ( name == "X-Qtopia-Gender" ) {
1341 c.setGender( value ); 1362 c.setGender( value );
1342 } 1363 }
1343 else if ( name == "X-Qtopia-Anniversary" ) { 1364 else if ( name == "X-Qtopia-Anniversary" ) {
1344 c.setAnniversary( TimeConversion::fromString( value ) ); 1365 c.setAnniversary( TimeConversion::fromString( value ) );
1345 } 1366 }
1346 else if ( name == "X-Qtopia-Nickname" ) { 1367 else if ( name == "X-Qtopia-Nickname" ) {
1347 c.setNickname( value ); 1368 c.setNickname( value );
1348 } 1369 }
1349 else if ( name == "X-Qtopia-Children" ) { 1370 else if ( name == "X-Qtopia-Children" ) {
1350 c.setChildren( value ); 1371 c.setChildren( value );
1372 }
1373 else if ( name == VCBirthDateProp ) {
1374 // Reading Birthdate regarding RFC 2425 (5.8.4)
1375 c.setBirthday( convVCardDateToDate( value ) );
1376
1351 } 1377 }
1352 1378
1353
1354#if 0 1379#if 0
1355 else { 1380 else {
1356 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); 1381 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
1357 VObjectIterator nit; 1382 VObjectIterator nit;
1358 initPropIterator( &nit, o ); 1383 initPropIterator( &nit, o );
1359 while( moreIteration( &nit ) ) { 1384 while( moreIteration( &nit ) ) {
1360 VObject *o = nextVObject( &nit ); 1385 VObject *o = nextVObject( &nit );
1361 QCString name = vObjectName( o ); 1386 QCString name = vObjectName( o );
1362 QString value = vObjectStringZValue( o ); 1387 QString value = vObjectStringZValue( o );
1363 printf(" subprop: %s = %s\n", name.data(), value.latin1() ); 1388 printf(" subprop: %s = %s\n", name.data(), value.latin1() );
1364 } 1389 }
1365 } 1390 }
1366#endif 1391#endif
1367 } 1392 }
1368 c.setFileAs(); 1393 c.setFileAs();
1369 return c; 1394 return c;
1370} 1395}
1371 1396
1372/*! 1397/*!
1373 Writes the list of \a contacts as a set of VCards to the file \a filename. 1398 Writes the list of \a contacts as a set of VCards to the file \a filename.
1374*/ 1399*/
1375void OContact::writeVCard( const QString &filename, const QValueList<OContact> &contacts) 1400void OContact::writeVCard( const QString &filename, const QValueList<OContact> &contacts)
1376{ 1401{
1377 QFileDirect f( filename.utf8().data() ); 1402 QFileDirect f( filename.utf8().data() );
@@ -1586,24 +1611,25 @@ void OContact::removeEmail( const QString &v )
1586 } 1611 }
1587} 1612}
1588void OContact::clearEmails() 1613void OContact::clearEmails()
1589{ 1614{
1590 mMap.remove( Qtopia::DefaultEmail ); 1615 mMap.remove( Qtopia::DefaultEmail );
1591 mMap.remove( Qtopia::Emails ); 1616 mMap.remove( Qtopia::Emails );
1592} 1617}
1593void OContact::setDefaultEmail( const QString &v ) 1618void OContact::setDefaultEmail( const QString &v )
1594{ 1619{
1595 QString e = v.simplifyWhiteSpace(); 1620 QString e = v.simplifyWhiteSpace();
1596 1621
1597 //qDebug("OContact::setDefaultEmail %s", e.latin1()); 1622 //qDebug("OContact::setDefaultEmail %s", e.latin1());
1598 replace( Qtopia::DefaultEmail, e ); 1623 replace( Qtopia::DefaultEmail, e );
1599 1624
1600 if ( !e.isEmpty() ) 1625 if ( !e.isEmpty() )
1601 insertEmail( e ); 1626 insertEmail( e );
1602 1627
1603} 1628}
1604 1629
1605void OContact::insertEmails( const QStringList &v ) 1630void OContact::insertEmails( const QStringList &v )
1606{ 1631{
1607 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) 1632 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
1608 insertEmail( *it ); 1633 insertEmail( *it );
1609} 1634}
1635
diff --git a/libopie2/opiepim/ocontact.h b/libopie2/opiepim/ocontact.h
index 9e83150..382ab94 100644
--- a/libopie2/opiepim/ocontact.h
+++ b/libopie2/opiepim/ocontact.h
@@ -192,54 +192,55 @@ public:
192 192
193 static QStringList fields(); 193 static QStringList fields();
194 static QStringList trfields(); 194 static QStringList trfields();
195 static QStringList untrfields(); 195 static QStringList untrfields();
196 196
197 QString toRichText() const; 197 QString toRichText() const;
198 QMap<int, QString> toMap() const; 198 QMap<int, QString> toMap() const;
199 QString field( int key ) const { return find( key ); } 199 QString field( int key ) const { return find( key ); }
200 200
201 201
202 // journaling... 202 // journaling...
203 void saveJournal( journal_action action, const QString &key = QString::null ); 203 void saveJournal( journal_action action, const QString &key = QString::null );
204 void save( QString &buf ) const; 204 void save( QString &buf ) const;
205 205
206 void setUid( int i ) 206 void setUid( int i )
207{ Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); } 207{ Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); }
208 208
209 QString toShortText()const; 209 QString toShortText()const;
210 QString OContact::type()const; 210 QString OContact::type()const;
211 QMap<QString,QString> OContact::toExtraMap() const; 211 QMap<QString,QString> OContact::toExtraMap() const;
212 class QString OContact::recordField(int) const; 212 class QString OContact::recordField(int) const;
213 213
214 // Why private ? (eilers,se) 214 // Why private ? (eilers,se)
215 QString emailSeparator() const { return " "; } 215 QString emailSeparator() const { return " "; }
216 // the emails should be seperated by a comma 216 // the emails should be seperated by a comma
217 void setEmails( const QString &v ); 217 void setEmails( const QString &v );
218 QString emails() const { return find( Qtopia::Emails ); } 218 QString emails() const { return find( Qtopia::Emails ); }
219 219
220 220
221private: 221private:
222 friend class AbEditor; 222 friend class AbEditor;
223 friend class AbTable; 223 friend class AbTable;
224 friend class AddressBookAccessPrivate; 224 friend class AddressBookAccessPrivate;
225 friend class XMLIO; 225 friend class XMLIO;
226 226
227
228 void insert( int key, const QString &value ); 227 void insert( int key, const QString &value );
229 void replace( int key, const QString &value ); 228 void replace( int key, const QString &value );
230 QString find( int key ) const; 229 QString find( int key ) const;
231 230
232 QString displayAddress( const QString &street, 231 QString displayAddress( const QString &street,
233 const QString &city, 232 const QString &city,
234 const QString &state, 233 const QString &state,
235 const QString &zip, 234 const QString &zip,
236 const QString &country ) const; 235 const QString &country ) const;
237 236
238 Qtopia::UidGen &uidGen() { return sUidGen; } 237 Qtopia::UidGen &uidGen() { return sUidGen; }
238
239
239 static Qtopia::UidGen sUidGen; 240 static Qtopia::UidGen sUidGen;
240 QMap<int, QString> mMap; 241 QMap<int, QString> mMap;
241 ContactPrivate *d; 242 ContactPrivate *d;
242}; 243};
243 244
244 245
245#endif 246#endif