From f1c3bf52ca25d4b6f70b4bb45cbbb64363194256 Mon Sep 17 00:00:00 2001 From: Boris Faure Date: Sat, 15 Jun 2013 22:39:35 +0200 Subject: [PATCH] use dbus to tell e.TeamWork whenever a link is detected This was requested by the crazy e18 release manager. --- configure.ac | 12 ++++++++++ src/bin/Makefile.am | 3 ++- src/bin/dbus.c | 54 ++++++++++++++++++++++++++++++++++++++++++++ src/bin/dbus.h | 8 +++++++ src/bin/main.c | 5 ++++ src/bin/termiolink.c | 8 ++++++- 6 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 src/bin/dbus.c create mode 100644 src/bin/dbus.h diff --git a/configure.ac b/configure.ac index 95759d5b..cc2c80b3 100644 --- a/configure.ac +++ b/configure.ac @@ -38,6 +38,15 @@ requirements="\ PKG_CHECK_MODULES([TERMINOLOGY], [${requirements}]) +PKG_CHECK_MODULES([ELDBUS], + [eldbus], + [ + AC_DEFINE(HAVE_ELDBUS, 1, [DBUS support]) + have_eldbus="yes" + ], + [have_eldbus="no"] + ) + AC_CHECK_FUNCS(mkstemps) EFL_WITH_BIN([edje], [edje-cc], [edje_cc]) @@ -96,3 +105,6 @@ echo echo "Installation...............: make install (as root if needed, with 'su' or 'sudo')" echo " prefix...................: $prefix" echo +echo "Features:" +echo " dbus................: $have_eldbus" +echo diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index c6b2779b..e95dae79 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -6,7 +6,7 @@ terminology_CPPFLAGS = -I. \ -DPACKAGE_BIN_DIR=\"$(bindir)\" -DPACKAGE_LIB_DIR=\"$(libdir)\" \ -DPACKAGE_DATA_DIR=\"$(pkgdatadir)\" @TERMINOLOGY_CFLAGS@ -terminology_LDADD = @TERMINOLOGY_LIBS@ +terminology_LDADD = @TERMINOLOGY_LIBS@ @ELDBUS_LIBS@ terminology_SOURCES = \ private.h \ @@ -41,6 +41,7 @@ lz4/lz4.c lz4/lz4.h \ utf8.c utf8.h \ win.c win.h \ utils.c utils.h \ +dbus.c dbus.h \ extns.h tybg_SOURCES = \ diff --git a/src/bin/dbus.c b/src/bin/dbus.c new file mode 100644 index 00000000..bbed85db --- /dev/null +++ b/src/bin/dbus.c @@ -0,0 +1,54 @@ +#include "private.h" +#include +#include "dbus.h" +#ifdef HAVE_ELDBUS +#include + +static Eldbus_Connection *ty_dbus_conn = NULL; +static Eldbus_Object *ty_e_object = NULL; + +void +ty_dbus_link_detect(const char *url) +{ + Eldbus_Message *msg; + + msg = eldbus_message_method_call_new("org.enlightenment.wm.service", + "/org/enlightenment/wm/RemoteObject", + "org.enlightenment.wm.Teamwork", + "LinkDetect"); + + eldbus_message_arguments_append(msg, "s", url); + eldbus_object_send(ty_e_object, msg, NULL, NULL, -1); +} + +void +ty_dbus_init(void) +{ + Eldbus_Service_Interface *iface; + + if (ty_dbus_conn) return; + + eldbus_init(); + + ty_dbus_conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION); + ty_e_object = eldbus_object_get(ty_dbus_conn, + "org.enlightenment.wm.service", + "/org/enlightenment/wm/RemoteObject"); +} + +void +ty_dbus_shutdown(void) +{ + if (ty_dbus_conn) eldbus_connection_unref(ty_dbus_conn); + ty_dbus_conn = NULL; + ty_e_object = NULL; + eldbus_shutdown(); +} + +#else + +void ty_dbus_link_detect(const char *url __UNUSED__) {} +void ty_dbus_init(void) {} +void ty_dbus_shutdown(void) {} + +#endif diff --git a/src/bin/dbus.h b/src/bin/dbus.h new file mode 100644 index 00000000..089e1136 --- /dev/null +++ b/src/bin/dbus.h @@ -0,0 +1,8 @@ +#ifndef _DBUS_H__ +#define _DBUS_H__ 1 + +void ty_dbus_link_detect(const char *url); +void ty_dbus_init(void); +void ty_dbus_shutdown(void); + +#endif diff --git a/src/bin/main.c b/src/bin/main.c index acd42118..5bbf3dcd 100644 --- a/src/bin/main.c +++ b/src/bin/main.c @@ -13,6 +13,7 @@ #include "utils.h" #include "ipc.h" #include "sel.h" +#include "dbus.h" #if (ELM_VERSION_MAJOR == 1) && (ELM_VERSION_MINOR < 8) #define PANES_TOP "left" @@ -2936,12 +2937,16 @@ remote: if (nowm) ecore_evas_focus_set(ecore_evas_ecore_evas_get( evas_object_evas_get(wn->win)), 1); + + ty_dbus_init(); + elm_run(); end: #if (ECORE_VERSION_MAJOR > 1) || (ECORE_VERSION_MINOR >= 8) free(cmd); #endif + ty_dbus_shutdown(); ipc_shutdown(); while (wins) diff --git a/src/bin/termiolink.c b/src/bin/termiolink.c index 8731da2e..f7255e59 100644 --- a/src/bin/termiolink.c +++ b/src/bin/termiolink.c @@ -2,6 +2,7 @@ #include #include "termio.h" #include "utils.h" +#include "dbus.h" static Eina_Bool coord_back(int *x, int *y, int w, int h __UNUSED__) @@ -204,9 +205,10 @@ _termio_link_find(Evas_Object *obj, int cx, int cy, if ((len > 1) && (!endmatch)) { Eina_Bool is_file = _is_file(s); + Eina_Bool is_url = link_is_url(s); if (is_file || link_is_email(s) || - link_is_url(s)) + is_url) { if (x1r) *x1r = x1; if (y1r) *y1r = y1; @@ -219,6 +221,10 @@ _termio_link_find(Evas_Object *obj, int cx, int cy, free(s); return ret; } + else if (is_url) + { + ty_dbus_link_detect(s); + } return s; }