author | mickeyl <mickeyl> | 2004-11-16 19:14:18 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-11-16 19:14:18 (UTC) |
commit | ea3945a9bd8f9830f70b1efa133f9df13b19362f (patch) (unidiff) | |
tree | f2ea22cc50e9aa8aa73ee7dea148f41c563c9666 /libopie/pim/otodoaccessvcal.cpp | |
parent | 1c6f490e8541626f68422e0a3a7c7281d7f5b7d3 (diff) | |
download | opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.zip opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.tar.gz opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.tar.bz2 |
libopie1 goes into unsupported
Diffstat (limited to 'libopie/pim/otodoaccessvcal.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie/pim/otodoaccessvcal.cpp | 249 |
1 files changed, 0 insertions, 249 deletions
diff --git a/libopie/pim/otodoaccessvcal.cpp b/libopie/pim/otodoaccessvcal.cpp deleted file mode 100644 index 6415952..0000000 --- a/libopie/pim/otodoaccessvcal.cpp +++ b/dev/null | |||
@@ -1,249 +0,0 @@ | |||
1 | #include <qfile.h> | ||
2 | |||
3 | #include <qtopia/private/vobject_p.h> | ||
4 | #include <qtopia/timeconversion.h> | ||
5 | #include <qtopia/private/qfiledirect_p.h> | ||
6 | |||
7 | #include "otodoaccessvcal.h" | ||
8 | |||
9 | namespace { | ||
10 | static OTodo eventByVObj( VObject *obj ){ | ||
11 | OTodo event; | ||
12 | VObject *ob; | ||
13 | QCString name; | ||
14 | // no uid, attendees, ... and no fun | ||
15 | // description | ||
16 | if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){ | ||
17 | name = vObjectStringZValue( ob ); | ||
18 | #if 0 | ||
19 | event.setDescription( name ); | ||
20 | #else | ||
21 | event.setSummary( name ); | ||
22 | #endif | ||
23 | } | ||
24 | // summary | ||
25 | if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) { | ||
26 | name = vObjectStringZValue( ob ); | ||
27 | #if 0 | ||
28 | event.setSummary( name ); | ||
29 | #else | ||
30 | event.setDescription( name ); | ||
31 | #endif | ||
32 | } | ||
33 | // completed | ||
34 | if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){ | ||
35 | name = vObjectStringZValue( ob ); | ||
36 | if( name == "COMPLETED" ){ | ||
37 | event.setCompleted( true ); | ||
38 | }else{ | ||
39 | event.setCompleted( false ); | ||
40 | } | ||
41 | }else | ||
42 | event.setCompleted( false ); | ||
43 | // priority | ||
44 | if ((ob = isAPropertyOf(obj, VCPriorityProp))) { | ||
45 | name = vObjectStringZValue( ob ); | ||
46 | bool ok; | ||
47 | event.setPriority(name.toInt(&ok) ); | ||
48 | } | ||
49 | //due date | ||
50 | if((ob = isAPropertyOf(obj, VCDueProp)) ){ | ||
51 | event.setHasDueDate( true ); | ||
52 | name = vObjectStringZValue( ob ); | ||
53 | event.setDueDate( TimeConversion::fromISO8601( name).date() ); | ||
54 | } | ||
55 | // categories | ||
56 | if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){ | ||
57 | name = vObjectStringZValue( ob ); | ||
58 | qWarning("Categories:%s", name.data() ); | ||
59 | } | ||
60 | |||
61 | event.setUid( 1 ); | ||
62 | return event; | ||
63 | }; | ||
64 | static VObject *vobjByEvent( const OTodo &event ) { | ||
65 | VObject *task = newVObject( VCTodoProp ); | ||
66 | if( task == 0 ) | ||
67 | return 0l; | ||
68 | |||
69 | if( event.hasDueDate() ) { | ||
70 | QTime time(0, 0, 0); | ||
71 | QDateTime date(event.dueDate(), time ); | ||
72 | addPropValue( task, VCDueProp, | ||
73 | TimeConversion::toISO8601( date ) ); | ||
74 | } | ||
75 | |||
76 | if( event.isCompleted() ) | ||
77 | addPropValue( task, VCStatusProp, "COMPLETED"); | ||
78 | |||
79 | QString string = QString::number(event.priority() ); | ||
80 | addPropValue( task, VCPriorityProp, string.local8Bit() ); | ||
81 | |||
82 | addPropValue( task, VCCategoriesProp, | ||
83 | event.idsToString( event.categories() ).local8Bit() ); | ||
84 | |||
85 | #if 0 | ||
86 | |||
87 | // There seems a misrepresentation between summary in otodoevent | ||
88 | // and summary in vcard. | ||
89 | // The same with description.. | ||
90 | // Description is summary and vice versa.. Argh.. (eilers) | ||
91 | |||
92 | |||
93 | addPropValue( task, VCDescriptionProp, | ||
94 | event.description().local8Bit() ); | ||
95 | |||
96 | addPropValue( task, VCSummaryProp, | ||
97 | event.summary().local8Bit() ); | ||
98 | |||
99 | #else | ||
100 | addPropValue( task, VCDescriptionProp, | ||
101 | event.summary().local8Bit() ); | ||
102 | |||
103 | addPropValue( task, VCSummaryProp, | ||
104 | event.description().local8Bit() ); | ||
105 | #endif | ||
106 | return task; | ||
107 | }; | ||
108 | } | ||
109 | |||
110 | OTodoAccessVCal::OTodoAccessVCal( const QString& path ) | ||
111 | : m_dirty(false), m_file( path ) | ||
112 | { | ||
113 | } | ||
114 | OTodoAccessVCal::~OTodoAccessVCal() { | ||
115 | } | ||
116 | bool OTodoAccessVCal::load() { | ||
117 | m_map.clear(); | ||
118 | m_dirty = false; | ||
119 | |||
120 | VObject* vcal = 0l; | ||
121 | vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); | ||
122 | if (!vcal ) | ||
123 | return false; | ||
124 | |||
125 | // Iterate over the list | ||
126 | VObjectIterator it; | ||
127 | VObject* vobj; | ||
128 | |||
129 | initPropIterator(&it, vcal); | ||
130 | |||
131 | while( moreIteration( &it ) ) { | ||
132 | vobj = ::nextVObject( &it ); | ||
133 | QCString name = ::vObjectName( vobj ); | ||
134 | if( name == VCTodoProp ){ | ||
135 | OTodo to = eventByVObj( vobj ); | ||
136 | m_map.insert( to.uid(), to ); | ||
137 | } | ||
138 | } | ||
139 | |||
140 | // Should I do a delete vcal? | ||
141 | |||
142 | return true; | ||
143 | } | ||
144 | bool OTodoAccessVCal::reload() { | ||
145 | return load(); | ||
146 | } | ||
147 | bool OTodoAccessVCal::save() { | ||
148 | if (!m_dirty ) | ||
149 | return true; | ||
150 | |||
151 | QFileDirect file( m_file ); | ||
152 | if (!file.open(IO_WriteOnly ) ) | ||
153 | return false; | ||
154 | |||
155 | VObject *obj; | ||
156 | obj = newVObject( VCCalProp ); | ||
157 | addPropValue( obj, VCVersionProp, "1.0" ); | ||
158 | VObject *vo; | ||
159 | for(QMap<int, OTodo>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ | ||
160 | vo = vobjByEvent( it.data() ); | ||
161 | addVObjectProp(obj, vo ); | ||
162 | } | ||
163 | writeVObject( file.directHandle(), obj ); | ||
164 | cleanVObject( obj ); | ||
165 | cleanStrTbl(); | ||
166 | |||
167 | m_dirty = false; | ||
168 | return true; | ||
169 | } | ||
170 | void OTodoAccessVCal::clear() { | ||
171 | m_map.clear(); | ||
172 | m_dirty = true; | ||
173 | } | ||
174 | bool OTodoAccessVCal::add( const OTodo& to ) { | ||
175 | m_map.insert( to.uid(), to ); | ||
176 | m_dirty = true; | ||
177 | return true; | ||
178 | } | ||
179 | bool OTodoAccessVCal::remove( int uid ) { | ||
180 | m_map.remove( uid ); | ||
181 | m_dirty = true; | ||
182 | return true; | ||
183 | } | ||
184 | void OTodoAccessVCal::removeAllCompleted() { | ||
185 | for ( QMap<int, OTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) { | ||
186 | if ( (*it).isCompleted() ) | ||
187 | m_map.remove( it ); | ||
188 | } | ||
189 | } | ||
190 | bool OTodoAccessVCal::replace( const OTodo& to ) { | ||
191 | m_map.replace( to.uid(), to ); | ||
192 | m_dirty = true; | ||
193 | return true; | ||
194 | } | ||
195 | OTodo OTodoAccessVCal::find(int uid )const { | ||
196 | return m_map[uid]; | ||
197 | } | ||
198 | QArray<int> OTodoAccessVCal::sorted( bool, int, int, int ) { | ||
199 | QArray<int> ar(0); | ||
200 | return ar; | ||
201 | } | ||
202 | QArray<int> OTodoAccessVCal::allRecords()const { | ||
203 | QArray<int> ar( m_map.count() ); | ||
204 | QMap<int, OTodo>::ConstIterator it; | ||
205 | int i = 0; | ||
206 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { | ||
207 | ar[i] = it.key(); | ||
208 | i++; | ||
209 | } | ||
210 | return ar; | ||
211 | } | ||
212 | QArray<int> OTodoAccessVCal::matchRegexp(const QRegExp& /* r */)const { | ||
213 | QArray<int> ar(0); | ||
214 | return ar; | ||
215 | } | ||
216 | QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) { | ||
217 | QArray<int> ar(0); | ||
218 | return ar; | ||
219 | } | ||
220 | QArray<int> OTodoAccessVCal::effectiveToDos( const QDate& , | ||
221 | const QDate& , | ||
222 | bool ) { | ||
223 | QArray<int> ar(0); | ||
224 | return ar; | ||
225 | } | ||
226 | QArray<int> OTodoAccessVCal::overDue() { | ||
227 | QArray<int> ar(0); | ||
228 | return ar; | ||
229 | } | ||
230 | QBitArray OTodoAccessVCal::supports()const { | ||
231 | static QBitArray ar = sup(); | ||
232 | |||
233 | return ar; | ||
234 | } | ||
235 | QBitArray OTodoAccessVCal::sup() { | ||
236 | QBitArray ar ( OTodo::CompletedDate +1 ); | ||
237 | ar.fill( true ); | ||
238 | |||
239 | ar[OTodo::CrossReference] = false; | ||
240 | ar[OTodo::State ] = false; | ||
241 | ar[OTodo::Reminders] = false; | ||
242 | ar[OTodo::Notifiers] = false; | ||
243 | ar[OTodo::Maintainer] = false; | ||
244 | ar[OTodo::Progress] = false; | ||
245 | ar[OTodo::Alarms ] = false; | ||
246 | ar[OTodo::Recurrence] = false; | ||
247 | |||
248 | return ar; | ||
249 | } | ||