5 * Memory data and functions.
7 #ifndef __gammu_memory_h
8 #define __gammu_memory_h
11 * \defgroup Memory Memory
12 * Memory entries manipulations.
15 #include <gammu-datetime.h>
16 #include <gammu-limits.h>
17 #include <gammu-bitmap.h>
18 #include <gammu-debug.h>
21 * Enum defines ID for various phone and SIM memories.
22 * Phone modules can translate them to values specific for concrete models.
23 * Two letter codes (excluding VM and SL) are from GSM 07.07.
29 * Internal memory of the mobile equipment
53 * Combined ME and SIM phonebook
72 * Quick dialing choices.
78 * Returns string representation of a memory type.
80 * \param x Memory type to convert
82 * \return Static string.
86 #define GSM_MemoryTypeToString(x) \
87 ((x) == MEM_ME ? "ME" : \
88 ((x) == MEM_SM ? "SM" : \
89 ((x) == MEM_ON ? "ON" : \
90 ((x) == MEM_DC ? "DC" : \
91 ((x) == MEM_RC ? "RC" : \
92 ((x) == MEM_MC ? "MC" : \
93 ((x) == MEM_MT ? "MT" : \
94 ((x) == MEM_FD ? "FD" : \
95 ((x) == MEM_VM ? "VM" : \
96 ((x) == MEM_QD ? "QD" : \
97 ((x) == MEM_SL ? "SL" : "XX")))))))))))
100 * Converts memory type from string.
102 * \param s String with memory type.
104 * \return Parsed memory type or 0 on failure.
106 GSM_MemoryType
GSM_StringToMemoryType(const char *s
);
109 * Structure contains info about number of used/free entries in phonebook
116 * Number of used entries
122 GSM_MemoryType MemoryType
;
124 * Number of free entries
130 * Type of specific phonebook entry. In parenthesis is specified in which
131 * member of @ref GSM_SubMemoryEntry value is stored.
137 * General number. (Text)
139 PBK_Number_General
= 1,
141 * Mobile number. (Text)
149 * Pager number. (Text)
153 * Other number. (Text)
161 * Complete postal address. (Text)
169 * Second email. (Text)
177 * Date and time of last call. (Date)
181 * Caller group. (Number)
205 * Category. (Number, if -1 then text)
209 * Whether entry is private. (Number)
213 * Street address. (Text)
215 PBK_Text_StreetAddress
,
233 * Custom information 1. (Text)
237 * Custom information 2. (Text)
241 * Custom information 3. (Text)
245 * Custom information 4. (Text)
249 * Ringtone ID. (Number)
253 * Picture ID. (Number)
261 * Length of call (Number)
265 * LUID - Unique Identifier used for synchronisation (Text)
269 * Date of last modification (Date)
281 * Picture name (on phone filesystem). (Text)
283 PBK_Text_PictureName
,
285 * Push-to-talk ID (Text)
289 * Favorite messaging number. (Text)
291 PBK_Number_Messaging
,
297 * Second name. (Text)
301 * VOIP address (Text).
305 * SIP address (Text).
313 * Video number. (Text)
317 * See What I See address. (Text)
321 * Wireless Village user ID. (Text)
335 * Location of memory contact.
341 * No/Unknown location.
343 PBK_Location_Unknown
= 0,
355 * One value of phonebook memory entry.
363 GSM_EntryType EntryType
;
365 * Location for the entry.
367 GSM_EntryLocation Location
;
369 * Text of entry (if applicable, see @ref GSM_EntryType).
373 * Number of entry (if applicable, see @ref GSM_EntryType).
377 * Voice dialling tag.
384 * During adding SubEntry Gammu can return here info, if it was done OK
388 * Text of entry (if applicable, see @ref GSM_EntryType).
390 unsigned char Text
[(GSM_PHONEBOOK_TEXT_LENGTH
+ 1) * 2];
394 GSM_BinaryPicture Picture
;
395 } GSM_SubMemoryEntry
;
398 * Structure for saving phonebook entries.
404 * Used memory for phonebook entry
406 GSM_MemoryType MemoryType
;
408 * Used location for phonebook entry
412 * Number of SubEntries in Entries table.
416 * Values of SubEntries.
418 GSM_SubMemoryEntry Entries
[GSM_PHONEBOOK_ENTRIES
];
422 * Structure for saving speed dials.
428 * Number of speed dial: 2,3..,8,9
432 * ID of phone number used in phonebook entry
436 * Memory, where is saved used phonebook entry
438 GSM_MemoryType MemoryType
;
440 * Location in memory, where is saved used phonebook entry
446 * Gets memory (phonebooks or calls) status (eg. number of used and
449 * \param s State machine pointer.
450 * \param status Storage for status information, MemoryType has to be
453 * \return Error code.
457 GSM_Error
GSM_GetMemoryStatus(GSM_StateMachine
* s
, GSM_MemoryStatus
* status
);
460 * Reads entry from memory (phonebooks or calls). Which entry should
461 * be read is defined in entry.
463 * \param s State machine pointer.
464 * \param entry Storage for retrieved entry, MemoryType and Location has
467 * \return Error code.
471 GSM_Error
GSM_GetMemory(GSM_StateMachine
* s
, GSM_MemoryEntry
* entry
);
474 * Reads entry from memory (phonebooks or calls). Which entry should
475 * be read is defined in entry. This can be easily used for reading all entries.
477 * \param s State machine pointer.
478 * \param entry Storage for retrieved entry. MemoryType has to be set
479 * for first call (with start set to TRUE), for subsequent calls
480 * Location has to stay intact from previous reading.
481 * \param start Whether we should start from beginning.
483 * \return Error code.
487 GSM_Error
GSM_GetNextMemory(GSM_StateMachine
* s
, GSM_MemoryEntry
* entry
,
491 * Sets memory (phonebooks or calls) entry.
493 * \param s State machine pointer.
494 * \param entry Entry to set, Location and MemoryType has to be set.
496 * \return Error code.
500 GSM_Error
GSM_SetMemory(GSM_StateMachine
* s
, GSM_MemoryEntry
* entry
);
503 * Adds memory (phonebooks or calls) entry.
505 * \param s State machine pointer.
506 * \param entry Entry to add, Location is ignored, MemoryType has to be
509 * \return Error code.
513 GSM_Error
GSM_AddMemory(GSM_StateMachine
* s
, GSM_MemoryEntry
* entry
);
516 * Deletes memory (phonebooks or calls) entry.
518 * \param s State machine pointer.
519 * \param entry Entry to delete, Location and MemoryType has to be set.
521 * \return Error code.
525 GSM_Error
GSM_DeleteMemory(GSM_StateMachine
* s
, GSM_MemoryEntry
* entry
);
528 * Deletes all memory (phonebooks or calls) entries of specified type.
530 * \param s State machine pointer.
531 * \param MemoryType Where to delete all entries.
533 * \return Error code.
537 GSM_Error
GSM_DeleteAllMemory(GSM_StateMachine
* s
, GSM_MemoryType MemoryType
);
542 * \param s State machine pointer.
543 * \param Speed Storage for speed dial, Location has to be set.
545 * \return Error code.
549 GSM_Error
GSM_GetSpeedDial(GSM_StateMachine
* s
, GSM_SpeedDial
* Speed
);
554 * \param s State machine pointer.
555 * \param Speed Sspeed dial to set.
557 * \return Error code.
561 GSM_Error
GSM_SetSpeedDial(GSM_StateMachine
* s
, GSM_SpeedDial
* Speed
);
564 * Returns name of entry. It might be possibly concatenated from first
567 * \param entry Entry to process.
569 * \return Static unicode string containing name.
573 unsigned char *GSM_PhonebookGetEntryName(const GSM_MemoryEntry
* entry
);
576 * Finds default name, number and group for entry.
578 * \param entry Entry to process.
579 * \param Name Output index of name.
580 * \param Number Output index of number.
581 * \param Group Output index of group.
585 void GSM_PhonebookFindDefaultNameNumberGroup(const GSM_MemoryEntry
* entry
,
586 int *Name
, int *Number
,
595 * vCard 1.0 hacked for Nokia.
599 * vCard 2.1 hacked for Nokia.
603 * vCard 1.0 hacked for Sony-Ericsson (should be standard
606 SonyEricsson_VCard10
,
608 * vCard 2.1 hacked for Sony-Ericsson (should be standard
611 SonyEricsson_VCard21
,
613 * vCard 2.1 hacked for Sony-Ericsson (should be standard
614 * vCard) from phone (no parsing of location and memory type).
616 SonyEricsson_VCard21_Phone
,
620 * Encodes memory entry to vCard.
622 * \param di Pointer to debugging description.
623 * \param[out] Buffer Buffer to store vCard text.
624 * \param[in] buff_len Size of output buffer.
625 * \param[in,out] Pos Position in output buffer.
626 * \param[in,out] pbk Phonebook data, AddError will be set on non
628 * \param[in] header Whether to include vCard header in output.
629 * \param[in] Version What vCard version to create.
631 * \return Error code.
635 GSM_Error
GSM_EncodeVCARD(GSM_Debug_Info
* di
, char *Buffer
,
636 const size_t buff_len
, size_t * Pos
,
637 GSM_MemoryEntry
* pbk
, const gboolean header
,
638 const GSM_VCardVersion Version
);
641 * Decodes memory entry from vCard.
643 * \param di Pointer to debugging description.
644 * \param[in] Buffer Buffer to readCard text.
645 * \param[in,out] Pos Position in output buffer.
646 * \param[out] Pbk Phonebook data read from vCard.
647 * \param[in] Version What vCard version to parse.
649 * \return Error code.
653 GSM_Error
GSM_DecodeVCARD(GSM_Debug_Info
* di
, char *Buffer
, size_t * Pos
,
654 GSM_MemoryEntry
* Pbk
,
655 const GSM_VCardVersion Version
);
658 * Frees any dynamically allocated memory inside memory
661 * \param[in] Entry Pointer to memory entry to process.
663 void GSM_FreeMemoryEntry(GSM_MemoryEntry
* Entry
);
666 /* Editor configuration
667 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72: