-rw-r--r-- | gammu/emb/common/service/gsmcal.c | 15 | ||||
-rw-r--r-- | gammu/emb/common/service/gsmcal.h | 1 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 6 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 12 | ||||
-rw-r--r-- | microkde/kapplication.cpp | 22 | ||||
-rw-r--r-- | microkde/kapplication.h | 1 |
6 files changed, 50 insertions, 7 deletions
diff --git a/gammu/emb/common/service/gsmcal.c b/gammu/emb/common/service/gsmcal.c index 0ea8e06..0375fee 100644 --- a/gammu/emb/common/service/gsmcal.c +++ b/gammu/emb/common/service/gsmcal.c @@ -1,512 +1,521 @@ /* (c) 2002-2003 by Marcin Wiacek */ #include <string.h> #include "gsmcal.h" #include "gsmmisc.h" #include "../misc/coding/coding.h" bool IsCalendarNoteFromThePast(GSM_CalendarEntry *note) { bool Past = true; int i; GSM_DateTime DT; GSM_GetCurrentDateTime (&DT); for (i = 0; i < note->EntriesNum; i++) { switch (note->Entries[i].EntryType) { case CAL_RECURRANCE: Past = false; break; case CAL_START_DATETIME : if (note->Entries[i].Date.Year > DT.Year) Past = false; if (note->Entries[i].Date.Year == DT.Year && note->Entries[i].Date.Month > DT.Month) Past = false; if (note->Entries[i].Date.Year == DT.Year && note->Entries[i].Date.Month == DT.Month && note->Entries[i].Date.Day > DT.Day) Past = false; break; default: break; } if (!Past) break; } switch (note->Type) { case GSM_CAL_BIRTHDAY: Past = false; break; default: break; } return Past; } void GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(GSM_CalendarEntry *entry, int *Text, int *Time, int *Alarm, int *Phone, int *Recurrance, int *EndTime, int *Location) { int i; *Text = -1; *Time = -1; *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); 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, ¬e->Entries[Time].Date, "DTSTART"); if (EndTime != -1) { SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); } if (Alarm != -1) { if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); } else { SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); } } /* Birthday is known to be recurranced */ if (Recurrance != -1 && note->Type != GSM_CAL_BIRTHDAY) { 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; } } } 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); 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, ¬e->Entries[Time].Date, "DTSTART"); if (Alarm != -1) { SaveVCALDateTime(Buffer, Length, ¬e->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; } } 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, "DESCRIPTION"); + SaveVCALText(Buffer, Length, buffer, "SUMMARY"); } else { - SaveVCALText(Buffer, Length, note->Entries[Text].Text, "DESCRIPTION"); + 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); 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, ¬e->Entries[Time].Date, "DTSTART"); if (EndTime != -1) { SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); } if (Alarm != -1) { SaveVCALDateTime(Buffer, Length, ¬e->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; } } } GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool header, GSM_VToDoVersion Version) { int Text, Alarm, Completed, EndTime, Phone; GSM_ToDoFindDefaultTextTimeAlarmCompleted(note, &Text, &Alarm, &Completed, &EndTime, &Phone); 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:VTODO%c%c",13,10); if (Version == Nokia_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 (EndTime != -1) { SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DUE"); } if (Alarm != -1) { if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); } else { SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); } } } 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, ¬e->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: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++; } - if ((ReadVCALText(Line, "SUMMARY", Buff)) || (ReadVCALText(Line, "DESCRIPTION", Buff))) { + // 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; if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; dbgprintf("atoi is %i %s\n",atoi(DecodeUnicodeString(Buff)),DecodeUnicodeString(Buff)); } else if (ToDoVer == Nokia_VToDo) { ToDo->Priority = GSM_Priority_Medium; if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; } } if (strstr(Line,"PERCENT-COMPLETE:100")) { ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_COMPLETED; ToDo->Entries[ToDo->EntriesNum].Number = 1; ToDo->EntriesNum++; } break; } } if (Calendar->EntriesNum == 0 && ToDo->EntriesNum == 0) return ERR_EMPTY; return ERR_NONE; } GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note) { *Length+=sprintf(Buffer+(*Length), "BEGIN:VNOTE%c%c",13,10); *Length+=sprintf(Buffer+(*Length), "VERSION:1.1%c%c",13,10); SaveVCALText(Buffer, Length, Note->Text, "BODY"); *Length+=sprintf(Buffer+(*Length), "END:VNOTE%c%c",13,10); return ERR_NONE; } /* How should editor hadle tabs in this file? Add editor commands here. * vim: noexpandtab sw=8 ts=8 sts=8: */ diff --git a/gammu/emb/common/service/gsmcal.h b/gammu/emb/common/service/gsmcal.h index 0a41b7b..c69fdbe 100644 --- a/gammu/emb/common/service/gsmcal.h +++ b/gammu/emb/common/service/gsmcal.h @@ -1,445 +1,446 @@ /* (c) 2002-2004 by Marcin Wiacek */ /* 5210 calendar IDs by Frederick Ros */ #ifndef __gsm_cal_h #define __gsm_cal_h #include "../gsmcomon.h" /* ---------------------------- calendar ----------------------------------- */ #define GSM_CALENDAR_ENTRIES 16 #define MAX_CALENDAR_TEXT_LENGTH 256 /* In 6310 max. 256 chars */ /** * Enum defines types of calendar notes */ typedef enum { /** * Reminder or Date */ GSM_CAL_REMINDER=1, /** * Call */ GSM_CAL_CALL, /** * Meeting */ GSM_CAL_MEETING, /** * Birthday or Anniversary or Special Occasion */ GSM_CAL_BIRTHDAY, /** * Memo or Miscellaneous */ GSM_CAL_MEMO, /** * Travel */ GSM_CAL_TRAVEL, /** * Vacation */ GSM_CAL_VACATION, /** * Training - Athletism */ GSM_CAL_T_ATHL, /** * Training - Ball Games */ GSM_CAL_T_BALL, /** * Training - Cycling */ GSM_CAL_T_CYCL, /** * Training - Budo */ GSM_CAL_T_BUDO, /** * Training - Dance */ GSM_CAL_T_DANC, /** * Training - Extreme Sports */ GSM_CAL_T_EXTR, /** * Training - Football */ GSM_CAL_T_FOOT, /** * Training - Golf */ GSM_CAL_T_GOLF, /** * Training - Gym */ GSM_CAL_T_GYM, /** * Training - Horse Race */ GSM_CAL_T_HORS, /** * Training - Hockey */ GSM_CAL_T_HOCK, /** * Training - Races */ GSM_CAL_T_RACE, /** * Training - Rugby */ GSM_CAL_T_RUGB, /** * Training - Sailing */ GSM_CAL_T_SAIL, /** * Training - Street Games */ GSM_CAL_T_STRE, /** * Training - Swimming */ GSM_CAL_T_SWIM, /** * Training - Tennis */ GSM_CAL_T_TENN, /** * Training - Travels */ GSM_CAL_T_TRAV, /** * Training - Winter Games */ GSM_CAL_T_WINT, /** * Alarm */ GSM_CAL_ALARM, /** * Alarm repeating each day. */ GSM_CAL_DAILY_ALARM } GSM_CalendarNoteType; /** * One value of calendar event. */ typedef enum { /** * Date and time of event start. */ CAL_START_DATETIME = 1, /** * Date and time of event end. */ CAL_END_DATETIME, /** * Alarm date and time. */ CAL_ALARM_DATETIME, /** * Date and time of silent alarm. */ CAL_SILENT_ALARM_DATETIME, /** * Recurrance. */ CAL_RECURRANCE, /** * Text. */ CAL_TEXT, + CAL_DESCRIPTION, // LR added /** * Location. */ CAL_LOCATION, /** * Phone number. */ CAL_PHONE, /** * Whether this entry is private. */ CAL_PRIVATE, /** * Related contact id. */ CAL_CONTACTID, /** * Repeat each x'th day of week. */ CAL_REPEAT_DAYOFWEEK, /** * Repeat each x'th day of month. */ CAL_REPEAT_DAY, /** * Repeat x'th week of month. */ CAL_REPEAT_WEEKOFMONTH, /** * Repeat x'th month. */ CAL_REPEAT_MONTH, /** * Repeating frequency. */ CAL_REPEAT_FREQUENCY, /** * Repeating start. */ CAL_REPEAT_STARTDATE, /** * Repeating end. */ CAL_REPEAT_STOPDATE } GSM_CalendarType; /** * One value of calendar event. */ typedef struct { /** * Type of value. */ GSM_CalendarType EntryType; /** * Text of value, if applicable. */ unsigned char Text[(MAX_CALENDAR_TEXT_LENGTH + 1)*2]; /** * Date and time of value, if applicable. */ GSM_DateTime Date; /** * Number of value, if applicable. */ unsigned int Number; } GSM_SubCalendarEntry; /** * Calendar note values. */ typedef struct { /** * Type of calendar note. */ GSM_CalendarNoteType Type; /** * Location in memory. */ int Location; /** * Number of entries. */ int EntriesNum; /** * Values of entries. */ GSM_SubCalendarEntry Entries[GSM_CALENDAR_ENTRIES]; } GSM_CalendarEntry; void GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(GSM_CalendarEntry *entry, int *Text, int *Time, int *Alarm, int *Phone, int *Recurrance, int *EndTime, int *Location); typedef enum { Nokia_VCalendar = 1, Siemens_VCalendar, SonyEricsson_VCalendar } GSM_VCalendarVersion; GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note, bool header, GSM_VCalendarVersion Version); bool IsCalendarNoteFromThePast(GSM_CalendarEntry *note); typedef struct { /** * Monday = 1, Tuesday = 2,... */ int StartDay; /** * 0 = no delete, 1 = after day,... */ int AutoDelete; } GSM_CalendarSettings; /** * Structure used for returning calendar status. */ typedef struct { /** * Number of used positions. */ int Used; } GSM_CalendarStatus; /* ------------------------------ to-do ------------------------------------ */ #define GSM_TODO_ENTRIES 7 #define MAX_TODO_TEXT_LENGTH 50 /* Alcatel BE5 50 chars */ /** * Types of to do values. In parenthesis is member of @ref GSM_SubToDoEntry, * where value is stored. */ typedef enum { /** * Due date. (Date) */ TODO_END_DATETIME = 1, /** * Whether is completed. (Number) */ TODO_COMPLETED, /** * When should alarm be fired (Date). */ TODO_ALARM_DATETIME, /** * When should silent alarm be fired (Date). */ TODO_SILENT_ALARM_DATETIME, /** * Text of to do (Text). */ TODO_TEXT, /** * Whether entry is private (Number). */ TODO_PRIVATE, /** * Category of entry (Number). */ TODO_CATEGORY, /** * Related contact ID (Number). */ TODO_CONTACTID, /** * Number to call (Text). */ TODO_PHONE } GSM_ToDoType; /** * Priority of to do. */ typedef enum { GSM_Priority_High = 1, GSM_Priority_Medium, GSM_Priority_Low } GSM_ToDo_Priority; /** * Value of to do entry. */ typedef struct { /** * Type of entry. */ GSM_ToDoType EntryType; /** * Text of value, if appropriate, see @ref GSM_ToDoType. */ unsigned char Text[(MAX_TODO_TEXT_LENGTH + 1)*2]; /** * Date of value, if appropriate, see @ref GSM_ToDoType. */ GSM_DateTime Date; /** * Number of value, if appropriate, see @ref GSM_ToDoType. */ unsigned int Number; } GSM_SubToDoEntry; /** * To do entry. */ typedef struct { /** * Priority of entry. */ GSM_ToDo_Priority Priority; /** * Location in memory. */ int Location; /** * Number of entries. */ int EntriesNum; /** * Values of current entry. */ GSM_SubToDoEntry Entries[GSM_TODO_ENTRIES]; } GSM_ToDoEntry; void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone); typedef enum { Nokia_VToDo = 1, SonyEricsson_VToDo } GSM_VToDoVersion; GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool header, GSM_VToDoVersion Version); /** * Status of to do entries. */ typedef struct { /** * Number of used positions. */ int Used; } GSM_ToDoStatus; /* --------------------------- note ---------------------------------------- */ typedef struct { int Location; char Text[3000*2]; } GSM_NoteEntry; GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note); /* --------------------------- alarm --------------------------------------- */ /** * Alarm values. */ typedef struct { /** * Location where it is stored. */ int Location; /** * Date and time of alarm. */ GSM_DateTime DateTime; /** * Whether it repeats each day. */ bool Repeating; /** * Text that is shown on display. */ char Text[(MAX_CALENDAR_TEXT_LENGTH + 1) * 2]; } GSM_Alarm; /* --------------------------- calendar & todo ----------------------------- */ GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_CalendarEntry *Calendar, GSM_ToDoEntry *ToDo, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer); #endif /* How should editor hadle tabs in this file? Add editor commands here. * vim: noexpandtab sw=8 ts=8 sts=8: */ diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 47ed858..dae9cd2 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -304,1043 +304,1045 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const SLOT( browse( const QString& ) ) ); mAddressBookService = new KAddressBookService( this ); #endif //KAB_EMBEDDED mEditorDialog = 0; createAddresseeEditorDialog( this ); setModified( false ); } KABCore::~KABCore() { // save(); //saveSettings(); //KABPrefs::instance()->writeConfig(); delete AddresseeConfig::instance(); mAddressBook = 0; KABC::StdAddressBook::close(); delete syncManager; } void KABCore::recieve( QString fn ) { //qDebug("KABCore::recieve "); mAddressBook->importFromFile( fn, true ); mViewManager->refreshView(); topLevelWidget()->raise(); } void KABCore::restoreSettings() { mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; bool state; if (mMultipleViewsAtOnce) state = KABPrefs::instance()->mDetailsPageVisible; else state = false; mActionDetails->setChecked( state ); setDetailsVisible( state ); state = KABPrefs::instance()->mJumpButtonBarVisible; mActionJumpBar->setChecked( state ); setJumpButtonBarVisible( state ); /*US QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; if ( splitterSize.count() == 0 ) { splitterSize.append( width() / 2 ); splitterSize.append( width() / 2 ); } mMiniSplitter->setSizes( splitterSize ); if ( mExtensionBarSplitter ) { splitterSize = KABPrefs::instance()->mExtensionsSplitter; if ( splitterSize.count() == 0 ) { splitterSize.append( width() / 2 ); splitterSize.append( width() / 2 ); } mExtensionBarSplitter->setSizes( splitterSize ); } */ mViewManager->restoreSettings(); mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); mExtensionManager->restoreSettings(); #ifdef DESKTOP_VERSION int wid = width(); if ( wid < 10 ) wid = 400; #else int wid = QApplication::desktop()->width(); if ( wid < 640 ) wid = QApplication::desktop()->height(); #endif QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; if ( true /*splitterSize.count() == 0*/ ) { splitterSize.append( wid / 2 ); splitterSize.append( wid / 2 ); } mMiniSplitter->setSizes( splitterSize ); if ( mExtensionBarSplitter ) { //splitterSize = KABPrefs::instance()->mExtensionsSplitter; if ( true /*splitterSize.count() == 0*/ ) { splitterSize.append( wid / 2 ); splitterSize.append( wid / 2 ); } mExtensionBarSplitter->setSizes( splitterSize ); } } void KABCore::saveSettings() { KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); if ( mExtensionBarSplitter ) KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); #ifndef KAB_EMBEDDED KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); #endif //KAB_EMBEDDED mExtensionManager->saveSettings(); mViewManager->saveSettings(); KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); } KABC::AddressBook *KABCore::addressBook() const { return mAddressBook; } KConfig *KABCore::config() { #ifndef KAB_EMBEDDED return KABPrefs::instance()->config(); #else //KAB_EMBEDDED return KABPrefs::instance()->getConfig(); #endif //KAB_EMBEDDED } KActionCollection *KABCore::actionCollection() const { return mGUIClient->actionCollection(); } KABC::Field *KABCore::currentSearchField() const { if (mIncSearchWidget) return mIncSearchWidget->currentField(); else return 0; } QStringList KABCore::selectedUIDs() const { return mViewManager->selectedUids(); } KABC::Resource *KABCore::requestResource( QWidget *parent ) { QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); QPtrList<KRES::Resource> kresResources; QPtrListIterator<KABC::Resource> resIt( kabcResources ); KABC::Resource *resource; while ( ( resource = resIt.current() ) != 0 ) { ++resIt; if ( !resource->readOnly() ) { KRES::Resource *res = static_cast<KRES::Resource*>( resource ); if ( res ) kresResources.append( res ); } } KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); return static_cast<KABC::Resource*>( res ); } #ifndef KAB_EMBEDDED KAboutData *KABCore::createAboutData() #else //KAB_EMBEDDED void KABCore::createAboutData() #endif //KAB_EMBEDDED { #ifndef KAB_EMBEDDED KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), "3.1", I18N_NOOP( "The KDE Address Book" ), KAboutData::License_GPL_V2, I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); about->addAuthor( "Cornelius Schumacher", I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), "schumacher@kde.org" ); about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), "mpilone@slac.com" ); about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), "michel@klaralvdalens-datakonsult.se" ); about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), "hansen@kde.org" ); return about; #endif //KAB_EMBEDDED QString version; #include <../version> QMessageBox::about( this, "About KAddressbook/Pi", "KAddressbook/Platform-independent\n" "(KA/Pi) " +version + " - " + #ifdef DESKTOP_VERSION "Desktop Edition\n" #else "PDA-Edition\n" "for: Zaurus 5500 / 7x0 / 8x0\n" #endif "(c) 2004 Ulf Schenk\n" "(c) 2004 Lutz Rogowski\n" "(c) 1997-2003, The KDE PIM Team\n" "Tobias Koenig Current maintainer\ntokoe@kde.org\n" "Don Sanders Original author\n" "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" "Greg Stern DCOP interface\n" "Mark Westcot Contact pinning\n" "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" #ifdef _WIN32_ "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" #endif ); } void KABCore::setContactSelected( const QString &uid ) { KABC::Addressee addr = mAddressBook->findByUid( uid ); if ( !mDetails->isHidden() ) mDetails->setAddressee( addr ); if ( !addr.isEmpty() ) { emit contactSelected( addr.formattedName() ); KABC::Picture pic = addr.photo(); if ( pic.isIntern() ) { //US emit contactSelected( pic.data() ); //US instead use: QPixmap px; if (pic.data().isNull() != true) { px.convertFromImage(pic.data()); } emit contactSelected( px ); } } mExtensionManager->setSelectionChanged(); // update the actions bool selected = !uid.isEmpty(); if ( mReadWrite ) { mActionCut->setEnabled( selected ); mActionPaste->setEnabled( selected ); } mActionCopy->setEnabled( selected ); mActionDelete->setEnabled( selected ); mActionEditAddressee->setEnabled( selected ); mActionMail->setEnabled( selected ); mActionMailVCard->setEnabled( selected ); //if (mActionBeam) //mActionBeam->setEnabled( selected ); if (mActionBeamVCard) mActionBeamVCard->setEnabled( selected ); mActionExport2phone->setEnabled( selected ); mActionWhoAmI->setEnabled( selected ); mActionCategories->setEnabled( selected ); } void KABCore::sendMail() { sendMail( mViewManager->selectedEmails().join( ", " ) ); } void KABCore::sendMail( const QString& emaillist ) { // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " if (emaillist.contains(",") > 0) ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); else ExternalAppHandler::instance()->mailToOneContact( emaillist ); } void KABCore::mailVCard() { QStringList uids = mViewManager->selectedUids(); if ( !uids.isEmpty() ) mailVCard( uids ); } void KABCore::mailVCard( const QStringList& uids ) { QStringList urls; // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); QString dirName = "/tmp/" + KApplication::randomString( 8 ); QDir().mkdir( dirName, true ); for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { KABC::Addressee a = mAddressBook->findByUid( *it ); if ( a.isEmpty() ) continue; QString name = a.givenName() + "_" + a.familyName() + ".vcf"; QString fileName = dirName + "/" + name; QFile outFile(fileName); if ( outFile.open(IO_WriteOnly) ) { // file opened successfully KABC::VCardConverter converter; QString vcard; converter.addresseeToVCard( a, vcard ); QTextStream t( &outFile ); // use a text stream t.setEncoding( QTextStream::UnicodeUTF8 ); t << vcard; outFile.close(); urls.append( fileName ); } } bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); /*US kapp->invokeMailer( QString::null, QString::null, QString::null, QString::null, // subject QString::null, // body QString::null, urls ); // attachments */ } /** Beams the "WhoAmI contact. */ void KABCore::beamMySelf() { KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); if (!a.isEmpty()) { QStringList uids; uids << a.uid(); beamVCard(uids); } else { KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); } } void KABCore::export2phone() { KAex2phonePrefs ex2phone; ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); if ( !ex2phone.exec() ) { return; } KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, KPimGlobalPrefs::instance()->mEx2PhoneConnection, KPimGlobalPrefs::instance()->mEx2PhoneModel ); QStringList uids = mViewManager->selectedUids(); if ( uids.isEmpty() ) return; #ifdef _WIN32_ QString fileName = locateLocal("tmp", "phonefile.vcf"); #else QString fileName = "/tmp/phonefile.vcf"; #endif if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) return; if ( PhoneAccess::writeToPhone( fileName ) ) qDebug("Export okay "); else qDebug("Error export contacts "); #if 0 setCaption( i18n("Writing to phone...")); if ( PhoneFormat::writeToPhone( cal ) ) setCaption( i18n("Export to phone successful!")); else setCaption( i18n("Error exporting to phone!")); #endif } void KABCore::beamVCard() { QStringList uids = mViewManager->selectedUids(); if ( !uids.isEmpty() ) beamVCard( uids ); } void KABCore::beamVCard(const QStringList& uids) { /*US QString beamFilename; Opie::OPimContact c; if ( actionPersonal->isOn() ) { beamFilename = addressbookPersonalVCardName(); if ( !QFile::exists( beamFilename ) ) return; // can't beam a non-existent file Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, beamFilename ); Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); Opie::OPimContactAccess::List allList = access->allRecords(); Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first c = *it; delete access; } else { unlink( beamfile ); // delete if exists mkdir("/tmp/obex/", 0755); c = m_abView -> currentEntry(); Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, beamfile ); Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); access->add( c ); access->save(); delete access; beamFilename = beamfile; } owarn << "Beaming: " << beamFilename << oendl; */ #if 0 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); QString name = "contact.vcf"; QString fileName = dirName + "/" + name; #endif // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory // QString fileName = "/tmp/kapibeamfile.vcf"; //QDir().mkdir( dirName, true ); KABC::VCardConverter converter; QString description; QString datastream; for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { KABC::Addressee a = mAddressBook->findByUid( *it ); if ( a.isEmpty() ) continue; if (description.isEmpty()) description = a.formattedName(); QString vcard; converter.addresseeToVCard( a, vcard ); int start = 0; int next; while ( (next = vcard.find("TYPE=", start) )>= 0 ) { int semi = vcard.find(";", next); int dopp = vcard.find(":", next); int sep; if ( semi < dopp && semi >= 0 ) sep = semi ; else sep = dopp; datastream +=vcard.mid( start, next - start); datastream +=vcard.mid( next+5,sep -next -5 ).upper(); start = sep; } datastream += vcard.mid( start,vcard.length() ); } #ifndef DESKTOP_VERSION QFile outFile(fileName); if ( outFile.open(IO_WriteOnly) ) { datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); QTextStream t( &outFile ); // use a text stream - t.setEncoding( QTextStream::UnicodeUTF8 ); - t <<datastream; + //t.setEncoding( QTextStream::UnicodeUTF8 ); + t.setEncoding( QTextStream::Latin1 ); + t <<datastream.latin1(); outFile.close(); Ir *ir = new Ir( this ); connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); ir->send( fileName, description, "text/x-vCard" ); } else { qDebug("Error open temp beam file "); return; } #endif } void KABCore::beamDone( Ir *ir ) { #ifndef DESKTOP_VERSION delete ir; #endif + topLevelWidget()->raise(); } void KABCore::browse( const QString& url ) { #ifndef KAB_EMBEDDED kapp->invokeBrowser( url ); #else //KAB_EMBEDDED qDebug("KABCore::browse must be fixed"); #endif //KAB_EMBEDDED } void KABCore::selectAllContacts() { mViewManager->setSelected( QString::null, true ); } void KABCore::deleteContacts() { QStringList uidList = mViewManager->selectedUids(); deleteContacts( uidList ); } void KABCore::deleteContacts( const QStringList &uids ) { if ( uids.count() > 0 ) { PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); UndoStack::instance()->push( command ); RedoStack::instance()->clear(); // now if we deleted anything, refresh setContactSelected( QString::null ); setModified( true ); } } void KABCore::copyContacts() { KABC::Addressee::List addrList = mViewManager->selectedAddressees(); QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; QClipboard *cb = QApplication::clipboard(); cb->setText( clipText ); } void KABCore::cutContacts() { QStringList uidList = mViewManager->selectedUids(); //US if ( uidList.size() > 0 ) { if ( uidList.count() > 0 ) { PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); UndoStack::instance()->push( command ); RedoStack::instance()->clear(); setModified( true ); } } void KABCore::pasteContacts() { QClipboard *cb = QApplication::clipboard(); KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); pasteContacts( list ); } void KABCore::pasteContacts( KABC::Addressee::List &list ) { KABC::Resource *resource = requestResource( this ); KABC::Addressee::List::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) (*it).setResource( resource ); PwPasteCommand *command = new PwPasteCommand( this, list ); UndoStack::instance()->push( command ); RedoStack::instance()->clear(); setModified( true ); } void KABCore::setWhoAmI() { KABC::Addressee::List addrList = mViewManager->selectedAddressees(); if ( addrList.count() > 1 ) { KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); return; } QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); } void KABCore::setCategories() { KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); if ( !dlg.exec() ) return; bool merge = false; QString msg = i18n( "Merge with existing categories?" ); if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) merge = true; QStringList categories = dlg.selectedCategories(); QStringList uids = mViewManager->selectedUids(); QStringList::Iterator it; for ( it = uids.begin(); it != uids.end(); ++it ) { KABC::Addressee addr = mAddressBook->findByUid( *it ); if ( !addr.isEmpty() ) { if ( !merge ) addr.setCategories( categories ); else { QStringList addrCategories = addr.categories(); QStringList::Iterator catIt; for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { if ( !addrCategories.contains( *catIt ) ) addrCategories.append( *catIt ); } addr.setCategories( addrCategories ); } mAddressBook->insertAddressee( addr ); } } if ( uids.count() > 0 ) setModified( true ); } void KABCore::setSearchFields( const KABC::Field::List &fields ) { mIncSearchWidget->setFields( fields ); } void KABCore::incrementalSearch( const QString& text ) { mViewManager->doSearch( text, mIncSearchWidget->currentField() ); } void KABCore::setModified() { setModified( true ); } void KABCore::setModifiedWOrefresh() { // qDebug("KABCore::setModifiedWOrefresh() "); mModified = true; mActionSave->setEnabled( mModified ); #ifdef DESKTOP_VERSION mDetails->refreshView(); #endif } void KABCore::setModified( bool modified ) { mModified = modified; mActionSave->setEnabled( mModified ); if ( modified ) mJumpButtonBar->recreateButtons(); mViewManager->refreshView(); mDetails->refreshView(); } bool KABCore::modified() const { return mModified; } void KABCore::contactModified( const KABC::Addressee &addr ) { Command *command = 0; QString uid; // check if it exists already KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); if ( origAddr.isEmpty() ) command = new PwNewCommand( mAddressBook, addr ); else { command = new PwEditCommand( mAddressBook, origAddr, addr ); uid = addr.uid(); } UndoStack::instance()->push( command ); RedoStack::instance()->clear(); setModified( true ); } void KABCore::newContact() { QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); QPtrList<KRES::Resource> kresResources; QPtrListIterator<KABC::Resource> it( kabcResources ); KABC::Resource *resource; while ( ( resource = it.current() ) != 0 ) { ++it; if ( !resource->readOnly() ) { KRES::Resource *res = static_cast<KRES::Resource*>( resource ); if ( res ) kresResources.append( res ); } } KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); resource = static_cast<KABC::Resource*>( res ); if ( resource ) { KABC::Addressee addr; addr.setResource( resource ); mEditorDialog->setAddressee( addr ); KApplication::execDialog ( mEditorDialog ); } else return; // mEditorDict.insert( dialog->addressee().uid(), dialog ); } void KABCore::addEmail( QString aStr ) { #ifndef KAB_EMBEDDED QString fullName, email; KABC::Addressee::parseEmailAddress( aStr, fullName, email ); // Try to lookup the addressee matching the email address bool found = false; QStringList emailList; KABC::AddressBook::Iterator it; for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { emailList = (*it).emails(); if ( emailList.contains( email ) > 0 ) { found = true; (*it).setNameFromString( fullName ); editContact( (*it).uid() ); } } if ( !found ) { KABC::Addressee addr; addr.setNameFromString( fullName ); addr.insertEmail( email, true ); mAddressBook->insertAddressee( addr ); mViewManager->refreshView( addr.uid() ); editContact( addr.uid() ); } #else //KAB_EMBEDDED qDebug("KABCore::addEmail finsih method"); #endif //KAB_EMBEDDED } void KABCore::importVCard( const KURL &url, bool showPreview ) { mXXPortManager->importVCard( url, showPreview ); } void KABCore::importFromOL() { #ifdef _WIN32_ KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); idgl->exec(); KABC::Addressee::List list = idgl->getAddressList(); if ( list.count() > 0 ) { KABC::Addressee::List listNew; KABC::Addressee::List listExisting; KABC::Addressee::List::Iterator it; KABC::AddressBook::Iterator iter; for ( it = list.begin(); it != list.end(); ++it ) { if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) listNew.append( (*it) ); else listExisting.append( (*it) ); } if ( listExisting.count() > 0 ) KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); if ( listNew.count() > 0 ) { pasteWithNewUid = false; pasteContacts( listNew ); pasteWithNewUid = true; } } delete idgl; #endif } void KABCore::importVCard( const QString &vCard, bool showPreview ) { mXXPortManager->importVCard( vCard, showPreview ); } //US added a second method without defaultparameter void KABCore::editContact2() { editContact( QString::null ); } void KABCore::editContact( const QString &uid ) { if ( mExtensionManager->isQuickEditVisible() ) return; // First, locate the contact entry QString localUID = uid; if ( localUID.isNull() ) { QStringList uidList = mViewManager->selectedUids(); if ( uidList.count() > 0 ) localUID = *( uidList.at( 0 ) ); } KABC::Addressee addr = mAddressBook->findByUid( localUID ); if ( !addr.isEmpty() ) { mEditorDialog->setAddressee( addr ); KApplication::execDialog ( mEditorDialog ); } } /** Shows or edits the detail view for the given uid. If the uid is QString::null, the method will try to find a selected addressee in the view. */ void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) { if ( mMultipleViewsAtOnce ) { editContact( uid ); } else { setDetailsVisible( true ); mActionDetails->setChecked(true); } } void KABCore::save() { if (syncManager->blockSave()) return; if ( !mModified ) return; syncManager->setBlockSave(true); QString text = i18n( "There was an error while attempting to save\n the " "address book. Please check that some \nother application is " "not using it. " ); statusMessage(i18n("Saving addressbook ... ")); #ifndef KAB_EMBEDDED KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); if ( !b || !b->save() ) { KMessageBox::error( this, text, i18n( "Unable to Save" ) ); } #else //KAB_EMBEDDED KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); if ( !b || !b->save() ) { QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); } #endif //KAB_EMBEDDED statusMessage(i18n("Addressbook saved!")); setModified( false ); syncManager->setBlockSave(false); } void KABCore::statusMessage(QString mess , int time ) { //topLevelWidget()->setCaption( mess ); // pending setting timer to revome message } void KABCore::undo() { UndoStack::instance()->undo(); // Refresh the view mViewManager->refreshView(); } void KABCore::redo() { RedoStack::instance()->redo(); // Refresh the view mViewManager->refreshView(); } void KABCore::setJumpButtonBarVisible( bool visible ) { if (mMultipleViewsAtOnce) { if ( visible ) mJumpButtonBar->show(); else mJumpButtonBar->hide(); } else { // show the jumpbar only if "the details are hidden" == "viewmanager are shown" if (mViewManager->isVisible()) { if ( visible ) mJumpButtonBar->show(); else mJumpButtonBar->hide(); } else { mJumpButtonBar->hide(); } } } void KABCore::setDetailsToState() { setDetailsVisible( mActionDetails->isChecked() ); } void KABCore::setDetailsVisible( bool visible ) { if (visible && mDetails->isHidden()) { KABC::Addressee::List addrList = mViewManager->selectedAddressees(); if ( addrList.count() > 0 ) mDetails->setAddressee( addrList[ 0 ] ); } // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between // the listview and the detailview. We do that by changing the splitbar size. if (mMultipleViewsAtOnce) { if ( visible ) mDetails->show(); else mDetails->hide(); } else { if ( visible ) { mViewManager->hide(); mDetails->show(); } else { mViewManager->show(); mDetails->hide(); } setJumpButtonBarVisible( !visible ); } } void KABCore::extensionChanged( int id ) { //change the details view only for non desktop systems #ifndef DESKTOP_VERSION if (id == 0) { //the user disabled the extension. if (mMultipleViewsAtOnce) { // enable detailsview again setDetailsVisible( true ); mActionDetails->setChecked( true ); } else { //go back to the listview setDetailsVisible( false ); mActionDetails->setChecked( false ); mActionDetails->setEnabled(true); } } else { //the user enabled the extension. setDetailsVisible( false ); mActionDetails->setChecked( false ); if (!mMultipleViewsAtOnce) { mActionDetails->setEnabled(false); } mExtensionManager->setSelectionChanged(); } #endif// DESKTOP_VERSION } void KABCore::extensionModified( const KABC::Addressee::List &list ) diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 1f2c6da..3e0a27d 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -1814,1054 +1814,1062 @@ void CalendarView::writeSettings() config->writeEntry("Separator2",list); #endif mViewManager->writeSettings( config ); mTodoList->saveLayout(config,QString("Todo Layout")); mDialogManager->writeSettings( config ); //KOPrefs::instance()->usrWriteConfig(); KOPrefs::instance()->writeConfig(); writeFilterSettings(config); config->setGroup( "Views" ); config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); #ifdef DESKTOP_VERSION config->setGroup("WidgetLayout"); QStringList list ;//= config->readListEntry("MainLayout"); int x,y,w,h; QWidget* wid; wid = topLevelWidget(); x = wid->geometry().x(); y = wid->geometry().y(); w = wid->width(); h = wid->height(); list.clear(); list << QString::number( x ); list << QString::number( y ); list << QString::number( w ); list << QString::number( h ); config->writeEntry("MainLayout",list ); wid = mEventEditor; x = wid->geometry().x(); y = wid->geometry().y(); w = wid->width(); h = wid->height(); list.clear(); list << QString::number( x ); list << QString::number( y ); list << QString::number( w ); list << QString::number( h ); config->writeEntry("EditEventLayout",list ); wid = mTodoEditor; x = wid->geometry().x(); y = wid->geometry().y(); w = wid->width(); h = wid->height(); list.clear(); list << QString::number( x ); list << QString::number( y ); list << QString::number( w ); list << QString::number( h ); config->writeEntry("EditTodoLayout",list ); wid = getEventViewerDialog(); x = wid->geometry().x(); y = wid->geometry().y(); w = wid->width(); h = wid->height(); list.clear(); list << QString::number( x ); list << QString::number( y ); list << QString::number( w ); list << QString::number( h ); config->writeEntry("ViewerLayout",list ); wid = mDialogManager->getSearchDialog(); if ( wid ) { x = wid->geometry().x(); y = wid->geometry().y(); w = wid->width(); h = wid->height(); list.clear(); list << QString::number( x ); list << QString::number( y ); list << QString::number( w ); list << QString::number( h ); config->writeEntry("SearchLayout",list ); } #endif config->sync(); } void CalendarView::readFilterSettings(KConfig *config) { // kdDebug() << "CalendarView::readFilterSettings()" << endl; mFilters.clear(); config->setGroup("General"); QStringList filterList = config->readListEntry("CalendarFilters"); QStringList::ConstIterator it = filterList.begin(); QStringList::ConstIterator end = filterList.end(); while(it != end) { // kdDebug() << " filter: " << (*it) << endl; CalFilter *filter; filter = new CalFilter(*it); config->setGroup("Filter_" + (*it)); //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); filter->setCriteria(config->readNumEntry("Criteria",0)); filter->setCategoryList(config->readListEntry("CategoryList")); mFilters.append(filter); ++it; } if (mFilters.count() == 0) { CalFilter *filter = new CalFilter(i18n("Default")); mFilters.append(filter); } mFilterView->updateFilters(); config->setGroup("FilterView"); mFilterView->blockSignals(true); mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); mFilterView->setSelectedFilter(config->readEntry("Current Filter")); mFilterView->blockSignals(false); // We do it manually to avoid it being done twice by the above calls updateFilter(); } void CalendarView::writeFilterSettings(KConfig *config) { // kdDebug() << "CalendarView::writeFilterSettings()" << endl; QStringList filterList; CalFilter *filter = mFilters.first(); while(filter) { // kdDebug() << " fn: " << filter->name() << endl; filterList << filter->name(); config->setGroup("Filter_" + filter->name()); config->writeEntry("Criteria",filter->criteria()); config->writeEntry("CategoryList",filter->categoryList()); filter = mFilters.next(); } config->setGroup("General"); config->writeEntry("CalendarFilters",filterList); config->setGroup("FilterView"); config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); } void CalendarView::goToday() { mNavigator->selectToday(); } void CalendarView::goNext() { mNavigator->selectNext(); } void CalendarView::goPrevious() { mNavigator->selectPrevious(); } void CalendarView::goNextMonth() { mNavigator->selectNextMonth(); } void CalendarView::goPreviousMonth() { mNavigator->selectPreviousMonth(); } void CalendarView::writeLocale() { //KPimGlobalPrefs::instance()->setGlobalConfig(); #if 0 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); QString dummy = KOPrefs::instance()->mUserDateFormatLong; KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); dummy = KOPrefs::instance()->mUserDateFormatShort; KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, KOPrefs::instance()->mDaylightsavingStart, KOPrefs::instance()->mDaylightsavingEnd ); KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); #endif } void CalendarView::updateConfig() { writeLocale(); if ( KOPrefs::instance()->mUseAppColors ) QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); emit configChanged(); mTodoList->updateConfig(); // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); // To make the "fill window" configurations work //mViewManager->raiseCurrentView(); } void CalendarView::eventChanged(Event *event) { changeEventDisplay(event,KOGlobals::EVENTEDITED); //updateUnmanagedViews(); } void CalendarView::eventAdded(Event *event) { changeEventDisplay(event,KOGlobals::EVENTADDED); } void CalendarView::eventToBeDeleted(Event *) { kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; } void CalendarView::eventDeleted() { changeEventDisplay(0,KOGlobals::EVENTDELETED); } void CalendarView::changeTodoDisplay(Todo *which, int action) { changeIncidenceDisplay((Incidence *)which, action); mDateNavigator->updateView(); //LR //mDialogManager->updateSearchDialog(); if (which) { mViewManager->updateWNview(); //mTodoList->updateView(); } } void CalendarView::changeIncidenceDisplay(Incidence *which, int action) { updateUnmanagedViews(); //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); if ( action == KOGlobals::EVENTDELETED ) { //delete mCalendar->checkAlarmForIncidence( 0, true ); if ( mEventViewerDialog ) mEventViewerDialog->hide(); } else mCalendar->checkAlarmForIncidence( which , false ); } // most of the changeEventDisplays() right now just call the view's // total update mode, but they SHOULD be recoded to be more refresh-efficient. void CalendarView::changeEventDisplay(Event *which, int action) { // kdDebug() << "CalendarView::changeEventDisplay" << endl; changeIncidenceDisplay((Incidence *)which, action); mDateNavigator->updateView(); //mDialogManager->updateSearchDialog(); if (which) { // If there is an event view visible update the display mViewManager->currentView()->changeEventDisplay(which,action); // TODO: check, if update needed // if (which->getTodoStatus()) { mTodoList->updateView(); // } } else { mViewManager->currentView()->updateView(); } } void CalendarView::updateTodoViews() { mTodoList->updateView(); mViewManager->currentView()->updateView(); } void CalendarView::updateView(const QDate &start, const QDate &end) { mTodoList->updateView(); mViewManager->updateView(start, end); //mDateNavigator->updateView(); } void CalendarView::updateView() { DateList tmpList = mNavigator->selectedDates(); // We assume that the navigator only selects consecutive days. updateView( tmpList.first(), tmpList.last() ); } void CalendarView::updateUnmanagedViews() { mDateNavigator->updateDayMatrix(); } int CalendarView::msgItemDelete() { return KMessageBox::warningContinueCancel(this, i18n("This item will be\npermanently deleted."), i18n("KO/Pi Confirmation"),i18n("Delete")); } void CalendarView::edit_cut() { Event *anEvent=0; Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); if (mViewManager->currentView()->isEventView()) { if ( incidence && incidence->type() == "Event" ) { anEvent = static_cast<Event *>(incidence); } } if (!anEvent) { KNotifyClient::beep(); return; } DndFactory factory( mCalendar ); factory.cutEvent(anEvent); changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); } void CalendarView::edit_copy() { Event *anEvent=0; Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); if (mViewManager->currentView()->isEventView()) { if ( incidence && incidence->type() == "Event" ) { anEvent = static_cast<Event *>(incidence); } } if (!anEvent) { KNotifyClient::beep(); return; } DndFactory factory( mCalendar ); factory.copyEvent(anEvent); } void CalendarView::edit_paste() { QDate date = mNavigator->selectedDates().first(); DndFactory factory( mCalendar ); Event *pastedEvent = factory.pasteEvent( date ); changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); } void CalendarView::edit_options() { mDialogManager->showOptionsDialog(); //writeSettings(); } void CalendarView::slotSelectPickerDate( QDate d) { mDateFrame->hide(); if ( mDatePickerMode == 1 ) { mNavigator->slotDaySelect( d ); } else if ( mDatePickerMode == 2 ) { if ( mMoveIncidence->type() == "Todo" ) { Todo * to = (Todo *) mMoveIncidence; QTime tim; if ( to->hasDueDate() ) tim = to->dtDue().time(); else { tim = QTime ( 0,0,0 ); to->setFloats( true ); to->setHasDueDate( true ); } QDateTime dt ( d,tim ); to->setDtDue( dt ); todoChanged( to ); } else { QTime tim = mMoveIncidence->dtStart().time(); int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); QDateTime dt ( d,tim ); mMoveIncidence->setDtStart( dt ); ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); } mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); } } void CalendarView::removeCategories() { QPtrList<Incidence> incList = mCalendar->rawIncidences(); QStringList catList = KOPrefs::instance()->mCustomCategories; QStringList catIncList; QStringList newCatList; Incidence* inc = incList.first(); int i; int count = 0; while ( inc ) { newCatList.clear(); catIncList = inc->categories() ; for( i = 0; i< catIncList.count(); ++i ) { if ( catList.contains (catIncList[i])) newCatList.append( catIncList[i] ); } newCatList.sort(); inc->setCategories( newCatList.join(",") ); inc = incList.next(); } } int CalendarView::addCategories() { QPtrList<Incidence> incList = mCalendar->rawIncidences(); QStringList catList = KOPrefs::instance()->mCustomCategories; QStringList catIncList; Incidence* inc = incList.first(); int i; int count = 0; while ( inc ) { catIncList = inc->categories() ; for( i = 0; i< catIncList.count(); ++i ) { if ( !catList.contains (catIncList[i])) { catList.append( catIncList[i] ); //qDebug("add cat %s ", catIncList[i].latin1()); ++count; } } inc = incList.next(); } catList.sort(); KOPrefs::instance()->mCustomCategories = catList; return count; } void CalendarView::manageCategories() { KOCatPrefs* cp = new KOCatPrefs(); cp->show(); int w =cp->sizeHint().width() ; int h = cp->sizeHint().height() ; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); if ( !cp->exec() ) { delete cp; return; } int count = 0; if ( cp->addCat() ) { count = addCategories(); if ( count ) { topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); writeSettings(); } } else { removeCategories(); updateView(); } delete cp; } void CalendarView::beamIncidence(Incidence * Inc) { QPtrList<Incidence> delSel ; delSel.append(Inc); beamIncidenceList( delSel ); } void CalendarView::beamCalendar() { QPtrList<Incidence> delSel = mCalendar->rawIncidences(); //qDebug("beamCalendar() "); beamIncidenceList( delSel ); } void CalendarView::beamFilteredCalendar() { QPtrList<Incidence> delSel = mCalendar->incidences(); //qDebug("beamFilteredCalendar() "); beamIncidenceList( delSel ); } void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) { if ( beamDialog->exec () == QDialog::Rejected ) return; QString fn = "/tmp/kopibeamfile"; QString mes; bool createbup = true; if ( createbup ) { QString description = "\n"; CalendarLocal* cal = new CalendarLocal(); if ( beamDialog->beamLocal() ) cal->setLocalTime(); else cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); Incidence *incidence = delSel.first(); bool addText = false; if ( delSel.count() < 10 ) addText = true; else { description.sprintf(i18n(" %d items?"),delSel.count() ); } while ( incidence ) { Incidence *in = incidence->clone(); + if ( ! in->summary().isEmpty() ) { + in->setDescription(""); + } else { + in->setSummary( in->description().left(20)); + in->setDescription(""); + } if ( addText ) description += in->summary() + "\n"; cal->addIncidence( in ); incidence = delSel.next(); } if ( beamDialog->beamVcal() ) { fn += ".vcs"; FileStorage storage( cal, fn, new VCalFormat ); storage.save(); } else { fn += ".ics"; FileStorage storage( cal, fn, new ICalFormat( ) ); storage.save(); } delete cal; mes = i18n("KO/Pi: Ready for beaming"); - setCaption(mes); - + topLevelWidget()->setCaption(mes); + KApplication::convert2latin1( fn ); #ifndef DESKTOP_VERSION Ir *ir = new Ir( this ); connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); ir->send( fn, description, "text/x-vCalendar" ); #endif } } void CalendarView::beamDone( Ir *ir ) { #ifndef DESKTOP_VERSION delete ir; #endif + topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); + topLevelWidget()->raise(); } void CalendarView::moveIncidence(Incidence * inc ) { if ( !inc ) return; // qDebug("showDatePickerForIncidence( ) "); if ( mDateFrame->isVisible() ) mDateFrame->hide(); else { int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); mDateFrame->show(); } mDatePickerMode = 2; mMoveIncidence = inc ; QDate da; if ( mMoveIncidence->type() == "Todo" ) { Todo * to = (Todo *) mMoveIncidence; if ( to->hasDueDate() ) da = to->dtDue().date(); else da = QDate::currentDate(); } else { da = mMoveIncidence->dtStart().date(); } mDatePicker->setDate( da ); } void CalendarView::showDatePicker( ) { //qDebug("CalendarView::showDatePicker( ) "); if ( mDateFrame->isVisible() ) mDateFrame->hide(); else { int w =mDatePicker->sizeHint().width() ; int h = mDatePicker->sizeHint().height() ; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); mDateFrame->show(); } mDatePickerMode = 1; mDatePicker->setDate( mNavigator->selectedDates().first() ); } void CalendarView::showEventEditor() { #ifdef DESKTOP_VERSION mEventEditor->show(); #else mEventEditor->showMaximized(); #endif } void CalendarView::showTodoEditor() { #ifdef DESKTOP_VERSION mTodoEditor->show(); #else mTodoEditor->showMaximized(); #endif } void CalendarView::cloneIncidence() { Incidence *incidence = currentSelection(); if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); if ( incidence ) { cloneIncidence(incidence); } } void CalendarView::moveIncidence() { Incidence *incidence = currentSelection(); if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); if ( incidence ) { moveIncidence(incidence); } } void CalendarView::beamIncidence() { Incidence *incidence = currentSelection(); if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); if ( incidence ) { beamIncidence(incidence); } } void CalendarView::toggleCancelIncidence() { Incidence *incidence = currentSelection(); if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); if ( incidence ) { cancelIncidence(incidence); } } void CalendarView::cancelIncidence(Incidence * inc ) { inc->setCancelled( ! inc->cancelled() ); changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); updateView(); } void CalendarView::cloneIncidence(Incidence * orgInc ) { Incidence * newInc = orgInc->clone(); newInc->recreate(); if ( newInc->type() == "Todo" ) { Todo* t = (Todo*) newInc; mTodoEditor->editTodo( t ); showTodoEditor(); if ( mTodoEditor->exec() ) { mCalendar->addTodo( t ); updateView(); } else { delete t; } } else { Event* e = (Event*) newInc; mEventEditor->editEvent( e ); showEventEditor(); if ( mEventEditor->exec() ) { mCalendar->addEvent( e ); updateView(); } else { delete e; } } } void CalendarView::newEvent() { // TODO: Replace this code by a common eventDurationHint of KOBaseView. KOAgendaView *aView = mViewManager->agendaView(); if (aView) { if (aView->selectionStart().isValid()) { if (aView->selectedIsAllDay()) { newEvent(aView->selectionStart(),aView->selectionEnd(),true); } else { newEvent(aView->selectionStart(),aView->selectionEnd()); } return; } } QDate date = mNavigator->selectedDates().first(); QDateTime current = QDateTime::currentDateTime(); if ( date <= current.date() ) { int hour = current.time().hour() +1; newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); } else newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), QDateTime( date, QTime( KOPrefs::instance()->mStartTime + KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); } void CalendarView::newEvent(QDateTime fh) { newEvent(fh, QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); } void CalendarView::newEvent(QDate dt) { newEvent(QDateTime(dt, QTime(0,0,0)), QDateTime(dt, QTime(0,0,0)), true); } void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) { mEventEditor->newEvent(fromHint,toHint,allDay); if ( mFilterView->filtersEnabled() ) { CalFilter *filter = mFilterView->selectedFilter(); if (filter && filter->showCategories()) { mEventEditor->setCategories(filter->categoryList().join(",") ); } if ( filter ) mEventEditor->setSecrecy( filter->getSecrecy() ); } showEventEditor(); } void CalendarView::todoAdded(Todo * t) { changeTodoDisplay ( t ,KOGlobals::EVENTADDED); updateTodoViews(); } void CalendarView::todoChanged(Todo * t) { emit todoModified( t, 4 ); // updateTodoViews(); } void CalendarView::todoToBeDeleted(Todo *) { //qDebug("todoToBeDeleted(Todo *) "); updateTodoViews(); } void CalendarView::todoDeleted() { //qDebug(" todoDeleted()"); updateTodoViews(); } void CalendarView::newTodo() { mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); if ( mFilterView->filtersEnabled() ) { CalFilter *filter = mFilterView->selectedFilter(); if (filter && filter->showCategories()) { mTodoEditor->setCategories(filter->categoryList().join(",") ); } if ( filter ) mTodoEditor->setSecrecy( filter->getSecrecy() ); } showTodoEditor(); } void CalendarView::newSubTodo() { Todo *todo = selectedTodo(); if ( todo ) newSubTodo( todo ); } void CalendarView::newSubTodo(Todo *parentEvent) { mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); showTodoEditor(); } void CalendarView::newFloatingEvent() { DateList tmpList = mNavigator->selectedDates(); QDate date = tmpList.first(); newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), QDateTime( date, QTime( 12, 0, 0 ) ), true ); } void CalendarView::editEvent( Event *event ) { if ( !event ) return; if ( event->isReadOnly() ) { showEvent( event ); return; } mEventEditor->editEvent( event , mFlagEditDescription); showEventEditor(); } void CalendarView::editJournal( Journal *jour ) { if ( !jour ) return; mDialogManager->hideSearchDialog(); mViewManager->showJournalView(); mNavigator->slotDaySelect( jour->dtStart().date() ); } void CalendarView::editTodo( Todo *todo ) { if ( !todo ) return; if ( todo->isReadOnly() ) { showTodo( todo ); return; } mTodoEditor->editTodo( todo ,mFlagEditDescription); showTodoEditor(); } KOEventViewerDialog* CalendarView::getEventViewerDialog() { if ( !mEventViewerDialog ) { mEventViewerDialog = new KOEventViewerDialog(this); connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), viewManager(), SLOT( showAgendaView( bool ) ) ); mEventViewerDialog->resize( 640, 480 ); } return mEventViewerDialog; } void CalendarView::showEvent(Event *event) { getEventViewerDialog()->setEvent(event); getEventViewerDialog()->showMe(); } void CalendarView::showTodo(Todo *event) { getEventViewerDialog()->setTodo(event); getEventViewerDialog()->showMe(); } void CalendarView::showJournal( Journal *jour ) { getEventViewerDialog()->setJournal(jour); getEventViewerDialog()->showMe(); } // void CalendarView::todoModified (Todo *event, int changed) // { // // if (mDialogList.find (event) != mDialogList.end ()) { // // kdDebug() << "Todo modified and open" << endl; // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; // // temp->modified (changed); // // } // mViewManager->updateView(); // } void CalendarView::appointment_show() { Event *anEvent = 0; Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); if (mViewManager->currentView()->isEventView()) { if ( incidence && incidence->type() == "Event" ) { anEvent = static_cast<Event *>(incidence); } } if (!anEvent) { KNotifyClient::beep(); return; } showEvent(anEvent); } void CalendarView::appointment_edit() { Event *anEvent = 0; Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); if (mViewManager->currentView()->isEventView()) { if ( incidence && incidence->type() == "Event" ) { anEvent = static_cast<Event *>(incidence); } } if (!anEvent) { KNotifyClient::beep(); return; } editEvent(anEvent); } void CalendarView::appointment_delete() { Event *anEvent = 0; Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); if (mViewManager->currentView()->isEventView()) { if ( incidence && incidence->type() == "Event" ) { anEvent = static_cast<Event *>(incidence); } } if (!anEvent) { KNotifyClient::beep(); return; } deleteEvent(anEvent); } void CalendarView::todo_unsub(Todo *anTodo ) { // Todo *anTodo = selectedTodo(); if (!anTodo) return; if (!anTodo->relatedTo()) return; anTodo->relatedTo()->removeRelation(anTodo); anTodo->setRelatedTo(0); anTodo->updated(); anTodo->setRelatedToUid(""); setModified(true); updateView(); } void CalendarView::deleteTodo(Todo *todo) { if (!todo) { KNotifyClient::beep(); return; } if (KOPrefs::instance()->mConfirm) { switch (msgItemDelete()) { case KMessageBox::Continue: // OK if (!todo->relations().isEmpty()) { KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), i18n("Delete To-Do")); } else { checkExternalId( todo ); calendar()->deleteTodo(todo); changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); updateView(); } break; } // switch } else { if (!todo->relations().isEmpty()) { KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), i18n("Delete To-Do")); } else { checkExternalId( todo ); mCalendar->deleteTodo(todo); changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); updateView(); } } emit updateSearchDialog(); } void CalendarView::deleteJournal(Journal *jour) { if (!jour) { KNotifyClient::beep(); return; } if (KOPrefs::instance()->mConfirm) { switch (msgItemDelete()) { case KMessageBox::Continue: // OK calendar()->deleteJournal(jour); updateView(); break; } // switch } else { calendar()->deleteJournal(jour);; updateView(); } emit updateSearchDialog(); } void CalendarView::deleteEvent(Event *anEvent) { if (!anEvent) { KNotifyClient::beep(); return; } if (anEvent->recurrence()->doesRecur()) { QDate itemDate = mViewManager->currentSelectionDate(); int km; if (!itemDate.isValid()) { //kdDebug() << "Date Not Valid" << endl; if (KOPrefs::instance()->mConfirm) { km = KMessageBox::warningContinueCancel(this,anEvent->summary() + i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), i18n("KO/Pi Confirmation"),i18n("Delete All")); if ( km == KMessageBox::Continue ) km = KMessageBox::No; // No = all below } else km = KMessageBox::No; } else { km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), i18n("KO/Pi Confirmation"),i18n("Current"), i18n("All")); } switch(km) { case KMessageBox::No: // Continue // all //qDebug("KMessageBox::No "); if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) schedule(Scheduler::Cancel,anEvent); checkExternalId( anEvent); mCalendar->deleteEvent(anEvent); changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); break; // Disabled because it does not work //#if 0 case KMessageBox::Yes: // just this one //QDate qd = mNavigator->selectedDates().first(); //if (!qd.isValid()) { // kdDebug() << "no date selected, or invalid date" << endl; // KNotifyClient::beep(); // return; //} //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { anEvent->addExDate(itemDate); int duration = anEvent->recurrence()->duration(); if ( duration > 0 ) { anEvent->recurrence()->setDuration( duration - 1 ); } changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); } break; //#endif } // switch } else { if (KOPrefs::instance()->mConfirm) { switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + diff --git a/microkde/kapplication.cpp b/microkde/kapplication.cpp index 98ef2f2..56c01af 100644 --- a/microkde/kapplication.cpp +++ b/microkde/kapplication.cpp @@ -1,84 +1,106 @@ #include <stdlib.h> #include <stdio.h> #include "kapplication.h" #include <qapplication.h> #include <qstring.h> #include <qfile.h> #include <qtextstream.h> #include <qdialog.h> #include <qlayout.h> #include <qtextbrowser.h> int KApplication::random() { return rand(); } //US QString KApplication::randomString(int length) { if (length <=0 ) return QString::null; QString str; while (length--) { int r=random() % 62; r+=48; if (r>57) r+=7; if (r>90) r+=6; str += char(r); // so what if I work backwards? } return str; } int KApplication::execDialog( QDialog* d ) { if (QApplication::desktop()->width() <= 640 ) d->showMaximized(); return d->exec(); } void KApplication::showLicence() { KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/LICENCE.TXT" ); } void KApplication::showFile(QString caption, QString fn) { QString text; QString fileName; #ifndef DESKTOP_VERSION fileName = getenv("QPEDIR"); fileName += "/pics/" + fn ; #else fileName = qApp->applicationDirPath () + "/" + fn; #endif QFile file( fileName ); if (!file.open( IO_ReadOnly ) ) { return ; } QTextStream ts( &file ); text = ts.read(); file.close(); KApplication::showText( caption, text ); } +bool KApplication::convert2latin1(QString fileName) +{ + QString text; + QFile file( fileName ); + if (!file.open( IO_ReadOnly ) ) { + return false; + + } + QTextStream ts( &file ); + ts.setEncoding( QTextStream::UnicodeUTF8 ); + text = ts.read(); + file.close(); + if (!file.open( IO_WriteOnly ) ) { + return false; + } + QTextStream tsIn( &file ); + tsIn.setEncoding( QTextStream::Latin1 ); + tsIn << text.latin1(); + file.close(); + + +} void KApplication::showText(QString caption, QString text) { QDialog dia( 0, "name", true ); ; dia.setCaption( caption ); QVBoxLayout* lay = new QVBoxLayout( &dia ); lay->setSpacing( 3 ); lay->setMargin( 3 ); QTextBrowser tb ( &dia ); lay->addWidget( &tb ); tb.setText( text ); #ifdef DESKTOP_VERSION dia.resize( 640, 480); #else dia.showMaximized(); #endif dia.exec(); } diff --git a/microkde/kapplication.h b/microkde/kapplication.h index 79cdb33..41546a0 100644 --- a/microkde/kapplication.h +++ b/microkde/kapplication.h @@ -1,26 +1,27 @@ #ifndef MINIKDE_KAPPLICATION_H #define MINIKDE_KAPPLICATION_H #include "qstring.h" #include <qdialog.h> class KApplication { public: static int random(); //US /** * Generates a random string. It operates in the range [A-Za-z0-9] * @param length Generate a string of this length. * @return the random string */ static QString randomString(int length); static int execDialog( QDialog* ); static void showLicence(); static void showFile(QString caption, QString file); static void showText(QString caption, QString text); + static bool convert2latin1(QString file); }; #endif |