Gammu internals  1.38.0
Note

Data Structures

struct  GSM_NoteEntry
 

Functions

GSM_Error GSM_DecodeVNOTE (char *Buffer, size_t *Pos, GSM_NoteEntry *Note)
 
GSM_Error GSM_EncodeVNTFile (char *Buffer, const size_t buff_len, size_t *Length, GSM_NoteEntry *Note)
 
GSM_Error GSM_GetNotesStatus (GSM_StateMachine *s, GSM_ToDoStatus *status)
 
GSM_Error GSM_GetNote (GSM_StateMachine *s, GSM_NoteEntry *Note)
 
GSM_Error GSM_GetNextNote (GSM_StateMachine *s, GSM_NoteEntry *Note, gboolean start)
 
GSM_Error GSM_SetNote (GSM_StateMachine *s, GSM_NoteEntry *Note)
 
GSM_Error GSM_AddNote (GSM_StateMachine *s, GSM_NoteEntry *Note)
 
GSM_Error GSM_DeleteNote (GSM_StateMachine *s, GSM_NoteEntry *Note)
 
GSM_Error GSM_DeleteAllNotes (GSM_StateMachine *s)
 

Detailed Description

Notes manipulations.

Function Documentation

§ GSM_AddNote()

GSM_Error GSM_AddNote ( GSM_StateMachine s,
GSM_NoteEntry Note 
)

Adds note entry.

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

Adds note entry.

Definition at line 1592 of file api.c.

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

1593 {
1594  GSM_Error err;
1595 
1597  PRINT_NOTE_INFO();
1598 
1599  err = s->Phone.Functions->AddNote(s, Note);
1600  PRINT_LOG_ERROR(err);
1601  return err;
1602 }
GSM_Error
Definition: gammu-error.h:23
GSM_Error(* AddNote)(GSM_StateMachine *s, GSM_NoteEntry *Note)
Definition: gsmstate.h:1221
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
#define PRINT_NOTE_INFO()
Definition: api.c:18

§ GSM_DecodeVNOTE()

GSM_Error GSM_DecodeVNOTE ( char *  Buffer,
size_t *  Pos,
GSM_NoteEntry Note 
)

Decodes vNote from buffer.

Parameters
BufferBuffer to decode.
PosCurrent position in buffer (will be updated).
NoteStorage for note entry.
Returns
Error code.

Definition at line 2030 of file gsmcal.c.

References CopyUnicodeString(), ERR_EMPTY, ERR_NONE, FALSE, MyGetLine(), ReadVCALText(), GSM_NoteEntry::Text, TRUE, and UnicodeLength().

2031 {
2032  unsigned char Line[2000],Buff[2000];
2033  int Level = 0;
2034  GSM_Error error;
2035  gboolean empty = TRUE;
2036 
2037  Note->Text[0] = 0;
2038  Note->Text[1] = 0;
2039 
2040  while (1) {
2041  error = MyGetLine(Buffer, Pos, Line, strlen(Buffer), sizeof(Line), TRUE);
2042  if (error != ERR_NONE) return error;
2043  if (strlen(Line) == 0) break;
2044  switch (Level) {
2045  case 0:
2046  if (strstr(Line,"BEGIN:VNOTE")) Level = 1;
2047  empty = TRUE;
2048  break;
2049  case 1:
2050  if (strstr(Line,"END:VNOTE")) {
2051  if (UnicodeLength(Note->Text) == 0) return ERR_EMPTY;
2052  return ERR_NONE;
2053  }
2054  if (ReadVCALText(Line, "BODY", Buff, FALSE, NULL)) {
2055  CopyUnicodeString(Note->Text, Buff);
2056  empty = FALSE;
2057  }
2058  break;
2059  }
2060  }
2061  if (empty) return ERR_EMPTY;
2062 
2063  return ERR_NONE;
2064 }
void CopyUnicodeString(unsigned char *Dest, const unsigned char *Source)
Definition: coding.c:1192
GSM_Error
Definition: gammu-error.h:23
size_t UnicodeLength(const unsigned char *str)
Definition: coding.c:186
char Text[(GSM_MAX_NOTE_TEXT_LENGTH+1) *2]
int gboolean
Definition: gammu-types.h:23
#define FALSE
Definition: gammu-types.h:25
gboolean ReadVCALText(char *Buffer, const char *Start, unsigned char *Value, const gboolean UTF8, GSM_EntryLocation *location)
Definition: gsmmisc.c:468
#define TRUE
Definition: gammu-types.h:28
GSM_Error MyGetLine(char *Buffer, size_t *Pos, char *OutBuffer, size_t MaxLen, size_t MaxOutLen, gboolean MergeLines)
Definition: coding.c:1580

§ GSM_DeleteAllNotes()

GSM_Error GSM_DeleteAllNotes ( GSM_StateMachine s)

Deletes all notes entries.

Parameters
sState machine pointer.
Returns
Error code

Deletes all notes entries.

Definition at line 1620 of file api.c.

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

1621 {
1622  GSM_Error err;
1623 
1625 
1626  err = s->Phone.Functions->DeleteAllNotes(s);
1627  PRINT_LOG_ERROR(err);
1628  return err;
1629 }
GSM_Error
Definition: gammu-error.h:23
GSM_Error(* DeleteAllNotes)(GSM_StateMachine *s)
Definition: gsmstate.h:1229
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_DeleteNote()

GSM_Error GSM_DeleteNote ( GSM_StateMachine s,
GSM_NoteEntry Note 
)

Deletes note entry.

Parameters
sState machine pointer.
NoteNote to delete, must contain position.
Returns
Error code

Deletes note entry.

Definition at line 1606 of file api.c.

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

1607 {
1608  GSM_Error err;
1609 
1611  PRINT_NOTE_INFO();
1612 
1613  err = s->Phone.Functions->DeleteNote(s, Note);
1614  PRINT_LOG_ERROR(err);
1615  return err;
1616 }
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(* DeleteNote)(GSM_StateMachine *s, GSM_NoteEntry *Note)
Definition: gsmstate.h:1225
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373
#define PRINT_NOTE_INFO()
Definition: api.c:18

§ GSM_EncodeVNTFile()

GSM_Error GSM_EncodeVNTFile ( char *  Buffer,
const size_t  buff_len,
size_t *  Length,
GSM_NoteEntry Note 
)

Encodes vNote to buffer.

Parameters
BufferStorage for data.
[in]buff_lenSize of output buffer.
LengthPointer to current position in data (will be incremented).
NoteNote to encode.
Returns
Error code.

Definition at line 2066 of file gsmcal.c.

References ERR_NONE, FALSE, GSM_NoteEntry::Text, VC_StoreLine(), and VC_StoreText().

2067 {
2068  GSM_Error error;
2069 
2070  error = VC_StoreLine(Buffer, buff_len, Length, "BEGIN:VNOTE");
2071  if (error != ERR_NONE) return error;
2072  error = VC_StoreLine(Buffer, buff_len, Length, "VERSION:1.1");
2073  if (error != ERR_NONE) return error;
2074  error = VC_StoreText(Buffer, buff_len, Length, Note->Text, "BODY", FALSE);
2075  if (error != ERR_NONE) return error;
2076  error = VC_StoreLine(Buffer, buff_len, Length, "END:VNOTE");
2077  if (error != ERR_NONE) return error;
2078 
2079  return ERR_NONE;
2080 }
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
char Text[(GSM_MAX_NOTE_TEXT_LENGTH+1) *2]
#define FALSE
Definition: gammu-types.h:25

§ GSM_GetNextNote()

GSM_Error GSM_GetNextNote ( GSM_StateMachine s,
GSM_NoteEntry Note,
gboolean  start 
)

Retrieves note entry. This is useful for continuous reading of all notes entries.

Parameters
sState machine pointer.
NoteStorage 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

Retrieves note entry. This is useful for continuous reading of all notes entries.

Definition at line 1563 of file api.c.

References CHECK_PHONE_CONNECTION, GSM_Phone::Functions, GSM_Phone_Functions::GetNextNote, _GSM_StateMachine::Phone, PRINT_LOG_ERROR, PRINT_NOTE_INFO, and PRINT_START.

1564 {
1565  GSM_Error err;
1566 
1568  PRINT_START();
1569  PRINT_NOTE_INFO();
1570 
1571  err = s->Phone.Functions->GetNextNote(s, Note, start);
1572  PRINT_LOG_ERROR(err);
1573  return err;
1574 }
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_Error(* GetNextNote)(GSM_StateMachine *s, GSM_NoteEntry *Note, gboolean start)
Definition: gsmstate.h:1213
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373
#define PRINT_NOTE_INFO()
Definition: api.c:18

§ GSM_GetNote()

GSM_Error GSM_GetNote ( GSM_StateMachine s,
GSM_NoteEntry Note 
)

Retrieves notes entry.

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

Retrieves notes entry.

Definition at line 1548 of file api.c.

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

1549 {
1550  GSM_Error err;
1551 
1553  PRINT_NOTE_INFO();
1554 
1555  err = s->Phone.Functions->GetNote(s, Note);
1556  PRINT_LOG_ERROR(err);
1557  return err;
1558 }
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(* GetNote)(GSM_StateMachine *s, GSM_NoteEntry *Note)
Definition: gsmstate.h:1208
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373
#define PRINT_NOTE_INFO()
Definition: api.c:18

§ GSM_GetNotesStatus()

GSM_Error GSM_GetNotesStatus ( GSM_StateMachine s,
GSM_ToDoStatus status 
)

Retrieves notes status (number of used entries).

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

Retrieves notes status (number of used entries).

Definition at line 1535 of file api.c.

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

1536 {
1537  GSM_Error err;
1538 
1540 
1541  err = s->Phone.Functions->GetNotesStatus(s, status);
1542  PRINT_LOG_ERROR(err);
1543  return err;
1544 }
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(* GetNotesStatus)(GSM_StateMachine *s, GSM_ToDoStatus *status)
Definition: gsmstate.h:1204

§ GSM_SetNote()

GSM_Error GSM_SetNote ( GSM_StateMachine s,
GSM_NoteEntry Note 
)

Sets note entry

Parameters
sState machine pointer.
NoteNew note values, needs to contain valid position.
Returns
Error code

Sets note entry

Definition at line 1578 of file api.c.

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

1579 {
1580  GSM_Error err;
1581 
1583  PRINT_NOTE_INFO();
1584 
1585  err = s->Phone.Functions->SetNote(s, Note);
1586  PRINT_LOG_ERROR(err);
1587  return err;
1588 }
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
#define PRINT_NOTE_INFO()
Definition: api.c:18
GSM_Error(* SetNote)(GSM_StateMachine *s, GSM_NoteEntry *Note)
Definition: gsmstate.h:1217