diff options
Diffstat (limited to 'meta/recipes-connectivity/gsm/files/028_shell-phonebook-find-and-read-range-support.patch')
-rw-r--r-- | meta/recipes-connectivity/gsm/files/028_shell-phonebook-find-and-read-range-support.patch | 264 |
1 files changed, 264 insertions, 0 deletions
diff --git a/meta/recipes-connectivity/gsm/files/028_shell-phonebook-find-and-read-range-support.patch b/meta/recipes-connectivity/gsm/files/028_shell-phonebook-find-and-read-range-support.patch new file mode 100644 index 0000000000..db07a5df35 --- /dev/null +++ b/meta/recipes-connectivity/gsm/files/028_shell-phonebook-find-and-read-range-support.patch | |||
@@ -0,0 +1,264 @@ | |||
1 | From: Sean Chiang <sean_chiang@openmoko.com> | ||
2 | Subject: [PATCH] improvement for find and read phonebooks in shell | ||
3 | |||
4 | This patch improves the functions to find and read phonebooks in shell. | ||
5 | |||
6 | Besides prr and pf, I add two new commands pRr and pRf to retrieve the | ||
7 | phonebook. | ||
8 | |||
9 | Signed-off-by: Jim Huang <jserv@openmoko.org> | ||
10 | |||
11 | Index: gsm/src/util/shell.c | ||
12 | =================================================================== | ||
13 | --- gsm.orig/src/util/shell.c 2007-09-17 23:57:51.000000000 +0800 | ||
14 | +++ gsm/src/util/shell.c 2007-09-17 23:59:04.000000000 +0800 | ||
15 | @@ -34,8 +34,6 @@ | ||
16 | #include <gsmd/usock.h> | ||
17 | #include <gsmd/ts0705.h> | ||
18 | |||
19 | -#include <common/linux_list.h> | ||
20 | - | ||
21 | #ifndef __GSMD__ | ||
22 | #define __GSMD__ | ||
23 | #include <gsmd/talloc.h> | ||
24 | @@ -43,9 +41,8 @@ | ||
25 | #endif | ||
26 | |||
27 | #define STDIN_BUF_SIZE 1024 | ||
28 | - | ||
29 | -static LLIST_HEAD(storage_list); | ||
30 | -static LLIST_HEAD(phonebook_list); | ||
31 | +static int nFIND = 0; | ||
32 | +static int nREADRG = 0; | ||
33 | |||
34 | /* this is the handler for receiving passthrough responses */ | ||
35 | static int pt_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh) | ||
36 | @@ -62,46 +59,23 @@ | ||
37 | struct gsmd_phonebook_storage *gpst; | ||
38 | char *payload; | ||
39 | char *fcomma, *lcomma, *ptr = NULL; | ||
40 | + int *num; | ||
41 | char buf[128]; | ||
42 | + int i; | ||
43 | |||
44 | switch (gmh->msg_subtype) { | ||
45 | -#if 0 | ||
46 | case GSMD_PHONEBOOK_FIND: | ||
47 | + num = (int *) ((char *)gmh + sizeof(*gmh)); | ||
48 | + printf("Records:%d\n", *num); | ||
49 | + | ||
50 | + nFIND = *num; | ||
51 | + break; | ||
52 | case GSMD_PHONEBOOK_READRG: | ||
53 | - payload = (char *)gmh + sizeof(*gmh); | ||
54 | + num = (int *) ((char *)gmh + sizeof(*gmh)); | ||
55 | + printf("Records:%d\n", *num); | ||
56 | |||
57 | - if (!strncmp(payload, "+CPBR", 5) || | ||
58 | - !strncmp(payload, "+CPBF", 5)) { | ||
59 | - gp = (struct gsmd_phonebook *) malloc(sizeof(struct gsmd_phonebook)); | ||
60 | - ptr = strchr(payload, ' '); | ||
61 | - gp->index = atoi(ptr+1); | ||
62 | - | ||
63 | - fcomma = strchr(payload, '"'); | ||
64 | - lcomma = strchr(fcomma+1, '"'); | ||
65 | - strncpy(gp->numb, fcomma + 1, (lcomma-fcomma-1)); | ||
66 | - gp->numb[(lcomma - fcomma) - 1] = '\0'; | ||
67 | - | ||
68 | - gp->type = atoi(lcomma + 2); | ||
69 | - | ||
70 | - ptr = strrchr(payload, ','); | ||
71 | - fcomma = ptr + 1; | ||
72 | - lcomma = strchr(fcomma + 1, '"'); | ||
73 | - strncpy(gp->text, fcomma + 1, (lcomma - fcomma - 1)); | ||
74 | - gp->text[(lcomma - fcomma) - 1] = '\0'; | ||
75 | - | ||
76 | - llist_add_tail(&gp->list, &phonebook_list); | ||
77 | - | ||
78 | -#if 0 | ||
79 | - llist_for_each_entry(gp, &phonebook_list, list) { | ||
80 | - printf("%d, %s, %d, %s\n", gp->index, gp->numb, gp->type, gp->text); | ||
81 | - } | ||
82 | -#endif | ||
83 | - printf("%d, %s, %d, %s\n", gp->index, gp->numb, gp->type, gp->text); | ||
84 | - } | ||
85 | - else | ||
86 | - printf("%s\n", payload); | ||
87 | + nREADRG = *num; | ||
88 | break; | ||
89 | -#endif | ||
90 | case GSMD_PHONEBOOK_READ: | ||
91 | gp = (struct gsmd_phonebook *) ((char *)gmh + sizeof(*gmh)); | ||
92 | if (gp->index) | ||
93 | @@ -115,48 +89,18 @@ | ||
94 | gps = (struct gsmd_phonebook_support *) ((char *)gmh + sizeof(*gmh)); | ||
95 | printf("(1-%d), %d, %d\n", gps->index, gps->nlength, gps->tlength); | ||
96 | break; | ||
97 | -#if 0 | ||
98 | - case GSMD_PHONEBOOK_LIST_STORAGE: | ||
99 | - payload = (char *)gmh + sizeof(*gmh); | ||
100 | |||
101 | - if (!strncmp(payload, "+CPBS", 5)) { | ||
102 | - char* delim = "(,"; | ||
103 | - struct gsmd_phonebook_storage *cur, *cur2; | ||
104 | - | ||
105 | - /* Remove previous record */ | ||
106 | - if (!llist_empty(&storage_list)) { | ||
107 | - llist_for_each_entry_safe(cur, cur2, | ||
108 | - &storage_list, list) { | ||
109 | - llist_del(&cur->list); | ||
110 | - talloc_free(cur); | ||
111 | - } | ||
112 | - } | ||
113 | - | ||
114 | - ptr = strpbrk(payload, delim); | ||
115 | - | ||
116 | - while ( ptr ) { | ||
117 | - gpst = (struct gsmd_phonebook_storage *) malloc(sizeof(struct gsmd_phonebook_storage)); | ||
118 | - strncpy(gpst->storage, ptr+2, 2); | ||
119 | - gpst->storage[2] = '\0'; | ||
120 | - | ||
121 | - ptr = strpbrk(ptr+2, delim); | ||
122 | - | ||
123 | - llist_add_tail(&gpst->list, &storage_list); | ||
124 | - } | ||
125 | + case GSMD_PHONEBOOK_LIST_STORAGE: | ||
126 | + gpst = (struct gsmd_phonebook_storage *)((char *)gmh + sizeof(*gmh)); | ||
127 | |||
128 | - if (llist_empty(&storage_list)) | ||
129 | - return 0; | ||
130 | + for (i = 0; i < gpst->num; i++) { | ||
131 | + printf("%s, ", gpst->mem[i].type); | ||
132 | + } | ||
133 | |||
134 | - llist_for_each_entry(cur, &storage_list, list) { | ||
135 | - printf("\n%s",cur->storage); | ||
136 | - } | ||
137 | + printf("\n"); | ||
138 | |||
139 | - printf("\n"); | ||
140 | - } | ||
141 | - else | ||
142 | - printf("%s\n", payload); | ||
143 | break; | ||
144 | -#endif | ||
145 | + | ||
146 | case GSMD_PHONEBOOK_WRITE: | ||
147 | case GSMD_PHONEBOOK_DELETE: | ||
148 | case GSMD_PHONEBOOK_SET_STORAGE: | ||
149 | @@ -164,6 +108,26 @@ | ||
150 | payload = (char *)gmh + sizeof(*gmh); | ||
151 | printf("%s\n", payload); | ||
152 | break; | ||
153 | + case GSMD_PHONEBOOK_RETRIEVE_READRG: | ||
154 | + gp = (struct gsmd_phonebook *) ((char *)gmh + sizeof(*gmh)); | ||
155 | + | ||
156 | + for (i=0; i<nREADRG; i++) { | ||
157 | + printf("%d,%s,%d,%s\n", gp->index, gp->numb, gp->type, gp->text); | ||
158 | + gp++; | ||
159 | + } | ||
160 | + | ||
161 | + nREADRG = 0; | ||
162 | + break; | ||
163 | + case GSMD_PHONEBOOK_RETRIEVE_FIND: | ||
164 | + gp = (struct gsmd_phonebook *) ((char *)gmh + sizeof(*gmh)); | ||
165 | + | ||
166 | + for (i = 0; i < nFIND; i++) { | ||
167 | + printf("%d,%s,%d,%s\n", gp->index, gp->numb, gp->type, gp->text); | ||
168 | + gp++; | ||
169 | + } | ||
170 | + | ||
171 | + nFIND = 0; | ||
172 | + break; | ||
173 | default: | ||
174 | return -EINVAL; | ||
175 | } | ||
176 | @@ -381,11 +345,13 @@ | ||
177 | "\tpd\tPB Delete (pb=index)\n" | ||
178 | "\tpr\tPB Read (pr=index)\n" | ||
179 | "\tprr\tPB Read Range (prr=index1,index2)\n" | ||
180 | - "\tpf\tPB Find (pff=indtext)\n" | ||
181 | + "\tpf\tPB Find (pf=indtext)\n" | ||
182 | "\tpw\tPB Write (pw=index,number,text)\n" | ||
183 | "\tps\tPB Support\n" | ||
184 | "\tpm\tPB Memory\n" | ||
185 | "\tpp\tPB Set Memory (pp=storage)\n" | ||
186 | + "\tpRr\tRetrieve Readrg Records\n" | ||
187 | + "\tpRf\tRetrieve Find Records\n" | ||
188 | "\tsd\tSMS Delete (sd=index,delflg)\n" | ||
189 | "\tsl\tSMS List (sl=stat)\n" | ||
190 | "\tsr\tSMS Read (sr=index)\n" | ||
191 | @@ -509,48 +475,21 @@ | ||
192 | printf("Delete Phonebook Entry\n"); | ||
193 | ptr = strchr(buf, '='); | ||
194 | lgsm_pb_del_entry(lgsmh, atoi(ptr+1)); | ||
195 | -#if 0 | ||
196 | } else if ( !strncmp(buf, "prr", 3)) { | ||
197 | printf("Read Phonebook Entries\n"); | ||
198 | struct lgsm_phonebook_readrg pb_readrg; | ||
199 | - struct gsmd_phonebook *gp_cur, *gp_cur2; | ||
200 | - | ||
201 | - /* Remove records */ | ||
202 | - if (!llist_empty(&phonebook_list)) { | ||
203 | - llist_for_each_entry_safe(gp_cur, | ||
204 | - gp_cur2, | ||
205 | - &phonebook_list, | ||
206 | - list) { | ||
207 | - llist_del(&gp_cur->list); | ||
208 | - talloc_free(gp_cur); | ||
209 | - } | ||
210 | - } | ||
211 | |||
212 | ptr = strchr(buf, '='); | ||
213 | pb_readrg.index1 = atoi(ptr+1); | ||
214 | ptr = strchr(buf, ','); | ||
215 | pb_readrg.index2 = atoi(ptr+1); | ||
216 | lgsm_pb_read_entries(lgsmh, &pb_readrg); | ||
217 | -#endif | ||
218 | } else if ( !strncmp(buf, "pr", 2)) { | ||
219 | ptr = strchr(buf, '='); | ||
220 | lgsm_pb_read_entry(lgsmh, atoi(ptr+1)); | ||
221 | -#if 0 | ||
222 | } else if ( !strncmp(buf, "pf", 2)) { | ||
223 | printf("Find Phonebook Entry\n"); | ||
224 | struct lgsm_phonebook_find pb_find; | ||
225 | - struct gsmd_phonebook *gp_cur, *gp_cur2; | ||
226 | - | ||
227 | - /* Remove records */ | ||
228 | - if (!llist_empty(&phonebook_list)) { | ||
229 | - llist_for_each_entry_safe(gp_cur, | ||
230 | - gp_cur2, | ||
231 | - &phonebook_list, | ||
232 | - list) { | ||
233 | - llist_del(&gp_cur->list); | ||
234 | - talloc_free(gp_cur); | ||
235 | - } | ||
236 | - } | ||
237 | |||
238 | ptr = strchr(buf, '='); | ||
239 | strncpy(pb_find.findtext, | ||
240 | @@ -559,7 +498,6 @@ | ||
241 | pb_find.findtext[strlen(ptr+1)] = '\0'; | ||
242 | |||
243 | lgsm_pb_find_entry(lgsmh, &pb_find); | ||
244 | -#endif | ||
245 | } else if ( !strncmp(buf, "pw", 2)) { | ||
246 | printf("Write Phonebook Entry\n"); | ||
247 | struct lgsm_phonebook pb; | ||
248 | @@ -591,6 +529,16 @@ | ||
249 | } else if ( !strncmp(buf, "ps", 2)) { | ||
250 | printf("Get Phonebook Support\n"); | ||
251 | lgsm_pb_get_support(lgsmh); | ||
252 | + } else if( !strncmp(buf, "pRr", 3) ) { | ||
253 | + printf("Retrieve Readrg Records\n"); | ||
254 | + | ||
255 | + if ( nREADRG ) | ||
256 | + lgsm_pb_retrieve_readrg(lgsmh, nREADRG); | ||
257 | + } else if( !strncmp(buf, "pRf", 3) ) { | ||
258 | + printf("Retrieve Find Records\n"); | ||
259 | + | ||
260 | + if ( nFIND ) | ||
261 | + lgsm_pb_retrieve_find(lgsmh, nFIND); | ||
262 | } else if ( !strncmp(buf, "sd", 2)) { | ||
263 | printf("Delete SMS\n"); | ||
264 | struct lgsm_sms_delete sms_del; | ||