src/give_drag_and_drop.c File Reference

#include "give_drag_and_drop.h"
#include "give_bluetooth.h"
#include "give_ebook.h"
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <dbus/dbus-glib.h>
#include <locale.h>
#include <libintl.h>

Include dependency graph for give_drag_and_drop.c:

Go to the source code of this file.

Classes

struct  _give_drag_and_drop_private
 Struct of private members of give_bluetooth. More...

Defines

#define _(String)   gettext(String)
#define GIVE_DRAG_AND_DROP_GET_PRIVATE(obj)
#define TEMP_DIR   "/tmp"
Bluez
#define BLUEZ_DBUS_SERVICE   "org.bluez"
#define BLUEZ_DBUS_PATH   "/org/bluez/hci0"
#define BLUEZ_DBUS_INTERFACE   "org.bluez.Adapter"
#define BLUEZ_DBUS_SET_MODE   "SetMode"
#define BLUEZ_DBUS_MESSAGE   "connectable"
Accepted d&d types
#define PLAIN_TEXT_TYPE   "text/plain"
#define URI_LIST_TYPE   "text/uri-list"
#define CALENDAR_EVENT_TYPE   "application/x-e-calendar-event"
#define CONTACT_LIST_TYPE   "x-osso-contact-list"
#define TREE_ROW_TYPE   "GTK_TREE_MODEL_ROW"
#define TREE_AS_STRING_TYPE   "text/tree-path-as-string-list"
#define MODEST_EMAIL_TYPE   "text/modest-email"

Typedefs

typedef struct
_give_drag_and_drop_private 
give_drag_and_drop_private

Enumerations

enum  {
  PLAIN_TEXT, URI_LIST, CALENDAR_EVENT, CONTACT_LIST,
  TREE_ROW, TREE_AS_STRING, MODEST_EMAIL
}

Functions

Private functions
GType give_drag_and_drop_get_type (void)
 Registers the give_drag_and_drop type statically.
static void give_drag_and_drop_class_init (give_drag_and_dropClass *klass)
 Overrites the class finalize function and adds the private structure.
static void give_drag_and_drop_init (give_drag_and_drop *self)
 Connects to DBus and instantiates give_bluetooth and give_ebook.
static void give_drag_and_drop_finalize (GObject *self)
 Unsets the widget as d&d destination, unrefs objects.
give_drag_and_dropgive_drag_and_drop_new (GtkWidget *widget)
 Creates a new instance of give_drag_and_drop.
static void give_drag_and_drop_set_dest (give_drag_and_drop *self, GtkWidget *widget)
 Sets the parameter widget a d&d destination.
void give_drag_and_drop_have_bt (give_drag_and_drop *self, gboolean setting)
 Sets _give_drag_and_drop_private::bt_is_on.
gboolean give_drag_and_drop_turn_bt_on_dialog (give_drag_and_drop *self)
 Confirmation dialog whether to turn on the Bluetooth adapter or not.
Public functions
static GtkWidget * give_drag_and_drop_create_dialog (give_drag_and_drop *self, const guint info, const gchar *text, guint *file_count, GtkWidget **entry)
 Creates a confirmation dialog with whether to send the data or not.
static int give_drag_and_drop_run_dialog (give_drag_and_drop *self, GtkWidget *dialog, const guint info, const gchar *text, const guint file_count, gchar ***files, const GtkWidget *entry)
 Runs the dialog created by give_drag_and_drop_create_dialog.
static void give_drag_and_drop_send (give_drag_and_drop *self, const guint info, const gchar *text)
 Creates a confirmation dialog and send the files.
static void give_drag_and_drop_drag_recieved (GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *selection_data, guint info, guint32 time, gpointer user_data)
 Handles the "drag_data_received" signal.

Variables

const GtkTargetEntry drop_types []
 Accepted d&d types.


Detailed Description

The drag & drop object examines the recieved data, converts it into file or files, according to its nature. For example, a contact will be send as a VCard, a calendar event as an VCal event, and so on. For VCard data manipulation, an EBook connection has been defined. The data transfer has been done with the Bluetooth object. Also, the state of the device's Bluetooth is checked, and if it's turned off, a dialog appears, asking for permission of the user to turn it on.

Definition in file give_drag_and_drop.c.


Define Documentation

#define _ ( String   )     gettext(String)

Definition at line 43 of file give_drag_and_drop.c.

Referenced by give_drag_and_drop_create_dialog(), give_drag_and_drop_turn_bt_on_dialog(), give_statusbar_plugin_about_dialog(), give_statusbar_plugin_clicked(), give_statusbar_plugin_item_clicked(), give_statusbar_plugin_pand_dialog(), give_statusbar_plugin_start_pand(), and give_statusbar_plugin_stop_pand().

#define BLUEZ_DBUS_INTERFACE   "org.bluez.Adapter"

Definition at line 76 of file give_drag_and_drop.c.

Referenced by give_drag_and_drop_init().

#define BLUEZ_DBUS_MESSAGE   "connectable"

Definition at line 78 of file give_drag_and_drop.c.

Referenced by give_drag_and_drop_turn_bt_on_dialog().

#define BLUEZ_DBUS_PATH   "/org/bluez/hci0"

Definition at line 75 of file give_drag_and_drop.c.

Referenced by give_drag_and_drop_init().

#define BLUEZ_DBUS_SERVICE   "org.bluez"

Definition at line 74 of file give_drag_and_drop.c.

Referenced by give_drag_and_drop_init().

#define BLUEZ_DBUS_SET_MODE   "SetMode"

Definition at line 77 of file give_drag_and_drop.c.

Referenced by give_drag_and_drop_turn_bt_on_dialog().

#define CALENDAR_EVENT_TYPE   "application/x-e-calendar-event"

Definition at line 88 of file give_drag_and_drop.c.

#define CONTACT_LIST_TYPE   "x-osso-contact-list"

Definition at line 89 of file give_drag_and_drop.c.

#define GIVE_DRAG_AND_DROP_GET_PRIVATE ( obj   ) 

Value:

(G_TYPE_INSTANCE_GET_PRIVATE ((obj),\
                        GIVE_DRAG_AND_DROP_TYPE, \
                        give_drag_and_drop_private));

Definition at line 47 of file give_drag_and_drop.c.

Referenced by give_drag_and_drop_create_dialog(), give_drag_and_drop_drag_recieved(), give_drag_and_drop_finalize(), give_drag_and_drop_have_bt(), give_drag_and_drop_init(), give_drag_and_drop_run_dialog(), give_drag_and_drop_send(), give_drag_and_drop_set_dest(), and give_drag_and_drop_turn_bt_on_dialog().

#define MODEST_EMAIL_TYPE   "text/modest-email"

Definition at line 93 of file give_drag_and_drop.c.

#define PLAIN_TEXT_TYPE   "text/plain"

Definition at line 86 of file give_drag_and_drop.c.

#define TEMP_DIR   "/tmp"

Definition at line 69 of file give_drag_and_drop.c.

Referenced by give_drag_and_drop_run_dialog().

#define TREE_AS_STRING_TYPE   "text/tree-path-as-string-list"

Definition at line 92 of file give_drag_and_drop.c.

#define TREE_ROW_TYPE   "GTK_TREE_MODEL_ROW"

Definition at line 91 of file give_drag_and_drop.c.

#define URI_LIST_TYPE   "text/uri-list"

Definition at line 87 of file give_drag_and_drop.c.


Typedef Documentation

typedef struct _give_drag_and_drop_private give_drag_and_drop_private

Definition at line 45 of file give_drag_and_drop.c.


Enumeration Type Documentation

anonymous enum

Enumerator:
PLAIN_TEXT 
URI_LIST 
CALENDAR_EVENT 
CONTACT_LIST 
TREE_ROW 
TREE_AS_STRING 
MODEST_EMAIL 

Definition at line 99 of file give_drag_and_drop.c.


Function Documentation

static void give_drag_and_drop_class_init ( give_drag_and_dropClass klass  )  [static]

Overrites the class finalize function and adds the private structure.

Sets give_drag_and_drop_finalize as the class' finalize function.
Registers the give_drag_and_drop_private structure as private member.

Parameters:
klass a give_drag_and_dropClass.

Definition at line 214 of file give_drag_and_drop.c.

References give_drag_and_drop_finalize().

Referenced by give_drag_and_drop_get_type().

Here is the call graph for this function:

Here is the caller graph for this function:

static GtkWidget * give_drag_and_drop_create_dialog ( give_drag_and_drop self,
const guint  info,
const gchar *  text,
guint *  file_count,
GtkWidget **  entry 
) [static]

Creates a confirmation dialog with whether to send the data or not.

The created dialog will be run by give_drag_and_drop_run_dialog.
The dialog contains the filenames.

Definition at line 405 of file give_drag_and_drop.c.

References _, CALENDAR_EVENT, CONTACT_LIST, GIVE_DRAG_AND_DROP_GET_PRIVATE, GIVE_DRAG_AND_DROP_IS_OBJECT, give_ebook_get_contact_name(), _give_drag_and_drop_private::give_ebook_object, PLAIN_TEXT, and URI_LIST.

Referenced by give_drag_and_drop_send().

Here is the call graph for this function:

Here is the caller graph for this function:

static void give_drag_and_drop_drag_recieved ( GtkWidget *  widget,
GdkDragContext *  context,
gint  x,
gint  y,
GtkSelectionData *  selection_data,
guint  info,
guint32  time,
gpointer  user_data 
) [static]

Handles the "drag_data_received" signal.

Todo:
Investigate whether the got data needs to freed or not. probably yes, since the data is copied (GDK_ACTION_COPY)

Definition at line 857 of file give_drag_and_drop.c.

References _give_drag_and_drop_private::bt_is_on, GIVE_DRAG_AND_DROP_GET_PRIVATE, GIVE_DRAG_AND_DROP_IS_OBJECT, give_drag_and_drop_send(), give_drag_and_drop_turn_bt_on_dialog(), MODEST_EMAIL, TREE_AS_STRING, and TREE_ROW.

Referenced by give_drag_and_drop_set_dest().

Here is the call graph for this function:

Here is the caller graph for this function:

static void give_drag_and_drop_finalize ( GObject *  self  )  [static]

Unsets the widget as d&d destination, unrefs objects.

Definition at line 283 of file give_drag_and_drop.c.

References _give_drag_and_drop_private::dbus_proxy, _give_drag_and_drop_private::destination, _give_drag_and_drop_private::give_bt_object, GIVE_DRAG_AND_DROP_GET_PRIVATE, GIVE_DRAG_AND_DROP_IS_OBJECT, _give_drag_and_drop_private::give_ebook_object, and _give_drag_and_drop_private::handler_id.

Referenced by give_drag_and_drop_class_init().

Here is the caller graph for this function:

GType give_drag_and_drop_get_type ( void   ) 

Registers the give_drag_and_drop type statically.

Sets class init, and instance init functions.
The class finalize function has been set in the class init function.

Returns:
The new registered GType, with the name of "give_drag_and_drop".

Definition at line 177 of file give_drag_and_drop.c.

References give_drag_and_drop_class_init(), and give_drag_and_drop_init().

Here is the call graph for this function:

void give_drag_and_drop_have_bt ( give_drag_and_drop self,
gboolean  setting 
)

Sets _give_drag_and_drop_private::bt_is_on.

Parameters:
self A give_drag_and_drop object.
setting Sets the private member _give_drag_and_drop_private::bt_is_on according to setting.

Definition at line 371 of file give_drag_and_drop.c.

References _give_drag_and_drop_private::bt_is_on, GIVE_DRAG_AND_DROP_GET_PRIVATE, and GIVE_DRAG_AND_DROP_IS_OBJECT.

Referenced by give_drag_and_drop_init(), and give_statusbar_plugin_update_status().

Here is the caller graph for this function:

static void give_drag_and_drop_init ( give_drag_and_drop self  )  [static]

Connects to DBus and instantiates give_bluetooth and give_ebook.

Definition at line 234 of file give_drag_and_drop.c.

References BLUEZ_DBUS_INTERFACE, BLUEZ_DBUS_PATH, BLUEZ_DBUS_SERVICE, _give_drag_and_drop_private::dbus_proxy, give_bluetooth_new(), _give_drag_and_drop_private::give_bt_object, GIVE_DRAG_AND_DROP_GET_PRIVATE, give_drag_and_drop_have_bt(), GIVE_DRAG_AND_DROP_IS_OBJECT, give_ebook_new(), and _give_drag_and_drop_private::give_ebook_object.

Referenced by give_drag_and_drop_get_type().

Here is the call graph for this function:

Here is the caller graph for this function:

give_drag_and_drop * give_drag_and_drop_new ( GtkWidget *  widget  ) 

Creates a new instance of give_drag_and_drop.

Sets the widget parameter as a d&d destination with give_drag_and_drop_set_dest.

Parameters:
widget A widget, it's the button of the plugin.
Returns:
A new give_drag_and_drop.

Definition at line 314 of file give_drag_and_drop.c.

References give_drag_and_drop_set_dest(), and GIVE_DRAG_AND_DROP_TYPE.

Referenced by give_statusbar_plugin_init().

Here is the call graph for this function:

Here is the caller graph for this function:

static gint give_drag_and_drop_run_dialog ( give_drag_and_drop self,
GtkWidget *  dialog,
const guint  info,
const gchar *  text,
const guint  file_count,
gchar ***  files,
const GtkWidget *  entry 
) [static]

Runs the dialog created by give_drag_and_drop_create_dialog.

Allocates a stringlist containing the list of filenames to be send. The filenames are absolute since the Bluetooth sending call needs it.
The temporary files at the text, calendar event and contact cases are stored under TEMP_DIR. They are created by printing the formatted data into the appropriate files.

Parameters:
self A give_drag_and_drop object.
dialog The dialog, created by give_drag_and_drop_create_dialog.
info The type of the dragged data.
text The dragged data.
file_count Number of files or contacs processed. Used for memory allocation.
files Returned filenames, with absolute paths.
entry Pointer to the file name entry in the text and calendar ceses. Used by give_drag_and_drop_run_dialog to get the value.
Returns:
1 on approval, 0 if the user cancels the send.

Definition at line 591 of file give_drag_and_drop.c.

References CALENDAR_EVENT, CONTACT_LIST, GIVE_DRAG_AND_DROP_GET_PRIVATE, GIVE_DRAG_AND_DROP_IS_OBJECT, give_ebook_get_contact_name(), give_ebook_get_contact_vcard(), _give_drag_and_drop_private::give_ebook_object, PLAIN_TEXT, TEMP_DIR, and URI_LIST.

Referenced by give_drag_and_drop_send().

Here is the call graph for this function:

Here is the caller graph for this function:

static void give_drag_and_drop_send ( give_drag_and_drop self,
const guint  info,
const gchar *  text 
) [static]

Creates a confirmation dialog and send the files.

Creates and runs a confirmation dialog with give_drag_and_drop_create_dialog and give_drag_and_drop_run_dialog.
Send the files with the give_bluetooth_send_file method of the give_bluetooth object.

Parameters:
self A give_drag_and_drop object.
info The type of the dragged data.
text The dragged data.

Todo:
Remove temporary files after sending.

Definition at line 741 of file give_drag_and_drop.c.

References give_bluetooth_send_file(), _give_drag_and_drop_private::give_bt_object, give_drag_and_drop_create_dialog(), GIVE_DRAG_AND_DROP_GET_PRIVATE, GIVE_DRAG_AND_DROP_IS_OBJECT, and give_drag_and_drop_run_dialog().

Referenced by give_drag_and_drop_drag_recieved().

Here is the call graph for this function:

Here is the caller graph for this function:

static void give_drag_and_drop_set_dest ( give_drag_and_drop self,
GtkWidget *  widget 
) [static]

Sets the parameter widget a d&d destination.

Definition at line 338 of file give_drag_and_drop.c.

References _give_drag_and_drop_private::destination, drop_types, give_drag_and_drop_drag_recieved(), GIVE_DRAG_AND_DROP_GET_PRIVATE, GIVE_DRAG_AND_DROP_IS_OBJECT, and _give_drag_and_drop_private::handler_id.

Referenced by give_drag_and_drop_new().

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean give_drag_and_drop_turn_bt_on_dialog ( give_drag_and_drop self  ) 

Confirmation dialog whether to turn on the Bluetooth adapter or not.

Parameters:
self A give_drag_and_drop object.

Definition at line 778 of file give_drag_and_drop.c.

References _, BLUEZ_DBUS_MESSAGE, BLUEZ_DBUS_SET_MODE, _give_drag_and_drop_private::dbus_proxy, GIVE_DRAG_AND_DROP_GET_PRIVATE, and GIVE_DRAG_AND_DROP_IS_OBJECT.

Referenced by give_drag_and_drop_drag_recieved(), and give_statusbar_plugin_pand_dialog().

Here is the caller graph for this function:


Variable Documentation

const GtkTargetEntry drop_types[]

Initial value:

Accepted d&d types.

Definition at line 118 of file give_drag_and_drop.c.

Referenced by give_drag_and_drop_set_dest().


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