-rw-r--r-- | libkcal/sharpformat.cpp | 15 | ||||
-rw-r--r-- | libkcal/syncdefines.h | 22 |
2 files changed, 30 insertions, 7 deletions
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp index f83f72e..973f19d 100644 --- a/libkcal/sharpformat.cpp +++ b/libkcal/sharpformat.cpp | |||
@@ -1,301 +1,302 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <qdatetime.h> | 22 | #include <qdatetime.h> |
23 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | #include <qapplication.h> | 24 | #include <qapplication.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | #include <qregexp.h> | 26 | #include <qregexp.h> |
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qclipboard.h> | 28 | #include <qclipboard.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qtextcodec.h> | 31 | #include <qtextcodec.h> |
32 | #include <qxml.h> | 32 | #include <qxml.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | 34 | ||
35 | #include <kdebug.h> | 35 | #include <kdebug.h> |
36 | #include <klocale.h> | 36 | #include <klocale.h> |
37 | #include <kglobal.h> | 37 | #include <kglobal.h> |
38 | 38 | ||
39 | #include "calendar.h" | 39 | #include "calendar.h" |
40 | #include "alarm.h" | 40 | #include "alarm.h" |
41 | #include "recurrence.h" | 41 | #include "recurrence.h" |
42 | #include "calendarlocal.h" | 42 | #include "calendarlocal.h" |
43 | 43 | ||
44 | #include "sharpformat.h" | 44 | #include "sharpformat.h" |
45 | #include "syncdefines.h" | ||
45 | 46 | ||
46 | using namespace KCal; | 47 | using namespace KCal; |
47 | 48 | ||
48 | //CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY | 49 | //CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY |
49 | // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 50 | // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
50 | 51 | ||
51 | //ARSD silentalarm = 0 | 52 | //ARSD silentalarm = 0 |
52 | // 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly | 53 | // 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly |
53 | // 12 RFRQ | 54 | // 12 RFRQ |
54 | // 13 RPOS pos = 4. monday in month | 55 | // 13 RPOS pos = 4. monday in month |
55 | // 14 RDYS days: 1 mon/ 2 tue .. 64 sun | 56 | // 14 RDYS days: 1 mon/ 2 tue .. 64 sun |
56 | // 15 REND 0 = no end/ 1 = end | 57 | // 15 REND 0 = no end/ 1 = end |
57 | // 16 REDT rec end dt | 58 | // 16 REDT rec end dt |
58 | //ALSD | 59 | //ALSD |
59 | //ALED | 60 | //ALED |
60 | //MDAY | 61 | //MDAY |
61 | 62 | ||
62 | class SharpParser : public QObject | 63 | class SharpParser : public QObject |
63 | { | 64 | { |
64 | public: | 65 | public: |
65 | SharpParser( Calendar *calendar ) : mCalendar( calendar ) { | 66 | SharpParser( Calendar *calendar ) : mCalendar( calendar ) { |
66 | oldCategories = 0; | 67 | oldCategories = 0; |
67 | } | 68 | } |
68 | 69 | ||
69 | bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName ) | 70 | bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName ) |
70 | { | 71 | { |
71 | int i = 1; | 72 | int i = 1; |
72 | bool skip = true; | 73 | bool skip = true; |
73 | int max = attList.count() -2; | 74 | int max = attList.count() -2; |
74 | while ( i < max ) { | 75 | while ( i < max ) { |
75 | if ( !attList[i].isEmpty() ) { | 76 | if ( !attList[i].isEmpty() ) { |
76 | skip = false; | 77 | skip = false; |
77 | break; | 78 | break; |
78 | } | 79 | } |
79 | ++i ; | 80 | ++i ; |
80 | } | 81 | } |
81 | if ( skip ) | 82 | if ( skip ) |
82 | return false; | 83 | return false; |
83 | ulong cSum = SharpFormat::getCsum(attList ); | 84 | ulong cSum = SharpFormat::getCsum(attList ); |
84 | 85 | ||
85 | if ( qName == "Event" ) { | 86 | if ( qName == "Event" ) { |
86 | Event *event; | 87 | Event *event; |
87 | event = existingCalendar->event( attList[0].toInt() ); | 88 | event = existingCalendar->event( attList[0].toInt() ); |
88 | if ( event ) | 89 | if ( event ) |
89 | event = (Event*)event->clone(); | 90 | event = (Event*)event->clone(); |
90 | else | 91 | else |
91 | event = new Event; | 92 | event = new Event; |
92 | event->setZaurusId( attList[0].toInt() ); | 93 | event->setZaurusId( attList[0].toInt() ); |
93 | event->setZaurusUid( cSum ); | 94 | event->setZaurusUid( cSum ); |
94 | event->setZaurusStat( -2 ); | 95 | event->setZaurusStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); |
95 | 96 | ||
96 | event->setSummary( attList[2] ); | 97 | event->setSummary( attList[2] ); |
97 | event->setLocation( attList[3] ); | 98 | event->setLocation( attList[3] ); |
98 | event->setDescription( attList[4] ); | 99 | event->setDescription( attList[4] ); |
99 | if ( attList[7] == "1" ) { | 100 | if ( attList[7] == "1" ) { |
100 | event->setDtStart( QDateTime(fromString( attList[17]+"000000", false ).date(),QTime(0,0,0 ) )); | 101 | event->setDtStart( QDateTime(fromString( attList[17]+"000000", false ).date(),QTime(0,0,0 ) )); |
101 | event->setDtEnd( QDateTime(fromString( attList[18]+"000000", false ).date(),QTime(0,0,0 ))); | 102 | event->setDtEnd( QDateTime(fromString( attList[18]+"000000", false ).date(),QTime(0,0,0 ))); |
102 | event->setFloats( true ); | 103 | event->setFloats( true ); |
103 | } else { | 104 | } else { |
104 | event->setFloats( false ); | 105 | event->setFloats( false ); |
105 | event->setDtStart( fromString( attList[5] ) ); | 106 | event->setDtStart( fromString( attList[5] ) ); |
106 | event->setDtEnd( fromString( attList[6] )); | 107 | event->setDtEnd( fromString( attList[6] )); |
107 | } | 108 | } |
108 | 109 | ||
109 | QString rtype = attList[11]; | 110 | QString rtype = attList[11]; |
110 | if ( rtype != "255" ) { | 111 | if ( rtype != "255" ) { |
111 | // qDebug("recurs "); | 112 | // qDebug("recurs "); |
112 | QDate startDate = event->dtStart().date(); | 113 | QDate startDate = event->dtStart().date(); |
113 | 114 | ||
114 | QString freqStr = attList[12]; | 115 | QString freqStr = attList[12]; |
115 | int freq = freqStr.toInt(); | 116 | int freq = freqStr.toInt(); |
116 | 117 | ||
117 | QString hasEndDateStr = attList[15] ; | 118 | QString hasEndDateStr = attList[15] ; |
118 | bool hasEndDate = hasEndDateStr == "1"; | 119 | bool hasEndDate = hasEndDateStr == "1"; |
119 | 120 | ||
120 | QString endDateStr = attList[16]; | 121 | QString endDateStr = attList[16]; |
121 | QDate endDate = fromString( endDateStr ).date(); | 122 | QDate endDate = fromString( endDateStr ).date(); |
122 | 123 | ||
123 | QString weekDaysStr = attList[14]; | 124 | QString weekDaysStr = attList[14]; |
124 | uint weekDaysNum = weekDaysStr.toInt(); | 125 | uint weekDaysNum = weekDaysStr.toInt(); |
125 | 126 | ||
126 | QBitArray weekDays( 7 ); | 127 | QBitArray weekDays( 7 ); |
127 | int i; | 128 | int i; |
128 | int bb = 1; | 129 | int bb = 1; |
129 | for( i = 1; i <= 7; ++i ) { | 130 | for( i = 1; i <= 7; ++i ) { |
130 | weekDays.setBit( i - 1, ( bb & weekDaysNum )); | 131 | weekDays.setBit( i - 1, ( bb & weekDaysNum )); |
131 | bb = 2 << (i-1); | 132 | bb = 2 << (i-1); |
132 | //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); | 133 | //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); |
133 | } | 134 | } |
134 | // qDebug("next "); | 135 | // qDebug("next "); |
135 | QString posStr = attList[13]; | 136 | QString posStr = attList[13]; |
136 | int pos = posStr.toInt(); | 137 | int pos = posStr.toInt(); |
137 | Recurrence *r = event->recurrence(); | 138 | Recurrence *r = event->recurrence(); |
138 | 139 | ||
139 | if ( rtype == "0" ) { | 140 | if ( rtype == "0" ) { |
140 | if ( hasEndDate ) r->setDaily( freq, endDate ); | 141 | if ( hasEndDate ) r->setDaily( freq, endDate ); |
141 | else r->setDaily( freq, -1 ); | 142 | else r->setDaily( freq, -1 ); |
142 | } else if ( rtype == "1" ) { | 143 | } else if ( rtype == "1" ) { |
143 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); | 144 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); |
144 | else r->setWeekly( freq, weekDays, -1 ); | 145 | else r->setWeekly( freq, weekDays, -1 ); |
145 | } else if ( rtype == "3" ) { | 146 | } else if ( rtype == "3" ) { |
146 | if ( hasEndDate ) | 147 | if ( hasEndDate ) |
147 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); | 148 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); |
148 | else | 149 | else |
149 | r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); | 150 | r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); |
150 | r->addMonthlyDay( startDate.day() ); | 151 | r->addMonthlyDay( startDate.day() ); |
151 | } else if ( rtype == "2" ) { | 152 | } else if ( rtype == "2" ) { |
152 | if ( hasEndDate ) | 153 | if ( hasEndDate ) |
153 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); | 154 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); |
154 | else | 155 | else |
155 | r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); | 156 | r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); |
156 | QBitArray days( 7 ); | 157 | QBitArray days( 7 ); |
157 | days.fill( false ); | 158 | days.fill( false ); |
158 | days.setBit( startDate.dayOfWeek() - 1 ); | 159 | days.setBit( startDate.dayOfWeek() - 1 ); |
159 | r->addMonthlyPos( pos, days ); | 160 | r->addMonthlyPos( pos, days ); |
160 | } else if ( rtype == "4" ) { | 161 | } else if ( rtype == "4" ) { |
161 | if ( hasEndDate ) | 162 | if ( hasEndDate ) |
162 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | 163 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); |
163 | else | 164 | else |
164 | r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); | 165 | r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); |
165 | r->addYearlyNum( startDate.month() ); | 166 | r->addYearlyNum( startDate.month() ); |
166 | } | 167 | } |
167 | } | 168 | } |
168 | 169 | ||
169 | QString categoryList = attList[1] ; | 170 | QString categoryList = attList[1] ; |
170 | event->setCategories( lookupCategories( categoryList ) ); | 171 | event->setCategories( lookupCategories( categoryList ) ); |
171 | 172 | ||
172 | // strange 0 semms to mean: alarm enabled | 173 | // strange 0 semms to mean: alarm enabled |
173 | if ( attList[8] == "0" ) { | 174 | if ( attList[8] == "0" ) { |
174 | Alarm *alarm; | 175 | Alarm *alarm; |
175 | if ( event->alarms().count() > 0 ) | 176 | if ( event->alarms().count() > 0 ) |
176 | alarm = event->alarms().first(); | 177 | alarm = event->alarms().first(); |
177 | else { | 178 | else { |
178 | alarm = new Alarm( event ); | 179 | alarm = new Alarm( event ); |
179 | event->addAlarm( alarm ); | 180 | event->addAlarm( alarm ); |
180 | } | 181 | } |
181 | alarm->setType( Alarm::Audio ); | 182 | alarm->setType( Alarm::Audio ); |
182 | alarm->setEnabled( true ); | 183 | alarm->setEnabled( true ); |
183 | int alarmOffset = attList[9].toInt(); | 184 | int alarmOffset = attList[9].toInt(); |
184 | alarm->setStartOffset( alarmOffset * -60 ); | 185 | alarm->setStartOffset( alarmOffset * -60 ); |
185 | } | 186 | } |
186 | 187 | ||
187 | mCalendar->addEvent( event); | 188 | mCalendar->addEvent( event); |
188 | } else if ( qName == "Todo" ) { | 189 | } else if ( qName == "Todo" ) { |
189 | Todo *todo; | 190 | Todo *todo; |
190 | 191 | ||
191 | todo = existingCalendar->todo( attList[0].toInt() ); | 192 | todo = existingCalendar->todo( attList[0].toInt() ); |
192 | if (todo ) | 193 | if (todo ) |
193 | todo = (Todo*)todo->clone(); | 194 | todo = (Todo*)todo->clone(); |
194 | else | 195 | else |
195 | todo = new Todo; | 196 | todo = new Todo; |
196 | 197 | ||
197 | //CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 | 198 | //CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 |
198 | // 0 1 2 3 4 5 6 7 8 | 199 | // 0 1 2 3 4 5 6 7 8 |
199 | //1,,,,,1,4,Loch zumachen,"" | 200 | //1,,,,,1,4,Loch zumachen,"" |
200 | //3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " | 201 | //3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " |
201 | //2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes | 202 | //2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes |
202 | 203 | ||
203 | todo->setZaurusId( attList[0].toInt() ); | 204 | todo->setZaurusId( attList[0].toInt() ); |
204 | todo->setZaurusUid( cSum ); | 205 | todo->setZaurusUid( cSum ); |
205 | todo->setZaurusStat( -2 ); | 206 | todo->setZaurusStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
206 | 207 | ||
207 | todo->setSummary( attList[7] ); | 208 | todo->setSummary( attList[7] ); |
208 | todo->setDescription( attList[8]); | 209 | todo->setDescription( attList[8]); |
209 | 210 | ||
210 | int priority = attList[6].toInt(); | 211 | int priority = attList[6].toInt(); |
211 | if ( priority == 0 ) priority = 3; | 212 | if ( priority == 0 ) priority = 3; |
212 | todo->setPriority( priority ); | 213 | todo->setPriority( priority ); |
213 | 214 | ||
214 | QString categoryList = attList[1]; | 215 | QString categoryList = attList[1]; |
215 | todo->setCategories( lookupCategories( categoryList ) ); | 216 | todo->setCategories( lookupCategories( categoryList ) ); |
216 | 217 | ||
217 | 218 | ||
218 | 219 | ||
219 | QString hasDateStr = attList[3]; // due | 220 | QString hasDateStr = attList[3]; // due |
220 | if ( !hasDateStr.isEmpty() ) { | 221 | if ( !hasDateStr.isEmpty() ) { |
221 | if ( hasDateStr.right(6) == "000000" ) { | 222 | if ( hasDateStr.right(6) == "000000" ) { |
222 | todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); | 223 | todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); |
223 | todo->setFloats( true ); | 224 | todo->setFloats( true ); |
224 | } | 225 | } |
225 | else { | 226 | else { |
226 | todo->setDtDue( fromString( hasDateStr ) ); | 227 | todo->setDtDue( fromString( hasDateStr ) ); |
227 | todo->setFloats( false ); | 228 | todo->setFloats( false ); |
228 | } | 229 | } |
229 | 230 | ||
230 | todo->setHasDueDate( true ); | 231 | todo->setHasDueDate( true ); |
231 | } | 232 | } |
232 | hasDateStr = attList[2];//start | 233 | hasDateStr = attList[2];//start |
233 | if ( !hasDateStr.isEmpty() ) { | 234 | if ( !hasDateStr.isEmpty() ) { |
234 | 235 | ||
235 | todo->setDtStart( fromString( hasDateStr ) ); | 236 | todo->setDtStart( fromString( hasDateStr ) ); |
236 | todo->setHasStartDate( true); | 237 | todo->setHasStartDate( true); |
237 | } else | 238 | } else |
238 | todo->setHasStartDate( false ); | 239 | todo->setHasStartDate( false ); |
239 | hasDateStr = attList[4];//completed | 240 | hasDateStr = attList[4];//completed |
240 | if ( !hasDateStr.isEmpty() ) { | 241 | if ( !hasDateStr.isEmpty() ) { |
241 | todo->setCompleted(fromString( hasDateStr ) ); | 242 | todo->setCompleted(fromString( hasDateStr ) ); |
242 | } | 243 | } |
243 | QString completedStr = attList[5]; | 244 | QString completedStr = attList[5]; |
244 | if ( completedStr == "0" ) | 245 | if ( completedStr == "0" ) |
245 | todo->setCompleted( true ); | 246 | todo->setCompleted( true ); |
246 | else | 247 | else |
247 | todo->setCompleted( false ); | 248 | todo->setCompleted( false ); |
248 | mCalendar->addTodo( todo ); | 249 | mCalendar->addTodo( todo ); |
249 | 250 | ||
250 | } else if ( qName == "Category" ) { | 251 | } else if ( qName == "Category" ) { |
251 | /* | 252 | /* |
252 | QString id = attributes.value( "id" ); | 253 | QString id = attributes.value( "id" ); |
253 | QString name = attributes.value( "name" ); | 254 | QString name = attributes.value( "name" ); |
254 | setCategory( id, name ); | 255 | setCategory( id, name ); |
255 | */ | 256 | */ |
256 | } | 257 | } |
257 | //qDebug("end "); | 258 | //qDebug("end "); |
258 | return true; | 259 | return true; |
259 | } | 260 | } |
260 | 261 | ||
261 | 262 | ||
262 | void setCategoriesList ( QStringList * c ) | 263 | void setCategoriesList ( QStringList * c ) |
263 | { | 264 | { |
264 | oldCategories = c; | 265 | oldCategories = c; |
265 | } | 266 | } |
266 | 267 | ||
267 | QDateTime fromString ( QString s, bool useTz = true ) { | 268 | QDateTime fromString ( QString s, bool useTz = true ) { |
268 | QDateTime dt; | 269 | QDateTime dt; |
269 | int y,m,t,h,min,sec; | 270 | int y,m,t,h,min,sec; |
270 | y = s.mid(0,4).toInt(); | 271 | y = s.mid(0,4).toInt(); |
271 | m = s.mid(4,2).toInt(); | 272 | m = s.mid(4,2).toInt(); |
272 | t = s.mid(6,2).toInt(); | 273 | t = s.mid(6,2).toInt(); |
273 | h = s.mid(9,2).toInt(); | 274 | h = s.mid(9,2).toInt(); |
274 | min = s.mid(11,2).toInt(); | 275 | min = s.mid(11,2).toInt(); |
275 | sec = s.mid(13,2).toInt(); | 276 | sec = s.mid(13,2).toInt(); |
276 | dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); | 277 | dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); |
277 | int offset = KGlobal::locale()->localTimeOffset( dt ); | 278 | int offset = KGlobal::locale()->localTimeOffset( dt ); |
278 | if ( useTz ) | 279 | if ( useTz ) |
279 | dt = dt.addSecs ( offset*60); | 280 | dt = dt.addSecs ( offset*60); |
280 | return dt; | 281 | return dt; |
281 | 282 | ||
282 | } | 283 | } |
283 | protected: | 284 | protected: |
284 | QDateTime toDateTime( const QString &value ) | 285 | QDateTime toDateTime( const QString &value ) |
285 | { | 286 | { |
286 | QDateTime dt; | 287 | QDateTime dt; |
287 | dt.setTime_t( value.toUInt() ); | 288 | dt.setTime_t( value.toUInt() ); |
288 | 289 | ||
289 | return dt; | 290 | return dt; |
290 | } | 291 | } |
291 | 292 | ||
292 | QStringList lookupCategories( const QString &categoryList ) | 293 | QStringList lookupCategories( const QString &categoryList ) |
293 | { | 294 | { |
294 | QStringList categoryIds = QStringList::split( ";", categoryList ); | 295 | QStringList categoryIds = QStringList::split( ";", categoryList ); |
295 | QStringList categories; | 296 | QStringList categories; |
296 | QStringList::ConstIterator it; | 297 | QStringList::ConstIterator it; |
297 | for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) { | 298 | for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) { |
298 | QString cate = category( *it ); | 299 | QString cate = category( *it ); |
299 | if ( oldCategories ) { | 300 | if ( oldCategories ) { |
300 | if ( ! oldCategories->contains( cate ) ) | 301 | if ( ! oldCategories->contains( cate ) ) |
301 | oldCategories->append( cate ); | 302 | oldCategories->append( cate ); |
@@ -374,322 +375,322 @@ bool SharpFormat::load( Calendar *calendar, Calendar *existngCal ) | |||
374 | int dw = QApplication::desktop()->width(); | 375 | int dw = QApplication::desktop()->width(); |
375 | int dh = QApplication::desktop()->height(); | 376 | int dh = QApplication::desktop()->height(); |
376 | status.setCaption(i18n("Reading DTM Data") ); | 377 | status.setCaption(i18n("Reading DTM Data") ); |
377 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 378 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
378 | status.show(); | 379 | status.show(); |
379 | status.raise(); | 380 | status.raise(); |
380 | qApp->processEvents(); | 381 | qApp->processEvents(); |
381 | QString fileName; | 382 | QString fileName; |
382 | if ( ! debug ) { | 383 | if ( ! debug ) { |
383 | fileName = "/tmp/kopitempout"; | 384 | fileName = "/tmp/kopitempout"; |
384 | QString command ="db2file datebook -r -c "+ codec + " > " + fileName; | 385 | QString command ="db2file datebook -r -c "+ codec + " > " + fileName; |
385 | system ( command.latin1() ); | 386 | system ( command.latin1() ); |
386 | } else { | 387 | } else { |
387 | fileName = "/tmp/events.txt"; | 388 | fileName = "/tmp/events.txt"; |
388 | 389 | ||
389 | } | 390 | } |
390 | QFile file( fileName ); | 391 | QFile file( fileName ); |
391 | if (!file.open( IO_ReadOnly ) ) { | 392 | if (!file.open( IO_ReadOnly ) ) { |
392 | return false; | 393 | return false; |
393 | 394 | ||
394 | } | 395 | } |
395 | QTextStream ts( &file ); | 396 | QTextStream ts( &file ); |
396 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 397 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
397 | text = ts.read(); | 398 | text = ts.read(); |
398 | file.close(); | 399 | file.close(); |
399 | status.setText( i18n("Processing events ...") ); | 400 | status.setText( i18n("Processing events ...") ); |
400 | status.raise(); | 401 | status.raise(); |
401 | qApp->processEvents(); | 402 | qApp->processEvents(); |
402 | fromString2Cal( calendar, existngCal, text, "Event" ); | 403 | fromString2Cal( calendar, existngCal, text, "Event" ); |
403 | status.setText( i18n("Reading todos ...") ); | 404 | status.setText( i18n("Reading todos ...") ); |
404 | qApp->processEvents(); | 405 | qApp->processEvents(); |
405 | if ( ! debug ) { | 406 | if ( ! debug ) { |
406 | fileName = "/tmp/kopitempout"; | 407 | fileName = "/tmp/kopitempout"; |
407 | QString command = "db2file todo -r -c " + codec+ " > " + fileName; | 408 | QString command = "db2file todo -r -c " + codec+ " > " + fileName; |
408 | system ( command.latin1() ); | 409 | system ( command.latin1() ); |
409 | } else { | 410 | } else { |
410 | fileName = "/tmp/todo.txt"; | 411 | fileName = "/tmp/todo.txt"; |
411 | } | 412 | } |
412 | file.setName( fileName ); | 413 | file.setName( fileName ); |
413 | if (!file.open( IO_ReadOnly ) ) { | 414 | if (!file.open( IO_ReadOnly ) ) { |
414 | return false; | 415 | return false; |
415 | 416 | ||
416 | } | 417 | } |
417 | ts.setDevice( &file ); | 418 | ts.setDevice( &file ); |
418 | text = ts.read(); | 419 | text = ts.read(); |
419 | file.close(); | 420 | file.close(); |
420 | 421 | ||
421 | status.setText( i18n("Processing todos ...") ); | 422 | status.setText( i18n("Processing todos ...") ); |
422 | status.raise(); | 423 | status.raise(); |
423 | qApp->processEvents(); | 424 | qApp->processEvents(); |
424 | fromString2Cal( calendar, existngCal, text, "Todo" ); | 425 | fromString2Cal( calendar, existngCal, text, "Todo" ); |
425 | return true; | 426 | return true; |
426 | } | 427 | } |
427 | int SharpFormat::getNumFromRecord( QString answer, Incidence* inc ) | 428 | int SharpFormat::getNumFromRecord( QString answer, Incidence* inc ) |
428 | { | 429 | { |
429 | int retval = -1; | 430 | int retval = -1; |
430 | QStringList templist; | 431 | QStringList templist; |
431 | QString tempString; | 432 | QString tempString; |
432 | int start = 0; | 433 | int start = 0; |
433 | int len = answer.length(); | 434 | int len = answer.length(); |
434 | int end = answer.find ("\n",start)+1; | 435 | int end = answer.find ("\n",start)+1; |
435 | bool ok = true; | 436 | bool ok = true; |
436 | start = end; | 437 | start = end; |
437 | int ccc = 0; | 438 | int ccc = 0; |
438 | while ( start > 0 ) { | 439 | while ( start > 0 ) { |
439 | templist.clear(); | 440 | templist.clear(); |
440 | ok = true; | 441 | ok = true; |
441 | int loopCount = 0; | 442 | int loopCount = 0; |
442 | while ( ok ) { | 443 | while ( ok ) { |
443 | ++loopCount; | 444 | ++loopCount; |
444 | if ( loopCount > 25 ) { | 445 | if ( loopCount > 25 ) { |
445 | qDebug("KO: Error in while loop"); | 446 | qDebug("KO: Error in while loop"); |
446 | ok = false; | 447 | ok = false; |
447 | start = 0; | 448 | start = 0; |
448 | break; | 449 | break; |
449 | } | 450 | } |
450 | if ( ok ) | 451 | if ( ok ) |
451 | tempString = getPart( answer, ok, start ); | 452 | tempString = getPart( answer, ok, start ); |
452 | if ( start >= len || start == 0 ) { | 453 | if ( start >= len || start == 0 ) { |
453 | start = 0; | 454 | start = 0; |
454 | ok = false; | 455 | ok = false; |
455 | } | 456 | } |
456 | if ( tempString.right(1) =="\n" ) | 457 | if ( tempString.right(1) =="\n" ) |
457 | tempString = tempString.left( tempString.length()-1); | 458 | tempString = tempString.left( tempString.length()-1); |
458 | 459 | ||
459 | templist.append( tempString ); | 460 | templist.append( tempString ); |
460 | } | 461 | } |
461 | ++ccc; | 462 | ++ccc; |
462 | if ( ccc == 2 && loopCount < 25 ) { | 463 | if ( ccc == 2 && loopCount < 25 ) { |
463 | start = 0; | 464 | start = 0; |
464 | bool ok; | 465 | bool ok; |
465 | int newnum = templist[0].toInt( &ok ); | 466 | int newnum = templist[0].toInt( &ok ); |
466 | if ( ok && newnum > 0) { | 467 | if ( ok && newnum > 0) { |
467 | retval = newnum; | 468 | retval = newnum; |
468 | inc->setZaurusId( newnum ); | 469 | inc->setZaurusId( newnum ); |
469 | inc->setZaurusUid( getCsum( templist ) ); | 470 | inc->setZaurusUid( getCsum( templist ) ); |
470 | inc->setZaurusStat( -4 ); | 471 | inc->setZaurusStat( SYNC_TEMPSTATE_NEW_ID ); |
471 | } | 472 | } |
472 | } | 473 | } |
473 | } | 474 | } |
474 | //qDebug("getNumFromRecord returning : %d ", retval); | 475 | //qDebug("getNumFromRecord returning : %d ", retval); |
475 | return retval; | 476 | return retval; |
476 | } | 477 | } |
477 | bool SharpFormat::save( Calendar *calendar) | 478 | bool SharpFormat::save( Calendar *calendar) |
478 | { | 479 | { |
479 | 480 | ||
480 | QLabel status ( i18n("Processing/adding events ..."), 0 ); | 481 | QLabel status ( i18n("Processing/adding events ..."), 0 ); |
481 | int w = status.sizeHint().width()+20 ; | 482 | int w = status.sizeHint().width()+20 ; |
482 | if ( w < 200 ) w = 200; | 483 | if ( w < 200 ) w = 200; |
483 | int h = status.sizeHint().height()+20 ; | 484 | int h = status.sizeHint().height()+20 ; |
484 | int dw = QApplication::desktop()->width(); | 485 | int dw = QApplication::desktop()->width(); |
485 | int dh = QApplication::desktop()->height(); | 486 | int dh = QApplication::desktop()->height(); |
486 | status.setCaption(i18n("Writing DTM Data") ); | 487 | status.setCaption(i18n("Writing DTM Data") ); |
487 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 488 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
488 | status.show(); | 489 | status.show(); |
489 | status.raise(); | 490 | status.raise(); |
490 | qApp->processEvents(); | 491 | qApp->processEvents(); |
491 | bool debug = DEBUGMODE; | 492 | bool debug = DEBUGMODE; |
492 | QString codec = "utf8"; | 493 | QString codec = "utf8"; |
493 | QString answer; | 494 | QString answer; |
494 | QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n"; | 495 | QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n"; |
495 | QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; | 496 | QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; |
496 | QString command; | 497 | QString command; |
497 | QPtrList<Event> er = calendar->rawEvents(); | 498 | QPtrList<Event> er = calendar->rawEvents(); |
498 | Event* ev = er.first(); | 499 | Event* ev = er.first(); |
499 | QString fileName = "/tmp/kopitempout"; | 500 | QString fileName = "/tmp/kopitempout"; |
500 | int i = 0; | 501 | int i = 0; |
501 | QString changeString = ePrefix; | 502 | QString changeString = ePrefix; |
502 | QString deleteString = ePrefix; | 503 | QString deleteString = ePrefix; |
503 | bool deleteEnt = false; | 504 | bool deleteEnt = false; |
504 | bool changeEnt = false; | 505 | bool changeEnt = false; |
505 | QString message = i18n("Processing event # "); | 506 | QString message = i18n("Processing event # "); |
506 | int procCount = 0; | 507 | int procCount = 0; |
507 | while ( ev ) { | 508 | while ( ev ) { |
508 | //qDebug("i %d ", ++i); | 509 | //qDebug("i %d ", ++i); |
509 | if ( ev->zaurusStat() != -2 ) { | 510 | if ( ev->zaurusStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
510 | status.setText ( message + QString::number ( ++procCount ) ); | 511 | status.setText ( message + QString::number ( ++procCount ) ); |
511 | qApp->processEvents(); | 512 | qApp->processEvents(); |
512 | QString eString = getEventString( ev ); | 513 | QString eString = getEventString( ev ); |
513 | if ( ev->zaurusStat() == -3 ) { // delete | 514 | if ( ev->zaurusStat() == SYNC_TEMPSTATE_DELETE ) { // delete |
514 | // deleting empty strings does not work. | 515 | // deleting empty strings does not work. |
515 | // we write first and x and then delete the record with the x | 516 | // we write first and x and then delete the record with the x |
516 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); | 517 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); |
517 | changeString += eString + "\n"; | 518 | changeString += eString + "\n"; |
518 | deleteString += eString + "\n"; | 519 | deleteString += eString + "\n"; |
519 | deleteEnt = true; | 520 | deleteEnt = true; |
520 | changeEnt = true; | 521 | changeEnt = true; |
521 | } | 522 | } |
522 | else if ( ev->zaurusId() == -1 ) { // add new | 523 | else if ( ev->zaurusId() == -1 ) { // add new |
523 | command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; | 524 | command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; |
524 | system ( command.utf8() ); | 525 | system ( command.utf8() ); |
525 | QFile file( fileName ); | 526 | QFile file( fileName ); |
526 | if (!file.open( IO_ReadOnly ) ) { | 527 | if (!file.open( IO_ReadOnly ) ) { |
527 | return false; | 528 | return false; |
528 | 529 | ||
529 | } | 530 | } |
530 | QTextStream ts( &file ); | 531 | QTextStream ts( &file ); |
531 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 532 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
532 | answer = ts.read(); | 533 | answer = ts.read(); |
533 | file.close(); | 534 | file.close(); |
534 | //qDebug("answer \n%s ", answer.latin1()); | 535 | //qDebug("answer \n%s ", answer.latin1()); |
535 | getNumFromRecord( answer, ev ) ; | 536 | getNumFromRecord( answer, ev ) ; |
536 | 537 | ||
537 | } | 538 | } |
538 | else { // change existing | 539 | else { // change existing |
539 | //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() ); | 540 | //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() ); |
540 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; | 541 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; |
541 | changeString += eString + "\n"; | 542 | changeString += eString + "\n"; |
542 | changeEnt = true; | 543 | changeEnt = true; |
543 | 544 | ||
544 | } | 545 | } |
545 | } | 546 | } |
546 | ev = er.next(); | 547 | ev = er.next(); |
547 | } | 548 | } |
548 | status.setText ( i18n("Changing events ...") ); | 549 | status.setText ( i18n("Changing events ...") ); |
549 | qApp->processEvents(); | 550 | qApp->processEvents(); |
550 | //qDebug("changing... "); | 551 | //qDebug("changing... "); |
551 | if ( changeEnt ) { | 552 | if ( changeEnt ) { |
552 | QFile file( fileName ); | 553 | QFile file( fileName ); |
553 | if (!file.open( IO_WriteOnly ) ) { | 554 | if (!file.open( IO_WriteOnly ) ) { |
554 | return false; | 555 | return false; |
555 | 556 | ||
556 | } | 557 | } |
557 | QTextStream ts( &file ); | 558 | QTextStream ts( &file ); |
558 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 559 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
559 | ts << changeString ; | 560 | ts << changeString ; |
560 | file.close(); | 561 | file.close(); |
561 | command = "db2file datebook -w -g -c " + codec+ " < "+ fileName; | 562 | command = "db2file datebook -w -g -c " + codec+ " < "+ fileName; |
562 | system ( command.latin1() ); | 563 | system ( command.latin1() ); |
563 | //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); | 564 | //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); |
564 | 565 | ||
565 | } | 566 | } |
566 | status.setText ( i18n("Deleting events ...") ); | 567 | status.setText ( i18n("Deleting events ...") ); |
567 | qApp->processEvents(); | 568 | qApp->processEvents(); |
568 | //qDebug("deleting... "); | 569 | //qDebug("deleting... "); |
569 | if ( deleteEnt ) { | 570 | if ( deleteEnt ) { |
570 | QFile file( fileName ); | 571 | QFile file( fileName ); |
571 | if (!file.open( IO_WriteOnly ) ) { | 572 | if (!file.open( IO_WriteOnly ) ) { |
572 | return false; | 573 | return false; |
573 | 574 | ||
574 | } | 575 | } |
575 | QTextStream ts( &file ); | 576 | QTextStream ts( &file ); |
576 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 577 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
577 | ts << deleteString; | 578 | ts << deleteString; |
578 | file.close(); | 579 | file.close(); |
579 | command = "db2file datebook -d -c " + codec+ " < "+ fileName; | 580 | command = "db2file datebook -d -c " + codec+ " < "+ fileName; |
580 | system ( command.latin1() ); | 581 | system ( command.latin1() ); |
581 | // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); | 582 | // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); |
582 | } | 583 | } |
583 | 584 | ||
584 | 585 | ||
585 | changeString = tPrefix; | 586 | changeString = tPrefix; |
586 | deleteString = tPrefix; | 587 | deleteString = tPrefix; |
587 | status.setText ( i18n("Processing todos ...") ); | 588 | status.setText ( i18n("Processing todos ...") ); |
588 | qApp->processEvents(); | 589 | qApp->processEvents(); |
589 | QPtrList<Todo> tl = calendar->rawTodos(); | 590 | QPtrList<Todo> tl = calendar->rawTodos(); |
590 | Todo* to = tl.first(); | 591 | Todo* to = tl.first(); |
591 | i = 0; | 592 | i = 0; |
592 | message = i18n("Processing todo # "); | 593 | message = i18n("Processing todo # "); |
593 | procCount = 0; | 594 | procCount = 0; |
594 | while ( to ) { | 595 | while ( to ) { |
595 | if ( to->zaurusStat() != -2 ) { | 596 | if ( to->zaurusStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
596 | status.setText ( message + QString::number ( ++procCount ) ); | 597 | status.setText ( message + QString::number ( ++procCount ) ); |
597 | qApp->processEvents(); | 598 | qApp->processEvents(); |
598 | QString eString = getTodoString( to ); | 599 | QString eString = getTodoString( to ); |
599 | if ( to->zaurusStat() == -3 ) { // delete | 600 | if ( to->zaurusStat() == SYNC_TEMPSTATE_DELETE ) { // delete |
600 | // deleting empty strings does not work. | 601 | // deleting empty strings does not work. |
601 | // we write first and x and then delete the record with the x | 602 | // we write first and x and then delete the record with the x |
602 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); | 603 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); |
603 | changeString += eString + "\n"; | 604 | changeString += eString + "\n"; |
604 | deleteString += eString + "\n"; | 605 | deleteString += eString + "\n"; |
605 | deleteEnt = true; | 606 | deleteEnt = true; |
606 | changeEnt = true; | 607 | changeEnt = true; |
607 | } | 608 | } |
608 | else if ( to->zaurusId() == -1 ) { // add new | 609 | else if ( to->zaurusId() == -1 ) { // add new |
609 | command = "(echo \"" + tPrefix + eString + "\" ) | db2file todo -w -g -c " + codec+ " > "+ fileName; | 610 | command = "(echo \"" + tPrefix + eString + "\" ) | db2file todo -w -g -c " + codec+ " > "+ fileName; |
610 | system ( command.utf8() ); | 611 | system ( command.utf8() ); |
611 | QFile file( fileName ); | 612 | QFile file( fileName ); |
612 | if (!file.open( IO_ReadOnly ) ) { | 613 | if (!file.open( IO_ReadOnly ) ) { |
613 | return false; | 614 | return false; |
614 | 615 | ||
615 | } | 616 | } |
616 | QTextStream ts( &file ); | 617 | QTextStream ts( &file ); |
617 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 618 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
618 | answer = ts.read(); | 619 | answer = ts.read(); |
619 | file.close(); | 620 | file.close(); |
620 | //qDebug("answer \n%s ", answer.latin1()); | 621 | //qDebug("answer \n%s ", answer.latin1()); |
621 | getNumFromRecord( answer, to ) ; | 622 | getNumFromRecord( answer, to ) ; |
622 | 623 | ||
623 | } | 624 | } |
624 | else { // change existing | 625 | else { // change existing |
625 | //qDebug("canging %d %d",to->zaurusStat() ,to->zaurusId() ); | 626 | //qDebug("canging %d %d",to->zaurusStat() ,to->zaurusId() ); |
626 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; | 627 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; |
627 | changeString += eString + "\n"; | 628 | changeString += eString + "\n"; |
628 | changeEnt = true; | 629 | changeEnt = true; |
629 | 630 | ||
630 | } | 631 | } |
631 | } | 632 | } |
632 | 633 | ||
633 | to = tl.next(); | 634 | to = tl.next(); |
634 | } | 635 | } |
635 | status.setText ( i18n("Changing todos ...") ); | 636 | status.setText ( i18n("Changing todos ...") ); |
636 | qApp->processEvents(); | 637 | qApp->processEvents(); |
637 | //qDebug("changing... "); | 638 | //qDebug("changing... "); |
638 | if ( changeEnt ) { | 639 | if ( changeEnt ) { |
639 | QFile file( fileName ); | 640 | QFile file( fileName ); |
640 | if (!file.open( IO_WriteOnly ) ) { | 641 | if (!file.open( IO_WriteOnly ) ) { |
641 | return false; | 642 | return false; |
642 | 643 | ||
643 | } | 644 | } |
644 | QTextStream ts( &file ); | 645 | QTextStream ts( &file ); |
645 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 646 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
646 | ts << changeString ; | 647 | ts << changeString ; |
647 | file.close(); | 648 | file.close(); |
648 | command = "db2file todo -w -g -c " + codec+ " < "+ fileName; | 649 | command = "db2file todo -w -g -c " + codec+ " < "+ fileName; |
649 | system ( command.latin1() ); | 650 | system ( command.latin1() ); |
650 | //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); | 651 | //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); |
651 | 652 | ||
652 | } | 653 | } |
653 | status.setText ( i18n("Deleting todos ...") ); | 654 | status.setText ( i18n("Deleting todos ...") ); |
654 | qApp->processEvents(); | 655 | qApp->processEvents(); |
655 | //qDebug("deleting... "); | 656 | //qDebug("deleting... "); |
656 | if ( deleteEnt ) { | 657 | if ( deleteEnt ) { |
657 | QFile file( fileName ); | 658 | QFile file( fileName ); |
658 | if (!file.open( IO_WriteOnly ) ) { | 659 | if (!file.open( IO_WriteOnly ) ) { |
659 | return false; | 660 | return false; |
660 | 661 | ||
661 | } | 662 | } |
662 | QTextStream ts( &file ); | 663 | QTextStream ts( &file ); |
663 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 664 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
664 | ts << deleteString; | 665 | ts << deleteString; |
665 | file.close(); | 666 | file.close(); |
666 | command = "db2file todo -d -c " + codec+ " < "+ fileName; | 667 | command = "db2file todo -d -c " + codec+ " < "+ fileName; |
667 | system ( command.latin1() ); | 668 | system ( command.latin1() ); |
668 | // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); | 669 | // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); |
669 | } | 670 | } |
670 | 671 | ||
671 | return true; | 672 | return true; |
672 | } | 673 | } |
673 | QString SharpFormat::dtToString( const QDateTime& dti, bool useTZ ) | 674 | QString SharpFormat::dtToString( const QDateTime& dti, bool useTZ ) |
674 | { | 675 | { |
675 | QString datestr; | 676 | QString datestr; |
676 | QString timestr; | 677 | QString timestr; |
677 | int offset = KGlobal::locale()->localTimeOffset( dti ); | 678 | int offset = KGlobal::locale()->localTimeOffset( dti ); |
678 | QDateTime dt; | 679 | QDateTime dt; |
679 | if (useTZ) | 680 | if (useTZ) |
680 | dt = dti.addSecs ( -(offset*60)); | 681 | dt = dti.addSecs ( -(offset*60)); |
681 | else | 682 | else |
682 | dt = dti; | 683 | dt = dti; |
683 | if(dt.date().isValid()){ | 684 | if(dt.date().isValid()){ |
684 | const QDate& date = dt.date(); | 685 | const QDate& date = dt.date(); |
685 | datestr.sprintf("%04d%02d%02d", | 686 | datestr.sprintf("%04d%02d%02d", |
686 | date.year(), date.month(), date.day()); | 687 | date.year(), date.month(), date.day()); |
687 | } | 688 | } |
688 | if(dt.time().isValid()){ | 689 | if(dt.time().isValid()){ |
689 | const QTime& time = dt.time(); | 690 | const QTime& time = dt.time(); |
690 | timestr.sprintf("T%02d%02d%02d", | 691 | timestr.sprintf("T%02d%02d%02d", |
691 | time.hour(), time.minute(), time.second()); | 692 | time.hour(), time.minute(), time.second()); |
692 | } | 693 | } |
693 | return datestr + timestr; | 694 | return datestr + timestr; |
694 | } | 695 | } |
695 | QString SharpFormat::getEventString( Event* event ) | 696 | QString SharpFormat::getEventString( Event* event ) |
diff --git a/libkcal/syncdefines.h b/libkcal/syncdefines.h new file mode 100644 index 0000000..57642ec --- a/dev/null +++ b/libkcal/syncdefines.h | |||
@@ -0,0 +1,22 @@ | |||
1 | |||
2 | #ifndef _KSYNC_DEFINES_H_ | ||
3 | #define _KSYNC_DEFINES_H_ | ||
4 | |||
5 | #define SYNC_PREF_LOCAL 0 | ||
6 | #define SYNC_PREF_REMOTE 1 | ||
7 | #define SYNC_PREF_NEWEST 2 | ||
8 | #define SYNC_PREF_ASK 3 | ||
9 | #define SYNC_PREF_FORCE_LOCAL 4 | ||
10 | #define SYNC_PREF_FORCE_REMOTE 5 | ||
11 | #define SYNC_PREF_TAKE_BOTH 6 | ||
12 | |||
13 | #define SYNC_MODE_NORMAL 0 | ||
14 | #define SYNC_MODE_EXTERNAL 1 | ||
15 | |||
16 | #define SYNC_TEMPSTATE_INITIAL 0 | ||
17 | #define SYNC_TEMPSTATE_NEW_EXTERNAL -2 | ||
18 | #define SYNC_TEMPSTATE_DELETE -3 | ||
19 | #define SYNC_TEMPSTATE_NEW_ID -4 | ||
20 | |||
21 | |||
22 | #endif | ||