src/give_statusbar_plugin.c File Reference

#include "config.h"
#include "give_statusbar_plugin.h"
#include "give_drag_and_drop.h"
#include <locale.h>
#include <libintl.h>
#include <dbus/dbus-glib.h>
#include <gconf/gconf-client.h>
#include <hildon/hildon-banner.h>

Include dependency graph for give_statusbar_plugin.c:

Go to the source code of this file.

Classes

struct  _GiveStatusbarPluginPrivate
 Struct of private members of GiveStatusbarPlugin. More...

Defines

#define _(String)   gettext(String)
#define GIVE_STATUSBAR_PLUGIN_GET_PRIVATE(obj)
#define BT_DIR   "/system/osso/connectivity/BT"
#define BT_KEY   "/system/osso/connectivity/BT/enabled"
#define LOG_FILE   "/tmp/give_log.txt"

Typedefs

typedef struct
_GiveStatusbarPluginPrivate 
GiveStatusbarPluginPrivate

Enumerations

enum  bt_state { BT_IS_OFF, BT_IS_ON, BT_PAND_IS_ACTIVE }
 The states of the plugin. More...
enum  menu_items {
  NOTE_ITEM, FILE_ITEM, APPOINTMENT_ITEM, CONTACT_ITEM,
  EMAIL_ITEM, ABOUT_ITEM
}
 Enumeration of the menu of Give, except the Net access. More...

Functions

 HD_DEFINE_PLUGIN (GiveStatusbarPlugin, give_statusbar_plugin, STATUSBAR_TYPE_ITEM)
Private functions
static void give_statusbar_plugin_class_init (GiveStatusbarPluginClass *klass)
 Overrites the class finalize function and adds the private structure.
static void give_statusbar_plugin_init (GiveStatusbarPlugin *self)
 Initialize the plugin.
static void give_statusbar_plugin_finalize (GObject *self)
 Unreferences the private members.
static void give_statusbar_plugin_popup_place (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data)
 Calculates the popup place of the Give menu.
static void give_statusbar_plugin_update_status (GiveStatusbarPlugin *self)
 Update the icon of plugin according to the Bluetooth status.
static void give_statusbar_plugin_clicked (GtkButton *button, GiveStatusbarPlugin *self)
 Builds up the popup menu of Give and show it.
static void give_statusbar_plugin_item_clicked (GtkWidget *menu_item, guint item)
 Handles the clicks in the popup menu.
static void give_statusbar_plugin_about_dialog (void)
 Shows the about dialog about Give.
static void give_statusbar_plugin_log_handler (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data)
 Give's own log handler.
static void give_statusbar_plugin_bt_changed (GConfClient *gc_client, guint cnxn_id, GConfEntry *entry, gpointer data)
 Gets the Bluetooth adapter's state from GConf and sets the private _GiveStatusbarPluginPrivate::state due to this.
static void give_statusbar_plugin_pand_dialog (GtkMenuItem *menuitem, GiveStatusbarPlugin *self)
 Creates and shows the stop/start pand dialog.
static void give_statusbar_plugin_start_pand (GtkMenuItem *menuitem, GiveStatusbarPlugin *self)
 Starts the pand daemon.
static void give_statusbar_plugin_stop_pand (GiveStatusbarPlugin *self)
 Kills the pand daemon.


Detailed Description

Statusbar plugin for easy drag & drop data sending via Bluetooth.
The icon is a d&d destination for specified types in drop_types.
Pressing it invokes the Give menu and the icon itself represents the Bluetooth state bt_state.

Definition in file give_statusbar_plugin.c.


Define Documentation

#define _ ( String   )     gettext(String)

Definition at line 34 of file give_statusbar_plugin.c.

#define BT_DIR   "/system/osso/connectivity/BT"

Definition at line 48 of file give_statusbar_plugin.c.

Referenced by give_statusbar_plugin_finalize(), and give_statusbar_plugin_init().

#define BT_KEY   "/system/osso/connectivity/BT/enabled"

boolean, TRUE if the Bluetooth adapter is on, FALSE otherwise.

Definition at line 50 of file give_statusbar_plugin.c.

Referenced by give_statusbar_plugin_bt_changed(), and give_statusbar_plugin_init().

#define GIVE_STATUSBAR_PLUGIN_GET_PRIVATE ( obj   ) 

Value:

(G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
                        GIVE_TYPE_STATUSBAR_PLUGIN, \
                        GiveStatusbarPluginPrivate));

Definition at line 42 of file give_statusbar_plugin.c.

Referenced by give_statusbar_plugin_bt_changed(), give_statusbar_plugin_clicked(), give_statusbar_plugin_finalize(), give_statusbar_plugin_init(), give_statusbar_plugin_pand_dialog(), give_statusbar_plugin_start_pand(), give_statusbar_plugin_stop_pand(), and give_statusbar_plugin_update_status().

#define LOG_FILE   "/tmp/give_log.txt"

Logfile used if compiled with --enable-ltf=yes.

Definition at line 53 of file give_statusbar_plugin.c.

Referenced by give_statusbar_plugin_log_handler().


Typedef Documentation

typedef struct _GiveStatusbarPluginPrivate GiveStatusbarPluginPrivate

Definition at line 40 of file give_statusbar_plugin.c.


Enumeration Type Documentation

enum bt_state

The states of the plugin.

Enumerator:
BT_IS_OFF 
BT_IS_ON 
BT_PAND_IS_ACTIVE 

Definition at line 81 of file give_statusbar_plugin.c.

enum menu_items

Enumeration of the menu of Give, except the Net access.

Enumerator:
NOTE_ITEM 
FILE_ITEM 
APPOINTMENT_ITEM 
CONTACT_ITEM 
EMAIL_ITEM 
ABOUT_ITEM 

Definition at line 88 of file give_statusbar_plugin.c.


Function Documentation

static void give_statusbar_plugin_about_dialog ( void   )  [static]

Shows the about dialog about Give.

Definition at line 564 of file give_statusbar_plugin.c.

References _.

Referenced by give_statusbar_plugin_item_clicked().

Here is the caller graph for this function:

static void give_statusbar_plugin_bt_changed ( GConfClient *  gc_client,
guint  cnxn_id,
GConfEntry *  entry,
gpointer  data 
) [static]

Gets the Bluetooth adapter's state from GConf and sets the private _GiveStatusbarPluginPrivate::state due to this.

Parameters:
gc_client The GConfClient notifying us.
cnxn_id Connection ID from gconf_client_notify_add(). Not used.
entry A GConfEntry. Not used.
data User data from gconf_client_notify_add(). It's a GiveStatusbarPlugin object.

Definition at line 675 of file give_statusbar_plugin.c.

References BT_IS_OFF, BT_IS_ON, BT_KEY, GIVE_IS_STATUSBAR_PLUGIN, GIVE_STATUSBAR_PLUGIN_GET_PRIVATE, give_statusbar_plugin_stop_pand(), give_statusbar_plugin_update_status(), _GiveStatusbarPluginPrivate::pand_pid, and _GiveStatusbarPluginPrivate::state.

Referenced by give_statusbar_plugin_init().

Here is the call graph for this function:

Here is the caller graph for this function:

static void give_statusbar_plugin_class_init ( GiveStatusbarPluginClass klass  )  [static]

Overrites the class finalize function and adds the private structure.

Sets give_statusbar_plugin_finalize as the class' finalize function.
Registers the GiveStatusbarPluginPrivate structure as private member.

Parameters:
klass a GiveStatusbarPluginClass class.

Definition at line 138 of file give_statusbar_plugin.c.

References give_statusbar_plugin_finalize().

Here is the call graph for this function:

static void give_statusbar_plugin_clicked ( GtkButton *  button,
GiveStatusbarPlugin self 
) [static]

Builds up the popup menu of Give and show it.

Parameters:
button The button of the plugin.
self A GiveStatusbarPlugin object.

Definition at line 361 of file give_statusbar_plugin.c.

References _, ABOUT_ITEM, APPOINTMENT_ITEM, BT_PAND_IS_ACTIVE, CONTACT_ITEM, EMAIL_ITEM, FILE_ITEM, GIVE_IS_STATUSBAR_PLUGIN, GIVE_STATUSBAR_PLUGIN_GET_PRIVATE, give_statusbar_plugin_item_clicked(), give_statusbar_plugin_pand_dialog(), give_statusbar_plugin_popup_place(), NOTE_ITEM, and _GiveStatusbarPluginPrivate::state.

Referenced by give_statusbar_plugin_init().

Here is the call graph for this function:

Here is the caller graph for this function:

static void give_statusbar_plugin_finalize ( GObject *  self  )  [static]

Unreferences the private members.

Definition at line 240 of file give_statusbar_plugin.c.

References BT_DIR, _GiveStatusbarPluginPrivate::dnd, _GiveStatusbarPluginPrivate::gc_client, GIVE_IS_STATUSBAR_PLUGIN, GIVE_STATUSBAR_PLUGIN_GET_PRIVATE, and _GiveStatusbarPluginPrivate::notify_uid.

Referenced by give_statusbar_plugin_class_init().

Here is the caller graph for this function:

static void give_statusbar_plugin_init ( GiveStatusbarPlugin self  )  [static]

Initialize the plugin.

Definition at line 161 of file give_statusbar_plugin.c.

References BT_DIR, BT_IS_OFF, BT_KEY, _GiveStatusbarPluginPrivate::button, _GiveStatusbarPluginPrivate::dnd, _GiveStatusbarPluginPrivate::gc_client, give_drag_and_drop_new(), GIVE_IS_STATUSBAR_PLUGIN, give_statusbar_plugin_bt_changed(), give_statusbar_plugin_clicked(), GIVE_STATUSBAR_PLUGIN_GET_PRIVATE, give_statusbar_plugin_log_handler(), _GiveStatusbarPluginPrivate::image, _GiveStatusbarPluginPrivate::notify_uid, _GiveStatusbarPluginPrivate::pand_pid, and _GiveStatusbarPluginPrivate::state.

Here is the call graph for this function:

static void give_statusbar_plugin_item_clicked ( GtkWidget *  menu_item,
guint  item 
) [static]

Handles the clicks in the popup menu.

Invokes the programs for:

Definition at line 496 of file give_statusbar_plugin.c.

References _, ABOUT_ITEM, APPOINTMENT_ITEM, CONTACT_ITEM, EMAIL_ITEM, FILE_ITEM, give_statusbar_plugin_about_dialog(), and NOTE_ITEM.

Referenced by give_statusbar_plugin_clicked().

Here is the call graph for this function:

Here is the caller graph for this function:

static void give_statusbar_plugin_log_handler ( const gchar *  log_domain,
GLogLevelFlags  log_level,
const gchar *  message,
gpointer  user_data 
) [static]

Give's own log handler.

Definition at line 595 of file give_statusbar_plugin.c.

References LOG_FILE.

Referenced by give_statusbar_plugin_init().

Here is the caller graph for this function:

static void give_statusbar_plugin_pand_dialog ( GtkMenuItem *  menuitem,
GiveStatusbarPlugin self 
) [static]

Creates and shows the stop/start pand dialog.

According to _GiveStatusbarPluginPrivate::state it stops pand if it's running and starts if it's not.
Invokes the _GiveStatusbarPluginPrivate::dnd object's give_drag_and_drop_turn_bt_on_dialog if the Bluetooth is off.

Parameters:
menuitem The menuitem recieved the "activate" signal.
self A GiveStatusbarPlugin object.

Definition at line 746 of file give_statusbar_plugin.c.

References _, BT_IS_OFF, BT_PAND_IS_ACTIVE, _GiveStatusbarPluginPrivate::dnd, give_drag_and_drop_turn_bt_on_dialog(), GIVE_IS_STATUSBAR_PLUGIN, GIVE_STATUSBAR_PLUGIN_GET_PRIVATE, give_statusbar_plugin_start_pand(), give_statusbar_plugin_stop_pand(), and _GiveStatusbarPluginPrivate::state.

Referenced by give_statusbar_plugin_clicked().

Here is the call graph for this function:

Here is the caller graph for this function:

static void give_statusbar_plugin_popup_place ( GtkMenu *  menu,
gint *  x,
gint *  y,
gboolean *  push_in,
gpointer  user_data 
) [static]

Calculates the popup place of the Give menu.

Parameters:
menu A GtkMenu.
x A address of the gint representing the horizontal position where the menu shall be drawn. This is an output parameter.
y A address of the gint representing the vertical position where the menu shall be drawn. This is an output parameter.
push_in This parameter controls how menus placed outside the monitor are handled. Not used.
user_data The data supplied by the user in the gtk_menu_popup() data parameter.

Definition at line 282 of file give_statusbar_plugin.c.

Referenced by give_statusbar_plugin_clicked().

Here is the caller graph for this function:

static void give_statusbar_plugin_start_pand ( GtkMenuItem *  menuitem,
GiveStatusbarPlugin self 
) [static]

Starts the pand daemon.

Stores the PID in _GiveStatusbarPluginPrivate::pand_pid so it can be killed later with give_statusbar_plugin_stop_pand.

Todo:
The device don't act as a server just as a client.
Parameters:
menuitem The menuitem recieved the "activate" signal.
self A GiveStatusbarPlugin object.

Definition at line 818 of file give_statusbar_plugin.c.

References _, BT_PAND_IS_ACTIVE, GIVE_IS_STATUSBAR_PLUGIN, GIVE_STATUSBAR_PLUGIN_GET_PRIVATE, give_statusbar_plugin_update_status(), _GiveStatusbarPluginPrivate::pand_pid, and _GiveStatusbarPluginPrivate::state.

Referenced by give_statusbar_plugin_pand_dialog().

Here is the call graph for this function:

Here is the caller graph for this function:

static void give_statusbar_plugin_stop_pand ( GiveStatusbarPlugin self  )  [static]

Kills the pand daemon.

The PID of the process is stored in _GiveStatusbarPluginPrivate::notify_uid.

Parameters:
self GiveStatusbarPlugin.

Definition at line 863 of file give_statusbar_plugin.c.

References _, BT_IS_ON, GIVE_IS_STATUSBAR_PLUGIN, GIVE_STATUSBAR_PLUGIN_GET_PRIVATE, give_statusbar_plugin_update_status(), _GiveStatusbarPluginPrivate::pand_pid, and _GiveStatusbarPluginPrivate::state.

Referenced by give_statusbar_plugin_bt_changed(), and give_statusbar_plugin_pand_dialog().

Here is the call graph for this function:

Here is the caller graph for this function:

static void give_statusbar_plugin_update_status ( GiveStatusbarPlugin self  )  [static]

Update the icon of plugin according to the Bluetooth status.

Parameters:
self A GiveStatusbarPlugin object.

Definition at line 316 of file give_statusbar_plugin.c.

References BT_IS_OFF, BT_IS_ON, BT_PAND_IS_ACTIVE, _GiveStatusbarPluginPrivate::dnd, give_drag_and_drop_have_bt(), GIVE_IS_STATUSBAR_PLUGIN, GIVE_STATUSBAR_PLUGIN_GET_PRIVATE, _GiveStatusbarPluginPrivate::image, and _GiveStatusbarPluginPrivate::state.

Referenced by give_statusbar_plugin_bt_changed(), give_statusbar_plugin_start_pand(), and give_statusbar_plugin_stop_pand().

Here is the call graph for this function:

Here is the caller graph for this function:

HD_DEFINE_PLUGIN ( GiveStatusbarPlugin  ,
give_statusbar_plugin  ,
STATUSBAR_TYPE_ITEM   
)


Generated on Sat May 17 16:27:33 2008 for Give by  doxygen 1.5.3