summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-08-01 12:02:39 (UTC)
committer zautrix <zautrix>2004-08-01 12:02:39 (UTC)
commitc31e99f265dbe8762efca20667f8ccd973840f8f (patch) (unidiff)
tree29e7fd6845d187f41f9d80e756611dc8bc182bdc
parente954cc1e29b129982e4d07c4f490d7e881597374 (diff)
downloadkdepimpi-c31e99f265dbe8762efca20667f8ccd973840f8f.zip
kdepimpi-c31e99f265dbe8762efca20667f8ccd973840f8f.tar.gz
kdepimpi-c31e99f265dbe8762efca20667f8ccd973840f8f.tar.bz2
Changed zaurusstat to tempsyncstat
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp4
-rw-r--r--libkcal/icalformatimpl.cpp8
-rw-r--r--libkcal/incidencebase.cpp12
-rw-r--r--libkcal/incidencebase.h6
-rw-r--r--libkcal/sharpformat.cpp14
5 files changed, 18 insertions, 26 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index fd68dc4..b543eca 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -972,65 +972,65 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
972 if ( !skipIncidence ) { 972 if ( !skipIncidence ) {
973 inL = local->incidence( uid ); 973 inL = local->incidence( uid );
974 if ( inL ) { // maybe conflict - same uid in both calendars 974 if ( inL ) { // maybe conflict - same uid in both calendars
975 int maxrev = inL->revision(); 975 int maxrev = inL->revision();
976 if ( maxrev < inR->revision() ) 976 if ( maxrev < inR->revision() )
977 maxrev = inR->revision(); 977 maxrev = inR->revision();
978 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 978 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
979 //qDebug("take %d %s ", take, inL->summary().latin1()); 979 //qDebug("take %d %s ", take, inL->summary().latin1());
980 if ( take == 3 ) 980 if ( take == 3 )
981 return false; 981 return false;
982 if ( take == 1 ) {// take local 982 if ( take == 1 ) {// take local
983 inL->setZaurusUid( inR->zaurusUid() ); 983 inL->setZaurusUid( inR->zaurusUid() );
984 remote->deleteIncidence( inR ); 984 remote->deleteIncidence( inR );
985 if ( inL->revision() < maxrev ) 985 if ( inL->revision() < maxrev )
986 inL->setRevision( maxrev ); 986 inL->setRevision( maxrev );
987 remote->addIncidence( inL->clone() ); 987 remote->addIncidence( inL->clone() );
988 ++changedRemote; 988 ++changedRemote;
989 } else { 989 } else {
990 if ( inR->revision() < maxrev ) 990 if ( inR->revision() < maxrev )
991 inR->setRevision( maxrev ); 991 inR->setRevision( maxrev );
992 local->deleteIncidence( inL ); 992 local->deleteIncidence( inL );
993 local->addIncidence( inR->clone() ); 993 local->addIncidence( inR->clone() );
994 ++changedLocal; 994 ++changedLocal;
995 } 995 }
996 } 996 }
997 } else { // no conflict 997 } else { // no conflict
998 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 998 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
999 QString des = eventLSync->description(); 999 QString des = eventLSync->description();
1000 QString pref = "e"; 1000 QString pref = "e";
1001 if ( inR->type() == "Todo" ) 1001 if ( inR->type() == "Todo" )
1002 pref = "t"; 1002 pref = "t";
1003 if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it 1003 if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it
1004 inR->setZaurusStat( SYNC_TEMPSTATE_DELETE ); 1004 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1005 //remote->deleteIncidence( inR ); 1005 //remote->deleteIncidence( inR );
1006 ++deletedEventR; 1006 ++deletedEventR;
1007 } else { 1007 } else {
1008 inR->setLastModified( modifiedCalendar ); 1008 inR->setLastModified( modifiedCalendar );
1009 local->addIncidence( inR->clone() ); 1009 local->addIncidence( inR->clone() );
1010 ++addedEvent; 1010 ++addedEvent;
1011 } 1011 }
1012 } else { 1012 } else {
1013 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1013 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1014 inR->setLastModified( modifiedCalendar ); 1014 inR->setLastModified( modifiedCalendar );
1015 local->addIncidence( inR->clone() ); 1015 local->addIncidence( inR->clone() );
1016 ++addedEvent; 1016 ++addedEvent;
1017 } else { 1017 } else {
1018 checkSharpEvent(eventRSyncSharp, inR); 1018 checkSharpEvent(eventRSyncSharp, inR);
1019 remote->deleteIncidence( inR ); 1019 remote->deleteIncidence( inR );
1020 ++deletedEventR; 1020 ++deletedEventR;
1021 } 1021 }
1022 } 1022 }
1023 } 1023 }
1024 } 1024 }
1025 inR = er.next(); 1025 inR = er.next();
1026 } 1026 }
1027 QPtrList<Incidence> el = local->rawIncidences(); 1027 QPtrList<Incidence> el = local->rawIncidences();
1028 inL = el.first(); 1028 inL = el.first();
1029 modulo = (el.count()/10)+1; 1029 modulo = (el.count()/10)+1;
1030 bar.setCaption (i18n("Add / remove events") ); 1030 bar.setCaption (i18n("Add / remove events") );
1031 bar.setTotalSteps ( el.count() ) ; 1031 bar.setTotalSteps ( el.count() ) ;
1032 bar.show(); 1032 bar.show();
1033 incCounter = 0; 1033 incCounter = 0;
1034 1034
1035 while ( inL ) { 1035 while ( inL ) {
1036 1036
@@ -1142,65 +1142,65 @@ void CalendarView::syncSharp()
1142#ifndef DESKTOP_VERSION 1142#ifndef DESKTOP_VERSION
1143 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1143 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1144 //mCurrentSyncDevice = "sharp-DTM"; 1144 //mCurrentSyncDevice = "sharp-DTM";
1145 if ( KOPrefs::instance()->mAskForPreferences ) 1145 if ( KOPrefs::instance()->mAskForPreferences )
1146 edit_sync_options(); 1146 edit_sync_options();
1147 qApp->processEvents(); 1147 qApp->processEvents();
1148 CalendarLocal* calendar = new CalendarLocal(); 1148 CalendarLocal* calendar = new CalendarLocal();
1149 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1149 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1150 bool syncOK = false; 1150 bool syncOK = false;
1151 SharpFormat sharpFormat; 1151 SharpFormat sharpFormat;
1152 if ( sharpFormat.load( calendar, mCalendar ) ) { 1152 if ( sharpFormat.load( calendar, mCalendar ) ) {
1153 getEventViewerDialog()->setSyncMode( true ); 1153 getEventViewerDialog()->setSyncMode( true );
1154 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1154 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1155 getEventViewerDialog()->setSyncMode( false ); 1155 getEventViewerDialog()->setSyncMode( false );
1156 qApp->processEvents(); 1156 qApp->processEvents();
1157 if ( syncOK ) { 1157 if ( syncOK ) {
1158 if ( KOPrefs::instance()->mWriteBackFile ) 1158 if ( KOPrefs::instance()->mWriteBackFile )
1159 { 1159 {
1160 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1160 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1161 Incidence* inc = iL.first(); 1161 Incidence* inc = iL.first();
1162 /* obsolete 1162 /* obsolete
1163 while ( inc ) { 1163 while ( inc ) {
1164 inc->setZaurusStat( inc->revision () ); 1164 inc->setZaurusStat( inc->revision () );
1165 inc = iL.next(); 1165 inc = iL.next();
1166 } 1166 }
1167 */ 1167 */
1168 // pending: clean last sync event description 1168 // pending: clean last sync event description
1169 sharpFormat.save(calendar); 1169 sharpFormat.save(calendar);
1170 iL = calendar->rawIncidences(); 1170 iL = calendar->rawIncidences();
1171 inc = iL.first(); 1171 inc = iL.first();
1172 Incidence* loc; 1172 Incidence* loc;
1173 while ( inc ) { 1173 while ( inc ) {
1174 if ( inc->zaurusStat() == SYNC_TEMPSTATE_NEW_ID ) { 1174 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1175 loc = mCalendar->incidence(inc->uid() ); 1175 loc = mCalendar->incidence(inc->uid() );
1176 if ( loc ) { 1176 if ( loc ) {
1177 loc->setZaurusId( inc->zaurusId() ); 1177 loc->setZaurusId( inc->zaurusId() );
1178 loc->setZaurusUid( inc->zaurusUid() ); 1178 loc->setZaurusUid( inc->zaurusUid() );
1179 } 1179 }
1180 } 1180 }
1181 inc = iL.next(); 1181 inc = iL.next();
1182 } 1182 }
1183 Incidence* lse = getLastSyncEvent(); 1183 Incidence* lse = getLastSyncEvent();
1184 if ( lse ) { 1184 if ( lse ) {
1185 lse->setReadOnly( false ); 1185 lse->setReadOnly( false );
1186 lse->setDescription( "" ); 1186 lse->setDescription( "" );
1187 lse->setReadOnly( true ); 1187 lse->setReadOnly( true );
1188 } 1188 }
1189 } 1189 }
1190 } 1190 }
1191 setModified( true ); 1191 setModified( true );
1192 } else { 1192 } else {
1193 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1193 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1194 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1194 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1195 question, i18n("Ok")) ; 1195 question, i18n("Ok")) ;
1196 1196
1197 } 1197 }
1198 delete calendar; 1198 delete calendar;
1199 updateView(); 1199 updateView();
1200 return ;//syncOK; 1200 return ;//syncOK;
1201#endif 1201#endif
1202} 1202}
1203 1203
1204 1204
1205#include <kabc/stdaddressbook.h> 1205#include <kabc/stdaddressbook.h>
1206bool CalendarView::importBday() 1206bool CalendarView::importBday()
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp
index 3437f45..df05ab3 100644
--- a/libkcal/icalformatimpl.cpp
+++ b/libkcal/icalformatimpl.cpp
@@ -245,67 +245,64 @@ icalcomponent *ICalFormatImpl::writeJournal(Journal *journal)
245 245
246 // start time 246 // start time
247 if (journal->dtStart().isValid()) { 247 if (journal->dtStart().isValid()) {
248 icaltimetype start; 248 icaltimetype start;
249 if (journal->doesFloat()) { 249 if (journal->doesFloat()) {
250// kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; 250// kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl;
251 start = writeICalDate(journal->dtStart().date()); 251 start = writeICalDate(journal->dtStart().date());
252 } else { 252 } else {
253// kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; 253// kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl;
254 start = writeICalDateTime(journal->dtStart()); 254 start = writeICalDateTime(journal->dtStart());
255 } 255 }
256 icalcomponent_add_property(vjournal,icalproperty_new_dtstart(start)); 256 icalcomponent_add_property(vjournal,icalproperty_new_dtstart(start));
257 } 257 }
258 258
259 return vjournal; 259 return vjournal;
260} 260}
261 261
262void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) 262void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence)
263{ 263{
264 // pilot sync stuff 264 // pilot sync stuff
265// TODO: move this application-specific code to kpilot 265// TODO: move this application-specific code to kpilot
266 if (incidence->pilotId()) { 266 if (incidence->pilotId()) {
267 incidence->setNonKDECustomProperty("X-PILOTID", QString::number(incidence->pilotId())); 267 incidence->setNonKDECustomProperty("X-PILOTID", QString::number(incidence->pilotId()));
268 incidence->setNonKDECustomProperty("X-PILOTSTAT", QString::number(incidence->syncStatus())); 268 incidence->setNonKDECustomProperty("X-PILOTSTAT", QString::number(incidence->syncStatus()));
269 } 269 }
270 if (incidence->zaurusId() >= 0) { 270 if (incidence->zaurusId() >= 0) {
271 incidence->setNonKDECustomProperty("X-ZAURUSID", QString::number(incidence->zaurusId())); 271 incidence->setNonKDECustomProperty("X-ZAURUSID", QString::number(incidence->zaurusId()));
272 } 272 }
273 273
274 if (incidence->zaurusUid() > 0) { 274 if (incidence->zaurusUid() > 0) {
275 incidence->setNonKDECustomProperty("X-ZAURUSUID", QString::number(incidence->zaurusUid())); 275 incidence->setNonKDECustomProperty("X-ZAURUSUID", QString::number(incidence->zaurusUid()));
276 } 276 }
277 if (incidence->zaurusStat() > 0) {
278 incidence->setNonKDECustomProperty("X-ZAURUSSTAT", QString::number(incidence->zaurusStat()));
279 }
280 277
281 writeIncidenceBase(parent,incidence); 278 writeIncidenceBase(parent,incidence);
282 if (incidence->cancelled()) { 279 if (incidence->cancelled()) {
283 icalcomponent_add_property(parent,icalproperty_new_status(ICAL_STATUS_CANCELLED)); 280 icalcomponent_add_property(parent,icalproperty_new_status(ICAL_STATUS_CANCELLED));
284 } 281 }
285 282
286 // creation date 283 // creation date
287 icalcomponent_add_property(parent,icalproperty_new_created( 284 icalcomponent_add_property(parent,icalproperty_new_created(
288 writeICalDateTime(incidence->created()))); 285 writeICalDateTime(incidence->created())));
289 286
290 // unique id 287 // unique id
291 icalcomponent_add_property(parent,icalproperty_new_uid( 288 icalcomponent_add_property(parent,icalproperty_new_uid(
292 incidence->uid().utf8())); 289 incidence->uid().utf8()));
293 290
294 // revision 291 // revision
295 icalcomponent_add_property(parent,icalproperty_new_sequence( 292 icalcomponent_add_property(parent,icalproperty_new_sequence(
296 incidence->revision())); 293 incidence->revision()));
297 294
298 // last modification date 295 // last modification date
299 icalcomponent_add_property(parent,icalproperty_new_lastmodified( 296 icalcomponent_add_property(parent,icalproperty_new_lastmodified(
300 writeICalDateTime(incidence->lastModified()))); 297 writeICalDateTime(incidence->lastModified())));
301 298
302 // description 299 // description
303 if (!incidence->description().isEmpty()) { 300 if (!incidence->description().isEmpty()) {
304 icalcomponent_add_property(parent,icalproperty_new_description( 301 icalcomponent_add_property(parent,icalproperty_new_description(
305 incidence->description().utf8())); 302 incidence->description().utf8()));
306 } 303 }
307 304
308 // summary 305 // summary
309 if (!incidence->summary().isEmpty()) { 306 if (!incidence->summary().isEmpty()) {
310 icalcomponent_add_property(parent,icalproperty_new_summary( 307 icalcomponent_add_property(parent,icalproperty_new_summary(
311 incidence->summary().utf8())); 308 incidence->summary().utf8()));
@@ -1264,69 +1261,64 @@ void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence)
1264 1261
1265 default: 1262 default:
1266// kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind 1263// kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind
1267// << endl; 1264// << endl;
1268 break; 1265 break;
1269 } 1266 }
1270 1267
1271 p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); 1268 p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY);
1272 } 1269 }
1273 if ( readrec ) { 1270 if ( readrec ) {
1274 readRecurrenceRule(rectype,incidence); 1271 readRecurrenceRule(rectype,incidence);
1275 } 1272 }
1276 // kpilot stuff 1273 // kpilot stuff
1277// TODO: move this application-specific code to kpilot 1274// TODO: move this application-specific code to kpilot
1278 QString kp = incidence->nonKDECustomProperty("X-PILOTID"); 1275 QString kp = incidence->nonKDECustomProperty("X-PILOTID");
1279 if (!kp.isNull()) { 1276 if (!kp.isNull()) {
1280 incidence->setPilotId(kp.toInt()); 1277 incidence->setPilotId(kp.toInt());
1281 } 1278 }
1282 kp = incidence->nonKDECustomProperty("X-PILOTSTAT"); 1279 kp = incidence->nonKDECustomProperty("X-PILOTSTAT");
1283 if (!kp.isNull()) { 1280 if (!kp.isNull()) {
1284 incidence->setSyncStatus(kp.toInt()); 1281 incidence->setSyncStatus(kp.toInt());
1285 } 1282 }
1286 kp = incidence->nonKDECustomProperty("X-ZAURUSID"); 1283 kp = incidence->nonKDECustomProperty("X-ZAURUSID");
1287 if (!kp.isNull()) { 1284 if (!kp.isNull()) {
1288 incidence->setZaurusId(kp.toInt()); 1285 incidence->setZaurusId(kp.toInt());
1289 } 1286 }
1290 1287
1291 kp = incidence->nonKDECustomProperty("X-ZAURUSUID"); 1288 kp = incidence->nonKDECustomProperty("X-ZAURUSUID");
1292 if (!kp.isNull()) { 1289 if (!kp.isNull()) {
1293 incidence->setZaurusUid(kp.toInt()); 1290 incidence->setZaurusUid(kp.toInt());
1294 } 1291 }
1295 1292
1296 kp = incidence->nonKDECustomProperty("X-ZAURUSSTAT");
1297 if (!kp.isNull()) {
1298 incidence->setZaurusStat(kp.toInt());
1299 }
1300
1301 // Cancel backwards compatibility mode for subsequent changes by the application 1293 // Cancel backwards compatibility mode for subsequent changes by the application
1302 incidence->recurrence()->setCompatVersion(); 1294 incidence->recurrence()->setCompatVersion();
1303 1295
1304 // add categories 1296 // add categories
1305 incidence->setCategories(categories); 1297 incidence->setCategories(categories);
1306 1298
1307 // iterate through all alarms 1299 // iterate through all alarms
1308 for (icalcomponent *alarm = icalcomponent_get_first_component(parent,ICAL_VALARM_COMPONENT); 1300 for (icalcomponent *alarm = icalcomponent_get_first_component(parent,ICAL_VALARM_COMPONENT);
1309 alarm; 1301 alarm;
1310 alarm = icalcomponent_get_next_component(parent,ICAL_VALARM_COMPONENT)) { 1302 alarm = icalcomponent_get_next_component(parent,ICAL_VALARM_COMPONENT)) {
1311 readAlarm(alarm,incidence); 1303 readAlarm(alarm,incidence);
1312 } 1304 }
1313} 1305}
1314 1306
1315void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) 1307void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase)
1316{ 1308{
1317 icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); 1309 icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY);
1318 1310
1319 while (p) { 1311 while (p) {
1320 icalproperty_kind kind = icalproperty_isa(p); 1312 icalproperty_kind kind = icalproperty_isa(p);
1321 switch (kind) { 1313 switch (kind) {
1322 1314
1323 case ICAL_UID_PROPERTY: // unique id 1315 case ICAL_UID_PROPERTY: // unique id
1324 incidenceBase->setUid(QString::fromUtf8(icalproperty_get_uid(p))); 1316 incidenceBase->setUid(QString::fromUtf8(icalproperty_get_uid(p)));
1325 break; 1317 break;
1326 1318
1327 case ICAL_ORGANIZER_PROPERTY: // organizer 1319 case ICAL_ORGANIZER_PROPERTY: // organizer
1328 incidenceBase->setOrganizer(QString::fromUtf8(icalproperty_get_organizer(p))); 1320 incidenceBase->setOrganizer(QString::fromUtf8(icalproperty_get_organizer(p)));
1329 break; 1321 break;
1330 1322
1331 case ICAL_ATTENDEE_PROPERTY: // attendee 1323 case ICAL_ATTENDEE_PROPERTY: // attendee
1332 incidenceBase->addAttendee(readAttendee(p)); 1324 incidenceBase->addAttendee(readAttendee(p));
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 9479048..707d666 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -11,88 +11,88 @@
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <kglobal.h> 21#include <kglobal.h>
22#include <klocale.h> 22#include <klocale.h>
23#include <kdebug.h> 23#include <kdebug.h>
24 24
25#include "calformat.h" 25#include "calformat.h"
26 26
27#include "incidencebase.h" 27#include "incidencebase.h"
28 28
29using namespace KCal; 29using namespace KCal;
30 30
31IncidenceBase::IncidenceBase() : 31IncidenceBase::IncidenceBase() :
32 mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), 32 mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false),
33 mPilotId(0), mSyncStatus(SYNCMOD) 33 mPilotId(0), mSyncStatus(SYNCMOD)
34{ 34{
35 setUid(CalFormat::createUniqueId()); 35 setUid(CalFormat::createUniqueId());
36 mOrganizer = ""; 36 mOrganizer = "";
37 mFloats = false; 37 mFloats = false;
38 mDuration = 0; 38 mDuration = 0;
39 mHasDuration = false; 39 mHasDuration = false;
40 mPilotId = 0; 40 mPilotId = 0;
41 mZaurusId = -1; 41 mZaurusId = -1;
42 mZaurusUid = 0; 42 mZaurusUid = 0;
43 mZaurusStat = 0; 43 mTempSyncStat = 0;
44 mSyncStatus = 0; 44 mSyncStatus = 0;
45 mAttendees.setAutoDelete( true ); 45 mAttendees.setAutoDelete( true );
46} 46}
47 47
48IncidenceBase::IncidenceBase(const IncidenceBase &i) : 48IncidenceBase::IncidenceBase(const IncidenceBase &i) :
49 CustomProperties( i ) 49 CustomProperties( i )
50{ 50{
51 mReadOnly = i.mReadOnly; 51 mReadOnly = i.mReadOnly;
52 mDtStart = i.mDtStart; 52 mDtStart = i.mDtStart;
53 mDuration = i.mDuration; 53 mDuration = i.mDuration;
54 mHasDuration = i.mHasDuration; 54 mHasDuration = i.mHasDuration;
55 mOrganizer = i.mOrganizer; 55 mOrganizer = i.mOrganizer;
56 mUid = i.mUid; 56 mUid = i.mUid;
57 QPtrList<Attendee> attendees = i.attendees(); 57 QPtrList<Attendee> attendees = i.attendees();
58 for( Attendee *a = attendees.first(); a; a = attendees.next() ) { 58 for( Attendee *a = attendees.first(); a; a = attendees.next() ) {
59 mAttendees.append( new Attendee( *a ) ); 59 mAttendees.append( new Attendee( *a ) );
60 } 60 }
61 mFloats = i.mFloats; 61 mFloats = i.mFloats;
62 mLastModified = i.mLastModified; 62 mLastModified = i.mLastModified;
63 mPilotId = i.mPilotId; 63 mPilotId = i.mPilotId;
64 mZaurusId = i.mZaurusId; 64 mZaurusId = i.mZaurusId;
65 mZaurusUid = i.mZaurusUid; 65 mZaurusUid = i.mZaurusUid;
66 mZaurusStat = i.mZaurusStat; 66 mTempSyncStat = i.mTempSyncStat;
67 mSyncStatus = i.mSyncStatus; 67 mSyncStatus = i.mSyncStatus;
68 68
69 // The copied object is a new one, so it isn't observed by the observer 69 // The copied object is a new one, so it isn't observed by the observer
70 // of the original object. 70 // of the original object.
71 mObservers.clear(); 71 mObservers.clear();
72 72
73 mAttendees.setAutoDelete( true ); 73 mAttendees.setAutoDelete( true );
74} 74}
75 75
76IncidenceBase::~IncidenceBase() 76IncidenceBase::~IncidenceBase()
77{ 77{
78} 78}
79 79
80 80
81bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) 81bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 )
82{ 82{
83 83
84 if( i1.attendees().count() != i2.attendees().count() ) { 84 if( i1.attendees().count() != i2.attendees().count() ) {
85 return false; // no need to check further 85 return false; // no need to check further
86 } 86 }
87 if ( i1.attendees().count() > 0 ) { 87 if ( i1.attendees().count() > 0 ) {
88 Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; 88 Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ;
89 while ( a1 ) { 89 while ( a1 ) {
90 if ( !( (*a1) == (*a2)) ) 90 if ( !( (*a1) == (*a2)) )
91 { 91 {
92 //qDebug("Attendee not equal "); 92 //qDebug("Attendee not equal ");
93 return false; 93 return false;
94 } 94 }
95 a1 = i1.attendees().next(); 95 a1 = i1.attendees().next();
96 a2 = i2.attendees().next(); 96 a2 = i2.attendees().next();
97 } 97 }
98 } 98 }
@@ -333,61 +333,61 @@ int IncidenceBase::syncStatus() const
333 333
334void IncidenceBase::setPilotId( int id ) 334void IncidenceBase::setPilotId( int id )
335{ 335{
336 if (mReadOnly) return; 336 if (mReadOnly) return;
337 mPilotId = id; 337 mPilotId = id;
338} 338}
339 339
340int IncidenceBase::pilotId() const 340int IncidenceBase::pilotId() const
341{ 341{
342 return mPilotId; 342 return mPilotId;
343} 343}
344void IncidenceBase::setZaurusId( int id ) 344void IncidenceBase::setZaurusId( int id )
345{ 345{
346 if (mReadOnly) return; 346 if (mReadOnly) return;
347 mZaurusId = id; 347 mZaurusId = id;
348} 348}
349 349
350int IncidenceBase::zaurusId() const 350int IncidenceBase::zaurusId() const
351{ 351{
352 return mZaurusId; 352 return mZaurusId;
353} 353}
354 354
355int IncidenceBase::zaurusUid() const 355int IncidenceBase::zaurusUid() const
356{ 356{
357 return mZaurusUid; 357 return mZaurusUid;
358} 358}
359void IncidenceBase::setZaurusUid( int id ) 359void IncidenceBase::setZaurusUid( int id )
360{ 360{
361 if (mReadOnly) return; 361 if (mReadOnly) return;
362 mZaurusUid = id; 362 mZaurusUid = id;
363} 363}
364 364
365int IncidenceBase::zaurusStat() const 365int IncidenceBase::tempSyncStat() const
366{ 366{
367 return mZaurusStat; 367 return mTempSyncStat;
368} 368}
369void IncidenceBase::setZaurusStat( int id ) 369void IncidenceBase::setTempSyncStat( int id )
370{ 370{
371 if (mReadOnly) return; 371 if (mReadOnly) return;
372 mZaurusStat = id; 372 mTempSyncStat = id;
373} 373}
374 374
375void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) 375void IncidenceBase::registerObserver( IncidenceBase::Observer *observer )
376{ 376{
377 if( !mObservers.contains(observer) ) mObservers.append( observer ); 377 if( !mObservers.contains(observer) ) mObservers.append( observer );
378} 378}
379 379
380void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) 380void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer )
381{ 381{
382 mObservers.remove( observer ); 382 mObservers.remove( observer );
383} 383}
384 384
385void IncidenceBase::updated() 385void IncidenceBase::updated()
386{ 386{
387 QPtrListIterator<Observer> it(mObservers); 387 QPtrListIterator<Observer> it(mObservers);
388 while( it.current() ) { 388 while( it.current() ) {
389 Observer *o = it.current(); 389 Observer *o = it.current();
390 ++it; 390 ++it;
391 o->incidenceUpdated( this ); 391 o->incidenceUpdated( this );
392 } 392 }
393} 393}
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index 0ab7eef..ce6e254 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -101,70 +101,70 @@ class IncidenceBase : public CustomProperties
101 Attendee object. 101 Attendee object.
102 */ 102 */
103 void addAttendee(Attendee *a, bool doupdate=true ); 103 void addAttendee(Attendee *a, bool doupdate=true );
104// void removeAttendee(Attendee *a); 104// void removeAttendee(Attendee *a);
105// void removeAttendee(const char *n); 105// void removeAttendee(const char *n);
106 /** Remove all Attendees. */ 106 /** Remove all Attendees. */
107 void clearAttendees(); 107 void clearAttendees();
108 /** Return list of attendees. */ 108 /** Return list of attendees. */
109 QPtrList<Attendee> attendees() const { return mAttendees; }; 109 QPtrList<Attendee> attendees() const { return mAttendees; };
110 /** Return number of attendees. */ 110 /** Return number of attendees. */
111 int attendeeCount() const { return mAttendees.count(); }; 111 int attendeeCount() const { return mAttendees.count(); };
112 /** Return the Attendee with this email */ 112 /** Return the Attendee with this email */
113 Attendee* attendeeByMail(const QString &); 113 Attendee* attendeeByMail(const QString &);
114 /** Return first Attendee with one of this emails */ 114 /** Return first Attendee with one of this emails */
115 Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null); 115 Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null);
116 116
117 /** pilot syncronization states */ 117 /** pilot syncronization states */
118 enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 }; 118 enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 };
119 /** Set synchronisation satus. */ 119 /** Set synchronisation satus. */
120 void setSyncStatus(int stat); 120 void setSyncStatus(int stat);
121 /** Return synchronisation status. */ 121 /** Return synchronisation status. */
122 int syncStatus() const; 122 int syncStatus() const;
123 123
124 /** Set Pilot Id. */ 124 /** Set Pilot Id. */
125 void setPilotId(int id); 125 void setPilotId(int id);
126 /** Return Pilot Id. */ 126 /** Return Pilot Id. */
127 int pilotId() const; 127 int pilotId() const;
128 128
129 void setZaurusId(int id); 129 void setZaurusId(int id);
130 int zaurusId() const; 130 int zaurusId() const;
131 void setZaurusUid(int id); 131 void setZaurusUid(int id);
132 int zaurusUid() const; 132 int zaurusUid() const;
133 void setZaurusStat(int id); 133 void setTempSyncStat(int id);
134 int zaurusStat() const; 134 int tempSyncStat() const;
135 135
136 void registerObserver( Observer * ); 136 void registerObserver( Observer * );
137 void unRegisterObserver( Observer * ); 137 void unRegisterObserver( Observer * );
138 void updated(); 138 void updated();
139 139
140 protected: 140 protected:
141 bool mReadOnly; 141 bool mReadOnly;
142 QDateTime getEvenTime( QDateTime ); 142 QDateTime getEvenTime( QDateTime );
143 143
144 private: 144 private:
145 // base components 145 // base components
146 QDateTime mDtStart; 146 QDateTime mDtStart;
147 QString mOrganizer; 147 QString mOrganizer;
148 QString mUid; 148 QString mUid;
149 QDateTime mLastModified; 149 QDateTime mLastModified;
150 QPtrList<Attendee> mAttendees; 150 QPtrList<Attendee> mAttendees;
151 151
152 bool mFloats; 152 bool mFloats;
153 153
154 int mDuration; 154 int mDuration;
155 bool mHasDuration; 155 bool mHasDuration;
156 int mZaurusId; 156 int mZaurusId;
157 int mZaurusUid; 157 int mZaurusUid;
158 int mZaurusStat; 158 int mTempSyncStat;
159 159
160 // PILOT SYNCHRONIZATION STUFF 160 // PILOT SYNCHRONIZATION STUFF
161 int mPilotId; // unique id for pilot sync 161 int mPilotId; // unique id for pilot sync
162 int mSyncStatus; // status (for sync) 162 int mSyncStatus; // status (for sync)
163 163
164 QPtrList<Observer> mObservers; 164 QPtrList<Observer> mObservers;
165}; 165};
166 166
167bool operator==( const IncidenceBase&, const IncidenceBase& ); 167bool operator==( const IncidenceBase&, const IncidenceBase& );
168} 168}
169 169
170#endif 170#endif
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp
index 973f19d..d39d2dd 100644
--- a/libkcal/sharpformat.cpp
+++ b/libkcal/sharpformat.cpp
@@ -63,65 +63,65 @@ using namespace KCal;
63class SharpParser : public QObject 63class SharpParser : public QObject
64{ 64{
65 public: 65 public:
66 SharpParser( Calendar *calendar ) : mCalendar( calendar ) { 66 SharpParser( Calendar *calendar ) : mCalendar( calendar ) {
67 oldCategories = 0; 67 oldCategories = 0;
68 } 68 }
69 69
70 bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName ) 70 bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName )
71 { 71 {
72 int i = 1; 72 int i = 1;
73 bool skip = true; 73 bool skip = true;
74 int max = attList.count() -2; 74 int max = attList.count() -2;
75 while ( i < max ) { 75 while ( i < max ) {
76 if ( !attList[i].isEmpty() ) { 76 if ( !attList[i].isEmpty() ) {
77 skip = false; 77 skip = false;
78 break; 78 break;
79 } 79 }
80 ++i ; 80 ++i ;
81 } 81 }
82 if ( skip ) 82 if ( skip )
83 return false; 83 return false;
84 ulong cSum = SharpFormat::getCsum(attList ); 84 ulong cSum = SharpFormat::getCsum(attList );
85 85
86 if ( qName == "Event" ) { 86 if ( qName == "Event" ) {
87 Event *event; 87 Event *event;
88 event = existingCalendar->event( attList[0].toInt() ); 88 event = existingCalendar->event( attList[0].toInt() );
89 if ( event ) 89 if ( event )
90 event = (Event*)event->clone(); 90 event = (Event*)event->clone();
91 else 91 else
92 event = new Event; 92 event = new Event;
93 event->setZaurusId( attList[0].toInt() ); 93 event->setZaurusId( attList[0].toInt() );
94 event->setZaurusUid( cSum ); 94 event->setZaurusUid( cSum );
95 event->setZaurusStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); 95 event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL );
96 96
97 event->setSummary( attList[2] ); 97 event->setSummary( attList[2] );
98 event->setLocation( attList[3] ); 98 event->setLocation( attList[3] );
99 event->setDescription( attList[4] ); 99 event->setDescription( attList[4] );
100 if ( attList[7] == "1" ) { 100 if ( attList[7] == "1" ) {
101 event->setDtStart( QDateTime(fromString( attList[17]+"000000", false ).date(),QTime(0,0,0 ) )); 101 event->setDtStart( QDateTime(fromString( attList[17]+"000000", false ).date(),QTime(0,0,0 ) ));
102 event->setDtEnd( QDateTime(fromString( attList[18]+"000000", false ).date(),QTime(0,0,0 ))); 102 event->setDtEnd( QDateTime(fromString( attList[18]+"000000", false ).date(),QTime(0,0,0 )));
103 event->setFloats( true ); 103 event->setFloats( true );
104 } else { 104 } else {
105 event->setFloats( false ); 105 event->setFloats( false );
106 event->setDtStart( fromString( attList[5] ) ); 106 event->setDtStart( fromString( attList[5] ) );
107 event->setDtEnd( fromString( attList[6] )); 107 event->setDtEnd( fromString( attList[6] ));
108 } 108 }
109 109
110 QString rtype = attList[11]; 110 QString rtype = attList[11];
111 if ( rtype != "255" ) { 111 if ( rtype != "255" ) {
112 // qDebug("recurs "); 112 // qDebug("recurs ");
113 QDate startDate = event->dtStart().date(); 113 QDate startDate = event->dtStart().date();
114 114
115 QString freqStr = attList[12]; 115 QString freqStr = attList[12];
116 int freq = freqStr.toInt(); 116 int freq = freqStr.toInt();
117 117
118 QString hasEndDateStr = attList[15] ; 118 QString hasEndDateStr = attList[15] ;
119 bool hasEndDate = hasEndDateStr == "1"; 119 bool hasEndDate = hasEndDateStr == "1";
120 120
121 QString endDateStr = attList[16]; 121 QString endDateStr = attList[16];
122 QDate endDate = fromString( endDateStr ).date(); 122 QDate endDate = fromString( endDateStr ).date();
123 123
124 QString weekDaysStr = attList[14]; 124 QString weekDaysStr = attList[14];
125 uint weekDaysNum = weekDaysStr.toInt(); 125 uint weekDaysNum = weekDaysStr.toInt();
126 126
127 QBitArray weekDays( 7 ); 127 QBitArray weekDays( 7 );
@@ -174,65 +174,65 @@ class SharpParser : public QObject
174 if ( attList[8] == "0" ) { 174 if ( attList[8] == "0" ) {
175 Alarm *alarm; 175 Alarm *alarm;
176 if ( event->alarms().count() > 0 ) 176 if ( event->alarms().count() > 0 )
177 alarm = event->alarms().first(); 177 alarm = event->alarms().first();
178 else { 178 else {
179 alarm = new Alarm( event ); 179 alarm = new Alarm( event );
180 event->addAlarm( alarm ); 180 event->addAlarm( alarm );
181 } 181 }
182 alarm->setType( Alarm::Audio ); 182 alarm->setType( Alarm::Audio );
183 alarm->setEnabled( true ); 183 alarm->setEnabled( true );
184 int alarmOffset = attList[9].toInt(); 184 int alarmOffset = attList[9].toInt();
185 alarm->setStartOffset( alarmOffset * -60 ); 185 alarm->setStartOffset( alarmOffset * -60 );
186 } 186 }
187 187
188 mCalendar->addEvent( event); 188 mCalendar->addEvent( event);
189 } else if ( qName == "Todo" ) { 189 } else if ( qName == "Todo" ) {
190 Todo *todo; 190 Todo *todo;
191 191
192 todo = existingCalendar->todo( attList[0].toInt() ); 192 todo = existingCalendar->todo( attList[0].toInt() );
193 if (todo ) 193 if (todo )
194 todo = (Todo*)todo->clone(); 194 todo = (Todo*)todo->clone();
195 else 195 else
196 todo = new Todo; 196 todo = new Todo;
197 197
198//CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 198//CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1
199// 0 1 2 3 4 5 6 7 8 199// 0 1 2 3 4 5 6 7 8
200//1,,,,,1,4,Loch zumachen,"" 200//1,,,,,1,4,Loch zumachen,""
201//3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " 201//3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" "
202//2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes 202//2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes
203 203
204 todo->setZaurusId( attList[0].toInt() ); 204 todo->setZaurusId( attList[0].toInt() );
205 todo->setZaurusUid( cSum ); 205 todo->setZaurusUid( cSum );
206 todo->setZaurusStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 206 todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
207 207
208 todo->setSummary( attList[7] ); 208 todo->setSummary( attList[7] );
209 todo->setDescription( attList[8]); 209 todo->setDescription( attList[8]);
210 210
211 int priority = attList[6].toInt(); 211 int priority = attList[6].toInt();
212 if ( priority == 0 ) priority = 3; 212 if ( priority == 0 ) priority = 3;
213 todo->setPriority( priority ); 213 todo->setPriority( priority );
214 214
215 QString categoryList = attList[1]; 215 QString categoryList = attList[1];
216 todo->setCategories( lookupCategories( categoryList ) ); 216 todo->setCategories( lookupCategories( categoryList ) );
217 217
218 218
219 219
220 QString hasDateStr = attList[3]; // due 220 QString hasDateStr = attList[3]; // due
221 if ( !hasDateStr.isEmpty() ) { 221 if ( !hasDateStr.isEmpty() ) {
222 if ( hasDateStr.right(6) == "000000" ) { 222 if ( hasDateStr.right(6) == "000000" ) {
223 todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); 223 todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) );
224 todo->setFloats( true ); 224 todo->setFloats( true );
225 } 225 }
226 else { 226 else {
227 todo->setDtDue( fromString( hasDateStr ) ); 227 todo->setDtDue( fromString( hasDateStr ) );
228 todo->setFloats( false ); 228 todo->setFloats( false );
229 } 229 }
230 230
231 todo->setHasDueDate( true ); 231 todo->setHasDueDate( true );
232 } 232 }
233 hasDateStr = attList[2];//start 233 hasDateStr = attList[2];//start
234 if ( !hasDateStr.isEmpty() ) { 234 if ( !hasDateStr.isEmpty() ) {
235 235
236 todo->setDtStart( fromString( hasDateStr ) ); 236 todo->setDtStart( fromString( hasDateStr ) );
237 todo->setHasStartDate( true); 237 todo->setHasStartDate( true);
238 } else 238 } else
@@ -439,108 +439,108 @@ int SharpFormat::getNumFromRecord( QString answer, Incidence* inc )
439 while ( start > 0 ) { 439 while ( start > 0 ) {
440 templist.clear(); 440 templist.clear();
441 ok = true; 441 ok = true;
442 int loopCount = 0; 442 int loopCount = 0;
443 while ( ok ) { 443 while ( ok ) {
444 ++loopCount; 444 ++loopCount;
445 if ( loopCount > 25 ) { 445 if ( loopCount > 25 ) {
446 qDebug("KO: Error in while loop"); 446 qDebug("KO: Error in while loop");
447 ok = false; 447 ok = false;
448 start = 0; 448 start = 0;
449 break; 449 break;
450 } 450 }
451 if ( ok ) 451 if ( ok )
452 tempString = getPart( answer, ok, start ); 452 tempString = getPart( answer, ok, start );
453 if ( start >= len || start == 0 ) { 453 if ( start >= len || start == 0 ) {
454 start = 0; 454 start = 0;
455 ok = false; 455 ok = false;
456 } 456 }
457 if ( tempString.right(1) =="\n" ) 457 if ( tempString.right(1) =="\n" )
458 tempString = tempString.left( tempString.length()-1); 458 tempString = tempString.left( tempString.length()-1);
459 459
460 templist.append( tempString ); 460 templist.append( tempString );
461 } 461 }
462 ++ccc; 462 ++ccc;
463 if ( ccc == 2 && loopCount < 25 ) { 463 if ( ccc == 2 && loopCount < 25 ) {
464 start = 0; 464 start = 0;
465 bool ok; 465 bool ok;
466 int newnum = templist[0].toInt( &ok ); 466 int newnum = templist[0].toInt( &ok );
467 if ( ok && newnum > 0) { 467 if ( ok && newnum > 0) {
468 retval = newnum; 468 retval = newnum;
469 inc->setZaurusId( newnum ); 469 inc->setZaurusId( newnum );
470 inc->setZaurusUid( getCsum( templist ) ); 470 inc->setZaurusUid( getCsum( templist ) );
471 inc->setZaurusStat( SYNC_TEMPSTATE_NEW_ID ); 471 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
472 } 472 }
473 } 473 }
474 } 474 }
475 //qDebug("getNumFromRecord returning : %d ", retval); 475 //qDebug("getNumFromRecord returning : %d ", retval);
476 return retval; 476 return retval;
477} 477}
478bool SharpFormat::save( Calendar *calendar) 478bool SharpFormat::save( Calendar *calendar)
479{ 479{
480 480
481 QLabel status ( i18n("Processing/adding events ..."), 0 ); 481 QLabel status ( i18n("Processing/adding events ..."), 0 );
482 int w = status.sizeHint().width()+20 ; 482 int w = status.sizeHint().width()+20 ;
483 if ( w < 200 ) w = 200; 483 if ( w < 200 ) w = 200;
484 int h = status.sizeHint().height()+20 ; 484 int h = status.sizeHint().height()+20 ;
485 int dw = QApplication::desktop()->width(); 485 int dw = QApplication::desktop()->width();
486 int dh = QApplication::desktop()->height(); 486 int dh = QApplication::desktop()->height();
487 status.setCaption(i18n("Writing DTM Data") ); 487 status.setCaption(i18n("Writing DTM Data") );
488 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 488 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
489 status.show(); 489 status.show();
490 status.raise(); 490 status.raise();
491 qApp->processEvents(); 491 qApp->processEvents();
492 bool debug = DEBUGMODE; 492 bool debug = DEBUGMODE;
493 QString codec = "utf8"; 493 QString codec = "utf8";
494 QString answer; 494 QString answer;
495 QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n"; 495 QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n";
496 QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; 496 QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n";
497 QString command; 497 QString command;
498 QPtrList<Event> er = calendar->rawEvents(); 498 QPtrList<Event> er = calendar->rawEvents();
499 Event* ev = er.first(); 499 Event* ev = er.first();
500 QString fileName = "/tmp/kopitempout"; 500 QString fileName = "/tmp/kopitempout";
501 int i = 0; 501 int i = 0;
502 QString changeString = ePrefix; 502 QString changeString = ePrefix;
503 QString deleteString = ePrefix; 503 QString deleteString = ePrefix;
504 bool deleteEnt = false; 504 bool deleteEnt = false;
505 bool changeEnt = false; 505 bool changeEnt = false;
506 QString message = i18n("Processing event # "); 506 QString message = i18n("Processing event # ");
507 int procCount = 0; 507 int procCount = 0;
508 while ( ev ) { 508 while ( ev ) {
509 //qDebug("i %d ", ++i); 509 //qDebug("i %d ", ++i);
510 if ( ev->zaurusStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 510 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
511 status.setText ( message + QString::number ( ++procCount ) ); 511 status.setText ( message + QString::number ( ++procCount ) );
512 qApp->processEvents(); 512 qApp->processEvents();
513 QString eString = getEventString( ev ); 513 QString eString = getEventString( ev );
514 if ( ev->zaurusStat() == SYNC_TEMPSTATE_DELETE ) { // delete 514 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete
515 // deleting empty strings does not work. 515 // deleting empty strings does not work.
516 // we write first and x and then delete the record with the x 516 // we write first and x and then delete the record with the x
517 eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); 517 eString = eString.replace( QRegExp(",\"\""),",\"x\"" );
518 changeString += eString + "\n"; 518 changeString += eString + "\n";
519 deleteString += eString + "\n"; 519 deleteString += eString + "\n";
520 deleteEnt = true; 520 deleteEnt = true;
521 changeEnt = true; 521 changeEnt = true;
522 } 522 }
523 else if ( ev->zaurusId() == -1 ) { // add new 523 else if ( ev->zaurusId() == -1 ) { // add new
524 command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; 524 command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
525 system ( command.utf8() ); 525 system ( command.utf8() );
526 QFile file( fileName ); 526 QFile file( fileName );
527 if (!file.open( IO_ReadOnly ) ) { 527 if (!file.open( IO_ReadOnly ) ) {
528 return false; 528 return false;
529 529
530 } 530 }
531 QTextStream ts( &file ); 531 QTextStream ts( &file );
532 ts.setCodec( QTextCodec::codecForName("utf8") ); 532 ts.setCodec( QTextCodec::codecForName("utf8") );
533 answer = ts.read(); 533 answer = ts.read();
534 file.close(); 534 file.close();
535 //qDebug("answer \n%s ", answer.latin1()); 535 //qDebug("answer \n%s ", answer.latin1());
536 getNumFromRecord( answer, ev ) ; 536 getNumFromRecord( answer, ev ) ;
537 537
538 } 538 }
539 else { // change existing 539 else { // change existing
540 //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() ); 540 //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() );
541 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; 541 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
542 changeString += eString + "\n"; 542 changeString += eString + "\n";
543 changeEnt = true; 543 changeEnt = true;
544 544
545 } 545 }
546 } 546 }
@@ -564,69 +564,69 @@ bool SharpFormat::save( Calendar *calendar)
564 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); 564 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1());
565 565
566 } 566 }
567 status.setText ( i18n("Deleting events ...") ); 567 status.setText ( i18n("Deleting events ...") );
568 qApp->processEvents(); 568 qApp->processEvents();
569 //qDebug("deleting... "); 569 //qDebug("deleting... ");
570 if ( deleteEnt ) { 570 if ( deleteEnt ) {
571 QFile file( fileName ); 571 QFile file( fileName );
572 if (!file.open( IO_WriteOnly ) ) { 572 if (!file.open( IO_WriteOnly ) ) {
573 return false; 573 return false;
574 574
575 } 575 }
576 QTextStream ts( &file ); 576 QTextStream ts( &file );
577 ts.setCodec( QTextCodec::codecForName("utf8") ); 577 ts.setCodec( QTextCodec::codecForName("utf8") );
578 ts << deleteString; 578 ts << deleteString;
579 file.close(); 579 file.close();
580 command = "db2file datebook -d -c " + codec+ " < "+ fileName; 580 command = "db2file datebook -d -c " + codec+ " < "+ fileName;
581 system ( command.latin1() ); 581 system ( command.latin1() );
582 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); 582 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1());
583 } 583 }
584 584
585 585
586 changeString = tPrefix; 586 changeString = tPrefix;
587 deleteString = tPrefix; 587 deleteString = tPrefix;
588 status.setText ( i18n("Processing todos ...") ); 588 status.setText ( i18n("Processing todos ...") );
589 qApp->processEvents(); 589 qApp->processEvents();
590 QPtrList<Todo> tl = calendar->rawTodos(); 590 QPtrList<Todo> tl = calendar->rawTodos();
591 Todo* to = tl.first(); 591 Todo* to = tl.first();
592 i = 0; 592 i = 0;
593 message = i18n("Processing todo # "); 593 message = i18n("Processing todo # ");
594 procCount = 0; 594 procCount = 0;
595 while ( to ) { 595 while ( to ) {
596 if ( to->zaurusStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 596 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
597 status.setText ( message + QString::number ( ++procCount ) ); 597 status.setText ( message + QString::number ( ++procCount ) );
598 qApp->processEvents(); 598 qApp->processEvents();
599 QString eString = getTodoString( to ); 599 QString eString = getTodoString( to );
600 if ( to->zaurusStat() == SYNC_TEMPSTATE_DELETE ) { // delete 600 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete
601 // deleting empty strings does not work. 601 // deleting empty strings does not work.
602 // we write first and x and then delete the record with the x 602 // we write first and x and then delete the record with the x
603 eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); 603 eString = eString.replace( QRegExp(",\"\""),",\"x\"" );
604 changeString += eString + "\n"; 604 changeString += eString + "\n";
605 deleteString += eString + "\n"; 605 deleteString += eString + "\n";
606 deleteEnt = true; 606 deleteEnt = true;
607 changeEnt = true; 607 changeEnt = true;
608 } 608 }
609 else if ( to->zaurusId() == -1 ) { // add new 609 else if ( to->zaurusId() == -1 ) { // add new
610 command = "(echo \"" + tPrefix + eString + "\" ) | db2file todo -w -g -c " + codec+ " > "+ fileName; 610 command = "(echo \"" + tPrefix + eString + "\" ) | db2file todo -w -g -c " + codec+ " > "+ fileName;
611 system ( command.utf8() ); 611 system ( command.utf8() );
612 QFile file( fileName ); 612 QFile file( fileName );
613 if (!file.open( IO_ReadOnly ) ) { 613 if (!file.open( IO_ReadOnly ) ) {
614 return false; 614 return false;
615 615
616 } 616 }
617 QTextStream ts( &file ); 617 QTextStream ts( &file );
618 ts.setCodec( QTextCodec::codecForName("utf8") ); 618 ts.setCodec( QTextCodec::codecForName("utf8") );
619 answer = ts.read(); 619 answer = ts.read();
620 file.close(); 620 file.close();
621 //qDebug("answer \n%s ", answer.latin1()); 621 //qDebug("answer \n%s ", answer.latin1());
622 getNumFromRecord( answer, to ) ; 622 getNumFromRecord( answer, to ) ;
623 623
624 } 624 }
625 else { // change existing 625 else { // change existing
626 //qDebug("canging %d %d",to->zaurusStat() ,to->zaurusId() ); 626 //qDebug("canging %d %d",to->zaurusStat() ,to->zaurusId() );
627 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; 627 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
628 changeString += eString + "\n"; 628 changeString += eString + "\n";
629 changeEnt = true; 629 changeEnt = true;
630 630
631 } 631 }
632 } 632 }