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-34


From: Pawel Kot
Subject: [SCM] libgnokii and core programs branch, master, updated. rel_0_6_29-344-g6d59b8b
Date: Sun, 25 Dec 2011 20:42:15 +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  6d59b8b1a0f96b41a6160b6ddd1dae2396ff38c5 (commit)
      from  68a3e1085dd30965bc2e68399855bffc84e711cc (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=6d59b8b1a0f96b41a6160b6ddd1dae2396ff38c5


commit 6d59b8b1a0f96b41a6160b6ddd1dae2396ff38c5
Author: Pawel Kot <address@hidden>
Date:   Sun Dec 25 21:36:26 2011 +0100

    Move callbacks from gn_data to gn_statemachine->callbacks
    
    Callbacks were registered in gn_data. It might have been dangerous as
    various callers might call gn_data_clear() quite often.  It may clear
    registered callbacks.  Therefore let's keep it in the statemachine in a
    separate new structure.

diff --git a/ChangeLog b/ChangeLog
index 99a1d94..1f85a45 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,8 @@
       to execute connect_script and disconnect_script with all
       connection types                                  (Paweł Kot)
     o implement GN_OP_Ping operation                    (Paweł Kot)
+    o move callbacks from gn_data to separate structure put into
+      gn_statemaching                                   (Paweł Kot)
  * at driver updates
     o in the default case autodetect if PDU SMS starts with SMSC
                                                     (Daniele Forsi)
diff --git a/common/data/at-emulator.c b/common/data/at-emulator.c
index b7bfc0b..eb4e620 100644
--- a/common/data/at-emulator.c
+++ b/common/data/at-emulator.c
@@ -142,7 +142,7 @@ bool gn_atem_initialise(int read_fd, int write_fd, struct 
gn_statemachine *vmsm)
        MessageFormat = PDU_MODE;
 
        /* Set the call passup so that we get notified of incoming calls */
-       data.call_notification = gn_atem_call_passup;
+       sm->callbacks.call_notification = gn_atem_call_passup;
        gn_sm_functions(GN_OP_SetCallNotification, &data, sm);
 
        /* query model, revision and imei */
@@ -195,7 +195,7 @@ static void  gn_atem_answer_phone(void)
 {
        /* For now we'll also initialise the datapump + rlp code again */
        dp_Initialise(PtyRDFD, PtyWRFD);
-       data.call_notification = dp_CallPassup;
+       sm->callbacks.call_notification = dp_CallPassup;
        gn_sm_functions(GN_OP_SetCallNotification, &data, sm);
        data.call_info->call_id = IncomingCallNo;
        gn_sm_functions(GN_OP_AnswerCall, &data, sm);
@@ -372,7 +372,7 @@ void        gn_atem_at_parse(char *cmd_buffer)
                        buf++;
                        if (toupper(*buf) == 'T' || toupper(*buf) == 'P') buf++;
                        while (*buf == ' ') buf++;
-                       data.call_notification = dp_CallPassup;
+                       sm->callbacks.call_notification = dp_CallPassup;
                        gn_sm_functions(GN_OP_SetCallNotification, &data, sm);
                        snprintf(data.call_info->number, 
sizeof(data.call_info->number), "%s", buf);
                        if (ModemRegisters[S35] == 0)
diff --git a/common/data/datapump.c b/common/data/datapump.c
index c164029..891facc 100644
--- a/common/data/datapump.c
+++ b/common/data/datapump.c
@@ -60,7 +60,7 @@ bool dp_Initialise(int read_fd, int write_fd)
        rlp_user_request_set(Attach_Req, true);
        pluscount = 0;
        connected = false;
-       data.rlp_rx_callback = rlp_f96_frame_display;
+       sm->callbacks.rlp_rx_callback = rlp_f96_frame_display;
        gn_sm_functions(GN_OP_SetRLPRXCallback, &data, sm);
 
        return true;
@@ -89,7 +89,7 @@ static int DP_CallBack(rlp_user_inds ind, unsigned char 
*buffer, int length)
                if (CommandMode == false) gn_atem_modem_result(MR_NOCARRIER);
                connected = false;
                /* Set the call passup back to the at emulator */
-               data.call_notification = gn_atem_call_passup;
+               sm->callbacks.call_notification = gn_atem_call_passup;
                gn_sm_functions(GN_OP_SetCallNotification, &data, sm);
                CommandMode = true;
                break;
@@ -124,7 +124,7 @@ static int DP_CallBack(rlp_user_inds ind, unsigned char 
*buffer, int length)
                        if (pluscount == 3) {
                                CommandMode = true;
                                /* Set the call passup back to the at emulator 
*/
-                               data.call_notification = gn_atem_call_passup;
+                               sm->callbacks.call_notification = 
gn_atem_call_passup;
                                gn_sm_functions(GN_OP_SetCallNotification, 
&data, sm);
                                gn_atem_string_out("\r\n");
                                gn_atem_modem_result(MR_OK);
@@ -154,7 +154,7 @@ void dp_CallPassup(gn_call_status CallStatus, gn_call_info 
*CallInfo, struct gn_
        case GN_CALL_RemoteHangup:
                CommandMode = true;
                /* Set the call passup back to the at emulator */
-               data.call_notification = gn_atem_call_passup;
+               sm->callbacks.call_notification = gn_atem_call_passup;
                gn_sm_functions(GN_OP_SetCallNotification, &data, sm);
                gn_atem_modem_result(MR_NOCARRIER);
                rlp_user_request_set(Disc_Req, true);
diff --git a/common/phones/atgen.c b/common/phones/atgen.c
index 21f7a49..b677436 100644
--- a/common/phones/atgen.c
+++ b/common/phones/atgen.c
@@ -1589,7 +1589,7 @@ static gn_error AT_SetCallNotification(gn_data *data, 
struct gn_statemachine *st
        at_driver_instance *drvinst = AT_DRVINST(state);
        gn_error err;
 
-       if (!drvinst->call_notification && !data->call_notification)
+       if (!drvinst->call_notification && !state->callbacks.call_notification)
                return GN_ERR_NONE;
 
        if (!drvinst->call_notification) {
@@ -1609,7 +1609,7 @@ static gn_error AT_SetCallNotification(gn_data *data, 
struct gn_statemachine *st
                sm_block_no_retry(GN_OP_SetCallNotification, data, state);
        }
 
-       drvinst->call_notification = data->call_notification;
+       drvinst->call_notification = state->callbacks.call_notification;
        drvinst->call_callback_data = data->callback_data;
 
        return GN_ERR_NONE;
@@ -1623,7 +1623,7 @@ static gn_error AT_GetNetworkInfo(gn_data *data, struct 
gn_statemachine *state)
         * AT+CREG enables +CREG notifications, so register notification
         * callback.
         */
-       drvinst->reg_notification = data->reg_notification;
+       drvinst->reg_notification = state->callbacks.reg_notification;
        drvinst->reg_callback_data = data->callback_data;
 
        if (!data->network_info)
@@ -1787,7 +1787,7 @@ static gn_error AT_OnSMS(gn_data *data, struct 
gn_statemachine *state)
                error = sm_block_no_retry(GN_OP_OnSMS, data, state);
        } while (mode-- && error);
        if (error == GN_ERR_NONE) {
-               AT_DRVINST(state)->on_sms = data->on_sms;
+               AT_DRVINST(state)->on_sms = state->callbacks.on_sms;
                AT_DRVINST(state)->sms_callback_data = data->callback_data;
        }
        return error;
diff --git a/common/phones/nk3110.c b/common/phones/nk3110.c
index 9f61117..abec7de 100644
--- a/common/phones/nk3110.c
+++ b/common/phones/nk3110.c
@@ -589,7 +589,7 @@ static gn_error P3110_SendRLPFrame(gn_data *data, struct 
gn_statemachine *state)
 
 static gn_error P3110_SetRLPRXCallback(gn_data *data, struct gn_statemachine 
*state)
 {
-       DRVINSTANCE(state)->rlp_rx_callback = data->rlp_rx_callback;
+       DRVINSTANCE(state)->rlp_rx_callback = state->callbacks.rlp_rx_callback;
 
        return GN_ERR_NONE;
 }
diff --git a/common/phones/nk6100.c b/common/phones/nk6100.c
index 1a471fd..1c11dd7 100644
--- a/common/phones/nk6100.c
+++ b/common/phones/nk6100.c
@@ -1310,8 +1310,8 @@ static gn_error SetCellBroadcast(gn_data *data, struct 
gn_statemachine *state)
        if (DRVINSTANCE(state)->capabilities & NK6100_CAP_NO_CB)
                return GN_ERR_NOTSUPPORTED;
 
-       req = data->on_cell_broadcast ? req_ena : req_dis;
-       DRVINSTANCE(state)->on_cell_broadcast = data->on_cell_broadcast;
+       req = state->callbacks.on_cell_broadcast ? req_ena : req_dis;
+       DRVINSTANCE(state)->on_cell_broadcast = 
state->callbacks.on_cell_broadcast;
        DRVINSTANCE(state)->cb_callback_data = data->callback_data;
 
        if (sm_message_send(10, 0x02, req, state)) return GN_ERR_NOTREADY;
@@ -1407,8 +1407,8 @@ static void FlushLostSMSNotifications(struct 
gn_statemachine *state)
 
 static gn_error SetOnSMS(gn_data *data, struct gn_statemachine *state)
 {
-       if (data->on_sms) {
-               DRVINSTANCE(state)->on_sms = data->on_sms;
+       if (state->callbacks.on_sms) {
+               DRVINSTANCE(state)->on_sms = state->callbacks.on_sms;
                DRVINSTANCE(state)->sms_callback_data = data->callback_data;
                DRVINSTANCE(state)->sms_notification_lost = true;
                FlushLostSMSNotifications(state);
@@ -3364,7 +3364,7 @@ static gn_error CancelCall1(gn_data *data, struct 
gn_statemachine *state)
 
 static gn_error SetCallNotification(gn_data *data, struct gn_statemachine 
*state)
 {
-       DRVINSTANCE(state)->call_notification = data->call_notification;
+       DRVINSTANCE(state)->call_notification = 
state->callbacks.call_notification;
        DRVINSTANCE(state)->call_callback_data = data->callback_data;
 
        return GN_ERR_NONE;
@@ -3599,7 +3599,7 @@ static gn_error SendRLPFrame(gn_data *data, struct 
gn_statemachine *state)
 
 static gn_error SetRLPRXCallback(gn_data *data, struct gn_statemachine *state)
 {
-       DRVINSTANCE(state)->rlp_rx_callback = data->rlp_rx_callback;
+       DRVINSTANCE(state)->rlp_rx_callback = state->callbacks.rlp_rx_callback;
 
        return GN_ERR_NONE;
 }
diff --git a/common/phones/nk6510.c b/common/phones/nk6510.c
index c30ddbc..06c5f80 100644
--- a/common/phones/nk6510.c
+++ b/common/phones/nk6510.c
@@ -426,11 +426,11 @@ static gn_error NK6510_Functions(gn_operation op, gn_data 
*data, struct gn_state
        case GN_OP_WriteWAPSetting:
                return NK6510_WriteWAPSetting(data, state);
        case GN_OP_OnSMS:
-               DRVINSTANCE(state)->on_sms = data->on_sms;
+               DRVINSTANCE(state)->on_sms = state->callbacks.on_sms;
                DRVINSTANCE(state)->sms_callback_data = data->callback_data;
                return NK6510_Subscribe(data, state);
        case GN_OP_SetCallNotification:
-               DRVINSTANCE(state)->call_notification = data->call_notification;
+               DRVINSTANCE(state)->call_notification = 
state->callbacks.call_notification;
                DRVINSTANCE(state)->call_callback_data = data->callback_data;
                return NK6510_Subscribe(data, state);
        case GN_OP_DeleteSMS:
@@ -2282,8 +2282,8 @@ static gn_error NK6510_GetFile(gn_data *data, struct 
gn_statemachine *state)
        int i;
 
        /* Register callback */
-       if (data->progress_indication) {
-               DRVINSTANCE(state)->progress_indication = 
data->progress_indication;
+       if (state->callbacks.progress_indication) {
+               DRVINSTANCE(state)->progress_indication = 
state->callbacks.progress_indication;
                DRVINSTANCE(state)->progress_callback_data = 
data->callback_data;
        }
 
@@ -2363,8 +2363,8 @@ static gn_error NK6510_GetFileById(gn_data *data, struct 
gn_statemachine *state)
        int i, length;
 
        /* Register callback */
-       if (data->progress_indication) {
-               DRVINSTANCE(state)->progress_indication = 
data->progress_indication;
+       if (state->callbacks.progress_indication) {
+               DRVINSTANCE(state)->progress_indication = 
state->callbacks.progress_indication;
                DRVINSTANCE(state)->progress_callback_data = 
data->callback_data;
        }
 
diff --git a/common/phones/nk7110.c b/common/phones/nk7110.c
index 1da5630..70611e6 100644
--- a/common/phones/nk7110.c
+++ b/common/phones/nk7110.c
@@ -235,10 +235,10 @@ static gn_error NK7110_Functions(gn_operation op, gn_data 
*data, struct gn_state
                dprintf("Getting SMS (no validating)...\n");
                return NK7110_GetSMSnoValidate(data, state);
        case GN_OP_OnSMS:
-               DRVINSTANCE(state)->on_sms = data->on_sms;
+               DRVINSTANCE(state)->on_sms = state->callbacks.on_sms;
                DRVINSTANCE(state)->sms_callback_data = data->callback_data;
                /* Register notify when running for the first time */
-               if (data->on_sms) {
+               if (state->callbacks.on_sms) {
                        DRVINSTANCE(state)->new_sms = true;
                        return GN_ERR_NONE; /* FIXME 
NK7110_GetIncomingSMS(data, state); */
                }
diff --git a/gnokii/gnokii-file.c b/gnokii/gnokii-file.c
index 80b73e3..6cf4ea2 100644
--- a/gnokii/gnokii-file.c
+++ b/gnokii/gnokii-file.c
@@ -246,7 +246,7 @@ gn_error getfile(int argc, char *argv[], gn_data *data, 
struct gn_statemachine *
        gn_data_clear(data);
        data->file = &fi;
 
-       data->progress_indication = NULL;
+       state->callbacks.progress_indication = NULL;
 
        if ((error = gn_sm_functions(GN_OP_GetFile, data, state)) != 
GN_ERR_NONE)
                fprintf(stderr, _("Failed to get file %s: %s\n"), optarg, 
gn_error_print(error));
@@ -312,7 +312,7 @@ gn_error getfilebyid(int argc, char *argv[], gn_data *data, 
struct gn_statemachi
        data->file = &fi;
        data->file_list = &fil;
 
-       data->progress_indication = NULL;
+       state->callbacks.progress_indication = NULL;
 
        if ((error = gn_sm_functions(GN_OP_GetFileDetailsById, data, state)) != 
GN_ERR_NONE)
                fprintf(stderr, _("Failed to get file: %s\n"), 
gn_error_print(error));
diff --git a/gnokii/gnokii-monitor.c b/gnokii/gnokii-monitor.c
index ef0ae07..2c022d5 100644
--- a/gnokii/gnokii-monitor.c
+++ b/gnokii/gnokii-monitor.c
@@ -221,9 +221,9 @@ gn_error monitormode(int argc, char *argv[], gn_data *data, 
struct gn_statemachi
        data->power_source = &powersource;
        data->sms_status = &smsstatus;
        data->network_info = &networkinfo;
-       data->on_cell_broadcast = storecbmessage;
-       data->call_notification = callnotifier;
-       data->reg_notification = networkinfo_print;
+       state->callbacks.on_cell_broadcast = storecbmessage;
+       state->callbacks.call_notification = callnotifier;
+       state->callbacks.reg_notification = networkinfo_print;
        data->callback_data = NULL;
 
        gn_sm_functions(GN_OP_SetCallNotification, data, state);
@@ -301,7 +301,7 @@ gn_error monitormode(int argc, char *argv[], gn_data *data, 
struct gn_statemachi
                sleep(d);
        }
 
-       data->on_cell_broadcast = NULL;
+       state->callbacks.on_cell_broadcast = NULL;
        error = gn_sm_functions(GN_OP_SetCellBroadcast, data, state);
 
        fprintf(stderr, _("Leaving monitor mode...\n"));
diff --git a/gnokii/gnokii-other.c b/gnokii/gnokii-other.c
index d6b1774..23b009a 100644
--- a/gnokii/gnokii-other.c
+++ b/gnokii/gnokii-other.c
@@ -167,7 +167,7 @@ gn_error getnetworkinfo(gn_data *data, struct 
gn_statemachine *state)
        memset(&networkinfo, 0, sizeof(networkinfo));
 
        data->network_info = &networkinfo;
-       data->reg_notification = NULL;
+       state->callbacks.reg_notification = NULL;
        data->callback_data = NULL;
 
        if ((error = gn_sm_functions(GN_OP_GetNetworkInfo, data, state)) != 
GN_ERR_NONE) {
diff --git a/gnokii/gnokii-sms.c b/gnokii/gnokii-sms.c
index d00c468..2d137b0 100644
--- a/gnokii/gnokii-sms.c
+++ b/gnokii/gnokii-sms.c
@@ -1291,7 +1291,7 @@ gn_error smsreader(gn_data *data, struct gn_statemachine 
*state)
 {
        gn_error error;
 
-       data->on_sms = smsslave;
+       state->callbacks.on_sms = smsslave;
        data->callback_data = NULL;
        error = gn_sm_functions(GN_OP_OnSMS, data, state);
        if (!error) {
@@ -1308,7 +1308,7 @@ gn_error smsreader(gn_data *data, struct gn_statemachine 
*state)
                fprintf(stderr, _("Shutting down\n"));
 
                fprintf(stderr, _("Exiting sms reader mode...\n"));
-               data->on_sms = NULL;
+               state->callbacks.on_sms = NULL;
 
                error = gn_sm_functions(GN_OP_OnSMS, data, state);
                if (error != GN_ERR_NONE)
diff --git a/include/gnokii/data.h b/include/gnokii/data.h
index a35c3dd..4cc248f 100644
--- a/include/gnokii/data.h
+++ b/include/gnokii/data.h
@@ -76,16 +76,11 @@ typedef struct {
        gn_calnote_alarm *alarm;
        gn_raw_data *raw_data;
        gn_call_divert *call_divert;
-       gn_error (*on_sms)(gn_sms *message, struct gn_statemachine *state, void 
*callback_data);
        int *display_status;
-       void (*on_cell_broadcast)(gn_cb_message *message, struct 
gn_statemachine *state, void *callback_data);
        gn_netmonitor *netmonitor;
        gn_call_info *call_info;
-       void (*call_notification)(gn_call_status call_status, gn_call_info 
*call_info,
-                                 struct gn_statemachine *state, void 
*callback_data);
        gn_rlp_f96_frame *rlp_frame;
        int rlp_out_dtx;
-       void (*rlp_rx_callback)(gn_rlp_f96_frame *frame);
        gn_security_code *security_code;
        const char *dtmf_string;
        unsigned char reset_type;
@@ -104,16 +99,6 @@ typedef struct {
         */
        void *callback_data;
        /*
-        * This is a callback function for any changes related to the network
-        * registration parameters changes: status, LAC, cell id.
-        */
-       void (*reg_notification)(gn_network_info *info, void *callback_data);
-       /*
-        * This is callback function for file download progress.
-        * progress is value in range [0, 100].
-        */
-       void (*progress_indication)(int progress, void *callback_data);
-       /*
         * This is for phone driver, application using libgnokii should not
         * touch this.
         */
@@ -170,8 +155,32 @@ typedef struct {
        char m_imei[GN_IMEI_MAX_LENGTH];
 } gn_config;
 
+/*
+ * Structure to keep all callbacks
+ */
+typedef gn_error (*gn_on_sms_func_t)(gn_sms *message, struct gn_statemachine 
*state, void *callback_data);
+typedef void (*gn_on_cell_broadcast_func_t)(gn_cb_message *message, struct 
gn_statemachine *state, void *callback_data);
+typedef void (*gn_call_notification_func_t)(gn_call_status call_status, 
gn_call_info *call_info,
+                                         struct gn_statemachine *state, void 
*callback_data);
+typedef void (*gn_rlp_rx_callback_func_t)(gn_rlp_f96_frame *frame);
+typedef void (*gn_reg_notification_func_t)(gn_network_info *info, void 
*callback_data);
+typedef void (*gn_progress_indication_func_t)(int progress, void 
*callback_data);
 typedef gn_error (*gn_auth_interactive_func_t)(struct gn_statemachine *state);
 typedef struct {
+       gn_on_sms_func_t on_sms;
+       gn_on_cell_broadcast_func_t on_cell_broadcast;
+       gn_call_notification_func_t call_notification;
+       gn_rlp_rx_callback_func_t rlp_rx_callback;
+       /*
+        * This is a callback function for any changes related to the network
+        * registration parameters changes: status, LAC, cell id.
+        */
+       gn_reg_notification_func_t reg_notification;
+       /*
+        * This is callback function for file download progress.
+        * progress is value in range [0, 100].
+        */
+       gn_progress_indication_func_t progress_indication;
        gn_auth_interactive_func_t auth_interactive;
 } gn_callback;
 
diff --git a/include/gnokii/statemachine.h b/include/gnokii/statemachine.h
index 61cef77..c80beb2 100644
--- a/include/gnokii/statemachine.h
+++ b/include/gnokii/statemachine.h
@@ -59,7 +59,7 @@ struct gn_statemachine {
        gn_driver driver;
        char *lockfile;
        gn_callback callbacks;  /* We store all callbacks in here */
-       
+
        /* Store last message for resend purposes */
        unsigned char last_msg_type;
        unsigned int last_msg_size;
diff --git a/xgnokii/xgnokii_lowlevel.c b/xgnokii/xgnokii_lowlevel.c
index 89b4d15..0dbf07a 100644
--- a/xgnokii/xgnokii_lowlevel.c
+++ b/xgnokii/xgnokii_lowlevel.c
@@ -1048,7 +1048,7 @@ static gint A_GetNetworkInfo(gpointer data)
 
        pthread_mutex_lock(&getNetworkInfoMutex);
        gdat.network_info = d->info;
-       gdat.reg_notification = NULL;
+       statemachine->callbacks.reg_notification = NULL;
        gdat.callback_data = NULL;
        error = d->status = gn_sm_functions(GN_OP_GetNetworkInfo, &gdat, 
statemachine);
        pthread_cond_signal(&getNetworkInfoCond);

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

Summary of changes:
 ChangeLog                     |    2 ++
 common/data/at-emulator.c     |    6 +++---
 common/data/datapump.c        |    8 ++++----
 common/phones/atgen.c         |    8 ++++----
 common/phones/nk3110.c        |    2 +-
 common/phones/nk6100.c        |   12 ++++++------
 common/phones/nk6510.c        |   12 ++++++------
 common/phones/nk7110.c        |    4 ++--
 gnokii/gnokii-file.c          |    4 ++--
 gnokii/gnokii-monitor.c       |    8 ++++----
 gnokii/gnokii-other.c         |    2 +-
 gnokii/gnokii-sms.c           |    4 ++--
 include/gnokii/data.h         |   39 ++++++++++++++++++++++++---------------
 include/gnokii/statemachine.h |    2 +-
 xgnokii/xgnokii_lowlevel.c    |    2 +-
 15 files changed, 63 insertions(+), 52 deletions(-)


hooks/post-receive
-- 
libgnokii and core programs



reply via email to

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