gnokii-commit
[Top][All Lists]
Advanced

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

[SCM] libgnokii and core programs branch, master, updated. rel_0_6_29-52


From: Daniele Forsi
Subject: [SCM] libgnokii and core programs branch, master, updated. rel_0_6_29-523-g212261b
Date: Wed, 01 May 2013 15:25:32 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "libgnokii and core programs".

The branch, master has been updated
       via  212261b0be05904ca39d0e1e78867dbaf796fc80 (commit)
      from  9c78cff5411c66b1b379f9198af481bb12437970 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/gnokii.git/commit/?id=212261b0be05904ca39d0e1e78867dbaf796fc80


commit 212261b0be05904ca39d0e1e78867dbaf796fc80
Author: Daniele Forsi <address@hidden>
Date:   Wed May 1 17:15:14 2013 +0200

    Share handling of phonebook error codes between nk7110.c and nk6510.c

diff --git a/common/nokia-decoding.c b/common/nokia-decoding.c
index f7f77a4..35d303f 100644
--- a/common/nokia-decoding.c
+++ b/common/nokia-decoding.c
@@ -28,6 +28,39 @@
 #include "nokia-decoding.h"
 #include "compat.h"
 
+/**
+ * nokia_phonebook_error:
+ * @message: pointer to a #NK6510_MSG_PHONEBOOK or to a #NK7110_MSG_PHONEBOOK 
FBUS frame
+ * @length: length of the FBUS frame
+ *
+ * Translates the FBUS error code returned by nk6510.c or nk7110.c into a 
#gn_error code.
+ */
+gn_error nokia_phonebook_error(unsigned char *message, int length)
+{
+       if (length < 11)
+               return GN_ERR_UNHANDLEDFRAME;
+       if (message[6] != 0x0f) /* not found */
+               return GN_ERR_NONE;
+
+       switch (message[10]) {
+       case 0x0f: return GN_ERR_WRONGDATAFORMAT;       /* I got this when 
sending incorrect block (with 0 length) */
+       case 0x23: return GN_ERR_WRONGDATAFORMAT;       /* Block size does not 
match a definition */
+       case 0x27: return GN_ERR_NOTREADY;              /* Phone is turned off 
*/
+       case 0x30: return GN_ERR_EMPTYLOCATION;
+       case 0x31: return GN_ERR_INVALIDMEMORYTYPE;
+       case 0x33: return GN_ERR_EMPTYLOCATION;
+       case 0x34: return GN_ERR_INVALIDLOCATION;
+       case 0x36: return GN_ERR_WRONGDATAFORMAT;       /* Name block is too 
long */
+       case 0x3b: return GN_ERR_EMPTYLOCATION;
+       case 0x3c: return GN_ERR_WRONGDATAFORMAT;       /* Both name and number 
are missing */
+       case 0x3d: return GN_ERR_FAILED;
+       case 0x3e: return GN_ERR_FAILED;
+       case 0x43: return GN_ERR_WRONGDATAFORMAT;       /* Probably there are 
incorrect characters to be saved */
+       default:
+               return GN_ERR_UNHANDLEDFRAME;
+       }
+}
+
 gn_error phonebook_decode(unsigned char *blockstart, int length, gn_data *data,
                          int blocks, int memtype, int speeddial_pos)
 {
diff --git a/common/phones/nk6510.c b/common/phones/nk6510.c
index 6e87392..9cb8a02 100644
--- a/common/phones/nk6510.c
+++ b/common/phones/nk6510.c
@@ -2722,6 +2722,7 @@ static gn_error NK6510_IncomingPhonebook(int messagetype, 
unsigned char *message
 {
        unsigned char blocks;
        char *req = state->last_msg;
+       gn_error error;
 
        switch (message[3]) {
        case 0x04:  /* Get status response */
@@ -2742,6 +2743,9 @@ static gn_error NK6510_IncomingPhonebook(int messagetype, 
unsigned char *message
                        dprintf("Got read memory response back at unexpected 
time\n");
                        return GN_ERR_UNSOLICITED;
                }
+               error = nokia_phonebook_error(message, length);
+               if (error != GN_ERR_NONE)
+                       return error;
                if (data->phonebook_entry) {
                        data->phonebook_entry->empty = true;
                        data->phonebook_entry->caller_group = 
GN_PHONEBOOK_GROUP_None;
@@ -2759,52 +2763,13 @@ static gn_error NK6510_IncomingPhonebook(int 
messagetype, unsigned char *message
                if (data->bitmap) {
                        data->bitmap->text[0] = '\0';
                }
-               if (message[6] == 0x0f) { /* not found */
-                       switch (message[10]) {
-                       case 0x30:
-                               return GN_ERR_EMPTYLOCATION;
-                       case 0x33:
-                               return GN_ERR_EMPTYLOCATION;
-                       case 0x34:
-                               return GN_ERR_INVALIDLOCATION;
-                       case 0x31:
-                               return GN_ERR_INVALIDMEMORYTYPE;
-                       default:
-                               return GN_ERR_UNKNOWN;
-                       }
-               }
                dprintf("Received phonebook info\n");
                blocks     = message[21];
                return phonebook_decode(message + 22, length - 21, data, 
blocks, message[11], 12);
-
        case 0x0c: /* Write memory location */
-               if (message[6] == 0x0f) {
-                       dprintf("response 0x10 error 0x%x\n", message[10]);
-                       switch (message[10]) {
-                       case 0x0f: return GN_ERR_WRONGDATAFORMAT; /* I got this 
when sending incorrect
-                                                                    block 
(with 0 length) */
-                       case 0x23: return GN_ERR_WRONGDATAFORMAT; /* block size 
does not match a definition */
-                       case 0x36: return GN_ERR_WRONGDATAFORMAT; /* name block 
is too long */
-                       case 0x3c: return GN_ERR_WRONGDATAFORMAT; /* both name 
and number are missing */
-                       case 0x3d: return GN_ERR_FAILED;
-                       case 0x3e: return GN_ERR_FAILED;
-                       case 0x43: return GN_ERR_WRONGDATAFORMAT; /* Probably 
there are incorrect
-                                                                    characters 
to be saved */
-                       default:   return GN_ERR_UNHANDLEDFRAME;
-                       }
-               }
-               break;
+               return nokia_phonebook_error(message, length);
        case 0x10:
-               if (message[6] == 0x0f) {
-                       dprintf("response 0x10 error 0x%x\n", message[10]);
-                       switch (message[10]) {
-                       case 0x33: return GN_ERR_WRONGDATAFORMAT;
-                       case 0x34: return GN_ERR_INVALIDLOCATION;
-                       case 0x3b: return GN_ERR_EMPTYLOCATION;
-                       default:   return GN_ERR_UNHANDLEDFRAME;
-                       }
-               }
-               break;
+               return nokia_phonebook_error(message, length);
        default:
                dprintf("%s: Unknown subtype 0x%02x\n", __FUNCTION__, 
message[3]);
                return GN_ERR_UNHANDLEDFRAME;
diff --git a/common/phones/nk7110.c b/common/phones/nk7110.c
index efccdb0..b8dcbdf 100644
--- a/common/phones/nk7110.c
+++ b/common/phones/nk7110.c
@@ -666,6 +666,7 @@ static gn_error NK7110_IncomingPhonebook(int messagetype, 
unsigned char *message
        unsigned char *blockstart;
        unsigned char blocks;
        int memtype, location;
+       gn_error error;
 
        switch (message[3]) {
        case 0x04:  /* Get status response */
@@ -682,6 +683,9 @@ static gn_error NK7110_IncomingPhonebook(int messagetype, 
unsigned char *message
                }
                break;
        case 0x08:  /* Read Memory response */
+               error = nokia_phonebook_error(message, length);
+               if (error != GN_ERR_NONE)
+                       return error;
                memtype = message[11];
                location = (message[12] << 8) + message[13];
                if (data->phonebook_entry) {
@@ -701,23 +705,6 @@ static gn_error NK7110_IncomingPhonebook(int messagetype, 
unsigned char *message
                if (data->bitmap) {
                        data->bitmap->text[0] = '\0';
                }
-               if (message[6] == 0x0f) { /* not found */
-                       switch (message[10]) {
-                       case 0x27:
-                               /* Phone is turned off */
-                               return GN_ERR_NOTREADY;
-                       case 0x30:
-                               return GN_ERR_EMPTYLOCATION;
-                       case 0x31:
-                               return GN_ERR_INVALIDMEMORYTYPE;
-                       case 0x33:
-                               return GN_ERR_EMPTYLOCATION;
-                       case 0x34:
-                               return GN_ERR_INVALIDLOCATION;
-                       default:
-                               return GN_ERR_UNHANDLEDFRAME;
-                       }
-               }
                if ((drvinst->ll_memtype != memtype && drvinst->ll_memtype != 
NK7110_MEMORY_CB) || drvinst->ll_location != location) {
                        dprintf("skipping entry: ll_memtype: %d, memtype: %d, 
ll_location: %d, location: %d\n",
                                drvinst->ll_memtype, memtype, 
drvinst->ll_location, location);
@@ -728,15 +715,7 @@ static gn_error NK7110_IncomingPhonebook(int messagetype, 
unsigned char *message
                blockstart = message + 18;
                return phonebook_decode(blockstart, length - 17, data, blocks, 
message[11], 8);
        case 0x0c:
-               if (message[6] == 0x0f) {
-                       switch (message[10]) {
-                       case 0x34: return GN_ERR_FAILED; /* invalid location ? 
*/
-                       case 0x3d: return GN_ERR_FAILED;
-                       case 0x3e: return GN_ERR_FAILED;
-                       default:   return GN_ERR_UNHANDLEDFRAME;
-                       }
-               }
-               break;
+               return nokia_phonebook_error(message, length);
        case 0x10:
                dprintf("Entry successfully deleted!\n");
                break;
diff --git a/include/gnokii-internal.h b/include/gnokii-internal.h
index cf53384..c4f6d62 100644
--- a/include/gnokii-internal.h
+++ b/include/gnokii-internal.h
@@ -142,6 +142,7 @@ gn_error file_xpm_load(char *filename, gn_bmp *bitmap);
 
 int ringtone_sms_encode(unsigned char *message, gn_ringtone *ringtone);
 int imelody_sms_encode(unsigned char *imelody, unsigned char *message);
+gn_error nokia_phonebook_error(unsigned char *message, int length);
 gn_error phonebook_decode(unsigned char *blockstart, int length,
                          gn_data *data, int blocks, int memtype, int 
speeddial_pos);
 gn_error calnote_decode(unsigned char *message, int length, gn_data *data);

-----------------------------------------------------------------------

Summary of changes:
 common/nokia-decoding.c   |   33 +++++++++++++++++++++++++++++++
 common/phones/nk6510.c    |   47 +++++---------------------------------------
 common/phones/nk7110.c    |   31 ++++------------------------
 include/gnokii-internal.h |    1 +
 4 files changed, 45 insertions(+), 67 deletions(-)


hooks/post-receive
-- 
libgnokii and core programs



reply via email to

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