Gammu internals  1.38.0
Memory

Data Structures

struct  GSM_MemoryStatus
 
struct  GSM_SubMemoryEntry
 
struct  GSM_MemoryEntry
 
struct  GSM_SpeedDial
 

Macros

#define GSM_MemoryTypeToString(x)
 

Enumerations

enum  GSM_MemoryType {
  MEM_ME = 1, MEM_SM, MEM_ON, MEM_DC,
  MEM_RC, MEM_MC, MEM_MT, MEM_FD,
  MEM_VM, MEM_SL, MEM_QD, MEM_INVALID
}
 
enum  GSM_EntryType {
  PBK_Number_General = 1, PBK_Number_Mobile, PBK_Number_Fax, PBK_Number_Pager,
  PBK_Number_Other, PBK_Text_Note, PBK_Text_Postal, PBK_Text_Email,
  PBK_Text_Email2, PBK_Text_URL, PBK_Date, PBK_Caller_Group,
  PBK_Text_Name, PBK_Text_LastName, PBK_Text_FirstName, PBK_Text_Company,
  PBK_Text_JobTitle, PBK_Category, PBK_Private, PBK_Text_StreetAddress,
  PBK_Text_City, PBK_Text_State, PBK_Text_Zip, PBK_Text_Country,
  PBK_Text_Custom1, PBK_Text_Custom2, PBK_Text_Custom3, PBK_Text_Custom4,
  PBK_RingtoneID, PBK_PictureID, PBK_Text_UserID, PBK_CallLength,
  PBK_Text_LUID, PBK_LastModified, PBK_Text_NickName, PBK_Text_FormalName,
  PBK_Text_PictureName, PBK_PushToTalkID, PBK_Number_Messaging, PBK_Photo,
  PBK_Text_SecondName, PBK_Text_VOIP, PBK_Text_SIP, PBK_Text_DTMF,
  PBK_Number_Video, PBK_Text_SWIS, PBK_Text_WVID, PBK_Text_NamePrefix,
  PBK_Text_NameSuffix
}
 
enum  GSM_EntryLocation { PBK_Location_Unknown = 0, PBK_Location_Home, PBK_Location_Work }
 
enum  GSM_VCardVersion {
  Nokia_VCard10 = 1, Nokia_VCard21, SonyEricsson_VCard10, SonyEricsson_VCard21,
  SonyEricsson_VCard21_Phone
}
 

Functions

GSM_Error GSM_GetMemoryStatus (GSM_StateMachine *s, GSM_MemoryStatus *status)
 
GSM_Error GSM_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry)
 
GSM_Error GSM_GetNextMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry, gboolean start)
 
GSM_Error GSM_SetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry)
 
GSM_Error GSM_AddMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry)
 
GSM_Error GSM_DeleteMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry)
 
GSM_Error GSM_DeleteAllMemory (GSM_StateMachine *s, GSM_MemoryType MemoryType)
 
GSM_Error GSM_GetSpeedDial (GSM_StateMachine *s, GSM_SpeedDial *Speed)
 
GSM_Error GSM_SetSpeedDial (GSM_StateMachine *s, GSM_SpeedDial *Speed)
 
unsigned char * GSM_PhonebookGetEntryName (const GSM_MemoryEntry *entry)
 
void GSM_PhonebookFindDefaultNameNumberGroup (const GSM_MemoryEntry *entry, int *Name, int *Number, int *Group)
 
GSM_Error GSM_EncodeVCARD (GSM_Debug_Info *di, char *Buffer, const size_t buff_len, size_t *Pos, GSM_MemoryEntry *pbk, const gboolean header, const GSM_VCardVersion Version)
 
GSM_Error GSM_DecodeVCARD (GSM_Debug_Info *di, char *Buffer, size_t *Pos, GSM_MemoryEntry *Pbk, const GSM_VCardVersion Version)
 

Detailed Description

Memory entries manipulations.

Macro Definition Documentation

§ GSM_MemoryTypeToString

#define GSM_MemoryTypeToString (   x)
Value:
((x) == MEM_ME ? "ME" : \
((x) == MEM_SM ? "SM" : \
((x) == MEM_ON ? "ON" : \
((x) == MEM_DC ? "DC" : \
((x) == MEM_RC ? "RC" : \
((x) == MEM_MC ? "MC" : \
((x) == MEM_MT ? "MT" : \
((x) == MEM_FD ? "FD" : \
((x) == MEM_VM ? "VM" : \
((x) == MEM_QD ? "QD" : \
((x) == MEM_SL ? "SL" : "XX")))))))))))

Returns string representation of a memory type.

Parameters
xMemory type to convert
Returns
Static string.

Definition at line 95 of file gammu-memory.h.

Referenced by DUMMY_AddMemory(), DUMMY_DeleteAllMemory(), DUMMY_GetMemoryStatus(), DUMMY_GetNextMemory(), DUMMY_MemoryPath(), and GSM_EncodeVCARD().

Enumeration Type Documentation

§ GSM_EntryLocation

Location of memory contact.

Enumerator
PBK_Location_Unknown 

No/Unknown location.

PBK_Location_Home 

Home

PBK_Location_Work 

Work

Definition at line 348 of file gammu-memory.h.

§ GSM_EntryType

Type of specific phonebook entry. In parenthesis is specified in which member of GSM_SubMemoryEntry value is stored.

Enumerator
PBK_Number_General 

General number. (Text)

PBK_Number_Mobile 

Mobile number. (Text)

PBK_Number_Fax 

Fax number. (Text)

PBK_Number_Pager 

Pager number. (Text)

PBK_Number_Other 

Other number. (Text)

PBK_Text_Note 

Note. (Text)

PBK_Text_Postal 

Complete postal address. (Text)

PBK_Text_Email 

Email. (Text)

PBK_Text_Email2 
PBK_Text_URL 

URL (Text)

PBK_Date 

Date and time of last call. (Date)

PBK_Caller_Group 

Caller group. (Number)

PBK_Text_Name 

Name (Text)

PBK_Text_LastName 

Last name. (Text)

PBK_Text_FirstName 

First name. (Text)

PBK_Text_Company 

Company. (Text)

PBK_Text_JobTitle 

Job title. (Text)

PBK_Category 

Category. (Number, if -1 then text)

PBK_Private 

Whether entry is private. (Number)

PBK_Text_StreetAddress 

Street address. (Text)

PBK_Text_City 

City. (Text)

PBK_Text_State 

State. (Text)

PBK_Text_Zip 

Zip code. (Text)

PBK_Text_Country 

Country. (Text)

PBK_Text_Custom1 

Custom information 1. (Text)

PBK_Text_Custom2 

Custom information 2. (Text)

PBK_Text_Custom3 

Custom information 3. (Text)

PBK_Text_Custom4 

Custom information 4. (Text)

PBK_RingtoneID 

Ringtone ID. (Number)

PBK_PictureID 

Picture ID. (Number)

PBK_Text_UserID 

User ID. (Text)

PBK_CallLength 

Length of call (Number)

PBK_Text_LUID 

LUID - Unique Identifier used for synchronisation (Text)

PBK_LastModified 

Date of last modification (Date)

PBK_Text_NickName 

Nick name (Text)

PBK_Text_FormalName 

Formal name (Text)

PBK_Text_PictureName 

Picture name (on phone filesystem). (Text)

PBK_PushToTalkID 

Push-to-talk ID (Text)

PBK_Number_Messaging 

Favorite messaging number. (Text)

PBK_Photo 

Photo (Picture).

PBK_Text_SecondName 

Second name. (Text)

PBK_Text_VOIP 

VOIP address (Text).

PBK_Text_SIP 

SIP address (Text).

PBK_Text_DTMF 

DTMF (Text).

PBK_Number_Video 

Video number. (Text)

PBK_Text_SWIS 

See What I See address. (Text)

PBK_Text_WVID 

Wireless Village user ID. (Text)

PBK_Text_NamePrefix 

Name prefix (Text)

PBK_Text_NameSuffix 

Name suffix (Text)

Definition at line 144 of file gammu-memory.h.

144  {
148  PBK_Number_General = 1,
177  /*
178  * Second email. (Text)
179  */
184  PBK_Text_URL,
188  PBK_Date,
216  PBK_Category,
220  PBK_Private,
236  PBK_Text_Zip,
304  PBK_Photo,
316  PBK_Text_SIP,
341 } GSM_EntryType;
GSM_EntryType
Definition: gammu-memory.h:144

§ GSM_MemoryType

Enum defines ID for various phone and SIM memories. Phone modules can translate them to values specific for concrete models. Two letter codes (excluding VM and SL) are from GSM 07.07.

Enumerator
MEM_ME 

Internal memory of the mobile equipment

MEM_SM 

SIM card memory

MEM_ON 

Own numbers

MEM_DC 

Dialled calls

MEM_RC 

Received calls

MEM_MC 

Missed calls

MEM_MT 

Combined ME and SIM phonebook

MEM_FD 

Fixed dial

MEM_VM 

Voice mailbox

MEM_SL 

Sent SMS logs

MEM_QD 

Quick dialing choices.

MEM_INVALID 

Invalid memory type.

Definition at line 31 of file gammu-memory.h.

31  {
35  MEM_ME = 1,
39  MEM_SM,
43  MEM_ON,
47  MEM_DC,
51  MEM_RC,
55  MEM_MC,
59  MEM_MT,
63  MEM_FD,
64 
68  MEM_VM,
69 
73  MEM_SL,
74 
78  MEM_QD,
79 
GSM_MemoryType
Definition: gammu-memory.h:31

§ GSM_VCardVersion

Types of vCard.

Enumerator
Nokia_VCard10 

vCard 1.0 hacked for Nokia.

Nokia_VCard21 

vCard 2.1 hacked for Nokia.

SonyEricsson_VCard10 

vCard 1.0 hacked for Sony-Ericsson (should be standard vCard).

SonyEricsson_VCard21 

vCard 2.1 hacked for Sony-Ericsson (should be standard vCard).

SonyEricsson_VCard21_Phone 

vCard 2.1 hacked for Sony-Ericsson (should be standard vCard) from phone (no parsing of location and memory type).

Definition at line 602 of file gammu-memory.h.

Function Documentation

§ GSM_AddMemory()

GSM_Error GSM_AddMemory ( GSM_StateMachine s,
GSM_MemoryEntry entry 
)

Adds memory (phonebooks or calls) entry.

Parameters
sState machine pointer.
entryEntry to add, Location is ignored, MemoryType has to be set.
Returns
Error code.

Deletes memory (phonebooks or calls) entry.

Definition at line 561 of file api.c.

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

562 {
563  GSM_Error err;
564 
567 
568  err = s->Phone.Functions->AddMemory(s, entry);
569  PRINT_LOG_ERROR(err);
570  return err;
571 }
GSM_Error(* AddMemory)(GSM_StateMachine *s, GSM_MemoryEntry *entry)
Definition: gsmstate.h:909
GSM_Error
Definition: gammu-error.h:23
#define PRINT_MEMORY_INFO()
Definition: api.c:15
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_DecodeVCARD()

GSM_Error GSM_DecodeVCARD ( GSM_Debug_Info di,
char *  Buffer,
size_t *  Pos,
GSM_MemoryEntry Pbk,
GSM_VCardVersion  Version 
)

Decodes memory entry from vCard.

Parameters
diPointer to debugging description.
[in]BufferBuffer to readCard text.
[in,out]PosPosition in output buffer.
[out]PbkPhonebook data read from vCard.
[in]VersionWhat vCard version to parse.
Returns
Error code.
Bug:
We should avoid using static buffers here.

Definition at line 677 of file gsmpbk.c.

References GSM_BinaryPicture::Buffer, CHECK_NUM_ENTRIES, CopyUnicodeString(), GSM_SubMemoryEntry::Date, dbgprintf, DecodeBASE64(), DecodeUnicodeString(), GSM_MemoryEntry::Entries, GSM_MemoryEntry::EntriesNum, GSM_SubMemoryEntry::EntryType, ERR_EMPTY, ERR_MOREMEMORY, ERR_NONE, GSM_GetVCSLine(), GSM_StringToMemoryType(), GSM_TweakInternationalNumber(), GSM_BinaryPicture::Length, GSM_SubMemoryEntry::Location, GSM_MemoryEntry::Location, MEM_MT, GSM_MemoryEntry::MemoryType, GSM_SubMemoryEntry::Number, NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN, PBK_Caller_Group, PBK_Category, PBK_Date, PBK_LastModified, PBK_Location_Unknown, PBK_Number_Fax, PBK_Number_General, PBK_Number_Mobile, PBK_Number_Other, PBK_Number_Video, PBK_Photo, PBK_Private, PBK_PushToTalkID, PBK_Text_City, PBK_Text_Company, PBK_Text_Country, PBK_Text_DTMF, PBK_Text_Email, PBK_Text_FirstName, PBK_Text_FormalName, PBK_Text_JobTitle, PBK_Text_LastName, PBK_Text_LUID, PBK_Text_Name, PBK_Text_NamePrefix, PBK_Text_NameSuffix, PBK_Text_NickName, PBK_Text_Note, PBK_Text_Postal, PBK_Text_SIP, PBK_Text_State, PBK_Text_StreetAddress, PBK_Text_SWIS, PBK_Text_URL, PBK_Text_VOIP, PBK_Text_WVID, PBK_Text_Zip, GSM_SubMemoryEntry::Picture, PICTURE_JPG, ReadVCALDateTime(), ReadVCALText(), GSM_SubMemoryEntry::SMSList, SonyEricsson_VCard21_Phone, GSM_SubMemoryEntry::Text, TRUE, GSM_BinaryPicture::Type, UnicodeLength(), VCALGetTextPart(), and GSM_SubMemoryEntry::VoiceTag.

678 {
679  char Buff[20000];
680  int Level = 0;
681  char *s;
682  int pos;
683  int version = 1;
684  GSM_Error error;
685  char *Line = NULL;
686  GSM_EntryLocation location;
687 
688  Buff[0] = 0;
689  Pbk->EntriesNum = 0;
690  if (Version != SonyEricsson_VCard21_Phone) {
691  Pbk->Location = 0;
692  Pbk->MemoryType = MEM_MT;
693  }
694 
695  while (1) {
696  free(Line);
697  Line = NULL;
698  error = GSM_GetVCSLine(&Line, Buffer, Pos, strlen(Buffer), TRUE);
699  if (error != ERR_NONE) goto vcard_done;
700  if (strlen(Line) == 0) break;
701  switch (Level) {
702  case 0:
703  if (strstr(Line,"BEGIN:VCARD")) Level = 1;
704  break;
705  case 1:
707  if (strstr(Line,"END:VCARD")) {
708  goto vcard_complete;
709  }
710  if (strstr(Line, "VERSION:") != NULL) {
711  version = atoi(Line + 8);
712  dbgprintf(di, "vCard version %d\n", version);
713  }
714  if (ReadVCALText(Line, "N", Buff, (version >= 3), NULL)) {
715  pos = 0;
716  s = VCALGetTextPart(Buff, &pos);
717  if (s == NULL) {
718  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
721  Pbk->EntriesNum++;
722  continue;
723  } else {
724  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text, s);
725  /* Skip empty name */
726  if (UnicodeLength(Pbk->Entries[Pbk->EntriesNum].Text) > 0) {
729  Pbk->EntriesNum++;
730  }
731 
732  s = VCALGetTextPart(Buff, &pos);
733  if (s == NULL) continue;
735  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text, s);
738  Pbk->EntriesNum++;
739  continue;
740  }
741  }
742  if (strncmp(Line, "PHOTO;JPEG;BASE64:", 18) == 0 ||
743  strncmp(Line, "PHOTO;BASE64;JPEG:", 18) == 0 ||
744  strncmp(Line, "PHOTO;TYPE=JPEG;BASE64:", 23) == 0 ||
745  strncmp(Line, "PHOTO;BASE64;TYPE=JPEG:", 23) == 0 ||
746  strncmp(Line, "PHOTO;TYPE=JPEG;ENCODING=BASE64:", 32) == 0 ||
747  strncmp(Line, "PHOTO;ENCODING=BASE64;TYPE=JPEG:", 32) == 0 ||
748  strncmp(Line, "PHOTO;JPEG;ENCODING=BASE64:", 27) == 0 ||
749  strncmp(Line, "PHOTO;ENCODING=BASE64;JPEG:", 27) == 0) {
750  /* Find : (it should be there we matched it above) */
751  s = strchr(Line, ':');
752  s++;
753  /* Skip whitespace */
754  while (isspace((int)*s) && *s) s++;
755 
756  Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Photo;
759 
760  /* We allocate here more memory than is actually required */
761  Pbk->Entries[Pbk->EntriesNum].Picture.Buffer = (unsigned char *)malloc(strlen(s));
762  if (Pbk->Entries[Pbk->EntriesNum].Picture.Buffer == NULL)
763  return ERR_MOREMEMORY;
764 
765  Pbk->Entries[Pbk->EntriesNum].Picture.Length =
766  DecodeBASE64(s, Pbk->Entries[Pbk->EntriesNum].Picture.Buffer, strlen(s));
767  Pbk->EntriesNum++;
768  continue;
769  }
770 
771  if (ReadVCALText(Line, "TEL", Buff, (version >= 3), &location) ||
772  ReadVCALText(Line, "TEL;VOICE", Buff, (version >= 3), &location) ||
773  ReadVCALText(Line, "TEL;MAIN", Buff, (version >= 3), &location)) {
774  if (Buff[1] == '+') {
776  }
777  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
779  Pbk->Entries[Pbk->EntriesNum].Location = location;
780  Pbk->Entries[Pbk->EntriesNum].SMSList[0] = 0;
781  Pbk->Entries[Pbk->EntriesNum].VoiceTag = 0;
782  Pbk->EntriesNum++;
783  continue;
784  }
785  if (ReadVCALText(Line, "TEL;VIDEO", Buff, (version >= 3), &location)) {
786  if (Buff[1] == '+') {
788  }
789  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
791  Pbk->Entries[Pbk->EntriesNum].Location = location;
792  Pbk->Entries[Pbk->EntriesNum].SMSList[0] = 0;
793  Pbk->Entries[Pbk->EntriesNum].VoiceTag = 0;
794  Pbk->EntriesNum++;
795  continue;
796  }
797  if (ReadVCALText(Line, "TEL;CELL", Buff, (version >= 3), &location) ||
798  ReadVCALText(Line, "TEL;CELL;VOICE", Buff, (version >= 3), &location)) {
799  if (Buff[1] == '+') {
801  }
802  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
804  Pbk->Entries[Pbk->EntriesNum].Location = location;
805  Pbk->Entries[Pbk->EntriesNum].SMSList[0] = 0;
806  Pbk->Entries[Pbk->EntriesNum].VoiceTag = 0;
807  Pbk->EntriesNum++;
808  continue;
809  }
810  if (ReadVCALText(Line, "TEL;OTHER", Buff, (version >= 3), &location) ||
811  ReadVCALText(Line, "TEL;OTHER;VOICE", Buff, (version >= 3), &location)) {
812  if (Buff[1] == '+') {
814  }
815  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
817  Pbk->Entries[Pbk->EntriesNum].Location = location;
818  Pbk->Entries[Pbk->EntriesNum].SMSList[0] = 0;
819  Pbk->Entries[Pbk->EntriesNum].VoiceTag = 0;
820  Pbk->EntriesNum++;
821  continue;
822  }
823  if (ReadVCALText(Line, "TEL;PAGER", Buff, (version >= 3), &location) ||
824  ReadVCALText(Line, "TEL;PAGER;VOICE", Buff, (version >= 3), &location)) {
825  if (Buff[1] == '+') {
827  }
828  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
830  Pbk->Entries[Pbk->EntriesNum].Location = location;
831  Pbk->Entries[Pbk->EntriesNum].SMSList[0] = 0;
832  Pbk->Entries[Pbk->EntriesNum].VoiceTag = 0;
833  Pbk->EntriesNum++;
834  continue;
835  }
836  if (ReadVCALText(Line, "TEL;MSG", Buff, (version >= 3), &location) ||
837  ReadVCALText(Line, "TEL;MSG;VOICE", Buff, (version >= 3), &location)) {
838  if (Buff[1] == '+') {
840  }
841  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
843  Pbk->Entries[Pbk->EntriesNum].Location = location;
844  Pbk->Entries[Pbk->EntriesNum].SMSList[0] = 0;
845  Pbk->Entries[Pbk->EntriesNum].VoiceTag = 0;
846  Pbk->EntriesNum++;
847  continue;
848  }
849  /* FAX + VOICE looks like nonsense */
850  if (ReadVCALText(Line, "TEL;FAX", Buff, (version >= 3), &location) ||
851  ReadVCALText(Line, "TEL;FAX;VOICE", Buff, (version >= 3), &location)) {
852  if (Buff[1] == '+') {
854  }
855  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
857  Pbk->Entries[Pbk->EntriesNum].Location = location;
858  Pbk->Entries[Pbk->EntriesNum].SMSList[0] = 0;
859  Pbk->Entries[Pbk->EntriesNum].VoiceTag = 0;
860  Pbk->EntriesNum++;
861  continue;
862  }
863  if (ReadVCALText(Line, "TITLE", Buff, (version >= 3), &location)) {
864  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
866  Pbk->Entries[Pbk->EntriesNum].Location = location;
867  Pbk->EntriesNum++;
868  continue;
869  }
870  if (ReadVCALText(Line, "NOTE", Buff, (version >= 3), &location)) {
871  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
873  Pbk->Entries[Pbk->EntriesNum].Location = location;
874  Pbk->EntriesNum++;
875  continue;
876  }
877  if (ReadVCALText(Line, "LABEL", Buff, (version >= 3), &location) ||
878  ReadVCALText(Line, "ADR", Buff, (version >= 3), &location)) {
879  pos = 0;
880  s = VCALGetTextPart(Buff, &pos); /* PO box, ignore for now */
881  if (s == NULL) {
882  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
884  Pbk->Entries[Pbk->EntriesNum].Location = location;
885  Pbk->EntriesNum++;
886  continue;
887  } else {
888  s = VCALGetTextPart(Buff, &pos); /* Don't know ... */
889 
890  s = VCALGetTextPart(Buff, &pos);
891  if (s == NULL) continue;
892  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text, s);
894  Pbk->Entries[Pbk->EntriesNum].Location = location;
895  Pbk->EntriesNum++;
897 
898  s = VCALGetTextPart(Buff, &pos);
899  if (s == NULL) continue;
900  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text, s);
902  Pbk->Entries[Pbk->EntriesNum].Location = location;
903  Pbk->EntriesNum++;
905 
906  s = VCALGetTextPart(Buff, &pos);
907  if (s == NULL) continue;
908  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text, s);
910  Pbk->Entries[Pbk->EntriesNum].Location = location;
911  Pbk->EntriesNum++;
913 
914  s = VCALGetTextPart(Buff, &pos);
915  if (s == NULL) continue;
916  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text, s);
918  Pbk->Entries[Pbk->EntriesNum].Location = location;
919  Pbk->EntriesNum++;
921 
922  s = VCALGetTextPart(Buff, &pos);
923  if (s == NULL) continue;
924  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text, s);
926  Pbk->Entries[Pbk->EntriesNum].Location = location;
927  Pbk->EntriesNum++;
928  continue;
929  }
930  }
931  if (ReadVCALText(Line, "EMAIL", Buff, (version >= 3), &location) ||
932  ReadVCALText(Line, "EMAIL;OTHER", Buff, (version >= 3), &location) ||
933  ReadVCALText(Line, "EMAIL;INTERNET", Buff, (version >= 3), &location)) {
934  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
936  Pbk->Entries[Pbk->EntriesNum].Location = location;
937  Pbk->EntriesNum++;
938  continue;
939  }
940  if (ReadVCALText(Line, "X-IRMC-LUID", Buff, (version >= 3), &location)) {
941  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
943  Pbk->Entries[Pbk->EntriesNum].Location = location;
944  Pbk->EntriesNum++;
945  continue;
946  }
947  if (ReadVCALText(Line, "X-DTMF", Buff, (version >= 3), &location)) {
948  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
950  Pbk->Entries[Pbk->EntriesNum].Location = location;
951  Pbk->EntriesNum++;
952  continue;
953  }
954  if (ReadVCALText(Line, "X-SIP", Buff, (version >= 3), &location)) {
955  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
957  Pbk->Entries[Pbk->EntriesNum].Location = location;
958  Pbk->EntriesNum++;
959  continue;
960  }
961  if (ReadVCALText(Line, "X-SIP;VOIP", Buff, (version >= 3), &location)) {
962  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
964  Pbk->Entries[Pbk->EntriesNum].Location = location;
965  Pbk->EntriesNum++;
966  continue;
967  }
968  if (ReadVCALText(Line, "X-WV-ID", Buff, (version >= 3), &location)) {
969  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
971  Pbk->Entries[Pbk->EntriesNum].Location = location;
972  Pbk->EntriesNum++;
973  continue;
974  }
975  if (ReadVCALText(Line, "X-SIP;SWIS", Buff, (version >= 3), &location)) {
976  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
978  Pbk->Entries[Pbk->EntriesNum].Location = location;
979  Pbk->EntriesNum++;
980  continue;
981  }
982  if (ReadVCALText(Line, "X-SIP;POC", Buff, (version >= 3), &location)) {
983  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
985  Pbk->Entries[Pbk->EntriesNum].Location = location;
986  Pbk->EntriesNum++;
987  continue;
988  }
989  if (ReadVCALText(Line, "URL", Buff, (version >= 3), &location)) {
990  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
992  Pbk->Entries[Pbk->EntriesNum].Location = location;
993  Pbk->EntriesNum++;
994  continue;
995  }
996  if (ReadVCALText(Line, "ORG", Buff, (version >= 3), &location)) {
997  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
999  Pbk->Entries[Pbk->EntriesNum].Location = location;
1000  Pbk->EntriesNum++;
1001  continue;
1002  }
1003  if (ReadVCALText(Line, "NICKNAME", Buff, (version >= 3), &location)) {
1004  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
1006  Pbk->Entries[Pbk->EntriesNum].Location = location;
1007  Pbk->EntriesNum++;
1008  continue;
1009  }
1010  if (ReadVCALText(Line, "FN", Buff, (version >= 3), &location)) {
1011  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
1013  Pbk->Entries[Pbk->EntriesNum].Location = location;
1014  Pbk->EntriesNum++;
1015  continue;
1016  }
1017  if (ReadVCALText(Line, "X-NAME-PREFIX", Buff, (version >= 3), &location)) {
1018  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
1020  Pbk->Entries[Pbk->EntriesNum].Location = location;
1021  Pbk->EntriesNum++;
1022  continue;
1023  }
1024  if (ReadVCALText(Line, "X-NAME-SUFFIX", Buff, (version >= 3), &location)) {
1025  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
1027  Pbk->Entries[Pbk->EntriesNum].Location = location;
1028  Pbk->EntriesNum++;
1029  continue;
1030  }
1031  if (ReadVCALText(Line, "CATEGORIES", Buff, (version >= 3), &location)) {
1032  CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
1033  Pbk->Entries[Pbk->EntriesNum].Number = -1;
1035  Pbk->Entries[Pbk->EntriesNum].Location = location;
1036  Pbk->EntriesNum++;
1037  continue;
1038  }
1039  if (ReadVCALText(Line, "BDAY", Buff, (version >= 3), NULL)) {
1040  if (ReadVCALDateTime(DecodeUnicodeString(Buff), &Pbk->Entries[Pbk->EntriesNum].Date)) {
1041  Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Date;
1043  Pbk->EntriesNum++;
1044  continue;
1045  }
1046  }
1047  if (ReadVCALText(Line, "LAST-MODIFIED", Buff, (version >= 3), NULL)) {
1048  if (ReadVCALDateTime(DecodeUnicodeString(Buff), &Pbk->Entries[Pbk->EntriesNum].Date)) {
1051  Pbk->EntriesNum++;
1052  continue;
1053  }
1054  }
1055  if (ReadVCALText(Line, "X-PRIVATE", Buff, (version >= 3), NULL)) {
1056  Pbk->Entries[Pbk->EntriesNum].Number = atoi(DecodeUnicodeString(Buff));
1057  Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Private;
1059  Pbk->EntriesNum++;
1060  continue;
1061  }
1062  if (ReadVCALText(Line, "X-CALLER-GROUP", Buff, (version >= 3), NULL)) {
1063  Pbk->Entries[Pbk->EntriesNum].Number = atoi(DecodeUnicodeString(Buff));
1066  Pbk->EntriesNum++;
1067  continue;
1068  }
1069  if (ReadVCALText(Line, "X-GAMMU-LOCATION", Buff, (version >= 3), NULL)) {
1070  Pbk->Location = atoi(DecodeUnicodeString(Buff));
1071  }
1072  if (ReadVCALText(Line, "X-GAMMU-MEMORY", Buff, (version >= 3), NULL)) {
1074  }
1075  break;
1076  }
1077  }
1078 
1079 vcard_complete:
1080  if (Pbk->EntriesNum == 0) error = ERR_EMPTY;
1081  else error = ERR_NONE;
1082 
1083 vcard_done:
1084  free(Line);
1085  Line=NULL;
1086  return error;
1087 }
void GSM_TweakInternationalNumber(unsigned char *Number, const GSM_NumberType numType)
Definition: gsmpbk.c:620
char * DecodeUnicodeString(const unsigned char *src)
Definition: coding.c:245
unsigned char * VCALGetTextPart(unsigned char *Buff, int *pos)
Definition: gsmmisc.c:436
void CopyUnicodeString(unsigned char *Dest, const unsigned char *Source)
Definition: coding.c:1192
GSM_Error GSM_GetVCSLine(char **OutBuffer, char *Buffer, size_t *Pos, size_t MaxLen, gboolean MergeLines)
Definition: coding.c:1656
GSM_MemoryType MemoryType
Definition: gammu-memory.h:415
GSM_EntryLocation
Definition: gammu-memory.h:348
GSM_Error
Definition: gammu-error.h:23
GSM_BinaryPicture_Types Type
Definition: gammu-bitmap.h:44
unsigned char * Buffer
Definition: gammu-bitmap.h:45
size_t UnicodeLength(const unsigned char *str)
Definition: coding.c:186
#define CHECK_NUM_ENTRIES
Definition: gsmpbk.c:669
GSM_BinaryPicture Picture
Definition: gammu-memory.h:403
GSM_EntryType EntryType
Definition: gammu-memory.h:372
gboolean ReadVCALDateTime(const char *Buffer, GSM_DateTime *dt)
Definition: gsmmisc.c:254
unsigned char Text[(GSM_PHONEBOOK_TEXT_LENGTH+1) *2]
Definition: gammu-memory.h:399
GSM_DateTime Date
Definition: gammu-memory.h:380
gboolean ReadVCALText(char *Buffer, const char *Start, unsigned char *Value, const gboolean UTF8, GSM_EntryLocation *location)
Definition: gsmmisc.c:468
#define dbgprintf
Definition: debug.h:72
GSM_EntryLocation Location
Definition: gammu-memory.h:376
#define TRUE
Definition: gammu-types.h:28
GSM_MemoryType GSM_StringToMemoryType(const char *s)
Definition: gsmpbk.c:16
int DecodeBASE64(const char *Input, unsigned char *Output, const size_t Length)
Definition: coding.c:2149
GSM_SubMemoryEntry Entries[GSM_PHONEBOOK_ENTRIES]
Definition: gammu-memory.h:427

§ GSM_DeleteAllMemory()

GSM_Error GSM_DeleteAllMemory ( GSM_StateMachine s,
GSM_MemoryType  MemoryType 
)

Deletes all memory (phonebooks or calls) entries of specified type.

Parameters
sState machine pointer.
MemoryTypeWhere to delete all entries.
Returns
Error code.

Deletes all memory (phonebooks or calls) entries of specified type.

Definition at line 589 of file api.c.

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

590 {
591  GSM_Error err;
592 
594 
595  err = s->Phone.Functions->DeleteAllMemory(s, MemoryType);
596  PRINT_LOG_ERROR(err);
597  return err;
598 }
GSM_Error
Definition: gammu-error.h:23
GSM_Error(* DeleteAllMemory)(GSM_StateMachine *s, GSM_MemoryType MemoryType)
Definition: gsmstate.h:917
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_DeleteMemory()

GSM_Error GSM_DeleteMemory ( GSM_StateMachine s,
GSM_MemoryEntry entry 
)

Deletes memory (phonebooks or calls) entry.

Parameters
sState machine pointer.
entryEntry to delete, Location and MemoryType has to be set.
Returns
Error code.

Deletes memory (phonebooks or calls) entry.

Definition at line 575 of file api.c.

References CHECK_PHONE_CONNECTION, GSM_Phone_Functions::DeleteMemory, GSM_Phone::Functions, _GSM_StateMachine::Phone, PRINT_LOG_ERROR, PRINT_MEMORY_INFO, and RUN_RESTARTABLE.

576 {
577  GSM_Error err;
578 
581 
582  RUN_RESTARTABLE(err, s->Phone.Functions->DeleteMemory(s, entry));
583  PRINT_LOG_ERROR(err);
584  return err;
585 }
GSM_Error(* DeleteMemory)(GSM_StateMachine *s, GSM_MemoryEntry *entry)
Definition: gsmstate.h:913
GSM_Error
Definition: gammu-error.h:23
#define PRINT_MEMORY_INFO()
Definition: api.c:15
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 RUN_RESTARTABLE(return_value, function_call)
Definition: api.c:56

§ GSM_EncodeVCARD()

GSM_Error GSM_EncodeVCARD ( GSM_Debug_Info di,
char *  Buffer,
const size_t  buff_len,
size_t *  Pos,
GSM_MemoryEntry pbk,
const gboolean  header,
const GSM_VCardVersion  Version 
)

Encodes memory entry to vCard.

Parameters
diPointer to debugging description.
[out]BufferBuffer to store vCard text.
[in]buff_lenSize of output buffer.
[in,out]PosPosition in output buffer.
[in,out]pbkPhonebook data, AddError will be set on non converted entries.
[in]headerWhether to include vCard header in output.
[in]VersionWhat vCard version to create.
Returns
Error code.

Definition at line 126 of file gsmpbk.c.

References GSM_SubMemoryEntry::AddError, GSM_BinaryPicture::Buffer, CopyUnicodeString(), GSM_SubMemoryEntry::Date, DecodeUnicodeString(), GSM_MemoryEntry::Entries, GSM_MemoryEntry::EntriesNum, GSM_SubMemoryEntry::EntryType, ERR_NONE, ERR_NOTSUPPORTED, FALSE, GSM_MemoryTypeToString, GSM_PhonebookFindDefaultNameNumberGroup(), GSM_BinaryPicture::Length, GSM_SubMemoryEntry::Location, GSM_MemoryEntry::Location, GSM_MemoryEntry::MemoryType, Nokia_VCard10, Nokia_VCard21, GSM_SubMemoryEntry::Number, PBK_Caller_Group, PBK_CallLength, PBK_Category, PBK_Date, PBK_LastModified, PBK_Location_Home, PBK_Location_Unknown, PBK_Location_Work, PBK_Number_Fax, PBK_Number_General, PBK_Number_Messaging, PBK_Number_Mobile, PBK_Number_Other, PBK_Number_Pager, PBK_Number_Video, PBK_Photo, PBK_PictureID, PBK_Private, PBK_PushToTalkID, PBK_RingtoneID, PBK_Text_City, PBK_Text_Company, PBK_Text_Country, PBK_Text_Custom1, PBK_Text_Custom2, PBK_Text_Custom3, PBK_Text_Custom4, PBK_Text_DTMF, PBK_Text_Email, PBK_Text_Email2, PBK_Text_FirstName, PBK_Text_FormalName, PBK_Text_JobTitle, PBK_Text_LastName, PBK_Text_LUID, PBK_Text_Name, PBK_Text_NamePrefix, PBK_Text_NameSuffix, PBK_Text_NickName, PBK_Text_Note, PBK_Text_PictureName, PBK_Text_Postal, PBK_Text_SecondName, PBK_Text_SIP, PBK_Text_State, PBK_Text_StreetAddress, PBK_Text_SWIS, PBK_Text_URL, PBK_Text_UserID, PBK_Text_VOIP, PBK_Text_WVID, PBK_Text_Zip, GSM_SubMemoryEntry::Picture, PICTURE_BMP, PICTURE_GIF, PICTURE_ICN, PICTURE_JPG, PICTURE_PNG, smfprintf(), SonyEricsson_VCard10, SonyEricsson_VCard21, SonyEricsson_VCard21_Phone, GSM_SubMemoryEntry::Text, TRUE, GSM_BinaryPicture::Type, UnicodeLength(), VC_Store(), VC_StoreBase64(), VC_StoreDate(), VC_StoreDateTime(), VC_StoreLine(), and VC_StoreText().

Referenced by GSM_EncodeMultiPartSMS().

127 {
128  int Name, Number, Group, i;
129  int firstname = -1, secondname = -1, lastname = -1;
130  int address = -1, city = -1, state = -1, zip = -1, country = -1;
131  int workaddress = -1, workcity = -1, workstate = -1, workzip = -1, workcountry = -1;
132  unsigned char buffer[1024];
133  int pos;
134  gboolean ignore;
135  GSM_Error error;
136  GSM_BinaryPicture *bitmap;
137 
138  GSM_PhonebookFindDefaultNameNumberGroup(pbk, &Name, &Number, &Group);
139 
140  if (header) {
141  error = VC_StoreLine(Buffer, buff_len, Length, "BEGIN:VCARD");
142  if (error != ERR_NONE) return error;
143  }
144  if (Version == Nokia_VCard10 || Version == SonyEricsson_VCard10) {
145  if (Name != -1) {
146  error = VC_StoreLine(Buffer, buff_len, Length, "N:%s",
147  DecodeUnicodeString(pbk->Entries[Name].Text));
148  if (error != ERR_NONE) return error;
149  }
150  if (Number != -1) {
151  error = VC_StoreLine(Buffer, buff_len, Length, "TEL:%s",
152  DecodeUnicodeString(pbk->Entries[Number].Text));
153  if (error != ERR_NONE) return error;
154  }
155  } else if (Version == Nokia_VCard21 || Version == SonyEricsson_VCard21_Phone || Version == SonyEricsson_VCard21) {
156  if (header) {
157  error = VC_StoreLine(Buffer, buff_len, Length, "VERSION:2.1");
158  if (error != ERR_NONE) return error;
159  }
160 
161  if (Version != SonyEricsson_VCard21_Phone) {
162  error = VC_StoreLine(Buffer, buff_len, Length, "X-GAMMU-LOCATION:%d", pbk->Location);
163  if (error != ERR_NONE) return error;
164 
165  error = VC_StoreLine(Buffer, buff_len, Length, "X-GAMMU-MEMORY:%s", GSM_MemoryTypeToString(pbk->MemoryType));
166  if (error != ERR_NONE) return error;
167  }
168 
169  for (i=0; i < pbk->EntriesNum; i++) {
170  ignore = FALSE;
171  pbk->Entries[i].AddError = ERR_NONE;
172  switch(pbk->Entries[i].EntryType) {
173  case PBK_Text_Name:
174  error = VC_Store(Buffer, buff_len, Length, "N");
175  if (error != ERR_NONE) return error;
176  break;
177  case PBK_Text_NickName:
178  error = VC_Store(Buffer, buff_len, Length, "NICKNAME");
179  if (error != ERR_NONE) return error;
180  break;
181  case PBK_Text_FormalName:
182  error = VC_Store(Buffer, buff_len, Length, "FN");
183  if (error != ERR_NONE) return error;
184  break;
185  case PBK_Text_NamePrefix:
186  error = VC_Store(Buffer, buff_len, Length, "X-NAME-PREFIX");
187  if (error != ERR_NONE) return error;
188  break;
189  case PBK_Text_NameSuffix:
190  error = VC_Store(Buffer, buff_len, Length, "X-NAME-SUFFIX");
191  if (error != ERR_NONE) return error;
192  break;
193  case PBK_Text_FirstName:
194  firstname = i;
195  ignore = TRUE;
196  break;
197  case PBK_Text_SecondName:
198  secondname = i;
199  ignore = TRUE;
200  break;
201  case PBK_Text_LastName:
202  lastname = i;
203  ignore = TRUE;
204  break;
206  if (pbk->Entries[i].Location == PBK_Location_Work) {
207  workaddress = i;
208  } else {
209  address = i;
210  }
211  ignore = TRUE;
212  break;
213  case PBK_Text_City:
214  if (pbk->Entries[i].Location == PBK_Location_Work) {
215  workcity = i;
216  } else {
217  city = i;
218  }
219  ignore = TRUE;
220  break;
221  case PBK_Text_State:
222  if (pbk->Entries[i].Location == PBK_Location_Work) {
223  workstate = i;
224  } else {
225  state = i;
226  }
227  ignore = TRUE;
228  break;
229  case PBK_Text_Zip:
230  if (pbk->Entries[i].Location == PBK_Location_Work) {
231  workzip = i;
232  } else {
233  zip = i;
234  }
235  ignore = TRUE;
236  break;
237  case PBK_Text_Country:
238  if (pbk->Entries[i].Location == PBK_Location_Work) {
239  workcountry = i;
240  } else {
241  country = i;
242  }
243  ignore = TRUE;
244  break;
245  case PBK_Date:
246  error = VC_StoreDate(Buffer, buff_len, Length, &(pbk->Entries[i].Date), "BDAY");
247  if (error != ERR_NONE) return error;
248  ignore = TRUE;
249  break;
250  case PBK_LastModified:
251  error = VC_StoreDateTime(Buffer, buff_len, Length, &(pbk->Entries[i].Date), "LAST-MODIFIED");
252  if (error != ERR_NONE) return error;
253  ignore = TRUE;
254  break;
255  case PBK_Number_General:
256  case PBK_Number_Video:
257  case PBK_Number_Other:
258  case PBK_Number_Pager:
259  case PBK_Number_Mobile :
260  case PBK_Number_Fax :
261  case PBK_Number_Messaging :
262  if (UnicodeLength(pbk->Entries[i].Text) == 0) {
263  ignore = TRUE;
264  break;
265  }
266  error = VC_Store(Buffer, buff_len, Length, "TEL");
267  if (error != ERR_NONE) return error;
268 
269  if (Version != SonyEricsson_VCard21 && Number == i) {
270  error = VC_Store(Buffer, buff_len, Length, ";PREF");
271  if (error != ERR_NONE) return error;
272  }
273  switch (pbk->Entries[i].Location) {
274  case PBK_Location_Home:
275  error = VC_Store(Buffer, buff_len, Length, ";HOME");
276  if (error != ERR_NONE) return error;
277  break;
278  case PBK_Location_Work:
279  error = VC_Store(Buffer, buff_len, Length, ";WORK");
280  if (error != ERR_NONE) return error;
281  break;
283  break;
284  }
285  switch (pbk->Entries[i].EntryType) {
286  case PBK_Number_Other:
287  error = VC_Store(Buffer, buff_len, Length, ";OTHER");
288  if (error != ERR_NONE) return error;
289  break;
290  case PBK_Number_Pager:
291  error = VC_Store(Buffer, buff_len, Length, ";PAGER");
292  if (error != ERR_NONE) return error;
293  break;
294  case PBK_Number_Mobile:
295  error = VC_Store(Buffer, buff_len, Length, ";CELL");
296  if (error != ERR_NONE) return error;
297  break;
298  case PBK_Number_Fax:
299  error = VC_Store(Buffer, buff_len, Length, ";FAX");
300  if (error != ERR_NONE) return error;
301  break;
303  error = VC_Store(Buffer, buff_len, Length, ";MSG");
304  if (error != ERR_NONE) return error;
305  break;
306  case PBK_Number_Video:
307  error = VC_Store(Buffer, buff_len, Length, ";VIDEO");
308  if (error != ERR_NONE) return error;
309  break;
310  default:
311  break;
312  }
313  break;
314  case PBK_Text_Note :
315  if (UnicodeLength(pbk->Entries[i].Text) == 0) {
316  ignore = TRUE;
317  break;
318  }
319  error = VC_Store(Buffer, buff_len, Length, "NOTE");
320  if (error != ERR_NONE) return error;
321  break;
322  case PBK_Text_Postal :
323  if (UnicodeLength(pbk->Entries[i].Text) == 0) {
324  ignore = TRUE;
325  break;
326  }
327  /* Don't ask why. Nokia phones save postal address
328  * double - once like LABEL, second like ADR
329  */
330  error = VC_StoreText(Buffer, buff_len, Length, pbk->Entries[i].Text, "LABEL", FALSE);
331  if (error != ERR_NONE) return error;
332  if (pbk->Entries[i].Location == PBK_Location_Work) {
333  error = VC_Store(Buffer, buff_len, Length, "ADR;WORK");
334  } else if (pbk->Entries[i].Location == PBK_Location_Home) {
335  error = VC_Store(Buffer, buff_len, Length, "ADR;HOME");
336  } else {
337  error = VC_Store(Buffer, buff_len, Length, "ADR");
338  }
339  if (error != ERR_NONE) return error;
340  break;
341  case PBK_Text_Email :
342  case PBK_Text_Email2 :
343  if (UnicodeLength(pbk->Entries[i].Text) == 0) {
344  ignore = TRUE;
345  break;
346  }
347  error = VC_Store(Buffer, buff_len, Length, "EMAIL");
348  if (error != ERR_NONE) return error;
349  break;
350  case PBK_Text_URL :
351  if (UnicodeLength(pbk->Entries[i].Text) == 0) {
352  ignore = TRUE;
353  break;
354  }
355  error = VC_Store(Buffer, buff_len, Length, "URL");
356  if (error != ERR_NONE) return error;
357  break;
358  case PBK_Text_LUID :
359  if (UnicodeLength(pbk->Entries[i].Text) == 0) {
360  ignore = TRUE;
361  break;
362  }
363  error = VC_Store(Buffer, buff_len, Length, "X-IRMC-LUID");
364  if (error != ERR_NONE) return error;
365  break;
366  case PBK_Text_VOIP :
367  if (UnicodeLength(pbk->Entries[i].Text) == 0) {
368  ignore = TRUE;
369  break;
370  }
371  error = VC_Store(Buffer, buff_len, Length, "X-SIP;VOIP");
372  if (error != ERR_NONE) return error;
373  break;
374  case PBK_Text_SWIS :
375  if (UnicodeLength(pbk->Entries[i].Text) == 0) {
376  ignore = TRUE;
377  break;
378  }
379  error = VC_Store(Buffer, buff_len, Length, "X-SIP;SWIS");
380  if (error != ERR_NONE) return error;
381  break;
382  case PBK_Text_WVID :
383  if (UnicodeLength(pbk->Entries[i].Text) == 0) {
384  ignore = TRUE;
385  break;
386  }
387  error = VC_Store(Buffer, buff_len, Length, "X-WV-ID");
388  if (error != ERR_NONE) return error;
389  break;
390  case PBK_Text_SIP :
391  if (UnicodeLength(pbk->Entries[i].Text) == 0) {
392  ignore = TRUE;
393  break;
394  }
395  error = VC_Store(Buffer, buff_len, Length, "X-SIP");
396  if (error != ERR_NONE) return error;
397  break;
398  case PBK_Text_DTMF :
399  if (UnicodeLength(pbk->Entries[i].Text) == 0) {
400  ignore = TRUE;
401  break;
402  }
403  error = VC_Store(Buffer, buff_len, Length, "X-DTMF");
404  if (error != ERR_NONE) return error;
405  break;
406  case PBK_PushToTalkID:
407  if (UnicodeLength(pbk->Entries[i].Text) == 0) {
408  ignore = TRUE;
409  break;
410  }
411  error = VC_Store(Buffer, buff_len, Length, "X-SIP;POC");
412  if (error != ERR_NONE) return error;
413  break;
414  case PBK_Text_JobTitle:
415  if (UnicodeLength(pbk->Entries[i].Text) == 0) {
416  ignore = TRUE;
417  break;
418  }
419  error = VC_Store(Buffer, buff_len, Length, "TITLE");
420  if (error != ERR_NONE) return error;
421  break;
422  case PBK_Text_Company:
423  if (UnicodeLength(pbk->Entries[i].Text) == 0) {
424  ignore = TRUE;
425  break;
426  }
427  error = VC_Store(Buffer, buff_len, Length, "ORG");
428  if (error != ERR_NONE) return error;
429  break;
430  case PBK_Photo:
431  bitmap = &(pbk->Entries[i].Picture);
432  error = VC_Store(Buffer, buff_len, Length, "PHOTO;TYPE=");
433  if (error != ERR_NONE) return error;
434  switch (bitmap->Type) {
435  case PICTURE_BMP:
436  error = VC_Store(Buffer, buff_len, Length, "BMP;");
437  break;
438  case PICTURE_GIF:
439  error = VC_Store(Buffer, buff_len, Length, "GIF;");
440  break;
441  case PICTURE_JPG:
442  error = VC_Store(Buffer, buff_len, Length, "JPEG;");
443  break;
444  case PICTURE_ICN:
445  error = VC_Store(Buffer, buff_len, Length, "ICO;");
446  break;
447  case PICTURE_PNG:
448  error = VC_Store(Buffer, buff_len, Length, "PNG;");
449  break;
450  default:
451  smfprintf(di, "Unknown picture format: %d\n", bitmap->Type);
452  error = VC_Store(Buffer, buff_len, Length, "UNKNOWN;");
453  break;
454  }
455  if (error != ERR_NONE) return error;
456  error = VC_Store(Buffer, buff_len, Length, "ENCODING=BASE64:");
457  if (error != ERR_NONE) return error;
458  error = VC_StoreBase64(Buffer, buff_len, Length, bitmap->Buffer, bitmap->Length);
459  if (error != ERR_NONE) return error;
460  ignore = TRUE;
461  break;
462  case PBK_Caller_Group:
463  error = VC_StoreLine(Buffer, buff_len, Length, "X-CALLER-GROUP:%d", pbk->Entries[i].Number);
464  if (error != ERR_NONE) return error;
465  ignore = TRUE;
466  break;
467  case PBK_Private:
468  error = VC_StoreLine(Buffer, buff_len, Length, "X-PRIVATE:%d", pbk->Entries[i].Number);
469  if (error != ERR_NONE) return error;
470  ignore = TRUE;
471  break;
472  /* Not supported fields */
473  case PBK_Category:
474  case PBK_RingtoneID:
475  case PBK_PictureID:
476  case PBK_Text_UserID:
477  case PBK_CallLength:
478  case PBK_Text_Custom1:
479  case PBK_Text_Custom2:
480  case PBK_Text_Custom3:
481  case PBK_Text_Custom4:
484  ignore = TRUE;
485  break;
486  }
487  if (!ignore) {
488  error = VC_StoreText(Buffer, buff_len, Length, pbk->Entries[i].Text, "", FALSE);
489  if (error != ERR_NONE) return error;
490  }
491  }
492  /* Save name if it is composed from parts */
493  if (firstname != -1 || secondname != -1 || lastname != -1) {
494  pos = 0;
495  if (lastname != -1) {
496  CopyUnicodeString(buffer + 2*pos, pbk->Entries[lastname].Text);
497  pos += UnicodeLength(pbk->Entries[lastname].Text);
498  }
499  buffer[2*pos] = 0;
500  buffer[2*pos + 1] = ';';
501  pos++;
502  if (firstname != -1) {
503  CopyUnicodeString(buffer + 2*pos, pbk->Entries[firstname].Text);
504  pos += UnicodeLength(pbk->Entries[firstname].Text);
505  }
506  if (secondname != -1) {
507  buffer[2*pos] = 0;
508  buffer[2*pos + 1] = ' ';
509  pos++;
510  CopyUnicodeString(buffer + 2*pos, pbk->Entries[secondname].Text);
511  pos += UnicodeLength(pbk->Entries[secondname].Text);
512  }
513  buffer[2*pos] = 0;
514  buffer[2*pos + 1] = 0;
515  error = VC_StoreText(Buffer, buff_len, Length, buffer, "N", FALSE);
516  if (error != ERR_NONE) return error;
517  }
518  /* Save workaddress if it is composed from parts */
519  if (workaddress != -1 || workcity != -1 || workstate != -1 || workzip != -1 || workcountry != -1) {
520  pos = 0;
521  buffer[2*pos] = 0;
522  buffer[2*pos + 1] = ';';
523  pos++;
524  buffer[2*pos] = 0;
525  buffer[2*pos + 1] = ';';
526  pos++;
527  if (workaddress != -1) {
528  CopyUnicodeString(buffer + 2*pos, pbk->Entries[workaddress].Text);
529  pos += UnicodeLength(pbk->Entries[workaddress].Text);
530  }
531  buffer[2*pos] = 0;
532  buffer[2*pos + 1] = ';';
533  pos++;
534  if (workcity != -1) {
535  CopyUnicodeString(buffer + 2*pos, pbk->Entries[workcity].Text);
536  pos += UnicodeLength(pbk->Entries[workcity].Text);
537  }
538  buffer[2*pos] = 0;
539  buffer[2*pos + 1] = ';';
540  pos++;
541  if (workstate != -1) {
542  CopyUnicodeString(buffer + 2*pos, pbk->Entries[workstate].Text);
543  pos += UnicodeLength(pbk->Entries[workstate].Text);
544  }
545  buffer[2*pos] = 0;
546  buffer[2*pos + 1] = ';';
547  pos++;
548  if (workzip != -1) {
549  CopyUnicodeString(buffer + 2*pos, pbk->Entries[workzip].Text);
550  pos += UnicodeLength(pbk->Entries[workzip].Text);
551  }
552  buffer[2*pos] = 0;
553  buffer[2*pos + 1] = ';';
554  pos++;
555  if (workcountry != -1) {
556  CopyUnicodeString(buffer + 2*pos, pbk->Entries[workcountry].Text);
557  pos += UnicodeLength(pbk->Entries[workcountry].Text);
558  }
559  buffer[2*pos] = 0;
560  buffer[2*pos + 1] = 0;
561  error = VC_StoreText(Buffer, buff_len, Length, buffer, "ADR;WORK", FALSE);
562  if (error != ERR_NONE) return error;
563  }
564  /* Save address if it is composed from parts */
565  if (address != -1 || city != -1 || state != -1 || zip != -1 || country != -1) {
566  pos = 0;
567  buffer[2*pos] = 0;
568  buffer[2*pos + 1] = ';';
569  pos++;
570  buffer[2*pos] = 0;
571  buffer[2*pos + 1] = ';';
572  pos++;
573  if (address != -1) {
574  CopyUnicodeString(buffer + 2*pos, pbk->Entries[address].Text);
575  pos += UnicodeLength(pbk->Entries[address].Text);
576  }
577  buffer[2*pos] = 0;
578  buffer[2*pos + 1] = ';';
579  pos++;
580  if (city != -1) {
581  CopyUnicodeString(buffer + 2*pos, pbk->Entries[city].Text);
582  pos += UnicodeLength(pbk->Entries[city].Text);
583  }
584  buffer[2*pos] = 0;
585  buffer[2*pos + 1] = ';';
586  pos++;
587  if (state != -1) {
588  CopyUnicodeString(buffer + 2*pos, pbk->Entries[state].Text);
589  pos += UnicodeLength(pbk->Entries[state].Text);
590  }
591  buffer[2*pos] = 0;
592  buffer[2*pos + 1] = ';';
593  pos++;
594  if (zip != -1) {
595  CopyUnicodeString(buffer + 2*pos, pbk->Entries[zip].Text);
596  pos += UnicodeLength(pbk->Entries[zip].Text);
597  }
598  buffer[2*pos] = 0;
599  buffer[2*pos + 1] = ';';
600  pos++;
601  if (country != -1) {
602  CopyUnicodeString(buffer + 2*pos, pbk->Entries[country].Text);
603  pos += UnicodeLength(pbk->Entries[country].Text);
604  }
605  buffer[2*pos] = 0;
606  buffer[2*pos + 1] = 0;
607  error = VC_StoreText(Buffer, buff_len, Length, buffer, "ADR;HOME", FALSE);
608  if (error != ERR_NONE) return error;
609  }
610  } else {
611  return ERR_NOTSUPPORTED;
612  }
613  if (header) {
614  error = VC_StoreLine(Buffer, buff_len, Length, "END:VCARD");
615  if (error != ERR_NONE) return error;
616  }
617  return ERR_NONE;
618 }
char * DecodeUnicodeString(const unsigned char *src)
Definition: coding.c:245
void GSM_PhonebookFindDefaultNameNumberGroup(const GSM_MemoryEntry *entry, int *Name, int *Number, int *Group)
Definition: gsmpbk.c:78
void CopyUnicodeString(unsigned char *Dest, const unsigned char *Source)
Definition: coding.c:1192
GSM_MemoryType MemoryType
Definition: gammu-memory.h:415
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_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_BinaryPicture_Types Type
Definition: gammu-bitmap.h:44
unsigned char * Buffer
Definition: gammu-bitmap.h:45
#define GSM_MemoryTypeToString(x)
Definition: gammu-memory.h:95
size_t UnicodeLength(const unsigned char *str)
Definition: coding.c:186
GSM_BinaryPicture Picture
Definition: gammu-memory.h:403
GSM_Error VC_StoreLine(char *Buffer, const size_t buff_len, size_t *Pos, const char *format,...)
Definition: gsmmisc.c:187
GSM_EntryType EntryType
Definition: gammu-memory.h:372
GSM_Error VC_Store(char *Buffer, const size_t buff_len, size_t *Pos, const char *format,...)
Definition: gsmmisc.c:208
unsigned char Text[(GSM_PHONEBOOK_TEXT_LENGTH+1) *2]
Definition: gammu-memory.h:399
int gboolean
Definition: gammu-types.h:23
#define FALSE
Definition: gammu-types.h:25
GSM_Error VC_StoreBase64(char *Buffer, const size_t buff_len, size_t *Pos, const unsigned char *data, const size_t length)
Definition: gsmmisc.c:392
GSM_DateTime Date
Definition: gammu-memory.h:380
GSM_EntryLocation Location
Definition: gammu-memory.h:376
int smfprintf(GSM_Debug_Info *d, const char *format,...)
Definition: debug.c:240
#define TRUE
Definition: gammu-types.h:28
GSM_Error VC_StoreDate(char *Buffer, const size_t buff_len, size_t *Pos, const GSM_DateTime *Date, const char *Start)
Definition: gsmmisc.c:240
GSM_SubMemoryEntry Entries[GSM_PHONEBOOK_ENTRIES]
Definition: gammu-memory.h:427

§ GSM_GetMemory()

GSM_Error GSM_GetMemory ( GSM_StateMachine s,
GSM_MemoryEntry entry 
)

Reads entry from memory (phonebooks or calls). Which entry should be read is defined in entry.

Parameters
sState machine pointer.
entryStorage for retrieved entry, MemoryType and Location has to be set.
Returns
Error code.

Reads entry from memory (phonebooks or calls). Which entry should be read is defined in entry.

Definition at line 517 of file api.c.

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

518 {
519  GSM_Error err;
520 
523 
524  err = s->Phone.Functions->GetMemory(s, entry);
525  PRINT_LOG_ERROR(err);
526  return err;
527 }
GSM_Error
Definition: gammu-error.h:23
#define PRINT_MEMORY_INFO()
Definition: api.c:15
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(* GetMemory)(GSM_StateMachine *s, GSM_MemoryEntry *entry)
Definition: gsmstate.h:896
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373

§ GSM_GetMemoryStatus()

GSM_Error GSM_GetMemoryStatus ( GSM_StateMachine s,
GSM_MemoryStatus status 
)

Gets memory (phonebooks or calls) status (eg. number of used and free entries).

Parameters
sState machine pointer.
statusStorage for status information, MemoryType has to be set.
Returns
Error code.

Gets memory (phonebooks or calls) status (eg. number of used and free entries).

Definition at line 503 of file api.c.

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

504 {
505  GSM_Error err;
506 
508 
509  err = s->Phone.Functions->GetMemoryStatus(s, status);
510  PRINT_LOG_ERROR(err);
511  return err;
512 }
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(* GetMemoryStatus)(GSM_StateMachine *s, GSM_MemoryStatus *status)
Definition: gsmstate.h:891

§ GSM_GetNextMemory()

GSM_Error GSM_GetNextMemory ( GSM_StateMachine s,
GSM_MemoryEntry entry,
gboolean  start 
)

Reads entry from memory (phonebooks or calls). Which entry should be read is defined in entry. This can be easily used for reading all entries.

Parameters
sState machine pointer.
entryStorage for retrieved entry. MemoryType has to be set for first call (with start set to TRUE), for subsequent calls Location has to stay intact from previous reading.
startWhether we should start from beginning.
Returns
Error code.

Reads entry from memory (phonebooks or calls). Which entry should be read is defined in entry. This can be easily used for reading all entries.

Definition at line 532 of file api.c.

References CHECK_PHONE_CONNECTION, GSM_Phone::Functions, GSM_Phone_Functions::GetNextMemory, _GSM_StateMachine::Phone, PRINT_LOG_ERROR, PRINT_MEMORY_INFO, and PRINT_START.

533 {
534  GSM_Error err;
535 
537  PRINT_START();
539 
540  err = s->Phone.Functions->GetNextMemory(s, entry, start);
541  PRINT_LOG_ERROR(err);
542  return err;
543 }
GSM_Error
Definition: gammu-error.h:23
#define PRINT_START()
Definition: api.c:21
GSM_Error(* GetNextMemory)(GSM_StateMachine *s, GSM_MemoryEntry *entry, gboolean start)
Definition: gsmstate.h:901
#define PRINT_MEMORY_INFO()
Definition: api.c:15
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_GetSpeedDial()

GSM_Error GSM_GetSpeedDial ( GSM_StateMachine s,
GSM_SpeedDial Speed 
)

Gets speed dial.

Parameters
sState machine pointer.
SpeedStorage for speed dial, Location has to be set.
Returns
Error code.

Gets speed dial.

Definition at line 602 of file api.c.

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

603 {
604  GSM_Error err;
605 
607 
608  err = s->Phone.Functions->GetSpeedDial(s, Speed);
609  PRINT_LOG_ERROR(err);
610  return err;
611 }
GSM_Error
Definition: gammu-error.h:23
GSM_Error(* GetSpeedDial)(GSM_StateMachine *s, GSM_SpeedDial *Speed)
Definition: gsmstate.h:921
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_PhonebookFindDefaultNameNumberGroup()

void GSM_PhonebookFindDefaultNameNumberGroup ( const GSM_MemoryEntry entry,
int *  Name,
int *  Number,
int *  Group 
)

Finds default name, number and group for entry.

Parameters
entryEntry to process.
NameOutput index of name.
NumberOutput index of number.
GroupOutput index of group.

Definition at line 78 of file gsmpbk.c.

References GSM_MemoryEntry::Entries, GSM_MemoryEntry::EntriesNum, GSM_SubMemoryEntry::EntryType, PBK_Caller_Group, PBK_Number_Fax, PBK_Number_General, PBK_Number_Mobile, PBK_Number_Other, PBK_Number_Pager, PBK_Text_FirstName, PBK_Text_LastName, and PBK_Text_Name.

Referenced by GSM_EncodeVCARD().

79 {
80  int i;
81 
82  *Name = -1;
83  *Number = -1;
84  *Group = -1;
85  for (i = 0; i < entry->EntriesNum; i++) {
86  switch (entry->Entries[i].EntryType) {
87  case PBK_Number_General : if (*Number == -1) *Number = i; break;
88  case PBK_Text_Name : if (*Name == -1) *Name = i; break;
89  case PBK_Caller_Group : if (*Group == -1) *Group = i; break;
90  default : break;
91  }
92  }
93  if ((*Number) == -1) {
94  for (i = 0; i < entry->EntriesNum; i++) {
95  switch (entry->Entries[i].EntryType) {
96  case PBK_Number_Mobile:
97  case PBK_Number_General:
98  case PBK_Number_Fax:
99  case PBK_Number_Pager:
100  case PBK_Number_Other:
101  *Number = i;
102  break;
103  default:
104  break;
105  }
106  if (*Number != -1) break;
107  }
108  }
109  if ((*Name) == -1) {
110  for (i = 0; i < entry->EntriesNum; i++) {
111  if (entry->Entries[i].EntryType != PBK_Text_LastName) continue;
112  *Name = i;
113  break;
114  }
115  }
116  if ((*Name) == -1) {
117  for (i = 0; i < entry->EntriesNum; i++) {
118  if (entry->Entries[i].EntryType != PBK_Text_FirstName) continue;
119  *Name = i;
120  break;
121  }
122  }
123 }
GSM_EntryType EntryType
Definition: gammu-memory.h:372
GSM_SubMemoryEntry Entries[GSM_PHONEBOOK_ENTRIES]
Definition: gammu-memory.h:427

§ GSM_PhonebookGetEntryName()

unsigned char* GSM_PhonebookGetEntryName ( const GSM_MemoryEntry entry)

Returns name of entry. It might be possibly concatenated from first and last names.

Parameters
entryEntry to process.
Returns
Static unicode string containing name.

Definition at line 33 of file gsmpbk.c.

References CopyUnicodeString(), GSM_MemoryEntry::Entries, GSM_MemoryEntry::EntriesNum, GSM_SubMemoryEntry::EntryType, GSM_PHONEBOOK_TEXT_LENGTH, PBK_Text_FirstName, PBK_Text_LastName, PBK_Text_Name, GSM_SubMemoryEntry::Text, and UnicodeLength().

34 {
35  /* We possibly store here "LastName, FirstName" so allocate enough memory */
36  static char dest[(GSM_PHONEBOOK_TEXT_LENGTH*2+2+1)*2];
37  static char split[] = { '\0', ',', '\0', ' ', '\0', '\0'};
38  int i;
39  int first = -1, last = -1, name = -1;
40  int len = 0;
41 
42  for (i = 0; i < entry->EntriesNum; i++) {
43  switch (entry->Entries[i].EntryType) {
44  case PBK_Text_LastName:
45  last = i;
46  break;
47  case PBK_Text_FirstName:
48  first = i;
49  break;
50  case PBK_Text_Name:
51  name = i;
52  break;
53  default:
54  break;
55  }
56  }
57 
58  if (name != -1) {
59  CopyUnicodeString(dest, entry->Entries[name].Text);
60  } else {
61  if (last != -1 && first != -1) {
62  len = UnicodeLength(entry->Entries[last].Text);
63  CopyUnicodeString(dest, entry->Entries[last].Text);
64  CopyUnicodeString(dest + 2*len, split);
65  CopyUnicodeString(dest + 2*len + 4, entry->Entries[first].Text);
66  } else if (last != -1) {
67  CopyUnicodeString(dest, entry->Entries[last].Text);
68  } else if (first != -1) {
69  CopyUnicodeString(dest, entry->Entries[first].Text);
70  } else {
71  return NULL;
72  }
73  }
74 
75  return dest;
76 }
void CopyUnicodeString(unsigned char *Dest, const unsigned char *Source)
Definition: coding.c:1192
#define GSM_PHONEBOOK_TEXT_LENGTH
Definition: gammu-limits.h:91
size_t UnicodeLength(const unsigned char *str)
Definition: coding.c:186
GSM_EntryType EntryType
Definition: gammu-memory.h:372
unsigned char Text[(GSM_PHONEBOOK_TEXT_LENGTH+1) *2]
Definition: gammu-memory.h:399
GSM_SubMemoryEntry Entries[GSM_PHONEBOOK_ENTRIES]
Definition: gammu-memory.h:427

§ GSM_SetMemory()

GSM_Error GSM_SetMemory ( GSM_StateMachine s,
GSM_MemoryEntry entry 
)

Sets memory (phonebooks or calls) entry.

Parameters
sState machine pointer.
entryEntry to set, Location and MemoryType has to be set.
Returns
Error code.

Sets memory (phonebooks or calls) entry.

Definition at line 547 of file api.c.

References CHECK_PHONE_CONNECTION, GSM_Phone::Functions, _GSM_StateMachine::Phone, PRINT_LOG_ERROR, PRINT_MEMORY_INFO, RUN_RESTARTABLE, and GSM_Phone_Functions::SetMemory.

548 {
549  GSM_Error err;
550 
553 
554  RUN_RESTARTABLE(err, s->Phone.Functions->SetMemory(s, entry));
555  PRINT_LOG_ERROR(err);
556  return err;
557 }
GSM_Error
Definition: gammu-error.h:23
#define PRINT_MEMORY_INFO()
Definition: api.c:15
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(* SetMemory)(GSM_StateMachine *s, GSM_MemoryEntry *entry)
Definition: gsmstate.h:905
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373
#define RUN_RESTARTABLE(return_value, function_call)
Definition: api.c:56

§ GSM_SetSpeedDial()

GSM_Error GSM_SetSpeedDial ( GSM_StateMachine s,
GSM_SpeedDial Speed 
)

Sets speed dial.

Parameters
sState machine pointer.
SpeedSspeed dial to set.
Returns
Error code.

Sets speed dial.

Definition at line 615 of file api.c.

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

616 {
617  GSM_Error err;
618 
620 
621  err = s->Phone.Functions->SetSpeedDial(s, Speed);
622  PRINT_LOG_ERROR(err);
623  return err;
624 }
GSM_Error(* SetSpeedDial)(GSM_StateMachine *s, GSM_SpeedDial *Speed)
Definition: gsmstate.h:925
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