Back to index

indicator-appmenu  12.10.0
Classes | Defines | Typedefs | Functions
usage-tracker.h File Reference
#include <glib-object.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _UsageTrackerClass
struct  _UsageTracker

Defines

#define USAGE_TRACKER_TYPE   (usage_tracker_get_type ())
#define USAGE_TRACKER(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), USAGE_TRACKER_TYPE, UsageTracker))
#define USAGE_TRACKER_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), USAGE_TRACKER_TYPE, UsageTrackerClass))
#define IS_USAGE_TRACKER(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), USAGE_TRACKER_TYPE))
#define IS_USAGE_TRACKER_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), USAGE_TRACKER_TYPE))
#define USAGE_TRACKER_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), USAGE_TRACKER_TYPE, UsageTrackerClass))

Typedefs

typedef struct _UsageTracker
typedef struct _UsageTrackerClass
typedef struct _UsageTrackerPrivate

Functions

GType usage_tracker_get_type (void)
UsageTracker * usage_tracker_new (void)
void usage_tracker_mark_usage (UsageTracker *self, const gchar *application, const gchar *entry)
guint usage_tracker_get_usage (UsageTracker *self, const gchar *application, const gchar *entry)
UsageTracker * usage_tracker_get_instance (void)

Class Documentation

struct _UsageTrackerClass

Definition at line 41 of file usage-tracker.h.

Class Members
GObjectClass parent_class
struct _UsageTracker

Definition at line 45 of file usage-tracker.h.

Class Members
GObject parent
UsageTrackerPrivate * priv

Define Documentation

#define IS_USAGE_TRACKER (   obj)    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), USAGE_TRACKER_TYPE))

Definition at line 33 of file usage-tracker.h.

#define IS_USAGE_TRACKER_CLASS (   klass)    (G_TYPE_CHECK_CLASS_TYPE ((klass), USAGE_TRACKER_TYPE))

Definition at line 34 of file usage-tracker.h.

#define USAGE_TRACKER (   obj)    (G_TYPE_CHECK_INSTANCE_CAST ((obj), USAGE_TRACKER_TYPE, UsageTracker))

Definition at line 31 of file usage-tracker.h.

#define USAGE_TRACKER_CLASS (   klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), USAGE_TRACKER_TYPE, UsageTrackerClass))

Definition at line 32 of file usage-tracker.h.

#define USAGE_TRACKER_GET_CLASS (   obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), USAGE_TRACKER_TYPE, UsageTrackerClass))

Definition at line 35 of file usage-tracker.h.

Definition at line 30 of file usage-tracker.h.


Typedef Documentation

typedef struct _UsageTracker

Definition at line 37 of file usage-tracker.h.

typedef struct _UsageTrackerClass

Definition at line 38 of file usage-tracker.h.

typedef struct _UsageTrackerPrivate

Definition at line 39 of file usage-tracker.h.


Function Documentation

UsageTracker* usage_tracker_get_instance ( void  )

Definition at line 497 of file usage-tracker.c.

{
  static UsageTracker *usage_tracker_instance;

  if (usage_tracker_instance == NULL)
    usage_tracker_instance = usage_tracker_new ();

  return usage_tracker_instance;
}

Here is the call graph for this function:

Here is the caller graph for this function:

GType usage_tracker_get_type ( void  )
guint usage_tracker_get_usage ( UsageTracker *  self,
const gchar *  application,
const gchar *  entry 
)

Definition at line 377 of file usage-tracker.c.

{
       g_return_val_if_fail(IS_USAGE_TRACKER(self), 0);
       g_return_val_if_fail(self->priv->db != NULL, 0);

       check_app_init(self, application);

       sqlite3_reset(self->priv->entry_count);

       int bind_status = SQLITE_OK;

       bind_status = sqlite3_bind_text(self->priv->entry_count, SQL_VAR_APPLICATION, application, -1, SQLITE_TRANSIENT);
       if (bind_status != SQLITE_OK) {
              g_warning("Unable to bind application info: %s", sqlite3_errmsg(self->priv->db));
              return 0;
       }

       bind_status = sqlite3_bind_text(self->priv->entry_count, SQL_VAR_ENTRY, entry, -1, SQLITE_TRANSIENT);
       if (bind_status != SQLITE_OK) {
              g_warning("Unable to bind entry info: %s", sqlite3_errmsg(self->priv->db));
              return 0;
       }

       int exec_status = SQLITE_ROW;
       guint count = 0;

       while ((exec_status = sqlite3_step(self->priv->entry_count)) == SQLITE_ROW) {
              count = sqlite3_column_int(self->priv->entry_count, 0);
       }

       if (exec_status != SQLITE_DONE) {
              g_warning("Unknown status from executing entry_count: %d", exec_status);
       }

       g_debug ("Usage of %s %s is %u", application, entry, count);

       return count;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void usage_tracker_mark_usage ( UsageTracker *  self,
const gchar *  application,
const gchar *  entry 
)

Definition at line 340 of file usage-tracker.c.

{
       g_return_if_fail(IS_USAGE_TRACKER(self));
       g_return_if_fail(self->priv->db != NULL);

       g_debug ("Marking %s %s", application, entry);

       check_app_init(self, application);

       sqlite3_reset(self->priv->insert_entry);

       int bind_status = SQLITE_OK;

       bind_status = sqlite3_bind_text(self->priv->insert_entry, SQL_VAR_APPLICATION, application, -1, SQLITE_TRANSIENT);
       if (bind_status != SQLITE_OK) {
              g_warning("Unable to bind application info: %s", sqlite3_errmsg(self->priv->db));
              return;
       }

       bind_status = sqlite3_bind_text(self->priv->insert_entry, SQL_VAR_ENTRY, entry, -1, SQLITE_TRANSIENT);
       if (bind_status != SQLITE_OK) {
              g_warning("Unable to bind entry info: %s", sqlite3_errmsg(self->priv->db));
              return;
       }

       int exec_status = SQLITE_ROW;
       while ((exec_status = sqlite3_step(self->priv->insert_entry)) == SQLITE_ROW) {
       }

       if (exec_status != SQLITE_DONE) {
              g_warning("Unknown status from executing insert_entry: %d", exec_status);
       }

       return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

UsageTracker* usage_tracker_new ( void  )

Definition at line 172 of file usage-tracker.c.

{
       return g_object_new(USAGE_TRACKER_TYPE, NULL);
}

Here is the caller graph for this function: