Changeset 094d7ba9d7b4e9483c1f14d8280c3d7a31057015
- Timestamp:
- 12/04/09 15:15:14 (3 years ago)
- Children:
- 8dc28ed1da5ac2e103d76c799697b12de5797c11
- Parents:
- 67a1dd501331bba8bcb39ddb141685879f82c944
- git-committer:
- Nedko Arnaudov <nedko@arnaudov.name> / 2009-12-04T15:15:14Z+0200
- Files:
-
- 4 modified
-
daemon/app_supervisor.c (modified) (10 diffs)
-
gui/app_supervisor_proxy.c (modified) (3 diffs)
-
gui/app_supervisor_proxy.h (modified) (1 diff)
-
gui/graph_view.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
daemon/app_supervisor.c
r6b7103e r094d7ba 26 26 27 27 #include <ctype.h> 28 #include <sys/types.h> 29 #include <signal.h> 28 30 29 31 #include "app_supervisor.h" … … 38 40 char * name; 39 41 char * commandline; 42 bool terminal; 43 uint8_t level; 40 44 pid_t pid; 41 45 }; … … 105 109 } 106 110 111 struct ladish_app * ladish_app_supervisor_find_app_by_id(struct ladish_app_supervisor * supervisor_ptr, uint64_t id) 112 { 113 struct list_head * node_ptr; 114 struct ladish_app * app_ptr; 115 116 list_for_each(node_ptr, &supervisor_ptr->applist) 117 { 118 app_ptr = list_entry(node_ptr, struct ladish_app, siblings); 119 if (app_ptr->id == id) 120 { 121 return app_ptr; 122 } 123 } 124 125 return NULL; 126 } 127 107 128 #define supervisor_ptr ((struct ladish_app_supervisor *)supervisor_handle) 108 129 … … 136 157 { 137 158 log_info("exit of studio child '%s' detected.", app_ptr->name); 159 138 160 list_del(&app_ptr->siblings); 161 162 dbus_signal_emit( 163 g_dbus_connection, 164 supervisor_ptr->opath, 165 IFACE_APP_SUPERVISOR, 166 "AppRemoved", 167 "tt", 168 &supervisor_ptr->version, 169 &app_ptr->id); 170 139 171 free(app_ptr->name); 140 172 free(app_ptr->commandline); … … 155 187 struct list_head * node_ptr; 156 188 struct ladish_app * app_ptr; 189 dbus_bool_t running; 190 dbus_bool_t terminal; 157 191 158 192 log_info("get_all called"); … … 171 205 } 172 206 173 if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "(ts )", &array_iter))207 if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "(tsbby)", &array_iter)) 174 208 { 175 209 goto fail_unref; … … 180 214 app_ptr = list_entry(node_ptr, struct ladish_app, siblings); 181 215 216 log_info("app '%s' (%llu)", app_ptr->name, (unsigned long long)app_ptr->id); 217 182 218 if (!dbus_message_iter_open_container (&array_iter, DBUS_TYPE_STRUCT, NULL, &struct_iter)) 183 219 { … … 190 226 } 191 227 192 log_info("app '%s' (%llu)", app_ptr->name, (unsigned long long)app_ptr->id);193 228 if (!dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_STRING, &app_ptr->name)) 229 { 230 goto fail_unref; 231 } 232 233 running = app_ptr->pid != 0; 234 if (!dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_BOOLEAN, &running)) 235 { 236 goto fail_unref; 237 } 238 239 terminal = app_ptr->terminal; 240 if (!dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_BOOLEAN, &terminal)) 241 { 242 goto fail_unref; 243 } 244 245 if (!dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_BYTE, &app_ptr->level)) 194 246 { 195 247 goto fail_unref; … … 227 279 unsigned int index; 228 280 struct ladish_app * app_ptr; 281 dbus_bool_t running; 229 282 230 283 if (!dbus_message_get_args( … … 327 380 log_info("%s pid is %lu", app_ptr->name, (unsigned long)app_ptr->pid); 328 381 382 running = true; 383 terminal = app_ptr->terminal; 384 385 dbus_signal_emit( 386 g_dbus_connection, 387 supervisor_ptr->opath, 388 IFACE_APP_SUPERVISOR, 389 "AppAdded", 390 "ttsbby", 391 &supervisor_ptr->version, 392 &app_ptr->id, 393 &app_ptr->name, 394 &running, 395 &terminal, 396 &app_ptr->level); 397 329 398 method_return_new_void(call_ptr); 330 399 } 331 400 401 static void start_app(struct dbus_method_call * call_ptr) 402 { 403 uint64_t id; 404 struct ladish_app * app_ptr; 405 406 if (!dbus_message_get_args( 407 call_ptr->message, 408 &g_dbus_error, 409 DBUS_TYPE_UINT64, &id, 410 DBUS_TYPE_INVALID)) 411 { 412 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message); 413 dbus_error_free(&g_dbus_error); 414 return; 415 } 416 417 app_ptr = ladish_app_supervisor_find_app_by_id(supervisor_ptr, id); 418 if (app_ptr == NULL) 419 { 420 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App with ID %"PRIu64" not found", id); 421 return; 422 } 423 424 if (app_ptr->pid != 0) 425 { 426 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App %s is already running", app_ptr->name); 427 return; 428 } 429 430 if (!loader_execute(supervisor_ptr->name, app_ptr->name, "/", app_ptr->terminal, app_ptr->commandline, &app_ptr->pid)) 431 { 432 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_GENERIC, "Execution of '%s' failed", app_ptr->commandline); 433 return; 434 } 435 436 log_info("%s pid is %lu", app_ptr->name, (unsigned long)app_ptr->pid); 437 438 method_return_new_void(call_ptr); 439 } 440 441 static void stop_app(struct dbus_method_call * call_ptr) 442 { 443 uint64_t id; 444 struct ladish_app * app_ptr; 445 446 if (!dbus_message_get_args( 447 call_ptr->message, 448 &g_dbus_error, 449 DBUS_TYPE_UINT64, &id, 450 DBUS_TYPE_INVALID)) 451 { 452 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message); 453 dbus_error_free(&g_dbus_error); 454 return; 455 } 456 457 app_ptr = ladish_app_supervisor_find_app_by_id(supervisor_ptr, id); 458 if (app_ptr == NULL) 459 { 460 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App with ID %"PRIu64" not found", id); 461 return; 462 } 463 464 if (app_ptr->pid == 0) 465 { 466 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App %s is not running", app_ptr->name); 467 return; 468 } 469 470 kill(app_ptr->pid, SIGTERM); 471 472 method_return_new_void(call_ptr); 473 } 474 475 static void kill_app(struct dbus_method_call * call_ptr) 476 { 477 uint64_t id; 478 struct ladish_app * app_ptr; 479 480 if (!dbus_message_get_args( 481 call_ptr->message, 482 &g_dbus_error, 483 DBUS_TYPE_UINT64, &id, 484 DBUS_TYPE_INVALID)) 485 { 486 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message); 487 dbus_error_free(&g_dbus_error); 488 return; 489 } 490 491 app_ptr = ladish_app_supervisor_find_app_by_id(supervisor_ptr, id); 492 if (app_ptr == NULL) 493 { 494 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App with ID %"PRIu64" not found", id); 495 return; 496 } 497 498 if (app_ptr->pid == 0) 499 { 500 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App %s is not running", app_ptr->name); 501 return; 502 } 503 504 kill(app_ptr->pid, SIGKILL); 505 506 method_return_new_void(call_ptr); 507 } 508 509 static void get_app_properties(struct dbus_method_call * call_ptr) 510 { 511 } 512 513 static void set_app_properties(struct dbus_method_call * call_ptr) 514 { 515 } 516 517 static void remove_app(struct dbus_method_call * call_ptr) 518 { 519 } 520 521 static void is_app_running(struct dbus_method_call * call_ptr) 522 { 523 uint64_t id; 524 struct ladish_app * app_ptr; 525 dbus_bool_t running; 526 527 if (!dbus_message_get_args( 528 call_ptr->message, 529 &g_dbus_error, 530 DBUS_TYPE_UINT64, &id, 531 DBUS_TYPE_INVALID)) 532 { 533 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message); 534 dbus_error_free(&g_dbus_error); 535 return; 536 } 537 538 app_ptr = ladish_app_supervisor_find_app_by_id(supervisor_ptr, id); 539 if (app_ptr == NULL) 540 { 541 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App with ID %"PRIu64" not found", id); 542 return; 543 } 544 545 running = app_ptr->pid != 0; 546 547 method_return_new_single(call_ptr, DBUS_TYPE_BOOLEAN, &running); 548 } 549 332 550 #undef supervisor_ptr 333 551 334 METHOD_ARGS_BEGIN(GetAll, "Get list of runningapps")335 METHOD_ARG_DESCRIBE_OUT("list_version", "t", "Version of the list")336 METHOD_ARG_DESCRIBE_OUT("apps_list", "a(ts )", "List of runningapps")552 METHOD_ARGS_BEGIN(GetAll, "Get list of apps") 553 METHOD_ARG_DESCRIBE_OUT("list_version", DBUS_TYPE_UINT64_AS_STRING, "Version of the list") 554 METHOD_ARG_DESCRIBE_OUT("apps_list", "a(tsbby)", "List of apps") 337 555 METHOD_ARGS_END 338 556 339 557 METHOD_ARGS_BEGIN(RunCustom, "Start application by supplying commandline") 340 METHOD_ARG_DESCRIBE_IN("terminal", "b", "Whether to run in terminal") 341 METHOD_ARG_DESCRIBE_IN("commandline", "s", "Commandline") 342 METHOD_ARG_DESCRIBE_IN("name", "s", "Name") 343 METHOD_ARGS_END 558 METHOD_ARG_DESCRIBE_IN("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether to run in terminal") 559 METHOD_ARG_DESCRIBE_IN("commandline", DBUS_TYPE_STRING_AS_STRING, "Commandline") 560 METHOD_ARG_DESCRIBE_IN("name", DBUS_TYPE_STRING_AS_STRING, "Name") 561 METHOD_ARG_DESCRIBE_IN("level", DBUS_TYPE_BYTE_AS_STRING, "Level") 562 METHOD_ARGS_END 563 564 METHOD_ARGS_BEGIN(StartApp, "Start application") 565 METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app") 566 METHOD_ARGS_END 567 568 METHOD_ARGS_BEGIN(StopApp, "Stop application") 569 METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app") 570 METHOD_ARGS_END 571 572 METHOD_ARGS_BEGIN(KillApp, "Kill application") 573 METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app") 574 METHOD_ARGS_END 575 576 METHOD_ARGS_BEGIN(GetAppProperties, "Get properties of an application") 577 METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app") 578 METHOD_ARG_DESCRIBE_OUT("name", DBUS_TYPE_STRING_AS_STRING, "") 579 METHOD_ARG_DESCRIBE_OUT("commandline", DBUS_TYPE_STRING_AS_STRING, "Commandline") 580 METHOD_ARG_DESCRIBE_OUT("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether to run in terminal") 581 METHOD_ARG_DESCRIBE_OUT("level", DBUS_TYPE_BYTE_AS_STRING, "Level") 582 METHOD_ARGS_END 583 584 METHOD_ARGS_BEGIN(SetAppProperties, "Set properties of an application") 585 METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app") 586 METHOD_ARG_DESCRIBE_IN("name", DBUS_TYPE_STRING_AS_STRING, "") 587 METHOD_ARG_DESCRIBE_IN("commandline", DBUS_TYPE_STRING_AS_STRING, "Commandline") 588 METHOD_ARG_DESCRIBE_IN("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether to run in terminal") 589 METHOD_ARG_DESCRIBE_IN("level", DBUS_TYPE_BYTE_AS_STRING, "Level") 590 METHOD_ARGS_END 591 592 METHOD_ARGS_BEGIN(IsAppRunning, "Check whether application is running") 593 METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app") 594 METHOD_ARG_DESCRIBE_IN("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether app is running") 595 METHOD_ARGS_END 596 344 597 345 598 METHODS_BEGIN 346 599 METHOD_DESCRIBE(GetAll, get_all) 347 600 METHOD_DESCRIBE(RunCustom, run_custom) 601 METHOD_DESCRIBE(StartApp, start_app) 602 METHOD_DESCRIBE(StopApp, stop_app) 603 METHOD_DESCRIBE(KillApp, kill_app) 604 METHOD_DESCRIBE(GetAppProperties, get_app_properties) 605 METHOD_DESCRIBE(SetAppProperties, set_app_properties) 606 METHOD_DESCRIBE(KillApp, remove_app) 607 METHOD_DESCRIBE(IsAppRunning, is_app_running) 348 608 METHODS_END 349 609 610 SIGNAL_ARGS_BEGIN(AppAdded, "") 611 SIGNAL_ARG_DESCRIBE("new_list_version", DBUS_TYPE_UINT64_AS_STRING, "") 612 SIGNAL_ARG_DESCRIBE("id", DBUS_TYPE_UINT64_AS_STRING, "") 613 SIGNAL_ARG_DESCRIBE("name", DBUS_TYPE_STRING_AS_STRING, "") 614 SIGNAL_ARG_DESCRIBE("running", DBUS_TYPE_BOOLEAN_AS_STRING, "") 615 SIGNAL_ARG_DESCRIBE("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether to run in terminal") 616 SIGNAL_ARG_DESCRIBE("level", DBUS_TYPE_BYTE_AS_STRING, "Level") 617 SIGNAL_ARGS_END 618 619 SIGNAL_ARGS_BEGIN(AppRemoved, "") 620 SIGNAL_ARG_DESCRIBE("new_list_version", DBUS_TYPE_UINT64_AS_STRING, "") 621 SIGNAL_ARG_DESCRIBE("id", DBUS_TYPE_UINT64_AS_STRING, "") 622 SIGNAL_ARGS_END 623 624 SIGNAL_ARGS_BEGIN(AppStateChanged, "") 625 SIGNAL_ARG_DESCRIBE("id", DBUS_TYPE_UINT64_AS_STRING, "") 626 SIGNAL_ARG_DESCRIBE("name", DBUS_TYPE_STRING_AS_STRING, "") 627 SIGNAL_ARG_DESCRIBE("running", DBUS_TYPE_BOOLEAN_AS_STRING, "") 628 SIGNAL_ARG_DESCRIBE("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether to run in terminal") 629 SIGNAL_ARG_DESCRIBE("level", DBUS_TYPE_BYTE_AS_STRING, "Level") 630 SIGNAL_ARGS_END 631 350 632 SIGNALS_BEGIN 633 SIGNAL_DESCRIBE(AppAdded) 634 SIGNAL_DESCRIBE(AppRemoved) 635 SIGNAL_DESCRIBE(AppStateChanged) 351 636 SIGNALS_END 352 637 -
gui/app_supervisor_proxy.c
r67a1dd5 r094d7ba 35 35 char * object; 36 36 uint64_t version; 37 38 void * context; 39 void (* app_added)(void * context, uint64_t id, const char * name, bool running, bool terminal, uint8_t level); 40 void (* app_removed)(void * context, uint64_t id); 37 41 }; 38 42 39 bool ladish_app_supervisor_proxy_create(const char * service, const char * object, ladish_app_supervisor_proxy_handle * handle_ptr) 43 static const char * g_signals[] = 44 { 45 "AppAdded", 46 "AppRemoved", 47 "AppStateChanged", 48 NULL 49 }; 50 51 #define proxy_ptr ((struct ladish_app_supervisor_proxy *)proxy) 52 53 static 54 DBusHandlerResult 55 message_hook( 56 DBusConnection * connection, 57 DBusMessage * message, 58 void * proxy) 59 { 60 const char * object_path; 61 uint64_t new_list_version; 62 uint64_t id; 63 const char * name; 64 dbus_bool_t running; 65 dbus_bool_t terminal; 66 uint8_t level; 67 68 object_path = dbus_message_get_path(message); 69 if (object_path == NULL || strcmp(object_path, proxy_ptr->object) != 0) 70 { 71 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; 72 } 73 74 if (dbus_message_is_signal(message, IFACE_APP_SUPERVISOR, "AppAdded")) 75 { 76 if (!dbus_message_get_args( 77 message, 78 &g_dbus_error, 79 DBUS_TYPE_UINT64, &new_list_version, 80 DBUS_TYPE_UINT64, &id, 81 DBUS_TYPE_STRING, &name, 82 DBUS_TYPE_BOOLEAN, &running, 83 DBUS_TYPE_BOOLEAN, &terminal, 84 DBUS_TYPE_BYTE, &level, 85 DBUS_TYPE_INVALID)) 86 { 87 log_error("dbus_message_get_args() failed to extract AppAdded signal arguments (%s)", g_dbus_error.message); 88 dbus_error_free(&g_dbus_error); 89 return DBUS_HANDLER_RESULT_HANDLED; 90 } 91 92 //log_info("AppAdded signal received. id=%"PRIu64", name='%s', %srunning, %s, level %u", id, name, running ? "" : "not ", terminal ? "terminal" : "shell", (unsigned int)level); 93 proxy_ptr->app_added(proxy_ptr->context, id, name, running, terminal, level); 94 return DBUS_HANDLER_RESULT_HANDLED; 95 } 96 97 if (dbus_message_is_signal(message, IFACE_APP_SUPERVISOR, "AppRemoved")) 98 { 99 if (!dbus_message_get_args( 100 message, 101 &g_dbus_error, 102 DBUS_TYPE_UINT64, &new_list_version, 103 DBUS_TYPE_UINT64, &id, 104 DBUS_TYPE_INVALID)) 105 { 106 log_error("dbus_message_get_args() failed to extract AppRemoved signal arguments (%s)", g_dbus_error.message); 107 dbus_error_free(&g_dbus_error); 108 return DBUS_HANDLER_RESULT_HANDLED; 109 } 110 111 //log_info("AppRemoved signal received, id=%"PRIu64, id); 112 proxy_ptr->app_removed(proxy_ptr->context, id); 113 return DBUS_HANDLER_RESULT_HANDLED; 114 } 115 116 if (dbus_message_is_signal(message, IFACE_APP_SUPERVISOR, "AppStateChanged")) 117 { 118 if (!dbus_message_get_args( 119 message, 120 &g_dbus_error, 121 DBUS_TYPE_UINT64, &new_list_version, 122 DBUS_TYPE_UINT64, &id, 123 DBUS_TYPE_STRING, &name, 124 DBUS_TYPE_BOOLEAN, &running, 125 DBUS_TYPE_BOOLEAN, &terminal, 126 DBUS_TYPE_BYTE, &level, 127 DBUS_TYPE_INVALID)) 128 { 129 log_error("dbus_message_get_args() failed to extract AppStateChanged signal arguments (%s)", g_dbus_error.message); 130 dbus_error_free(&g_dbus_error); 131 return DBUS_HANDLER_RESULT_HANDLED; 132 } 133 134 log_info("AppStateChanged signal received"); 135 return DBUS_HANDLER_RESULT_HANDLED; 136 } 137 138 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; 139 } 140 141 #undef proxy_ptr 142 143 static void refresh_internal(struct ladish_app_supervisor_proxy * proxy_ptr, bool force) 144 { 145 DBusMessage* reply_ptr; 146 DBusMessageIter iter; 147 dbus_uint64_t version; 148 const char * reply_signature; 149 DBusMessageIter array_iter; 150 DBusMessageIter struct_iter; 151 uint64_t id; 152 const char * name; 153 dbus_bool_t running; 154 dbus_bool_t terminal; 155 uint8_t level; 156 157 log_info("refresh_internal() called"); 158 159 version = proxy_ptr->version; 160 161 if (!dbus_call(proxy_ptr->service, proxy_ptr->object, IFACE_APP_SUPERVISOR, "GetAll", "t", &version, NULL, &reply_ptr)) 162 { 163 log_error("GetAll() failed."); 164 return; 165 } 166 167 reply_signature = dbus_message_get_signature(reply_ptr); 168 169 if (strcmp(reply_signature, "ta(tsbby)") != 0) 170 { 171 log_error("GetAll() reply signature mismatch. '%s'", reply_signature); 172 goto unref; 173 } 174 175 dbus_message_iter_init(reply_ptr, &iter); 176 177 //log_info_msg("version " + (char)dbus_message_iter_get_arg_type(&iter)); 178 dbus_message_iter_get_basic(&iter, &version); 179 dbus_message_iter_next(&iter); 180 181 if (!force && version <= proxy_ptr->version) 182 { 183 goto unref; 184 } 185 186 //log_info("got new list version %llu", (unsigned long long)version); 187 proxy_ptr->version = version; 188 189 for (dbus_message_iter_recurse(&iter, &array_iter); 190 dbus_message_iter_get_arg_type(&array_iter) != DBUS_TYPE_INVALID; 191 dbus_message_iter_next(&array_iter)) 192 { 193 dbus_message_iter_recurse(&array_iter, &struct_iter); 194 195 dbus_message_iter_get_basic(&struct_iter, &id); 196 dbus_message_iter_next(&struct_iter); 197 198 dbus_message_iter_get_basic(&struct_iter, &name); 199 dbus_message_iter_next(&struct_iter); 200 201 dbus_message_iter_get_basic(&struct_iter, &running); 202 dbus_message_iter_next(&struct_iter); 203 204 dbus_message_iter_get_basic(&struct_iter, &terminal); 205 dbus_message_iter_next(&struct_iter); 206 207 dbus_message_iter_get_basic(&struct_iter, &level); 208 dbus_message_iter_next(&struct_iter); 209 210 //log_info("App id=%"PRIu64", name='%s', %srunning, %s, level %u", id, name, running ? "" : "not ", terminal ? "terminal" : "shell", (unsigned int)level); 211 proxy_ptr->app_added(proxy_ptr->context, id, name, running, terminal, level); 212 213 dbus_message_iter_next(&struct_iter); 214 } 215 216 unref: 217 dbus_message_unref(reply_ptr); 218 } 219 220 bool 221 ladish_app_supervisor_proxy_create( 222 const char * service, 223 const char * object, 224 void * context, 225 void (* app_added)(void * context, uint64_t id, const char * name, bool running, bool terminal, uint8_t level), 226 void (* app_removed)(void * context, uint64_t id), 227 ladish_app_supervisor_proxy_handle * handle_ptr) 40 228 { 41 229 struct ladish_app_supervisor_proxy * proxy_ptr; … … 64 252 proxy_ptr->version = 0; 65 253 254 proxy_ptr->context = context; 255 proxy_ptr->app_added = app_added; 256 proxy_ptr->app_removed = app_removed; 257 258 if (!dbus_register_object_signal_handler( 259 g_dbus_connection, 260 proxy_ptr->service, 261 proxy_ptr->object, 262 IFACE_APP_SUPERVISOR, 263 g_signals, 264 message_hook, 265 proxy_ptr)) 266 { 267 return false; 268 } 269 270 refresh_internal(proxy_ptr, true); 271 66 272 *handle_ptr = (ladish_app_supervisor_proxy_handle)proxy_ptr; 67 273 … … 82 288 void ladish_app_supervisor_proxy_destroy(ladish_app_supervisor_proxy_handle proxy) 83 289 { 290 dbus_unregister_object_signal_handler( 291 g_dbus_connection, 292 proxy_ptr->service, 293 proxy_ptr->object, 294 IFACE_APP_SUPERVISOR, 295 g_signals, 296 message_hook, 297 proxy_ptr); 298 84 299 free(proxy_ptr->object); 85 300 free(proxy_ptr->service); -
gui/app_supervisor_proxy.h
r67a1dd5 r094d7ba 32 32 typedef struct ladish_app_supervisor_proxy_tag { int unused; } * ladish_app_supervisor_proxy_handle; 33 33 34 bool ladish_app_supervisor_proxy_create(const char * service, const char * object, ladish_app_supervisor_proxy_handle * proxy_ptr); 34 bool 35 ladish_app_supervisor_proxy_create( 36 const char * service, 37 const char * object, 38 void * context, 39 void (* app_added)(void * context, uint64_t id, const char * name, bool running, bool terminal, uint8_t level), 40 void (* app_removed)(void * context, uint64_t id), 41 ladish_app_supervisor_proxy_handle * proxy_ptr); 42 35 43 void ladish_app_supervisor_proxy_destroy(ladish_app_supervisor_proxy_handle proxy); 36 44 bool ladish_app_supervisor_proxy_run_custom(ladish_app_supervisor_proxy_handle proxy, const char * command, const char * name, bool run_in_terminal); -
gui/graph_view.c
r67a1dd5 r094d7ba 51 51 INIT_LIST_HEAD(&g_views); 52 52 g_current_view = NULL; 53 } 54 55 static void app_added(void * context, uint64_t id, const char * name, bool running, bool terminal, uint8_t level) 56 { 57 log_info("app added. id=%"PRIu64", name='%s', %srunning, %s, level %u", id, name, running ? "" : "not ", terminal ? "terminal" : "shell", (unsigned int)level); 58 } 59 60 static void app_removed(void * context, uint64_t id) 61 { 62 log_info("app removed. id=%"PRIu64, id); 53 63 } 54 64 … … 81 91 if (app_supervisor_supported) 82 92 { 83 if (!ladish_app_supervisor_proxy_create(service, object, &view_ptr->app_supervisor))93 if (!ladish_app_supervisor_proxy_create(service, object, view_ptr, app_added, app_removed, &view_ptr->app_supervisor)) 84 94 { 85 95 goto free_name;
