author | zautrix <zautrix> | 2004-08-08 20:46:59 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-08 20:46:59 (UTC) |
commit | 3a769cd15cfdb8e19e5fec2088c59aadeed4800a (patch) (side-by-side diff) | |
tree | 93b3dee16f7ae02c762f1cfd63864b3676ac65cb | |
parent | 957c13e21844ca75e337fc1c864554dd2240fc78 (diff) | |
download | kdepimpi-3a769cd15cfdb8e19e5fec2088c59aadeed4800a.zip kdepimpi-3a769cd15cfdb8e19e5fec2088c59aadeed4800a.tar.gz kdepimpi-3a769cd15cfdb8e19e5fec2088c59aadeed4800a.tar.bz2 |
Fixed reading from phone
-rw-r--r-- | libkcal/phoneformat.cpp | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 238b0ef..1a9ccbc 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp @@ -83,58 +83,61 @@ public: case GSM_Priority_Low : priority = 1; break; case GSM_Priority_Medium : priority = 3; break; case GSM_Priority_High : priority = 5; break; default :priority = 3 ; break; } todo->setPriority( priority ); GSM_Phone_Functions *Phone; Phone=s->Phone.Functions; int j; GSM_DateTime* dtp; bool alarm = false; QDateTime alarmDt; GSM_Category Category; int error; QString completedString = "no"; for (j=0;j<ToDo->EntriesNum;j++) { + + //qDebug(" for todo %d",ToDo->Location ); switch (ToDo->Entries[j].EntryType) { case TODO_END_DATETIME: dtp = &ToDo->Entries[j].Date ; todo->setDtDue (fromGSM ( dtp )); break; case TODO_COMPLETED: if ( ToDo->Entries[j].Number == 1 ) { todo->setCompleted( true ); completedString = "yes"; } else { todo->setCompleted( false ); } break; case TODO_ALARM_DATETIME: dtp = &ToDo->Entries[j].Date ; alarm = true; alarmDt = fromGSM ( dtp ); break; case TODO_SILENT_ALARM_DATETIME: dtp = &ToDo->Entries[j].Date ; alarm = true; alarmDt = fromGSM ( dtp ); break; case TODO_TEXT: - todo->setSummary( QString ( (const char*) ToDo->Entries[j].Text )); + //qDebug(" text *%s* ", (const char*) DecodeUnicodeConsole(ToDo->Entries[j].Text )); + todo->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole(ToDo->Entries[j].Text ))); break; case TODO_PRIVATE: if ( ToDo->Entries[j].Number == 1 ) todo->setSecrecy( Incidence::SecrecyPrivate ); else todo->setSecrecy( Incidence::SecrecyPublic ); break; case TODO_CATEGORY: Category.Location = ToDo->Entries[j].Number; Category.Type = Category_ToDo; error=Phone->GetCategory(s, &Category); if (error == ERR_NONE) { QStringList cat = todo->categories(); QString nCat = QString ( (const char*)Category.Name ); if ( !nCat.isEmpty() ) if ( !cat.contains( nCat )) { @@ -221,33 +224,33 @@ public: bool repeating = false; int repeat_dayofweek = -1; int repeat_day = -1; int repeat_weekofmonth = -1; int repeat_month = -1; int repeat_frequency = -1; int rec_type = -1; GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; GSM_DateTime* dtp; bool alarm = false; QDateTime alarmDt; repeat_startdate.Day = 0; repeat_stopdate.Day = 0; for (i=0;i<Note->EntriesNum;i++) { - qDebug(" for "); + //qDebug(" for ev"); switch (Note->Entries[i].EntryType) { case CAL_START_DATETIME: dtp = &Note->Entries[i].Date ; if ( dtp->Hour > 24 ) { event->setFloats( true ); event->setDtStart( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); } else { event->setDtStart (fromGSM ( dtp )); } break; case CAL_END_DATETIME: dtp = &Note->Entries[i].Date ; if ( dtp->Hour > 24 ) { event->setFloats( true ); event->setDtEnd( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); @@ -257,36 +260,37 @@ public: break; case CAL_ALARM_DATETIME: dtp = &Note->Entries[i].Date ; alarm = true; alarmDt = fromGSM ( dtp ); break; case CAL_SILENT_ALARM_DATETIME: dtp = &Note->Entries[i].Date ; alarm = true; alarmDt = fromGSM ( dtp ); break; case CAL_RECURRANCE: rec_type = Note->Entries[i].Number; //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" ); break; case CAL_TEXT: - event->setSummary( QString ( (const char*) Note->Entries[i].Text )); + //qDebug(" ev text %s", DecodeUnicodeConsole(Note->Entries[i].Text) ); + event->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole( Note->Entries[i].Text ))); break; case CAL_LOCATION: - event->setLocation(QString ((const char*) Note->Entries[i].Text )); + event->setLocation(QString::fromUtf8 ((const char*) DecodeUnicodeConsole(Note->Entries[i].Text) )); break; case CAL_PHONE: //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); break; case CAL_PRIVATE: if ( Note->Entries[i].Number == 1 ) event->setSecrecy( Incidence::SecrecyPrivate ); else event->setSecrecy( Incidence::SecrecyPublic ); break; case CAL_CONTACTID: #if 0 entry.Location = Note->Entries[i].Number; entry.MemoryType = MEM_ME; error=Phone->GetMemory(&s, &entry); @@ -599,32 +603,33 @@ ulong PhoneFormat::getCsum( const QStringList & attList) } } return cSum; } //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); #include <stdlib.h> #define DEBUGMODE false bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal ,QString profileName, QString device,QString connection, QString model ) { mProfileName = profileName; GSM_StateMachine s; qDebug(" load "); s.opened = false; s.msg = NULL; s.ConfigNum = 0; +#if 0 static char *cp; static INI_Section *cfg = NULL; cfg=GSM_FindGammuRC(); int i; for (i = 0; i <= MAX_CONFIG_NUM; i++) { if (cfg!=NULL) { cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false); if (cp) di.coding = cp; s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false); if (s.Config[i].Localize) { s.msg=INI_ReadFile(s.Config[i].Localize, true); } else { #if !defined(WIN32) && defined(LOCALE_PATH) locale = setlocale(LC_MESSAGES, NULL); if (locale != NULL) { @@ -640,53 +645,79 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal ,QString profi /* Wanted user specific configuration? */ if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; s.ConfigNum++; /* We want to use only one file descriptor for global and state machine debug output */ s.Config[i].UseGlobalDebugFile = true; /* We wanted to read just user specified configuration. */ {break;} } +#endif + setlocale(LC_ALL, ""); + GSM_ReadConfig(NULL, &s.Config[0], 0); + s.ConfigNum = 1; + GSM_Config *cfg = &s.Config[0]; + di.coding = "utf8"; + if ( ! connection.isEmpty() ) { + cfg->Connection = strdup(connection.latin1()); + cfg->DefaultConnection = false; + qDebug("Connection set %s ", cfg->Connection ); + + } + if ( ! device.isEmpty() ) { + cfg->Device = strdup(device.latin1()); + cfg->DefaultDevice = false; + qDebug("Device set %s ", cfg->Device); + + } + if ( ! model.isEmpty() ) { + strcpy(cfg->Model,model.latin1() ); + cfg->DefaultModel = false; + qDebug("Model set %s ",cfg->Model ); + + + } int error=GSM_InitConnection(&s,3); qDebug(" init %d %d", error, ERR_NONE); if ( error != ERR_NONE ) return false; // fromString2Cal( calendar, existngCal, &s, "Event" ); GSM_Phone_Functions *Phone; GSM_CalendarEntry note; - bool refresh = true; + bool start = true; Phone=s.Phone.Functions; bool gshutdown = false; PhoneParser handler( calendar, profileName ); int ccc = 0; - while (!gshutdown && ccc++ < 10 ) { + while (!gshutdown && ccc++ < 3) { qDebug("readEvent %d ", ccc); - error=Phone->GetNextCalendar(&s,¬e,refresh); + error=Phone->GetNextCalendar(&s,¬e,start); if (error == ERR_EMPTY) break; + start = false; handler.readEvent( existingCal, ¬e ); } - bool start = true; + start = true; GSM_ToDoEntry ToDo; ccc = 0; while (!gshutdown) { error = Phone->GetNextToDo(&s, &ToDo, start); if (error == ERR_EMPTY) break; start = false; qDebug("readTodo %d ", ++ccc); handler.readTodo( existingCal, &ToDo, &s); } error=GSM_TerminateConnection(&s); return true; } |