summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-08-07 21:04:24 (UTC)
committer zautrix <zautrix>2004-08-07 21:04:24 (UTC)
commita9c3191a42084b6631dededef1709fa67eb2c048 (patch) (unidiff)
tree9950e3c8fc54c2994a4a50417008921bfdc58889
parent809e502f4b6e84524c10fa963e2d17564e6b1af9 (diff)
downloadkdepimpi-a9c3191a42084b6631dededef1709fa67eb2c048.zip
kdepimpi-a9c3191a42084b6631dededef1709fa67eb2c048.tar.gz
kdepimpi-a9c3191a42084b6631dededef1709fa67eb2c048.tar.bz2
more phone sync
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp9
-rw-r--r--libkcal/phoneformat.cpp273
-rw-r--r--libkcal/phoneformat.h3
3 files changed, 222 insertions, 63 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index b307649..d6ead37 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1151,85 +1151,90 @@ bool CalendarView::syncCalendar(QString filename, int mode)
1151 mGlobalSyncMode = SYNC_MODE_NORMAL; 1151 mGlobalSyncMode = SYNC_MODE_NORMAL;
1152 CalendarLocal* calendar = new CalendarLocal(); 1152 CalendarLocal* calendar = new CalendarLocal();
1153 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1153 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1154 FileStorage* storage = new FileStorage( calendar ); 1154 FileStorage* storage = new FileStorage( calendar );
1155 bool syncOK = false; 1155 bool syncOK = false;
1156 storage->setFileName( filename ); 1156 storage->setFileName( filename );
1157 // qDebug("loading ... "); 1157 // qDebug("loading ... ");
1158 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 1158 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
1159 getEventViewerDialog()->setSyncMode( true ); 1159 getEventViewerDialog()->setSyncMode( true );
1160 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1160 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1161 getEventViewerDialog()->setSyncMode( false ); 1161 getEventViewerDialog()->setSyncMode( false );
1162 if ( syncOK ) { 1162 if ( syncOK ) {
1163 if ( KOPrefs::instance()->mWriteBackFile ) 1163 if ( KOPrefs::instance()->mWriteBackFile )
1164 { 1164 {
1165 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1165 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1166 storage->save(); 1166 storage->save();
1167 } 1167 }
1168 } 1168 }
1169 setModified( true ); 1169 setModified( true );
1170 } 1170 }
1171 delete storage; 1171 delete storage;
1172 delete calendar; 1172 delete calendar;
1173 if ( syncOK ) 1173 if ( syncOK )
1174 updateView(); 1174 updateView();
1175 return syncOK; 1175 return syncOK;
1176} 1176}
1177void CalendarView::syncPhone() 1177void CalendarView::syncPhone()
1178{ 1178{
1179 syncExternal( 1 ); 1179 syncExternal( 1 );
1180} 1180}
1181void CalendarView::syncExternal( int mode ) 1181void CalendarView::syncExternal( int mode )
1182{ 1182{
1183 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1183 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1184 //mCurrentSyncDevice = "sharp-DTM"; 1184 //mCurrentSyncDevice = "sharp-DTM";
1185 if ( KOPrefs::instance()->mAskForPreferences ) 1185 if ( KOPrefs::instance()->mAskForPreferences )
1186 edit_sync_options(); 1186 edit_sync_options();
1187 qApp->processEvents(); 1187 qApp->processEvents();
1188 CalendarLocal* calendar = new CalendarLocal(); 1188 CalendarLocal* calendar = new CalendarLocal();
1189 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1189 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1190 bool syncOK = false; 1190 bool syncOK = false;
1191 bool loadSuccess = false; 1191 bool loadSuccess = false;
1192 PhoneFormat* phoneFormat = 0; 1192 PhoneFormat* phoneFormat = 0;
1193#ifndef DESKTOP_VERSION 1193#ifndef DESKTOP_VERSION
1194 SharpFormat* sharpFormat = 0; 1194 SharpFormat* sharpFormat = 0;
1195 if ( mode == 0 ) { // sharp 1195 if ( mode == 0 ) { // sharp
1196 sharpFormat = new SharpFormat () ; 1196 sharpFormat = new SharpFormat () ;
1197 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1197 loadSuccess = sharpFormat->load( calendar, mCalendar );
1198 1198
1199 } else 1199 } else
1200#endif 1200#endif
1201 if ( mode == 1 ) { // phone 1201 if ( mode == 1 ) { // phone
1202 phoneFormat = new PhoneFormat (); 1202 phoneFormat = new PhoneFormat ();
1203 loadSuccess = phoneFormat->load( calendar, mCalendar ); 1203 loadSuccess = phoneFormat->load( calendar,
1204 mCalendar,
1205 mCurrentSyncDevice,
1206 KOPrefs::instance()->mPhoneDevice,
1207 KOPrefs::instance()->mPhoneConnection,
1208 KOPrefs::instance()->mPhoneModel);
1204 1209
1205 } else 1210 } else
1206 return; 1211 return;
1207 if ( loadSuccess ) { 1212 if ( loadSuccess ) {
1208 getEventViewerDialog()->setSyncMode( true ); 1213 getEventViewerDialog()->setSyncMode( true );
1209 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1214 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1210 getEventViewerDialog()->setSyncMode( false ); 1215 getEventViewerDialog()->setSyncMode( false );
1211 qApp->processEvents(); 1216 qApp->processEvents();
1212 if ( syncOK ) { 1217 if ( syncOK ) {
1213 if ( KOPrefs::instance()->mWriteBackFile ) 1218 if ( KOPrefs::instance()->mWriteBackFile )
1214 { 1219 {
1215 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1220 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1216 Incidence* inc = iL.first(); 1221 Incidence* inc = iL.first();
1217 /* obsolete 1222 /* obsolete
1218 while ( inc ) { 1223 while ( inc ) {
1219 inc->setZaurusStat( inc->revision () ); 1224 inc->setZaurusStat( inc->revision () );
1220 inc = iL.next(); 1225 inc = iL.next();
1221 } 1226 }
1222 */ 1227 */
1223#ifndef DESKTOP_VERSION 1228#ifndef DESKTOP_VERSION
1224 if ( sharpFormat ) 1229 if ( sharpFormat )
1225 sharpFormat->save(calendar); 1230 sharpFormat->save(calendar);
1226#endif 1231#endif
1227 if ( phoneFormat ) 1232 if ( phoneFormat )
1228 phoneFormat->save(calendar); 1233 phoneFormat->save(calendar);
1229 iL = calendar->rawIncidences(); 1234 iL = calendar->rawIncidences();
1230 inc = iL.first(); 1235 inc = iL.first();
1231 Incidence* loc; 1236 Incidence* loc;
1232 while ( inc ) { 1237 while ( inc ) {
1233 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1238 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1234 loc = mCalendar->incidence(inc->uid() ); 1239 loc = mCalendar->incidence(inc->uid() );
1235 if ( loc ) { 1240 if ( loc ) {
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index fa18683..fd6b6af 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -13,445 +13,597 @@
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#include "syncdefines.h"
45 46
46using namespace KCal; 47using 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
62class PhoneParser : public QObject 63class PhoneParser : public QObject
63{ 64{
64 public: 65 public:
65 PhoneParser( Calendar *calendar ) : mCalendar( calendar ) { 66 PhoneParser( Calendar *calendar, QString profileName ) : mCalendar( calendar ), mProfileName ( profileName ) {
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, GSM_CalendarEntry*Note, QString qName )
70 { 71 {
72 QStringList attList;
73 /*
74// pending csum
71 int i = 1; 75 int i = 1;
72 bool skip = true; 76 bool skip = true;
73 int max = attList.count() -2; 77 int max = attList.count() -2;
74 while ( i < max ) { 78 while ( i < max ) {
75 if ( !attList[i].isEmpty() ) { 79 if ( !attList[i].isEmpty() ) {
76 skip = false; 80 skip = false;
77 break; 81 break;
78 } 82 }
79 ++i ; 83 ++i ;
80 } 84 }
81 if ( skip ) 85 if ( skip )
82 return false; 86 return false;
83 ulong cSum = PhoneFormat::getCsum(attList ); 87 ulong cSum = PhoneFormat::getCsum(attList );
84 88 */
85 if ( qName == "Event" ) { 89 if ( qName == "Event" ) {
90 int id = Note->Location;
86 Event *event; 91 Event *event;
87 event = existingCalendar->event( attList[0] ); 92 event = existingCalendar->event( mProfileName ,QString::number( id ) );
88 if ( event ) 93 if ( event )
89 event = (Event*)event->clone(); 94 event = (Event*)event->clone();
90 else 95 else
91 event = new Event; 96 event = new Event;
92 // event->setZaurusId( attList[0].toInt() ); 97 event->setID( mProfileName, attList[0] );
93 //event->setZaurusUid( cSum ); 98 // pending event->setCsum( "Sharp_DTM", QString::number( cSum ));
94 //event->setZaurusStat( -2 ); 99 event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL );
100
101
102 int i = 0;
103 bool repeating = false;
104 int repeat_dayofweek = -1;
105 int repeat_day = -1;
106 int repeat_weekofmonth = -1;
107 int repeat_month = -1;
108 int repeat_frequency = -1;
109 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0};
110 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0};
111 GSM_DateTime* dtp;
112 bool alarm = false;
113 QDateTime alarmDt;
114 repeat_startdate.Day= 0;
115 repeat_stopdate.Day = 0;
116 for (i=0;i<Note->EntriesNum;i++) {
117
118 qDebug(" for ");
119 switch (Note->Entries[i].EntryType) {
120 case CAL_START_DATETIME:
121 dtp = &Note->Entries[i].Date ;
122 if ( dtp->Hour > 24 ) {
123 event->setFloats( true );
124 event->setDtStart( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 )));
125 } else {
126 event->setDtStart (fromGSM ( dtp ));
95 127
96 event->setSummary( attList[2] ); 128 }
97 event->setLocation( attList[3] ); 129 break;
98 event->setDescription( attList[4] ); 130 case CAL_END_DATETIME:
99 if ( attList[7] == "1" ) { 131 dtp = &Note->Entries[i].Date ;
100 event->setDtStart( QDateTime(fromString( attList[17]+"T000000", false ).date(),QTime(0,0,0 ) )); 132 if ( dtp->Hour > 24 ) {
101 event->setDtEnd( QDateTime(fromString( attList[18]+"T000000", false ).date(),QTime(0,0,0 ))); 133 event->setFloats( true );
102 event->setFloats( true ); 134 event->setDtEnd( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 )));
103 } else { 135 } else {
104 event->setFloats( false ); 136 event->setDtEnd (fromGSM ( dtp ));
105 event->setDtStart( fromString( attList[5] ) ); 137 }
106 event->setDtEnd( fromString( attList[6] )); 138 break;
139 case CAL_ALARM_DATETIME:
140 dtp = &Note->Entries[i].Date ;
141 alarm = true;
142 alarmDt = fromGSM ( dtp );
143 break;
144 case CAL_SILENT_ALARM_DATETIME:
145 dtp = &Note->Entries[i].Date ;
146 alarm = true;
147 alarmDt = fromGSM ( dtp );
148 break;
149 case CAL_RECURRANCE:
150 //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" );
151 break;
152 case CAL_TEXT:
153 event->setSummary( QString ( (const char*) Note->Entries[i].Text ));
154 break;
155 case CAL_LOCATION:
156 event->setLocation(QString ((const char*) Note->Entries[i].Text ));
157 break;
158 case CAL_PHONE:
159 //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text));
160 break;
161 case CAL_PRIVATE:
162 //printmsg("Private : %s\n",Note->Entries[i].Number == 1 ? "Yes" : "No");
163 break;
164 case CAL_CONTACTID:
165#if 0
166 entry.Location = Note->Entries[i].Number;
167 entry.MemoryType = MEM_ME;
168 error=Phone->GetMemory(&s, &entry);
169 if (error == ERR_NONE) {
170 name = GSM_PhonebookGetEntryName(&entry);
171 if (name != NULL) {
172 //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number);
173 } else {
174 //printmsg("Contact ID : %d\n",Note->Entries[i].Number);
175 }
176 } else {
177 //printmsg("Contact ID : %d\n",Note->Entries[i].Number);
178 }
179#endif
180 break;
181 case CAL_REPEAT_DAYOFWEEK:
182 repeat_dayofweek = Note->Entries[i].Number;
183 repeating = true;
184 break;
185 case CAL_REPEAT_DAY:
186 repeat_day = Note->Entries[i].Number;
187 repeating = true;
188 break;
189 case CAL_REPEAT_WEEKOFMONTH:
190 repeat_weekofmonth = Note->Entries[i].Number;
191 repeating = true;
192 break;
193 case CAL_REPEAT_MONTH:
194 repeat_month = Note->Entries[i].Number;
195 repeating = true;
196 break;
197 case CAL_REPEAT_FREQUENCY:
198 repeat_frequency = Note->Entries[i].Number;
199 repeating = true;
200 break;
201 case CAL_REPEAT_STARTDATE:
202 repeat_startdate = Note->Entries[i].Date;
203 repeating = true;
204 break;
205 case CAL_REPEAT_STOPDATE:
206 repeat_stopdate = Note->Entries[i].Date;
207 repeating = true;
208 break;
209 }
107 } 210 }
211#if 0
212 event->setDescription( attList[4] );
213 bool repeating = false;
214 int repeat_dayofweek = -1;
215 int repeat_day = -1;
216 int repeat_weekofmonth = -1;
217 int repeat_month = -1;
218 int repeat_frequency = -1;
219 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0};
220 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0};
221
222#endif
108 223
109 QString rtype = attList[11]; 224 QString rtype = attList[11];
110 if ( rtype != "255" ) { 225 if ( repeating ) {
226 int rtype = 0;
111 // qDebug("recurs "); 227 // qDebug("recurs ");
112 QDate startDate = event->dtStart().date(); 228 QDate startDate, endDate;
113 229 if ( repeat_startdate.Day > 0 )
114 QString freqStr = attList[12]; 230 startDate = datefromGSM ( &repeat_startdate );
115 int freq = freqStr.toInt(); 231 else
116 232 startDate = event->dtStart().date();
117 QString hasEndDateStr = attList[15] ; 233 int freq = repeat_frequency;
118 bool hasEndDate = hasEndDateStr == "1"; 234 bool hasEndDate = false;
119 235 if ( repeat_stopdate.Day > 0 ) {
120 QString endDateStr = attList[16]; 236 endDate = datefromGSM ( &repeat_stopdate );
121 QDate endDate = fromString( endDateStr ).date(); 237 hasEndDate = true;
122 238 }
123 QString weekDaysStr = attList[14]; 239
124 uint weekDaysNum = weekDaysStr.toInt(); 240 uint weekDaysNum = repeat_dayofweek ;
125 241
126 QBitArray weekDays( 7 ); 242 QBitArray weekDays( 7 );
127 int i; 243 int i;
128 int bb = 1; 244 int bb = 1;
129 for( i = 1; i <= 7; ++i ) { 245 for( i = 1; i <= 7; ++i ) {
130 weekDays.setBit( i - 1, ( bb & weekDaysNum )); 246 weekDays.setBit( i - 1, ( bb & weekDaysNum ));
131 bb = 2 << (i-1); 247 bb = 2 << (i-1);
132 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); 248 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) );
133 } 249 }
134 // qDebug("next "); 250 // qDebug("next ");
135 QString posStr = attList[13]; 251 int pos = 0;
136 int pos = posStr.toInt();
137 Recurrence *r = event->recurrence(); 252 Recurrence *r = event->recurrence();
253 /*
254 0 daily;
255 1 weekly;x
256 2 monthpos;x
257 3 monthlyday;
258 4 rYearlyMont
259 */
260 int dayOfWeek = startDate.dayOfWeek();
261 if ( repeat_weekofmonth >= 0 ) {
262 rtype = 2;
263 pos = repeat_weekofmonth;
264 if ( repeat_dayofweek >= 0 )
265 dayOfWeek = repeat_dayofweek;
266 } else if ( repeat_dayofweek >= 0 ) {
267 rtype = 1;
268 } if ( repeat_dayofweek >= 0 ) {
269 rtype = 1;
270 }
138 271
139 if ( rtype == "0" ) { 272 if ( rtype == 0 ) {
140 if ( hasEndDate ) r->setDaily( freq, endDate ); 273 if ( hasEndDate ) r->setDaily( freq, endDate );
141 else r->setDaily( freq, -1 ); 274 else r->setDaily( freq, -1 );
142 } else if ( rtype == "1" ) { 275 } else if ( rtype == 1 ) {
143 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); 276 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate );
144 else r->setWeekly( freq, weekDays, -1 ); 277 else r->setWeekly( freq, weekDays, -1 );
145 } else if ( rtype == "3" ) { 278 } else if ( rtype == 3 ) {
146 if ( hasEndDate ) 279 if ( hasEndDate )
147 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); 280 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
148 else 281 else
149 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); 282 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 );
150 r->addMonthlyDay( startDate.day() ); 283 r->addMonthlyDay( startDate.day() );
151 } else if ( rtype == "2" ) { 284 } else if ( rtype == 2 ) {
152 if ( hasEndDate ) 285 if ( hasEndDate )
153 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); 286 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
154 else 287 else
155 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); 288 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 );
156 QBitArray days( 7 ); 289 QBitArray days( 7 );
157 days.fill( false ); 290 days.fill( false );
158 days.setBit( startDate.dayOfWeek() - 1 ); 291 days.setBit( dayOfWeek - 1 );
159 r->addMonthlyPos( pos, days ); 292 r->addMonthlyPos( pos, days );
160 } else if ( rtype == "4" ) { 293 } else if ( rtype == 4 ) {
161 if ( hasEndDate ) 294 if ( hasEndDate )
162 r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); 295 r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
163 else 296 else
164 r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); 297 r->setYearly( Recurrence::rYearlyMonth, freq, -1 );
165 r->addYearlyNum( startDate.month() ); 298 r->addYearlyNum( startDate.month() );
166 } 299 }
300 } else {
301 event->recurrence()->unsetRecurs();
167 } 302 }
168 303
169 QString categoryList = attList[1] ; 304 QString categoryList = attList[1] ;
170 event->setCategories( lookupCategories( categoryList ) ); 305 event->setCategories( lookupCategories( categoryList ) );
171 306
172 // strange 0 semms to mean: alarm enabled 307 // strange 0 semms to mean: alarm enabled
173 if ( attList[8] == "0" ) { 308 if ( alarm ) {
174 Alarm *alarm; 309 Alarm *alarm;
175 if ( event->alarms().count() > 0 ) 310 if ( event->alarms().count() > 0 )
176 alarm = event->alarms().first(); 311 alarm = event->alarms().first();
177 else { 312 else {
178 alarm = new Alarm( event ); 313 alarm = new Alarm( event );
179 event->addAlarm( alarm ); 314 event->addAlarm( alarm );
180 } 315 }
181 alarm->setType( Alarm::Audio ); 316 alarm->setType( Alarm::Audio );
182 alarm->setEnabled( true ); 317 alarm->setEnabled( true );
183 int alarmOffset = attList[9].toInt(); 318 int alarmOffset = alarmDt.secsTo( event->dtStart() );
184 alarm->setStartOffset( alarmOffset * -60 ); 319 alarm->setStartOffset( alarmOffset );
185 } 320 }
186
187 mCalendar->addEvent( event); 321 mCalendar->addEvent( event);
188 } else if ( qName == "Todo" ) { 322 } else if ( qName == "Todo" ) {
323#if 0
189 Todo *todo; 324 Todo *todo;
190 325
191 todo = existingCalendar->todo( attList[0] ); 326 todo = existingCalendar->todo( attList[0] );
192 if (todo ) 327 if (todo )
193 todo = (Todo*)todo->clone(); 328 todo = (Todo*)todo->clone();
194 else 329 else
195 todo = new Todo; 330 todo = new Todo;
196 331
197//CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 332//CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1
198// 0 1 2 3 4 5 6 7 8 333// 0 1 2 3 4 5 6 7 8
199//1,,,,,1,4,Loch zumachen,"" 334//1,,,,,1,4,Loch zumachen,""
200//3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " 335//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 336//2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes
202 337
203 //todo->setZaurusId( attList[0] ); 338 //todo->setZaurusId( attList[0] );
204 //todo->setZaurusUid( cSum ); 339 //todo->setZaurusUid( cSum );
205 //todo->setZaurusStat( -2 ); 340 //todo->setZaurusStat( -2 );
206 341
207 todo->setSummary( attList[7] ); 342 todo->setSummary( attList[7] );
208 todo->setDescription( attList[8]); 343 todo->setDescription( attList[8]);
209 344
210 int priority = attList[6].toInt(); 345 int priority = attList[6].toInt();
211 if ( priority == 0 ) priority = 3; 346 if ( priority == 0 ) priority = 3;
212 todo->setPriority( priority ); 347 todo->setPriority( priority );
213 348
214 QString categoryList = attList[1]; 349 QString categoryList = attList[1];
215 todo->setCategories( lookupCategories( categoryList ) ); 350 todo->setCategories( lookupCategories( categoryList ) );
216 351
217 352
218 353
219 QString hasDateStr = attList[3]; // due 354 QString hasDateStr = attList[3]; // due
220 if ( !hasDateStr.isEmpty() ) { 355 if ( !hasDateStr.isEmpty() ) {
221 if ( hasDateStr.right(6) == "000000" ) { 356 if ( hasDateStr.right(6) == "000000" ) {
222 todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); 357 todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) );
223 todo->setFloats( true ); 358 todo->setFloats( true );
224 } 359 }
225 else { 360 else {
226 todo->setDtDue( fromString( hasDateStr ) ); 361 todo->setDtDue( fromString( hasDateStr ) );
227 todo->setFloats( false ); 362 todo->setFloats( false );
228 } 363 }
229 364
230 todo->setHasDueDate( true ); 365 todo->setHasDueDate( true );
231 } 366 }
232 hasDateStr = attList[2];//start 367 hasDateStr = attList[2];//start
233 if ( !hasDateStr.isEmpty() ) { 368 if ( !hasDateStr.isEmpty() ) {
234 369
235 todo->setDtStart( fromString( hasDateStr ) ); 370 todo->setDtStart( fromString( hasDateStr ) );
236 todo->setHasStartDate( true); 371 todo->setHasStartDate( true);
237 } else 372 } else
238 todo->setHasStartDate( false ); 373 todo->setHasStartDate( false );
239 hasDateStr = attList[4];//completed 374 hasDateStr = attList[4];//completed
240 if ( !hasDateStr.isEmpty() ) { 375 if ( !hasDateStr.isEmpty() ) {
241 todo->setCompleted(fromString( hasDateStr ) ); 376 todo->setCompleted(fromString( hasDateStr ) );
242 } 377 }
243 QString completedStr = attList[5]; 378 QString completedStr = attList[5];
244 if ( completedStr == "0" ) 379 if ( completedStr == "0" )
245 todo->setCompleted( true ); 380 todo->setCompleted( true );
246 else 381 else
247 todo->setCompleted( false ); 382 todo->setCompleted( false );
248 mCalendar->addTodo( todo ); 383 mCalendar->addTodo( todo );
384#endif
249 385
250 } else if ( qName == "Category" ) { 386 } else if ( qName == "Category" ) {
251 /* 387 /*
252 QString id = attributes.value( "id" ); 388 QString id = attributes.value( "id" );
253 QString name = attributes.value( "name" ); 389 QString name = attributes.value( "name" );
254 setCategory( id, name ); 390 setCategory( id, name );
255 */ 391 */
256 } 392 }
257 //qDebug("end "); 393 //qDebug("end ");
258 return true; 394 return true;
259 } 395 }
260 396
261 397
262 void setCategoriesList ( QStringList * c ) 398 void setCategoriesList ( QStringList * c )
263 { 399 {
264 oldCategories = c; 400 oldCategories = c;
265 } 401 }
266 402
267 QDateTime fromString ( QString s, bool useTz = true ) { 403 QDateTime fromGSM ( GSM_DateTime*dtp, bool useTz = true ) {
268 QDateTime dt; 404 QDateTime dt;
269 int y,m,t,h,min,sec; 405 int y,m,t,h,min,sec;
270 y = s.mid(0,4).toInt(); 406 y = dtp->Year;
271 m = s.mid(4,2).toInt(); 407 m = dtp->Month;
272 t = s.mid(6,2).toInt(); 408 t = dtp->Day;
273 h = s.mid(9,2).toInt(); 409 h = dtp->Hour;
274 min = s.mid(11,2).toInt(); 410 min = dtp->Minute;
275 sec = s.mid(13,2).toInt(); 411 sec = dtp->Second;
276 dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); 412 dt = QDateTime(QDate(y,m,t), QTime(h,min,sec));
413 // dtp->Timezone: offset in hours
277 int offset = KGlobal::locale()->localTimeOffset( dt ); 414 int offset = KGlobal::locale()->localTimeOffset( dt );
278 if ( useTz ) 415 if ( useTz )
279 dt = dt.addSecs ( offset*60); 416 dt = dt.addSecs ( offset*60);
280 return dt; 417 return dt;
281 418
282 } 419 }
420 QDate datefromGSM ( GSM_DateTime*dtp ) {
421 return QDate ( dtp->Year, dtp->Month, dtp->Day );
422 }
283 protected: 423 protected:
284 QDateTime toDateTime( const QString &value ) 424 QDateTime toDateTime( const QString &value )
285 { 425 {
286 QDateTime dt; 426 QDateTime dt;
287 dt.setTime_t( value.toUInt() ); 427 dt.setTime_t( value.toUInt() );
288 428
289 return dt; 429 return dt;
290 } 430 }
291 431
292 QStringList lookupCategories( const QString &categoryList ) 432 QStringList lookupCategories( const QString &categoryList )
293 { 433 {
294 QStringList categoryIds = QStringList::split( ";", categoryList ); 434 QStringList categoryIds = QStringList::split( ";", categoryList );
295 QStringList categories; 435 QStringList categories;
296 QStringList::ConstIterator it; 436 QStringList::ConstIterator it;
297 for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) { 437 for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) {
298 QString cate = category( *it ); 438 QString cate = category( *it );
299 if ( oldCategories ) { 439 if ( oldCategories ) {
300 if ( ! oldCategories->contains( cate ) ) 440 if ( ! oldCategories->contains( cate ) )
301 oldCategories->append( cate ); 441 oldCategories->append( cate );
302 } 442 }
303 categories.append(cate ); 443 categories.append(cate );
304 } 444 }
305 return categories; 445 return categories;
306 } 446 }
307 447
308 private: 448 private:
449 QString mProfileName ;
309 Calendar *mCalendar; 450 Calendar *mCalendar;
310 QStringList * oldCategories; 451 QStringList * oldCategories;
311 static QString category( const QString &id ) 452 static QString category( const QString &id )
312 { 453 {
313 QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id ); 454 QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id );
314 if ( it == mCategoriesMap.end() ) return id; 455 if ( it == mCategoriesMap.end() ) return id;
315 else return *it; 456 else return *it;
316 } 457 }
317 458
318 static void setCategory( const QString &id, const QString &name ) 459 static void setCategory( const QString &id, const QString &name )
319 { 460 {
320 mCategoriesMap.insert( id, name ); 461 mCategoriesMap.insert( id, name );
321 } 462 }
322 463
323 static QMap<QString,QString> mCategoriesMap; 464 static QMap<QString,QString> mCategoriesMap;
324}; 465};
325 466
326QMap<QString,QString> PhoneParser::mCategoriesMap; 467QMap<QString,QString> PhoneParser::mCategoriesMap;
327 468
328PhoneFormat::PhoneFormat() 469PhoneFormat::PhoneFormat()
329{ 470{
330 mCategories = 0; 471 mCategories = 0;
331} 472}
332 473
333PhoneFormat::~PhoneFormat() 474PhoneFormat::~PhoneFormat()
334{ 475{
335} 476}
336ulong PhoneFormat::getCsum( const QStringList & attList) 477ulong PhoneFormat::getCsum( const QStringList & attList)
337{ 478{
338 int max = attList.count() -1; 479 int max = attList.count() -1;
339 ulong cSum = 0; 480 ulong cSum = 0;
340 int j,k,i; 481 int j,k,i;
341 int add; 482 int add;
342 for ( i = 1; i < max ; ++i ) { 483 for ( i = 1; i < max ; ++i ) {
343 QString s = attList[i]; 484 QString s = attList[i];
344 if ( ! s.isEmpty() ){ 485 if ( ! s.isEmpty() ){
345 j = s.length(); 486 j = s.length();
346 for ( k = 0; k < j; ++k ) { 487 for ( k = 0; k < j; ++k ) {
347 int mul = k +1; 488 int mul = k +1;
348 add = s[k].unicode (); 489 add = s[k].unicode ();
349 if ( k < 16 ) 490 if ( k < 16 )
350 mul = mul * mul; 491 mul = mul * mul;
351 add = add * mul *i*i*i; 492 add = add * mul *i*i*i;
352 cSum += add; 493 cSum += add;
353 } 494 }
354 } 495 }
355 } 496 }
356 return cSum; 497 return cSum;
357 498
358} 499}
359//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); 500//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum);
360#include <stdlib.h> 501#include <stdlib.h>
361#define DEBUGMODE false 502#define DEBUGMODE false
362bool PhoneFormat::load( Calendar *calendar, Calendar *existngCal ) 503bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal ,QString profileName, QString device,QString connection, QString model )
363{ 504{
364 505 mProfileName = profileName;
365 GSM_StateMachines; 506 GSM_StateMachines;
366 qDebug(" load "); 507 qDebug(" load ");
367 s.opened = false; 508 s.opened = false;
368 s.msg = NULL; 509 s.msg = NULL;
369 s.ConfigNum = 0; 510 s.ConfigNum = 0;
370 static char*cp; 511 static char*cp;
371 static INI_Section *cfg = NULL; 512 static INI_Section *cfg = NULL;
372 cfg=GSM_FindGammuRC(); 513 cfg=GSM_FindGammuRC();
373 int i; 514 int i;
374 for (i = 0; i <= MAX_CONFIG_NUM; i++) { 515 for (i = 0; i <= MAX_CONFIG_NUM; i++) {
375 if (cfg!=NULL) { 516 if (cfg!=NULL) {
376 cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false); 517 cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false);
377 if (cp) di.coding = cp; 518 if (cp) di.coding = cp;
378 519
379 s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false); 520 s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false);
380 if (s.Config[i].Localize) { 521 if (s.Config[i].Localize) {
381 s.msg=INI_ReadFile(s.Config[i].Localize, true); 522 s.msg=INI_ReadFile(s.Config[i].Localize, true);
382 } else { 523 } else {
383#if !defined(WIN32) && defined(LOCALE_PATH) 524#if !defined(WIN32) && defined(LOCALE_PATH)
384 locale = setlocale(LC_MESSAGES, NULL); 525 locale = setlocale(LC_MESSAGES, NULL);
385 if (locale != NULL) { 526 if (locale != NULL) {
386 snprintf(locale_file, 200, "%s/gammu_%c%c.txt", 527 snprintf(locale_file, 200, "%s/gammu_%c%c.txt",
387 LOCALE_PATH, 528 LOCALE_PATH,
388 tolower(locale[0]), 529 tolower(locale[0]),
389 tolower(locale[1])); 530 tolower(locale[1]));
390 s.msg = INI_ReadFile(locale_file, true); 531 s.msg = INI_ReadFile(locale_file, true);
391 } 532 }
392#endif 533#endif
393 } 534 }
394 } 535 }
395 536
396 /* Wanted user specific configuration? */ 537 /* Wanted user specific configuration? */
397 538
398 if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; 539 if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break;
399 540
400 s.ConfigNum++; 541 s.ConfigNum++;
401 542
402 /* We want to use only one file descriptor for global and state machine debug output */ 543 /* We want to use only one file descriptor for global and state machine debug output */
403 s.Config[i].UseGlobalDebugFile = true; 544 s.Config[i].UseGlobalDebugFile = true;
404 545
405 546
406 547
407 /* We wanted to read just user specified configuration. */ 548 /* We wanted to read just user specified configuration. */
408 {break;} 549 {break;}
409 } 550 }
410 551
411 552
412 553
413 554
414 int error=GSM_InitConnection(&s,3); 555 int error=GSM_InitConnection(&s,3);
415 556
416 557
417 qDebug(" init %d %d", error, ERR_NONE); 558 qDebug(" init %d %d", error, ERR_NONE);
418 if ( error != ERR_NONE ) 559 if ( error != ERR_NONE )
419 return false; 560 return false;
420 fromString2Cal( calendar, existngCal, &s, "Event" ); 561 // fromString2Cal( calendar, existngCal, &s, "Event" );
421 562 GSM_Phone_Functions*Phone;
422 563 GSM_CalendarEntrynote;
564 bool refresh= true;
565 Phone=s.Phone.Functions;
566 bool gshutdown = false;
567 PhoneParser handler( calendar, profileName );
568 //handler.setCategoriesList( mCategories );
569 int ccc = 0;
570 while (!gshutdown && ccc++ < 10 ) {
571
572 qDebug("count %d ", ccc);
573 error=Phone->GetNextCalendar(&s,&note,refresh);
574 if (error == ERR_EMPTY) break;
575 handler.startElement( existingCal, &note, "Event" );
576 }
423 error=GSM_TerminateConnection(&s); 577 error=GSM_TerminateConnection(&s);
424
425
426#if 0 578#if 0
427 579
428 bool debug = DEBUGMODE; 580 bool debug = DEBUGMODE;
429 //debug = true; 581 //debug = true;
430 QString text; 582 QString text;
431 QString codec = "utf8"; 583 QString codec = "utf8";
432 QLabel status ( i18n("Reading events ..."), 0 ); 584 QLabel status ( i18n("Reading events ..."), 0 );
433 585
434 int w = status.sizeHint().width()+20 ; 586 int w = status.sizeHint().width()+20 ;
435 if ( w < 200 ) w = 200; 587 if ( w < 200 ) w = 200;
436 int h = status.sizeHint().height()+20 ; 588 int h = status.sizeHint().height()+20 ;
437 int dw = QApplication::desktop()->width(); 589 int dw = QApplication::desktop()->width();
438 int dh = QApplication::desktop()->height(); 590 int dh = QApplication::desktop()->height();
439 status.setCaption(i18n("Reading DTM Data") ); 591 status.setCaption(i18n("Reading DTM Data") );
440 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 592 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
441 status.show(); 593 status.show();
442 status.raise(); 594 status.raise();
443 qApp->processEvents(); 595 qApp->processEvents();
444 QString fileName; 596 QString fileName;
445 if ( ! debug ) { 597 if ( ! debug ) {
446 fileName = "/tmp/kopitempout"; 598 fileName = "/tmp/kopitempout";
447 QString command ="db2file datebook -r -c "+ codec + " > " + fileName; 599 QString command ="db2file datebook -r -c "+ codec + " > " + fileName;
448 system ( command.latin1() ); 600 system ( command.latin1() );
449 } else { 601 } else {
450 fileName = "/tmp/events.txt"; 602 fileName = "/tmp/events.txt";
451 603
452 } 604 }
453 QFile file( fileName ); 605 QFile file( fileName );
454 if (!file.open( IO_ReadOnly ) ) { 606 if (!file.open( IO_ReadOnly ) ) {
455 return false; 607 return false;
456 608
457 } 609 }
@@ -1010,64 +1162,65 @@ QString PhoneFormat::getPart( const QString & text, bool &ok, int &start )
1010 //qDebug("retval***%s*** ",retval.latin1() ); 1162 //qDebug("retval***%s*** ",retval.latin1() );
1011 return retval; 1163 return retval;
1012 1164
1013 } else { 1165 } else {
1014 int nl = text.find ("\n",start); 1166 int nl = text.find ("\n",start);
1015 int kom = text.find (',',start); 1167 int kom = text.find (',',start);
1016 if ( kom < nl ) { 1168 if ( kom < nl ) {
1017 // qDebug("kom < nl %d ", kom); 1169 // qDebug("kom < nl %d ", kom);
1018 retval = text.mid(start, kom-start); 1170 retval = text.mid(start, kom-start);
1019 start = kom+1; 1171 start = kom+1;
1020 return retval; 1172 return retval;
1021 } else { 1173 } else {
1022 if ( nl == kom ) { 1174 if ( nl == kom ) {
1023 // qDebug(" nl == kom "); 1175 // qDebug(" nl == kom ");
1024 start = 0; 1176 start = 0;
1025 ok = false; 1177 ok = false;
1026 return "0"; 1178 return "0";
1027 } 1179 }
1028 // qDebug(" nl < kom ", nl); 1180 // qDebug(" nl < kom ", nl);
1029 retval = text.mid( start, nl-start); 1181 retval = text.mid( start, nl-start);
1030 ok = false; 1182 ok = false;
1031 start = nl+1; 1183 start = nl+1;
1032 return retval; 1184 return retval;
1033 } 1185 }
1034 } 1186 }
1035} 1187}
1036bool PhoneFormat::fromString( Calendar *calendar, const QString & text) 1188bool PhoneFormat::fromString( Calendar *calendar, const QString & text)
1037{ 1189{
1038 return false; 1190 return false;
1039} 1191}
1040 bool PhoneFormat::fromString2Cal( Calendar *calendar,Calendar *existingCalendar, GSM_StateMachine*s, const QString & type) 1192 bool PhoneFormat::fromString2Cal( Calendar *calendar,Calendar *existingCalendar, GSM_StateMachine*s, const QString & type)
1041{ 1193{
1194#if 0
1042 GSM_Phone_Functions*Phone; 1195 GSM_Phone_Functions*Phone;
1043 1196
1044 GSM_CalendarEntrynote; 1197 GSM_CalendarEntrynote;
1045 GSM_CalendarEntry*Note; 1198 GSM_CalendarEntry*Note;
1046 bool refresh= true; 1199 bool refresh= true;
1047 1200
1048 Phone=s->Phone.Functions; 1201 Phone=s->Phone.Functions;
1049 bool gshutdown = false; 1202 bool gshutdown = false;
1050 PhoneParser handler( calendar ); 1203 PhoneParser handler( calendar );
1051 //handler.setCategoriesList( mCategories ); 1204 //handler.setCategoriesList( mCategories );
1052 QStringList templist; 1205 QStringList templist;
1053 QString tempString; 1206 QString tempString;
1054 int start = 0; 1207 int start = 0;
1055 int error; 1208 int error;
1056 int ccc = 0; 1209 int ccc = 0;
1057 while (!gshutdown && ccc++ < 10 ) { 1210 while (!gshutdown && ccc++ < 10 ) {
1058 QString CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY; 1211 QString CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY;
1059 templist.clear(); 1212 templist.clear();
1060 qDebug("count %d ", ccc); 1213 qDebug("count %d ", ccc);
1061 error=Phone->GetNextCalendar(s,&note,refresh); 1214 error=Phone->GetNextCalendar(s,&note,refresh);
1062 if (error == ERR_EMPTY) break; 1215 if (error == ERR_EMPTY) break;
1063 1216
1064 Note = &note; 1217 Note = &note;
1065//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY 1218//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY
1066// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1219// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
1067 1220
1068//ARSD silentalarm = 0 1221//ARSD silentalarm = 0
1069// 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly 1222// 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly
1070// 12 RFRQ 1223// 12 RFRQ
1071// 13 RPOS pos = 4. monday in month 1224// 13 RPOS pos = 4. monday in month
1072// 14 RDYS days: 1 mon/ 2 tue .. 64 sun 1225// 14 RDYS days: 1 mon/ 2 tue .. 64 sun
1073// 15 REND 0 = no end/ 1 = end 1226// 15 REND 0 = no end/ 1 = end
@@ -1296,65 +1449,65 @@ typedef struct {
1296 break; 1449 break;
1297 case CAL_REPEAT_FREQUENCY: 1450 case CAL_REPEAT_FREQUENCY:
1298 repeat_frequency = Note->Entries[i].Number; 1451 repeat_frequency = Note->Entries[i].Number;
1299 repeating = true; 1452 repeating = true;
1300 break; 1453 break;
1301 case CAL_REPEAT_STARTDATE: 1454 case CAL_REPEAT_STARTDATE:
1302 repeat_startdate = Note->Entries[i].Date; 1455 repeat_startdate = Note->Entries[i].Date;
1303 repeating = true; 1456 repeating = true;
1304 break; 1457 break;
1305 case CAL_REPEAT_STOPDATE: 1458 case CAL_REPEAT_STOPDATE:
1306 repeat_stopdate = Note->Entries[i].Date; 1459 repeat_stopdate = Note->Entries[i].Date;
1307 repeating = true; 1460 repeating = true;
1308 break; 1461 break;
1309 } 1462 }
1310 } 1463 }
1311 1464
1312 1465
1313 1466
1314 if ( ARON == "0" ) { 1467 if ( ARON == "0" ) {
1315 QDateTime start,alarm; 1468 QDateTime start,alarm;
1316 start = handler.fromString( TIM1 ); 1469 start = handler.fromString( TIM1 );
1317 alarm = handler.fromString( ARMN ); 1470 alarm = handler.fromString( ARMN );
1318 int min = alarm.secsTo ( start )/60; 1471 int min = alarm.secsTo ( start )/60;
1319 ARMN = QString::number ( min ); 1472 ARMN = QString::number ( min );
1320 } 1473 }
1321 1474
1322 templist.clear(); 1475 templist.clear();
1323 templist << CARDID << CATEGORY << DSRP << PLCE << MEM1 << TIM1 << TIM2 << ADAY << ARON << ARMN << ARSD << RTYP << RFRQ << RPOS << RDYS << REND << REDT << ALSD << ALED << MDAY; 1476 templist << CARDID << CATEGORY << DSRP << PLCE << MEM1 << TIM1 << TIM2 << ADAY << ARON << ARMN << ARSD << RTYP << RFRQ << RPOS << RDYS << REND << REDT << ALSD << ALED << MDAY;
1324 handler.startElement( existingCalendar, templist, type ); 1477 handler.startElement( existingCalendar, templist, type );
1325 } 1478 }
1326 1479
1327 1480
1328 1481#endif
1329#if 0 1482#if 0
1330 // qDebug("test %s ", text.latin1()); 1483 // qDebug("test %s ", text.latin1());
1331 QStringList templist; 1484 QStringList templist;
1332 QString tempString; 1485 QString tempString;
1333 int start = 0; 1486 int start = 0;
1334 int len = text.length(); 1487 int len = text.length();
1335 int end = text.find ("\n",start)+1; 1488 int end = text.find ("\n",start)+1;
1336 bool ok = true; 1489 bool ok = true;
1337 start = end; 1490 start = end;
1338 PhoneParser handler( calendar ); 1491 PhoneParser handler( calendar );
1339 handler.setCategoriesList( mCategories ); 1492 handler.setCategoriesList( mCategories );
1340 while ( start > 0 ) { 1493 while ( start > 0 ) {
1341 templist.clear(); 1494 templist.clear();
1342 ok = true; 1495 ok = true;
1343 while ( ok ) { 1496 while ( ok ) {
1344 tempString = getPart( text, ok, start ); 1497 tempString = getPart( text, ok, start );
1345 if ( start >= len || start == 0 ) { 1498 if ( start >= len || start == 0 ) {
1346 start = 0; 1499 start = 0;
1347 ok = false; 1500 ok = false;
1348 } 1501 }
1349 if ( tempString.right(1) =="\n" ) 1502 if ( tempString.right(1) =="\n" )
1350 tempString = tempString.left( tempString.length()-1); 1503 tempString = tempString.left( tempString.length()-1);
1351 //if ( ok ) 1504 //if ( ok )
1352 templist.append( tempString ); 1505 templist.append( tempString );
1353 //qDebug("%d ---%s---", templist.count(),tempString.latin1() ); 1506 //qDebug("%d ---%s---", templist.count(),tempString.latin1() );
1354 } 1507 }
1355 handler.startElement( existingCalendar, templist, type ); 1508 handler.startElement( existingCalendar, templist, type );
1356 } 1509 }
1357#endif 1510#endif
1358 return false; 1511 return false;
1359} 1512}
1360 1513
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h
index 4ddf6f0..4da38c8 100644
--- a/libkcal/phoneformat.h
+++ b/libkcal/phoneformat.h
@@ -13,53 +13,54 @@
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 PHONEFORMAT_H 21#ifndef PHONEFORMAT_H
22#define PHONEFORMAT_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/emb/common/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 Phone. 36 This class implements the calendar format used by Phone.
37*/ 37*/
38 38
39class PhoneFormat : public QObject { 39class PhoneFormat : public QObject {
40 public: 40 public:
41 /** Create new iCalendar format. */ 41 /** Create new iCalendar format. */
42 PhoneFormat(); 42 PhoneFormat();
43 virtual ~PhoneFormat(); 43 virtual ~PhoneFormat();
44 44
45 bool load( Calendar * ,Calendar *); 45 bool load( Calendar * ,Calendar *, QString profileName, QString device,QString connection, QString model );
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 QString mProfileName;
61}; 62};
62 63
63} 64}
64 65
65#endif 66#endif