From bfbf55700091bb6084b3cbe151a762816db0e3f0 Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Wed, 11 Apr 2012 03:12:40 +0200 Subject: initial import --- meego/Makefile | 27 ++ meego/debug.h | 20 ++ meego/glue.h | 558 +++++++++++++++++++++++++++++++++++ meego/meego-im-client.xml | 78 +++++ meego/meego-im-connector.c | 111 +++++++ meego/meego-im-connector.h | 27 ++ meego/meego-im-defs.h | 91 ++++++ meego/meego-im-proxy-glue.h | 590 ++++++++++++++++++++++++++++++++++++++ meego/meego-im-proxy.c | 328 +++++++++++++++++++++ meego/meego-im-proxy.h | 82 ++++++ meego/meego-imcontext-dbus-glue.h | 491 +++++++++++++++++++++++++++++++ meego/meego-imcontext-dbus.c | 225 +++++++++++++++ meego/meego-imcontext-dbus.h | 78 +++++ meego/meego-imcontext-dbus.xml | 71 +++++ meego/qt-keysym-map.cpp | 542 ++++++++++++++++++++++++++++++++++ meego/qt-keysym-map.h | 13 + meego/qt-translate.cpp | 195 +++++++++++++ meego/qt-translate.h | 34 +++ meego/src.pro | 71 +++++ 19 files changed, 3632 insertions(+) create mode 100644 meego/Makefile create mode 100644 meego/debug.h create mode 100644 meego/glue.h create mode 100644 meego/meego-im-client.xml create mode 100644 meego/meego-im-connector.c create mode 100644 meego/meego-im-connector.h create mode 100644 meego/meego-im-defs.h create mode 100644 meego/meego-im-proxy-glue.h create mode 100644 meego/meego-im-proxy.c create mode 100644 meego/meego-im-proxy.h create mode 100644 meego/meego-imcontext-dbus-glue.h create mode 100644 meego/meego-imcontext-dbus.c create mode 100644 meego/meego-imcontext-dbus.h create mode 100644 meego/meego-imcontext-dbus.xml create mode 100644 meego/qt-keysym-map.cpp create mode 100644 meego/qt-keysym-map.h create mode 100644 meego/qt-translate.cpp create mode 100644 meego/qt-translate.h create mode 100644 meego/src.pro (limited to 'meego') diff --git a/meego/Makefile b/meego/Makefile new file mode 100644 index 0000000..4992cad --- /dev/null +++ b/meego/Makefile @@ -0,0 +1,27 @@ +CFLAGS?=-g -O0 -Wall +LDFLAGS?=-Wl,-O1 + +MEEGOIMCOMMON_TARGET:=libmeego-im-common.a + +MEEGOIMCOMMON_OBJS:=meego-im-connector.o meego-imcontext-dbus.o meego-im-proxy.o \ + qt-keysym-map.o qt-translate.o +MEEGOIMCOMMON_PKGCONFIG:=x11 dbus-glib-1 QtCore QtGui +MEEGOIMCOMMON_CFLAGS:=$(shell pkg-config --cflags $(MEEGOIMCOMMON_PKGCONFIG)) -DQT_NO_KEYWORDS -std=c99 +MEEGOIMCOMMON_CXXFLAGS:=$(shell pkg-config --cflags $(MEEGOIMCOMMON_PKGCONFIG)) + +all: $(MEEGOIMCOMMON_TARGET) + +$(MEEGOIMCOMMON_TARGET): $(MEEGOIMCOMMON_OBJS) + ar rcs $@ $^ + +%.o: %.c + $(CC) $(MEEGOIMCOMMON_CFLAGS) $(CFLAGS) -o $@ -c $< + +%.o: %.cpp + $(CXX) $(MEEGOIMCOMMON_CXXFLAGS) $(CFLAGS) -o $@ -c $< + +clean: + rm -f $(MEEGOIMCOMMON_TARGET) *.o + +.PHONY: all clean + diff --git a/meego/debug.h b/meego/debug.h new file mode 100644 index 0000000..46f0766 --- /dev/null +++ b/meego/debug.h @@ -0,0 +1,20 @@ +#ifndef _DEBUG_H +#define _DEBUG_H + +#include +#include + +G_BEGIN_DECLS + +#if defined(ENABLE_DEBUG) +#define DBG(x, a...) g_fprintf (stderr, __FILE__ ",%d,%s: " x "\n", __LINE__, __func__, ##a) +#else +#define DBG(x, a...) do {} while (0) +#endif + +#define STEP() DBG("") + +#define UNUSED(v) (void)v; + +G_END_DECLS +#endif // _DEBUG_H diff --git a/meego/glue.h b/meego/glue.h new file mode 100644 index 0000000..974bd1d --- /dev/null +++ b/meego/glue.h @@ -0,0 +1,558 @@ +/* Generated by dbus-binding-tool; do not edit! */ + +#include +#include + +G_BEGIN_DECLS + +#ifndef _DBUS_GLIB_ASYNC_DATA_FREE +#define _DBUS_GLIB_ASYNC_DATA_FREE +static +#ifdef G_HAVE_INLINE +inline +#endif +void +_dbus_glib_async_data_free (gpointer stuff) +{ + g_slice_free (DBusGAsyncData, stuff); +} +#endif + +#ifndef DBUS_GLIB_CLIENT_WRAPPERS_com_meego_inputmethod_inputcontext1 +#define DBUS_GLIB_CLIENT_WRAPPERS_com_meego_inputmethod_inputcontext1 + +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_inputcontext1_activation_lost_event (DBusGProxy *proxy, GError **error) + +{ + dbus_g_proxy_call_no_reply (proxy, "activationLostEvent", G_TYPE_INVALID, G_TYPE_INVALID); + return TRUE; +} + +typedef void (*com_meego_inputmethod_inputcontext1_activation_lost_event_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_inputcontext1_activation_lost_event_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(com_meego_inputmethod_inputcontext1_activation_lost_event_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_inputcontext1_activation_lost_event_async (DBusGProxy *proxy, com_meego_inputmethod_inputcontext1_activation_lost_event_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "activationLostEvent", com_meego_inputmethod_inputcontext1_activation_lost_event_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_inputcontext1_im_initiated_hide (DBusGProxy *proxy, GError **error) + +{ + dbus_g_proxy_call_no_reply (proxy, "imInitiatedHide", G_TYPE_INVALID, G_TYPE_INVALID); + return TRUE; +} + +typedef void (*com_meego_inputmethod_inputcontext1_im_initiated_hide_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_inputcontext1_im_initiated_hide_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(com_meego_inputmethod_inputcontext1_im_initiated_hide_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_inputcontext1_im_initiated_hide_async (DBusGProxy *proxy, com_meego_inputmethod_inputcontext1_im_initiated_hide_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "imInitiatedHide", com_meego_inputmethod_inputcontext1_im_initiated_hide_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_inputcontext1_commit_string (DBusGProxy *proxy, const char * IN_string, const gint IN_replaceStart, const gint IN_replaceLength, const gint IN_cursorPos, GError **error) + +{ + dbus_g_proxy_call_no_reply (proxy, "commitString", G_TYPE_STRING, IN_string, G_TYPE_INT, IN_replaceStart, G_TYPE_INT, IN_replaceLength, G_TYPE_INT, IN_cursorPos, G_TYPE_INVALID, G_TYPE_INVALID); + return TRUE; +} + +typedef void (*com_meego_inputmethod_inputcontext1_commit_string_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_inputcontext1_commit_string_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(com_meego_inputmethod_inputcontext1_commit_string_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_inputcontext1_commit_string_async (DBusGProxy *proxy, const char * IN_string, const gint IN_replaceStart, const gint IN_replaceLength, const gint IN_cursorPos, com_meego_inputmethod_inputcontext1_commit_string_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "commitString", com_meego_inputmethod_inputcontext1_commit_string_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_STRING, IN_string, G_TYPE_INT, IN_replaceStart, G_TYPE_INT, IN_replaceLength, G_TYPE_INT, IN_cursorPos, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_inputcontext1_update_preedit (DBusGProxy *proxy, const char * IN_string, const GPtrArray* IN_formatList, const gint IN_replaceStart, const gint IN_replaceLength, const gint IN_cursorPos, GError **error) + +{ + dbus_g_proxy_call_no_reply (proxy, "updatePreedit", G_TYPE_STRING, IN_string, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_struct ("GValueArray", G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INVALID)), IN_formatList, G_TYPE_INT, IN_replaceStart, G_TYPE_INT, IN_replaceLength, G_TYPE_INT, IN_cursorPos, G_TYPE_INVALID, G_TYPE_INVALID); + return TRUE; +} + +typedef void (*com_meego_inputmethod_inputcontext1_update_preedit_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_inputcontext1_update_preedit_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(com_meego_inputmethod_inputcontext1_update_preedit_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_inputcontext1_update_preedit_async (DBusGProxy *proxy, const char * IN_string, const GPtrArray* IN_formatList, const gint IN_replaceStart, const gint IN_replaceLength, const gint IN_cursorPos, com_meego_inputmethod_inputcontext1_update_preedit_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "updatePreedit", com_meego_inputmethod_inputcontext1_update_preedit_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_STRING, IN_string, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_struct ("GValueArray", G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INVALID)), IN_formatList, G_TYPE_INT, IN_replaceStart, G_TYPE_INT, IN_replaceLength, G_TYPE_INT, IN_cursorPos, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_inputcontext1_key_event (DBusGProxy *proxy, const gint IN_type, const gint IN_key, const gint IN_modifiers, const char * IN_text, const gboolean IN_autoRepeat, const gint IN_count, const guchar IN_requestType, GError **error) + +{ + dbus_g_proxy_call_no_reply (proxy, "keyEvent", G_TYPE_INT, IN_type, G_TYPE_INT, IN_key, G_TYPE_INT, IN_modifiers, G_TYPE_STRING, IN_text, G_TYPE_BOOLEAN, IN_autoRepeat, G_TYPE_INT, IN_count, G_TYPE_UCHAR, IN_requestType, G_TYPE_INVALID, G_TYPE_INVALID); + return TRUE; +} + +typedef void (*com_meego_inputmethod_inputcontext1_key_event_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_inputcontext1_key_event_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(com_meego_inputmethod_inputcontext1_key_event_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_inputcontext1_key_event_async (DBusGProxy *proxy, const gint IN_type, const gint IN_key, const gint IN_modifiers, const char * IN_text, const gboolean IN_autoRepeat, const gint IN_count, const guchar IN_requestType, com_meego_inputmethod_inputcontext1_key_event_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "keyEvent", com_meego_inputmethod_inputcontext1_key_event_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INT, IN_type, G_TYPE_INT, IN_key, G_TYPE_INT, IN_modifiers, G_TYPE_STRING, IN_text, G_TYPE_BOOLEAN, IN_autoRepeat, G_TYPE_INT, IN_count, G_TYPE_UCHAR, IN_requestType, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_inputcontext1_update_input_method_area (DBusGProxy *proxy, const GArray* IN_data, GError **error) + +{ + dbus_g_proxy_call_no_reply (proxy, "updateInputMethodArea", dbus_g_type_get_collection ("GArray", G_TYPE_UCHAR), IN_data, G_TYPE_INVALID, G_TYPE_INVALID); + return TRUE; +} + +typedef void (*com_meego_inputmethod_inputcontext1_update_input_method_area_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_inputcontext1_update_input_method_area_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(com_meego_inputmethod_inputcontext1_update_input_method_area_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_inputcontext1_update_input_method_area_async (DBusGProxy *proxy, const GArray* IN_data, com_meego_inputmethod_inputcontext1_update_input_method_area_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "updateInputMethodArea", com_meego_inputmethod_inputcontext1_update_input_method_area_async_callback, stuff, _dbus_glib_async_data_free, dbus_g_type_get_collection ("GArray", G_TYPE_UCHAR), IN_data, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_inputcontext1_set_global_correction_enabled (DBusGProxy *proxy, const gboolean IN_enabled, GError **error) + +{ + dbus_g_proxy_call_no_reply (proxy, "setGlobalCorrectionEnabled", G_TYPE_BOOLEAN, IN_enabled, G_TYPE_INVALID, G_TYPE_INVALID); + return TRUE; +} + +typedef void (*com_meego_inputmethod_inputcontext1_set_global_correction_enabled_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_inputcontext1_set_global_correction_enabled_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(com_meego_inputmethod_inputcontext1_set_global_correction_enabled_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_inputcontext1_set_global_correction_enabled_async (DBusGProxy *proxy, const gboolean IN_enabled, com_meego_inputmethod_inputcontext1_set_global_correction_enabled_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "setGlobalCorrectionEnabled", com_meego_inputmethod_inputcontext1_set_global_correction_enabled_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_BOOLEAN, IN_enabled, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_inputcontext1_copy (DBusGProxy *proxy, GError **error) + +{ + dbus_g_proxy_call_no_reply (proxy, "copy", G_TYPE_INVALID, G_TYPE_INVALID); + return TRUE; +} + +typedef void (*com_meego_inputmethod_inputcontext1_copy_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_inputcontext1_copy_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(com_meego_inputmethod_inputcontext1_copy_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_inputcontext1_copy_async (DBusGProxy *proxy, com_meego_inputmethod_inputcontext1_copy_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "copy", com_meego_inputmethod_inputcontext1_copy_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_inputcontext1_paste (DBusGProxy *proxy, GError **error) + +{ + dbus_g_proxy_call_no_reply (proxy, "paste", G_TYPE_INVALID, G_TYPE_INVALID); + return TRUE; +} + +typedef void (*com_meego_inputmethod_inputcontext1_paste_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_inputcontext1_paste_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(com_meego_inputmethod_inputcontext1_paste_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_inputcontext1_paste_async (DBusGProxy *proxy, com_meego_inputmethod_inputcontext1_paste_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "paste", com_meego_inputmethod_inputcontext1_paste_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_inputcontext1_set_redirect_keys (DBusGProxy *proxy, const gboolean IN_enabled, GError **error) + +{ + dbus_g_proxy_call_no_reply (proxy, "setRedirectKeys", G_TYPE_BOOLEAN, IN_enabled, G_TYPE_INVALID, G_TYPE_INVALID); + return TRUE; +} + +typedef void (*com_meego_inputmethod_inputcontext1_set_redirect_keys_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_inputcontext1_set_redirect_keys_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(com_meego_inputmethod_inputcontext1_set_redirect_keys_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_inputcontext1_set_redirect_keys_async (DBusGProxy *proxy, const gboolean IN_enabled, com_meego_inputmethod_inputcontext1_set_redirect_keys_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "setRedirectKeys", com_meego_inputmethod_inputcontext1_set_redirect_keys_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_BOOLEAN, IN_enabled, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_inputcontext1_preedit_rectangle (DBusGProxy *proxy, gboolean* OUT_valid, GValueArray** OUT_rect, GError **error) + +{ + return dbus_g_proxy_call (proxy, "preeditRectangle", error, G_TYPE_INVALID, G_TYPE_BOOLEAN, OUT_valid, dbus_g_type_get_struct ("GValueArray", G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INVALID), OUT_rect, G_TYPE_INVALID); +} + +typedef void (*com_meego_inputmethod_inputcontext1_preedit_rectangle_reply) (DBusGProxy *proxy, gboolean OUT_valid, GValueArray *OUT_rect, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_inputcontext1_preedit_rectangle_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + gboolean OUT_valid; + GValueArray* OUT_rect; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_BOOLEAN, &OUT_valid, dbus_g_type_get_struct ("GValueArray", G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INVALID), &OUT_rect, G_TYPE_INVALID); + (*(com_meego_inputmethod_inputcontext1_preedit_rectangle_reply)data->cb) (proxy, OUT_valid, OUT_rect, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_inputcontext1_preedit_rectangle_async (DBusGProxy *proxy, com_meego_inputmethod_inputcontext1_preedit_rectangle_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "preeditRectangle", com_meego_inputmethod_inputcontext1_preedit_rectangle_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_inputcontext1_set_detectable_auto_repeat (DBusGProxy *proxy, const gboolean IN_enabled, GError **error) + +{ + return dbus_g_proxy_call (proxy, "setDetectableAutoRepeat", error, G_TYPE_BOOLEAN, IN_enabled, G_TYPE_INVALID, G_TYPE_INVALID); +} + +typedef void (*com_meego_inputmethod_inputcontext1_set_detectable_auto_repeat_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_inputcontext1_set_detectable_auto_repeat_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(com_meego_inputmethod_inputcontext1_set_detectable_auto_repeat_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_inputcontext1_set_detectable_auto_repeat_async (DBusGProxy *proxy, const gboolean IN_enabled, com_meego_inputmethod_inputcontext1_set_detectable_auto_repeat_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "setDetectableAutoRepeat", com_meego_inputmethod_inputcontext1_set_detectable_auto_repeat_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_BOOLEAN, IN_enabled, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_inputcontext1_set_selection (DBusGProxy *proxy, const gint IN_start, const gint IN_length, GError **error) + +{ + return dbus_g_proxy_call (proxy, "setSelection", error, G_TYPE_INT, IN_start, G_TYPE_INT, IN_length, G_TYPE_INVALID, G_TYPE_INVALID); +} + +typedef void (*com_meego_inputmethod_inputcontext1_set_selection_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_inputcontext1_set_selection_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(com_meego_inputmethod_inputcontext1_set_selection_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_inputcontext1_set_selection_async (DBusGProxy *proxy, const gint IN_start, const gint IN_length, com_meego_inputmethod_inputcontext1_set_selection_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "setSelection", com_meego_inputmethod_inputcontext1_set_selection_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INT, IN_start, G_TYPE_INT, IN_length, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_inputcontext1_selection (DBusGProxy *proxy, gboolean* OUT_valid, char ** OUT_selectionText, GError **error) + +{ + return dbus_g_proxy_call (proxy, "selection", error, G_TYPE_INVALID, G_TYPE_BOOLEAN, OUT_valid, G_TYPE_STRING, OUT_selectionText, G_TYPE_INVALID); +} + +typedef void (*com_meego_inputmethod_inputcontext1_selection_reply) (DBusGProxy *proxy, gboolean OUT_valid, char * OUT_selectionText, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_inputcontext1_selection_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + gboolean OUT_valid; + char * OUT_selectionText; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_BOOLEAN, &OUT_valid, G_TYPE_STRING, &OUT_selectionText, G_TYPE_INVALID); + (*(com_meego_inputmethod_inputcontext1_selection_reply)data->cb) (proxy, OUT_valid, OUT_selectionText, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_inputcontext1_selection_async (DBusGProxy *proxy, com_meego_inputmethod_inputcontext1_selection_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "selection", com_meego_inputmethod_inputcontext1_selection_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INVALID); +} +#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_com_meego_inputmethod_inputcontext1 */ + +G_END_DECLS diff --git a/meego/meego-im-client.xml b/meego/meego-im-client.xml new file mode 100644 index 0000000..a6024cb --- /dev/null +++ b/meego/meego-im-client.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/meego/meego-im-connector.c b/meego/meego-im-connector.c new file mode 100644 index 0000000..d316235 --- /dev/null +++ b/meego/meego-im-connector.c @@ -0,0 +1,111 @@ +/* * This file is part of meego-im-framework * + * + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (directui@nokia.com) + * + * If you have questions regarding the use of this file, please contact + * Nokia at directui@nokia.com. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation + * and appearing in the file LICENSE.LGPL included in the packaging + * of this file. + */ + +#include "meego-im-connector.h" + +#include + +#define MEEGO_IM_SOCKET_PATH "unix:path=/tmp/meego-im-uiserver/imserver_dbus" + +MeegoImConnector *meego_im_connector_new(); + +static gboolean +try_reconnect(MeegoImConnector *connector) +{ + meego_im_connector_run(connector); + return FALSE; // _run is responsible for setting up a new timeout if needed +} + + +static void +connection_dropped(gpointer instance, MeegoImConnector *connector) +{ + if (connector->connection) { + dbus_g_connection_unref(connector->connection); + } + try_reconnect(connector); +} + + +/** + * MeegoImConnector: + * + * Connects and maintains the DBusConnection, and the objects + * that depend on it. Makes sure that MeegoIMProxy and MeegoIMDbusObj + * has the correct DBusConnection by calling _connect on them when + * the connection has changed. + * + * MeegoIMProxy is responsible for letting the connector know that the + * connection was dropped by emitting the "connection-dropped signal". + */ +MeegoImConnector * +meego_im_connector_new() +{ + MeegoImConnector *self = g_new(MeegoImConnector, 1); + + self->connection = NULL; + self->dbusobj = meego_imcontext_dbusobj_get_singleton(); + self->proxy = meego_im_proxy_get_singleton(); + + g_signal_connect(self->proxy, "connection-dropped", + G_CALLBACK(connection_dropped), (gpointer)self); + + return self; +} + +void +meego_im_connector_free(MeegoImConnector *self) +{ + if (self->connection) { + dbus_g_connection_unref(self->connection); + } + g_free(self); +} + +MeegoImConnector * +meego_im_connector_get_singleton() +{ + static MeegoImConnector *connector = NULL; + if (!connector) { + connector = meego_im_connector_new(); + meego_im_connector_run(connector); + } + return connector; +} + +void +meego_im_connector_run(MeegoImConnector *self) +{ + GError *error = NULL; + DBusGConnection *connection = NULL; + + g_return_if_fail(self != NULL); + + connection = dbus_g_connection_open(MEEGO_IM_SOCKET_PATH, &error); + + if (error != NULL) { + g_warning("Couldn't connect to Maliit server. Retrying..."); + g_error_free(error); + + g_timeout_add_seconds(2, (GSourceFunc)try_reconnect, self); + return; + } + + self->connection = connection; + + meego_im_proxy_connect(self->proxy, self->connection); + meego_imcontext_dbusobj_connect(self->dbusobj, self->connection); +} diff --git a/meego/meego-im-connector.h b/meego/meego-im-connector.h new file mode 100644 index 0000000..cb283a5 --- /dev/null +++ b/meego/meego-im-connector.h @@ -0,0 +1,27 @@ +/* * This file is part of meego-im-framework * + * + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (directui@nokia.com) + * + * If you have questions regarding the use of this file, please contact + * Nokia at directui@nokia.com. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation + * and appearing in the file LICENSE.LGPL included in the packaging + * of this file. + */ + +#include "meego-im-proxy.h" +#include "meego-imcontext-dbus.h" + +typedef struct { + MeegoIMProxy *proxy; + MeegoIMContextDbusObj *dbusobj; + DBusGConnection *connection; +} MeegoImConnector; + +void meego_im_connector_run(MeegoImConnector *self); +MeegoImConnector *meego_im_connector_get_singleton(); diff --git a/meego/meego-im-defs.h b/meego/meego-im-defs.h new file mode 100644 index 0000000..85443bc --- /dev/null +++ b/meego/meego-im-defs.h @@ -0,0 +1,91 @@ +/* * This file partially from the meego-im-framework * + * + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (directui@nokia.com) + * + * If you have questions regarding the use of this file, please contact + * Nokia at directui@nokia.com. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation + * and appearing in the file LICENSE.LGPL included in the packaging + * of this file. + */ + +#ifndef MEEGO_IM_DEFS_H +#define MEEGO_IM_DEFS_H + +#include + +enum MeegoImOrientationAngle { + MeegoImAngle0 = 0, + MeegoImAngle90 = 90, + MeegoImAngle180 = 180, + MeegoImAngle270 = 270 +}; + +/*! + * This enum contains possible values for orientation of windows in the application. + * + * \sa OrientationAngle + */ +enum MeegoImOrientation { + MeegoImPortrait, //!< equal to either M::Angle90 or M::Angle270 orientation angles + MeegoImLandscape //!< equal to either M::Angle0 or M::Angle180 orientation angles +}; + +//! Content type for text entries. Used at least with MTextEdit +enum MeegoImTextContentType { + //! all characters allowed + MeegoImFreeTextContentType, + + //! only integer numbers allowed + MeegoImNumberContentType, + + //! allows numbers and certain other characters used in phone numbers + MeegoImPhoneNumberContentType, + + //! allows only characters permitted in email address + MeegoImEmailContentType, + + //! allows only character permitted in URL address + MeegoImUrlContentType, + + //! allows content with user defined format + MeegoImCustomContentType +}; + +enum MeegoImInputMethodMode { + //! Normal mode allows to use preedit and error correction + MeegoImInputMethodModeNormal, + + //! Virtual keyboard sends QKeyEvent for every key press or release + MeegoImInputMethodModeDirect, + + //! Used with proxy widget + MeegoImInputMethodModeProxy +}; + +typedef enum _MeegoImPreeditFace { + MeegoImPreeditDefault, + MeegoImPreeditNoCandidates, + MeegoImPreeditKeyPress //! Used for displaying the hwkbd key just pressed +} MeegoImPreeditFace; + +typedef struct _MeegoImPreeditFormat { + int start; + int length; + MeegoImPreeditFace face; +} MeegoImPreeditFormat; + +typedef struct _MeegoImKeyEvent +{ + gboolean release; + unsigned int state; + unsigned int keysym; + char *text; +} MeegoImKeyEvent; + +#endif diff --git a/meego/meego-im-proxy-glue.h b/meego/meego-im-proxy-glue.h new file mode 100644 index 0000000..948368c --- /dev/null +++ b/meego/meego-im-proxy-glue.h @@ -0,0 +1,590 @@ +/* Generated by dbus-binding-tool; do not edit! */ + +#include +#include + +G_BEGIN_DECLS + +#ifndef _DBUS_GLIB_ASYNC_DATA_FREE +#define _DBUS_GLIB_ASYNC_DATA_FREE +static +#ifdef G_HAVE_INLINE +inline +#endif +void +_dbus_glib_async_data_free (gpointer stuff) +{ + g_slice_free (DBusGAsyncData, stuff); +} +#endif + +#ifndef DBUS_GLIB_CLIENT_WRAPPERS_com_meego_inputmethod_uiserver1 +#define DBUS_GLIB_CLIENT_WRAPPERS_com_meego_inputmethod_uiserver1 + +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_uiserver1_show_input_method (DBusGProxy *proxy, GError **error) + +{ + dbus_g_proxy_call_no_reply (proxy, "showInputMethod", G_TYPE_INVALID, G_TYPE_INVALID); + return TRUE; +} + +typedef void (*com_meego_inputmethod_uiserver1_show_input_method_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_uiserver1_show_input_method_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(com_meego_inputmethod_uiserver1_show_input_method_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_uiserver1_show_input_method_async (DBusGProxy *proxy, com_meego_inputmethod_uiserver1_show_input_method_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "showInputMethod", com_meego_inputmethod_uiserver1_show_input_method_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_uiserver1_hide_input_method (DBusGProxy *proxy, GError **error) + +{ + dbus_g_proxy_call_no_reply (proxy, "hideInputMethod", G_TYPE_INVALID, G_TYPE_INVALID); + return TRUE; +} + +typedef void (*com_meego_inputmethod_uiserver1_hide_input_method_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_uiserver1_hide_input_method_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(com_meego_inputmethod_uiserver1_hide_input_method_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_uiserver1_hide_input_method_async (DBusGProxy *proxy, com_meego_inputmethod_uiserver1_hide_input_method_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "hideInputMethod", com_meego_inputmethod_uiserver1_hide_input_method_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_uiserver1_mouse_clicked_on_preedit (DBusGProxy *proxy, const gint IN_posX, const gint IN_posY, const gint IN_preeditX, const gint IN_preeditY, const gint IN_preeditWidth, const gint IN_preeditHeight, GError **error) + +{ + return dbus_g_proxy_call (proxy, "mouseClickedOnPreedit", error, G_TYPE_INT, IN_posX, G_TYPE_INT, IN_posY, G_TYPE_INT, IN_preeditX, G_TYPE_INT, IN_preeditY, G_TYPE_INT, IN_preeditWidth, G_TYPE_INT, IN_preeditHeight, G_TYPE_INVALID, G_TYPE_INVALID); +} + +typedef void (*com_meego_inputmethod_uiserver1_mouse_clicked_on_preedit_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_uiserver1_mouse_clicked_on_preedit_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(com_meego_inputmethod_uiserver1_mouse_clicked_on_preedit_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_uiserver1_mouse_clicked_on_preedit_async (DBusGProxy *proxy, const gint IN_posX, const gint IN_posY, const gint IN_preeditX, const gint IN_preeditY, const gint IN_preeditWidth, const gint IN_preeditHeight, com_meego_inputmethod_uiserver1_mouse_clicked_on_preedit_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "mouseClickedOnPreedit", com_meego_inputmethod_uiserver1_mouse_clicked_on_preedit_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INT, IN_posX, G_TYPE_INT, IN_posY, G_TYPE_INT, IN_preeditX, G_TYPE_INT, IN_preeditY, G_TYPE_INT, IN_preeditWidth, G_TYPE_INT, IN_preeditHeight, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_uiserver1_set_preedit (DBusGProxy *proxy, const char * IN_text, const gint IN_cursorPos, GError **error) + +{ + dbus_g_proxy_call_no_reply (proxy, "setPreedit", G_TYPE_STRING, IN_text, G_TYPE_INT, IN_cursorPos, G_TYPE_INVALID, G_TYPE_INVALID); + return TRUE; +} + +typedef void (*com_meego_inputmethod_uiserver1_set_preedit_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_uiserver1_set_preedit_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(com_meego_inputmethod_uiserver1_set_preedit_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_uiserver1_set_preedit_async (DBusGProxy *proxy, const char * IN_text, const gint IN_cursorPos, com_meego_inputmethod_uiserver1_set_preedit_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "setPreedit", com_meego_inputmethod_uiserver1_set_preedit_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_STRING, IN_text, G_TYPE_INT, IN_cursorPos, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_uiserver1_update_widget_information (DBusGProxy *proxy, const GHashTable* IN_encodedState, const gboolean IN_focusChanged, GError **error) + +{ + return dbus_g_proxy_call (proxy, "updateWidgetInformation", error, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), IN_encodedState, G_TYPE_BOOLEAN, IN_focusChanged, G_TYPE_INVALID, G_TYPE_INVALID); +} + +typedef void (*com_meego_inputmethod_uiserver1_update_widget_information_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_uiserver1_update_widget_information_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(com_meego_inputmethod_uiserver1_update_widget_information_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_uiserver1_update_widget_information_async (DBusGProxy *proxy, const GHashTable* IN_encodedState, const gboolean IN_focusChanged, com_meego_inputmethod_uiserver1_update_widget_information_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "updateWidgetInformation", com_meego_inputmethod_uiserver1_update_widget_information_async_callback, stuff, _dbus_glib_async_data_free, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), IN_encodedState, G_TYPE_BOOLEAN, IN_focusChanged, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_uiserver1_reset (DBusGProxy *proxy, GError **error) + +{ + dbus_g_proxy_call_no_reply (proxy, "reset", G_TYPE_INVALID, G_TYPE_INVALID); + return TRUE; +} + +typedef void (*com_meego_inputmethod_uiserver1_reset_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_uiserver1_reset_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(com_meego_inputmethod_uiserver1_reset_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_uiserver1_reset_async (DBusGProxy *proxy, com_meego_inputmethod_uiserver1_reset_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "reset", com_meego_inputmethod_uiserver1_reset_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_uiserver1_set_context_object (DBusGProxy *proxy, const char * IN_callbackObject, GError **error) + +{ + dbus_g_proxy_call_no_reply (proxy, "setContextObject", G_TYPE_STRING, IN_callbackObject, G_TYPE_INVALID, G_TYPE_INVALID); + return TRUE; +} + +typedef void (*com_meego_inputmethod_uiserver1_set_context_object_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_uiserver1_set_context_object_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(com_meego_inputmethod_uiserver1_set_context_object_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_uiserver1_set_context_object_async (DBusGProxy *proxy, const char * IN_callbackObject, com_meego_inputmethod_uiserver1_set_context_object_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "setContextObject", com_meego_inputmethod_uiserver1_set_context_object_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_STRING, IN_callbackObject, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_uiserver1_activate_context (DBusGProxy *proxy, GError **error) + +{ + dbus_g_proxy_call_no_reply (proxy, "activateContext", G_TYPE_INVALID, G_TYPE_INVALID); + return TRUE; +} + +typedef void (*com_meego_inputmethod_uiserver1_activate_context_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_uiserver1_activate_context_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(com_meego_inputmethod_uiserver1_activate_context_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_uiserver1_activate_context_async (DBusGProxy *proxy, com_meego_inputmethod_uiserver1_activate_context_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "activateContext", com_meego_inputmethod_uiserver1_activate_context_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_uiserver1_app_orientation_about_to_change (DBusGProxy *proxy, const gint IN_angle, GError **error) + +{ + return dbus_g_proxy_call (proxy, "appOrientationAboutToChange", error, G_TYPE_INT, IN_angle, G_TYPE_INVALID, G_TYPE_INVALID); +} + +typedef void (*com_meego_inputmethod_uiserver1_app_orientation_about_to_change_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_uiserver1_app_orientation_about_to_change_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(com_meego_inputmethod_uiserver1_app_orientation_about_to_change_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_uiserver1_app_orientation_about_to_change_async (DBusGProxy *proxy, const gint IN_angle, com_meego_inputmethod_uiserver1_app_orientation_about_to_change_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "appOrientationAboutToChange", com_meego_inputmethod_uiserver1_app_orientation_about_to_change_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INT, IN_angle, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_uiserver1_app_orientation_changed (DBusGProxy *proxy, const gint IN_angle, GError **error) + +{ + dbus_g_proxy_call_no_reply (proxy, "appOrientationChanged", G_TYPE_INT, IN_angle, G_TYPE_INVALID, G_TYPE_INVALID); + return TRUE; +} + +typedef void (*com_meego_inputmethod_uiserver1_app_orientation_changed_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_uiserver1_app_orientation_changed_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(com_meego_inputmethod_uiserver1_app_orientation_changed_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_uiserver1_app_orientation_changed_async (DBusGProxy *proxy, const gint IN_angle, com_meego_inputmethod_uiserver1_app_orientation_changed_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "appOrientationChanged", com_meego_inputmethod_uiserver1_app_orientation_changed_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INT, IN_angle, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_uiserver1_set_copy_paste_state (DBusGProxy *proxy, const gboolean IN_copyAvailable, const gboolean IN_pasteAvailable, GError **error) + +{ + dbus_g_proxy_call_no_reply (proxy, "setCopyPasteState", G_TYPE_BOOLEAN, IN_copyAvailable, G_TYPE_BOOLEAN, IN_pasteAvailable, G_TYPE_INVALID, G_TYPE_INVALID); + return TRUE; +} + +typedef void (*com_meego_inputmethod_uiserver1_set_copy_paste_state_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_uiserver1_set_copy_paste_state_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(com_meego_inputmethod_uiserver1_set_copy_paste_state_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_uiserver1_set_copy_paste_state_async (DBusGProxy *proxy, const gboolean IN_copyAvailable, const gboolean IN_pasteAvailable, com_meego_inputmethod_uiserver1_set_copy_paste_state_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "setCopyPasteState", com_meego_inputmethod_uiserver1_set_copy_paste_state_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_BOOLEAN, IN_copyAvailable, G_TYPE_BOOLEAN, IN_pasteAvailable, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_uiserver1_process_key_event (DBusGProxy *proxy, const gint IN_keyType, const gint IN_keyCode, const gint IN_modifiers, const char * IN_text, const gboolean IN_autoRepeat, const gint IN_count, const guint IN_nativeScanCode, const guint IN_nativeModifiers, const guint IN_time, GError **error) + +{ + dbus_g_proxy_call_no_reply (proxy, "processKeyEvent", G_TYPE_INT, IN_keyType, G_TYPE_INT, IN_keyCode, G_TYPE_INT, IN_modifiers, G_TYPE_STRING, IN_text, G_TYPE_BOOLEAN, IN_autoRepeat, G_TYPE_INT, IN_count, G_TYPE_UINT, IN_nativeScanCode, G_TYPE_UINT, IN_nativeModifiers, G_TYPE_UINT, IN_time, G_TYPE_INVALID, G_TYPE_INVALID); + return TRUE; +} + +typedef void (*com_meego_inputmethod_uiserver1_process_key_event_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_uiserver1_process_key_event_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(com_meego_inputmethod_uiserver1_process_key_event_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_uiserver1_process_key_event_async (DBusGProxy *proxy, const gint IN_keyType, const gint IN_keyCode, const gint IN_modifiers, const char * IN_text, const gboolean IN_autoRepeat, const gint IN_count, const guint IN_nativeScanCode, const guint IN_nativeModifiers, const guint IN_time, com_meego_inputmethod_uiserver1_process_key_event_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "processKeyEvent", com_meego_inputmethod_uiserver1_process_key_event_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INT, IN_keyType, G_TYPE_INT, IN_keyCode, G_TYPE_INT, IN_modifiers, G_TYPE_STRING, IN_text, G_TYPE_BOOLEAN, IN_autoRepeat, G_TYPE_INT, IN_count, G_TYPE_UINT, IN_nativeScanCode, G_TYPE_UINT, IN_nativeModifiers, G_TYPE_UINT, IN_time, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_uiserver1_register_attribute_extension (DBusGProxy *proxy, const gint IN_id, const char * IN_fileName, GError **error) + +{ + return dbus_g_proxy_call (proxy, "registerAttributeExtension", error, G_TYPE_INT, IN_id, G_TYPE_STRING, IN_fileName, G_TYPE_INVALID, G_TYPE_INVALID); +} + +typedef void (*com_meego_inputmethod_uiserver1_register_attribute_extension_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_uiserver1_register_attribute_extension_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(com_meego_inputmethod_uiserver1_register_attribute_extension_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_uiserver1_register_attribute_extension_async (DBusGProxy *proxy, const gint IN_id, const char * IN_fileName, com_meego_inputmethod_uiserver1_register_attribute_extension_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "registerAttributeExtension", com_meego_inputmethod_uiserver1_register_attribute_extension_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INT, IN_id, G_TYPE_STRING, IN_fileName, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_uiserver1_unregister_attribute_extension (DBusGProxy *proxy, const gint IN_id, GError **error) + +{ + return dbus_g_proxy_call (proxy, "unregisterAttributeExtension", error, G_TYPE_INT, IN_id, G_TYPE_INVALID, G_TYPE_INVALID); +} + +typedef void (*com_meego_inputmethod_uiserver1_unregister_attribute_extension_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_uiserver1_unregister_attribute_extension_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(com_meego_inputmethod_uiserver1_unregister_attribute_extension_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_uiserver1_unregister_attribute_extension_async (DBusGProxy *proxy, const gint IN_id, com_meego_inputmethod_uiserver1_unregister_attribute_extension_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "unregisterAttributeExtension", com_meego_inputmethod_uiserver1_unregister_attribute_extension_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INT, IN_id, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +com_meego_inputmethod_uiserver1_set_extended_attribute (DBusGProxy *proxy, const gint IN_id, const char * IN_target, const char * IN_targetItem, const char * IN_attribute, const GArray* IN_value, GError **error) + +{ + return dbus_g_proxy_call (proxy, "setExtendedAttribute", error, G_TYPE_INT, IN_id, G_TYPE_STRING, IN_target, G_TYPE_STRING, IN_targetItem, G_TYPE_STRING, IN_attribute, dbus_g_type_get_collection ("GArray", G_TYPE_UCHAR), IN_value, G_TYPE_INVALID, G_TYPE_INVALID); +} + +typedef void (*com_meego_inputmethod_uiserver1_set_extended_attribute_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +com_meego_inputmethod_uiserver1_set_extended_attribute_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(com_meego_inputmethod_uiserver1_set_extended_attribute_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +com_meego_inputmethod_uiserver1_set_extended_attribute_async (DBusGProxy *proxy, const gint IN_id, const char * IN_target, const char * IN_targetItem, const char * IN_attribute, const GArray* IN_value, com_meego_inputmethod_uiserver1_set_extended_attribute_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_slice_new (DBusGAsyncData); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "setExtendedAttribute", com_meego_inputmethod_uiserver1_set_extended_attribute_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INT, IN_id, G_TYPE_STRING, IN_target, G_TYPE_STRING, IN_targetItem, G_TYPE_STRING, IN_attribute, dbus_g_type_get_collection ("GArray", G_TYPE_UCHAR), IN_value, G_TYPE_INVALID); +} +#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_com_meego_inputmethod_uiserver1 */ + +G_END_DECLS diff --git a/meego/meego-im-proxy.c b/meego/meego-im-proxy.c new file mode 100644 index 0000000..5326d3b --- /dev/null +++ b/meego/meego-im-proxy.c @@ -0,0 +1,328 @@ +/* + * Copyright (C) 2010, Intel Corporation. + * + * Author: Raymond Liu + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include "meego-im-proxy.h" +#include "meego-im-proxy-glue.h" +#include "debug.h" + +G_DEFINE_TYPE(MeegoIMProxy, meego_im_proxy, G_TYPE_OBJECT); + +#define MEEGO_IM_OBJECT_PATH "/com/meego/inputmethod/uiserver1" +#define MEEGO_IM_SERVICE_INTERFACE "com.meego.inputmethod.uiserver1" + +static void meego_im_proxy_finalize(GObject *object); +static void meego_im_proxy_class_init(MeegoIMProxyClass *klass); +static void meego_im_proxy_init(MeegoIMProxy *meego_im_proxy); + +enum { + SIGNAL_CONNECTION_DROPPED = 0, + N_SIGNALS +}; + +static guint meego_im_proxy_signals[N_SIGNALS]; + +static void +handle_disconnect(gpointer instance, MeegoIMProxy *im_proxy) +{ + g_return_if_fail(im_proxy); + + im_proxy->dbusproxy = NULL; + g_signal_emit(im_proxy, meego_im_proxy_signals[SIGNAL_CONNECTION_DROPPED], 0, NULL); + +} + +MeegoIMProxy * +meego_im_proxy_get_singleton(void) +{ + static MeegoIMProxy *proxy = NULL; + if (!proxy) + proxy = g_object_new(MEEGO_TYPE_IM_PROXY, NULL); + return proxy; +} + + +static void +meego_im_proxy_finalize(GObject *object) +{ + //MeegoIMProxy *im_proxy = MEEGO_IM_PROXY(object); + + G_OBJECT_CLASS(meego_im_proxy_parent_class)->finalize(object); +} + + +static void +meego_im_proxy_class_init(MeegoIMProxyClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS(klass); + + gobject_class->finalize = meego_im_proxy_finalize; + + meego_im_proxy_signals[SIGNAL_CONNECTION_DROPPED] = + g_signal_new("connection-dropped", G_TYPE_FROM_CLASS(klass), + 0, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); +} + + +static void +meego_im_proxy_init(MeegoIMProxy *self) +{ + UNUSED(self); +} + +void +meego_im_proxy_connect(MeegoIMProxy *proxy, DBusGConnection *connection) +{ + DBusGProxy *dbusproxy; + g_return_if_fail(connection != NULL); + + if (proxy->dbusproxy) { + g_object_unref(proxy->dbusproxy); + } + + dbusproxy = dbus_g_proxy_new_for_peer(connection, + MEEGO_IM_OBJECT_PATH, /* obj path */ + MEEGO_IM_SERVICE_INTERFACE /* interface */); + + if (dbusproxy == NULL) { + g_warning("could not create dbus_proxy\n"); + } + + g_signal_connect(G_OBJECT(dbusproxy), "destroy", G_CALLBACK(handle_disconnect), proxy); + + proxy->dbusproxy = dbusproxy; +} + +gboolean +meego_im_proxy_activate_context(MeegoIMProxy *proxy) +{ + GError *error = NULL; + gboolean ret = TRUE; + + STEP(); + if (!proxy || proxy->dbusproxy == NULL) + return FALSE; + + ret = com_meego_inputmethod_uiserver1_activate_context(proxy->dbusproxy, &error); + + if (error != NULL) { + g_warning("%s", error->message); + } + + return ret; +} + + +gboolean +meego_im_proxy_app_orientation_changed(MeegoIMProxy *proxy, const gint angle) +{ + GError *error = NULL; + gboolean ret = TRUE; + + STEP(); + if (!proxy || proxy->dbusproxy == NULL) + return FALSE; + + ret = com_meego_inputmethod_uiserver1_app_orientation_changed(proxy->dbusproxy, angle, &error); + + if (error != NULL) { + g_warning("%s", error->message); + } + + return ret; +} + + +gboolean +meego_im_proxy_hide_input_method(MeegoIMProxy *proxy) +{ + GError *error = NULL; + gboolean ret = TRUE; + + STEP(); + if (!proxy || proxy->dbusproxy == NULL) + return FALSE; + + ret = com_meego_inputmethod_uiserver1_hide_input_method(proxy->dbusproxy, &error); + + if (error != NULL) { + g_warning("%s", error->message); + } + + return ret; +} + + +#if 0 +// Not yet really implemented + +gboolean +meego_im_proxy_mouse_clicked_on_preedit(MeegoIMProxy *proxy, const GValueArray *pos, + const GValueArray *preedit_rect) +{ + GError *error = NULL; + gboolean ret = TRUE; + + if (!proxy || proxy->dbusproxy == NULL) + return FALSE; + + ret = com_meego_inputmethod_uiserver1_mouse_clicked_on_preedit(proxy->dbusproxy, + pos, preedit_rect, &error); + + if (error != NULL) { + g_warning("%s", error->message); + } + + return ret; +} +#endif + +gboolean +meego_im_proxy_update_widget_info(MeegoIMProxy *proxy, const GHashTable *state_information, gboolean focus_changed) +{ + GError *error = NULL; + gboolean ret = TRUE; + + STEP(); + if (!proxy || proxy->dbusproxy == NULL) + return FALSE; + + ret = com_meego_inputmethod_uiserver1_update_widget_information(proxy->dbusproxy, + state_information, focus_changed, &error); + + if (error != NULL) { + g_warning("%s", error->message); + } + + return ret; +} + + + + +gboolean +meego_im_proxy_process_key_event(MeegoIMProxy *proxy, const gint type, const gint code, + const gint modifiers, const char *text, + const gboolean auto_repeat, const gint count, + const guint native_scan_code, + const guint native_modifiers, + const guint time) +{ + GError *error = NULL; + gboolean ret = TRUE; + + DBG("QT key event type=0x%x, code=0x%x, modifiers=0x%x, text=%s", + type, code, modifiers, text); + if (!proxy || proxy->dbusproxy == NULL) + return FALSE; + + ret = com_meego_inputmethod_uiserver1_process_key_event(proxy->dbusproxy, + type, code, modifiers, text, auto_repeat, + count, native_scan_code, native_modifiers, + time, &error); + + if (error != NULL) { + g_warning("%s", error->message); + } + + return ret; +} + + +gboolean +meego_im_proxy_reset(MeegoIMProxy *proxy) +{ + GError *error = NULL; + gboolean ret = TRUE; + + STEP(); + if (!proxy || proxy->dbusproxy == NULL) + return FALSE; + + ret = com_meego_inputmethod_uiserver1_reset(proxy->dbusproxy, &error); + + if (error != NULL) { + g_warning("%s", error->message); + } + + return ret; +} + + +gboolean +meego_im_proxy_set_copy_paste_state(MeegoIMProxy *proxy, const gboolean copy_available, + const gboolean paste_available) +{ + GError *error = NULL; + gboolean ret = TRUE; + + STEP(); + if (!proxy || proxy->dbusproxy == NULL) + return FALSE; + + ret = com_meego_inputmethod_uiserver1_set_copy_paste_state(proxy->dbusproxy, + copy_available, paste_available, &error); + + if (error != NULL) { + g_warning("%s", error->message); + } + + return ret; +} + + +gboolean +meego_im_proxy_set_preedit(MeegoIMProxy *proxy, const char *text, gint cursor_pos) +{ + GError *error = NULL; + gboolean ret = TRUE; + + STEP(); + if (!proxy || proxy->dbusproxy == NULL) + return FALSE; + + ret = com_meego_inputmethod_uiserver1_set_preedit(proxy->dbusproxy, text, cursor_pos, &error); + + if (error != NULL) { + g_warning("%s", error->message); + } + + return ret; +} + + +gboolean +meego_im_proxy_show_input_method(MeegoIMProxy *proxy) +{ + GError *error = NULL; + gboolean ret = TRUE; + + STEP(); + if (!proxy || proxy->dbusproxy == NULL) + return FALSE; + + ret = com_meego_inputmethod_uiserver1_show_input_method(proxy->dbusproxy, &error); + + if (error != NULL) { + g_warning("%s", error->message); + } + + return ret; +} diff --git a/meego/meego-im-proxy.h b/meego/meego-im-proxy.h new file mode 100644 index 0000000..85dad7c --- /dev/null +++ b/meego/meego-im-proxy.h @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2010, Intel Corporation. + * + * Author: Raymond Liu + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#ifndef _MEEGO_IM_PROXY_H +#define _MEEGO_IM_PROXY_H + +#include +#include +#include + +G_BEGIN_DECLS + +typedef struct _MeegoIMProxy MeegoIMProxy; +typedef struct _MeegoIMProxyClass MeegoIMProxyClass; + +#define MEEGO_TYPE_IM_PROXY (meego_im_proxy_get_type()) +#define MEEGO_IM_PROXY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), MEEGO_TYPE_IM_PROXY, MeegoIMProxy)) +#define MEEGO_IM_PROXY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), MEEGO_TYPE_IM_PROXY, MeegoIMProxyClass)) +#define MEEGO_IS_IM_PROXY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), MEEGO_TYPE_IM_PROXY)) +#define MEEGO_IS_IM_PROXY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), MEEGO_TYPE_IM_PROXY)) +#define MEEGO_IM_PROXY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), MEEGO_TYPE_IM_PROXY, MeegoIMProxyClass)) + + +struct _MeegoIMProxy { + GObject parent; + + DBusGProxy *dbusproxy; +}; + +struct _MeegoIMProxyClass { + GObjectClass parent; +}; + +GType meego_im_proxy_get_type(void); + +MeegoIMProxy *meego_im_proxy_get_singleton(void); +void meego_im_proxy_connect(MeegoIMProxy *proxy, DBusGConnection *connection); +gboolean meego_im_proxy_activate_context(MeegoIMProxy *proxy); +gboolean meego_im_proxy_app_orientation_changed(MeegoIMProxy *proxy, const gint angle); +gboolean meego_im_proxy_hide_input_method(MeegoIMProxy *proxy); +#if 0 +// Not yet really implemented +gboolean meego_im_proxy_mouse_clicked_on_preedit(MeegoIMProxy *proxy, const GValueArray *pos, + const GValueArray *preedit_rect); +#endif + +gboolean meego_im_proxy_update_widget_info(MeegoIMProxy *proxy, const GHashTable *state_information, gboolean focus_changed); + +gboolean meego_im_proxy_process_key_event(MeegoIMProxy *proxy, const gint type, const gint code, + const gint modifiers, const char *text, + const gboolean auto_repeat, const gint count, + const guint native_scan_code, + const guint native_modifiers, + const guint time); + +gboolean meego_im_proxy_reset(MeegoIMProxy *proxy); +gboolean meego_im_proxy_set_context_object(MeegoIMProxy *proxy, const char *object_name); +gboolean meego_im_proxy_set_copy_paste_state(MeegoIMProxy *proxy, const gboolean copy_available, + const gboolean paste_available); +gboolean meego_im_proxy_set_preedit(MeegoIMProxy *proxy, const char *text, const gint cursor_pos); +gboolean meego_im_proxy_show_input_method(MeegoIMProxy *proxy); + +G_END_DECLS + +#endif //_MEEGO_IM_PROXY_H diff --git a/meego/meego-imcontext-dbus-glue.h b/meego/meego-imcontext-dbus-glue.h new file mode 100644 index 0000000..ba7a1d5 --- /dev/null +++ b/meego/meego-imcontext-dbus-glue.h @@ -0,0 +1,491 @@ +/* Generated by dbus-binding-tool; do not edit! */ + + +#ifndef __dbus_glib_marshal_meego_imcontext_dbus_MARSHAL_H__ +#define __dbus_glib_marshal_meego_imcontext_dbus_MARSHAL_H__ + +#include + +G_BEGIN_DECLS + +#ifdef G_ENABLE_DEBUG +#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v) +#define g_marshal_value_peek_char(v) g_value_get_char (v) +#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v) +#define g_marshal_value_peek_int(v) g_value_get_int (v) +#define g_marshal_value_peek_uint(v) g_value_get_uint (v) +#define g_marshal_value_peek_long(v) g_value_get_long (v) +#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v) +#define g_marshal_value_peek_int64(v) g_value_get_int64 (v) +#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v) +#define g_marshal_value_peek_enum(v) g_value_get_enum (v) +#define g_marshal_value_peek_flags(v) g_value_get_flags (v) +#define g_marshal_value_peek_float(v) g_value_get_float (v) +#define g_marshal_value_peek_double(v) g_value_get_double (v) +#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v) +#define g_marshal_value_peek_param(v) g_value_get_param (v) +#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v) +#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v) +#define g_marshal_value_peek_object(v) g_value_get_object (v) +#define g_marshal_value_peek_variant(v) g_value_get_variant (v) +#else /* !G_ENABLE_DEBUG */ +/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API. + * Do not access GValues directly in your code. Instead, use the + * g_value_get_*() functions + */ +#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int +#define g_marshal_value_peek_char(v) (v)->data[0].v_int +#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint +#define g_marshal_value_peek_int(v) (v)->data[0].v_int +#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint +#define g_marshal_value_peek_long(v) (v)->data[0].v_long +#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong +#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64 +#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64 +#define g_marshal_value_peek_enum(v) (v)->data[0].v_long +#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong +#define g_marshal_value_peek_float(v) (v)->data[0].v_float +#define g_marshal_value_peek_double(v) (v)->data[0].v_double +#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer +#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer +#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer +#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer +#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer +#define g_marshal_value_peek_variant(v) (v)->data[0].v_pointer +#endif /* !G_ENABLE_DEBUG */ + + +/* BOOLEAN:INT,INT,INT,STRING,BOOLEAN,INT,UCHAR,POINTER */ +extern void dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__INT_INT_INT_STRING_BOOLEAN_INT_UCHAR_POINTER (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +void +dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__INT_INT_INT_STRING_BOOLEAN_INT_UCHAR_POINTER (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) +{ + typedef gboolean (*GMarshalFunc_BOOLEAN__INT_INT_INT_STRING_BOOLEAN_INT_UCHAR_POINTER) (gpointer data1, + gint arg_1, + gint arg_2, + gint arg_3, + gpointer arg_4, + gboolean arg_5, + gint arg_6, + guchar arg_7, + gpointer arg_8, + gpointer data2); + register GMarshalFunc_BOOLEAN__INT_INT_INT_STRING_BOOLEAN_INT_UCHAR_POINTER callback; + register GCClosure *cc = (GCClosure*) closure; + register gpointer data1, data2; + gboolean v_return; + + g_return_if_fail (return_value != NULL); + g_return_if_fail (n_param_values == 9); + + if (G_CCLOSURE_SWAP_DATA (closure)) + { + data1 = closure->data; + data2 = g_value_peek_pointer (param_values + 0); + } + else + { + data1 = g_value_peek_pointer (param_values + 0); + data2 = closure->data; + } + callback = (GMarshalFunc_BOOLEAN__INT_INT_INT_STRING_BOOLEAN_INT_UCHAR_POINTER) (marshal_data ? marshal_data : cc->callback); + + v_return = callback (data1, + g_marshal_value_peek_int (param_values + 1), + g_marshal_value_peek_int (param_values + 2), + g_marshal_value_peek_int (param_values + 3), + g_marshal_value_peek_string (param_values + 4), + g_marshal_value_peek_boolean (param_values + 5), + g_marshal_value_peek_int (param_values + 6), + g_marshal_value_peek_uchar (param_values + 7), + g_marshal_value_peek_pointer (param_values + 8), + data2); + + g_value_set_boolean (return_value, v_return); +} + +/* BOOLEAN:INT,INT,POINTER */ +extern void dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__INT_INT_POINTER (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +void +dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__INT_INT_POINTER (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) +{ + typedef gboolean (*GMarshalFunc_BOOLEAN__INT_INT_POINTER) (gpointer data1, + gint arg_1, + gint arg_2, + gpointer arg_3, + gpointer data2); + register GMarshalFunc_BOOLEAN__INT_INT_POINTER callback; + register GCClosure *cc = (GCClosure*) closure; + register gpointer data1, data2; + gboolean v_return; + + g_return_if_fail (return_value != NULL); + g_return_if_fail (n_param_values == 4); + + if (G_CCLOSURE_SWAP_DATA (closure)) + { + data1 = closure->data; + data2 = g_value_peek_pointer (param_values + 0); + } + else + { + data1 = g_value_peek_pointer (param_values + 0); + data2 = closure->data; + } + callback = (GMarshalFunc_BOOLEAN__INT_INT_POINTER) (marshal_data ? marshal_data : cc->callback); + + v_return = callback (data1, + g_marshal_value_peek_int (param_values + 1), + g_marshal_value_peek_int (param_values + 2), + g_marshal_value_peek_pointer (param_values + 3), + data2); + + g_value_set_boolean (return_value, v_return); +} + +/* BOOLEAN:POINTER */ +extern void dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__POINTER (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +void +dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__POINTER (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) +{ + typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER) (gpointer data1, + gpointer arg_1, + gpointer data2); + register GMarshalFunc_BOOLEAN__POINTER callback; + register GCClosure *cc = (GCClosure*) closure; + register gpointer data1, data2; + gboolean v_return; + + g_return_if_fail (return_value != NULL); + g_return_if_fail (n_param_values == 2); + + if (G_CCLOSURE_SWAP_DATA (closure)) + { + data1 = closure->data; + data2 = g_value_peek_pointer (param_values + 0); + } + else + { + data1 = g_value_peek_pointer (param_values + 0); + data2 = closure->data; + } + callback = (GMarshalFunc_BOOLEAN__POINTER) (marshal_data ? marshal_data : cc->callback); + + v_return = callback (data1, + g_marshal_value_peek_pointer (param_values + 1), + data2); + + g_value_set_boolean (return_value, v_return); +} + +/* BOOLEAN:STRING,BOXED,INT,INT,INT,POINTER */ +extern void dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__STRING_BOXED_INT_INT_INT_POINTER (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +void +dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__STRING_BOXED_INT_INT_INT_POINTER (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) +{ + typedef gboolean (*GMarshalFunc_BOOLEAN__STRING_BOXED_INT_INT_INT_POINTER) (gpointer data1, + gpointer arg_1, + gpointer arg_2, + gint arg_3, + gint arg_4, + gint arg_5, + gpointer arg_6, + gpointer data2); + register GMarshalFunc_BOOLEAN__STRING_BOXED_INT_INT_INT_POINTER callback; + register GCClosure *cc = (GCClosure*) closure; + register gpointer data1, data2; + gboolean v_return; + + g_return_if_fail (return_value != NULL); + g_return_if_fail (n_param_values == 7); + + if (G_CCLOSURE_SWAP_DATA (closure)) + { + data1 = closure->data; + data2 = g_value_peek_pointer (param_values + 0); + } + else + { + data1 = g_value_peek_pointer (param_values + 0); + data2 = closure->data; + } + callback = (GMarshalFunc_BOOLEAN__STRING_BOXED_INT_INT_INT_POINTER) (marshal_data ? marshal_data : cc->callback); + + v_return = callback (data1, + g_marshal_value_peek_string (param_values + 1), + g_marshal_value_peek_boxed (param_values + 2), + g_marshal_value_peek_int (param_values + 3), + g_marshal_value_peek_int (param_values + 4), + g_marshal_value_peek_int (param_values + 5), + g_marshal_value_peek_pointer (param_values + 6), + data2); + + g_value_set_boolean (return_value, v_return); +} + +/* BOOLEAN:BOXED,POINTER */ +extern void dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__BOXED_POINTER (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +void +dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__BOXED_POINTER (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) +{ + typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_POINTER) (gpointer data1, + gpointer arg_1, + gpointer arg_2, + gpointer data2); + register GMarshalFunc_BOOLEAN__BOXED_POINTER callback; + register GCClosure *cc = (GCClosure*) closure; + register gpointer data1, data2; + gboolean v_return; + + g_return_if_fail (return_value != NULL); + g_return_if_fail (n_param_values == 3); + + if (G_CCLOSURE_SWAP_DATA (closure)) + { + data1 = closure->data; + data2 = g_value_peek_pointer (param_values + 0); + } + else + { + data1 = g_value_peek_pointer (param_values + 0); + data2 = closure->data; + } + callback = (GMarshalFunc_BOOLEAN__BOXED_POINTER) (marshal_data ? marshal_data : cc->callback); + + v_return = callback (data1, + g_marshal_value_peek_boxed (param_values + 1), + g_marshal_value_peek_pointer (param_values + 2), + data2); + + g_value_set_boolean (return_value, v_return); +} + +/* BOOLEAN:POINTER,POINTER,POINTER */ +extern void dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__POINTER_POINTER_POINTER (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +void +dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__POINTER_POINTER_POINTER (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) +{ + typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER) (gpointer data1, + gpointer arg_1, + gpointer arg_2, + gpointer arg_3, + gpointer data2); + register GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER callback; + register GCClosure *cc = (GCClosure*) closure; + register gpointer data1, data2; + gboolean v_return; + + g_return_if_fail (return_value != NULL); + g_return_if_fail (n_param_values == 4); + + if (G_CCLOSURE_SWAP_DATA (closure)) + { + data1 = closure->data; + data2 = g_value_peek_pointer (param_values + 0); + } + else + { + data1 = g_value_peek_pointer (param_values + 0); + data2 = closure->data; + } + callback = (GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER) (marshal_data ? marshal_data : cc->callback); + + v_return = callback (data1, + g_marshal_value_peek_pointer (param_values + 1), + g_marshal_value_peek_pointer (param_values + 2), + g_marshal_value_peek_pointer (param_values + 3), + data2); + + g_value_set_boolean (return_value, v_return); +} + +/* BOOLEAN:STRING,INT,INT,INT,POINTER */ +extern void dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__STRING_INT_INT_INT_POINTER (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +void +dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__STRING_INT_INT_INT_POINTER (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) +{ + typedef gboolean (*GMarshalFunc_BOOLEAN__STRING_INT_INT_INT_POINTER) (gpointer data1, + gpointer arg_1, + gint arg_2, + gint arg_3, + gint arg_4, + gpointer arg_5, + gpointer data2); + register GMarshalFunc_BOOLEAN__STRING_INT_INT_INT_POINTER callback; + register GCClosure *cc = (GCClosure*) closure; + register gpointer data1, data2; + gboolean v_return; + + g_return_if_fail (return_value != NULL); + g_return_if_fail (n_param_values == 6); + + if (G_CCLOSURE_SWAP_DATA (closure)) + { + data1 = closure->data; + data2 = g_value_peek_pointer (param_values + 0); + } + else + { + data1 = g_value_peek_pointer (param_values + 0); + data2 = closure->data; + } + callback = (GMarshalFunc_BOOLEAN__STRING_INT_INT_INT_POINTER) (marshal_data ? marshal_data : cc->callback); + + v_return = callback (data1, + g_marshal_value_peek_string (param_values + 1), + g_marshal_value_peek_int (param_values + 2), + g_marshal_value_peek_int (param_values + 3), + g_marshal_value_peek_int (param_values + 4), + g_marshal_value_peek_pointer (param_values + 5), + data2); + + g_value_set_boolean (return_value, v_return); +} + +/* BOOLEAN:BOOLEAN,POINTER */ +extern void dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__BOOLEAN_POINTER (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +void +dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__BOOLEAN_POINTER (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) +{ + typedef gboolean (*GMarshalFunc_BOOLEAN__BOOLEAN_POINTER) (gpointer data1, + gboolean arg_1, + gpointer arg_2, + gpointer data2); + register GMarshalFunc_BOOLEAN__BOOLEAN_POINTER callback; + register GCClosure *cc = (GCClosure*) closure; + register gpointer data1, data2; + gboolean v_return; + + g_return_if_fail (return_value != NULL); + g_return_if_fail (n_param_values == 3); + + if (G_CCLOSURE_SWAP_DATA (closure)) + { + data1 = closure->data; + data2 = g_value_peek_pointer (param_values + 0); + } + else + { + data1 = g_value_peek_pointer (param_values + 0); + data2 = closure->data; + } + callback = (GMarshalFunc_BOOLEAN__BOOLEAN_POINTER) (marshal_data ? marshal_data : cc->callback); + + v_return = callback (data1, + g_marshal_value_peek_boolean (param_values + 1), + g_marshal_value_peek_pointer (param_values + 2), + data2); + + g_value_set_boolean (return_value, v_return); +} + +G_END_DECLS + +#endif /* __dbus_glib_marshal_meego_imcontext_dbus_MARSHAL_H__ */ + +#include +static const DBusGMethodInfo dbus_glib_meego_imcontext_dbus_methods[] = { + { (GCallback) meego_imcontext_dbus_activation_lost_event, dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__POINTER, 0 }, + { (GCallback) meego_imcontext_dbus_im_initiated_hide, dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__POINTER, 59 }, + { (GCallback) meego_imcontext_dbus_commit_string, dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__STRING_INT_INT_INT_POINTER, 114 }, + { (GCallback) meego_imcontext_dbus_update_preedit, dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__STRING_BOXED_INT_INT_INT_POINTER, 226 }, + { (GCallback) meego_imcontext_dbus_key_event, dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__INT_INT_INT_STRING_BOOLEAN_INT_UCHAR_POINTER, 359 }, + { (GCallback) meego_imcontext_dbus_update_input_method_area, dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__BOXED_POINTER, 488 }, + { (GCallback) meego_imcontext_dbus_set_global_correction_enabled, dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__BOOLEAN_POINTER, 559 }, + { (GCallback) meego_imcontext_dbus_copy, dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__POINTER, 637 }, + { (GCallback) meego_imcontext_dbus_paste, dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__POINTER, 681 }, + { (GCallback) meego_imcontext_dbus_set_redirect_keys, dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__BOOLEAN_POINTER, 726 }, + { (GCallback) meego_imcontext_dbus_preedit_rectangle, dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__POINTER_POINTER_POINTER, 793 }, + { (GCallback) meego_imcontext_dbus_set_detectable_auto_repeat, dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__BOOLEAN_POINTER, 881 }, + { (GCallback) meego_imcontext_dbus_set_selection, dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__INT_INT_POINTER, 956 }, + { (GCallback) meego_imcontext_dbus_selection, dbus_glib_marshal_meego_imcontext_dbus_BOOLEAN__POINTER_POINTER_POINTER, 1029 }, +}; + +const DBusGObjectInfo dbus_glib_meego_imcontext_dbus_object_info = { 1, + dbus_glib_meego_imcontext_dbus_methods, + 14, +"com.meego.inputmethod.inputcontext1\0activationLostEvent\0S\0\0com.meego.inputmethod.inputcontext1\0imInitiatedHide\0S\0\0com.meego.inputmethod.inputcontext1\0commitString\0S\0string\0I\0s\0replaceStart\0I\0i\0replaceLength\0I\0i\0cursorPos\0I\0i\0\0com.meego.inputmethod.inputcontext1\0updatePreedit\0S\0string\0I\0s\0formatList\0I\0a(iii)\0replaceStart\0I\0i\0replaceLength\0I\0i\0cursorPos\0I\0i\0\0com.meego.inputmethod.inputcontext1\0keyEvent\0S\0type\0I\0i\0key\0I\0i\0modifiers\0I\0i\0text\0I\0s\0autoRepeat\0I\0b\0count\0I\0i\0requestType\0I\0y\0\0com.meego.inputmethod.inputcontext1\0updateInputMethodArea\0S\0data\0I\0ay\0\0com.meego.inputmethod.inputcontext1\0setGlobalCorrectionEnabled\0S\0enabled\0I\0b\0\0com.meego.inputmethod.inputcontext1\0copy\0S\0\0com.meego.inputmethod.inputcontext1\0paste\0S\0\0com.meego.inputmethod.inputcontext1\0setRedirectKeys\0S\0enabled\0I\0b\0\0com.meego.inputmethod.inputcontext1\0preeditRectangle\0S\0valid\0O\0F\0N\0b\0rect\0O\0F\0N\0(iiii)\0\0com.meego.inputmethod.inputcontext1\0setDetectableAutoRepeat\0S\0enabled\0I\0b\0\0com.meego.inputmethod.inputcontext1\0setSelection\0S\0start\0I\0i\0length\0I\0i\0\0com.meego.inputmethod.inputcontext1\0selection\0S\0valid\0O\0F\0N\0b\0selectionText\0O\0F\0N\0s\0\0\0", +"\0", +"\0" +}; + diff --git a/meego/meego-imcontext-dbus.c b/meego/meego-imcontext-dbus.c new file mode 100644 index 0000000..625fbe4 --- /dev/null +++ b/meego/meego-imcontext-dbus.c @@ -0,0 +1,225 @@ +/* + * Copyright (C) 2010 Intel Corporation + * + * Author: Raymond Liu + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +#include +#include + +#include "meego-imcontext-dbus.h" +#include "debug.h" + +#define MEEGO_IMCONTEXT_DBUSOBJ_SERVICE_OBJECT_PATH "/com/meego/inputmethod/inputcontext" + +G_DEFINE_TYPE(MeegoIMContextDbusObj, meego_imcontext_dbusobj, G_TYPE_OBJECT) + +gboolean meego_imcontext_dbus_activation_lost_event(MeegoIMContextDbusObj *obj, GError **error); +gboolean meego_imcontext_dbus_im_initiated_hide(MeegoIMContextDbusObj *obj, GError **error); +gboolean meego_imcontext_dbus_commit_string(MeegoIMContextDbusObj *obj, char *string, gint replacement_start, + int replacement_length, int cursor_pos, GError **error); +gboolean meego_imcontext_dbus_update_preedit(MeegoIMContextDbusObj *obj, + const char * string, const GPtrArray* formatList, + const gint replaceStart, const gint replaceLength, const gint cursorPos, + GError **error); +gboolean meego_imcontext_dbus_key_event(MeegoIMContextDbusObj *obj, + int type, int key, int modifiers, char *text, + gboolean auto_repeat, int count, + GError **error); +gboolean meego_imcontext_dbus_update_input_method_area(MeegoIMContextDbusObj *obj, GPtrArray *data, GError **error); +gboolean meego_imcontext_dbus_set_global_correction_enabled(MeegoIMContextDbusObj *obj, gboolean correction, GError **error); +gboolean meego_imcontext_dbus_copy(MeegoIMContextDbusObj *obj, GError **error); +gboolean meego_imcontext_dbus_paste(MeegoIMContextDbusObj *obj, GError **error); +gboolean meego_imcontext_dbus_set_redirect_keys(MeegoIMContextDbusObj *obj, gboolean enabled, GError **error); +gboolean meego_imcontext_dbus_preedit_rectangle(MeegoIMContextDbusObj *obj, GValueArray **rect, gboolean *valid, GError **error); + + +#include "meego-imcontext-dbus-glue.h" + + +static void +meego_imcontext_dbusobj_init(MeegoIMContextDbusObj *obj) +{ + STEP(); + g_assert(obj != NULL); +} + + +static void +meego_imcontext_dbusobj_class_init(MeegoIMContextDbusObjClass *klass) +{ + g_assert(klass != NULL); + + dbus_g_object_type_install_info(MEEGO_IMCONTEXT_TYPE_DBUSOBJ, + &dbus_glib_meego_imcontext_dbus_object_info); +} + + + +void +meego_imcontext_dbusobj_connect(MeegoIMContextDbusObj *obj, DBusGConnection *connection) +{ + dbus_g_connection_register_g_object(connection, + MEEGO_IMCONTEXT_DBUSOBJ_SERVICE_OBJECT_PATH, + G_OBJECT(obj)); +} + +MeegoIMContextDbusObj * +meego_imcontext_dbusobj_get_singleton(void) +{ + static MeegoIMContextDbusObj *dbusobj = NULL; + + if (!dbusobj) + dbusobj = g_object_new(MEEGO_IMCONTEXT_TYPE_DBUSOBJ, NULL); + return dbusobj; +} + + +gboolean +meego_imcontext_dbus_activation_lost_event(MeegoIMContextDbusObj *obj, GError **error) +{ + STEP(); + return TRUE; +} + + +gboolean +meego_imcontext_dbus_im_initiated_hide(MeegoIMContextDbusObj *obj, GError **error) +{ + STEP(); + return TRUE; +} + + +gboolean +meego_imcontext_dbus_commit_string(MeegoIMContextDbusObj *obj, char *string, gint replacement_start, + int replacement_length, int cursor_pos, GError **error) +{ + DBG("string is:%s", string); + return meego_imcontext_client_commit_string(obj, string, replacement_start, replacement_length, cursor_pos); +} + + +gboolean +meego_imcontext_dbus_update_preedit(MeegoIMContextDbusObj *obj, + const char * string, const GPtrArray* formatList, + const gint replaceStart, const gint replaceLength, const gint cursorPos, + GError **error) +{ + int i; + int preeditFormatCount = formatList->len; + MeegoImPreeditFormat *preeditFormat = g_new0(MeegoImPreeditFormat, preeditFormatCount); + + for (i = 0; i < preeditFormatCount; i++) { + GValueArray *valarr = formatList->pdata[i]; + g_return_val_if_fail(valarr, FALSE); + g_return_val_if_fail(valarr->n_values == 3, FALSE); + g_return_val_if_fail(G_VALUE_HOLDS_INT(g_value_array_get_nth(valarr, 0)), FALSE); + g_return_val_if_fail(G_VALUE_HOLDS_INT(g_value_array_get_nth(valarr, 1)), FALSE); + g_return_val_if_fail(G_VALUE_HOLDS_INT(g_value_array_get_nth(valarr, 2)), FALSE); + preeditFormat[i].start = g_value_get_int(g_value_array_get_nth(valarr, 0)); + preeditFormat[i].length = g_value_get_int(g_value_array_get_nth(valarr, 0)); + preeditFormat[i].face = g_value_get_int(g_value_array_get_nth(valarr, 0)); + } + + return meego_imcontext_client_update_preedit(obj, string, preeditFormatCount, preeditFormat, + replaceStart, replaceLength, cursorPos); +} + + +gboolean +meego_imcontext_dbus_key_event(MeegoIMContextDbusObj *obj, int type, int key, int modifiers, char *text, + gboolean auto_repeat, int count, GError **error) +{ + DBG("type=0x%x, key=0x%x, modifiers=0x%x, text = %s, auto_repeat=%d, count=%d", + type, key, modifiers, text, auto_repeat, count); + return meego_imcontext_client_key_event(obj, type, key, modifiers, text, auto_repeat, count); +} + + +gboolean +meego_imcontext_dbus_update_input_method_area(MeegoIMContextDbusObj *obj, GPtrArray *data, GError **error) +{ + STEP(); + return TRUE; +} + + +gboolean +meego_imcontext_dbus_set_global_correction_enabled(MeegoIMContextDbusObj *obj, gboolean correction, GError **error) +{ + STEP(); + return TRUE; +} + + +gboolean +meego_imcontext_dbus_copy(MeegoIMContextDbusObj *obj, GError **error) +{ + STEP(); + return meego_imcontext_client_copy(obj); + return TRUE; +} + + +gboolean +meego_imcontext_dbus_paste(MeegoIMContextDbusObj *obj, GError **error) +{ + STEP(); + return meego_imcontext_client_paste(obj); + return TRUE; +} + + +gboolean +meego_imcontext_dbus_set_redirect_keys(MeegoIMContextDbusObj *obj, gboolean enabled, GError **error) +{ + STEP(); + meego_imcontext_client_set_redirect_keys(obj, enabled); + return TRUE; +} + + +gboolean +meego_imcontext_dbus_preedit_rectangle(MeegoIMContextDbusObj *obj, GValueArray **rect, gboolean *valid, GError **error) +{ + STEP(); + return TRUE; +} + +gboolean +meego_imcontext_dbus_set_detectable_auto_repeat(MeegoIMContextDbusObj *obj, gboolean enabled, GError **error) +{ + STEP(); + return TRUE; +} + +gboolean +meego_imcontext_dbus_set_selection(MeegoIMContextDbusObj *obj, int start, int length, GError **error) +{ + STEP(); + return TRUE; +} + +gboolean +meego_imcontext_dbus_selection(MeegoIMContextDbusObj *obj, gboolean *valid, gchar **gdata, GError **error) +{ + STEP(); + return TRUE; +} + diff --git a/meego/meego-imcontext-dbus.h b/meego/meego-imcontext-dbus.h new file mode 100644 index 0000000..4836aaa --- /dev/null +++ b/meego/meego-imcontext-dbus.h @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2010 Intel Corporation + * + * Author: Raymond Liu + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +#ifndef _MEEGO_IMCONTEXT_DBUS_H +#define _MEEGO_IMCONTEXT_DBUS_H + +#include +#include "meego-im-defs.h" + +typedef struct { + GObject parent; + + DBusGConnection *connection; +} MeegoIMContextDbusObj; + +typedef struct { + GObjectClass parent; +} MeegoIMContextDbusObjClass; + +GType meego_imcontext_dbusobj_get_type(void); + + +#define MEEGO_IMCONTEXT_TYPE_DBUSOBJ (meego_imcontext_dbusobj_get_type()) +#define MEEGO_IMCONTEXT_DBUSOBJ(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), MEEGO_IMCONTEXT_TYPE_DBUSOBJ, MeegoIMContextDbusObj)) +#define MEEGO_IMCONTEXT_DBUSOBJ_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), MEEGO_IMCONTEXT_TYPE_DBUSOBJ, MeegoIMContextDbusObjClass)) +#define MEEGO_IMCONTEXT_IS_DBUSOBJ(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), MEEGO_IMCONTEXT_TYPE_DBUSOBJ)) +#define MEEGO_IMCONTEXT_IS_DBUSOBJ_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), MEEGO_IMCONTEXT_TYPE_DBUSOBJ)) +#define MEEGO_IMCONTEXT_DBUSOBJ_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj), MEEGO_IMCONTEXT_TYPE_DBUSOBJ, MeegoIMContextDbusObjClass)) + + +MeegoIMContextDbusObj *meego_imcontext_dbusobj_get_singleton(void); +void meego_imcontext_dbusobj_connect(MeegoIMContextDbusObj *obj, DBusGConnection *connection); + +// Call back functions for dbus obj, need to be implemented in imcontext client side + +gboolean meego_imcontext_client_activation_lost_event(MeegoIMContextDbusObj *obj); +gboolean meego_imcontext_client_im_initiated_hide(MeegoIMContextDbusObj *obj); +gboolean meego_imcontext_client_commit_string(MeegoIMContextDbusObj *obj, const char *string, + int replace_start, int replace_length, int cursor_pos); +gboolean meego_imcontext_client_update_preedit(MeegoIMContextDbusObj *obj, const char *string, + int preedit_format_count, const MeegoImPreeditFormat *preedit_formats, + int replace_start, int replace_length, int cursor_pos); +gboolean meego_imcontext_client_key_event(MeegoIMContextDbusObj *obj, int type, int key, int modifiers, char *text, + gboolean auto_repeat, int count); +gboolean meego_imcontext_client_update_input_method_area(MeegoIMContextDbusObj *obj, GPtrArray *data); +gboolean meego_imcontext_client_set_global_correction_enabled(MeegoIMContextDbusObj *obj, gboolean correction); +gboolean meego_imcontext_client_copy(MeegoIMContextDbusObj *obj); +gboolean meego_imcontext_client_paste(MeegoIMContextDbusObj *obj); +gboolean meego_imcontext_client_set_redirect_keys(MeegoIMContextDbusObj *obj, gboolean enabled); +gboolean meego_imcontext_client_preedit_rectangle(MeegoIMContextDbusObj *obj, GValueArray **rect, gboolean *valid); +gboolean meego_imcontext_dbus_set_detectable_auto_repeat(MeegoIMContextDbusObj *obj, gboolean enabled, GError **error); +gboolean meego_imcontext_dbus_set_selection(MeegoIMContextDbusObj *obj, int start, int length, GError **error); +gboolean meego_imcontext_dbus_selection(MeegoIMContextDbusObj *obj, gboolean *valid, gchar **gdata, GError **error); + +#endif /* _MEEGO_IMCONTEXT_DBUS_H */ diff --git a/meego/meego-imcontext-dbus.xml b/meego/meego-imcontext-dbus.xml new file mode 100644 index 0000000..80ac29c --- /dev/null +++ b/meego/meego-imcontext-dbus.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/meego/qt-keysym-map.cpp b/meego/qt-keysym-map.cpp new file mode 100644 index 0000000..e114fef --- /dev/null +++ b/meego/qt-keysym-map.cpp @@ -0,0 +1,542 @@ +/* + * Copyright (C) 2001 Ellis Whitehead + * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + * Copyright (C) 2010, Intel Corporation. + * + * Author: Raymond Liu + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + + +#include +#include + +#include "qt-keysym-map.h" +#include "debug.h" + + +#if 0 + +typedef struct { + int QtKey; + uint XKeySym; +} KeySymMap; + +static const KeySymMap QtKeyXSymMaps[] = +{ + { '/', XK_KP_Divide }, + { '*', XK_KP_Multiply }, + { '-', XK_KP_Subtract }, + { '+', XK_KP_Add }, + { Qt::Key_Escape, XK_Escape }, + { Qt::Key_Tab, XK_Tab }, + { Qt::Key_Backtab, XK_ISO_Left_Tab }, + { Qt::Key_Backspace, XK_BackSpace }, + { Qt::Key_Return, XK_Return }, + { Qt::Key_Enter, XK_KP_Enter }, + { Qt::Key_Insert, XK_Insert }, + { Qt::Key_Delete, XK_Delete }, + { Qt::Key_Pause, XK_Pause }, + { Qt::Key_Print, XK_Print }, + { Qt::Key_SysReq, XK_Sys_Req }, + { Qt::Key_Home, XK_Home }, + { Qt::Key_End, XK_End }, + { Qt::Key_Left, XK_Left }, + { Qt::Key_Up, XK_Up }, + { Qt::Key_Right, XK_Right }, + { Qt::Key_Down, XK_Down }, + { Qt::Key_CapsLock, XK_Caps_Lock }, + { Qt::Key_NumLock, XK_Num_Lock }, + { Qt::Key_ScrollLock, XK_Scroll_Lock }, + { Qt::Key_F1, XK_F1 }, + { Qt::Key_F2, XK_F2 }, + { Qt::Key_F3, XK_F3 }, + { Qt::Key_F4, XK_F4 }, + { Qt::Key_F5, XK_F5 }, + { Qt::Key_F6, XK_F6 }, + { Qt::Key_F7, XK_F7 }, + { Qt::Key_F8, XK_F8 }, + { Qt::Key_F9, XK_F9 }, + { Qt::Key_F10, XK_F10 }, + { Qt::Key_F11, XK_F11 }, + { Qt::Key_F12, XK_F12 }, + { Qt::Key_F13, XK_F13 }, + { Qt::Key_F14, XK_F14 }, + { Qt::Key_F15, XK_F15 }, + { Qt::Key_F16, XK_F16 }, + { Qt::Key_F17, XK_F17 }, + { Qt::Key_F18, XK_F18 }, + { Qt::Key_F19, XK_F19 }, + { Qt::Key_F20, XK_F20 }, + { Qt::Key_F21, XK_F21 }, + { Qt::Key_F22, XK_F22 }, + { Qt::Key_F23, XK_F23 }, + { Qt::Key_F24, XK_F24 }, + { Qt::Key_F25, XK_F25 }, + { Qt::Key_F26, XK_F26 }, + { Qt::Key_F27, XK_F27 }, + { Qt::Key_F28, XK_F28 }, + { Qt::Key_F29, XK_F29 }, + { Qt::Key_F30, XK_F30 }, + { Qt::Key_F31, XK_F31 }, + { Qt::Key_F32, XK_F32 }, + { Qt::Key_F33, XK_F33 }, + { Qt::Key_F34, XK_F34 }, + { Qt::Key_F35, XK_F35 }, + { Qt::Key_Super_L, XK_Super_L }, + { Qt::Key_Super_R, XK_Super_R }, + { Qt::Key_Menu, XK_Menu }, + { Qt::Key_Hyper_L, XK_Hyper_L }, + { Qt::Key_Hyper_R, XK_Hyper_R }, + { Qt::Key_Help, XK_Help }, + { Qt::Key_Return, XK_KP_Enter }, + + { Qt::Key_Multi_key, XK_Multi_key }, + { Qt::Key_Codeinput, XK_Codeinput }, + { Qt::Key_SingleCandidate, XK_SingleCandidate }, + { Qt::Key_MultipleCandidate, XK_MultipleCandidate }, + { Qt::Key_PreviousCandidate, XK_PreviousCandidate }, + { Qt::Key_Mode_switch, XK_Mode_switch }, + { Qt::Key_Kanji, XK_Kanji }, + { Qt::Key_Muhenkan, XK_Muhenkan }, + { Qt::Key_Henkan, XK_Henkan }, + { Qt::Key_Romaji, XK_Romaji }, + { Qt::Key_Hiragana, XK_Hiragana }, + { Qt::Key_Katakana, XK_Katakana }, + { Qt::Key_Hiragana_Katakana, XK_Hiragana_Katakana }, + { Qt::Key_Zenkaku, XK_Zenkaku }, + { Qt::Key_Hankaku, XK_Hankaku }, + { Qt::Key_Zenkaku_Hankaku, XK_Zenkaku_Hankaku }, + { Qt::Key_Touroku, XK_Touroku }, + { Qt::Key_Massyo, XK_Massyo }, + { Qt::Key_Kana_Lock, XK_Kana_Lock }, + { Qt::Key_Kana_Shift, XK_Kana_Shift }, + { Qt::Key_Eisu_Shift, XK_Eisu_Shift }, + { Qt::Key_Eisu_toggle, XK_Eisu_toggle }, + { Qt::Key_Hangul, XK_Hangul }, + { Qt::Key_Hangul_Start, XK_Hangul_Start }, + { Qt::Key_Hangul_End, XK_Hangul_End }, + { Qt::Key_Hangul_Hanja, XK_Hangul_Hanja }, + { Qt::Key_Hangul_Jamo, XK_Hangul_Jamo }, + { Qt::Key_Hangul_Romaja, XK_Hangul_Romaja }, + { Qt::Key_Hangul_Jeonja, XK_Hangul_Jeonja }, + { Qt::Key_Hangul_Banja, XK_Hangul_Banja }, + { Qt::Key_Hangul_PreHanja, XK_Hangul_PreHanja }, + { Qt::Key_Hangul_Special, XK_Hangul_Special }, + + { 0, 0 } +}; + +#else + +typedef struct { + uint XKeySym; + int QtKey; +} KeySymMap; + +// keyboard mapping table, modified from QKeymapper_x11.cpp +static const KeySymMap QtKeyXSymMaps[] = { + +// misc keys + + { XK_Escape, Qt::Key_Escape }, + { XK_Tab, Qt::Key_Tab }, + { XK_ISO_Left_Tab, Qt::Key_Backtab }, + { XK_BackSpace, Qt::Key_Backspace }, + { XK_Return, Qt::Key_Return }, + { XK_Insert, Qt::Key_Insert }, + { XK_Delete, Qt::Key_Delete }, + { XK_Clear, Qt::Key_Delete }, + { XK_Pause, Qt::Key_Pause }, + { XK_Print, Qt::Key_Print }, + { 0x1005FF60, Qt::Key_SysReq }, // hardcoded Sun SysReq + { 0x1007ff00, Qt::Key_SysReq }, // hardcoded X386 SysReq + +// cursor movement + + { XK_Home, Qt::Key_Home }, + { XK_End, Qt::Key_End }, + { XK_Left, Qt::Key_Left }, + { XK_Up, Qt::Key_Up }, + { XK_Right, Qt::Key_Right }, + { XK_Down, Qt::Key_Down }, + { XK_Prior, Qt::Key_PageUp }, + { XK_Next, Qt::Key_PageDown }, + +// modifiers + + { XK_Shift_L, Qt::Key_Shift }, + { XK_Shift_R, Qt::Key_Shift }, + { XK_Shift_Lock, Qt::Key_Shift }, + { XK_Control_L, Qt::Key_Control }, + { XK_Control_R, Qt::Key_Control }, + { XK_Meta_L, Qt::Key_Meta }, + { XK_Meta_R, Qt::Key_Meta }, + { XK_Alt_L, Qt::Key_Alt }, + { XK_Alt_R, Qt::Key_Alt }, + { XK_Caps_Lock, Qt::Key_CapsLock }, + { XK_Num_Lock, Qt::Key_NumLock }, + { XK_Scroll_Lock, Qt::Key_ScrollLock }, + { XK_Super_L, Qt::Key_Super_L }, + { XK_Super_R, Qt::Key_Super_R }, + { XK_Menu, Qt::Key_Menu }, + { XK_Hyper_L, Qt::Key_Hyper_L }, + { XK_Hyper_R, Qt::Key_Hyper_R }, + { XK_Help, Qt::Key_Help }, + { 0x1000FF74, Qt::Key_Backtab }, // hardcoded HP backtab + { 0x1005FF10, Qt::Key_F11 }, // hardcoded Sun F36 (labeled F11) + { 0x1005FF11, Qt::Key_F12 }, // hardcoded Sun F37 (labeled F12) + +// function keys + + { XK_F1, Qt::Key_F1 }, + { XK_F2, Qt::Key_F2 }, + { XK_F3, Qt::Key_F3 }, + { XK_F4, Qt::Key_F4 }, + { XK_F5, Qt::Key_F5 }, + { XK_F6, Qt::Key_F6 }, + { XK_F7, Qt::Key_F7 }, + { XK_F8, Qt::Key_F8 }, + { XK_F9, Qt::Key_F9 }, + { XK_F10, Qt::Key_F10 }, + { XK_F11, Qt::Key_F11 }, + { XK_F12, Qt::Key_F12 }, + { XK_F13, Qt::Key_F13 }, + { XK_F14, Qt::Key_F14 }, + { XK_F15, Qt::Key_F15 }, + { XK_F16, Qt::Key_F16 }, + { XK_F17, Qt::Key_F17 }, + { XK_F18, Qt::Key_F18 }, + { XK_F19, Qt::Key_F19 }, + { XK_F20, Qt::Key_F20 }, + +// numeric and function keypad keys + + { XK_KP_Space, Qt::Key_Space }, + { XK_KP_Tab, Qt::Key_Tab }, + { XK_KP_Enter, Qt::Key_Enter }, + { XK_KP_F1, Qt::Key_F1 }, + { XK_KP_F2, Qt::Key_F2 }, + { XK_KP_F3, Qt::Key_F3 }, + { XK_KP_F4, Qt::Key_F4 }, + + { XK_KP_Home, Qt::Key_Home }, + { XK_KP_Left, Qt::Key_Left }, + { XK_KP_Up, Qt::Key_Up }, + { XK_KP_Right, Qt::Key_Right }, + { XK_KP_Down, Qt::Key_Down }, + { XK_KP_Prior, Qt::Key_PageUp }, + { XK_KP_Next, Qt::Key_PageDown }, + { XK_KP_End, Qt::Key_End }, + { XK_KP_Begin, Qt::Key_Clear }, + { XK_KP_Insert, Qt::Key_Insert }, + { XK_KP_Delete, Qt::Key_Delete }, + { XK_KP_Equal, Qt::Key_Equal }, + { XK_KP_Multiply, Qt::Key_Asterisk }, + { XK_KP_Add, Qt::Key_Plus }, + { XK_KP_Separator, Qt::Key_Comma }, + { XK_KP_Subtract, Qt::Key_Minus }, + { XK_KP_Decimal, Qt::Key_Period }, + { XK_KP_Divide, Qt::Key_Slash }, + + { XK_KP_0, Qt::Key_0 }, + { XK_KP_1, Qt::Key_1 }, + { XK_KP_2, Qt::Key_2 }, + { XK_KP_3, Qt::Key_3 }, + { XK_KP_4, Qt::Key_4 }, + { XK_KP_5, Qt::Key_5 }, + { XK_KP_6, Qt::Key_6 }, + { XK_KP_7, Qt::Key_7 }, + { XK_KP_8, Qt::Key_8 }, + { XK_KP_9, Qt::Key_9 }, + +//International input method support keys +//International & multi-key character composition + + { XK_ISO_Level3_Shift, Qt::Key_AltGr }, + { XK_Multi_key, Qt::Key_Multi_key }, + { XK_Codeinput, Qt::Key_Codeinput }, + { XK_SingleCandidate, Qt::Key_SingleCandidate }, + { XK_MultipleCandidate, Qt::Key_MultipleCandidate }, + { XK_PreviousCandidate, Qt::Key_PreviousCandidate }, + +// Misc Functions + { XK_Mode_switch, Qt::Key_Mode_switch }, + { XK_script_switch, Qt::Key_Mode_switch }, + +// Japanese keyboard support + { XK_Kanji, Qt::Key_Kanji }, + { XK_Muhenkan, Qt::Key_Muhenkan }, + //{ XK_Henkan_Mode, Qt::Key_Henkan_Mode }, + { XK_Henkan_Mode, Qt::Key_Henkan }, + { XK_Henkan, Qt::Key_Henkan }, + { XK_Romaji, Qt::Key_Romaji }, + { XK_Hiragana, Qt::Key_Hiragana }, + { XK_Katakana, Qt::Key_Katakana }, + { XK_Hiragana_Katakana, Qt::Key_Hiragana_Katakana }, + { XK_Zenkaku, Qt::Key_Zenkaku }, + { XK_Hankaku, Qt::Key_Hankaku }, + { XK_Zenkaku_Hankaku, Qt::Key_Zenkaku_Hankaku }, + { XK_Touroku, Qt::Key_Touroku }, + { XK_Massyo, Qt::Key_Massyo }, + { XK_Kana_Lock, Qt::Key_Kana_Lock }, + { XK_Kana_Shift, Qt::Key_Kana_Shift }, + { XK_Eisu_Shift, Qt::Key_Eisu_Shift }, + { XK_Eisu_toggle, Qt::Key_Eisu_toggle }, + //{ XK_Kanji_Bangou, Qt::Key_Kanji_Bangou }, + //{ XK_Zen_Koho, Qt::Key_Zen_Koho }, + //{ XK_Mae_Koho, Qt::Key_Mae_Koho }, + { XK_Kanji_Bangou, Qt::Key_Codeinput }, + { XK_Zen_Koho, Qt::Key_MultipleCandidate }, + { XK_Mae_Koho, Qt::Key_PreviousCandidate }, + +#ifdef XK_KOREAN +// Korean keyboard support + { XK_Hangul, Qt::Key_Hangul }, + { XK_Hangul_Start, Qt::Key_Hangul_Start }, + { XK_Hangul_End, Qt::Key_Hangul_End }, + { XK_Hangul_Hanja, Qt::Key_Hangul_Hanja }, + { XK_Hangul_Jamo, Qt::Key_Hangul_Jamo }, + { XK_Hangul_Romaja, Qt::Key_Hangul_Romaja }, + //{ XK_Hangul_Codeinput, Qt::Key_Hangul_Codeinput }, + { XK_Hangul_Codeinput, Qt::Key_Codeinput }, + { XK_Hangul_Jeonja, Qt::Key_Hangul_Jeonja }, + { XK_Hangul_Banja, Qt::Key_Hangul_Banja }, + { XK_Hangul_PreHanja, Qt::Key_Hangul_PreHanja }, + { XK_Hangul_PostHanja, Qt::Key_Hangul_PostHanja }, + //{ XK_Hangul_SingleCandidate,Qt::Key_Hangul_SingleCandidate }, + //{ XK_Hangul_MultipleCandidate,Qt::Key_Hangul_MultipleCandidate }, + //{ XK_Hangul_PreviousCandidate,Qt::Key_Hangul_PreviousCandidate }, + { XK_Hangul_SingleCandidate, Qt::Key_SingleCandidate }, + { XK_Hangul_MultipleCandidate,Qt::Key_MultipleCandidate }, + { XK_Hangul_PreviousCandidate,Qt::Key_PreviousCandidate }, + { XK_Hangul_Special, Qt::Key_Hangul_Special }, + //{ XK_Hangul_switch, Qt::Key_Hangul_switch }, + { XK_Hangul_switch, Qt::Key_Mode_switch }, +#endif // XK_KOREAN + +// dead keys + { XK_dead_grave, Qt::Key_Dead_Grave }, + { XK_dead_acute, Qt::Key_Dead_Acute }, + { XK_dead_circumflex, Qt::Key_Dead_Circumflex }, + { XK_dead_tilde, Qt::Key_Dead_Tilde }, + { XK_dead_macron, Qt::Key_Dead_Macron }, + { XK_dead_breve, Qt::Key_Dead_Breve }, + { XK_dead_abovedot, Qt::Key_Dead_Abovedot }, + { XK_dead_diaeresis, Qt::Key_Dead_Diaeresis }, + { XK_dead_abovering, Qt::Key_Dead_Abovering }, + { XK_dead_doubleacute, Qt::Key_Dead_Doubleacute }, + { XK_dead_caron, Qt::Key_Dead_Caron }, + { XK_dead_cedilla, Qt::Key_Dead_Cedilla }, + { XK_dead_ogonek, Qt::Key_Dead_Ogonek }, + { XK_dead_iota, Qt::Key_Dead_Iota }, + { XK_dead_voiced_sound, Qt::Key_Dead_Voiced_Sound }, + { XK_dead_semivoiced_sound, Qt::Key_Dead_Semivoiced_Sound }, + { XK_dead_belowdot, Qt::Key_Dead_Belowdot }, + { XK_dead_hook, Qt::Key_Dead_Hook }, + { XK_dead_horn, Qt::Key_Dead_Horn }, + +// Special keys from X.org - This include multimedia keys, +// wireless/bluetooth/uwb keys , special launcher keys, etc. + +#if 0 + { XF86XK_Back, Qt::Key_Back }, + { XF86XK_Forward, Qt::Key_Forward }, + { XF86XK_Stop, Qt::Key_Stop }, + { XF86XK_Refresh, Qt::Key_Refresh }, + { XF86XK_Favorites, Qt::Key_Favorites }, + { XF86XK_AudioMedia, Qt::Key_LaunchMedia }, + { XF86XK_OpenURL, Qt::Key_OpenUrl }, + { XF86XK_HomePage, Qt::Key_HomePage }, + { XF86XK_Search, Qt::Key_Search }, + { XF86XK_AudioLowerVolume, Qt::Key_VolumeDown }, + { XF86XK_AudioMute, Qt::Key_VolumeMute }, + { XF86XK_AudioRaiseVolume, Qt::Key_VolumeUp }, + { XF86XK_AudioPlay, Qt::Key_MediaPlay }, + { XF86XK_AudioStop, Qt::Key_MediaStop }, + { XF86XK_AudioPrev, Qt::Key_MediaPrevious }, + { XF86XK_AudioNext, Qt::Key_MediaNext }, + { XF86XK_AudioRecord, Qt::Key_MediaRecord }, + { XF86XK_Mail, Qt::Key_LaunchMail }, + { XF86XK_MyComputer, Qt::Key_Launch0 }, + { XF86XK_Calculator, Qt::Key_Calculator }, + { XF86XK_Memo, Qt::Key_Memo }, + { XF86XK_ToDoList, Qt::Key_ToDoList }, + { XF86XK_Calendar, Qt::Key_Calendar }, + { XF86XK_PowerDown, Qt::Key_PowerDown }, + { XF86XK_ContrastAdjust, Qt::Key_ContrastAdjust }, + { XF86XK_Standby, Qt::Key_Standby }, + { XF86XK_MonBrightnessUp, Qt::Key_MonBrightnessUp }, + { XF86XK_MonBrightnessDown, Qt::Key_MonBrightnessDown }, + { XF86XK_KbdLightOnOff, Qt::Key_KeyboardLightOnOff }, + { XF86XK_KbdBrightnessUp, Qt::Key_KeyboardBrightnessUp }, + { XF86XK_KbdBrightnessDown, Qt::Key_KeyboardBrightnessDown }, + { XF86XK_PowerOff, Qt::Key_PowerOff }, + { XF86XK_WakeUp, Qt::Key_WakeUp }, + { XF86XK_Eject, Qt::Key_Eject }, + { XF86XK_ScreenSaver, Qt::Key_ScreenSaver }, + { XF86XK_WWW, Qt::Key_WWW }, + { XF86XK_Sleep, Qt::Key_Sleep }, + { XF86XK_LightBulb, Qt::Key_LightBulb }, + { XF86XK_Shop, Qt::Key_Shop }, + { XF86XK_History, Qt::Key_History }, + { XF86XK_AddFavorite, Qt::Key_AddFavorite }, + { XF86XK_HotLinks, Qt::Key_HotLinks }, + { XF86XK_BrightnessAdjust, Qt::Key_BrightnessAdjust }, + { XF86XK_Finance, Qt::Key_Finance }, + { XF86XK_Community, Qt::Key_Community }, + { XF86XK_AudioRewind, Qt::Key_AudioRewind }, + { XF86XK_BackForward, Qt::Key_BackForward }, + { XF86XK_ApplicationLeft, Qt::Key_ApplicationLeft }, + { XF86XK_ApplicationRight, Qt::Key_ApplicationRight }, + { XF86XK_Book, Qt::Key_Book }, + { XF86XK_CD, Qt::Key_CD }, + { XF86XK_Calculater, Qt::Key_Calculator }, + { XF86XK_Clear, Qt::Key_Clear }, + { XF86XK_ClearGrab, Qt::Key_ClearGrab }, + { XF86XK_Close, Qt::Key_Close }, + { XF86XK_Copy, Qt::Key_Copy }, + { XF86XK_Cut, Qt::Key_Cut }, + { XF86XK_Display, Qt::Key_Display }, + { XF86XK_DOS, Qt::Key_DOS }, + { XF86XK_Documents, Qt::Key_Documents }, + { XF86XK_Excel, Qt::Key_Excel }, + { XF86XK_Explorer, Qt::Key_Explorer }, + { XF86XK_Game, Qt::Key_Game }, + { XF86XK_Go, Qt::Key_Go }, + { XF86XK_iTouch, Qt::Key_iTouch }, + { XF86XK_LogOff, Qt::Key_LogOff }, + { XF86XK_Market, Qt::Key_Market }, + { XF86XK_Meeting, Qt::Key_Meeting }, + { XF86XK_MenuKB, Qt::Key_MenuKB }, + { XF86XK_MenuPB, Qt::Key_MenuPB }, + { XF86XK_MySites, Qt::Key_MySites }, + { XF86XK_News, Qt::Key_News }, + { XF86XK_OfficeHome, Qt::Key_OfficeHome }, + { XF86XK_Option, Qt::Key_Option }, + { XF86XK_Paste, Qt::Key_Paste }, + { XF86XK_Phone, Qt::Key_Phone }, + { XF86XK_Reply, Qt::Key_Reply }, + { XF86XK_Reload, Qt::Key_Reload }, + { XF86XK_RotateWindows, Qt::Key_RotateWindows }, + { XF86XK_RotationPB, Qt::Key_RotationPB }, + { XF86XK_RotationKB, Qt::Key_RotationKB }, + { XF86XK_Save, Qt::Key_Save }, + { XF86XK_Send, Qt::Key_Send }, + { XF86XK_Spell, Qt::Key_Spell }, + { XF86XK_SplitScreen, Qt::Key_SplitScreen }, + { XF86XK_Support, Qt::Key_Support }, + { XF86XK_TaskPane, Qt::Key_TaskPane }, + { XF86XK_Terminal, Qt::Key_Terminal }, + { XF86XK_Tools, Qt::Key_Tools }, + { XF86XK_Travel, Qt::Key_Travel }, + { XF86XK_Video, Qt::Key_Video }, + { XF86XK_Word, Qt::Key_Word }, + { XF86XK_Xfer, Qt::Key_Xfer }, + { XF86XK_ZoomIn, Qt::Key_ZoomIn }, + { XF86XK_ZoomOut, Qt::Key_ZoomOut }, + { XF86XK_Away, Qt::Key_Away }, + { XF86XK_Messenger, Qt::Key_Messenger }, + { XF86XK_WebCam, Qt::Key_WebCam }, + { XF86XK_MailForward, Qt::Key_MailForward }, + { XF86XK_Pictures, Qt::Key_Pictures }, + { XF86XK_Music, Qt::Key_Music }, + { XF86XK_Battery, Qt::Key_Battery }, + { XF86XK_Bluetooth, Qt::Key_Bluetooth }, + { XF86XK_WLAN, Qt::Key_WLAN }, + { XF86XK_UWB, Qt::Key_UWB }, + { XF86XK_AudioForward, Qt::Key_AudioForward }, + { XF86XK_AudioRepeat, Qt::Key_AudioRepeat }, + { XF86XK_AudioRandomPlay, Qt::Key_AudioRandomPlay }, + { XF86XK_Subtitle, Qt::Key_Subtitle }, + { XF86XK_AudioCycleTrack, Qt::Key_AudioCycleTrack }, + { XF86XK_Time, Qt::Key_Time }, + { XF86XK_Select, Qt::Key_Select }, + { XF86XK_View, Qt::Key_View }, + { XF86XK_TopMenu, Qt::Key_TopMenu }, + { XF86XK_Bluetooth, Qt::Key_Bluetooth }, + { XF86XK_Suspend, Qt::Key_Suspend }, + { XF86XK_Hibernate, Qt::Key_Hibernate }, + { XF86XK_Launch0, Qt::Key_Launch2 }, + { XF86XK_Launch1, Qt::Key_Launch3 }, + { XF86XK_Launch2, Qt::Key_Launch4 }, + { XF86XK_Launch3, Qt::Key_Launch5 }, + { XF86XK_Launch4, Qt::Key_Launch6 }, + { XF86XK_Launch5, Qt::Key_Launch7 }, + { XF86XK_Launch6, Qt::Key_Launch8 }, + { XF86XK_Launch7, Qt::Key_Launch9 }, + { XF86XK_Launch8, Qt::Key_LaunchA }, + { XF86XK_Launch9, Qt::Key_LaunchB }, + { XF86XK_LaunchA, Qt::Key_LaunchC }, + { XF86XK_LaunchB, Qt::Key_LaunchD }, + { XF86XK_LaunchC, Qt::Key_LaunchE }, + { XF86XK_LaunchD, Qt::Key_LaunchF }, +#endif + + { 0, 0} +}; + +#endif + + +int +QtKeyToXKeySym(int qtKey) { + + // TODO: Need to complete this function for all scenario. + int i; + int count = sizeof(QtKeyXSymMaps)/sizeof(KeySymMap); + + if (qtKey < 0x1000) { + //return QChar(qtKey).toLower().unicode(); + return qtKey; + } + + for(i = 0; i < count; i++ ) { + if( QtKeyXSymMaps[i].QtKey == qtKey ) { + return QtKeyXSymMaps[i].XKeySym; + } + } + + return 0; +} + + +int +XKeySymToQTKey(uint keySym) +{ + int i; + int count = sizeof(QtKeyXSymMaps)/sizeof(KeySymMap); + + if ((keySym < 0x1000)) { + //if (keySym >= 'a' && keySym <= 'z') + // return QChar(keySym).toUpper().toAscii(); + return keySym; + } + +#ifdef Q_WS_WIN + if(keySym < 0x3000) + return keySym; +#else + if (keySym < 0x3000 ) + return keySym | Qt::UNICODE_ACCEL; + + for(i = 0; i < count; i++) + if(QtKeyXSymMaps[i].XKeySym == keySym) + return QtKeyXSymMaps[i].QtKey; +#endif + return Qt::Key_unknown; +} + diff --git a/meego/qt-keysym-map.h b/meego/qt-keysym-map.h new file mode 100644 index 0000000..bfd1a96 --- /dev/null +++ b/meego/qt-keysym-map.h @@ -0,0 +1,13 @@ +#ifndef _QT_KEYSYM_MAP_H +#define _QT_KEYSYM_MAP_H + +#include + +G_BEGIN_DECLS + +int QtKeyToXKeySym(int qtKey); +int XKeySymToQTKey(guint keySym); + +G_END_DECLS + +#endif //_QT_KEYSYM_MAP_H diff --git a/meego/qt-translate.cpp b/meego/qt-translate.cpp new file mode 100644 index 0000000..866610c --- /dev/null +++ b/meego/qt-translate.cpp @@ -0,0 +1,195 @@ +/* + * Copyright (C) 2010, Intel Corporation. + * + * Author: Raymond Liu + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include "debug.h" + +#include +#include + +#include "qt-keysym-map.h" + +#include "qt-translate.h" + +enum { + ShiftModifier = 1 << 0, + ControlModifier = 1 << 2, + AltModifier = 1 << 3 +}; +#define SHIFT_MASK 1 << 0) + +void meego_im_key_event_decode(MeegoImKeyEvent *e, int type, int key, int modifiers, char *text) +{ + g_warn_if_fail(type == QEvent::KeyPress || type == QEvent::KeyRelease); + e->release = type == QEvent::KeyRelease; + + e->state = 0; + if (modifiers & Qt::ShiftModifier) + e->state |= ShiftModifier; + if (modifiers & Qt::ControlModifier) + e->state |= ControlModifier; + if (modifiers & Qt::AltModifier) + e->state |= AltModifier; + + e->keysym = QtKeyToXKeySym(key); + + if (text && strlen(text) > 0) { + e->text = text; + } +} + +void meego_im_key_event_encode(const MeegoImKeyEvent *e, int *type, int *key, int *modifiers, char **text) +{ + *type = e->release ? QEvent::KeyRelease : QEvent::KeyPress; + *key = XKeySymToQTKey(e->keysym); + *modifiers = Qt::NoModifier; + if (e->state & ShiftModifier) + *modifiers |= Qt::ShiftModifier; + if (e->state & ControlModifier) + *modifiers |= Qt::ControlModifier; + if (e->state & AltModifier) + *modifiers |= Qt::AltModifier; + *text = e->text && strlen(e->text) > 0 ? e->text : NULL; +} + +#if 0 +GdkEventKey * +compose_gdk_keyevent(GdkEventType type, guint keyval, guint state, GdkWindow *window) +{ + GdkEventKey *event = NULL; +#if GTK_CHECK_VERSION (3, 0, 0) + GdkDisplay *display; + GdkDeviceManager *device_manager; + GdkDevice *client_pointer; +#endif + if ((type != GDK_KEY_PRESS) && (type != GDK_KEY_RELEASE)) + return NULL; + + event = (GdkEventKey *)(gdk_event_new(type)); + event->length = 0; + event->string = 0; + event->is_modifier = 0; + event->time = GDK_CURRENT_TIME; + event->state = state; + +#if GTK_CHECK_VERSION (3, 0, 0) + display = gdk_window_get_display (window); + device_manager = gdk_display_get_device_manager (display); + client_pointer = gdk_device_manager_get_client_pointer (device_manager); + + gdk_event_set_device ((GdkEvent *)event, + gdk_device_get_associated_device (client_pointer)); +#endif + + if (type == GDK_KEY_RELEASE) + event->state |= GDK_RELEASE_MASK; + event->keyval = keyval; + event->window = window; + + if (event->window) { + GdkKeymap *key_map = gdk_keymap_get_default(); + GdkKeymapKey *keys; + gint n; + + g_object_ref(event->window); // seems when event is freed, the event->window will be unref + + if (gdk_keymap_get_entries_for_keyval(key_map, event->keyval, &keys, &n)) { + event->hardware_keycode = keys[0].keycode; + event->group = keys[0].group; + } else { + event->hardware_keycode = 0; + event->group = 0; + } + } + + DBG("event type=0x%x, state=0x%x, keyval=0x%x, keycode=0x%x, group=%d", + event->type, event->state, event->keyval, event->hardware_keycode, event->group); + + return event; +} + + + +GdkEventKey * +qt_key_event_to_gdk(int type, int key, int modifiers, char *text, GdkWindow *window) +{ + Q_UNUSED(text); + guint state = 0; + guint keyval; + + STEP(); + if ((type != QEvent::KeyPress) && (type != QEvent::KeyRelease)) + return NULL; + + if (modifiers & Qt::ShiftModifier) + state |= GDK_SHIFT_MASK; + if (modifiers & Qt::ControlModifier) + state |= GDK_CONTROL_MASK; + if (modifiers & Qt::AltModifier) + state |= GDK_MOD1_MASK; + + keyval = QtKeyToXKeySym(key); + + if (type == QEvent::KeyPress) { + return compose_gdk_keyevent(GDK_KEY_PRESS, keyval, state, window); + } else { + return compose_gdk_keyevent(GDK_KEY_RELEASE, keyval, state, window); + } + +} + + +gboolean +gdk_key_event_to_qt(GdkEventKey *event, int *type, int *key, int *modifier) +{ + + switch (event->type) { + case GDK_KEY_PRESS: + *type = QEvent::KeyPress; + break; + case GDK_KEY_RELEASE: + *type = QEvent::KeyRelease; + break; + default: + return FALSE; + } + + *key = XKeySymToQTKey(event->keyval); + if (*key == Qt::Key_unknown) { + qWarning("Unkonwn key"); + return FALSE; + } + + *modifier = Qt::NoModifier; + if (event->state & GDK_SHIFT_MASK) + *modifier |= Qt::ShiftModifier; + if (event->state & GDK_CONTROL_MASK) + *modifier |= Qt::ControlModifier; + if (event->state & GDK_MOD1_MASK) + *modifier |= Qt::AltModifier; + if (event->state & GDK_META_MASK) + *modifier |= Qt::MetaModifier; + + DBG("qtkey type =%d, qtkey=0x%x, modifier=0x%x", *type, *key, *modifier); + + return TRUE; +} + +#endif diff --git a/meego/qt-translate.h b/meego/qt-translate.h new file mode 100644 index 0000000..178683f --- /dev/null +++ b/meego/qt-translate.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2010, Intel Corporation. + * + * Author: Raymond Liu + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#ifndef _QT_TRANSLATE_H +#define _QT_TRANSLATE_H + +#include +#include "meego-im-defs.h" + +G_BEGIN_DECLS + +void meego_im_key_event_decode(MeegoImKeyEvent *e, int type, int key, int modifiers, char *text); +void meego_im_key_event_encode(const MeegoImKeyEvent *e, int *type, int *key, int *modifiers, char **text); + +G_END_DECLS + +#endif //_QT_GTK_TRANSLATE_H diff --git a/meego/src.pro b/meego/src.pro new file mode 100644 index 0000000..8e140dd --- /dev/null +++ b/meego/src.pro @@ -0,0 +1,71 @@ +include(../../config.pri) + +TEMPLATE = lib +TARGET = maliit-im-common + +CONFIG += link_pkgconfig +PKGCONFIG += glib-2.0 gthread-2.0 dbus-glib-1 + +debug{ + DEFINES += ENABLE_DEBUG +} + +# Generated dbus glue code has warnings of this type, so disable them +QMAKE_CFLAGS_DEBUG += -Wno-unused-parameter +QMAKE_CFLAGS_RELEASE += -Wno-unused-parameter + +HEADERS += \ + meego-im-proxy.h \ + meego-imcontext-dbus.h \ + meego-im-connector.h \ + qt-keysym-map.h \ + debug.h \ + +SOURCES += \ + meego-im-proxy.c \ + meego-imcontext-dbus.c \ + meego-im-connector.c \ + qt-keysym-map.cpp \ + +GTK3_IM_MODULEDIR = + +target.path = $$M_IM_INSTALL_LIBS + +INSTALLS += target + +EXTRA_FILES = \ + meego-im-client.xml \ + meego-imcontext-dbus.xml + + +# improxy +# Generate dbus glue +QMAKE_EXTRA_TARGETS += dbus_glue_improxy +dbus_glue_improxy.target = $$OUT_PWD/meego-im-proxy-glue.h +dbus_glue_improxy.output = $$OUT_PWD/meego-im-proxy-glue.h +dbus_glue_improxy.depends = $$IN_PWD/meego-im-client.xml +dbus_glue_improxy.commands = \ + dbus-binding-tool --prefix=meego_im_proxy --mode=glib-client \ + --output=$$OUT_PWD/meego-im-proxy-glue.h \ + meego-im-client.xml + +# Use to work around the fact that qmake looks up the target for the generated header wrong +QMAKE_EXTRA_TARGETS += fake_dbus_glue_improxy +fake_dbus_glue_improxy.target = meego-im-proxy-glue.h +fake_dbus_glue_improxy.depends = dbus_glue_improxy + +# imcontext +# Generate dbus glue +QMAKE_EXTRA_TARGETS += dbus_glue_imcontext +dbus_glue_imcontext.target = $$OUT_PWD/meego-imcontext-dbus-glue.h +dbus_glue_imcontext.output = $$OUT_PWD/meego-imcontext-dbus-glue.h +dbus_glue_imcontext.depends = $$IN_PWD/meego-imcontext-dbus.xml +dbus_glue_imcontext.commands = \ + dbus-binding-tool --prefix=meego_imcontext_dbus --mode=glib-server \ + --output=$$OUT_PWD/meego-imcontext-dbus-glue.h \ + meego-imcontext-dbus.xml + +# Use to work around the fact that qmake looks up the target for the generated header wrong +QMAKE_EXTRA_TARGETS += fake_dbus_glue_imcontext +fake_dbus_glue_imcontext.target = meego-imcontext-dbus-glue.h +fake_dbus_glue_imcontext.depends = dbus_glue_imcontext -- cgit v1.2.3