Back to index

bamf  0.2.120
Classes | Defines | Functions
bamf-indicator.c File Reference
#include "bamf-view-private.h"
#include "bamf-indicator.h"
#include "bamf-factory.h"
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>

Go to the source code of this file.

Classes

struct  _BamfIndicatorPrivate

Defines

#define BAMF_INDICATOR_GET_PRIVATE(o)   (G_TYPE_INSTANCE_GET_PRIVATE ((o), BAMF_TYPE_INDICATOR, BamfIndicatorPrivate))

Functions

 G_DEFINE_TYPE (BamfIndicator, bamf_indicator, BAMF_TYPE_VIEW)
 SECTION:bamf-indicator : The base class for all indicators.
const gchar * bamf_indicator_get_dbus_menu_path (BamfIndicator *self)
const gchar * bamf_indicator_get_remote_path (BamfIndicator *self)
const gchar * bamf_indicator_get_remote_address (BamfIndicator *self)
static void bamf_indicator_dispose (GObject *object)
static void bamf_indicator_set_path (BamfView *view, const char *path)
static void bamf_indicator_class_init (BamfIndicatorClass *klass)
static void bamf_indicator_init (BamfIndicator *self)
BamfIndicator * bamf_indicator_new (const char *path)

Class Documentation

struct _BamfIndicatorPrivate

Definition at line 49 of file bamf-indicator.c.

Class Members
char * address
gchar * address
DBusGConnection * connection
BamfDBusItemIndicator * dbus_iface
gchar * dbus_menu
char * id
char * path
gchar * path
guint32 pid
GDBusProxy * proxy
DBusGProxy * proxy

Define Documentation

#define BAMF_INDICATOR_GET_PRIVATE (   o)    (G_TYPE_INSTANCE_GET_PRIVATE ((o), BAMF_TYPE_INDICATOR, BamfIndicatorPrivate))

Definition at line 46 of file bamf-indicator.c.


Function Documentation

static void bamf_indicator_class_init ( BamfIndicatorClass *  klass) [static]

Definition at line 233 of file bamf-indicator.c.

{
  GObjectClass  *obj_class  = G_OBJECT_CLASS (klass);
  BamfViewClass *view_class = BAMF_VIEW_CLASS (klass);

  g_type_class_add_private (obj_class, sizeof (BamfIndicatorPrivate));
  
  obj_class->dispose     = bamf_indicator_dispose;
  view_class->set_path   = bamf_indicator_set_path;
}

Here is the call graph for this function:

static void bamf_indicator_dispose ( GObject *  object) [static]

Definition at line 172 of file bamf-indicator.c.

{
  BamfIndicator *self;
  BamfIndicatorPrivate *priv;
  
  self = BAMF_INDICATOR (object);
  priv = self->priv;

  if (priv->proxy)
    {
      g_object_unref (priv->proxy);
      priv->proxy = NULL;
    }
  
  if (priv->path)
    {
      g_free (priv->path);
      priv->path = NULL;
    }
  
  if (priv->dbus_menu)
    {
      g_free (priv->dbus_menu);
      priv->dbus_menu = NULL;
    }
  
  if (priv->address)
    {
      g_free (priv->address);
      priv->address = NULL;
    }
  
  if (G_OBJECT_CLASS (bamf_indicator_parent_class)->dispose)
    G_OBJECT_CLASS (bamf_indicator_parent_class)->dispose (object);
}

Here is the caller graph for this function:

const gchar* bamf_indicator_get_dbus_menu_path ( BamfIndicator *  self)

Definition at line 59 of file bamf-indicator.c.

{
  BamfIndicatorPrivate *priv;
  gchar *path = NULL;
  DBusGProxy *proxy;
  GValue value = {0};
  GError *error = NULL;

  g_return_val_if_fail (BAMF_IS_INDICATOR (self), NULL);
  priv = self->priv;
  
  if (priv->dbus_menu)
    return priv->dbus_menu;
  
  if (!_bamf_view_remote_ready (BAMF_VIEW (self)))
    return NULL;
  
  proxy = dbus_g_proxy_new_for_name (priv->connection,
                                     bamf_indicator_get_remote_address (self),
                                     bamf_indicator_get_remote_path (self),
                                     "org.freedesktop.DBus.Properties");
  
  if (!dbus_g_proxy_call (proxy,
                          "Get",
                          &error,
                          G_TYPE_STRING, "org.kde.StatusNotifierItem",
                          G_TYPE_STRING, "Menu",
                          G_TYPE_INVALID,
                          G_TYPE_VALUE, &value,
                          G_TYPE_INVALID))
    {
      g_warning ("Failed to fetch remote path: %s", error->message);
      g_error_free (error);
      
      return NULL;
    }
  
  path = g_value_get_boxed (&value);
  priv->dbus_menu = path;

  g_object_unref (proxy);
  return priv->dbus_menu;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const gchar* bamf_indicator_get_remote_address ( BamfIndicator *  self)

Definition at line 138 of file bamf-indicator.c.

{
  BamfIndicatorPrivate *priv;
  char *address = NULL;
  GError *error = NULL;

  g_return_val_if_fail (BAMF_IS_INDICATOR (self), NULL);
  priv = self->priv;
  
  if (priv->address)
    return priv->address;
  
  if (!_bamf_view_remote_ready (BAMF_VIEW (self)))
    return NULL;
  
  if (!dbus_g_proxy_call (priv->proxy,
                          "Address",
                          &error,
                          G_TYPE_INVALID,
                          G_TYPE_STRING, &address,
                          G_TYPE_INVALID))
    {
      g_warning ("Failed to fetch remote path: %s", error->message);
      g_error_free (error);
      
      return NULL;
    }

  priv->address = address;

  return address;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const gchar* bamf_indicator_get_remote_path ( BamfIndicator *  self)

Definition at line 104 of file bamf-indicator.c.

{
  BamfIndicatorPrivate *priv;
  char *path = NULL;
  GError *error = NULL;

  g_return_val_if_fail (BAMF_IS_INDICATOR (self), NULL);
  priv = self->priv;
  
  if (priv->path)
    return priv->path;
  
  if (!_bamf_view_remote_ready (BAMF_VIEW (self)))
    return NULL;
  
  if (!dbus_g_proxy_call (priv->proxy,
                          "Path",
                          &error,
                          G_TYPE_INVALID,
                          G_TYPE_STRING, &path,
                          G_TYPE_INVALID))
    {
      g_warning ("Failed to fetch remote path: %s", error->message);
      g_error_free (error);
      
      return NULL;
    }

  priv->path = path;

  return path;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void bamf_indicator_init ( BamfIndicator *  self) [static]

Definition at line 246 of file bamf-indicator.c.

{
  BamfIndicatorPrivate *priv;
  GError           *error = NULL;

  priv = self->priv = BAMF_INDICATOR_GET_PRIVATE (self);

  priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
  if (priv->connection == NULL)
    {
      g_critical ("Failed to open connection to bus: %s",
               error != NULL ? error->message : "Unknown");
      if (error)
        g_error_free (error);
      return;
    }
}
BamfIndicator* bamf_indicator_new ( const char *  path)

Definition at line 265 of file bamf-indicator.c.

{
  BamfIndicator *self;
  self = g_object_new (BAMF_TYPE_INDICATOR, NULL);

  _bamf_view_set_path (BAMF_VIEW (self), path);

  return self;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void bamf_indicator_set_path ( BamfView *  view,
const char *  path 
) [static]

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

{
  BamfIndicator *self;
  BamfIndicatorPrivate *priv;
  
  self = BAMF_INDICATOR (view);
  priv = self->priv;

  if (priv->proxy)
    {
      g_object_unref (priv->proxy);
    }

  priv->proxy = dbus_g_proxy_new_for_name (priv->connection,
                                           "org.ayatana.bamf",
                                           path,
                                           "org.ayatana.bamf.indicator");
  if (priv->proxy == NULL)
    {
      g_error ("Unable to get org.ayatana.bamf.indicator indicator");
    }
}

Here is the caller graph for this function:

G_DEFINE_TYPE ( BamfIndicator  ,
bamf_indicator  ,
BAMF_TYPE_VIEW   
)

SECTION:bamf-indicator : The base class for all indicators.

BamfIndicator is the base class that all indicators need to derive from.