4
* Copyright (c) 2006 Ryo Dairiki <ryo-dairiki@users.sourceforge.net>
5
* Copyright (C) 2009, Intel Corporation.
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation and
10
* appearing in the file LICENSE.LGPL included in the package of this file.
11
* You can also redistribute it and/or modify it under the terms of
12
* the GNU General Public License as published by the Free Software Foundation and
13
* appearing in the file LICENSE.GPL included in the package of this file.
15
* This library is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22
#include <sys/select.h>
23
#include <sys/types.h>
27
#include <clutter/clutter.h>
29
#include "scim-bridge-client.h"
30
#include "scim-bridge-client-clutter.h"
31
#include "scim-bridge-client-imcontext-clutter.h"
32
#include "scim-bridge-client-protected.h"
33
#include "scim-bridge-imcontext.h"
34
#include "scim-bridge-output.h"
36
/* Private Variables */
37
static GIOChannel *messenger_iochannel = NULL;
38
static guint messenger_event_source = -1;
40
static boolean initialized = FALSE;
43
/* Private Functions */
44
static gboolean handle_message (GIOChannel *source, GIOCondition condition, gpointer data)
46
const int socket_fd = scim_bridge_client_get_messenger_fd ();
50
FD_SET (socket_fd, &read_set);
52
struct timeval timeout;
55
if (select (socket_fd + 1, &read_set, NULL, NULL, &timeout) > 0) {
56
if (scim_bridge_client_read_and_dispatch ()) {
57
scim_bridge_perrorln ("An IOException occurred at handle_message ()");
66
/* Public Functions */
67
void scim_bridge_client_clutter_initialize ()
69
scim_bridge_pdebugln (5, "scim_bridge_client_clutter_initialize ()");
77
if (scim_bridge_client_initialize ()) {
78
scim_bridge_perrorln ("Failed to initialize scim-bridge...");
80
scim_bridge_client_open_messenger ();
83
scim_bridge_client_imcontext_static_initialize ();
87
void scim_bridge_client_clutter_finalize ()
89
scim_bridge_pdebugln (5, "scim_bridge_client_clutter_finalize ()");
97
scim_bridge_client_finalize ();
98
scim_bridge_client_imcontext_static_finalize ();
102
void scim_bridge_client_messenger_opened ()
104
if (messenger_iochannel == NULL) {
105
messenger_iochannel = g_io_channel_unix_new (scim_bridge_client_get_messenger_fd ());
106
messenger_event_source = g_io_add_watch (messenger_iochannel, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL, &handle_message, NULL);
109
scim_bridge_client_imcontext_connection_opened ();
113
void scim_bridge_client_messenger_closed ()
115
if (messenger_iochannel != NULL) {
116
g_io_channel_unref (messenger_iochannel);
117
messenger_iochannel = NULL;
118
g_source_remove (messenger_event_source);
119
messenger_event_source = -1;
122
scim_bridge_client_imcontext_connection_closed ();