summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-15 14:26:07 (UTC)
committer zautrix <zautrix>2004-10-15 14:26:07 (UTC)
commit4f276d80bd977401d656851515474cc00c661e5b (patch) (side-by-side diff)
tree0d3a747bef0431ef791b69876f5bda554f9ca83f
parentc2fb960297c4b08980921c818a4d347057732390 (diff)
downloadkdepimpi-4f276d80bd977401d656851515474cc00c661e5b.zip
kdepimpi-4f276d80bd977401d656851515474cc00c661e5b.tar.gz
kdepimpi-4f276d80bd977401d656851515474cc00c661e5b.tar.bz2
many phone and sync fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/common/service/gsmcal.c20
-rw-r--r--kabc/addressee.cpp1
-rw-r--r--kabc/kabc.pro2
-rw-r--r--korganizer/calendarview.cpp4
-rw-r--r--libkcal/event.cpp46
-rw-r--r--libkcal/event.h2
-rw-r--r--libkcal/phoneformat.cpp104
-rw-r--r--libkcal/phoneformat.h2
-rw-r--r--libkcal/todo.cpp58
-rw-r--r--libkcal/todo.h1
-rw-r--r--libkcal/vcalformat.cpp141
-rw-r--r--libkdepim/phoneaccess.cpp69
-rw-r--r--microkde/microkde.pro2
-rw-r--r--microkde/ofileselector_p.cpp7
14 files changed, 305 insertions, 154 deletions
diff --git a/gammu/emb/common/service/gsmcal.c b/gammu/emb/common/service/gsmcal.c
index 0375fee..7310755 100644
--- a/gammu/emb/common/service/gsmcal.c
+++ b/gammu/emb/common/service/gsmcal.c
@@ -50,238 +50,238 @@ void GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(GSM_CalendarEntry *entr
*Alarm = -1;
*Phone = -1;
*Recurrance = -1;
*EndTime = -1;
*Location = -1;
for (i = 0; i < entry->EntriesNum; i++) {
switch (entry->Entries[i].EntryType) {
case CAL_START_DATETIME :
if (*Time == -1) *Time = i;
break;
case CAL_END_DATETIME :
if (*EndTime == -1) *EndTime = i;
break;
case CAL_ALARM_DATETIME :
case CAL_SILENT_ALARM_DATETIME:
if (*Alarm == -1) *Alarm = i;
break;
case CAL_RECURRANCE:
if (*Recurrance == -1) *Recurrance = i;
break;
case CAL_TEXT:
*Text = i;
break;
case CAL_DESCRIPTION:
if (*Text == -1) *Text = i;
break;
case CAL_PHONE:
if (*Phone == -1) *Phone = i;
break;
case CAL_LOCATION:
if (*Location == -1) *Location = i;
break;
default:
break;
}
}
}
GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note, bool header, GSM_VCalendarVersion Version)
{
int Text, Time, Alarm, Phone, Recurrance, EndTime, Location;
char buffer[2000];
GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(note, &Text, &Time, &Alarm, &Phone, &Recurrance, &EndTime, &Location);
if (header) {
*Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10);
*Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10);
}
*Length+=sprintf(Buffer+(*Length), "BEGIN:VEVENT%c%c",13,10);
if (Version == Nokia_VCalendar) {
*Length+=sprintf(Buffer+(*Length), "CATEGORIES:");
switch (note->Type) {
case GSM_CAL_REMINDER:
*Length+=sprintf(Buffer+(*Length), "Reminder%c%c",13,10);
break;
case GSM_CAL_MEMO:
*Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10);
break;
case GSM_CAL_CALL:
*Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10);
break;
case GSM_CAL_BIRTHDAY:
- *Length+=sprintf(Buffer+(*Length), "Special Occasion%c%c",13,10);
+ *Length+=sprintf(Buffer+(*Length), "Birthday%c%c",13,10);
break;
case GSM_CAL_MEETING:
default:
*Length+=sprintf(Buffer+(*Length), "MeetingDEF%c%c",13,10);
break;
}
if (note->Type == GSM_CAL_CALL) {
buffer[0] = 0;
buffer[1] = 0;
if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text);
if (Text != -1) {
if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1);
CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text);
}
SaveVCALText(Buffer, Length, buffer, "SUMMARY");
} else {
SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY");
}
if (note->Type == GSM_CAL_MEETING && Location != -1) {
SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION");
}
if (Time == -1) return ERR_UNKNOWN;
SaveVCALDateTime(Buffer, Length, &note->Entries[Time].Date, "DTSTART");
if (EndTime != -1) {
SaveVCALDateTime(Buffer, Length, &note->Entries[EndTime].Date, "DTEND");
}
if (Alarm != -1) {
if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) {
SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "DALARM");
} else {
SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "DALARM");
}
}
/* Birthday is known to be recurranced */
- if (Recurrance != -1 && note->Type != GSM_CAL_BIRTHDAY) {
+ if (Recurrance != -1 ) {
switch(note->Entries[Recurrance].Number/24) {
case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1 #0%c%c",13,10); break;
case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:W1 #0%c%c",13,10); break;
case 14 : *Length+=sprintf(Buffer+(*Length), "RRULE:W2 #0%c%c",13,10); break;
- case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1 #0%c%c",13,10); break;
+ case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YM1 #0%c%c",13,10); break;
}
}
} else if (Version == Siemens_VCalendar) {
*Length+=sprintf(Buffer+(*Length), "CATEGORIES:");
switch (note->Type) {
case GSM_CAL_MEETING:
*Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10);
break;
case GSM_CAL_CALL:
*Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10);
break;
case GSM_CAL_BIRTHDAY:
- *Length+=sprintf(Buffer+(*Length), "Anniversary%c%c",13,10);
+ *Length+=sprintf(Buffer+(*Length), "Birthday%c%c",13,10);
break;
case GSM_CAL_MEMO:
default:
*Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10);
break;
}
if (Time == -1) return ERR_UNKNOWN;
SaveVCALDateTime(Buffer, Length, &note->Entries[Time].Date, "DTSTART");
if (Alarm != -1) {
SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "DALARM");
}
if (Recurrance != -1) {
switch(note->Entries[Recurrance].Number/24) {
case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1%c%c",13,10); break;
case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:D7%c%c",13,10); break;
case 30 : *Length+=sprintf(Buffer+(*Length), "RRULE:MD1%c%c",13,10); break;
- case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1%c%c",13,10); break;
+ case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YM1%c%c",13,10); break;
}
}
if (note->Type == GSM_CAL_CALL) {
buffer[0] = 0;
buffer[1] = 0;
if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text);
if (Text != -1) {
if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1);
CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text);
}
SaveVCALText(Buffer, Length, buffer, "SUMMARY");
} else {
SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY");
}
} else if (Version == SonyEricsson_VCalendar) {
*Length+=sprintf(Buffer+(*Length), "CATEGORIES:");
switch (note->Type) {
case GSM_CAL_MEETING:
*Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10);
break;
case GSM_CAL_REMINDER:
*Length+=sprintf(Buffer+(*Length), "Date%c%c",13,10);
break;
case GSM_CAL_TRAVEL:
*Length+=sprintf(Buffer+(*Length), "Travel%c%c",13,10);
break;
case GSM_CAL_VACATION:
*Length+=sprintf(Buffer+(*Length), "Vacation%c%c",13,10);
break;
case GSM_CAL_BIRTHDAY:
- *Length+=sprintf(Buffer+(*Length), "Anninversary%c%c",13,10);
+ *Length+=sprintf(Buffer+(*Length), "Birthday%c%c",13,10);
break;
case GSM_CAL_MEMO:
default:
*Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10);
break;
}
if (Time == -1) return ERR_UNKNOWN;
SaveVCALDateTime(Buffer, Length, &note->Entries[Time].Date, "DTSTART");
if (EndTime != -1) {
SaveVCALDateTime(Buffer, Length, &note->Entries[EndTime].Date, "DTEND");
}
if (Alarm != -1) {
SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "AALARM");
}
SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY");
if (Location != -1) {
SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION");
}
}
*Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10);
*Length+=sprintf(Buffer+(*Length), "END:VEVENT%c%c",13,10);
if (header) *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10);
return ERR_NONE;
}
void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone)
{
int i;
*Text = -1;
*EndTime = -1;
*Alarm = -1;
*Completed = -1;
*Phone = -1;
for (i = 0; i < entry->EntriesNum; i++) {
switch (entry->Entries[i].EntryType) {
case TODO_END_DATETIME :
if (*EndTime == -1) *EndTime = i;
break;
case TODO_ALARM_DATETIME :
case TODO_SILENT_ALARM_DATETIME:
if (*Alarm == -1) *Alarm = i;
break;
case TODO_TEXT:
if (*Text == -1) *Text = i;
break;
case TODO_COMPLETED:
if (*Completed == -1) *Completed = i;
break;
case TODO_PHONE:
if (*Phone == -1) *Phone = i;
break;
default:
break;
}
}
}
@@ -329,158 +329,164 @@ GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool h
} else if (Version == SonyEricsson_VToDo) {
if (Text == -1) return ERR_UNKNOWN;
SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY");
if (Completed == -1) {
*Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10);
} else {
*Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10);
}
switch (note->Priority) {
case GSM_Priority_Low : *Length+=sprintf(Buffer+(*Length), "PRIORITY:5%c%c",13,10); break;
case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break;
case GSM_Priority_High : *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break;
}
if (Alarm != -1) {
SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "AALARM");
}
}
*Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10);
*Length+=sprintf(Buffer+(*Length), "END:VTODO%c%c",13,10);
if (header) {
*Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10);
}
return ERR_NONE;
}
GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_CalendarEntry *Calendar, GSM_ToDoEntry *ToDo, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer)
{
unsigned char Line[2000],Buff[2000];
int Level = 0;
Calendar->EntriesNum = 0;
ToDo->EntriesNum = 0;
while (1) {
MyGetLine(Buffer, Pos, Line, strlen(Buffer));
if (strlen(Line) == 0) break;
switch (Level) {
case 0:
if (strstr(Line,"BEGIN:VEVENT")) {
Calendar->Type = GSM_CAL_MEMO;
Level = 1;
}
if (strstr(Line,"BEGIN:VTODO")) {
ToDo->Priority = GSM_Priority_Medium;
Level = 2;
}
break;
case 1: /* Calendar note */
if (strstr(Line,"END:VEVENT")) {
if (Calendar->EntriesNum == 0) return ERR_EMPTY;
return ERR_NONE;
}
Calendar->Type = GSM_CAL_MEETING;
if (strstr(Line,"CATEGORIES:Reminder")) Calendar->Type = GSM_CAL_REMINDER;
if (strstr(Line,"CATEGORIES:Date")) Calendar->Type = GSM_CAL_REMINDER;//SE
if (strstr(Line,"CATEGORIES:Travel")) Calendar->Type = GSM_CAL_TRAVEL; //SE
if (strstr(Line,"CATEGORIES:Vacation")) Calendar->Type = GSM_CAL_VACATION;//SE
if (strstr(Line,"CATEGORIES:Miscellaneous")) Calendar->Type = GSM_CAL_MEMO;
if (strstr(Line,"CATEGORIES:Phone Call")) Calendar->Type = GSM_CAL_CALL;
- if (strstr(Line,"CATEGORIES:Special Occasion")) Calendar->Type = GSM_CAL_BIRTHDAY;
if (strstr(Line,"CATEGORIES:Anniversary")) Calendar->Type = GSM_CAL_BIRTHDAY;
+ if (strstr(Line,"CATEGORIES:Birthday")) Calendar->Type = GSM_CAL_BIRTHDAY;
if (strstr(Line,"CATEGORIES:Meeting")) Calendar->Type = GSM_CAL_MEETING;
if (strstr(Line,"CATEGORIES:Appointment")) Calendar->Type = GSM_CAL_MEETING;
if (strstr(Line,"RRULE:D1")) {
Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE;
Calendar->Entries[Calendar->EntriesNum].Number = 1*24;
Calendar->EntriesNum++;
}
if ((strstr(Line,"RRULE:W1")) || (strstr(Line,"RRULE:D7"))) {
Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE;
Calendar->Entries[Calendar->EntriesNum].Number = 7*24;
Calendar->EntriesNum++;
}
if (strstr(Line,"RRULE:W2")) {
Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE;
Calendar->Entries[Calendar->EntriesNum].Number = 14*24;
Calendar->EntriesNum++;
}
if (strstr(Line,"RRULE:MD1")) {
Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE;
Calendar->Entries[Calendar->EntriesNum].Number = 30*24;
Calendar->EntriesNum++;
}
if (strstr(Line,"RRULE:YD1")) {
Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE;
Calendar->Entries[Calendar->EntriesNum].Number = 365*24;
Calendar->EntriesNum++;
}
// LR
+ if (strstr(Line,"RRULE:YM1")) {
+ Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE;
+ Calendar->Entries[Calendar->EntriesNum].Number = 365*24;
+ Calendar->EntriesNum++;
+ }
+ // LR
if ((ReadVCALText(Line, "SUMMARY", Buff)) ) {
Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_TEXT;
CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff);
Calendar->EntriesNum++;
}
if (ReadVCALText(Line, "DESCRIPTION", Buff)) {
Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_DESCRIPTION;
CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff);
Calendar->EntriesNum++;
}
if (ReadVCALText(Line, "LOCATION", Buff)) {
Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_LOCATION;
CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff);
Calendar->EntriesNum++;
}
if (ReadVCALText(Line, "DTSTART", Buff)) {
Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_START_DATETIME;
ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date);
Calendar->EntriesNum++;
}
if (ReadVCALText(Line, "DTEND", Buff)) {
Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_END_DATETIME;
ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date);
Calendar->EntriesNum++;
}
if (ReadVCALText(Line, "DALARM", Buff)) {
Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_SILENT_ALARM_DATETIME;
ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date);
Calendar->EntriesNum++;
}
if (ReadVCALText(Line, "AALARM", Buff)) {
Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_ALARM_DATETIME;
ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date);
Calendar->EntriesNum++;
}
break;
case 2: /* ToDo note */
if (strstr(Line,"END:VTODO")) {
if (ToDo->EntriesNum == 0) return ERR_EMPTY;
return ERR_NONE;
}
if (ReadVCALText(Line, "DUE", Buff)) {
ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_END_DATETIME;
ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date);
ToDo->EntriesNum++;
}
if (ReadVCALText(Line, "DALARM", Buff)) {
ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_SILENT_ALARM_DATETIME;
ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date);
ToDo->EntriesNum++;
}
if (ReadVCALText(Line, "AALARM", Buff)) {
ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_ALARM_DATETIME;
ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date);
ToDo->EntriesNum++;
}
if (ReadVCALText(Line, "SUMMARY", Buff)) {
ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_TEXT;
CopyUnicodeString(ToDo->Entries[ToDo->EntriesNum].Text,Buff);
ToDo->EntriesNum++;
}
if (ReadVCALText(Line, "PRIORITY", Buff)) {
if (ToDoVer == SonyEricsson_VToDo) {
ToDo->Priority = GSM_Priority_Medium;
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 2564894..40877ef 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -249,128 +249,129 @@ void Addressee::computeCsum(const QString &dev)
t.sort();
for ( iii = 0; iii < t.count(); ++iii)
l.append( t[iii] );
t = mData->categories;
t.sort();
for ( iii = 0; iii < t.count(); ++iii)
l.append( t[iii] );
t = mData->custom;
t.sort();
for ( iii = 0; iii < t.count(); ++iii)
l.append( t[iii] );
KABC::Address::List::Iterator addressIter;
for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
++addressIter ) {
t = (*addressIter).asList();
t.sort();
for ( iii = 0; iii < t.count(); ++iii)
l.append( t[iii] );
}
uint cs = getCsum4List(l);
// qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
setCsum( dev, QString::number (cs ));
}
void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
{
detach();
if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
if ( !mData->birthday.isValid() )
if ( ad.mData->birthday.isValid())
mData->birthday = ad.mData->birthday;
if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
QStringList t;
QStringList tAD;
uint iii;
// ********** phone numbers
PhoneNumber::List phoneAD = ad.phoneNumbers();
PhoneNumber::List::Iterator phoneItAD;
for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
bool found = false;
PhoneNumber::List::Iterator it;
for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
if ( ( *phoneItAD ).contains( (*it) ) ) {
found = true;
(*it).setType( ( *phoneItAD ).type() );
+ (*it).setNumber( ( *phoneItAD ).number() );
break;
}
}
if ( isSubSet && ! found )
mData->phoneNumbers.append( *phoneItAD );
}
if ( isSubSet ) {
// ************* emails;
t = mData->emails;
tAD = ad.mData->emails;
for ( iii = 0; iii < tAD.count(); ++iii)
if ( !t.contains(tAD[iii] ) )
mData->emails.append( tAD[iii] );
}
// ************* categories;
t = mData->categories;
tAD = ad.mData->categories;
for ( iii = 0; iii < tAD.count(); ++iii)
if ( !t.contains(tAD[iii] ) )
mData->categories.append( tAD[iii] );
QStringList::ConstIterator it;
for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) {
QString qualifiedName = (*it).left( (*it).find( ":" ));
bool found = false;
QStringList::ConstIterator itL;
for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) {
if ( (*itL).startsWith( qualifiedName ) ) {
found = true;
break;
}
}
if ( ! found ) {
mData->custom.append( *it );
}
}
if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo;
if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
if ( !mData->sound.isIntern() ) {
if ( mData->sound.url().isEmpty() ) {
mData->sound = ad.mData->sound;
}
}
if ( !mData->agent.isIntern() ) {
if ( mData->agent.url().isEmpty() ) {
mData->agent = ad.mData->agent;
}
}
{
Key::List::Iterator itA;
for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) {
bool found = false;
Key::List::Iterator it;
for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
if ( (*it) == (*itA)) {
found = true;
break;
}
}
if ( ! found ) {
mData->keys.append( *itA );
}
}
diff --git a/kabc/kabc.pro b/kabc/kabc.pro
index d690acc..17ebff8 100644
--- a/kabc/kabc.pro
+++ b/kabc/kabc.pro
@@ -1,220 +1,218 @@
TEMPLATE = lib
CONFIG += qt warn_on
#release debug
DESTDIR=../bin
TARGET = microkabc
include( ../variables.pri )
INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim ../qtcompat ../microkde/kdeui ..
#LIBS += -lmicrokde -lldap
LIBS += -L$(QPEDIR)/lib
DEFINES += KAB_EMBEDDED DESKTOP_VERSION
unix : {
OBJECTS_DIR = obj/unix
MOC_DIR = moc/unix
}
win32: {
DEFINES += _WIN32_
OBJECTS_DIR = obj/win
MOC_DIR = moc/win
}
INTERFACES = \
HEADERS = \
resource.h \
stdaddressbook.h \
agent.h \
geo.h \
key.h \
field.h \
plugin.h \
address.h \
addresseelist.h \
addresseeview.h \
formatfactory.h \
formatplugin.h \
phonenumber.h \
distributionlist.h \
distributionlistdialog.h \
distributionlisteditor.h \
vcardformatplugin.h \
formats/vcardformatplugin2.h \
picture.h \
secrecy.h \
sound.h \
addressbook.h \
- syncprefwidget.h \
timezone.h \
tmpaddressbook.h \
addressee.h \
addresseedialog.h \
vcardconverter.h \
vcard21parser.h \
vcardformatimpl.h \
plugins/file/resourcefile.h \
plugins/file/resourcefileconfig.h \
plugins/dir/resourcedir.h \
plugins/dir/resourcedirconfig.h \
vcardparser/vcardline.h \
vcardparser/vcard.h \
vcardparser/vcardtool.h \
vcardparser/vcardparser.h \
vcard/include/VCardAdrParam.h \
vcard/include/VCardAdrValue.h \
vcard/include/VCardAgentParam.h \
vcard/include/VCardContentLine.h \
vcard/include/VCardDateParam.h \
vcard/include/VCardDateValue.h \
vcard/include/VCardEmailParam.h \
vcard/include/VCardGeoValue.h \
vcard/include/VCardGroup.h \
vcard/include/VCardImageParam.h \
vcard/include/VCardImageValue.h \
vcard/include/VCardLangValue.h \
vcard/include/VCardNValue.h \
vcard/include/VCardParam.h \
vcard/include/VCardPhoneNumberValue.h \
vcard/include/VCardSourceParam.h \
vcard/include/VCardTelParam.h \
vcard/include/VCardTextParam.h \
vcard/include/VCardTextValue.h \
vcard/include/VCardTextBinParam.h \
vcard/include/VCardURIValue.h \
vcard/include/VCardVCard.h \
vcard/include/VCardEntity.h \
vcard/include/VCardValue.h \
vcard/include/VCardSoundValue.h \
vcard/include/VCardAgentValue.h \
vcard/include/VCardTelValue.h \
vcard/include/VCardTextBinValue.h \
vcard/include/VCardOrgValue.h \
vcard/include/VCardUTCValue.h \
vcard/include/VCardClassValue.h \
vcard/include/VCardFloatValue.h \
vcard/include/VCardTextListValue.h \
vcard/include/generated/AdrParam-generated.h \
vcard/include/generated/AdrValue-generated.h \
vcard/include/generated/AgentParam-generated.h \
vcard/include/generated/ContentLine-generated.h \
vcard/include/generated/DateParam-generated.h \
vcard/include/generated/DateValue-generated.h \
vcard/include/generated/EmailParam-generated.h \
vcard/include/generated/GeoValue-generated.h \
vcard/include/generated/Group-generated.h \
vcard/include/generated/ImageParam-generated.h \
vcard/include/generated/ImageValue-generated.h \
vcard/include/generated/LangValue-generated.h \
vcard/include/generated/NValue-generated.h \
vcard/include/generated/Param-generated.h \
vcard/include/generated/PhoneNumberValue-generated.h \
vcard/include/generated/SourceParam-generated.h \
vcard/include/generated/TelParam-generated.h \
vcard/include/generated/TextParam-generated.h \
vcard/include/generated/TextNSParam-generated.h \
vcard/include/generated/TextValue-generated.h \
vcard/include/generated/TextBinParam-generated.h \
vcard/include/generated/URIValue-generated.h \
vcard/include/generated/VCard-generated.h \
vcard/include/generated/VCardEntity-generated.h \
vcard/include/generated/Value-generated.h \
vcard/include/generated/SoundValue-generated.h \
vcard/include/generated/AgentValue-generated.h \
vcard/include/generated/TelValue-generated.h \
vcard/include/generated/TextBinValue-generated.h \
vcard/include/generated/OrgValue-generated.h \
vcard/include/generated/UTCValue-generated.h \
vcard/include/generated/ClassValue-generated.h \
vcard/include/generated/FloatValue-generated.h \
vcard/include/generated/TextListValue-generated.h
# plugins/ldap/resourceldap.h \
# plugins/ldap/resourceldapconfig.h \
#formats/binary/binaryformat.h \
#vcard/include/VCardTextNSParam.h \
SOURCES = \
distributionlist.cpp \
distributionlistdialog.cpp \
distributionlisteditor.cpp \
vcardformatplugin.cpp \
formats/vcardformatplugin2.cpp \
formatfactory.cpp \
resource.cpp \
stdaddressbook.cpp \
plugin.cpp \
agent.cpp \
geo.cpp \
key.cpp \
field.cpp \
addresseeview.cpp \
address.cpp \
phonenumber.cpp \
picture.cpp \
secrecy.cpp \
sound.cpp \
addressbook.cpp \
- syncprefwidget.cpp \
timezone.cpp \
tmpaddressbook.cpp \
addressee.cpp \
addresseelist.cpp \
addresseedialog.cpp \
vcardconverter.cpp \
vcard21parser.cpp \
vcardformatimpl.cpp \
plugins/file/resourcefile.cpp \
plugins/file/resourcefileconfig.cpp \
plugins/dir/resourcedir.cpp \
plugins/dir/resourcedirconfig.cpp \
vcardparser/vcardline.cpp \
vcardparser/vcard.cpp \
vcardparser/vcardtool.cpp \
vcardparser/vcardparser.cpp \
vcard/AdrParam.cpp \
vcard/AdrValue.cpp \
vcard/AgentParam.cpp \
vcard/ContentLine.cpp \
vcard/DateParam.cpp \
vcard/DateValue.cpp \
vcard/EmailParam.cpp \
vcard/Entity.cpp \
vcard/Enum.cpp \
vcard/GeoValue.cpp \
vcard/ImageParam.cpp \
vcard/ImageValue.cpp \
vcard/LangValue.cpp \
vcard/NValue.cpp \
vcard/Param.cpp \
vcard/PhoneNumberValue.cpp \
vcard/RToken.cpp \
vcard/SourceParam.cpp \
vcard/TelParam.cpp \
vcard/TextParam.cpp \
vcard/TextValue.cpp \
vcard/TextBinParam.cpp \
vcard/URIValue.cpp \
vcard/VCardv.cpp \
vcard/VCardEntity.cpp \
vcard/Value.cpp \
vcard/SoundValue.cpp \
vcard/AgentValue.cpp \
vcard/TelValue.cpp \
vcard/TextBinValue.cpp \
vcard/OrgValue.cpp \
vcard/UTCValue.cpp \
vcard/ClassValue.cpp \
vcard/FloatValue.cpp \
vcard/TextListValue.cpp
# plugins/ldap/resourceldap.cpp \
# plugins/ldap/resourceldapconfig.cpp \
#formats/binary/binaryformat.cpp \
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 3e0a27d..e4a11f5 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1069,174 +1069,176 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
}
}
}
inR = er.next();
}
QPtrList<Incidence> el = local->rawIncidences();
inL = el.first();
modulo = (el.count()/10)+1;
bar.setCaption (i18n("Add / remove events") );
bar.setTotalSteps ( el.count() ) ;
bar.show();
incCounter = 0;
while ( inL ) {
qApp->processEvents();
if ( ! bar.isVisible() )
return false;
if ( incCounter % modulo == 0 )
bar.setProgress( incCounter );
++incCounter;
uid = inL->uid();
bool skipIncidence = false;
if ( uid.left(15) == QString("last-syncEvent-") )
skipIncidence = true;
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
skipIncidence = true;
if ( !skipIncidence ) {
inR = remote->incidence( uid );
if ( ! inR ) {
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
checkExternSyncEvent(eventLSyncSharp, inL);
local->deleteIncidence( inL );
++deletedEventL;
} else {
if ( ! mSyncManager->mWriteBackExistingOnly ) {
inL->removeID(mCurrentSyncDevice );
++addedEventR;
//qDebug("remote added Incidence %s ", inL->summary().latin1());
inL->setLastModified( modifiedCalendar );
inR = inL->clone();
inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
remote->addIncidence( inR );
}
}
} else {
if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
checkExternSyncEvent(eventLSyncSharp, inL);
local->deleteIncidence( inL );
++deletedEventL;
} else {
if ( ! mSyncManager->mWriteBackExistingOnly ) {
++addedEventR;
inL->setLastModified( modifiedCalendar );
remote->addIncidence( inL->clone() );
}
}
}
}
}
inL = el.next();
}
int delFut = 0;
+ int remRem = 0;
if ( mSyncManager->mWriteBackInFuture ) {
er = remote->rawIncidences();
+ remRem = er.count();
inR = er.first();
QDateTime dt;
QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 );
while ( inR ) {
if ( inR->type() == "Todo" ) {
Todo * t = (Todo*)inR;
if ( t->hasDueDate() )
dt = t->dtDue();
else
dt = cur.addSecs( 62 );
}
else if (inR->type() == "Event" ) {
bool ok;
dt = inR->getNextOccurence( cur, &ok );
if ( !ok )
dt = cur.addSecs( -62 );
}
else
dt = inR->dtStart();
if ( dt < cur || dt > end ) {
remote->deleteIncidence( inR );
++delFut;
}
inR = er.next();
}
}
bar.hide();
mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
eventLSync->setReadOnly( false );
eventLSync->setDtStart( mLastCalendarSync );
eventRSync->setDtStart( mLastCalendarSync );
eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
eventLSync->setReadOnly( true );
if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
remote->addEvent( eventRSync );
QString mes;
mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR );
QString delmess;
if ( delFut ) {
- delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, mSyncManager->mWriteBackInFuture );
+ delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut);
mes += delmess;
}
if ( mSyncManager->mShowSyncSummary ) {
KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
}
qDebug( mes );
mCalendar->checkAlarmForIncidence( 0, true );
return syncOK;
}
void CalendarView::setSyncDevice( QString s )
{
mCurrentSyncDevice= s;
}
void CalendarView::setSyncName( QString s )
{
mCurrentSyncName= s;
}
bool CalendarView::syncCalendar(QString filename, int mode)
{
//qDebug("syncCalendar %s ", filename.latin1());
mGlobalSyncMode = SYNC_MODE_NORMAL;
CalendarLocal* calendar = new CalendarLocal();
calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
FileStorage* storage = new FileStorage( calendar );
bool syncOK = false;
storage->setFileName( filename );
// qDebug("loading ... ");
if ( storage->load() ) {
getEventViewerDialog()->setSyncMode( true );
syncOK = synchronizeCalendar( mCalendar, calendar, mode );
getEventViewerDialog()->setSyncMode( false );
if ( syncOK ) {
if ( mSyncManager->mWriteBackFile )
{
storage->setSaveFormat( new ICalFormat() );
storage->save();
}
}
setModified( true );
}
delete storage;
delete calendar;
if ( syncOK )
updateView();
return syncOK;
}
void CalendarView::syncExternal( int mode )
{
mGlobalSyncMode = SYNC_MODE_EXTERNAL;
qApp->processEvents();
CalendarLocal* calendar = new CalendarLocal();
calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
bool syncOK = false;
bool loadSuccess = false;
PhoneFormat* phoneFormat = 0;
#ifndef DESKTOP_VERSION
SharpFormat* sharpFormat = 0;
if ( mode == 0 ) { // sharp
sharpFormat = new SharpFormat () ;
loadSuccess = sharpFormat->load( calendar, mCalendar );
diff --git a/libkcal/event.cpp b/libkcal/event.cpp
index dfa265b..7256f05 100644
--- a/libkcal/event.cpp
+++ b/libkcal/event.cpp
@@ -1,122 +1,168 @@
/*
This file is part of libkcal.
Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <kglobal.h>
#include <klocale.h>
#include <kdebug.h>
#include "event.h"
using namespace KCal;
Event::Event() :
mHasEndDate( false ), mTransparency( Opaque )
{
}
Event::Event(const Event &e) : Incidence(e)
{
mDtEnd = e.mDtEnd;
mHasEndDate = e.mHasEndDate;
mTransparency = e.mTransparency;
}
Event::~Event()
{
}
Incidence *Event::clone()
{
return new Event(*this);
}
bool KCal::operator==( const Event& e1, const Event& e2 )
{
return operator==( (const Incidence&)e1, (const Incidence&)e2 ) &&
e1.dtEnd() == e2.dtEnd() &&
e1.hasEndDate() == e2.hasEndDate() &&
e1.transparency() == e2.transparency();
}
+bool Event::contains ( Event* from )
+{
+
+ if ( !from->summary().isEmpty() )
+ if ( !summary().startsWith( from->summary() ))
+ return false;
+ if ( from->dtStart().isValid() )
+ if (dtStart() != from->dtStart() )
+ return false;
+ if ( from->dtEnd().isValid() )
+ if ( dtEnd() != from->dtEnd() )
+ return false;
+ if ( !from->location().isEmpty() )
+ if ( !location().startsWith( from->location() ) )
+ return false;
+ if ( !from->description().isEmpty() )
+ if ( !description().startsWith( from->description() ))
+ return false;
+ if ( from->alarms().count() ) {
+ Alarm *a = from->alarms().first();
+ if ( a->enabled() ){
+ if ( !alarms().count() )
+ return false;
+ Alarm *b = alarms().first();
+ if( ! b->enabled() )
+ return false;
+ if ( ! (a->offset() == b->offset() ))
+ return false;
+ }
+ }
+ QStringList cat = categories();
+ QStringList catFrom = from->categories();
+ QString nCat;
+ int iii;
+ for ( iii = 0; iii < catFrom.count();++iii ) {
+ nCat = catFrom[iii];
+ if ( !nCat.isEmpty() )
+ if ( !cat.contains( nCat )) {
+ return false;
+ }
+ }
+ if ( from->doesRecur() )
+ if ( from->doesRecur() != doesRecur() && ! (from->doesRecur()== Recurrence::rYearlyMonth && doesRecur()== Recurrence::rYearlyDay) )
+ return false;
+ return true;
+}
void Event::setDtEnd(const QDateTime &dtEnd)
{
if (mReadOnly) return;
mDtEnd = getEvenTime( dtEnd );
setHasEndDate(true);
setHasDuration(false);
updated();
}
QDateTime Event::dtEnd() const
{
if (hasEndDate()) return mDtEnd;
if (hasDuration()) return dtStart().addSecs(duration());
kdDebug(5800) << "Warning! Event '" << summary()
<< "' does have neither end date nor duration." << endl;
return dtStart();
}
QString Event::dtEndTimeStr() const
{
return KGlobal::locale()->formatTime(mDtEnd.time());
}
QString Event::dtEndDateStr(bool shortfmt) const
{
return KGlobal::locale()->formatDate(mDtEnd.date(),shortfmt);
}
QString Event::dtEndStr(bool shortfmt) const
{
return KGlobal::locale()->formatDateTime(mDtEnd, shortfmt);
}
void Event::setHasEndDate(bool b)
{
mHasEndDate = b;
}
bool Event::hasEndDate() const
{
return mHasEndDate;
}
bool Event::isMultiDay() const
{
bool multi = !(dtStart().date() == dtEnd().date());
return multi;
}
void Event::setTransparency(Event::Transparency transparency)
{
if (mReadOnly) return;
mTransparency = transparency;
updated();
}
Event::Transparency Event::transparency() const
{
return mTransparency;
diff --git a/libkcal/event.h b/libkcal/event.h
index 2a8bd95..3bc8adc 100644
--- a/libkcal/event.h
+++ b/libkcal/event.h
@@ -10,79 +10,81 @@
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef EVENT_H
#define EVENT_H
//
// Event component, representing a VEVENT object
//
#include "incidence.h"
namespace KCal {
/**
This class provides an Event in the sense of RFC2445.
*/
class Event : public Incidence
{
public:
enum Transparency { Opaque, Transparent };
typedef ListBase<Event> List;
Event();
Event(const Event &);
~Event();
QCString type() const { return "Event"; }
Incidence *clone();
QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const;
/** for setting an event's ending date/time with a QDateTime. */
void setDtEnd(const QDateTime &dtEnd);
/** Return the event's ending date/time as a QDateTime. */
virtual QDateTime dtEnd() const;
/** returns an event's end time as a string formatted according to the
users locale settings */
QString dtEndTimeStr() const;
/** returns an event's end date as a string formatted according to the
users locale settings */
QString dtEndDateStr(bool shortfmt=true) const;
/** returns an event's end date and time as a string formatted according
to the users locale settings */
QString dtEndStr(bool shortfmt=true) const;
void setHasEndDate(bool);
/** Return whether the event has an end date/time. */
bool hasEndDate() const;
/** Return true if the event spans multiple days, otherwise return false. */
bool isMultiDay() const;
/** set the event's time transparency level. */
void setTransparency(Transparency transparency);
/** get the event's time transparency level. */
Transparency transparency() const;
void setDuration(int seconds);
+ bool contains ( Event*);
+
private:
bool accept(Visitor &v) { return v.visit(this); }
QDateTime mDtEnd;
bool mHasEndDate;
Transparency mTransparency;
};
bool operator==( const Event&, const Event& );
}
#endif
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index 281434e..101db57 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -251,384 +251,370 @@ ulong PhoneFormat::getCsumEvent( Event* event )
attList << list.join("");
attList << event->categoriesStr();
//qDebug("csum cat %s", event->categoriesStr().latin1());
attList << event->secrecyStr();
return PhoneFormat::getCsum(attList );
}
ulong PhoneFormat::getCsum( const QStringList & attList)
{
int max = attList.count();
ulong cSum = 0;
int j,k,i;
int add;
for ( i = 0; i < max ; ++i ) {
QString s = attList[i];
if ( ! s.isEmpty() ){
j = s.length();
for ( k = 0; k < j; ++k ) {
int mul = k +1;
add = s[k].unicode ();
if ( k < 16 )
mul = mul * mul;
int ii = i+1;
add = add * mul *ii*ii*ii;
cSum += add;
}
}
}
//QString dump = attList.join(",");
//qDebug("csum: %d %s", cSum,dump.latin1());
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 fileName;
#ifdef _WIN32_
fileName = locateLocal("tmp", "phonefile.vcs");
#else
fileName = "/tmp/phonefile.vcs";
#endif
QString command;
if ( ! PhoneAccess::readFromPhone( fileName )) {
return false;
}
VCalFormat vfload;
vfload.setLocalTime ( true );
qDebug("loading file ...");
if ( ! vfload.load( calendar, fileName ) )
return false;
QPtrList<Event> er = calendar->rawEvents();
Event* ev = er.first();
qDebug("reading events... ");
while ( ev ) {
QStringList cat = ev->categories();
if ( cat.contains( "MeetingDEF" )) {
ev->setCategories( QStringList() );
+ } else
+ if ( cat.contains( "Birthday" )) {
+ ev->setFloats( true );
+ QDate da = ev->dtStart().date();
+ ev->setDtStart( QDateTime( da) );
+ ev->setDtEnd( QDateTime( da.addDays(1)) );
+
}
+ uint cSum;
+ cSum = PhoneFormat::getCsumEvent( ev );
int id = ev->pilotId();
Event *event;
event = existingCal->event( mProfileName ,QString::number( id ) );
if ( event ) {
event = (Event*)event->clone();
copyEvent( event, ev );
calendar->deleteEvent( ev );
calendar->addEvent( event);
}
else
event = ev;
- uint cSum;
- cSum = PhoneFormat::getCsumEvent( event );
event->setCsum( mProfileName, QString::number( cSum ));
event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
event->setID( mProfileName,QString::number( id ) );
ev = er.next();
}
{
qDebug("reading todos... ");
QPtrList<Todo> tr = calendar->rawTodos();
Todo* ev = tr.first();
while ( ev ) {
QStringList cat = ev->categories();
if ( cat.contains( "MeetingDEF" )) {
ev->setCategories( QStringList() );
}
int id = ev->pilotId();
+ uint cSum;
+ cSum = PhoneFormat::getCsumTodo( ev );
Todo *event;
event = existingCal->todo( mProfileName ,QString::number( id ) );
if ( event ) {
//qDebug("copy todo %s ", event->summary().latin1());
event = (Todo*)event->clone();
copyTodo( event, ev );
calendar->deleteTodo( ev );
calendar->addTodo( event);
}
else
event = ev;
- uint cSum;
- cSum = PhoneFormat::getCsumTodo( event );
event->setCsum( mProfileName, QString::number( cSum ));
event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
event->setID( mProfileName,QString::number( id ) );
ev = tr.next();
}
}
return true;
}
void PhoneFormat::copyEvent( Event* to, Event* from )
{
if ( from->dtStart().isValid() )
to->setDtStart( from->dtStart() );
if ( from->dtEnd().isValid() )
to->setDtEnd( from->dtEnd() );
if ( !from->location().isEmpty() )
to->setLocation( from->location() );
if ( !from->description().isEmpty() )
to->setDescription( from->description() );
if ( !from->summary().isEmpty() )
to->setSummary( from->summary() );
if ( from->alarms().count() ) {
to->clearAlarms();
Alarm *a = from->alarms().first();
Alarm *b = to->newAlarm( );
b->setEnabled( a->enabled() );
- if ( a->hasStartOffset() ) {
- b->setStartOffset( a->startOffset() );
- }
- if ( a->hasTime() )
- b->setTime( a->time() );
+ b->setStartOffset(Duration( a->offset() ) );
}
QStringList cat = to->categories();
QStringList catFrom = from->categories();
QString nCat;
int iii;
for ( iii = 0; iii < catFrom.count();++iii ) {
nCat = catFrom[iii];
if ( !nCat.isEmpty() )
if ( !cat.contains( nCat )) {
cat << nCat;
}
}
to->setCategories( cat );
- Recurrence * r = new Recurrence( *from->recurrence(),to);
- to->setRecurrence( r ) ;
+ if ( from->doesRecur() ) {
+ Recurrence * r = new Recurrence( *from->recurrence(),to);
+ to->setRecurrence( r ) ;
+ }
}
void PhoneFormat::copyTodo( Todo* to, Todo* from )
{
- if ( from->dtStart().isValid() )
+ if ( from->hasStartDate() ) {
+ to->setHasStartDate( true );
to->setDtStart( from->dtStart() );
- if ( from->dtDue().isValid() )
+ }
+ if ( from->hasDueDate() ){
+ to->setHasDueDate( true );
to->setDtDue( from->dtDue() );
+ }
if ( !from->location().isEmpty() )
to->setLocation( from->location() );
if ( !from->description().isEmpty() )
to->setDescription( from->description() );
if ( !from->summary().isEmpty() )
to->setSummary( from->summary() );
if ( from->alarms().count() ) {
to->clearAlarms();
Alarm *a = from->alarms().first();
Alarm *b = to->newAlarm( );
b->setEnabled( a->enabled() );
- if ( a->hasStartOffset() )
- b->setStartOffset( a->startOffset() );
- if ( a->hasTime() )
- b->setTime( a->time() );
+ b->setStartOffset(Duration( a->offset() ) );
}
QStringList cat = to->categories();
QStringList catFrom = from->categories();
QString nCat;
int iii;
for ( iii = 0; iii < catFrom.count();++iii ) {
nCat = catFrom[iii];
if ( !nCat.isEmpty() )
if ( !cat.contains( nCat )) {
cat << nCat;
}
}
to->setCategories( cat );
if ( from->isCompleted() ) {
to->setCompleted( true );
if( from->completed().isValid() )
to->setCompleted( from->completed() );
} else {
// set percentcomplete only, if to->isCompleted()
if ( to->isCompleted() )
to->setPercentComplete(from->percentComplete());
}
if( to->priority() == 2 && from->priority() == 1 )
; //skip
else if (to->priority() == 4 && from->priority() == 5 )
;
else
to->setPriority(from->priority());
}
#include <qcstring.h>
-void PhoneFormat::afterSave( Incidence* inc)
+void PhoneFormat::afterSave( Incidence* inc,const QString& id ,const QString& csum)
{
- uint csum;
- inc->removeID( mProfileName );
- if ( inc->type() == "Event")
- csum = PhoneFormat::getCsumEvent( (Event*) inc );
- else
- csum = PhoneFormat::getCsumTodo( (Todo*) inc );
- inc->setCsum( mProfileName, QString::number( csum ));
-
+ inc->setID( mProfileName, id );
+ inc->setCsum( mProfileName, csum);
inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
}
bool PhoneFormat::writeToPhone( Calendar * calendar)
{
#ifdef _WIN32_
- QString fileName = locateLocal("tmp", "tempfile.vcs");
+ QString fileName = locateLocal("tmp", "phonefile.vcs");
#else
- QString fileName = "/tmp/kdepimtemp.vcs";
+ QString fileName = "/tmp/phonefile.vcs";
#endif
VCalFormat vfsave;
vfsave.setLocalTime ( true );
QString id = calendar->timeZoneId();
calendar->setLocalTime();
if ( ! vfsave.save( calendar, fileName ) )
return false;
calendar->setTimeZoneId( id );
return PhoneAccess::writeToPhone( fileName );
}
bool PhoneFormat::save( Calendar *calendar)
{
- QLabel status ( i18n(" Opening device ..."), 0 );
- int w = status.sizeHint().width()+20 ;
- if ( w < 200 ) w = 230;
- int h = status.sizeHint().height()+20 ;
- int dw = QApplication::desktop()->width();
- int dh = QApplication::desktop()->height();
- status.setCaption(i18n("Writing to phone...") );
- status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
- status.show();
- status.raise();
- qApp->processEvents();
- QString message;
+
// 1 remove events which should be deleted
QPtrList<Event> er = calendar->rawEvents();
Event* ev = er.first();
while ( ev ) {
if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
calendar->deleteEvent( ev );
} else {
}
ev = er.next();
}
// 2 remove todos which should be deleted
QPtrList<Todo> tl = calendar->rawTodos();
Todo* to = tl.first();
while ( to ) {
if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
calendar->deleteTodo( to );
} else {
if ( to->isCompleted()) {
calendar->deleteTodo( to );
}
}
to = tl.next();
}
// 3 save file
if ( !writeToPhone( calendar ) )
return false;
-
+ QLabel status ( i18n(" Opening device ..."), 0 );
+ int w = status.sizeHint().width()+20 ;
+ if ( w < 200 ) w = 230;
+ int h = status.sizeHint().height()+20 ;
+ int dw = QApplication::desktop()->width();
+ int dh = QApplication::desktop()->height();
+ status.setCaption(i18n("Writing to phone...") );
+ status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
+ QString message;
+ status.show();
+ status.raise();
+ qApp->processEvents();
// 5 reread data
message = i18n(" Rereading all data ... ");
status.setText ( message );
qApp->processEvents();
CalendarLocal* calendarTemp = new CalendarLocal();
calendarTemp->setTimeZoneId( calendar->timeZoneId());
if ( ! load( calendarTemp,calendar) ){
qDebug("error reloading calendar ");
delete calendarTemp;
return false;
}
// 6 compare data
//algo 6 compare event
er = calendar->rawEvents();
ev = er.first();
message = i18n(" Comparing event # ");
QPtrList<Event> er1 = calendarTemp->rawEvents();
Event* ev1;
int procCount = 0;
while ( ev ) {
//qDebug("event new ID %s",ev->summary().latin1());
status.setText ( message + QString::number ( ++procCount ) );
qApp->processEvents();
- uint csum;
- csum = PhoneFormat::getCsumEvent( ev );
- QString cSum = QString::number( csum );
- //ev->setCsum( mProfileName, cSum );
- //qDebug("Event cSum %s ", cSum.latin1());
ev1 = er1.first();
while ( ev1 ) {
- if ( ev1->getCsum( mProfileName ) == cSum ) {
+ if ( ev->contains( ev1 ) ) {
+ afterSave( ev ,ev1->getID(mProfileName),ev1->getCsum(mProfileName));
er1.remove( ev1 );
- afterSave( ev );
- ev->setID(mProfileName, ev1->getID(mProfileName) );
- //qDebug("Event found on phone for %s ", ev->summary().latin1());
-
break;
}
ev1 = er1.next();
}
if ( ! ev1 ) {
// ev->removeID(mProfileName);
qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1());
}
ev = er.next();
}
//algo 6 compare todo
tl = calendar->rawTodos();
to = tl.first();
procCount = 0;
QPtrList<Todo> tl1 = calendarTemp->rawTodos();
Todo* to1 ;
message = i18n(" Comparing todo # ");
while ( to ) {
status.setText ( message + QString::number ( ++procCount ) );
qApp->processEvents();
- uint csum;
- csum = PhoneFormat::getCsumTodo( to );
- QString cSum = QString::number( csum );
- //to->setCsum( mProfileName, cSum );
- //qDebug("Todo cSum %s ", cSum.latin1());
Todo* to1 = tl1.first();
while ( to1 ) {
- if ( to1->getCsum( mProfileName ) == cSum ) {
+ if ( to->contains( to1 ) ) {
+ afterSave( to ,to1->getID(mProfileName),to1->getCsum(mProfileName));
tl1.remove( to1 );
- afterSave( to );
- to->setID(mProfileName, to1->getID(mProfileName) );
break;
}
to1 = tl1.next();
}
if ( ! to1 ) {
//to->removeID(mProfileName);
qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1());
}
to = tl.next();
}
delete calendarTemp;
return true;
}
QString PhoneFormat::toString( Calendar * )
{
return QString::null;
}
bool PhoneFormat::fromString( Calendar *calendar, const QString & text)
{
return false;
}
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h
index 001fd81..d11f68b 100644
--- a/libkcal/phoneformat.h
+++ b/libkcal/phoneformat.h
@@ -1,62 +1,62 @@
/*
This file is part of libkcal.
Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef PHONEFORMAT_H
#define PHONEFORMAT_H
#include <qstring.h>
#include "scheduler.h"
#include "vcalformat.h"
#include "calformat.h"
namespace KCal {
/**
This class implements the calendar format used by Phone.
*/
class Event;
class Todo;
class PhoneFormat : public QObject {
public:
/** Create new iCalendar format. */
PhoneFormat(QString profileName, QString device,QString connection, QString model);
virtual ~PhoneFormat();
bool load( Calendar * ,Calendar * );
bool save( Calendar * );
bool fromString( Calendar *, const QString & );
QString toString( Calendar * );
static ulong getCsum( const QStringList & );
static ulong getCsumTodo( Todo* to );
static ulong getCsumEvent( Event* ev );
static bool writeToPhone( Calendar * );
private:
void copyEvent( Event* to, Event* from );
void copyTodo( Todo* to, Todo* from );
//int initDevice(GSM_StateMachine *s);
QString mProfileName;
- void afterSave( Incidence* );
+ void afterSave( Incidence* ,const QString&,const QString&);
};
}
#endif
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 0c1e3e4..3d2de61 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -1,123 +1,181 @@
/*
This file is part of libkcal.
Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <kglobal.h>
#include <klocale.h>
#include <kdebug.h>
#include "todo.h"
using namespace KCal;
Todo::Todo(): Incidence()
{
// mStatus = TENTATIVE;
mHasDueDate = false;
setHasStartDate( false );
mCompleted = getEvenTime(QDateTime::currentDateTime());
mHasCompletedDate = false;
mPercentComplete = 0;
}
Todo::Todo(const Todo &t) : Incidence(t)
{
mDtDue = t.mDtDue;
mHasDueDate = t.mHasDueDate;
mCompleted = t.mCompleted;
mHasCompletedDate = t.mHasCompletedDate;
mPercentComplete = t.mPercentComplete;
}
Todo::~Todo()
{
}
Incidence *Todo::clone()
{
return new Todo(*this);
}
+bool Todo::contains ( Todo* from )
+{
+ if ( !from->summary().isEmpty() )
+ if ( !summary().startsWith( from->summary() ))
+ return false;
+ if ( from->hasStartDate() ) {
+ if ( !hasStartDate() )
+ return false;
+ if ( from->dtStart() != dtStart())
+ return false;
+ }
+ if ( from->hasDueDate() ){
+ if ( !hasDueDate() )
+ return false;
+ if ( from->dtDue() != dtDue())
+ return false;
+ }
+ if ( !from->location().isEmpty() )
+ if ( !location().startsWith( from->location() ) )
+ return false;
+ if ( !from->description().isEmpty() )
+ if ( !description().startsWith( from->description() ))
+ return false;
+ if ( from->alarms().count() ) {
+ Alarm *a = from->alarms().first();
+ if ( a->enabled() ){
+ if ( !alarms().count() )
+ return false;
+ Alarm *b = alarms().first();
+ if( ! b->enabled() )
+ return false;
+ if ( ! (a->offset() == b->offset() ))
+ return false;
+ }
+ }
+
+ QStringList cat = categories();
+ QStringList catFrom = from->categories();
+ QString nCat;
+ int iii;
+ for ( iii = 0; iii < catFrom.count();++iii ) {
+ nCat = catFrom[iii];
+ if ( !nCat.isEmpty() )
+ if ( !cat.contains( nCat )) {
+ return false;
+ }
+ }
+ if ( from->isCompleted() ) {
+ if ( !isCompleted() )
+ return false;
+ }
+ if( priority() != from->priority() )
+ return false;
+
+
+ return true;
+
+}
bool KCal::operator==( const Todo& t1, const Todo& t2 )
{
bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 );
if ( ! ret )
return false;
if ( t1.hasDueDate() == t2.hasDueDate() ) {
if ( t1.hasDueDate() ) {
if ( t1.doesFloat() == t2.doesFloat() ) {
if ( t1.doesFloat() ) {
if ( t1.dtDue().date() != t2.dtDue().date() )
return false;
} else
if ( t1.dtDue() != t2.dtDue() )
return false;
} else
return false;// float !=
}
} else
return false;
if ( t1.percentComplete() != t2.percentComplete() )
return false;
if ( t1.isCompleted() ) {
if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) {
if ( t1.hasCompletedDate() ) {
if ( t1.completed() != t2.completed() )
return false;
}
} else
return false;
}
return true;
}
void Todo::setDtDue(const QDateTime &dtDue)
{
//int diffsecs = mDtDue.secsTo(dtDue);
/*if (mReadOnly) return;
const QPtrList<Alarm>& alarms = alarms();
for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) {
if (alarm->enabled()) {
alarm->setTime(alarm->time().addSecs(diffsecs));
}
}*/
mDtDue = getEvenTime(dtDue);
//kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl;
/*const QPtrList<Alarm>& alarms = alarms();
for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next())
alarm->setAlarmStart(mDtDue);*/
updated();
}
QDateTime Todo::dtDue() const
{
return mDtDue;
}
diff --git a/libkcal/todo.h b/libkcal/todo.h
index 9aa92f8..0f22c59 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -38,84 +38,85 @@ class Todo : public Incidence
~Todo();
typedef ListBase<Todo> List;
QCString type() const { return "Todo"; }
/** Return an exact copy of this todo. */
Incidence *clone();
QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const;
/** for setting the todo's due date/time with a QDateTime. */
void setDtDue(const QDateTime &dtDue);
/** returns an event's Due date/time as a QDateTime. */
QDateTime dtDue() const;
/** returns an event's due time as a string formatted according to the
users locale settings */
QString dtDueTimeStr() const;
/** returns an event's due date as a string formatted according to the
users locale settings */
QString dtDueDateStr(bool shortfmt=true) const;
/** returns an event's due date and time as a string formatted according
to the users locale settings */
QString dtDueStr(bool shortfmt=true) const;
/** returns TRUE or FALSE depending on whether the todo has a due date */
bool hasDueDate() const;
/** sets the event's hasDueDate value. */
void setHasDueDate(bool f);
/** sets the event's status to the string specified. The string
* must be a recognized value for the status field, i.e. a string
* equivalent of the possible status enumerations previously described. */
// void setStatus(const QString &statStr);
/** sets the event's status to the value specified. See the enumeration
* above for possible values. */
// void setStatus(int);
/** return the event's status. */
// int status() const;
/** return the event's status in string format. */
// QString statusStr() const;
/** return, if this todo is completed */
bool isCompleted() const;
/** set completed state of this todo */
void setCompleted(bool);
/**
Return how many percent of the task are completed. Returns a value
between 0 and 100.
*/
int percentComplete() const;
/**
Set how many percent of the task are completed. Valid values are in the
range from 0 to 100.
*/
void setPercentComplete(int);
/** return date and time when todo was completed */
QDateTime completed() const;
QString completedStr() const;
/** set date and time of completion */
void setCompleted(const QDateTime &completed);
/** Return true, if todo has a date associated with completion */
bool hasCompletedDate() const;
+ bool contains ( Todo*);
private:
bool accept(Visitor &v) { return v.visit(this); }
QDateTime mDtDue; // due date of todo
bool mHasDueDate; // if todo has associated due date
// int mStatus; // confirmed/delegated/tentative/etc
QDateTime mCompleted;
bool mHasCompletedDate;
int mPercentComplete;
};
bool operator==( const Todo&, const Todo& );
}
#endif
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp
index a6ae1bc..df93209 100644
--- a/libkcal/vcalformat.cpp
+++ b/libkcal/vcalformat.cpp
@@ -1,157 +1,159 @@
/*
This file is part of libkcal.
Copyright (c) 1998 Preston Brwon
Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <qapplication.h>
#include <qdatetime.h>
#include <qstring.h>
#include <qptrlist.h>
#include <qregexp.h>
#include <qclipboard.h>
#include <qdialog.h>
#include <qfile.h>
#include <kdebug.h>
#include <kglobal.h>
#include <kmessagebox.h>
#include <kiconloader.h>
#include <klocale.h>
#include "vcc.h"
#include "vobject.h"
#include "vcaldrag.h"
#include "calendar.h"
#include "vcalformat.h"
using namespace KCal;
VCalFormat::VCalFormat()
{
mCalendar = 0;
useLocalTime = false;
}
VCalFormat::~VCalFormat()
{
}
void VCalFormat::setLocalTime ( bool b )
{
useLocalTime = b;
}
bool VCalFormat::load(Calendar *calendar, const QString &fileName)
{
mCalendar = calendar;
clearException();
- useLocalTime = mCalendar->isLocalTime();
+ if ( ! useLocalTime )
+ useLocalTime = mCalendar->isLocalTime();
VObject *vcal = 0;
// this is not necessarily only 1 vcal. Could be many vcals, or include
// a vcard...
vcal = Parse_MIME_FromFileName(const_cast<char *>(QFile::encodeName(fileName).data()));
if (!vcal) {
setException(new ErrorFormat(ErrorFormat::CalVersionUnknown));
return FALSE;
}
// any other top-level calendar stuff should be added/initialized here
// put all vobjects into their proper places
populate(vcal);
// clean up from vcal API stuff
cleanVObjects(vcal);
cleanStrTbl();
return true;
}
bool VCalFormat::save(Calendar *calendar, const QString &fileName)
{
mCalendar = calendar;
- useLocalTime = mCalendar->isLocalTime();
+ if ( ! useLocalTime )
+ useLocalTime = mCalendar->isLocalTime();
QString tmpStr;
VObject *vcal, *vo;
vcal = newVObject(VCCalProp);
// addPropValue(vcal,VCLocationProp, "0.0");
addPropValue(vcal,VCProdIdProp, productId());
tmpStr = mCalendar->getTimeZoneStr();
//qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() );
addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit());
addPropValue(vcal,VCVersionProp, _VCAL_VERSION);
// TODO STUFF
QPtrList<Todo> todoList = mCalendar->rawTodos();
QPtrListIterator<Todo> qlt(todoList);
for (; qlt.current(); ++qlt) {
vo = eventToVTodo(qlt.current());
addVObjectProp(vcal, vo);
}
// EVENT STUFF
QPtrList<Event> events = mCalendar->rawEvents();
Event *ev;
for(ev=events.first();ev;ev=events.next()) {
vo = eventToVEvent(ev);
addVObjectProp(vcal, vo);
}
writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal);
cleanVObjects(vcal);
cleanStrTbl();
if (QFile::exists(fileName)) {
return true;
} else {
return false; // error
}
}
bool VCalFormat::fromString( Calendar *calendar, const QString &text )
{
// TODO: Factor out VCalFormat::fromString()
QCString data = text.utf8();
if ( !data.size() ) return false;
VObject *vcal = Parse_MIME( data.data(), data.size());
if ( !vcal ) return false;
VObjectIterator i;
VObject *curvo;
initPropIterator( &i, vcal );
// we only take the first object. TODO: parse all incidences.
do {
curvo = nextVObject( &i );
} while ( strcmp( vObjectName( curvo ), VCEventProp ) &&
strcmp( vObjectName( curvo ), VCTodoProp ) );
if ( strcmp( vObjectName( curvo ), VCEventProp ) == 0 ) {
Event *event = VEventToEvent( curvo );
@@ -1111,194 +1113,198 @@ Event* VCalFormat::VEventToEvent(VObject *vevent)
index += 2; // advance to day(s)
while (numFromDay(tmpStr.mid(index,3)) >= 0) {
int dayNum = numFromDay(tmpStr.mid(index,3));
qba.setBit(dayNum);
index += 3; // advance to next day, or possibly pos or "#"
}
anEvent->recurrence()->addMonthlyPos(tmpPos, qba);
qba.detach();
qba.fill(FALSE); // clear out
} // while != "#"
}
index = last; if (tmpStr.mid(index,1) == "#") index++;
if (tmpStr.find('T', index) != -1) {
QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length() -
index))).date();
anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rEndDate);
} else {
int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt();
if (rDuration == 0)
anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, -1);
else
anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rDuration);
}
}
/**************************** MONTHLY-BY-DAY ***************************/
else if (tmpStr.left(2) == "MD") {
int index = tmpStr.find(' ');
int last = tmpStr.findRev(' ') + 1;
int rFreq = tmpStr.mid(2, (index-1)).toInt();
index += 1;
short tmpDay;
if( index == last ) {
// e.g. MD1 #0
tmpDay = anEvent->dtStart().date().day();
anEvent->recurrence()->addMonthlyDay(tmpDay);
}
else {
// e.g. MD1 3 #0
while (index < last) {
int index2 = tmpStr.find(' ', index);
tmpDay = tmpStr.mid(index, (index2-index)).toShort();
index = index2-1;
if (tmpStr.mid(index, 1) == "-")
tmpDay = 0 - tmpDay;
index += 2; // advance the index;
anEvent->recurrence()->addMonthlyDay(tmpDay);
} // while != #
}
index = last; if (tmpStr.mid(index,1) == "#") index++;
if (tmpStr.find('T', index) != -1) {
QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date();
anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rEndDate);
} else {
int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt();
if (rDuration == 0)
anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, -1);
else
anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rDuration);
}
}
/*********************** YEARLY-BY-MONTH *******************************/
else if (tmpStr.left(2) == "YM") {
- int index = tmpStr.find(' ');
- int last = tmpStr.findRev(' ') + 1;
- int rFreq = tmpStr.mid(2, (index-1)).toInt();
- index += 1;
- short tmpMonth;
- if( index == last ) {
- // e.g. YM1 #0
- tmpMonth = anEvent->dtStart().date().month();
- anEvent->recurrence()->addYearlyNum(tmpMonth);
- }
- else {
- // e.g. YM1 3 #0
- while (index < last) {
- int index2 = tmpStr.find(' ', index);
- tmpMonth = tmpStr.mid(index, (index2-index)).toShort();
- index = index2+1;
- anEvent->recurrence()->addYearlyNum(tmpMonth);
- } // while != #
- }
- index = last; if (tmpStr.mid(index,1) == "#") index++;
- if (tmpStr.find('T', index) != -1) {
- QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date();
- anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rEndDate);
- } else {
- int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt();
- if (rDuration == 0)
- anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, -1);
- else
- anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rDuration);
- }
+ // we have to set this such that recurrence accepts addYearlyNum(tmpDay);
+ anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, 1, -1);
+ int index = tmpStr.find(' ');
+ int last = tmpStr.findRev(' ') + 1;
+ int rFreq = tmpStr.mid(2, (index-1)).toInt();
+ index += 1;
+ short tmpMonth;
+ if( index == last ) {
+ // e.g. YM1 #0
+ tmpMonth = anEvent->dtStart().date().month();
+ anEvent->recurrence()->addYearlyNum(tmpMonth);
+ }
+ else {
+ // e.g. YM1 3 #0
+ while (index < last) {
+ int index2 = tmpStr.find(' ', index);
+ tmpMonth = tmpStr.mid(index, (index2-index)).toShort();
+ index = index2+1;
+ anEvent->recurrence()->addYearlyNum(tmpMonth);
+ } // while != #
+ }
+ index = last; if (tmpStr.mid(index,1) == "#") index++;
+ if (tmpStr.find('T', index) != -1) {
+ QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date();
+ anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rEndDate);
+ } else {
+ int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt();
+ if (rDuration == 0)
+ anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, -1);
+ else
+ anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rDuration);
+ }
}
/*********************** YEARLY-BY-DAY *********************************/
else if (tmpStr.left(2) == "YD") {
- int index = tmpStr.find(' ');
- int last = tmpStr.findRev(' ') + 1;
- int rFreq = tmpStr.mid(2, (index-1)).toInt();
- index += 1;
- short tmpDay;
- if( index == last ) {
- // e.g. YD1 #0
- tmpDay = anEvent->dtStart().date().dayOfYear();
- anEvent->recurrence()->addYearlyNum(tmpDay);
- }
- else {
- // e.g. YD1 123 #0
- while (index < last) {
- int index2 = tmpStr.find(' ', index);
- tmpDay = tmpStr.mid(index, (index2-index)).toShort();
- index = index2+1;
- anEvent->recurrence()->addYearlyNum(tmpDay);
- } // while != #
- }
- index = last; if (tmpStr.mid(index,1) == "#") index++;
- if (tmpStr.find('T', index) != -1) {
- QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date();
- anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate);
- } else {
- int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt();
- if (rDuration == 0)
- anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1);
- else
- anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration);
- }
+ // we have to set this such that recurrence accepts addYearlyNum(tmpDay);
+ anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, 1, -1);
+ int index = tmpStr.find(' ');
+ int last = tmpStr.findRev(' ') + 1;
+ int rFreq = tmpStr.mid(2, (index-1)).toInt();
+ index += 1;
+ short tmpDay;
+ if( index == last ) {
+ // e.g. YD1 #0
+ tmpDay = anEvent->dtStart().date().dayOfYear();
+ anEvent->recurrence()->addYearlyNum(tmpDay);
+ }
+ else {
+ // e.g. YD1 123 #0
+ while (index < last) {
+ int index2 = tmpStr.find(' ', index);
+ tmpDay = tmpStr.mid(index, (index2-index)).toShort();
+ index = index2+1;
+ anEvent->recurrence()->addYearlyNum(tmpDay);
+ } // while != #
+ }
+ index = last; if (tmpStr.mid(index,1) == "#") index++;
+ if (tmpStr.find('T', index) != -1) {
+ QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date();
+ anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate);
+ } else {
+ int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt();
+ if (rDuration == 0)
+ anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1);
+ else
+ anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration);
+ }
} else {
- kdDebug(5800) << "we don't understand this type of recurrence!" << endl;
+ kdDebug(5800) << "we don't understand this type of recurrence!" << endl;
} // if
} // repeats
// recurrence exceptions
if ((vo = isAPropertyOf(vevent, VCExpDateProp)) != 0) {
s = fakeCString(vObjectUStringZValue(vo));
QStringList exDates = QStringList::split(",",s);
QStringList::ConstIterator it;
for(it = exDates.begin(); it != exDates.end(); ++it ) {
anEvent->addExDate(ISOToQDate(*it));
}
deleteStr(s);
}
// summary
if ((vo = isAPropertyOf(vevent, VCSummaryProp))) {
s = fakeCString(vObjectUStringZValue(vo));
anEvent->setSummary(QString::fromLocal8Bit(s));
deleteStr(s);
}
if ((vo = isAPropertyOf(vevent, VCLocationProp))) {
s = fakeCString(vObjectUStringZValue(vo));
anEvent->setLocation(QString::fromLocal8Bit(s));
deleteStr(s);
}
// description
if ((vo = isAPropertyOf(vevent, VCDescriptionProp)) != 0) {
s = fakeCString(vObjectUStringZValue(vo));
if (!anEvent->description().isEmpty()) {
anEvent->setDescription(anEvent->description() + "\n" +
QString::fromLocal8Bit(s));
} else {
anEvent->setDescription(QString::fromLocal8Bit(s));
}
deleteStr(s);
}
// some stupid vCal exporters ignore the standard and use Description
// instead of Summary for the default field. Correct for this.
if (anEvent->summary().isEmpty() &&
!(anEvent->description().isEmpty())) {
QString tmpStr = anEvent->description().simplifyWhiteSpace();
anEvent->setDescription("");
anEvent->setSummary(tmpStr);
}
#if 0
// status
if ((vo = isAPropertyOf(vevent, VCStatusProp)) != 0) {
QString tmpStr(s = fakeCString(vObjectUStringZValue(vo)));
deleteStr(s);
// TODO: Define Event status
// anEvent->setStatus(tmpStr);
}
else
// anEvent->setStatus("NEEDS ACTION");
#endif
// secrecy
int secrecy = Incidence::SecrecyPublic;
if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) {
s = fakeCString(vObjectUStringZValue(vo));
@@ -1475,134 +1481,135 @@ QDateTime VCalFormat::ISOToQDateTime(const QString & dtStr)
tmpDate.setYMD(year, month, day);
tmpTime.setHMS(hour, minute, second);
ASSERT(tmpDate.isValid());
ASSERT(tmpTime.isValid());
QDateTime tmpDT(tmpDate, tmpTime);
// correct for GMT if string is in Zulu format
if (dtStr.at(dtStr.length()-1) == 'Z')
tmpDT = tmpDT.addSecs (KGlobal::locale()->localTimeOffset( tmpDT )*60);
return tmpDT;
}
QDate VCalFormat::ISOToQDate(const QString &dateStr)
{
int year, month, day;
year = dateStr.left(4).toInt();
month = dateStr.mid(4,2).toInt();
day = dateStr.mid(6,2).toInt();
return(QDate(year, month, day));
}
// take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc.
// and break it down from it's tree-like format into the dictionary format
// that is used internally in the VCalFormat.
void VCalFormat::populate(VObject *vcal)
{
// this function will populate the caldict dictionary and other event
// lists. It turns vevents into Events and then inserts them.
VObjectIterator i;
VObject *curVO, *curVOProp;
Event *anEvent;
if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) {
char *methodType = 0;
methodType = fakeCString(vObjectUStringZValue(curVO));
kdDebug() << "This calendar is an iTIP transaction of type '"
<< methodType << "'" << endl;
delete methodType;
}
// warn the user that we might have trouble reading non-known calendar.
if ((curVO = isAPropertyOf(vcal, VCProdIdProp)) != 0) {
char *s = fakeCString(vObjectUStringZValue(curVO));
if (strcmp(productId().local8Bit(), s) != 0)
kdDebug() << "This vCalendar file was not created by KOrganizer "
"or any other product we support. Loading anyway..." << endl;
mLoadedProductId = s;
deleteStr(s);
}
// warn the user we might have trouble reading this unknown version.
if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) {
char *s = fakeCString(vObjectUStringZValue(curVO));
if (strcmp(_VCAL_VERSION, s) != 0)
kdDebug() << "This vCalendar file has version " << s
<< "We only support " << _VCAL_VERSION << endl;
deleteStr(s);
}
// set the time zone
if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) {
- char *s = fakeCString(vObjectUStringZValue(curVO));
- mCalendar->setTimeZone(s);
- deleteStr(s);
+ if ( vObjectUStringZValue(curVO) != 0 ) {
+ char *s = fakeCString(vObjectUStringZValue(curVO));
+ mCalendar->setTimeZone(s);
+ deleteStr(s);
+ }
}
-
// Store all events with a relatedTo property in a list for post-processing
mEventsRelate.clear();
mTodosRelate.clear();
initPropIterator(&i, vcal);
// go through all the vobjects in the vcal
while (moreIteration(&i)) {
curVO = nextVObject(&i);
/************************************************************************/
// now, check to see that the object is an event or todo.
if (strcmp(vObjectName(curVO), VCEventProp) == 0) {
if ((curVOProp = isAPropertyOf(curVO, XPilotStatusProp)) != 0) {
char *s;
s = fakeCString(vObjectUStringZValue(curVOProp));
// check to see if event was deleted by the kpilot conduit
if (atoi(s) == Event::SYNCDEL) {
deleteStr(s);
kdDebug(5800) << "skipping pilot-deleted event" << endl;
goto SKIP;
}
deleteStr(s);
}
// this code checks to see if we are trying to read in an event
// that we already find to be in the calendar. If we find this
// to be the case, we skip the event.
if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) {
char *s = fakeCString(vObjectUStringZValue(curVOProp));
QString tmpStr(s);
deleteStr(s);
if (mCalendar->event(tmpStr)) {
goto SKIP;
}
if (mCalendar->todo(tmpStr)) {
goto SKIP;
}
}
if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) &&
(!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) {
kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl;
goto SKIP;
}
anEvent = VEventToEvent(curVO);
// we now use addEvent instead of insertEvent so that the
// signal/slot get connected.
if (anEvent) {
if ( !anEvent->dtStart().isValid() || !anEvent->dtEnd().isValid() ) {
kdDebug() << "VCalFormat::populate(): Event has invalid dates."
<< endl;
} else {
mCalendar->addEvent(anEvent);
}
} else {
// some sort of error must have occurred while in translation.
goto SKIP;
}
} else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) {
diff --git a/libkdepim/phoneaccess.cpp b/libkdepim/phoneaccess.cpp
index 8298aa6..e24ad9e 100644
--- a/libkdepim/phoneaccess.cpp
+++ b/libkdepim/phoneaccess.cpp
@@ -1,173 +1,216 @@
/*
This file is part of libkdepim.
Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <qstring.h>
#include <qapplication.h>
#include <qptrlist.h>
#include <qregexp.h>
#include <qfile.h>
+#include <qlabel.h>
#include <qtextstream.h>
#include <qtextcodec.h>
#include <qdir.h>
#include <kmessagebox.h>
#include <stdlib.h>
#include "phoneaccess.h"
void PhoneAccess::writeConfig( QString device, QString connection, QString model )
{
#ifdef _WIN32_
QString fileName = qApp->applicationDirPath () +"\\gammurc";
#else
QString fileName = QDir::homeDirPath() +"/.gammurc";
#endif
//qDebug("save %d ", load );
QString content = "[gammu]\n";;
bool write = false;
bool addPort = true, addConnection = true, addModel = true;
QFile file( fileName );
if ( QFile::exists( fileName) ) {
if (!file.open( IO_ReadOnly ) ) {
qDebug("Error: cannot open %s ", fileName.latin1() );
return;
}
QString line;
while ( file.readLine( line, 1024 ) > 0 ) {
//qDebug("*%s* ", line.latin1() );
if ( line.left(7 ) == "[gammu]" ) {
;
} else
if ( line.left(4 ) == "port" ) {
if ( line == "port = " + device+"\n" ) {
content += line ;
addPort = false;
//qDebug("port found" );
}
} else if ( line.left(5 ) == "model" ) {
if ( line == "model = " + model +"\n") {
content += line ;
addModel = false;
//qDebug("model found" );
}
} else if ( line.left( 10 ) == "connection" ) {
if ( line == "connection = " + connection +"\n") {
addConnection = false;
content += line ;
//qDebug("con found" );
}
} else {
content += line ;
}
}
file.close();
} else {
if ( ! connection.isEmpty() ) {
addConnection = true;
}
if ( ! device.isEmpty() ) {
addPort = true;
}
if ( ! model.isEmpty() ) {
addModel = true;
}
}
if ( addConnection ) {
write = true;
content += "connection = ";
content += connection;
content += "\n";
}
if ( addPort ) {
write = true;
content += "port = ";
content += device;
content += "\n";
}
if ( addModel ) {
write = true;
content += "model = ";
content += model;
content += "\n";
}
if ( write ) {
if (!file.open( IO_WriteOnly ) ) {
qDebug("Error: cannot write file %s ", fileName.latin1() );
return;
}
qDebug("Writing file %s ", fileName.latin1() );
QTextStream ts( &file );
ts << content ;
file.close();
}
}
bool PhoneAccess::writeToPhone( QString fileName)
{
#ifdef DESKTOP_VERSION
#ifdef _WIN32_
QString command ="kammu --restore " + fileName ;
#else
QString command ="./kammu --restore " + fileName ;
#endif
#else
QString command ="kammu --restore " + fileName ;
#endif
- int ret;
- while ( (ret = system ( command.latin1())) != 0 ) {
- qDebug("Error S::command returned %d.", ret);
- int retval = KMessageBox::warningContinueCancel(0,
- i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel"));
- if ( retval != KMessageBox::Continue )
- return false;
+ int ret = 1;
+ while ( ret != 0 ) {
+ QLabel* status = new QLabel( i18n(" This may take 1-3 minutes!"), 0 );
+ int w = 235;
+ int h = status->sizeHint().height()+20 ;
+ int dw = QApplication::desktop()->width();
+ int dh = QApplication::desktop()->height();
+ if ( dw > 310 )
+ w = 310;
+ status->setCaption(i18n("Writing to phone...") );
+ status->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
+ status->show();
+ status->raise();
+ status->update();
+ qApp->processEvents();
+ status->update();
+ qApp->processEvents();
+ ret = system ( command.latin1());
+ delete status;
+ qApp->processEvents();
+ if ( ret ) {
+ qDebug("Error S::command returned %d.", ret);
+ int retval = KMessageBox::warningContinueCancel(0,
+ i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel"));
+ if ( retval != KMessageBox::Continue )
+ return false;
+ }
}
return true;
}
bool PhoneAccess::readFromPhone( QString fileName)
{
#ifdef DESKTOP_VERSION
#ifdef _WIN32_
QString command ="kammu --backup " + fileName + " -yes" ;
#else
QString command ="./kammu --backup " + fileName + " -yes" ;
#endif
#else
QString command ="kammu --backup " + fileName + " -yes" ;
#endif
int ret;
- while ( (ret = system ( command.latin1())) != 0 ) {
- qDebug("Error reading from phone:Command returned %d", ret);
- int retval = KMessageBox::warningContinueCancel(0,
- i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel"));
- if ( retval != KMessageBox::Continue )
- return false;
+ while ( ret != 0 ) {
+ QLabel* status = new QLabel( i18n(" This may take 1-3 minutes!"), 0 );
+ int w = 235;
+ int h = status->sizeHint().height()+20 ;
+ int dw = QApplication::desktop()->width();
+ int dh = QApplication::desktop()->height();
+ if ( dw > 310 )
+ w = 310;
+ status->setCaption(i18n("Reading from phone...") );
+ status->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
+ status->show();
+ status->raise();
+ status->update();
+ qApp->processEvents();
+ status->update();
+ qApp->processEvents();
+ ret = system ( command.latin1() );
+ delete status;
+ qApp->processEvents();
+ if ( ret ) {
+ qDebug("Error reading from phone:Command returned %d", ret);
+ int retval = KMessageBox::warningContinueCancel(0,
+ i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel"));
+ if ( retval != KMessageBox::Continue )
+ return false;
+
+ }
}
+ qApp->processEvents();
return true;
}
diff --git a/microkde/microkde.pro b/microkde/microkde.pro
index 71d662b..21da158 100644
--- a/microkde/microkde.pro
+++ b/microkde/microkde.pro
@@ -20,157 +20,155 @@ MOC_DIR = moc/win
include( ../variables.pri )
HEADERS = \
qlayoutengine_p.h \
KDGanttMinimizeSplitter.h \
kapplication.h \
kaudioplayer.h \
kcalendarsystem.h \
kcalendarsystemgregorian.h \
kcolorbutton.h \
kcolordialog.h \
kcombobox.h \
kconfig.h \
kdatetbl.h \
kdebug.h \
kdialog.h \
kdialogbase.h \
keditlistbox.h \
kemailsettings.h \
kfiledialog.h \
kfontdialog.h \
kglobal.h \
kglobalsettings.h \
kiconloader.h \
klineedit.h \
klineeditdlg.h \
kmessagebox.h \
knotifyclient.h \
kprinter.h \
kprocess.h \
krestrictedline.h \
krun.h \
ksimpleconfig.h \
kstaticdeleter.h \
ksystemtray.h \
ktempfile.h \
ktextedit.h \
kunload.h \
kurl.h \
kdeui/kguiitem.h \
kdeui/kcmodule.h \
kdeui/kbuttonbox.h \
kdeui/klistbox.h \
kdeui/klistview.h \
kdeui/kjanuswidget.h \
kdeui/kseparator.h \
kdeui/knuminput.h \
kdeui/knumvalidator.h \
kdeui/ksqueezedtextlabel.h \
kio/job.h \
kio/kio/kdirwatch.h \
kio/kio/kdirwatch_p.h \
kio/kfile/kurlrequester.h \
kresources/resource.h \
kresources/factory.h \
kresources/managerimpl.h \
kresources/manager.h \
kresources/selectdialog.h \
kresources/configpage.h \
kresources/configwidget.h \
kresources/configdialog.h \
kresources/kcmkresources.h \
- kresources/syncwidget.h \
kdecore/kmdcodec.h \
kdecore/kconfigbase.h \
kdecore/klocale.h \
kdecore/kcatalogue.h \
kdecore/ksharedptr.h \
kdecore/kshell.h \
kdecore/kstandarddirs.h \
kdecore/kstringhandler.h \
kdecore/kshortcut.h \
kutils/kcmultidialog.h \
kdeui/kxmlguiclient.h \
kdeui/kstdaction.h \
kdeui/kmainwindow.h \
kdeui/ktoolbar.h \
kdeui/ktoolbarbutton.h \
kdeui/ktoolbarhandler.h \
kdeui/kaction.h \
kdeui/kactionclasses.h \
kdeui/kactioncollection.h \
kdecore/kprefs.h \
kdecore/klibloader.h \
kidmanager.h
# kdecore/klibloader.h \
SOURCES = \
KDGanttMinimizeSplitter.cpp \
kapplication.cpp \
kcalendarsystem.cpp \
kcalendarsystemgregorian.cpp \
kcolorbutton.cpp \
kcolordialog.cpp \
kconfig.cpp \
kdatetbl.cpp \
kdialog.cpp \
kdialogbase.cpp \
keditlistbox.cpp \
kemailsettings.cpp \
kfontdialog.cpp \
kfiledialog.cpp \
kglobal.cpp \
kglobalsettings.cpp \
kiconloader.cpp \
kmessagebox.cpp \
ktextedit.cpp \
kprocess.cpp \
krun.cpp \
ksystemtray.cpp \
ktempfile.cpp \
kurl.cpp \
kdecore/kcatalogue.cpp \
kdecore/klocale.cpp \
kdecore/kmdcodec.cpp \
kdecore/kshell.cpp \
kdecore/kstandarddirs.cpp \
kdecore/kstringhandler.cpp \
kdeui/kbuttonbox.cpp \
kdeui/kcmodule.cpp \
kdeui/kguiitem.cpp \
kdeui/kjanuswidget.cpp \
kdeui/klistbox.cpp \
kdeui/klistview.cpp \
kdeui/knuminput.cpp \
kdeui/knumvalidator.cpp \
kdeui/kseparator.cpp \
kdeui/ksqueezedtextlabel.cpp \
kio/kio/kdirwatch.cpp \
kio/kfile/kurlrequester.cpp \
kresources/configpage.cpp \
kresources/configdialog.cpp \
kresources/configwidget.cpp \
kresources/factory.cpp \
kresources/kcmkresources.cpp \
kresources/managerimpl.cpp \
kresources/resource.cpp \
kresources/selectdialog.cpp \
- kresources/syncwidget.cpp \
kutils/kcmultidialog.cpp \
kdeui/kaction.cpp \
kdeui/kactionclasses.cpp \
kdeui/kactioncollection.cpp \
kdeui/kmainwindow.cpp \
kdeui/ktoolbar.cpp \
kdeui/ktoolbarbutton.cpp \
kdeui/ktoolbarhandler.cpp \
kdeui/kstdaction.cpp \
kdeui/kxmlguiclient.cpp \
kdecore/kprefs.cpp \
kdecore/klibloader.cpp \
kidmanager.cpp
diff --git a/microkde/ofileselector_p.cpp b/microkde/ofileselector_p.cpp
index cf6074d..fd5f965 100644
--- a/microkde/ofileselector_p.cpp
+++ b/microkde/ofileselector_p.cpp
@@ -1,86 +1,88 @@
#include <qcombobox.h>
#include <qdir.h>
#include <qhbox.h>
#include <qheader.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qlistview.h>
#include <qpopupmenu.h>
#include <qwidgetstack.h>
#include <qregexp.h>
#include <qobjectlist.h>
/* hacky but we need to get FileSelector::filter */
#define private public
#include <qpe/fileselector.h>
#undef private
#include <qpe/qpeapplication.h>
#include <qpe/mimetype.h>
#include <qpe/resource.h>
#include <qpe/storage.h>
+#include <kglobal.h>
+#include <klocale.h>
#include "ofileselector_p.h"
//US#include "ofileselector.h"
#include "klocale.h"
OFileViewInterface::OFileViewInterface( OFileSelector* selector )
: m_selector( selector ) {
}
OFileViewInterface::~OFileViewInterface() {
}
QString OFileViewInterface::name()const{
return m_name;
}
void OFileViewInterface::setName( const QString& name ) {
m_name = name;
}
OFileSelector* OFileViewInterface::selector()const {
return m_selector;
}
DocLnk OFileViewInterface::selectedDocument()const {
return DocLnk( selectedName() );
}
bool OFileViewInterface::showNew()const {
return selector()->showNew();
}
bool OFileViewInterface::showClose()const {
return selector()->showClose();
}
MimeTypes OFileViewInterface::mimeTypes()const {
return selector()->mimeTypes();
}
QStringList OFileViewInterface::currentMimeType()const {
return selector()->currentMimeType();
}
void OFileViewInterface::activate( const QString& ) {
// not implemented here
}
void OFileViewInterface::ok() {
emit selector()->ok();
}
void OFileViewInterface::cancel() {
emit selector()->cancel();
}
void OFileViewInterface::closeMe() {
emit selector()->closeMe();
}
void OFileViewInterface::fileSelected( const QString& str) {
emit selector()->fileSelected( str);
}
void OFileViewInterface::fileSelected( const DocLnk& lnk) {
emit selector()->fileSelected( lnk );
}
void OFileViewInterface::setCurrentFileName( const QString& str ) {
selector()->m_lneEdit->setText( str );
}
QString OFileViewInterface::currentFileName()const{
return selector()->m_lneEdit->text();
}
QString OFileViewInterface::startDirectory()const{
return selector()->m_startDir;
}
@@ -406,149 +408,150 @@ void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) {
#if 0
OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item);
if (!sel->isDir() ) {
selector()->m_lneEdit->setText( sel->text(1) );
// if in fileselector mode we will emit selected
if ( selector()->mode() == OFileSelector::FileSelector ) {
qWarning("slot Current Changed");
QStringList str = QStringList::split("->", sel->text(1) );
QString path = sel->directory() + "/" + str[0].stripWhiteSpace();
emit selector()->fileSelected( path );
DocLnk lnk( path );
emit selector()->fileSelected( lnk );
}
}
#endif
}
void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) {
if (!item || ( button != Qt::LeftButton) )
return;
OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item);
if (!sel->isLocked() ) {
QStringList str = QStringList::split("->", sel->text(1) );
if (sel->isDir() ) {
m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace();
emit selector()->dirSelected( m_currentDir );
reread( m_all );
}else { // file
qWarning("slot Clicked");
selector()->m_lneEdit->setText( str[0].stripWhiteSpace() );
QString path = sel->directory() + "/" + str[0].stripWhiteSpace();
emit selector()->fileSelected( path );
DocLnk lnk( path );
emit selector()->fileSelected( lnk );
}
} // not locked
}
void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) {
MimeType type( info->absFilePath() );
if (!compliesMime( type.id() ) )
return;
QPixmap pix = type.pixmap();
QString dir, name; bool locked;
if ( pix.isNull() ) {
QWMatrix matrix;
QPixmap pixer(Resource::loadPixmap("UnknownDocument") );
matrix.scale( .4, .4 );
pix = pixer.xForm( matrix );
}
dir = info->dirPath( true );
locked = false;
if ( symlink )
name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink();
else{
name = info->fileName();
if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) ||
( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) {
locked = true; pix = Resource::loadPixmap("locked");
}
}
(void)new OFileSelectorItem( m_view, pix, name,
- info->lastModified().toString(), QString::number( info->size() ),
+ KGlobal::locale()->formatDateTime(info->lastModified(),true, true, KLocale::ISODate),
+ QString::number( info->size() ),
dir, locked );
}
void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) {
bool locked = false; QString name; QPixmap pix;
if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) ||
( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) {
locked = true;
if ( symlink )
pix = Resource::loadPixmap( "symlink" );
else
pix = Resource::loadPixmap( "lockedfolder" );
}else
pix = symlink ? Resource::loadPixmap( "symlink") : Resource::loadPixmap("folder");
name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() :
info->fileName();
(void)new OFileSelectorItem( m_view, pix, name,
- info->lastModified().toString(),
+ KGlobal::locale()->formatDateTime(info->lastModified(),true, true, KLocale::ISODate),
QString::number( info->size() ),
info->dirPath( true ), locked, true );
}
void OFileViewFileListView::addSymlink( QFileInfo* , bool ) {
}
void OFileViewFileListView::cdUP() {
QDir dir( m_currentDir );
dir.cdUp();
if (!dir.exists() )
m_currentDir = "/";
else
m_currentDir = dir.absPath();
emit selector()->dirSelected( m_currentDir );
reread( m_all );
}
void OFileViewFileListView::cdHome() {
m_currentDir = QDir::homeDirPath();
emit selector()->dirSelected( m_currentDir );
reread( m_all );
}
void OFileViewFileListView::cdDoc() {
m_currentDir = QPEApplication::documentDir();
emit selector()->dirSelected( m_currentDir );
reread( m_all );
}
void OFileViewFileListView::changeDir( const QString& dir ) {
m_currentDir = dir;
emit selector()->dirSelected( m_currentDir );
reread( m_all );
}
void OFileViewFileListView::slotFSActivated( int id ) {
changeDir ( m_dev[m_fsPop->text(id)] );
}
/* check if the mimetype in mime
* complies with the one which is current
*/
/*
* We've the mimetype of the file
* We need to get the stringlist of the current mimetype
*
* mime = image@slashjpeg
* QStringList = 'image@slash*'
* or QStringList = image/jpeg;image/png;application/x-ogg
* or QStringList = application/x-ogg;image@slash*;
* with all these mime filters it should get acceptes
* to do so we need to look if mime is contained inside
* the stringlist
* if it's contained return true
* if not ( I'm no RegExp expert at all ) we'll look if a '@slash*'
* is contained in the mimefilter and then we will
* look if both are equal until the '/'
*/
bool OFileViewFileListView::compliesMime( const QString& str) {
if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() )
return true;
for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) {
QRegExp reg( (*it) );