Back to index

bamf  0.2.120
Classes | Defines | Enumerations | Functions
bamf-indicator.c File Reference
#include "bamf-indicator.h"

Go to the source code of this file.

Classes

struct  _BamfIndicatorPrivate

Defines

#define BAMF_INDICATOR_GET_PRIVATE(object)

Enumerations

enum  {
  PROP_0, PROP_ADDRESS, PROP_PID, PROP_PATH,
  PROP_ID
}

Functions

const char * bamf_indicator_get_path (BamfIndicator *self)
const char * bamf_indicator_get_address (BamfIndicator *self)
const char * bamf_indicator_get_id (BamfIndicator *self)
guint32 bamf_indicator_get_pid (BamfIndicator *self)
gboolean bamf_indicator_matches_signature (BamfIndicator *self, gint pid, const char *address, const char *path)
static const char * bamf_indicator_get_view_type (BamfView *view)
static char * bamf_indicator_get_stable_bus_name (BamfView *view)
static void bamf_indicator_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
static void bamf_indicator_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
static void bamf_indicator_on_destroy (GObject *object, GParamSpec *pspec, BamfIndicator *self)
static gboolean on_dbus_handle_path (BamfDBusItemIndicator *interface, GDBusMethodInvocation *invocation, BamfIndicator *self)
static gboolean on_dbus_handle_address (BamfDBusItemIndicator *interface, GDBusMethodInvocation *invocation, BamfIndicator *self)
static void bamf_indicator_constructed (GObject *object)
static void bamf_indicator_dispose (GObject *object)
static void bamf_indicator_finalize (GObject *object)
static void bamf_indicator_class_init (BamfIndicatorClass *klass)
static void bamf_indicator_init (BamfIndicator *self)
BamfIndicator * bamf_indicator_new (const char *id, const char *path, const char *address, guint32 pid)

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 (   object)
Value:
(G_TYPE_INSTANCE_GET_PRIVATE((object), \
                                           BAMF_TYPE_INDICATOR, BamfIndicatorPrivate))

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


Enumeration Type Documentation

anonymous enum
Enumerator:
PROP_0 
PROP_ADDRESS 
PROP_PID 
PROP_PATH 
PROP_ID 

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


Function Documentation

static void bamf_indicator_class_init ( BamfIndicatorClass *  klass) [static]

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

{
  GParamSpec *pspec;
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
  BamfViewClass *view_class = BAMF_VIEW_CLASS (klass);

  object_class->constructed   = bamf_indicator_constructed;
  object_class->get_property  = bamf_indicator_get_property;
  object_class->set_property  = bamf_indicator_set_property;
  object_class->dispose       = bamf_indicator_dispose;
  object_class->finalize      = bamf_indicator_finalize;

  view_class->view_type       = bamf_indicator_get_view_type;
  view_class->stable_bus_name = bamf_indicator_get_stable_bus_name;

  pspec = g_param_spec_string ("address", "address", "address", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
  g_object_class_install_property (object_class, PROP_ADDRESS, pspec);
  
  pspec = g_param_spec_string ("path", "path", "path", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
  g_object_class_install_property (object_class, PROP_PATH, pspec);
  
  pspec = g_param_spec_string ("id", "id", "id", NULL, G_PARAM_READWRITE);
  g_object_class_install_property (object_class, PROP_ID, pspec);
  
  pspec = g_param_spec_uint ("pid", "pid", "pid", 0, G_MAXUINT32, 0, G_PARAM_READWRITE);
  g_object_class_install_property (object_class, PROP_PID, pspec);

  g_type_class_add_private (object_class, sizeof (BamfIndicatorPrivate));
}

Here is the call graph for this function:

static void bamf_indicator_constructed ( GObject *  object) [static]

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

{
  BamfIndicator *self;
  BamfIndicatorPrivate *priv;
  GDBusProxy *proxy;
  GError *error = NULL;

  if (G_OBJECT_CLASS (bamf_indicator_parent_class)->constructed)
    G_OBJECT_CLASS (bamf_indicator_parent_class)->constructed (object);

  self = BAMF_INDICATOR (object);
  priv = self->priv;

  proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
                                         G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES|
                                         G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS|
                                         G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
                                         NULL,
                                         priv->address,
                                         priv->path,
                                         "org.ayatana.indicator.application.service",
                                         NULL,
                                         &error);

  if (error)
    {
      g_debug ("Could not setup proxy: %s %s: %s", priv->address, priv->path,
                                                   error->message);
      g_error_free (error);
    }
  else
    {
      gchar *owner = g_dbus_proxy_get_name_owner (proxy);

      if (owner)
        {
          g_free (owner);

          g_signal_connect (G_OBJECT (proxy), "notify::g-name-owner",
                            G_CALLBACK (bamf_indicator_on_destroy), self);

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

          priv->proxy = proxy;
        }
      else
        {
           g_debug ("Failed to get notification approver proxy: no owner available");
           g_object_unref (proxy);
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void bamf_indicator_dispose ( GObject *  object) [static]

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

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

  if (priv->proxy)
    {
      g_object_unref (priv->proxy);
      priv->proxy = NULL;
    }
  
  if (priv->path)
    {
      g_free (priv->path);
      priv->path = NULL;
    }

  if (priv->address)
    {
      g_free (priv->address);
      priv->address = NULL;
    }
    
  if (priv->id)
    {
      g_free (priv->id);
      priv->id = NULL;
    }  

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

Here is the caller graph for this function:

static void bamf_indicator_finalize ( GObject *  object) [static]

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

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

  g_object_unref (priv->dbus_iface);

  G_OBJECT_CLASS (bamf_indicator_parent_class)->finalize (object);
}

Here is the caller graph for this function:

const char* bamf_indicator_get_address ( BamfIndicator *  self)

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

{
  g_return_val_if_fail (BAMF_IS_INDICATOR (self), NULL);
  return self->priv->address;
}

Here is the caller graph for this function:

const char* bamf_indicator_get_id ( BamfIndicator *  self)

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

{
  g_return_val_if_fail (BAMF_IS_INDICATOR (self), NULL);
  return self->priv->id;
}
const char* bamf_indicator_get_path ( BamfIndicator *  self)

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

{
  g_return_val_if_fail (BAMF_IS_INDICATOR (self), NULL);
  return self->priv->path;
}

Here is the caller graph for this function:

guint32 bamf_indicator_get_pid ( BamfIndicator *  self)

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

{
  g_return_val_if_fail (BAMF_IS_INDICATOR (self), 0);
  return self->priv->pid;
}

Here is the caller graph for this function:

static void bamf_indicator_get_property ( GObject *  object,
guint  property_id,
GValue *  value,
GParamSpec *  pspec 
) [static]

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

{
  BamfIndicator *self;

  self = BAMF_INDICATOR (object);

  switch (property_id)
    {
      case PROP_ADDRESS:
        g_value_set_string (value, self->priv->address);
        break;
      
      case PROP_PATH:
        g_value_set_string (value, self->priv->path);
        break;
      
      case PROP_ID:
        g_value_set_string (value, self->priv->id);
        break;
      
      case PROP_PID:
        g_value_set_uint (value, self->priv->pid);
        break;

      default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
    }
}

Here is the caller graph for this function:

static char* bamf_indicator_get_stable_bus_name ( BamfView *  view) [static]

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

{
  BamfIndicator *self;

  g_return_val_if_fail (BAMF_IS_INDICATOR (view), NULL);  
  self = BAMF_INDICATOR (view);
  
  return g_strdup_printf ("indicator%i", bamf_indicator_get_pid (self));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static const char* bamf_indicator_get_view_type ( BamfView *  view) [static]

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

{
  return "indicator";
}

Here is the caller graph for this function:

static void bamf_indicator_init ( BamfIndicator *  self) [static]

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

{
  self->priv = BAMF_INDICATOR_GET_PRIVATE (self);

  self->priv->dbus_iface = bamf_dbus_item_indicator_skeleton_new ();

  /* Registering signal callbacks to reply to dbus method calls */
  g_signal_connect (self->priv->dbus_iface, "handle-path",
                    G_CALLBACK (on_dbus_handle_path), self);

  g_signal_connect (self->priv->dbus_iface, "handle-address",
                    G_CALLBACK (on_dbus_handle_address), self);

  /* Setting the interface for the dbus object */
  bamf_dbus_item_object_skeleton_set_indicator (BAMF_DBUS_ITEM_OBJECT_SKELETON (self),
                                                self->priv->dbus_iface);
}

Here is the call graph for this function:

gboolean bamf_indicator_matches_signature ( BamfIndicator *  self,
gint  pid,
const char *  address,
const char *  path 
)

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

{
  g_return_val_if_fail (BAMF_IS_INDICATOR (self), FALSE);

  return g_strcmp0 (self->priv->address, address) == 0 &&
         g_strcmp0 (self->priv->path, path) == 0 &&
         pid == self->priv->pid;         
}

Here is the caller graph for this function:

BamfIndicator* bamf_indicator_new ( const char *  id,
const char *  path,
const char *  address,
guint32  pid 
)

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

{
  BamfIndicator *self;
  self = g_object_new (BAMF_TYPE_INDICATOR, 
                       "address", address,
                       "path", path,
                       "pid", pid,
                       "id", id,
                       NULL);
                       
  return self;
}
static void bamf_indicator_on_destroy ( GObject *  object,
GParamSpec *  pspec,
BamfIndicator *  self 
) [static]

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

{
  g_object_unref (self->priv->proxy);
  self->priv->proxy = NULL;

  bamf_view_close (BAMF_VIEW (self));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void bamf_indicator_set_property ( GObject *  object,
guint  property_id,
const GValue *  value,
GParamSpec *  pspec 
) [static]

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

{
  BamfIndicator *self;

  self = BAMF_INDICATOR (object);

  switch (property_id)
    {
      case PROP_ADDRESS:
        self->priv->address = g_value_dup_string (value);
        break;
      
      case PROP_PATH:
        self->priv->path = g_value_dup_string (value);
        break;
        
      case PROP_ID:
        self->priv->id = g_value_dup_string (value);
        break;
      
      case PROP_PID:
        self->priv->pid = g_value_get_uint (value);
        break;

      default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
    }
}

Here is the caller graph for this function:

static gboolean on_dbus_handle_address ( BamfDBusItemIndicator *  interface,
GDBusMethodInvocation *  invocation,
BamfIndicator *  self 
) [static]

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

{
  const char *address = bamf_indicator_get_address (self);
  g_dbus_method_invocation_return_value (invocation,
                                         g_variant_new ("(s)", address ? address : ""));

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static gboolean on_dbus_handle_path ( BamfDBusItemIndicator *  interface,
GDBusMethodInvocation *  invocation,
BamfIndicator *  self 
) [static]

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

{
  const char *path = bamf_indicator_get_path (self);
  g_dbus_method_invocation_return_value (invocation,
                                         g_variant_new ("(s)", path ? path : ""));

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function: