Back to index

bamf  0.2.120
Classes | Defines | Functions | Variables
bamf-daemon.c File Reference
#include "bamf.h"
#include "bamf-daemon.h"
#include "bamf-matcher.h"
#include "bamf-control.h"
#include "bamf-indicator-source.h"

Go to the source code of this file.

Classes

struct  _BamfDaemonPrivate

Defines

#define BAMF_DAEMON_GET_PRIVATE(obj)

Functions

 G_DEFINE_TYPE (BamfDaemon, bamf_daemon, G_TYPE_OBJECT)
gboolean bamf_daemon_is_running (BamfDaemon *self)
static void bamf_on_bus_acquired (GDBusConnection *connection, const gchar *name, BamfDaemon *self)
static void bamf_on_name_acquired (GDBusConnection *connection, const gchar *name, BamfDaemon *self)
static void bamf_on_name_lost (GDBusConnection *connection, const gchar *name, BamfDaemon *self)
void bamf_daemon_start (BamfDaemon *self)
void bamf_daemon_stop (BamfDaemon *self)
static void bamf_daemon_dispose (GObject *object)
static void bamf_daemon_finalize (GObject *object)
static void bamf_daemon_init (BamfDaemon *self)
static void bamf_daemon_class_init (BamfDaemonClass *klass)
BamfDaemon * bamf_daemon_get_default (void)

Variables

static BamfDaemon * instance = NULL

Class Documentation

struct _BamfDaemonPrivate

Definition at line 33 of file bamf-daemon.c.

Class Members
BamfIndicatorSource * approver
BamfControl * control
GMainLoop * loop
BamfMatcher * matcher

Define Documentation

#define BAMF_DAEMON_GET_PRIVATE (   obj)
Value:
(G_TYPE_INSTANCE_GET_PRIVATE(obj, \
                                      BAMF_TYPE_DAEMON, BamfDaemonPrivate))

Definition at line 28 of file bamf-daemon.c.


Function Documentation

static void bamf_daemon_class_init ( BamfDaemonClass *  klass) [static]

Definition at line 198 of file bamf-daemon.c.

{
  GObjectClass *object_class = G_OBJECT_CLASS (klass);

  object_class->dispose  = bamf_daemon_dispose;
  object_class->finalize = bamf_daemon_finalize;

  g_type_class_add_private (klass, sizeof (BamfDaemonPrivate));
}

Here is the call graph for this function:

static void bamf_daemon_dispose ( GObject *  object) [static]

Definition at line 167 of file bamf-daemon.c.

{
  BamfDaemon *self = BAMF_DAEMON (object);

  bamf_daemon_stop (self);

  if (self->priv->loop)
    {
      g_main_loop_unref (self->priv->loop);
      self->priv->loop = NULL;
    }

  G_OBJECT_CLASS (bamf_daemon_parent_class)->dispose (object);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void bamf_daemon_finalize ( GObject *  object) [static]

Definition at line 183 of file bamf-daemon.c.

{
  instance = NULL;
}

Here is the caller graph for this function:

BamfDaemon* bamf_daemon_get_default ( void  )

Definition at line 209 of file bamf-daemon.c.

{
  if (!BAMF_IS_DAEMON (instance))
    instance = (BamfDaemon *) g_object_new (BAMF_TYPE_DAEMON, NULL);

  return instance;
}

Here is the caller graph for this function:

static void bamf_daemon_init ( BamfDaemon *  self) [static]

Definition at line 189 of file bamf-daemon.c.

{
  BamfDaemonPrivate *priv;
  priv = self->priv = BAMF_DAEMON_GET_PRIVATE (self);

  priv->loop = g_main_loop_new (NULL, FALSE);
}
gboolean bamf_daemon_is_running ( BamfDaemon *  self)

Definition at line 42 of file bamf-daemon.c.

{
  g_return_val_if_fail (self, FALSE);

  if (self->priv->loop && g_main_loop_is_running (self->priv->loop))
    {
      return TRUE;
    }

  return FALSE;
}

Here is the caller graph for this function:

void bamf_daemon_start ( BamfDaemon *  self)

Definition at line 123 of file bamf-daemon.c.

{
  g_return_if_fail (BAMF_IS_DAEMON (self));

  if (bamf_daemon_is_running (self))
    return;

  g_bus_own_name (G_BUS_TYPE_SESSION, BAMF_DBUS_SERVICE,
                  G_BUS_NAME_OWNER_FLAGS_NONE,
                  (GBusAcquiredCallback) bamf_on_bus_acquired,
                  (GBusNameAcquiredCallback) bamf_on_name_acquired,
                  (GBusNameLostCallback) bamf_on_name_lost,
                  self, NULL);

  g_main_loop_run (self->priv->loop);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void bamf_daemon_stop ( BamfDaemon *  self)

Definition at line 141 of file bamf-daemon.c.

{
  g_return_if_fail (BAMF_IS_DAEMON (self));

  if (self->priv->matcher)
    {
      g_object_unref (self->priv->matcher);
      self->priv->matcher = NULL;
    }

  if (self->priv->control)
    {
      g_object_unref (self->priv->control);
      self->priv->control = NULL;
    }

  if (self->priv->approver)
    {
      g_object_unref (self->priv->approver);
      self->priv->approver = NULL;
    }

  g_main_loop_quit (self->priv->loop);
}

Here is the caller graph for this function:

static void bamf_on_bus_acquired ( GDBusConnection *  connection,
const gchar *  name,
BamfDaemon *  self 
) [static]

Definition at line 55 of file bamf-daemon.c.

{
  GError *error = NULL;
  g_return_if_fail (BAMF_IS_DAEMON (self));

  g_debug ("Acquired a message bus connection");

  g_dbus_connection_set_exit_on_close (connection, TRUE);

  self->priv->matcher = bamf_matcher_get_default ();
  self->priv->control = bamf_control_get_default ();
  //self->priv->approver = bamf_indicator_source_get_default ();

  g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->priv->matcher),
                                    connection,
                                    BAMF_MATCHER_PATH,
                                    &error);

  if (error)
    {
      g_critical ("Can't register BAMF matcher at path %s: %s", BAMF_MATCHER_PATH,
                                                                error->message);
      g_clear_error (&error);
    }

  g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->priv->control),
                                    connection,
                                    BAMF_CONTROL_PATH,
                                    &error);

  if (error)
    {
      g_critical ("Can't register BAMF control at path %s: %s", BAMF_CONTROL_PATH,
                                                                error->message);
      g_clear_error (&error);
    }
/*
  g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->priv->approver),
                                    connection,
                                    BAMF_INDICATOR_SOURCE_PATH,
                                    &error);

  if (error)
    {
      g_critical ("Can't register BAMF approver at path %s: %s",
                                     BAMF_INDICATOR_SOURCE_PATH, error->message);
      g_clear_error (&error);
    }
*/
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void bamf_on_name_acquired ( GDBusConnection *  connection,
const gchar *  name,
BamfDaemon *  self 
) [static]

Definition at line 108 of file bamf-daemon.c.

{
  g_debug ("Acquired the name %s", name);
}

Here is the caller graph for this function:

static void bamf_on_name_lost ( GDBusConnection *  connection,
const gchar *  name,
BamfDaemon *  self 
) [static]

Definition at line 115 of file bamf-daemon.c.

{
  g_critical ("Lost the name %s, another BAMF daemon is currently running", name);

  bamf_daemon_stop (self);
}

Here is the call graph for this function:

Here is the caller graph for this function:

G_DEFINE_TYPE ( BamfDaemon  ,
bamf_daemon  ,
G_TYPE_OBJECT   
)

Variable Documentation

BamfDaemon* instance = NULL [static]

Definition at line 31 of file bamf-daemon.c.