diff options
author | laforge <laforge@99fdad57-331a-0410-800a-d7fa5415bdb3> | 2007-08-17 08:32:50 +0000 |
---|---|---|
committer | laforge <laforge@99fdad57-331a-0410-800a-d7fa5415bdb3> | 2007-08-17 08:32:50 +0000 |
commit | c5eec553984f937b1f1682378ab7096b7f6b3933 (patch) | |
tree | 16c7413845e962384ef49191689f9a06567e33cd /src/libgsmd | |
parent | 86c7ff07f100489d085efd6541b8c104a44209e0 (diff) |
SIM Phonebook access implementation.
This patch adds primitive-but-working support for SIM phonebook access,
including phonebook memory storage and entry read/write/delete. Also,
libgsmd-tools shell is modified to perform listing actions.
API changes:
lgsm_pb_read_entryies -> lgsm_pb_read_entries
lgsm_pb_list_storage (new):
List of supported phonebook memory storage.
lgsm_pb_set_storage (new);
Select phonebook memory storage.
lgsmd_pb_del_entry -> lgsm_pb_del_entry
lgsmd_pb_write_entry -> lgsm_pb_write_entry
git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@2726 99fdad57-331a-0410-800a-d7fa5415bdb3
Diffstat (limited to 'src/libgsmd')
-rw-r--r-- | src/libgsmd/libgsmd_phonebook.c | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/src/libgsmd/libgsmd_phonebook.c b/src/libgsmd/libgsmd_phonebook.c index c569e02..671566b 100644 --- a/src/libgsmd/libgsmd_phonebook.c +++ b/src/libgsmd/libgsmd_phonebook.c @@ -11,6 +11,38 @@ #include "lgsm_internals.h" + +int lgsm_pb_list_storage(struct lgsm_handle *lh) +{ + return lgsm_send_simple(lh, GSMD_MSG_PHONEBOOK, + GSMD_PHONEBOOK_LIST_STORAGE); +} + +int lgsm_pb_set_storage(struct lgsm_handle *lh, char *storage) +{ + struct gsmd_msg_hdr *gmh; + int rc; + + gmh = lgsm_gmh_fill(GSMD_MSG_PHONEBOOK, + GSMD_PHONEBOOK_SET_STORAGE, 3); + + if (!gmh) + return -ENOMEM; + + strncpy((char*)gmh->data, storage, 2); + gmh->data[2] = '\0'; + + rc = lgsm_send(lh, gmh); + if (rc < gmh->len + 3) { + lgsm_gmh_free(gmh); + return -EIO; + } + + lgsm_gmh_free(gmh); + + return 0; +} + int lgsm_pb_find_entry(struct lgsm_handle *lh, const struct lgsm_phonebook_find *pb_find) { @@ -37,6 +69,7 @@ int lgsm_pb_find_entry(struct lgsm_handle *lh, return 0; } + int lgsm_pb_read_entry(struct lgsm_handle *lh, int index) { struct gsmd_msg_hdr *gmh; @@ -46,6 +79,7 @@ int lgsm_pb_read_entry(struct lgsm_handle *lh, int index) GSMD_PHONEBOOK_READ, sizeof(int)); if (!gmh) return -ENOMEM; + *(int *) gmh->data = index; rc = lgsm_send(lh, gmh); @@ -59,7 +93,7 @@ int lgsm_pb_read_entry(struct lgsm_handle *lh, int index) return 0; } -int lgsm_pb_read_entryies(struct lgsm_handle *lh, +int lgsm_pb_read_entries(struct lgsm_handle *lh, const struct lgsm_phonebook_readrg *pb_readrg) { struct gsmd_msg_hdr *gmh; @@ -85,7 +119,7 @@ int lgsm_pb_read_entryies(struct lgsm_handle *lh, return 0; } -int lgsmd_pb_del_entry(struct lgsm_handle *lh, int index) +int lgsm_pb_del_entry(struct lgsm_handle *lh, int index) { struct gsmd_msg_hdr *gmh; int rc; @@ -108,7 +142,7 @@ int lgsmd_pb_del_entry(struct lgsm_handle *lh, int index) return 0; } -int lgsmd_pb_write_entry(struct lgsm_handle *lh, +int lgsm_pb_write_entry(struct lgsm_handle *lh, const struct lgsm_phonebook *pb) { /* FIXME: only support alphabet now */ @@ -139,7 +173,6 @@ int lgsmd_pb_write_entry(struct lgsm_handle *lh, return 0; } - int lgsm_pb_get_support(struct lgsm_handle *lh) { return lgsm_send_simple(lh, GSMD_MSG_PHONEBOOK, GSMD_PHONEBOOK_GET_SUPPORT); |