summaryrefslogtreecommitdiff
path: root/libopie
authoreilers <eilers>2003-04-22 14:09:11 (UTC)
committer eilers <eilers>2003-04-22 14:09:11 (UTC)
commit84be228e70b7d36627a8610386f44b6928d35d6a (patch) (unidiff)
tree033bed687c526700661df02f412582a5fc8ac8ab /libopie
parent93aa0affde672012c65dcde0df2f5a11078aa376 (diff)
downloadopie-84be228e70b7d36627a8610386f44b6928d35d6a.zip
opie-84be228e70b7d36627a8610386f44b6928d35d6a.tar.gz
opie-84be228e70b7d36627a8610386f44b6928d35d6a.tar.bz2
Fixing incompatibility to Qtopia 1.6 (especially syncing with QTDesktop 1.6):
They using a special format for storing birthdays/anniversaries. This patch does not convert all entries, just new/modificated contacts will be stored in this new format ! Addressbook is able to work with both formats (new and old) Complete conversion will be done by the new kitchensync release, provided soon...
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/libopie.pro2
-rw-r--r--libopie/pim/ocontact.cpp14
-rw-r--r--libopie/pim/ocontact.h4
-rw-r--r--libopie/pim/oconversion.cpp76
-rw-r--r--libopie/pim/oconversion.h36
5 files changed, 121 insertions, 11 deletions
diff --git a/libopie/libopie.pro b/libopie/libopie.pro
index 5550c20..c0ccdf2 100644
--- a/libopie/libopie.pro
+++ b/libopie/libopie.pro
@@ -19,4 +19,5 @@ HEADERS = ofontmenu.h \
19 pim/otodoaccess.h \ 19 pim/otodoaccess.h \
20 pim/otodoaccessbackend.h \ 20 pim/otodoaccessbackend.h \
21 pim/oconversion.h \
21 pim/ocontact.h \ 22 pim/ocontact.h \
22 pim/ocontactaccess.h \ 23 pim/ocontactaccess.h \
@@ -63,4 +64,5 @@ SOURCES = ofontmenu.cc \
63 pim/otodoaccessbackend.cpp \ 64 pim/otodoaccessbackend.cpp \
64 pim/otodoaccessxml.cpp \ 65 pim/otodoaccessxml.cpp \
66 pim/oconversion.cpp \
65 pim/ocontact.cpp \ 67 pim/ocontact.cpp \
66 pim/ocontactaccess.cpp \ 68 pim/ocontactaccess.cpp \
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp
index 9cccfc8..96a5f65 100644
--- a/libopie/pim/ocontact.cpp
+++ b/libopie/pim/ocontact.cpp
@@ -1,7 +1,5 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) 3** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de)
4**
5** This file is part of the Qtopia Environment.
6** 4**
7** This file may be distributed and/or modified under the terms of the 5** This file may be distributed and/or modified under the terms of the
@@ -26,5 +24,5 @@
26 24
27#include <qpe/stringutil.h> 25#include <qpe/stringutil.h>
28#include <qpe/timeconversion.h> 26#include "oconversion.h"
29#include <qpe/timestring.h> 27#include <qpe/timestring.h>
30 28
@@ -1018,5 +1016,5 @@ void OContact::setBirthday( const QDate &v )
1018 1016
1019 if ( v.isValid() ) 1017 if ( v.isValid() )
1020 replace( Qtopia::Birthday, TimeConversion::toString( v ) ); 1018 replace( Qtopia::Birthday, OConversion::dateToString( v ) );
1021 1019
1022} 1020}
@@ -1036,5 +1034,5 @@ void OContact::setAnniversary( const QDate &v )
1036 1034
1037 if ( v.isValid() ) 1035 if ( v.isValid() )
1038 replace( Qtopia::Anniversary, TimeConversion::toString( v ) ); 1036 replace( Qtopia::Anniversary, OConversion::dateToString( v ) );
1039} 1037}
1040 1038
@@ -1047,5 +1045,5 @@ QDate OContact::birthday() const
1047 qWarning ("Birthday %s", str.latin1() ); 1045 qWarning ("Birthday %s", str.latin1() );
1048 if ( !str.isEmpty() ) 1046 if ( !str.isEmpty() )
1049 return TimeConversion::fromString ( str ); 1047 return OConversion::dateFromString ( str );
1050 else 1048 else
1051 return QDate(); 1049 return QDate();
@@ -1062,5 +1060,5 @@ QDate OContact::anniversary() const
1062 qWarning ("Anniversary %s", str.latin1() ); 1060 qWarning ("Anniversary %s", str.latin1() );
1063 if ( !str.isEmpty() ) 1061 if ( !str.isEmpty() )
1064 return TimeConversion::fromString ( str ); 1062 return OConversion::dateFromString ( str );
1065 else 1063 else
1066 return empty; 1064 return empty;
diff --git a/libopie/pim/ocontact.h b/libopie/pim/ocontact.h
index 25fa0e7..50f6176 100644
--- a/libopie/pim/ocontact.h
+++ b/libopie/pim/ocontact.h
@@ -1,7 +1,5 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) 3** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de)
4**
5** This file is part of the Qtopia Environment.
6** 4**
7** This file may be distributed and/or modified under the terms of the 5** This file may be distributed and/or modified under the terms of the
diff --git a/libopie/pim/oconversion.cpp b/libopie/pim/oconversion.cpp
new file mode 100644
index 0000000..c3aa89b
--- a/dev/null
+++ b/libopie/pim/oconversion.cpp
@@ -0,0 +1,76 @@
1/**********************************************************************
2** Copyright (C) 2003 by Stefan Eilers (eilers.stefan@epost.de)
3**
4** This file may be distributed and/or modified under the terms of the
5** GNU Lesser General Public License version 2 as published by the Free Software
6** Foundation and appearing in the file LICENSE.GPL included in the
7** packaging of this file.
8**
9** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11**
12**********************************************************************/
13
14#include "oconversion.h"
15#include <qpe/timeconversion.h>
16
17
18QString OConversion::dateToString( const QDate &d )
19{
20 if ( d.isNull() || !d.isValid() )
21 return QString::null;
22
23 // ISO format in year, month, day (YYYYMMDD); e.g. 20021231
24 QString year = QString::number( d.year() );
25 QString month = QString::number( d.month() );
26 month = month.rightJustify( 2, '0' );
27 QString day = QString::number( d.day() );
28 day = day.rightJustify( 2, '0' );
29
30 QString str = year + month + day;
31 //qDebug( "\tPimContact dateToStr = %s", str.latin1() );
32
33 return str;
34}
35
36QDate OConversion::dateFromString( const QString& s )
37{
38 QDate date;
39
40 if ( s.isEmpty() )
41 return date;
42
43 // Be backward compatible to old Opie format:
44 // Try to load old format. If it fails, try new ISO-Format!
45 date = TimeConversion::fromString ( s );
46 if ( date.isValid() )
47 return date;
48
49 // Read ISO-Format (YYYYMMDD)
50 int year = s.mid(0, 4).toInt();
51 int month = s.mid(4,2).toInt();
52 int day = s.mid(6,2).toInt();
53
54 // do some quick sanity checking
55 if ( year < 1900 || year > 3000 ) {
56 qWarning( "PimContact year is not in range");
57 return date;
58 }
59 if ( month < 0 || month > 12 ) {
60 qWarning( "PimContact month is not in range");
61 return date;
62 }
63 if ( day < 0 || day > 31 ) {
64 qWarning( "PimContact day is not in range");
65 return date;
66 }
67
68 date.setYMD( year, month, day );
69 if ( !date.isValid() ) {
70 qWarning( "PimContact date is not valid");
71 return QDate();
72 }
73
74 return date;
75}
76
diff --git a/libopie/pim/oconversion.h b/libopie/pim/oconversion.h
new file mode 100644
index 0000000..6540889
--- a/dev/null
+++ b/libopie/pim/oconversion.h
@@ -0,0 +1,36 @@
1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de)
4**
5** This file may be distributed and/or modified under the terms of the
6** GNU General Public License version 2 as published by the Free Software
7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file.
9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12**
13** See http://www.trolltech.com/gpl/ for GPL licensing information.
14**
15** Contact info@trolltech.com if any conditions of this licensing are
16** not clear to you.
17**********************************************************************/
18
19#ifndef __oconversion_h__
20#define __oconversion_h__
21
22/* #include <time.h> */
23/* #include <sys/types.h> */
24#include <qdatetime.h>
25
26
27class OConversion
28{
29public:
30 static QString dateToString( const QDate &d );
31 static QDate dateFromString( const QString &datestr );
32
33};
34
35#endif // __oconversion_h__
36