summaryrefslogtreecommitdiff
Unidiff
Diffstat (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
-rw-r--r--libopie2/opiepim/core/oconversion.cpp76
-rw-r--r--libopie2/opiepim/core/oconversion.h36
-rw-r--r--libopie2/opiepim/ocontact.cpp14
-rw-r--r--libopie2/opiepim/ocontact.h4
9 files changed, 240 insertions, 22 deletions
diff --git a/libopie/libopie.pro b/libopie/libopie.pro
index 5550c20..c0ccdf2 100644
--- a/libopie/libopie.pro
+++ b/libopie/libopie.pro
@@ -18,6 +18,7 @@ HEADERS = ofontmenu.h \
18 pim/opimaccessbackend.h \ 18 pim/opimaccessbackend.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 \
23 pim/ocontactaccessbackend.h \ 24 pim/ocontactaccessbackend.h \
@@ -62,6 +63,7 @@ SOURCES = ofontmenu.cc \
62 pim/otodoaccess.cpp \ 63 pim/otodoaccess.cpp \
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 \
67 pim/ocontactaccessbackend_vcard.cpp \ 69 pim/ocontactaccessbackend_vcard.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,8 +1,6 @@
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
8** GNU General Public License version 2 as published by the Free Software 6** GNU General Public License version 2 as published by the Free Software
@@ -25,7 +23,7 @@
25#include "opimresolver.h" 23#include "opimresolver.h"
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
31#include <qobject.h> 29#include <qobject.h>
@@ -1017,7 +1015,7 @@ void OContact::setBirthday( const QDate &v )
1017 } 1015 }
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}
1023 1021
@@ -1035,7 +1033,7 @@ void OContact::setAnniversary( const QDate &v )
1035 } 1033 }
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
1041/*! \fn QDate OContact::birthday() const 1039/*! \fn QDate OContact::birthday() const
@@ -1046,7 +1044,7 @@ QDate OContact::birthday() const
1046 QString str = find( Qtopia::Birthday ); 1044 QString str = find( Qtopia::Birthday );
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();
1052} 1050}
@@ -1061,7 +1059,7 @@ QDate OContact::anniversary() const
1061 QString str = find( Qtopia::Anniversary ); 1059 QString str = find( Qtopia::Anniversary );
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;
1067} 1065}
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,8 +1,6 @@
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
8** GNU General Public License version 2 as published by the Free Software 6** GNU General Public License version 2 as published by the Free Software
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
diff --git a/libopie2/opiepim/core/oconversion.cpp b/libopie2/opiepim/core/oconversion.cpp
new file mode 100644
index 0000000..c3aa89b
--- a/dev/null
+++ b/libopie2/opiepim/core/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/libopie2/opiepim/core/oconversion.h b/libopie2/opiepim/core/oconversion.h
new file mode 100644
index 0000000..6540889
--- a/dev/null
+++ b/libopie2/opiepim/core/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
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp
index 9cccfc8..96a5f65 100644
--- a/libopie2/opiepim/ocontact.cpp
+++ b/libopie2/opiepim/ocontact.cpp
@@ -1,8 +1,6 @@
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
8** GNU General Public License version 2 as published by the Free Software 6** GNU General Public License version 2 as published by the Free Software
@@ -25,7 +23,7 @@
25#include "opimresolver.h" 23#include "opimresolver.h"
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
31#include <qobject.h> 29#include <qobject.h>
@@ -1017,7 +1015,7 @@ void OContact::setBirthday( const QDate &v )
1017 } 1015 }
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}
1023 1021
@@ -1035,7 +1033,7 @@ void OContact::setAnniversary( const QDate &v )
1035 } 1033 }
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
1041/*! \fn QDate OContact::birthday() const 1039/*! \fn QDate OContact::birthday() const
@@ -1046,7 +1044,7 @@ QDate OContact::birthday() const
1046 QString str = find( Qtopia::Birthday ); 1044 QString str = find( Qtopia::Birthday );
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();
1052} 1050}
@@ -1061,7 +1059,7 @@ QDate OContact::anniversary() const
1061 QString str = find( Qtopia::Anniversary ); 1059 QString str = find( Qtopia::Anniversary );
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;
1067} 1065}
diff --git a/libopie2/opiepim/ocontact.h b/libopie2/opiepim/ocontact.h
index 25fa0e7..50f6176 100644
--- a/libopie2/opiepim/ocontact.h
+++ b/libopie2/opiepim/ocontact.h
@@ -1,8 +1,6 @@
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
8** GNU General Public License version 2 as published by the Free Software 6** GNU General Public License version 2 as published by the Free Software