Translated using Weblate.
[gammu.git] / include / gammu-memory.h
blob565875c7a6bf6d0ae21d34b3720f1757ece67492
1 /**
2 * \file gammu-memory.h
3 * \author Michal Čihař
5 * Memory data and functions.
6 */
7 #ifndef __gammu_memory_h
8 #define __gammu_memory_h
10 /**
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>
20 /**
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.
25 * \ingroup Memory
27 typedef enum {
28 /**
29 * Internal memory of the mobile equipment
31 MEM_ME = 1,
32 /**
33 * SIM card memory
35 MEM_SM,
36 /**
37 * Own numbers
39 MEM_ON,
40 /**
41 * Dialled calls
43 MEM_DC,
44 /**
45 * Received calls
47 MEM_RC,
48 /**
49 * Missed calls
51 MEM_MC,
52 /**
53 * Combined ME and SIM phonebook
55 MEM_MT,
56 /**
57 * Fixed dial
59 MEM_FD,
61 /**
62 * Voice mailbox
64 MEM_VM,
66 /**
67 * Sent SMS logs
69 MEM_SL,
71 /**
72 * Quick dialing choices.
74 MEM_QD
75 } GSM_MemoryType;
77 /**
78 * Returns string representation of a memory type.
80 * \param x Memory type to convert
82 * \return Static string.
84 * \ingroup Memory
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")))))))))))
99 /**
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
110 * memory.
112 * \ingroup Memory
114 typedef struct {
116 * Number of used entries
118 int MemoryUsed;
120 * Memory type
122 GSM_MemoryType MemoryType;
124 * Number of free entries
126 int MemoryFree;
127 } GSM_MemoryStatus;
130 * Type of specific phonebook entry. In parenthesis is specified in which
131 * member of @ref GSM_SubMemoryEntry value is stored.
133 * \ingroup Memory
135 typedef enum {
137 * General number. (Text)
139 PBK_Number_General = 1,
141 * Mobile number. (Text)
143 PBK_Number_Mobile,
145 * Fax number. (Text)
147 PBK_Number_Fax,
149 * Pager number. (Text)
151 PBK_Number_Pager,
153 * Other number. (Text)
155 PBK_Number_Other,
157 * Note. (Text)
159 PBK_Text_Note,
161 * Complete postal address. (Text)
163 PBK_Text_Postal,
165 * Email. (Text)
167 PBK_Text_Email,
169 * Second email. (Text)
171 PBK_Text_Email2,
173 * URL (Text)
175 PBK_Text_URL,
177 * Date and time of last call. (Date)
179 PBK_Date,
181 * Caller group. (Number)
183 PBK_Caller_Group,
185 * Name (Text)
187 PBK_Text_Name,
189 * Last name. (Text)
191 PBK_Text_LastName,
193 * First name. (Text)
195 PBK_Text_FirstName,
197 * Company. (Text)
199 PBK_Text_Company,
201 * Job title. (Text)
203 PBK_Text_JobTitle,
205 * Category. (Number, if -1 then text)
207 PBK_Category,
209 * Whether entry is private. (Number)
211 PBK_Private,
213 * Street address. (Text)
215 PBK_Text_StreetAddress,
217 * City. (Text)
219 PBK_Text_City,
221 * State. (Text)
223 PBK_Text_State,
225 * Zip code. (Text)
227 PBK_Text_Zip,
229 * Country. (Text)
231 PBK_Text_Country,
233 * Custom information 1. (Text)
235 PBK_Text_Custom1,
237 * Custom information 2. (Text)
239 PBK_Text_Custom2,
241 * Custom information 3. (Text)
243 PBK_Text_Custom3,
245 * Custom information 4. (Text)
247 PBK_Text_Custom4,
249 * Ringtone ID. (Number)
251 PBK_RingtoneID,
253 * Picture ID. (Number)
255 PBK_PictureID,
257 * User ID. (Text)
259 PBK_Text_UserID,
261 * Length of call (Number)
263 PBK_CallLength,
265 * LUID - Unique Identifier used for synchronisation (Text)
267 PBK_Text_LUID,
269 * Date of last modification (Date)
271 PBK_LastModified,
273 * Nick name (Text)
275 PBK_Text_NickName,
277 * Formal name (Text)
279 PBK_Text_FormalName,
281 * Picture name (on phone filesystem). (Text)
283 PBK_Text_PictureName,
285 * Push-to-talk ID (Text)
287 PBK_PushToTalkID,
289 * Favorite messaging number. (Text)
291 PBK_Number_Messaging,
293 * Photo (Picture).
295 PBK_Photo,
297 * Second name. (Text)
299 PBK_Text_SecondName,
301 * VOIP address (Text).
303 PBK_Text_VOIP,
305 * SIP address (Text).
307 PBK_Text_SIP,
309 * DTMF (Text).
311 PBK_Text_DTMF,
313 * Video number. (Text)
315 PBK_Number_Video,
317 * See What I See address. (Text)
319 PBK_Text_SWIS,
321 * Wireless Village user ID. (Text)
323 PBK_Text_WVID,
325 * Name prefix (Text)
327 PBK_Text_NamePrefix,
329 * Name suffix (Text)
331 PBK_Text_NameSuffix,
332 } GSM_EntryType;
335 * Location of memory contact.
337 * \ingroup Memory
339 typedef enum {
341 * No/Unknown location.
343 PBK_Location_Unknown = 0,
345 * Home
347 PBK_Location_Home,
349 * Work
351 PBK_Location_Work,
352 } GSM_EntryLocation;
355 * One value of phonebook memory entry.
357 * \ingroup Memory
359 typedef struct {
361 * Type of entry.
363 GSM_EntryType EntryType;
365 * Location for the entry.
367 GSM_EntryLocation Location;
369 * Text of entry (if applicable, see @ref GSM_EntryType).
371 GSM_DateTime Date;
373 * Number of entry (if applicable, see @ref GSM_EntryType).
375 int Number;
377 * Voice dialling tag.
379 int VoiceTag;
380 int SMSList[20];
381 int CallLength;
384 * During adding SubEntry Gammu can return here info, if it was done OK
386 GSM_Error AddError;
388 * Text of entry (if applicable, see @ref GSM_EntryType).
390 unsigned char Text[(GSM_PHONEBOOK_TEXT_LENGTH + 1) * 2];
392 * Picture data.
394 GSM_BinaryPicture Picture;
395 } GSM_SubMemoryEntry;
398 * Structure for saving phonebook entries.
400 * \ingroup Memory
402 typedef struct {
404 * Used memory for phonebook entry
406 GSM_MemoryType MemoryType;
408 * Used location for phonebook entry
410 int Location;
412 * Number of SubEntries in Entries table.
414 int EntriesNum;
416 * Values of SubEntries.
418 GSM_SubMemoryEntry Entries[GSM_PHONEBOOK_ENTRIES];
419 } GSM_MemoryEntry;
422 * Structure for saving speed dials.
424 * \ingroup Memory
426 typedef struct {
428 * Number of speed dial: 2,3..,8,9
430 int Location;
432 * ID of phone number used in phonebook entry
434 int MemoryNumberID;
436 * Memory, where is saved used phonebook entry
438 GSM_MemoryType MemoryType;
440 * Location in memory, where is saved used phonebook entry
442 int MemoryLocation;
443 } GSM_SpeedDial;
446 * Gets memory (phonebooks or calls) status (eg. number of used and
447 * free entries).
449 * \param s State machine pointer.
450 * \param status Storage for status information, MemoryType has to be
451 * set.
453 * \return Error code.
455 * \ingroup Memory
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
465 * to be set.
467 * \return Error code.
469 * \ingroup Memory
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.
485 * \ingroup Memory
487 GSM_Error GSM_GetNextMemory(GSM_StateMachine * s, GSM_MemoryEntry * entry,
488 gboolean start);
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.
498 * \ingroup Memory
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
507 * set.
509 * \return Error code.
511 * \ingroup Memory
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.
523 * \ingroup Memory
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.
535 * \ingroup Memory
537 GSM_Error GSM_DeleteAllMemory(GSM_StateMachine * s, GSM_MemoryType MemoryType);
540 * Gets speed dial.
542 * \param s State machine pointer.
543 * \param Speed Storage for speed dial, Location has to be set.
545 * \return Error code.
547 * \ingroup Memory
549 GSM_Error GSM_GetSpeedDial(GSM_StateMachine * s, GSM_SpeedDial * Speed);
552 * Sets speed dial.
554 * \param s State machine pointer.
555 * \param Speed Sspeed dial to set.
557 * \return Error code.
559 * \ingroup Memory
561 GSM_Error GSM_SetSpeedDial(GSM_StateMachine * s, GSM_SpeedDial * Speed);
564 * Returns name of entry. It might be possibly concatenated from first
565 * and last names.
567 * \param entry Entry to process.
569 * \return Static unicode string containing name.
571 * \ingroup Memory
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.
583 * \ingroup Memory
585 void GSM_PhonebookFindDefaultNameNumberGroup(const GSM_MemoryEntry * entry,
586 int *Name, int *Number,
587 int *Group);
589 * Types of vCard.
591 * \ingroup Memory
593 typedef enum {
595 * vCard 1.0 hacked for Nokia.
597 Nokia_VCard10 = 1,
599 * vCard 2.1 hacked for Nokia.
601 Nokia_VCard21,
603 * vCard 1.0 hacked for Sony-Ericsson (should be standard
604 * vCard).
606 SonyEricsson_VCard10,
608 * vCard 2.1 hacked for Sony-Ericsson (should be standard
609 * vCard).
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,
617 } GSM_VCardVersion;
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
627 * converted entries.
628 * \param[in] header Whether to include vCard header in output.
629 * \param[in] Version What vCard version to create.
631 * \return Error code.
633 * \ingroup Memory
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.
651 * \ingroup Memory
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
659 * entry structure.
661 * \param[in] Entry Pointer to memory entry to process.
663 void GSM_FreeMemoryEntry(GSM_MemoryEntry * Entry);
664 #endif
666 /* Editor configuration
667 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72: