author | mickeyl <mickeyl> | 2004-02-24 20:15:06 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-02-24 20:15:06 (UTC) |
commit | a1a6a1013eae9a4ca4607f2d656c98821a30f431 (patch) (unidiff) | |
tree | 1622cd7992b061d9105965fcd3adbceda8504499 /libopie2/opiepim/backend/otodoaccessvcal.cpp | |
parent | 17eafbf019590393ccd01647c5c9d5d880b95e39 (diff) | |
download | opie-a1a6a1013eae9a4ca4607f2d656c98821a30f431.zip opie-a1a6a1013eae9a4ca4607f2d656c98821a30f431.tar.gz opie-a1a6a1013eae9a4ca4607f2d656c98821a30f431.tar.bz2 |
substitute hack with another hack to enforce LGPL compliance
Diffstat (limited to 'libopie2/opiepim/backend/otodoaccessvcal.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/backend/otodoaccessvcal.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.cpp b/libopie2/opiepim/backend/otodoaccessvcal.cpp index 0a1baf9..03d4479 100644 --- a/libopie2/opiepim/backend/otodoaccessvcal.cpp +++ b/libopie2/opiepim/backend/otodoaccessvcal.cpp | |||
@@ -1,282 +1,285 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) | 3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
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 | #include <qfile.h> | ||
30 | |||
31 | #include <qtopia/private/vobject_p.h> | ||
32 | #include <qtopia/timeconversion.h> | ||
33 | #include <qtopia/private/qfiledirect_p.h> | ||
34 | 29 | ||
30 | /* OPIE */ | ||
31 | #include "vobject_p.h" | ||
32 | #include <qpe/timeconversion.h> | ||
35 | #include <opie2/otodoaccessvcal.h> | 33 | #include <opie2/otodoaccessvcal.h> |
36 | 34 | ||
35 | //FIXME: Hack to allow direct access to FILE* fh. Rewrite this! | ||
36 | #define protected public | ||
37 | #include <qfile.h> | ||
38 | #undef protected | ||
39 | |||
37 | using namespace Opie; | 40 | using namespace Opie; |
38 | 41 | ||
39 | namespace { | 42 | namespace { |
40 | static OPimTodo eventByVObj( VObject *obj ){ | 43 | static OPimTodo eventByVObj( VObject *obj ){ |
41 | OPimTodo event; | 44 | OPimTodo event; |
42 | VObject *ob; | 45 | VObject *ob; |
43 | QCString name; | 46 | QCString name; |
44 | // no uid, attendees, ... and no fun | 47 | // no uid, attendees, ... and no fun |
45 | // description | 48 | // description |
46 | if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){ | 49 | if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){ |
47 | name = vObjectStringZValue( ob ); | 50 | name = vObjectStringZValue( ob ); |
48 | #if 0 | 51 | #if 0 |
49 | event.setDescription( name ); | 52 | event.setDescription( name ); |
50 | #else | 53 | #else |
51 | event.setSummary( name ); | 54 | event.setSummary( name ); |
52 | #endif | 55 | #endif |
53 | } | 56 | } |
54 | // summary | 57 | // summary |
55 | if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) { | 58 | if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) { |
56 | name = vObjectStringZValue( ob ); | 59 | name = vObjectStringZValue( ob ); |
57 | #if 0 | 60 | #if 0 |
58 | event.setSummary( name ); | 61 | event.setSummary( name ); |
59 | #else | 62 | #else |
60 | event.setDescription( name ); | 63 | event.setDescription( name ); |
61 | #endif | 64 | #endif |
62 | } | 65 | } |
63 | // completed | 66 | // completed |
64 | if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){ | 67 | if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){ |
65 | name = vObjectStringZValue( ob ); | 68 | name = vObjectStringZValue( ob ); |
66 | if( name == "COMPLETED" ){ | 69 | if( name == "COMPLETED" ){ |
67 | event.setCompleted( true ); | 70 | event.setCompleted( true ); |
68 | }else{ | 71 | }else{ |
69 | event.setCompleted( false ); | 72 | event.setCompleted( false ); |
70 | } | 73 | } |
71 | }else | 74 | }else |
72 | event.setCompleted( false ); | 75 | event.setCompleted( false ); |
73 | // priority | 76 | // priority |
74 | if ((ob = isAPropertyOf(obj, VCPriorityProp))) { | 77 | if ((ob = isAPropertyOf(obj, VCPriorityProp))) { |
75 | name = vObjectStringZValue( ob ); | 78 | name = vObjectStringZValue( ob ); |
76 | bool ok; | 79 | bool ok; |
77 | event.setPriority(name.toInt(&ok) ); | 80 | event.setPriority(name.toInt(&ok) ); |
78 | } | 81 | } |
79 | //due date | 82 | //due date |
80 | if((ob = isAPropertyOf(obj, VCDueProp)) ){ | 83 | if((ob = isAPropertyOf(obj, VCDueProp)) ){ |
81 | event.setHasDueDate( true ); | 84 | event.setHasDueDate( true ); |
82 | name = vObjectStringZValue( ob ); | 85 | name = vObjectStringZValue( ob ); |
83 | event.setDueDate( TimeConversion::fromISO8601( name).date() ); | 86 | event.setDueDate( TimeConversion::fromISO8601( name).date() ); |
84 | } | 87 | } |
85 | // categories | 88 | // categories |
86 | if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){ | 89 | if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){ |
87 | name = vObjectStringZValue( ob ); | 90 | name = vObjectStringZValue( ob ); |
88 | qWarning("Categories:%s", name.data() ); | 91 | qWarning("Categories:%s", name.data() ); |
89 | } | 92 | } |
90 | 93 | ||
91 | event.setUid( 1 ); | 94 | event.setUid( 1 ); |
92 | return event; | 95 | return event; |
93 | }; | 96 | }; |
94 | static VObject *vobjByEvent( const OPimTodo &event ) { | 97 | static VObject *vobjByEvent( const OPimTodo &event ) { |
95 | VObject *task = newVObject( VCTodoProp ); | 98 | VObject *task = newVObject( VCTodoProp ); |
96 | if( task == 0 ) | 99 | if( task == 0 ) |
97 | return 0l; | 100 | return 0l; |
98 | 101 | ||
99 | if( event.hasDueDate() ) { | 102 | if( event.hasDueDate() ) { |
100 | QTime time(0, 0, 0); | 103 | QTime time(0, 0, 0); |
101 | QDateTime date(event.dueDate(), time ); | 104 | QDateTime date(event.dueDate(), time ); |
102 | addPropValue( task, VCDueProp, | 105 | addPropValue( task, VCDueProp, |
103 | TimeConversion::toISO8601( date ) ); | 106 | TimeConversion::toISO8601( date ) ); |
104 | } | 107 | } |
105 | 108 | ||
106 | if( event.isCompleted() ) | 109 | if( event.isCompleted() ) |
107 | addPropValue( task, VCStatusProp, "COMPLETED"); | 110 | addPropValue( task, VCStatusProp, "COMPLETED"); |
108 | 111 | ||
109 | QString string = QString::number(event.priority() ); | 112 | QString string = QString::number(event.priority() ); |
110 | addPropValue( task, VCPriorityProp, string.local8Bit() ); | 113 | addPropValue( task, VCPriorityProp, string.local8Bit() ); |
111 | 114 | ||
112 | addPropValue( task, VCCategoriesProp, | 115 | addPropValue( task, VCCategoriesProp, |
113 | event.idsToString( event.categories() ).local8Bit() ); | 116 | event.idsToString( event.categories() ).local8Bit() ); |
114 | 117 | ||
115 | #if 0 | 118 | #if 0 |
116 | 119 | ||
117 | // There seems a misrepresentation between summary in otodoevent | 120 | // There seems a misrepresentation between summary in otodoevent |
118 | // and summary in vcard. | 121 | // and summary in vcard. |
119 | // The same with description.. | 122 | // The same with description.. |
120 | // Description is summary and vice versa.. Argh.. (eilers) | 123 | // Description is summary and vice versa.. Argh.. (eilers) |
121 | 124 | ||
122 | 125 | ||
123 | addPropValue( task, VCDescriptionProp, | 126 | addPropValue( task, VCDescriptionProp, |
124 | event.description().local8Bit() ); | 127 | event.description().local8Bit() ); |
125 | 128 | ||
126 | addPropValue( task, VCSummaryProp, | 129 | addPropValue( task, VCSummaryProp, |
127 | event.summary().local8Bit() ); | 130 | event.summary().local8Bit() ); |
128 | 131 | ||
129 | #else | 132 | #else |
130 | addPropValue( task, VCDescriptionProp, | 133 | addPropValue( task, VCDescriptionProp, |
131 | event.summary().local8Bit() ); | 134 | event.summary().local8Bit() ); |
132 | 135 | ||
133 | addPropValue( task, VCSummaryProp, | 136 | addPropValue( task, VCSummaryProp, |
134 | event.description().local8Bit() ); | 137 | event.description().local8Bit() ); |
135 | #endif | 138 | #endif |
136 | return task; | 139 | return task; |
137 | }; | 140 | }; |
138 | } | 141 | } |
139 | 142 | ||
140 | namespace Opie { | 143 | namespace Opie { |
141 | OPimTodoAccessVCal::OPimTodoAccessVCal( const QString& path ) | 144 | OPimTodoAccessVCal::OPimTodoAccessVCal( const QString& path ) |
142 | : m_dirty(false), m_file( path ) | 145 | : m_dirty(false), m_file( path ) |
143 | { | 146 | { |
144 | } | 147 | } |
145 | OPimTodoAccessVCal::~OPimTodoAccessVCal() { | 148 | OPimTodoAccessVCal::~OPimTodoAccessVCal() { |
146 | } | 149 | } |
147 | bool OPimTodoAccessVCal::load() { | 150 | bool OPimTodoAccessVCal::load() { |
148 | m_map.clear(); | 151 | m_map.clear(); |
149 | m_dirty = false; | 152 | m_dirty = false; |
150 | 153 | ||
151 | VObject* vcal = 0l; | 154 | VObject* vcal = 0l; |
152 | vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); | 155 | vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); |
153 | if (!vcal ) | 156 | if (!vcal ) |
154 | return false; | 157 | return false; |
155 | 158 | ||
156 | // Iterate over the list | 159 | // Iterate over the list |
157 | VObjectIterator it; | 160 | VObjectIterator it; |
158 | VObject* vobj; | 161 | VObject* vobj; |
159 | 162 | ||
160 | initPropIterator(&it, vcal); | 163 | initPropIterator(&it, vcal); |
161 | 164 | ||
162 | while( moreIteration( &it ) ) { | 165 | while( moreIteration( &it ) ) { |
163 | vobj = ::nextVObject( &it ); | 166 | vobj = ::nextVObject( &it ); |
164 | QCString name = ::vObjectName( vobj ); | 167 | QCString name = ::vObjectName( vobj ); |
165 | if( name == VCTodoProp ){ | 168 | if( name == VCTodoProp ){ |
166 | OPimTodo to = eventByVObj( vobj ); | 169 | OPimTodo to = eventByVObj( vobj ); |
167 | m_map.insert( to.uid(), to ); | 170 | m_map.insert( to.uid(), to ); |
168 | } | 171 | } |
169 | } | 172 | } |
170 | 173 | ||
171 | // Should I do a delete vcal? | 174 | // Should I do a delete vcal? |
172 | 175 | ||
173 | return true; | 176 | return true; |
174 | } | 177 | } |
175 | bool OPimTodoAccessVCal::reload() { | 178 | bool OPimTodoAccessVCal::reload() { |
176 | return load(); | 179 | return load(); |
177 | } | 180 | } |
178 | bool OPimTodoAccessVCal::save() { | 181 | bool OPimTodoAccessVCal::save() { |
179 | if (!m_dirty ) | 182 | if (!m_dirty ) |
180 | return true; | 183 | return true; |
181 | 184 | ||
182 | QFileDirect file( m_file ); | 185 | QFile file( m_file ); |
183 | if (!file.open(IO_WriteOnly ) ) | 186 | if (!file.open(IO_WriteOnly ) ) |
184 | return false; | 187 | return false; |
185 | 188 | ||
186 | VObject *obj; | 189 | VObject *obj; |
187 | obj = newVObject( VCCalProp ); | 190 | obj = newVObject( VCCalProp ); |
188 | addPropValue( obj, VCVersionProp, "1.0" ); | 191 | addPropValue( obj, VCVersionProp, "1.0" ); |
189 | VObject *vo; | 192 | VObject *vo; |
190 | for(QMap<int, OPimTodo>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ | 193 | for(QMap<int, OPimTodo>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ |
191 | vo = vobjByEvent( it.data() ); | 194 | vo = vobjByEvent( it.data() ); |
192 | addVObjectProp(obj, vo ); | 195 | addVObjectProp(obj, vo ); |
193 | } | 196 | } |
194 | writeVObject( file.directHandle(), obj ); | 197 | writeVObject( file.fh, obj ); //FIXME: HACK!!! |
195 | cleanVObject( obj ); | 198 | cleanVObject( obj ); |
196 | cleanStrTbl(); | 199 | cleanStrTbl(); |
197 | 200 | ||
198 | m_dirty = false; | 201 | m_dirty = false; |
199 | return true; | 202 | return true; |
200 | } | 203 | } |
201 | void OPimTodoAccessVCal::clear() { | 204 | void OPimTodoAccessVCal::clear() { |
202 | m_map.clear(); | 205 | m_map.clear(); |
203 | m_dirty = true; | 206 | m_dirty = true; |
204 | } | 207 | } |
205 | bool OPimTodoAccessVCal::add( const OPimTodo& to ) { | 208 | bool OPimTodoAccessVCal::add( const OPimTodo& to ) { |
206 | m_map.insert( to.uid(), to ); | 209 | m_map.insert( to.uid(), to ); |
207 | m_dirty = true; | 210 | m_dirty = true; |
208 | return true; | 211 | return true; |
209 | } | 212 | } |
210 | bool OPimTodoAccessVCal::remove( int uid ) { | 213 | bool OPimTodoAccessVCal::remove( int uid ) { |
211 | m_map.remove( uid ); | 214 | m_map.remove( uid ); |
212 | m_dirty = true; | 215 | m_dirty = true; |
213 | return true; | 216 | return true; |
214 | } | 217 | } |
215 | void OPimTodoAccessVCal::removeAllCompleted() { | 218 | void OPimTodoAccessVCal::removeAllCompleted() { |
216 | for ( QMap<int, OPimTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) { | 219 | for ( QMap<int, OPimTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) { |
217 | if ( (*it).isCompleted() ) | 220 | if ( (*it).isCompleted() ) |
218 | m_map.remove( it ); | 221 | m_map.remove( it ); |
219 | } | 222 | } |
220 | } | 223 | } |
221 | bool OPimTodoAccessVCal::replace( const OPimTodo& to ) { | 224 | bool OPimTodoAccessVCal::replace( const OPimTodo& to ) { |
222 | m_map.replace( to.uid(), to ); | 225 | m_map.replace( to.uid(), to ); |
223 | m_dirty = true; | 226 | m_dirty = true; |
224 | return true; | 227 | return true; |
225 | } | 228 | } |
226 | OPimTodo OPimTodoAccessVCal::find(int uid )const { | 229 | OPimTodo OPimTodoAccessVCal::find(int uid )const { |
227 | return m_map[uid]; | 230 | return m_map[uid]; |
228 | } | 231 | } |
229 | QArray<int> OPimTodoAccessVCal::sorted( bool, int, int, int ) { | 232 | QArray<int> OPimTodoAccessVCal::sorted( bool, int, int, int ) { |
230 | QArray<int> ar(0); | 233 | QArray<int> ar(0); |
231 | return ar; | 234 | return ar; |
232 | } | 235 | } |
233 | QArray<int> OPimTodoAccessVCal::allRecords()const { | 236 | QArray<int> OPimTodoAccessVCal::allRecords()const { |
234 | QArray<int> ar( m_map.count() ); | 237 | QArray<int> ar( m_map.count() ); |
235 | QMap<int, OPimTodo>::ConstIterator it; | 238 | QMap<int, OPimTodo>::ConstIterator it; |
236 | int i = 0; | 239 | int i = 0; |
237 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { | 240 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { |
238 | ar[i] = it.key(); | 241 | ar[i] = it.key(); |
239 | i++; | 242 | i++; |
240 | } | 243 | } |
241 | return ar; | 244 | return ar; |
242 | } | 245 | } |
243 | QArray<int> OPimTodoAccessVCal::matchRegexp(const QRegExp& /* r */)const { | 246 | QArray<int> OPimTodoAccessVCal::matchRegexp(const QRegExp& /* r */)const { |
244 | QArray<int> ar(0); | 247 | QArray<int> ar(0); |
245 | return ar; | 248 | return ar; |
246 | } | 249 | } |
247 | QArray<int> OPimTodoAccessVCal::queryByExample( const OPimTodo&, int, const QDateTime& ) { | 250 | QArray<int> OPimTodoAccessVCal::queryByExample( const OPimTodo&, int, const QDateTime& ) { |
248 | QArray<int> ar(0); | 251 | QArray<int> ar(0); |
249 | return ar; | 252 | return ar; |
250 | } | 253 | } |
251 | QArray<int> OPimTodoAccessVCal::effectiveToDos( const QDate& , | 254 | QArray<int> OPimTodoAccessVCal::effectiveToDos( const QDate& , |
252 | const QDate& , | 255 | const QDate& , |
253 | bool ) { | 256 | bool ) { |
254 | QArray<int> ar(0); | 257 | QArray<int> ar(0); |
255 | return ar; | 258 | return ar; |
256 | } | 259 | } |
257 | QArray<int> OPimTodoAccessVCal::overDue() { | 260 | QArray<int> OPimTodoAccessVCal::overDue() { |
258 | QArray<int> ar(0); | 261 | QArray<int> ar(0); |
259 | return ar; | 262 | return ar; |
260 | } | 263 | } |
261 | QBitArray OPimTodoAccessVCal::supports()const { | 264 | QBitArray OPimTodoAccessVCal::supports()const { |
262 | static QBitArray ar = sup(); | 265 | static QBitArray ar = sup(); |
263 | 266 | ||
264 | return ar; | 267 | return ar; |
265 | } | 268 | } |
266 | QBitArray OPimTodoAccessVCal::sup() { | 269 | QBitArray OPimTodoAccessVCal::sup() { |
267 | QBitArray ar ( OPimTodo::CompletedDate +1 ); | 270 | QBitArray ar ( OPimTodo::CompletedDate +1 ); |
268 | ar.fill( true ); | 271 | ar.fill( true ); |
269 | 272 | ||
270 | ar[OPimTodo::CrossReference] = false; | 273 | ar[OPimTodo::CrossReference] = false; |
271 | ar[OPimTodo::State ] = false; | 274 | ar[OPimTodo::State ] = false; |
272 | ar[OPimTodo::Reminders] = false; | 275 | ar[OPimTodo::Reminders] = false; |
273 | ar[OPimTodo::Notifiers] = false; | 276 | ar[OPimTodo::Notifiers] = false; |
274 | ar[OPimTodo::Maintainer] = false; | 277 | ar[OPimTodo::Maintainer] = false; |
275 | ar[OPimTodo::Progress] = false; | 278 | ar[OPimTodo::Progress] = false; |
276 | ar[OPimTodo::Alarms ] = false; | 279 | ar[OPimTodo::Alarms ] = false; |
277 | ar[OPimTodo::Recurrence] = false; | 280 | ar[OPimTodo::Recurrence] = false; |
278 | 281 | ||
279 | return ar; | 282 | return ar; |
280 | } | 283 | } |
281 | 284 | ||
282 | } | 285 | } |