Back to index

unity  6.0.0
Public Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
unity::debug::DebugDBusInterface Class Reference

#include <DebugDBusInterface.h>

List of all members.

Public Member Functions

 DebugDBusInterface (Introspectable *introspectable)
 ~DebugDBusInterface ()

Static Private Member Functions

static void OnBusAcquired (GDBusConnection *connection, const gchar *name, gpointer data)
static void OnNameAcquired (GDBusConnection *connection, const gchar *name, gpointer data)
static void OnNameLost (GDBusConnection *connection, const gchar *name, gpointer data)
static void HandleDBusMethodCall (GDBusConnection *connection, const gchar *sender, const gchar *object_path, const gchar *interface_name, const gchar *method_name, GVariant *parameters, GDBusMethodInvocation *invocation, gpointer user_data)
static GVariant * BuildFakeReturn ()

Private Attributes

guint _owner_id

Static Private Attributes

static const char * DBUS_DEBUG_OBJECT_PATH = "/com/canonical/Unity/Debug"
static const gchar introspection_xml [] = " </node>"
static GDBusInterfaceVTable interface_vtable

Detailed Description

Definition at line 36 of file DebugDBusInterface.h.


Constructor & Destructor Documentation

Definition at line 103 of file DebugDBusInterface.cpp.

{
  _parent_introspectable = parent;
  _owner_id = g_bus_own_name(G_BUS_TYPE_SESSION,
                             unity::DBUS_BUS_NAME.c_str(),
                             G_BUS_NAME_OWNER_FLAGS_NONE,
                             &DebugDBusInterface::OnBusAcquired,
                             &DebugDBusInterface::OnNameAcquired,
                             &DebugDBusInterface::OnNameLost,
                             this,
                             NULL);
}

Here is the call graph for this function:

Definition at line 116 of file DebugDBusInterface.cpp.

{
  g_bus_unown_name(_owner_id);
}

Member Function Documentation

static GVariant* unity::debug::DebugDBusInterface::BuildFakeReturn ( ) [static, private]
void unity::debug::DebugDBusInterface::HandleDBusMethodCall ( GDBusConnection *  connection,
const gchar *  sender,
const gchar *  object_path,
const gchar *  interface_name,
const gchar *  method_name,
GVariant *  parameters,
GDBusMethodInvocation *  invocation,
gpointer  user_data 
) [static, private]

Definition at line 165 of file DebugDBusInterface.cpp.

{
  if (g_strcmp0(method_name, "GetState") == 0)
  {
    GVariant* ret;
    const gchar* input;
    g_variant_get(parameters, "(&s)", &input);

    ret = GetState(input);
    // GetState returns a floating variant and
    // g_dbus_method_invocation_return_value ref sinks it
    g_dbus_method_invocation_return_value(invocation, ret);
  }
  else if (g_strcmp0(method_name, "StartLogToFile") == 0)
  {
    const gchar* log_path;
    g_variant_get(parameters, "(&s)", &log_path);

    StartLogToFile(log_path);
    g_dbus_method_invocation_return_value(invocation, NULL);
  }
  else if (g_strcmp0(method_name, "ResetLogging") == 0)
  {
    ResetLogging();
    g_dbus_method_invocation_return_value(invocation, NULL);
  }
  else if (g_strcmp0(method_name, "SetLogSeverity") == 0)
  {
    const gchar* component;
    const gchar* severity;
    g_variant_get(parameters, "(&s&s)", &component, &severity);

    SetLogSeverity(component, severity);
    g_dbus_method_invocation_return_value(invocation, NULL);
  }
  else if (g_strcmp0(method_name, "LogMessage") == 0)
  {
    const gchar* severity;
    const gchar* message;
    g_variant_get(parameters, "(&s&s)", &severity, &message);

    LogMessage(severity, message);
    g_dbus_method_invocation_return_value(invocation, NULL);
  }
  else
  {
    g_dbus_method_invocation_return_dbus_error(invocation,
                                               unity::DBUS_BUS_NAME.c_str(),
                                               "Failed to find method");
  }
}

Here is the call graph for this function:

void unity::debug::DebugDBusInterface::OnBusAcquired ( GDBusConnection *  connection,
const gchar *  name,
gpointer  data 
) [static, private]

Definition at line 122 of file DebugDBusInterface.cpp.

{
  int i = 0;
  GError* error;

  GDBusNodeInfo* introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL);
  if (!introspection_data)
  {
    LOG_WARNING(logger) << "No dbus introspection data could be loaded. State introspection will not work";
    return;
  }

  while (introspection_data->interfaces[i] != NULL)
  {
    error = NULL;
    g_dbus_connection_register_object(connection,
                                      DebugDBusInterface::DBUS_DEBUG_OBJECT_PATH,
                                      introspection_data->interfaces[i],
                                      &interface_vtable,
                                      data,
                                      NULL,
                                      &error);
    if (error != NULL)
    {
      g_warning("Could not register debug interface onto d-bus");
      g_error_free(error);
    }
    i++;
  }
  g_dbus_node_info_unref(introspection_data);
}

Here is the caller graph for this function:

void unity::debug::DebugDBusInterface::OnNameAcquired ( GDBusConnection *  connection,
const gchar *  name,
gpointer  data 
) [static, private]

Definition at line 155 of file DebugDBusInterface.cpp.

{
}

Here is the caller graph for this function:

void unity::debug::DebugDBusInterface::OnNameLost ( GDBusConnection *  connection,
const gchar *  name,
gpointer  data 
) [static, private]

Definition at line 160 of file DebugDBusInterface.cpp.

{
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 62 of file DebugDBusInterface.h.

const char * unity::debug::DebugDBusInterface::DBUS_DEBUG_OBJECT_PATH = "/com/canonical/Unity/Debug" [static, private]

Definition at line 55 of file DebugDBusInterface.h.

GDBusInterfaceVTable unity::debug::DebugDBusInterface::interface_vtable [static, private]
Initial value:

Definition at line 57 of file DebugDBusInterface.h.

const gchar unity::debug::DebugDBusInterface::introspection_xml = " </node>" [static, private]

Definition at line 56 of file DebugDBusInterface.h.


The documentation for this class was generated from the following files: