gnokii-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Re: Encoding in atgen.c


From: Hugo Haas
Subject: [PATCH] Re: Encoding in atgen.c
Date: Sat, 26 Jun 2004 18:45:55 +0200
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Hi Pawel, all.

* Pawel Kot <address@hidden> [2004-06-09 01:03:26+0200]:
>> * Pawel Kot <address@hidden> [2004-04-25 18:18:52+0200]:
>> >> Pawel, what are your thoughts? I am not sure that a simple extra
>> >> encoding operation warrants redifining completely the functions that
>> >> need it in ateric.c.
>> >
>> > I still think we should do it. But I'm afraid that not all Ericssons will
>> > behave the same way. Would you be so kind at take all information we got
>> > and make a table to summarize which phone behaves which way?
>> >
>> > I'm working currently on AT driver so probably I'll commit some changes
>> > soon (they touch a bit the problem we are talking about).
>>
>> I didn't see anything committed about this in CVS. I was wondering
>> what the status of this was.
>
> That's my fault. I haven't done anything useful for gnokii over last 6
> weeks. I know I will have time for gnokii Thursday-Sunday. I'll spend it
> the best I can. Some things will be probably straighten up (waiting
> already for a looong time)

I have implemented my encoding fix based on the data below:

* Hugo Haas <address@hidden> [2004-04-25 22:42:23+0200]:
> * Pawel Kot <address@hidden> [2004-04-25 18:18:52+0200]:
>>> Pawel, what are your thoughts? I am not sure that a simple extra
>>> encoding operation warrants redifining completely the functions that
>>> need it in ateric.c.
>>
>> I still think we should do it. But I'm afraid that not all Ericssons will
>> behave the same way. Would you be so kind at take all information we got
>> and make a table to summarize which phone behaves which way?
>
> Here is the information we got:
>
> Model                   Needs UCS2 encoding instead of ASCII for:
> ----------------------- ------------------------------------------
> Sony Ericsson T610      Names, phone numbers, memory type
> Nokia 6310              Names
> Sony Ericsson T68i      Patch has no effect: UCS2 not supported
> Philips 530             Names
>
> So, it seems that the patch fixes the T610 problems without breaking
> the T68i.
>
> Nokia and Philips phones need the current system to work.

I have added an encode_everything boolean in the AT phone driver
information. By default, it's set to 0, and is set to 1 for phones
declaring themselves as "SONY ERICSSON". I believe that T610's need
this to communicate with Gnokii, and it doesn't break the
communication with the T68i.

When drvinst->encode_everything is set, all strings between double
quotes are encoded and decoded, i.e. names, phone numbers and memory
types instead of just names.

The patch is attached. It is essentially the patch I sent for 0.6.1[1]
with its effects only applied to Sony Ericsson phones. Let me know if
this is acceptable for inclusion.

Regards,

Hugo

[1]  http://lists.nongnu.org/archive/html/gnokii-users/2004-04/msg00086.html

-- 
Hugo Haas - http://larve.net/people/hugo/
Index: common/phones/atgen.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/phones/atgen.c,v
retrieving revision 1.105
diff -u -r1.105 atgen.c
--- common/phones/atgen.c       10 Jun 2004 15:18:50 -0000      1.105
+++ common/phones/atgen.c       26 Jun 2004 16:22:36 -0000
@@ -497,12 +497,19 @@
 {
        at_driver_instance *drvinst = AT_DRVINST(state);
        gn_data data;
-       char req[32];
+       char req[32], memtype[10];
+       int len;
        gn_error ret = GN_ERR_NONE;
 
        if (mt != drvinst->memorytype) {
-               sprintf(req, "AT+CPBS=\"%s\"\r", memorynames[mt]);
-               ret = sm_message_send(13, GN_OP_Init, req, state);
+               if (! drvinst->encode_everything) {
+                       sprintf(req, "AT+CPBS=\"%s\"\r", memorynames[mt]);
+                       ret = sm_message_send(13, GN_OP_Init, req, state);
+               } else {
+                       len = at_encode(drvinst->charset, memtype, 
memorynames[mt], strlen(memorynames[mt]));
+                       sprintf(req, "AT+CPBS=\"%s\"\r", memtype);
+                       ret = sm_message_send(11 + len, GN_OP_Init, req, state);
+               }
                if (ret)
                        return GN_ERR_NOTREADY;
                gn_data_clear(&data);
@@ -724,7 +731,7 @@
 {
        at_driver_instance *drvinst = AT_DRVINST(state);
        int len, ofs;
-       char req[256], *tmp;
+       char req[256], pnumber[256], *tmp;
        gn_error ret;
        
        ret = at_memory_type_set(data->phonebook_entry->memory_type, state);
@@ -736,9 +743,15 @@
                ret = state->driver.functions(GN_OP_AT_SetCharset, data, state);
                if (ret)
                        return ret;
+               if (drvinst->encode_everything) {
+                       at_encode(drvinst->charset, pnumber, 
data->phonebook_entry->number, strlen(data->phonebook_entry->number));
+               } else {
+                       strncpy(pnumber, data->phonebook_entry->number, 255);
+                       pnumber[255] = '\0';
+               }
                ofs = sprintf(req, "AT+CPBW=%d,\"%s\",%s,\"",
                              
data->phonebook_entry->location+drvinst->memoryoffset,
-                             data->phonebook_entry->number,
+                             pnumber,
                              data->phonebook_entry->number[0] == '+' ? "145" : 
"129");
                len = strlen(data->phonebook_entry->name);
                tmp = req + ofs;
@@ -1075,7 +1088,11 @@
                        endpos = strchr(++pos, '\"');
                if (endpos) {
                        *endpos = '\0';
-                       strcpy(data->phonebook_entry->number, pos);
+                       if (!drvinst->encode_everything) {
+                               strcpy(data->phonebook_entry->number, pos);
+                       } else {
+                               at_decode(drvinst->charset, 
data->phonebook_entry->number, pos, strlen(pos));
+                       }
                }
 
                /* store name */
@@ -1636,6 +1653,7 @@
        drvinst->smsmemorytype = GN_MT_XX;
        drvinst->defaultcharset = AT_CHAR_UNKNOWN;
        drvinst->charset = AT_CHAR_UNKNOWN;
+       drvinst->encode_everything = 0;
 
        drvinst->if_pos = 0;
        for (i = 0; i < GN_OP_AT_Max; i++) {
@@ -1688,6 +1706,8 @@
                at_bosch_init(model, setupdata->model, state);
        else if (!strncasecmp(manufacturer, "ericsson", 8))
                at_ericsson_init(model, setupdata->model, state);
+       else if (!strncasecmp(manufacturer, "SONY ERICSSON", 13))
+               drvinst->encode_everything = 1;
        else if (!strncasecmp(manufacturer, "nokia", 5))
                at_nokia_init(model, setupdata->model, state);
        else if (!strncasecmp(manufacturer, "siemens", 7))
Index: include/phones/atgen.h
===================================================================
RCS file: /cvsroot/gnokii/gnokii/include/phones/atgen.h,v
retrieving revision 1.17
diff -u -r1.17 atgen.h
--- include/phones/atgen.h      9 Jun 2004 13:58:32 -0000       1.17
+++ include/phones/atgen.h      26 Jun 2004 16:22:36 -0000
@@ -73,6 +73,7 @@
        at_charset availcharsets;
        at_charset defaultcharset;
        at_charset charset;
+       short encode_everything;
 } at_driver_instance;
 
 #define AT_DRVINST(s) ((at_driver_instance *)((s)->driver.driver_instance))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]