summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hirt <daniel.hirt@samsung.com>2015-09-13 09:40:44 +0300
committerDaniel Hirt <daniel.hirt@samsung.com>2015-09-13 09:40:44 +0300
commit27f70ecf157afe2227dfb3fe4d6a7b05c460d273 (patch)
tree2a48a73830e363488fa622350d4d2016d7a03d81
parent1f188e95cc12e7ef33d34a7baac82a9c540aae67 (diff)
Complete code for SDB mode
-rw-r--r--src/client.c2
-rw-r--r--src/debugd.c57
2 files changed, 37 insertions, 22 deletions
diff --git a/src/client.c b/src/client.c
index 510c982..a9b01f8 100644
--- a/src/client.c
+++ b/src/client.c
@@ -106,7 +106,7 @@ _init_bridge(void)
106 * Recieved messages should contain ASCII text. Send back UPPERCASE 106 * Recieved messages should contain ASCII text. Send back UPPERCASE
107 * conversion of these messages */ 107 * conversion of these messages */
108 108
109 const char *cmd_bridge = "sdb shell /home/developer/bridge"; 109 const char *cmd_bridge = "sdb shell /home/developer/debugd bridge";
110 const char *cmd_test = "./debugd bridge test"; 110 const char *cmd_test = "./debugd bridge test";
111 111
112 const char *cmd; 112 const char *cmd;
diff --git a/src/debugd.c b/src/debugd.c
index 1a535f2..2431222 100644
--- a/src/debugd.c
+++ b/src/debugd.c
@@ -37,9 +37,20 @@ static Eina_Bool
37_cb_client_data(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) 37_cb_client_data(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
38{ 38{
39 IPC_HEAD(Data); 39 IPC_HEAD(Data);
40
41 char tmp[1024];
42 char *c;
43
44 strncpy(tmp, e->data, e->size);
45
46#if 1
47 for (c = tmp; *c != 0; c++)
48 *c = toupper(toupper(*c));
49#endif
50
40 if (e->major == 1) 51 if (e->major == 1)
41 { 52 {
42 ecore_ipc_client_send(e->client, 1, 0, 0, 0, 0, NULL, 0); 53 ecore_ipc_client_send(e->client, 1, 0, 0, 0, 0, tmp, e->size);
43 } 54 }
44 return ECORE_CALLBACK_DONE; 55 return ECORE_CALLBACK_DONE;
45} 56}
@@ -78,18 +89,14 @@ _server_shutdown(void)
78static Eina_Bool 89static Eina_Bool
79_server_init(void) 90_server_init(void)
80{ 91{
81 fprintf(stdout, "Initializing server\n");
82 if (ipc) return EINA_TRUE; 92 if (ipc) return EINA_TRUE;
83 93
84 ipc = ecore_ipc_server_add(ECORE_IPC_LOCAL_USER, "debugd", 0, NULL); 94 ipc = ecore_ipc_server_add(ECORE_IPC_LOCAL_USER, "debugd", 0, NULL);
85 if (!ipc) 95 if (!ipc)
86 { 96 {
87 fprintf(stdout, "Failed raising server");
88 _server_shutdown(); 97 _server_shutdown();
89 return EINA_FALSE; 98 return EINA_FALSE;
90 } 99 }
91 fprintf(stdout, "Server initialized successfully on 0 port\n");
92
93 hnd_add = ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_ADD, 100 hnd_add = ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_ADD,
94 _cb_client_add, NULL); 101 _cb_client_add, NULL);
95 hnd_del = ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DEL, 102 hnd_del = ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DEL,
@@ -110,7 +117,6 @@ typedef enum
110Eina_Bool 117Eina_Bool
111_daemon(Daemon_Mode mode) 118_daemon(Daemon_Mode mode)
112{ 119{
113 fprintf(stdout, "Daemon Mode!!!\n");
114#if 1 120#if 1
115 if (!_server_init()) 121 if (!_server_init())
116 { 122 {
@@ -167,9 +173,14 @@ static Eina_Bool
167_cb_server_data(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) 173_cb_server_data(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
168{ 174{
169 SVR_IPC_HEAD(Data); 175 SVR_IPC_HEAD(Data);
176 char tmp[1024];
177
178 strncpy(tmp, e->data, e->size);
179 tmp[e->size] = 0;
180
170 if (e->major == 1) // registration 181 if (e->major == 1) // registration
171 { 182 {
172 fprintf(stdout, "Server responded!\n"); 183 fprintf(stdout, "Server responded: %s\n", tmp);
173 } 184 }
174 return ECORE_CALLBACK_DONE; 185 return ECORE_CALLBACK_DONE;
175} 186}
@@ -199,11 +210,11 @@ static Eina_Bool
199debug_daemon_init(void) 210debug_daemon_init(void)
200{ 211{
201 srv_ipc = ecore_ipc_server_connect(ECORE_IPC_LOCAL_USER, "debugd", 0, NULL); 212 srv_ipc = ecore_ipc_server_connect(ECORE_IPC_LOCAL_USER, "debugd", 0, NULL);
213
202 if (!srv_ipc) _ipc_launch(); 214 if (!srv_ipc) _ipc_launch();
203 215
204 if (!srv_ipc) 216 if (!srv_ipc)
205 { 217 {
206 perror ("Could not connect to ipc server");
207 ecore_ipc_shutdown(); 218 ecore_ipc_shutdown();
208 return EINA_FALSE; 219 return EINA_FALSE;
209 } 220 }
@@ -219,7 +230,7 @@ debug_daemon_init(void)
219 230
220/////// Bridge-CLI Comm ///////// 231/////// Bridge-CLI Comm /////////
221 232
222///////// ADB MODE ///////////// 233///////// SDB MODE /////////////
223const char *tmp_dir = "/home/developer/tmp"; 234const char *tmp_dir = "/home/developer/tmp";
224int tmpcount = 0; 235int tmpcount = 0;
225 236
@@ -255,8 +266,7 @@ _tmp_file_monitor_cb(void *data, Ecore_File_Monitor *em,
255 266
256 if (cmd) 267 if (cmd)
257 { 268 {
258 fputs(cmd, stdout); 269 _bridge_send(cmd, strlen(cmd));
259 fflush(stdout);
260 } 270 }
261 } 271 }
262} 272}
@@ -314,7 +324,6 @@ _fd_handler_cb(void *data, Ecore_Fd_Handler *fd_handler EINA_UNUSED)
314static Eina_Bool 324static Eina_Bool
315_bridge_test(void) 325_bridge_test(void)
316{ 326{
317 fprintf(stdout, "BRIDGE TEST MODE\n");
318 ecore_main_fd_handler_add(STDIN_FILENO, 327 ecore_main_fd_handler_add(STDIN_FILENO,
319 ECORE_FD_READ, 328 ECORE_FD_READ,
320 _fd_handler_cb, 329 _fd_handler_cb,
@@ -323,10 +332,9 @@ _bridge_test(void)
323 return EINA_TRUE; 332 return EINA_TRUE;
324} 333}
325 334
326static int 335static Eina_Bool
327_bridge(Daemon_Mode mode) 336_bridge(Daemon_Mode mode)
328{ 337{
329
330 /* Initialize debug daemon */ 338 /* Initialize debug daemon */
331 if (!debug_daemon_init()) 339 if (!debug_daemon_init())
332 { 340 {
@@ -335,9 +343,11 @@ _bridge(Daemon_Mode mode)
335 } 343 }
336 344
337 if (mode == DAEMON_MODE_BRIDGE_TEST) 345 if (mode == DAEMON_MODE_BRIDGE_TEST)
338 return _bridge_test(); 346 _bridge_test();
339 else //BRIDGE_NORMAL 347 else //BRIDGE_NORMAL
340 return _bridge_sdb(); 348 _bridge_sdb();
349
350 return EINA_TRUE;
341} 351}
342 352
343//////////////////////////////////////////////////////////// 353////////////////////////////////////////////////////////////
@@ -358,22 +368,27 @@ int main (int argc, char **argv)
358 } 368 }
359 369
360 mode = DAEMON_MODE_NORMAL; 370 mode = DAEMON_MODE_NORMAL;
361 if (argc == 2) 371 if (argc > 1)
362 { 372 {
363 if (!strcmp(argv[1], "test")) 373 if (!strcmp(argv[1], "bridge"))
374 {
375 mode = DAEMON_MODE_BRIDGE_NORMAL;
376 }
377 else if (!strcmp(argv[1], "test"))
364 { 378 {
365 mode = DAEMON_MODE_TEST; 379 mode = DAEMON_MODE_TEST;
366 } 380 }
381
367 } 382 }
368 else if ((argc == 3) && !strcmp(argv[1], "bridge")) 383 if ((argc == 3) && !strcmp(argv[2], "test"))
369 { 384 {
370 if (!strcmp(argv[2], "test")) 385 if (mode == DAEMON_MODE_BRIDGE_NORMAL)
371 { 386 {
372 mode = DAEMON_MODE_BRIDGE_TEST; 387 mode = DAEMON_MODE_BRIDGE_TEST;
373 } 388 }
374 else 389 else
375 { 390 {
376 mode = DAEMON_MODE_BRIDGE_NORMAL; 391 mode = DAEMON_MODE_TEST;
377 } 392 }
378 } 393 }
379 394