Index: common/data/at-emulator.c =================================================================== RCS file: /sources/gnokii/gnokii/common/data/at-emulator.c,v retrieving revision 1.45 diff -u -p -r1.45 at-emulator.c --- common/data/at-emulator.c 3 Oct 2006 21:26:37 -0000 1.45 +++ common/data/at-emulator.c 4 Jul 2007 10:18:19 -0000 @@ -218,7 +218,7 @@ static void gn_atem_answer_phone(void) /* This gets called to indicate an incoming call */ -void gn_atem_call_passup(gn_call_status CallStatus, gn_call_info *CallInfo, struct gn_statemachine *state) +void gn_atem_call_passup(gn_call_status CallStatus, gn_call_info *CallInfo, struct gn_statemachine *state, void *user_data) { dprintf("gn_atem_call_passup called with %d\n", CallStatus); Index: common/phones/atgen.c =================================================================== RCS file: /sources/gnokii/gnokii/common/phones/atgen.c,v retrieving revision 1.143 diff -u -p -r1.143 atgen.c --- common/phones/atgen.c 1 May 2007 23:50:14 -0000 1.143 +++ common/phones/atgen.c 4 Jul 2007 10:18:20 -0000 @@ -1133,6 +1133,7 @@ static gn_error AT_SetCallNotification(g } drvinst->call_notification = data->call_notification; + drvinst->call_notification_user_data = data->user_data; return GN_ERR_NONE; } @@ -1563,6 +1564,52 @@ static gn_error ReplyGetSMS(int messaget if (!data->raw_sms) return GN_ERR_INTERNALERROR; + /* Try to figure out the status first */ + tmp = strchr (buf.line2, ','); + if (tmp != NULL && ((char *) tmp - buf.line2 - strlen ("+CMGR: ")) >= 1) { + char *status; + int len; + + len = (char *) tmp - buf.line2 - strlen ("+CMGR: "); + status = malloc (len + 1); + if (!status) { + dprintf("Not enough memory for buffer.\n"); + return GN_ERR_INTERNALERROR; + } + + memcpy (status, buf.line2 + strlen ("+CMGR: "), len); + status[len] = '\0'; + + if (strstr (status, "UNREAD") != NULL) { + data->raw_sms->status = GN_SMS_Unread; + } else if (strstr (status, "READ") != NULL) { + data->raw_sms->status = GN_SMS_Read; + } else if (strstr (status, "UNSENT") != NULL) { + data->raw_sms->status = GN_SMS_Unsent; + } else if (strstr (status, "SENT") != NULL) { + data->raw_sms->status = GN_SMS_Sent; + } else { + int s; + + s = atoi (status); + switch (s) { + case 0: + data->raw_sms->status = GN_SMS_Unread; + break; + case 1: + data->raw_sms->status = GN_SMS_Read; + break; + case 2: + data->raw_sms->status = GN_SMS_Unsent; + break; + case 3: + data->raw_sms->status = GN_SMS_Sent; + break; + } + } + free(status); + } + tmp = strrchr(buf.line2, ','); /* The following sequence is correct for emtpy location: * w: AT+CMGR=9 @@ -1744,22 +1791,22 @@ static gn_error ReplyRing(int messagetyp else return GN_ERR_UNHANDLEDFRAME; - drvinst->call_notification(GN_CALL_Incoming, &cinfo, state); + drvinst->call_notification(GN_CALL_Incoming, &cinfo, state, drvinst->call_notification_user_data); } else if (!strncmp(buf.line1, "CONNECT", 7)) - drvinst->call_notification(GN_CALL_Established, &cinfo, state); + drvinst->call_notification(GN_CALL_Established, &cinfo, state, drvinst->call_notification_user_data); else if (!strncmp(buf.line1, "BUSY", 4)) - drvinst->call_notification(GN_CALL_RemoteHangup, &cinfo, state); + drvinst->call_notification(GN_CALL_RemoteHangup, &cinfo, state, drvinst->call_notification_user_data); else if (!strncmp(buf.line1, "NO ANSWER", 9)) - drvinst->call_notification(GN_CALL_RemoteHangup, &cinfo, state); + drvinst->call_notification(GN_CALL_RemoteHangup, &cinfo, state, drvinst->call_notification_user_data); else if (!strncmp(buf.line1, "NO CARRIER", 10)) - drvinst->call_notification(GN_CALL_RemoteHangup, &cinfo, state); + drvinst->call_notification(GN_CALL_RemoteHangup, &cinfo, state, drvinst->call_notification_user_data); else if (!strncmp(buf.line1, "NO DIALTONE", 11)) - drvinst->call_notification(GN_CALL_LocalHangup, &cinfo, state); + drvinst->call_notification(GN_CALL_LocalHangup, &cinfo, state, drvinst->call_notification_user_data); else return GN_ERR_UNHANDLEDFRAME; @@ -1935,6 +1982,7 @@ static gn_error Initialise(gn_data *setu drvinst->charset = AT_CHAR_UNKNOWN; drvinst->no_smsc = 0; drvinst->call_notification = NULL; + drvinst->call_notification_user_data = NULL; drvinst->if_pos = 0; for (i = 0; i < GN_OP_AT_Max; i++) { Index: common/phones/nk6100.c =================================================================== RCS file: /sources/gnokii/gnokii/common/phones/nk6100.c,v retrieving revision 1.211 diff -u -p -r1.211 nk6100.c --- common/phones/nk6100.c 15 May 2007 09:29:55 -0000 1.211 +++ common/phones/nk6100.c 4 Jul 2007 10:18:22 -0000 @@ -1295,6 +1295,10 @@ static gn_error SetCellBroadcast(gn_data req = data->on_cell_broadcast ? req_ena : req_dis; DRVINSTANCE(state)->on_cell_broadcast = data->on_cell_broadcast; + if (data->on_cell_broadcast != NULL) + DRVINSTANCE(state)->cell_broadcast_user_data = data->user_data; + else + DRVINSTANCE(state)->cell_broadcast_user_data = NULL; if (sm_message_send(10, 0x02, req, state)) return GN_ERR_NOTREADY; return sm_block(0x02, data, state); @@ -1359,7 +1363,7 @@ static bool CheckIncomingSMS(struct gn_s return false; } - DRVINSTANCE(state)->on_sms(&sms, state); + DRVINSTANCE(state)->on_sms(&sms, state, DRVINSTANCE(state)->sms_user_data); dprintf("deleting sms#%hd\n", sms.number); gn_data_clear(&data); @@ -1386,10 +1390,12 @@ static gn_error SetOnSMS(gn_data *data, { if (data->on_sms) { DRVINSTANCE(state)->on_sms = data->on_sms; + DRVINSTANCE(state)->sms_user_data = data->user_data; DRVINSTANCE(state)->sms_notification_lost = true; FlushLostSMSNotifications(state); } else { DRVINSTANCE(state)->on_sms = NULL; + DRVINSTANCE(state)->sms_user_data = NULL; } return GN_ERR_NONE; @@ -1452,7 +1458,7 @@ static gn_error IncomingSMS1(int message cbmsg.channel = message[7]; n = char_7bit_unpack(0, length-10, sizeof(cbmsg.message)-1, message+10, cbmsg.message); char_ascii_decode(cbmsg.message, cbmsg.message, n); - DRVINSTANCE(state)->on_cell_broadcast(&cbmsg); + DRVINSTANCE(state)->on_cell_broadcast(&cbmsg, DRVINSTANCE(state)->cell_broadcast_user_data); } return GN_ERR_UNSOLICITED; @@ -3282,6 +3288,11 @@ static gn_error CancelCall1(gn_data *dat static gn_error SetCallNotification(gn_data *data, struct gn_statemachine *state) { DRVINSTANCE(state)->call_notification = data->call_notification; + if (data->call_notification != NULL) + DRVINSTANCE(state)->call_notification_user_data = data->user_data; + else + DRVINSTANCE(state)->call_notification_user_data = NULL; + return GN_ERR_NONE; } @@ -3354,7 +3365,7 @@ static gn_error IncomingCallInfo(int mes memset(&cinfo, 0, sizeof(cinfo)); cinfo.call_id = message[4]; if (DRVINSTANCE(state)->call_notification) - DRVINSTANCE(state)->call_notification(GN_CALL_Established, &cinfo, state); + DRVINSTANCE(state)->call_notification(GN_CALL_Established, &cinfo, state, DRVINSTANCE(state)->call_notification_user_data); if (!data->call_info) return GN_ERR_UNSOLICITED; data->call_info->call_id = message[4]; break; @@ -3369,7 +3380,7 @@ static gn_error IncomingCallInfo(int mes memset(&cinfo, 0, sizeof(cinfo)); cinfo.call_id = message[4]; if (DRVINSTANCE(state)->call_notification) - DRVINSTANCE(state)->call_notification(GN_CALL_RemoteHangup, &cinfo, state); + DRVINSTANCE(state)->call_notification(GN_CALL_RemoteHangup, &cinfo, state, DRVINSTANCE(state)->call_notification_user_data); return GN_ERR_UNSOLICITED; /* incoming call alert */ @@ -3387,7 +3398,7 @@ static gn_error IncomingCallInfo(int mes memcpy(cinfo.name, pos + 1, *pos); pos += *pos + 1; if (DRVINSTANCE(state)->call_notification) - DRVINSTANCE(state)->call_notification(GN_CALL_Incoming, &cinfo, state); + DRVINSTANCE(state)->call_notification(GN_CALL_Incoming, &cinfo, state, DRVINSTANCE(state)->call_notification_user_data); return GN_ERR_UNSOLICITED; /* answered call */ @@ -3399,7 +3410,7 @@ static gn_error IncomingCallInfo(int mes memset(&cinfo, 0, sizeof(cinfo)); cinfo.call_id = message[4]; if (DRVINSTANCE(state)->call_notification) - DRVINSTANCE(state)->call_notification(GN_CALL_LocalHangup, &cinfo, state); + DRVINSTANCE(state)->call_notification(GN_CALL_LocalHangup, &cinfo, state, DRVINSTANCE(state)->call_notification_user_data); if (!data->call_info) return GN_ERR_UNSOLICITED; data->call_info->call_id = message[4]; break; @@ -3449,7 +3460,7 @@ static gn_error IncomingCallInfo(int mes memset(&cinfo, 0, sizeof(cinfo)); cinfo.call_id = message[4]; if (DRVINSTANCE(state)->call_notification) - DRVINSTANCE(state)->call_notification(GN_CALL_Held, &cinfo, state); + DRVINSTANCE(state)->call_notification(GN_CALL_Held, &cinfo, state, DRVINSTANCE(state)->call_notification_user_data); return GN_ERR_UNSOLICITED; /* call resumed */ @@ -3457,7 +3468,7 @@ static gn_error IncomingCallInfo(int mes memset(&cinfo, 0, sizeof(cinfo)); cinfo.call_id = message[4]; if (DRVINSTANCE(state)->call_notification) - DRVINSTANCE(state)->call_notification(GN_CALL_Resumed, &cinfo, state); + DRVINSTANCE(state)->call_notification(GN_CALL_Resumed, &cinfo, state, DRVINSTANCE(state)->call_notification_user_data); return GN_ERR_UNSOLICITED; /* call switch */ Index: gnokii/gnokii-sms.c =================================================================== RCS file: /sources/gnokii/gnokii/gnokii/gnokii-sms.c,v retrieving revision 1.28 diff -u -p -r1.28 gnokii-sms.c --- gnokii/gnokii-sms.c 29 May 2007 22:19:01 -0000 1.28 +++ gnokii/gnokii-sms.c 4 Jul 2007 10:18:25 -0000 @@ -1317,7 +1317,7 @@ int showsmsfolderstatus(gn_data *data, s } /* SMS handler for --smsreader mode */ -static gn_error smsslave(gn_sms *message, struct gn_statemachine *state) +static gn_error smsslave(gn_sms *message, struct gn_statemachine *state, void *user_data) { FILE *output; char *s = message->user_data[0].u.text; @@ -1390,6 +1390,7 @@ int smsreader(gn_data *data, struct gn_s gn_error error; data->on_sms = smsslave; + error = gn_sm_functions(GN_OP_Subscribe, data, state); error = gn_sm_functions(GN_OP_OnSMS, data, state); if (!error) { /* We do not want to see texts forever - press Ctrl+C to stop. */ Index: include/data/at-emulator.h =================================================================== RCS file: /sources/gnokii/gnokii/include/data/at-emulator.h,v retrieving revision 1.12 diff -u -p -r1.12 at-emulator.h --- include/data/at-emulator.h 20 Sep 2004 16:05:38 -0000 1.12 +++ include/data/at-emulator.h 4 Jul 2007 10:18:25 -0000 @@ -47,7 +47,7 @@ bool gn_atem_command_plusc(char **buf); bool gn_atem_command_plusg(char **buf); int gn_atem_num_get(char **p); void gn_atem_modem_result(int code); -void gn_atem_call_passup(gn_call_status call_status, gn_call_info *call_info, struct gn_statemachine *state); +void gn_atem_call_passup(gn_call_status call_status, gn_call_info *call_info, struct gn_statemachine *state, void *user_data); void gn_atem_cid_out(gn_call_info *callinfo); bool gn_atem_command_diesis(char **buf); Index: include/gnokii/data.h =================================================================== RCS file: /sources/gnokii/gnokii/include/gnokii/data.h,v retrieving revision 1.81 diff -u -p -r1.81 data.h --- include/gnokii/data.h 29 May 2007 19:26:40 -0000 1.81 +++ include/gnokii/data.h 4 Jul 2007 10:18:25 -0000 @@ -82,13 +82,13 @@ 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); + gn_error (*on_sms)(gn_sms *message, struct gn_statemachine *state, void *user_data); int *display_status; - void (*on_cell_broadcast)(gn_cb_message *message); + void (*on_cell_broadcast)(gn_cb_message *message, void *user_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); + struct gn_statemachine *state, void *user_data); gn_rlp_f96_frame *rlp_frame; int rlp_out_dtx; void (*rlp_rx_callback)(gn_rlp_f96_frame *frame); @@ -104,6 +104,7 @@ typedef struct { gn_call_active *call_active; gn_file_list *file_list; gn_file *file; + void *user_data; } gn_data; /* Index: include/phones/atgen.h =================================================================== RCS file: /sources/gnokii/gnokii/include/phones/atgen.h,v retrieving revision 1.23 diff -u -p -r1.23 atgen.h --- include/phones/atgen.h 14 Apr 2007 19:36:35 -0000 1.23 +++ include/phones/atgen.h 4 Jul 2007 10:18:25 -0000 @@ -80,7 +80,8 @@ typedef struct { at_charset defaultcharset; at_charset charset; - void (*call_notification)(gn_call_status call_status, gn_call_info *call_info, struct gn_statemachine *state); + void (*call_notification)(gn_call_status call_status, gn_call_info *call_info, struct gn_statemachine *state, void *user_data); + void *call_notification_user_data; } at_driver_instance; #define AT_DRVINST(s) (*((at_driver_instance **)(&(s)->driver.driver_instance))) Index: include/phones/nk6100.h =================================================================== RCS file: /sources/gnokii/gnokii/include/phones/nk6100.h,v retrieving revision 1.27 diff -u -p -r1.27 nk6100.h --- include/phones/nk6100.h 10 Jan 2007 19:31:35 -0000 1.27 +++ include/phones/nk6100.h 4 Jul 2007 10:18:25 -0000 @@ -66,10 +66,13 @@ typedef struct { } nk6100_keytable; typedef struct { - void (*on_cell_broadcast)(gn_cb_message *msg); - void (*call_notification)(gn_call_status call_status, gn_call_info *call_info, struct gn_statemachine *state); + void (*on_cell_broadcast)(gn_cb_message *msg, void *user_data); + void *cell_broadcast_user_data; + void (*call_notification)(gn_call_status call_status, gn_call_info *call_info, struct gn_statemachine *state, void *user_data); + void *call_notification_user_data; void (*rlp_rx_callback)(gn_rlp_f96_frame *frame); - gn_error (*on_sms)(gn_sms *message, struct gn_statemachine *state); + gn_error (*on_sms)(gn_sms *message, struct gn_statemachine *state, void *user_data); + void *sms_user_data; unsigned char magic_bytes[4]; bool sms_notification_in_progress;