summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/otodoaccessvcal.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/backend/otodoaccessvcal.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/otodoaccessvcal.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.cpp b/libopie2/opiepim/backend/otodoaccessvcal.cpp
index 03d4479..14a325e 100644
--- a/libopie2/opiepim/backend/otodoaccessvcal.cpp
+++ b/libopie2/opiepim/backend/otodoaccessvcal.cpp
@@ -6,53 +6,57 @@
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/* OPIE */
31#include "vobject_p.h" 30#include "vobject_p.h"
32#include <qpe/timeconversion.h> 31
32/* OPIE */
33#include <opie2/otodoaccessvcal.h> 33#include <opie2/otodoaccessvcal.h>
34#include <opie2/odebug.h>
34 35
36#include <qpe/timeconversion.h>
37
38/* QT */
35//FIXME: Hack to allow direct access to FILE* fh. Rewrite this! 39//FIXME: Hack to allow direct access to FILE* fh. Rewrite this!
36#define protected public 40#define protected public
37#include <qfile.h> 41#include <qfile.h>
38#undef protected 42#undef protected
39 43
40using namespace Opie; 44using namespace Opie;
41 45
42namespace { 46namespace {
43 static OPimTodo eventByVObj( VObject *obj ){ 47 static OPimTodo eventByVObj( VObject *obj ){
44 OPimTodo event; 48 OPimTodo event;
45 VObject *ob; 49 VObject *ob;
46 QCString name; 50 QCString name;
47 // no uid, attendees, ... and no fun 51 // no uid, attendees, ... and no fun
48 // description 52 // description
49 if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){ 53 if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){
50 name = vObjectStringZValue( ob ); 54 name = vObjectStringZValue( ob );
51#if 0 55#if 0
52 event.setDescription( name ); 56 event.setDescription( name );
53#else 57#else
54 event.setSummary( name ); 58 event.setSummary( name );
55#endif 59#endif
56 } 60 }
57 // summary 61 // summary
58 if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) { 62 if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) {
@@ -67,96 +71,96 @@ namespace {
67 if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){ 71 if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){
68 name = vObjectStringZValue( ob ); 72 name = vObjectStringZValue( ob );
69 if( name == "COMPLETED" ){ 73 if( name == "COMPLETED" ){
70 event.setCompleted( true ); 74 event.setCompleted( true );
71 }else{ 75 }else{
72 event.setCompleted( false ); 76 event.setCompleted( false );
73 } 77 }
74 }else 78 }else
75 event.setCompleted( false ); 79 event.setCompleted( false );
76 // priority 80 // priority
77 if ((ob = isAPropertyOf(obj, VCPriorityProp))) { 81 if ((ob = isAPropertyOf(obj, VCPriorityProp))) {
78 name = vObjectStringZValue( ob ); 82 name = vObjectStringZValue( ob );
79 bool ok; 83 bool ok;
80 event.setPriority(name.toInt(&ok) ); 84 event.setPriority(name.toInt(&ok) );
81 } 85 }
82 //due date 86 //due date
83 if((ob = isAPropertyOf(obj, VCDueProp)) ){ 87 if((ob = isAPropertyOf(obj, VCDueProp)) ){
84 event.setHasDueDate( true ); 88 event.setHasDueDate( true );
85 name = vObjectStringZValue( ob ); 89 name = vObjectStringZValue( ob );
86 event.setDueDate( TimeConversion::fromISO8601( name).date() ); 90 event.setDueDate( TimeConversion::fromISO8601( name).date() );
87 } 91 }
88 // categories 92 // categories
89 if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){ 93 if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){
90 name = vObjectStringZValue( ob ); 94 name = vObjectStringZValue( ob );
91 qWarning("Categories:%s", name.data() ); 95 owarn << "Categories:" << name.data() << "" << oendl;
92 } 96 }
93 97
94 event.setUid( 1 ); 98 event.setUid( 1 );
95 return event; 99 return event;
96 }; 100 };
97 static VObject *vobjByEvent( const OPimTodo &event ) { 101 static VObject *vobjByEvent( const OPimTodo &event ) {
98 VObject *task = newVObject( VCTodoProp ); 102 VObject *task = newVObject( VCTodoProp );
99 if( task == 0 ) 103 if( task == 0 )
100 return 0l; 104 return 0l;
101 105
102 if( event.hasDueDate() ) { 106 if( event.hasDueDate() ) {
103 QTime time(0, 0, 0); 107 QTime time(0, 0, 0);
104 QDateTime date(event.dueDate(), time ); 108 QDateTime date(event.dueDate(), time );
105 addPropValue( task, VCDueProp, 109 addPropValue( task, VCDueProp,
106 TimeConversion::toISO8601( date ) ); 110 TimeConversion::toISO8601( date ) );
107 } 111 }
108 112
109 if( event.isCompleted() ) 113 if( event.isCompleted() )
110 addPropValue( task, VCStatusProp, "COMPLETED"); 114 addPropValue( task, VCStatusProp, "COMPLETED");
111 115
112 QString string = QString::number(event.priority() ); 116 QString string = QString::number(event.priority() );
113 addPropValue( task, VCPriorityProp, string.local8Bit() ); 117 addPropValue( task, VCPriorityProp, string.local8Bit() );
114 118
115 addPropValue( task, VCCategoriesProp, 119 addPropValue( task, VCCategoriesProp,
116 event.idsToString( event.categories() ).local8Bit() ); 120 event.idsToString( event.categories() ).local8Bit() );
117 121
118#if 0 122#if 0
119 123
120 // There seems a misrepresentation between summary in otodoevent 124 // There seems a misrepresentation between summary in otodoevent
121 // and summary in vcard. 125 // and summary in vcard.
122 // The same with description.. 126 // The same with description..
123 // Description is summary and vice versa.. Argh.. (eilers) 127 // Description is summary and vice versa.. Argh.. (eilers)
124 128
125 129
126 addPropValue( task, VCDescriptionProp, 130 addPropValue( task, VCDescriptionProp,
127 event.description().local8Bit() ); 131 event.description().local8Bit() );
128 132
129 addPropValue( task, VCSummaryProp, 133 addPropValue( task, VCSummaryProp,
130 event.summary().local8Bit() ); 134 event.summary().local8Bit() );
131 135
132#else 136#else
133 addPropValue( task, VCDescriptionProp, 137 addPropValue( task, VCDescriptionProp,
134 event.summary().local8Bit() ); 138 event.summary().local8Bit() );
135 139
136 addPropValue( task, VCSummaryProp, 140 addPropValue( task, VCSummaryProp,
137 event.description().local8Bit() ); 141 event.description().local8Bit() );
138#endif 142#endif
139 return task; 143 return task;
140}; 144};
141} 145}
142 146
143namespace Opie { 147namespace Opie {
144OPimTodoAccessVCal::OPimTodoAccessVCal( const QString& path ) 148OPimTodoAccessVCal::OPimTodoAccessVCal( const QString& path )
145 : m_dirty(false), m_file( path ) 149 : m_dirty(false), m_file( path )
146{ 150{
147} 151}
148OPimTodoAccessVCal::~OPimTodoAccessVCal() { 152OPimTodoAccessVCal::~OPimTodoAccessVCal() {
149} 153}
150bool OPimTodoAccessVCal::load() { 154bool OPimTodoAccessVCal::load() {
151 m_map.clear(); 155 m_map.clear();
152 m_dirty = false; 156 m_dirty = false;
153 157
154 VObject* vcal = 0l; 158 VObject* vcal = 0l;
155 vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); 159 vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() );
156 if (!vcal ) 160 if (!vcal )
157 return false; 161 return false;
158 162
159 // Iterate over the list 163 // Iterate over the list
160 VObjectIterator it; 164 VObjectIterator it;
161 VObject* vobj; 165 VObject* vobj;
162 166