PageRenderTime 28ms CodeModel.GetById 10ms RepoModel.GetById 1ms app.codeStats 0ms

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

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