summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-08-09 16:39:16 (UTC)
committer zautrix <zautrix>2004-08-09 16:39:16 (UTC)
commite1909ade2188e53feee65089d5f2882563876c58 (patch) (unidiff)
treef812864838ff03b2758a27dd3fd77504a8295474
parentecdcad49975976ff877ff506fae3b14934c01898 (diff)
downloadkdepimpi-e1909ade2188e53feee65089d5f2882563876c58.zip
kdepimpi-e1909ade2188e53feee65089d5f2882563876c58.tar.gz
kdepimpi-e1909ade2188e53feee65089d5f2882563876c58.tar.bz2
added status info
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/phoneformat.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index e43a507..11c68c5 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -761,24 +761,35 @@ ulong PhoneFormat::getCsum( const QStringList & attList)
761 761
762} 762}
763//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); 763//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum);
764#include <stdlib.h> 764#include <stdlib.h>
765#define DEBUGMODE false 765#define DEBUGMODE false
766bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) 766bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
767{ 767{
768 GSM_StateMachines; 768 GSM_StateMachines;
769 qDebug(" load "); 769 qDebug(" load ");
770 s.opened = false; 770 s.opened = false;
771 s.msg = NULL; 771 s.msg = NULL;
772 s.ConfigNum = 0; 772 s.ConfigNum = 0;
773 QLabel status ( i18n("Reading data. Opening device ..."), 0 );
774 int w = status.sizeHint().width()+20 ;
775 if ( w < 200 ) w = 200;
776 int h = status.sizeHint().height()+20 ;
777 int dw = QApplication::desktop()->width();
778 int dh = QApplication::desktop()->height();
779 status.setCaption(i18n("Reading Phone Data") );
780 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
781 status.show();
782 status.raise();
783 qApp->processEvents();
773#if 0 784#if 0
774 static char*cp; 785 static char*cp;
775 static INI_Section *cfg = NULL; 786 static INI_Section *cfg = NULL;
776 cfg=GSM_FindGammuRC(); 787 cfg=GSM_FindGammuRC();
777 int i; 788 int i;
778 for (i = 0; i <= MAX_CONFIG_NUM; i++) { 789 for (i = 0; i <= MAX_CONFIG_NUM; i++) {
779 if (cfg!=NULL) { 790 if (cfg!=NULL) {
780 cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false); 791 cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false);
781 if (cp) di.coding = cp; 792 if (cp) di.coding = cp;
782 793
783 s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false); 794 s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false);
784 if (s.Config[i].Localize) { 795 if (s.Config[i].Localize) {
@@ -815,38 +826,45 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
815#endif 826#endif
816 int error=initDevice(&s); 827 int error=initDevice(&s);
817 qDebug("GSM Init %d (no error is %d)", error, ERR_NONE); 828 qDebug("GSM Init %d (no error is %d)", error, ERR_NONE);
818 if ( error != ERR_NONE ) 829 if ( error != ERR_NONE )
819 return false; 830 return false;
820 GSM_Phone_Functions*Phone; 831 GSM_Phone_Functions*Phone;
821 GSM_CalendarEntrynote; 832 GSM_CalendarEntrynote;
822 bool start = true; 833 bool start = true;
823 Phone=s.Phone.Functions; 834 Phone=s.Phone.Functions;
824 bool gshutdown = false; 835 bool gshutdown = false;
825 PhoneParser handler( calendar, mProfileName ); 836 PhoneParser handler( calendar, mProfileName );
826 int ccc = 0; 837 int ccc = 0;
838 QString message = i18n("Processing event # ");
839 int procCount = 0;
827 qDebug("Debug: only 10 calender items are downloaded "); 840 qDebug("Debug: only 10 calender items are downloaded ");
828 while (!gshutdown && ccc++ < 10) { 841 while (!gshutdown && ccc++ < 10) {
829 842 status.setText ( message + QString::number ( ++procCount ) );
843 qApp->processEvents();
830 qDebug("readEvent %d ", ccc); 844 qDebug("readEvent %d ", ccc);
831 error=Phone->GetNextCalendar(&s,&note,start); 845 error=Phone->GetNextCalendar(&s,&note,start);
832 if (error == ERR_EMPTY) break; 846 if (error == ERR_EMPTY) break;
833 start = false; 847 start = false;
834 handler.readEvent( existingCal, &note ); 848 handler.readEvent( existingCal, &note );
835 } 849 }
836 850
837 start = true; 851 start = true;
838 GSM_ToDoEntry ToDo; 852 GSM_ToDoEntry ToDo;
839 ccc = 0; 853 ccc = 0;
854 message = i18n("Processing todo # ");
855 procCount = 0;
840 while (!gshutdown) { 856 while (!gshutdown) {
857 status.setText ( message + QString::number ( ++procCount ) );
858 qApp->processEvents();
841 error = Phone->GetNextToDo(&s, &ToDo, start); 859 error = Phone->GetNextToDo(&s, &ToDo, start);
842 if (error == ERR_EMPTY) break; 860 if (error == ERR_EMPTY) break;
843 start = false; 861 start = false;
844 qDebug("ReadTodo %d ", ++ccc); 862 qDebug("ReadTodo %d ", ++ccc);
845 handler.readTodo( existingCal, &ToDo, &s); 863 handler.readTodo( existingCal, &ToDo, &s);
846 864
847 } 865 }
848 866
849 error=GSM_TerminateConnection(&s); 867 error=GSM_TerminateConnection(&s);
850 868
851 return true; 869 return true;
852} 870}
@@ -921,25 +939,25 @@ bool PhoneFormat::save( Calendar *calendar)
921{ 939{
922 GSM_StateMachines; 940 GSM_StateMachines;
923 qDebug(" save "); 941 qDebug(" save ");
924 s.opened = false; 942 s.opened = false;
925 s.msg = NULL; 943 s.msg = NULL;
926 s.ConfigNum = 0; 944 s.ConfigNum = 0;
927 QLabel status ( i18n("Writing data. Opening device ..."), 0 ); 945 QLabel status ( i18n("Writing data. Opening device ..."), 0 );
928 int w = status.sizeHint().width()+20 ; 946 int w = status.sizeHint().width()+20 ;
929 if ( w < 200 ) w = 200; 947 if ( w < 200 ) w = 200;
930 int h = status.sizeHint().height()+20 ; 948 int h = status.sizeHint().height()+20 ;
931 int dw = QApplication::desktop()->width(); 949 int dw = QApplication::desktop()->width();
932 int dh = QApplication::desktop()->height(); 950 int dh = QApplication::desktop()->height();
933 status.setCaption(i18n("Writing DTM Data") ); 951 status.setCaption(i18n("Writing Phone Data") );
934 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 952 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
935 status.show(); 953 status.show();
936 status.raise(); 954 status.raise();
937 qApp->processEvents(); 955 qApp->processEvents();
938 956
939 int error=initDevice(&s); 957 int error=initDevice(&s);
940 qDebug("GSM Init %d (no error is %d)", error, ERR_NONE); 958 qDebug("GSM Init %d (no error is %d)", error, ERR_NONE);
941 if ( error != ERR_NONE ) 959 if ( error != ERR_NONE )
942 return false; 960 return false;
943 GSM_Phone_Functions*Phone; 961 GSM_Phone_Functions*Phone;
944 GSM_CalendarEntryNote; 962 GSM_CalendarEntryNote;
945 bool start = true; 963 bool start = true;
@@ -973,24 +991,25 @@ bool PhoneFormat::save( Calendar *calendar)
973 // pending get empty slots 991 // pending get empty slots
974 while ( ev ) { 992 while ( ev ) {
975 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && ev->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { 993 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && ev->tempSyncStat() != SYNC_TEMPSTATE_DELETE) {
976 if ( ev->getID(mProfileName).isEmpty() ) { 994 if ( ev->getID(mProfileName).isEmpty() ) {
977 status.setText ( message + QString::number ( ++procCount ) ); 995 status.setText ( message + QString::number ( ++procCount ) );
978 qApp->processEvents(); 996 qApp->processEvents();
979 //int newID ;//= pending 997 //int newID ;//= pending
980 //ev->setID(mProfileName, QString::number( newID )); 998 //ev->setID(mProfileName, QString::number( newID ));
981 event2GSM( ev, &Note ); 999 event2GSM( ev, &Note );
982 Note.Location = 0; 1000 Note.Location = 0;
983 error = Phone->AddCalendar(&s, &Note); 1001 error = Phone->AddCalendar(&s, &Note);
984 ev->setID( mProfileName, QString::number( Note.Location ) ); 1002 ev->setID( mProfileName, QString::number( Note.Location ) );
1003 qDebug("New Calendar. Location %d ",Note.Location );
985 afterSave( ev ); 1004 afterSave( ev );
986 } else { 1005 } else {
987 afterSave( ev ); // setting temp sync stat for changed items 1006 afterSave( ev ); // setting temp sync stat for changed items
988 } 1007 }
989 } 1008 }
990 ev = er.next(); 1009 ev = er.next();
991 } 1010 }
992 GSM_ToDoEntry ToDoEntry; 1011 GSM_ToDoEntry ToDoEntry;
993 QPtrList<Todo> tl = calendar->rawTodos(); 1012 QPtrList<Todo> tl = calendar->rawTodos();
994 Todo* to = tl.first(); 1013 Todo* to = tl.first();
995 1014
996 message = i18n("Processing todo # "); 1015 message = i18n("Processing todo # ");
@@ -998,25 +1017,25 @@ bool PhoneFormat::save( Calendar *calendar)
998 while ( to ) { 1017 while ( to ) {
999 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 1018 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
1000 status.setText ( message + QString::number ( ++procCount ) ); 1019 status.setText ( message + QString::number ( ++procCount ) );
1001 qApp->processEvents(); 1020 qApp->processEvents();
1002 todo2GSM( to, &ToDoEntry ); 1021 todo2GSM( to, &ToDoEntry );
1003 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete 1022 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete
1004 error=Phone->DeleteToDo(&s,&ToDoEntry); 1023 error=Phone->DeleteToDo(&s,&ToDoEntry);
1005 } 1024 }
1006 else if ( to->getID("Sharp_DTM").isEmpty() ) { // add new 1025 else if ( to->getID("Sharp_DTM").isEmpty() ) { // add new
1007 ; 1026 ;
1008 } 1027 }
1009 else { // change existing 1028 else { // change existing
1010 error=Phone->AddToDo(&s,&ToDoEntry); 1029 error=Phone->SetToDo(&s,&ToDoEntry);
1011 } 1030 }
1012 } 1031 }
1013 to = tl.next(); 1032 to = tl.next();
1014 } 1033 }
1015 1034
1016 // pending get empty slots 1035 // pending get empty slots
1017 to = tl.first(); 1036 to = tl.first();
1018 while ( to ) { 1037 while ( to ) {
1019 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && to->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { 1038 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && to->tempSyncStat() != SYNC_TEMPSTATE_DELETE) {
1020 if ( to->getID(mProfileName).isEmpty() ) { 1039 if ( to->getID(mProfileName).isEmpty() ) {
1021 status.setText ( message + QString::number ( ++procCount ) ); 1040 status.setText ( message + QString::number ( ++procCount ) );
1022 qApp->processEvents(); 1041 qApp->processEvents();