summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2013-06-15 22:39:35 +0200
committerBoris Faure <billiob@gmail.com>2013-06-15 22:47:09 +0200
commitf1c3bf52ca25d4b6f70b4bb45cbbb64363194256 (patch)
treeda3ce54cedac2a364a65ee7ed23834b47b6581b7
parent3ed65bbcdc80b82fb3c404c98bf51631f211bbf9 (diff)
use dbus to tell e.TeamWork whenever a link is detected
This was requested by the crazy e18 release manager.
-rw-r--r--configure.ac12
-rw-r--r--src/bin/Makefile.am3
-rw-r--r--src/bin/dbus.c54
-rw-r--r--src/bin/dbus.h8
-rw-r--r--src/bin/main.c5
-rw-r--r--src/bin/termiolink.c8
6 files changed, 88 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index 95759d5..cc2c80b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,6 +38,15 @@ requirements="\
38 38
39PKG_CHECK_MODULES([TERMINOLOGY], [${requirements}]) 39PKG_CHECK_MODULES([TERMINOLOGY], [${requirements}])
40 40
41PKG_CHECK_MODULES([ELDBUS],
42 [eldbus],
43 [
44 AC_DEFINE(HAVE_ELDBUS, 1, [DBUS support])
45 have_eldbus="yes"
46 ],
47 [have_eldbus="no"]
48 )
49
41AC_CHECK_FUNCS(mkstemps) 50AC_CHECK_FUNCS(mkstemps)
42 51
43EFL_WITH_BIN([edje], [edje-cc], [edje_cc]) 52EFL_WITH_BIN([edje], [edje-cc], [edje_cc])
@@ -96,3 +105,6 @@ echo
96echo "Installation...............: make install (as root if needed, with 'su' or 'sudo')" 105echo "Installation...............: make install (as root if needed, with 'su' or 'sudo')"
97echo " prefix...................: $prefix" 106echo " prefix...................: $prefix"
98echo 107echo
108echo "Features:"
109echo " dbus................: $have_eldbus"
110echo
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index c6b2779..e95dae7 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -6,7 +6,7 @@ terminology_CPPFLAGS = -I. \
6-DPACKAGE_BIN_DIR=\"$(bindir)\" -DPACKAGE_LIB_DIR=\"$(libdir)\" \ 6-DPACKAGE_BIN_DIR=\"$(bindir)\" -DPACKAGE_LIB_DIR=\"$(libdir)\" \
7-DPACKAGE_DATA_DIR=\"$(pkgdatadir)\" @TERMINOLOGY_CFLAGS@ 7-DPACKAGE_DATA_DIR=\"$(pkgdatadir)\" @TERMINOLOGY_CFLAGS@
8 8
9terminology_LDADD = @TERMINOLOGY_LIBS@ 9terminology_LDADD = @TERMINOLOGY_LIBS@ @ELDBUS_LIBS@
10 10
11terminology_SOURCES = \ 11terminology_SOURCES = \
12private.h \ 12private.h \
@@ -41,6 +41,7 @@ lz4/lz4.c lz4/lz4.h \
41utf8.c utf8.h \ 41utf8.c utf8.h \
42win.c win.h \ 42win.c win.h \
43utils.c utils.h \ 43utils.c utils.h \
44dbus.c dbus.h \
44extns.h 45extns.h
45 46
46tybg_SOURCES = \ 47tybg_SOURCES = \
diff --git a/src/bin/dbus.c b/src/bin/dbus.c
new file mode 100644
index 0000000..bbed85d
--- /dev/null
+++ b/src/bin/dbus.c
@@ -0,0 +1,54 @@
1#include "private.h"
2#include <Elementary.h>
3#include "dbus.h"
4#ifdef HAVE_ELDBUS
5#include <Eldbus.h>
6
7static Eldbus_Connection *ty_dbus_conn = NULL;
8static Eldbus_Object *ty_e_object = NULL;
9
10void
11ty_dbus_link_detect(const char *url)
12{
13 Eldbus_Message *msg;
14
15 msg = eldbus_message_method_call_new("org.enlightenment.wm.service",
16 "/org/enlightenment/wm/RemoteObject",
17 "org.enlightenment.wm.Teamwork",
18 "LinkDetect");
19
20 eldbus_message_arguments_append(msg, "s", url);
21 eldbus_object_send(ty_e_object, msg, NULL, NULL, -1);
22}
23
24void
25ty_dbus_init(void)
26{
27 Eldbus_Service_Interface *iface;
28
29 if (ty_dbus_conn) return;
30
31 eldbus_init();
32
33 ty_dbus_conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION);
34 ty_e_object = eldbus_object_get(ty_dbus_conn,
35 "org.enlightenment.wm.service",
36 "/org/enlightenment/wm/RemoteObject");
37}
38
39void
40ty_dbus_shutdown(void)
41{
42 if (ty_dbus_conn) eldbus_connection_unref(ty_dbus_conn);
43 ty_dbus_conn = NULL;
44 ty_e_object = NULL;
45 eldbus_shutdown();
46}
47
48#else
49
50void ty_dbus_link_detect(const char *url __UNUSED__) {}
51void ty_dbus_init(void) {}
52void ty_dbus_shutdown(void) {}
53
54#endif
diff --git a/src/bin/dbus.h b/src/bin/dbus.h
new file mode 100644
index 0000000..089e113
--- /dev/null
+++ b/src/bin/dbus.h
@@ -0,0 +1,8 @@
1#ifndef _DBUS_H__
2#define _DBUS_H__ 1
3
4void ty_dbus_link_detect(const char *url);
5void ty_dbus_init(void);
6void ty_dbus_shutdown(void);
7
8#endif
diff --git a/src/bin/main.c b/src/bin/main.c
index acd4211..5bbf3dc 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -13,6 +13,7 @@
13#include "utils.h" 13#include "utils.h"
14#include "ipc.h" 14#include "ipc.h"
15#include "sel.h" 15#include "sel.h"
16#include "dbus.h"
16 17
17#if (ELM_VERSION_MAJOR == 1) && (ELM_VERSION_MINOR < 8) 18#if (ELM_VERSION_MAJOR == 1) && (ELM_VERSION_MINOR < 8)
18 #define PANES_TOP "left" 19 #define PANES_TOP "left"
@@ -2936,12 +2937,16 @@ remote:
2936 if (nowm) 2937 if (nowm)
2937 ecore_evas_focus_set(ecore_evas_ecore_evas_get( 2938 ecore_evas_focus_set(ecore_evas_ecore_evas_get(
2938 evas_object_evas_get(wn->win)), 1); 2939 evas_object_evas_get(wn->win)), 1);
2940
2941 ty_dbus_init();
2942
2939 elm_run(); 2943 elm_run();
2940 end: 2944 end:
2941#if (ECORE_VERSION_MAJOR > 1) || (ECORE_VERSION_MINOR >= 8) 2945#if (ECORE_VERSION_MAJOR > 1) || (ECORE_VERSION_MINOR >= 8)
2942 free(cmd); 2946 free(cmd);
2943#endif 2947#endif
2944 2948
2949 ty_dbus_shutdown();
2945 ipc_shutdown(); 2950 ipc_shutdown();
2946 2951
2947 while (wins) 2952 while (wins)
diff --git a/src/bin/termiolink.c b/src/bin/termiolink.c
index 8731da2..f7255e5 100644
--- a/src/bin/termiolink.c
+++ b/src/bin/termiolink.c
@@ -2,6 +2,7 @@
2#include <Elementary.h> 2#include <Elementary.h>
3#include "termio.h" 3#include "termio.h"
4#include "utils.h" 4#include "utils.h"
5#include "dbus.h"
5 6
6static Eina_Bool 7static Eina_Bool
7coord_back(int *x, int *y, int w, int h __UNUSED__) 8coord_back(int *x, int *y, int w, int h __UNUSED__)
@@ -204,9 +205,10 @@ _termio_link_find(Evas_Object *obj, int cx, int cy,
204 if ((len > 1) && (!endmatch)) 205 if ((len > 1) && (!endmatch))
205 { 206 {
206 Eina_Bool is_file = _is_file(s); 207 Eina_Bool is_file = _is_file(s);
208 Eina_Bool is_url = link_is_url(s);
207 if (is_file || 209 if (is_file ||
208 link_is_email(s) || 210 link_is_email(s) ||
209 link_is_url(s)) 211 is_url)
210 { 212 {
211 if (x1r) *x1r = x1; 213 if (x1r) *x1r = x1;
212 if (y1r) *y1r = y1; 214 if (y1r) *y1r = y1;
@@ -219,6 +221,10 @@ _termio_link_find(Evas_Object *obj, int cx, int cy,
219 free(s); 221 free(s);
220 return ret; 222 return ret;
221 } 223 }
224 else if (is_url)
225 {
226 ty_dbus_link_detect(s);
227 }
222 228
223 return s; 229 return s;
224 } 230 }