summaryrefslogtreecommitdiffabout
path: root/libkcal/phoneformat.cpp
authorzautrix <zautrix>2004-09-12 13:11:10 (UTC)
committer zautrix <zautrix>2004-09-12 13:11:10 (UTC)
commitb2dede5d5735e2b4ab5afd51cf6a2c46d9be9b26 (patch) (side-by-side diff)
treea25dbba0cac09b7a7892405b11eb08c7d02e6b6b /libkcal/phoneformat.cpp
parent3c954091cb8d90c185403c68a8bbbb2a961f67fe (diff)
downloadkdepimpi-b2dede5d5735e2b4ab5afd51cf6a2c46d9be9b26.zip
kdepimpi-b2dede5d5735e2b4ab5afd51cf6a2c46d9be9b26.tar.gz
kdepimpi-b2dede5d5735e2b4ab5afd51cf6a2c46d9be9b26.tar.bz2
many phonesync fixes
Diffstat (limited to 'libkcal/phoneformat.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/phoneformat.cpp53
1 files changed, 45 insertions, 8 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index 2ad1b5a..6df639f 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -32,12 +32,13 @@
#include <qxml.h>
#include <qlabel.h>
#include <kdebug.h>
#include <klocale.h>
#include <kglobal.h>
+#include <kmessagebox.h>
#include "calendar.h"
#include "alarm.h"
#include "recurrence.h"
#include "calendarlocal.h"
@@ -243,12 +244,14 @@ ulong PhoneFormat::getCsumEvent( Event* event )
list.append( "20991231T000000" );
}
}
attList << list.join("");
attList << event->categoriesStr();
+ //qDebug("csum cat %s", event->categoriesStr().latin1());
+
attList << event->secrecyStr();
return PhoneFormat::getCsum(attList );
}
ulong PhoneFormat::getCsum( const QStringList & attList)
{
int max = attList.count() -1;
@@ -266,12 +269,15 @@ ulong PhoneFormat::getCsum( const QStringList & attList)
mul = mul * mul;
add = add * mul *i*i*i;
cSum += add;
}
}
}
+ //QString dump = attList.join(",");
+ //qDebug("csum: %s", dump.latin1());
+
return cSum;
}
//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum);
#include <stdlib.h>
#define DEBUGMODE false
@@ -284,21 +290,31 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
#else
fileName = "/tmp/kdepimtemp.vcs";
#endif
QString command ="./kammu --backup " + fileName + " -yes -C" +
mConnection +" -D" + mDevice +" -M" + mModel;
int ret = system ( command.latin1() );
- if ( ret != 0 )
+ if ( ret != 0 ) {
+ qDebug("Error::command returned %d", ret);
return false;
+ }
+ qDebug("Command returned %d", ret);
VCalFormat vfload;
vfload.setLocalTime ( true );
+ qDebug("loading file ...");
+
if ( ! vfload.load( calendar, fileName ) )
return false;
QPtrList<Event> er = calendar->rawEvents();
Event* ev = er.first();
+ qDebug("reading events... ");
while ( ev ) {
+ QStringList cat = ev->categories();
+ if ( cat.contains( "MeetingDEF" )) {
+ ev->setCategories( QStringList() );
+ }
int id = ev->pilotId();
Event *event;
event = existingCal->event( mProfileName ,QString::number( id ) );
if ( event ) {
event = (Event*)event->clone();
copyEvent( event, ev );
@@ -312,12 +328,13 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
event->setCsum( mProfileName, QString::number( cSum ));
event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
event->setID( mProfileName,QString::number( id ) );
ev = er.next();
}
{
+ qDebug("reading todos... ");
QPtrList<Todo> tr = calendar->rawTodos();
Todo* ev = tr.first();
while ( ev ) {
QStringList cat = ev->categories();
if ( cat.contains( "MeetingDEF" )) {
@@ -479,24 +496,33 @@ bool PhoneFormat::save( Calendar *calendar)
Todo* to = tl.first();
while ( to ) {
if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
calendar->deleteTodo( to );
}
to = tl.next();
- }
+ }
// 3 save file
VCalFormat vfsave;
vfsave.setLocalTime ( true );
if ( ! vfsave.save( calendar, fileName ) )
return false;
// 4 call kammu
QString command ="./kammu --restore " + fileName + " -C" +
- mConnection +" -D" + mDevice +" -M" + mModel;;
- int ret = system ( command.latin1() );
- if ( ret != 0 )
+ mConnection +" -D" + mDevice +" -M" + mModel;
+ int ret;
+ while ( (ret = system ( command.latin1())) != 0 ) {
+ qDebug("Error S::command returned %d. asking users", ret);
+ int retval = KMessageBox::warningContinueCancel(0,
+ i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone sync"),i18n("Retry"),i18n("Cancel"));
+ if ( retval != KMessageBox::Continue )
+ return false;
+ }
+ if ( ret != 0 ) {
+ qDebug("Error S::command returned %d", ret);
return false;
+ }
// 5 reread data
message = i18n(" Rereading all data ... ");
status.setText ( message );
qApp->processEvents();
CalendarLocal* calendarTemp = new CalendarLocal();
calendarTemp->setTimeZoneId( calendar->timeZoneId());
@@ -512,22 +538,28 @@ bool PhoneFormat::save( Calendar *calendar)
ev = er.first();
message = i18n(" Comparing event # ");
QPtrList<Event> er1 = calendarTemp->rawEvents();
Event* ev1;
int procCount = 0;
while ( ev ) {
- qDebug("event new ID ");
+ //qDebug("event new ID %s",ev->summary().latin1());
status.setText ( message + QString::number ( ++procCount ) );
qApp->processEvents();
- QString cSum = ev->getCsum(mProfileName);
+ uint csum;
+ csum = PhoneFormat::getCsumEvent( ev );
+ QString cSum = QString::number( csum );
+ ev->setCsum( mProfileName, cSum );
+ //qDebug("Event cSum %s ", cSum.latin1());
ev1 = er1.first();
while ( ev1 ) {
if ( ev1->getCsum( mProfileName ) == cSum ) {
er1.remove( ev1 );
afterSave( ev );
ev->setID(mProfileName, ev1->getID(mProfileName) );
+ //qDebug("Event found on phone for %s ", ev->summary().latin1());
+
break;
}
ev1 = er1.next();
}
if ( ! ev1 ) {
ev->removeID(mProfileName);
@@ -535,22 +567,27 @@ bool PhoneFormat::save( Calendar *calendar)
}
ev = er.next();
}
//algo 6 compare todo
+ tl = calendar->rawTodos();
to = tl.first();
procCount = 0;
QPtrList<Todo> tl1 = calendarTemp->rawTodos();
Todo* to1 ;
message = i18n(" Comparing todo # ");
while ( to ) {
qDebug("todo2 %d ", procCount);
status.setText ( message + QString::number ( ++procCount ) );
qApp->processEvents();
- QString cSum = to->getCsum(mProfileName);
+ uint csum;
+ csum = PhoneFormat::getCsumTodo( to );
+ QString cSum = QString::number( csum );
+ to->setCsum( mProfileName, cSum );
+ qDebug("Todo cSum %s ", cSum.latin1());
Todo* to1 = tl1.first();
while ( to1 ) {
if ( to1->getCsum( mProfileName ) == cSum ) {
tl1.remove( to1 );
afterSave( to );
to->setID(mProfileName, to1->getID(mProfileName) );