From 5e988040575d346c4ca41061248e72d676467ed0 Mon Sep 17 00:00:00 2001 From: jserv Date: Wed, 17 Oct 2007 06:18:34 +0000 Subject: Improvement for find and read phonebooks in gsmd. From: Sean Chiang Subject: [PATCH] Improvement for find and read phonebooks in gsmd This patch is an improvement for find and read phonebooks. After clients make a request to find / read phonebooks, then clients should make a request to retrieve all the records. git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@3202 99fdad57-331a-0410-800a-d7fa5415bdb3 --- src/libgsmd/libgsmd_phonebook.c | 48 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) (limited to 'src/libgsmd') diff --git a/src/libgsmd/libgsmd_phonebook.c b/src/libgsmd/libgsmd_phonebook.c index 671566b..1f59e34 100644 --- a/src/libgsmd/libgsmd_phonebook.c +++ b/src/libgsmd/libgsmd_phonebook.c @@ -33,7 +33,7 @@ int lgsm_pb_set_storage(struct lgsm_handle *lh, char *storage) gmh->data[2] = '\0'; rc = lgsm_send(lh, gmh); - if (rc < gmh->len + 3) { + if (rc < gmh->len + sizeof(*gmh)) { lgsm_gmh_free(gmh); return -EIO; } @@ -177,3 +177,49 @@ int lgsm_pb_get_support(struct lgsm_handle *lh) { return lgsm_send_simple(lh, GSMD_MSG_PHONEBOOK, GSMD_PHONEBOOK_GET_SUPPORT); } + +int lgsm_pb_retrieve_readrg(struct lgsm_handle *lh, int num) +{ + struct gsmd_msg_hdr *gmh; + int rc; + + gmh = lgsm_gmh_fill(GSMD_MSG_PHONEBOOK, + GSMD_PHONEBOOK_RETRIEVE_READRG, sizeof(int)); + if (!gmh) + return -ENOMEM; + + *(int *)(gmh->data) = num; + + rc = lgsm_send(lh, gmh); + if (rc < gmh->len + sizeof(*gmh)) { + lgsm_gmh_free(gmh); + return -EIO; + } + + lgsm_gmh_free(gmh); + + return 0; +} + +int lgsm_pb_retrieve_find(struct lgsm_handle *lh, int num) +{ + struct gsmd_msg_hdr *gmh; + int rc; + + gmh = lgsm_gmh_fill(GSMD_MSG_PHONEBOOK, + GSMD_PHONEBOOK_RETRIEVE_FIND, sizeof(int)); + if (!gmh) + return -ENOMEM; + + *(int *)(gmh->data) = num; + + rc = lgsm_send(lh, gmh); + if (rc < gmh->len + sizeof(*gmh)) { + lgsm_gmh_free(gmh); + return -EIO; + } + + lgsm_gmh_free(gmh); + + return 0; +} -- cgit v1.2.3