From 853e68b8ed145f5cd17edebb9cb634994851846f Mon Sep 17 00:00:00 2001 From: Kyeongchul Kim Date: Tue, 21 Aug 2012 22:23:12 +0900 Subject: [PATCH] release tizen_2.0 beta --- README | 1 - debian/changelog | 42 +- include/atchannel.h | 2 +- include/s_call.h | 4 +- include/s_modem.h | 3 +- include/s_network.h | 3 +- include/s_ps.h | 3 +- include/s_sim.h | 3 +- include/s_sms.h | 3 +- include/s_ss.h | 7 +- packaging/tel-plugin-atmodem.spec | 7 +- src/desc_at.c | 112 ++- src/s_call.c | 1046 +++++++++++++++++------------ src/s_common.c | 2 +- src/s_modem.c | 121 ++-- src/s_network.c | 26 +- src/s_ps.c | 121 ++-- src/s_sim.c | 330 +++++---- src/s_sms.c | 284 ++++---- src/s_ss.c | 661 ++++++++++-------- tel-plugin-atmodem.manifest | 11 + 21 files changed, 1538 insertions(+), 1254 deletions(-) delete mode 100644 README create mode 100644 tel-plugin-atmodem.manifest diff --git a/README b/README deleted file mode 100644 index 74c53d9..0000000 --- a/README +++ /dev/null @@ -1 +0,0 @@ -AT based modem plugin diff --git a/debian/changelog b/debian/changelog index 9532c9f..71f7a5c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,35 @@ +tel-plugin-atmodem (0.1.8) unstable; urgency=low + + * Fix OBS Build Error + * Git: slp/pkgs/t/tel-plugin-atmodem + * Tag: tel-plugin-atmodem_0.1.8 + + -- Youngman Park Fri, 25 May 2012 14:35:07 +0900 + +tel-plugin-atmodem (0.1.7) unstable; urgency=low + + * Fix Build Error + * Git: slp/pkgs/t/tel-plugin-atmodem + * Tag: tel-plugin-atmodem_0.1.7 + + -- Youngman Park Fri, 18 May 2012 11:25:07 +0900 + +tel-plugin-atmodem (0.1.6) unstable; urgency=low + + * Add Call New API ( call custom service ) + * Git: slp/pkgs/t/tel-plugin-atmodem + * Tag: tel-plugin-atmodem_0.1.6 + + -- Youngman Park Mon, 07 May 2012 17:10:07 +0900 + +tel-plugin-atmodem (0.1.5) unstable; urgency=low + + * Adding the at the last SIM/SMS AT cmds + * Git: slp/pkgs/t/tel-plugin-atmodem + * Tag: tel-plugin-atmodem_0.1.5 + + -- JaYoung Gu Tue, 11 Apr 2012 08:17:07 +0900 + tel-plugin-atmodem (0.1.4) unstable; urgency=low * version up for code sync with public binary @@ -9,7 +41,7 @@ tel-plugin-atmodem (0.1.4) unstable; urgency=low tel-plugin-atmodem (0.1.3) unstable; urgency=low * Fix prefix (TAPI_ to TCORE_) - * Git: pkgs/t/tel-plugin-atmodem + * Git: slp/pkgs/t/tel-plugin-atmodem * Tag: tel-plugin-atmodem_0.1.3 -- Inho Oh Tue, 27 Mar 2012 22:11:38 +0900 @@ -17,15 +49,15 @@ tel-plugin-atmodem (0.1.3) unstable; urgency=low tel-plugin-atmodem (0.1.2) unstable; urgency=low * Fix build break and Add .spec file for OBS - * Git: pkgs/t/tel-plugin-atmodem - * tel-plugin-atmodem_0.1.2 + * Git: slp/pkgs/t/tel-plugin-atmodem + * Tag: tel-plugin-atmodem_0.1.2 -- DongHoo Park Sat, 17 Mar 2012 02:30:20 +0900 tel-plugin-atmodem (0.1.1) unstable; urgency=low * Remove unused header - * Git: pkgs/t/tel-plugin-atmodem + * Git: slp/pkgs/t/tel-plugin-atmodem * Tag: tel-plugin-atmodem_0.1.1 -- Inho Oh Fri, 16 Mar 2012 02:39:47 +0900 @@ -33,7 +65,7 @@ tel-plugin-atmodem (0.1.1) unstable; urgency=low tel-plugin-atmodem (0.1.0) unstable; urgency=low * Initial - * Git: pkgs/t/tel-plugin-atmodem + * Git: slp/pkgs/t/tel-plugin-atmodem * Tag: tel-plugin-atmodem_0.1.0 -- Inho Oh Thu, 15 Mar 2012 22:37:29 +0900 diff --git a/include/atchannel.h b/include/atchannel.h index c1649e7..e79f69b 100644 --- a/include/atchannel.h +++ b/include/atchannel.h @@ -159,7 +159,7 @@ TReturn convertCMEError(enum ATCMEError error); #define AT_NOTI_TOK_ERROR_INTERNEL(token, file, line) \ {\ err("AT_NOTI_TOK_ERROR_INTERNEL %s:%d %s",file,line,token?token:"");\ - return;\ + return TRUE;\ }\ #endif /* __ATCHANNEL_H__ */ diff --git a/include/s_call.h b/include/s_call.h index d65ca92..c5135ea 100644 --- a/include/s_call.h +++ b/include/s_call.h @@ -21,8 +21,8 @@ #ifndef __S_CALL_H__ #define __S_CALL_H__ -gboolean s_call_init( TcorePlugin *p ); -void s_call_exit( TcorePlugin *p ); +gboolean s_call_init(TcorePlugin *p, TcoreHal *h); +void s_call_exit(TcorePlugin *p); #endif diff --git a/include/s_modem.h b/include/s_modem.h index 063bafe..f4aa759 100644 --- a/include/s_modem.h +++ b/include/s_modem.h @@ -21,8 +21,9 @@ #ifndef __S_MODEM_H__ #define __S_MODEM_H__ -gboolean s_modem_init(TcorePlugin *p); +gboolean s_modem_init(TcorePlugin *p, TcoreHal *h); void s_modem_exit(TcorePlugin *p); gboolean s_modem_send_poweron(TcorePlugin *p); + #endif diff --git a/include/s_network.h b/include/s_network.h index 2432da1..a02c75d 100644 --- a/include/s_network.h +++ b/include/s_network.h @@ -21,8 +21,7 @@ #ifndef __S_NETWORK_H__ #define __S_NETWORK_H__ - -gboolean s_network_init(TcorePlugin *p); +gboolean s_network_init(TcorePlugin *p, TcoreHal *h); void s_network_exit(TcorePlugin *p); #endif diff --git a/include/s_ps.h b/include/s_ps.h index 4a2d38d..0707297 100644 --- a/include/s_ps.h +++ b/include/s_ps.h @@ -21,8 +21,7 @@ #ifndef __S_PS_H__ #define __S_PS_H__ - -gboolean s_ps_init(TcorePlugin *p); +gboolean s_ps_init(TcorePlugin *p, TcoreHal *h); void s_ps_exit(TcorePlugin *p); #endif diff --git a/include/s_sim.h b/include/s_sim.h index f42de62..758d677 100644 --- a/include/s_sim.h +++ b/include/s_sim.h @@ -21,8 +21,7 @@ #ifndef __S_SIM_H__ #define __S_SIM_H__ - -gboolean s_sim_init(TcorePlugin *p); +gboolean s_sim_init(TcorePlugin *p, TcoreHal *h); void s_sim_exit(TcorePlugin *p); #endif diff --git a/include/s_sms.h b/include/s_sms.h index a0e5b92..a477258 100644 --- a/include/s_sms.h +++ b/include/s_sms.h @@ -21,8 +21,7 @@ #ifndef __S_SMS_H__ #define __S_SMS_H__ - -gboolean s_sms_init(TcorePlugin *p); +gboolean s_sms_init(TcorePlugin *p, TcoreHal *h); void s_sms_exit(TcorePlugin *p); #endif diff --git a/include/s_ss.h b/include/s_ss.h index a80b73f..4467797 100644 --- a/include/s_ss.h +++ b/include/s_ss.h @@ -21,10 +21,7 @@ #ifndef __S_SS_H__ #define __S_SS_H__ - -gboolean s_ss_init( TcorePlugin *p ); -void s_ss_exit( TcorePlugin *p ); - - +gboolean s_ss_init(TcorePlugin *p, TcoreHal *h); +void s_ss_exit(TcorePlugin *p); #endif diff --git a/packaging/tel-plugin-atmodem.spec b/packaging/tel-plugin-atmodem.spec index 944d965..e6ffdb6 100644 --- a/packaging/tel-plugin-atmodem.spec +++ b/packaging/tel-plugin-atmodem.spec @@ -1,7 +1,7 @@ #sbs-git:slp/pkgs/t/tel-plugin-atmodem -Name: tel-plugin-atmodem -Summary: Telephony AT Modem library -Version: 0.1.4 +Name: tel-plugin-atmodem +Summary: Telephony AT Modem library +Version: 0.1.15 Release: 1 Group: System/Libraries License: Apache @@ -52,6 +52,7 @@ rm -rf %{buildroot} %make_install %files +%manifest tel-plugin-atmodem.manifest %defattr(-,root,root,-) #%doc COPYING %{_libdir}/telephony/plugins/atmodem-plugin* diff --git a/src/desc_at.c b/src/desc_at.c index 702a46c..41b5a1c 100644 --- a/src/desc_at.c +++ b/src/desc_at.c @@ -107,12 +107,12 @@ static void stopSMSBuffering() if(spc.line1 != NULL) free(spc.line1); spc.line1 = NULL; - + spc.sms_pdu_len = 0; spc.cum_pdu_len =0; spc.sms_pdu_mode = FALSE; - + if(spc.ppdu !=NULL) free(spc.ppdu); spc.ppdu = NULL; @@ -127,12 +127,12 @@ static void handleFinalResponse(TcoreHal* hal, const char *line) dbg("Final response arrived. call response callback"); // 1. add final rsp string into sp_response - sp_response->finalResponse = strdup(line); + sp_response->finalResponse = strdup(line); - // 1.1 reverse intermediates + // 1.1 reverse intermediates reverseIntermediates(sp_response); - // 2. pop head pending from queue -> call callback hung pending(on_response) -> + // 2. pop head pending from queue -> call callback hung pending(on_response) -> // release sp_response/s_responsePrefix -> release userRequest/pending -> send next pending from queue // warning) length have no meaning. data always pointer sp_response tcore_hal_dispatch_response_data(hal, ID_RESERVED_AT, strlen(line), sp_response); @@ -152,14 +152,14 @@ static void onUnsolicited (const char *s, TcorePlugin* plugin, char* sms_pdu, in if(strStartsWith(s,"+CMT:")){ - //SMS incoming + //SMS incoming cmd = EVENT_SMS_INCOM_MSG; - + smsPdu.cmdLine = strdup(s); smsPdu.pdu = malloc(pdu_len); memcpy(smsPdu.pdu, sms_pdu, pdu_len); smsPdu.len = pdu_len; - + tcore_plugin_core_object_event_emit(plugin, cmd, &smsPdu); free(smsPdu.cmdLine); free(smsPdu.pdu); @@ -168,7 +168,7 @@ static void onUnsolicited (const char *s, TcorePlugin* plugin, char* sms_pdu, in } /* Ignore unsolicited responses until we're initialized. * This is OK because the RIL library will poll for initial state - */ + */ else if (strStartsWith(s,"%SCFUN:")){ /* SS specific -- modem power status notification */ cmd = EVENT_MODEM_PHONE_STATE; @@ -199,7 +199,7 @@ static void onUnsolicited (const char *s, TcorePlugin* plugin, char* sms_pdu, in free(line); - dbg("%SCLCC cmd : %d",cmd); + dbg("%SCLCC cmd : %d",cmd); } else if (strStartsWith(s,"+CRING:") || strStartsWith(s,"RING")){ @@ -217,17 +217,17 @@ static void onUnsolicited (const char *s, TcorePlugin* plugin, char* sms_pdu, in else if(strStartsWith(s,"+CCWA:")){ dbg("call waiting notification - wait for SCLCC with status 5"); return; - } + } else if (strStartsWith(s,"+CREG:") || strStartsWith(s,"+CGREG:")){ cmd = EVENT_NETWORK_REGISTRATION; } else if (strStartsWith(s,"+CMGS:")) { cmd = EVENT_SMS_SEND_ACK; - } + } else if (strStartsWith(s,"%SCDEV:")) { cmd = EVENT_SMS_DEVICE_READY; - } + } else if(strStartsWith(s,"+CIEV:")){ cmd = EVENT_NETWORK_ICON_INFO; } @@ -241,17 +241,17 @@ static void onUnsolicited (const char *s, TcorePlugin* plugin, char* sms_pdu, in /* Send Event */ if(cmd) { - line = strdup(s); + line = strdup(s); tcore_plugin_core_object_event_emit(plugin, cmd, line); free(line); } - + } static void processLine(TcoreHal *hal, char *line, TcorePlugin* p) { TcoreQueue* pPendingQueue = NULL; - TcorePending* pPending =NULL; + TcorePending* pPending =NULL; gboolean result_status = FALSE; pPendingQueue =(TcoreQueue*)tcore_hal_ref_queue(hal); pPending = (TcorePending*)tcore_queue_ref_head(pPendingQueue); //topmost request @@ -260,7 +260,7 @@ static void processLine(TcoreHal *hal, char *line, TcorePlugin* p) if(TCORE_RETURN_SUCCESS == tcore_pending_get_send_status(pPending, &result_status) && (result_status == FALSE))//request not sent but data comes - Unsolicited msg! - { + { /* no command pending */ dbg("no command pending. call onUnsolicited()"); onUnsolicited(line, p, NULL, 0); @@ -269,7 +269,7 @@ static void processLine(TcoreHal *hal, char *line, TcorePlugin* p) sp_response->success = 1; handleFinalResponse(hal, line); } else if (isFinalResponseError(line)) { - dbg("final response -ERROR. call handleFinalResponse()"); + dbg("final response -ERROR. call handleFinalResponse()"); sp_response->success = 0; handleFinalResponse(hal, line); } else switch (s_type) { @@ -303,7 +303,7 @@ static void processLine(TcoreHal *hal, char *line, TcorePlugin* p) addIntermediate(line); } else { /* we already have an intermediate response */ - dbg("[SINGLELINE]:we already have an intermediate response. call onUnsolicited()"); + dbg("[SINGLELINE]:we already have an intermediate response. call onUnsolicited()"); onUnsolicited(line,p, NULL, 0); } } @@ -345,12 +345,12 @@ static gboolean readline(TcoreHal *hal, unsigned int data_len, const void *data, * the buffer continues until a \0 */ -/*check sms pdu cumulating process - data hijacking*/ + /*check sms pdu cumulating process - data hijacking*/ if(spc.sms_pdu_mode == TRUE) { //continue sms pdu buffering dbg("resume pdu buffering. pdu size : %d, gathered size : %d",spc.sms_pdu_len,spc.cum_pdu_len); len = spc.sms_pdu_len - spc.cum_pdu_len; //length needed - + if(act_len > len){ dbg("whole pdu received - data surplus"); memcpy(spc.ppdu_marker, act_data,len);//data fully copied @@ -360,20 +360,20 @@ static gboolean readline(TcoreHal *hal, unsigned int data_len, const void *data, act_data = act_data + len; act_len = act_len - len; dbg("recv string changed to = %s, length changed to : %d", (char*)act_data, act_len); - + onUnsolicited(spc.line1, p, spc.ppdu, spc.sms_pdu_len); - stopSMSBuffering(); - dbg("incoming sms handled. back to normal mode & continue"); + stopSMSBuffering(); + dbg("incoming sms handled. back to normal mode & continue"); } else if(act_len == len){ dbg("exactly whole pdu received"); - + memcpy(spc.ppdu_marker, act_data,len);//data fully copied spc.cum_pdu_len = spc.cum_pdu_len + len; - + onUnsolicited(spc.line1, p, spc.ppdu, spc.sms_pdu_len); - stopSMSBuffering(); - dbg("all incoming data consumed. return"); + stopSMSBuffering(); + dbg("all incoming data consumed. return"); return TRUE; } else { @@ -385,17 +385,17 @@ static gboolean readline(TcoreHal *hal, unsigned int data_len, const void *data, return TRUE; } } - - - if (*s_ATBufferCur == '\0') + + + if (*s_ATBufferCur == '\0') { /* empty buffer */ s_ATBufferCur = s_ATBuffer; *s_ATBufferCur = '\0'; p_read = s_ATBuffer; } - else - { + else + { /* *s_ATBufferCur != '\0' */ /* there's data in the buffer from the last read */ @@ -405,7 +405,7 @@ static gboolean readline(TcoreHal *hal, unsigned int data_len, const void *data, p_eol = findNextEOL(s_ATBufferCur); - if (p_eol == NULL) + if (p_eol == NULL) { /* a partial line. move it up and prepare to read more */ unsigned int len; @@ -463,7 +463,7 @@ static gboolean readline(TcoreHal *hal, unsigned int data_len, const void *data, p_eol = findNextEOL(s_ATBufferCur); - if(p_eol !=NULL) /*end of line found!*/ + if(p_eol !=NULL) /*end of line found!*/ { /* a full line in the buffer. Place a \0 over the \r and return */ ret = s_ATBufferCur; @@ -472,44 +472,44 @@ static gboolean readline(TcoreHal *hal, unsigned int data_len, const void *data, /* and there will be a \0 at *p_read */ dbg("complete line found. process it/n"); - dbg("rsp line : %s/n",ret); + dbg("rsp line : %s/n",ret); if(1 == isSMSUnsolicited(ret)) { dbg("start of incoming sms found!!! - next data is PDU"); startSMSBuffering(ret); s_ATBufferCur++; //move starting point by 1 - it goes to the very starting point of PDU leftover_len = p_marker - s_ATBufferCur; - + dbg("count leftover : %d", leftover_len); if(leftover_len <0){ - dbg("pointer address error -serious!"); + dbg("pointer address error -serious!"); return FALSE; } else if(leftover_len ==0){ - dbg("no pdu received - wait for incoming data"); + dbg("no pdu received - wait for incoming data"); spc.cum_pdu_len =0; spc.ppdu_marker = spc.ppdu; } else if(leftover_len >= spc.sms_pdu_len){ - dbg("whole pdu already received!"); + dbg("whole pdu already received!"); memcpy(spc.ppdu, s_ATBufferCur, spc.sms_pdu_len); spc.cum_pdu_len = spc.sms_pdu_len; onUnsolicited(spc.line1, p, spc.ppdu, spc.sms_pdu_len); s_ATBufferCur = s_ATBufferCur+spc.sms_pdu_len; - dbg("move buffercur to point the very end of pdu!"); + dbg("move buffercur to point the very end of pdu!"); stopSMSBuffering(); } else { - dbg("staring part of pdu received!"); - memcpy(spc.ppdu, s_ATBufferCur,leftover_len); - spc.ppdu_marker = spc.ppdu + leftover_len; - spc.cum_pdu_len = leftover_len; - s_ATBufferCur = s_ATBufferCur + leftover_len; - } + dbg("staring part of pdu received!"); + memcpy(spc.ppdu, s_ATBufferCur,leftover_len); + spc.ppdu_marker = spc.ppdu + leftover_len; + spc.cum_pdu_len = leftover_len; + s_ATBufferCur = s_ATBufferCur + leftover_len; + } } else - { + { processLine(hal, ret,p); } } @@ -558,19 +558,17 @@ static gboolean on_init(TcorePlugin *p) return FALSE; } - tcore_plugin_set_hal(p, h); - tcore_hal_add_send_hook(h, on_hal_send, p); tcore_hal_add_recv_callback(h, on_hal_recv, p); - s_modem_init(p); - s_network_init(p); - s_sim_init(p); + s_modem_init(p, h); + s_network_init(p, h); + s_sim_init(p, h); // s_sap_init(p); - s_ps_init(p); - s_call_init(p); - s_ss_init(p); - s_sms_init(p); + s_ps_init(p, h); + s_call_init(p, h); + s_ss_init(p, h); + s_sms_init(p, h); // s_phonebook_init(p); #ifndef TEST_AT_SOCKET tcore_hal_set_power(h, TRUE); diff --git a/src/s_call.c b/src/s_call.c index e69ad9d..0a02aa1 100644 --- a/src/s_call.c +++ b/src/s_call.c @@ -44,17 +44,12 @@ extern struct ATResponse *sp_response; extern char *s_responsePrefix; extern enum ATCommandType s_type; -struct call_confirm_info_t { - CallObject *co; - enum tcore_response_command resp; -}; - struct CLCC_call_t { struct CLCC_call_info_t { int id; - enum tcore_call_direction direction; + enum tcore_call_direction direction; enum tcore_call_status status; - enum tcore_call_type type; + enum tcore_call_type type; int mpty; int num_len; int num_type; @@ -63,7 +58,7 @@ struct CLCC_call_t { }; -static gboolean _call_request_message( CoreObject *o, UserRequest* ur, char* cmd_string, +static gboolean _call_request_message( CoreObject *o, UserRequest* ur, char* cmd_string, unsigned int cmd_length, void* on_resp, void* user_data); static void _call_status_idle( TcorePlugin *p, CallObject *co ); @@ -81,18 +76,11 @@ static gboolean _call_is_in_mpty(int mpty); static TReturn _call_list_get( CoreObject *o, CallObject *co ); static void on_confirmation_call_message_send( TcorePending *p, gboolean result, void *user_data ); // from Kernel -static void on_confirmation_call_request( TcorePending *p, int data_len, const void *data, void *user_data ); // from Modem -static void on_confirmation_call_hold( TcorePending *p, int data_len, const void *data, void *user_data ); -static void on_confirmation_call_swap( TcorePending *p, int data_len, const void *data, void *user_data ); -static void on_confirmation_call_split( TcorePending *p, int data_len, const void *data, void *user_data ); -static void on_confirmation_call_hold_and_accept( TcorePending *p, int data_len, const void *data, void *user_data ); -static void on_confirmation_call_endall( TcorePending *p, int data_len, const void *data, void *user_data ); // from Modem - static void on_response_call_list_get(TcorePending *p, int data_len, const void *data, void *user_data); -static void on_notification_call_waiting( CoreObject *o, const void *data, void *user_data ); -static void on_notification_call_incoming( CoreObject *o, const void *data, void *user_data ); -static void on_notification_call_status( CoreObject *o, const void *data, void *user_data); +static gboolean on_notification_call_waiting( CoreObject *o, const void *data, void *user_data ); +static gboolean on_notification_call_incoming( CoreObject *o, const void *data, void *user_data ); +static gboolean on_notification_call_status( CoreObject *o, const void *data, void *user_data); static int _callFromCLCCLine(char *line, struct CLCC_call_t *p_call); @@ -129,8 +117,8 @@ static enum tcore_call_status _call_status(unsigned int status) case 5: return TCORE_CALL_STATUS_WAITING; case 6: - return TCORE_CALL_STATUS_DIALING; //connecting not exist. set to dialing - case 7: + return TCORE_CALL_STATUS_DIALING; //connecting not exist. set to dialing + case 7: return TCORE_CALL_STATUS_IDLE; default: @@ -186,7 +174,7 @@ static gboolean _call_request_message( CoreObject *o, info_len = sizeof(struct ATReqMetaInfo); dbg("_call_request_message - cmd : %s, cmdlen :%d (including '\r')",cmd_string, cmd_len); - + pending = tcore_pending_new(o, ID_RESERVED_AT); tcore_pending_set_request_data(pending, cmd_len, cmd_string); @@ -205,14 +193,14 @@ static gboolean _call_request_message( CoreObject *o, } p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); tcore_hal_send_request(h, pending); return TRUE; } -static void _call_status_idle( TcorePlugin *p, CallObject *co ) +static void _call_status_idle( TcorePlugin *p, CallObject *co ) { struct tnoti_call_status_idle data; @@ -233,7 +221,7 @@ static void _call_status_idle( TcorePlugin *p, CallObject *co ) tcore_call_object_set_status( co, TCORE_CALL_STATUS_IDLE ); - tcore_server_send_notification( tcore_plugin_ref_server(p), + tcore_server_send_notification( tcore_plugin_ref_server(p), o, TNOTI_CALL_STATUS_IDLE, sizeof(struct tnoti_call_status_idle), @@ -264,7 +252,7 @@ static void _call_status_dialing( TcorePlugin *p, CallObject *co ) tcore_call_object_set_status( co, TCORE_CALL_STATUS_DIALING ); - tcore_server_send_notification( tcore_plugin_ref_server(p), + tcore_server_send_notification( tcore_plugin_ref_server(p), tcore_plugin_ref_core_object(p, "call"), TNOTI_CALL_STATUS_DIALING, sizeof(struct tnoti_call_status_dialing), @@ -294,7 +282,7 @@ static void _call_status_alert( TcorePlugin *p, CallObject *co ) tcore_call_object_set_status( co, TCORE_CALL_STATUS_ALERT ); - tcore_server_send_notification( tcore_plugin_ref_server(p), + tcore_server_send_notification( tcore_plugin_ref_server(p), tcore_plugin_ref_core_object(p, "call"), TNOTI_CALL_STATUS_ALERT, sizeof(struct tnoti_call_status_alert), @@ -321,7 +309,7 @@ static void _call_status_active( TcorePlugin *p, CallObject *co ) tcore_call_object_set_status( co, TCORE_CALL_STATUS_ACTIVE ); - tcore_server_send_notification( tcore_plugin_ref_server(p), + tcore_server_send_notification( tcore_plugin_ref_server(p), tcore_plugin_ref_core_object(p, "call"), TNOTI_CALL_STATUS_ACTIVE, sizeof(struct tnoti_call_status_active), @@ -344,7 +332,7 @@ static void _call_status_held( TcorePlugin *p, CallObject *co ) tcore_call_object_set_status( co, TCORE_CALL_STATUS_HELD ); - tcore_server_send_notification( tcore_plugin_ref_server(p), + tcore_server_send_notification( tcore_plugin_ref_server(p), tcore_plugin_ref_core_object(p, "call"), TNOTI_CALL_STATUS_HELD, sizeof(struct tnoti_call_status_held), @@ -385,7 +373,7 @@ static void _call_status_incoming( TcorePlugin *p, CallObject *co ) data.active_line = tcore_call_object_get_active_line( co ); dbg("data.active_line : [%d]", data.active_line ); - tcore_server_send_notification( tcore_plugin_ref_server(p), + tcore_server_send_notification( tcore_plugin_ref_server(p), tcore_plugin_ref_core_object(p, "call"), TNOTI_CALL_STATUS_INCOMING, sizeof(struct tnoti_call_status_incoming), @@ -440,11 +428,11 @@ static void _call_branch_by_status( TcorePlugin *p, CallObject *co, unsigned int static TReturn _call_list_get( CoreObject *o, CallObject *co ) { gboolean ret = FALSE; - UserRequest* ur = NULL; + UserRequest* ur = NULL; - char* cmd_str = NULL; + char* cmd_str = NULL; struct ATReqMetaInfo metainfo; - int info_len =0; + int info_len =0; if ( !o ) return TCORE_RETURN_FAILURE; @@ -460,8 +448,8 @@ static TReturn _call_list_get( CoreObject *o, CallObject *co ) cmd_str = g_strdup("AT+CLCC\r"); - ret = _call_request_message ( o, ur, cmd_str, strlen(cmd_str), on_response_call_list_get, NULL); - + ret = _call_request_message ( o, ur, cmd_str, strlen(cmd_str), on_response_call_list_get, NULL); + if ( !ret ) return TCORE_RETURN_FAILURE; @@ -489,11 +477,11 @@ static void on_confirmation_call_message_send( TcorePending *p, gboolean result, metainfo = (struct ATReqMetaInfo*)tcore_user_request_ref_metainfo(ur,&info_len); if((metainfo->type == SINGLELINE)|| - (metainfo->type == MULTILINE)) + (metainfo->type == MULTILINE)) { - //cp rsp prefix + //cp rsp prefix s_responsePrefix = strdup(metainfo->responsePrefix); - dbg("duplicating responsePrefix : %s\n", s_responsePrefix); + dbg("duplicating responsePrefix : %s\n", s_responsePrefix); } else { @@ -501,7 +489,7 @@ static void on_confirmation_call_message_send( TcorePending *p, gboolean result, } //set atcmd type into s_type - s_type = metainfo->type; + s_type = metainfo->type; if (result == FALSE) { /* Fail */ @@ -512,167 +500,315 @@ static void on_confirmation_call_message_send( TcorePending *p, gboolean result, } } -static void _confirmation_call( CoreObject *o, UserRequest *ur, TReturn err, struct call_confirm_info_t *ci ) +static void on_confirmation_call_outgoing( TcorePending *p, int data_len, const void *data, void *user_data ) { - struct tresp_call_general resp; + CoreObject *o = 0; + UserRequest *ur = 0; + + struct tresp_call_dial resp; - if ( !ci->co ) - dbg("call object is NULL, is it general requst??"); + o = tcore_pending_ref_core_object(p); + ur = tcore_pending_ref_user_request(p); - resp.type = (enum telephony_call_type )tcore_call_object_get_type( ci->co ); - resp.id = tcore_call_object_get_id( ci->co ); - resp.err = err; + if(sp_response->success >0) + resp.err = TCORE_RETURN_SUCCESS; + else + resp.err = TCORE_RETURN_FAILURE; + + ReleaseResponse(); if (ur) { - tcore_user_request_send_response(ur, ci->resp, sizeof(struct tresp_call_general), &resp); + tcore_user_request_send_response(ur, TRESP_CALL_DIAL, sizeof(struct tresp_call_dial), &resp); } else { dbg("[ error ] ur is NULL"); return ; } +} - dbg("resp.err : [ 0x%x ]", resp.err); +static void on_confirmation_call_accept( TcorePending *p, int data_len, const void *data, void *user_data ) +{ + CoreObject *o = 0; + UserRequest *ur = 0; -#if 0 - _call_list_get( o, ci->co ); -#endif + struct tresp_call_answer resp; + + o = tcore_pending_ref_core_object(p); + ur = tcore_pending_ref_user_request(p); + + if(sp_response->success >0) + resp.err = TCORE_RETURN_SUCCESS; + else + resp.err = TCORE_RETURN_FAILURE; + + ReleaseResponse(); + + resp.id = tcore_call_object_get_id( (CallObject*)user_data ); + + if (ur) { + tcore_user_request_send_response(ur, TRESP_CALL_ANSWER, sizeof(struct tresp_call_answer), &resp); + } else { + dbg("[ error ] ur is NULL"); + return ; + } } -static void on_confirmation_call_request( TcorePending *p, int data_len, const void *data, void *user_data ) +static void on_confirmation_call_reject( TcorePending *p, int data_len, const void *data, void *user_data ) { - CoreObject* o = 0; - UserRequest* ur = 0; - TReturn err = TCORE_RETURN_SUCCESS; + CoreObject *o = 0; + UserRequest *ur = 0; - struct call_confirm_info_t* ci = 0; + struct tresp_call_answer resp; o = tcore_pending_ref_core_object(p); ur = tcore_pending_ref_user_request(p); + if(sp_response->success >0) + resp.err = TCORE_RETURN_SUCCESS; + else + resp.err = TCORE_RETURN_FAILURE; + + ReleaseResponse(); + + resp.id = tcore_call_object_get_id( (CallObject*)user_data ); - ci = (struct call_confirm_info_t *)user_data; - if ( !ci ) { - dbg("[ error ] user_data is NULL"); + if (ur) { + tcore_user_request_send_response(ur, TRESP_CALL_ANSWER, sizeof(struct tresp_call_answer), &resp); + + } else { + dbg("[ error ] ur is NULL"); return ; } +} + +static void on_confirmation_call_replace( TcorePending *p, int data_len, const void *data, void *user_data ) +{ + CoreObject *o = 0; + UserRequest *ur = 0; + + struct tresp_call_answer resp; + + o = tcore_pending_ref_core_object(p); + ur = tcore_pending_ref_user_request(p); + + resp.id = tcore_call_object_get_id( (CallObject*)user_data ); if(sp_response->success >0) - err = TCORE_RETURN_SUCCESS; + resp.err = TCORE_RETURN_SUCCESS; else - err = TCORE_RETURN_FAILURE; + resp.err = TCORE_RETURN_FAILURE; ReleaseResponse(); - _confirmation_call( o, ur, err, ci ); - g_free( ci ); + if (ur) { + tcore_user_request_send_response(ur, TRESP_CALL_ANSWER, sizeof(struct tresp_call_answer), &resp); + + } else { + dbg("[ error ] ur is NULL"); + return ; + } } -static void on_confirmation_call_split( TcorePending *p, int data_len, const void *data, void *user_data ) +static void on_confirmation_call_hold_and_accept( TcorePending *p, int data_len, const void *data, void *user_data ) { CoreObject* o = 0; UserRequest* ur = 0; - struct tresp_call_general resp; - struct call_confirm_info_t *ci = 0; + struct tresp_call_answer resp; dbg("ok, function entrance"); - printResponse(); o = tcore_pending_ref_core_object(p); ur = tcore_pending_ref_user_request(p); - ci = (struct call_confirm_info_t *)user_data; - if ( !ci ) { - dbg("[ error ] user_data is NULL"); - goto out; - } + resp.id = tcore_call_object_get_id( (CallObject*)user_data ); - resp.type = (enum telephony_call_type )tcore_call_object_get_type( ci->co ); - resp.id = tcore_call_object_get_id( ci->co ); - if(sp_response->success >0){ - resp.err = FALSE; - }else{ - resp.err = TRUE; - } + if(sp_response->success >0) + resp.err = TCORE_RETURN_SUCCESS; + else + resp.err = TCORE_RETURN_FAILURE; ReleaseResponse(); + if ( ur ) { - tcore_user_request_send_response(ur, ci->resp, sizeof(struct tresp_call_general), &resp); + tcore_user_request_send_response(ur, TRESP_CALL_ANSWER, sizeof(struct tresp_call_answer), &resp); } else { dbg("[ error ] ur is NULL"); - goto out; + return ; } if ( !resp.err ) { - GSList *active = 0; + GSList *l = 0; CallObject *co = 0; - active = tcore_call_object_find_by_status( o, TCORE_CALL_STATUS_ACTIVE ); - if ( !active ) { + l = tcore_call_object_find_by_status( o, TCORE_CALL_STATUS_ACTIVE ); + if ( !l ) { dbg("[ error ] can't find active call"); - goto out; + return ; } - co = (CallObject*)active->data; + co = (CallObject*)l->data; if ( !co ) { dbg("[ error ] can't get active call object"); - goto out; + return ; } tcore_call_object_set_status( co, TCORE_CALL_STATUS_HELD ); - tcore_call_object_set_status( ci->co, TCORE_CALL_STATUS_ACTIVE ); } +} + +static void on_confirmation_call_release_all( TcorePending *p, int data_len, const void *data, void *user_data ) +{ + CoreObject *o = 0; + UserRequest *ur = 0; + + struct tresp_call_end resp; -out: - g_free( ci ); + o = tcore_pending_ref_core_object(p); + ur = tcore_pending_ref_user_request(p); + + + resp.type = CALL_END_TYPE_ALL; + resp.id = tcore_call_object_get_id( (CallObject*)user_data ); + + if(sp_response->success >0) + resp.err = TCORE_RETURN_SUCCESS; + else + resp.err = TCORE_RETURN_FAILURE; + + ReleaseResponse(); + + if (ur) { + tcore_user_request_send_response(ur, TRESP_CALL_END, sizeof(struct tresp_call_end), &resp); + } else { + dbg("[ error ] ur is NULL"); + return ; + } +} + + + +static void on_confirmation_call_release_specific( TcorePending *p, int data_len, const void *data, void *user_data ) +{ + CoreObject *o = 0; + UserRequest *ur = 0; + + struct tresp_call_end resp; + + o = tcore_pending_ref_core_object(p); + ur = tcore_pending_ref_user_request(p); + + resp.type = CALL_END_TYPE_DEFAULT; + resp.id = tcore_call_object_get_id( (CallObject*)user_data ); + + if(sp_response->success >0) + resp.err = TCORE_RETURN_SUCCESS; + else + resp.err = TCORE_RETURN_FAILURE; + + ReleaseResponse(); + + if (ur) { + tcore_user_request_send_response(ur, TRESP_CALL_END, sizeof(struct tresp_call_end), &resp); + + } else { + dbg("[ error ] ur is NULL"); + return ; + } +} + +static void on_confirmation_call_release_all_active( TcorePending *p, int data_len, const void *data, void *user_data ) +{ + CoreObject *o = 0; + UserRequest *ur = 0; + + struct tresp_call_end resp; + + o = tcore_pending_ref_core_object(p); + ur = tcore_pending_ref_user_request(p); + + resp.type = CALL_END_TYPE_ACTIVE_ALL; + resp.id = tcore_call_object_get_id( (CallObject*)user_data ); + + if(sp_response->success >0) + resp.err = TCORE_RETURN_SUCCESS; + else + resp.err = TCORE_RETURN_FAILURE; + + ReleaseResponse(); + + if (ur) { + tcore_user_request_send_response(ur, TRESP_CALL_END, sizeof(struct tresp_call_end), &resp); + + } else { + dbg("[ error ] ur is NULL"); + return ; + } } +static void on_confirmation_call_release_all_held( TcorePending *p, int data_len, const void *data, void *user_data ) +{ + CoreObject *o = 0; + UserRequest *ur = 0; + + struct tresp_call_end resp; + + o = tcore_pending_ref_core_object(p); + ur = tcore_pending_ref_user_request(p); + + resp.type = CALL_END_TYPE_HOLD_ALL; + resp.id = tcore_call_object_get_id( (CallObject*)user_data ); + + if(sp_response->success >0) + resp.err = TCORE_RETURN_SUCCESS; + else + resp.err = TCORE_RETURN_FAILURE; + + ReleaseResponse(); + + if (ur) { + tcore_user_request_send_response(ur, TRESP_CALL_END, sizeof(struct tresp_call_end), &resp); + + } else { + dbg("[ error ] ur is NULL"); + return ; + } +} static void on_confirmation_call_hold( TcorePending *p, int data_len, const void *data, void *user_data ) { CoreObject* o = 0; UserRequest* ur = 0; - struct tresp_call_general resp; - struct call_confirm_info_t *ci = 0; + struct tresp_call_hold resp; dbg("ok, function entrance"); - printResponse(); o = tcore_pending_ref_core_object(p); ur = tcore_pending_ref_user_request(p); - ci = (struct call_confirm_info_t *)user_data; - if ( !ci ) { - dbg("[ error ] user_data is NULL"); - goto out; - } + resp.id = tcore_call_object_get_id( (CallObject*)user_data ); - resp.type = (enum telephony_call_type )tcore_call_object_get_type( ci->co ); - resp.id = tcore_call_object_get_id( ci->co ); - - if(sp_response->success >0){ - resp.err = FALSE; - }else{ - resp.err = TRUE; - } + if(sp_response->success >0) + resp.err = TCORE_RETURN_SUCCESS; + else + resp.err = TCORE_RETURN_FAILURE; ReleaseResponse(); - if ( ur ) { - tcore_user_request_send_response(ur, ci->resp, sizeof(struct tresp_call_general), &resp); + tcore_user_request_send_response(ur, TRESP_CALL_HOLD, sizeof(struct tresp_call_hold), &resp); } else { dbg("[ error ] ur is NULL"); - goto out; + return ; } if ( !resp.err ) { @@ -683,20 +819,46 @@ static void on_confirmation_call_hold( TcorePending *p, int data_len, const void active = tcore_call_object_find_by_status( o, TCORE_CALL_STATUS_ACTIVE ); if ( !active ) { dbg("[ error ] can't find active call"); - goto out; + return ; } co = (CallObject*)active->data; if ( !co ) { dbg("[ error ] can't get active call object"); - goto out; + return ; } tcore_call_object_set_status( co, TCORE_CALL_STATUS_HELD ); } -out: - g_free( ci ); +} + +static void on_confirmation_call_active( TcorePending *p, int data_len, const void *data, void *user_data ) +{ + CoreObject *o = 0; + UserRequest *ur = 0; + + struct tresp_call_active resp; + + o = tcore_pending_ref_core_object(p); + ur = tcore_pending_ref_user_request(p); + + resp.id = tcore_call_object_get_id( (CallObject*)user_data ); + + if(sp_response->success >0) + resp.err = TCORE_RETURN_SUCCESS; + else + resp.err = TCORE_RETURN_FAILURE; + + ReleaseResponse(); + + if (ur) { + tcore_user_request_send_response(ur, TRESP_CALL_ACTIVE, sizeof(struct tresp_call_active), &resp); + + } else { + dbg("[ error ] ur is NULL"); + return ; + } } @@ -705,38 +867,28 @@ static void on_confirmation_call_swap( TcorePending *p, int data_len, const void CoreObject* o = 0; UserRequest* ur = 0; - struct tresp_call_general resp; - struct call_confirm_info_t *ci = 0; + struct tresp_call_swap resp; dbg("ok, function entrance"); - printResponse(); o = tcore_pending_ref_core_object(p); ur = tcore_pending_ref_user_request(p); - ci = (struct call_confirm_info_t *)user_data; - if ( !ci ) { - dbg("[ error ] user_data is NULL"); - goto out; - } - + resp.id = tcore_call_object_get_id( (CallObject*)user_data ); - resp.type = (enum telephony_call_type )tcore_call_object_get_type( ci->co ); - resp.id = tcore_call_object_get_id( ci->co ); - if(sp_response->success >0){ - resp.err = FALSE; - }else{ - resp.err = TRUE; - } + if(sp_response->success >0) + resp.err = TCORE_RETURN_SUCCESS; + else + resp.err = TCORE_RETURN_FAILURE; ReleaseResponse(); if ( ur ) { - tcore_user_request_send_response(ur, ci->resp, sizeof(struct tresp_call_general), &resp); + tcore_user_request_send_response(ur, TRESP_CALL_SWAP, sizeof(struct tresp_call_swap), &resp); } else { dbg("[ error ] ur is NULL"); - goto out; + return ; } if ( !resp.err ) { @@ -747,114 +899,181 @@ static void on_confirmation_call_swap( TcorePending *p, int data_len, const void held = tcore_call_object_find_by_status( o, TCORE_CALL_STATUS_HELD ); if ( !held ) { dbg("[ error ] can't find held call"); - goto out; + return ; } active = tcore_call_object_find_by_status( o, TCORE_CALL_STATUS_ACTIVE ); if ( !active ) { dbg("[ error ] can't find active call"); - goto out; + return ; } co = (CallObject*)held->data; if ( !co ) { dbg("[ error ] can't get held call object"); - goto out; + return ; } resp.id = tcore_call_object_get_id( co ); tcore_call_object_set_status( co, TCORE_CALL_STATUS_ACTIVE ); - tcore_user_request_send_response(ur, TRESP_CALL_ACTIVE, sizeof(struct tresp_call_general), &resp); + tcore_user_request_send_response(ur, TRESP_CALL_ACTIVE, sizeof(struct tresp_call_active), &resp); co = (CallObject*)active->data; if ( !co ) { dbg("[ error ] can't get active call object"); - goto out; + return ; } resp.id = tcore_call_object_get_id( co ); tcore_call_object_set_status( co, TCORE_CALL_STATUS_HELD ); - tcore_user_request_send_response(ur, TRESP_CALL_HOLD, sizeof(struct tresp_call_general), &resp); + tcore_user_request_send_response(ur, TRESP_CALL_HOLD, sizeof(struct tresp_call_hold), &resp); } +} + +static void on_confirmation_call_join( TcorePending *p, int data_len, const void *data, void *user_data ) +{ + CoreObject *o = 0; + UserRequest *ur = 0; + + struct tresp_call_join resp; + + o = tcore_pending_ref_core_object(p); + ur = tcore_pending_ref_user_request(p); + + resp.id = tcore_call_object_get_id( (CallObject*)user_data ); + + if(sp_response->success >0) + resp.err = TCORE_RETURN_SUCCESS; + else + resp.err = TCORE_RETURN_FAILURE; -out: - g_free( ci ); + ReleaseResponse(); + + if (ur) { + tcore_user_request_send_response(ur, TRESP_CALL_JOIN, sizeof(struct tresp_call_join), &resp); + + } else { + dbg("[ error ] ur is NULL"); + return ; + } } -static void on_confirmation_call_hold_and_accept( TcorePending *p, int data_len, const void *data, void *user_data ) +static void on_confirmation_call_split( TcorePending *p, int data_len, const void *data, void *user_data ) { CoreObject* o = 0; UserRequest* ur = 0; - struct tresp_call_general resp; - struct call_confirm_info_t *ci = 0; + + struct tresp_call_split resp; dbg("ok, function entrance"); - printResponse(); o = tcore_pending_ref_core_object(p); ur = tcore_pending_ref_user_request(p); - ci = (struct call_confirm_info_t *)user_data; - if ( !ci ) { - dbg("[ error ] user_data is NULL"); - goto out; - } - + resp.id = tcore_call_object_get_id( (CallObject*)user_data ); - resp.type = (enum telephony_call_type )tcore_call_object_get_type( ci->co ); - resp.id = tcore_call_object_get_id( ci->co ); - - if(sp_response->success >0){ - resp.err = FALSE; - }else{ - resp.err = TRUE; - } + if(sp_response->success >0) + resp.err = TCORE_RETURN_SUCCESS; + else + resp.err = TCORE_RETURN_FAILURE; ReleaseResponse(); - + if ( ur ) { - tcore_user_request_send_response(ur, ci->resp, sizeof(struct tresp_call_general), &resp); + tcore_user_request_send_response(ur, TRESP_CALL_SPLIT, sizeof(struct tresp_call_split), &resp); } else { dbg("[ error ] ur is NULL"); - goto out; + return ; } if ( !resp.err ) { - GSList *l = 0; + GSList *active = 0; CallObject *co = 0; - l = tcore_call_object_find_by_status( o, TCORE_CALL_STATUS_ACTIVE ); - if ( !l ) { + active = tcore_call_object_find_by_status( o, TCORE_CALL_STATUS_ACTIVE ); + if ( !active ) { dbg("[ error ] can't find active call"); - goto out; + return ; } - co = (CallObject*)l->data; + co = (CallObject*)active->data; if ( !co ) { dbg("[ error ] can't get active call object"); - goto out; + return ; } tcore_call_object_set_status( co, TCORE_CALL_STATUS_HELD ); + tcore_call_object_set_status( (CallObject*)user_data, TCORE_CALL_STATUS_ACTIVE ); } +} + +static void on_confirmation_call_deflect( TcorePending *p, int data_len, const void *data, void *user_data ) +{ + CoreObject *o = 0; + UserRequest *ur = 0; -out: - g_free( ci ); + struct tresp_call_deflect resp; + + o = tcore_pending_ref_core_object(p); + ur = tcore_pending_ref_user_request(p); + + resp.id = tcore_call_object_get_id( (CallObject*)user_data ); + + if(sp_response->success >0) + resp.err = TCORE_RETURN_SUCCESS; + else + resp.err = TCORE_RETURN_FAILURE; + + ReleaseResponse(); + + if (ur) { + tcore_user_request_send_response(ur, TRESP_CALL_DEFLECT, sizeof(struct tresp_call_deflect), &resp); + + } else { + dbg("[ error ] ur is NULL"); + return ; + } +} + +static void on_confirmation_call_transfer( TcorePending *p, int data_len, const void *data, void *user_data ) +{ + CoreObject *o = 0; + UserRequest *ur = 0; + + struct tresp_call_transfer resp; + + o = tcore_pending_ref_core_object(p); + ur = tcore_pending_ref_user_request(p); + + resp.id = tcore_call_object_get_id( (CallObject*)user_data ); + + if(sp_response->success >0) + resp.err = TCORE_RETURN_SUCCESS; + else + resp.err = TCORE_RETURN_FAILURE; + + ReleaseResponse(); + + if (ur) { + tcore_user_request_send_response(ur, TRESP_CALL_TRANSFER, sizeof(struct tresp_call_transfer), &resp); + + } else { + dbg("[ error ] ur is NULL"); + return ; + } } -// RESPONSE +// RESPONSE static void on_confirmation_call_endall( TcorePending *p, int data_len, const void *data, void *user_data ) { CoreObject* o = 0; UserRequest* ur = 0; - //TReturn err = TCORE_RETURN_SUCCESS; - struct call_confirm_info_t* ci = 0; - + dbg("on_confirmation_call_endall - 1st result. wait for final result"); @@ -863,28 +1082,22 @@ static void on_confirmation_call_endall( TcorePending *p, int data_len, const vo //skip response handling - actual result will be handled in on_confirmation_call_request ReleaseResponse(); - - ci = (struct call_confirm_info_t *)user_data; - if ( !ci ) { - dbg("[ error ] user_data is NULL"); - return ; - } } -// RESPONSE +// RESPONSE static void on_response_call_list_get(TcorePending *p, int data_len, const void *data, void *user_data) { TcorePlugin* plugin = 0; CoreObject* o = 0; CallObject* co = 0; - struct ATLine *p_cur; + struct ATLine *p_cur; char* cmd= 0; - struct CLCC_call_t* call_list = 0; + struct CLCC_call_t* call_list = 0; int i = 0, countCalls =0, countValidCalls =0, err =0; - + plugin = tcore_pending_ref_plugin( p ); o = tcore_pending_ref_core_object( p ); @@ -895,31 +1108,31 @@ static void on_response_call_list_get(TcorePending *p, int data_len, const void if(sp_response->success > 0) { - /* count the calls */ - for (countCalls = 0, p_cur = sp_response->p_intermediates - ; p_cur != NULL - ; p_cur = p_cur->p_next - ) { - countCalls++; - } - dbg("total calls : %d",countCalls); + /* count the calls */ + for (countCalls = 0, p_cur = sp_response->p_intermediates + ; p_cur != NULL + ; p_cur = p_cur->p_next + ) { + countCalls++; + } + dbg("total calls : %d",countCalls); - if(countCalls ==0) - return; + if(countCalls ==0) + return; call_list = g_new0( struct CLCC_call_t, countCalls); - + for (countValidCalls = 0, p_cur = sp_response->p_intermediates - ; p_cur != NULL - ; p_cur = p_cur->p_next) - { + ; p_cur != NULL + ; p_cur = p_cur->p_next) + { err = _callFromCLCCLine( p_cur->line, call_list + countValidCalls ); - if (err != 0) { - continue; - } + if (err != 0) { + continue; + } co = tcore_call_object_find_by_id( o, call_list[i].info.id ); if ( !co ) { @@ -950,97 +1163,97 @@ static int _callFromCLCCLine(char *line, struct CLCC_call_t*p_call) int err; int state; - int mode; - int isMT; - char* num; - - err = at_tok_start(&line); - if (err < 0) goto error; - -//id - err = at_tok_nextint(&line, &(p_call->info.id)); - if (err < 0) goto error; - dbg("id : [%d]\n", p_call->info.id ); -//MO/MTcall - err = at_tok_nextint(&line, &isMT); - if (err < 0) goto error; + int mode; + int isMT; + char* num; + + err = at_tok_start(&line); + if (err < 0) goto error; + + //id + err = at_tok_nextint(&line, &(p_call->info.id)); + if (err < 0) goto error; + dbg("id : [%d]\n", p_call->info.id ); + //MO/MTcall + err = at_tok_nextint(&line, &isMT); + if (err < 0) goto error; + + if(isMT ==0) + p_call->info.direction = TCORE_CALL_DIRECTION_OUTGOING; + else + p_call->info.direction = TCORE_CALL_DIRECTION_INCOMING; - if(isMT ==0) - p_call->info.direction = TCORE_CALL_DIRECTION_OUTGOING; - else - p_call->info.direction = TCORE_CALL_DIRECTION_INCOMING; - dbg("direction : [ %d ]\n", p_call->info.direction); -//state - err = at_tok_nextint(&line, &state); - if (err < 0) goto error; + //state + err = at_tok_nextint(&line, &state); + if (err < 0) goto error; - switch(state){ - case 0: //active - p_call->info.status = TCORE_CALL_STATUS_ACTIVE; - break; - case 1: - p_call->info.status = TCORE_CALL_STATUS_HELD; - break; - case 2: - p_call->info.status = TCORE_CALL_STATUS_DIALING; - break; - case 3: - p_call->info.status = TCORE_CALL_STATUS_ALERT; - break; - case 4: - p_call->info.status = TCORE_CALL_STATUS_INCOMING; - break; - case 5: - p_call->info.status = TCORE_CALL_STATUS_WAITING; - break; - } + switch(state){ + case 0: //active + p_call->info.status = TCORE_CALL_STATUS_ACTIVE; + break; + case 1: + p_call->info.status = TCORE_CALL_STATUS_HELD; + break; + case 2: + p_call->info.status = TCORE_CALL_STATUS_DIALING; + break; + case 3: + p_call->info.status = TCORE_CALL_STATUS_ALERT; + break; + case 4: + p_call->info.status = TCORE_CALL_STATUS_INCOMING; + break; + case 5: + p_call->info.status = TCORE_CALL_STATUS_WAITING; + break; + } dbg("status : [%d]\n", p_call->info.status ); - -//mode - err = at_tok_nextint(&line, &mode); - if (err < 0) goto error; - - switch(mode) - { - case 0: - p_call->info.type = TCORE_CALL_TYPE_VOICE; - break; - case 1: - p_call->info.type = TCORE_CALL_TYPE_VIDEO; - break; - - default: // only Voice/VT call is supported in CS. treat other unknown calls as error - dbg("invalid type : [%d]\n", mode ); - goto error; - break; - } + //mode + err = at_tok_nextint(&line, &mode); + if (err < 0) goto error; + + switch(mode) + { + case 0: + p_call->info.type = TCORE_CALL_TYPE_VOICE; + break; + + case 1: + p_call->info.type = TCORE_CALL_TYPE_VIDEO; + break; + + default: // only Voice/VT call is supported in CS. treat other unknown calls as error + dbg("invalid type : [%d]\n", mode ); + goto error; + break; + } dbg("type : [%d]\n", p_call->info.type ); - - err = at_tok_nextint(&line, &(p_call->info.mpty)); + + err = at_tok_nextint(&line, &(p_call->info.mpty)); if (err < 0) goto error; - dbg("mpty : [%d]\n", p_call->info.mpty ); + dbg("mpty : [%d]\n", p_call->info.mpty ); - if (at_tok_hasmore(&line)) { - err = at_tok_nextstr(&line, &num); + if (at_tok_hasmore(&line)) { + err = at_tok_nextstr(&line, &num); - /* tolerate null here */ - if (err < 0) return 0; + /* tolerate null here */ + if (err < 0) return 0; - memcpy(p_call->number, num, strlen(num)); - dbg("number : [ %s ]\n", p_call->number ); + memcpy(p_call->number, num, strlen(num)); + dbg("number : [ %s ]\n", p_call->number ); - p_call->info.num_len = strlen(num); - dbg("num_len : [0x%x]\n", p_call->info.num_len ); + p_call->info.num_len = strlen(num); + dbg("num_len : [0x%x]\n", p_call->info.num_len ); - err = at_tok_nextint(&line, &(p_call->info.num_type)); - if (err < 0) goto error; - dbg("num_type : [0x%x]\n", p_call->info.num_type ); - - } + err = at_tok_nextint(&line, &(p_call->info.num_type)); + if (err < 0) goto error; + dbg("num_type : [0x%x]\n", p_call->info.num_type ); + + } return 0; @@ -1051,16 +1264,16 @@ error: // NOTIFICATION -static void on_notification_call_waiting( CoreObject *o, const void *data, void *user_data ) +static gboolean on_notification_call_waiting( CoreObject *o, const void *data, void *user_data ) { TcorePlugin* plugin = NULL; char* cmd = NULL, *num = NULL; CallObject *co, *dupco = 0; - int id, status, err, type, mpty,direction; + int id, status, err, type, mpty,direction; GSList* pList = NULL; #define LINE_DEFAULT 0 - dbg("call waiting noti : %s", cmd); + dbg("call waiting noti : %s", cmd); plugin = tcore_object_ref_plugin(o); cmd = (char*)data; @@ -1078,33 +1291,33 @@ static void on_notification_call_waiting( CoreObject *o, const void *data, void dbg("id: %d, direction : %d, status : %d, type :%d, mpty : %d, num : %s", id,direction,status, type, mpty, num); } else { - dbg("id: %d, direction : %d, status : %d, type :%d, mpty : %d, num : NULL", id,direction,status, type, mpty); + dbg("id: %d, direction : %d, status : %d, type :%d, mpty : %d, num : NULL", id,direction,status, type, mpty); } // check call with incoming status already exist pList = tcore_call_object_find_by_status(o, TCORE_CALL_STATUS_WAITING); if(pList != NULL){ dbg("waiting call already exist. skip"); - return; + return TRUE; } pList = tcore_call_object_find_by_status(o, TCORE_CALL_STATUS_INCOMING); if(pList != NULL){ dbg("incoming call already exist. skip"); - return; + return TRUE; } dupco = tcore_call_object_find_by_id(o, id); if(dupco!= NULL){ dbg("co with same id already exist. skip"); - return; + return TRUE; } // make new co, add to list co = tcore_call_object_new( o, id); - if ( !co ) { - dbg("[ error ] co is NULL"); - return ; - } + if ( !co ) { + dbg("[ error ] co is NULL"); + return TRUE; + } tcore_call_object_set_type(co, _call_type(type)); tcore_call_object_set_multiparty_state(co,_call_is_in_mpty(mpty)); @@ -1113,18 +1326,20 @@ static void on_notification_call_waiting( CoreObject *o, const void *data, void tcore_call_object_set_active_line(co, LINE_DEFAULT); _call_list_get( o, co ); + + return TRUE; } -static void on_notification_call_incoming( CoreObject *o, const void *data, void *user_data ) +static gboolean on_notification_call_incoming( CoreObject *o, const void *data, void *user_data ) { TcorePlugin* plugin = NULL; char* cmd = NULL, *num = NULL; CallObject *co, *dupco = 0; - int id, status, err, type, mpty,direction; + int id, status, err, type, mpty,direction; GSList* pList = NULL; #define LINE_DEFAULT 0 - dbg("call incoming noti : %s", cmd); + dbg("call incoming noti : %s", cmd); plugin = tcore_object_ref_plugin(o); cmd = (char*)data; @@ -1142,27 +1357,27 @@ static void on_notification_call_incoming( CoreObject *o, const void *data, void dbg("id: %d, direction : %d, status : %d, type :%d, mpty : %d, num : %s", id,direction,status, type, mpty, num); } else { - dbg("id: %d, direction : %d, status : %d, type :%d, mpty : %d, num : NULL", id,direction,status, type, mpty); + dbg("id: %d, direction : %d, status : %d, type :%d, mpty : %d, num : NULL", id,direction,status, type, mpty); } // check call with incoming status already exist pList = tcore_call_object_find_by_status(o, TCORE_CALL_STATUS_INCOMING); if(pList != NULL){ dbg("incoming call already exist. skip"); - return; + return TRUE; } dupco = tcore_call_object_find_by_id(o, id); if(dupco!= NULL){ dbg("co with same id already exist. skip"); - return; + return TRUE; } // make new co, add to list co = tcore_call_object_new( o, id); - if ( !co ) { - dbg("[ error ] co is NULL"); - return ; - } + if ( !co ) { + dbg("[ error ] co is NULL"); + return TRUE; + } tcore_call_object_set_type(co, _call_type(type)); tcore_call_object_set_multiparty_state(co,_call_is_in_mpty(mpty)); @@ -1172,9 +1387,10 @@ static void on_notification_call_incoming( CoreObject *o, const void *data, void _call_list_get( o, co ); + return TRUE; } -static void on_notification_call_status( CoreObject *o, const void *data, void *user_data) +static gboolean on_notification_call_status( CoreObject *o, const void *data, void *user_data) { char* cmd = NULL, *num = NULL; TcorePlugin* p = 0; @@ -1184,7 +1400,7 @@ static void on_notification_call_status( CoreObject *o, const void *data, void * enum tcore_call_status co_status; - p = tcore_object_ref_plugin( o ); + p = tcore_object_ref_plugin( o ); cmd = (char*)data; at_tok_start(&cmd); @@ -1195,12 +1411,12 @@ static void on_notification_call_status( CoreObject *o, const void *data, void * err = at_tok_nextint(&cmd,&type); err = at_tok_nextint(&cmd,&mpty); - if(at_tok_hasmore(&cmd)) { + if (at_tok_hasmore(&cmd)) { err = at_tok_nextstr(&cmd,&num); dbg("id: %d, direction : %d, status : %d, type :%d, mpty : %d, num : %s", id,direction,status, type, mpty, num); } - else { - dbg("id: %d, direction : %d, status : %d, type :%d, mpty : %d, num : NULL", id,direction,status, type, mpty); + else { + dbg("id: %d, direction : %d, status : %d, type :%d, mpty : %d, num : NULL", id,direction,status, type, mpty); } co_status = _call_status(status); @@ -1212,7 +1428,7 @@ static void on_notification_call_status( CoreObject *o, const void *data, void * co = tcore_call_object_find_by_id(o,id); if ( !co ) { dbg("co is NULL"); - return ; + return TRUE; } _call_status_active( p, co ); @@ -1222,12 +1438,12 @@ static void on_notification_call_status( CoreObject *o, const void *data, void * case CALL_STATUS_DIALING: { dbg("call(%d) status : [ dialing ]", id); - co = tcore_call_object_find_by_id(o,id); + co = tcore_call_object_find_by_id(o,id); if ( !co ) { co = tcore_call_object_new( o, id ); if ( !co ) { dbg("error : tcore_call_object_new [ id : %d ]", id); - return ; + return TRUE; } } @@ -1241,10 +1457,10 @@ static void on_notification_call_status( CoreObject *o, const void *data, void * { dbg("call(%d) status : [ alert ]", id); - co = tcore_call_object_find_by_id(o, id); + co = tcore_call_object_find_by_id(o, id); if ( !co ) { dbg("co is NULL"); - return ; + return TRUE; } _call_list_get( o, co ); @@ -1271,7 +1487,9 @@ static void on_notification_call_status( CoreObject *o, const void *data, void * default: break; - } + } + + return TRUE; } static TReturn s_call_outgoing( CoreObject *o, UserRequest *ur ) @@ -1282,7 +1500,6 @@ static TReturn s_call_outgoing( CoreObject *o, UserRequest *ur ) char* raw_str= NULL; char* cmd_str = NULL; const char *cclir; - struct call_confirm_info_t* ci = 0; struct ATReqMetaInfo metainfo; int info_len =0; enum tcore_call_cli_mode clir = CALL_CLI_MODE_DEFAULT; @@ -1291,21 +1508,17 @@ static TReturn s_call_outgoing( CoreObject *o, UserRequest *ur ) data = (struct treq_call_dial*)tcore_user_request_ref_data( ur, 0 ); p = tcore_object_ref_plugin( o ); - - ci = g_new0( struct call_confirm_info_t, 1 ); - ci->co = NULL; - ci->resp = TRESP_CALL_DIAL; clir = _get_clir_status( data->number ); -//Compose ATCmd string - switch (clir) +//Compose ATCmd string + switch (clir) { - case TCORE_CALL_CLI_MODE_PRESENT: + case TCORE_CALL_CLI_MODE_PRESENT: cclir = "I"; break; /*invocation*/ - case TCORE_CALL_CLI_MODE_RESTRICT: - cclir = "i"; + case TCORE_CALL_CLI_MODE_RESTRICT: + cclir = "i"; break; /*suppression*/ case TCORE_CALL_CLI_MODE_DEFAULT: default: @@ -1325,11 +1538,11 @@ static TReturn s_call_outgoing( CoreObject *o, UserRequest *ur ) tcore_user_request_set_metainfo(ur, info_len, &metainfo); - ret = _call_request_message ( o, ur, cmd_str, strlen(cmd_str), on_confirmation_call_request, ci); + ret = _call_request_message ( o, ur, cmd_str, strlen(cmd_str), on_confirmation_call_outgoing, co); free(raw_str); - free(cmd_str); - + free(cmd_str); + if ( !ret ) { tcore_call_object_free( o, co ); return TCORE_RETURN_FAILURE; @@ -1342,24 +1555,15 @@ static TReturn s_call_answer( CoreObject *o, UserRequest *ur ) { CallObject* co = 0; struct treq_call_answer* data = 0; -// unsigned int ipc_size = 0; gboolean ret = FALSE; char* cmd_str = NULL; struct ATReqMetaInfo metainfo ; unsigned int info_len =0; - - struct call_confirm_info_t* ci = 0; - data = (struct treq_call_answer*)tcore_user_request_ref_data( ur, 0 ); co = tcore_call_object_find_by_id( o, data->id ); - ci = g_new0( struct call_confirm_info_t, 1 ); - ci->co = co; - ci->resp = TRESP_CALL_ANSWER; - - memset(&metainfo, 0, sizeof(struct ATReqMetaInfo)); //set metainfo @@ -1372,7 +1576,7 @@ static TReturn s_call_answer( CoreObject *o, UserRequest *ur ) if ( data->type == CALL_ANSWER_TYPE_ACCEPT ) { cmd_str = g_strdup_printf("%s%s","ATA","\r"); - ret = _call_request_message ( o, ur, (void*)cmd_str, strlen(cmd_str), on_confirmation_call_request, ci); + ret = _call_request_message ( o, ur, (void*)cmd_str, strlen(cmd_str), on_confirmation_call_accept, co); free(cmd_str); if ( !ret ) return TCORE_RETURN_FAILURE; @@ -1382,17 +1586,17 @@ static TReturn s_call_answer( CoreObject *o, UserRequest *ur ) switch ( data->type ) { case CALL_ANSWER_TYPE_REJECT: { dbg("call answer reject"); - tcore_call_control_answer_reject( o, ur, on_confirmation_call_request, ci ); + tcore_call_control_answer_reject( o, ur, on_confirmation_call_reject, co ); } break; case CALL_ANSWER_TYPE_REPLACE: { dbg("call answer replace"); - tcore_call_control_answer_replace( o, ur, on_confirmation_call_request, ci ); + tcore_call_control_answer_replace( o, ur, on_confirmation_call_replace, co ); } break; case CALL_ANSWER_TYPE_HOLD_ACCEPT: { dbg("call answer hold and accept"); - tcore_call_control_answer_hold_and_accept( o, ur, on_confirmation_call_hold_and_accept, ci ); + tcore_call_control_answer_hold_and_accept( o, ur, on_confirmation_call_hold_and_accept, co ); } break; default : @@ -1409,7 +1613,6 @@ static TReturn s_call_release( CoreObject *o, UserRequest *ur ) CallObject* co = 0; struct treq_call_end* data = 0; - struct call_confirm_info_t* ci = 0; gboolean ret = FALSE; UserRequest* ur_dup = 0; @@ -1423,16 +1626,11 @@ static TReturn s_call_release( CoreObject *o, UserRequest *ur ) co = tcore_call_object_find_by_id( o, data->id ); - ci = g_new0( struct call_confirm_info_t, 1 ); - ci->co = co; - if ( data->type == CALL_END_TYPE_ALL ) { - ci->resp = TRESP_CALL_END_ALL; - - //releaseAll do not exist on legacy request. send CHLD=0, CHLD=1 in sequence - chld0_cmd = g_strdup("AT+CHLD=0\r"); - chld1_cmd = g_strdup("AT+CHLD=1\r"); + //releaseAll do not exist on legacy request. send CHLD=0, CHLD=1 in sequence + chld0_cmd = g_strdup("AT+CHLD=0\r"); + chld1_cmd = g_strdup("AT+CHLD=1\r"); memset(&metainfo1, 0, sizeof(struct ATReqMetaInfo)); memset(&metainfo2, 0, sizeof(struct ATReqMetaInfo)); @@ -1457,11 +1655,11 @@ static TReturn s_call_release( CoreObject *o, UserRequest *ur ) free(chld0_cmd); if ( !ret ) return TCORE_RETURN_FAILURE; - - ret = _call_request_message(o, ur, chld1_cmd, strlen(chld1_cmd), on_confirmation_call_request, ci); + + ret = _call_request_message(o, ur, chld1_cmd, strlen(chld1_cmd), on_confirmation_call_release_all, co); free(chld1_cmd); if ( !ret ) - return TCORE_RETURN_FAILURE; + return TCORE_RETURN_FAILURE; } else { @@ -1470,26 +1668,20 @@ static TReturn s_call_release( CoreObject *o, UserRequest *ur ) int id = 0; id = tcore_call_object_get_id( co ); - ci->resp = TRESP_CALL_END; - dbg("call end call id [%d]", id); - tcore_call_control_end_specific( o, ur, id, on_confirmation_call_request, ci ); + tcore_call_control_end_specific( o, ur, id, on_confirmation_call_release_specific, co ); } break; case CALL_END_TYPE_ACTIVE_ALL: { - ci->resp = TRESP_CALL_END_ALL_ACTIVE; - dbg("call end all active"); - tcore_call_control_end_all_active( o, ur, on_confirmation_call_request, ci ); + tcore_call_control_end_all_active( o, ur, on_confirmation_call_release_all_active, co ); } break; case TCORE_CALL_END_ALL_HELD: { - ci->resp = TRESP_CALL_END_ALL_HELD; - dbg("call end all held"); - tcore_call_control_end_all_held( o, ur, on_confirmation_call_request, ci ); + tcore_call_control_end_all_held( o, ur, on_confirmation_call_release_all_held, co ); } break; default : @@ -1504,134 +1696,113 @@ static TReturn s_call_release( CoreObject *o, UserRequest *ur ) static TReturn s_call_hold( CoreObject *o, UserRequest *ur ) { - struct call_confirm_info_t* ci = 0; - unsigned int *id = 0; - id = (unsigned int*)tcore_user_request_ref_data( ur, 0 ); + struct treq_call_hold *hold = 0; + CallObject *co = 0; - ci = g_new0( struct call_confirm_info_t, 1 ); + hold = (struct treq_call_hold*)tcore_user_request_ref_data( ur, 0 ); - dbg("call id : [ %d ]", *id); + dbg("call id : [ %d ]", hold->id); - ci->co = tcore_call_object_find_by_id( o, *id ); - ci->resp = TRESP_CALL_HOLD; + co = tcore_call_object_find_by_id( o, hold->id ); - tcore_call_control_hold( o, ur, on_confirmation_call_hold, ci ); + tcore_call_control_hold( o, ur, on_confirmation_call_hold, co ); return TCORE_RETURN_SUCCESS; } static TReturn s_call_active( CoreObject *o, UserRequest *ur ) { - struct call_confirm_info_t* ci = 0; - unsigned int *id = 0; - id = (unsigned int*)tcore_user_request_ref_data( ur, 0 ); + struct treq_call_active *active = 0; + CallObject *co = 0; - ci = g_new0( struct call_confirm_info_t, 1 ); + active = (struct treq_call_active*)tcore_user_request_ref_data( ur, 0 ); - dbg("call id : [ %d ]", *id); + dbg("call id : [ %d ]", active->id); - ci->co = tcore_call_object_find_by_id( o, *id ); - ci->resp = TRESP_CALL_ACTIVE; + co = tcore_call_object_find_by_id( o, active->id ); - tcore_call_control_active( o, ur, on_confirmation_call_request, ci ); + tcore_call_control_active( o, ur, on_confirmation_call_active, co ); return TCORE_RETURN_SUCCESS; } static TReturn s_call_swap( CoreObject *o, UserRequest *ur ) { - struct call_confirm_info_t* ci = 0; - unsigned int *id = 0; - id = (unsigned int*)tcore_user_request_ref_data( ur, 0 ); - - ci = g_new0( struct call_confirm_info_t, 1 ); + struct treq_call_swap *swap = 0; + CallObject *co = 0; + swap = (struct treq_call_swap*)tcore_user_request_ref_data( ur, 0 ); - dbg("call id : [ %d ]", *id); + dbg("call id : [ %d ]", swap->id); - ci->co = tcore_call_object_find_by_id( o, *id ); - ci->resp = TRESP_CALL_SWAP; + co = tcore_call_object_find_by_id( o, swap->id ); - tcore_call_control_swap( o, ur, on_confirmation_call_swap, ci ); + tcore_call_control_swap( o, ur, on_confirmation_call_swap, co ); return TCORE_RETURN_SUCCESS; } static TReturn s_call_join( CoreObject *o, UserRequest *ur ) { - struct call_confirm_info_t* ci = 0; - unsigned int *id = 0; - id = (unsigned int*)tcore_user_request_ref_data( ur, 0 ); + struct treq_call_join *join = 0; + CallObject *co = 0; - ci = g_new0( struct call_confirm_info_t, 1 ); + join = (struct treq_call_join*)tcore_user_request_ref_data( ur, 0 ); - dbg("call id : [ %d ]", *id); + dbg("call id : [ %d ]", join->id); - ci->co = tcore_call_object_find_by_id( o, *id ); - ci->resp = TRESP_CALL_JOIN; + co = tcore_call_object_find_by_id( o, join->id ); - tcore_call_control_join( o, ur, on_confirmation_call_request, ci ); + tcore_call_control_join( o, ur, on_confirmation_call_join, co ); return TCORE_RETURN_SUCCESS; } static TReturn s_call_split( CoreObject *o, UserRequest *ur ) { - struct call_confirm_info_t* ci = 0; - unsigned int *id = 0; + struct treq_call_split *split = 0; + CallObject *co = 0; - ci = g_new0( struct call_confirm_info_t, 1 ); + split = (struct treq_call_split*)tcore_user_request_ref_data( ur, 0 ); - id = (unsigned int *)tcore_user_request_ref_data( ur, 0 ); - ci->co = tcore_call_object_find_by_id ( o, *id ); - ci->resp = TRESP_CALL_SPLIT; + co = tcore_call_object_find_by_id ( o, split->id ); - tcore_call_control_split( o, ur, *id, on_confirmation_call_split, ci ); + tcore_call_control_split( o, ur, split->id, on_confirmation_call_split, co ); return TCORE_RETURN_SUCCESS; } static TReturn s_call_deflect( CoreObject *o, UserRequest *ur ) { - struct call_confirm_info_t* ci = 0; - char *number = 0; + struct treq_call_deflect *deflect = 0; + CallObject *co = 0; - ci = g_new0( struct call_confirm_info_t, 1 ); - number = (char*)tcore_user_request_ref_data( ur, 0 ); + deflect = (struct treq_call_deflect*)tcore_user_request_ref_data( ur, 0 ); - ci->co = tcore_call_object_find_by_number( o, number ); - ci->resp = TRESP_CALL_DEFLECT; + co = tcore_call_object_find_by_number( o, deflect->number ); - tcore_call_control_deflect( o, ur, number, on_confirmation_call_request, ci ); + tcore_call_control_deflect( o, ur, deflect->number, on_confirmation_call_deflect, co ); return TCORE_RETURN_SUCCESS; } static TReturn s_call_transfer( CoreObject *o, UserRequest *ur ) { - struct call_confirm_info_t* ci = 0; - unsigned int *id = 0; - id = (unsigned int*)tcore_user_request_ref_data( ur, 0 ); + struct treq_call_transfer *transfer = 0; + CallObject *co = 0; - ci = g_new0( struct call_confirm_info_t, 1 ); + transfer = (struct treq_call_transfer*)tcore_user_request_ref_data( ur, 0 ); - dbg("call id : [ %d ]", *id); + dbg("call id : [ %d ]", transfer->id); - ci->co = tcore_call_object_find_by_id( o, *id ); - ci->resp = TRESP_CALL_TRANSFER; + co = tcore_call_object_find_by_id( o, transfer->id ); - tcore_call_control_transfer( o, ur, on_confirmation_call_request, ci ); + tcore_call_control_transfer( o, ur, on_confirmation_call_transfer, co ); return TCORE_RETURN_SUCCESS; } static TReturn s_call_send_dtmf( CoreObject *o, UserRequest *ur ) { - struct call_confirm_info_t* ci = 0; - ci = g_new0( struct call_confirm_info_t, 1 ); - - ci->co = 0; - ci->resp = TRESP_CALL_SEND_DTMF; - return TCORE_RETURN_SUCCESS; } @@ -1671,7 +1842,6 @@ static TReturn s_call_get_mute_status( CoreObject *o, UserRequest *ur ) return TCORE_RETURN_SUCCESS; } - static struct tcore_call_operations call_ops = { .dial = s_call_outgoing, .answer = s_call_answer, @@ -1709,7 +1879,7 @@ static void s_call_info_mo_waiting( CoreObject *o ) id = tcore_call_object_get_id( co ); - tcore_server_send_notification( tcore_plugin_ref_server(p), + tcore_server_send_notification( tcore_plugin_ref_server(p), tcore_plugin_ref_core_object(p, "call"), TNOTI_CALL_INFO_WAITING, sizeof(unsigned int), @@ -1731,7 +1901,7 @@ static void s_call_info_mo_forwarded( CoreObject *o ) } id = tcore_call_object_get_id( co ); - tcore_server_send_notification( tcore_plugin_ref_server(p), + tcore_server_send_notification( tcore_plugin_ref_server(p), tcore_plugin_ref_core_object(p, "call"), TNOTI_CALL_INFO_FORWARDED, sizeof(unsigned int), @@ -1753,7 +1923,7 @@ static void s_call_info_mo_barred_incoming( CoreObject *o ) } id = tcore_call_object_get_id( co ); - tcore_server_send_notification( tcore_plugin_ref_server(p), + tcore_server_send_notification( tcore_plugin_ref_server(p), tcore_plugin_ref_core_object(p, "call"), TNOTI_CALL_INFO_BARRED_INCOMING, sizeof(unsigned int), @@ -1775,7 +1945,7 @@ static void s_call_info_mo_barred_outgoing( CoreObject *o ) } id = tcore_call_object_get_id( co ); - tcore_server_send_notification( tcore_plugin_ref_server(p), + tcore_server_send_notification( tcore_plugin_ref_server(p), tcore_plugin_ref_core_object(p, "call"), TNOTI_CALL_INFO_BARRED_OUTGOING, sizeof(unsigned int), @@ -1797,7 +1967,7 @@ static void s_call_info_mo_deflected( CoreObject *o ) } id = tcore_call_object_get_id( co ); - tcore_server_send_notification( tcore_plugin_ref_server(p), + tcore_server_send_notification( tcore_plugin_ref_server(p), tcore_plugin_ref_core_object(p, "call"), TNOTI_CALL_INFO_DEFLECTED, sizeof(unsigned int), @@ -1819,7 +1989,7 @@ static void s_call_info_mo_clir_suppression_reject( CoreObject *o ) } id = tcore_call_object_get_id( co ); - tcore_server_send_notification( tcore_plugin_ref_server(p), + tcore_server_send_notification( tcore_plugin_ref_server(p), tcore_plugin_ref_core_object(p, "call"), TNOTI_CALL_INFO_CLIR_SUPPRESSION_REJECT, sizeof(unsigned int), @@ -1841,7 +2011,7 @@ static void s_call_info_mo_cfu( CoreObject *o ) } id = tcore_call_object_get_id( co ); - tcore_server_send_notification( tcore_plugin_ref_server(p), + tcore_server_send_notification( tcore_plugin_ref_server(p), tcore_plugin_ref_core_object(p, "call"), TNOTI_CALL_INFO_FORWARD_UNCONDITIONAL, sizeof(unsigned int), @@ -1863,7 +2033,7 @@ static void s_call_info_mo_cfc( CoreObject *o ) } id = tcore_call_object_get_id( co ); - tcore_server_send_notification( tcore_plugin_ref_server(p), + tcore_server_send_notification( tcore_plugin_ref_server(p), tcore_plugin_ref_core_object(p, "call"), TNOTI_CALL_INFO_FORWARD_CONDITIONAL, sizeof(unsigned int), @@ -1910,14 +2080,14 @@ static void s_call_info_mt_forwarded_call( CoreObject *o, char* number ) id = tcore_call_object_get_id( co ); - tcore_server_send_notification( tcore_plugin_ref_server(p), + tcore_server_send_notification( tcore_plugin_ref_server(p), tcore_plugin_ref_core_object(p, "call"), TNOTI_CALL_INFO_FORWARDED_CALL, sizeof(unsigned int), (void*)&id ); } -static void s_call_info_mt_deflected_call( CoreObject *o, char* number ) +static void s_call_info_mt_deflected_call( CoreObject *o, char* number ) { CallObject *co = 0; int id = 0; @@ -1933,7 +2103,7 @@ static void s_call_info_mt_deflected_call( CoreObject *o, char* number ) id = tcore_call_object_get_id( co ); - tcore_server_send_notification( tcore_plugin_ref_server(p), + tcore_server_send_notification( tcore_plugin_ref_server(p), tcore_plugin_ref_core_object(p, "call"), TNOTI_CALL_INFO_DEFLECTED_CALL, sizeof(unsigned int), @@ -1956,7 +2126,7 @@ static void s_call_info_mt_transfered( CoreObject *o, char* number ) id = tcore_call_object_get_id( co ); - tcore_server_send_notification( tcore_plugin_ref_server(p), + tcore_server_send_notification( tcore_plugin_ref_server(p), tcore_plugin_ref_core_object(p, "call"), TNOTI_CALL_INFO_TRANSFERED_CALL, sizeof(unsigned int), @@ -1979,7 +2149,7 @@ static void s_call_info_held( CoreObject *o, char* number ) id = tcore_call_object_get_id( co ); - tcore_server_send_notification( tcore_plugin_ref_server(p), + tcore_server_send_notification( tcore_plugin_ref_server(p), tcore_plugin_ref_core_object(p, "call"), TNOTI_CALL_INFO_HELD, sizeof(unsigned int), @@ -2002,7 +2172,7 @@ static void s_call_info_active( CoreObject *o, char* number ) id = tcore_call_object_get_id( co ); - tcore_server_send_notification( tcore_plugin_ref_server(p), + tcore_server_send_notification( tcore_plugin_ref_server(p), tcore_plugin_ref_core_object(p, "call"), TNOTI_CALL_INFO_ACTIVE, sizeof(unsigned int), @@ -2025,7 +2195,7 @@ static void s_call_info_joined( CoreObject *o, char* number ) id = tcore_call_object_get_id( co ); - tcore_server_send_notification( tcore_plugin_ref_server(p), + tcore_server_send_notification( tcore_plugin_ref_server(p), tcore_plugin_ref_core_object(p, "call"), TNOTI_CALL_INFO_JOINED, sizeof(unsigned int), @@ -2048,7 +2218,7 @@ static void s_call_info_released_on_hold( CoreObject *o, char* number ) id = tcore_call_object_get_id( co ); - tcore_server_send_notification( tcore_plugin_ref_server(p), + tcore_server_send_notification( tcore_plugin_ref_server(p), tcore_plugin_ref_core_object(p, "call"), TNOTI_CALL_INFO_RELEASED_ON_HOLD, sizeof(unsigned int), @@ -2071,7 +2241,7 @@ static void s_call_info_transfer_alert( CoreObject *o, char* number ) id = tcore_call_object_get_id( co ); - tcore_server_send_notification( tcore_plugin_ref_server(p), + tcore_server_send_notification( tcore_plugin_ref_server(p), tcore_plugin_ref_core_object(p, "call"), TNOTI_CALL_INFO_TRANSFER_ALERT, sizeof(unsigned int), @@ -2094,7 +2264,7 @@ static void s_call_info_transfered( CoreObject *o, char* number ) id = tcore_call_object_get_id( co ); - tcore_server_send_notification( tcore_plugin_ref_server(p), + tcore_server_send_notification( tcore_plugin_ref_server(p), tcore_plugin_ref_core_object(p, "call"), TNOTI_CALL_INFO_TRANSFERED, sizeof(unsigned int), @@ -2117,7 +2287,7 @@ static void s_call_info_cf_check_message( CoreObject *o, char* number ) id = tcore_call_object_get_id( co ); - tcore_server_send_notification( tcore_plugin_ref_server(p), + tcore_server_send_notification( tcore_plugin_ref_server(p), tcore_plugin_ref_core_object(p, "call"), TNOTI_CALL_INFO_CF_CHECK_MESSAGE, sizeof(unsigned int), @@ -2126,7 +2296,7 @@ static void s_call_info_cf_check_message( CoreObject *o, char* number ) static struct tcore_call_information_operations call_information_ops = { - .mo_call_col = 0, + .mo_call_col = 0, .mo_call_waiting = s_call_info_mo_waiting, .mo_call_cug = 0, .mo_call_forwarded = s_call_info_mo_forwarded, @@ -2151,13 +2321,13 @@ static struct tcore_call_information_operations call_information_ops = { .call_cf_check_message = s_call_info_cf_check_message, }; -gboolean s_call_init( TcorePlugin *p ) +gboolean s_call_init(TcorePlugin *p, TcoreHal *h) { CoreObject *o = NULL; // TcoreHal *h = NULL; struct property_call_info *data = NULL; - o = tcore_call_new( p, "call", &call_ops ); + o = tcore_call_new(p, "call", &call_ops, h); if (!o) return FALSE; diff --git a/src/s_common.c b/src/s_common.c index 6acedd4..17037d4 100644 --- a/src/s_common.c +++ b/src/s_common.c @@ -116,7 +116,7 @@ gboolean util_add_waiting_job(GQueue *queue, unsigned int id, UserRequest *ur) return FALSE; wqd->id = id; - wqd->ur = tcore_user_request_dup(ur); + wqd->ur = tcore_user_request_ref(ur); g_queue_push_tail(queue, wqd); dbg("id = %d, ur = 0x%x", wqd->id, wqd->ur); diff --git a/src/s_modem.c b/src/s_modem.c index 341892a..1cc4950 100644 --- a/src/s_modem.c +++ b/src/s_modem.c @@ -108,9 +108,9 @@ static void on_confirmation_modem_message_send( TcorePending *p, gboolean result if((metainfo->type == SINGLELINE)|| (metainfo->type == MULTILINE)) { - //cp rsp prefix + //cp rsp prefix s_responsePrefix = strdup(metainfo->responsePrefix); - dbg("duplicating responsePrefix : %s\n", s_responsePrefix); + dbg("duplicating responsePrefix : %s\n", s_responsePrefix); } else { @@ -128,7 +128,7 @@ static void on_confirmation_modem_message_send( TcorePending *p, gboolean result dbg("SEND OK"); } } -static void on_sys_event_modem_power(CoreObject *o, const void *event_info, void *user_data) +static gboolean on_sys_event_modem_power(CoreObject *o, const void *event_info, void *user_data) { struct tnoti_modem_power modem_power; enum cp_state *state; @@ -147,13 +147,15 @@ static void on_sys_event_modem_power(CoreObject *o, const void *event_info, void } else { dbg("useless state : (0x%x)", *state); - return ; + return TRUE; } tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)), o, TNOTI_MODEM_POWER, sizeof(struct tnoti_modem_power), &modem_power); + + return TRUE; } -static void on_event_modem_power(CoreObject *o, const void *event_info, void *user_data) +static gboolean on_event_modem_power(CoreObject *o, const void *event_info, void *user_data) { struct treq_modem_set_flightmode flight_mode_set; struct tnoti_modem_power modem_power; @@ -164,7 +166,7 @@ static void on_event_modem_power(CoreObject *o, const void *event_info, void *us strg = tcore_server_find_storage(tcore_plugin_ref_server(tcore_object_ref_plugin(o)), "vconf"); flight_mode_set.enable = tcore_storage_get_bool(strg, STORAGE_KEY_SETAPPL_FLIGHT_MODE_BOOL); - h = tcore_plugin_ref_hal(tcore_object_ref_plugin(o)); + h = tcore_object_get_hal(o); tcore_hal_set_power_state(h, TRUE); @@ -187,9 +189,11 @@ static void on_event_modem_power(CoreObject *o, const void *event_info, void *us tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)), o, TNOTI_MODEM_POWER, sizeof(struct tnoti_modem_power), &modem_power); + + return TRUE; } -static void on_event_modem_phone_state(CoreObject *o, const void *event_info, void *user_data) +static gboolean on_event_modem_phone_state(CoreObject *o, const void *event_info, void *user_data) { char* line = (char*)event_info; GQueue *queue; @@ -230,6 +234,8 @@ static void on_event_modem_phone_state(CoreObject *o, const void *event_info, vo tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)), o, TNOTI_MODEM_FLIGHT_MODE, sizeof(struct tnoti_modem_flight_mode), &modem_flight_mode); + + return TRUE; } static void on_response_poweron(TcorePending *p, int data_len, const void *data, void *user_data) { @@ -238,8 +244,8 @@ static void on_response_poweron(TcorePending *p, int data_len, const void *data, int response = 0; int err; -#define CPAS_RES_READY 0 -#define CPAS_RES_UNAVAIL 1 +#define CPAS_RES_READY 0 +#define CPAS_RES_UNAVAIL 1 #define CPAS_RES_UNKNOWN 2 #define CPAS_RES_RINGING 3 #define CPAS_RES_CALL_PROGRESS 4 @@ -248,7 +254,7 @@ static void on_response_poweron(TcorePending *p, int data_len, const void *data, //print sp_response - for debug printResponse(); - if(sp_response->success > 0){ + if(sp_response->success > 0){ dbg("RESPONSE OK"); //parse response line = sp_response->p_intermediates->line; @@ -270,7 +276,7 @@ static void on_response_poweron(TcorePending *p, int data_len, const void *data, switch(response) { case CPAS_RES_READY: - case CPAS_RES_RINGING: + case CPAS_RES_RINGING: case CPAS_RES_CALL_PROGRESS: case CPAS_RES_ASLEEP: bpoweron = TRUE; @@ -301,7 +307,7 @@ error: dbg("CPAS once again"); s_modem_send_poweron(tcore_object_ref_plugin(tcore_pending_ref_core_object(p))); - } + } } static void on_response_set_flight_mode(TcorePending *p, int data_len, const void *data, void *user_data) @@ -319,43 +325,43 @@ static void on_response_set_flight_mode(TcorePending *p, int data_len, const voi ur = tcore_pending_ref_user_request(p); if(sp_response->success > 0) - { + { dbg("RESPONSE OK"); //parse response queue = tcore_object_ref_user_data(o); - if (queue) + if (queue) { - ur = tcore_user_request_dup(ur); + ur = tcore_user_request_ref(ur); util_add_waiting_job(queue, ID_RESERVED_AT, ur); } ReleaseResponse(); - } + } else { dbg("RESPONSE NOK"); line = sp_response->finalResponse; err = at_tok_start(&line); - if (err < 0) + if (err < 0) { dbg("err cause not specified or string corrupted"); - res.result = TCORE_RETURN_3GPP_ERROR; + res.result = TCORE_RETURN_3GPP_ERROR; } else { err = at_tok_nextint(&line, &response); - if (err < 0) + if (err < 0) { dbg("err not specified or string not contail error"); - res.result = TCORE_RETURN_3GPP_ERROR; + res.result = TCORE_RETURN_3GPP_ERROR; } else { - res.result = convertCMEError((enum ATCMEError)response); + res.result = convertCMEError((enum ATCMEError)response); } ReleaseResponse(); - + tcore_user_request_send_response(ur, TRESP_MODEM_SET_FLIGHTMODE, sizeof(struct tresp_modem_set_flightmode), &res); } } @@ -369,7 +375,7 @@ static void on_response_imei(TcorePending *p, int data_len, const void *data, vo char *line; int response; int err; - + printResponse(); memset(&res, 0, sizeof(struct tresp_modem_get_imei)); @@ -384,10 +390,10 @@ static void on_response_imei(TcorePending *p, int data_len, const void *data, vo strncpy(res.imei, line, 16); dbg("imei = [%s]", res.imei); - + plugin = tcore_pending_ref_plugin(p); imei_property = tcore_plugin_ref_property(plugin, "IMEI"); - if (imei_property) + if (imei_property) { imei_property->sn_index = TAPI_MISC_ME_IMEI; imei_property->sn_len = strlen(res.imei); @@ -400,7 +406,7 @@ static void on_response_imei(TcorePending *p, int data_len, const void *data, vo line = sp_response->finalResponse; err = at_tok_start(&line); - if (err < 0) + if (err < 0) { dbg("err cause not specified or string corrupted"); res.result = TCORE_RETURN_3GPP_ERROR; @@ -408,20 +414,20 @@ static void on_response_imei(TcorePending *p, int data_len, const void *data, vo else { err = at_tok_nextint(&line, &response); - if (err < 0) + if (err < 0) { dbg("err not specified or string not contail error"); - res.result = TCORE_RETURN_3GPP_ERROR; + res.result = TCORE_RETURN_3GPP_ERROR; } else { - res.result = convertCMEError((enum ATCMEError)response); + res.result = convertCMEError((enum ATCMEError)response); } } } - + ReleaseResponse(); - + ur = tcore_pending_ref_user_request(p); tcore_user_request_send_response(ur, TRESP_MODEM_GET_IMEI, sizeof(struct tresp_modem_get_imei), &res); @@ -434,7 +440,7 @@ static void on_response_version(TcorePending *p, int data_len, const void *data, struct TelMiscVersionInformation *vi_property; struct tresp_modem_get_version res; UserRequest *ur; - char* line=NULL; + char* line=NULL; char *swver= NULL,*hwver=NULL, *caldate=NULL,*pcode=NULL,*id=NULL; int response, err; @@ -460,7 +466,7 @@ static void on_response_version(TcorePending *p, int data_len, const void *data, err = at_tok_nextstr(&line,&id); dbg("version: sw=[%s], hw=[%s], rf_cal=[%s], product_code=[%s], model_id=[%s]", swver, hwver, caldate, pcode, id); - + vi = calloc(sizeof(struct TelMiscVersionInformation), 1); memcpy(vi->szSwVersion, swver, strlen(swver)); memcpy(vi->szHwVersion, hwver, strlen(hwver)); @@ -473,7 +479,7 @@ static void on_response_version(TcorePending *p, int data_len, const void *data, snprintf(res.hardware, (AT_VER_LEN >strlen(hwver) ?strlen(hwver):AT_VER_LEN), "%s", hwver); plugin = tcore_pending_ref_plugin(p); - vi_property = tcore_plugin_ref_property(plugin, "VERSION"); + vi_property = tcore_plugin_ref_property(plugin, "VERSION"); memcpy(vi_property, vi, sizeof(struct TelMiscVersionInformation)); } else @@ -484,7 +490,7 @@ static void on_response_version(TcorePending *p, int data_len, const void *data, memset(&res, 0, sizeof(struct tresp_modem_get_version)); err = at_tok_start(&line); - if (err < 0) + if (err < 0) { dbg("err cause not specified or string corrupted"); res.result = TCORE_RETURN_3GPP_ERROR; @@ -492,23 +498,23 @@ static void on_response_version(TcorePending *p, int data_len, const void *data, else { err = at_tok_nextint(&line, &response); - if (err < 0) + if (err < 0) { dbg("err not specified or string not contail error"); - res.result = TCORE_RETURN_3GPP_ERROR; + res.result = TCORE_RETURN_3GPP_ERROR; } else { - res.result = convertCMEError((enum ATCMEError)response); + res.result = convertCMEError((enum ATCMEError)response); } } - } + } ReleaseResponse(); ur = tcore_pending_ref_user_request(p); tcore_user_request_send_response(ur, TRESP_MODEM_GET_VERSION, sizeof(struct tresp_modem_get_version), &res); - + } static TReturn power_on(CoreObject *o, UserRequest *ur) @@ -519,6 +525,14 @@ static TReturn power_on(CoreObject *o, UserRequest *ur) static TReturn power_off(CoreObject *o, UserRequest *ur) { + struct tnoti_modem_power modem_power; + modem_power.state = MODEM_STATE_OFFLINE; + + tcore_modem_set_powered(o, FALSE); + + tcore_server_send_notification( tcore_plugin_ref_server(tcore_object_ref_plugin(o)), o, TNOTI_MODEM_POWER, + sizeof(struct tnoti_modem_power), &modem_power); + return TCORE_RETURN_SUCCESS; } static TReturn power_reset(CoreObject *o, UserRequest *ur) @@ -536,7 +550,7 @@ static TReturn get_imei(CoreObject *o, UserRequest *ur) int info_len =0; p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); memset(&metainfo, 0, sizeof(struct ATReqMetaInfo)); metainfo.type = NUMERIC; @@ -557,7 +571,7 @@ static TReturn get_imei(CoreObject *o, UserRequest *ur) tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT); tcore_pending_set_send_callback(pending, on_confirmation_modem_message_send, NULL); - + tcore_hal_send_request(h, pending); @@ -573,8 +587,8 @@ static TReturn get_version(CoreObject *o, UserRequest *ur) struct ATReqMetaInfo metainfo; int info_len =0; - p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + p = tcore_object_ref_plugin(o); + h = tcore_object_get_hal(o); memset(&metainfo, 0, sizeof(struct ATReqMetaInfo)); metainfo.type = SINGLELINE; @@ -585,8 +599,8 @@ static TReturn get_version(CoreObject *o, UserRequest *ur) cmd_str = g_strdup("AT+CGMR\r"); - dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str)); - + dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str)); + pending = tcore_pending_new(o, ID_RESERVED_AT); tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str); free(cmd_str); @@ -613,11 +627,10 @@ static TReturn set_flight_mode(CoreObject *o, UserRequest *ur) int info_len =0; p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); req_data = tcore_user_request_ref_data(ur, NULL); - if (req_data->enable) { dbg("Flight mode on/n"); cmd_str = g_strdup("AT+CFUN=0\r"); @@ -634,7 +647,7 @@ static TReturn set_flight_mode(CoreObject *o, UserRequest *ur) tcore_user_request_set_metainfo(ur, info_len, &metainfo); - dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str)); + dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str)); pending = tcore_pending_new(o, ID_RESERVED_AT); tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str); @@ -661,14 +674,14 @@ static struct tcore_modem_operations modem_ops = .get_version = get_version, }; -gboolean s_modem_init(TcorePlugin *p) +gboolean s_modem_init(TcorePlugin *p, TcoreHal *h) { CoreObject *o; GQueue *work_queue; struct TelMiscVersionInformation *vi_property; struct TelMiscSNInformation *imei_property; - o = tcore_modem_new(p, "modem", &modem_ops); + o = tcore_modem_new(p, "modem", &modem_ops, h); if (!o) return FALSE; @@ -725,9 +738,8 @@ gboolean s_modem_send_poweron(TcorePlugin *p) char* cmd_str = NULL; struct ATReqMetaInfo metainfo; int info_len =0; - + ur = tcore_user_request_new(NULL, NULL); - hal = tcore_plugin_ref_hal(p); memset(&metainfo, 0, sizeof(struct ATReqMetaInfo)); metainfo.type = SINGLELINE; @@ -740,7 +752,8 @@ gboolean s_modem_send_poweron(TcorePlugin *p) dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d",cmd_str, metainfo.responsePrefix, strlen(cmd_str)); o = tcore_plugin_ref_core_object(p, "modem"); - + hal = tcore_object_get_hal(o); + pending = tcore_pending_new(o, ID_RESERVED_AT); tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str); free(cmd_str); diff --git a/src/s_network.c b/src/s_network.c index 71952cf..a43cb6c 100644 --- a/src/s_network.c +++ b/src/s_network.c @@ -111,7 +111,7 @@ static void __send_at_request(CoreObject *o, char* atcmd, UserRequest *ur, Tcore TcorePending *pending = NULL; plugin = tcore_object_ref_plugin(o); - hal = tcore_plugin_ref_hal(plugin); + hal = tcore_object_get_hal(o); pending = tcore_pending_new(o, ID_RESERVED_AT); tcore_pending_set_request_data(pending, strlen(atcmd), atcmd); @@ -574,7 +574,7 @@ static void on_response_get_serving_network(TcorePending *pending, int data_len, return; } -static void on_event_network_regist(CoreObject *o, const void *event_info, void *user_data) +static gboolean on_event_network_regist(CoreObject *o, const void *event_info, void *user_data) { struct tnoti_network_registration_status regist_status; enum telephony_network_service_domain_status cs_status; @@ -597,7 +597,7 @@ static void on_event_network_regist(CoreObject *o, const void *event_info, void else if (strStartsWith(line,"+CGREG:")) svc_domain = NETWORK_SERVICE_DOMAIN_PS; else - return; + return TRUE; dbg("svc_domain = 0x%x", svc_domain); @@ -700,9 +700,11 @@ process: TNOTI_NETWORK_REGISTRATION_STATUS, sizeof(struct tnoti_network_registration_status), ®ist_status); get_serving_network(o, NULL); + + return TRUE; } -static void on_event_network_icon_info(CoreObject *o, const void *event_info, void *user_data) +static gboolean on_event_network_icon_info(CoreObject *o, const void *event_info, void *user_data) { char *line = (char *)event_info; static struct tnoti_network_icon_info net_icon_info = {0xff,0,0,0}; @@ -728,20 +730,24 @@ static void on_event_network_icon_info(CoreObject *o, const void *event_info, vo case CIND_NOTI_RSSI: dbg("CIND_NOTI_RSSI. ind=%d",ind); net_icon_info.rssi = ind; - break; + break; case CIND_NOTI_BATTERY: dbg("CIND_NOTI_BATTERY. ind=%d",ind); net_icon_info.battery = ind; - break; + break; default: err("This event is not handled val=%d",descr); - return; + return TRUE; } + dbg("type=%d, rssi=%d, battery=%d, hdr_rssi=%d", - net_icon_info.type, net_icon_info.rssi, net_icon_info.battery, net_icon_info.hdr_rssi); + net_icon_info.type, net_icon_info.rssi, net_icon_info.battery, net_icon_info.hdr_rssi); + tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)), o, TNOTI_NETWORK_ICON_INFO, sizeof(struct tnoti_network_icon_info), &net_icon_info); + + return TRUE; } static void on_sim_resp_hook_get_netname(UserRequest *ur, enum tcore_response_command command, unsigned int data_len, @@ -980,11 +986,11 @@ static struct tcore_network_operations network_ops = { .get_serving_network = get_serving_network, }; -gboolean s_network_init(TcorePlugin *plugin) +gboolean s_network_init(TcorePlugin *plugin, TcoreHal *h) { CoreObject *o; - o = tcore_network_new(plugin, "umts_network", &network_ops); + o = tcore_network_new(plugin, "umts_network", &network_ops, h); if (!o) return FALSE; diff --git a/src/s_ps.c b/src/s_ps.c index dfef543..12f7ac7 100755 --- a/src/s_ps.c +++ b/src/s_ps.c @@ -65,9 +65,9 @@ static void on_confirmation_ps_message_send( TcorePending *p, gboolean result, v metainfo = (struct ATReqMetaInfo*)tcore_user_request_ref_metainfo(ur,&info_len); if ((metainfo->type == SINGLELINE)||(metainfo->type == MULTILINE)) { - //cp rsp prefix + //cp rsp prefix s_responsePrefix = strdup(metainfo->responsePrefix); - dbg("duplicating responsePrefix : %s\n", s_responsePrefix); + dbg("duplicating responsePrefix : %s\n", s_responsePrefix); } else { s_responsePrefix = NULL; @@ -128,26 +128,26 @@ static void on_event_ps_ipconfiguration(CoreObject *o, const void *event_info, v char *line = NULL, *ip = NULL, *gateway = NULL;//, *netmask = NULL; /* count the PDP contexts */ - for (pdpContextCnt = 0, p_cur = p_response->p_intermediates - ; p_cur != NULL - ; p_cur = p_cur->p_next) { - pdpContextCnt++; - } - - dbg("Total number of PDP contexts : %d",pdpContextCnt); - - if(pdpContextCnt == 0) + for (pdpContextCnt = 0, p_cur = p_response->p_intermediates + ; p_cur != NULL + ; p_cur = p_cur->p_next) { + pdpContextCnt++; + } + + dbg("Total number of PDP contexts : %d",pdpContextCnt); + + if(pdpContextCnt == 0) return; for (p_cur = p_response->p_intermediates - ; p_cur != NULL - ; p_cur = p_cur->p_next) { + ; p_cur != NULL + ; p_cur = p_cur->p_next) { line = p_response->p_intermediates->line; - + err = at_tok_start(&line); err = at_tok_nextint(&line,&p_cid); dbg("cid: %d", p_cid); - + /* Send IP Configuration noti only on the requested CID. */ if (p_cid && (cid == (unsigned int)p_cid)) { err = at_tok_nextstr(&line,&pdp_type); @@ -181,7 +181,7 @@ static void on_event_ps_ipconfiguration(CoreObject *o, const void *event_info, v dbg("inet_pton() failed."); return; } - + snprintf(addr_buf[0], 20, "%d.%d.%d.%d", noti.ip_address[0], noti.ip_address[1], noti.ip_address[2], noti.ip_address[3]); ip = addr_buf[0]; @@ -206,7 +206,7 @@ static void on_event_ps_ipconfiguration(CoreObject *o, const void *event_info, v gateway = addr_buf[3]; dbg("gateway = [%s]", gateway); - /* FIX ME: use static netmask. */ + /* FIX ME: use static netmask. */ noti.subnet_mask[0] = 255; noti.subnet_mask[1] = 255; noti.subnet_mask[2] = 255; @@ -237,19 +237,19 @@ static void on_response_get_ipconfiguration(TcorePending *pending, int data_len, struct ATLine *p_cur; CoreObject *ps_context = (CoreObject *)user_data; char *line = NULL; - + printResponse(); if (sp_response->success > 0) { dbg("RESPONSE OK"); - + for (p_cur = sp_response->p_intermediates - ; p_cur != NULL - ; p_cur = p_cur->p_next) { + ; p_cur != NULL + ; p_cur = p_cur->p_next) { line = sp_response->p_intermediates->line; dbg("%s\n", line); } - + dbg("Call on_ipc_event_ps_ipconfiguration"); on_event_ps_ipconfiguration(tcore_pending_ref_core_object(pending), sp_response, ps_context); } @@ -280,7 +280,7 @@ static void on_response_ps_attached(TcorePending *p, int data_len, const void *d dbg("RESPONSE OK"); line = sp_response->p_intermediates->line; dbg("on_response_ps_attached: %s", line); - + ur = tcore_user_request_new(NULL, NULL); memset(&metainfo, 0, sizeof(struct ATReqMetaInfo)); memcpy(metainfo.responsePrefix,"+CGDCONT:",strlen("+CGDCONT:")); @@ -293,22 +293,22 @@ static void on_response_ps_attached(TcorePending *p, int data_len, const void *d cmd_str = g_strdup("AT+CGDCONT?\r"); pl = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(pl); + h = tcore_object_get_hal(o); pending = tcore_pending_new(o, ID_RESERVED_AT); tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str); free(cmd_str); - + tcore_pending_set_timeout(pending, 0); tcore_pending_set_response_callback(pending, on_response_get_ipconfiguration, ps_context); tcore_pending_link_user_request(pending, ur); tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT); tcore_pending_set_send_callback(pending, on_confirmation_ps_message_send, NULL); - tcore_hal_send_request(h, pending); + tcore_hal_send_request(h, pending); } else { dbg("RESPONSE NOK"); } - + ReleaseResponse(); } @@ -324,7 +324,7 @@ static void on_response_active_set(TcorePending *p, int data_len, const void *da char* cmd_str = NULL; struct ATReqMetaInfo metainfo; int info_len =0; - + printResponse(); if (sp_response->success > 0) { @@ -336,19 +336,19 @@ static void on_response_active_set(TcorePending *p, int data_len, const void *da info_len = sizeof(struct ATReqMetaInfo); tcore_user_request_set_metainfo(ur, info_len, &metainfo); - + dbg(" Send: ATD*99***1#\r "); cmd_str = g_strdup("ATD*99***1#\r"); pl = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(pl); + h = tcore_object_get_hal(o); pending = tcore_pending_new(o, ID_RESERVED_AT); - + tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str); free(cmd_str); tcore_pending_set_timeout(pending, 0); - tcore_pending_set_response_callback(pending, on_response_ps_attached, ps_context); + tcore_pending_set_response_callback(pending, on_response_ps_attached, ps_context); tcore_pending_link_user_request(pending, ur); tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT); tcore_pending_set_send_callback(pending, on_confirmation_ps_message_send, NULL); @@ -357,7 +357,7 @@ static void on_response_active_set(TcorePending *p, int data_len, const void *da else { dbg("RESPONSE NOK"); tcore_context_set_state(ps_context, CONTEXT_STATE_DEACTIVATED); - } + } ReleaseResponse(); } @@ -371,7 +371,7 @@ static void on_response_deactive_set(TcorePending *p, int data_len, const void * } else { dbg("RESPONSE NOK"); - } + } ReleaseResponse(); } @@ -380,39 +380,39 @@ static gboolean pdp_active_set(CoreObject *o, CoreObject *ps_context) { TcorePlugin *p = NULL; TcoreHal *h = NULL; - TcorePending *pending = NULL; + TcorePending *pending = NULL; UserRequest *ur; unsigned int cid; - char* cmd_str = NULL; + char* cmd_str = NULL; struct ATReqMetaInfo metainfo; int info_len =0; - + if ( !o ) return TCORE_RETURN_FAILURE; p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); - - ur = tcore_user_request_new(NULL, NULL); + + ur = tcore_user_request_new(NULL, NULL); memset(&metainfo, 0, sizeof(struct ATReqMetaInfo)); metainfo.type = NO_RESULT; info_len = sizeof(struct ATReqMetaInfo); tcore_user_request_set_metainfo(ur, info_len, &metainfo); - + cid = tcore_context_get_id(ps_context); - + dbg("Example: AT+CGACT=1,0"); cmd_str = g_strdup_printf("%s=%d,%d%s","AT+CGACT", 1, cid, "\r"); - + pending = tcore_pending_new(o, ID_RESERVED_AT); tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str); free(cmd_str); tcore_pending_set_timeout(pending, 0); - tcore_pending_set_response_callback(pending, on_response_active_set, ps_context); + tcore_pending_set_response_callback(pending, on_response_active_set, ps_context); tcore_pending_link_user_request(pending, ur); tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT); tcore_pending_set_send_callback(pending, on_confirmation_ps_message_send, NULL); @@ -428,13 +428,13 @@ static void on_response_define_pdp(TcorePending *p, int data_len, const void *da printResponse(); if (sp_response->success > 0) { - dbg("RESPONSE OK"); + dbg("RESPONSE OK"); pdp_active_set(tcore_pending_ref_core_object(p), ps_context); } else { dbg("RESPONSE NOK"); tcore_context_set_state(tcore_pending_ref_core_object(p), CONTEXT_STATE_DEACTIVATED); - } + } ReleaseResponse(); } @@ -451,16 +451,16 @@ static TReturn activate_ps_context(CoreObject *o, CoreObject *ps_context, void * unsigned int cid; enum co_context_type pdp_type; enum co_context_d_comp d_comp; - enum co_context_h_comp h_comp; + enum co_context_h_comp h_comp; char *cmd_str = NULL; struct ATReqMetaInfo metainfo; - int info_len =0; + int info_len =0; if ( !o ) return TCORE_RETURN_FAILURE; p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); ur = tcore_user_request_new(NULL, NULL); memset(&metainfo, 0, sizeof(struct ATReqMetaInfo)); metainfo.type = NO_RESULT; @@ -472,10 +472,10 @@ static TReturn activate_ps_context(CoreObject *o, CoreObject *ps_context, void * pdp_type = tcore_context_get_type(ps_context); d_comp = tcore_context_get_data_compression(ps_context); h_comp = tcore_context_get_header_compression(ps_context); - + dbg("Example: AT+CGDCONT=1,\"IP\",\"www.example.co.kr\",,0,0"); - cmd_str = g_strdup_printf("AT+CGDCONT=%d,\"%d\",\"%s\",%s,%d,%d%s", - cid, pdp_type, apn, addr, d_comp, h_comp, "\r"); + cmd_str = g_strdup_printf("AT+CGDCONT=%d,\"%d\",\"%s\",%s,%d,%d%s", + cid, pdp_type, apn, addr, d_comp, h_comp, "\r"); pending = tcore_pending_new(o, ID_RESERVED_AT); tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str); @@ -499,26 +499,26 @@ static TReturn deactivate_ps_context(CoreObject *o, CoreObject *ps_context, void UserRequest *ur; unsigned int cid; - char* cmd_str = NULL; + char* cmd_str = NULL; struct ATReqMetaInfo metainfo; - int info_len =0; + int info_len =0; if ( !o ) return TCORE_RETURN_FAILURE; p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); ur = tcore_user_request_new(NULL, NULL); memset(&metainfo, 0, sizeof(struct ATReqMetaInfo)); metainfo.type = NO_RESULT; info_len = sizeof(struct ATReqMetaInfo); - + cid = tcore_context_get_id(ps_context); - + dbg("Example: AT+CGACT=0,1"); cmd_str = g_strdup_printf("%s=%d,%d%s","AT+CGACT", 0, cid, "\r"); - + pending = tcore_pending_new(o, ID_RESERVED_AT); tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str); free(cmd_str); @@ -535,17 +535,16 @@ static TReturn deactivate_ps_context(CoreObject *o, CoreObject *ps_context, void static struct tcore_ps_operations ps_ops = { - .pin_ctrl = NULL, .activate_context = activate_ps_context, .deactivate_context = deactivate_ps_context }; -gboolean s_ps_init(TcorePlugin *p) +gboolean s_ps_init(TcorePlugin *p, TcoreHal *h) { CoreObject *o; GQueue *work_queue; - o = tcore_ps_new(p, "umts_ps", &ps_ops); + o = tcore_ps_new(p, "umts_ps", &ps_ops, h); if (!o) return FALSE; diff --git a/src/s_sim.c b/src/s_sim.c index a3d89e3..1ca7d49 100644 --- a/src/s_sim.c +++ b/src/s_sim.c @@ -113,38 +113,38 @@ struct s_sim_property { enum s_sim_sec_locktype_e{ SEC_LOCK_TYPE_NONE =0, SEC_LOCK_TYPE_READY, /* ME is not locked */ - SEC_LOCK_TYPE_PS, /* PH-SIM, Lock Phone to SIM/UICC card(MT asks password when other than current SIM/UICC card inserted; MT may remember certain amount of - previously used cards thus not requiring password when they are inserted ) */ - SEC_LOCK_TYPE_PF, /* PH-FSIM, Lock Phone to the very First inserted SIM/UICC card ( MT asks password when other than the first SIM/UICC card is inserted ) */ - SEC_LOCK_TYPE_SC, /*Lock SIM/UICC card ( SIM asks password in ME power-up and when this command is issued ) */ - SEC_LOCK_TYPE_FD, /* SIM card or active application in the UICC(GSM or USIM) fixed dialing memory feature */ + SEC_LOCK_TYPE_PS, /* PH-SIM, Lock Phone to SIM/UICC card(MT asks password when other than current SIM/UICC card inserted; MT may remember certain amount of + previously used cards thus not requiring password when they are inserted ) */ + SEC_LOCK_TYPE_PF, /* PH-FSIM, Lock Phone to the very First inserted SIM/UICC card ( MT asks password when other than the first SIM/UICC card is inserted ) */ + SEC_LOCK_TYPE_SC, /*Lock SIM/UICC card ( SIM asks password in ME power-up and when this command is issued ) */ + SEC_LOCK_TYPE_FD, /* SIM card or active application in the UICC(GSM or USIM) fixed dialing memory feature */ SEC_LOCK_TYPE_PN, /* Network Personalization */ - SEC_LOCK_TYPE_PU, /* Network subset Personalization */ - SEC_LOCK_TYPE_PP, /* Service Provider Personalization */ - SEC_LOCK_TYPE_PC, /* Corporate Personalization */ - SEC_LOCK_TYPE_SC2, /* Lock PIN2 ( ... ) */ - SEC_LOCL_TYPE_PUK2, /* Lock PUK2 (... ) */ - SEC_LOCK_TYPE_ACL, /* ACL */ - - SEC_LOCK_TYPE_NO_SIM, /* SIM is not inserted */ - SEC_LOCK_TYPE_UNAVAIL, /* SIM is inserted but can not communicate with SIM ( SIM interface error ) */ - SEC_SIM_INIT_COMPLETED, /* SIM Initialize Completed */ - SEC_PB_INIT_COMPLETED, /* Phonebook Initialize Completed*/ - SEC_SIM_INIT_CRASH, /* SIM Crash request from SMC lab*/ - - SEC_LOCK_TYPE_MAX + SEC_LOCK_TYPE_PU, /* Network subset Personalization */ + SEC_LOCK_TYPE_PP, /* Service Provider Personalization */ + SEC_LOCK_TYPE_PC, /* Corporate Personalization */ + SEC_LOCK_TYPE_SC2, /* Lock PIN2 ( ... ) */ + SEC_LOCL_TYPE_PUK2, /* Lock PUK2 (... ) */ + SEC_LOCK_TYPE_ACL, /* ACL */ + + SEC_LOCK_TYPE_NO_SIM, /* SIM is not inserted */ + SEC_LOCK_TYPE_UNAVAIL, /* SIM is inserted but can not communicate with SIM ( SIM interface error ) */ + SEC_SIM_INIT_COMPLETED, /* SIM Initialize Completed */ + SEC_PB_INIT_COMPLETED, /* Phonebook Initialize Completed*/ + SEC_SIM_INIT_CRASH, /* SIM Crash request from SMC lab*/ + + SEC_LOCK_TYPE_MAX }; enum s_sim_sec_lockkey_e{ SEC_LOCK_KEY_NONE, - SEC_LOCK_KEY_UNLOCKED, /* Not necessary */ - SEC_LOCK_KEY_PIN, /* PIN required as a password */ - SEC_LOCK_KEY_PUK, /* 0PUK required as a password */ - SEC_LOCK_KEY_PIN2, /* PIN2 required as a password */ - SEC_LOCK_KEY_PUK2, /* PUK2 required as a password */ - SEC_LOCK_KEY_PERM_BLOCKED, /* PIN Permanent Blocked */ - SEC_LOCK_KEY_PIN2_DISABLE, /* PIN2 Lock Disabled*/ - SEC_LOCK_KEY_MAX + SEC_LOCK_KEY_UNLOCKED, /* Not necessary */ + SEC_LOCK_KEY_PIN, /* PIN required as a password */ + SEC_LOCK_KEY_PUK, /* 0PUK required as a password */ + SEC_LOCK_KEY_PIN2, /* PIN2 required as a password */ + SEC_LOCK_KEY_PUK2, /* PUK2 required as a password */ + SEC_LOCK_KEY_PERM_BLOCKED, /* PIN Permanent Blocked */ + SEC_LOCK_KEY_PIN2_DISABLE, /* PIN2 Lock Disabled*/ + SEC_LOCK_KEY_MAX }; @@ -165,16 +165,16 @@ static gboolean _convert_SCPIN_noti(char* line, enum s_sim_sec_locktype_e* lock_ int err; if(line == NULL) return FALSE; - + dbg("incoming string : %s\n", line); - + //rip off %SCPIN: at_tok_start(&line); // 1. find type string err = at_tok_nextstr(&line, &type); if(err<0){ - // no type string found. + // no type string found. type = NULL; } if(type !=NULL){ @@ -224,8 +224,8 @@ static gboolean _convert_SCPIN_noti(char* line, enum s_sim_sec_locktype_e* lock_ else if(strStartsWith (type, "INIT_ERROR")) *lock_type = SEC_SIM_INIT_CRASH; else - *lock_type = SEC_LOCK_TYPE_NONE; - } + *lock_type = SEC_LOCK_TYPE_NONE; + } else type = SEC_LOCK_TYPE_NONE; @@ -248,23 +248,23 @@ static gboolean _convert_SCPIN_noti(char* line, enum s_sim_sec_locktype_e* lock_ else *lock_key = SEC_LOCK_KEY_NONE; } - else + else *lock_key = SEC_LOCK_KEY_NONE; - - -// 4. apply exceptional case. + + + // 4. apply exceptional case. //if type is READY, key has no meanig - if(*lock_type == SEC_LOCK_TYPE_READY) - *lock_key = SEC_LOCK_KEY_UNLOCKED; + if(*lock_type == SEC_LOCK_TYPE_READY) + *lock_key = SEC_LOCK_KEY_UNLOCKED; // no sim, unvail, init_comp, init_error have no key info - if((*lock_type == SEC_LOCK_TYPE_NO_SIM)||(*lock_type == SEC_LOCK_TYPE_UNAVAIL)|| + if((*lock_type == SEC_LOCK_TYPE_NO_SIM)||(*lock_type == SEC_LOCK_TYPE_UNAVAIL)|| (*lock_type == SEC_SIM_INIT_COMPLETED)||(*lock_type == SEC_SIM_INIT_CRASH)) - *lock_key = SEC_LOCK_KEY_NONE; - + *lock_key = SEC_LOCK_KEY_NONE; + dbg("type : %d, key : %d\n", *lock_type, *lock_key); - - return TRUE; + + return TRUE; } static enum tcore_response_command _find_resp_command(UserRequest *ur) @@ -335,11 +335,8 @@ static enum tcore_response_command _find_resp_command(UserRequest *ur) case TREQ_SIM_GET_PNN: return TRESP_SIM_GET_PNN; break; - case TREQ_SIM_GET_CPHS_SHORTNETNAME: - return TRESP_SIM_GET_CPHS_SHORTNETNAME; - break; - case TREQ_SIM_GET_CPHS_FULLNETNAME: - return TRESP_SIM_GET_CPHS_FULLNETNAME; + case TREQ_SIM_GET_CPHS_NETNAME: + return TRESP_SIM_GET_CPHS_NETNAME; break; case TREQ_SIM_GET_OPLMNWACT: return TRESP_SIM_GET_OPLMNWACT; @@ -883,9 +880,9 @@ static void on_confirmation_sim_message_send( TcorePending *p, gboolean result, if((metainfo->type == SINGLELINE)|| (metainfo->type == MULTILINE)) { - //cp rsp prefix + //cp rsp prefix s_responsePrefix = strdup(metainfo->responsePrefix); - dbg("duplicating responsePrefix : %s\n", s_responsePrefix); + dbg("duplicating responsePrefix : %s\n", s_responsePrefix); } else { @@ -894,7 +891,7 @@ static void on_confirmation_sim_message_send( TcorePending *p, gboolean result, //set atcmd type into s_type s_type = metainfo->type; - + if (result == FALSE) { /* Fail */ dbg("SEND FAIL"); @@ -911,19 +908,19 @@ static void _response_get_sim_type(TcorePending *p, int data_len, const void *da enum tel_sim_type sim_type = SIM_TYPE_UNKNOWN; char* line=NULL; int ret = 0; - + if(sp_response->success > 0) { line = sp_response->p_intermediates->line; - + ret = at_tok_start(&line); if (ret < 0) AT_TOK_ERROR(line); ret = at_tok_nextint(&line,(int *)&sim_type); if (ret < 0) - AT_TOK_ERROR(line); - } + AT_TOK_ERROR(line); + } else { sim_type = SIM_TYPE_UNKNOWN; @@ -932,11 +929,11 @@ static void _response_get_sim_type(TcorePending *p, int data_len, const void *da dbg("resp sim type[%d]", sim_type); ReleaseResponse(); - + co_sim = tcore_pending_ref_core_object(p); tcore_sim_set_type(co_sim, sim_type); sp = tcore_sim_ref_userdata(co_sim); - _sim_status_update(co_sim, sp->first_recv_status); + _sim_status_update(co_sim, sp->first_recv_status); } static void _response_get_file_info(TcorePending *p, int data_len, const void *data, void *user_data) @@ -952,7 +949,7 @@ static void _response_get_file_info(TcorePending *p, int data_len, const void *d int sw2 = 0; //char *hexData; //char *recordData; - + co_sim = tcore_pending_ref_core_object(p); if(!co_sim){ dbg("error - core object is null"); @@ -991,15 +988,15 @@ static void _response_get_file_info(TcorePending *p, int data_len, const void *d unsigned char file_type_tag = 0x07; unsigned char *ptr_data; - char *hexData; + char *hexData; char *recordData; ret = at_tok_nextstr(&line,&hexData); if (ret < 0) AT_TOK_ERROR(line); - + recordData = util_hexStringToBytes(hexData); util_hex_dump(" ", strlen(hexData)/2, recordData); - + ptr_data = (unsigned char *)recordData; if (tcore_sim_get_type(co_sim) == SIM_TYPE_USIM) { /* @@ -1102,7 +1099,7 @@ static void _response_get_file_info(TcorePending *p, int data_len, const void *d } else { dbg("INVALID FCP received - DEbug!"); free(recordData); - ReleaseResponse(); + ReleaseResponse(); return; } @@ -1179,7 +1176,7 @@ static void _response_get_file_info(TcorePending *p, int data_len, const void *d } else { dbg("INVALID FCP received[0x%x] - DEbug!", *ptr_data); free(recordData); - ReleaseResponse(); + ReleaseResponse(); return; } @@ -1308,8 +1305,8 @@ static void _response_get_file_info(TcorePending *p, int data_len, const void *d dbg(" not handled file type"); break; } - } - else + } + else { dbg(" Card Type - UNKNOWN [%d]", tcore_sim_get_type(co_sim)); } @@ -1325,7 +1322,7 @@ static void _response_get_file_info(TcorePending *p, int data_len, const void *d rt = SIM_ACCESS_SUCCESS; free(recordData); } - else + else { /*2. SIM access fail case*/ dbg("error to get ef[0x%x]", file_meta->file_id); @@ -1334,7 +1331,7 @@ static void _response_get_file_info(TcorePending *p, int data_len, const void *d ReleaseResponse(); - ur = tcore_user_request_dup(ur); + ur = tcore_user_request_ref(ur); _next_from_get_file_info(co_sim, ur, file_meta->file_id, rt); } else @@ -1343,8 +1340,8 @@ static void _response_get_file_info(TcorePending *p, int data_len, const void *d dbg("error to get ef[0x%x]", file_meta->file_id); rt = SIM_ACCESS_FAILED;; - ur = tcore_user_request_dup(ur); - _next_from_get_file_info(co_sim, ur, file_meta->file_id, rt); + ur = tcore_user_request_ref(ur); + _next_from_get_file_info(co_sim, ur, file_meta->file_id, rt); } } @@ -1375,9 +1372,9 @@ static void _response_get_file_data(TcorePending *p, int data_len, const void *d file_meta = (struct s_sim_property*)tcore_user_request_ref_metainfo(ur, NULL); if(sp_response->success > 0) - { + { line = sp_response->p_intermediates->line; - + ret = at_tok_start(&line); if (ret < 0) AT_TOK_ERROR(line); @@ -1396,14 +1393,14 @@ static void _response_get_file_data(TcorePending *p, int data_len, const void *d ret = at_tok_nextstr(&line,&hexStr); if (ret < 0) AT_TOK_ERROR(line); - + fileData = util_hexStringToBytes(hexStr); util_hex_dump(" ", strlen(hexStr)/2, fileData); rt = SIM_ACCESS_SUCCESS; file_meta->files.result = rt; - switch (file_meta->file_id) + switch (file_meta->file_id) { case SIM_EF_IMSI: dr = tcore_sim_decode_imsi(&imsi, (unsigned char *)fileData, strlen(fileData)); @@ -1520,7 +1517,7 @@ static void _response_get_file_data(TcorePending *p, int data_len, const void *d break; case SIM_EF_CPHS_OPERATOR_NAME_STRING: - dr = tcore_sim_decode_ons(&file_meta->files.data.cphs_f_name, (unsigned char *)fileData, strlen(fileData)); + dr = tcore_sim_decode_ons((unsigned char*)&file_meta->files.data.cphs_net.full_name, (unsigned char *)fileData, strlen(fileData)); break; case SIM_EF_CPHS_DYNAMICFLAGS: @@ -1528,7 +1525,7 @@ static void _response_get_file_data(TcorePending *p, int data_len, const void *d break; case SIM_EF_CPHS_DYNAMIC2FLAG: -/* dr = tcore_sim_decode_dynamic2_flag(&po->p_cphs->d2flagsinfo, fileData, strlen(fileData));*/ +/* dr = tcore_sim_decode_dynamic2_flag(&po->p_cphs->d2flagsinfo, fileData, strlen(fileData));*/ break; case SIM_EF_CPHS_CPHS_INFO: @@ -1536,7 +1533,7 @@ static void _response_get_file_data(TcorePending *p, int data_len, const void *d break; case SIM_EF_CPHS_OPERATOR_NAME_SHORT_FORM_STRING: - dr = tcore_sim_decode_short_ons(&file_meta->files.data.cphs_s_name, (unsigned char *)fileData, strlen(fileData)); + dr = tcore_sim_decode_short_ons((unsigned char*)&file_meta->files.data.cphs_net.short_name, (unsigned char *)fileData, strlen(fileData)); break; case SIM_EF_CPHS_INFORMATION_NUMBERS: @@ -1550,7 +1547,7 @@ static void _response_get_file_data(TcorePending *p, int data_len, const void *d } free(fileData); - } + } else { rt = _decode_status_word(sw1, sw2); @@ -1563,10 +1560,10 @@ static void _response_get_file_data(TcorePending *p, int data_len, const void *d { ReleaseResponse(); rt = SIM_ACCESS_FAILED;; - file_meta->files.result = rt; + file_meta->files.result = rt; } - ur = tcore_user_request_dup(ur); + ur = tcore_user_request_ref(ur); _next_from_get_file_data(tcore_pending_ref_core_object(p), ur, rt, dr); } @@ -1585,7 +1582,7 @@ static gboolean _get_sim_type(CoreObject *o) return FALSE; p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); memset(&metainfo, 0, sizeof(struct ATReqMetaInfo)); metainfo.type = SINGLELINE; @@ -1593,20 +1590,20 @@ static gboolean _get_sim_type(CoreObject *o) info_len = sizeof(struct ATReqMetaInfo); ur = tcore_user_request_new(NULL, NULL); - + tcore_user_request_set_metainfo(ur, info_len, &metainfo); - + // AT+CPIN=[,] cmd_str = g_strdup("AT%SCCT\r"); - + pending = tcore_pending_new(o, ID_RESERVED_AT); tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str); tcore_pending_set_timeout(pending, 0); tcore_pending_set_response_callback(pending, _response_get_sim_type, NULL); tcore_pending_link_user_request(pending, ur); - + tcore_pending_set_send_callback(pending, on_confirmation_sim_message_send, NULL); - + tcore_hal_send_request(h, pending); free(cmd_str); @@ -1630,7 +1627,7 @@ static TReturn _get_file_info(CoreObject *o, UserRequest *ur, const enum tel_sim return TCORE_RETURN_EINVAL; p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); file_meta.file_id = ef; file_meta.metainfo.type = SINGLELINE; @@ -1638,10 +1635,10 @@ static TReturn _get_file_info(CoreObject *o, UserRequest *ur, const enum tel_sim info_len = sizeof(struct s_sim_property); tcore_user_request_set_command(ur, TREQ_CUSTOM); - + trt = tcore_user_request_set_metainfo(ur, sizeof(struct s_sim_property), &file_meta); dbg("trt[%d]",trt); - + // AT+CRSM=,,, cmd_str = g_strdup_printf("AT+CRSM=192, %d%s", ef, "\r"); @@ -1680,9 +1677,9 @@ static gboolean _get_file_data(CoreObject *o, UserRequest *ur, const enum tel_si dbg("new pending(IPC_SEC_RSIM_ACCESS GET - READ BIN)"); p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); -// offset for reading the TRANSPARENT data +// offset for reading the TRANSPARENT data p1 = (unsigned char)(offset & 0xFF00) >> 8; p2 = (unsigned char)offset & 0x00FF; //offset low p3 = (unsigned char)length; @@ -1695,7 +1692,7 @@ static gboolean _get_file_data(CoreObject *o, UserRequest *ur, const enum tel_si // AT+CRSM=,,, cmd_str = g_strdup_printf("AT+CRSM=176, %d%s", ef, "\r"); - + pending = tcore_pending_new(o, ID_RESERVED_AT); tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str); tcore_pending_set_timeout(pending, 0); @@ -1704,7 +1701,7 @@ static gboolean _get_file_data(CoreObject *o, UserRequest *ur, const enum tel_si tcore_pending_set_send_callback(pending, on_confirmation_sim_message_send, NULL); - tcore_hal_send_request(h, pending); + tcore_hal_send_request(h, pending); free(cmd_str); return TRUE; } @@ -1716,7 +1713,7 @@ static gboolean _get_file_record(CoreObject *o, UserRequest *ur, const enum tel_ return TRUE; } -static void on_event_pin_status(CoreObject *o, const void *event_info, void *user_data) +static gboolean on_event_pin_status(CoreObject *o, const void *event_info, void *user_data) { UserRequest *ur; char *line = (char *) event_info; @@ -1861,7 +1858,7 @@ static void on_event_pin_status(CoreObject *o, const void *event_info, void *use case SEC_PB_INIT_COMPLETED: dbg("[SIM DATA] MODEM SIM PB INIT COMPLETED. not handled here! s_phonebook should handle!"); - return; + return TRUE; break; default: @@ -1908,6 +1905,7 @@ static void on_event_pin_status(CoreObject *o, const void *event_info, void *use break; } + return TRUE; } static void on_response_verify_pins(TcorePending *p, int data_len, const void *data, void *user_data) @@ -1919,7 +1917,7 @@ static void on_response_verify_pins(TcorePending *p, int data_len, const void *d char* line=NULL; int ret; - int error; + int error; co_sim = tcore_pending_ref_core_object(p); sp = tcore_sim_ref_userdata(co_sim); @@ -1933,35 +1931,35 @@ static void on_response_verify_pins(TcorePending *p, int data_len, const void *d if(sp_response->success > 0) { ReleaseResponse(); - + resp.result = SIM_PIN_OPERATION_SUCCESS; resp.pin_type = _sim_get_current_pin_facility(sp); - tcore_user_request_send_response(ur, TRESP_SIM_VERIFY_PINS, sizeof(struct tresp_sim_verify_pins), &resp); + tcore_user_request_send_response(ur, TRESP_SIM_VERIFY_PINS, sizeof(struct tresp_sim_verify_pins), &resp); } else { //failure case - consider this later line = sp_response->finalResponse; - + ret = at_tok_start(&line); if (ret < 0) AT_TOK_ERROR(line); ret = at_tok_nextint(&line,&error); if (ret < 0) - AT_TOK_ERROR(line); + AT_TOK_ERROR(line); ReleaseResponse(); // ur = user_request_dup(ur); // _get_retry_count(co_sim, ur); - + resp.result = SIM_INCORRECT_PASSWORD; resp.pin_type = _sim_get_current_pin_facility(sp); resp.retry_count = 3; - tcore_user_request_send_response(ur, TRESP_SIM_VERIFY_PINS, sizeof(struct tresp_sim_verify_pins), &resp); - - } + tcore_user_request_send_response(ur, TRESP_SIM_VERIFY_PINS, sizeof(struct tresp_sim_verify_pins), &resp); + + } } static void on_response_verify_puks(TcorePending *p, int data_len, const void *data, void *user_data) @@ -1973,7 +1971,7 @@ static void on_response_verify_puks(TcorePending *p, int data_len, const void *d char* line=NULL; int ret; - int error; + int error; co_sim = tcore_pending_ref_core_object(p); sp = tcore_sim_ref_userdata(co_sim); @@ -1987,34 +1985,34 @@ static void on_response_verify_puks(TcorePending *p, int data_len, const void *d if(sp_response->success > 0) { ReleaseResponse(); - + resp.result = SIM_PIN_OPERATION_SUCCESS; resp.pin_type = _sim_get_current_pin_facility(sp); - tcore_user_request_send_response(ur, TRESP_SIM_VERIFY_PINS, sizeof(struct tresp_sim_verify_pins), &resp); + tcore_user_request_send_response(ur, TRESP_SIM_VERIFY_PINS, sizeof(struct tresp_sim_verify_pins), &resp); } else { //failure case - consider this later line = sp_response->finalResponse; - + ret = at_tok_start(&line); if (ret < 0) AT_TOK_ERROR(line); ret = at_tok_nextint(&line,&error); if (ret < 0) - AT_TOK_ERROR(line); + AT_TOK_ERROR(line); ReleaseResponse(); // ur = user_request_dup(ur); // _get_retry_count(co_sim, ur); - + resp.result = SIM_INCORRECT_PASSWORD; resp.pin_type = _sim_get_current_pin_facility(sp); - tcore_user_request_send_response(ur, TRESP_SIM_VERIFY_PUKS, sizeof(struct tresp_sim_verify_puks), &resp); - - } + tcore_user_request_send_response(ur, TRESP_SIM_VERIFY_PUKS, sizeof(struct tresp_sim_verify_puks), &resp); + + } } static void on_response_change_pins(TcorePending *p, int data_len, const void *data, void *user_data) @@ -2026,7 +2024,7 @@ static void on_response_change_pins(TcorePending *p, int data_len, const void *d char* line=NULL; int ret; - int error; + int error; co_sim = tcore_pending_ref_core_object(p); sp = tcore_sim_ref_userdata(co_sim); @@ -2040,32 +2038,32 @@ static void on_response_change_pins(TcorePending *p, int data_len, const void *d if(sp_response->success > 0) { ReleaseResponse(); - + resp.result = SIM_PIN_OPERATION_SUCCESS; resp.pin_type = _sim_get_current_pin_facility(sp); - tcore_user_request_send_response(ur, TRESP_SIM_VERIFY_PINS, sizeof(struct tresp_sim_verify_pins), &resp); + tcore_user_request_send_response(ur, TRESP_SIM_VERIFY_PINS, sizeof(struct tresp_sim_verify_pins), &resp); } else { //failure case - consider this later line = sp_response->finalResponse; - + ret = at_tok_start(&line); if (ret < 0) AT_TOK_ERROR(line); ret = at_tok_nextint(&line,&error); if (ret < 0) - AT_TOK_ERROR(line); + AT_TOK_ERROR(line); ReleaseResponse(); // ur = user_request_dup(ur); // _get_retry_count(co_sim, ur); - + resp.result = SIM_INCORRECT_PASSWORD; resp.pin_type = _sim_get_current_pin_facility(sp); - tcore_user_request_send_response(ur, TRESP_SIM_CHANGE_PINS, sizeof(struct tresp_sim_change_pins), &resp); + tcore_user_request_send_response(ur, TRESP_SIM_CHANGE_PINS, sizeof(struct tresp_sim_change_pins), &resp); } } @@ -2091,14 +2089,14 @@ static void on_response_get_facility_status(TcorePending *p, int data_len, const if(sp_response->success > 0) { line = sp_response->p_intermediates->line; - + ret = at_tok_start(&line); if (ret < 0) AT_TOK_ERROR(line); ret = at_tok_nextint(&line,(int *)&resp.b_enable); if (ret < 0) - AT_TOK_ERROR(line); + AT_TOK_ERROR(line); } else { @@ -2109,7 +2107,7 @@ static void on_response_get_facility_status(TcorePending *p, int data_len, const if (ur) { tcore_user_request_send_response(ur, TRESP_SIM_GET_FACILITY_STATUS, - sizeof(struct tresp_sim_get_facility_status), &resp); + sizeof(struct tresp_sim_get_facility_status), &resp); } } @@ -2137,14 +2135,14 @@ static void on_response_enable_facility(TcorePending *p, int data_len, const voi if(sp_response->success > 0) { line = sp_response->p_intermediates->line; - + ret = at_tok_start(&line); if (ret < 0) AT_TOK_ERROR(line); ret = at_tok_nextint(&line,(int *)&resp.result); if (ret < 0) - AT_TOK_ERROR(line); + AT_TOK_ERROR(line); } else { @@ -2183,14 +2181,14 @@ static void on_response_disable_facility(TcorePending *p, int data_len, const vo if(sp_response->success > 0) { line = sp_response->p_intermediates->line; - + ret = at_tok_start(&line); if (ret < 0) AT_TOK_ERROR(line); ret = at_tok_nextint(&line,(int *)&resp.result); if (ret < 0) - AT_TOK_ERROR(line); + AT_TOK_ERROR(line); } else { @@ -2222,7 +2220,7 @@ static TReturn s_verify_pins(CoreObject *o, UserRequest *ur) return TCORE_RETURN_EINVAL; p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); req_data = tcore_user_request_ref_data(ur, NULL); sp = tcore_sim_ref_userdata(o); @@ -2246,13 +2244,13 @@ static TReturn s_verify_pins(CoreObject *o, UserRequest *ur) metainfo.type = NO_RESULT; metainfo.responsePrefix[0] ='\0'; info_len = sizeof(struct ATReqMetaInfo); - + tcore_user_request_set_metainfo(ur, info_len, &metainfo); - + // AT+CPIN=[,] cmd_str = g_strdup_printf("AT+CPIN=\"%s\"%s", req_data->pin, "\r"); dbg("new pending(verify - pins), %s", cmd_str); - + pending = tcore_pending_new(o,ID_RESERVED_AT); tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str); tcore_pending_set_timeout(pending, 0); @@ -2265,7 +2263,7 @@ static TReturn s_verify_pins(CoreObject *o, UserRequest *ur) tcore_hal_send_request(h, pending); free(cmd_str); - + return TCORE_RETURN_SUCCESS; } @@ -2286,7 +2284,7 @@ static TReturn s_verify_puks(CoreObject *o, UserRequest *ur) return TCORE_RETURN_EINVAL; p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); req_data = tcore_user_request_ref_data(ur, NULL); sp = tcore_sim_ref_userdata(o); @@ -2305,12 +2303,12 @@ static TReturn s_verify_puks(CoreObject *o, UserRequest *ur) metainfo.type = NO_RESULT; metainfo.responsePrefix[0] ='\0'; info_len = sizeof(struct ATReqMetaInfo); - + tcore_user_request_set_metainfo(ur, info_len, &metainfo); - + // AT+CPIN=[,] cmd_str = g_strdup_printf("AT+CPIN=\"%s\", \"%s\"%s", req_data->puk, req_data->pin, "\r"); - + dbg("new pending(IPC_SEC_PIN_STATUS SET - verify puks)"); pending = tcore_pending_new(o, ID_RESERVED_AT); tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str); @@ -2320,11 +2318,11 @@ static TReturn s_verify_puks(CoreObject *o, UserRequest *ur) tcore_pending_link_user_request(pending, ur); tcore_pending_set_send_callback(pending, on_confirmation_sim_message_send, NULL); - + tcore_hal_send_request(h, pending); free(cmd_str); - + return TCORE_RETURN_SUCCESS; } @@ -2345,7 +2343,7 @@ static TReturn s_change_pins(CoreObject *o, UserRequest *ur) return TCORE_RETURN_EINVAL; p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); req_data = tcore_user_request_ref_data(ur, NULL); sp = tcore_sim_ref_userdata(o); @@ -2363,12 +2361,12 @@ static TReturn s_change_pins(CoreObject *o, UserRequest *ur) metainfo.type = NO_RESULT; metainfo.responsePrefix[0] ='\0'; info_len = sizeof(struct ATReqMetaInfo); - + tcore_user_request_set_metainfo(ur, info_len, &metainfo); - + // AT+CPIN=[,] cmd_str = g_strdup_printf("AT+CPIN=\"%s\", \"%s\"%s", req_data->old_pin, req_data->new_pin, "\r"); - + dbg("new pending(IPC_SEC_CHANGE_LOCKING_PW SET)"); pending = tcore_pending_new(o, ID_RESERVED_AT); tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str); @@ -2378,11 +2376,11 @@ static TReturn s_change_pins(CoreObject *o, UserRequest *ur) tcore_pending_link_user_request(pending, ur); tcore_pending_set_send_callback(pending, on_confirmation_sim_message_send, NULL); - + tcore_hal_send_request(h, pending); free(cmd_str); - + return TCORE_RETURN_SUCCESS; } @@ -2406,7 +2404,7 @@ static TReturn s_get_facility_status(CoreObject *o, UserRequest *ur) return TCORE_RETURN_EINVAL; p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); req_data = tcore_user_request_ref_data(ur, NULL); if(req_data->type == SIM_FACILITY_PS) @@ -2433,7 +2431,7 @@ static TReturn s_get_facility_status(CoreObject *o, UserRequest *ur) tcore_user_request_set_command(ur, TREQ_CUSTOM); trt = tcore_user_request_set_metainfo(ur, sizeof(struct s_sim_property), &sec_meta); dbg("trt[%d]",trt); - + // AT+CLCK=,, cmd_str = g_strdup_printf("AT+CLCK=\"%s\", %d%s", fac, mode, "\r"); @@ -2446,7 +2444,7 @@ static TReturn s_get_facility_status(CoreObject *o, UserRequest *ur) tcore_pending_link_user_request(pending, ur); tcore_pending_set_send_callback(pending, on_confirmation_sim_message_send, NULL); - + tcore_hal_send_request(h, pending); free(cmd_str); @@ -2468,12 +2466,12 @@ static TReturn s_enable_facility(CoreObject *o, UserRequest *ur) char *cmd_str = NULL; // struct ATReqMetaInfo metainfo; int info_len =0; - + if (!o || !ur) return TCORE_RETURN_EINVAL; p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); req_data = tcore_user_request_ref_data(ur, NULL); sp = tcore_sim_ref_userdata(o); @@ -2495,7 +2493,7 @@ static TReturn s_enable_facility(CoreObject *o, UserRequest *ur) return TCORE_RETURN_EINVAL; sp->current_sec_op = SEC_SIM_ENABLE; - + sec_meta.current_sec_op = req_data->type; sec_meta.metainfo.type = SINGLELINE; memcpy(sec_meta.metainfo.responsePrefix,"+CLCK:",strlen("+CLCK:")); @@ -2506,7 +2504,7 @@ static TReturn s_enable_facility(CoreObject *o, UserRequest *ur) // AT+CLCK=,, cmd_str = g_strdup_printf("AT+CLCK=\"%s\", %d, %s%s", fac, mode, req_data->password,"\r"); dbg("new pending(enable_facility), %s", cmd_str); - + pending = tcore_pending_new(o, ID_RESERVED_AT); tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str); tcore_pending_set_timeout(pending, 0); @@ -2515,7 +2513,7 @@ static TReturn s_enable_facility(CoreObject *o, UserRequest *ur) tcore_pending_link_user_request(pending, ur); tcore_pending_set_send_callback(pending, on_confirmation_sim_message_send, NULL); - + tcore_hal_send_request(h, pending); free(cmd_str); @@ -2535,14 +2533,14 @@ static TReturn s_disable_facility(CoreObject *o, UserRequest *ur) int mode = 0; // 2:query, 0: unlock, 1:lock char *cmd_str = NULL; -// struct ATReqMetaInfo metainfo; + // struct ATReqMetaInfo metainfo; int info_len =0; - + if (!o || !ur) return TCORE_RETURN_EINVAL; p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); req_data = tcore_user_request_ref_data(ur, NULL); sp = tcore_sim_ref_userdata(o); @@ -2564,7 +2562,7 @@ static TReturn s_disable_facility(CoreObject *o, UserRequest *ur) return TCORE_RETURN_EINVAL; sp->current_sec_op = SEC_SIM_ENABLE; - + sec_meta.current_sec_op = req_data->type; sec_meta.metainfo.type = SINGLELINE; memcpy(sec_meta.metainfo.responsePrefix,"+CLCK:",strlen("+CLCK:")); @@ -2575,7 +2573,7 @@ static TReturn s_disable_facility(CoreObject *o, UserRequest *ur) // AT+CLCK=,, cmd_str = g_strdup_printf("AT+CLCK=\"%s\", %d, %s%s", fac, mode, req_data->password,"\r"); dbg("new pending(enable_facility), %s", cmd_str); - + pending = tcore_pending_new(o, ID_RESERVED_AT); tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str); tcore_pending_set_timeout(pending, 0); @@ -2584,7 +2582,7 @@ static TReturn s_disable_facility(CoreObject *o, UserRequest *ur) tcore_pending_link_user_request(pending, ur); tcore_pending_set_send_callback(pending, on_confirmation_sim_message_send, NULL); - + tcore_hal_send_request(h, pending); free(cmd_str); @@ -2667,18 +2665,8 @@ static TReturn s_read_file(CoreObject *o, UserRequest *ur) api_ret = _get_file_info(o, ur, SIM_EF_PNN); break; - case TREQ_SIM_GET_CPHS_SHORTNETNAME: - if(tcore_sim_get_cphs_status(o)) - api_ret = _get_file_info(o, ur, SIM_EF_CPHS_OPERATOR_NAME_SHORT_FORM_STRING); - else - api_ret = TCORE_RETURN_ENOSYS; - break; - - case TREQ_SIM_GET_CPHS_FULLNETNAME: - if(tcore_sim_get_cphs_status(o)) - api_ret = _get_file_info(o, ur, SIM_EF_CPHS_OPERATOR_NAME_STRING); - else - api_ret = TCORE_RETURN_ENOSYS; + case TREQ_SIM_GET_CPHS_NETNAME: + api_ret = TCORE_RETURN_ENOSYS; break; case TREQ_SIM_GET_OPLMNWACT: @@ -2733,12 +2721,12 @@ static struct tcore_sim_operations sim_ops = .req_authentication = s_req_authentication }; -gboolean s_sim_init(TcorePlugin *p) +gboolean s_sim_init(TcorePlugin *p, TcoreHal *h) { CoreObject *o; struct s_sim_property *sp = NULL; - o = tcore_sim_new(p, "sim", &sim_ops); + o = tcore_sim_new(p, "sim", &sim_ops, h); if (!o) return FALSE; diff --git a/src/s_sms.c b/src/s_sms.c index 834eba1..3ee2e21 100644 --- a/src/s_sms.c +++ b/src/s_sms.c @@ -274,22 +274,22 @@ static int util_sms_ipcError2SmsError(int err) case 302: //Operation not allowed; case 303: //Operation not supported; returnStatus = SMS_OPERATION_NOT_SUPPORTED; - break; + break; case 304: //Invalid PDU mode parameter; case 305: //Invalid text mode parameter; returnStatus = SMS_INVALID_PARAMETER_FORMAT; - break; + break; case 320: //memory failure; case 321: //invalid memory index; case 322: //memory full; returnStatus = SMS_MEMORY_FAILURE; - break; + break; case 330: //SCA unknown; case 500: //Unknown error; default: returnStatus = SMS_UNKNOWN; - break; - } + break; + } return returnStatus; } @@ -298,7 +298,7 @@ static int util_sms_ipcError2SmsError(int err) /************************ Events Cb *************************/ /************************************************************/ -static void on_event_sms_incom_msg(CoreObject *o, const void *event_info, void *user_data) +static gboolean on_event_sms_incom_msg(CoreObject *o, const void *event_info, void *user_data) { struct smsDeliveryPDU *smsPdu = (struct smsDeliveryPDU *)event_info; struct property_sms_info *property; @@ -331,7 +331,7 @@ static void on_event_sms_incom_msg(CoreObject *o, const void *event_info, void * property = tcore_plugin_ref_property(tcore_object_ref_plugin(o), "SMS"); if(!property) { dbg("property is NULL"); - return; + return TRUE; } memcpy(gsmMsgInfo.msgInfo.sca, &smsPdu->pdu[0], (ScLength+1)); @@ -355,35 +355,26 @@ static void on_event_sms_incom_msg(CoreObject *o, const void *event_info, void * { dbg("Invalid Message Length"); } - - return; + + return TRUE; } -static void on_event_sms_device_ready(CoreObject *o, const void *event_info, void *user_data) +static gboolean on_event_sms_device_ready(CoreObject *o, const void *event_info, void *user_data) { - struct tnoti_sms_device_ready_status deviceStatusInfo = {0,}; - struct property_sms_info *property = NULL; - + struct tnoti_sms_ready_status readyStatusInfo = {0,}; int rtn = -1; dbg(" Func Entrance"); + readyStatusInfo.status = TRUE; + tcore_sms_set_ready_status(o, readyStatusInfo.status); - property = tcore_plugin_ref_property(tcore_object_ref_plugin(o), "SMS"); - if(!property) { - dbg("property is NULL"); - return; - } - - property->bDevice_Ready = 1; // TRUE - deviceStatusInfo.status = 1; - - dbg("bDevice_Ready = [0x%02x]", property->bDevice_Ready); + dbg("SMS Ready status = [%s]", readyStatusInfo.status ? "TRUE" : "FALSE"); - rtn = tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)), o, TNOTI_SMS_DEVICE_READY, sizeof(struct tnoti_sms_device_ready_status), &deviceStatusInfo); + rtn = tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)), o, TNOTI_SMS_DEVICE_READY, sizeof(struct tnoti_sms_ready_status), &readyStatusInfo); dbg(" Return value [%d]",rtn); - return; + return TRUE; } /*************************************************************/ @@ -406,9 +397,9 @@ static void on_confirmation_sms_message_send( TcorePending *p, gboolean result, if((metainfo->type == SINGLELINE)|| (metainfo->type == MULTILINE)) { - //cp rsp prefix + //cp rsp prefix s_responsePrefix = strdup(metainfo->responsePrefix); - dbg("duplicating responsePrefix : %s\n", s_responsePrefix); + dbg("duplicating responsePrefix : %s\n", s_responsePrefix); } else { @@ -445,24 +436,24 @@ static void on_response_send_umts_msg(TcorePending *p, int data_len, const void } printResponse(); - + if(sp_response->success == TRUE) { ReleaseResponse(); - ur = tcore_user_request_dup(ur); + ur = tcore_user_request_ref(ur); ret = (int) Send_SmsSubmitTpdu(tcore_pending_ref_core_object(p), ur); if(ret != (int)TCORE_RETURN_SUCCESS) { respSendMsg.result = SMS_INVALID_PARAMETER; tcore_user_request_send_response(ur, TRESP_SMS_SEND_UMTS_MSG, sizeof(struct tresp_sms_send_umts_msg), &respSendMsg); - } + } } else { //failure case - consider this later line = sp_response->finalResponse; - + ret = at_tok_start(&line); if (ret < 0) AT_TOK_ERROR(line); @@ -490,35 +481,36 @@ static void on_response_send_smsSubmitTpdu(TcorePending *p, int data_len, const int mr; int error; char *hexData; - + char cSCA = '\0'; printResponse(); - + if(sp_response->success > 0) { line = sp_response->p_intermediates->line; - + memset(&respUmtsInfo, 0 , sizeof(struct tresp_sms_send_umts_msg)); // +CMGS: [, ] // SMS_SMDATA_SIZE_MAX + 1 ret = at_tok_start(&line); - if (ret < 0) - AT_NOTI_TOK_ERROR(line); + if (ret < 0) + AT_TOK_ERROR(line); ret = at_tok_nextint(&line, &mr); - if (ret < 0) + if (ret < 0) return; ret = at_tok_nextstr(&line, &hexData); - if (ret < 0) + if (ret < 0) { dbg(" ackpdu is NULL "); + ackpdu = NULL; + } else { + ackpdu = util_hexStringToBytes(hexData); + util_hex_dump(" ", strlen(hexData)/2, ackpdu); } - ackpdu = util_hexStringToBytes(hexData); - util_hex_dump(" ", strlen(hexData)/2, ackpdu); - dbg(" Func Entrance "); ur = tcore_pending_ref_user_request(p); @@ -526,7 +518,11 @@ static void on_response_send_smsSubmitTpdu(TcorePending *p, int data_len, const { memcpy(respUmtsInfo.dataInfo.sca, &cSCA, sizeof(char)); - respUmtsInfo.dataInfo.msgLength = strlen(ackpdu); + if (ackpdu) { + respUmtsInfo.dataInfo.msgLength = strlen(ackpdu); + } else { + respUmtsInfo.dataInfo.msgLength = 0; + } if ( (respUmtsInfo.dataInfo.msgLength >= 0) && (0xff >= respUmtsInfo.dataInfo.msgLength)) { @@ -563,7 +559,7 @@ static void on_response_send_smsSubmitTpdu(TcorePending *p, int data_len, const { //failure case - consider this later line = sp_response->finalResponse; - + ret = at_tok_start(&line); if (ret < 0) AT_TOK_ERROR(line); @@ -571,21 +567,21 @@ static void on_response_send_smsSubmitTpdu(TcorePending *p, int data_len, const ret = at_tok_nextint(&line,&error); if (ret < 0) AT_TOK_ERROR(line); - + //5. release sp_response & s_responsePrefix - before sending user callback, because user callback can request additional request // and if queue is empty, that req can be directly sent to mdm - can cause sp_response, s_responsePrefix dangling ReleaseResponse(); - + ur = tcore_pending_ref_user_request(p); if (ur) { struct tresp_sms_send_umts_msg respSendMsg; memset(&respSendMsg, 0, sizeof(struct tresp_sms_send_umts_msg)); respSendMsg.result = SMS_INVALID_MANDATORY_INFO; - + respSendMsg.result = util_sms_ipcError2SmsError(error); - + tcore_user_request_send_response(ur, TRESP_SMS_SEND_UMTS_MSG, sizeof(struct tresp_sms_send_umts_msg), &respSendMsg); } else { @@ -614,12 +610,12 @@ static void on_response_get_storedMsgCnt(TcorePending *p, int data_len, const vo } printResponse(); - + if(sp_response->success > 0) { //failure case - consider this later line = sp_response->p_intermediates->line; - + ret = at_tok_start(&line); if (ret < 0) AT_TOK_ERROR(line); @@ -629,7 +625,7 @@ static void on_response_get_storedMsgCnt(TcorePending *p, int data_len, const vo AT_TOK_ERROR(line); ret = at_tok_nextint(&line,&totalCount); if (ret < 0) - AT_TOK_ERROR(line) + AT_TOK_ERROR(line); respStoredMsgCnt.storedMsgCnt.totalCount = totalCount; respStoredMsgCnt.storedMsgCnt.usedCount = usedCount; @@ -642,7 +638,7 @@ static void on_response_get_storedMsgCnt(TcorePending *p, int data_len, const vo { //failure case - consider this later line = sp_response->finalResponse; - + ret = at_tok_start(&line); if (ret < 0) AT_TOK_ERROR(line); @@ -656,7 +652,7 @@ static void on_response_get_storedMsgCnt(TcorePending *p, int data_len, const vo ReleaseResponse(); - + tcore_user_request_send_response(ur, TRESP_SMS_GET_STORED_MSG_COUNT, sizeof(struct tresp_sms_get_storedMsgCnt), &respStoredMsgCnt); return; @@ -687,7 +683,7 @@ static void on_response_get_sca(TcorePending *p, int data_len, const void *data, if(sp_response->success > 0) { respGetSca.result = SMS_SUCCESS; - + line = sp_response->p_intermediates->line; ret = at_tok_start(&line); if (ret < 0) @@ -710,10 +706,10 @@ static void on_response_get_sca(TcorePending *p, int data_len, const void *data, respGetSca.scaAddress.dialNumLen = strlen(scaStr); if(scaType == 145) - respGetSca.scaAddress.typeOfNum = SIM_TON_INTERNATIONAL; + respGetSca.scaAddress.typeOfNum = SIM_TON_INTERNATIONAL; else respGetSca.scaAddress.typeOfNum = SIM_TON_NATIONAL; respGetSca.scaAddress.numPlanId = 0; - + memcpy(respGetSca.scaAddress.diallingNum, scaStr, strlen(scaStr)); } @@ -721,7 +717,7 @@ static void on_response_get_sca(TcorePending *p, int data_len, const void *data, { //failure case - consider this later line = sp_response->finalResponse; - + ret = at_tok_start(&line); if (ret < 0) AT_TOK_ERROR(line); @@ -731,9 +727,9 @@ static void on_response_get_sca(TcorePending *p, int data_len, const void *data, AT_TOK_ERROR(line); respGetSca.result = util_sms_ipcError2SmsError(error); - + } - + ReleaseResponse(); tcore_user_request_send_response(ur, TRESP_SMS_GET_SCA, sizeof(struct tresp_sms_get_sca), &respGetSca); @@ -755,9 +751,9 @@ static void on_response_set_sca(TcorePending *p, int data_len, const void *data, dbg("no user_request"); return; } - + printResponse(); - + if(sp_response->success > 0) { respSetSca.result = SMS_SUCCESS; @@ -766,7 +762,7 @@ static void on_response_set_sca(TcorePending *p, int data_len, const void *data, { //failure case - consider this later line = sp_response->finalResponse; - + ret = at_tok_start(&line); if (ret < 0) AT_TOK_ERROR(line); @@ -779,9 +775,9 @@ static void on_response_set_sca(TcorePending *p, int data_len, const void *data, } ReleaseResponse(); - + tcore_user_request_send_response(ur, TRESP_SMS_SET_SCA, sizeof(struct tresp_sms_get_sca), &respSetSca); - + return; } @@ -802,7 +798,7 @@ static void on_response_set_delivery_report(TcorePending *p, int data_len, const } printResponse(); - + if(sp_response->success > 0) { respSetDeliveryReport.result = SMS_SUCCESS; @@ -811,7 +807,7 @@ static void on_response_set_delivery_report(TcorePending *p, int data_len, const { //failure case - consider this later line = sp_response->finalResponse; - + ret = at_tok_start(&line); if (ret < 0) AT_TOK_ERROR(line); @@ -825,7 +821,7 @@ static void on_response_set_delivery_report(TcorePending *p, int data_len, const ReleaseResponse(); - + tcore_user_request_send_response(ur, TRESP_SMS_SET_DELIVERY_REPORT, sizeof(struct tresp_sms_set_delivery_report), &respSetDeliveryReport); return; @@ -836,7 +832,7 @@ static void on_response_get_sms_params(TcorePending *p, int data_len, const void UserRequest *ur; struct tresp_sms_get_params respGetSmsParams; struct property_sms_info *property = NULL; - + char *line = NULL; int error; int ret = 0; @@ -854,11 +850,11 @@ static void on_response_get_sms_params(TcorePending *p, int data_len, const void dbg("no user_request"); return; } - + if(sp_response->success > 0) - { + { line = sp_response->p_intermediates->line; - + ret = at_tok_start(&line); if (ret < 0) AT_TOK_ERROR(line); @@ -870,19 +866,19 @@ static void on_response_get_sms_params(TcorePending *p, int data_len, const void if (ret < 0) AT_TOK_ERROR(line); - if(sw1 != 144 || sw2 != 0) + if(sw1 != 144 || sw2 != 0) respGetSmsParams.result = SMS_UNKNOWN; else { char *hexData; - + ret = at_tok_nextstr(&line,&hexData); if (ret < 0) AT_TOK_ERROR(line); - + recordData = util_hexStringToBytes(hexData); util_hex_dump(" ", strlen(hexData)/2, recordData); - + // respGetSmsParams.paramsInfo.recordIndex = 0; respGetSmsParams.paramsInfo.recordLen = strlen(hexData)/2; @@ -907,7 +903,7 @@ static void on_response_get_sms_params(TcorePending *p, int data_len, const void respGetSmsParams.result = SMS_UNKNOWN; //failure case - consider this later line = sp_response->finalResponse; - + ret = at_tok_start(&line); if (ret < 0) AT_TOK_ERROR(line); @@ -916,11 +912,11 @@ static void on_response_get_sms_params(TcorePending *p, int data_len, const void if (ret < 0) AT_TOK_ERROR(line); - respGetSmsParams.result = util_sms_ipcError2SmsError(error); + respGetSmsParams.result = util_sms_ipcError2SmsError(error); } - ReleaseResponse(); - + ReleaseResponse(); + tcore_user_request_send_response(ur, TRESP_SMS_GET_PARAMS, sizeof(struct tresp_sms_get_params), &respGetSmsParams); return; @@ -968,15 +964,15 @@ static void on_response_get_paramcnt(TcorePending *p, int data_len, const void * unsigned char file_type_tag = 0x07; unsigned char *ptr_data; - char *hexData; + char *hexData; char *recordData; ret = at_tok_nextstr(&line,&hexData); if (ret < 0) AT_TOK_ERROR(line); - + recordData = util_hexStringToBytes(hexData); util_hex_dump(" ", strlen(hexData)/2, recordData); - + ptr_data = (unsigned char *)recordData; co_sim = tcore_plugin_ref_core_object(tcore_pending_ref_plugin(p), "sim"); @@ -1023,7 +1019,7 @@ static void on_response_get_paramcnt(TcorePending *p, int data_len, const void * dbg("Getting FileType: [Transparent file type]"); /* increment to next byte */ ptr_data++; - file_type = 0x01; //SIM_FTYPE_TRANSPARENT + file_type = 0x01; //SIM_FTYPE_TRANSPARENT /* data coding byte - value 21 */ ptr_data++; break; @@ -1081,7 +1077,7 @@ static void on_response_get_paramcnt(TcorePending *p, int data_len, const void * } else { dbg("INVALID FCP received - DEbug!"); free(recordData); - ReleaseResponse(); + ReleaseResponse(); return; } @@ -1158,7 +1154,7 @@ static void on_response_get_paramcnt(TcorePending *p, int data_len, const void * } else { dbg("INVALID FCP received[0x%x] - DEbug!", *ptr_data); free(recordData); - ReleaseResponse(); + ReleaseResponse(); return; } @@ -1210,7 +1206,7 @@ static void on_response_get_paramcnt(TcorePending *p, int data_len, const void * return; } } - else if (tcore_sim_get_type(co_sim) == SIM_TYPE_GSM) + else if (tcore_sim_get_type(co_sim) == SIM_TYPE_GSM) { unsigned char gsm_specific_file_data_len = 0; /* ignore RFU byte1 and byte2 */ @@ -1289,8 +1285,8 @@ static void on_response_get_paramcnt(TcorePending *p, int data_len, const void * dbg(" not handled file type"); break; } - } - else + } + else { dbg(" Card Type - UNKNOWN [%d]", tcore_sim_get_type(co_sim)); } @@ -1299,10 +1295,10 @@ static void on_response_get_paramcnt(TcorePending *p, int data_len, const void * respGetParamCnt.recordCount = num_of_records; respGetParamCnt.result = SMS_SUCCESS; - + free(recordData); } - else + else { /*2. SIM access fail case*/ dbg("SIM access fail"); @@ -1332,7 +1328,6 @@ static TReturn send_umts_msg(CoreObject *o, UserRequest *ur) TcoreHal *h = NULL; TcorePending *pending = NULL; const struct treq_sms_send_umts_msg *sendUmtsMsg = NULL; - GQueue *queue = NULL; char *cmd_str = NULL; struct ATReqMetaInfo metainfo; int info_len =0; @@ -1342,7 +1337,7 @@ static TReturn send_umts_msg(CoreObject *o, UserRequest *ur) sendUmtsMsg = tcore_user_request_ref_data(ur, NULL); p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); if (!sendUmtsMsg || !h) return TCORE_RETURN_ENOSYS; @@ -1351,17 +1346,13 @@ static TReturn send_umts_msg(CoreObject *o, UserRequest *ur) metainfo.type = NO_RESULT; metainfo.responsePrefix[0] ='\0'; info_len = sizeof(struct ATReqMetaInfo); - + tcore_user_request_set_metainfo(ur, info_len, &metainfo); // AT+CMMS= cmd_str = g_strdup_printf("AT+CMMS=%d%s", sendUmtsMsg->more, "\r"); dbg("[tcore_SMS] *************************MsgLen[%d]", sendUmtsMsg->msgDataPackage.msgLength); - queue = tcore_object_ref_user_data(o); - if (queue) - util_add_waiting_job(queue, ID_RESERVED_AT, ur); - pending = tcore_pending_new(o, ID_RESERVED_AT); tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str); tcore_pending_set_timeout(pending, 0); @@ -1371,8 +1362,8 @@ static TReturn send_umts_msg(CoreObject *o, UserRequest *ur) tcore_pending_set_send_callback(pending, on_confirmation_sms_message_send, NULL); free(cmd_str); - - return tcore_hal_send_request(h, pending); + + return tcore_hal_send_request(h, pending); } static TReturn Send_SmsSubmitTpdu(CoreObject *o, UserRequest *ur) @@ -1381,7 +1372,6 @@ static TReturn Send_SmsSubmitTpdu(CoreObject *o, UserRequest *ur) TcoreHal *h = NULL; TcorePending *pending = NULL; const struct treq_sms_send_umts_msg *sendUmtsMsg = NULL; - GQueue *queue = NULL; char *cmd_str = NULL; struct ATReqMetaInfo metainfo; int info_len =0; @@ -1398,7 +1388,7 @@ static TReturn Send_SmsSubmitTpdu(CoreObject *o, UserRequest *ur) sendUmtsMsg = tcore_user_request_ref_data(ur, NULL); p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); if (!sendUmtsMsg || !h) return TCORE_RETURN_ENOSYS; @@ -1413,12 +1403,12 @@ static TReturn Send_SmsSubmitTpdu(CoreObject *o, UserRequest *ur) if (sendUmtsMsg->msgDataPackage.msgLength < SMS_SMDATA_SIZE_MAX) { memset(tpdu, 0, sizeof(MAX_GSM_SMS_TPDU_SIZE)); - + memset(&metainfo, 0, sizeof(struct ATReqMetaInfo)); metainfo.type = SINGLELINE; memcpy(metainfo.responsePrefix,"+CMGS:",strlen("+CMGS:")); info_len = sizeof(struct ATReqMetaInfo); - + tcore_user_request_set_metainfo(ur, info_len, &metainfo); ScLength = sendUmtsMsg->msgDataPackage.sca[0]; @@ -1453,7 +1443,7 @@ static TReturn Send_SmsSubmitTpdu(CoreObject *o, UserRequest *ur) tpduDataLen = sendUmtsMsg->msgDataPackage.msgLength + (ScLength + 2); hexString = calloc(tpduDataLen*2, 1);; - for( i=0; ipdu_is_given cmd_str = g_strdup_printf("AT+CMGS=%d%s%s%x%s", sendUmtsMsg->msgDataPackage.msgLength, "\r", hexString, 0x1A,"\r"); dbg("cmd_str is %s", cmd_str); - queue = tcore_object_ref_user_data(o); - if (queue) - util_add_waiting_job(queue, ID_RESERVED_AT, ur); - pending = tcore_pending_new(o, ID_RESERVED_AT); tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str); tcore_pending_set_timeout(pending, 0); @@ -1484,8 +1470,8 @@ static TReturn Send_SmsSubmitTpdu(CoreObject *o, UserRequest *ur) tcore_pending_link_user_request(pending, ur); tcore_pending_set_send_callback(pending, on_confirmation_sms_message_send, NULL); - - api_err = tcore_hal_send_request(h, pending); + + api_err = tcore_hal_send_request(h, pending); free(cmd_str); free(hexString); @@ -1502,7 +1488,7 @@ static TReturn Send_SmsSubmitTpdu(CoreObject *o, UserRequest *ur) dbg("[tcore_SMS] Invalid Data Length"); api_err = TCORE_RETURN_SMS_INVALID_DATA_LEN; } - + return api_err; } @@ -1537,20 +1523,20 @@ static TReturn get_storedMsgCnt(CoreObject *o, UserRequest *ur) TcorePending *pending = NULL; const struct treq_sms_get_msg_count *getStoredMsgCnt = NULL; - char *cmd_str = NULL; + char *cmd_str = NULL; struct ATReqMetaInfo metainfo; - int info_len =0; + int info_len =0; dbg("new pending(IPC_SMS_GET_STORED_MSG_COUNT)"); getStoredMsgCnt = tcore_user_request_ref_data(ur, NULL); p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); if (!h) { - dbg("[ERR] tcore_plugin_ref_hal() pointer is NULL"); + dbg("[ERR] tcore_object_get_hal() pointer is NULL"); return TCORE_RETURN_ENOSYS; } @@ -1558,11 +1544,11 @@ static TReturn get_storedMsgCnt(CoreObject *o, UserRequest *ur) metainfo.type = SINGLELINE; memcpy(metainfo.responsePrefix,"+CPMS:",strlen("+CPMS:")); info_len = sizeof(struct ATReqMetaInfo); - + tcore_user_request_set_metainfo(ur, info_len, &metainfo); - + // AT+CPMS=[,[,]] - // Possible response(s) : +CPMS: ,,,,, + // Possible response(s) : +CPMS: ,,,,, cmd_str = g_strdup_printf("AT+CPMS=\"SM\"%s", "\r"); pending = tcore_pending_new(o, ID_RESERVED_AT); @@ -1585,7 +1571,7 @@ static TReturn get_sca(CoreObject *o, UserRequest *ur) TcoreHal *h = NULL; TcorePending *pending = NULL; const struct treq_sms_get_sca *getSca = NULL; - char *cmd_str = NULL; + char *cmd_str = NULL; struct ATReqMetaInfo metainfo; int info_len =0; @@ -1594,7 +1580,7 @@ static TReturn get_sca(CoreObject *o, UserRequest *ur) getSca = tcore_user_request_ref_data(ur, NULL); p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); if (!getSca || !h) return TCORE_RETURN_ENOSYS; @@ -1603,13 +1589,13 @@ static TReturn get_sca(CoreObject *o, UserRequest *ur) metainfo.type = SINGLELINE; memcpy(metainfo.responsePrefix,"+CSCA:",strlen("+CSCA:")); info_len = sizeof(struct ATReqMetaInfo); - + tcore_user_request_set_metainfo(ur, info_len, &metainfo); - + // AT +CSCA? - // Possible response(s) : +CSCA: , + // Possible response(s) : +CSCA: , cmd_str = g_strdup_printf("AT +CSCA?%s", "\r"); - + pending = tcore_pending_new(o, ID_RESERVED_AT); tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str); tcore_pending_set_timeout(pending, 0); @@ -1617,7 +1603,7 @@ static TReturn get_sca(CoreObject *o, UserRequest *ur) tcore_pending_link_user_request(pending, ur); tcore_pending_set_send_callback(pending, on_confirmation_sms_message_send, NULL); - + free(cmd_str); return tcore_hal_send_request(h, pending); @@ -1645,7 +1631,7 @@ static TReturn set_sca(CoreObject *o, UserRequest *ur) } p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); if (!setSca || !h) return TCORE_RETURN_ENOSYS; @@ -1658,11 +1644,11 @@ static TReturn set_sca(CoreObject *o, UserRequest *ur) metainfo.type = NO_RESULT; metainfo.responsePrefix[0] ='\0'; info_len = sizeof(struct ATReqMetaInfo); - + tcore_user_request_set_metainfo(ur, info_len, &metainfo); - - // AT +CSCA=[,] - // 129:Unknown numbering plan, national/international number unknown, 145:international number + + // AT +CSCA=[,] + // 129:Unknown numbering plan, national/international number unknown, 145:international number cmd_str = g_strdup_printf("AT+CSCA=\"%s\", %d%s", setSca->scaInfo.diallingNum, scaType, "\r"); pending = tcore_pending_new(o, ID_RESERVED_AT); @@ -1672,7 +1658,7 @@ static TReturn set_sca(CoreObject *o, UserRequest *ur) tcore_pending_link_user_request(pending, ur); tcore_pending_set_send_callback(pending, on_confirmation_sms_message_send, NULL); - + free(cmd_str); return tcore_hal_send_request(h, pending); @@ -1724,7 +1710,7 @@ static TReturn set_delivery_report(CoreObject *o, UserRequest *ur) deliveryReport = tcore_user_request_ref_data(ur, NULL); p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); if (!deliveryReport || !h) return TCORE_RETURN_ENOSYS; @@ -1733,9 +1719,9 @@ static TReturn set_delivery_report(CoreObject *o, UserRequest *ur) metainfo.type = NO_RESULT; metainfo.responsePrefix[0] ='\0'; info_len = sizeof(struct ATReqMetaInfo); - + tcore_user_request_set_metainfo(ur, info_len, &metainfo); - + // AT+CNMA if(deliveryReport->rspType == SMS_SENDSMS_SUCCESS) cmd_str = g_strdup_printf("AT+CNMA=0%s", "\r"); @@ -1749,7 +1735,7 @@ static TReturn set_delivery_report(CoreObject *o, UserRequest *ur) tcore_pending_link_user_request(pending, ur); tcore_pending_set_send_callback(pending, on_confirmation_sms_message_send, NULL); - + free(cmd_str); return tcore_hal_send_request(h, pending); @@ -1778,7 +1764,7 @@ static TReturn get_sms_params(CoreObject *o, UserRequest *ur) getSmsParams = tcore_user_request_ref_data(ur, NULL); p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); if (!getSmsParams || !h) { @@ -1790,10 +1776,10 @@ static TReturn get_sms_params(CoreObject *o, UserRequest *ur) metainfo.type = SINGLELINE; memcpy(metainfo.responsePrefix,"+CRSM:",strlen("+CRSM:")); info_len = sizeof(struct ATReqMetaInfo); - + tcore_user_request_set_metainfo(ur, info_len, &metainfo); - // AT+CRSM=,,, + // AT+CRSM=,,, cmd_str = g_strdup_printf("AT+CRSM=%d, %d, %d, 4, 40%s", 178, 0x6F42, getSmsParams->index + 1, "\r"); pending = tcore_pending_new(o, ID_RESERVED_AT); @@ -1803,9 +1789,9 @@ static TReturn get_sms_params(CoreObject *o, UserRequest *ur) tcore_pending_link_user_request(pending, ur); tcore_pending_set_send_callback(pending, on_confirmation_sms_message_send, NULL); - + free(cmd_str); - + return tcore_hal_send_request(h, pending); } @@ -1830,7 +1816,7 @@ static TReturn get_paramcnt(CoreObject *o, UserRequest *ur) getParamCnt = tcore_user_request_ref_data(ur, NULL); p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); if (!h) // request data is NULL, so do not NULL check for getParamCnt { @@ -1842,12 +1828,12 @@ static TReturn get_paramcnt(CoreObject *o, UserRequest *ur) metainfo.type = SINGLELINE; memcpy(metainfo.responsePrefix,"+CRSM:",strlen("+CRSM:")); info_len = sizeof(struct ATReqMetaInfo); - + tcore_user_request_set_metainfo(ur, info_len, &metainfo); - - // AT+CRSM=,,,, EFsmsp: 0x6F42 + + // AT+CRSM=,,,, EFsmsp: 0x6F42 cmd_str = g_strdup_printf("AT+CRSM=192, %d%s", 0x6F42, "\r"); - + pending = tcore_pending_new(o, ID_RESERVED_AT); tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str); tcore_pending_set_timeout(pending, 0); @@ -1855,9 +1841,9 @@ static TReturn get_paramcnt(CoreObject *o, UserRequest *ur) tcore_pending_link_user_request(pending, ur); tcore_pending_set_send_callback(pending, on_confirmation_sms_message_send, NULL); - + free(cmd_str); - + return tcore_hal_send_request(h, pending); } @@ -1883,13 +1869,13 @@ static struct tcore_sms_operations sms_ops = .send_cdma_msg = send_cdma_msg, }; -gboolean s_sms_init(TcorePlugin *p) +gboolean s_sms_init(TcorePlugin *p, TcoreHal *h) { CoreObject *o; struct property_sms_info *data; GQueue *work_queue; - o = tcore_sms_new(p, "umts_sms", &sms_ops); + o = tcore_sms_new(p, "umts_sms", &sms_ops, h); if (!o) return FALSE; diff --git a/src/s_ss.c b/src/s_ss.c index 05b056c..d9be92c 100644 --- a/src/s_ss.c +++ b/src/s_ss.c @@ -65,35 +65,35 @@ struct ss_confirm_info { int data_len; }; - #define TIZEN_NUM_TYPE_INTERNATIONAL 0x01 - #define TIZEN_NUM_PLAN_ISDN 0x01 +#define TIZEN_NUM_TYPE_INTERNATIONAL 0x01 +#define TIZEN_NUM_PLAN_ISDN 0x01 -static gboolean _ss_request_message( CoreObject *o, +static gboolean _ss_request_message( CoreObject *o, UserRequest *ur, - char *cmd, - unsigned int cmd_len, - void* on_resp, + char *cmd, + unsigned int cmd_len, + void* on_resp, void* user_data ); #if 0 static TReturn _ss_general_response_result(const int result); #endif -static TReturn _ss_barring_get( CoreObject *o, - UserRequest *ur, - enum telephony_ss_class class, - enum telephony_ss_barring_mode type, +static TReturn _ss_barring_get( CoreObject *o, + UserRequest *ur, + enum telephony_ss_class class, + enum telephony_ss_barring_mode type, enum tcore_response_command resp ); -static TReturn _ss_forwarding_get( CoreObject *o, - UserRequest *ur, - enum telephony_ss_class class, - enum telephony_ss_forwarding_mode type, +static TReturn _ss_forwarding_get( CoreObject *o, + UserRequest *ur, + enum telephony_ss_class class, + enum telephony_ss_forwarding_mode type, enum tcore_response_command resp ); -static TReturn _ss_waiting_get( CoreObject *o, - UserRequest *ur, - enum telephony_ss_class class, +static TReturn _ss_waiting_get( CoreObject *o, + UserRequest *ur, + enum telephony_ss_class class, enum tcore_response_command resp ); @@ -139,18 +139,18 @@ static void on_confirmation_call_control_ss_message_send( TcorePending *p, gbool static void on_confirmation_ss_message_send( TcorePending *p, gboolean result, void *user_data ); -static void on_notification_ss_info( CoreObject *o, const void *data, void *user_data ); +static gboolean on_notification_ss_info( CoreObject *o, const void *data, void *user_data ); static void _ss_ussd_response( UserRequest *ur, const char* ussd_str, enum telephony_ss_ussd_type type, enum telephony_ss_ussd_status status ); static void _ss_ussd_notification( TcorePlugin *p, const char* ussd_str, enum telephony_ss_ussd_status status ); -static void on_notification_ss_ussd( CoreObject *o, const void *data, void *user_data ); +static gboolean on_notification_ss_ussd( CoreObject *o, const void *data, void *user_data ); -static gboolean _ss_request_message( CoreObject *o, +static gboolean _ss_request_message( CoreObject *o, UserRequest *ur, - char *cmd, - unsigned int cmd_len, - void* on_resp, + char *cmd, + unsigned int cmd_len, + void* on_resp, void* user_data ) { TcorePending *pending = 0; @@ -158,7 +158,7 @@ static gboolean _ss_request_message( CoreObject *o, TcoreHal *h = 0; UserRequest *ur2 = 0; - ur2 = tcore_user_request_dup( ur ); + ur2 = tcore_user_request_ref( ur ); pending = tcore_pending_new(o, ID_RESERVED_AT); tcore_pending_set_request_data(pending, cmd_len, cmd); @@ -176,7 +176,7 @@ static gboolean _ss_request_message( CoreObject *o, } p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); tcore_hal_send_request(h, pending); return TRUE; @@ -193,7 +193,7 @@ static TReturn _ss_general_response_result(const int ret) } #endif -static void _ss_ussd_response( UserRequest *ur, const char* ussd_str, enum telephony_ss_ussd_type type, enum telephony_ss_ussd_status status ) +static void _ss_ussd_response( UserRequest *ur, const char* ussd_str, enum telephony_ss_ussd_type type, enum telephony_ss_ussd_status status ) { struct tresp_ss_ussd resp; @@ -207,7 +207,7 @@ static void _ss_ussd_response( UserRequest *ur, const char* ussd_str, enum telep resp.err = FALSE; if ( ussd_str ) { - + int len = strlen( ussd_str ); if ( len < MAX_SS_USSD_LEN ) { @@ -269,7 +269,7 @@ static void _ss_ussd_notification( TcorePlugin *p, const char* ussd_str, enum te } -static void on_notification_ss_ussd( CoreObject *o, const void *data, void *user_data ) +static gboolean on_notification_ss_ussd( CoreObject *o, const void *data, void *user_data ) { enum telephony_ss_ussd_status status; UssdSession *ussd_session = 0; @@ -291,47 +291,46 @@ static void on_notification_ss_ussd( CoreObject *o, const void *data, void *user switch(m){ case 0: status = SS_USSD_NO_ACTION_REQUIRE; - break; + break; case 1: status = SS_USSD_ACTION_REQUIRE; - break; + break; case 2: status = SS_USSD_TERMINATED_BY_NET; - break; + break; case 3: status = SS_USSD_OTHER_CLIENT; - break; + break; case 4: status = SS_USSD_NOT_SUPPORT; - break; + break; case 5: status = SS_USSD_TIME_OUT; - break; + break; default: dbg("unsupported m : %d", m); status = SS_USSD_MAX; - break; + break; } if(at_tok_hasmore(&cmd)) { - err = at_tok_nextstr(&cmd, &tmp_str); + err = at_tok_nextstr(&cmd, &tmp_str); err = at_tok_nextint(&cmd, &dcs); dbg("ussdstr: %s, dcs :%d", tmp_str, dcs); - } switch ( tcore_util_get_cbs_coding_scheme(dcs) ) { case TCORE_DCS_TYPE_7_BIT: case TCORE_DCS_TYPE_UNSPECIFIED: { - ussd_str = tcore_util_unpack_gsm7bit(tmp_str, strlen(tmp_str)); + ussd_str = (char *)tcore_util_unpack_gsm7bit((const unsigned char *)tmp_str, strlen(tmp_str)); } break; case TCORE_DCS_TYPE_UCS2: @@ -341,7 +340,7 @@ static void on_notification_ss_ussd( CoreObject *o, const void *data, void *user memcpy( ussd_str,tmp_str, strlen(tmp_str) ); ussd_str[ strlen(tmp_str) ] = '\0'; } - } break; + } break; default: { dbg("[ error ] unknown dcs type. ussd_session : %x", ussd_session); if ( ussd_session ) { @@ -352,19 +351,19 @@ static void on_notification_ss_ussd( CoreObject *o, const void *data, void *user tcore_ss_ussd_get_session_data( ussd_session, (void**)&ur ); if ( !ur ) { dbg("[ error ] ur : (0)"); - return; + return TRUE; } type = (enum telephony_ss_ussd_type)tcore_ss_ussd_get_session_type( ussd_session ); _ss_ussd_response( ur, ussd_str, type, status ); - } - return; + } + return TRUE; } } switch ( status ) { - case SS_USSD_NO_ACTION_REQUIRE: + case SS_USSD_NO_ACTION_REQUIRE: case SS_USSD_ACTION_REQUIRE: case SS_USSD_OTHER_CLIENT: case SS_USSD_NOT_SUPPORT: @@ -380,7 +379,7 @@ static void on_notification_ss_ussd( CoreObject *o, const void *data, void *user tcore_ss_ussd_get_session_data( ussd_session, (void**)&ur ); if ( !ur ) { dbg("[ error ] ur : (0)"); - return; + return TRUE; } type = (enum telephony_ss_ussd_type)tcore_ss_ussd_get_session_type( ussd_session ); @@ -398,7 +397,7 @@ static void on_notification_ss_ussd( CoreObject *o, const void *data, void *user g_free( ussd_str ); } - } break; + } break; case SS_USSD_TERMINATED_BY_NET: { if ( ussd_session ) { @@ -407,19 +406,20 @@ static void on_notification_ss_ussd( CoreObject *o, const void *data, void *user tcore_ss_ussd_get_session_data( ussd_session, (void**)&ur ); if ( ur ) - tcore_user_request_free( ur ); + tcore_user_request_unref( ur ); tcore_ss_ussd_destroy_session( ussd_session ); } - } break; + } break; default: break; } + return TRUE; } -static void on_notification_ss_info( CoreObject *o, const void *data, void *user_data ) +static gboolean on_notification_ss_info( CoreObject *o, const void *data, void *user_data ) { TcorePlugin *p = 0; CoreObject *co = 0; @@ -431,7 +431,7 @@ static void on_notification_ss_info( CoreObject *o, const void *data, void *user co = tcore_plugin_ref_core_object( p, "call" ); if (!co) { dbg("[ error ] plugin_ref_core_object : call"); - return ; + return TRUE; } cmd = (char*)data; @@ -444,51 +444,53 @@ static void on_notification_ss_info( CoreObject *o, const void *data, void *user err = at_tok_nextint(&cmd, &index); //cug index - skip if(at_tok_hasmore(&cmd)){ err = at_tok_nextstr(&cmd, &number); - dbg("number : %s",number); + dbg("number : %s",number); err = at_tok_nextint(&cmd, &ton); } switch(code2){ case 0: //this is a forwarded call (MT call setup) tcore_call_information_mt_forwarded_call( co, number ); - break; + break; case 2: //call has been put on hold (during a voice call) tcore_call_information_held( co, number ); - break; + break; case 3: //call has been retrieved (during a voice call) tcore_call_information_active( co, number ); - break; + break; case 4: //multiparty call entered (during a voice call) tcore_call_information_joined( co, number ); - break; + break; case 5: //call on hold has been released tcore_call_information_released_on_hold( co, number ); - break; + break; case 6: //forward check SS message received (can be received whenever) tcore_call_information_cf_check_ss_message( co, number ); - break; + break; - case 7: //call is being connected (alerting) with the remote party in alerting state in explicit call transfer operation (during a voice call) + case 7: //call is being connected (alerting) with the remote party in alerting state in explicit call transfer operation (during a voice call) tcore_call_information_transfer_alert( co, number ); - break; + break; case 8: //call has been connected with the other remote party in explicit call transfer operation (also number and subaddress parameters may be present) (during a voice call or MT call setup) tcore_call_information_transfered( co, number ); - break; + break; case 9: //this is a deflected call (MT call setup): tcore_call_information_mt_deflected_call( co, number ); - break; + break; default: - dbg("unsupported cmd2 : %d",code2); - break; + dbg("unsupported cmd2 : %d",code2); + break; } + + return TRUE; } static void on_confirmation_ss_message_send( TcorePending *p, gboolean result, void *user_data ) @@ -509,9 +511,9 @@ static void on_confirmation_ss_message_send( TcorePending *p, gboolean result, v if((metainfo->type == SINGLELINE)|| (metainfo->type == MULTILINE)) { - //cp rsp prefix + //cp rsp prefix s_responsePrefix = strdup(metainfo->responsePrefix); - dbg("duplicating responsePrefix : %s\n", s_responsePrefix); + dbg("duplicating responsePrefix : %s\n", s_responsePrefix); } else { @@ -521,7 +523,7 @@ static void on_confirmation_ss_message_send( TcorePending *p, gboolean result, v //set atcmd type into s_type s_type = metainfo->type; } - + static void on_confirmation_call_control_ss_message_send( TcorePending *p, gboolean result, void *user_data ) { UserRequest* ur = NULL; @@ -538,35 +540,35 @@ static void on_confirmation_call_control_ss_message_send( TcorePending *p, gbool metainfo = (struct ATReqMetaInfo*)tcore_user_request_ref_metainfo(ur,&info_len); if((metainfo->type == SINGLELINE)|| - (metainfo->type == MULTILINE)) + (metainfo->type == MULTILINE)) { - //cp rsp prefix + //cp rsp prefix s_responsePrefix = strdup(metainfo->responsePrefix); - dbg("duplicating responsePrefix : %s\n", s_responsePrefix); + dbg("duplicating responsePrefix : %s\n", s_responsePrefix); } else { s_responsePrefix = NULL; } -//set atcmd type into s_type + //set atcmd type into s_type s_type = metainfo->type; } -static void on_response_ss_barring_set( TcorePending *p, int data_len, const void *data, void *user_data ) +static void on_response_ss_barring_set( TcorePending *p, int data_len, const void *data, void *user_data ) { struct ss_confirm_info *info = 0; enum telephony_ss_class class; - + CoreObject* o = 0; UserRequest *ur; struct tresp_ss_general resp; UserRequest *ur_dup=0; - + o = tcore_pending_ref_core_object(p); ur = tcore_pending_ref_user_request(p); - printResponse(); + printResponse(); info = (struct ss_confirm_info*)user_data; class = info->class; @@ -586,12 +588,12 @@ static void on_response_ss_barring_set( TcorePending *p, int data_len, const voi { ReleaseResponse(); - if ( info->class == SS_CLASS_VOICE ) + if ( info->class == SS_CLASS_VOICE ) class = SS_CLASS_ALL_TELE_BEARER; - ur_dup = tcore_user_request_dup(ur); + ur_dup = tcore_user_request_ref(ur); - if ( info->flavor_type == SS_BARR_MODE_AB || + if ( info->flavor_type == SS_BARR_MODE_AB || info->flavor_type == SS_BARR_MODE_AOB ) _ss_barring_get( o, ur_dup, class, SS_BARR_MODE_BAOC, info->resp ); else if ( info->flavor_type == SS_BARR_MODE_AIB ) @@ -606,7 +608,7 @@ static void on_response_ss_barring_set( TcorePending *p, int data_len, const voi if ( ur ) tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_general), &resp); - else + else dbg("[ error ] ur is 0"); } @@ -615,14 +617,15 @@ static void on_response_ss_barring_set( TcorePending *p, int data_len, const voi } -static void on_response_ss_barring_change_pwd( TcorePending *p, int data_len, const void *data, void *user_data ) + +static void on_response_ss_barring_change_pwd( TcorePending *p, int data_len, const void *data, void *user_data ) { struct ss_confirm_info *info = 0; UserRequest *ur; struct tresp_ss_general resp; ur = tcore_pending_ref_user_request(p); - + info = (struct ss_confirm_info*)user_data; printResponse(); @@ -640,21 +643,20 @@ static void on_response_ss_barring_change_pwd( TcorePending *p, int data_len, co if ( ur ) tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_general), &resp); - else + else dbg("[ error ] ur is 0"); g_free(user_data); - } -static void on_response_ss_barring_get( TcorePending *p, int data_len, const void *data, void *user_data ) +static void on_response_ss_barring_get( TcorePending *p, int data_len, const void *data, void *user_data ) { CoreObject* o = 0; UserRequest* ur = 0; - struct ATLine *p_cur; + struct ATLine *p_cur; int status=0, classx =0, err=0; - + struct ss_confirm_info* info = 0; struct tresp_ss_barring resp; int countRecords=0, countValidRecords =0; @@ -662,18 +664,18 @@ static void on_response_ss_barring_get( TcorePending *p, int data_len, const voi o = tcore_pending_ref_core_object(p); ur = tcore_pending_ref_user_request(p); - printResponse(); + printResponse(); info = (struct ss_confirm_info*)user_data; /* count the calls */ for (countRecords = 0, p_cur = sp_response->p_intermediates - ; p_cur != NULL - ; p_cur = p_cur->p_next - ) { - countRecords++; + ; p_cur != NULL + ; p_cur = p_cur->p_next + ) { + countRecords++; } - dbg("total records : %d",countRecords); + dbg("total records : %d",countRecords); resp.record_num = countRecords; @@ -684,20 +686,20 @@ static void on_response_ss_barring_get( TcorePending *p, int data_len, const voi resp.record = g_new0( struct barring_info, resp.record_num ); for (countValidRecords = 0, p_cur = sp_response->p_intermediates - ; p_cur != NULL - ; p_cur = p_cur->p_next) + ; p_cur != NULL + ; p_cur = p_cur->p_next) { err = at_tok_start(&(p_cur->line)); if (err < 0){ - dbg("start line error. skip this line"); - goto error; + dbg("start line error. skip this line"); + goto error; } err = at_tok_nextint(&(p_cur->line), &status);// status if (err < 0) { - dbg("status error. skip this line"); - goto error; - } - + dbg("status error. skip this line"); + goto error; + } + if(status == 1){ resp.record[countValidRecords].status = SS_STATUS_ACTIVATE; } @@ -709,58 +711,58 @@ static void on_response_ss_barring_get( TcorePending *p, int data_len, const voi if (err < 0) { dbg("class error. classx not exist - set to requested one : %d", info->class); switch(info->class){ - case SS_CLASS_ALL_TELE: - classx =7; - break; - case SS_CLASS_VOICE: - classx =1; - break; - case SS_CLASS_ALL_DATA_TELE: - classx =2; - break; - case SS_CLASS_FAX: - classx =4; - break; - case SS_CLASS_SMS: - classx = 8; - break; - case SS_CLASS_ALL_CS_SYNC: - classx = 16; - break; - - default: - classx =7; - dbg("unsupported class %d. set to default : 7", info->class); - break; + case SS_CLASS_ALL_TELE: + classx =7; + break; + case SS_CLASS_VOICE: + classx =1; + break; + case SS_CLASS_ALL_DATA_TELE: + classx =2; + break; + case SS_CLASS_FAX: + classx =4; + break; + case SS_CLASS_SMS: + classx = 8; + break; + case SS_CLASS_ALL_CS_SYNC: + classx = 16; + break; + + default: + classx =7; + dbg("unsupported class %d. set to default : 7", info->class); + break; } - } + } switch(classx){ case 1: resp.record[countValidRecords].class = SS_CLASS_VOICE; - break; + break; case 2: resp.record[countValidRecords].class = SS_CLASS_ALL_DATA_TELE; - break; + break; case 4: resp.record[countValidRecords].class = SS_CLASS_FAX; - break; + break; case 7: resp.record[countValidRecords].class = SS_CLASS_ALL_TELE; - break; + break; case 8: resp.record[countValidRecords].class = SS_CLASS_SMS; - break; + break; case 16: resp.record[countValidRecords].class = SS_CLASS_ALL_CS_SYNC; - break; + break; case 32: resp.record[countValidRecords].class = SS_CLASS_ALL_CS_ASYNC; - break; + break; default: - dbg("unspoorted class : [%d]\n", classx ); + dbg("unspoorted class : [%d]\n", classx ); goto error; - break; + break; } resp.record[countValidRecords].mode = (enum telephony_ss_barring_mode)(info->flavor_type); @@ -775,27 +777,34 @@ error: dbg("valid count :%d",countValidRecords); resp.record_num = countValidRecords; resp.err = TCORE_RETURN_SUCCESS; - + } else { dbg("no active status - return to user") + } + + if(sp_response->success > 0){ + resp.err = TCORE_RETURN_SUCCESS; + } + else{ resp.err = TCORE_RETURN_FAILURE; } + dbg("on_response_ss_barring_get- rsp.err : %d, ur : %x", resp.err, ur); ReleaseResponse(); if ( ur ) tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_barring), &resp); - else + else dbg("[ error ] ur is 0"); g_free( user_data ); - + } -static void on_response_ss_forwarding_set( TcorePending *p, int data_len, const void *data, void *user_data ) +static void on_response_ss_forwarding_set( TcorePending *p, int data_len, const void *data, void *user_data ) { CoreObject* o = 0; UserRequest* ur = 0, *dup_ur=0; @@ -803,7 +812,7 @@ static void on_response_ss_forwarding_set( TcorePending *p, int data_len, const struct tresp_ss_general resp; o = tcore_pending_ref_core_object(p); - ur = tcore_pending_ref_user_request(p); + ur = tcore_pending_ref_user_request(p); info = (struct ss_confirm_info*)user_data; @@ -824,16 +833,16 @@ static void on_response_ss_forwarding_set( TcorePending *p, int data_len, const ReleaseResponse(); - if ( info->flavor_type == SS_CF_MODE_CF_ALL || + if ( info->flavor_type == SS_CF_MODE_CF_ALL || info->flavor_type == SS_CF_MODE_CFC ) { if ( ur ) tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_general), &resp); - else + else dbg("[ error ] ur is 0"); } else { - dup_ur = tcore_user_request_dup(ur); + dup_ur = tcore_user_request_ref(ur); _ss_forwarding_get( o, dup_ur, info->class, info->flavor_type, info->resp ); } @@ -842,21 +851,21 @@ static void on_response_ss_forwarding_set( TcorePending *p, int data_len, const if ( ur ) tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_general), &resp); - else + else dbg("[ error ] ur is 0"); } g_free(user_data); } -static void on_response_ss_forwarding_get( TcorePending *p, int data_len, const void *data, void *user_data ) +static void on_response_ss_forwarding_get( TcorePending *p, int data_len, const void *data, void *user_data ) { CoreObject* o = 0; UserRequest* ur = 0; - struct ATLine *p_cur; + struct ATLine *p_cur; int status=0, classx =0, err=0, ton =0, time=0; char* num, *subaddr; - + struct ss_confirm_info* info = 0; struct tresp_ss_forwarding resp; int countRecords=0, countValidRecords =0; @@ -864,42 +873,42 @@ static void on_response_ss_forwarding_get( TcorePending *p, int data_len, const o = tcore_pending_ref_core_object(p); ur = tcore_pending_ref_user_request(p); - printResponse(); + printResponse(); info = (struct ss_confirm_info*)user_data; /* count the calls */ for (countRecords = 0, p_cur = sp_response->p_intermediates - ; p_cur != NULL - ; p_cur = p_cur->p_next - ) { - countRecords++; + ; p_cur != NULL + ; p_cur = p_cur->p_next + ) { + countRecords++; } - dbg("total records : %d",countRecords); + dbg("total records : %d",countRecords); resp.record_num = countRecords; if ( resp.record_num > 0 ) { -// int i = 0; + // int i = 0; resp.record = g_new0( struct forwarding_info, resp.record_num ); for (countValidRecords = 0, p_cur = sp_response->p_intermediates - ; p_cur != NULL - ; p_cur = p_cur->p_next) + ; p_cur != NULL + ; p_cur = p_cur->p_next) { err = at_tok_start(&(p_cur->line)); if (err < 0){ - dbg("start line error. skip this line"); - goto error; + dbg("start line error. skip this line"); + goto error; } err = at_tok_nextint(&(p_cur->line), &status);// status if (err < 0) { - dbg("status error. skip this line"); - goto error; - } - + dbg("status error. skip this line"); + goto error; + } + if(status == 1){ resp.record[countValidRecords].status = SS_STATUS_ACTIVATE; } @@ -909,43 +918,43 @@ static void on_response_ss_forwarding_get( TcorePending *p, int data_len, const err = at_tok_nextint(&(p_cur->line), &classx); //class if (err < 0) { - dbg("class error. skip this line"); - goto error; - } + dbg("class error. skip this line"); + goto error; + } switch(classx){ case 1: resp.record[countValidRecords].class = SS_CLASS_VOICE; - break; + break; case 2: resp.record[countValidRecords].class = SS_CLASS_ALL_DATA_TELE; - break; + break; case 4: resp.record[countValidRecords].class = SS_CLASS_FAX; - break; + break; case 7: resp.record[countValidRecords].class = SS_CLASS_ALL_TELE; - break; + break; case 8: resp.record[countValidRecords].class = SS_CLASS_SMS; - break; + break; case 16: resp.record[countValidRecords].class = SS_CLASS_ALL_CS_SYNC; - break; + break; case 32: resp.record[countValidRecords].class = SS_CLASS_ALL_CS_ASYNC; - break; + break; default: - dbg("unspoorted class : [%d]\n", classx ); + dbg("unspoorted class : [%d]\n", classx ); goto error; - break; + break; } - if(at_tok_hasmore(&(p_cur->line)) ==1){ //more data present + if(at_tok_hasmore(&(p_cur->line)) ==1){ //more data present err = at_tok_nextstr(&(p_cur->line), &num); //number memcpy((resp.record[countValidRecords].number), num, strlen(num)); resp.record[countValidRecords].number_present = TRUE; - + err = at_tok_nextint(&(p_cur->line), &ton); // type of number - skip resp.record[countValidRecords].number_type = ton; @@ -959,7 +968,7 @@ static void on_response_ss_forwarding_get( TcorePending *p, int data_len, const } } - + } resp.record[countValidRecords].mode = (enum telephony_ss_barring_mode)(info->flavor_type); @@ -979,6 +988,12 @@ error: else { dbg("no active status - return to user") + } + + if(sp_response->success > 0){ + resp.err = TCORE_RETURN_SUCCESS; + } + else{ resp.err = TCORE_RETURN_FAILURE; } @@ -987,14 +1002,14 @@ error: if ( ur ) tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_forwarding), &resp); - else + else dbg("[ error ] ur is 0"); g_free( user_data ); - + } -static void on_response_ss_waiting_set( TcorePending *p, int data_len, const void *data, void *user_data ) +static void on_response_ss_waiting_set( TcorePending *p, int data_len, const void *data, void *user_data ) { CoreObject* o = 0; UserRequest* ur = 0; @@ -1024,20 +1039,20 @@ static void on_response_ss_waiting_set( TcorePending *p, int data_len, const voi if ( ur ) tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_general), &resp); - else + else dbg("[ error ] ur is 0"); } g_free( user_data ); } -static void on_response_ss_waiting_get( TcorePending *p, int data_len, const void *data, void *user_data ) +static void on_response_ss_waiting_get( TcorePending *p, int data_len, const void *data, void *user_data ) { CoreObject* o = 0; UserRequest* ur = 0; - struct ATLine *p_cur; + struct ATLine *p_cur; int status=0, classx =0, err=0; - + struct ss_confirm_info* info = 0; struct tresp_ss_waiting resp; int countRecords=0, countValidRecords =0; @@ -1045,43 +1060,43 @@ static void on_response_ss_waiting_get( TcorePending *p, int data_len, const voi o = tcore_pending_ref_core_object(p); ur = tcore_pending_ref_user_request(p); - printResponse(); + printResponse(); info = (struct ss_confirm_info*)user_data; /* count the calls */ for (countRecords = 0, p_cur = sp_response->p_intermediates - ; p_cur != NULL - ; p_cur = p_cur->p_next - ) { - countRecords++; + ; p_cur != NULL + ; p_cur = p_cur->p_next + ) { + countRecords++; } - dbg("total records : %d",countRecords); + dbg("total records : %d",countRecords); resp.record_num = countRecords; if ( resp.record_num > 0 ) { -// int i = 0; + // int i = 0; resp.record = g_new0( struct waiting_info, resp.record_num ); for (countValidRecords = 0, p_cur = sp_response->p_intermediates - ; p_cur != NULL - ; p_cur = p_cur->p_next) + ; p_cur != NULL + ; p_cur = p_cur->p_next) { err = at_tok_start(&(p_cur->line)); if (err < 0){ - dbg("start line error. skip this line"); - goto error; + dbg("start line error. skip this line"); + goto error; } - + err = at_tok_nextint(&(p_cur->line), &status);// status if (err < 0) { - dbg("status error. skip this line"); - goto error; - } - + dbg("status error. skip this line"); + goto error; + } + if(status == 1){ resp.record[countValidRecords].status = SS_STATUS_ACTIVATE; } @@ -1091,36 +1106,36 @@ static void on_response_ss_waiting_get( TcorePending *p, int data_len, const voi err = at_tok_nextint(&(p_cur->line), &classx); //class if (err < 0) { - dbg("class error. skip this line"); - goto error; - } + dbg("class error. skip this line"); + goto error; + } switch(classx){ case 1: resp.record[countValidRecords].class = SS_CLASS_VOICE; - break; + break; case 2: resp.record[countValidRecords].class = SS_CLASS_ALL_DATA_TELE; - break; + break; case 4: resp.record[countValidRecords].class = SS_CLASS_FAX; - break; + break; case 7: resp.record[countValidRecords].class = SS_CLASS_ALL_TELE; - break; + break; case 8: resp.record[countValidRecords].class = SS_CLASS_SMS; - break; + break; case 16: resp.record[countValidRecords].class = SS_CLASS_ALL_CS_SYNC; - break; + break; case 32: resp.record[countValidRecords].class = SS_CLASS_ALL_CS_ASYNC; - break; + break; default: - dbg("unspoorted class : [%d]\n", classx ); + dbg("unspoorted class : [%d]\n", classx ); goto error; - break; + break; } countValidRecords++; @@ -1137,19 +1152,26 @@ error: else { dbg("no active status - return to user") + } + + if(sp_response->success > 0){ + resp.err = TCORE_RETURN_SUCCESS; + } + else{ resp.err = TCORE_RETURN_FAILURE; } + dbg("on_response_ss_waiting_get - rsp.err : %d, ur : %x", resp.err, ur); ReleaseResponse(); if ( ur ) tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_waiting), &resp); - else + else dbg("[ error ] ur is 0"); g_free( user_data ); - + } static void on_confirmation_ss_ussd( TcorePending *p, int data_len, const void *data, void *user_data ) @@ -1164,13 +1186,13 @@ static void on_confirmation_ss_ussd( TcorePending *p, int data_len, const void * ur = tcore_pending_ref_user_request(p); - printResponse(); - + printResponse(); + info = (struct ss_confirm_info*)user_data; - + if(sp_response->success > 0){ resp.err = TCORE_RETURN_SUCCESS; - } + } else{ resp.err = TCORE_RETURN_FAILURE; } @@ -1178,7 +1200,7 @@ static void on_confirmation_ss_ussd( TcorePending *p, int data_len, const void * dbg("on_confirmation_ss_ussd - rsp.err : %d, ur : %x", resp.err, ur); - if ( resp.err ) { + if (sp_response->success > 0) { UssdSession *ussd_s = 0; enum tcore_ss_ussd_type type = 0; @@ -1197,7 +1219,7 @@ static void on_confirmation_ss_ussd( TcorePending *p, int data_len, const void * tcore_ss_ussd_get_session_data( ussd_s, (void**)&ur2 ); if ( ur2 ) - tcore_user_request_free( ur2 ); + tcore_user_request_unref( ur2 ); tcore_ss_ussd_destroy_session( ussd_s ); } @@ -1209,6 +1231,9 @@ static void on_confirmation_ss_ussd( TcorePending *p, int data_len, const void * ReleaseResponse(); } + + g_free( user_data ); + } @@ -1248,7 +1273,7 @@ static TReturn _ss_barring_set( CoreObject *o, UserRequest *ur, enum telephony_s int opco; int classx; char* facility = NULL; - + barring = (struct treq_ss_barring*)tcore_user_request_ref_data( ur, 0 ); p = tcore_object_ref_plugin( o ); @@ -1327,7 +1352,7 @@ static TReturn _ss_barring_set( CoreObject *o, UserRequest *ur, enum telephony_s case SS_CLASS_ALL_CS_SYNC: classx = 16; break; - + default: classx =7; dbg("unsupported class %d. set to default : 7", barring->class); @@ -1339,10 +1364,8 @@ static TReturn _ss_barring_set( CoreObject *o, UserRequest *ur, enum telephony_s passwd[MAX_SS_BARRING_PASSWORD_LEN]='\0'; - cmd_str = g_strdup_printf("AT+CLCK=\"%s\",%d,\"%s\",%d%s", facility, opco, passwd, classx,"\r"); + cmd_str = g_strdup_printf("AT+CLCK=\"%s\",%d,\"%s\",%d%s", facility, opco, passwd, classx,"\r"); dbg("request command : %s", cmd_str); - - user_data = g_new0( struct ss_confirm_info, 1 ); @@ -1370,10 +1393,10 @@ static TReturn _ss_barring_set( CoreObject *o, UserRequest *ur, enum telephony_s return TCORE_RETURN_SUCCESS; } -static TReturn _ss_barring_get( CoreObject *o, - UserRequest *ur, - enum telephony_ss_class class, - enum telephony_ss_barring_mode mode, +static TReturn _ss_barring_get( CoreObject *o, + UserRequest *ur, + enum telephony_ss_class class, + enum telephony_ss_barring_mode mode, enum tcore_response_command resp ) { TcorePlugin *p = 0; @@ -1385,7 +1408,7 @@ static TReturn _ss_barring_get( CoreObject *o, char* cmd_str = NULL; int opco, classx; char* facility = NULL; - + p = tcore_object_ref_plugin( o ); memset(&metainfo, 0, sizeof(struct ATReqMetaInfo)); @@ -1395,7 +1418,7 @@ static TReturn _ss_barring_get( CoreObject *o, tcore_user_request_set_metainfo(ur, info_len, &metainfo); - //query status - opco is fixed to 2 + //query status - opco is fixed to 2 opco = 2; //barring mode @@ -1452,7 +1475,7 @@ static TReturn _ss_barring_get( CoreObject *o, case SS_CLASS_ALL_CS_SYNC: classx = 16; break; - + default: classx =7; dbg("unsupported class %d. set to default : 7", class); @@ -1583,13 +1606,13 @@ static TReturn _ss_forwarding_set( CoreObject *o, UserRequest *ur, enum telephon break; case SS_CF_MODE_CFC: reason = 5; - break; - + break; + default: dbg("unsupported reason : %d"); break; } - + switch(op){ case TIZEN_SS_OPCO_DEACTIVATE: mode = 0; @@ -1631,14 +1654,14 @@ static TReturn _ss_forwarding_set( CoreObject *o, UserRequest *ur, enum telephon case SS_CLASS_ALL_CS_SYNC: classx = 16; break; - + default: classx =7; dbg("unsupported class %d. set to default : 7", forwarding->class); break; } -//number +//number len = strlen(forwarding->number); if ( len > 0 ){ valid_num = TRUE; @@ -1672,19 +1695,16 @@ static TReturn _ss_forwarding_set( CoreObject *o, UserRequest *ur, enum telephon else// other opcode does not need num field tmp_str = g_strdup_printf("AT+CCFC=%d,%d,,,%d", reason, mode, classx); - if(forwarding->mode == SS_CF_MODE_CFNRy){ //add time info to 'no reply' case time = (int)(forwarding->time); - cmd_str = g_strdup_printf("%s,,,%d%s", tmp_str,time,"\r"); + cmd_str = g_strdup_printf("%s,,,%d%s", tmp_str,time,"\r"); } else { - cmd_str = g_strdup_printf("%s%s", tmp_str,"\r"); + cmd_str = g_strdup_printf("%s%s", tmp_str,"\r"); } dbg("request command : %s", cmd_str); - - user_data->flavor_type = forwarding->mode; user_data->class = forwarding->class; @@ -1699,10 +1719,10 @@ static TReturn _ss_forwarding_set( CoreObject *o, UserRequest *ur, enum telephon return TCORE_RETURN_SUCCESS; } -static TReturn _ss_forwarding_get( CoreObject *o, - UserRequest *ur, - enum telephony_ss_class class, - enum telephony_ss_forwarding_mode type, +static TReturn _ss_forwarding_get( CoreObject *o, + UserRequest *ur, + enum telephony_ss_class class, + enum telephony_ss_forwarding_mode type, enum tcore_response_command resp ) { TcorePlugin *p = 0; @@ -1743,8 +1763,8 @@ static TReturn _ss_forwarding_get( CoreObject *o, break; case SS_CF_MODE_CFC: reason = 5; - break; - + break; + default: dbg("unsupported reason : %d"); break; @@ -1774,7 +1794,7 @@ static TReturn _ss_forwarding_get( CoreObject *o, classx =7; dbg("unsupported class %d. set to default : 7", class); break; - } + } //query status - mode set to 2 mode =2; @@ -1839,14 +1859,14 @@ static TReturn _ss_waiting_set( CoreObject *o, UserRequest *ur, enum telephony_s int mode=0, classx=0; char* cmd_str; struct ATReqMetaInfo metainfo; - + //set metainfo memset(&metainfo, 0, sizeof(struct ATReqMetaInfo)); metainfo.type = NO_RESULT; metainfo.responsePrefix[0] ='\0'; tcore_user_request_set_metainfo(ur, sizeof(struct ATReqMetaInfo), &metainfo); - + p = tcore_object_ref_plugin( o ); waiting = (struct treq_ss_waiting*) tcore_user_request_ref_data( ur, 0 ); @@ -1856,7 +1876,7 @@ static TReturn _ss_waiting_set( CoreObject *o, UserRequest *ur, enum telephony_s if ( opco == TIZEN_SS_OPCO_ACTIVATE ){ user_data->resp = TRESP_SS_WAITING_ACTIVATE; mode = 1;//enable - } + } else if ( opco == TIZEN_SS_OPCO_DEACTIVATE ){ user_data->resp = TRESP_SS_WAITING_DEACTIVATE; mode =0; //diable @@ -1864,32 +1884,32 @@ static TReturn _ss_waiting_set( CoreObject *o, UserRequest *ur, enum telephony_s else dbg("[ error ] unknown ss mode (0x%x)", opco); -switch(waiting->class) + switch(waiting->class) { case SS_CLASS_ALL_TELE: classx =7; - break; + break; case SS_CLASS_VOICE: classx =1; - break; + break; case SS_CLASS_ALL_DATA_TELE: classx =2; - break; + break; case SS_CLASS_FAX: classx =4; - break; + break; case SS_CLASS_SMS: classx = 8; - break; - + break; + default: classx =7; dbg("unsupported class %d. set to default : 7", waiting->class); - break; - } - + break; + } - user_data->class = waiting->class; + +user_data->class = waiting->class; user_data->flavor_type = (int)opco; cmd_str = g_strdup_printf("AT+CCWA=1,%d,%d%s", mode, classx,"\r"); //always enable +CCWA: unsolicited cmd @@ -1904,9 +1924,9 @@ switch(waiting->class) return TCORE_RETURN_SUCCESS; } -static TReturn _ss_waiting_get( CoreObject *o, - UserRequest *ur, - enum telephony_ss_class class, +static TReturn _ss_waiting_get( CoreObject *o, + UserRequest *ur, + enum telephony_ss_class class, enum tcore_response_command resp ) { TcorePlugin *p = 0; @@ -1925,7 +1945,7 @@ static TReturn _ss_waiting_get( CoreObject *o, info_len = sizeof(struct ATReqMetaInfo); tcore_user_request_set_metainfo(ur, sizeof(struct ATReqMetaInfo), &metainfo); - + p = tcore_object_ref_plugin( o ); switch(class) @@ -1950,7 +1970,7 @@ static TReturn _ss_waiting_get( CoreObject *o, classx =7; dbg("unsupported class %d. set to default : 7", class); break; - } + } dbg("allocating user data"); user_data = g_new0( struct ss_confirm_info, 1 ); @@ -2000,6 +2020,73 @@ static TReturn s_ss_cli_deactivate( CoreObject *o, UserRequest *ur ) static TReturn s_ss_cli_get_status( CoreObject *o, UserRequest *ur ) { + TcorePlugin *p = 0; + + struct treq_ss_cli *cli = 0; + gboolean ret = FALSE; + char *cmd_prefix = NULL, *rsp_prefix = NULL, *cmd_str = NULL; + struct ATReqMetaInfo metainfo; + enum telephony_ss_cli_type *user_data = 0; + + int info_len =0; + + p = tcore_object_ref_plugin(o); + + cli = (struct treq_ss_cli*)tcore_user_request_ref_data( ur, 0 ); + + switch(cli->type){ + case SS_CLI_TYPE_CLIP: + cmd_prefix = "+CLIP"; + rsp_prefix = "+CLIP:"; + break; + + case SS_CLI_TYPE_CLIR: + cmd_prefix = "+CLIR"; + rsp_prefix = "+CLIR:"; + break; + + case SS_CLI_TYPE_COLP: + cmd_prefix = "+COLP"; + rsp_prefix = "+COLP:"; + break; + + case SS_CLI_TYPE_CDIP: + cmd_prefix = "+CDIP"; + rsp_prefix = "+CDIP:"; + break; + + default: + dbg("unsupported cli_type : %d", cli->type); + return TCORE_RETURN_FAILURE; + break; + } + + dbg("cmd_prefix : %s",cmd_prefix); + +//set metaInfo + memset(&metainfo, 0, sizeof(struct ATReqMetaInfo)); + metainfo.type = SINGLELINE; + memcpy(metainfo.responsePrefix,rsp_prefix,strlen(rsp_prefix)); + info_len = sizeof(struct ATReqMetaInfo); + + tcore_user_request_set_metainfo(ur, sizeof(struct ATReqMetaInfo), &metainfo); + + //make cmd string + + cmd_str = g_strdup_printf("AT%s?%s", cmd_prefix, "\r"); + dbg("request cmd : %s", cmd_str); + + // make userinfo for callback + user_data = g_new0( enum telephony_ss_cli_type, 1 ); + *user_data = cli->type; + + ret = _ss_request_message( o, ur, cmd_str, strlen(cmd_str), on_response_ss_waiting_get, user_data ); + + g_free(cmd_str); + + if ( !ret ) + return TCORE_RETURN_FAILURE; + return TCORE_RETURN_SUCCESS; } @@ -2010,17 +2097,17 @@ static TReturn s_ss_send_ussd( CoreObject *o, UserRequest *ur ) struct treq_ss_ussd *ussd = 0; struct ss_confirm_info *user_data = 0; - + gboolean ret = FALSE; char* cmd_str; struct ATReqMetaInfo metainfo; - -//set metainfo + + //set metainfo memset(&metainfo, 0, sizeof(struct ATReqMetaInfo)); metainfo.type = NO_RESULT; metainfo.responsePrefix[0] ='\0'; tcore_user_request_set_metainfo(ur, sizeof(struct ATReqMetaInfo), &metainfo); - + p = tcore_object_ref_plugin(o); ussd = (struct treq_ss_ussd*)tcore_user_request_ref_data( ur, 0 ); @@ -2033,7 +2120,7 @@ static TReturn s_ss_send_ussd( CoreObject *o, UserRequest *ur ) ussd_s = tcore_ss_ussd_get_session( o ); if ( !ussd_s ) { - tcore_ss_ussd_create_session( o, (enum tcore_ss_ussd_type)ussd->type, (void*)tcore_user_request_dup(ur), 0 ); + tcore_ss_ussd_create_session( o, (enum tcore_ss_ussd_type)ussd->type, (void*)tcore_user_request_ref(ur), 0 ); } else { if ( ussd->type == SS_USSD_TYPE_USER_INITIATED ) { @@ -2093,7 +2180,7 @@ static TReturn s_ss_manage_call_0_send( CoreObject* o, UserRequest* ur, ConfirmC int info_len =0; p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); memset(&metainfo, 0, sizeof(struct ATReqMetaInfo)); metainfo.type = NO_RESULT; @@ -2131,7 +2218,7 @@ static TReturn s_ss_manage_call_1_send( CoreObject* o, UserRequest* ur, ConfirmC int info_len =0; p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); memset(&metainfo, 0, sizeof(struct ATReqMetaInfo)); metainfo.type = NO_RESULT; @@ -2169,7 +2256,7 @@ static TReturn s_ss_manage_call_1x_send( CoreObject* o, UserRequest* ur, const i int info_len =0; p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); memset(&metainfo, 0, sizeof(struct ATReqMetaInfo)); metainfo.type = NO_RESULT; @@ -2207,7 +2294,7 @@ static TReturn s_ss_manage_call_2_send( CoreObject* o, UserRequest* ur, ConfirmC int info_len =0; p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); memset(&metainfo, 0, sizeof(struct ATReqMetaInfo)); metainfo.type = NO_RESULT; @@ -2245,7 +2332,7 @@ static TReturn s_ss_manage_call_2x_send( CoreObject* o, UserRequest* ur, const i int info_len =0; p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); memset(&metainfo, 0, sizeof(struct ATReqMetaInfo)); metainfo.type = NO_RESULT; @@ -2279,9 +2366,9 @@ static TReturn s_ss_manage_call_3_send( CoreObject* o, UserRequest* ur, ConfirmC TcorePlugin *p = NULL; TcoreHal *h = NULL; TcorePending *pending = NULL; - char* cmd_str = NULL; + char* cmd_str = NULL; struct ATReqMetaInfo metainfo; - int info_len =0; + int info_len =0; GSList *l = 0; CallObject *co = 0; @@ -2298,7 +2385,7 @@ static TReturn s_ss_manage_call_3_send( CoreObject* o, UserRequest* ur, ConfirmC dbg("active call id : [ %d ]"); p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); memset(&metainfo, 0, sizeof(struct ATReqMetaInfo)); metainfo.type = NO_RESULT; @@ -2337,7 +2424,7 @@ static TReturn s_ss_manage_call_4_send( CoreObject* o, UserRequest* ur, ConfirmC int info_len =0; p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); memset(&metainfo, 0, sizeof(struct ATReqMetaInfo)); metainfo.type = NO_RESULT; @@ -2348,7 +2435,7 @@ static TReturn s_ss_manage_call_4_send( CoreObject* o, UserRequest* ur, ConfirmC cmd_str = g_strdup_printf("%s%s", "AT+CHLD=4", "\r"); - + dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str)); pending = tcore_pending_new(o, ID_RESERVED_AT); @@ -2377,7 +2464,7 @@ static TReturn s_ss_manage_call_4dn_send( CoreObject* o, UserRequest* ur, const int info_len =0; p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); memset(&metainfo, 0, sizeof(struct ATReqMetaInfo)); metainfo.type = NO_RESULT; @@ -2388,7 +2475,7 @@ static TReturn s_ss_manage_call_4dn_send( CoreObject* o, UserRequest* ur, const cmd_str = g_strdup_printf("%s%s%s", "AT+CHLD=4", number,"\r"); - + dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str)); pending = tcore_pending_new(o, ID_RESERVED_AT); @@ -2418,7 +2505,7 @@ static TReturn s_ss_manage_call_5_send( CoreObject* o, UserRequest* ur, ConfirmC int info_len =0; p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); memset(&metainfo, 0, sizeof(struct ATReqMetaInfo)); metainfo.type = NO_RESULT; @@ -2428,7 +2515,7 @@ static TReturn s_ss_manage_call_5_send( CoreObject* o, UserRequest* ur, ConfirmC tcore_user_request_set_metainfo(ur, info_len, &metainfo); - cmd_str = g_strdup_printf("%s%s", "AT+CHLD=5", "\r"); + cmd_str = g_strdup_printf("%s%s", "AT+CHLD=5", "\r"); dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str)); @@ -2458,7 +2545,7 @@ static TReturn s_ss_manage_call_6_send( CoreObject* o, UserRequest* ur, ConfirmC int info_len =0; p = tcore_object_ref_plugin(o); - h = tcore_plugin_ref_hal(p); + h = tcore_object_get_hal(o); memset(&metainfo, 0, sizeof(struct ATReqMetaInfo)); metainfo.type = NO_RESULT; @@ -2468,7 +2555,7 @@ static TReturn s_ss_manage_call_6_send( CoreObject* o, UserRequest* ur, ConfirmC tcore_user_request_set_metainfo(ur, info_len, &metainfo); - cmd_str= g_strdup_printf("%s%s", "AT+CHLD=6", "\r"); + cmd_str= g_strdup_printf("%s%s", "AT+CHLD=6", "\r"); dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str)); @@ -2490,14 +2577,14 @@ static TReturn s_ss_manage_call_6_send( CoreObject* o, UserRequest* ur, ConfirmC #endif -gboolean s_ss_init( TcorePlugin *p ) +gboolean s_ss_init(TcorePlugin *p, TcoreHal *h) { CoreObject *so = 0, *co = 0; struct property_call_info *data = 0; dbg("s_ss_init()"); - so = tcore_ss_new( p, "ss", &ss_ops ); + so = tcore_ss_new(p, "ss", &ss_ops, h); if (!so) { dbg("[ error ] ss_new()"); return FALSE; diff --git a/tel-plugin-atmodem.manifest b/tel-plugin-atmodem.manifest new file mode 100644 index 0000000..d832b3a --- /dev/null +++ b/tel-plugin-atmodem.manifest @@ -0,0 +1,11 @@ + + + + + + + + + + + -- 2.34.1