summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2004-08-09 14:56:56 (UTC)
committer zautrix <zautrix>2004-08-09 14:56:56 (UTC)
commitad99dd380750834b3ccc4dd6fdcdd446ca5ba7ee (patch) (unidiff)
tree0394df7d796d38e7df637e6d45b82e7945fab55e /korganizer
parent48f53b2d2e7ed189e88f924259693ab66ff44b7f (diff)
downloadkdepimpi-ad99dd380750834b3ccc4dd6fdcdd446ca5ba7ee.zip
kdepimpi-ad99dd380750834b3ccc4dd6fdcdd446ca5ba7ee.tar.gz
kdepimpi-ad99dd380750834b3ccc4dd6fdcdd446ca5ba7ee.tar.bz2
more phone sync
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index d6ead37..547d02b 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1106,199 +1106,197 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
1106 } else { 1106 } else {
1107 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1107 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1108 ++addedEventR; 1108 ++addedEventR;
1109 inL->setLastModified( modifiedCalendar ); 1109 inL->setLastModified( modifiedCalendar );
1110 remote->addIncidence( inL->clone() ); 1110 remote->addIncidence( inL->clone() );
1111 } 1111 }
1112 } 1112 }
1113 } 1113 }
1114 } 1114 }
1115 } 1115 }
1116 inL = el.next(); 1116 inL = el.next();
1117 } 1117 }
1118 1118
1119 bar.hide(); 1119 bar.hide();
1120 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1120 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1121 eventLSync->setReadOnly( false ); 1121 eventLSync->setReadOnly( false );
1122 eventLSync->setDtStart( mLastCalendarSync ); 1122 eventLSync->setDtStart( mLastCalendarSync );
1123 eventRSync->setDtStart( mLastCalendarSync ); 1123 eventRSync->setDtStart( mLastCalendarSync );
1124 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1124 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1125 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1125 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1126 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1126 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1127 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1127 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1128 eventLSync->setReadOnly( true ); 1128 eventLSync->setReadOnly( true );
1129 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1129 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1130 remote->addEvent( eventRSync ); 1130 remote->addEvent( eventRSync );
1131 QString mes; 1131 QString mes;
1132 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); 1132 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR );
1133 if ( KOPrefs::instance()->mShowSyncSummary ) { 1133 if ( KOPrefs::instance()->mShowSyncSummary ) {
1134 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1134 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1135 } 1135 }
1136 qDebug( mes ); 1136 qDebug( mes );
1137 mCalendar->checkAlarmForIncidence( 0, true ); 1137 mCalendar->checkAlarmForIncidence( 0, true );
1138 return syncOK; 1138 return syncOK;
1139} 1139}
1140 1140
1141void CalendarView::setSyncDevice( QString s ) 1141void CalendarView::setSyncDevice( QString s )
1142{ 1142{
1143 mCurrentSyncDevice= s; 1143 mCurrentSyncDevice= s;
1144} 1144}
1145void CalendarView::setSyncName( QString s ) 1145void CalendarView::setSyncName( QString s )
1146{ 1146{
1147 mCurrentSyncName= s; 1147 mCurrentSyncName= s;
1148} 1148}
1149bool CalendarView::syncCalendar(QString filename, int mode) 1149bool CalendarView::syncCalendar(QString filename, int mode)
1150{ 1150{
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 (mCurrentSyncDevice,
1203 loadSuccess = phoneFormat->load( calendar,
1204 mCalendar,
1205 mCurrentSyncDevice,
1206 KOPrefs::instance()->mPhoneDevice, 1203 KOPrefs::instance()->mPhoneDevice,
1207 KOPrefs::instance()->mPhoneConnection, 1204 KOPrefs::instance()->mPhoneConnection,
1208 KOPrefs::instance()->mPhoneModel); 1205 KOPrefs::instance()->mPhoneModel);
1206 loadSuccess = phoneFormat->load( calendar,mCalendar);
1209 1207
1210 } else 1208 } else
1211 return; 1209 return;
1212 if ( loadSuccess ) { 1210 if ( loadSuccess ) {
1213 getEventViewerDialog()->setSyncMode( true ); 1211 getEventViewerDialog()->setSyncMode( true );
1214 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1212 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1215 getEventViewerDialog()->setSyncMode( false ); 1213 getEventViewerDialog()->setSyncMode( false );
1216 qApp->processEvents(); 1214 qApp->processEvents();
1217 if ( syncOK ) { 1215 if ( syncOK ) {
1218 if ( KOPrefs::instance()->mWriteBackFile ) 1216 if ( KOPrefs::instance()->mWriteBackFile )
1219 { 1217 {
1220 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1218 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1221 Incidence* inc = iL.first(); 1219 Incidence* inc = iL.first();
1222 /* obsolete 1220 /* obsolete
1223 while ( inc ) { 1221 while ( inc ) {
1224 inc->setZaurusStat( inc->revision () ); 1222 inc->setZaurusStat( inc->revision () );
1225 inc = iL.next(); 1223 inc = iL.next();
1226 } 1224 }
1227 */ 1225 */
1228#ifndef DESKTOP_VERSION 1226#ifndef DESKTOP_VERSION
1229 if ( sharpFormat ) 1227 if ( sharpFormat )
1230 sharpFormat->save(calendar); 1228 sharpFormat->save(calendar);
1231#endif 1229#endif
1232 if ( phoneFormat ) 1230 if ( phoneFormat )
1233 phoneFormat->save(calendar); 1231 phoneFormat->save(calendar);
1234 iL = calendar->rawIncidences(); 1232 iL = calendar->rawIncidences();
1235 inc = iL.first(); 1233 inc = iL.first();
1236 Incidence* loc; 1234 Incidence* loc;
1237 while ( inc ) { 1235 while ( inc ) {
1238 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1236 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1239 loc = mCalendar->incidence(inc->uid() ); 1237 loc = mCalendar->incidence(inc->uid() );
1240 if ( loc ) { 1238 if ( loc ) {
1241 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1239 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1242 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1240 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1243 } 1241 }
1244 } 1242 }
1245 inc = iL.next(); 1243 inc = iL.next();
1246 } 1244 }
1247 Incidence* lse = getLastSyncEvent(); 1245 Incidence* lse = getLastSyncEvent();
1248 if ( lse ) { 1246 if ( lse ) {
1249 lse->setReadOnly( false ); 1247 lse->setReadOnly( false );
1250 lse->setDescription( "" ); 1248 lse->setDescription( "" );
1251 lse->setReadOnly( true ); 1249 lse->setReadOnly( true );
1252 } 1250 }
1253 } 1251 }
1254 } 1252 }
1255 setModified( true ); 1253 setModified( true );
1256 } else { 1254 } else {
1257 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1255 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1258 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1256 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1259 question, i18n("Ok")) ; 1257 question, i18n("Ok")) ;
1260 1258
1261 } 1259 }
1262 delete calendar; 1260 delete calendar;
1263 updateView(); 1261 updateView();
1264 return ;//syncOK; 1262 return ;//syncOK;
1265 1263
1266} 1264}
1267void CalendarView::syncSharp() 1265void CalendarView::syncSharp()
1268{ 1266{
1269 syncExternal( 0 ); 1267 syncExternal( 0 );
1270 1268
1271} 1269}
1272 1270
1273 1271
1274#include <kabc/stdaddressbook.h> 1272#include <kabc/stdaddressbook.h>
1275bool CalendarView::importBday() 1273bool CalendarView::importBday()
1276{ 1274{
1277 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1275 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1278 KABC::AddressBook::Iterator it; 1276 KABC::AddressBook::Iterator it;
1279 int count = 0; 1277 int count = 0;
1280 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1278 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1281 ++count; 1279 ++count;
1282 } 1280 }
1283 QProgressBar bar(count,0 ); 1281 QProgressBar bar(count,0 );
1284 int w = 300; 1282 int w = 300;
1285 if ( QApplication::desktop()->width() < 320 ) 1283 if ( QApplication::desktop()->width() < 320 )
1286 w = 220; 1284 w = 220;
1287 int h = bar.sizeHint().height() ; 1285 int h = bar.sizeHint().height() ;
1288 int dw = QApplication::desktop()->width(); 1286 int dw = QApplication::desktop()->width();
1289 int dh = QApplication::desktop()->height(); 1287 int dh = QApplication::desktop()->height();
1290 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1288 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1291 bar.show(); 1289 bar.show();
1292 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1290 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1293 qApp->processEvents(); 1291 qApp->processEvents();
1294 count = 0; 1292 count = 0;
1295 int addCount = 0; 1293 int addCount = 0;
1296 KCal::Attendee* a = 0; 1294 KCal::Attendee* a = 0;
1297 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1295 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1298 if ( ! bar.isVisible() ) 1296 if ( ! bar.isVisible() )
1299 return false; 1297 return false;
1300 bar.setProgress( count++ ); 1298 bar.setProgress( count++ );
1301 qApp->processEvents(); 1299 qApp->processEvents();
1302 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1300 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1303 if ( (*it).birthday().date().isValid() ){ 1301 if ( (*it).birthday().date().isValid() ){
1304 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1302 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;