PageRenderTime 204ms CodeModel.GetById 28ms app.highlight 161ms RepoModel.GetById 0ms app.codeStats 1ms

/libgxim/gximprotocol10.c

https://bitbucket.org/tagoh/libgxim
C | 2304 lines | 1902 code | 315 blank | 87 comment | 103 complexity | ac0a6a7fcfec031a91c1c6c2107b1687 MD5 | raw file
Possible License(s): LGPL-2.1

Large files files are truncated, but you can click here to view the full file

   1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
   2/* 
   3 * gximprotocol10.c
   4 * Copyright (C) 2008-2011 Akira TAGOH
   5 * 
   6 * Authors:
   7 *   Akira TAGOH  <akira@tagoh.org>
   8 * 
   9 * This library is free software; you can redistribute it and/or
  10 * modify it under the terms of the GNU Lesser General Public
  11 * License as published by the Free Software Foundation; either
  12 * version 2 of the License, or (at your option) any later version.
  13 * 
  14 * This library is distributed in the hope that it will be useful,
  15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17 * Lesser General Public License for more details.
  18 * 
  19 * You should have received a copy of the GNU Lesser General Public
  20 * License along with this library; if not, write to the
  21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth
  22 * Floor, Boston, MA  02110-1301  USA
  23 */
  24#ifdef HAVE_CONFIG_H
  25#include "config.h"
  26#endif
  27
  28#ifdef HAVE_STRING_H
  29#include <string.h>
  30#endif
  31#include <gdk/gdkkeysyms.h>
  32#include <gio/gio.h>
  33#include "gximattr.h"
  34#include "gximconnection.h"
  35#include "gximsrvconn.h"
  36#include "gximmarshal.h"
  37#include "gximmessages.h"
  38#include "gximmisc.h"
  39#include "gximprotocol.h"
  40#include "gximprotocol10.h"
  41
  42#define PROTO_ERROR(_m_,_n_)			(g_xim_protocol_raise_parser_error(proto, G_ ## _m_, (_n_), 0, 0))
  43#define PROTO_ERROR_IM(_m_,_n_,_imid_)		(g_xim_protocol_raise_parser_error(proto, G_ ##_m_, (_n_), (_imid_), 0))
  44#define PROTO_ERROR_IMIC(_m_,_n_,_imid_,_icid_)	(g_xim_protocol_raise_parser_error(proto, G_ ##_m_, (_n_), (_imid_), (_icid_)))
  45#define SIG_NOIMPL(_s_)				(g_xim_protocol10_closure_signal_no_impl(proto, #_s_, G_XIM_EMASK_NO_VALID_ID, 0, 0))
  46#define SIG_NOIMPL_IM(_s_,_imid_)		(g_xim_protocol10_closure_signal_no_impl(proto, #_s_, G_XIM_EMASK_VALID_IMID, (_imid_), 0))
  47#define SIG_NOIMPL_IMIC(_s_,_imid_,_icid_)	(g_xim_protocol10_closure_signal_no_impl(proto, #_s_, G_XIM_EMASK_VALID_IMID|G_XIM_EMASK_VALID_ICID, (_imid_), (_icid_)))
  48#define MSG_NOIMPL(_s_)				(g_xim_messages_error(G_XIM_PROTOCOL_GET_IFACE (proto)->message, "No implementation or an error occurred in %s", #_s_))
  49#define MSG_NOIMPL_IM(_s_,_imid_)		(g_xim_messages_error(G_XIM_PROTOCOL_GET_IFACE (proto)->message, "No implementation or an error occurred in %s [imid: %d]", #_s_, (_imid_)))
  50#define MSG_NOIMPL_IMIC(_s_,_imid_,_icid_)	(g_xim_messages_error(G_XIM_PROTOCOL_GET_IFACE (proto)->message, "No implementation or an error occurred in %s [imid: %d, icid: %d]", #_s_, (_imid_), (_icid_)))
  51
  52
  53/*
  54 * Private functions
  55 */
  56static gboolean
  57g_xim_protocol10_closure_XIM_CONNECT(GXimProtocolClosure  *closure,
  58				     GXimProtocol         *proto,
  59				     GDataInputStream     *stream,
  60				     GError              **error,
  61				     gpointer              user_data)
  62{
  63	guint8 b;
  64	guint16 major = 0, minor = 0;
  65	GSList *list = NULL;
  66	gboolean retval = FALSE;
  67
  68	if (g_xim_protocol_read_format(proto, stream, NULL, error, 6,
  69				       G_XIM_TYPE_BYTE, &b,
  70				       G_XIM_TYPE_PADDING, 1,
  71				       G_XIM_TYPE_WORD, &major,
  72				       G_XIM_TYPE_WORD, &minor,
  73				       G_XIM_TYPE_MARKER_N_ITEMS_2, G_XIM_TYPE_LIST_OF_STRING,
  74				       G_XIM_TYPE_LIST_OF_STRING, &list)) {
  75		retval = g_xim_protocol_closure_emit_signal(closure, proto,
  76							    major, minor, list);
  77	} else {
  78		/* better handling error */
  79		PROTO_ERROR (XIM_CONNECT, 0);
  80	}
  81
  82	g_slist_foreach(list, (GFunc)g_xim_string_free, NULL);
  83	g_slist_free(list);
  84
  85	return retval;
  86}
  87
  88static gboolean
  89g_xim_protocol10_closure_XIM_CONNECT_REPLY(GXimProtocolClosure  *closure,
  90					   GXimProtocol         *proto,
  91					   GDataInputStream     *stream,
  92					   GError              **error,
  93					   gpointer              user_data)
  94{
  95	guint16 major, minor;
  96	gboolean retval = FALSE;
  97
  98	if (g_xim_protocol_read_format(proto, stream, NULL, error, 2,
  99				       G_XIM_TYPE_WORD, &major,
 100				       G_XIM_TYPE_WORD, &minor)) {
 101		retval = g_xim_protocol_closure_emit_signal(closure, proto,
 102							    major, minor);
 103	} else {
 104		/* better handling error */
 105		PROTO_ERROR (XIM_CONNECT_REPLY, 0);
 106	}
 107
 108	return retval;
 109}
 110
 111static gboolean
 112g_xim_protocol10_closure_XIM_DISCONNECT(GXimProtocolClosure  *closure,
 113					GXimProtocol         *proto,
 114					GDataInputStream     *stream,
 115					GError              **error,
 116					gpointer              user_data)
 117{
 118	gboolean retval = FALSE;
 119
 120	retval = g_xim_protocol_closure_emit_signal(closure, proto);
 121
 122	return retval;
 123}
 124
 125static gboolean
 126g_xim_protocol10_closure_XIM_DISCONNECT_REPLY(GXimProtocolClosure  *closure,
 127					      GXimProtocol         *proto,
 128					      GDataInputStream     *stream,
 129					      GError              **error,
 130					      gpointer              user_data)
 131{
 132	GXimProtocolPrivate *priv;
 133	gboolean retval = FALSE;
 134
 135	priv = g_xim_protocol_get_private(proto);
 136
 137	retval = g_xim_protocol_closure_emit_signal(closure, proto);
 138
 139	priv->is_disconnected = TRUE;
 140
 141	return retval;
 142}
 143
 144static gboolean
 145g_xim_protocol10_closure_XIM_AUTH_REQUIRED(GXimProtocolClosure  *closure,
 146					   GXimProtocol         *proto,
 147					   GDataInputStream     *stream,
 148					   GError              **error,
 149					   gpointer              user_data)
 150{
 151	gboolean retval = FALSE;
 152
 153	/* XXX */
 154	PROTO_ERROR (XIM_AUTH_REQUIRED, 0);
 155
 156	return retval;
 157}
 158
 159static gboolean
 160g_xim_protocol10_closure_XIM_AUTH_REPLY(GXimProtocolClosure  *closure,
 161					GXimProtocol         *proto,
 162					GDataInputStream     *stream,
 163					GError              **error,
 164					gpointer              user_data)
 165{
 166	gboolean retval = FALSE;
 167
 168	/* XXX */
 169	PROTO_ERROR (XIM_AUTH_REPLY, 0);
 170
 171	return retval;
 172}
 173
 174static gboolean
 175g_xim_protocol10_closure_XIM_AUTH_NEXT(GXimProtocolClosure  *closure,
 176				       GXimProtocol         *proto,
 177				       GDataInputStream     *stream,
 178				       GError              **error,
 179				       gpointer              user_data)
 180{
 181	gboolean retval = FALSE;
 182
 183	/* XXX */
 184	PROTO_ERROR (XIM_AUTH_NEXT, 0);
 185
 186	return retval;
 187}
 188
 189static gboolean
 190g_xim_protocol10_closure_XIM_AUTH_SETUP(GXimProtocolClosure  *closure,
 191					GXimProtocol         *proto,
 192					GDataInputStream     *stream,
 193					GError              **error,
 194					gpointer              user_data)
 195{
 196	gboolean retval = FALSE;
 197
 198	/* XXX */
 199	PROTO_ERROR (XIM_AUTH_SETUP, 0);
 200
 201	return retval;
 202}
 203
 204static gboolean
 205g_xim_protocol10_closure_XIM_AUTH_NG(GXimProtocolClosure  *closure,
 206				     GXimProtocol         *proto,
 207				     GDataInputStream     *stream,
 208				     GError              **error,
 209				     gpointer              user_data)
 210{
 211	gboolean retval = FALSE;
 212
 213	retval = g_xim_protocol_closure_emit_signal(closure, proto);
 214
 215	return retval;
 216}
 217
 218static gboolean
 219g_xim_protocol10_closure_XIM_ERROR(GXimProtocolClosure  *closure,
 220				   GXimProtocol         *proto,
 221				   GDataInputStream     *stream,
 222				   GError              **error,
 223				   gpointer              user_data)
 224{
 225	gboolean retval = FALSE;
 226	guint16 imid, icid, flag, detail;
 227	GXimErrorCode error_code = 0;
 228	gchar *error_message = NULL;
 229
 230	if (g_xim_protocol_read_format(proto, stream, NULL, error, 8,
 231				       G_XIM_TYPE_WORD, &imid,
 232				       G_XIM_TYPE_WORD, &icid,
 233				       G_XIM_TYPE_WORD, &flag,
 234				       G_XIM_TYPE_WORD, &error_code,
 235				       G_XIM_TYPE_MARKER_N_BYTES_2, G_XIM_TYPE_CHAR,
 236				       G_XIM_TYPE_WORD, &detail,
 237				       G_XIM_TYPE_CHAR, &error_message,
 238				       G_XIM_TYPE_AUTO_PADDING, 0)) {
 239		retval = g_xim_protocol_closure_emit_signal(closure, proto,
 240							    imid, icid, flag, error_code, detail, error_message);
 241	}
 242	g_free(error_message);
 243
 244	return retval;
 245}
 246
 247static gboolean
 248g_xim_protocol10_closure_XIM_OPEN(GXimProtocolClosure  *closure,
 249				  GXimProtocol         *proto,
 250				  GDataInputStream     *stream,
 251				  GError              **error,
 252				  gpointer              user_data)
 253{
 254	GXimStr *locale = NULL;
 255	gboolean retval = FALSE;
 256
 257	if (g_xim_protocol_read_format(proto, stream, NULL, error, 2,
 258				       G_XIM_TYPE_STR, &locale,
 259				       G_XIM_TYPE_AUTO_PADDING, 0)) {
 260		retval = g_xim_protocol_closure_emit_signal(closure, proto,
 261							    locale);
 262	} else {
 263		/* better handling error */
 264		PROTO_ERROR (XIM_OPEN, 0);
 265	}
 266
 267	g_xim_str_free(locale);
 268
 269	return retval;
 270}
 271
 272static gboolean
 273g_xim_protocol10_closure_XIM_OPEN_REPLY(GXimProtocolClosure  *closure,
 274					GXimProtocol         *proto,
 275					GDataInputStream     *stream,
 276					GError              **error,
 277					gpointer              user_data)
 278{
 279	GSList *imlist = NULL, *iclist = NULL, *l;
 280	GXimAttr *imattr = NULL, *icattr = NULL;
 281	guint16 imid = 0;
 282	gboolean retval = FALSE;
 283
 284	if (g_xim_protocol_read_format(proto, stream, NULL, error, 6,
 285				       G_XIM_TYPE_WORD, &imid,
 286				       G_XIM_TYPE_MARKER_N_BYTES_2, G_XIM_TYPE_LIST_OF_IMATTR,
 287				       G_XIM_TYPE_LIST_OF_IMATTR, &imlist,
 288				       G_XIM_TYPE_MARKER_N_BYTES_2, G_XIM_TYPE_LIST_OF_ICATTR,
 289				       G_XIM_TYPE_PADDING, 2,
 290				       G_XIM_TYPE_LIST_OF_ICATTR, &iclist)) {
 291		imattr = g_object_new(G_TYPE_XIM_IM_ATTR, NULL);
 292		icattr = g_object_new(G_TYPE_XIM_IC_ATTR, NULL);
 293		for (l = imlist; l != NULL; l = g_slist_next(l)) {
 294			g_xim_attr_set_raw_attr(imattr, l->data);
 295			g_xim_raw_attr_free(l->data);
 296		}
 297		for (l = iclist; l != NULL; l = g_slist_next(l)) {
 298			g_xim_attr_set_raw_attr(icattr, l->data);
 299			g_xim_raw_attr_free(l->data);
 300		}
 301		g_slist_free(imlist);
 302		g_slist_free(iclist);
 303
 304		retval = g_xim_protocol_closure_emit_signal(closure, proto,
 305							    imid, imattr, icattr);
 306	} else {
 307		/* better handling error */
 308		PROTO_ERROR_IM (XIM_OPEN_REPLY, 0, imid);
 309	}
 310
 311	if (imattr)
 312		g_object_unref(imattr);
 313	if (icattr)
 314		g_object_unref(icattr);
 315
 316	return retval;
 317}
 318
 319static gboolean
 320g_xim_protocol10_closure_XIM_CLOSE(GXimProtocolClosure  *closure,
 321				   GXimProtocol         *proto,
 322				   GDataInputStream     *stream,
 323				   GError              **error,
 324				   gpointer              user_data)
 325{
 326	gboolean retval = FALSE;
 327	guint16 imid = 0;
 328
 329	if (g_xim_protocol_read_format(proto, stream, NULL, error, 2,
 330				       G_XIM_TYPE_WORD, &imid,
 331				       G_XIM_TYPE_PADDING, 2)) {
 332		retval = g_xim_protocol_closure_emit_signal(closure, proto,
 333							    imid);
 334	} else {
 335		/* better handling error */
 336		PROTO_ERROR_IM (XIM_CLOSE, 0, imid);
 337	}
 338
 339	return retval;
 340}
 341
 342static gboolean
 343g_xim_protocol10_closure_XIM_CLOSE_REPLY(GXimProtocolClosure  *closure,
 344					 GXimProtocol         *proto,
 345					 GDataInputStream     *stream,
 346					 GError              **error,
 347					 gpointer              user_data)
 348{
 349	gboolean retval = FALSE;
 350	guint16 imid = 0;
 351
 352	if (g_xim_protocol_read_format(proto, stream, NULL, error, 2,
 353				       G_XIM_TYPE_WORD, &imid,
 354				       G_XIM_TYPE_PADDING, 2)) {
 355		retval = g_xim_protocol_closure_emit_signal(closure, proto,
 356							    imid);
 357	} else {
 358		/* better handling error */
 359		PROTO_ERROR_IM (XIM_CLOSE_REPLY, 0, imid);
 360	}
 361
 362	return retval;
 363}
 364
 365static gboolean
 366g_xim_protocol10_closure_XIM_REGISTER_TRIGGERKEYS(GXimProtocolClosure  *closure,
 367						  GXimProtocol         *proto,
 368						  GDataInputStream     *stream,
 369						  GError              **error,
 370						  gpointer              user_data)
 371{
 372	gboolean retval = FALSE;
 373	guint16 imid;
 374	GSList *onkeys = NULL, *offkeys = NULL;
 375
 376	if (g_xim_protocol_read_format(proto, stream, NULL, error, 4,
 377				       G_XIM_TYPE_WORD, &imid,
 378				       G_XIM_TYPE_PADDING, 2,
 379				       G_XIM_TYPE_MARKER_N_BYTES_4, G_XIM_TYPE_LIST_OF_HOTKEY_TRIGGER,
 380				       G_XIM_TYPE_LIST_OF_HOTKEY_TRIGGER, &onkeys)) {
 381		/* check the off-keys list separately.
 382		 * some IMs sends XIM_REGISTER_TRIGGERKEYS without
 383		 * the off-keys list.
 384		 */
 385		g_xim_protocol_read_format(proto, stream, NULL, error, 2,
 386					   G_XIM_TYPE_MARKER_N_BYTES_4, G_XIM_TYPE_LIST_OF_HOTKEY_TRIGGER,
 387					   G_XIM_TYPE_LIST_OF_HOTKEY_TRIGGER, &offkeys);
 388		if (*error) {
 389			g_xim_messages_warning(G_XIM_PROTOCOL_GET_IFACE (proto)->message,
 390					       "No off-keys received in XIM_REGISTER_TRIGGERKEYS:\n  %s",
 391					       (*error)->message);
 392			g_clear_error(error);
 393		}
 394		retval = g_xim_protocol_closure_emit_signal(closure, proto,
 395							    imid, onkeys, offkeys);
 396	}
 397	g_slist_foreach(onkeys, (GFunc)g_xim_hotkey_trigger_free, NULL);
 398	g_slist_foreach(offkeys, (GFunc)g_xim_hotkey_trigger_free, NULL);
 399	g_slist_free(onkeys);
 400	g_slist_free(offkeys);
 401
 402	return retval;
 403}
 404
 405static gboolean
 406g_xim_protocol10_closure_XIM_TRIGGER_NOTIFY(GXimProtocolClosure  *closure,
 407					    GXimProtocol         *proto,
 408					    GDataInputStream     *stream,
 409					    GError              **error,
 410					    gpointer              user_data)
 411{
 412	gboolean retval = FALSE;
 413	guint16 imid = 0, icid = 0;
 414	guint32 flag, index_, mask;
 415
 416	if (g_xim_protocol_read_format(proto, stream, NULL, error, 5,
 417				       G_XIM_TYPE_WORD, &imid,
 418				       G_XIM_TYPE_WORD, &icid,
 419				       G_XIM_TYPE_LONG, &flag,
 420				       G_XIM_TYPE_LONG, &index_,
 421				       G_XIM_TYPE_LONG, &mask)) {
 422		retval = g_xim_protocol_closure_emit_signal(closure, proto,
 423							    imid, icid, flag, index_, mask);
 424	} else {
 425		/* better handling error */
 426		PROTO_ERROR_IMIC (XIM_TRIGGER_NOTIFY, 0, imid, icid);
 427	}
 428
 429	return retval;
 430}
 431
 432static gboolean
 433g_xim_protocol10_closure_XIM_TRIGGER_NOTIFY_REPLY(GXimProtocolClosure  *closure,
 434						  GXimProtocol         *proto,
 435						  GDataInputStream     *stream,
 436						  GError              **error,
 437						  gpointer              user_data)
 438{
 439	gboolean retval = FALSE;
 440	guint16 imid = 0, icid = 0;
 441
 442	if (g_xim_protocol_read_format(proto, stream, NULL, error, 2,
 443				       G_XIM_TYPE_WORD, &imid,
 444				       G_XIM_TYPE_WORD, &icid)) {
 445		retval = g_xim_protocol_closure_emit_signal(closure, proto,
 446							    imid, icid);
 447	} else {
 448		/* better handling error */
 449		PROTO_ERROR_IMIC (XIM_TRIGGER_NOTIFY_REPLY, 0, imid, icid);
 450	}
 451
 452	return retval;
 453}
 454
 455static gboolean
 456g_xim_protocol10_closure_XIM_SET_EVENT_MASK(GXimProtocolClosure  *closure,
 457					    GXimProtocol         *proto,
 458					    GDataInputStream     *stream,
 459					    GError              **error,
 460					    gpointer              user_data)
 461{
 462	gboolean retval = FALSE;
 463	guint16 imid, icid;
 464	guint32 forward_mask, sync_mask;
 465
 466	if (g_xim_protocol_read_format(proto, stream, NULL, error, 4,
 467				       G_XIM_TYPE_WORD, &imid,
 468				       G_XIM_TYPE_WORD, &icid,
 469				       G_XIM_TYPE_LONG, &forward_mask,
 470				       G_XIM_TYPE_LONG, &sync_mask)) {
 471		retval = g_xim_protocol_closure_emit_signal(closure, proto,
 472							    imid, icid, forward_mask, sync_mask);
 473	}
 474
 475	return retval;
 476}
 477
 478static gboolean
 479g_xim_protocol10_closure_XIM_ENCODING_NEGOTIATION(GXimProtocolClosure  *closure,
 480						  GXimProtocol         *proto,
 481						  GDataInputStream     *stream,
 482						  GError              **error,
 483						  gpointer              user_data)
 484{
 485	gboolean retval = FALSE;
 486	GSList *list = NULL, *enclist = NULL;
 487	guint16 imid = 0;
 488
 489	if (g_xim_protocol_read_format(proto, stream, NULL, error, 7,
 490				       G_XIM_TYPE_WORD, &imid,
 491				       G_XIM_TYPE_MARKER_N_BYTES_2, G_XIM_TYPE_LIST_OF_STR,
 492				       G_XIM_TYPE_LIST_OF_STR, &list,
 493				       G_XIM_TYPE_AUTO_PADDING, 0,
 494				       G_XIM_TYPE_MARKER_N_BYTES_2, G_XIM_TYPE_LIST_OF_ENCODINGINFO,
 495				       G_XIM_TYPE_PADDING, 2,
 496				       G_XIM_TYPE_LIST_OF_ENCODINGINFO, &enclist)) {
 497		retval = g_xim_protocol_closure_emit_signal(closure, proto,
 498							    imid, list, enclist);
 499	} else {
 500		/* better handling error */
 501		PROTO_ERROR_IM (XIM_ENCODING_NEGOTIATION, 0, imid);
 502	}
 503
 504	g_slist_foreach(list,
 505			(GFunc)g_xim_str_free,
 506			NULL);
 507	g_slist_foreach(enclist,
 508			(GFunc)g_xim_encodinginfo_free,
 509			NULL);
 510	g_slist_free(list);
 511	g_slist_free(enclist);
 512
 513	return retval;
 514}
 515
 516static gboolean
 517g_xim_protocol10_closure_XIM_ENCODING_NEGOTIATION_REPLY(GXimProtocolClosure  *closure,
 518							GXimProtocol         *proto,
 519							GDataInputStream     *stream,
 520							GError              **error,
 521							gpointer              user_data)
 522{
 523	gboolean retval = FALSE;
 524	guint16 imid = 0, category;
 525	gint16 index_;
 526
 527	if (g_xim_protocol_read_format(proto, stream, NULL, error, 4,
 528				       G_XIM_TYPE_WORD, &imid,
 529				       G_XIM_TYPE_WORD, &category,
 530				       G_XIM_TYPE_WORD, &index_,
 531				       G_XIM_TYPE_PADDING, 2)) {
 532		retval = g_xim_protocol_closure_emit_signal(closure, proto,
 533							    imid, category, index_);
 534	} else {
 535		/* better handling error */
 536		PROTO_ERROR_IM (XIM_ENCODING_NEGOTIATION_REPLY, 0, imid);
 537	}
 538
 539	return retval;
 540}
 541
 542static gboolean
 543g_xim_protocol10_closure_XIM_QUERY_EXTENSION(GXimProtocolClosure  *closure,
 544					     GXimProtocol         *proto,
 545					     GDataInputStream     *stream,
 546					     GError              **error,
 547					     gpointer              user_data)
 548{
 549	gboolean retval = FALSE;
 550	GSList *list = NULL;
 551	guint16 imid = 0;
 552
 553	if (g_xim_protocol_read_format(proto, stream, NULL, error, 4,
 554				       G_XIM_TYPE_WORD, &imid,
 555				       G_XIM_TYPE_MARKER_N_BYTES_2, G_XIM_TYPE_LIST_OF_STR,
 556				       G_XIM_TYPE_LIST_OF_STR, &list,
 557				       G_XIM_TYPE_AUTO_PADDING, 0)) {
 558		retval = g_xim_protocol_closure_emit_signal(closure, proto,
 559							    imid, list);
 560	} else {
 561		/* better handling error */
 562		PROTO_ERROR_IM (XIM_QUERY_EXTENSION, 0, imid);
 563	}
 564
 565	g_slist_foreach(list,
 566			(GFunc)g_xim_str_free,
 567			NULL);
 568	g_slist_free(list);
 569
 570	return retval;
 571}
 572
 573static gboolean
 574g_xim_protocol10_closure_XIM_QUERY_EXTENSION_REPLY(GXimProtocolClosure  *closure,
 575						   GXimProtocol         *proto,
 576						   GDataInputStream     *stream,
 577						   GError              **error,
 578						   gpointer              user_data)
 579{
 580	gboolean retval = FALSE;
 581	GSList *list = NULL;
 582	guint16 imid;
 583
 584	if (!g_xim_protocol_read_format(proto, stream, NULL, error, 1,
 585					G_XIM_TYPE_WORD, &imid)) {
 586		/* XXX: There may be no way of recoverying from here */
 587		return FALSE;
 588	}
 589	g_xim_protocol_read_format(proto, stream, NULL, error, 2,
 590				   G_XIM_TYPE_MARKER_N_BYTES_2, G_XIM_TYPE_LIST_OF_EXT,
 591				   G_XIM_TYPE_LIST_OF_EXT, &list);
 592	if (*error) {
 593		/* deal with it as warning really, because we can
 594		 * recover it.
 595		 */
 596		g_xim_messages_warning(G_XIM_PROTOCOL_GET_IFACE (proto)->message,
 597				       "%s", (*error)->message);
 598		g_clear_error(error);
 599	}
 600	/* ignore an error. we could just send the null list */
 601	retval = g_xim_protocol_closure_emit_signal(closure, proto,
 602						    imid, list);
 603
 604	g_slist_foreach(list,
 605			(GFunc)g_xim_ext_free,
 606			NULL);
 607	g_slist_free(list);
 608
 609	return retval;
 610}
 611
 612static gboolean
 613g_xim_protocol10_closure_XIM_SET_IM_VALUES(GXimProtocolClosure  *closure,
 614					   GXimProtocol         *proto,
 615					   GDataInputStream     *stream,
 616					   GError              **error,
 617					   gpointer              user_data)
 618{
 619	gboolean retval = FALSE;
 620	guint16 imid = 0;
 621	GSList *list = NULL;
 622
 623	if (g_xim_protocol_read_format(proto, stream, NULL, error, 3,
 624				       G_XIM_TYPE_WORD, &imid,
 625				       G_XIM_TYPE_MARKER_N_BYTES_2, G_XIM_TYPE_LIST_OF_IMATTRIBUTE,
 626				       G_XIM_TYPE_LIST_OF_IMATTRIBUTE, &list)) {
 627		retval = g_xim_protocol_closure_emit_signal(closure, proto,
 628							    imid, list);
 629	} else {
 630		/* better handling error */
 631		PROTO_ERROR_IM (XIM_SET_IM_VALUES, 0, imid);
 632	}
 633
 634	g_slist_foreach(list,
 635			(GFunc)g_xim_attribute_free,
 636			NULL);
 637	g_slist_free(list);
 638
 639	return retval;
 640}
 641
 642static gboolean
 643g_xim_protocol10_closure_XIM_SET_IM_VALUES_REPLY(GXimProtocolClosure  *closure,
 644						 GXimProtocol         *proto,
 645						 GDataInputStream     *stream,
 646						 GError              **error,
 647						 gpointer              user_data)
 648{
 649	gboolean retval = FALSE;
 650	guint16 imid = 0;
 651
 652	if (g_xim_protocol_read_format(proto, stream, NULL, error, 2,
 653				       G_XIM_TYPE_WORD, &imid,
 654				       G_XIM_TYPE_PADDING, 2)) {
 655		retval = g_xim_protocol_closure_emit_signal(closure, proto,
 656							    imid);
 657	} else {
 658		/* better handling error */
 659		PROTO_ERROR_IM (XIM_SET_IM_VALUES_REPLY, 0, imid);
 660	}
 661
 662	return retval;
 663}
 664
 665static gboolean
 666g_xim_protocol10_closure_XIM_GET_IM_VALUES(GXimProtocolClosure  *closure,
 667					   GXimProtocol         *proto,
 668					   GDataInputStream     *stream,
 669					   GError              **error,
 670					   gpointer              user_data)
 671{
 672	gboolean retval = FALSE;
 673	GSList *list = NULL;
 674	guint16 imid = 0;
 675
 676	if (g_xim_protocol_read_format(proto, stream, NULL, error, 4,
 677				       G_XIM_TYPE_WORD, &imid,
 678				       G_XIM_TYPE_MARKER_N_BYTES_2, G_XIM_TYPE_LIST_OF_CARD16,
 679				       G_XIM_TYPE_LIST_OF_CARD16, &list,
 680				       G_XIM_TYPE_AUTO_PADDING, 0)) {
 681		retval = g_xim_protocol_closure_emit_signal(closure, proto,
 682							    imid, list);
 683	} else {
 684		/* better handling error */
 685		PROTO_ERROR_IM (XIM_GET_IM_VALUES, 0, imid);
 686	}
 687
 688	g_slist_free(list);
 689
 690	return retval;
 691}
 692
 693static gboolean
 694g_xim_protocol10_closure_XIM_GET_IM_VALUES_REPLY(GXimProtocolClosure  *closure,
 695						 GXimProtocol         *proto,
 696						 GDataInputStream     *stream,
 697						 GError              **error,
 698						 gpointer              user_data)
 699{
 700	gboolean retval = FALSE;
 701	GSList *list = NULL;
 702	guint16 imid;
 703	GError *err = NULL;
 704
 705	if (!g_xim_protocol_read_format(proto, stream, NULL, error, 1,
 706					G_XIM_TYPE_WORD, &imid)) {
 707		/* XXX: There may be no way of recovering from here. */
 708		return FALSE;
 709	}
 710	g_xim_protocol_read_format(proto, stream, NULL, &err, 2,
 711				   G_XIM_TYPE_MARKER_N_BYTES_2, G_XIM_TYPE_LIST_OF_IMATTRIBUTE,
 712				   G_XIM_TYPE_LIST_OF_IMATTRIBUTE, &list);
 713	if (err) {
 714		/* deal with it as warning really, because we can
 715		 * recover it.
 716		 */
 717		g_xim_messages_warning(G_XIM_PROTOCOL_GET_IFACE (proto)->message,
 718				       "%s", err->message);
 719		g_error_free(err);
 720	}
 721	/* ignore an error. we could just send the null list */
 722	retval = g_xim_protocol_closure_emit_signal(closure, proto,
 723						    imid, list);
 724
 725	g_slist_foreach(list, (GFunc)g_xim_attribute_free, NULL);
 726	g_slist_free(list);
 727
 728	return retval;
 729}
 730
 731static gboolean
 732g_xim_protocol10_closure_XIM_CREATE_IC(GXimProtocolClosure  *closure,
 733				       GXimProtocol         *proto,
 734				       GDataInputStream     *stream,
 735				       GError              **error,
 736				       gpointer              user_data)
 737{
 738	gboolean retval = FALSE;
 739	GSList *list = NULL;
 740	guint16 imid;
 741
 742	if (!g_xim_protocol_read_format(proto, stream, NULL, error, 1,
 743				       G_XIM_TYPE_WORD, &imid))
 744		return FALSE;
 745
 746	g_xim_protocol_read_format(proto, stream, NULL, error, 2,
 747				   G_XIM_TYPE_MARKER_N_BYTES_2, G_XIM_TYPE_LIST_OF_ICATTRIBUTE,
 748				   G_XIM_TYPE_LIST_OF_ICATTRIBUTE, &list);
 749	/* deal with all of errors as warnings to give aid to
 750	 * the attributes retrieved successfully.
 751	 */
 752	/* XXX: or should we just send back the error? */
 753	if (*error) {
 754		g_xim_messages_warning(G_XIM_PROTOCOL_GET_IFACE (proto)->message,
 755				       "%s", (*error)->message);
 756		g_clear_error(error);
 757	}
 758	retval = g_xim_protocol_closure_emit_signal(closure, proto,
 759						    imid, list);
 760
 761	g_slist_foreach(list, (GFunc)g_xim_attribute_free, NULL);
 762	g_slist_free(list);
 763
 764	return retval;
 765}
 766
 767static gboolean
 768g_xim_protocol10_closure_XIM_CREATE_IC_REPLY(GXimProtocolClosure  *closure,
 769					     GXimProtocol         *proto,
 770					     GDataInputStream     *stream,
 771					     GError              **error,
 772					     gpointer              user_data)
 773{
 774	gboolean retval = FALSE;
 775	guint16 imid = 0, icid = 0;
 776
 777	if (g_xim_protocol_read_format(proto, stream, NULL, error, 2,
 778				       G_XIM_TYPE_WORD, &imid,
 779				       G_XIM_TYPE_WORD, &icid)) {
 780		retval = g_xim_protocol_closure_emit_signal(closure, proto,
 781							    imid, icid);
 782	} else {
 783		/* better handling error */
 784		PROTO_ERROR_IMIC (XIM_CREATE_IC_REPLY, 0, imid, icid);
 785	}
 786
 787	return retval;
 788}
 789
 790static gboolean
 791g_xim_protocol10_closure_XIM_DESTROY_IC(GXimProtocolClosure  *closure,
 792					GXimProtocol         *proto,
 793					GDataInputStream     *stream,
 794					GError              **error,
 795					gpointer              user_data)
 796{
 797	gboolean retval = FALSE;
 798	guint16 imid = 0, icid = 0;
 799
 800	if (g_xim_protocol_read_format(proto, stream, NULL, error, 2,
 801				       G_XIM_TYPE_WORD, &imid,
 802				       G_XIM_TYPE_WORD, &icid)) {
 803		retval = g_xim_protocol_closure_emit_signal(closure, proto,
 804							    imid, icid);
 805	} else {
 806		/* better handling error */
 807		PROTO_ERROR_IMIC (XIM_DESTROY_IC, 0, imid, icid);
 808	}
 809
 810	return retval;
 811}
 812
 813static gboolean
 814g_xim_protocol10_closure_XIM_DESTROY_IC_REPLY(GXimProtocolClosure  *closure,
 815					      GXimProtocol         *proto,
 816					      GDataInputStream     *stream,
 817					      GError              **error,
 818					      gpointer              user_data)
 819{
 820	gboolean retval = FALSE;
 821	guint16 imid = 0, icid = 0;
 822
 823	if (g_xim_protocol_read_format(proto, stream, NULL, error, 2,
 824				       G_XIM_TYPE_WORD, &imid,
 825				       G_XIM_TYPE_WORD, &icid)) {
 826		retval = g_xim_protocol_closure_emit_signal(closure, proto,
 827							    imid, icid);
 828	} else {
 829		/* better handling error */
 830		PROTO_ERROR_IMIC (XIM_DESTROY_IC_REPLY, 0, imid, icid);
 831	}
 832
 833	return retval;
 834}
 835
 836static gboolean
 837g_xim_protocol10_closure_XIM_SET_IC_VALUES(GXimProtocolClosure  *closure,
 838					   GXimProtocol         *proto,
 839					   GDataInputStream     *stream,
 840					   GError              **error,
 841					   gpointer              user_data)
 842{
 843	gboolean retval = FALSE;
 844	guint16 imid = 0, icid = 0;
 845	GSList *list = NULL;
 846
 847	if (g_xim_protocol_read_format(proto, stream, NULL, error, 5,
 848				       G_XIM_TYPE_WORD, &imid,
 849				       G_XIM_TYPE_WORD, &icid,
 850				       G_XIM_TYPE_MARKER_N_BYTES_2, G_XIM_TYPE_LIST_OF_ICATTRIBUTE,
 851				       G_XIM_TYPE_PADDING, 2,
 852				       G_XIM_TYPE_LIST_OF_ICATTRIBUTE, &list)) {
 853		retval = g_xim_protocol_closure_emit_signal(closure, proto,
 854							    imid, icid, list);
 855	} else {
 856		/* better handling error */
 857		PROTO_ERROR_IMIC (XIM_SET_IC_VALUES, 0, imid, icid);
 858	}
 859
 860	g_slist_foreach(list,
 861			(GFunc)g_xim_attribute_free,
 862			NULL);
 863	g_slist_free(list);
 864
 865	return retval;
 866}
 867
 868static gboolean
 869g_xim_protocol10_closure_XIM_SET_IC_VALUES_REPLY(GXimProtocolClosure  *closure,
 870						 GXimProtocol         *proto,
 871						 GDataInputStream     *stream,
 872						 GError              **error,
 873						 gpointer              user_data)
 874{
 875	gboolean retval = FALSE;
 876	guint16 imid = 0, icid = 0;
 877
 878	if (g_xim_protocol_read_format(proto, stream, NULL, error, 2,
 879				       G_XIM_TYPE_WORD, &imid,
 880				       G_XIM_TYPE_WORD, &icid)) {
 881		retval = g_xim_protocol_closure_emit_signal(closure, proto,
 882							    imid, icid);
 883	} else {
 884		/* better handling error */
 885		PROTO_ERROR_IMIC (XIM_SET_IC_VALUES_REPLY, 0, imid, icid);
 886	}
 887
 888	return retval;
 889}
 890
 891static gboolean
 892g_xim_protocol10_closure_XIM_GET_IC_VALUES(GXimProtocolClosure  *closure,
 893					   GXimProtocol         *proto,
 894					   GDataInputStream     *stream,
 895					   GError              **error,
 896					   gpointer              user_data)
 897{
 898	gboolean retval = FALSE;
 899	guint16 imid = 0, icid = 0;
 900	GSList *list = NULL;
 901
 902	if (g_xim_protocol_read_format(proto, stream, NULL, error, 5,
 903				       G_XIM_TYPE_WORD, &imid,
 904				       G_XIM_TYPE_WORD, &icid,
 905				       G_XIM_TYPE_MARKER_N_BYTES_2, G_XIM_TYPE_LIST_OF_CARD16,
 906				       G_XIM_TYPE_LIST_OF_CARD16, &list,
 907				       G_XIM_TYPE_AUTO_PADDING, 2)) {
 908		retval = g_xim_protocol_closure_emit_signal(closure, proto,
 909							    imid, icid, list);
 910	} else {
 911		/* better handling error */
 912		PROTO_ERROR_IMIC (XIM_GET_IC_VALUES, 0, imid, icid);
 913	}
 914
 915	g_slist_free(list);
 916
 917	return retval;
 918}
 919
 920static gboolean
 921g_xim_protocol10_closure_XIM_GET_IC_VALUES_REPLY(GXimProtocolClosure  *closure,
 922						 GXimProtocol         *proto,
 923						 GDataInputStream     *stream,
 924						 GError              **error,
 925						 gpointer              user_data)
 926{
 927	gboolean retval = FALSE;
 928	guint16 imid = 0, icid = 0;
 929	GSList *list = NULL;
 930
 931	if (g_xim_protocol_read_format(proto, stream, NULL, error, 5,
 932				       G_XIM_TYPE_WORD, &imid,
 933				       G_XIM_TYPE_WORD, &icid,
 934				       G_XIM_TYPE_MARKER_N_BYTES_2, G_XIM_TYPE_LIST_OF_ICATTRIBUTE,
 935				       G_XIM_TYPE_PADDING, 2,
 936				       G_XIM_TYPE_LIST_OF_ICATTRIBUTE, &list)) {
 937		retval = g_xim_protocol_closure_emit_signal(closure, proto,
 938							    imid, icid, list);
 939	} else {
 940		/* better handling error */
 941		PROTO_ERROR_IMIC (XIM_GET_IC_VALUES_REPLY, 0, imid, icid);
 942	}
 943
 944	g_slist_foreach(list, (GFunc)g_xim_attribute_free, NULL);
 945	g_slist_free(list);
 946
 947	return retval;
 948}
 949
 950static gboolean
 951g_xim_protocol10_closure_XIM_SET_IC_FOCUS(GXimProtocolClosure  *closure,
 952					  GXimProtocol         *proto,
 953					  GDataInputStream     *stream,
 954					  GError              **error,
 955					  gpointer              user_data)
 956{
 957	gboolean retval = FALSE;
 958	guint16 imid, icid;
 959
 960	if (g_xim_protocol_read_format(proto, stream, NULL, error, 2,
 961				       G_XIM_TYPE_WORD, &imid,
 962				       G_XIM_TYPE_WORD, &icid)) {
 963		retval = g_xim_protocol_closure_emit_signal(closure, proto,
 964							    imid, icid);
 965	}
 966
 967	return retval;
 968}
 969
 970static gboolean
 971g_xim_protocol10_closure_XIM_UNSET_IC_FOCUS(GXimProtocolClosure  *closure,
 972					    GXimProtocol         *proto,
 973					    GDataInputStream     *stream,
 974					    GError              **error,
 975					    gpointer              user_data)
 976{
 977	gboolean retval = FALSE;
 978	guint16 imid, icid;
 979
 980	if (g_xim_protocol_read_format(proto, stream, NULL, error, 2,
 981				       G_XIM_TYPE_WORD, &imid,
 982				       G_XIM_TYPE_WORD, &icid)) {
 983		retval = g_xim_protocol_closure_emit_signal(closure, proto,
 984							    imid, icid);
 985	}
 986
 987	return retval;
 988}
 989
 990static gboolean
 991g_xim_protocol10_closure_XIM_FORWARD_EVENT(GXimProtocolClosure  *closure,
 992					   GXimProtocol         *proto,
 993					   GDataInputStream     *stream,
 994					   GError              **error,
 995					   gpointer              user_data)
 996{
 997	gboolean retval = FALSE;
 998	guint16 imid = 0, icid = 0, flag = 0;
 999	GdkEvent *event = NULL;
1000
1001	if (g_xim_protocol_read_format(proto, stream, NULL, error, 4,
1002				       G_XIM_TYPE_WORD, &imid,
1003				       G_XIM_TYPE_WORD, &icid,
1004				       G_XIM_TYPE_WORD, &flag,
1005				       G_XIM_TYPE_GDKEVENT, &event)) {
1006		retval = g_xim_protocol_closure_emit_signal(closure, proto,
1007							    imid, icid, flag, event);
1008	} else {
1009		/* better handling error */
1010		if (flag & G_XIM_Event_Synchronous)
1011			g_xim_connection_cmd_sync_reply(G_XIM_CONNECTION (proto), imid, icid);
1012
1013		retval = g_xim_connection_cmd_forward_event(G_XIM_CONNECTION (proto), imid, icid, flag & ~G_XIM_Event_Synchronous, event);
1014	}
1015	if (event)
1016		gdk_event_free(event);
1017
1018	return retval;
1019}
1020
1021static gboolean
1022g_xim_protocol10_closure_XIM_SYNC(GXimProtocolClosure  *closure,
1023				  GXimProtocol         *proto,
1024				  GDataInputStream     *stream,
1025				  GError              **error,
1026				  gpointer              user_data)
1027{
1028	gboolean retval = FALSE;
1029	guint16 imid = 0, icid = 0;
1030
1031	if (g_xim_protocol_read_format(proto, stream, NULL, error, 2,
1032				       G_XIM_TYPE_WORD, &imid,
1033				       G_XIM_TYPE_WORD, &icid)) {
1034		retval = g_xim_protocol_closure_emit_signal(closure, proto,
1035							    imid, icid);
1036	} else {
1037		/* better handling error */
1038		PROTO_ERROR_IMIC (XIM_SYNC, 0, imid, icid);
1039	}
1040
1041	return retval;
1042}
1043
1044static gboolean
1045g_xim_protocol10_closure_XIM_SYNC_REPLY(GXimProtocolClosure  *closure,
1046					GXimProtocol         *proto,
1047					GDataInputStream     *stream,
1048					GError              **error,
1049					gpointer              user_data)
1050{
1051	gboolean retval = FALSE;
1052	guint16 imid, icid;
1053
1054	if (g_xim_protocol_read_format(proto, stream, NULL, error, 2,
1055				       G_XIM_TYPE_WORD, &imid,
1056				       G_XIM_TYPE_WORD, &icid)) {
1057		retval = g_xim_protocol_closure_emit_signal(closure, proto,
1058							    imid, icid);
1059	}
1060
1061	return retval;
1062}
1063
1064static gboolean
1065g_xim_protocol10_closure_XIM_COMMIT(GXimProtocolClosure  *closure,
1066				    GXimProtocol         *proto,
1067				    GDataInputStream     *stream,
1068				    GError              **error,
1069				    gpointer              user_data)
1070{
1071	gboolean retval = FALSE;
1072	guint16 imid = 0, icid = 0, flag = 0;
1073	gint padding = 0;
1074	guint32 keysym = GDK_KEY_VoidSymbol;
1075	GString *string = NULL;
1076
1077	if (!g_xim_protocol_read_format(proto, stream, NULL, error, 3,
1078					G_XIM_TYPE_WORD, &imid,
1079					G_XIM_TYPE_WORD, &icid,
1080					G_XIM_TYPE_WORD, &flag))
1081		goto fail;
1082
1083	if (flag & G_XIM_XLookupKeySym) {
1084		if (!g_xim_protocol_read_format(proto, stream, NULL, error, 2,
1085						G_XIM_TYPE_PADDING, 2,
1086						G_XIM_TYPE_LONG, &keysym))
1087			goto fail;
1088		padding += 2;
1089	}
1090	if (flag & G_XIM_XLookupChars) {
1091		if (!g_xim_protocol_read_format(proto, stream, NULL, error, 2,
1092						G_XIM_TYPE_GSTRING, &string,
1093						G_XIM_TYPE_AUTO_PADDING, padding))
1094			goto fail;
1095	}
1096	retval = g_xim_protocol_closure_emit_signal(closure, proto,
1097						    imid, icid, flag, keysym, string);
1098	if (string)
1099		g_string_free(string, TRUE);
1100
1101	return retval;
1102  fail:
1103	if (string)
1104		g_string_free(string, TRUE);
1105
1106	if (flag & G_XIM_XLookupSynchronous)
1107		return g_xim_connection_cmd_sync_reply(G_XIM_CONNECTION (proto), imid, icid);
1108
1109	return FALSE;
1110}
1111
1112static gboolean
1113g_xim_protocol10_closure_XIM_RESET_IC(GXimProtocolClosure  *closure,
1114				      GXimProtocol         *proto,
1115				      GDataInputStream     *stream,
1116				      GError              **error,
1117				      gpointer              user_data)
1118{
1119	gboolean retval = FALSE;
1120	guint16 imid = 0, icid = 0;
1121
1122	if (g_xim_protocol_read_format(proto, stream, NULL, error, 2,
1123				       G_XIM_TYPE_WORD, &imid,
1124				       G_XIM_TYPE_WORD, &icid)) {
1125		retval = g_xim_protocol_closure_emit_signal(closure, proto,
1126							    imid, icid);
1127	} else {
1128		/* better handling error */
1129		PROTO_ERROR_IMIC (XIM_RESET_IC, 0, imid, icid);
1130	}
1131
1132	return retval;
1133}
1134
1135static gboolean
1136g_xim_protocol10_closure_XIM_RESET_IC_REPLY(GXimProtocolClosure  *closure,
1137					    GXimProtocol         *proto,
1138					    GDataInputStream     *stream,
1139					    GError              **error,
1140					    gpointer              user_data)
1141{
1142	gboolean retval = FALSE;
1143	guint16 imid = 0, icid = 0;
1144	GString *string = NULL;
1145
1146	if (g_xim_protocol_read_format(proto, stream, NULL, error, 5,
1147				       G_XIM_TYPE_WORD, &imid,
1148				       G_XIM_TYPE_WORD, &icid,
1149				       G_XIM_TYPE_MARKER_N_BYTES_2, G_XIM_TYPE_LIST_OF_BYTE,
1150				       G_XIM_TYPE_LIST_OF_BYTE, &string,
1151				       G_XIM_TYPE_AUTO_PADDING, 2)) {
1152		retval = g_xim_protocol_closure_emit_signal(closure, proto,
1153							    imid, icid, string);
1154	} else {
1155		/* better handling error */
1156		PROTO_ERROR_IMIC (XIM_RESET_IC_REPLY, 0, imid, icid);
1157	}
1158	g_string_free(string, TRUE);
1159
1160	return retval;
1161}
1162
1163static gboolean
1164g_xim_protocol10_closure_XIM_GEOMETRY(GXimProtocolClosure  *closure,
1165				      GXimProtocol         *proto,
1166				      GDataInputStream     *stream,
1167				      GError              **error,
1168				      gpointer              user_data)
1169{
1170	gboolean retval = FALSE;
1171	guint16 imid, icid;
1172
1173	if (g_xim_protocol_read_format(proto, stream, NULL, error, 2,
1174				       G_XIM_TYPE_WORD, &imid,
1175				       G_XIM_TYPE_WORD, &icid)) {
1176		retval = g_xim_protocol_closure_emit_signal(closure, proto,
1177							    imid, icid);
1178	}
1179
1180	return retval;
1181}
1182
1183static gboolean
1184g_xim_protocol10_closure_XIM_STR_CONVERSION(GXimProtocolClosure  *closure,
1185					    GXimProtocol         *proto,
1186					    GDataInputStream     *stream,
1187					    GError              **error,
1188					    gpointer              user_data)
1189{
1190	gboolean retval = FALSE;
1191	guint16 imid = 0, icid = 0;
1192
1193	/* XXX */
1194	g_xim_protocol_read_format(proto, stream, NULL, error, 2,
1195				   G_XIM_TYPE_WORD, &imid,
1196				   G_XIM_TYPE_WORD, &icid);
1197	PROTO_ERROR_IMIC (XIM_STR_CONVERSION, 0, imid, icid);
1198
1199	return retval;
1200}
1201
1202static gboolean
1203g_xim_protocol10_closure_XIM_STR_CONVERSION_REPLY(GXimProtocolClosure  *closure,
1204						  GXimProtocol         *proto,
1205						  GDataInputStream     *stream,
1206						  GError              **error,
1207						  gpointer              user_data)
1208{
1209	gboolean retval = FALSE;
1210
1211	/* XXX */
1212	return retval;
1213}
1214
1215static gboolean
1216g_xim_protocol10_closure_XIM_PREEDIT_START(GXimProtocolClosure  *closure,
1217					   GXimProtocol         *proto,
1218					   GDataInputStream     *stream,
1219					   GError              **error,
1220					   gpointer              user_data)
1221{
1222	gboolean retval = FALSE;
1223	guint16 imid = 0, icid = 0;
1224
1225	if (g_xim_protocol_read_format(proto, stream, NULL, error, 2,
1226				       G_XIM_TYPE_WORD, &imid,
1227				       G_XIM_TYPE_WORD, &icid)) {
1228		retval = g_xim_protocol_closure_emit_signal(closure, proto,
1229							    imid, icid);
1230	} else {
1231		/* better handling error */
1232		/* XXX: should we send back PREEDIT_START_REPLY with an error in the return value? */
1233		PROTO_ERROR_IMIC (XIM_PREEDIT_START, 0, imid, icid);
1234	}
1235
1236	return retval;
1237}
1238
1239static gboolean
1240g_xim_protocol10_closure_XIM_PREEDIT_START_REPLY(GXimProtocolClosure  *closure,
1241						 GXimProtocol         *proto,
1242						 GDataInputStream     *stream,
1243						 GError              **error,
1244						 gpointer              user_data)
1245{
1246	gboolean retval = FALSE;
1247	guint16 imid, icid;
1248	gint32 ret;
1249
1250	if (g_xim_protocol_read_format(proto, stream, NULL, error, 3,
1251				       G_XIM_TYPE_WORD, &imid,
1252				       G_XIM_TYPE_WORD, &icid,
1253				       G_XIM_TYPE_LONG, &ret)) {
1254		retval = g_xim_protocol_closure_emit_signal(closure, proto,
1255							    imid, icid, ret);
1256	}
1257
1258	return retval;
1259}
1260
1261static gboolean
1262g_xim_protocol10_closure_XIM_PREEDIT_DRAW(GXimProtocolClosure  *closure,
1263					  GXimProtocol         *proto,
1264					  GDataInputStream     *stream,
1265					  GError              **error,
1266					  gpointer              user_data)
1267{
1268	gboolean retval = FALSE;
1269	guint16 imid, icid;
1270	GXimPreeditDraw *draw;
1271
1272	if (g_xim_protocol_read_format(proto, stream, NULL, error, 3,
1273				       G_XIM_TYPE_WORD, &imid,
1274				       G_XIM_TYPE_WORD, &icid,
1275				       G_XIM_TYPE_PREEDIT_DRAW, &draw)) {
1276		retval = g_xim_protocol_closure_emit_signal(closure, proto,
1277							    imid, icid, draw);
1278	}
1279	g_xim_preedit_draw_free(draw);
1280
1281	return retval;
1282}
1283
1284static gboolean
1285g_xim_protocol10_closure_XIM_PREEDIT_CARET(GXimProtocolClosure  *closure,
1286					   GXimProtocol         *proto,
1287					   GDataInputStream     *stream,
1288					   GError              **error,
1289					   gpointer              user_data)
1290{
1291	gboolean retval = FALSE;
1292	guint16 imid = 0, icid = 0;
1293	GXimPreeditCaret *caret;
1294
1295	if (g_xim_protocol_read_format(proto, stream, NULL, error, 3,
1296				       G_XIM_TYPE_WORD, &imid,
1297				       G_XIM_TYPE_WORD, &icid,
1298				       G_XIM_TYPE_PREEDIT_CARET, &caret)) {
1299		retval = g_xim_protocol_closure_emit_signal(closure, proto,
1300							    imid, icid, caret);
1301	} else {
1302		/* better handling error */
1303		/* XXX: should we send back PREEDIT_CARET_REPLY with an error in the return value? */
1304		PROTO_ERROR_IMIC (XIM_PREEDIT_CARET, 0, imid, icid);
1305	}
1306	g_xim_preedit_caret_free(caret);
1307
1308	return retval;
1309}
1310
1311static gboolean
1312g_xim_protocol10_closure_XIM_PREEDIT_CARET_REPLY(GXimProtocolClosure  *closure,
1313						 GXimProtocol         *proto,
1314						 GDataInputStream     *stream,
1315						 GError              **error,
1316						 gpointer              user_data)
1317{
1318	gboolean retval = FALSE;
1319	guint16 imid, icid;
1320	guint32 position;
1321
1322	if (g_xim_protocol_read_format(proto, stream, NULL, error, 3,
1323				       G_XIM_TYPE_WORD, &imid,
1324				       G_XIM_TYPE_WORD, &icid,
1325				       G_XIM_TYPE_LONG, &position)) {
1326		retval = g_xim_protocol_closure_emit_signal(closure, proto,
1327							    imid, icid, position);
1328	}
1329
1330	/* XXX */
1331	return retval;
1332}
1333
1334static gboolean
1335g_xim_protocol10_closure_XIM_PREEDIT_DONE(GXimProtocolClosure  *closure,
1336					  GXimProtocol         *proto,
1337					  GDataInputStream     *stream,
1338					  GError              **error,
1339					  gpointer              user_data)
1340{
1341	gboolean retval = FALSE;
1342	guint16 imid, icid;
1343
1344	if (g_xim_protocol_read_format(proto, stream, NULL, error, 2,
1345				       G_XIM_TYPE_WORD, &imid,
1346				       G_XIM_TYPE_WORD, &icid)) {
1347		retval = g_xim_protocol_closure_emit_signal(closure, proto,
1348							    imid, icid);
1349	}
1350
1351	return retval;
1352}
1353
1354static gboolean
1355g_xim_protocol10_closure_XIM_STATUS_START(GXimProtocolClosure  *closure,
1356					  GXimProtocol         *proto,
1357					  GDataInputStream     *stream,
1358					  GError              **error,
1359					  gpointer              user_data)
1360{
1361	gboolean retval = FALSE;
1362	guint16 imid, icid;
1363
1364	if (g_xim_protocol_read_format(proto, stream, NULL, error, 2,
1365				       G_XIM_TYPE_WORD, &imid,
1366				       G_XIM_TYPE_WORD, &icid)) {
1367		retval = g_xim_protocol_closure_emit_signal(closure, proto,
1368							    imid, icid);
1369	}
1370
1371	return retval;
1372}
1373
1374static gboolean
1375g_xim_protocol10_closure_XIM_STATUS_DRAW(GXimProtocolClosure  *closure,
1376					 GXimProtocol         *proto,
1377					 GDataInputStream     *stream,
1378					 GError              **error,
1379					 gpointer              user_data)
1380{
1381	gboolean retval = FALSE;
1382	guint16 imid, icid;
1383	GXimStatusDraw *draw;
1384
1385	if (g_xim_protocol_read_format(proto, stream, NULL, error, 3,
1386				       G_XIM_TYPE_WORD, &imid,
1387				       G_XIM_TYPE_WORD, &icid,
1388				       G_XIM_TYPE_STATUS_DRAW, &draw)) {
1389		retval = g_xim_protocol_closure_emit_signal(closure, proto,
1390							    imid, icid, draw);
1391	}
1392	g_xim_status_draw_free(draw);
1393
1394	return retval;
1395}
1396
1397static gboolean
1398g_xim_protocol10_closure_XIM_STATUS_DONE(GXimProtocolClosure  *closure,
1399					 GXimProtocol         *proto,
1400					 GDataInputStream     *stream,
1401					 GError              **error,
1402					 gpointer              user_data)
1403{
1404	gboolean retval = FALSE;
1405	guint16 imid, icid;
1406
1407	if (g_xim_protocol_read_format(proto, stream, NULL, error, 2,
1408				       G_XIM_TYPE_WORD, &imid,
1409				       G_XIM_TYPE_WORD, &icid)) {
1410		retval = g_xim_protocol_closure_emit_signal(closure, proto,
1411							    imid, icid);
1412	}
1413
1414	return retval;
1415}
1416
1417static gboolean
1418g_xim_protocol10_closure_XIM_PREEDITSTATE(GXimProtocolClosure  *closure,
1419					  GXimProtocol         *proto,
1420					  GDataInputStream     *stream,
1421					  GError              **error,
1422					  gpointer              user_data)
1423{
1424	gboolean retval = FALSE;
1425
1426	/* XXX */
1427	return retval;
1428}
1429
1430static void
1431gxim_marshal_FIXME(GClosure     *closure,
1432		   GValue       *return_value,
1433		   guint         n_param_values,
1434		   const GValue *param_values,
1435		   gpointer      invocation_hint,
1436		   gpointer      marshal_data)
1437{
1438	g_warning("FIXME");
1439}
1440
1441static void
1442g_xim_protocol10_closure_signal_no_impl(GXimProtocol  *proto,
1443					const gchar   *func,
1444					GXimErrorMask  flag,
1445					guint16        imid,
1446					guint16        icid)
1447{
1448	GXimProtocolIface *iface;
1449	static const gchar message[] = "Not yet implemented or any errors occurred";
1450	static size_t len = 0;
1451
1452	iface = G_XIM_PROTOCOL_GET_IFACE (proto);
1453	if (len == 0)
1454		len = strlen(message);
1455
1456	g_xim_messages_bug(iface->message, "No real implementation of `%s' or any errors occurred.", func);
1457	g_xim_connection_cmd_error(G_XIM_CONNECTION (proto), imid, icid, flag,
1458				   G_XIM_ERR_BadSomething, 0, message);
1459}
1460
1461static gboolean
1462g_xim_protocol10_closure_signal_XIM_CONNECT(GXimProtocol *proto,
1463					    guint16       major_version,
1464					    guint16       minor_version,
1465					    const GSList *list)
1466{
1467	return g_xim_connection_cmd_auth_ng(G_XIM_CONNECTION (proto));
1468}
1469
1470static gboolean
1471g_xim_protocol10_closure_signal_XIM_CONNECT_REPLY(GXimProtocol *proto,
1472						  guint16       major_version,
1473						  guint16       minor_version)
1474{
1475	MSG_NOIMPL(XIM_CONNECT_REPLY);
1476
1477	return TRUE;
1478}
1479
1480static gboolean
1481g_xim_protocol10_closure_signal_XIM_DISCONNECT(GXimProtocol *proto)
1482{
1483	SIG_NOIMPL(XIM_DISCONNECT);
1484
1485	return TRUE;
1486}
1487
1488static gboolean
1489g_xim_protocol10_closure_signal_XIM_DISCONNECT_REPLY(GXimProtocol *proto)
1490{
1491	MSG_NOIMPL(XIM_DISCONNECT_REPLY);
1492
1493	return TRUE;
1494}
1495
1496static gboolean
1497g_xim_protocol10_closure_signal_XIM_AUTH_REQUIRED(GXimProtocol *proto,
1498						  const gchar  *auth_data,
1499						  gsize         length)
1500{
1501	return g_xim_connection_cmd_auth_ng(G_XIM_CONNECTION (proto));
1502}
1503
1504static gboolean
1505g_xim_protocol10_closure_signal_XIM_AUTH_REPLY(GXimProtocol *proto,
1506					       const gchar  *auth_data,
1507					       gsize         length)
1508{
1509	return g_xim_connection_cmd_auth_ng(G_XIM_CONNECTION (proto));
1510}
1511
1512static gboolean
1513g_xim_protocol10_closure_signal_XIM_AUTH_NEXT(GXimProtocol *proto,
1514					      const gchar  *auth_data,
1515					      gsize         length)
1516{
1517	return g_xim_connection_cmd_auth_ng(G_XIM_CONNECTION (proto));
1518}
1519
1520static gboolean
1521g_xim_protocol10_closure_signal_XIM_AUTH_SETUP(GXimProtocol *proto,
1522					       const GSList *list)
1523{
1524	return g_xim_connection_cmd_auth_ng(G_XIM_CONNECTION (proto));
1525}
1526
1527static gboolean
1528g_xim_protocol10_closure_signal_XIM_AUTH_NG(GXimProtocol *proto)
1529{
1530	MSG_NOIMPL(XIM_AUTH_NG);
1531
1532	return TRUE;
1533}
1534
1535static gboolean
1536g_xim_protocol10_closure_signal_XIM_ERROR(GXimProtocol  *proto,
1537					  guint16        imid,
1538					  guint16        icid,
1539					  GXimErrorMask  flag,
1540					  GXimErrorCode  error_code,
1541					  guint16        detail,
1542					  const gchar   *error_message)
1543{
1544	gchar *simid, *sicid;
1545
1546	if (flag & G_XIM_EMASK_VALID_IMID)
1547		simid = g_strdup_printf("imid: %d, ", imid);
1548	else
1549		simid = g_strdup("");
1550	if (flag & G_XIM_EMASK_VALID_ICID)
1551		sicid = g_strdup_printf("icid: %d, ", icid);
1552	else
1553		sicid = g_strdup("");
1554	g_xim_messages_error(G_XIM_PROTOCOL_GET_IFACE (proto)->message,
1555			     "Received an error: %s%s error_code: %d, detail: %d, message: %s",
1556			     simid, sicid, error_code, detail, error_message);
1557	g_free(simid);
1558	g_free(sicid);
1559
1560	return TRUE;
1561}
1562
1563static gboolean
1564g_xim_protocol10_closure_signal_XIM_OPEN(GXimProtocol  *proto,
1565					 const GXimStr *locale)
1566{
1567	SIG_NOIMPL(XIM_OPEN);
1568
1569	return TRUE;
1570}
1571
1572static gboolean
1573g_xim_protocol10_closure_signal_XIM_OPEN_REPLY(GXimProtocol *proto,
1574					       guint16       imid,
1575					       GXimIMAttr   *imattr,
1576					       GXimICAttr   *icattr)
1577{
1578	MSG_NOIMPL_IM(XIM_OPEN_REPLY, imid);
1579
1580	return TRUE;
1581}
1582
1583static gboolean
1584g_xim_protocol10_closure_signal_XIM_CLOSE(GXimProtocol *proto,
1585					  guint16       imid)
1586{
1587	SIG_NOIMPL_IM(XIM_CLOSE, imid);
1588
1589	return TRUE;
1590}
1591
1592static gboolean
1593g_xim_protocol10_closure_signal_XIM_CLOSE_REPLY(GXimProtocol *proto,
1594						guint16       imid)
1595{
1596	MSG_NOIMPL_IM(XIM_CLOSE_REPLY, imid);
1597
1598	return TRUE;
1599}
1600
1601static gboolean
1602g_xim_protocol10_closure_signal_XIM_REGISTER_TRIGGERKEYS(GXimProtocol *proto,
1603							 guint16       imid,
1604							 const GSList *onkeys,
1605							 const GSList *offkeys)
1606{
1607	MSG_NOIMPL_IM(XIM_REGISTER_TRIGGERKEYS, imid);
1608
1609	return TRUE;
1610}
1611
1612static gboolean
1613g_xim_protocol10_closure_signal_XIM_TRIGGER_NOTIFY(GXimProtocol *proto,
1614						   guint16       imid,
1615						   guint16       icid,
1616						   guint32       flag,
1617						   guint32       index_,
1618						   guint32       mask)
1619{
1620	SIG_NOIMPL_IMIC(XIM_TRIGGER_NOTIFY, imid, icid);
1621
1622	return TRUE;
1623}
1624
1625static gboolean
1626g_xim_protocol10_closure_signal_XIM_TRIGGER_NOTIFY_REPLY(GXimProtocol *proto,
1627							 guint16       imid,
1628							 guint16       icid)
1629{
1630	MSG_NOIMPL_IMIC(XIM_TRIGGER_NOTIFY_REPLY, imid, icid);
1631
1632	return TRUE;
1633}
1634
1635static gboolean
1636g_xim_protocol10_closure_signal_XIM_SET_EVENT_MASK(GXimProtocol *proto,
1637						   guint16       imid,
1638						   guint16       icid,
1639						   guint32       forward_event_mask,
1640						   guint32       synchronous_event_mask)
1641{
1642	MSG_NOIMPL_IMIC(XIM_SET_EVENT_MASK, imid, icid);
1643
1644	return TRUE;
1645}
1646
1647static gboolean
1648g_xim_protocol10_closure_signal_XIM_ENCODING_NEGOTIATION(GXimProtocol *proto,
1649							 guint16       imid,
1650							 const GSList *encodings,
1651							 const GSList *details)
1652{
1653	SIG_NOIMPL_IM(XIM_ENCODING_NEGOTIATION, imid);
1654
1655	return TRUE;
1656}
1657
1658static gboolean
1659g_xim_protocol10_closure_signal_XIM_ENCODING_NEGOTIATION_REPLY(GXimProtocol *proto,
1660							       guint16       imid,
1661							       guint16       category,
1662							       gint16        index_)
1663{
1664	MSG_NOIMPL_IM(XIM_ENCODING_NEGOTIATION_REPLY, imid);
1665
1666	return TRUE;
1667}
1668
1669static gboolean
1670g_xim_protocol10_closure_signal_XIM_QUERY_EXTENSION(GXimProtocol *proto,
1671						    guint16       imid,
1672						    const GSList *extensions)
1673{
1674	SIG_NOIMPL_IM(XIM_QUERY_EXTENSION, imid);
1675
1676	return TRUE;
1677}
1678
1679static gboolean
1680g_xim_protocol10_closure_signal_XIM_QUERY_EXTENSION_REPLY(GXimProtocol *proto,
1681							  guint16       imid,
1682							  const GSList *extensions)
1683{
1684	MSG_NOIMPL_IM(XIM_QUERY_EXTENSION_REPLY, imid);
1685
1686	return TRUE;
1687}
1688
1689static gboolean
1690g_xim_protocol10_closure_signal_XIM_SET_IM_VALUES(GXimProtocol *proto,
1691						  guint16       imid,
1692						  const GSList *attributes)
1693{
1694	SIG_NOIMPL_IM(XIM_SET_IM_VALUES, imid);
1695
1696	return TRUE;
1697}
1698
1699static gboolean
1700g_xim_protocol10_closure_signal_XIM_SET_IM_VALUES_REPLY(GXimProtocol *proto,
1701							guint16       imid)
1702{
1703	MSG_NOIMPL_IM(XIM_SET_IM_VALUES_REPLY, imid);
1704
1705	return TRUE;
1706}
1707
1708static gboolean
1709g_xim_protocol10_closure_signal_XIM_GET_IM_VALUES(GXimProtocol *proto,
1710						  guint16       imid,
1711						  const GSList *attr_id)
1712{
1713	SIG_NOIMPL_IM(XIM_GET_IM_VALUES, imid);
1714
1715	return TRUE;
1716}
1717
1718static gboolean
1719g_xim_protocol10_closure_signal_XIM_GET_IM_VALUES_REPLY(GXimProtocol *proto,
1720							guint16       imid,
1721							const GSList *attributes)
1722{
1723	MSG_NOIMPL_IM(XIM_GET_IM_VALUES_REPLY, imid);
1724
1725	return TRUE;
1726}
1727
1728static gboolean
1729g_xim_protocol10_closure_signal_XIM_CREATE_IC(GXimProtocol *proto,
1730					      guint16       imid,
1731					      const GSList *attributes)
1732{
1733	SIG_NOIMPL_IM(XIM_CREATE_IC, imid);
1734
1735	return TRUE;
1736}
1737
1738static gboolean
1739g_xim_protocol10_closure_signal_XIM_CREATE_IC_REPLY(GXimProtocol *proto,
1740						    guint16       imid,
1741						    guint16       icid)
1742{
1743	MSG_NOIMPL_IMIC(XIM_CREATE_IC_REPLY, imid, icid);
1744
1745	return TRUE;
1746}
1747
1748static gboolean
1749g_xim_protocol10_closure_signal_XIM_DESTROY_IC(GXimProtocol *proto,
1750					       guint16       imid,
1751					       guint16       icid)
1752{
1753	MSG_NOIMPL_IMIC(XIM_DESTROY_IC, imid, icid);
1754
1755	if (!G_IS_XIM_SERVER_CONNECTION (proto)) {
1756		g_xim_messages_error(G_XIM_PROTOCOL_GET_IFACE (proto)->message,
1757				     "Non-server connection received XIM_DESTROY_IC [imid: %d, icid: %d]",
1758				     imid, icid);
1759		return FALSE;
1760	}
1761
1762	return g_xim_server_connection_cmd_destroy_ic_reply(G_XIM_SERVER_CONNECTION (proto), imid, icid);
1763}
1764
1765static gboolean
1766g_xim_protocol10_closure_signal_XIM_DESTROY_IC_REPLY(GXimProtocol *proto,
1767						     guint16       imid,
1768						     guint16       icid)
1769{
1770	MSG_NOIMPL_IMIC(XIM_DESTROY_IC_REPLY, imid, icid);
1771
1772	return TRUE;
1773}
1774
1775static gboolean
1776g_xim_protocol10_closure_signal_XIM_SET_IC_VALUES(GXimProtocol *proto,
1777						  guint16       imid,
1778						  guint16       icid,
1779						  const GSList *attributes)
1780{
1781	SIG_NOIMPL_IMIC(XIM_SET_IC_VALUES, imid, icid);
1782
1783	return TRUE;
1784}
1785
1786static gboolean
1787g_xim_protocol10_closure_signal_XIM_SET_IC_VALUES_REPLY(GXimProtocol *proto,
1788							guint16       imid,
1789							guint16       icid)
1790{
1791	MSG_NOIMPL_IMIC(XIM_SET_IC_VALUES_REPLY, imid, icid);
1792
1793	return TRUE;
1794}
1795
1796static gboolean
1797g_xim_protocol10_closure_signal_XIM_GET_IC_VALUES(GXimProtocol *proto,
1798						  guint16       imid,
1799						  guint16       icid,
1800						  const GSList *att

Large files files are truncated, but you can click here to view the full file