4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Hayoon Ko <hayoon.ko@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
24 #include <sys/utsname.h>
28 #include <core_object.h>
32 #include "s_network.h"
41 #include "s_phonebook.h"
44 static gboolean on_load()
51 static void on_confirmation_modem_message_send(TcorePending *p,
55 dbg("msg out from queue");
57 dbg("%s", result == FALSE ? "SEND FAIL" : "SEND OK");
60 static void on_response_bootup_subscription(TcorePending *p, int data_len, const void *data, void *user_data)
62 TcorePlugin *plugin = user_data;
63 const TcoreATResponse *resp = data;
67 if (resp->success > 0) {
74 modem_power_on(plugin);
77 static void modem_subscribe_events(TcorePlugin *plugin)
79 CoreObject *co_call = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_CALL);
80 CoreObject *co_sim = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SIM);
81 CoreObject *co_sms = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SMS);
82 CoreObject *co_modem = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_MODEM);
83 CoreObject *co_network = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_NETWORK);
84 CoreObject *co_ps = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_PS);
85 CoreObject *co_sap = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SAP);
86 CoreObject *co_gps = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_GPS);
90 /* XCALLSTAT subscription */
91 tcore_prepare_and_send_at_request(co_call, "at+xcallstat=1", NULL, TCORE_AT_NO_RESULT, NULL,
92 on_response_bootup_subscription, NULL,
93 on_confirmation_modem_message_send, NULL);
95 /* XSIMSTATE subscription */
96 tcore_prepare_and_send_at_request(co_sim, "at+xsimstate=1", NULL, TCORE_AT_NO_RESULT, NULL,
97 on_response_bootup_subscription, NULL,
98 on_confirmation_modem_message_send, NULL);
100 tcore_prepare_and_send_at_request(co_sms, "at+xsimstate=1", NULL, TCORE_AT_NO_RESULT, NULL,
101 on_response_bootup_subscription, NULL,
102 on_confirmation_modem_message_send, NULL);
103 tcore_prepare_and_send_at_request(co_modem, "at+xsimstate=1", NULL, TCORE_AT_NO_RESULT, NULL,
104 on_response_bootup_subscription, NULL,
105 on_confirmation_modem_message_send, NULL);
107 /* CREG subscription */
108 tcore_prepare_and_send_at_request(co_network, "at+creg=2", NULL, TCORE_AT_NO_RESULT, NULL,
109 on_response_bootup_subscription, NULL,
110 on_confirmation_modem_message_send, NULL);
112 /* CGREG subscription */
113 tcore_prepare_and_send_at_request(co_network, "at+cgreg=2", NULL, TCORE_AT_NO_RESULT, NULL,
114 on_response_bootup_subscription, NULL,
115 on_confirmation_modem_message_send, NULL);
117 /* Allow automatic time Zone updation via NITZ */
118 tcore_prepare_and_send_at_request(co_network, "at+ctzu=1", NULL, TCORE_AT_NO_RESULT, NULL,
119 on_response_bootup_subscription, NULL,
120 on_confirmation_modem_message_send, NULL);
122 /* TZ, time & daylight changing event reporting subscription */
123 tcore_prepare_and_send_at_request(co_network, "at+ctzr=1", NULL, TCORE_AT_NO_RESULT, NULL,
124 on_response_bootup_subscription, NULL,
125 on_confirmation_modem_message_send, NULL);
127 /* XMER subscription */
128 tcore_prepare_and_send_at_request(co_network, "at+xmer=1", NULL, TCORE_AT_NO_RESULT, NULL,
129 on_response_bootup_subscription, NULL,
130 on_confirmation_modem_message_send, NULL);
132 /* CGEREP subscription */
133 tcore_prepare_and_send_at_request(co_ps, "at+cgerep=1", NULL, TCORE_AT_NO_RESULT, NULL,
134 on_response_bootup_subscription, NULL,
135 on_confirmation_modem_message_send, NULL);
137 /* XDATASTAT subscription */
138 tcore_prepare_and_send_at_request(co_ps, "at+xdatastat=1", NULL, TCORE_AT_NO_RESULT, NULL,
139 on_response_bootup_subscription, NULL,
140 on_confirmation_modem_message_send, NULL);
142 /* CSSN subscription */
143 tcore_prepare_and_send_at_request(co_call, "at+cssn=1,1", NULL, TCORE_AT_NO_RESULT, NULL,
144 on_response_bootup_subscription, NULL,
145 on_confirmation_modem_message_send, NULL);
147 /* CUSD subscription */
148 tcore_prepare_and_send_at_request(co_call, "at+cusd=1", NULL, TCORE_AT_NO_RESULT, NULL,
149 on_response_bootup_subscription, NULL,
150 on_confirmation_modem_message_send, NULL);
152 /* XDNS subscription */
153 tcore_prepare_and_send_at_request(co_ps, "at+xdns=1,1", NULL, TCORE_AT_NO_RESULT, NULL,
154 on_response_bootup_subscription, NULL,
155 on_confirmation_modem_message_send, NULL);
157 /* CLIP subscription */
158 tcore_prepare_and_send_at_request(co_call, "at+clip=1", NULL, TCORE_AT_NO_RESULT, NULL,
159 on_response_bootup_subscription, NULL,
160 on_confirmation_modem_message_send, NULL);
162 /*CMEE subscription for ps*/
163 tcore_prepare_and_send_at_request(co_ps, "at+cmee=2", NULL, TCORE_AT_NO_RESULT, NULL,
164 on_response_bootup_subscription, NULL,
165 on_confirmation_modem_message_send, NULL);
167 /*CMEE subscription for sms*/
168 tcore_prepare_and_send_at_request(co_sms, "at+cmee=2", NULL, TCORE_AT_NO_RESULT, NULL,
169 on_response_bootup_subscription, NULL,
170 on_confirmation_modem_message_send, NULL);
172 /*incoming sms,cb,status report subscription*/
173 tcore_prepare_and_send_at_request(co_sms, "at+cnmi=1,2,2,1,0", NULL, TCORE_AT_NO_RESULT, NULL,
174 on_response_bootup_subscription, NULL,
175 on_confirmation_modem_message_send, NULL);
177 /* XBCSTAT subscription */
178 tcore_prepare_and_send_at_request(co_sap, "at+xbcstat=1", NULL, TCORE_AT_NO_RESULT, NULL,
179 on_response_bootup_subscription, NULL,
180 on_confirmation_modem_message_send, NULL);
181 /* AGPS- assist data and reset assist data subscription */
182 tcore_prepare_and_send_at_request(co_gps, "at+cposr=1", NULL, TCORE_AT_NO_RESULT, NULL,
183 on_response_bootup_subscription, NULL,
184 on_confirmation_modem_message_send, NULL);
186 tcore_prepare_and_send_at_request(co_gps, "at+xcposr=1", NULL, TCORE_AT_NO_RESULT, NULL,
187 on_response_bootup_subscription, NULL,
188 on_confirmation_modem_message_send, NULL);
190 /* text/pdu mode subscription*/
191 tcore_prepare_and_send_at_request(co_sms, "at+cmgf=0", NULL, TCORE_AT_NO_RESULT, NULL,
192 on_response_bootup_subscription, plugin,
193 on_confirmation_modem_message_send, NULL);
198 struct object_initializer init_table = {
199 .modem_init = s_modem_init,
200 .sim_init = s_sim_init,
201 .sat_init = s_sat_init,
202 .sap_init = s_sap_init,
203 .network_init = s_network_init,
204 .ps_init = s_ps_init,
205 .call_init = s_call_init,
206 .ss_init = s_ss_init,
207 .sms_init = s_sms_init,
208 .phonebook_init = s_phonebook_init,
209 .gps_init = s_gps_init,
212 struct object_deinitializer deinit_table = {
213 .modem_deinit = s_modem_exit,
214 .sim_deinit = s_sim_exit,
215 .sat_deinit = s_sat_exit,
216 .sap_deinit = s_sap_exit,
217 .network_deinit = s_network_exit,
218 .ps_deinit = s_ps_exit,
219 .call_deinit = s_call_exit,
220 .ss_deinit = s_ss_exit,
221 .sms_deinit = s_sms_exit,
222 .phonebook_deinit = s_phonebook_exit,
223 .gps_deinit = s_gps_exit,
226 static gboolean on_init(TcorePlugin *p)
231 if (tcore_object_init_objects(p, &init_table)
232 != TCORE_RETURN_SUCCESS) {
233 err("Failed to initialize Core Objects");
239 modem_subscribe_events(p);
244 static void on_unload(TcorePlugin *p)
249 tcore_object_deinit_objects(p, &deinit_table);
254 struct tcore_plugin_define_desc plugin_define_desc = {
256 .priority = TCORE_PLUGIN_PRIORITY_MID,