summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/phoneformat.cpp24
1 files changed, 4 insertions, 20 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index 1a9ccbc..7e1c9cd 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -25,62 +25,48 @@
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#include "syncdefines.h"
46 46
47using namespace KCal; 47using namespace KCal;
48 48
49//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY
50// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
51
52//ARSD silentalarm = 0
53// 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly
54// 12 RFRQ
55// 13 RPOS pos = 4. monday in month
56// 14 RDYS days: 1 mon/ 2 tue .. 64 sun
57// 15 REND 0 = no end/ 1 = end
58// 16 REDT rec end dt
59//ALSD
60//ALED
61//MDAY
62
63class PhoneParser : public QObject 49class PhoneParser : public QObject
64{ 50{
65public: 51public:
66 PhoneParser( Calendar *calendar, QString profileName ) : mCalendar( calendar ), mProfileName ( profileName ) { 52 PhoneParser( Calendar *calendar, QString profileName ) : mCalendar( calendar ), mProfileName ( profileName ) {
67 ; 53 ;
68 } 54 }
69 bool readTodo( Calendar *existingCalendar,GSM_ToDoEntry *ToDo, GSM_StateMachine* s) 55 bool readTodo( Calendar *existingCalendar,GSM_ToDoEntry *ToDo, GSM_StateMachine* s)
70 { 56 {
71 57
72 int id = ToDo->Location; 58 int id = ToDo->Location;
73 Todo *todo; 59 Todo *todo;
74 todo = existingCalendar->todo( mProfileName ,QString::number( id ) ); 60 todo = existingCalendar->todo( mProfileName ,QString::number( id ) );
75 if (todo ) 61 if (todo )
76 todo = (Todo *)todo->clone(); 62 todo = (Todo *)todo->clone();
77 else 63 else
78 todo = new Todo; 64 todo = new Todo;
79 todo->setID( mProfileName,QString::number( id ) ); 65 todo->setID( mProfileName,QString::number( id ) );
80 todo->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); 66 todo->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL );
81 int priority; 67 int priority;
82 switch (ToDo->Priority) { 68 switch (ToDo->Priority) {
83 case GSM_Priority_Low : priority = 1; break; 69 case GSM_Priority_Low : priority = 1; break;
84 case GSM_Priority_Medium : priority = 3; break; 70 case GSM_Priority_Medium : priority = 3; break;
85 case GSM_Priority_High : priority = 5; break; 71 case GSM_Priority_High : priority = 5; break;
86 default :priority = 3 ;break; 72 default :priority = 3 ;break;
@@ -152,49 +138,48 @@ public:
152 entry.Location = ToDo->Entries[j].Number; 138 entry.Location = ToDo->Entries[j].Number;
153 entry.MemoryType = MEM_ME; 139 entry.MemoryType = MEM_ME;
154 error=Phone->GetMemory(s, &entry); 140 error=Phone->GetMemory(s, &entry);
155 if (error == ERR_NONE) { 141 if (error == ERR_NONE) {
156 name = GSM_PhonebookGetEntryName(&entry); 142 name = GSM_PhonebookGetEntryName(&entry);
157 if (name != NULL) { 143 if (name != NULL) {
158 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number); 144 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number);
159 } else { 145 } else {
160 printmsg("Contact ID : %d\n",ToDo->Entries[j].Number); 146 printmsg("Contact ID : %d\n",ToDo->Entries[j].Number);
161 } 147 }
162 } else { 148 } else {
163 printmsg("Contact : %d\n",ToDo->Entries[j].Number); 149 printmsg("Contact : %d\n",ToDo->Entries[j].Number);
164 } 150 }
165#endif 151#endif
166 break; 152 break;
167 case TODO_PHONE: 153 case TODO_PHONE:
168#if 0 154#if 0
169 // not supported 155 // not supported
170 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); 156 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text));
171#endif 157#endif
172 break; 158 break;
173 } 159 }
174 } 160 }
175 QString alarmString = ""; 161 QString alarmString = "";
176 // strange 0 semms to mean: alarm enabled
177 if ( alarm ) { 162 if ( alarm ) {
178 Alarm *alarm; 163 Alarm *alarm;
179 if ( todo->alarms().count() > 0 ) 164 if ( todo->alarms().count() > 0 )
180 alarm = todo->alarms().first(); 165 alarm = todo->alarms().first();
181 else { 166 else {
182 alarm = new Alarm( todo ); 167 alarm = new Alarm( todo );
183 todo->addAlarm( alarm ); 168 todo->addAlarm( alarm );
184 } 169 }
185 alarm->setType( Alarm::Audio ); 170 alarm->setType( Alarm::Audio );
186 alarm->setEnabled( true ); 171 alarm->setEnabled( true );
187 int alarmOffset = alarmDt.secsTo( todo->dtStart() ); 172 int alarmOffset = alarmDt.secsTo( todo->dtStart() );
188 alarm->setStartOffset( alarmOffset ); 173 alarm->setStartOffset( alarmOffset );
189 alarmString = QString::number( alarmOffset ); 174 alarmString = QString::number( alarmOffset );
190 } 175 }
191 // csum ***************************************** 176 // csum *****************************************
192 QStringList attList; 177 QStringList attList;
193 uint cSum; 178 uint cSum;
194 if ( todo->hasDueDate() ) 179 if ( todo->hasDueDate() )
195 attList << dtToString ( todo->dtDue() ); 180 attList << dtToString ( todo->dtDue() );
196 attList << QString::number( id ); 181 attList << QString::number( id );
197 attList << todo->summary(); 182 attList << todo->summary();
198 attList << completedString; 183 attList << completedString;
199 attList << QString::number( todo->priority() ); 184 attList << QString::number( todo->priority() );
200 attList << alarmString; 185 attList << alarmString;
@@ -642,97 +627,96 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal ,QString profi
642#endif 627#endif
643 } 628 }
644 } 629 }
645 630
646 /* Wanted user specific configuration? */ 631 /* Wanted user specific configuration? */
647 632
648 if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; 633 if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break;
649 634
650 s.ConfigNum++; 635 s.ConfigNum++;
651 636
652 /* We want to use only one file descriptor for global and state machine debug output */ 637 /* We want to use only one file descriptor for global and state machine debug output */
653 s.Config[i].UseGlobalDebugFile = true; 638 s.Config[i].UseGlobalDebugFile = true;
654 639
655 640
656 641
657 /* We wanted to read just user specified configuration. */ 642 /* We wanted to read just user specified configuration. */
658 {break;} 643 {break;}
659 } 644 }
660 645
661#endif 646#endif
662 setlocale(LC_ALL, ""); 647 setlocale(LC_ALL, "");
663 GSM_ReadConfig(NULL, &s.Config[0], 0); 648 GSM_ReadConfig(NULL, &s.Config[0], 0);
664 s.ConfigNum = 1; 649 s.ConfigNum = 1;
665 GSM_Config *cfg = &s.Config[0]; 650 GSM_Config *cfg = &s.Config[0];
666 di.coding = "utf8";
667 if ( ! connection.isEmpty() ) { 651 if ( ! connection.isEmpty() ) {
668 cfg->Connection = strdup(connection.latin1()); 652 cfg->Connection = strdup(connection.latin1());
669 cfg->DefaultConnection = false; 653 cfg->DefaultConnection = false;
670 qDebug("Connection set %s ", cfg->Connection ); 654 qDebug("Connection set %s ", cfg->Connection );
671 655
672 } 656 }
673 if ( ! device.isEmpty() ) { 657 if ( ! device.isEmpty() ) {
674 cfg->Device = strdup(device.latin1()); 658 cfg->Device = strdup(device.latin1());
675 cfg->DefaultDevice = false; 659 cfg->DefaultDevice = false;
676 qDebug("Device set %s ", cfg->Device); 660 qDebug("Device set %s ", cfg->Device);
677 661
678 } 662 }
679 if ( ! model.isEmpty() ) { 663 if ( ! model.isEmpty() ) {
680 strcpy(cfg->Model,model.latin1() ); 664 strcpy(cfg->Model,model.latin1() );
681 cfg->DefaultModel = false; 665 cfg->DefaultModel = false;
682 qDebug("Model set %s ",cfg->Model ); 666 qDebug("Model set %s ",cfg->Model );
683 667
684 668
685 } 669 }
686 int error=GSM_InitConnection(&s,3); 670 int error=GSM_InitConnection(&s,3);
687 qDebug(" init %d %d", error, ERR_NONE); 671 qDebug("GSM Init %d (no error is %d)", error, ERR_NONE);
688 if ( error != ERR_NONE ) 672 if ( error != ERR_NONE )
689 return false; 673 return false;
690 // fromString2Cal( calendar, existngCal, &s, "Event" );
691 GSM_Phone_Functions*Phone; 674 GSM_Phone_Functions*Phone;
692 GSM_CalendarEntrynote; 675 GSM_CalendarEntrynote;
693 bool start = true; 676 bool start = true;
694 Phone=s.Phone.Functions; 677 Phone=s.Phone.Functions;
695 bool gshutdown = false; 678 bool gshutdown = false;
696 PhoneParser handler( calendar, profileName ); 679 PhoneParser handler( calendar, profileName );
697 int ccc = 0; 680 int ccc = 0;
698 while (!gshutdown && ccc++ < 3) { 681 qDebug("Debug: only 10 calender items are downloaded ");
682 while (!gshutdown && ccc++ < 10) {
699 683
700 qDebug("readEvent %d ", ccc); 684 qDebug("readEvent %d ", ccc);
701 error=Phone->GetNextCalendar(&s,&note,start); 685 error=Phone->GetNextCalendar(&s,&note,start);
702 if (error == ERR_EMPTY) break; 686 if (error == ERR_EMPTY) break;
703 start = false; 687 start = false;
704 handler.readEvent( existingCal, &note ); 688 handler.readEvent( existingCal, &note );
705 } 689 }
706 690
707 start = true; 691 start = true;
708 GSM_ToDoEntry ToDo; 692 GSM_ToDoEntry ToDo;
709 ccc = 0; 693 ccc = 0;
710 while (!gshutdown) { 694 while (!gshutdown) {
711 error = Phone->GetNextToDo(&s, &ToDo, start); 695 error = Phone->GetNextToDo(&s, &ToDo, start);
712 if (error == ERR_EMPTY) break; 696 if (error == ERR_EMPTY) break;
713 start = false; 697 start = false;
714 qDebug("readTodo %d ", ++ccc); 698 qDebug("ReadTodo %d ", ++ccc);
715 handler.readTodo( existingCal, &ToDo, &s); 699 handler.readTodo( existingCal, &ToDo, &s);
716 700
717 } 701 }
718 702
719 error=GSM_TerminateConnection(&s); 703 error=GSM_TerminateConnection(&s);
720 704
721 return true; 705 return true;
722} 706}
723 707
724bool PhoneFormat::save( Calendar *calendar) 708bool PhoneFormat::save( Calendar *calendar)
725{ 709{
726#if 0 710#if 0
727 QLabel status ( i18n("Processing/adding events ..."), 0 ); 711 QLabel status ( i18n("Processing/adding events ..."), 0 );
728 int w = status.sizeHint().width()+20 ; 712 int w = status.sizeHint().width()+20 ;
729 if ( w < 200 ) w = 200; 713 if ( w < 200 ) w = 200;
730 int h = status.sizeHint().height()+20 ; 714 int h = status.sizeHint().height()+20 ;
731 int dw = QApplication::desktop()->width(); 715 int dw = QApplication::desktop()->width();
732 int dh = QApplication::desktop()->height(); 716 int dh = QApplication::desktop()->height();
733 status.setCaption(i18n("Writing DTM Data") ); 717 status.setCaption(i18n("Writing DTM Data") );
734 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 718 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
735 status.show(); 719 status.show();
736 status.raise(); 720 status.raise();
737 qApp->processEvents(); 721 qApp->processEvents();
738 bool debug = DEBUGMODE; 722 bool debug = DEBUGMODE;