-rw-r--r-- | gammu/emb/gammu/gammu.c | 47 | ||||
-rw-r--r-- | libkcal/phoneformat.cpp | 6 |
2 files changed, 50 insertions, 3 deletions
diff --git a/gammu/emb/gammu/gammu.c b/gammu/emb/gammu/gammu.c index 1d53fb0..5163d81 100644 --- a/gammu/emb/gammu/gammu.c +++ b/gammu/emb/gammu/gammu.c | |||
@@ -8237,24 +8237,69 @@ int main(int argc, char *argv[]) | |||
8237 | /* Help? */ | 8237 | /* Help? */ |
8238 | if (strncmp(argv[1 + start], "--help", 6) == 0) { | 8238 | if (strncmp(argv[1 + start], "--help", 6) == 0) { |
8239 | Help(argc - start, argv + start); | 8239 | Help(argc - start, argv + start); |
8240 | exit(1); | 8240 | exit(1); |
8241 | } | 8241 | } |
8242 | 8242 | ||
8243 | /* Is first parameter numeric? If so treat it as config that should be loaded. */ | 8243 | /* Is first parameter numeric? If so treat it as config that should be loaded. */ |
8244 | if (isdigit(argv[1][0])) { | 8244 | if (isdigit(argv[1][0])) { |
8245 | only_config = atoi(argv[1]); | 8245 | only_config = atoi(argv[1]); |
8246 | if (only_config >= 0) start++; else only_config = -1; | 8246 | if (only_config >= 0) start++; else only_config = -1; |
8247 | } | 8247 | } |
8248 | 8248 | ||
8249 | GSM_ReadConfig(NULL, &s.Config[0], 0); | ||
8250 | s.ConfigNum = 1; | ||
8251 | GSM_Config *con = &s.Config[0]; | ||
8252 | |||
8253 | char* tempC; | ||
8254 | tempC = argv[argc-1]+2; | ||
8255 | if ( *tempC != 0 ) { | ||
8256 | fprintf(stderr,"Using model %s \n",tempC); | ||
8257 | strcpy(con->Model,tempC ); | ||
8258 | } | ||
8259 | tempC = argv[argc-2]+2; | ||
8260 | if ( *tempC != 0 ) { | ||
8261 | fprintf(stderr,"Using device %s \n",tempC); | ||
8262 | con->Device = strdup(tempC); | ||
8263 | con->DefaultDevice = false; | ||
8264 | } | ||
8265 | tempC = argv[argc-3]+2; | ||
8266 | if ( *tempC != 0 ) { | ||
8267 | fprintf(stderr,"Using connection %s \n",tempC); | ||
8268 | con->Connection = strdup(tempC); | ||
8269 | con->DefaultConnection = false; | ||
8270 | } | ||
8271 | argc = argc-3; | ||
8272 | #if 0 | ||
8273 | if ( ! mConnection.isEmpty() ) { | ||
8274 | cfg->Connection = strdup(mConnection.latin1()); | ||
8275 | cfg->DefaultConnection = false; | ||
8276 | qDebug("Connection set %s ", cfg->Connection ); | ||
8277 | |||
8278 | } | ||
8279 | if ( ! mDevice.isEmpty() ) { | ||
8280 | cfg->Device = strdup(mDevice.latin1()); | ||
8281 | cfg->DefaultDevice = false; | ||
8282 | qDebug("Device set %s ", cfg->Device); | ||
8283 | |||
8284 | } | ||
8285 | if ( ! mModel.isEmpty() ) { | ||
8286 | strcpy(cfg->Model,mModel.latin1() ); | ||
8287 | cfg->DefaultModel = false; | ||
8288 | qDebug("Model set %s ",cfg->Model ); | ||
8289 | } | ||
8290 | |||
8291 | #endif | ||
8292 | |||
8293 | #if 0 | ||
8249 | cfg=GSM_FindGammuRC(); | 8294 | cfg=GSM_FindGammuRC(); |
8250 | for (i = 0; i <= MAX_CONFIG_NUM; i++) { | 8295 | for (i = 0; i <= MAX_CONFIG_NUM; i++) { |
8251 | if (cfg!=NULL) { | 8296 | if (cfg!=NULL) { |
8252 | cp = INI_GetValue(cfg, "gammu", "gammucoding", false); | 8297 | cp = INI_GetValue(cfg, "gammu", "gammucoding", false); |
8253 | if (cp) di.coding = cp; | 8298 | if (cp) di.coding = cp; |
8254 | 8299 | ||
8255 | s.Config[i].Localize = INI_GetValue(cfg, "gammu", "gammuloc", false); | 8300 | s.Config[i].Localize = INI_GetValue(cfg, "gammu", "gammuloc", false); |
8256 | if (s.Config[i].Localize) { | 8301 | if (s.Config[i].Localize) { |
8257 | s.msg=INI_ReadFile(s.Config[i].Localize, true); | 8302 | s.msg=INI_ReadFile(s.Config[i].Localize, true); |
8258 | } else { | 8303 | } else { |
8259 | #if !defined(WIN32) && defined(LOCALE_PATH) | 8304 | #if !defined(WIN32) && defined(LOCALE_PATH) |
8260 | locale = setlocale(LC_MESSAGES, NULL); | 8305 | locale = setlocale(LC_MESSAGES, NULL); |
@@ -8296,25 +8341,25 @@ int main(int argc, char *argv[]) | |||
8296 | } else { | 8341 | } else { |
8297 | /* Try to set debug level from config file */ | 8342 | /* Try to set debug level from config file */ |
8298 | GSM_SetDebugLevel(s.Config[i].DebugLevel, &di); | 8343 | GSM_SetDebugLevel(s.Config[i].DebugLevel, &di); |
8299 | } | 8344 | } |
8300 | /* If user gave debug file in gammurc, we will use it */ | 8345 | /* If user gave debug file in gammurc, we will use it */ |
8301 | error=GSM_SetDebugFile(s.Config[i].DebugFile, &di); | 8346 | error=GSM_SetDebugFile(s.Config[i].DebugFile, &di); |
8302 | Print_Error(error); | 8347 | Print_Error(error); |
8303 | } | 8348 | } |
8304 | 8349 | ||
8305 | /* We wanted to read just user specified configuration. */ | 8350 | /* We wanted to read just user specified configuration. */ |
8306 | if (only_config != -1) {break;} | 8351 | if (only_config != -1) {break;} |
8307 | } | 8352 | } |
8308 | 8353 | #endif | |
8309 | /* Do we have enough parameters? */ | 8354 | /* Do we have enough parameters? */ |
8310 | if (argc == 1 + start) { | 8355 | if (argc == 1 + start) { |
8311 | HelpGeneral(); | 8356 | HelpGeneral(); |
8312 | printmsg("Too few parameters!\n"); | 8357 | printmsg("Too few parameters!\n"); |
8313 | exit(-2); | 8358 | exit(-2); |
8314 | } | 8359 | } |
8315 | 8360 | ||
8316 | /* Check used version vs. compiled */ | 8361 | /* Check used version vs. compiled */ |
8317 | if (!mystrncasecmp(GetGammuVersion(),VERSION,0)) { | 8362 | if (!mystrncasecmp(GetGammuVersion(),VERSION,0)) { |
8318 | printmsg("ERROR: version of installed libGammu.so (%s) is different to version of Gammu (%s)\n", | 8363 | printmsg("ERROR: version of installed libGammu.so (%s) is different to version of Gammu (%s)\n", |
8319 | GetGammuVersion(),VERSION); | 8364 | GetGammuVersion(),VERSION); |
8320 | exit(-1); | 8365 | exit(-1); |
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 0bc9125..2ad1b5a 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -275,25 +275,26 @@ ulong PhoneFormat::getCsum( const QStringList & attList) | |||
275 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); | 275 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); |
276 | #include <stdlib.h> | 276 | #include <stdlib.h> |
277 | #define DEBUGMODE false | 277 | #define DEBUGMODE false |
278 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | 278 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) |
279 | { | 279 | { |
280 | 280 | ||
281 | QString fileName; | 281 | QString fileName; |
282 | #ifdef _WIN32_ | 282 | #ifdef _WIN32_ |
283 | fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; | 283 | fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; |
284 | #else | 284 | #else |
285 | fileName = "/tmp/kdepimtemp.vcs"; | 285 | fileName = "/tmp/kdepimtemp.vcs"; |
286 | #endif | 286 | #endif |
287 | QString command ="./kammu --backup " + fileName + " -yes"; | 287 | QString command ="./kammu --backup " + fileName + " -yes -C" + |
288 | mConnection +" -D" + mDevice +" -M" + mModel; | ||
288 | int ret = system ( command.latin1() ); | 289 | int ret = system ( command.latin1() ); |
289 | if ( ret != 0 ) | 290 | if ( ret != 0 ) |
290 | return false; | 291 | return false; |
291 | VCalFormat vfload; | 292 | VCalFormat vfload; |
292 | vfload.setLocalTime ( true ); | 293 | vfload.setLocalTime ( true ); |
293 | if ( ! vfload.load( calendar, fileName ) ) | 294 | if ( ! vfload.load( calendar, fileName ) ) |
294 | return false; | 295 | return false; |
295 | QPtrList<Event> er = calendar->rawEvents(); | 296 | QPtrList<Event> er = calendar->rawEvents(); |
296 | Event* ev = er.first(); | 297 | Event* ev = er.first(); |
297 | while ( ev ) { | 298 | while ( ev ) { |
298 | int id = ev->pilotId(); | 299 | int id = ev->pilotId(); |
299 | Event *event; | 300 | Event *event; |
@@ -479,25 +480,26 @@ bool PhoneFormat::save( Calendar *calendar) | |||
479 | while ( to ) { | 480 | while ( to ) { |
480 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 481 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
481 | calendar->deleteTodo( to ); | 482 | calendar->deleteTodo( to ); |
482 | } | 483 | } |
483 | to = tl.next(); | 484 | to = tl.next(); |
484 | } | 485 | } |
485 | // 3 save file | 486 | // 3 save file |
486 | VCalFormat vfsave; | 487 | VCalFormat vfsave; |
487 | vfsave.setLocalTime ( true ); | 488 | vfsave.setLocalTime ( true ); |
488 | if ( ! vfsave.save( calendar, fileName ) ) | 489 | if ( ! vfsave.save( calendar, fileName ) ) |
489 | return false; | 490 | return false; |
490 | // 4 call kammu | 491 | // 4 call kammu |
491 | QString command ="./kammu --restore " + fileName ; | 492 | QString command ="./kammu --restore " + fileName + " -C" + |
493 | mConnection +" -D" + mDevice +" -M" + mModel;; | ||
492 | int ret = system ( command.latin1() ); | 494 | int ret = system ( command.latin1() ); |
493 | if ( ret != 0 ) | 495 | if ( ret != 0 ) |
494 | return false; | 496 | return false; |
495 | // 5 reread data | 497 | // 5 reread data |
496 | message = i18n(" Rereading all data ... "); | 498 | message = i18n(" Rereading all data ... "); |
497 | status.setText ( message ); | 499 | status.setText ( message ); |
498 | qApp->processEvents(); | 500 | qApp->processEvents(); |
499 | CalendarLocal* calendarTemp = new CalendarLocal(); | 501 | CalendarLocal* calendarTemp = new CalendarLocal(); |
500 | calendarTemp->setTimeZoneId( calendar->timeZoneId()); | 502 | calendarTemp->setTimeZoneId( calendar->timeZoneId()); |
501 | if ( ! load( calendarTemp,calendar) ){ | 503 | if ( ! load( calendarTemp,calendar) ){ |
502 | qDebug("error reloading calendar "); | 504 | qDebug("error reloading calendar "); |
503 | delete calendarTemp; | 505 | delete calendarTemp; |