1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
3 * LADI Session Handler (ladish)
5 * Copyright (C) 2009 Nedko Arnaudov <nedko@arnaudov.name>
7 **************************************************************************
8 * This file contains implementation of code that interfaces
9 * app supervisor object through D-Bus
10 **************************************************************************
12 * LADI Session Handler is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * LADI Session Handler is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
24 * or write to the Free Software Foundation, Inc.,
25 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include "app_supervisor_proxy.h"
29 #include "../dbus/helpers.h"
30 #include "../dbus_constants.h"
32 struct ladish_app_supervisor_proxy
39 bool ladish_app_supervisor_proxy_create(const char * service
, const char * object
, ladish_app_supervisor_proxy_handle
* handle_ptr
)
41 struct ladish_app_supervisor_proxy
* proxy_ptr
;
43 proxy_ptr
= malloc(sizeof(struct ladish_app_supervisor_proxy
));
44 if (proxy_ptr
== NULL
)
46 log_error("malloc() failed to allocate struct proxy");
50 proxy_ptr
->service
= strdup(service
);
51 if (proxy_ptr
->service
== NULL
)
53 log_error("strdup() failed too duplicate service name '%s'", service
);
57 proxy_ptr
->object
= strdup(object
);
58 if (proxy_ptr
->object
== NULL
)
60 log_error("strdup() failed too duplicate object name '%s'", object
);
64 proxy_ptr
->version
= 0;
66 *handle_ptr
= (ladish_app_supervisor_proxy_handle
)proxy_ptr
;
71 free(proxy_ptr
->service
);
80 #define proxy_ptr ((struct ladish_app_supervisor_proxy *)proxy)
82 void ladish_app_supervisor_proxy_destroy(ladish_app_supervisor_proxy_handle proxy
)
84 free(proxy_ptr
->object
);
85 free(proxy_ptr
->service
);
89 bool ladish_app_supervisor_proxy_run_custom(ladish_app_supervisor_proxy_handle proxy
, const char * command
, const char * name
, bool run_in_terminal
)
92 if (!dbus_call(proxy_ptr
->service
, proxy_ptr
->object
, IFACE_APP_SUPERVISOR
, "RunCustom", "bss", &terminal
, &command
, &name
, ""))
94 log_error("RunCustom() failed.");