Index: export.c =================================================================== RCS file: /cvs/gpe/base/gpe-contacts/export.c,v retrieving revision 1.2 diff -u -r1.2 export.c --- export.c 29 Feb 2004 18:38:55 -0000 1.2 +++ export.c 13 Oct 2004 17:26:57 -0000 @@ -33,6 +33,7 @@ static DBusConnection *connection; #define BLUETOOTH_SERVICE_NAME "org.handhelds.gpe.bluez" +#define IRDA_SERVICE_NAME "org.handhelds.gpe.irda" static gchar * export_to_vcard (guint uid) @@ -76,6 +77,31 @@ g_free (card); } +void +menu_do_send_irda (void) +{ + gchar *card; + DBusMessage *message; + DBusMessageIter iter; + + card = export_to_vcard (menu_uid); + + message = dbus_message_new_method_call (IRDA_SERVICE_NAME, + "/org/handhelds/gpe/irda/OBEX", + IRDA_SERVICE_NAME ".OBEX", + "ObjectPush"); + + dbus_message_append_iter_init (message, &iter); + + dbus_message_iter_append_string (&iter, "GPE.vcf"); + dbus_message_iter_append_string (&iter, "application/x-vcard"); + dbus_message_iter_append_byte_array (&iter, card, strlen (card)); + + dbus_connection_send (connection, message, NULL); + + g_free (card); +} + static void select_file_done (GtkWidget *w, GtkWidget *filesel) { @@ -143,6 +169,19 @@ return r ? TRUE : FALSE; } +gboolean +export_irda_available (void) +{ + dbus_bool_t r; + + if (connection == NULL) + return FALSE; + + r = dbus_bus_service_exists (connection, IRDA_SERVICE_NAME, NULL); + + return r ? TRUE : FALSE; +} + void export_init (void) { Index: main.c =================================================================== RCS file: /cvs/gpe/base/gpe-contacts/main.c,v retrieving revision 1.100 diff -u -r1.100 main.c --- main.c 12 Oct 2004 14:23:18 -0000 1.100 +++ main.c 13 Oct 2004 17:26:57 -0000 @@ -54,6 +54,7 @@ GtkWidget *search_entry; GtkWidget *popup_menu; GtkWidget *bluetooth_menu_item; +GtkWidget *irda_menu_item; guint menu_uid; gboolean mode_landscape; gboolean mode_large_screen; @@ -1085,7 +1086,12 @@ gtk_widget_show (bluetooth_menu_item); else gtk_widget_hide (bluetooth_menu_item); - + + if (export_irda_available ()) + gtk_widget_show (irda_menu_item); + else + gtk_widget_hide (irda_menu_item); + gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL, NULL, widget, b->button, b->time); } @@ -1114,6 +1120,7 @@ { "/Delete", NULL, menu_do_delete, 0, "", GTK_STOCK_DELETE }, { "/Save as ...", NULL, menu_do_save, 0, "" }, { "/Send via Bluetooth", NULL, menu_do_send_bluetooth, 0, "", }, + { "/Send via Irda", NULL, menu_do_send_irda, 0, "", }, }; static GtkWidget * @@ -1129,6 +1136,7 @@ popup_items, NULL); bluetooth_menu_item = gtk_item_factory_get_widget (item_factory, "
/Send via Bluetooth"); + irda_menu_item = gtk_item_factory_get_widget (item_factory, "
/Send via Irda"); return gtk_item_factory_get_widget (item_factory, "
"); } Index: export.h =================================================================== RCS file: /cvs/gpe/base/gpe-contacts/export.h,v retrieving revision 1.2 diff -u -r1.2 export.h --- export.h 29 Feb 2004 18:38:55 -0000 1.2 +++ export.h 13 Oct 2004 17:26:57 -0000 @@ -1,5 +1,6 @@ void menu_do_send_bluetooth (void); +void menu_do_send_irda (void); void menu_do_save (void); void export_init (void); gboolean export_bluetooth_available (void); - +gboolean export_irda_available (void);