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
@@ -1123,5 +1123,10 @@ static VObject *createVObject( const OContact &c )
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() ) {
@@ -1150,4 +1155,20 @@ static VObject *createVObject( const OContact &c )
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{
@@ -1349,7 +1370,11 @@ static OContact parseVObject( VObject *obj )
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 {
@@ -1608,2 +1633,3 @@ void OContact::insertEmails( const QStringList &v )
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
@@ -214,5 +214,5 @@ public:
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 ); }
@@ -225,5 +225,4 @@ private:
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 );
@@ -237,4 +236,6 @@ private:
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;
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
@@ -1123,5 +1123,10 @@ static VObject *createVObject( const OContact &c )
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() ) {
@@ -1150,4 +1155,20 @@ static VObject *createVObject( const OContact &c )
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{
@@ -1349,7 +1370,11 @@ static OContact parseVObject( VObject *obj )
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 {
@@ -1608,2 +1633,3 @@ void OContact::insertEmails( const QStringList &v )
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
@@ -214,5 +214,5 @@ public:
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 ); }
@@ -225,5 +225,4 @@ private:
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 );
@@ -237,4 +236,6 @@ private:
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;