summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/phoneformat.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index c97b43d..238b0ef 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -130,131 +130,132 @@ public:
130 todo->setSecrecy( Incidence::SecrecyPublic ); 130 todo->setSecrecy( Incidence::SecrecyPublic );
131 break; 131 break;
132 case TODO_CATEGORY: 132 case TODO_CATEGORY:
133 Category.Location = ToDo->Entries[j].Number; 133 Category.Location = ToDo->Entries[j].Number;
134 Category.Type = Category_ToDo; 134 Category.Type = Category_ToDo;
135 error=Phone->GetCategory(s, &Category); 135 error=Phone->GetCategory(s, &Category);
136 if (error == ERR_NONE) { 136 if (error == ERR_NONE) {
137 QStringList cat = todo->categories(); 137 QStringList cat = todo->categories();
138 QString nCat = QString ( (const char*)Category.Name ); 138 QString nCat = QString ( (const char*)Category.Name );
139 if ( !nCat.isEmpty() ) 139 if ( !nCat.isEmpty() )
140 if ( !cat.contains( nCat )) { 140 if ( !cat.contains( nCat )) {
141 cat << nCat; 141 cat << nCat;
142 todo->setCategories( cat ); 142 todo->setCategories( cat );
143 } 143 }
144 } 144 }
145 break; 145 break;
146 case TODO_CONTACTID: 146 case TODO_CONTACTID:
147#if 0 147#if 0
148 // not supported 148 // not supported
149 entry.Location = ToDo->Entries[j].Number; 149 entry.Location = ToDo->Entries[j].Number;
150 entry.MemoryType = MEM_ME; 150 entry.MemoryType = MEM_ME;
151 error=Phone->GetMemory(s, &entry); 151 error=Phone->GetMemory(s, &entry);
152 if (error == ERR_NONE) { 152 if (error == ERR_NONE) {
153 name = GSM_PhonebookGetEntryName(&entry); 153 name = GSM_PhonebookGetEntryName(&entry);
154 if (name != NULL) { 154 if (name != NULL) {
155 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number); 155 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number);
156 } else { 156 } else {
157 printmsg("Contact ID : %d\n",ToDo->Entries[j].Number); 157 printmsg("Contact ID : %d\n",ToDo->Entries[j].Number);
158 } 158 }
159 } else { 159 } else {
160 printmsg("Contact : %d\n",ToDo->Entries[j].Number); 160 printmsg("Contact : %d\n",ToDo->Entries[j].Number);
161 } 161 }
162#endif 162#endif
163 break; 163 break;
164 case TODO_PHONE: 164 case TODO_PHONE:
165#if 0 165#if 0
166 // not supported 166 // not supported
167 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); 167 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text));
168#endif 168#endif
169 break; 169 break;
170 } 170 }
171 } 171 }
172 QString alarmString = ""; 172 QString alarmString = "";
173 // strange 0 semms to mean: alarm enabled 173 // strange 0 semms to mean: alarm enabled
174 if ( alarm ) { 174 if ( alarm ) {
175 Alarm *alarm; 175 Alarm *alarm;
176 if ( todo->alarms().count() > 0 ) 176 if ( todo->alarms().count() > 0 )
177 alarm = todo->alarms().first(); 177 alarm = todo->alarms().first();
178 else { 178 else {
179 alarm = new Alarm( todo ); 179 alarm = new Alarm( todo );
180 todo->addAlarm( alarm ); 180 todo->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 = alarmDt.secsTo( todo->dtStart() ); 184 int alarmOffset = alarmDt.secsTo( todo->dtStart() );
185 alarm->setStartOffset( alarmOffset ); 185 alarm->setStartOffset( alarmOffset );
186 alarmString = QString::number( alarmOffset ); 186 alarmString = QString::number( alarmOffset );
187 } 187 }
188 // csum ***************************************** 188 // csum *****************************************
189 QStringList attList; 189 QStringList attList;
190 uint cSum; 190 uint cSum;
191 if ( todo->hasDueDate() ) 191 if ( todo->hasDueDate() )
192 attList << dtToString ( todo->dtDue() ); 192 attList << dtToString ( todo->dtDue() );
193 attList << QString::number( id ); 193 attList << QString::number( id );
194 attList << todo->summary(); 194 attList << todo->summary();
195 attList << completedString; 195 attList << completedString;
196 attList << alarmString; 196 attList << QString::number( todo->priority() );
197 attList << alarmString;
197 attList << todo->categoriesStr(); 198 attList << todo->categoriesStr();
198 attList << todo->secrecyStr(); 199 attList << todo->secrecyStr();
199 cSum = PhoneFormat::getCsum(attList ); 200 cSum = PhoneFormat::getCsum(attList );
200 todo->setCsum( mProfileName, QString::number( cSum )); 201 todo->setCsum( mProfileName, QString::number( cSum ));
201 mCalendar->addTodo( todo); 202 mCalendar->addTodo( todo);
202 203
203 return true; 204 return true;
204 } 205 }
205 bool readEvent( Calendar *existingCalendar, GSM_CalendarEntry*Note) 206 bool readEvent( Calendar *existingCalendar, GSM_CalendarEntry*Note)
206 { 207 {
207 208
208 int id = Note->Location; 209 int id = Note->Location;
209 Event *event; 210 Event *event;
210 event = existingCalendar->event( mProfileName ,QString::number( id ) ); 211 event = existingCalendar->event( mProfileName ,QString::number( id ) );
211 if ( event ) 212 if ( event )
212 event = (Event*)event->clone(); 213 event = (Event*)event->clone();
213 else 214 else
214 event = new Event; 215 event = new Event;
215 event->setID( mProfileName,QString::number( id ) ); 216 event->setID( mProfileName,QString::number( id ) );
216 event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); 217 event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL );
217 218
218 219
219 int i = 0; 220 int i = 0;
220 bool repeating = false; 221 bool repeating = false;
221 int repeat_dayofweek = -1; 222 int repeat_dayofweek = -1;
222 int repeat_day = -1; 223 int repeat_day = -1;
223 int repeat_weekofmonth = -1; 224 int repeat_weekofmonth = -1;
224 int repeat_month = -1; 225 int repeat_month = -1;
225 int repeat_frequency = -1; 226 int repeat_frequency = -1;
226 int rec_type = -1; 227 int rec_type = -1;
227 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; 228 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0};
228 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; 229 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0};
229 GSM_DateTime* dtp; 230 GSM_DateTime* dtp;
230 bool alarm = false; 231 bool alarm = false;
231 QDateTime alarmDt; 232 QDateTime alarmDt;
232 repeat_startdate.Day= 0; 233 repeat_startdate.Day= 0;
233 repeat_stopdate.Day = 0; 234 repeat_stopdate.Day = 0;
234 for (i=0;i<Note->EntriesNum;i++) { 235 for (i=0;i<Note->EntriesNum;i++) {
235 236
236 qDebug(" for "); 237 qDebug(" for ");
237 switch (Note->Entries[i].EntryType) { 238 switch (Note->Entries[i].EntryType) {
238 case CAL_START_DATETIME: 239 case CAL_START_DATETIME:
239 dtp = &Note->Entries[i].Date ; 240 dtp = &Note->Entries[i].Date ;
240 if ( dtp->Hour > 24 ) { 241 if ( dtp->Hour > 24 ) {
241 event->setFloats( true ); 242 event->setFloats( true );
242 event->setDtStart( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); 243 event->setDtStart( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 )));
243 } else { 244 } else {
244 event->setDtStart (fromGSM ( dtp )); 245 event->setDtStart (fromGSM ( dtp ));
245 246
246 } 247 }
247 break; 248 break;
248 case CAL_END_DATETIME: 249 case CAL_END_DATETIME:
249 dtp = &Note->Entries[i].Date ; 250 dtp = &Note->Entries[i].Date ;
250 if ( dtp->Hour > 24 ) { 251 if ( dtp->Hour > 24 ) {
251 event->setFloats( true ); 252 event->setFloats( true );
252 event->setDtEnd( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); 253 event->setDtEnd( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 )));
253 } else { 254 } else {
254 event->setDtEnd (fromGSM ( dtp )); 255 event->setDtEnd (fromGSM ( dtp ));
255 } 256 }
256 break; 257 break;
257 case CAL_ALARM_DATETIME: 258 case CAL_ALARM_DATETIME:
258 dtp = &Note->Entries[i].Date ; 259 dtp = &Note->Entries[i].Date ;
259 alarm = true; 260 alarm = true;
260 alarmDt = fromGSM ( dtp ); 261 alarmDt = fromGSM ( dtp );
@@ -613,129 +614,129 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal ,QString profi
613 s.ConfigNum = 0; 614 s.ConfigNum = 0;
614 static char*cp; 615 static char*cp;
615 static INI_Section *cfg = NULL; 616 static INI_Section *cfg = NULL;
616 cfg=GSM_FindGammuRC(); 617 cfg=GSM_FindGammuRC();
617 int i; 618 int i;
618 for (i = 0; i <= MAX_CONFIG_NUM; i++) { 619 for (i = 0; i <= MAX_CONFIG_NUM; i++) {
619 if (cfg!=NULL) { 620 if (cfg!=NULL) {
620 cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false); 621 cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false);
621 if (cp) di.coding = cp; 622 if (cp) di.coding = cp;
622 623
623 s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false); 624 s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false);
624 if (s.Config[i].Localize) { 625 if (s.Config[i].Localize) {
625 s.msg=INI_ReadFile(s.Config[i].Localize, true); 626 s.msg=INI_ReadFile(s.Config[i].Localize, true);
626 } else { 627 } else {
627#if !defined(WIN32) && defined(LOCALE_PATH) 628#if !defined(WIN32) && defined(LOCALE_PATH)
628 locale = setlocale(LC_MESSAGES, NULL); 629 locale = setlocale(LC_MESSAGES, NULL);
629 if (locale != NULL) { 630 if (locale != NULL) {
630 snprintf(locale_file, 200, "%s/gammu_%c%c.txt", 631 snprintf(locale_file, 200, "%s/gammu_%c%c.txt",
631 LOCALE_PATH, 632 LOCALE_PATH,
632 tolower(locale[0]), 633 tolower(locale[0]),
633 tolower(locale[1])); 634 tolower(locale[1]));
634 s.msg = INI_ReadFile(locale_file, true); 635 s.msg = INI_ReadFile(locale_file, true);
635 } 636 }
636#endif 637#endif
637 } 638 }
638 } 639 }
639 640
640 /* Wanted user specific configuration? */ 641 /* Wanted user specific configuration? */
641 642
642 if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; 643 if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break;
643 644
644 s.ConfigNum++; 645 s.ConfigNum++;
645 646
646 /* We want to use only one file descriptor for global and state machine debug output */ 647 /* We want to use only one file descriptor for global and state machine debug output */
647 s.Config[i].UseGlobalDebugFile = true; 648 s.Config[i].UseGlobalDebugFile = true;
648 649
649 650
650 651
651 /* We wanted to read just user specified configuration. */ 652 /* We wanted to read just user specified configuration. */
652 {break;} 653 {break;}
653 } 654 }
654 655
655 int error=GSM_InitConnection(&s,3); 656 int error=GSM_InitConnection(&s,3);
656 qDebug(" init %d %d", error, ERR_NONE); 657 qDebug(" init %d %d", error, ERR_NONE);
657 if ( error != ERR_NONE ) 658 if ( error != ERR_NONE )
658 return false; 659 return false;
659 // fromString2Cal( calendar, existngCal, &s, "Event" ); 660 // fromString2Cal( calendar, existngCal, &s, "Event" );
660 GSM_Phone_Functions*Phone; 661 GSM_Phone_Functions*Phone;
661 GSM_CalendarEntrynote; 662 GSM_CalendarEntrynote;
662 bool refresh= true; 663 bool refresh= true;
663 Phone=s.Phone.Functions; 664 Phone=s.Phone.Functions;
664 bool gshutdown = false; 665 bool gshutdown = false;
665 PhoneParser handler( calendar, profileName ); 666 PhoneParser handler( calendar, profileName );
666 int ccc = 0; 667 int ccc = 0;
667 while (!gshutdown && ccc++ < 10 ) { 668 while (!gshutdown && ccc++ < 10 ) {
668 669
669 qDebug("readEvent %d ", ccc); 670 qDebug("readEvent %d ", ccc);
670 error=Phone->GetNextCalendar(&s,&note,refresh); 671 error=Phone->GetNextCalendar(&s,&note,refresh);
671 if (error == ERR_EMPTY) break; 672 if (error == ERR_EMPTY) break;
672 handler.readEvent( existingCal, &note ); 673 handler.readEvent( existingCal, &note );
673 } 674 }
674 675
675 bool start = true; 676 bool start = true;
676 GSM_ToDoEntry ToDo; 677 GSM_ToDoEntry ToDo;
677 int ccc = 0; 678 ccc = 0;
678 while (!gshutdown) { 679 while (!gshutdown) {
679 error = Phone->GetNextToDo(&s, &ToDo, start); 680 error = Phone->GetNextToDo(&s, &ToDo, start);
680 if (error == ERR_EMPTY) break; 681 if (error == ERR_EMPTY) break;
681 start = false; 682 start = false;
682 qDebug("readTodo %d ", ++ccc); 683 qDebug("readTodo %d ", ++ccc);
683 handler.readTodo( existingCal, &ToDo, &s); 684 handler.readTodo( existingCal, &ToDo, &s);
684 685
685 } 686 }
686 687
687 error=GSM_TerminateConnection(&s); 688 error=GSM_TerminateConnection(&s);
688 689
689 return true; 690 return true;
690} 691}
691 692
692bool PhoneFormat::save( Calendar *calendar) 693bool PhoneFormat::save( Calendar *calendar)
693{ 694{
694#if 0 695#if 0
695 QLabel status ( i18n("Processing/adding events ..."), 0 ); 696 QLabel status ( i18n("Processing/adding events ..."), 0 );
696 int w = status.sizeHint().width()+20 ; 697 int w = status.sizeHint().width()+20 ;
697 if ( w < 200 ) w = 200; 698 if ( w < 200 ) w = 200;
698 int h = status.sizeHint().height()+20 ; 699 int h = status.sizeHint().height()+20 ;
699 int dw = QApplication::desktop()->width(); 700 int dw = QApplication::desktop()->width();
700 int dh = QApplication::desktop()->height(); 701 int dh = QApplication::desktop()->height();
701 status.setCaption(i18n("Writing DTM Data") ); 702 status.setCaption(i18n("Writing DTM Data") );
702 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 703 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
703 status.show(); 704 status.show();
704 status.raise(); 705 status.raise();
705 qApp->processEvents(); 706 qApp->processEvents();
706 bool debug = DEBUGMODE; 707 bool debug = DEBUGMODE;
707 QString codec = "utf8"; 708 QString codec = "utf8";
708 QString answer; 709 QString answer;
709 QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n"; 710 QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n";
710 QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; 711 QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n";
711 QString command; 712 QString command;
712 QPtrList<Event> er = calendar->rawEvents(); 713 QPtrList<Event> er = calendar->rawEvents();
713 Event* ev = er.first(); 714 Event* ev = er.first();
714 QString fileName = "/tmp/kopitempout"; 715 QString fileName = "/tmp/kopitempout";
715 int i = 0; 716 int i = 0;
716 QString changeString = ePrefix; 717 QString changeString = ePrefix;
717 QString deleteString = ePrefix; 718 QString deleteString = ePrefix;
718 bool deleteEnt = false; 719 bool deleteEnt = false;
719 bool changeEnt = false; 720 bool changeEnt = false;
720 QString message = i18n("Processing event # "); 721 QString message = i18n("Processing event # ");
721 int procCount = 0; 722 int procCount = 0;
722 while ( ev ) { 723 while ( ev ) {
723 //qDebug("i %d ", ++i); 724 //qDebug("i %d ", ++i);
724 if ( true /*ev->zaurusStat() != -2*/ ) { 725 if ( true /*ev->zaurusStat() != -2*/ ) {
725 status.setText ( message + QString::number ( ++procCount ) ); 726 status.setText ( message + QString::number ( ++procCount ) );
726 qApp->processEvents(); 727 qApp->processEvents();
727 QString eString = getEventString( ev ); 728 QString eString = getEventString( ev );
728 if (/* ev->zaurusStat() == -3 */ true) { // delete 729 if (/* ev->zaurusStat() == -3 */ true) { // delete
729 // deleting empty strings does not work. 730 // deleting empty strings does not work.
730 // we write first and x and then delete the record with the x 731 // we write first and x and then delete the record with the x
731 eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); 732 eString = eString.replace( QRegExp(",\"\""),",\"x\"" );
732 changeString += eString + "\n"; 733 changeString += eString + "\n";
733 deleteString += eString + "\n"; 734 deleteString += eString + "\n";
734 deleteEnt = true; 735 deleteEnt = true;
735 changeEnt = true; 736 changeEnt = true;
736 } 737 }
737 else if ( /*ev->zaurusId() == -1*/true ) { // add new 738 else if ( /*ev->zaurusId() == -1*/true ) { // add new
738 command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; 739 command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
739 system ( command.utf8() ); 740 system ( command.utf8() );
740 QFile file( fileName ); 741 QFile file( fileName );
741 if (!file.open( IO_ReadOnly ) ) { 742 if (!file.open( IO_ReadOnly ) ) {