Gammu internals  1.38.0
Todo

Data Structures

struct  GSM_ToDoStatus
 
struct  GSM_SubToDoEntry
 
struct  GSM_ToDoEntry
 

Enumerations

enum  GSM_ToDoType {
  TODO_END_DATETIME = 1, TODO_COMPLETED, TODO_ALARM_DATETIME, TODO_SILENT_ALARM_DATETIME,
  TODO_TEXT, TODO_DESCRIPTION, TODO_LOCATION, TODO_PRIVATE,
  TODO_CATEGORY, TODO_CONTACTID, TODO_PHONE, TODO_LUID,
  TODO_LAST_MODIFIED, TODO_START_DATETIME, TODO_COMPLETED_DATETIME
}
 
enum  GSM_ToDo_Priority {
  GSM_Priority_None = 0, GSM_Priority_High, GSM_Priority_Medium, GSM_Priority_Low,
  GSM_Priority_INVALID
}
 
enum  GSM_VToDoVersion { Nokia_VToDo = 1, SonyEricsson_VToDo, Mozilla_VToDo }
 

Functions

GSM_Error GSM_EncodeVTODO (char *Buffer, const size_t buff_len, size_t *Length, const GSM_ToDoEntry *note, const gboolean header, const GSM_VToDoVersion Version)
 
GSM_Error GSM_GetToDoStatus (GSM_StateMachine *s, GSM_ToDoStatus *status)
 
GSM_Error GSM_GetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
 
GSM_Error GSM_GetNextToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo, gboolean start)
 
GSM_Error GSM_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
 
GSM_Error GSM_AddToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
 
GSM_Error GSM_DeleteToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
 
GSM_Error GSM_DeleteAllToDo (GSM_StateMachine *s)
 

Detailed Description

Todo entries manipulations.

Enumeration Type Documentation

§ GSM_ToDo_Priority

Priority of to do.

Enumerator
GSM_Priority_None 
GSM_Priority_High 
GSM_Priority_Medium 
GSM_Priority_Low 
GSM_Priority_INVALID 

Definition at line 433 of file gammu-calendar.h.

§ GSM_ToDoType

Types of to do values. In parenthesis is member of GSM_SubToDoEntry, where value is stored.

Enumerator
TODO_END_DATETIME 

Due date (Date).

TODO_COMPLETED 

Whether is completed (Number).

TODO_ALARM_DATETIME 

When should alarm be fired (Date).

TODO_SILENT_ALARM_DATETIME 

When should silent alarm be fired (Date).

TODO_TEXT 

Text of to do (Text).

TODO_DESCRIPTION 

Description of to do (Text).

TODO_LOCATION 

Location of to do (Text).

TODO_PRIVATE 

Whether entry is private (Number).

TODO_CATEGORY 

Category of entry (Number).

TODO_CONTACTID 

Related contact ID (Number).

TODO_PHONE 

Number to call (Text).

TODO_LUID 

IrMC LUID which can be used for synchronisation (Text).

TODO_LAST_MODIFIED 

Date and time of last modification (Date).

TODO_START_DATETIME 

Start date (Date).

TODO_COMPLETED_DATETIME 

Completed date (Date).

Definition at line 365 of file gammu-calendar.h.

§ GSM_VToDoVersion

Format of vTodo.

Enumerator
Nokia_VToDo 

Format compatible with Nokia - limited subsed of standard.

SonyEricsson_VToDo 

Format compatible with SonyEricsson - complete standard.

Mozilla_VToDo 

Format compatible with Mozilla - iCalendar based.

Definition at line 538 of file gammu-calendar.h.

Function Documentation

§ GSM_AddToDo()

GSM_Error GSM_AddToDo ( GSM_StateMachine s,
GSM_ToDoEntry ToDo 
)

Adds ToDo in phone.

Parameters
sState machine pointer.
ToDoToDo to add.
Returns
Error code

Adds ToDo in phone.

Definition at line 1370 of file api.c.

References GSM_Phone_Functions::AddToDo, CHECK_PHONE_CONNECTION, GSM_Phone::Functions, _GSM_StateMachine::Phone, PRINT_LOG_ERROR, and PRINT_TODO_INFO.

1371 {
1372  GSM_Error err;
1373 
1375  PRINT_TODO_INFO();
1376 
1377  err = s->Phone.Functions->AddToDo(s, ToDo);
1378  PRINT_LOG_ERROR(err);
1379  return err;
1380 }
#define PRINT_TODO_INFO()
Definition: api.c:16
GSM_Error
Definition: gammu-error.h:23
GSM_Phone Phone
Definition: gsmstate.h:1431
#define PRINT_LOG_ERROR(err)
Definition: api.c:28
#define CHECK_PHONE_CONNECTION()
Definition: api.c:38
GSM_Error(* AddToDo)(GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
Definition: gsmstate.h:1155
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373

§ GSM_DeleteAllToDo()

GSM_Error GSM_DeleteAllToDo ( GSM_StateMachine s)

Deletes all todo entries in phone.

Parameters
sState machine pointer.
Returns
Error code

Deletes all todo entries in phone.

Definition at line 1398 of file api.c.

References CHECK_PHONE_CONNECTION, GSM_Phone_Functions::DeleteAllToDo, GSM_Phone::Functions, _GSM_StateMachine::Phone, and PRINT_LOG_ERROR.

1399 {
1400  GSM_Error err;
1401 
1403 
1404  err = s->Phone.Functions->DeleteAllToDo(s);
1405  PRINT_LOG_ERROR(err);
1406  return err;
1407 }
GSM_Error
Definition: gammu-error.h:23
GSM_Error(* DeleteAllToDo)(GSM_StateMachine *s)
Definition: gsmstate.h:1163
GSM_Phone Phone
Definition: gsmstate.h:1431
#define PRINT_LOG_ERROR(err)
Definition: api.c:28
#define CHECK_PHONE_CONNECTION()
Definition: api.c:38
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373

§ GSM_DeleteToDo()

GSM_Error GSM_DeleteToDo ( GSM_StateMachine s,
GSM_ToDoEntry ToDo 
)

Deletes ToDo entry in phone.

Parameters
sState machine pointer.
ToDoToDo to delete, only location is actually used.
Returns
Error code

Deletes ToDo entry in phone.

Definition at line 1384 of file api.c.

References CHECK_PHONE_CONNECTION, GSM_Phone_Functions::DeleteToDo, GSM_Phone::Functions, _GSM_StateMachine::Phone, PRINT_LOG_ERROR, and PRINT_TODO_INFO.

1385 {
1386  GSM_Error err;
1387 
1389  PRINT_TODO_INFO();
1390 
1391  err = s->Phone.Functions->DeleteToDo(s, ToDo);
1392  PRINT_LOG_ERROR(err);
1393  return err;
1394 }
GSM_Error(* DeleteToDo)(GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
Definition: gsmstate.h:1159
#define PRINT_TODO_INFO()
Definition: api.c:16
GSM_Error
Definition: gammu-error.h:23
GSM_Phone Phone
Definition: gsmstate.h:1431
#define PRINT_LOG_ERROR(err)
Definition: api.c:28
#define CHECK_PHONE_CONNECTION()
Definition: api.c:38
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373

§ GSM_EncodeVTODO()

GSM_Error GSM_EncodeVTODO ( char *  Buffer,
const size_t  buff_len,
size_t *  Length,
const GSM_ToDoEntry note,
const gboolean  header,
const GSM_VToDoVersion  Version 
)

Encodes vTodo to buffer.

Parameters
BufferStorage for data.
[in]buff_lenSize of output buffer.
LengthPointer to current position in data (will be incremented).
noteNote to encode.
headerWhether to include vCalendar header.
VersionFormat of vTodo to create.
Returns
Error code.

Definition at line 1038 of file gsmcal.c.

References GSM_SubToDoEntry::Date, GSM_DateTime::Day, GSM_ToDoEntry::Entries, GSM_ToDoEntry::EntriesNum, GSM_SubToDoEntry::EntryType, ERR_NONE, GSM_CAL_BIRTHDAY, GSM_Priority_High, GSM_Priority_INVALID, GSM_Priority_Low, GSM_Priority_Medium, GSM_Priority_None, GSM_Translate_Category_To_VCal(), GSM_DateTime::Hour, GSM_ToDoEntry::Location, GSM_DateTime::Minute, GSM_DateTime::Month, Mozilla_VToDo, GSM_SubToDoEntry::Number, GSM_ToDoEntry::Priority, GSM_SubToDoEntry::Text, TODO_ALARM_DATETIME, TODO_CATEGORY, TODO_COMPLETED, TODO_COMPLETED_DATETIME, TODO_CONTACTID, TODO_DESCRIPTION, TODO_END_DATETIME, TODO_LAST_MODIFIED, TODO_LOCATION, TODO_LUID, TODO_PHONE, TODO_PRIVATE, TODO_SILENT_ALARM_DATETIME, TODO_START_DATETIME, TODO_TEXT, GSM_ToDoEntry::Type, VC_StoreDateTime(), VC_StoreLine(), VC_StoreText(), and GSM_DateTime::Year.

Referenced by GSM_EncodeMultiPartSMS().

1039 {
1040  char category[100];
1041  int i;
1042  GSM_Error error;
1043 
1044  /* Write header */
1045  if (header) {
1046  error = VC_StoreLine(Buffer, buff_len, Length, "BEGIN:VCALENDAR");
1047  if (error != ERR_NONE) return error;
1048  error = VC_StoreLine(Buffer, buff_len, Length, "VERSION:%s", Version == Mozilla_VToDo ? "2.0" : "1.0");
1049  if (error != ERR_NONE) return error;
1050  }
1051  error = VC_StoreLine(Buffer, buff_len, Length, "BEGIN:VTODO");
1052  if (error != ERR_NONE) return error;
1053 
1054  if (Version == Mozilla_VToDo) {
1055  /* Mozilla Calendar needs UIDs. http://www.innerjoin.org/iCalendar/events-and-uids.html */
1056  error = VC_StoreLine(Buffer, buff_len, Length, "UID:calendar-%i",note->Location);
1057  if (error != ERR_NONE) return error;
1058  error = VC_StoreLine(Buffer, buff_len, Length, "STATUS:CONFIRMED");
1059  if (error != ERR_NONE) return error;
1060  }
1061 
1062  if (Version == Mozilla_VToDo) {
1063  switch (note->Priority) {
1064  case GSM_Priority_None :
1065  case GSM_Priority_INVALID:
1066  error = VC_StoreLine(Buffer, buff_len, Length, "PRIORITY:0");
1067  if (error != ERR_NONE) return error;
1068  break;
1069  case GSM_Priority_Low :
1070  error = VC_StoreLine(Buffer, buff_len, Length, "PRIORITY:1");
1071  if (error != ERR_NONE) return error;
1072  break;
1073  case GSM_Priority_Medium:
1074  error = VC_StoreLine(Buffer, buff_len, Length, "PRIORITY:5");
1075  if (error != ERR_NONE) return error;
1076  break;
1077  case GSM_Priority_High :
1078  error = VC_StoreLine(Buffer, buff_len, Length, "PRIORITY:9");
1079  if (error != ERR_NONE) return error;
1080  break;
1081  }
1082  } else {
1083  switch (note->Priority) {
1084  case GSM_Priority_None :
1085  case GSM_Priority_INVALID:
1086  error = VC_StoreLine(Buffer, buff_len, Length, "PRIORITY:0");
1087  if (error != ERR_NONE) return error;
1088  break;
1089  case GSM_Priority_Low :
1090  error = VC_StoreLine(Buffer, buff_len, Length, "PRIORITY:1");
1091  if (error != ERR_NONE) return error;
1092  break;
1093  case GSM_Priority_Medium:
1094  error = VC_StoreLine(Buffer, buff_len, Length, "PRIORITY:2");
1095  if (error != ERR_NONE) return error;
1096  break;
1097  case GSM_Priority_High :
1098  error = VC_StoreLine(Buffer, buff_len, Length, "PRIORITY:3");
1099  if (error != ERR_NONE) return error;
1100  break;
1101  }
1102  }
1103  /* Store category */
1104  GSM_Translate_Category_To_VCal(category, note->Type);
1105  error = VC_StoreLine(Buffer, buff_len, Length, "CATEGORIES:%s", category);
1106  if (error != ERR_NONE) return error;
1107 
1108  /* Loop over entries */
1109  for (i=0; i < note->EntriesNum; i++) {
1110  switch (note->Entries[i].EntryType) {
1111  case TODO_END_DATETIME :
1112  if (note->Entries[i].Date.Year != 2037 &&
1113  note->Entries[i].Date.Month != 12 &&
1114  note->Entries[i].Date.Day != 31 &&
1115  note->Entries[i].Date.Hour != 23 &&
1116  note->Entries[i].Date.Minute != 59 ) {
1117  error = VC_StoreDateTime(Buffer, buff_len, Length, &note->Entries[i].Date, "DUE");
1118  if (error != ERR_NONE) return error;
1119  }
1120  break;
1121  case TODO_ALARM_DATETIME :
1122  /* Disable alarm for birthday entries. Mozilla would generate an alarm before birth! */
1123  if (Version != Mozilla_VToDo || note->Type != GSM_CAL_BIRTHDAY) {
1124  error = VC_StoreDateTime(Buffer, buff_len, Length, &note->Entries[i].Date, "AALARM");
1125  if (error != ERR_NONE) return error;
1126  }
1127  break;
1129  /* Disable alarm for birthday entries. Mozilla would generate an alarm before birth! */
1130  if (Version != Mozilla_VToDo || note->Type != GSM_CAL_BIRTHDAY) {
1131  error = VC_StoreDateTime(Buffer, buff_len, Length, &note->Entries[i].Date, "DALARM");
1132  if (error != ERR_NONE) return error;
1133  }
1134  break;
1135  case TODO_START_DATETIME:
1136  error = VC_StoreDateTime(Buffer, buff_len, Length, &note->Entries[i].Date, "DTSTART");
1137  if (error != ERR_NONE) return error;
1138  break;
1140  error = VC_StoreDateTime(Buffer, buff_len, Length, &note->Entries[i].Date, "COMPLETED");
1141  if (error != ERR_NONE) return error;
1142  break;
1143  case TODO_LAST_MODIFIED:
1144  error = VC_StoreDateTime(Buffer, buff_len, Length, &note->Entries[i].Date, "LAST-MODIFIED");
1145  if (error != ERR_NONE) return error;
1146  break;
1147  case TODO_TEXT:
1148  error = VC_StoreText(Buffer, buff_len, Length, note->Entries[i].Text, "SUMMARY", Version == Mozilla_VToDo);
1149  if (error != ERR_NONE) return error;
1150  break;
1151  case TODO_DESCRIPTION:
1152  error = VC_StoreText(Buffer, buff_len, Length, note->Entries[i].Text, "DESCRIPTION", Version == Mozilla_VToDo);
1153  if (error != ERR_NONE) return error;
1154  break;
1155  case TODO_PHONE:
1156  /* There is no specific field for phone number, use description */
1157  error = VC_StoreText(Buffer, buff_len, Length, note->Entries[i].Text, "DESCRIPTION", Version == Mozilla_VToDo);
1158  if (error != ERR_NONE) return error;
1159  break;
1160  case TODO_LOCATION:
1161  error = VC_StoreText(Buffer, buff_len, Length, note->Entries[i].Text, "LOCATION", Version == Mozilla_VToDo);
1162  if (error != ERR_NONE) return error;
1163  break;
1164  case TODO_LUID:
1165  error = VC_StoreText(Buffer, buff_len, Length, note->Entries[i].Text, "X-IRMC-LUID", Version == Mozilla_VToDo);
1166  if (error != ERR_NONE) return error;
1167  break;
1168  case TODO_PRIVATE:
1169  if (note->Entries[i].Number == 0) {
1170  error = VC_StoreLine(Buffer, buff_len, Length, "CLASS:PUBLIC");
1171  if (error != ERR_NONE) return error;
1172  } else {
1173  error = VC_StoreLine(Buffer, buff_len, Length, "CLASS:PRIVATE");
1174  if (error != ERR_NONE) return error;
1175  }
1176  break;
1177  case TODO_COMPLETED:
1178  if (note->Entries[i].Number == 1) {
1179  error = VC_StoreLine(Buffer, buff_len, Length, "STATUS:COMPLETED");
1180  if (error != ERR_NONE) return error;
1181  error = VC_StoreLine(Buffer, buff_len, Length, "PERCENT-COMPLETE:100");
1182  if (error != ERR_NONE) return error;
1183  } else {
1184  error = VC_StoreLine(Buffer, buff_len, Length, "STATUS:NEEDS ACTION");
1185  if (error != ERR_NONE) return error;
1186  }
1187  break;
1188  case TODO_CONTACTID:
1189  case TODO_CATEGORY:
1190  /* Not supported */
1191  break;
1192  }
1193  }
1194 
1195  error = VC_StoreLine(Buffer, buff_len, Length, "END:VTODO");
1196  if (error != ERR_NONE) return error;
1197  if (header) {
1198  error = VC_StoreLine(Buffer, buff_len, Length, "END:VCALENDAR");
1199  if (error != ERR_NONE) return error;
1200  }
1201 
1202  return ERR_NONE;
1203 }
GSM_ToDo_Priority Priority
unsigned int Number
GSM_Error VC_StoreDateTime(char *Buffer, const size_t buff_len, size_t *Pos, const GSM_DateTime *Date, const char *Start)
Definition: gsmmisc.c:224
GSM_CalendarNoteType Type
GSM_Error VC_StoreText(char *Buffer, const size_t buff_len, size_t *Pos, const unsigned char *Text, const char *Start, const gboolean UTF8)
Definition: gsmmisc.c:360
GSM_Error
Definition: gammu-error.h:23
GSM_Error VC_StoreLine(char *Buffer, const size_t buff_len, size_t *Pos, const char *format,...)
Definition: gsmmisc.c:187
GSM_ToDoType EntryType
GSM_SubToDoEntry Entries[GSM_TODO_ENTRIES]
GSM_Error GSM_Translate_Category_To_VCal(char *string, const GSM_CalendarNoteType Type)
Definition: gsmcal.c:404
unsigned char Text[(GSM_MAX_TODO_TEXT_LENGTH+1) *2]
GSM_DateTime Date

§ GSM_GetNextToDo()

GSM_Error GSM_GetNextToDo ( GSM_StateMachine s,
GSM_ToDoEntry ToDo,
gboolean  start 
)

Reads ToDo from phone.

Parameters
sState machine pointer.
ToDoStorage for note, if start is FALSE, should contain data from previous read (at least position).
startWhether we're doing initial read or continue in reading.
Returns
Error code

Reads ToDo from phone.

Definition at line 1341 of file api.c.

References CHECK_PHONE_CONNECTION, GSM_Phone::Functions, GSM_Phone_Functions::GetNextToDo, _GSM_StateMachine::Phone, PRINT_LOG_ERROR, PRINT_START, and PRINT_TODO_INFO.

1342 {
1343  GSM_Error err;
1344 
1346  PRINT_START();
1347  PRINT_TODO_INFO();
1348 
1349  err = s->Phone.Functions->GetNextToDo(s, ToDo, start);
1350  PRINT_LOG_ERROR(err);
1351  return err;
1352 }
GSM_Error(* GetNextToDo)(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, gboolean start)
Definition: gsmstate.h:1147
#define PRINT_TODO_INFO()
Definition: api.c:16
GSM_Error
Definition: gammu-error.h:23
#define PRINT_START()
Definition: api.c:21
GSM_Phone Phone
Definition: gsmstate.h:1431
#define PRINT_LOG_ERROR(err)
Definition: api.c:28
#define CHECK_PHONE_CONNECTION()
Definition: api.c:38
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373

§ GSM_GetToDo()

GSM_Error GSM_GetToDo ( GSM_StateMachine s,
GSM_ToDoEntry ToDo 
)

Reads ToDo from phone.

Parameters
sState machine pointer.
ToDoStorage for note.
Returns
Error code

Reads ToDo from phone.

Definition at line 1327 of file api.c.

References CHECK_PHONE_CONNECTION, GSM_Phone::Functions, GSM_Phone_Functions::GetToDo, _GSM_StateMachine::Phone, PRINT_LOG_ERROR, and PRINT_TODO_INFO.

1328 {
1329  GSM_Error err;
1330 
1332  PRINT_TODO_INFO();
1333 
1334  err = s->Phone.Functions->GetToDo(s, ToDo);
1335  PRINT_LOG_ERROR(err);
1336  return err;
1337 }
#define PRINT_TODO_INFO()
Definition: api.c:16
GSM_Error
Definition: gammu-error.h:23
GSM_Phone Phone
Definition: gsmstate.h:1431
#define PRINT_LOG_ERROR(err)
Definition: api.c:28
#define CHECK_PHONE_CONNECTION()
Definition: api.c:38
GSM_Error(* GetToDo)(GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
Definition: gsmstate.h:1143
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373

§ GSM_GetToDoStatus()

GSM_Error GSM_GetToDoStatus ( GSM_StateMachine s,
GSM_ToDoStatus status 
)

Gets status of ToDos (count of used entries).

Parameters
sState machine pointer.
statusStorage for todo status.
Returns
Error code

Gets status of ToDos (count of used entries).

Definition at line 1314 of file api.c.

References CHECK_PHONE_CONNECTION, GSM_Phone::Functions, GSM_Phone_Functions::GetToDoStatus, _GSM_StateMachine::Phone, and PRINT_LOG_ERROR.

1315 {
1316  GSM_Error err;
1317 
1319 
1320  err = s->Phone.Functions->GetToDoStatus(s, status);
1321  PRINT_LOG_ERROR(err);
1322  return err;
1323 }
GSM_Error(* GetToDoStatus)(GSM_StateMachine *s, GSM_ToDoStatus *status)
Definition: gsmstate.h:1139
GSM_Error
Definition: gammu-error.h:23
GSM_Phone Phone
Definition: gsmstate.h:1431
#define PRINT_LOG_ERROR(err)
Definition: api.c:28
#define CHECK_PHONE_CONNECTION()
Definition: api.c:38
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373

§ GSM_SetToDo()

GSM_Error GSM_SetToDo ( GSM_StateMachine s,
GSM_ToDoEntry ToDo 
)

Sets ToDo in phone.

Parameters
sState machine pointer.
ToDoToDo to set, should contain valid location.
Returns
Error code

Sets ToDo in phone.

Definition at line 1356 of file api.c.

References CHECK_PHONE_CONNECTION, GSM_Phone::Functions, _GSM_StateMachine::Phone, PRINT_LOG_ERROR, PRINT_TODO_INFO, and GSM_Phone_Functions::SetToDo.

1357 {
1358  GSM_Error err;
1359 
1361  PRINT_TODO_INFO();
1362 
1363  err = s->Phone.Functions->SetToDo(s, ToDo);
1364  PRINT_LOG_ERROR(err);
1365  return err;
1366 }
#define PRINT_TODO_INFO()
Definition: api.c:16
GSM_Error
Definition: gammu-error.h:23
GSM_Phone Phone
Definition: gsmstate.h:1431
#define PRINT_LOG_ERROR(err)
Definition: api.c:28
#define CHECK_PHONE_CONNECTION()
Definition: api.c:38
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373
GSM_Error(* SetToDo)(GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
Definition: gsmstate.h:1151