summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-14 06:42:01 (UTC)
committer zautrix <zautrix>2004-10-14 06:42:01 (UTC)
commita6dff815a9c6d3a91094573d23c28a8553fc7cc2 (patch) (side-by-side diff)
treea8830e9adcd72faa8178d4ee2517bfc31cda8653
parent909d25797c50fc38c435834a68aaf60bf87e32f9 (diff)
downloadkdepimpi-a6dff815a9c6d3a91094573d23c28a8553fc7cc2.zip
kdepimpi-a6dff815a9c6d3a91094573d23c28a8553fc7cc2.tar.gz
kdepimpi-a6dff815a9c6d3a91094573d23c28a8553fc7cc2.tar.bz2
fixes umlaute in beaming
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/common/service/gsmcal.c15
-rw-r--r--gammu/emb/common/service/gsmcal.h1
-rw-r--r--kaddressbook/kabcore.cpp6
-rw-r--r--korganizer/calendarview.cpp12
-rw-r--r--microkde/kapplication.cpp22
-rw-r--r--microkde/kapplication.h1
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, &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) {
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, &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;
}
}
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, &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;
}
}
}
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, &note->Entries[EndTime].Date, "DUE");
}
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, "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, &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: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
@@ -32,256 +32,257 @@ typedef enum {
*/
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 */
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 47ed858..dae9cd2 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -688,275 +688,277 @@ void KABCore::export2phone()
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 );
}
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 1f2c6da..3e0a27d 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -2198,286 +2198,294 @@ void CalendarView::slotSelectPickerDate( QDate d)
} 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 {
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