diff --git a/common/dirhelpers.c b/common/dirhelpers.c index f4743372..f5f14f74 100644 --- a/common/dirhelpers.c +++ b/common/dirhelpers.c @@ -32,6 +32,20 @@ #include #include +bool check_dir_exists(const char * dirname) +{ + struct stat st; + + ASSERT(*dirname); /* empty string? */ + + if (stat(dirname, &st) != 0) + { + return false; + } + + return S_ISDIR(st.st_mode); +} + /* ret=true, err=0 - directory was created successfully */ /* ret=true, err=EEXIST - directory already exists */ /* ret=true, err=ENOENT - A directory component in dirname does not exist or is a dangling symbolic link */ diff --git a/common/dirhelpers.h b/common/dirhelpers.h index 1e135e41..2274ccde 100644 --- a/common/dirhelpers.h +++ b/common/dirhelpers.h @@ -2,7 +2,7 @@ /* * LADI Session Handler (ladish) * - * Copyright (C) 2009,2010 Nedko Arnaudov + * Copyright (C) 2009,2010,2011 Nedko Arnaudov * ************************************************************************** * This file contains prototypes of the directory helper functions @@ -27,6 +27,7 @@ #ifndef DIRHELPERS_H__805193D2_2662_40FA_8814_AF8A4E08F4B0__INCLUDED #define DIRHELPERS_H__805193D2_2662_40FA_8814_AF8A4E08F4B0__INCLUDED +bool check_dir_exists(const char * dirname); bool ensure_dir_exist(const char * dirname, int mode); bool ensure_dir_exist_varg(int mode, ...); diff --git a/daemon/app_supervisor.c b/daemon/app_supervisor.c index 34c010d5..7b32bd2c 100644 --- a/daemon/app_supervisor.c +++ b/daemon/app_supervisor.c @@ -27,6 +27,7 @@ #include "config.h" /* Get _GNU_SOURCE defenition first to have some GNU extension available */ #include +#include #include #include @@ -36,6 +37,9 @@ #include "loader.h" #include "studio_internal.h" #include "../proxies/notify_proxy.h" +#include "../proxies/lash_client_proxy.h" +#include "../common/catdup.h" +#include "../common/dirhelpers.h" struct ladish_app { @@ -54,6 +58,8 @@ struct ladish_app bool zombie; /* if true, remove when stopped */ bool autorun; unsigned int state; + char * dbus_name; + struct ladish_app_supervisor * supervisor; }; struct ladish_app_supervisor @@ -79,7 +85,8 @@ bool ladish_check_app_level_validity(const char * level, size_t * len_ptr) } if (strcmp(level, LADISH_APP_LEVEL_0) != 0 && - strcmp(level, LADISH_APP_LEVEL_1) != 0) + strcmp(level, LADISH_APP_LEVEL_1) != 0&& + strcmp(level, LADISH_APP_LEVEL_LASH) != 0) { return false; } @@ -176,6 +183,7 @@ void remove_app_internal(struct ladish_app_supervisor * supervisor_ptr, struct l &supervisor_ptr->version, &app_ptr->id); + free(app_ptr->dbus_name); free(app_ptr->name); free(app_ptr->commandline); free(app_ptr); @@ -316,6 +324,8 @@ ladish_app_supervisor_add( return NULL; } + app_ptr->dbus_name = NULL; + app_ptr->terminal = terminal; memcpy(app_ptr->level, level, len + 1); app_ptr->pid = 0; @@ -337,6 +347,7 @@ ladish_app_supervisor_add( app_ptr->zombie = false; app_ptr->state = LADISH_APP_STATE_STOPPED; app_ptr->autorun = autorun; + app_ptr->supervisor = supervisor_ptr; list_add_tail(&app_ptr->siblings, &supervisor_ptr->applist); supervisor_ptr->version++; @@ -488,6 +499,109 @@ static void ladish_app_send_signal(struct ladish_app * app_ptr, int sig, bool pr } } +static inline void ladish_app_initiate_lash_save(struct ladish_app * app_ptr, const char * base_dir) +{ + char * app_dir; + char uuid_str[37]; + + if (base_dir == NULL) + { + log_error("Cannot initiate LASH save because base dir is unknown"); + ASSERT_NO_PASS; + goto exit; + } + + uuid_unparse(app_ptr->uuid, uuid_str); + app_dir = catdup3(base_dir, "/lash_apps/", uuid_str); + if (app_dir == NULL) + { + log_error("Cannot initiate LASH save because of memory allocation failure."); + goto exit; + } + + if (!ensure_dir_exist(app_dir, S_IRWXU | S_IRWXG | S_IRWXO)) + { + goto free; + } + + if (lash_client_proxy_save(app_ptr->dbus_name, app_dir)) + { + log_info("LASH Save into '%s' initiated for '%s' with D-Bus name '%s'", app_dir, app_ptr->name, app_ptr->dbus_name); + } + +free: + free(app_dir); +exit: + return; +} + +static inline void ladish_app_initiate_lash_restore(struct ladish_app * app_ptr, const char * base_dir) +{ + char * app_dir; + char uuid_str[37]; + struct st; + + if (base_dir == NULL) + { + log_error("Cannot initiate LASH restore because base dir is unknown"); + ASSERT_NO_PASS; + goto exit; + } + + uuid_unparse(app_ptr->uuid, uuid_str); + app_dir = catdup3(base_dir, "/lash_apps/", uuid_str); + if (app_dir == NULL) + { + log_error("Cannot initiate LASH restore because of memory allocation failure."); + goto exit; + } + + if (!check_dir_exists(app_dir)) + { + log_info("Not initiating LASH restore because of app directory '%s' does not exist.", app_dir); + goto free; + } + + if (lash_client_proxy_restore(app_ptr->dbus_name, app_dir)) + { + log_info("LASH Save from '%s' initiated for '%s' with D-Bus name '%s'", app_dir, app_ptr->name, app_ptr->dbus_name); + } + +free: + free(app_dir); +exit: + return; +} + +static inline void ladish_app_initiate_save(struct ladish_app * app_ptr) +{ + if (strcmp(app_ptr->level, LADISH_APP_LEVEL_LASH) == 0 && + app_ptr->dbus_name != NULL) + { + ladish_app_initiate_lash_save(app_ptr, app_ptr->supervisor->dir != NULL ? app_ptr->supervisor->dir : g_base_dir); + } + else if (strcmp(app_ptr->level, LADISH_APP_LEVEL_1) == 0) + { + ladish_app_send_signal(app_ptr, SIGUSR1, true); + } +} + +static inline void ladish_app_initiate_stop(struct ladish_app * app_ptr) +{ + app_ptr->state = LADISH_APP_STATE_STOPPING; + + if (strcmp(app_ptr->level, LADISH_APP_LEVEL_LASH) == 0 && + app_ptr->dbus_name != NULL && + lash_client_proxy_quit(app_ptr->dbus_name)) + { + log_info("LASH Quit initiated for '%s' with D-Bus name '%s'", app_ptr->name, app_ptr->dbus_name); + } + else + { + ladish_app_send_signal(app_ptr, SIGTERM, false); + } +} + bool ladish_app_supervisor_clear(ladish_app_supervisor_handle supervisor_handle) { struct list_head * node_ptr; @@ -509,9 +623,8 @@ bool ladish_app_supervisor_clear(ladish_app_supervisor_handle supervisor_handle) if (app_ptr->pid != 0) { log_info("terminating '%s'...", app_ptr->name); - ladish_app_send_signal(app_ptr, SIGTERM, false); + ladish_app_initiate_stop(app_ptr); app_ptr->zombie = true; - app_ptr->state = LADISH_APP_STATE_STOPPING; lifeless = false; } else @@ -645,14 +758,6 @@ ladish_app_supervisor_enum( return true; } -static inline void ladish_app_save_L1_internal(struct ladish_app * app_ptr) -{ - if (strcmp(app_ptr->level, LADISH_APP_LEVEL_1) == 0) - { - ladish_app_send_signal(app_ptr, SIGUSR1, true); - } -} - #define app_ptr ((struct ladish_app *)app_handle) bool ladish_app_supervisor_start_app(ladish_app_supervisor_handle supervisor_handle, ladish_app_handle app_handle) @@ -707,8 +812,7 @@ void ladish_app_get_uuid(ladish_app_handle app_handle, uuid_t uuid) void ladish_app_stop(ladish_app_handle app_handle) { - ladish_app_send_signal(app_ptr, SIGTERM, false); - app_ptr->state = LADISH_APP_STATE_STOPPING; + ladish_app_initiate_stop(app_ptr); } void ladish_app_kill(ladish_app_handle app_handle) @@ -717,9 +821,18 @@ void ladish_app_kill(ladish_app_handle app_handle) app_ptr->state = LADISH_APP_STATE_KILL; } -void ladish_app_save_L1(ladish_app_handle app_handle) +void ladish_app_save(ladish_app_handle app_handle) { - ladish_app_save_L1_internal(app_ptr); + ladish_app_initiate_save(app_ptr); +} + +void ladish_app_restore(ladish_app_handle app_handle) +{ + if (strcmp(app_ptr->level, LADISH_APP_LEVEL_LASH) == 0 && + app_ptr->dbus_name != NULL) + { + ladish_app_initiate_lash_restore(app_ptr, app_ptr->supervisor->dir != NULL ? app_ptr->supervisor->dir : g_base_dir); + } } void ladish_app_add_pid(ladish_app_handle app_handle, pid_t pid) @@ -775,6 +888,22 @@ void ladish_app_del_pid(ladish_app_handle app_handle, pid_t pid) } } +bool ladish_app_set_dbus_name(ladish_app_handle app_handle, const char * name) +{ + char * dup; + + dup = strdup(name); + if (dup == NULL) + { + log_error("strdup() failed for app dbus name"); + return false; + } + + free(app_ptr->dbus_name); + app_ptr->dbus_name = dup; + return true; +} + #undef app_ptr void ladish_app_supervisor_autorun(ladish_app_supervisor_handle supervisor_handle) @@ -814,14 +943,13 @@ void ladish_app_supervisor_stop(ladish_app_supervisor_handle supervisor_handle) if (app_ptr->pid != 0) { log_info("terminating '%s'...", app_ptr->name); - ladish_app_send_signal(app_ptr, SIGTERM, false); app_ptr->autorun = true; - app_ptr->state = LADISH_APP_STATE_STOPPING; + ladish_app_initiate_stop(app_ptr); } } } -void ladish_app_supervisor_initiate_save(ladish_app_supervisor_handle supervisor_handle) +void ladish_app_supervisor_save(ladish_app_supervisor_handle supervisor_handle) { struct list_head * node_ptr; struct ladish_app * app_ptr; @@ -840,7 +968,7 @@ void ladish_app_supervisor_initiate_save(ladish_app_supervisor_handle supervisor continue; } - ladish_app_save_L1_internal(app_ptr); + ladish_app_initiate_save(app_ptr); } } diff --git a/daemon/app_supervisor.h b/daemon/app_supervisor.h index 53fb24a0..e9d6fb4c 100644 --- a/daemon/app_supervisor.h +++ b/daemon/app_supervisor.h @@ -196,7 +196,7 @@ ladish_app_supervisor_clear( * @param[in] supervisor_handle supervisor object handle */ void -ladish_app_supervisor_initiate_save( +ladish_app_supervisor_save( ladish_app_supervisor_handle supervisor_handle); /** @@ -400,7 +400,7 @@ const char * ladish_app_get_name(ladish_app_handle app_handle); void ladish_app_get_uuid(ladish_app_handle app_handle, uuid_t uuid); /** - * Stop an app. The app must be in started state. + * Tell app to stop. The app must be in started state. * * @param[in] app_handle Handle of app to stop */ @@ -414,11 +414,18 @@ void ladish_app_stop(ladish_app_handle app_handle); void ladish_app_kill(ladish_app_handle app_handle); /** - * Send SIGUSR1 signal to app. The app must be in started state. + * Initiate save of app internal state. The app must be in started state. * - * @param[in] app_handle Handle of app to send signal to + * @param[in] app_handle Handle of app */ -void ladish_app_save_L1(ladish_app_handle app_handle); +void ladish_app_save(ladish_app_handle app_handle); + +/** + * Initiate restore of app internal state. The app must be in started state. + * + * @param[in] app_handle Handle of app + */ +void ladish_app_restore(ladish_app_handle app_handle); /** * Associate pid with app. @@ -436,6 +443,16 @@ void ladish_app_add_pid(ladish_app_handle app_handle, pid_t pid); */ void ladish_app_del_pid(ladish_app_handle app_handle, pid_t pid); +/** + * Set the D-Bus unique name for the app. + * + * @param[in] app_handle Handle of app + * @param[in] name D-Bus unique name + * + * @return success status + */ +bool ladish_app_set_dbus_name(ladish_app_handle app_handle, const char * name); + /** * D-Bus interface descriptor for the app supervisor interface. The call context must be a ::ladish_app_supervisor_handle */ diff --git a/daemon/cmd_save_studio.c b/daemon/cmd_save_studio.c index b52f8d97..3d45c2de 100644 --- a/daemon/cmd_save_studio.c +++ b/daemon/cmd_save_studio.c @@ -211,7 +211,7 @@ static bool run(void * command_context) ret = false; - ladish_app_supervisor_initiate_save(g_studio.app_supervisor); + ladish_app_supervisor_save(g_studio.app_supervisor); if (!ladish_studio_is_started()) { diff --git a/daemon/lash_server.c b/daemon/lash_server.c new file mode 100644 index 00000000..29cb018b --- /dev/null +++ b/daemon/lash_server.c @@ -0,0 +1,112 @@ +/* -*- Mode: C ; c-basic-offset: 2 -*- */ +/* + * LADI Session Handler (ladish) + * + * Copyright (C) 2011 Nedko Arnaudov + * + ************************************************************************** + * This file contains implementation of lash_server singleton object + ************************************************************************** + * + * LADI Session Handler is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * LADI Session Handler is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with LADI Session Handler. If not, see + * or write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "lash_server.h" +#include "../dbus_constants.h" +#include "../dbus/error.h" +#include "virtualizer.h" + +static dbus_object_path ladishd_g_lash_server_dbus_object; +extern const struct dbus_interface_descriptor g_iface_lash_server; + +bool lash_server_init(void) +{ + ladishd_g_lash_server_dbus_object = dbus_object_path_new( + LASH_SERVER_OBJECT_PATH, + &g_iface_lash_server, NULL, + NULL); + if (ladishd_g_lash_server_dbus_object == NULL) + { + return false; + } + + if (!dbus_object_path_register(cdbus_g_dbus_connection, ladishd_g_lash_server_dbus_object)) + { + dbus_object_path_destroy(cdbus_g_dbus_connection, ladishd_g_lash_server_dbus_object); + return false; + } + + return true; +} + +void lash_server_uninit(void) +{ + dbus_object_path_destroy(cdbus_g_dbus_connection, ladishd_g_lash_server_dbus_object); +} + +/**********************************************************************************/ +/* D-Bus methods */ +/**********************************************************************************/ + +static void lash_server_register_client(struct dbus_method_call * call_ptr) +{ + const char * sender; + const char * class; + dbus_uint64_t pid; + dbus_uint32_t flags; + ladish_app_handle app; + + if (!dbus_message_get_args( + call_ptr->message, + &cdbus_g_dbus_error, + DBUS_TYPE_UINT64, &pid, + DBUS_TYPE_STRING, &class, + DBUS_TYPE_UINT32, &flags, + DBUS_TYPE_INVALID)) + { + lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, cdbus_g_dbus_error.message); + dbus_error_free(&cdbus_g_dbus_error); + return; + } + + sender = dbus_message_get_sender(call_ptr->message); + + log_info("LASH client registered. pid=%"PRIu64" dbusname='%s' class='%s' flags=0x%"PRIu32")", pid, sender, class, flags); + + app = ladish_find_app_by_pid((pid_t)pid, NULL); + if (app == NULL) + { + log_error("Unknown LASH app registered"); + return; + } + + ladish_app_set_dbus_name(app, sender); + ladish_app_restore(app); +} + +METHOD_ARGS_BEGIN(RegisterClient, "Register LASH client") + METHOD_ARG_DESCRIBE_IN("class", DBUS_TYPE_STRING_AS_STRING, "LASH app class") + METHOD_ARG_DESCRIBE_IN("flags", DBUS_TYPE_UINT32_AS_STRING, "LASH app flags") +METHOD_ARGS_END + +METHODS_BEGIN + METHOD_DESCRIBE(RegisterClient, lash_server_register_client) +METHODS_END + +INTERFACE_BEGIN(g_iface_lash_server, IFACE_LASH_SERVER) + INTERFACE_DEFAULT_HANDLER + INTERFACE_EXPOSE_METHODS +INTERFACE_END diff --git a/daemon/lash_server.h b/daemon/lash_server.h new file mode 100644 index 00000000..c9b3bdfa --- /dev/null +++ b/daemon/lash_server.h @@ -0,0 +1,35 @@ +/* -*- Mode: C ; c-basic-offset: 2 -*- */ +/* + * LADI Session Handler (ladish) + * + * Copyright (C) 2011 Nedko Arnaudov + * + ************************************************************************** + * This file contains interface to lash_server singleton object + ************************************************************************** + * + * LADI Session Handler is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * LADI Session Handler is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with LADI Session Handler. If not, see + * or write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef LASH_SERVER_H__6AD709D8_150B_4AF4_9919_316B89466EF0__INCLUDED +#define LASH_SERVER_H__6AD709D8_150B_4AF4_9919_316B89466EF0__INCLUDED + +#include "common.h" + +bool lash_server_init(void); +void lash_server_uninit(void); + +#endif /* #ifndef LASH_SERVER_H__6AD709D8_150B_4AF4_9919_316B89466EF0__INCLUDED */ diff --git a/daemon/main.c b/daemon/main.c index 95693dd6..3f4cbe55 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -47,6 +47,7 @@ #include "../proxies/conf_proxy.h" #include "conf.h" #include "recent_projects.h" +#include "lash_server.h" bool g_quit; const char * g_dbus_unique_name; @@ -375,6 +376,11 @@ int main(int argc, char ** argv, char ** envp) goto uninit_jmcore; } + if (!lash_server_init()) + { + goto uninit_studio; + } + ladish_notify_simple(LADISH_NOTIFY_URGENCY_LOW, "LADI Session Handler daemon activated", NULL); while (!g_quit) @@ -392,6 +398,9 @@ int main(int argc, char ** argv, char ** envp) log_debug("Finished, cleaning up"); + lash_server_uninit(); + +uninit_studio: ladish_studio_uninit(); uninit_jmcore: diff --git a/daemon/room_save.c b/daemon/room_save.c index e912ea97..763da153 100644 --- a/daemon/room_save.c +++ b/daemon/room_save.c @@ -234,7 +234,7 @@ static bool ladish_room_save_project_do(struct ladish_room * room_ptr) goto close; } - ladish_app_supervisor_initiate_save(room_ptr->app_supervisor); + ladish_app_supervisor_save(room_ptr->app_supervisor); ladish_room_emit_project_properties_changed(room_ptr); diff --git a/daemon/virtualizer.c b/daemon/virtualizer.c index 803a111d..2ea8e32f 100644 --- a/daemon/virtualizer.c +++ b/daemon/virtualizer.c @@ -102,7 +102,7 @@ static bool lookup_app_in_supervisor(void * context, ladish_graph_handle graph, #undef app_find_context_ptr -static ladish_app_handle ladish_virtualizer_find_app_by_pid(struct virtualizer * virtualizer_ptr, pid_t pid, ladish_graph_handle * graph_ptr) +ladish_app_handle ladish_find_app_by_pid(pid_t pid, ladish_graph_handle * graph_ptr) { struct app_find_context context; @@ -119,7 +119,10 @@ static ladish_app_handle ladish_virtualizer_find_app_by_pid(struct virtualizer * } ASSERT(context.graph != NULL); - *graph_ptr = context.graph; + if (graph_ptr != NULL) + { + *graph_ptr = context.graph; + } return context.app; } @@ -289,7 +292,7 @@ static void client_appeared(void * context, uint64_t id, const char * jack_name) } else { - app = ladish_virtualizer_find_app_by_pid(virtualizer_ptr, pid, &graph); + app = ladish_find_app_by_pid(pid, &graph); if (app != NULL) { ladish_app_get_uuid(app, app_uuid); @@ -610,7 +613,7 @@ port_appeared( { log_info("ALSA client pid is %lld", (long long)pid); - app = ladish_virtualizer_find_app_by_pid(virtualizer_ptr, pid, &vgraph); + app = ladish_find_app_by_pid(pid, &vgraph); if (app != NULL) { ladish_app_get_uuid(app, app_uuid); diff --git a/daemon/virtualizer.h b/daemon/virtualizer.h index 5536808b..48dd132d 100644 --- a/daemon/virtualizer.h +++ b/daemon/virtualizer.h @@ -30,6 +30,7 @@ #include "common.h" #include "../proxies/graph_proxy.h" #include "graph.h" +#include "app_supervisor.h" typedef struct ladish_virtualizer { int unused; } * ladish_virtualizer_handle; @@ -92,4 +93,9 @@ ladish_virtualizer_join_clients( uint64_t client1_id, uint64_t client2_id); +ladish_app_handle +ladish_find_app_by_pid( + pid_t pid, + ladish_graph_handle * graph_ptr); + #endif /* #ifndef JACK_DISPATCH_H__C7566B66_081D_4D00_A702_7C18F7CC0735__INCLUDED */ diff --git a/dbus/object_path.c b/dbus/object_path.c index 80b43191..f75163a7 100644 --- a/dbus/object_path.c +++ b/dbus/object_path.c @@ -2,7 +2,7 @@ /* * LADI Session Handler (ladish) * - * Copyright (C) 2008, 2009, 2010 Nedko Arnaudov + * Copyright (C) 2008,2009,2010,2011 Nedko Arnaudov * Copyright (C) 2008 Juuso Alasuutari * ************************************************************************** @@ -427,6 +427,7 @@ bool dbus_object_path_register(DBusConnection * connection_ptr, dbus_object_path if (!dbus_connection_register_object_path(connection_ptr, opath_ptr->name, &vtable, opath_ptr)) { + log_error("dbus_connection_register_object_path() failed."); return false; } diff --git a/gui/gladish.ui b/gui/gladish.ui index f11ae3a9..8293e8e3 100644 --- a/gui/gladish.ui +++ b/gui/gladish.ui @@ -1238,7 +1238,7 @@ along with LADI Session Handler; if not, write to the Free Software Foundation, True app_level0 False - False + True True diff --git a/lash_compat/liblash/lash.c b/lash_compat/liblash/lash.c index 6450b71f..ca563d4c 100644 --- a/lash_compat/liblash/lash.c +++ b/lash_compat/liblash/lash.c @@ -262,6 +262,7 @@ lash_client_t * lash_init(const lash_args_t * args, const char * class, int clie const char * dbus_unique_name; bool ret; dbus_uint32_t flags32; + dbus_uint64_t pid; if ((client_flags & LASH_Server_Interface) != 0) { @@ -302,7 +303,8 @@ lash_client_t * lash_init(const lash_args_t * args, const char * class, int clie } flags32 = client_flags; - msg_ptr = cdbus_new_method_call_message(SERVICE_NAME, LASH_SERVER_OBJECT_PATH, IFACE_LASH_SERVER, "Init", "su", &class, &flags32); + pid = getpid(); + msg_ptr = cdbus_new_method_call_message(SERVICE_NAME, LASH_SERVER_OBJECT_PATH, IFACE_LASH_SERVER, "RegisterClient", "tsu", &pid, &class, &flags32); if (msg_ptr == NULL) { goto close_connection; diff --git a/proxies/lash_client_proxy.c b/proxies/lash_client_proxy.c new file mode 100644 index 00000000..f1c2baf6 --- /dev/null +++ b/proxies/lash_client_proxy.c @@ -0,0 +1,60 @@ +/* -*- Mode: C ; c-basic-offset: 2 -*- */ +/* + * LADI Session Handler (ladish) + * + * Copyright (C) 2011 Nedko Arnaudov + * + ************************************************************************** + * This file contains helper functionality for accessing LASH clients through D-Bus + ************************************************************************** + * + * LADI Session Handler is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * LADI Session Handler is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with LADI Session Handler. If not, see + * or write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "lash_client_proxy.h" + +bool lash_client_proxy_quit(const char * dest) +{ + if (!dbus_call(0, dest, "/", IFACE_LASH_CLIENT, "Quit", "", "")) + { + log_error(IFACE_LASH_CLIENT "::Quit() failed."); + return false; + } + + return true; +} + +bool lash_client_proxy_save(const char * dest, const char * app_dir) +{ + if (!dbus_call(0, dest, "/", IFACE_LASH_CLIENT, "Save", "s", &app_dir, "")) + { + log_error(IFACE_LASH_CLIENT "::Save() failed."); + return false; + } + + return true; +} + +bool lash_client_proxy_restore(const char * dest, const char * app_dir) +{ + if (!dbus_call(0, dest, "/", IFACE_LASH_CLIENT, "Restore", "s", &app_dir, "")) + { + log_error(IFACE_LASH_CLIENT "::Restore() failed."); + return false; + } + + return true; +} diff --git a/proxies/lash_client_proxy.h b/proxies/lash_client_proxy.h new file mode 100644 index 00000000..6f8cb1f3 --- /dev/null +++ b/proxies/lash_client_proxy.h @@ -0,0 +1,37 @@ +/* -*- Mode: C ; c-basic-offset: 2 -*- */ +/* + * LADI Session Handler (ladish) + * + * Copyright (C) 2011 Nedko Arnaudov + * + ************************************************************************** + * This file contains interface to the helper functionality for accessing + * LASH clients through D-Bus + ************************************************************************** + * + * LADI Session Handler is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * LADI Session Handler is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with LADI Session Handler. If not, see + * or write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef LASH_CLIENT_PROXY_H__EE7D1E7B_D2AA_405D_BE28_3C4F0FE26E19__INCLUDED +#define LASH_CLIENT_PROXY_H__EE7D1E7B_D2AA_405D_BE28_3C4F0FE26E19__INCLUDED + +#include "common.h" + +bool lash_client_proxy_quit(const char * dest); +bool lash_client_proxy_save(const char * dest, const char * app_dir); +bool lash_client_proxy_restore(const char * dest, const char * app_dir); + +#endif /* #ifndef LASH_CLIENT_PROXY_H__EE7D1E7B_D2AA_405D_BE28_3C4F0FE26E19__INCLUDED */ diff --git a/wscript b/wscript index 3e6877de..773f9e7d 100644 --- a/wscript +++ b/wscript @@ -368,6 +368,7 @@ def build(bld): 'recent_store.c', 'recent_projects.c', 'check_integrity.c', + 'lash_server.c', ]: daemon.source.append(os.path.join("daemon", source)) @@ -378,6 +379,7 @@ def build(bld): "jmcore_proxy.c", "notify_proxy.c", "conf_proxy.c", + "lash_client_proxy.c", ]: daemon.source.append(os.path.join("proxies", source))