Tizen 2.1 base
[platform/core/telephony/tel-plugin-imc.git] / packaging / 0015-Change-the-way-imc-plugin-is-initialized.patch
1 From 658e94ca29da1e7fc52b036a4dc231db1500f3ff Mon Sep 17 00:00:00 2001
2 From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
3 Date: Mon, 8 Oct 2012 15:42:12 +0200
4 Subject: [PATCH 15/23] Change the way imc plugin is initialized
5 Content-Type: text/plain; charset="utf-8"
6 Content-Transfer-Encoding: 8bit
7
8 Conflicts:
9         src/desc.c
10         src/s_modem.c
11 ---
12  src/desc.c    |   90 ++++++++++++++++++---------------------------------------
13  src/s_modem.c |   69 +------------------------------------------
14  2 files changed, 29 insertions(+), 130 deletions(-)
15
16 diff --git a/src/desc.c b/src/desc.c
17 index 7a5ef93..0cf4542 100644
18 --- a/src/desc.c
19 +++ b/src/desc.c
20 @@ -44,51 +44,6 @@
21  #include "s_gps.h"
22  
23  static char *cp_name;
24 -static int cp_count = 0;
25 -
26 -#define MAX_CP_QUERY_COUNT 60
27 -
28 -static gboolean _query_cp_state(gpointer data)
29 -{
30 -       gboolean power_state = FALSE;
31 -       TcorePlugin *p = NULL;
32 -       CoreObject* obj = NULL;
33 -       TcoreHal* h = NULL;
34 -
35 -       p = (TcorePlugin*)data;
36 -
37 -       if(cp_count > MAX_CP_QUERY_COUNT){
38 -               dbg("cp query counter exceeds MAX_CP_QUERY_COUNT");
39 -               return FALSE;
40 -       }
41 -       obj = tcore_plugin_ref_core_object(p, "modem");
42 -       h = tcore_object_get_hal(obj);
43 -       power_state = tcore_hal_get_power_state(h);
44 -
45 -       if(TRUE == power_state){
46 -               dbg("CP READY");
47 -               s_modem_send_poweron(p);
48 -               return FALSE;
49 -       }
50 -       else{
51 -               dbg("CP NOT READY, cp_count :%d", cp_count);
52 -               cp_count++;
53 -               return TRUE;
54 -       }
55 -}
56 -
57 -static enum tcore_hook_return on_hal_send(TcoreHal *hal, unsigned int data_len, void *data, void *user_data)
58 -{
59 -       hook_hex_dump(TX, data_len, data);
60 -       return TCORE_HOOK_RETURN_CONTINUE;
61 -}
62 -
63 -static void on_hal_recv(TcoreHal *hal, unsigned int data_len, const void *data, void *user_data)
64 -{
65 -       msg("=== RX data DUMP =====");
66 -       util_hex_dump("          ", data_len, data);
67 -       msg("=== RX data DUMP =====");
68 -}
69  
70  static gboolean on_load()
71  {
72 @@ -126,7 +81,7 @@ static int _get_cp_name(char **name)
73         dbg("u.__domainname : [ %s ]", u.__domainname);
74         dbg("u.machine : [ %s ]", u.machine);
75         dbg("u.release : [ %s ]", u.release);
76 -       dbg("u.sysname : [ %s ]", u.sysname);S
77 +       dbg("u.sysname : [ %s ]", u.sysname);
78         dbg("u.version : [ %s ]", u.version);
79  
80         /* By default, SUNRISE IMC modem is returned */
81 @@ -165,11 +120,35 @@ static int _get_cp_name(char **name)
82         return 0;
83  }
84  
85 +static void on_hal_set_power(TcoreHal *hal, void *user_data)
86 +{
87 +       TcorePlugin *p = user_data;
88 +       CoreObject *o;
89 +
90 +       dbg("Entry");
91 +
92 +       s_modem_init(p, hal);
93 +       s_sim_init(p, hal);
94 +       s_sat_init(p, hal);
95 +       s_network_init(p, hal);
96 +       s_ps_init(p, hal);
97 +       s_call_init(p, hal);
98 +       s_ss_init(p, hal);
99 +       s_sms_init(p, hal);
100 +       s_gps_init(p, hal);
101 +
102 +       o = tcore_plugin_ref_core_object(p, "modem");
103 +       tcore_server_send_notification(tcore_plugin_ref_server(p), o, TNOTI_MODEM_ADDED, 0, NULL);
104 +
105 +       s_modem_send_poweron(p);
106 +
107 +       dbg("Exit");
108 +}
109 +
110  static gboolean on_init(TcorePlugin *p)
111  {
112         TcoreHal *h;
113         struct global_data *gd;
114 -       // char *cp_name = 0;
115         int len = 0;
116  
117         if (!p)
118 @@ -208,25 +187,12 @@ static gboolean on_init(TcorePlugin *p)
119  
120         tcore_plugin_link_user_data(p, gd);
121  
122 -       tcore_hal_add_send_hook(h, on_hal_send, p);
123 -       tcore_hal_add_recv_callback(h, on_hal_recv, p);
124 +       g_free(cp_name);
125  
126 -       s_modem_init(p, h);
127 -       s_sim_init(p, h);
128 -       s_sat_init(p, h);
129 -       s_network_init(p, h);
130 -       s_ps_init(p, h);
131 -       s_call_init(p, h);
132 -       s_ss_init(p, h);
133 -       s_sms_init(p, h);
134 -       s_phonebook_init(p, h);
135 -       s_sap_init(p, h);
136 +       tcore_hal_set_power(h, TRUE, on_hal_set_power, p);
137  
138         g_free(cp_name);
139  
140 -       tcore_hal_set_power(h, TRUE);
141 -       //wait until CP is ready
142 -       g_timeout_add_full(G_PRIORITY_HIGH,500,_query_cp_state, p, 0 );
143         return TRUE;
144  }
145  
146 diff --git a/src/s_modem.c b/src/s_modem.c
147 index 6212467..47c6c63 100644
148 --- a/src/s_modem.c
149 +++ b/src/s_modem.c
150 @@ -616,69 +616,6 @@ static void _modem_subscribe_events(TcorePlugin *plugin)
151         return;
152  }
153  
154 -
155 -static void on_response_setupmux(TcorePending *p, int data_len, const void *data, void *user_data)
156 -{
157 -       TcorePlugin *plugin = NULL;
158 -       TcoreHal *hal = NULL;
159 -       TReturn ret;
160 -       dbg("Entry");
161 -
162 -       /* IMC Plugin dereferenced from pending request */
163 -       plugin = tcore_pending_ref_plugin(p);
164 -
165 -       /* Actual HAL - like svnet(2) */
166 -       hal = (TcoreHal *) user_data;
167 -
168 -       /* Initialize CMUX */
169 -       ret = tcore_cmux_init(plugin, hal);
170 -       if (TCORE_RETURN_SUCCESS == ret) {
171 -               dbg("Successfully initialized CMUX");
172 -       } else {
173 -               err("Failed to initialize CMUX");
174 -       }
175 -
176 -       dbg("Exit");
177 -       return;
178 -}
179 -
180 -
181 -
182 -static void setup_mux(CoreObject *o)
183 -{
184 -       TcoreHal *hal = NULL;
185 -       TcorePending *pending = NULL;
186 -       dbg("Entered");
187 -
188 -       /* HAL has type itself,
189 -        * e.g.) TCORE_HAL_MODE_AT
190 -        */
191 -       hal = tcore_object_get_hal(o);
192 -
193 -       pending = tcore_at_pending_new(o, "AT+CMUX=0,0,,1509,10,3,30,,", "+CMUX", TCORE_AT_NO_RESULT, on_response_setupmux, hal);
194 -
195 -       tcore_pending_set_send_callback(pending, on_confirmation_modem_message_send, NULL);
196 -
197 -       /* Send callback */
198 -       tcore_hal_send_request(hal, pending);
199 -
200 -       dbg("Exit");
201 -       return;
202 -}
203 -
204 -
205 -static gboolean on_event_mux_channel_up(CoreObject *o, const void *event_info, void *user_data)
206 -{
207 -       TcorePlugin *plugin = NULL;
208 -       dbg("Entry");
209 -
210 -       plugin = (TcorePlugin *) user_data;
211 -       _modem_subscribe_events(plugin);
212 -       dbg("Exit");
213 -       return TRUE;
214 -}
215 -
216 -
217  static void on_response_enable_logging(TcorePending *p, int data_len, const void *data, void *user_data)
218  {
219         const TcoreATResponse *resp = data;
220 @@ -700,8 +637,7 @@ static void on_response_enable_logging(TcorePending *p, int data_len, const void
221                 dbg("Enabling CP logging is failed !!!\n");
222         }
223  
224 -       dbg("Calling setup_mux");
225 -       setup_mux(tcore_pending_ref_core_object(p));
226 +       _modem_subscribe_events(plugin);
227  
228         /* sets the powersaving-mode */
229         prepare_and_send_pending_request(plugin, "modem", "at+xpow=0,0,0", NULL, TCORE_AT_NO_RESULT, NULL);
230 @@ -961,9 +897,6 @@ gboolean s_modem_init(TcorePlugin *p, TcoreHal *h)
231         sn_property = calloc(sizeof(TelMiscSNInformation), 1);
232         tcore_plugin_link_property(p, "SN", sn_property);
233  
234 -       dbg("Registerind for CMUX-UP event");
235 -       tcore_object_add_callback(o, "CMUX-UP", on_event_mux_channel_up, p);
236 -
237         dbg("Registering for +XSIM event");
238         tcore_object_add_callback(o, "+XSIM", on_event_bootup_sim_status, NULL);
239  
240 -- 
241 1.7.10.4
242