summaryrefslogtreecommitdiffabout
path: root/libkcal
Unidiff
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/phoneformat.cpp79
-rw-r--r--libkcal/phoneformat.h14
2 files changed, 49 insertions, 44 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index f78730d..fa18683 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -1,1359 +1,1364 @@
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 "phoneformat.h" 44#include "phoneformat.h"
45 45
46using namespace KCal; 46using namespace KCal;
47 47
48//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY 48//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 49// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
50 50
51//ARSD silentalarm = 0 51//ARSD silentalarm = 0
52// 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly 52// 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly
53// 12 RFRQ 53// 12 RFRQ
54// 13 RPOS pos = 4. monday in month 54// 13 RPOS pos = 4. monday in month
55// 14 RDYS days: 1 mon/ 2 tue .. 64 sun 55// 14 RDYS days: 1 mon/ 2 tue .. 64 sun
56// 15 REND 0 = no end/ 1 = end 56// 15 REND 0 = no end/ 1 = end
57// 16 REDT rec end dt 57// 16 REDT rec end dt
58//ALSD 58//ALSD
59//ALED 59//ALED
60//MDAY 60//MDAY
61 61
62class SharpParser : public QObject 62class PhoneParser : public QObject
63{ 63{
64 public: 64 public:
65 SharpParser( Calendar *calendar ) : mCalendar( calendar ) { 65 PhoneParser( Calendar *calendar ) : mCalendar( calendar ) {
66 oldCategories = 0; 66 oldCategories = 0;
67 } 67 }
68 68
69 bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName ) 69 bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName )
70 { 70 {
71 int i = 1; 71 int i = 1;
72 bool skip = true; 72 bool skip = true;
73 int max = attList.count() -2; 73 int max = attList.count() -2;
74 while ( i < max ) { 74 while ( i < max ) {
75 if ( !attList[i].isEmpty() ) { 75 if ( !attList[i].isEmpty() ) {
76 skip = false; 76 skip = false;
77 break; 77 break;
78 } 78 }
79 ++i ; 79 ++i ;
80 } 80 }
81 if ( skip ) 81 if ( skip )
82 return false; 82 return false;
83 ulong cSum = SharpFormat::getCsum(attList ); 83 ulong cSum = PhoneFormat::getCsum(attList );
84 84
85 if ( qName == "Event" ) { 85 if ( qName == "Event" ) {
86 Event *event; 86 Event *event;
87 event = existingCalendar->event( attList[0].toInt() ); 87 event = existingCalendar->event( attList[0] );
88 if ( event ) 88 if ( event )
89 event = (Event*)event->clone(); 89 event = (Event*)event->clone();
90 else 90 else
91 event = new Event; 91 event = new Event;
92 event->setZaurusId( attList[0].toInt() ); 92 // event->setZaurusId( attList[0].toInt() );
93 event->setZaurusUid( cSum ); 93 //event->setZaurusUid( cSum );
94 event->setZaurusStat( -2 ); 94 //event->setZaurusStat( -2 );
95 95
96 event->setSummary( attList[2] ); 96 event->setSummary( attList[2] );
97 event->setLocation( attList[3] ); 97 event->setLocation( attList[3] );
98 event->setDescription( attList[4] ); 98 event->setDescription( attList[4] );
99 if ( attList[7] == "1" ) { 99 if ( attList[7] == "1" ) {
100 event->setDtStart( QDateTime(fromString( attList[17]+"T000000", false ).date(),QTime(0,0,0 ) )); 100 event->setDtStart( QDateTime(fromString( attList[17]+"T000000", false ).date(),QTime(0,0,0 ) ));
101 event->setDtEnd( QDateTime(fromString( attList[18]+"T000000", false ).date(),QTime(0,0,0 ))); 101 event->setDtEnd( QDateTime(fromString( attList[18]+"T000000", false ).date(),QTime(0,0,0 )));
102 event->setFloats( true ); 102 event->setFloats( true );
103 } else { 103 } else {
104 event->setFloats( false ); 104 event->setFloats( false );
105 event->setDtStart( fromString( attList[5] ) ); 105 event->setDtStart( fromString( attList[5] ) );
106 event->setDtEnd( fromString( attList[6] )); 106 event->setDtEnd( fromString( attList[6] ));
107 } 107 }
108 108
109 QString rtype = attList[11]; 109 QString rtype = attList[11];
110 if ( rtype != "255" ) { 110 if ( rtype != "255" ) {
111 // qDebug("recurs "); 111 // qDebug("recurs ");
112 QDate startDate = event->dtStart().date(); 112 QDate startDate = event->dtStart().date();
113 113
114 QString freqStr = attList[12]; 114 QString freqStr = attList[12];
115 int freq = freqStr.toInt(); 115 int freq = freqStr.toInt();
116 116
117 QString hasEndDateStr = attList[15] ; 117 QString hasEndDateStr = attList[15] ;
118 bool hasEndDate = hasEndDateStr == "1"; 118 bool hasEndDate = hasEndDateStr == "1";
119 119
120 QString endDateStr = attList[16]; 120 QString endDateStr = attList[16];
121 QDate endDate = fromString( endDateStr ).date(); 121 QDate endDate = fromString( endDateStr ).date();
122 122
123 QString weekDaysStr = attList[14]; 123 QString weekDaysStr = attList[14];
124 uint weekDaysNum = weekDaysStr.toInt(); 124 uint weekDaysNum = weekDaysStr.toInt();
125 125
126 QBitArray weekDays( 7 ); 126 QBitArray weekDays( 7 );
127 int i; 127 int i;
128 int bb = 1; 128 int bb = 1;
129 for( i = 1; i <= 7; ++i ) { 129 for( i = 1; i <= 7; ++i ) {
130 weekDays.setBit( i - 1, ( bb & weekDaysNum )); 130 weekDays.setBit( i - 1, ( bb & weekDaysNum ));
131 bb = 2 << (i-1); 131 bb = 2 << (i-1);
132 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); 132 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) );
133 } 133 }
134 // qDebug("next "); 134 // qDebug("next ");
135 QString posStr = attList[13]; 135 QString posStr = attList[13];
136 int pos = posStr.toInt(); 136 int pos = posStr.toInt();
137 Recurrence *r = event->recurrence(); 137 Recurrence *r = event->recurrence();
138 138
139 if ( rtype == "0" ) { 139 if ( rtype == "0" ) {
140 if ( hasEndDate ) r->setDaily( freq, endDate ); 140 if ( hasEndDate ) r->setDaily( freq, endDate );
141 else r->setDaily( freq, -1 ); 141 else r->setDaily( freq, -1 );
142 } else if ( rtype == "1" ) { 142 } else if ( rtype == "1" ) {
143 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); 143 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate );
144 else r->setWeekly( freq, weekDays, -1 ); 144 else r->setWeekly( freq, weekDays, -1 );
145 } else if ( rtype == "3" ) { 145 } else if ( rtype == "3" ) {
146 if ( hasEndDate ) 146 if ( hasEndDate )
147 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); 147 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
148 else 148 else
149 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); 149 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 );
150 r->addMonthlyDay( startDate.day() ); 150 r->addMonthlyDay( startDate.day() );
151 } else if ( rtype == "2" ) { 151 } else if ( rtype == "2" ) {
152 if ( hasEndDate ) 152 if ( hasEndDate )
153 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); 153 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
154 else 154 else
155 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); 155 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 );
156 QBitArray days( 7 ); 156 QBitArray days( 7 );
157 days.fill( false ); 157 days.fill( false );
158 days.setBit( startDate.dayOfWeek() - 1 ); 158 days.setBit( startDate.dayOfWeek() - 1 );
159 r->addMonthlyPos( pos, days ); 159 r->addMonthlyPos( pos, days );
160 } else if ( rtype == "4" ) { 160 } else if ( rtype == "4" ) {
161 if ( hasEndDate ) 161 if ( hasEndDate )
162 r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); 162 r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
163 else 163 else
164 r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); 164 r->setYearly( Recurrence::rYearlyMonth, freq, -1 );
165 r->addYearlyNum( startDate.month() ); 165 r->addYearlyNum( startDate.month() );
166 } 166 }
167 } 167 }
168 168
169 QString categoryList = attList[1] ; 169 QString categoryList = attList[1] ;
170 event->setCategories( lookupCategories( categoryList ) ); 170 event->setCategories( lookupCategories( categoryList ) );
171 171
172 // strange 0 semms to mean: alarm enabled 172 // strange 0 semms to mean: alarm enabled
173 if ( attList[8] == "0" ) { 173 if ( attList[8] == "0" ) {
174 Alarm *alarm; 174 Alarm *alarm;
175 if ( event->alarms().count() > 0 ) 175 if ( event->alarms().count() > 0 )
176 alarm = event->alarms().first(); 176 alarm = event->alarms().first();
177 else { 177 else {
178 alarm = new Alarm( event ); 178 alarm = new Alarm( event );
179 event->addAlarm( alarm ); 179 event->addAlarm( alarm );
180 } 180 }
181 alarm->setType( Alarm::Audio ); 181 alarm->setType( Alarm::Audio );
182 alarm->setEnabled( true ); 182 alarm->setEnabled( true );
183 int alarmOffset = attList[9].toInt(); 183 int alarmOffset = attList[9].toInt();
184 alarm->setStartOffset( alarmOffset * -60 ); 184 alarm->setStartOffset( alarmOffset * -60 );
185 } 185 }
186 186
187 mCalendar->addEvent( event); 187 mCalendar->addEvent( event);
188 } else if ( qName == "Todo" ) { 188 } else if ( qName == "Todo" ) {
189 Todo *todo; 189 Todo *todo;
190 190
191 todo = existingCalendar->todo( attList[0].toInt() ); 191 todo = existingCalendar->todo( attList[0] );
192 if (todo ) 192 if (todo )
193 todo = (Todo*)todo->clone(); 193 todo = (Todo*)todo->clone();
194 else 194 else
195 todo = new Todo; 195 todo = new Todo;
196 196
197//CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 197//CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1
198// 0 1 2 3 4 5 6 7 8 198// 0 1 2 3 4 5 6 7 8
199//1,,,,,1,4,Loch zumachen,"" 199//1,,,,,1,4,Loch zumachen,""
200//3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " 200//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 201//2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes
202 202
203 todo->setZaurusId( attList[0].toInt() ); 203 //todo->setZaurusId( attList[0] );
204 todo->setZaurusUid( cSum ); 204 //todo->setZaurusUid( cSum );
205 todo->setZaurusStat( -2 ); 205 //todo->setZaurusStat( -2 );
206 206
207 todo->setSummary( attList[7] ); 207 todo->setSummary( attList[7] );
208 todo->setDescription( attList[8]); 208 todo->setDescription( attList[8]);
209 209
210 int priority = attList[6].toInt(); 210 int priority = attList[6].toInt();
211 if ( priority == 0 ) priority = 3; 211 if ( priority == 0 ) priority = 3;
212 todo->setPriority( priority ); 212 todo->setPriority( priority );
213 213
214 QString categoryList = attList[1]; 214 QString categoryList = attList[1];
215 todo->setCategories( lookupCategories( categoryList ) ); 215 todo->setCategories( lookupCategories( categoryList ) );
216 216
217 217
218 218
219 QString hasDateStr = attList[3]; // due 219 QString hasDateStr = attList[3]; // due
220 if ( !hasDateStr.isEmpty() ) { 220 if ( !hasDateStr.isEmpty() ) {
221 if ( hasDateStr.right(6) == "000000" ) { 221 if ( hasDateStr.right(6) == "000000" ) {
222 todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); 222 todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) );
223 todo->setFloats( true ); 223 todo->setFloats( true );
224 } 224 }
225 else { 225 else {
226 todo->setDtDue( fromString( hasDateStr ) ); 226 todo->setDtDue( fromString( hasDateStr ) );
227 todo->setFloats( false ); 227 todo->setFloats( false );
228 } 228 }
229 229
230 todo->setHasDueDate( true ); 230 todo->setHasDueDate( true );
231 } 231 }
232 hasDateStr = attList[2];//start 232 hasDateStr = attList[2];//start
233 if ( !hasDateStr.isEmpty() ) { 233 if ( !hasDateStr.isEmpty() ) {
234 234
235 todo->setDtStart( fromString( hasDateStr ) ); 235 todo->setDtStart( fromString( hasDateStr ) );
236 todo->setHasStartDate( true); 236 todo->setHasStartDate( true);
237 } else 237 } else
238 todo->setHasStartDate( false ); 238 todo->setHasStartDate( false );
239 hasDateStr = attList[4];//completed 239 hasDateStr = attList[4];//completed
240 if ( !hasDateStr.isEmpty() ) { 240 if ( !hasDateStr.isEmpty() ) {
241 todo->setCompleted(fromString( hasDateStr ) ); 241 todo->setCompleted(fromString( hasDateStr ) );
242 } 242 }
243 QString completedStr = attList[5]; 243 QString completedStr = attList[5];
244 if ( completedStr == "0" ) 244 if ( completedStr == "0" )
245 todo->setCompleted( true ); 245 todo->setCompleted( true );
246 else 246 else
247 todo->setCompleted( false ); 247 todo->setCompleted( false );
248 mCalendar->addTodo( todo ); 248 mCalendar->addTodo( todo );
249 249
250 } else if ( qName == "Category" ) { 250 } else if ( qName == "Category" ) {
251 /* 251 /*
252 QString id = attributes.value( "id" ); 252 QString id = attributes.value( "id" );
253 QString name = attributes.value( "name" ); 253 QString name = attributes.value( "name" );
254 setCategory( id, name ); 254 setCategory( id, name );
255 */ 255 */
256 } 256 }
257 //qDebug("end "); 257 //qDebug("end ");
258 return true; 258 return true;
259 } 259 }
260 260
261 261
262 void setCategoriesList ( QStringList * c ) 262 void setCategoriesList ( QStringList * c )
263 { 263 {
264 oldCategories = c; 264 oldCategories = c;
265 } 265 }
266 266
267 QDateTime fromString ( QString s, bool useTz = true ) { 267 QDateTime fromString ( QString s, bool useTz = true ) {
268 QDateTime dt; 268 QDateTime dt;
269 int y,m,t,h,min,sec; 269 int y,m,t,h,min,sec;
270 y = s.mid(0,4).toInt(); 270 y = s.mid(0,4).toInt();
271 m = s.mid(4,2).toInt(); 271 m = s.mid(4,2).toInt();
272 t = s.mid(6,2).toInt(); 272 t = s.mid(6,2).toInt();
273 h = s.mid(9,2).toInt(); 273 h = s.mid(9,2).toInt();
274 min = s.mid(11,2).toInt(); 274 min = s.mid(11,2).toInt();
275 sec = s.mid(13,2).toInt(); 275 sec = s.mid(13,2).toInt();
276 dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); 276 dt = QDateTime(QDate(y,m,t), QTime(h,min,sec));
277 int offset = KGlobal::locale()->localTimeOffset( dt ); 277 int offset = KGlobal::locale()->localTimeOffset( dt );
278 if ( useTz ) 278 if ( useTz )
279 dt = dt.addSecs ( offset*60); 279 dt = dt.addSecs ( offset*60);
280 return dt; 280 return dt;
281 281
282 } 282 }
283 protected: 283 protected:
284 QDateTime toDateTime( const QString &value ) 284 QDateTime toDateTime( const QString &value )
285 { 285 {
286 QDateTime dt; 286 QDateTime dt;
287 dt.setTime_t( value.toUInt() ); 287 dt.setTime_t( value.toUInt() );
288 288
289 return dt; 289 return dt;
290 } 290 }
291 291
292 QStringList lookupCategories( const QString &categoryList ) 292 QStringList lookupCategories( const QString &categoryList )
293 { 293 {
294 QStringList categoryIds = QStringList::split( ";", categoryList ); 294 QStringList categoryIds = QStringList::split( ";", categoryList );
295 QStringList categories; 295 QStringList categories;
296 QStringList::ConstIterator it; 296 QStringList::ConstIterator it;
297 for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) { 297 for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) {
298 QString cate = category( *it ); 298 QString cate = category( *it );
299 if ( oldCategories ) { 299 if ( oldCategories ) {
300 if ( ! oldCategories->contains( cate ) ) 300 if ( ! oldCategories->contains( cate ) )
301 oldCategories->append( cate ); 301 oldCategories->append( cate );
302 } 302 }
303 categories.append(cate ); 303 categories.append(cate );
304 } 304 }
305 return categories; 305 return categories;
306 } 306 }
307 307
308 private: 308 private:
309 Calendar *mCalendar; 309 Calendar *mCalendar;
310 QStringList * oldCategories; 310 QStringList * oldCategories;
311 static QString category( const QString &id ) 311 static QString category( const QString &id )
312 { 312 {
313 QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id ); 313 QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id );
314 if ( it == mCategoriesMap.end() ) return id; 314 if ( it == mCategoriesMap.end() ) return id;
315 else return *it; 315 else return *it;
316 } 316 }
317 317
318 static void setCategory( const QString &id, const QString &name ) 318 static void setCategory( const QString &id, const QString &name )
319 { 319 {
320 mCategoriesMap.insert( id, name ); 320 mCategoriesMap.insert( id, name );
321 } 321 }
322 322
323 static QMap<QString,QString> mCategoriesMap; 323 static QMap<QString,QString> mCategoriesMap;
324}; 324};
325 325
326QMap<QString,QString> SharpParser::mCategoriesMap; 326QMap<QString,QString> PhoneParser::mCategoriesMap;
327 327
328SharpFormat::SharpFormat() 328PhoneFormat::PhoneFormat()
329{ 329{
330 mCategories = 0; 330 mCategories = 0;
331} 331}
332 332
333SharpFormat::~SharpFormat() 333PhoneFormat::~PhoneFormat()
334{ 334{
335} 335}
336ulong SharpFormat::getCsum( const QStringList & attList) 336ulong PhoneFormat::getCsum( const QStringList & attList)
337{ 337{
338 int max = attList.count() -1; 338 int max = attList.count() -1;
339 ulong cSum = 0; 339 ulong cSum = 0;
340 int j,k,i; 340 int j,k,i;
341 int add; 341 int add;
342 for ( i = 1; i < max ; ++i ) { 342 for ( i = 1; i < max ; ++i ) {
343 QString s = attList[i]; 343 QString s = attList[i];
344 if ( ! s.isEmpty() ){ 344 if ( ! s.isEmpty() ){
345 j = s.length(); 345 j = s.length();
346 for ( k = 0; k < j; ++k ) { 346 for ( k = 0; k < j; ++k ) {
347 int mul = k +1; 347 int mul = k +1;
348 add = s[k].unicode (); 348 add = s[k].unicode ();
349 if ( k < 16 ) 349 if ( k < 16 )
350 mul = mul * mul; 350 mul = mul * mul;
351 add = add * mul *i*i*i; 351 add = add * mul *i*i*i;
352 cSum += add; 352 cSum += add;
353 } 353 }
354 } 354 }
355 } 355 }
356 return cSum; 356 return cSum;
357 357
358} 358}
359//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); 359//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum);
360#include <stdlib.h> 360#include <stdlib.h>
361#define DEBUGMODE false 361#define DEBUGMODE false
362bool SharpFormat::load( Calendar *calendar, Calendar *existngCal ) 362bool PhoneFormat::load( Calendar *calendar, Calendar *existngCal )
363{ 363{
364 364
365 GSM_StateMachines; 365 GSM_StateMachines;
366 qDebug(" load "); 366 qDebug(" load ");
367 s.opened = false; 367 s.opened = false;
368 s.msg = NULL; 368 s.msg = NULL;
369 s.ConfigNum = 0; 369 s.ConfigNum = 0;
370 static char*cp; 370 static char*cp;
371 static INI_Section *cfg = NULL; 371 static INI_Section *cfg = NULL;
372 cfg=GSM_FindGammuRC(); 372 cfg=GSM_FindGammuRC();
373 int i; 373 int i;
374 for (i = 0; i <= MAX_CONFIG_NUM; i++) { 374 for (i = 0; i <= MAX_CONFIG_NUM; i++) {
375 if (cfg!=NULL) { 375 if (cfg!=NULL) {
376 cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false); 376 cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false);
377 if (cp) di.coding = cp; 377 if (cp) di.coding = cp;
378 378
379 s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false); 379 s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false);
380 if (s.Config[i].Localize) { 380 if (s.Config[i].Localize) {
381 s.msg=INI_ReadFile(s.Config[i].Localize, true); 381 s.msg=INI_ReadFile(s.Config[i].Localize, true);
382 } else { 382 } else {
383#if !defined(WIN32) && defined(LOCALE_PATH) 383#if !defined(WIN32) && defined(LOCALE_PATH)
384 locale = setlocale(LC_MESSAGES, NULL); 384 locale = setlocale(LC_MESSAGES, NULL);
385 if (locale != NULL) { 385 if (locale != NULL) {
386 snprintf(locale_file, 200, "%s/gammu_%c%c.txt", 386 snprintf(locale_file, 200, "%s/gammu_%c%c.txt",
387 LOCALE_PATH, 387 LOCALE_PATH,
388 tolower(locale[0]), 388 tolower(locale[0]),
389 tolower(locale[1])); 389 tolower(locale[1]));
390 s.msg = INI_ReadFile(locale_file, true); 390 s.msg = INI_ReadFile(locale_file, true);
391 } 391 }
392#endif 392#endif
393 } 393 }
394 } 394 }
395 395
396 /* Wanted user specific configuration? */ 396 /* Wanted user specific configuration? */
397 397
398 if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; 398 if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break;
399 399
400 s.ConfigNum++; 400 s.ConfigNum++;
401 401
402 /* We want to use only one file descriptor for global and state machine debug output */ 402 /* We want to use only one file descriptor for global and state machine debug output */
403 s.Config[i].UseGlobalDebugFile = true; 403 s.Config[i].UseGlobalDebugFile = true;
404 404
405 405
406 406
407 /* We wanted to read just user specified configuration. */ 407 /* We wanted to read just user specified configuration. */
408 {break;} 408 {break;}
409 } 409 }
410 410
411 411
412 412
413 413
414 int error=GSM_InitConnection(&s,3); 414 int error=GSM_InitConnection(&s,3);
415 415
416 416
417 qDebug(" init %d %d", error, ERR_NONE); 417 qDebug(" init %d %d", error, ERR_NONE);
418 if ( error != ERR_NONE ) 418 if ( error != ERR_NONE )
419 return false; 419 return false;
420 fromString2Cal( calendar, existngCal, &s, "Event" ); 420 fromString2Cal( calendar, existngCal, &s, "Event" );
421 421
422 422
423 error=GSM_TerminateConnection(&s); 423 error=GSM_TerminateConnection(&s);
424 424
425 425
426#if 0 426#if 0
427 427
428 bool debug = DEBUGMODE; 428 bool debug = DEBUGMODE;
429 //debug = true; 429 //debug = true;
430 QString text; 430 QString text;
431 QString codec = "utf8"; 431 QString codec = "utf8";
432 QLabel status ( i18n("Reading events ..."), 0 ); 432 QLabel status ( i18n("Reading events ..."), 0 );
433 433
434 int w = status.sizeHint().width()+20 ; 434 int w = status.sizeHint().width()+20 ;
435 if ( w < 200 ) w = 200; 435 if ( w < 200 ) w = 200;
436 int h = status.sizeHint().height()+20 ; 436 int h = status.sizeHint().height()+20 ;
437 int dw = QApplication::desktop()->width(); 437 int dw = QApplication::desktop()->width();
438 int dh = QApplication::desktop()->height(); 438 int dh = QApplication::desktop()->height();
439 status.setCaption(i18n("Reading DTM Data") ); 439 status.setCaption(i18n("Reading DTM Data") );
440 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 440 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
441 status.show(); 441 status.show();
442 status.raise(); 442 status.raise();
443 qApp->processEvents(); 443 qApp->processEvents();
444 QString fileName; 444 QString fileName;
445 if ( ! debug ) { 445 if ( ! debug ) {
446 fileName = "/tmp/kopitempout"; 446 fileName = "/tmp/kopitempout";
447 QString command ="db2file datebook -r -c "+ codec + " > " + fileName; 447 QString command ="db2file datebook -r -c "+ codec + " > " + fileName;
448 system ( command.latin1() ); 448 system ( command.latin1() );
449 } else { 449 } else {
450 fileName = "/tmp/events.txt"; 450 fileName = "/tmp/events.txt";
451 451
452 } 452 }
453 QFile file( fileName ); 453 QFile file( fileName );
454 if (!file.open( IO_ReadOnly ) ) { 454 if (!file.open( IO_ReadOnly ) ) {
455 return false; 455 return false;
456 456
457 } 457 }
458 QTextStream ts( &file ); 458 QTextStream ts( &file );
459 ts.setCodec( QTextCodec::codecForName("utf8") ); 459 ts.setCodec( QTextCodec::codecForName("utf8") );
460 text = ts.read(); 460 text = ts.read();
461 file.close(); 461 file.close();
462 status.setText( i18n("Processing events ...") ); 462 status.setText( i18n("Processing events ...") );
463 status.raise(); 463 status.raise();
464 qApp->processEvents(); 464 qApp->processEvents();
465 fromString2Cal( calendar, existngCal, text, "Event" ); 465 fromString2Cal( calendar, existngCal, text, "Event" );
466 status.setText( i18n("Reading todos ...") ); 466 status.setText( i18n("Reading todos ...") );
467 qApp->processEvents(); 467 qApp->processEvents();
468 if ( ! debug ) { 468 if ( ! debug ) {
469 fileName = "/tmp/kopitempout"; 469 fileName = "/tmp/kopitempout";
470 QString command = "db2file todo -r -c " + codec+ " > " + fileName; 470 QString command = "db2file todo -r -c " + codec+ " > " + fileName;
471 system ( command.latin1() ); 471 system ( command.latin1() );
472 } else { 472 } else {
473 fileName = "/tmp/todo.txt"; 473 fileName = "/tmp/todo.txt";
474 } 474 }
475 file.setName( fileName ); 475 file.setName( fileName );
476 if (!file.open( IO_ReadOnly ) ) { 476 if (!file.open( IO_ReadOnly ) ) {
477 return false; 477 return false;
478 478
479 } 479 }
480 ts.setDevice( &file ); 480 ts.setDevice( &file );
481 text = ts.read(); 481 text = ts.read();
482 file.close(); 482 file.close();
483 483
484 status.setText( i18n("Processing todos ...") ); 484 status.setText( i18n("Processing todos ...") );
485 status.raise(); 485 status.raise();
486 qApp->processEvents(); 486 qApp->processEvents();
487 fromString2Cal( calendar, existngCal, text, "Todo" ); 487 fromString2Cal( calendar, existngCal, text, "Todo" );
488#endif 488#endif
489 return true; 489 return true;
490} 490}
491int SharpFormat::getNumFromRecord( QString answer, Incidence* inc ) 491int PhoneFormat::getNumFromRecord( QString answer, Incidence* inc )
492{ 492{
493 int retval = -1; 493 int retval = -1;
494 QStringList templist; 494 QStringList templist;
495 QString tempString; 495 QString tempString;
496 int start = 0; 496 int start = 0;
497 int len = answer.length(); 497 int len = answer.length();
498 int end = answer.find ("\n",start)+1; 498 int end = answer.find ("\n",start)+1;
499 bool ok = true; 499 bool ok = true;
500 start = end; 500 start = end;
501 int ccc = 0; 501 int ccc = 0;
502 while ( start > 0 ) { 502 while ( start > 0 ) {
503 templist.clear(); 503 templist.clear();
504 ok = true; 504 ok = true;
505 int loopCount = 0; 505 int loopCount = 0;
506 while ( ok ) { 506 while ( ok ) {
507 ++loopCount; 507 ++loopCount;
508 if ( loopCount > 25 ) { 508 if ( loopCount > 25 ) {
509 qDebug("KO: Error in while loop"); 509 qDebug("KO: Error in while loop");
510 ok = false; 510 ok = false;
511 start = 0; 511 start = 0;
512 break; 512 break;
513 } 513 }
514 if ( ok ) 514 if ( ok )
515 tempString = getPart( answer, ok, start ); 515 tempString = getPart( answer, ok, start );
516 if ( start >= len || start == 0 ) { 516 if ( start >= len || start == 0 ) {
517 start = 0; 517 start = 0;
518 ok = false; 518 ok = false;
519 } 519 }
520 if ( tempString.right(1) =="\n" ) 520 if ( tempString.right(1) =="\n" )
521 tempString = tempString.left( tempString.length()-1); 521 tempString = tempString.left( tempString.length()-1);
522 522
523 templist.append( tempString ); 523 templist.append( tempString );
524 } 524 }
525 ++ccc; 525 ++ccc;
526 if ( ccc == 2 && loopCount < 25 ) { 526 if ( ccc == 2 && loopCount < 25 ) {
527 start = 0; 527 start = 0;
528 bool ok; 528 bool ok;
529 int newnum = templist[0].toInt( &ok ); 529 int newnum = templist[0].toInt( &ok );
530 if ( ok && newnum > 0) { 530 if ( ok && newnum > 0) {
531 retval = newnum; 531 retval = newnum;
532 inc->setZaurusId( newnum ); 532 //inc->setZaurusId( newnum );
533 inc->setZaurusUid( getCsum( templist ) ); 533 //inc->setZaurusUid( getCsum( templist ) );
534 inc->setZaurusStat( -4 ); 534 //inc->setZaurusStat( -4 );
535 } 535 }
536 } 536 }
537 } 537 }
538 //qDebug("getNumFromRecord returning : %d ", retval); 538 //qDebug("getNumFromRecord returning : %d ", retval);
539 return retval; 539 return retval;
540} 540}
541bool SharpFormat::save( Calendar *calendar) 541bool PhoneFormat::save( Calendar *calendar)
542{ 542{
543 543
544 QLabel status ( i18n("Processing/adding events ..."), 0 ); 544 QLabel status ( i18n("Processing/adding events ..."), 0 );
545 int w = status.sizeHint().width()+20 ; 545 int w = status.sizeHint().width()+20 ;
546 if ( w < 200 ) w = 200; 546 if ( w < 200 ) w = 200;
547 int h = status.sizeHint().height()+20 ; 547 int h = status.sizeHint().height()+20 ;
548 int dw = QApplication::desktop()->width(); 548 int dw = QApplication::desktop()->width();
549 int dh = QApplication::desktop()->height(); 549 int dh = QApplication::desktop()->height();
550 status.setCaption(i18n("Writing DTM Data") ); 550 status.setCaption(i18n("Writing DTM Data") );
551 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 551 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
552 status.show(); 552 status.show();
553 status.raise(); 553 status.raise();
554 qApp->processEvents(); 554 qApp->processEvents();
555 bool debug = DEBUGMODE; 555 bool debug = DEBUGMODE;
556 QString codec = "utf8"; 556 QString codec = "utf8";
557 QString answer; 557 QString answer;
558 QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n"; 558 QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n";
559 QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; 559 QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n";
560 QString command; 560 QString command;
561 QPtrList<Event> er = calendar->rawEvents(); 561 QPtrList<Event> er = calendar->rawEvents();
562 Event* ev = er.first(); 562 Event* ev = er.first();
563 QString fileName = "/tmp/kopitempout"; 563 QString fileName = "/tmp/kopitempout";
564 int i = 0; 564 int i = 0;
565 QString changeString = ePrefix; 565 QString changeString = ePrefix;
566 QString deleteString = ePrefix; 566 QString deleteString = ePrefix;
567 bool deleteEnt = false; 567 bool deleteEnt = false;
568 bool changeEnt = false; 568 bool changeEnt = false;
569 QString message = i18n("Processing event # "); 569 QString message = i18n("Processing event # ");
570 int procCount = 0; 570 int procCount = 0;
571 while ( ev ) { 571 while ( ev ) {
572 //qDebug("i %d ", ++i); 572 //qDebug("i %d ", ++i);
573 if ( ev->zaurusStat() != -2 ) { 573 if ( true /*ev->zaurusStat() != -2*/ ) {
574 status.setText ( message + QString::number ( ++procCount ) ); 574 status.setText ( message + QString::number ( ++procCount ) );
575 qApp->processEvents(); 575 qApp->processEvents();
576 QString eString = getEventString( ev ); 576 QString eString = getEventString( ev );
577 if ( ev->zaurusStat() == -3 ) { // delete 577 if (/* ev->zaurusStat() == -3 */ true) { // delete
578 // deleting empty strings does not work. 578 // deleting empty strings does not work.
579 // we write first and x and then delete the record with the x 579 // we write first and x and then delete the record with the x
580 eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); 580 eString = eString.replace( QRegExp(",\"\""),",\"x\"" );
581 changeString += eString + "\n"; 581 changeString += eString + "\n";
582 deleteString += eString + "\n"; 582 deleteString += eString + "\n";
583 deleteEnt = true; 583 deleteEnt = true;
584 changeEnt = true; 584 changeEnt = true;
585 } 585 }
586 else if ( ev->zaurusId() == -1 ) { // add new 586 else if ( /*ev->zaurusId() == -1*/true ) { // add new
587 command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; 587 command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
588 system ( command.utf8() ); 588 system ( command.utf8() );
589 QFile file( fileName ); 589 QFile file( fileName );
590 if (!file.open( IO_ReadOnly ) ) { 590 if (!file.open( IO_ReadOnly ) ) {
591 return false; 591 return false;
592 592
593 } 593 }
594 QTextStream ts( &file ); 594 QTextStream ts( &file );
595 ts.setCodec( QTextCodec::codecForName("utf8") ); 595 ts.setCodec( QTextCodec::codecForName("utf8") );
596 answer = ts.read(); 596 answer = ts.read();
597 file.close(); 597 file.close();
598 //qDebug("answer \n%s ", answer.latin1()); 598 //qDebug("answer \n%s ", answer.latin1());
599 getNumFromRecord( answer, ev ) ; 599 getNumFromRecord( answer, ev ) ;
600 600
601 } 601 }
602 else { // change existing 602 else { // change existing
603 //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() ); 603 //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() );
604 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; 604 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
605 changeString += eString + "\n"; 605 changeString += eString + "\n";
606 changeEnt = true; 606 changeEnt = true;
607 607
608 } 608 }
609 } 609 }
610 ev = er.next(); 610 ev = er.next();
611 } 611 }
612 status.setText ( i18n("Changing events ...") ); 612 status.setText ( i18n("Changing events ...") );
613 qApp->processEvents(); 613 qApp->processEvents();
614 //qDebug("changing... "); 614 //qDebug("changing... ");
615 if ( changeEnt ) { 615 if ( changeEnt ) {
616 QFile file( fileName ); 616 QFile file( fileName );
617 if (!file.open( IO_WriteOnly ) ) { 617 if (!file.open( IO_WriteOnly ) ) {
618 return false; 618 return false;
619 619
620 } 620 }
621 QTextStream ts( &file ); 621 QTextStream ts( &file );
622 ts.setCodec( QTextCodec::codecForName("utf8") ); 622 ts.setCodec( QTextCodec::codecForName("utf8") );
623 ts << changeString ; 623 ts << changeString ;
624 file.close(); 624 file.close();
625 command = "db2file datebook -w -g -c " + codec+ " < "+ fileName; 625 command = "db2file datebook -w -g -c " + codec+ " < "+ fileName;
626 system ( command.latin1() ); 626 system ( command.latin1() );
627 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); 627 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1());
628 628
629 } 629 }
630 status.setText ( i18n("Deleting events ...") ); 630 status.setText ( i18n("Deleting events ...") );
631 qApp->processEvents(); 631 qApp->processEvents();
632 //qDebug("deleting... "); 632 //qDebug("deleting... ");
633 if ( deleteEnt ) { 633 if ( deleteEnt ) {
634 QFile file( fileName ); 634 QFile file( fileName );
635 if (!file.open( IO_WriteOnly ) ) { 635 if (!file.open( IO_WriteOnly ) ) {
636 return false; 636 return false;
637 637
638 } 638 }
639 QTextStream ts( &file ); 639 QTextStream ts( &file );
640 ts.setCodec( QTextCodec::codecForName("utf8") ); 640 ts.setCodec( QTextCodec::codecForName("utf8") );
641 ts << deleteString; 641 ts << deleteString;
642 file.close(); 642 file.close();
643 command = "db2file datebook -d -c " + codec+ " < "+ fileName; 643 command = "db2file datebook -d -c " + codec+ " < "+ fileName;
644 system ( command.latin1() ); 644 system ( command.latin1() );
645 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); 645 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1());
646 } 646 }
647 647
648 648
649 changeString = tPrefix; 649 changeString = tPrefix;
650 deleteString = tPrefix; 650 deleteString = tPrefix;
651 status.setText ( i18n("Processing todos ...") ); 651 status.setText ( i18n("Processing todos ...") );
652 qApp->processEvents(); 652 qApp->processEvents();
653 QPtrList<Todo> tl = calendar->rawTodos(); 653 QPtrList<Todo> tl = calendar->rawTodos();
654 Todo* to = tl.first(); 654 Todo* to = tl.first();
655 i = 0; 655 i = 0;
656 message = i18n("Processing todo # "); 656 message = i18n("Processing todo # ");
657 procCount = 0; 657 procCount = 0;
658 while ( to ) { 658 while ( to ) {
659 if ( to->zaurusStat() != -2 ) { 659 if ( true /*to->zaurusStat() != -2 */) {
660 status.setText ( message + QString::number ( ++procCount ) ); 660 status.setText ( message + QString::number ( ++procCount ) );
661 qApp->processEvents(); 661 qApp->processEvents();
662 QString eString = getTodoString( to ); 662 QString eString = getTodoString( to );
663 if ( to->zaurusStat() == -3 ) { // delete 663 if ( /*to->zaurusStat() == -3*/true ) { // delete
664 // deleting empty strings does not work. 664 // deleting empty strings does not work.
665 // we write first and x and then delete the record with the x 665 // we write first and x and then delete the record with the x
666 eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); 666 eString = eString.replace( QRegExp(",\"\""),",\"x\"" );
667 changeString += eString + "\n"; 667 changeString += eString + "\n";
668 deleteString += eString + "\n"; 668 deleteString += eString + "\n";
669 deleteEnt = true; 669 deleteEnt = true;
670 changeEnt = true; 670 changeEnt = true;
671 } 671 }
672 else if ( to->zaurusId() == -1 ) { // add new 672 else if ( true /*to->zaurusId() == -1*/ ) { // add new
673 command = "(echo \"" + tPrefix + eString + "\" ) | db2file todo -w -g -c " + codec+ " > "+ fileName; 673 command = "(echo \"" + tPrefix + eString + "\" ) | db2file todo -w -g -c " + codec+ " > "+ fileName;
674 system ( command.utf8() ); 674 system ( command.utf8() );
675 QFile file( fileName ); 675 QFile file( fileName );
676 if (!file.open( IO_ReadOnly ) ) { 676 if (!file.open( IO_ReadOnly ) ) {
677 return false; 677 return false;
678 678
679 } 679 }
680 QTextStream ts( &file ); 680 QTextStream ts( &file );
681 ts.setCodec( QTextCodec::codecForName("utf8") ); 681 ts.setCodec( QTextCodec::codecForName("utf8") );
682 answer = ts.read(); 682 answer = ts.read();
683 file.close(); 683 file.close();
684 //qDebug("answer \n%s ", answer.latin1()); 684 //qDebug("answer \n%s ", answer.latin1());
685 getNumFromRecord( answer, to ) ; 685 getNumFromRecord( answer, to ) ;
686 686
687 } 687 }
688 else { // change existing 688 else { // change existing
689 //qDebug("canging %d %d",to->zaurusStat() ,to->zaurusId() ); 689 //qDebug("canging %d %d",to->zaurusStat() ,to->zaurusId() );
690 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; 690 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
691 changeString += eString + "\n"; 691 changeString += eString + "\n";
692 changeEnt = true; 692 changeEnt = true;
693 693
694 } 694 }
695 } 695 }
696 696
697 to = tl.next(); 697 to = tl.next();
698 } 698 }
699 status.setText ( i18n("Changing todos ...") ); 699 status.setText ( i18n("Changing todos ...") );
700 qApp->processEvents(); 700 qApp->processEvents();
701 //qDebug("changing... "); 701 //qDebug("changing... ");
702 if ( changeEnt ) { 702 if ( changeEnt ) {
703 QFile file( fileName ); 703 QFile file( fileName );
704 if (!file.open( IO_WriteOnly ) ) { 704 if (!file.open( IO_WriteOnly ) ) {
705 return false; 705 return false;
706 706
707 } 707 }
708 QTextStream ts( &file ); 708 QTextStream ts( &file );
709 ts.setCodec( QTextCodec::codecForName("utf8") ); 709 ts.setCodec( QTextCodec::codecForName("utf8") );
710 ts << changeString ; 710 ts << changeString ;
711 file.close(); 711 file.close();
712 command = "db2file todo -w -g -c " + codec+ " < "+ fileName; 712 command = "db2file todo -w -g -c " + codec+ " < "+ fileName;
713 system ( command.latin1() ); 713 system ( command.latin1() );
714 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); 714 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1());
715 715
716 } 716 }
717 status.setText ( i18n("Deleting todos ...") ); 717 status.setText ( i18n("Deleting todos ...") );
718 qApp->processEvents(); 718 qApp->processEvents();
719 //qDebug("deleting... "); 719 //qDebug("deleting... ");
720 if ( deleteEnt ) { 720 if ( deleteEnt ) {
721 QFile file( fileName ); 721 QFile file( fileName );
722 if (!file.open( IO_WriteOnly ) ) { 722 if (!file.open( IO_WriteOnly ) ) {
723 return false; 723 return false;
724 724
725 } 725 }
726 QTextStream ts( &file ); 726 QTextStream ts( &file );
727 ts.setCodec( QTextCodec::codecForName("utf8") ); 727 ts.setCodec( QTextCodec::codecForName("utf8") );
728 ts << deleteString; 728 ts << deleteString;
729 file.close(); 729 file.close();
730 command = "db2file todo -d -c " + codec+ " < "+ fileName; 730 command = "db2file todo -d -c " + codec+ " < "+ fileName;
731 system ( command.latin1() ); 731 system ( command.latin1() );
732 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); 732 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1());
733 } 733 }
734 734
735 return true; 735 return true;
736} 736}
737QString SharpFormat::dtToString( const QDateTime& dti, bool useTZ ) 737QString PhoneFormat::dtToString( const QDateTime& dti, bool useTZ )
738{ 738{
739 QString datestr; 739 QString datestr;
740 QString timestr; 740 QString timestr;
741 int offset = KGlobal::locale()->localTimeOffset( dti ); 741 int offset = KGlobal::locale()->localTimeOffset( dti );
742 QDateTime dt; 742 QDateTime dt;
743 if (useTZ) 743 if (useTZ)
744 dt = dti.addSecs ( -(offset*60)); 744 dt = dti.addSecs ( -(offset*60));
745 else 745 else
746 dt = dti; 746 dt = dti;
747 if(dt.date().isValid()){ 747 if(dt.date().isValid()){
748 const QDate& date = dt.date(); 748 const QDate& date = dt.date();
749 datestr.sprintf("%04d%02d%02d", 749 datestr.sprintf("%04d%02d%02d",
750 date.year(), date.month(), date.day()); 750 date.year(), date.month(), date.day());
751 } 751 }
752 if(dt.time().isValid()){ 752 if(dt.time().isValid()){
753 const QTime& time = dt.time(); 753 const QTime& time = dt.time();
754 timestr.sprintf("T%02d%02d%02d", 754 timestr.sprintf("T%02d%02d%02d",
755 time.hour(), time.minute(), time.second()); 755 time.hour(), time.minute(), time.second());
756 } 756 }
757 return datestr + timestr; 757 return datestr + timestr;
758} 758}
759QString SharpFormat::getEventString( Event* event ) 759QString PhoneFormat::getEventString( Event* event )
760{ 760{
761#if 0
761 QStringList list; 762 QStringList list;
762 list.append( QString::number(event->zaurusId() ) ); 763 list.append( QString::number(event->zaurusId() ) );
763 list.append( event->categories().join(",") ); 764 list.append( event->categories().join(",") );
764 if ( !event->summary().isEmpty() ) 765 if ( !event->summary().isEmpty() )
765 list.append( event->summary() ); 766 list.append( event->summary() );
766 else 767 else
767 list.append("" ); 768 list.append("" );
768 if ( !event->location().isEmpty() ) 769 if ( !event->location().isEmpty() )
769 list.append( event->location() ); 770 list.append( event->location() );
770 else 771 else
771 list.append("" ); 772 list.append("" );
772 if ( !event->description().isEmpty() ) 773 if ( !event->description().isEmpty() )
773 list.append( event->description() ); 774 list.append( event->description() );
774 else 775 else
775 list.append( "" ); 776 list.append( "" );
776 if ( event->doesFloat () ) { 777 if ( event->doesFloat () ) {
777 list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false )); 778 list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false ));
778 list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6 779 list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6
779 list.append( "1" ); 780 list.append( "1" );
780 781
781 } 782 }
782 else { 783 else {
783 list.append( dtToString( event->dtStart()) ); 784 list.append( dtToString( event->dtStart()) );
784 list.append( dtToString( event->dtEnd()) ); //6 785 list.append( dtToString( event->dtEnd()) ); //6
785 list.append( "0" ); 786 list.append( "0" );
786 } 787 }
787 bool noAlarm = true; 788 bool noAlarm = true;
788 if ( event->alarms().count() > 0 ) { 789 if ( event->alarms().count() > 0 ) {
789 Alarm * al = event->alarms().first(); 790 Alarm * al = event->alarms().first();
790 if ( al->enabled() ) { 791 if ( al->enabled() ) {
791 noAlarm = false; 792 noAlarm = false;
792 list.append( "0" ); // yes, 0 == alarm 793 list.append( "0" ); // yes, 0 == alarm
793 list.append( QString::number( al->startOffset().asSeconds()/(-60) ) ); 794 list.append( QString::number( al->startOffset().asSeconds()/(-60) ) );
794 if ( al->type() == Alarm::Audio ) 795 if ( al->type() == Alarm::Audio )
795 list.append( "1" ); // type audio 796 list.append( "1" ); // type audio
796 else 797 else
797 list.append( "0" ); // type silent 798 list.append( "0" ); // type silent
798 } 799 }
799 } 800 }
800 if ( noAlarm ) { 801 if ( noAlarm ) {
801 list.append( "1" ); // yes, 1 == no alarm 802 list.append( "1" ); // yes, 1 == no alarm
802 list.append( "0" ); // no alarm offset 803 list.append( "0" ); // no alarm offset
803 list.append( "1" ); // type 804 list.append( "1" ); // type
804 } 805 }
805 // next is: 11 806 // next is: 11
806 // next is: 11-16 are recurrence 807 // next is: 11-16 are recurrence
807 Recurrence* rec = event->recurrence(); 808 Recurrence* rec = event->recurrence();
808 809
809 bool writeEndDate = false; 810 bool writeEndDate = false;
810 switch ( rec->doesRecur() ) 811 switch ( rec->doesRecur() )
811 { 812 {
812 case Recurrence::rDaily: // 0 813 case Recurrence::rDaily: // 0
813 list.append( "0" ); 814 list.append( "0" );
814 list.append( QString::number( rec->frequency() ));//12 815 list.append( QString::number( rec->frequency() ));//12
815 list.append( "0" ); 816 list.append( "0" );
816 list.append( "0" ); 817 list.append( "0" );
817 writeEndDate = true; 818 writeEndDate = true;
818 break; 819 break;
819 case Recurrence::rWeekly:// 1 820 case Recurrence::rWeekly:// 1
820 list.append( "1" ); 821 list.append( "1" );
821 list.append( QString::number( rec->frequency()) );//12 822 list.append( QString::number( rec->frequency()) );//12
822 list.append( "0" ); 823 list.append( "0" );
823 { 824 {
824 int days = 0; 825 int days = 0;
825 QBitArray weekDays = rec->days(); 826 QBitArray weekDays = rec->days();
826 int i; 827 int i;
827 for( i = 1; i <= 7; ++i ) { 828 for( i = 1; i <= 7; ++i ) {
828 if ( weekDays[i-1] ) { 829 if ( weekDays[i-1] ) {
829 days += 1 << (i-1); 830 days += 1 << (i-1);
830 } 831 }
831 } 832 }
832 list.append( QString::number( days ) ); 833 list.append( QString::number( days ) );
833 } 834 }
834 //pending weekdays 835 //pending weekdays
835 writeEndDate = true; 836 writeEndDate = true;
836 837
837 break; 838 break;
838 case Recurrence::rMonthlyPos:// 2 839 case Recurrence::rMonthlyPos:// 2
839 list.append( "2" ); 840 list.append( "2" );
840 list.append( QString::number( rec->frequency()) );//12 841 list.append( QString::number( rec->frequency()) );//12
841 842
842 writeEndDate = true; 843 writeEndDate = true;
843 { 844 {
844 int count = 1; 845 int count = 1;
845 QPtrList<Recurrence::rMonthPos> rmp; 846 QPtrList<Recurrence::rMonthPos> rmp;
846 rmp = rec->monthPositions(); 847 rmp = rec->monthPositions();
847 if ( rmp.first()->negative ) 848 if ( rmp.first()->negative )
848 count = 5 - rmp.first()->rPos - 1; 849 count = 5 - rmp.first()->rPos - 1;
849 else 850 else
850 count = rmp.first()->rPos - 1; 851 count = rmp.first()->rPos - 1;
851 list.append( QString::number( count ) ); 852 list.append( QString::number( count ) );
852 853
853 } 854 }
854 855
855 list.append( "0" ); 856 list.append( "0" );
856 break; 857 break;
857 case Recurrence::rMonthlyDay:// 3 858 case Recurrence::rMonthlyDay:// 3
858 list.append( "3" ); 859 list.append( "3" );
859 list.append( QString::number( rec->frequency()) );//12 860 list.append( QString::number( rec->frequency()) );//12
860 list.append( "0" ); 861 list.append( "0" );
861 list.append( "0" ); 862 list.append( "0" );
862 writeEndDate = true; 863 writeEndDate = true;
863 break; 864 break;
864 case Recurrence::rYearlyMonth://4 865 case Recurrence::rYearlyMonth://4
865 list.append( "4" ); 866 list.append( "4" );
866 list.append( QString::number( rec->frequency()) );//12 867 list.append( QString::number( rec->frequency()) );//12
867 list.append( "0" ); 868 list.append( "0" );
868 list.append( "0" ); 869 list.append( "0" );
869 writeEndDate = true; 870 writeEndDate = true;
870 break; 871 break;
871 872
872 default: 873 default:
873 list.append( "255" ); 874 list.append( "255" );
874 list.append( QString() ); 875 list.append( QString() );
875 list.append( "0" ); 876 list.append( "0" );
876 list.append( QString() ); 877 list.append( QString() );
877 list.append( "0" ); 878 list.append( "0" );
878 list.append( "20991231T000000" ); 879 list.append( "20991231T000000" );
879 break; 880 break;
880 } 881 }
881 if ( writeEndDate ) { 882 if ( writeEndDate ) {
882 883
883 if ( rec->endDate().isValid() ) { // 15 + 16 884 if ( rec->endDate().isValid() ) { // 15 + 16
884 list.append( "1" ); 885 list.append( "1" );
885 list.append( dtToString( rec->endDate()) ); 886 list.append( dtToString( rec->endDate()) );
886 } else { 887 } else {
887 list.append( "0" ); 888 list.append( "0" );
888 list.append( "20991231T000000" ); 889 list.append( "20991231T000000" );
889 } 890 }
890 891
891 } 892 }
892 if ( event->doesFloat () ) { 893 if ( event->doesFloat () ) {
893 list.append( dtToString( event->dtStart(), false ).left( 8 )); 894 list.append( dtToString( event->dtStart(), false ).left( 8 ));
894 list.append( dtToString( event->dtEnd(), false ).left( 8 )); //6 895 list.append( dtToString( event->dtEnd(), false ).left( 8 )); //6
895 896
896 } 897 }
897 else { 898 else {
898 list.append( QString() ); 899 list.append( QString() );
899 list.append( QString() ); 900 list.append( QString() );
900 901
901 } 902 }
902 if (event->dtStart().date() == event->dtEnd().date() ) 903 if (event->dtStart().date() == event->dtEnd().date() )
903 list.append( "0" ); 904 list.append( "0" );
904 else 905 else
905 list.append( "1" ); 906 list.append( "1" );
906 907
907 908
908 for(QStringList::Iterator it=list.begin(); 909 for(QStringList::Iterator it=list.begin();
909 it!=list.end(); ++it){ 910 it!=list.end(); ++it){
910 QString& s = (*it); 911 QString& s = (*it);
911 s.replace(QRegExp("\""), "\"\""); 912 s.replace(QRegExp("\""), "\"\"");
912 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ 913 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){
913 s.prepend('\"'); 914 s.prepend('\"');
914 s.append('\"'); 915 s.append('\"');
915 } else if(s.isEmpty() && !s.isNull()){ 916 } else if(s.isEmpty() && !s.isNull()){
916 s = "\"\""; 917 s = "\"\"";
917 } 918 }
918 } 919 }
919 return list.join(","); 920 return list.join(",");
920 921#endif
922 return QString();
921 923
922} 924}
923QString SharpFormat::getTodoString( Todo* todo ) 925QString PhoneFormat::getTodoString( Todo* todo )
924{ 926{
927#if 0
925 QStringList list; 928 QStringList list;
926 list.append( QString::number( todo->zaurusId() ) ); 929 list.append( QString::number( todo->zaurusId() ) );
927 list.append( todo->categories().join(",") ); 930 list.append( todo->categories().join(",") );
928 931
929 if ( todo->hasStartDate() ) { 932 if ( todo->hasStartDate() ) {
930 list.append( dtToString( todo->dtStart()) ); 933 list.append( dtToString( todo->dtStart()) );
931 } else 934 } else
932 list.append( QString() ); 935 list.append( QString() );
933 936
934 if ( todo->hasDueDate() ) { 937 if ( todo->hasDueDate() ) {
935 QTime tim; 938 QTime tim;
936 if ( todo->doesFloat()) { 939 if ( todo->doesFloat()) {
937 list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ; 940 list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ;
938 } else { 941 } else {
939 list.append( dtToString(todo->dtDue() ) ); 942 list.append( dtToString(todo->dtDue() ) );
940 } 943 }
941 } else 944 } else
942 list.append( QString() ); 945 list.append( QString() );
943 946
944 if ( todo->isCompleted() ) { 947 if ( todo->isCompleted() ) {
945 list.append( dtToString( todo->completed()) ); 948 list.append( dtToString( todo->completed()) );
946 list.append( "0" ); // yes 0 == completed 949 list.append( "0" ); // yes 0 == completed
947 } else { 950 } else {
948 list.append( dtToString( todo->completed()) ); 951 list.append( dtToString( todo->completed()) );
949 list.append( "1" ); 952 list.append( "1" );
950 } 953 }
951 list.append( QString::number( todo->priority() )); 954 list.append( QString::number( todo->priority() ));
952 if( ! todo->summary().isEmpty() ) 955 if( ! todo->summary().isEmpty() )
953 list.append( todo->summary() ); 956 list.append( todo->summary() );
954 else 957 else
955 list.append( "" ); 958 list.append( "" );
956 if (! todo->description().isEmpty() ) 959 if (! todo->description().isEmpty() )
957 list.append( todo->description() ); 960 list.append( todo->description() );
958 else 961 else
959 list.append( "" ); 962 list.append( "" );
960 for(QStringList::Iterator it=list.begin(); 963 for(QStringList::Iterator it=list.begin();
961 it!=list.end(); ++it){ 964 it!=list.end(); ++it){
962 QString& s = (*it); 965 QString& s = (*it);
963 s.replace(QRegExp("\""), "\"\""); 966 s.replace(QRegExp("\""), "\"\"");
964 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ 967 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){
965 s.prepend('\"'); 968 s.prepend('\"');
966 s.append('\"'); 969 s.append('\"');
967 } else if(s.isEmpty() && !s.isNull()){ 970 } else if(s.isEmpty() && !s.isNull()){
968 s = "\"\""; 971 s = "\"\"";
969 } 972 }
970 } 973 }
971 return list.join(","); 974 return list.join(",");
975#endif
976 return QString();
972} 977}
973QString SharpFormat::getPart( const QString & text, bool &ok, int &start ) 978QString PhoneFormat::getPart( const QString & text, bool &ok, int &start )
974{ 979{
975 //qDebug("start %d ", start); 980 //qDebug("start %d ", start);
976 981
977 QString retval =""; 982 QString retval ="";
978 if ( text.at(start) == '"' ) { 983 if ( text.at(start) == '"' ) {
979 if ( text.mid( start,2) == "\"\"" && !( text.mid( start+2,1) == "\"")) { 984 if ( text.mid( start,2) == "\"\"" && !( text.mid( start+2,1) == "\"")) {
980 start = start +2; 985 start = start +2;
981 if ( text.mid( start,1) == "," ) { 986 if ( text.mid( start,1) == "," ) {
982 start += 1; 987 start += 1;
983 } 988 }
984 retval = ""; 989 retval = "";
985 if ( text.mid( start,1) == "\n" ) { 990 if ( text.mid( start,1) == "\n" ) {
986 start += 1; 991 start += 1;
987 ok = false; 992 ok = false;
988 } 993 }
989 return retval; 994 return retval;
990 } 995 }
991 int hk = start+1; 996 int hk = start+1;
992 hk = text.find ('"',hk); 997 hk = text.find ('"',hk);
993 while ( text.at(hk+1) == '"' ) 998 while ( text.at(hk+1) == '"' )
994 hk = text.find ('"',hk+2); 999 hk = text.find ('"',hk+2);
995 retval = text.mid( start+1, hk-start-1); 1000 retval = text.mid( start+1, hk-start-1);
996 start = hk+1; 1001 start = hk+1;
997 retval.replace( QRegExp("\"\""), "\""); 1002 retval.replace( QRegExp("\"\""), "\"");
998 if ( text.mid( start,1) == "," ) { 1003 if ( text.mid( start,1) == "," ) {
999 start += 1; 1004 start += 1;
1000 } 1005 }
1001 if ( text.mid( start,1) == "\n" ) { 1006 if ( text.mid( start,1) == "\n" ) {
1002 start += 1; 1007 start += 1;
1003 ok = false; 1008 ok = false;
1004 } 1009 }
1005 //qDebug("retval***%s*** ",retval.latin1() ); 1010 //qDebug("retval***%s*** ",retval.latin1() );
1006 return retval; 1011 return retval;
1007 1012
1008 } else { 1013 } else {
1009 int nl = text.find ("\n",start); 1014 int nl = text.find ("\n",start);
1010 int kom = text.find (',',start); 1015 int kom = text.find (',',start);
1011 if ( kom < nl ) { 1016 if ( kom < nl ) {
1012 // qDebug("kom < nl %d ", kom); 1017 // qDebug("kom < nl %d ", kom);
1013 retval = text.mid(start, kom-start); 1018 retval = text.mid(start, kom-start);
1014 start = kom+1; 1019 start = kom+1;
1015 return retval; 1020 return retval;
1016 } else { 1021 } else {
1017 if ( nl == kom ) { 1022 if ( nl == kom ) {
1018 // qDebug(" nl == kom "); 1023 // qDebug(" nl == kom ");
1019 start = 0; 1024 start = 0;
1020 ok = false; 1025 ok = false;
1021 return "0"; 1026 return "0";
1022 } 1027 }
1023 // qDebug(" nl < kom ", nl); 1028 // qDebug(" nl < kom ", nl);
1024 retval = text.mid( start, nl-start); 1029 retval = text.mid( start, nl-start);
1025 ok = false; 1030 ok = false;
1026 start = nl+1; 1031 start = nl+1;
1027 return retval; 1032 return retval;
1028 } 1033 }
1029 } 1034 }
1030} 1035}
1031bool SharpFormat::fromString( Calendar *calendar, const QString & text) 1036bool PhoneFormat::fromString( Calendar *calendar, const QString & text)
1032{ 1037{
1033 return false; 1038 return false;
1034} 1039}
1035 bool SharpFormat::fromString2Cal( Calendar *calendar,Calendar *existingCalendar, GSM_StateMachine*s, const QString & type) 1040 bool PhoneFormat::fromString2Cal( Calendar *calendar,Calendar *existingCalendar, GSM_StateMachine*s, const QString & type)
1036{ 1041{
1037 GSM_Phone_Functions*Phone; 1042 GSM_Phone_Functions*Phone;
1038 1043
1039 GSM_CalendarEntrynote; 1044 GSM_CalendarEntrynote;
1040 GSM_CalendarEntry*Note; 1045 GSM_CalendarEntry*Note;
1041 bool refresh= true; 1046 bool refresh= true;
1042 1047
1043 Phone=s->Phone.Functions; 1048 Phone=s->Phone.Functions;
1044 bool gshutdown = false; 1049 bool gshutdown = false;
1045 SharpParser handler( calendar ); 1050 PhoneParser handler( calendar );
1046 //handler.setCategoriesList( mCategories ); 1051 //handler.setCategoriesList( mCategories );
1047 QStringList templist; 1052 QStringList templist;
1048 QString tempString; 1053 QString tempString;
1049 int start = 0; 1054 int start = 0;
1050 int error; 1055 int error;
1051 int ccc = 0; 1056 int ccc = 0;
1052 while (!gshutdown && ccc++ < 10 ) { 1057 while (!gshutdown && ccc++ < 10 ) {
1053 QString CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY; 1058 QString CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY;
1054 templist.clear(); 1059 templist.clear();
1055 qDebug("count %d ", ccc); 1060 qDebug("count %d ", ccc);
1056 error=Phone->GetNextCalendar(s,&note,refresh); 1061 error=Phone->GetNextCalendar(s,&note,refresh);
1057 if (error == ERR_EMPTY) break; 1062 if (error == ERR_EMPTY) break;
1058 1063
1059 Note = &note; 1064 Note = &note;
1060//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY 1065//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY
1061// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1066// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
1062 1067
1063//ARSD silentalarm = 0 1068//ARSD silentalarm = 0
1064// 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly 1069// 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly
1065// 12 RFRQ 1070// 12 RFRQ
1066// 13 RPOS pos = 4. monday in month 1071// 13 RPOS pos = 4. monday in month
1067// 14 RDYS days: 1 mon/ 2 tue .. 64 sun 1072// 14 RDYS days: 1 mon/ 2 tue .. 64 sun
1068// 15 REND 0 = no end/ 1 = end 1073// 15 REND 0 = no end/ 1 = end
1069// 16 REDT rec end dt 1074// 16 REDT rec end dt
1070//ALSD 1075//ALSD
1071//ALED 1076//ALED
1072//MDAY 1077//MDAY
1073 1078
1074 CARDID = QString::number( Note->Location ); // 0 1079 CARDID = QString::number( Note->Location ); // 0
1075 1080
1076 1081
1077 int i_age = 0,i; 1082 int i_age = 0,i;
1078 GSM_DateTime Alarm,DateTime; 1083 GSM_DateTime Alarm,DateTime;
1079 GSM_DateTime* dtp; 1084 GSM_DateTime* dtp;
1080 GSM_MemoryEntry entry; 1085 GSM_MemoryEntry entry;
1081 unsigned char *name; 1086 unsigned char *name;
1082 1087
1083 bool repeating = false; 1088 bool repeating = false;
1084 int repeat_dayofweek = -1; 1089 int repeat_dayofweek = -1;
1085 int repeat_day = -1; 1090 int repeat_day = -1;
1086 int repeat_weekofmonth = -1; 1091 int repeat_weekofmonth = -1;
1087 int repeat_month = -1; 1092 int repeat_month = -1;
1088 int repeat_frequency = -1; 1093 int repeat_frequency = -1;
1089 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; 1094 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0};
1090 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; 1095 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0};
1091 1096
1092 Alarm.Year = 0; 1097 Alarm.Year = 0;
1093 1098
1094 repeating = false; 1099 repeating = false;
1095 repeat_dayofweek = -1; 1100 repeat_dayofweek = -1;
1096 repeat_day = -1; 1101 repeat_day = -1;
1097 repeat_weekofmonth = -1; 1102 repeat_weekofmonth = -1;
1098 repeat_month = -1; 1103 repeat_month = -1;
1099 repeat_frequency = -1; 1104 repeat_frequency = -1;
1100 repeat_startdate.Day= 0; 1105 repeat_startdate.Day= 0;
1101 repeat_stopdate.Day = 0; 1106 repeat_stopdate.Day = 0;
1102 1107
1103 1108
1104 switch (Note->Type) { 1109 switch (Note->Type) {
1105 case GSM_CAL_REMINDER : CATEGORY = QString("Reminder"); break; 1110 case GSM_CAL_REMINDER : CATEGORY = QString("Reminder"); break;
1106 case GSM_CAL_CALL : CATEGORY = QString("Call"); break; 1111 case GSM_CAL_CALL : CATEGORY = QString("Call"); break;
1107 case GSM_CAL_MEETING : CATEGORY = QString("Meeting"); break; 1112 case GSM_CAL_MEETING : CATEGORY = QString("Meeting"); break;
1108 case GSM_CAL_BIRTHDAY : CATEGORY = QString("Birthday"); break; 1113 case GSM_CAL_BIRTHDAY : CATEGORY = QString("Birthday"); break;
1109 case GSM_CAL_MEMO : CATEGORY = QString("Memo"); break; 1114 case GSM_CAL_MEMO : CATEGORY = QString("Memo"); break;
1110 case GSM_CAL_TRAVEL : CATEGORY = QString("Travel"); break; 1115 case GSM_CAL_TRAVEL : CATEGORY = QString("Travel"); break;
1111 case GSM_CAL_VACATION : CATEGORY = QString("Vacation"); break; 1116 case GSM_CAL_VACATION : CATEGORY = QString("Vacation"); break;
1112 case GSM_CAL_ALARM : CATEGORY = QString("Alarm"); break; 1117 case GSM_CAL_ALARM : CATEGORY = QString("Alarm"); break;
1113 case GSM_CAL_DAILY_ALARM : CATEGORY = QString("Daily alarm"); break; 1118 case GSM_CAL_DAILY_ALARM : CATEGORY = QString("Daily alarm"); break;
1114 case GSM_CAL_T_ATHL : CATEGORY = QString("Training/Athletism"); break; 1119 case GSM_CAL_T_ATHL : CATEGORY = QString("Training/Athletism"); break;
1115 case GSM_CAL_T_BALL : CATEGORY = QString("Training/Ball Games"); break; 1120 case GSM_CAL_T_BALL : CATEGORY = QString("Training/Ball Games"); break;
1116 case GSM_CAL_T_CYCL : CATEGORY = QString("Training/Cycling"); break; 1121 case GSM_CAL_T_CYCL : CATEGORY = QString("Training/Cycling"); break;
1117 case GSM_CAL_T_BUDO : CATEGORY = QString("Training/Budo"); break; 1122 case GSM_CAL_T_BUDO : CATEGORY = QString("Training/Budo"); break;
1118 case GSM_CAL_T_DANC : CATEGORY = QString("Training/Dance"); break; 1123 case GSM_CAL_T_DANC : CATEGORY = QString("Training/Dance"); break;
1119 case GSM_CAL_T_EXTR : CATEGORY = QString("Training/Extreme Sports"); break; 1124 case GSM_CAL_T_EXTR : CATEGORY = QString("Training/Extreme Sports"); break;
1120 case GSM_CAL_T_FOOT : CATEGORY = QString("Training/Football"); break; 1125 case GSM_CAL_T_FOOT : CATEGORY = QString("Training/Football"); break;
1121 case GSM_CAL_T_GOLF : CATEGORY = QString("Training/Golf"); break; 1126 case GSM_CAL_T_GOLF : CATEGORY = QString("Training/Golf"); break;
1122 case GSM_CAL_T_GYM : CATEGORY = QString("Training/Gym"); break; 1127 case GSM_CAL_T_GYM : CATEGORY = QString("Training/Gym"); break;
1123 case GSM_CAL_T_HORS : CATEGORY = QString("Training/Horse Races"); break; 1128 case GSM_CAL_T_HORS : CATEGORY = QString("Training/Horse Races"); break;
1124 case GSM_CAL_T_HOCK : CATEGORY = QString("Training/Hockey"); break; 1129 case GSM_CAL_T_HOCK : CATEGORY = QString("Training/Hockey"); break;
1125 case GSM_CAL_T_RACE : CATEGORY = QString("Training/Races"); break; 1130 case GSM_CAL_T_RACE : CATEGORY = QString("Training/Races"); break;
1126 case GSM_CAL_T_RUGB : CATEGORY = QString("Training/Rugby"); break; 1131 case GSM_CAL_T_RUGB : CATEGORY = QString("Training/Rugby"); break;
1127 case GSM_CAL_T_SAIL : CATEGORY = QString("Training/Sailing"); break; 1132 case GSM_CAL_T_SAIL : CATEGORY = QString("Training/Sailing"); break;
1128 case GSM_CAL_T_STRE : CATEGORY = QString("Training/Street Games"); break; 1133 case GSM_CAL_T_STRE : CATEGORY = QString("Training/Street Games"); break;
1129 case GSM_CAL_T_SWIM : CATEGORY = QString("Training/Swimming"); break; 1134 case GSM_CAL_T_SWIM : CATEGORY = QString("Training/Swimming"); break;
1130 case GSM_CAL_T_TENN : CATEGORY = QString("Training/Tennis"); break; 1135 case GSM_CAL_T_TENN : CATEGORY = QString("Training/Tennis"); break;
1131 case GSM_CAL_T_TRAV : CATEGORY = QString("Training/Travels"); break; 1136 case GSM_CAL_T_TRAV : CATEGORY = QString("Training/Travels"); break;
1132 case GSM_CAL_T_WINT : CATEGORY = QString("Training/Winter Games"); break; 1137 case GSM_CAL_T_WINT : CATEGORY = QString("Training/Winter Games"); break;
1133 default : CATEGORY = QString(""); 1138 default : CATEGORY = QString("");
1134 } 1139 }
1135//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY 1140//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY
1136// 0x 1x 2x 3x 4x 5x 6x 7x 8x 9x 10? 11 12 13 14 15 16 17x 18x 19? 1141// 0x 1x 2x 3x 4x 5x 6x 7x 8x 9x 10? 11 12 13 14 15 16 17x 18x 19?
1137 1142
1138 MEM1 = ""; 1143 MEM1 = "";
1139 1144
1140#if 0 1145#if 0
1141 1146
1142 if ( attList[7] == "1" ) { 1147 if ( attList[7] == "1" ) {
1143 event->setDtStart( QDateTime(fromString( attList[17]+"000000", false ).date(),QTime(0,0,0 ) )); 1148 event->setDtStart( QDateTime(fromString( attList[17]+"000000", false ).date(),QTime(0,0,0 ) ));
1144 event->setDtEnd( QDateTime(fromString( attList[18]+"000000", false ).date(),QTime(0,0,0 ))); 1149 event->setDtEnd( QDateTime(fromString( attList[18]+"000000", false ).date(),QTime(0,0,0 )));
1145 event->setFloats( true ); 1150 event->setFloats( true );
1146 } else { 1151 } else {
1147 event->setFloats( false ); 1152 event->setFloats( false );
1148 event->setDtStart( fromString( attList[5] ) ); 1153 event->setDtStart( fromString( attList[5] ) );
1149 event->setDtEnd( fromString( attList[6] )); 1154 event->setDtEnd( fromString( attList[6] ));
1150 } 1155 }
1151 1156
1152 1157
1153 1158
1154typedef struct { 1159typedef struct {
1155 /** 1160 /**
1156 * The difference between local time and GMT in hours 1161 * The difference between local time and GMT in hours
1157 */ 1162 */
1158 int Timezone; 1163 int Timezone;
1159 1164
1160 unsigned int Second; 1165 unsigned int Second;
1161 unsigned int Minute; 1166 unsigned int Minute;
1162 unsigned int Hour; 1167 unsigned int Hour;
1163 1168
1164 unsigned int Day; 1169 unsigned int Day;
1165 /** 1170 /**
1166 * January = 1, February = 2, etc. 1171 * January = 1, February = 2, etc.
1167 */ 1172 */
1168 unsigned int Month; 1173 unsigned int Month;
1169 /** 1174 /**
1170 * Complete year number. Not 03, but 2003 1175 * Complete year number. Not 03, but 2003
1171 */ 1176 */
1172 unsigned int Year; 1177 unsigned int Year;
1173} GSM_DateTime; 1178} GSM_DateTime;
1174 1179
1175 if(dt.date().isValid()){ 1180 if(dt.date().isValid()){
1176 const QDate& date = dt.date(); 1181 const QDate& date = dt.date();
1177 datestr.sprintf("%04d%02d%02d", 1182 datestr.sprintf("%04d%02d%02d",
1178 date.year(), date.month(), date.day()); 1183 date.year(), date.month(), date.day());
1179 } 1184 }
1180 if(dt.time().isValid()){ 1185 if(dt.time().isValid()){
1181 const QTime& time = dt.time(); 1186 const QTime& time = dt.time();
1182 timestr.sprintf("T%02d%02d%02d", 1187 timestr.sprintf("T%02d%02d%02d",
1183 time.hour(), time.minute(), time.second()); 1188 time.hour(), time.minute(), time.second());
1184 } 1189 }
1185 return datestr + timestr; 1190 return datestr + timestr;
1186 1191
1187 1192
1188 1193
1189 1194
1190#endif 1195#endif
1191 1196
1192 1197
1193 ADAY = "0"; 1198 ADAY = "0";
1194 ARON = "1"; // 1 == disabled 1199 ARON = "1"; // 1 == disabled
1195 ARMN = "0"; //alarm offset in minutes 1200 ARMN = "0"; //alarm offset in minutes
1196 1201
1197 for (i=0;i<Note->EntriesNum;i++) { 1202 for (i=0;i<Note->EntriesNum;i++) {
1198 1203
1199 qDebug(" for "); 1204 qDebug(" for ");
1200 switch (Note->Entries[i].EntryType) { 1205 switch (Note->Entries[i].EntryType) {
1201 case CAL_START_DATETIME: 1206 case CAL_START_DATETIME:
1202 dtp = &Note->Entries[i].Date ; 1207 dtp = &Note->Entries[i].Date ;
1203 1208
1204 qDebug("hour: %d ", dtp->Hour); 1209 qDebug("hour: %d ", dtp->Hour);
1205 if ( dtp->Hour == -1 ) { 1210 if ( dtp->Hour == -1 ) {
1206 ADAY = "1"; 1211 ADAY = "1";
1207 ALSD.sprintf("%04d%02d%02d",dtp->Year, dtp->Month, dtp->Day ); 1212 ALSD.sprintf("%04d%02d%02d",dtp->Year, dtp->Month, dtp->Day );
1208 TIM1.sprintf("%04d%02d%02dT000000",dtp->Year, dtp->Month, dtp->Day ); 1213 TIM1.sprintf("%04d%02d%02dT000000",dtp->Year, dtp->Month, dtp->Day );
1209 } else { 1214 } else {
1210 TIM1.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second ); 1215 TIM1.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second );
1211 1216
1212 } 1217 }
1213 ////printmsg("Start : %s\n",OSDateTime(Note->Entries[i].Date,false)); 1218 ////printmsg("Start : %s\n",OSDateTime(Note->Entries[i].Date,false));
1214 //memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime)); 1219 //memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1215 break; 1220 break;
1216 case CAL_END_DATETIME: 1221 case CAL_END_DATETIME:
1217 dtp = &Note->Entries[i].Date ; 1222 dtp = &Note->Entries[i].Date ;
1218 qDebug("hour2: %d ", dtp->Hour); 1223 qDebug("hour2: %d ", dtp->Hour);
1219 if ( dtp->Hour == -1 ) { 1224 if ( dtp->Hour == -1 ) {
1220 ADAY = "1"; 1225 ADAY = "1";
1221 ALED.sprintf("%04d%02d%02d",dtp->Year, dtp->Month, dtp->Day ); 1226 ALED.sprintf("%04d%02d%02d",dtp->Year, dtp->Month, dtp->Day );
1222 TIM2.sprintf("%04d%02d%02dT000000",dtp->Year, dtp->Month, dtp->Day ); 1227 TIM2.sprintf("%04d%02d%02dT000000",dtp->Year, dtp->Month, dtp->Day );
1223 } else { 1228 } else {
1224 TIM2.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second ); 1229 TIM2.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second );
1225 1230
1226 } 1231 }
1227 //printmsg("Stop : %s\n",OSDateTime(Note->Entries[i].Date,false)); 1232 //printmsg("Stop : %s\n",OSDateTime(Note->Entries[i].Date,false));
1228 //memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime)); 1233 //memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1229 break; 1234 break;
1230 case CAL_ALARM_DATETIME: 1235 case CAL_ALARM_DATETIME:
1231 ARON = "0"; 1236 ARON = "0";
1232 dtp = &Note->Entries[i].Date ; 1237 dtp = &Note->Entries[i].Date ;
1233 ARMN.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second ); 1238 ARMN.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second );
1234 //printmsg("Tone alarm : %s\n",OSDateTime(Note->Entries[i].Date,false)); 1239 //printmsg("Tone alarm : %s\n",OSDateTime(Note->Entries[i].Date,false));
1235 memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime)); 1240 memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1236 break; 1241 break;
1237 case CAL_SILENT_ALARM_DATETIME: 1242 case CAL_SILENT_ALARM_DATETIME:
1238 ARON = "0"; 1243 ARON = "0";
1239 dtp = &Note->Entries[i].Date ; 1244 dtp = &Note->Entries[i].Date ;
1240 ARMN.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second ); 1245 ARMN.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second );
1241 //printmsg("Silent alarm : %s\n",OSDateTime(Note->Entries[i].Date,false)); 1246 //printmsg("Silent alarm : %s\n",OSDateTime(Note->Entries[i].Date,false));
1242 //memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime)); 1247 //memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1243 break; 1248 break;
1244 case CAL_RECURRANCE: 1249 case CAL_RECURRANCE:
1245 //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" ); 1250 //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" );
1246 break; 1251 break;
1247 case CAL_TEXT: 1252 case CAL_TEXT:
1248 DSRP = QString ( (const char*) Note->Entries[i].Text ); 1253 DSRP = QString ( (const char*) Note->Entries[i].Text );
1249 break; 1254 break;
1250 case CAL_LOCATION: 1255 case CAL_LOCATION:
1251 PLCE = QString ((const char*) Note->Entries[i].Text ); 1256 PLCE = QString ((const char*) Note->Entries[i].Text );
1252 break; 1257 break;
1253 case CAL_PHONE: 1258 case CAL_PHONE:
1254 //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); 1259 //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text));
1255 break; 1260 break;
1256 case CAL_PRIVATE: 1261 case CAL_PRIVATE:
1257 //printmsg("Private : %s\n",Note->Entries[i].Number == 1 ? "Yes" : "No"); 1262 //printmsg("Private : %s\n",Note->Entries[i].Number == 1 ? "Yes" : "No");
1258 break; 1263 break;
1259 case CAL_CONTACTID: 1264 case CAL_CONTACTID:
1260#if 0 1265#if 0
1261 entry.Location = Note->Entries[i].Number; 1266 entry.Location = Note->Entries[i].Number;
1262 entry.MemoryType = MEM_ME; 1267 entry.MemoryType = MEM_ME;
1263 error=Phone->GetMemory(&s, &entry); 1268 error=Phone->GetMemory(&s, &entry);
1264 if (error == ERR_NONE) { 1269 if (error == ERR_NONE) {
1265 name = GSM_PhonebookGetEntryName(&entry); 1270 name = GSM_PhonebookGetEntryName(&entry);
1266 if (name != NULL) { 1271 if (name != NULL) {
1267 //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number); 1272 //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number);
1268 } else { 1273 } else {
1269 //printmsg("Contact ID : %d\n",Note->Entries[i].Number); 1274 //printmsg("Contact ID : %d\n",Note->Entries[i].Number);
1270 } 1275 }
1271 } else { 1276 } else {
1272 //printmsg("Contact ID : %d\n",Note->Entries[i].Number); 1277 //printmsg("Contact ID : %d\n",Note->Entries[i].Number);
1273 } 1278 }
1274#endif 1279#endif
1275 break; 1280 break;
1276 case CAL_REPEAT_DAYOFWEEK: 1281 case CAL_REPEAT_DAYOFWEEK:
1277 repeat_dayofweek = Note->Entries[i].Number; 1282 repeat_dayofweek = Note->Entries[i].Number;
1278 repeating = true; 1283 repeating = true;
1279 break; 1284 break;
1280 case CAL_REPEAT_DAY: 1285 case CAL_REPEAT_DAY:
1281 repeat_day = Note->Entries[i].Number; 1286 repeat_day = Note->Entries[i].Number;
1282 repeating = true; 1287 repeating = true;
1283 break; 1288 break;
1284 case CAL_REPEAT_WEEKOFMONTH: 1289 case CAL_REPEAT_WEEKOFMONTH:
1285 repeat_weekofmonth = Note->Entries[i].Number; 1290 repeat_weekofmonth = Note->Entries[i].Number;
1286 repeating = true; 1291 repeating = true;
1287 break; 1292 break;
1288 case CAL_REPEAT_MONTH: 1293 case CAL_REPEAT_MONTH:
1289 repeat_month = Note->Entries[i].Number; 1294 repeat_month = Note->Entries[i].Number;
1290 repeating = true; 1295 repeating = true;
1291 break; 1296 break;
1292 case CAL_REPEAT_FREQUENCY: 1297 case CAL_REPEAT_FREQUENCY:
1293 repeat_frequency = Note->Entries[i].Number; 1298 repeat_frequency = Note->Entries[i].Number;
1294 repeating = true; 1299 repeating = true;
1295 break; 1300 break;
1296 case CAL_REPEAT_STARTDATE: 1301 case CAL_REPEAT_STARTDATE:
1297 repeat_startdate = Note->Entries[i].Date; 1302 repeat_startdate = Note->Entries[i].Date;
1298 repeating = true; 1303 repeating = true;
1299 break; 1304 break;
1300 case CAL_REPEAT_STOPDATE: 1305 case CAL_REPEAT_STOPDATE:
1301 repeat_stopdate = Note->Entries[i].Date; 1306 repeat_stopdate = Note->Entries[i].Date;
1302 repeating = true; 1307 repeating = true;
1303 break; 1308 break;
1304 } 1309 }
1305 } 1310 }
1306 1311
1307 1312
1308 1313
1309 if ( ARON == "0" ) { 1314 if ( ARON == "0" ) {
1310 QDateTime start,alarm; 1315 QDateTime start,alarm;
1311 start = handler.fromString( TIM1 ); 1316 start = handler.fromString( TIM1 );
1312 alarm = handler.fromString( ARMN ); 1317 alarm = handler.fromString( ARMN );
1313 int min = alarm.secsTo ( start )/60; 1318 int min = alarm.secsTo ( start )/60;
1314 ARMN = QString::number ( min ); 1319 ARMN = QString::number ( min );
1315 } 1320 }
1316 1321
1317 templist.clear(); 1322 templist.clear();
1318 templist << CARDID << CATEGORY << DSRP << PLCE << MEM1 << TIM1 << TIM2 << ADAY << ARON << ARMN << ARSD << RTYP << RFRQ << RPOS << RDYS << REND << REDT << ALSD << ALED << MDAY; 1323 templist << CARDID << CATEGORY << DSRP << PLCE << MEM1 << TIM1 << TIM2 << ADAY << ARON << ARMN << ARSD << RTYP << RFRQ << RPOS << RDYS << REND << REDT << ALSD << ALED << MDAY;
1319 handler.startElement( existingCalendar, templist, type ); 1324 handler.startElement( existingCalendar, templist, type );
1320 } 1325 }
1321 1326
1322 1327
1323 1328
1324#if 0 1329#if 0
1325 // qDebug("test %s ", text.latin1()); 1330 // qDebug("test %s ", text.latin1());
1326 QStringList templist; 1331 QStringList templist;
1327 QString tempString; 1332 QString tempString;
1328 int start = 0; 1333 int start = 0;
1329 int len = text.length(); 1334 int len = text.length();
1330 int end = text.find ("\n",start)+1; 1335 int end = text.find ("\n",start)+1;
1331 bool ok = true; 1336 bool ok = true;
1332 start = end; 1337 start = end;
1333 SharpParser handler( calendar ); 1338 PhoneParser handler( calendar );
1334 handler.setCategoriesList( mCategories ); 1339 handler.setCategoriesList( mCategories );
1335 while ( start > 0 ) { 1340 while ( start > 0 ) {
1336 templist.clear(); 1341 templist.clear();
1337 ok = true; 1342 ok = true;
1338 while ( ok ) { 1343 while ( ok ) {
1339 tempString = getPart( text, ok, start ); 1344 tempString = getPart( text, ok, start );
1340 if ( start >= len || start == 0 ) { 1345 if ( start >= len || start == 0 ) {
1341 start = 0; 1346 start = 0;
1342 ok = false; 1347 ok = false;
1343 } 1348 }
1344 if ( tempString.right(1) =="\n" ) 1349 if ( tempString.right(1) =="\n" )
1345 tempString = tempString.left( tempString.length()-1); 1350 tempString = tempString.left( tempString.length()-1);
1346 //if ( ok ) 1351 //if ( ok )
1347 templist.append( tempString ); 1352 templist.append( tempString );
1348 //qDebug("%d ---%s---", templist.count(),tempString.latin1() ); 1353 //qDebug("%d ---%s---", templist.count(),tempString.latin1() );
1349 } 1354 }
1350 handler.startElement( existingCalendar, templist, type ); 1355 handler.startElement( existingCalendar, templist, type );
1351 } 1356 }
1352#endif 1357#endif
1353 return false; 1358 return false;
1354} 1359}
1355 1360
1356QString SharpFormat::toString( Calendar * ) 1361QString PhoneFormat::toString( Calendar * )
1357{ 1362{
1358 return QString::null; 1363 return QString::null;
1359} 1364}
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h
index f4cb52c..4ddf6f0 100644
--- a/libkcal/phoneformat.h
+++ b/libkcal/phoneformat.h
@@ -1,65 +1,65 @@
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#ifndef SHARPFORMAT_H 21#ifndef PHONEFORMAT_H
22#define SHARPAFORMAT_H 22#define PHONEFORMAT_H
23 23
24#include <qstring.h> 24#include <qstring.h>
25 25
26#include "scheduler.h" 26#include "scheduler.h"
27 27
28#include "calformat.h" 28#include "calformat.h"
29extern "C" { 29extern "C" {
30#include "gammu.h" 30#include "../gammu/emb/common/gammu.h"
31} 31}
32 32
33namespace KCal { 33namespace KCal {
34 34
35/** 35/**
36 This class implements the calendar format used by Sharp. 36 This class implements the calendar format used by Phone.
37*/ 37*/
38 38
39class SharpFormat : public QObject { 39class PhoneFormat : public QObject {
40 public: 40 public:
41 /** Create new iCalendar format. */ 41 /** Create new iCalendar format. */
42 SharpFormat(); 42 PhoneFormat();
43 virtual ~SharpFormat(); 43 virtual ~PhoneFormat();
44 44
45 bool load( Calendar * ,Calendar *); 45 bool load( Calendar * ,Calendar *);
46 bool save( Calendar * ); 46 bool save( Calendar * );
47 void setCategoriesList ( QStringList * cat ){ mCategories = cat; } 47 void setCategoriesList ( QStringList * cat ){ mCategories = cat; }
48 bool fromString2Cal( Calendar *, Calendar *, GSM_StateMachine*s , const QString & ); 48 bool fromString2Cal( Calendar *, Calendar *, GSM_StateMachine*s , const QString & );
49 bool fromString( Calendar *, const QString & ); 49 bool fromString( Calendar *, const QString & );
50 QString toString( Calendar * ); 50 QString toString( Calendar * );
51 static ulong getCsum( const QStringList & ); 51 static ulong getCsum( const QStringList & );
52 52
53 private: 53 private:
54 QString getEventString( Event* ); 54 QString getEventString( Event* );
55 QString getTodoString( Todo* ); 55 QString getTodoString( Todo* );
56 QString dtToString( const QDateTime& dt, bool useTZ = true ); 56 QString dtToString( const QDateTime& dt, bool useTZ = true );
57 57
58 QStringList *mCategories; 58 QStringList *mCategories;
59 int getNumFromRecord( QString answer,Incidence* inc ) ; 59 int getNumFromRecord( QString answer,Incidence* inc ) ;
60 QString getPart( const QString & text, bool &ok, int &start ); 60 QString getPart( const QString & text, bool &ok, int &start );
61}; 61};
62 62
63} 63}
64 64
65#endif 65#endif