summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2004-10-06 00:33:20 (UTC)
committer zautrix <zautrix>2004-10-06 00:33:20 (UTC)
commit07fa092b413b7cde1bd4fc797ce0b30adcb8668d (patch) (unidiff)
tree34b54fe692412be32d26bd85dbbb77bafcfe8efa /libkcal
parent191ced43b27c047b0a39f0acdc8ba1f8a58817df (diff)
downloadkdepimpi-07fa092b413b7cde1bd4fc797ce0b30adcb8668d.zip
kdepimpi-07fa092b413b7cde1bd4fc797ce0b30adcb8668d.tar.gz
kdepimpi-07fa092b413b7cde1bd4fc797ce0b30adcb8668d.tar.bz2
export to phone added
Diffstat (limited to 'libkcal') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/phoneformat.cpp66
-rw-r--r--libkcal/phoneformat.h2
2 files changed, 43 insertions, 25 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index 29c1ae6..b2a62b1 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -39,192 +39,200 @@
39 39
40#include "calendar.h" 40#include "calendar.h"
41#include "alarm.h" 41#include "alarm.h"
42#include "recurrence.h" 42#include "recurrence.h"
43#include "calendarlocal.h" 43#include "calendarlocal.h"
44 44
45#include "phoneformat.h" 45#include "phoneformat.h"
46#include "syncdefines.h" 46#include "syncdefines.h"
47 47
48using namespace KCal; 48using namespace KCal;
49class PhoneParser : public QObject 49class PhoneParser : public QObject
50{ 50{
51public: 51public:
52 PhoneParser( ) { 52 PhoneParser( ) {
53 ; 53 ;
54 } 54 }
55 55
56 static QString dtToString( const QDateTime& dti, bool useTZ = false ) 56 static QString dtToString( const QDateTime& dti, bool useTZ = false )
57 { 57 {
58 QString datestr; 58 QString datestr;
59 QString timestr; 59 QString timestr;
60 int offset = KGlobal::locale()->localTimeOffset( dti ); 60 int offset = KGlobal::locale()->localTimeOffset( dti );
61 QDateTime dt; 61 QDateTime dt;
62 if (useTZ) 62 if (useTZ)
63 dt = dti.addSecs ( -(offset*60)); 63 dt = dti.addSecs ( -(offset*60));
64 else 64 else
65 dt = dti; 65 dt = dti;
66 if(dt.date().isValid()){ 66 if(dt.date().isValid()){
67 const QDate& date = dt.date(); 67 const QDate& date = dt.date();
68 datestr.sprintf("%04d%02d%02d", 68 datestr.sprintf("%04d%02d%02d",
69 date.year(), date.month(), date.day()); 69 date.year(), date.month(), date.day());
70 } 70 }
71 if(dt.time().isValid()){ 71 if(dt.time().isValid()){
72 const QTime& time = dt.time(); 72 const QTime& time = dt.time();
73 timestr.sprintf("T%02d%02d%02d", 73 timestr.sprintf("T%02d%02d%02d",
74 time.hour(), time.minute(), time.second()); 74 time.hour(), time.minute(), time.second());
75 } 75 }
76 return datestr + timestr; 76 return datestr + timestr;
77 } 77 }
78 78
79 79
80}; 80};
81 81
82 82
83 83
84PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) 84PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model )
85{ 85{
86 mProfileName = profileName; 86 mProfileName = profileName;
87 writeConfig( device, connection, model );
88}
87 89
90PhoneFormat::~PhoneFormat()
91{
92}
93void PhoneFormat::writeConfig( QString device, QString connection, QString model )
94{
95#ifdef _WIN32_
96 QString fileName = qApp->applicationDirPath () +"\\gammurc";
97#else
88 QString fileName = QDir::homeDirPath() +"/.gammurc"; 98 QString fileName = QDir::homeDirPath() +"/.gammurc";
99#endif
89 //qDebug("save %d ", load ); 100 //qDebug("save %d ", load );
90 QString content; 101 QString content;
91 bool write = false; 102 bool write = false;
92 bool addPort = true, addConnection = true, addModel = true; 103 bool addPort = true, addConnection = true, addModel = true;
93 QFile file( fileName ); 104 QFile file( fileName );
94 if ( QFile::exists( fileName) ) { 105 if ( QFile::exists( fileName) ) {
95 if (!file.open( IO_ReadOnly ) ) { 106 if (!file.open( IO_ReadOnly ) ) {
96 qDebug("Error: cannot open %s ", fileName.latin1() ); 107 qDebug("Error: cannot open %s ", fileName.latin1() );
97 return; 108 return;
98 } 109 }
99 QString line; 110 QString line;
100 while ( file.readLine( line, 1024 ) > 0 ) { 111 while ( file.readLine( line, 1024 ) > 0 ) {
101 //qDebug("*%s* ", line.latin1() ); 112 //qDebug("*%s* ", line.latin1() );
102 if ( line.left(7 ) == "[gammu]" ) { 113 if ( line.left(7 ) == "[gammu]" ) {
103 ; 114 ;
104 } else 115 } else
105 if ( line.left(4 ) == "port" ) { 116 if ( line.left(4 ) == "port" ) {
106 if ( line == "port = " + device+"\n" ) { 117 if ( line == "port = " + device+"\n" ) {
107 content += line ; 118 content += line ;
108 addPort = false; 119 addPort = false;
109 //qDebug("port found" ); 120 //qDebug("port found" );
110 } 121 }
111 122
112 } else if ( line.left(5 ) == "model" ) { 123 } else if ( line.left(5 ) == "model" ) {
113 if ( line == "model = " + model +"\n") { 124 if ( line == "model = " + model +"\n") {
114 content += line ; 125 content += line ;
115 addModel = false; 126 addModel = false;
116 //qDebug("model found" ); 127 //qDebug("model found" );
117 } 128 }
118 129
119 } else if ( line.left( 10 ) == "connection" ) { 130 } else if ( line.left( 10 ) == "connection" ) {
120 if ( line == "connection = " + connection +"\n") { 131 if ( line == "connection = " + connection +"\n") {
121 addConnection = false; 132 addConnection = false;
122 content += line ; 133 content += line ;
123 //qDebug("con found" ); 134 //qDebug("con found" );
124 } 135 }
125 136
126 } else { 137 } else {
127 content += line ; 138 content += line ;
128 } 139 }
129 } 140 }
130 file.close(); 141 file.close();
131 } else { 142 } else {
132 if ( ! connection.isEmpty() ) { 143 if ( ! connection.isEmpty() ) {
133 addConnection = true; 144 addConnection = true;
134 } 145 }
135 if ( ! device.isEmpty() ) { 146 if ( ! device.isEmpty() ) {
136 addPort = true; 147 addPort = true;
137 148
138 } 149 }
139 if ( ! model.isEmpty() ) { 150 if ( ! model.isEmpty() ) {
140 addModel = true; 151 addModel = true;
141 } 152 }
142 } 153 }
143 154
144 if ( addConnection ) { 155 if ( addConnection ) {
145 if ( ! write ) 156 if ( ! write )
146 content += "[gammu]\n"; 157 content += "[gammu]\n";
147 write = true; 158 write = true;
148 content += "connection = "; 159 content += "connection = ";
149 content += connection; 160 content += connection;
150 content += "\n"; 161 content += "\n";
151 } 162 }
152 if ( addPort ) { 163 if ( addPort ) {
153 if ( ! write ) 164 if ( ! write )
154 content += "[gammu]\n"; 165 content += "[gammu]\n";
155 write = true; 166 write = true;
156 content += "port = "; 167 content += "port = ";
157 content += device; 168 content += device;
158 content += "\n"; 169 content += "\n";
159 170
160 } 171 }
161 if ( addModel ) { 172 if ( addModel ) {
162 if ( ! write ) 173 if ( ! write )
163 content += "[gammu]\n"; 174 content += "[gammu]\n";
164 write = true; 175 write = true;
165 content += "model = "; 176 content += "model = ";
166 content += model; 177 content += model;
167 content += "\n"; 178 content += "\n";
168 } 179 }
169 if ( write ) { 180 if ( write ) {
170 if (!file.open( IO_WriteOnly ) ) { 181 if (!file.open( IO_WriteOnly ) ) {
171 qDebug("Error: cannot write file %s ", fileName.latin1() ); 182 qDebug("Error: cannot write file %s ", fileName.latin1() );
172 return; 183 return;
173 } 184 }
174 qDebug("Writing file %s ", fileName.latin1() ); 185 qDebug("Writing file %s ", fileName.latin1() );
175 QTextStream ts( &file ); 186 QTextStream ts( &file );
176 ts << content ; 187 ts << content ;
177 file.close(); 188 file.close();
178 } 189 }
179}
180 190
181PhoneFormat::~PhoneFormat()
182{
183} 191}
184#if 0 192#if 0
185int PhoneFormat::initDevice(GSM_StateMachine *s) 193int PhoneFormat::initDevice(GSM_StateMachine *s)
186{ 194{
187 GSM_ReadConfig(NULL, &s->Config[0], 0); 195 GSM_ReadConfig(NULL, &s->Config[0], 0);
188 s->ConfigNum = 1; 196 s->ConfigNum = 1;
189 GSM_Config *cfg = &s->Config[0]; 197 GSM_Config *cfg = &s->Config[0];
190 if ( ! mConnection.isEmpty() ) { 198 if ( ! mConnection.isEmpty() ) {
191 cfg->Connection = strdup(mConnection.latin1()); 199 cfg->Connection = strdup(mConnection.latin1());
192 cfg->DefaultConnection = false; 200 cfg->DefaultConnection = false;
193 qDebug("Connection set %s ", cfg->Connection ); 201 qDebug("Connection set %s ", cfg->Connection );
194 202
195 } 203 }
196 if ( ! mDevice.isEmpty() ) { 204 if ( ! mDevice.isEmpty() ) {
197 cfg->Device = strdup(mDevice.latin1()); 205 cfg->Device = strdup(mDevice.latin1());
198 cfg->DefaultDevice = false; 206 cfg->DefaultDevice = false;
199 qDebug("Device set %s ", cfg->Device); 207 qDebug("Device set %s ", cfg->Device);
200 208
201 } 209 }
202 if ( ! mModel.isEmpty() ) { 210 if ( ! mModel.isEmpty() ) {
203 strcpy(cfg->Model,mModel.latin1() ); 211 strcpy(cfg->Model,mModel.latin1() );
204 cfg->DefaultModel = false; 212 cfg->DefaultModel = false;
205 qDebug("Model set %s ",cfg->Model ); 213 qDebug("Model set %s ",cfg->Model );
206 } 214 }
207 int error=GSM_InitConnection(s,3); 215 int error=GSM_InitConnection(s,3);
208 return error; 216 return error;
209} 217}
210#endif 218#endif
211ulong PhoneFormat::getCsumTodo( Todo* todo ) 219ulong PhoneFormat::getCsumTodo( Todo* todo )
212{ 220{
213 QStringList attList; 221 QStringList attList;
214 if ( todo->hasDueDate() ) 222 if ( todo->hasDueDate() )
215 attList << PhoneParser::dtToString ( todo->dtDue() ); 223 attList << PhoneParser::dtToString ( todo->dtDue() );
216 attList << todo->summary(); 224 attList << todo->summary();
217 QString completedString = "no"; 225 QString completedString = "no";
218 if ( todo->isCompleted() ) 226 if ( todo->isCompleted() )
219 completedString = "yes"; 227 completedString = "yes";
220 attList << completedString; 228 attList << completedString;
221 int prio = todo->priority(); 229 int prio = todo->priority();
222 if( prio == 2 ) prio = 1; 230 if( prio == 2 ) prio = 1;
223 if (prio == 4 ) prio = 5 ; 231 if (prio == 4 ) prio = 5 ;
224 attList << QString::number( prio ); 232 attList << QString::number( prio );
225 QString alarmString = "na"; 233 QString alarmString = "na";
226 Alarm *alarm; 234 Alarm *alarm;
227 if ( todo->alarms().count() > 0 ) { 235 if ( todo->alarms().count() > 0 ) {
228 alarm = todo->alarms().first(); 236 alarm = todo->alarms().first();
229 if ( alarm->enabled() ) { 237 if ( alarm->enabled() ) {
230 alarmString = QString::number(alarm->offset() ); 238 alarmString = QString::number(alarm->offset() );
@@ -524,159 +532,167 @@ void PhoneFormat::copyTodo( Todo* to, Todo* from )
524 if ( a->hasTime() ) 532 if ( a->hasTime() )
525 b->setTime( a->time() ); 533 b->setTime( a->time() );
526 } 534 }
527 535
528 QStringList cat = to->categories(); 536 QStringList cat = to->categories();
529 QStringList catFrom = from->categories(); 537 QStringList catFrom = from->categories();
530 QString nCat; 538 QString nCat;
531 int iii; 539 int iii;
532 for ( iii = 0; iii < catFrom.count();++iii ) { 540 for ( iii = 0; iii < catFrom.count();++iii ) {
533 nCat = catFrom[iii]; 541 nCat = catFrom[iii];
534 if ( !nCat.isEmpty() ) 542 if ( !nCat.isEmpty() )
535 if ( !cat.contains( nCat )) { 543 if ( !cat.contains( nCat )) {
536 cat << nCat; 544 cat << nCat;
537 } 545 }
538 } 546 }
539 to->setCategories( cat ); 547 to->setCategories( cat );
540 if ( from->isCompleted() ) { 548 if ( from->isCompleted() ) {
541 to->setCompleted( true ); 549 to->setCompleted( true );
542 if( from->completed().isValid() ) 550 if( from->completed().isValid() )
543 to->setCompleted( from->completed() ); 551 to->setCompleted( from->completed() );
544 } else { 552 } else {
545 // set percentcomplete only, if to->isCompleted() 553 // set percentcomplete only, if to->isCompleted()
546 if ( to->isCompleted() ) 554 if ( to->isCompleted() )
547 to->setPercentComplete(from->percentComplete()); 555 to->setPercentComplete(from->percentComplete());
548 } 556 }
549 if( to->priority() == 2 && from->priority() == 1 ) 557 if( to->priority() == 2 && from->priority() == 1 )
550 ; //skip 558 ; //skip
551 else if (to->priority() == 4 && from->priority() == 5 ) 559 else if (to->priority() == 4 && from->priority() == 5 )
552 ; 560 ;
553 else 561 else
554 to->setPriority(from->priority()); 562 to->setPriority(from->priority());
555 563
556} 564}
557#include <qcstring.h> 565#include <qcstring.h>
558 566
559void PhoneFormat::afterSave( Incidence* inc) 567void PhoneFormat::afterSave( Incidence* inc)
560{ 568{
561 uint csum; 569 uint csum;
562 inc->removeID( mProfileName ); 570 inc->removeID( mProfileName );
563 if ( inc->type() == "Event") 571 if ( inc->type() == "Event")
564 csum = PhoneFormat::getCsumEvent( (Event*) inc ); 572 csum = PhoneFormat::getCsumEvent( (Event*) inc );
565 else 573 else
566 csum = PhoneFormat::getCsumTodo( (Todo*) inc ); 574 csum = PhoneFormat::getCsumTodo( (Todo*) inc );
567 inc->setCsum( mProfileName, QString::number( csum )); 575 inc->setCsum( mProfileName, QString::number( csum ));
568 576
569 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 577 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
570 578
571} 579}
580
581bool PhoneFormat::writeToPhone( Calendar * calendar)
582{
583#ifdef _WIN32_
584 QString fileName = locateLocal("tmp", "tempfile.vcs");
585#else
586 QString fileName = "/tmp/kdepimtemp.vcs";
587#endif
588
589 VCalFormat vfsave;
590 vfsave.setLocalTime ( true );
591 if ( ! vfsave.save( calendar, fileName ) )
592 return false;
593 // 4 call kammu
594#ifdef DESKTOP_VERSION
595 QString command ="./kammu --restore " + fileName ;
596#else
597 QString command ="kammu --restore " + fileName ;
598#endif
599 int ret;
600 while ( (ret = system ( command.latin1())) != 0 ) {
601 qDebug("Error S::command returned %d. asking users", ret);
602 int retval = KMessageBox::warningContinueCancel(0,
603 i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone access"),i18n("Retry"),i18n("Cancel"));
604 if ( retval != KMessageBox::Continue )
605 return false;
606 }
607 return true;
608}
572bool PhoneFormat::save( Calendar *calendar) 609bool PhoneFormat::save( Calendar *calendar)
573{ 610{
574 QLabel status ( i18n(" Opening device ..."), 0 ); 611 QLabel status ( i18n(" Opening device ..."), 0 );
575 int w = status.sizeHint().width()+20 ; 612 int w = status.sizeHint().width()+20 ;
576 if ( w < 200 ) w = 230; 613 if ( w < 200 ) w = 230;
577 int h = status.sizeHint().height()+20 ; 614 int h = status.sizeHint().height()+20 ;
578 int dw = QApplication::desktop()->width(); 615 int dw = QApplication::desktop()->width();
579 int dh = QApplication::desktop()->height(); 616 int dh = QApplication::desktop()->height();
580 status.setCaption(i18n("Writing to phone...") ); 617 status.setCaption(i18n("Writing to phone...") );
581 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 618 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
582 status.show(); 619 status.show();
583 status.raise(); 620 status.raise();
584 qApp->processEvents(); 621 qApp->processEvents();
585 QString message; 622 QString message;
586#ifdef _WIN32_
587 QString fileName = locateLocal("tmp", "tempfile.vcs");
588#else
589 QString fileName = "/tmp/kdepimtemp.vcs";
590#endif
591 623
592 // 1 remove events which should be deleted 624 // 1 remove events which should be deleted
593 QPtrList<Event> er = calendar->rawEvents(); 625 QPtrList<Event> er = calendar->rawEvents();
594 Event* ev = er.first(); 626 Event* ev = er.first();
595 while ( ev ) { 627 while ( ev ) {
596 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { 628 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
597 calendar->deleteEvent( ev ); 629 calendar->deleteEvent( ev );
598 } else { 630 } else {
599 631
600 } 632 }
601 ev = er.next(); 633 ev = er.next();
602 } 634 }
603 // 2 remove todos which should be deleted 635 // 2 remove todos which should be deleted
604 QPtrList<Todo> tl = calendar->rawTodos(); 636 QPtrList<Todo> tl = calendar->rawTodos();
605 Todo* to = tl.first(); 637 Todo* to = tl.first();
606 while ( to ) { 638 while ( to ) {
607 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { 639 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
608 calendar->deleteTodo( to ); 640 calendar->deleteTodo( to );
609 } else { 641 } else {
610 if ( to->isCompleted()) { 642 if ( to->isCompleted()) {
611 calendar->deleteTodo( to ); 643 calendar->deleteTodo( to );
612 } 644 }
613 } 645 }
614 to = tl.next(); 646 to = tl.next();
615 } 647 }
616 // 3 save file 648 // 3 save file
617 VCalFormat vfsave; 649 if ( !writeToPhone( calendar ) )
618 vfsave.setLocalTime ( true );
619 if ( ! vfsave.save( calendar, fileName ) )
620 return false;
621 // 4 call kammu
622#ifdef DESKTOP_VERSION
623 QString command ="./kammu --restore " + fileName ;
624#else
625 QString command ="kammu --restore " + fileName ;
626#endif
627 int ret;
628 while ( (ret = system ( command.latin1())) != 0 ) {
629 qDebug("Error S::command returned %d. asking users", ret);
630 int retval = KMessageBox::warningContinueCancel(0,
631 i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone sync"),i18n("Retry"),i18n("Cancel"));
632 if ( retval != KMessageBox::Continue )
633 return false; 650 return false;
634 }
635 651
636 // 5 reread data 652 // 5 reread data
637 message = i18n(" Rereading all data ... "); 653 message = i18n(" Rereading all data ... ");
638 status.setText ( message ); 654 status.setText ( message );
639 qApp->processEvents(); 655 qApp->processEvents();
640 CalendarLocal* calendarTemp = new CalendarLocal(); 656 CalendarLocal* calendarTemp = new CalendarLocal();
641 calendarTemp->setTimeZoneId( calendar->timeZoneId()); 657 calendarTemp->setTimeZoneId( calendar->timeZoneId());
642 if ( ! load( calendarTemp,calendar) ){ 658 if ( ! load( calendarTemp,calendar) ){
643 qDebug("error reloading calendar "); 659 qDebug("error reloading calendar ");
644 delete calendarTemp; 660 delete calendarTemp;
645 return false; 661 return false;
646 } 662 }
647 // 6 compare data 663 // 6 compare data
648 664
649//algo 6 compare event 665//algo 6 compare event
650 er = calendar->rawEvents(); 666 er = calendar->rawEvents();
651 ev = er.first(); 667 ev = er.first();
652 message = i18n(" Comparing event # "); 668 message = i18n(" Comparing event # ");
653 QPtrList<Event> er1 = calendarTemp->rawEvents(); 669 QPtrList<Event> er1 = calendarTemp->rawEvents();
654 Event* ev1; 670 Event* ev1;
655 int procCount = 0; 671 int procCount = 0;
656 while ( ev ) { 672 while ( ev ) {
657 //qDebug("event new ID %s",ev->summary().latin1()); 673 //qDebug("event new ID %s",ev->summary().latin1());
658 status.setText ( message + QString::number ( ++procCount ) ); 674 status.setText ( message + QString::number ( ++procCount ) );
659 qApp->processEvents(); 675 qApp->processEvents();
660 uint csum; 676 uint csum;
661 csum = PhoneFormat::getCsumEvent( ev ); 677 csum = PhoneFormat::getCsumEvent( ev );
662 QString cSum = QString::number( csum ); 678 QString cSum = QString::number( csum );
663 //ev->setCsum( mProfileName, cSum ); 679 //ev->setCsum( mProfileName, cSum );
664 //qDebug("Event cSum %s ", cSum.latin1()); 680 //qDebug("Event cSum %s ", cSum.latin1());
665 ev1 = er1.first(); 681 ev1 = er1.first();
666 while ( ev1 ) { 682 while ( ev1 ) {
667 if ( ev1->getCsum( mProfileName ) == cSum ) { 683 if ( ev1->getCsum( mProfileName ) == cSum ) {
668 er1.remove( ev1 ); 684 er1.remove( ev1 );
669 afterSave( ev ); 685 afterSave( ev );
670 ev->setID(mProfileName, ev1->getID(mProfileName) ); 686 ev->setID(mProfileName, ev1->getID(mProfileName) );
671 //qDebug("Event found on phone for %s ", ev->summary().latin1()); 687 //qDebug("Event found on phone for %s ", ev->summary().latin1());
672 688
673 break; 689 break;
674 } 690 }
675 ev1 = er1.next(); 691 ev1 = er1.next();
676 } 692 }
677 if ( ! ev1 ) { 693 if ( ! ev1 ) {
678 // ev->removeID(mProfileName); 694 // ev->removeID(mProfileName);
679 qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); 695 qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1());
680 } 696 }
681 697
682 698
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h
index 2d1ff79..61e8160 100644
--- a/libkcal/phoneformat.h
+++ b/libkcal/phoneformat.h
@@ -3,59 +3,61 @@
3 3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21#ifndef PHONEFORMAT_H 21#ifndef PHONEFORMAT_H
22#define PHONEFORMAT_H 22#define PHONEFORMAT_H
23 23
24#include <qstring.h> 24#include <qstring.h>
25 25
26#include "scheduler.h" 26#include "scheduler.h"
27 27
28#include "vcalformat.h" 28#include "vcalformat.h"
29#include "calformat.h" 29#include "calformat.h"
30 30
31namespace KCal { 31namespace KCal {
32 32
33/** 33/**
34 This class implements the calendar format used by Phone. 34 This class implements the calendar format used by Phone.
35*/ 35*/
36 class Event; 36 class Event;
37 class Todo; 37 class Todo;
38class PhoneFormat : public QObject { 38class PhoneFormat : public QObject {
39 public: 39 public:
40 /** Create new iCalendar format. */ 40 /** Create new iCalendar format. */
41 PhoneFormat(QString profileName, QString device,QString connection, QString model); 41 PhoneFormat(QString profileName, QString device,QString connection, QString model);
42 virtual ~PhoneFormat(); 42 virtual ~PhoneFormat();
43 43
44 bool load( Calendar * ,Calendar * ); 44 bool load( Calendar * ,Calendar * );
45 bool save( Calendar * ); 45 bool save( Calendar * );
46 bool fromString( Calendar *, const QString & ); 46 bool fromString( Calendar *, const QString & );
47 QString toString( Calendar * ); 47 QString toString( Calendar * );
48 static ulong getCsum( const QStringList & ); 48 static ulong getCsum( const QStringList & );
49 static ulong getCsumTodo( Todo* to ); 49 static ulong getCsumTodo( Todo* to );
50 static ulong getCsumEvent( Event* ev ); 50 static ulong getCsumEvent( Event* ev );
51 static void writeConfig( QString device,QString connection, QString model );
52 static bool writeToPhone( Calendar * );
51 private: 53 private:
52 void copyEvent( Event* to, Event* from ); 54 void copyEvent( Event* to, Event* from );
53 void copyTodo( Todo* to, Todo* from ); 55 void copyTodo( Todo* to, Todo* from );
54 //int initDevice(GSM_StateMachine *s); 56 //int initDevice(GSM_StateMachine *s);
55 QString mProfileName; 57 QString mProfileName;
56 void afterSave( Incidence* ); 58 void afterSave( Incidence* );
57}; 59};
58 60
59} 61}
60 62
61#endif 63#endif