From 8e963946721400567c03b47164981cce1ce0cbd4 Mon Sep 17 00:00:00 2001 From: Guillaume Zajac Date: Tue, 12 Mar 2013 14:54:42 +0100 Subject: [PATCH 1/1] Update plugin to compile with new libtcore Change-Id: I4ca742ee63becf69f25628a37b511bb1f4298418 --- include/s_call.h | 4 +- include/s_common.h | 80 ------ include/s_gps.h | 4 +- include/s_modem.h | 8 +- include/s_network.h | 4 +- include/s_phonebook.h | 4 +- include/s_ps.h | 4 +- include/s_sap.h | 4 +- include/s_sat.h | 4 +- include/s_sim.h | 4 +- include/s_sms.h | 4 +- include/s_ss.h | 4 +- src/desc.c | 325 ++++++++++++----------- src/s_call.c | 698 +------------------------------------------------- src/s_common.c | 99 +------ src/s_gps.c | 33 +-- src/s_modem.c | 446 ++++---------------------------- src/s_network.c | 68 +++-- src/s_phonebook.c | 22 +- src/s_ps.c | 468 +++++---------------------------- src/s_sap.c | 23 +- src/s_sat.c | 26 +- src/s_sim.c | 38 ++- src/s_sms.c | 208 ++++++--------- src/s_ss.c | 47 ++-- 25 files changed, 485 insertions(+), 2144 deletions(-) diff --git a/include/s_call.h b/include/s_call.h index 32e869c..c1e83c1 100644 --- a/include/s_call.h +++ b/include/s_call.h @@ -21,7 +21,7 @@ #ifndef __S_CALL_H__ #define __S_CALL_H__ -gboolean s_call_init(TcorePlugin *p, TcoreHal *h); -void s_call_exit(TcorePlugin *p); +gboolean s_call_init(TcorePlugin *cp, CoreObject *co_call); +void s_call_exit(TcorePlugin *cp, CoreObject *co_call); #endif diff --git a/include/s_common.h b/include/s_common.h index cb03d61..0250dec 100644 --- a/include/s_common.h +++ b/include/s_common.h @@ -21,88 +21,8 @@ #ifndef __S_COMMON_H__ #define __S_COMMON_H__ -#include #include -#include -#define EVENT_SYS_NOTI_MODEM_POWER "system_power" -#define EVENT_NOTI_MODEM_POWER "modem_power" -#define EVENT_NOTI_MODEM_PHONE_STATE "modem_phone_state" -#define EVENT_NOTI_MODEM_PIN_CTRL "ps_pin_control" - -#define EVENT_NOTI_CALL_STATUS "call_status" -#define EVENT_NOTI_CALL_INCOMING "call_incoming" -#define EVENT_NOTI_CALL_WAITING "call_waiting" -#define EVENT_NOTI_CALL_SOUND_WBAMR_REPORT "call_sound_wbamr_report" -#define EVENT_NOTI_CALL_SOUND_TWO_MIC "call_sound_two_mic" -#define EVENT_NOTI_CALL_SOUND_DHA "call_sound_dha" - -#define EVENT_NOTI_SS_INFO "ss_info" -#define EVENT_NOTI_SS_USSD "ss_ussd" - -#define EVENT_NOTI_PS_CALL_STATUS "ps_call_status" -#define EVENT_NOTI_PS_DATA_COUNTER "ps_data_counter" -#define EVENT_NOTI_PS_IPCONFIGURATION "ps_ipconfiguration" -#define EVENT_NOTI_PS_HSDPA_STATUS "ps_hsdpa_status" -#define EVENT_NOTI_PS_ATTACH_DETACH "ps_attach_detach" -#define EVENT_NOTI_PS_EXTERNAL_CALL "ps_external_call" - -#define EVENT_NOTI_SAP_STATUS "sap_status" -#define EVENT_NOTI_SAP_DISCONNECT "sap_disconnect" - -#define EVENT_NOTI_SIM_PIN_STATUS "sim_pin_status" - -#define EVENT_NOTI_SAT_ENVELOPE_RESP "sat_envelope_response" -#define EVENT_NOTI_SAT_REFRESH_STATUS "sat_refresh_status" -#define EVENT_NOTI_SAT_PROACTIVE_COMMAND "sat_proactive_command" -#define EVENT_NOTI_SAT_CONTROL_RESULT "sat_control_result" - -#define EVENT_NOTI_NETWORK_REGISTRATION "network_regist" -#define EVENT_NOTI_NETWORK_ICON_INFO "network_icon_info" -#define EVENT_NOTI_NETWORK_TIME_INFO "network_time_info" -#define EVENT_NOTI_NETWORK_IDENTITY "network_identity" - -#define EVENT_NOTI_SMS_INCOM_MSG "sms_incom_msg" -#define EVENT_NOTI_SMS_SEND_ACK "sms_send_ack" -#define EVENT_NOTI_SMS_MEMORY_STATUS "sms_memory_status" -#define EVENT_NOTI_SMS_CB_INCOM_MSG "sms_cb_incom_msg" -#define EVENT_NOTI_SMS_DELETE_MSG_CNF "sms_delete_msg_cnf" -#define EVENT_NOTI_SMS_WRITE_MSG_CNF "sms_write_msg_cnf" -#define EVENT_NOTI_SMS_DELIVERY_RPT_CNF "sms_deliver_rpt_cnf" -#define EVENT_NOTI_SMS_DEVICE_READY "sms_device_ready" - -#define EVENT_NOTI_PHONEBOOK_STATUS "phonebook_status" -#define EVENT_NOTI_PHONEBOOK_FIRST_INDEX "phonebook_first_index" - -#define EVENT_NOTI_GPS_ASSIST_DATA "gps_assist_data" -#define EVENT_IND_GPS_MEASURE_POSITION "gps_measure_position" -#define EVENT_NOTI_RESET_ASSIST_DATA "gps_reset_assist_data" - -enum direction_e { - RX, - TX -}; - -struct global_data { - unsigned int msg_auto_id_current; - unsigned int msg_auto_id_start; - unsigned int msg_auto_id_end; - - TcoreHal *hal; -}; - -struct work_queue_data { - unsigned int id; - UserRequest *ur; -}; - -#define UTIL_ID(hdr) ((hdr).main_cmd << 8 | (hdr).sub_cmd) -#define UTIL_IDP(hdr) ((hdr)->main_cmd << 8 | (hdr)->sub_cmd) - -void hook_hex_dump(enum direction_e d, int size, const void *data); -unsigned int util_assign_message_sequence_id(TcorePlugin *p); -gboolean util_add_waiting_job(GQueue *queue, unsigned int id, UserRequest *ur); -UserRequest* util_pop_waiting_job(GQueue *queue, unsigned int id); void util_hex_dump(char *pad, int size, const void *data); unsigned char util_hexCharToInt(char c); char* util_hexStringToBytes(char *s); diff --git a/include/s_gps.h b/include/s_gps.h index 9c1cb1f..73799f1 100644 --- a/include/s_gps.h +++ b/include/s_gps.h @@ -21,7 +21,7 @@ #ifndef __S_GPS_H__ #define __S_GPS_H__ -gboolean s_gps_init(TcorePlugin *p, TcoreHal *h); -void s_gps_exit(TcorePlugin *p); +gboolean s_gps_init(TcorePlugin *cp, CoreObject *co_gps); +void s_gps_exit(TcorePlugin *cp, CoreObject *co_gps); #endif diff --git a/include/s_modem.h b/include/s_modem.h index 2fdd1d8..d0fd6a8 100644 --- a/include/s_modem.h +++ b/include/s_modem.h @@ -21,9 +21,9 @@ #ifndef __S_MODEM_H__ #define __S_MODEM_H__ -gboolean on_event_modem_power(TcoreAT *at, const char *line, TcorePlugin *p); -gboolean s_modem_init(TcorePlugin *p, TcoreHal *h); -void s_modem_exit(TcorePlugin *p); -gboolean s_modem_send_poweron(TcorePlugin *p); +gboolean s_modem_init(TcorePlugin *cp, CoreObject *co_modem); +void s_modem_exit(TcorePlugin *cp, CoreObject *co_modem); + +gboolean modem_power_on(TcorePlugin *p); #endif diff --git a/include/s_network.h b/include/s_network.h index 43fde4c..d9db1f1 100644 --- a/include/s_network.h +++ b/include/s_network.h @@ -21,7 +21,7 @@ #ifndef __S_NETWORK_H__ #define __S_NETWORK_H__ -gboolean s_network_init(TcorePlugin *p, TcoreHal *h); -void s_network_exit(TcorePlugin *p); +gboolean s_network_init(TcorePlugin *cp, CoreObject *co_network); +void s_network_exit(TcorePlugin *cp, CoreObject *co_network); #endif diff --git a/include/s_phonebook.h b/include/s_phonebook.h index a277ed2..beae5fa 100644 --- a/include/s_phonebook.h +++ b/include/s_phonebook.h @@ -21,7 +21,7 @@ #ifndef S_PHONEBOOK_H_ #define S_PHONEBOOK_H_ -gboolean s_phonebook_init(TcorePlugin *p, TcoreHal *h); -void s_phonebook_exit(TcorePlugin *p); +gboolean s_phonebook_init(TcorePlugin *cp, CoreObject *co_phonebook); +void s_phonebook_exit(TcorePlugin *cp, CoreObject *co_phonebook); #endif /* S_PHONEBOOK_H_ */ diff --git a/include/s_ps.h b/include/s_ps.h index ee73554..195b78f 100644 --- a/include/s_ps.h +++ b/include/s_ps.h @@ -21,7 +21,7 @@ #ifndef __S_PS_H__ #define __S_PS_H__ -gboolean s_ps_init(TcorePlugin *p, TcoreHal *hal); -void s_ps_exit(TcorePlugin *p); +gboolean s_ps_init(TcorePlugin *cp, CoreObject *co_ps); +void s_ps_exit(TcorePlugin *cp, CoreObject *co_ps); #endif /*__S_PS_H__*/ diff --git a/include/s_sap.h b/include/s_sap.h index 8e713cd..8765f88 100644 --- a/include/s_sap.h +++ b/include/s_sap.h @@ -21,7 +21,7 @@ #ifndef S_SAP_H_ #define S_SAP_H_ -gboolean s_sap_init(TcorePlugin *p, TcoreHal *h); -void s_sap_exit(TcorePlugin *p); +gboolean s_sap_init(TcorePlugin *cp, CoreObject *co_sap); +void s_sap_exit(TcorePlugin *cp, CoreObject *co_sap); #endif /* S_SAP_H_ */ diff --git a/include/s_sat.h b/include/s_sat.h index c7cb514..90eb826 100644 --- a/include/s_sat.h +++ b/include/s_sat.h @@ -22,7 +22,7 @@ #ifndef S_SAT_H_ #define S_SAT_H_ -gboolean s_sat_init(TcorePlugin *p, TcoreHal *h); -void s_sat_exit(TcorePlugin *p); +gboolean s_sat_init(TcorePlugin *cp, CoreObject *co_sat); +void s_sat_exit(TcorePlugin *cp, CoreObject *co_sat); #endif /* S_SAT_H_ */ diff --git a/include/s_sim.h b/include/s_sim.h index 8f8081d..a7aac22 100644 --- a/include/s_sim.h +++ b/include/s_sim.h @@ -21,7 +21,7 @@ #ifndef __S_SIM_H__ #define __S_SIM_H__ -gboolean s_sim_init(TcorePlugin *p, TcoreHal *h); -void s_sim_exit(TcorePlugin *p); +gboolean s_sim_init(TcorePlugin *cp, CoreObject *co_sim); +void s_sim_exit(TcorePlugin *cp, CoreObject *co_sim); #endif diff --git a/include/s_sms.h b/include/s_sms.h index 9eaad7f..e818270 100644 --- a/include/s_sms.h +++ b/include/s_sms.h @@ -21,7 +21,7 @@ #ifndef S_SMS_H_ #define S_SMS_H_ -gboolean s_sms_init(TcorePlugin *p, TcoreHal *h); -void s_sms_exit(TcorePlugin *p); +gboolean s_sms_init(TcorePlugin *cp, CoreObject *co_sms); +void s_sms_exit(TcorePlugin *cp, CoreObject *co_sms); #endif // S_SMS_H_ diff --git a/include/s_ss.h b/include/s_ss.h index 7eeb2e9..394ba8a 100644 --- a/include/s_ss.h +++ b/include/s_ss.h @@ -21,7 +21,7 @@ #ifndef __S_SS_H__ #define __S_SS_H__ -gboolean s_ss_init(TcorePlugin *p, TcoreHal *h); -void s_ss_exit(TcorePlugin *p); +gboolean s_ss_init(TcorePlugin *cp, CoreObject *co_ss); +void s_ss_exit(TcorePlugin *cp, CoreObject *co_ss); #endif diff --git a/src/desc.c b/src/desc.c index fc00403..dc21ee3 100644 --- a/src/desc.c +++ b/src/desc.c @@ -25,12 +25,10 @@ #include #include #include +#include #include -#include #include -#include -#include "s_common.h" #include "s_network.h" #include "s_modem.h" #include "s_sim.h" @@ -43,52 +41,6 @@ #include "s_phonebook.h" #include "s_gps.h" -static char *cp_name; -static int cp_count = 0; - -#define MAX_CP_QUERY_COUNT 60 - -static gboolean _query_cp_state(gpointer data) -{ - gboolean power_state = FALSE; - TcorePlugin *p = NULL; - CoreObject* obj = NULL; - TcoreHal* h = NULL; - - p = (TcorePlugin *) data; - - if (cp_count > MAX_CP_QUERY_COUNT) { - dbg("cp query counter exceeds MAX_CP_QUERY_COUNT"); - return FALSE; - } - obj = tcore_plugin_ref_core_object(p, "modem"); - h = tcore_object_get_hal(obj); - power_state = tcore_hal_get_power_state(h); - - if (TRUE == power_state) { - dbg("CP READY"); - s_modem_send_poweron(p); - return FALSE; - } else { - dbg("CP NOT READY, cp_count :%d", cp_count); - cp_count++; - return TRUE; - } -} - -static enum tcore_hook_return on_hal_send(TcoreHal *hal, unsigned int data_len, void *data, void *user_data) -{ - hook_hex_dump(TX, data_len, data); - return TCORE_HOOK_RETURN_CONTINUE; -} - -static void on_hal_recv(TcoreHal *hal, unsigned int data_len, const void *data, void *user_data) -{ - msg("=== RX data DUMP ====="); - util_hex_dump(" ", data_len, data); - msg("=== RX data DUMP ====="); -} - static gboolean on_load() { dbg("i'm load!"); @@ -96,141 +48,206 @@ static gboolean on_load() return TRUE; } -static int _get_cp_name(char **name) +static void on_confirmation_modem_message_send(TcorePending *p, + gboolean result, + void *user_data) { - struct utsname u; - - char *svnet1_models[] = { - "F1", "S1", "M2", "H2", "H2_SDK", - "CRESPO", "STEALTHV", "SLP45", "Kessler", "P1P2", - "U1SLP", "U1HD", "SLP7_C210", "SLP10_C210", NULL - }; + dbg("on_confirmation_modem_message_send - msg out from queue."); - char *svnet2_models[] = { "SMDK4410", "SMDK4212", "TRATS2", "SLP_PQ_LTE", "SLP_NAPLES", "REDWOOD", "TRATS", NULL }; - - char *tty_models[] = { "QCT MSM8X55 SURF", "QCT MSM7x27a FFA", NULL }; - - int i = 0; - - if (*name) { - dbg("[ error ] name is not empty"); - return FALSE; - } + dbg("%s", result == FALSE ? "SEND FAIL" : "SEND OK"); +} - memset(&u, '\0', sizeof(struct utsname)); +static void on_response_bootup_subscription(TcorePending *p, int data_len, const void *data, void *user_data) +{ + TcorePlugin *plugin = user_data; + const TcoreATResponse *resp = data; - uname(&u); + dbg("entry of on_response_bootup_subscription() - response comes\n"); - dbg("u.nodename : [ %s ]", u.nodename); + if (resp->success) + dbg("result OK"); - for (i = 0; svnet1_models[i]; i++) { - if (!strcmp(u.nodename, svnet1_models[i])) { - *name = g_new0(char, 5); - strcpy(*name, "6260"); - return 5; - } - } + dbg("result ERROR"); - for (i = 0; svnet2_models[i]; i++) { - if (!strcmp(u.nodename, svnet2_models[i])) { - *name = g_new0(char, 5); - strcpy(*name, "6262"); - return 5; - } - } + if (plugin != NULL) + modem_power_on(plugin); +} - for (i = 0; tty_models[i]; i++) { - if (!strcmp(u.nodename, tty_models[i])) { - *name = g_new0(char, 6); - strcpy(*name, "dpram"); - return 6; - } - } +static void modem_subscribe_events(TcorePlugin *plugin) +{ + CoreObject *co_call = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_CALL); + CoreObject *co_sim = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SIM); + CoreObject *co_sms = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SMS); + CoreObject *co_modem = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_MODEM); + CoreObject *co_network = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_NETWORK); + CoreObject *co_ps = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_PS); + CoreObject *co_sap = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SAP); + CoreObject *co_gps = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_GPS); + + dbg("Entry"); + + /* XCALLSTAT subscription */ + tcore_prepare_and_send_at_request(co_call, "at+xcallstat=1", NULL, TCORE_AT_NO_RESULT, NULL, + on_response_bootup_subscription, NULL, + on_confirmation_modem_message_send, NULL); + + /* XSIMSTATE subscription */ + tcore_prepare_and_send_at_request(co_sim, "at+xsimstate=1", NULL, TCORE_AT_NO_RESULT, NULL, + on_response_bootup_subscription, NULL, + on_confirmation_modem_message_send, NULL); + + tcore_prepare_and_send_at_request(co_sms, "at+xsimstate=1", NULL, TCORE_AT_NO_RESULT, NULL, + on_response_bootup_subscription, NULL, + on_confirmation_modem_message_send, NULL); + tcore_prepare_and_send_at_request(co_modem, "at+xsimstate=1", NULL, TCORE_AT_NO_RESULT, NULL, + on_response_bootup_subscription, NULL, + on_confirmation_modem_message_send, NULL); + + /* CREG subscription */ + tcore_prepare_and_send_at_request(co_network, "at+creg=2", NULL, TCORE_AT_NO_RESULT, NULL, + on_response_bootup_subscription, NULL, + on_confirmation_modem_message_send, NULL); + + /* CGREG subscription */ + tcore_prepare_and_send_at_request(co_network, "at+cgreg=2", NULL, TCORE_AT_NO_RESULT, NULL, + on_response_bootup_subscription, NULL, + on_confirmation_modem_message_send, NULL); + + /* Allow automatic time Zone updation via NITZ */ + tcore_prepare_and_send_at_request(co_network, "at+ctzu=1", NULL, TCORE_AT_NO_RESULT, NULL, + on_response_bootup_subscription, NULL, + on_confirmation_modem_message_send, NULL); + + /* TZ, time & daylight changing event reporting subscription */ + tcore_prepare_and_send_at_request(co_network, "at+ctzr=1", NULL, TCORE_AT_NO_RESULT, NULL, + on_response_bootup_subscription, NULL, + on_confirmation_modem_message_send, NULL); + + /* XMER subscription */ + tcore_prepare_and_send_at_request(co_network, "at+xmer=1", NULL, TCORE_AT_NO_RESULT, NULL, + on_response_bootup_subscription, NULL, + on_confirmation_modem_message_send, NULL); + + /* CGEREP subscription */ + tcore_prepare_and_send_at_request(co_ps, "at+cgerep=1", NULL, TCORE_AT_NO_RESULT, NULL, + on_response_bootup_subscription, NULL, + on_confirmation_modem_message_send, NULL); + + /* XDATASTAT subscription */ + tcore_prepare_and_send_at_request(co_ps, "at+xdatastat=1", NULL, TCORE_AT_NO_RESULT, NULL, + on_response_bootup_subscription, NULL, + on_confirmation_modem_message_send, NULL); + + /* CSSN subscription */ + tcore_prepare_and_send_at_request(co_call, "at+cssn=1,1", NULL, TCORE_AT_NO_RESULT, NULL, + on_response_bootup_subscription, NULL, + on_confirmation_modem_message_send, NULL); + + /* CUSD subscription */ + tcore_prepare_and_send_at_request(co_call, "at+cusd=1", NULL, TCORE_AT_NO_RESULT, NULL, + on_response_bootup_subscription, NULL, + on_confirmation_modem_message_send, NULL); + + /* XDNS subscription */ + tcore_prepare_and_send_at_request(co_ps, "at+xdns=1,1", NULL, TCORE_AT_NO_RESULT, NULL, + on_response_bootup_subscription, NULL, + on_confirmation_modem_message_send, NULL); + + /* CLIP subscription */ + tcore_prepare_and_send_at_request(co_call, "at+clip=1", NULL, TCORE_AT_NO_RESULT, NULL, + on_response_bootup_subscription, NULL, + on_confirmation_modem_message_send, NULL); + + /*CMEE subscription for ps*/ + tcore_prepare_and_send_at_request(co_ps, "at+cmee=2", NULL, TCORE_AT_NO_RESULT, NULL, + on_response_bootup_subscription, NULL, + on_confirmation_modem_message_send, NULL); + + /*CMEE subscription for sms*/ + tcore_prepare_and_send_at_request(co_sms, "at+cmee=2", NULL, TCORE_AT_NO_RESULT, NULL, + on_response_bootup_subscription, NULL, + on_confirmation_modem_message_send, NULL); + + /*incoming sms,cb,status report subscription*/ + tcore_prepare_and_send_at_request(co_sms, "at+cnmi=1,2,2,1,0", NULL, TCORE_AT_NO_RESULT, NULL, + on_response_bootup_subscription, NULL, + on_confirmation_modem_message_send, NULL); + + /* XBCSTAT subscription */ + tcore_prepare_and_send_at_request(co_sap, "at+xbcstat=1", NULL, TCORE_AT_NO_RESULT, NULL, + on_response_bootup_subscription, NULL, + on_confirmation_modem_message_send, NULL); + /* AGPS- assist data and reset assist data subscription */ + tcore_prepare_and_send_at_request(co_gps, "at+cposr=1", NULL, TCORE_AT_NO_RESULT, NULL, + on_response_bootup_subscription, NULL, + on_confirmation_modem_message_send, NULL); + + tcore_prepare_and_send_at_request(co_gps, "at+xcposr=1", NULL, TCORE_AT_NO_RESULT, NULL, + on_response_bootup_subscription, NULL, + on_confirmation_modem_message_send, NULL); + + /* text/pdu mode subscription*/ + tcore_prepare_and_send_at_request(co_sms, "at+cmgf=0", NULL, TCORE_AT_NO_RESULT, NULL, + on_response_bootup_subscription, plugin, + on_confirmation_modem_message_send, NULL); + + dbg("Exit"); +} - dbg("[ error ] unknown model : (%s)", u.nodename); +struct object_initializer init_table = { + .modem_init = s_modem_init, + .sim_init = s_sim_init, + .sat_init = s_sat_init, + .sap_init = s_sap_init, + .network_init = s_network_init, + .ps_init = s_ps_init, + .call_init = s_call_init, + .ss_init = s_ss_init, + .sms_init = s_sms_init, + .phonebook_init = s_phonebook_init, + .gps_init = s_gps_init, +}; - return 0; -} +struct object_deinitializer deinit_table = { + .modem_deinit = s_modem_exit, + .sim_deinit = s_sim_exit, + .sat_deinit = s_sat_exit, + .sap_deinit = s_sap_exit, + .network_deinit = s_network_exit, + .ps_deinit = s_ps_exit, + .call_deinit = s_call_exit, + .ss_deinit = s_ss_exit, + .sms_deinit = s_sms_exit, + .phonebook_deinit = s_phonebook_exit, + .gps_deinit = s_gps_exit, +}; static gboolean on_init(TcorePlugin *p) { - TcoreHal *h; - struct global_data *gd; - // char *cp_name = 0; - int len = 0; - if (!p) return FALSE; - gd = calloc(sizeof(struct global_data), 1); - if (!gd) - return FALSE; - - dbg("i'm init!"); - - gd->msg_auto_id_current = 0; - gd->msg_auto_id_start = 1; - gd->msg_auto_id_end = 255; - - len = _get_cp_name(&cp_name); - if (!len) { - dbg("[ error ] unsupport cp (name : %s)", cp_name); - free(gd); + if (tcore_object_init_objects(p, &init_table) + != TCORE_RETURN_SUCCESS) { + err("Failed to initialize Core Objects"); return FALSE; } - /* FIXME: HAL will reside in Co-object. - * This HAL is just used as default before MUX setup. - * Each HAL has AT pasre functionality. - */ - h = tcore_server_find_hal(tcore_plugin_ref_server(p), cp_name); - if (!h) { - g_free(cp_name); - free(gd); - return FALSE; - } - - // set physical hal into plugin's userdata - gd->hal = h; - - tcore_plugin_link_user_data(p, gd); - - tcore_hal_add_send_hook(h, on_hal_send, p); - tcore_hal_add_recv_callback(h, on_hal_recv, p); - - s_modem_init(p, h); - s_sim_init(p, h); - s_sat_init(p, h); - s_network_init(p, h); - s_ps_init(p, h); - s_call_init(p, h); - s_ss_init(p, h); - s_sms_init(p, h); - s_phonebook_init(p, h); - s_sap_init(p, h); - s_gps_init(p, h); + dbg("i'm init!"); - g_free(cp_name); + modem_subscribe_events(p); - tcore_hal_set_power(h, TRUE); - //wait until CP is ready - g_timeout_add_full(G_PRIORITY_HIGH,500,_query_cp_state, p, 0 ); return TRUE; } static void on_unload(TcorePlugin *p) { - struct global_data *gd; - if (!p) return; - dbg("i'm unload"); + tcore_object_deinit_objects(p, &deinit_table); - gd = tcore_plugin_ref_user_data(p); - if (gd) { - free(gd); - } + dbg("i'm unload"); } struct tcore_plugin_define_desc plugin_define_desc = { diff --git a/src/s_call.c b/src/s_call.c index e48e900..00ed15a 100644 --- a/src/s_call.c +++ b/src/s_call.c @@ -474,7 +474,7 @@ static void _call_status_idle(TcorePlugin *p, CallObject *co) UserRequest *ur; dbg("Entry"); - core_obj = tcore_plugin_ref_core_object(p, "call"); + core_obj = tcore_plugin_ref_core_object(p, CORE_OBJECT_TYPE_CALL); dbg("Call ID [%d], Call Status [%d]", tcore_call_object_get_id(co), tcore_call_object_get_status(co)); if (tcore_call_object_get_status(co) != TCORE_CALL_STATUS_IDLE) { @@ -533,7 +533,7 @@ static void _call_status_dialing(TcorePlugin *p, CallObject *co) // Send notification to TAPI tcore_server_send_notification(tcore_plugin_ref_server(p), - tcore_plugin_ref_core_object(p, "call"), + tcore_plugin_ref_core_object(p, CORE_OBJECT_TYPE_CALL), TNOTI_CALL_STATUS_DIALING, sizeof(struct tnoti_call_status_dialing), (void *) &data); @@ -562,7 +562,7 @@ static void _call_status_alert(TcorePlugin *p, CallObject *co) // Send notification to TAPI tcore_server_send_notification(tcore_plugin_ref_server(p), - tcore_plugin_ref_core_object(p, "call"), + tcore_plugin_ref_core_object(p, CORE_OBJECT_TYPE_CALL), TNOTI_CALL_STATUS_ALERT, sizeof(struct tnoti_call_status_alert), (void *) &data); @@ -590,7 +590,7 @@ static void _call_status_active(TcorePlugin *p, CallObject *co) // Send notification to TAPI tcore_server_send_notification(tcore_plugin_ref_server(p), - tcore_plugin_ref_core_object(p, "call"), + tcore_plugin_ref_core_object(p, CORE_OBJECT_TYPE_CALL), TNOTI_CALL_STATUS_ACTIVE, sizeof(struct tnoti_call_status_active), (void *) &data); @@ -618,7 +618,7 @@ static void _call_status_held(TcorePlugin *p, CallObject *co) // Send notification to TAPI tcore_server_send_notification(tcore_plugin_ref_server(p), - tcore_plugin_ref_core_object(p, "call"), + tcore_plugin_ref_core_object(p, CORE_OBJECT_TYPE_CALL), TNOTI_CALL_STATUS_HELD, sizeof(struct tnoti_call_status_held), (void *) &data); @@ -662,7 +662,7 @@ static void _call_status_incoming(TcorePlugin *p, CallObject *co) // Send notification to TAPI tcore_server_send_notification(tcore_plugin_ref_server(p), - tcore_plugin_ref_core_object(p, "call"), + tcore_plugin_ref_core_object(p, CORE_OBJECT_TYPE_CALL), TNOTI_CALL_STATUS_INCOMING, sizeof(struct tnoti_call_status_incoming), (void *) &data); @@ -3397,696 +3397,22 @@ static struct tcore_call_operations call_ops = { .set_sound_noise_reduction = NULL, }; -static void s_call_info_mo_waiting(CoreObject *o) +gboolean s_call_init(TcorePlugin *cp, CoreObject *co_call) { - TcorePlugin *plugin = NULL; - CallObject *co = NULL; - int id = 0; - - dbg("Entry"); - - // Parent plugin - plugin = tcore_object_ref_plugin(o); - - // Call Core object - co = tcore_call_object_current_on_mo_processing(o); - if (!co) { - err("Failed to find Call Core object!"); - return; - } - - // Call ID - id = tcore_call_object_get_id(co); - - // Send notification to TAPI - tcore_server_send_notification(tcore_plugin_ref_server(plugin), - tcore_plugin_ref_core_object(plugin, "call"), - TNOTI_CALL_INFO_WAITING, - sizeof(unsigned int), - (void *) &id); - - dbg("Exit"); - return; -} - -static void s_call_info_mo_forwarded(CoreObject *o) -{ - TcorePlugin *plugin = NULL; - CallObject *co = NULL; - int id = 0; - - dbg("Entry"); - - // Parent plugin - plugin = tcore_object_ref_plugin(o); - - // Call Core object - co = tcore_call_object_current_on_mo_processing(o); - if (!co) { - err("Failed to find Call Core object!"); - return; - } - - // Call ID - id = tcore_call_object_get_id(co); - - // Send notification to TAPI - tcore_server_send_notification(tcore_plugin_ref_server(plugin), - tcore_plugin_ref_core_object(plugin, "call"), - TNOTI_CALL_INFO_FORWARDED, - sizeof(unsigned int), - (void *) &id); - - dbg("Exit"); - return; -} - -static void s_call_info_mo_barred_incoming(CoreObject *o) -{ - TcorePlugin *plugin = NULL; - CallObject *co = NULL; - int id = 0; - - dbg("Entry"); - - // Parent plugin - plugin = tcore_object_ref_plugin(o); - - // Call Core object - co = tcore_call_object_current_on_mo_processing(o); - if (!co) { - err("Failed to find Call Core object!"); - return; - } - - // Call ID - id = tcore_call_object_get_id(co); - - // Send notification to TAPI - tcore_server_send_notification(tcore_plugin_ref_server(plugin), - tcore_plugin_ref_core_object(plugin, "call"), - TNOTI_CALL_INFO_BARRED_INCOMING, - sizeof(unsigned int), - (void *) &id); - - dbg("Exit"); - return; -} - -static void s_call_info_mo_barred_outgoing(CoreObject *o) -{ - TcorePlugin *plugin = NULL; - CallObject *co = NULL; - int id = 0; - - dbg("Entry"); - - // Parent plugin - plugin = tcore_object_ref_plugin(o); - - // Call Core object - co = tcore_call_object_current_on_mo_processing(o); - if (!co) { - err("Failed to find Call Core object!"); - return; - } - - // Call ID - id = tcore_call_object_get_id(co); - - // Send notification to TAPI - tcore_server_send_notification(tcore_plugin_ref_server(plugin), - tcore_plugin_ref_core_object(plugin, "call"), - TNOTI_CALL_INFO_BARRED_OUTGOING, - sizeof(unsigned int), - (void *) &id); - - dbg("Exit"); - return; -} - -static void s_call_info_mo_deflected(CoreObject *o) -{ - TcorePlugin *plugin = NULL; - CallObject *co = NULL; - int id = 0; - - dbg("Entry"); - - // Parent plugin - plugin = tcore_object_ref_plugin(o); - - // Call Core object - co = tcore_call_object_current_on_mo_processing(o); - if (!co) { - err("Failed to find Call Core object!"); - return; - } - - // Call ID - id = tcore_call_object_get_id(co); - - // Send notification to TAPI - tcore_server_send_notification(tcore_plugin_ref_server(plugin), - tcore_plugin_ref_core_object(plugin, "call"), - TNOTI_CALL_INFO_DEFLECTED, - sizeof(unsigned int), - (void *) &id); - - dbg("Exit"); - return; -} - -static void s_call_info_mo_clir_suppression_reject(CoreObject *o) -{ - TcorePlugin *plugin = NULL; - CallObject *co = NULL; - int id = 0; - dbg("Entry"); - // Parent plugin - plugin = tcore_object_ref_plugin(o); + tcore_call_override_ops(co_call, &call_ops, NULL); - // Call Core object - co = tcore_call_object_current_on_mo_processing(o); - if (!co) { - err("Failed to find Call Core object!"); - return; - } - - // Call ID - id = tcore_call_object_get_id(co); - - // Send notification to TAPI - tcore_server_send_notification(tcore_plugin_ref_server(plugin), - tcore_plugin_ref_core_object(plugin, "call"), - TNOTI_CALL_INFO_CLIR_SUPPRESSION_REJECT, - sizeof(unsigned int), - (void *) &id); + /* Add Callbacks */ + tcore_object_override_callback(co_call, "+XCALLSTAT", on_notification_call_info, NULL); + tcore_object_override_callback(co_call, "+CLIP", on_notification_call_clip_info, NULL); dbg("Exit"); - return; -} - -static void s_call_info_mo_cfu(CoreObject *o) -{ - TcorePlugin *plugin = NULL; - CallObject *co = NULL; - int id = 0; - - dbg("Entry"); - - // Parent plugin - plugin = tcore_object_ref_plugin(o); - - // Call Core object - co = tcore_call_object_current_on_mo_processing(o); - if (!co) { - err("Failed to find Call Core object!"); - return; - } - - // Call ID - id = tcore_call_object_get_id(co); - - // Send notification to TAPI - tcore_server_send_notification(tcore_plugin_ref_server(plugin), - tcore_plugin_ref_core_object(plugin, "call"), - TNOTI_CALL_INFO_FORWARD_UNCONDITIONAL, - sizeof(unsigned int), - (void *) &id); - dbg("Exit"); - return; -} - -static void s_call_info_mo_cfc(CoreObject *o) -{ - TcorePlugin *plugin = NULL; - CallObject *co = NULL; - int id = 0; - - dbg("Entry"); - - // Parent plugin - plugin = tcore_object_ref_plugin(o); - - // Call Core object - co = tcore_call_object_current_on_mo_processing(o); - if (!co) { - err("Failed to find Call Core object!"); - return; - } - - // Call ID - id = tcore_call_object_get_id(co); - - // Send notification to TAPI - tcore_server_send_notification(tcore_plugin_ref_server(plugin), - tcore_plugin_ref_core_object(plugin, "call"), - TNOTI_CALL_INFO_FORWARD_CONDITIONAL, - sizeof(unsigned int), - (void *) &id); - - dbg("Exit"); - return; -} - -static void s_call_info_mt_cli(CoreObject *o, enum tcore_call_cli_mode mode, char *number) -{ - CallObject *co = NULL; - - dbg("Entry"); - - // Call Core object - co = tcore_call_object_current_on_mt_processing(o); - if (!co) { - err("Failed to find Call Core object!"); - return; - } - - // Set CLI information - tcore_call_object_set_cli_info(co, mode, number); - - dbg("Exit"); - return; -} - -static void s_call_info_mt_cna(CoreObject *o, enum tcore_call_cna_mode mode, char *name, int dcs) -{ - CallObject *co = NULL; - - dbg("Entry"); - - // Call Core object - co = tcore_call_object_current_on_mt_processing(o); - if (!co) { - err("Failed to find Call Core object!"); - return; - } - - // Set CNA information - tcore_call_object_set_cna_info(co, mode, name, dcs); - - dbg("Exit"); - return; -} - -static void s_call_info_mt_forwarded_call(CoreObject *o, char *number) -{ - TcorePlugin *plugin = NULL; - CallObject *co = NULL; - int id = 0; - - dbg("Entry"); - - // Parent plugin - plugin = tcore_object_ref_plugin(o); - - // Call Core object - co = tcore_call_object_find_by_number(o, number); - if (!co) { - err("Failed to find Call Core object!"); - return; - } - - // Call ID - id = tcore_call_object_get_id(co); - - // Send notification to TAPI - tcore_server_send_notification(tcore_plugin_ref_server(plugin), - tcore_plugin_ref_core_object(plugin, "call"), - TNOTI_CALL_INFO_FORWARDED_CALL, - sizeof(unsigned int), - (void *) &id); - - dbg("Exit"); - return; -} - -static void s_call_info_mt_deflected_call(CoreObject *o, char *number) -{ - TcorePlugin *plugin = NULL; - CallObject *co = NULL; - int id = 0; - - dbg("Entry"); - - // Parent plugin - plugin = tcore_object_ref_plugin(o); - - // Call Core object - co = tcore_call_object_find_by_number(o, number); - if (!co) { - err("Failed to find Call Core object!"); - return; - } - - // Call ID - id = tcore_call_object_get_id(co); - - // Send notification to TAPI - tcore_server_send_notification(tcore_plugin_ref_server(plugin), - tcore_plugin_ref_core_object(plugin, "call"), - TNOTI_CALL_INFO_DEFLECTED_CALL, - sizeof(unsigned int), - (void *) &id); - - dbg("Exit"); - return; -} - -static void s_call_info_mt_transfered(CoreObject *o, char *number) -{ - TcorePlugin *plugin = NULL; - CallObject *co = NULL; - int id = 0; - - dbg("Entry"); - - // Parent plugin - plugin = tcore_object_ref_plugin(o); - - // Call Core object - co = tcore_call_object_find_by_number(o, number); - if (!co) { - err("Failed to find Call Core object!"); - return; - } - - // Call ID - id = tcore_call_object_get_id(co); - - // Send notification to TAPI - tcore_server_send_notification(tcore_plugin_ref_server(plugin), - tcore_plugin_ref_core_object(plugin, "call"), - TNOTI_CALL_INFO_TRANSFERED_CALL, - sizeof(unsigned int), - (void *) &id); - - dbg("Exit"); - return; -} - -static void s_call_info_held(CoreObject *o, char *number) -{ - TcorePlugin *plugin = NULL; - CallObject *co = NULL; - int id = 0; - - dbg("Entry"); - - // Parent plugin - plugin = tcore_object_ref_plugin(o); - - // Call Core object - co = tcore_call_object_find_by_number(o, number); - if (!co) { - err("Failed to find Call Core object!"); - return; - } - - // Call ID - id = tcore_call_object_get_id(co); - - // Send notification to TAPI - tcore_server_send_notification(tcore_plugin_ref_server(plugin), - tcore_plugin_ref_core_object(plugin, "call"), - TNOTI_CALL_INFO_HELD, - sizeof(unsigned int), - (void *) &id); - - dbg("Exit"); - return; -} - -static void s_call_info_active(CoreObject *o, char *number) -{ - TcorePlugin *plugin = NULL; - CallObject *co = NULL; - int id = 0; - - dbg("Entry"); - - // Parent plugin - plugin = tcore_object_ref_plugin(o); - - // Call Core object - co = tcore_call_object_find_by_number(o, number); - if (!co) { - err("Failed to find Call Core object!"); - return; - } - - // Call ID - id = tcore_call_object_get_id(co); - - // Send notification to TAPI - tcore_server_send_notification(tcore_plugin_ref_server(plugin), - tcore_plugin_ref_core_object(plugin, "call"), - TNOTI_CALL_INFO_ACTIVE, - sizeof(unsigned int), - (void *) &id); - - dbg("Exit"); - return; -} - -static void s_call_info_joined(CoreObject *o, char *number) -{ - TcorePlugin *plugin = NULL; - CallObject *co = NULL; - int id = 0; - - dbg("Entry"); - - // Parent plugin - plugin = tcore_object_ref_plugin(o); - - // Call Core object - co = tcore_call_object_find_by_number(o, number); - if (!co) { - err("Failed to find Call Core object!"); - return; - } - - // Call ID - id = tcore_call_object_get_id(co); - - // Send notification to TAPI - tcore_server_send_notification(tcore_plugin_ref_server(plugin), - tcore_plugin_ref_core_object(plugin, "call"), - TNOTI_CALL_INFO_JOINED, - sizeof(unsigned int), - (void *) &id); - - dbg("Exit"); - return; -} - -static void s_call_info_released_on_hold(CoreObject *o, char *number) -{ - TcorePlugin *plugin = NULL; - CallObject *co = NULL; - int id = 0; - - dbg("Entry"); - - // Parent plugin - plugin = tcore_object_ref_plugin(o); - - // Call Core object - co = tcore_call_object_find_by_number(o, number); - if (!co) { - err("Failed to find Call Core object!"); - return; - } - - // Call ID - id = tcore_call_object_get_id(co); - - // Send notification to TAPI - tcore_server_send_notification(tcore_plugin_ref_server(plugin), - tcore_plugin_ref_core_object(plugin, "call"), - TNOTI_CALL_INFO_RELEASED_ON_HOLD, - sizeof(unsigned int), - (void *) &id); - - dbg("Exit"); - return; -} - -static void s_call_info_transfer_alert(CoreObject *o, char *number) -{ - TcorePlugin *plugin = NULL; - CallObject *co = NULL; - int id = 0; - - dbg("Entry"); - - // Parent plugin - plugin = tcore_object_ref_plugin(o); - - // Call Core object - co = tcore_call_object_find_by_number(o, number); - if (!co) { - err("Failed to find Call Core object!"); - return; - } - - // Call ID - id = tcore_call_object_get_id(co); - - // Send notification to TAPI - tcore_server_send_notification(tcore_plugin_ref_server(plugin), - tcore_plugin_ref_core_object(plugin, "call"), - TNOTI_CALL_INFO_TRANSFER_ALERT, - sizeof(unsigned int), - (void *) &id); - - dbg("Exit"); - return; -} - -static void s_call_info_transfered(CoreObject *o, char *number) -{ - TcorePlugin *plugin = NULL; - CallObject *co = NULL; - int id = 0; - - dbg("Entry"); - - // Parent plugin - plugin = tcore_object_ref_plugin(o); - - // Call Core object - co = tcore_call_object_find_by_number(o, number); - if (!co) { - err("Failed to find Call Core object!"); - return; - } - - // Call ID - id = tcore_call_object_get_id(co); - - // Send notification to TAPI - tcore_server_send_notification(tcore_plugin_ref_server(plugin), - tcore_plugin_ref_core_object(plugin, "call"), - TNOTI_CALL_INFO_TRANSFERED, - sizeof(unsigned int), - (void *) &id); - - dbg("Exit"); - return; -} - -static void s_call_info_cf_check_message(CoreObject *o, char *number) -{ - TcorePlugin *plugin = NULL; - CallObject *co = NULL; - int id = 0; - - dbg("Entry"); - - // Parent plugin - plugin = tcore_object_ref_plugin(o); - - // Call Core object - co = tcore_call_object_find_by_number(o, number); - if (!co) { - err("Failed to find Call Core object!"); - return; - } - - // Call ID - id = tcore_call_object_get_id(co); - - // Send notification to TAPI - tcore_server_send_notification(tcore_plugin_ref_server(plugin), - tcore_plugin_ref_core_object(plugin, "call"), - TNOTI_CALL_INFO_CF_CHECK_MESSAGE, - sizeof(unsigned int), - (void *) &id); - - dbg("Exit"); - return; -} - -// Call Information Operations -static struct tcore_call_information_operations call_information_ops = { - .mo_call_col = 0, - .mo_call_waiting = s_call_info_mo_waiting, - .mo_call_cug = 0, - .mo_call_forwarded = s_call_info_mo_forwarded, - .mo_call_barred_incoming = s_call_info_mo_barred_incoming, - .mo_call_barred_outgoing = s_call_info_mo_barred_outgoing, - .mo_call_deflected = s_call_info_mo_deflected, - .mo_call_clir_suppression_reject = s_call_info_mo_clir_suppression_reject, - .mo_call_cfu = s_call_info_mo_cfu, - .mo_call_cfc = s_call_info_mo_cfc, - .mt_call_cli = s_call_info_mt_cli, - .mt_call_cna = s_call_info_mt_cna, - .mt_call_forwarded_call = s_call_info_mt_forwarded_call, - .mt_call_cug_call = 0, - .mt_call_deflected_call = s_call_info_mt_deflected_call, - .mt_call_transfered = s_call_info_mt_transfered, - .call_held = s_call_info_held, - .call_active = s_call_info_active, - .call_joined = s_call_info_joined, - .call_released_on_hold = s_call_info_released_on_hold, - .call_transfer_alert = s_call_info_transfer_alert, - .call_transfered = s_call_info_transfered, - .call_cf_check_message = s_call_info_cf_check_message, -}; - -gboolean s_call_init(TcorePlugin *p, TcoreHal *h) -{ - CoreObject *o = NULL; - struct property_call_info *data = NULL; - - dbg("Entry"); - - // Creating Call COre object - o = tcore_call_new(p, "call", &call_ops, h); - if (!o) { - err("Failed to create Call Core Object"); - return FALSE; - } - - // Set Call Operations - tcore_call_information_set_operations(o, &call_information_ops); - - // Add Callbacks - tcore_object_add_callback(o, "+XCALLSTAT", on_notification_call_info, NULL); - tcore_object_add_callback(o, "+CLIP", on_notification_call_clip_info, NULL); - - // User Data - data = calloc(sizeof(struct property_call_info *), 1); - tcore_plugin_link_property(p, "CALL", data); - - dbg("Exit"); return TRUE; } -void s_call_exit(TcorePlugin *p) +void s_call_exit(TcorePlugin *cp, CoreObject *co_call) { - CoreObject *o = NULL; - struct property_network_info *data = NULL; - - dbg("Entry"); - - o = tcore_plugin_ref_core_object(p, "call"); - - // Free Call Core Object */ - tcore_call_free(o); - - // Free 'CALL' property */ - data = tcore_plugin_ref_property(p, "CALL"); - if (data) { - g_free(data); - } - dbg("Exit"); - return; } diff --git a/src/s_common.c b/src/s_common.c index 0c83ac5..50ee24e 100644 --- a/src/s_common.c +++ b/src/s_common.c @@ -23,12 +23,11 @@ #include #include +#include #include "s_common.h" -#include - #undef MAX #define MAX(a, b) (((a) > (b)) ? (a) : (b)) @@ -86,98 +85,6 @@ void util_hex_dump(char *pad, int size, const void *data) msg("%s", buf); } -void hook_hex_dump(enum direction_e d, int size, const void *data) -{ - msg("=== TX data DUMP ====="); - util_hex_dump(" ", size, data); - msg("=== TX data DUMP ====="); -} - -unsigned int util_assign_message_sequence_id(TcorePlugin *p) -{ - struct global_data *gd; - - if (!p) { - dbg("plugin is NULL"); - return -1; - } - - gd = tcore_plugin_ref_user_data(p); - if (!gd) { - dbg("global data is NULL"); - return -1; - } - - if (gd->msg_auto_id_current == 0) { - gd->msg_auto_id_current = gd->msg_auto_id_start; - dbg("pending_auto_id_current is 0, reset to start"); - } else if (gd->msg_auto_id_current >= gd->msg_auto_id_end) { - gd->msg_auto_id_current = gd->msg_auto_id_start; - dbg("pending_auto_id_current is over, reset to start"); - } else { - gd->msg_auto_id_current++; - } - - dbg("message_sequence_id = %d", gd->msg_auto_id_current); - - return gd->msg_auto_id_current; -} - -gboolean util_add_waiting_job(GQueue *queue, unsigned int id, UserRequest *ur) -{ - struct work_queue_data *wqd; - - if (!queue) - return FALSE; - - wqd = calloc(sizeof(struct work_queue_data), 1); - if (!wqd) - return FALSE; - - wqd->id = id; - wqd->ur = tcore_user_request_ref(ur); - g_queue_push_tail(queue, wqd); - - dbg("id = %d, ur = 0x%x", wqd->id, wqd->ur); - return TRUE; -} - -UserRequest* util_pop_waiting_job(GQueue *queue, unsigned int id) -{ - int i = 0; - UserRequest *ur; - struct work_queue_data *wqd; - - if (!queue) - return NULL; - - - dbg("before waiting job count: %d", g_queue_get_length(queue)); - - do { - wqd = g_queue_peek_nth(queue, i); - if (!wqd) - return NULL; - - if (wqd->id == id) { - wqd = g_queue_pop_nth(queue, i); - break; - } - - i++; - } while (wqd != NULL); - - dbg("after waiting job count: %d", g_queue_get_length(queue)); - - if (!wqd) - return NULL; - - ur = wqd->ur; - free(wqd); - - return ur; -} - unsigned char util_hexCharToInt(char c) { if (c >= '0' && c <= '9') @@ -226,9 +133,9 @@ char _util_unpackb(const char *src, int pos, int len) rshift = MAX(8 - (pos + len), 0); if (rshift > 0) { - result = MASK_AND_SHIFT(len, pos, rshift, *src); + result = MASK_AND_SHIFT(len, pos, rshift, (unsigned char)*src); } else { - result = MASK(8 - pos, pos, *src); + result = MASK(8 - pos, pos, (unsigned char)*src); src++; len -= 8 - pos; diff --git a/src/s_gps.c b/src/s_gps.c index 6079a53..85a66de 100644 --- a/src/s_gps.c +++ b/src/s_gps.c @@ -2094,38 +2094,21 @@ static struct tcore_gps_operations gps_ops = { .confirm_measure_pos = gps_confirm_measure_pos, }; -gboolean s_gps_init(TcorePlugin *p, TcoreHal *h) +gboolean s_gps_init(TcorePlugin *cp, CoreObject *co_gps) { - CoreObject *o = NULL; - GQueue *work_queue = NULL; + dbg("Enter"); - dbg("enter"); + tcore_gps_override_ops(co_gps, &gps_ops); - o = tcore_gps_new(p, "gps", &gps_ops, h); - if (!o) - return FALSE; + tcore_object_override_callback(co_gps, "+CPOSR", on_notification_gps_assist_data, NULL); + tcore_object_override_callback(co_gps, "+XCPOSR", on_notification_reset_assist_data, NULL); - work_queue = g_queue_new(); - tcore_object_link_user_data(o, work_queue); + dbg("Exit"); - tcore_object_add_callback(o, "+CPOSR", on_notification_gps_assist_data, NULL); - tcore_object_add_callback(o, "+XCPOSR", on_notification_reset_assist_data, NULL); - dbg("exit"); return TRUE; } -void s_gps_exit(TcorePlugin *p) +void s_gps_exit(TcorePlugin *cp, CoreObject *co_gps) { - CoreObject *o; - GQueue *work_queue; - - o = tcore_plugin_ref_core_object(p, "gps"); - if (!o) - return; - - work_queue = tcore_object_ref_user_data(o); - if (work_queue) - g_queue_free(work_queue); - - tcore_gps_free(o); + dbg("Exit"); } diff --git a/src/s_modem.c b/src/s_modem.c index 3ea6fc2..6d21f86 100644 --- a/src/s_modem.c +++ b/src/s_modem.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -97,28 +98,12 @@ typedef struct { } TelMiscVersionInformation; -void prepare_and_send_pending_request(TcorePlugin *plugin, char *co_name, const char *at_cmd, const char *prefix, enum tcore_at_command_type at_cmd_type, TcorePendingResponseCallback callback); +static void prepare_and_send_pending_request(CoreObject *co, const char *at_cmd, const char *prefix, enum tcore_at_command_type at_cmd_type, TcorePendingResponseCallback callback); static void on_confirmation_modem_message_send(TcorePending *p, gboolean result, void *user_data); // from Kernel void on_response_bootup_subscription(TcorePending *p, int data_len, const void *data, void *user_data); void on_response_last_bootup_subscription(TcorePending *p, int data_len, const void *data, void *user_data); -static void on_timeout_modem_poweron(TcorePending *p, void *user_data); static void on_response_enable_proactive_command(TcorePending *p, int data_len, const void *data, void *user_data); -static void on_timeout_modem_poweron(TcorePending *p, void *user_data) -{ - unsigned int data_len = 0; - char data[] = "AT+CPAS"; - - dbg("TIMEOUT for 1st AT Command !!!!! NO Response for initial AT command. Resending it"); - data_len = sizeof(data); - - /* Retransmit 1st AT command directly via HAL, don't disturb pending queue. */ - /* HAL was passed as user_data, re-use it */ - if (user_data) { - tcore_hal_send_data(user_data, data_len, (void *) data); - } -} - static void on_confirmation_modem_message_send(TcorePending *p, gboolean result, void *user_data) { dbg("on_confirmation_modem_message_send - msg out from queue.\n"); @@ -142,19 +127,17 @@ static void on_response_enable_proactive_command(TcorePending *p, int data_len, } } -void prepare_and_send_pending_request(TcorePlugin *plugin, char *co_name, const char *at_cmd, const char *prefix, enum tcore_at_command_type at_cmd_type, TcorePendingResponseCallback callback) +void prepare_and_send_pending_request(CoreObject *co, const char *at_cmd, const char *prefix, enum tcore_at_command_type at_cmd_type, TcorePendingResponseCallback callback) { TcoreATRequest *req = NULL; TcoreHal *hal = NULL; - CoreObject *o = NULL; TcorePending *pending = NULL; TReturn ret; - o = tcore_plugin_ref_core_object(plugin, co_name); - hal = tcore_object_get_hal(o); + hal = tcore_object_get_hal(co); dbg("hal: %p", hal); - pending = tcore_pending_new(o, 0); + pending = tcore_pending_new(co, 0); if (!pending) dbg("Pending is NULL"); req = tcore_at_request_new(at_cmd, prefix, at_cmd_type); @@ -164,36 +147,7 @@ void prepare_and_send_pending_request(TcorePlugin *plugin, char *co_name, const tcore_pending_set_request_data(pending, 0, req); tcore_pending_set_response_callback(pending, callback, NULL); tcore_pending_set_send_callback(pending, on_confirmation_modem_message_send, NULL); - tcore_pending_link_user_request(pending, NULL); // set user request to NULL - this is intenal request ret = tcore_hal_send_request(hal, pending); - return; -} - -void on_response_bootup_subscription(TcorePending *p, int data_len, const void *data, void *user_data) -{ - const TcoreATResponse *resp = data; - - dbg("entry of on_response_bootup_subscription() - response comes\n"); - - if (resp->success) { - dbg("result OK"); - } else { - dbg("result ERROR"); - } -} - -void on_response_last_bootup_subscription(TcorePending *p, int data_len, const void *data, void *user_data) -{ - const TcoreATResponse *resp = data; - - dbg("enry of on_response_last_bootup_subscription() - final response comes\n"); - if (resp->success) { - dbg("SEND OK"); - } else { - dbg("SEND FAIL"); - } - dbg("Response for AT+CLIP. Boot-up configration completed for IMC modem. Bring CP to online based on Flightmode status\n"); - on_event_modem_power(NULL, NULL, tcore_pending_ref_plugin(p)); } static void on_response_power_off(TcorePending *p, int data_len, const void *data, void *user_data) @@ -271,7 +225,7 @@ static void on_response_set_flight_mode(TcorePending *p, int data_len, const voi if (req_data->enable == 0) { dbg("Flight mode is disabled, trigger COPS to register on network"); /* Trigger Network registration (for the moment automatic) */ - prepare_and_send_pending_request(tcore_object_ref_plugin(o), "modem", "AT+COPS=0", NULL, TCORE_AT_NO_RESULT, NULL); + prepare_and_send_pending_request(o, "AT+COPS=0", NULL, TCORE_AT_NO_RESULT, NULL); } } @@ -452,8 +406,8 @@ static gboolean on_event_bootup_sim_status(CoreObject *o, const void *event_info if (7 == value) { dbg("SIM ready. request COPS & remove callback"); dbg("power on done set for proactive command receiving mode"); - prepare_and_send_pending_request(tcore_object_ref_plugin(o), "sat", "AT+CFUN=6", NULL, TCORE_AT_NO_RESULT, on_response_enable_proactive_command); - prepare_and_send_pending_request(tcore_object_ref_plugin(o), "umts_network", "AT+COPS=0", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription); + prepare_and_send_pending_request(o, "AT+CFUN=6", NULL, TCORE_AT_NO_RESULT, on_response_enable_proactive_command); + prepare_and_send_pending_request(o, "AT+COPS=0", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription); return FALSE; } @@ -466,305 +420,47 @@ OUT: -gboolean on_event_modem_power(TcoreAT *at, const char *line, TcorePlugin *p) +gboolean modem_power_on(TcorePlugin *p) { - CoreObject *o = NULL; + CoreObject *co_modem = NULL; struct treq_modem_set_flightmode flight_mode_set = {0}; struct tnoti_modem_power modem_power = {0}; TcoreHal *h = NULL; Storage *strg = NULL; - o = tcore_plugin_ref_core_object(p, "modem"); + co_modem = tcore_plugin_ref_core_object(p, CORE_OBJECT_TYPE_MODEM); strg = tcore_server_find_storage(tcore_plugin_ref_server(p), "vconf"); flight_mode_set.enable = tcore_storage_get_bool(strg, STORAGE_KEY_FLIGHT_MODE_BOOL); - h = tcore_object_get_hal(o); + h = tcore_object_get_hal(co_modem); tcore_hal_set_power_state(h, TRUE); /* Set Flight mode as per AP settings */ if (flight_mode_set.enable) { /* Radio Off */ - prepare_and_send_pending_request(p, "modem", "AT+CFUN=4", NULL, TCORE_AT_NO_RESULT, on_response_set_flight_mode); - tcore_modem_set_flight_mode_state(o, TRUE); + prepare_and_send_pending_request(co_modem, "AT+CFUN=4", NULL, TCORE_AT_NO_RESULT, on_response_set_flight_mode); + tcore_modem_set_flight_mode_state(co_modem, TRUE); } else { /* Radio On */ - prepare_and_send_pending_request(p, "modem", "AT+CFUN=1", NULL, TCORE_AT_NO_RESULT, on_response_set_flight_mode); - tcore_modem_set_flight_mode_state(o, FALSE); + prepare_and_send_pending_request(co_modem, "AT+CFUN=1", NULL, TCORE_AT_NO_RESULT, on_response_set_flight_mode); + tcore_modem_set_flight_mode_state(co_modem, FALSE); } /* Get IMEI */ - prepare_and_send_pending_request(p, "modem", "AT+CGSN", NULL, TCORE_AT_NUMERIC, on_response_imei); + prepare_and_send_pending_request(co_modem, "AT+CGSN", NULL, TCORE_AT_NUMERIC, on_response_imei); /* Get Version Number */ - prepare_and_send_pending_request(p, "modem", "AT+CGMR", NULL, TCORE_AT_SINGLELINE, on_response_version); + prepare_and_send_pending_request(co_modem, "AT+CGMR", NULL, TCORE_AT_SINGLELINE, on_response_version); - tcore_modem_set_powered(o, TRUE); + tcore_modem_set_powered(co_modem, TRUE); modem_power.state = MODEM_STATE_ONLINE; - tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)), o, TNOTI_MODEM_POWER, + tcore_server_send_notification(tcore_plugin_ref_server(p), co_modem, TNOTI_MODEM_POWER, sizeof(struct tnoti_modem_power), &modem_power); return TRUE; } -static void _modem_subscribe_events(TcorePlugin *plugin) -{ - dbg("Entry"); - - /* XCALLSTAT subscription */ - prepare_and_send_pending_request(plugin, "call", "at+xcallstat=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription); - - /* XSIMSTATE subscription */ - prepare_and_send_pending_request(plugin, "sim", "at+xsimstate=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription); - - prepare_and_send_pending_request(plugin, "umts_sms", "at+xsimstate=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription); - prepare_and_send_pending_request(plugin, "modem", "at+xsimstate=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription); - - /* CREG subscription */ - prepare_and_send_pending_request(plugin, "umts_network", "at+creg=2", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription); - - /* CGREG subscription */ - prepare_and_send_pending_request(plugin, "umts_network", "at+cgreg=2", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription); - - /* Allow automatic time Zone updation via NITZ */ - prepare_and_send_pending_request(plugin, "umts_network", "at+ctzu=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription); - - /* TZ, time & daylight changing event reporting subscription */ - prepare_and_send_pending_request(plugin, "umts_network", "at+ctzr=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription); - - /* XMER subscription */ - prepare_and_send_pending_request(plugin, "umts_network", "at+xmer=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription); - - /* CGEREP subscription */ - prepare_and_send_pending_request(plugin, "umts_ps", "at+cgerep=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription); - - /* XDATASTAT subscription */ - prepare_and_send_pending_request(plugin, "umts_ps", "at+xdatastat=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription); - - /* CSSN subscription */ - prepare_and_send_pending_request(plugin, "call", "at+cssn=1,1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription); - - /* CUSD subscription */ - prepare_and_send_pending_request(plugin, "call", "at+cusd=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription); - - /* XDNS subscription */ - prepare_and_send_pending_request(plugin, "umts_ps", "at+xdns=1,1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription); - - /* CLIP subscription */ - prepare_and_send_pending_request(plugin, "call", "at+clip=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription); - - /*CMEE subscription for ps*/ - prepare_and_send_pending_request(plugin, "umts_ps", "at+cmee=2", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription); - - /*CMEE subscription for sms*/ - prepare_and_send_pending_request(plugin, "umts_sms", "at+cmee=2", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription); - - /*incoming sms,cb,status report subscription*/ - prepare_and_send_pending_request(plugin, "umts_sms", "at+cnmi=1,2,2,1,0", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription); - - /* XBCSTAT subscription */ - prepare_and_send_pending_request(plugin, "sap", "at+xbcstat=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription); - /* AGPS- assist data and reset assist data subscription */ - prepare_and_send_pending_request(plugin, "gps", "at+cposr=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription); - - prepare_and_send_pending_request(plugin, "gps", "at+xcposr=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription); - - /* text/pdu mode subscription*/ - prepare_and_send_pending_request(plugin, "umts_sms", "at+cmgf=0", NULL, TCORE_AT_NO_RESULT, on_response_last_bootup_subscription); - - dbg("Exit"); - return; -} - - -static void on_response_setupmux(TcorePending *p, int data_len, const void *data, void *user_data) -{ - TcorePlugin *plugin = NULL; - TcoreHal *hal = NULL; - TReturn ret; - - dbg("Entry"); - - /* IMC Plugin dereferenced from pending request */ - plugin = tcore_pending_ref_plugin(p); - - /* Actual HAL - like svnet(2) */ - hal = (TcoreHal *) user_data; - - /* Initialize CMUX */ - ret = tcore_cmux_init(plugin, hal); - if (TCORE_RETURN_SUCCESS == ret) { - dbg("Successfully initialized CMUX"); - } else { - err("Failed to initialize CMUX"); - } - - dbg("Exit"); - return; -} - - - -static void setup_mux(CoreObject *o) -{ - TcoreHal *hal = NULL; - TcorePending *pending = NULL; - - dbg("Entered"); - - /* HAL has type itself, - * e.g.) TCORE_HAL_MODE_AT - */ - hal = tcore_object_get_hal(o); - - pending = tcore_at_pending_new(o, "AT+CMUX=0,0,,1509,10,3,30,,", "+CMUX", TCORE_AT_NO_RESULT, on_response_setupmux, hal); - - tcore_pending_set_send_callback(pending, on_confirmation_modem_message_send, NULL); - - /* Send callback */ - tcore_hal_send_request(hal, pending); - - dbg("Exit"); - return; -} - - -static gboolean on_event_mux_channel_up(CoreObject *o, const void *event_info, void *user_data) -{ - TcorePlugin *plugin = NULL; - - dbg("Entry"); - - plugin = (TcorePlugin *) user_data; - _modem_subscribe_events(plugin); - dbg("Exit"); - return TRUE; -} - - -static void on_response_enable_logging(TcorePending *p, int data_len, const void *data, void *user_data) -{ - const TcoreATResponse *resp = data; - TcorePlugin *plugin = NULL; - - plugin = tcore_pending_ref_plugin(p); - - /* DELETE ME: only for DEBUG */ - if (!resp) - dbg("no data"); - - dbg("response...(result = %d, final_response = '%s')", resp->success, resp->final_response); - - if (resp->success) { - dbg("RESPONSE OK"); - dbg("Enabling CP logging is success !!!\n"); - } else { - dbg("RESPONSE NOK"); - dbg("Enabling CP logging is failed !!!\n"); - } - - dbg("Calling setup_mux"); - setup_mux(tcore_pending_ref_core_object(p)); - - - dbg("Exit"); - return; -} - -static void _send_enable_logging_command(CoreObject *o) -{ - TcoreATRequest *req = NULL; - TcoreHal *hal = NULL; - TcorePending *pending = NULL; - TReturn ret = 0; - - /* DLELTE ME */ - dbg("Send Trace enabling command for CP logging. \n"); - - if (!o) { - dbg("Co-object is Null !!\n"); - // goto error; - } - - hal = tcore_object_get_hal(o); - pending = tcore_pending_new(o, 0); - req = tcore_at_request_new("at+xsystrace=1,\"digrf=1;bb_sw=1;3g_sw=1\",\"digrf=0x84\",\"oct=4\";+xsystrace=11;+trace=1", NULL, TCORE_AT_NO_RESULT); - - dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd)); - - tcore_pending_set_request_data(pending, 0, req); - tcore_pending_set_response_callback(pending, on_response_enable_logging, hal); - tcore_pending_set_send_callback(pending, on_confirmation_modem_message_send, NULL); - - ret = tcore_hal_send_request(hal, pending); - if (ret != TCORE_RETURN_SUCCESS) - dbg("tcore_hal_send_request fail !!! (hal: 0x%x, pending: 0x%x)\n", hal, pending); -} - -static void on_response_poweron(TcorePending *p, int data_len, const void *data, void *user_data) -{ - const TcoreATResponse *resp = data; - GSList *tokens = NULL; - const char *line = NULL; - gboolean bpoweron = FALSE; - int response = 0; - - if (resp->success) { - dbg("RESPONSE OK"); - /* Parse AT Response */ - if (resp->lines) { - line = (const char *) resp->lines->data; - tokens = tcore_at_tok_new(line); - if (g_slist_length(tokens) != 1) { - dbg("invalid message"); - bpoweron = FALSE; - goto error; - } - } - - response = atoi(g_slist_nth_data(tokens, 0)); - - dbg("CPAS: response %d", response); - - switch (response) { - case CPAS_RES_READY: - case CPAS_RES_RINGING: - case CPAS_RES_CALL_PROGRESS: - case CPAS_RES_ASLEEP: - bpoweron = TRUE; - break; - - case CPAS_RES_UNAVAIL: - case CPAS_RES_UNKNOWN: - default: - dbg("value is unvail/unknown - but CP responded - proceed poweron"); - // bpoweron = FALSE; - bpoweron = TRUE; - break; - } - } else { - dbg("CPAS: RESPONSE NOK"); - bpoweron = FALSE; - } - -error: - /* DELE ME: AT request & response are freed after AT processing in HAL. - * ref.) _emit_pending_response (libtcore/src/at.c) - */ - if (tokens != NULL) - tcore_at_tok_free(tokens); - - if (bpoweron == TRUE) { - dbg("Power on NOTI received, (pending: 0x%x, co: 0x%x)\n", p, tcore_pending_ref_core_object(p)); - - _send_enable_logging_command(tcore_pending_ref_core_object(p)); - } else { - dbg("CP is not ready, let us send CPAS once again"); - s_modem_send_poweron(tcore_object_ref_plugin(tcore_pending_ref_core_object(p))); - } - return; -} - static TReturn power_off(CoreObject *o, UserRequest *ur) { TcoreHal *hal = NULL; @@ -894,96 +590,48 @@ static struct tcore_modem_operations modem_ops = { .dun_pin_ctrl = NULL, }; -gboolean s_modem_init(TcorePlugin *p, TcoreHal *h) +gboolean s_modem_init(TcorePlugin *cp, CoreObject *co_modem) { - CoreObject *o = NULL; - GQueue *work_queue = NULL; - TelMiscVersionInformation *vi_property = NULL; - TelMiscSNInformation *imei_property = NULL; - TelMiscSNInformation *sn_property = NULL; + TelMiscVersionInformation *vi_property; + TelMiscSNInformation *imei_property; + TelMiscSNInformation *sn_property; - o = tcore_modem_new(p, "modem", &modem_ops, h); - if (!o) - return FALSE; - - work_queue = g_queue_new(); - tcore_object_link_user_data(o, work_queue); + dbg("Enter"); - vi_property = calloc(sizeof(TelMiscVersionInformation), 1); - tcore_plugin_link_property(p, "VERSION", vi_property); + tcore_modem_override_ops(co_modem, &modem_ops); - imei_property = calloc(sizeof(TelMiscSNInformation), 1); - tcore_plugin_link_property(p, "IMEI", imei_property); + vi_property = g_try_new0(TelMiscVersionInformation, 1); + tcore_plugin_link_property(cp, "VERSION", vi_property); - sn_property = calloc(sizeof(TelMiscSNInformation), 1); - tcore_plugin_link_property(p, "SN", sn_property); + imei_property = g_try_new0(TelMiscSNInformation, 1); + tcore_plugin_link_property(cp, "IMEI", imei_property); - dbg("Registerind for CMUX-UP event"); - tcore_object_add_callback(o, "CMUX-UP", on_event_mux_channel_up, p); + sn_property = g_try_new0(TelMiscSNInformation, 1); + tcore_plugin_link_property(cp, "SN", sn_property); dbg("Registering for +XSIM event"); - tcore_object_add_callback(o, "+XSIM", on_event_bootup_sim_status, NULL); - - return TRUE; -} + tcore_object_override_callback(co_modem, "+XSIM", on_event_bootup_sim_status, NULL); -void s_modem_exit(TcorePlugin *p) -{ - CoreObject *o = NULL; - GQueue *work_queue = NULL; - TelMiscVersionInformation *vi_property = NULL; - TelMiscSNInformation *imei_property = NULL; - TelMiscSNInformation *sn_property = NULL; - - if (!p) - return; - - o = tcore_plugin_ref_core_object(p, "modem"); - - work_queue = tcore_object_ref_user_data(o); - g_queue_free(work_queue); - - vi_property = tcore_plugin_ref_property(p, "VERSION"); - if (vi_property) - free(vi_property); - - imei_property = tcore_plugin_ref_property(p, "IMEI"); - if (imei_property) - free(imei_property); - - sn_property = tcore_plugin_ref_property(p, "SN"); - if (sn_property) - free(sn_property); + dbg("Exit"); - tcore_modem_free(o); - return; + return TRUE; } -gboolean s_modem_send_poweron(TcorePlugin *p) +void s_modem_exit(TcorePlugin *cp, CoreObject *co_modem) { - TcoreHal *hal; - TcoreATRequest *req; - TcorePending *pending = NULL; - CoreObject *o; + TelMiscVersionInformation *vi_property; + TelMiscSNInformation *imei_property; + TelMiscSNInformation *sn_property; + TcorePlugin *plugin = tcore_object_ref_plugin(co_modem); - o = tcore_plugin_ref_core_object(p, "modem"); - hal = tcore_object_get_hal(o); - - pending = tcore_pending_new(o, 0); - - req = tcore_at_request_new("AT+CPAS", "+CPAS", TCORE_AT_SINGLELINE); - - dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd)); + vi_property = tcore_plugin_ref_property(plugin, "VERSION"); + g_free(vi_property); - tcore_pending_set_timeout(pending, 10); - tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT); - tcore_pending_set_timeout_callback(pending, on_timeout_modem_poweron, hal); + imei_property = tcore_plugin_ref_property(plugin, "IMEI"); + g_free(imei_property); - tcore_pending_set_request_data(pending, 0, req); - tcore_pending_set_response_callback(pending, on_response_poweron, hal); - tcore_pending_set_send_callback(pending, on_confirmation_modem_message_send, NULL); - - tcore_hal_send_request(hal, pending); + sn_property = tcore_plugin_ref_property(plugin, "SN"); + g_free(sn_property); - return TRUE; + dbg("Exit"); } diff --git a/src/s_network.c b/src/s_network.c index 7c5e8d9..e4aab10 100644 --- a/src/s_network.c +++ b/src/s_network.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -118,18 +119,16 @@ static void on_confirmation_network_message_send(TcorePending *p, gboolean resul } } -static void nwk_prepare_and_send_pending_request(TcorePlugin *plugin, char *co_name, const char *at_cmd, const char *prefix, enum tcore_at_command_type at_cmd_type, UserRequest *ur, TcorePendingResponseCallback callback) +static void nwk_prepare_and_send_pending_request(CoreObject *co, const char *at_cmd, const char *prefix, enum tcore_at_command_type at_cmd_type, UserRequest *ur, TcorePendingResponseCallback callback) { TcoreATRequest *req = NULL; TcoreHal *hal; - CoreObject *o = NULL; TcorePending *pending = NULL; TReturn ret; - o = tcore_plugin_ref_core_object(plugin, co_name); - hal = tcore_object_get_hal(o); + hal = tcore_object_get_hal(co); - pending = tcore_pending_new(o, 0); + pending = tcore_pending_new(co, 0); req = tcore_at_request_new(at_cmd, prefix, at_cmd_type); dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd)); @@ -244,23 +243,18 @@ static enum telephony_network_service_type _get_service_type(enum telephony_netw static void _ps_set(TcorePlugin *p, int status) { - GSList *co_list = NULL; + CoreObject *co_ps; - co_list = tcore_plugin_get_core_objects_bytype(p, CORE_OBJECT_TYPE_PS); - do { - CoreObject *o = NULL; - o = (CoreObject *) co_list->data; - if (!o) - break; - - if (status == NETWORK_SERVICE_DOMAIN_STATUS_FULL) { - tcore_ps_set_online(o, TRUE); - } else { - tcore_ps_set_online(o, FALSE); - } - } while ((co_list = g_slist_next(co_list))); + co_ps = tcore_plugin_ref_core_object(p, CORE_OBJECT_TYPE_PS); + if (co_ps == NULL) { + err("No PS Core Object on plugin"); + return; + } - g_slist_free(co_list); + if (status == NETWORK_SERVICE_DOMAIN_STATUS_FULL) + tcore_ps_set_online(co_ps, TRUE); + else + tcore_ps_set_online(co_ps, FALSE); } static void on_timeout_search_network(TcorePending *p, void *user_data) @@ -1623,7 +1617,7 @@ minutes, seconds.*/ dbg("new pending(AT+XOPS=0/5/6 for Nitz PLMN name)"); /* Get NITZ name and plmn_id via AT+XCOPS = 0/5/6 */ - nwk_prepare_and_send_pending_request(tcore_object_ref_plugin(o), "umts_network", "AT+XCOPS=0;+XCOPS=5;+XCOPS=6", "+XCOPS", TCORE_AT_MULTILINE, ur, on_response_get_nitz_name); + nwk_prepare_and_send_pending_request(o, "AT+XCOPS=0;+XCOPS=5;+XCOPS=6", "+XCOPS", TCORE_AT_MULTILINE, ur, on_response_get_nitz_name); } else { dbg("line is NULL"); } @@ -2143,7 +2137,7 @@ static TReturn get_serving_network(CoreObject *o, UserRequest *ur) dbg("new pending(AT+COPS?)"); - nwk_prepare_and_send_pending_request(tcore_object_ref_plugin(o), "umts_network", "AT+COPS=3,2;+COPS?;+COPS=3,0;+COPS?", "+COPS", TCORE_AT_MULTILINE, ur, on_response_get_serving_network); + nwk_prepare_and_send_pending_request(o, "AT+COPS=3,2;+COPS?;+COPS=3,0;+COPS?", "+COPS", TCORE_AT_MULTILINE, ur, on_response_get_serving_network); return TCORE_RETURN_SUCCESS; } @@ -2165,33 +2159,29 @@ static struct tcore_network_operations network_ops = { .get_serving_network = get_serving_network, }; -gboolean s_network_init(TcorePlugin *p, TcoreHal *h) +gboolean s_network_init(TcorePlugin *cp, CoreObject *co_network) { - CoreObject *o = NULL; + dbg("Enter"); - o = tcore_network_new(p, "umts_network", &network_ops, h); - if (!o) - return FALSE; + tcore_network_override_ops(co_network, &network_ops); - tcore_object_add_callback(o, "+CREG", on_event_cs_network_regist, NULL); - tcore_object_add_callback(o, "+CGREG", on_event_ps_network_regist, NULL); - tcore_object_add_callback(o, "+XCIEV", on_event_network_icon_info, NULL); + tcore_object_override_callback(co_network, "+CREG", on_event_cs_network_regist, NULL); + tcore_object_override_callback(co_network, "+CGREG", on_event_ps_network_regist, NULL); + tcore_object_override_callback(co_network, "+XCIEV", on_event_network_icon_info, NULL); /* +CTZV: ,