nautilus-sendto r375 - in trunk: . src/plugins



Author: hadess
Date: Tue Jan  6 15:17:27 2009
New Revision: 375
URL: http://svn.gnome.org/viewvc/nautilus-sendto?rev=375&view=rev

Log:
2008-12-29  Jonny Lamb  <jonny lamb collabora co uk>

	* configure.in:
	* src/plugins/Makefile.am:
	* src/plugins/empathy.c: Added empathy plugin.



Added:
   trunk/src/plugins/empathy.c
Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/src/plugins/Makefile.am

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Tue Jan  6 15:17:27 2009
@@ -19,6 +19,8 @@
 GNOME_CXX_WARNINGS
 GNOME_MAINTAINER_MODE_DEFINES
 
+ERROR_CFLAGS="-Wall -Wextra -Werror -Wno_missing_field_initializers -Wno_unused_parameter"
+
 dnl --------------------------------------------------
 
 GLIB_REQUIRED=2.6.0
@@ -32,6 +34,8 @@
 DBUS_REQUIRED=1.0
 DBUS_GLIB_REQUIRED=0.60
 GUPNP_AV_REQUIRED=0.2.1
+EMPATHY_REQUIRED=2.23.91
+EMPATHY_GTK_REQUIRED=2.23.91
 
 AC_SUBST(GLIB_REQUIRED)
 AC_SUBST(GTK_REQUIRED)
@@ -44,6 +48,8 @@
 AC_SUBST(BLUETOOTH_REQUIRED)
 AC_SUBST(DBUS_REQUIRED)
 AC_SUBST(GUPNP_AV_REQUIRED)
+AC_SUBST(EMPATHY_REQUIRED)
+AC_SUBST(EMPATHY_GTK_REQUIRED)
 
 PKG_CHECK_MODULES(NAUTILUS_SENDTO,\
 	 glib-2.0 >= $GLIB_REQUIRED                \
@@ -238,6 +244,25 @@
 
 dnl -------------------------------------------------
 
+dnl Empathy support
+dnl -------------------------------------------------
+
+PKG_CHECK_MODULES(EMPATHY, libempathy >= $EMPATHY_REQUIRED libempathy-gtk >= $EMPATHY_GTK_REQUIRED gio-2.0,
+       [
+       AC_SUBST(EMPATHY_CFLAGS)
+       AC_SUBST(EMPATHY_LIBS)
+       enable_empathy=yes
+       ],
+       [
+       echo "Building without empathy"
+       enable_empathy=no
+       ]
+)
+
+AM_CONDITIONAL(HAVE_EMPATHY, test "x$enable_empathy" = "xyes")
+
+dnl -------------------------------------------------
+
 IT_PROG_INTLTOOL([0.35.0])
 
 GETTEXT_PACKAGE=nautilus-sendto
@@ -315,5 +340,11 @@
    echo "     Enable gajim plugin : NO"
 fi
 
+if test "x${enable_empathy}" = "xyes" ; then
+   echo " **  Enable empathy plugin : YES"
+else
+   echo "     Enable empathy plugin : NO"
+fi
+
 echo "                                                       "
 echo "-------------------------------------------------------"

Modified: trunk/src/plugins/Makefile.am
==============================================================================
--- trunk/src/plugins/Makefile.am	(original)
+++ trunk/src/plugins/Makefile.am	Tue Jan  6 15:17:27 2009
@@ -14,7 +14,8 @@
 	$(BLUETOOTH_CFLAGS)			\
 	$(UPNP_CFLAGS)				\
 	$(DBUS_CFLAGS)				\
-	$(WARN_CFLAGS)
+	$(WARN_CFLAGS)				\
+	$(EMPATHY_CFLAGS)
 
 if HAVE_GAIM
 GAIM_PLUGIN = libnstgaim.la
@@ -70,6 +71,12 @@
 GAJIM_PLUGIN = 
 endif
 
+if HAVE_EMPATHY
+EMPATHY_PLUGIN = libnstempathy.la
+else
+EMPATHY_PLUGIN  =
+endif
+
 MARSHALFILES = econtactentry-marshal.c econtactentry-marshal.h
 BUILT_SOURCES = $(MARSHALFILES)
 
@@ -83,7 +90,7 @@
 regenerate-built-sources:
 	EGGFILES="$(CLA_FILES) econtactentry-marshal.list" EGGDIR="$(CLADIR)" $(srcdir)/update-from-egg.sh || true
 
-plugin_LTLIBRARIES = $(EVOLUTION_PLUGIN) $(GAIM_PLUGIN) $(PIDGIN_PLUGIN) $(BLUETOOTH_PLUGIN) $(UPNP_PLUGIN) $(BALSA_PLUGIN) $(SYLPHEED_PLUGIN) $(THUNDERBIRD_PLUGIN) $(GAJIM_PLUGIN)
+plugin_LTLIBRARIES = $(EVOLUTION_PLUGIN) $(GAIM_PLUGIN) $(PIDGIN_PLUGIN) $(BLUETOOTH_PLUGIN) $(UPNP_PLUGIN) $(BALSA_PLUGIN) $(SYLPHEED_PLUGIN) $(THUNDERBIRD_PLUGIN) $(GAJIM_PLUGIN) $(EMPATHY_PLUGIN)
 
 libnstevolution_la_SOURCES = evolution.c $(CLA_FILES) $(MARSHALFILES)
 libnstevolution_la_LDFLAGS = -module -avoid-version
@@ -128,6 +135,10 @@
 libnstgajim_la_LDFLAGS = -module -avoid-version
 libnstgajim_la_LIBADD = $(DBUS_LIBS)
 
+libnstempathy_la_SOURCES = empathy.c
+libnstempathy_la_LDFLAGS = -module -avoid-version
+libnstempathy_la_LIBADD = $(EMPATHY_LIBS)
+
 EXTRA_DIST = bluetooth-marshal.list $(CLA_FILES)
 CLEANFILES = bluetooth-marshal.h bluetooth-marshal.c econtactentry-marshal.c econtactentry-marshal.h
 

Added: trunk/src/plugins/empathy.c
==============================================================================
--- (empty file)
+++ trunk/src/plugins/empathy.c	Tue Jan  6 15:17:27 2009
@@ -0,0 +1,197 @@
+/*
+ * Copyright (C) 2008 Collabora Ltd.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more av.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301  USA.
+ *
+ * Author: Jonny Lamb <jonny lamb collabora co uk>
+ */
+
+#include "config.h"
+
+#include <glib.h>
+#include <glib/gi18n-lib.h>
+#include <gtk/gtk.h>
+#include <gio/gio.h>
+
+#include <libempathy/empathy-debug.h>
+#include <libempathy/empathy-contact-manager.h>
+#include <libempathy/empathy-dispatcher.h>
+#include <libempathy/empathy-utils.h>
+
+#include <libempathy-gtk/empathy-contact-list-store.h>
+
+#include "../nautilus-sendto-plugin.h"
+
+static EmpathyContactManager *manager = NULL;
+static MissionControl *mc = NULL;
+
+static gboolean destroy (NstPlugin *plugin);
+
+static gboolean
+init (NstPlugin *plugin)
+{
+  GSList *accounts = NULL;
+  GSList *l;
+
+  g_print ("Init %s plugin\n", plugin->info->id);
+
+  empathy_debug_set_flags (g_getenv ("EMPATHY_DEBUG"));
+
+  mc = empathy_mission_control_new ();
+  accounts = mission_control_get_online_connections (mc, FALSE);
+
+  if (g_slist_length (accounts) == 0)
+    {
+      destroy (plugin);
+      return FALSE;
+    }
+
+  for (l = accounts; l; l = l->next)
+    g_object_unref (l->data);
+
+  g_slist_free (accounts);
+
+  return TRUE;
+}
+
+static GtkWidget *
+get_contacts_widget (NstPlugin *plugin)
+{
+  EmpathyContactListStore *store;
+  GtkWidget *combo;
+  GtkCellRenderer *renderer;
+
+  /* TODO: Replace all this with EmpathyContactSelector once it's fixed up and
+   * merged into libempathy-gtk. */
+  manager = empathy_contact_manager_new ();
+  store = empathy_contact_list_store_new (EMPATHY_CONTACT_LIST (manager));
+
+  empathy_contact_list_store_set_is_compact (store, TRUE);
+  empathy_contact_list_store_set_show_groups (store, FALSE);
+
+  combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
+
+  renderer = gtk_cell_renderer_text_new ();
+
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
+  gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo),
+      renderer, "text", EMPATHY_CONTACT_LIST_STORE_COL_NAME);
+
+  return combo;
+}
+
+static gboolean
+get_selected_contact (GtkWidget *contact_widget,
+                      EmpathyContact **contact)
+{
+  GtkTreeModel *model;
+  GtkTreeIter iter;
+
+  if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (contact_widget), &iter))
+    return FALSE;
+
+  model = gtk_combo_box_get_model (GTK_COMBO_BOX (contact_widget));
+  gtk_tree_model_get (model, &iter,
+      EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, contact, -1);
+
+  if (*contact == NULL)
+    return FALSE;
+
+  return TRUE;
+}
+
+static gboolean
+validate_destination (NstPlugin *plugin,
+                      GtkWidget *contact_widget,
+                      gchar **error)
+{
+  EmpathyContact *contact = NULL;
+
+  if (!get_selected_contact (contact_widget, &contact))
+    return FALSE;
+
+  if (!empathy_contact_can_send_files (contact))
+    {
+      *error = g_strdup (_("The contact selected cannot receive files."));
+      return FALSE;
+    }
+
+  if (!empathy_contact_is_online (contact))
+    {
+      *error = g_strdup (_("The contact selected is offline."));
+      return FALSE;
+    }
+
+  g_object_unref (contact);
+
+  return TRUE;
+}
+
+static gboolean
+send_files (NstPlugin *plugin,
+            GtkWidget *contact_widget,
+            GList *file_list)
+{
+  EmpathyContact *contact = NULL;
+  GList *l;
+
+  if (!get_selected_contact (contact_widget, &contact))
+    return FALSE;
+
+  for (l = file_list; l; l = l->next)
+    {
+      gchar *path = l->data;
+      GFile *file;
+
+      file = g_file_new_for_uri (path);
+      empathy_dispatcher_send_file (contact, file);
+
+      g_object_unref (file);
+      g_free (path);
+    }
+
+  g_object_unref (contact);
+
+  return TRUE;
+}
+
+static gboolean
+destroy (NstPlugin *plugin)
+{
+  if (manager)
+    g_object_unref (manager);
+
+  if (mc)
+    g_object_unref (mc);
+
+  return TRUE;
+}
+
+static
+NstPluginInfo plugin_info = {
+  "im",
+  "empathy",
+  N_("Instant Message (Empathy)"),
+  TRUE,
+  init,
+  get_contacts_widget,
+  validate_destination,
+  send_files,
+  destroy
+};
+
+NST_INIT_PLUGIN (plugin_info)
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]