IsStudioLoaded method
This commit is contained in:
parent
d88e11f203
commit
706229337a
|
@ -33,6 +33,36 @@
|
|||
|
||||
#define INTERFACE_NAME DBUS_NAME_BASE ".Control"
|
||||
|
||||
static void ladish_is_studio_loaded(method_call_t * call_ptr)
|
||||
{
|
||||
DBusMessageIter iter;
|
||||
dbus_bool_t is_loaded;
|
||||
|
||||
is_loaded = g_studio != NULL;
|
||||
|
||||
call_ptr->reply = dbus_message_new_method_return(call_ptr->message);
|
||||
if (call_ptr->reply == NULL)
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
|
||||
dbus_message_iter_init_append(call_ptr->reply, &iter);
|
||||
|
||||
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_BOOLEAN, &is_loaded))
|
||||
{
|
||||
goto fail_unref;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
fail_unref:
|
||||
dbus_message_unref(call_ptr->reply);
|
||||
call_ptr->reply = NULL;
|
||||
|
||||
fail:
|
||||
lash_error("Ran out of memory trying to construct method return");
|
||||
}
|
||||
|
||||
static void ladish_get_studio_list(method_call_t * call_ptr)
|
||||
{
|
||||
DBusMessageIter iter, array_iter;
|
||||
|
@ -205,6 +235,10 @@ void emit_studio_disappeared()
|
|||
signal_new_valist(g_dbus_connection, CONTROL_OBJECT_PATH, INTERFACE_NAME, "StudioDisappeared", DBUS_TYPE_INVALID);
|
||||
}
|
||||
|
||||
METHOD_ARGS_BEGIN(IsStudioLoaded, "Check whether studio D-Bus object is present")
|
||||
METHOD_ARG_DESCRIBE_OUT("present", "b", "Whether studio D-Bus object is present")
|
||||
METHOD_ARGS_END
|
||||
|
||||
METHOD_ARGS_BEGIN(GetStudioList, "Get list of studios")
|
||||
METHOD_ARG_DESCRIBE_OUT("studio_list", "a(sa{sv})", "List of studios, name and properties")
|
||||
METHOD_ARGS_END
|
||||
|
@ -222,6 +256,7 @@ METHOD_ARGS_BEGIN(Exit, "Tell ladish D-Bus service to exit")
|
|||
METHOD_ARGS_END
|
||||
|
||||
METHODS_BEGIN
|
||||
METHOD_DESCRIBE(IsStudioLoaded, ladish_is_studio_loaded)
|
||||
METHOD_DESCRIBE(GetStudioList, ladish_get_studio_list)
|
||||
METHOD_DESCRIBE(LoadStudio, ladish_load_studio)
|
||||
METHOD_DESCRIBE(GetApplicationList, ladish_get_application_list)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/*
|
||||
* LADI Session Handler (ladish)
|
||||
*
|
||||
* Copyright (C) 2008 Nedko Arnaudov <nedko@arnaudov.name>
|
||||
* Copyright (C) 2008, 2009 Nedko Arnaudov <nedko@arnaudov.name>
|
||||
*
|
||||
**************************************************************************
|
||||
* This file contains code that communicates with ladishd through D-Bus
|
||||
|
@ -37,7 +37,7 @@
|
|||
#include "dbus_helpers.h"
|
||||
|
||||
#define LASH_SERVICE DBUS_NAME_BASE
|
||||
#define LASH_OBJECT "/"
|
||||
#define LASH_OBJECT "/org/ladish/Control"
|
||||
#define LASH_IFACE_CONTROL DBUS_NAME_BASE ".Control"
|
||||
|
||||
struct lash_proxy_impl
|
||||
|
@ -46,6 +46,7 @@ struct lash_proxy_impl
|
|||
|
||||
void fetch_loaded_projects();
|
||||
void fetch_project_clients(boost::shared_ptr<project> project_ptr);
|
||||
bool is_studio_loaded();
|
||||
|
||||
static void error_msg(const std::string& msg);
|
||||
static void info_msg(const std::string& msg);
|
||||
|
@ -121,7 +122,7 @@ lash_proxy_impl::init()
|
|||
// this also actiavtes lash object if it not activated already
|
||||
//fetch_loaded_projects();
|
||||
|
||||
g_app->set_studio_availability(false);
|
||||
g_app->set_studio_availability(is_studio_loaded());
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -930,3 +931,34 @@ lash_proxy_impl::exit()
|
|||
|
||||
dbus_message_unref(reply_ptr);
|
||||
}
|
||||
|
||||
bool
|
||||
lash_proxy_impl::is_studio_loaded()
|
||||
{
|
||||
DBusMessage* reply_ptr;
|
||||
const char * reply_signature;
|
||||
DBusMessageIter iter;
|
||||
dbus_bool_t is_loaded;
|
||||
|
||||
if (!call(true, LASH_IFACE_CONTROL, "IsStudioLoaded", &reply_ptr, DBUS_TYPE_INVALID))
|
||||
{
|
||||
error_msg("IsStudioLoaded() call failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
reply_signature = dbus_message_get_signature(reply_ptr);
|
||||
|
||||
if (strcmp(reply_signature, "b") != 0)
|
||||
{
|
||||
error_msg((std::string)"IsStudioLoaded() reply signature mismatch. " + reply_signature);
|
||||
dbus_message_unref(reply_ptr);
|
||||
return false;
|
||||
}
|
||||
|
||||
dbus_message_iter_init(reply_ptr, &iter);
|
||||
|
||||
dbus_message_iter_get_basic(&iter, &is_loaded);
|
||||
|
||||
dbus_message_unref(reply_ptr);
|
||||
return is_loaded;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue