From 86c7ff07f100489d085efd6541b8c104a44209e0 Mon Sep 17 00:00:00 2001 From: laforge Date: Fri, 17 Aug 2007 08:32:14 +0000 Subject: From: Andrzej Zaborowski Date: Tue, 31 Jul 2007 22:26:36 +0200 Subject: [PATCH] Operations on the preferred operators list. This makes use of the AT+CPOL variants to add / delete / list entries in the preferred operators list on the SIM. There's some inconsistency, similarly as with operator selection, in that we return operator names in long alphanumeric format but we take only operators in numeric format as parameters. Either the client will have to convert between the formats or we should always use for example the long alphanumeric format, or maybe do something else. git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@2725 99fdad57-331a-0410-800a-d7fa5415bdb3 --- src/libgsmd/libgsmd_network.c | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'src/libgsmd') diff --git a/src/libgsmd/libgsmd_network.c b/src/libgsmd/libgsmd_network.c index 9a21fb5..0b458de 100644 --- a/src/libgsmd/libgsmd_network.c +++ b/src/libgsmd/libgsmd_network.c @@ -78,3 +78,53 @@ int lgsm_signal_quality(struct lgsm_handle *lh) { return lgsm_send_simple(lh, GSMD_MSG_NETWORK, GSMD_NETWORK_SIGQ_GET); } + +int lgsm_prefoper_list(struct lgsm_handle *lh) +{ + return lgsm_send_simple(lh, GSMD_MSG_NETWORK, GSMD_NETWORK_PREF_LIST); +} + +int lgsm_prefoper_delete(struct lgsm_handle *lh, int index) +{ + struct gsmd_msg_hdr *gmh; + + gmh = lgsm_gmh_fill(GSMD_MSG_NETWORK, GSMD_NETWORK_PREF_DEL, + sizeof(int)); + if (!gmh) + return -ENOMEM; + + memcpy(gmh->data, &index, sizeof(int)); + + if (lgsm_send(lh, gmh) < gmh->len + sizeof(*gmh)) { + lgsm_gmh_free(gmh); + return -EIO; + } + + lgsm_gmh_free(gmh); + return 0; +} + +int lgsm_prefoper_add(struct lgsm_handle *lh, gsmd_oper_numeric oper) +{ + struct gsmd_msg_hdr *gmh; + + gmh = lgsm_gmh_fill(GSMD_MSG_NETWORK, GSMD_NETWORK_PREF_ADD, + sizeof(gsmd_oper_numeric)); + if (!gmh) + return -ENOMEM; + + memcpy(gmh->data, oper, sizeof(gsmd_oper_numeric)); + + if (lgsm_send(lh, gmh) < gmh->len + sizeof(*gmh)) { + lgsm_gmh_free(gmh); + return -EIO; + } + + lgsm_gmh_free(gmh); + return 0; +} + +int lgsm_prefoper_get_space(struct lgsm_handle *lh) +{ + return lgsm_send_simple(lh, GSMD_MSG_NETWORK, GSMD_NETWORK_PREF_SPACE); +} -- cgit v1.2.3