Back to index

bamf  0.2.120
Classes | Defines | Typedefs | Enumerations | Functions
bamf-indicator-source.h File Reference
#include <glib-object.h>
#include "bamf-indicator.h"
#include "bamf-gdbus-indicator-source-generated.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _BamfIndicatorSource
struct  _BamfIndicatorSourceClass

Defines

#define BAMF_TYPE_INDICATOR_SOURCE   (bamf_indicator_source_get_type ())
#define BAMF_INDICATOR_SOURCE(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAMF_TYPE_INDICATOR_SOURCE, BamfIndicatorSource))
#define BAMF_INDICATOR_SOURCE_CONST(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAMF_TYPE_INDICATOR_SOURCE, BamfIndicatorSource const))
#define BAMF_INDICATOR_SOURCE_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), BAMF_TYPE_INDICATOR_SOURCE, BamfIndicatorSourceClass))
#define BAMF_IS_INDICATOR_SOURCE(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BAMF_TYPE_INDICATOR_SOURCE))
#define BAMF_IS_INDICATOR_SOURCE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), BAMF_TYPE_INDICATOR_SOURCE))
#define BAMF_INDICATOR_SOURCE_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), BAMF_TYPE_INDICATOR_SOURCE, BamfIndicatorSourceClass))

Typedefs

typedef struct _BamfIndicatorSource
typedef struct _BamfIndicatorSourceClass
typedef struct _BamfIndicatorSourcePrivate

Enumerations

enum  { BAMF_INDICATOR_SOURCE_APPROVE_NONE, BAMF_INDICATOR_SOURCE_APPROVE_MATCHED, BAMF_INDICATOR_SOURCE_APPROVE_ALL }

Functions

GType bamf_indicator_source_get_type (void) G_GNUC_CONST
GList * bamf_indicator_source_get_indicators (BamfIndicatorSource *self)
gboolean bamf_indicator_source_approve_item (BamfIndicatorSource *self, const char *id, const char *category, guint32 pid, const char *address, const char *proxy)
void bamf_indicator_source_set_behavior (BamfIndicatorSource *self, gint32 behavior)
BamfIndicatorSource * bamf_indicator_source_get_default (void)

Class Documentation

struct _BamfIndicatorSource

Definition at line 49 of file bamf-indicator-source.h.

Class Members
StatusNotifierApproverSkeleton parent
BamfIndicatorSourcePrivate * priv

Define Documentation

#define BAMF_INDICATOR_SOURCE (   obj)    (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAMF_TYPE_INDICATOR_SOURCE, BamfIndicatorSource))

Definition at line 31 of file bamf-indicator-source.h.

#define BAMF_INDICATOR_SOURCE_CLASS (   klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), BAMF_TYPE_INDICATOR_SOURCE, BamfIndicatorSourceClass))

Definition at line 33 of file bamf-indicator-source.h.

#define BAMF_INDICATOR_SOURCE_CONST (   obj)    (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAMF_TYPE_INDICATOR_SOURCE, BamfIndicatorSource const))

Definition at line 32 of file bamf-indicator-source.h.

#define BAMF_INDICATOR_SOURCE_GET_CLASS (   obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), BAMF_TYPE_INDICATOR_SOURCE, BamfIndicatorSourceClass))

Definition at line 36 of file bamf-indicator-source.h.

#define BAMF_IS_INDICATOR_SOURCE (   obj)    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BAMF_TYPE_INDICATOR_SOURCE))

Definition at line 34 of file bamf-indicator-source.h.

#define BAMF_IS_INDICATOR_SOURCE_CLASS (   klass)    (G_TYPE_CHECK_CLASS_TYPE ((klass), BAMF_TYPE_INDICATOR_SOURCE))

Definition at line 35 of file bamf-indicator-source.h.

Definition at line 30 of file bamf-indicator-source.h.


Typedef Documentation

typedef struct _BamfIndicatorSource

Definition at line 38 of file bamf-indicator-source.h.

typedef struct _BamfIndicatorSourceClass

Definition at line 39 of file bamf-indicator-source.h.

Definition at line 40 of file bamf-indicator-source.h.


Enumeration Type Documentation

anonymous enum
Enumerator:
BAMF_INDICATOR_SOURCE_APPROVE_NONE 
BAMF_INDICATOR_SOURCE_APPROVE_MATCHED 
BAMF_INDICATOR_SOURCE_APPROVE_ALL 

Definition at line 42 of file bamf-indicator-source.h.


Function Documentation

gboolean bamf_indicator_source_approve_item ( BamfIndicatorSource *  self,
const char *  id,
const char *  category,
guint32  pid,
const char *  address,
const char *  proxy 
)

Definition at line 115 of file bamf-indicator-source.c.

{
  GList *l;
  GError *error = NULL;
  BamfIndicator *indicator = NULL;

  g_return_val_if_fail (category, TRUE);
  g_return_val_if_fail (path, TRUE);
  g_return_val_if_fail (address, TRUE);
  g_return_val_if_fail (BAMF_IS_INDICATOR_SOURCE (self), TRUE);

  if (g_strcmp0 (category, "ApplicationStatus") != 0 || 
      g_strcmp0 (path, "/com/canonical/NotificationItem/dropbox_client") == 0)
    return TRUE;

  if (pid == 0)
    {
      GDBusProxy *gproxy;
      GVariant *remote_pid;

      g_warning ("Remote service passed indicator with pid of 0, manually fetching pid");

      gproxy = 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,
                                              NULL,
                                              "org.freedesktop.DBus",
                                              "/org/freedesktop/DBus",
                                              "org.freedesktop.DBus",
                                              NULL,
                                              &error);

      if (error)
        {
          g_warning ("Could not get indicator process id: %s", error->message);
          g_clear_error (&error);
        }

      g_return_val_if_fail (G_IS_DBUS_PROXY (gproxy), TRUE);

      remote_pid = g_dbus_proxy_call_sync (gproxy, "GetConnectionUnixProcessID",
                                           g_variant_new ("(s)", address),
                                           G_DBUS_CALL_FLAGS_NONE,
                                           -1,
                                           NULL,
                                           &error);
      if (error)
        {
          g_warning ("Could not get indicator process id: %s", error->message);
          g_clear_error (&error);
          return TRUE;
        }

      g_return_val_if_fail (remote_pid, TRUE);

      pid = g_variant_get_uint32 (g_variant_get_child_value (remote_pid, 0));

      g_object_unref (gproxy);
      g_variant_unref (remote_pid);

      if (pid == 0)
        return TRUE;
    }

  for (l = self->priv->indicators; l; l = l->next)
    {
      if (bamf_indicator_matches_signature (BAMF_INDICATOR (l->data), pid, address, path))
        {
          g_debug ("NotifierWatcher service passed already known indicator, ignoring");
          indicator = BAMF_INDICATOR (l->data);
          break;
        }
    }

  if (!indicator)
    {
      indicator = bamf_indicator_new (id, path, address,  pid);
      self->priv->indicators = g_list_prepend (self->priv->indicators, indicator);
  
      g_signal_connect (G_OBJECT (indicator), "closed", (GCallback) on_indicator_closed, self);
      g_signal_emit (self, indicator_source_signals[INDICATOR_OPENED], 0, indicator);
    }

  GList *parents = bamf_view_get_parents (BAMF_VIEW (indicator));

  switch (self->priv->behavior)
    {
      case BAMF_INDICATOR_SOURCE_APPROVE_NONE:
        return FALSE;

      case BAMF_INDICATOR_SOURCE_APPROVE_MATCHED:
        return !(indicator && parents);

      case BAMF_INDICATOR_SOURCE_APPROVE_ALL:
        return TRUE;
    }

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

BamfIndicatorSource* bamf_indicator_source_get_default ( void  )

Definition at line 419 of file bamf-indicator-source.c.

{
  if (!approver)
    approver = g_object_new (BAMF_TYPE_INDICATOR_SOURCE, NULL);

  return approver;
}

Here is the caller graph for this function:

GList* bamf_indicator_source_get_indicators ( BamfIndicatorSource *  self)

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

{
  g_return_val_if_fail (BAMF_IS_INDICATOR_SOURCE (self), NULL);

  return self->priv->indicators;
}
void bamf_indicator_source_set_behavior ( BamfIndicatorSource *  self,
gint32  behavior 
)

Definition at line 97 of file bamf-indicator-source.c.

{
  BamfIndicatorSourcePrivate *priv;

  g_return_if_fail (BAMF_IS_INDICATOR_SOURCE (self));
  
  priv = self->priv;
  
  if (priv->behavior == behavior)
    return;

  priv->behavior = behavior;

  g_list_foreach (priv->indicators, (GFunc) rejudge_approval, self);
}

Here is the call graph for this function:

Here is the caller graph for this function: