~ubuntu-branches/ubuntu/hoary/gimp/hoary

« back to all changes in this revision

Viewing changes to libgimpbase/gimpprotocol.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2005-04-04 14:51:23 UTC
  • Revision ID: james.westby@ubuntu.com-20050404145123-9py049eeelfymur8
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* LIBGIMP - The GIMP Library
 
2
 * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
 
3
 *
 
4
 * This library is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU Lesser General Public
 
6
 * License as published by the Free Software Foundation; either
 
7
 * version 2 of the License, or (at your option) any later version.
 
8
 *
 
9
 * This library is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * Library General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU Lesser General Public
 
15
 * License along with this library; if not, write to the
 
16
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
17
 * Boston, MA 02111-1307, USA.
 
18
 */
 
19
 
 
20
#include <stdio.h>
 
21
 
 
22
#include <glib-object.h>
 
23
 
 
24
#include "gimpbasetypes.h"
 
25
 
 
26
#include "gimpparasite.h"
 
27
#include "gimpprotocol.h"
 
28
#include "gimpwire.h"
 
29
 
 
30
 
 
31
static void _gp_quit_read                (GIOChannel   *channel,
 
32
                                          WireMessage  *msg,
 
33
                                          gpointer      user_data);
 
34
static void _gp_quit_write               (GIOChannel   *channel,
 
35
                                          WireMessage  *msg,
 
36
                                          gpointer      user_data);
 
37
static void _gp_quit_destroy             (WireMessage  *msg);
 
38
 
 
39
static void _gp_config_read              (GIOChannel   *channel,
 
40
                                          WireMessage  *msg,
 
41
                                          gpointer      user_data);
 
42
static void _gp_config_write             (GIOChannel   *channel,
 
43
                                          WireMessage  *msg,
 
44
                                          gpointer      user_data);
 
45
static void _gp_config_destroy           (WireMessage  *msg);
 
46
 
 
47
static void _gp_tile_req_read            (GIOChannel   *channel,
 
48
                                          WireMessage  *msg,
 
49
                                          gpointer      user_data);
 
50
static void _gp_tile_req_write           (GIOChannel   *channel,
 
51
                                          WireMessage  *msg,
 
52
                                          gpointer      user_data);
 
53
static void _gp_tile_req_destroy         (WireMessage  *msg);
 
54
 
 
55
static void _gp_tile_ack_read            (GIOChannel   *channel,
 
56
                                          WireMessage  *msg,
 
57
                                          gpointer      user_data);
 
58
static void _gp_tile_ack_write           (GIOChannel   *channel,
 
59
                                          WireMessage  *msg,
 
60
                                          gpointer      user_data);
 
61
static void _gp_tile_ack_destroy         (WireMessage  *msg);
 
62
 
 
63
static void _gp_tile_data_read           (GIOChannel   *channel,
 
64
                                          WireMessage  *msg,
 
65
                                          gpointer      user_data);
 
66
static void _gp_tile_data_write          (GIOChannel   *channel,
 
67
                                          WireMessage  *msg,
 
68
                                          gpointer      user_data);
 
69
static void _gp_tile_data_destroy        (WireMessage  *msg);
 
70
 
 
71
static void _gp_proc_run_read            (GIOChannel   *channel,
 
72
                                          WireMessage  *msg,
 
73
                                          gpointer      user_data);
 
74
static void _gp_proc_run_write           (GIOChannel   *channel,
 
75
                                          WireMessage  *msg,
 
76
                                          gpointer      user_data);
 
77
static void _gp_proc_run_destroy         (WireMessage  *msg);
 
78
 
 
79
static void _gp_proc_return_read         (GIOChannel   *channel,
 
80
                                          WireMessage  *msg,
 
81
                                          gpointer      user_data);
 
82
static void _gp_proc_return_write        (GIOChannel   *channel,
 
83
                                          WireMessage  *msg,
 
84
                                          gpointer      user_data);
 
85
static void _gp_proc_return_destroy      (WireMessage  *msg);
 
86
 
 
87
static void _gp_temp_proc_run_read       (GIOChannel   *channel,
 
88
                                          WireMessage  *msg,
 
89
                                          gpointer      user_data);
 
90
static void _gp_temp_proc_run_write      (GIOChannel   *channel,
 
91
                                          WireMessage  *msg,
 
92
                                          gpointer      user_data);
 
93
static void _gp_temp_proc_run_destroy    (WireMessage  *msg);
 
94
 
 
95
static void _gp_temp_proc_return_read    (GIOChannel   *channel,
 
96
                                          WireMessage  *msg,
 
97
                                          gpointer      user_data);
 
98
static void _gp_temp_proc_return_write   (GIOChannel   *channel,
 
99
                                          WireMessage  *msg,
 
100
                                          gpointer      user_data);
 
101
static void _gp_temp_proc_return_destroy (WireMessage  *msg);
 
102
 
 
103
static void _gp_proc_install_read        (GIOChannel   *channel,
 
104
                                          WireMessage  *msg,
 
105
                                          gpointer      user_data);
 
106
static void _gp_proc_install_write       (GIOChannel   *channel,
 
107
                                          WireMessage  *msg,
 
108
                                          gpointer      user_data);
 
109
static void _gp_proc_install_destroy     (WireMessage  *msg);
 
110
 
 
111
static void _gp_proc_uninstall_read      (GIOChannel   *channel,
 
112
                                          WireMessage  *msg,
 
113
                                          gpointer      user_data);
 
114
static void _gp_proc_uninstall_write     (GIOChannel   *channel,
 
115
                                          WireMessage  *msg,
 
116
                                          gpointer      user_data);
 
117
static void _gp_proc_uninstall_destroy   (WireMessage  *msg);
 
118
 
 
119
static void _gp_extension_ack_read       (GIOChannel   *channel,
 
120
                                          WireMessage  *msg,
 
121
                                          gpointer      user_data);
 
122
static void _gp_extension_ack_write      (GIOChannel   *channel,
 
123
                                          WireMessage  *msg,
 
124
                                          gpointer      user_data);
 
125
static void _gp_extension_ack_destroy    (WireMessage  *msg);
 
126
 
 
127
static void _gp_params_read              (GIOChannel   *channel,
 
128
                                          GPParam     **params,
 
129
                                          guint        *nparams,
 
130
                                          gpointer      user_data);
 
131
static void _gp_params_write             (GIOChannel   *channel,
 
132
                                          GPParam      *params,
 
133
                                          gint          nparams,
 
134
                                          gpointer      user_data);
 
135
 
 
136
/* used by gimp.c:gimp_destroy_params() */
 
137
void        _gp_params_destroy           (GPParam      *params,
 
138
                                          gint          nparams);
 
139
 
 
140
static void _gp_has_init_read            (GIOChannel   *channel,
 
141
                                          WireMessage  *msg,
 
142
                                          gpointer      user_data);
 
143
static void _gp_has_init_write           (GIOChannel   *channel,
 
144
                                          WireMessage  *msg,
 
145
                                          gpointer      user_data);
 
146
static void _gp_has_init_destroy         (WireMessage  *msg);
 
147
 
 
148
 
 
149
 
 
150
void
 
151
gp_init (void)
 
152
{
 
153
  wire_register (GP_QUIT,
 
154
                 _gp_quit_read,
 
155
                 _gp_quit_write,
 
156
                 _gp_quit_destroy);
 
157
  wire_register (GP_CONFIG,
 
158
                 _gp_config_read,
 
159
                 _gp_config_write,
 
160
                 _gp_config_destroy);
 
161
  wire_register (GP_TILE_REQ,
 
162
                 _gp_tile_req_read,
 
163
                 _gp_tile_req_write,
 
164
                 _gp_tile_req_destroy);
 
165
  wire_register (GP_TILE_ACK,
 
166
                 _gp_tile_ack_read,
 
167
                 _gp_tile_ack_write,
 
168
                 _gp_tile_ack_destroy);
 
169
  wire_register (GP_TILE_DATA,
 
170
                 _gp_tile_data_read,
 
171
                 _gp_tile_data_write,
 
172
                 _gp_tile_data_destroy);
 
173
  wire_register (GP_PROC_RUN,
 
174
                 _gp_proc_run_read,
 
175
                 _gp_proc_run_write,
 
176
                 _gp_proc_run_destroy);
 
177
  wire_register (GP_PROC_RETURN,
 
178
                 _gp_proc_return_read,
 
179
                 _gp_proc_return_write,
 
180
                 _gp_proc_return_destroy);
 
181
  wire_register (GP_TEMP_PROC_RUN,
 
182
                 _gp_temp_proc_run_read,
 
183
                 _gp_temp_proc_run_write,
 
184
                 _gp_temp_proc_run_destroy);
 
185
  wire_register (GP_TEMP_PROC_RETURN,
 
186
                 _gp_temp_proc_return_read,
 
187
                 _gp_temp_proc_return_write,
 
188
                 _gp_temp_proc_return_destroy);
 
189
  wire_register (GP_PROC_INSTALL,
 
190
                 _gp_proc_install_read,
 
191
                 _gp_proc_install_write,
 
192
                 _gp_proc_install_destroy);
 
193
  wire_register (GP_PROC_UNINSTALL,
 
194
                 _gp_proc_uninstall_read,
 
195
                 _gp_proc_uninstall_write,
 
196
                 _gp_proc_uninstall_destroy);
 
197
  wire_register (GP_EXTENSION_ACK,
 
198
                 _gp_extension_ack_read,
 
199
                 _gp_extension_ack_write,
 
200
                 _gp_extension_ack_destroy);
 
201
  wire_register (GP_HAS_INIT,
 
202
                 _gp_has_init_read,
 
203
                 _gp_has_init_write,
 
204
                 _gp_has_init_destroy);
 
205
}
 
206
 
 
207
gboolean
 
208
gp_quit_write (GIOChannel *channel,
 
209
               gpointer    user_data)
 
210
{
 
211
  WireMessage msg;
 
212
 
 
213
  msg.type = GP_QUIT;
 
214
  msg.data = NULL;
 
215
 
 
216
  if (! wire_write_msg (channel, &msg, user_data))
 
217
    return FALSE;
 
218
  if (! wire_flush (channel, user_data))
 
219
    return FALSE;
 
220
  return TRUE;
 
221
}
 
222
 
 
223
gboolean
 
224
gp_config_write (GIOChannel *channel,
 
225
                 GPConfig   *config,
 
226
                 gpointer    user_data)
 
227
{
 
228
  WireMessage msg;
 
229
 
 
230
  msg.type = GP_CONFIG;
 
231
  msg.data = config;
 
232
 
 
233
  if (! wire_write_msg (channel, &msg, user_data))
 
234
    return FALSE;
 
235
  if (! wire_flush (channel, user_data))
 
236
    return FALSE;
 
237
  return TRUE;
 
238
}
 
239
 
 
240
gboolean
 
241
gp_tile_req_write (GIOChannel *channel,
 
242
                   GPTileReq  *tile_req,
 
243
                   gpointer    user_data)
 
244
{
 
245
  WireMessage msg;
 
246
 
 
247
  msg.type = GP_TILE_REQ;
 
248
  msg.data = tile_req;
 
249
 
 
250
  if (! wire_write_msg (channel, &msg, user_data))
 
251
    return FALSE;
 
252
  if (! wire_flush (channel, user_data))
 
253
    return FALSE;
 
254
  return TRUE;
 
255
}
 
256
 
 
257
gboolean
 
258
gp_tile_ack_write (GIOChannel *channel,
 
259
                   gpointer    user_data)
 
260
{
 
261
  WireMessage msg;
 
262
 
 
263
  msg.type = GP_TILE_ACK;
 
264
  msg.data = NULL;
 
265
 
 
266
  if (! wire_write_msg (channel, &msg, user_data))
 
267
    return FALSE;
 
268
  if (! wire_flush (channel, user_data))
 
269
    return FALSE;
 
270
  return TRUE;
 
271
}
 
272
 
 
273
gboolean
 
274
gp_tile_data_write (GIOChannel *channel,
 
275
                    GPTileData *tile_data,
 
276
                    gpointer    user_data)
 
277
{
 
278
  WireMessage msg;
 
279
 
 
280
  msg.type = GP_TILE_DATA;
 
281
  msg.data = tile_data;
 
282
 
 
283
  if (! wire_write_msg (channel, &msg, user_data))
 
284
    return FALSE;
 
285
  if (! wire_flush (channel, user_data))
 
286
    return FALSE;
 
287
  return TRUE;
 
288
}
 
289
 
 
290
gboolean
 
291
gp_proc_run_write (GIOChannel *channel,
 
292
                   GPProcRun  *proc_run,
 
293
                   gpointer    user_data)
 
294
{
 
295
  WireMessage msg;
 
296
 
 
297
  msg.type = GP_PROC_RUN;
 
298
  msg.data = proc_run;
 
299
 
 
300
  if (! wire_write_msg (channel, &msg, user_data))
 
301
    return FALSE;
 
302
  if (! wire_flush (channel, user_data))
 
303
    return FALSE;
 
304
  return TRUE;
 
305
}
 
306
 
 
307
gboolean
 
308
gp_proc_return_write (GIOChannel   *channel,
 
309
                      GPProcReturn *proc_return,
 
310
                      gpointer      user_data)
 
311
{
 
312
  WireMessage msg;
 
313
 
 
314
  msg.type = GP_PROC_RETURN;
 
315
  msg.data = proc_return;
 
316
 
 
317
  if (! wire_write_msg (channel, &msg, user_data))
 
318
    return FALSE;
 
319
  if (! wire_flush (channel, user_data))
 
320
    return FALSE;
 
321
  return TRUE;
 
322
}
 
323
 
 
324
gboolean
 
325
gp_temp_proc_run_write (GIOChannel *channel,
 
326
                        GPProcRun  *proc_run,
 
327
                        gpointer    user_data)
 
328
{
 
329
  WireMessage msg;
 
330
 
 
331
  msg.type = GP_TEMP_PROC_RUN;
 
332
  msg.data = proc_run;
 
333
 
 
334
  if (! wire_write_msg (channel, &msg, user_data))
 
335
    return FALSE;
 
336
  if (! wire_flush (channel, user_data))
 
337
    return FALSE;
 
338
  return TRUE;
 
339
}
 
340
 
 
341
gboolean
 
342
gp_temp_proc_return_write (GIOChannel   *channel,
 
343
                           GPProcReturn *proc_return,
 
344
                           gpointer      user_data)
 
345
{
 
346
  WireMessage msg;
 
347
 
 
348
  msg.type = GP_TEMP_PROC_RETURN;
 
349
  msg.data = proc_return;
 
350
 
 
351
  if (! wire_write_msg (channel, &msg, user_data))
 
352
    return FALSE;
 
353
  if (! wire_flush (channel, user_data))
 
354
    return FALSE;
 
355
  return TRUE;
 
356
}
 
357
 
 
358
gboolean
 
359
gp_proc_install_write (GIOChannel    *channel,
 
360
                       GPProcInstall *proc_install,
 
361
                       gpointer       user_data)
 
362
{
 
363
  WireMessage msg;
 
364
 
 
365
  msg.type = GP_PROC_INSTALL;
 
366
  msg.data = proc_install;
 
367
 
 
368
  if (! wire_write_msg (channel, &msg, user_data))
 
369
    return FALSE;
 
370
  if (! wire_flush (channel, user_data))
 
371
    return FALSE;
 
372
  return TRUE;
 
373
}
 
374
 
 
375
gboolean
 
376
gp_proc_uninstall_write (GIOChannel      *channel,
 
377
                         GPProcUninstall *proc_uninstall,
 
378
                         gpointer         user_data)
 
379
{
 
380
  WireMessage msg;
 
381
 
 
382
  msg.type = GP_PROC_UNINSTALL;
 
383
  msg.data = proc_uninstall;
 
384
 
 
385
  if (! wire_write_msg (channel, &msg, user_data))
 
386
    return FALSE;
 
387
  if (! wire_flush (channel, user_data))
 
388
    return FALSE;
 
389
  return TRUE;
 
390
}
 
391
 
 
392
gboolean
 
393
gp_extension_ack_write (GIOChannel *channel,
 
394
                        gpointer    user_data)
 
395
{
 
396
  WireMessage msg;
 
397
 
 
398
  msg.type = GP_EXTENSION_ACK;
 
399
  msg.data = NULL;
 
400
 
 
401
  if (! wire_write_msg (channel, &msg, user_data))
 
402
    return FALSE;
 
403
  if (! wire_flush (channel, user_data))
 
404
    return FALSE;
 
405
  return TRUE;
 
406
}
 
407
 
 
408
gboolean
 
409
gp_has_init_write (GIOChannel *channel,
 
410
                   gpointer    user_data)
 
411
{
 
412
  WireMessage msg;
 
413
 
 
414
  msg.type = GP_HAS_INIT;
 
415
  msg.data = NULL;
 
416
 
 
417
  if (! wire_write_msg (channel, &msg, user_data))
 
418
    return FALSE;
 
419
  if (! wire_flush (channel, user_data))
 
420
    return FALSE;
 
421
  return TRUE;
 
422
}
 
423
 
 
424
/*  quit  */
 
425
 
 
426
static void
 
427
_gp_quit_read (GIOChannel  *channel,
 
428
               WireMessage *msg,
 
429
               gpointer     user_data)
 
430
{
 
431
}
 
432
 
 
433
static void
 
434
_gp_quit_write (GIOChannel  *channel,
 
435
                WireMessage *msg,
 
436
                gpointer     user_data)
 
437
{
 
438
}
 
439
 
 
440
static void
 
441
_gp_quit_destroy (WireMessage *msg)
 
442
{
 
443
}
 
444
 
 
445
/*  config  */
 
446
 
 
447
static void
 
448
_gp_config_read (GIOChannel  *channel,
 
449
                 WireMessage *msg,
 
450
                 gpointer     user_data)
 
451
{
 
452
  GPConfig *config;
 
453
 
 
454
  config = g_new0 (GPConfig, 1);
 
455
 
 
456
  if (! wire_read_int32 (channel,
 
457
                         &config->version, 1, user_data))
 
458
    goto cleanup;
 
459
  if (! wire_read_int32 (channel,
 
460
                         &config->tile_width, 1, user_data))
 
461
    goto cleanup;
 
462
  if (! wire_read_int32 (channel,
 
463
                         &config->tile_height, 1, user_data))
 
464
    goto cleanup;
 
465
  if (! wire_read_int32 (channel,
 
466
                         (guint32 *) &config->shm_ID, 1, user_data))
 
467
    goto cleanup;
 
468
  if (! wire_read_int8 (channel,
 
469
                        (guint8 *) &config->check_size, 1, user_data))
 
470
    goto cleanup;
 
471
  if (! wire_read_int8 (channel,
 
472
                        (guint8 *) &config->check_type, 1, user_data))
 
473
    goto cleanup;
 
474
  if (! wire_read_int8 (channel,
 
475
                        (guint8 *) &config->show_help_button, 1, user_data))
 
476
    goto cleanup;
 
477
  if (! wire_read_int8 (channel,
 
478
                        (guint8 *) &config->gimp_reserved_4, 1, user_data))
 
479
    goto cleanup;
 
480
  if (! wire_read_int8 (channel,
 
481
                        (guint8 *) &config->gimp_reserved_5, 1, user_data))
 
482
    goto cleanup;
 
483
  if (! wire_read_int8 (channel,
 
484
                        (guint8 *) &config->gimp_reserved_6, 1, user_data))
 
485
    goto cleanup;
 
486
  if (! wire_read_int8 (channel,
 
487
                        (guint8 *) &config->gimp_reserved_7, 1, user_data))
 
488
    goto cleanup;
 
489
  if (! wire_read_int8 (channel,
 
490
                        (guint8 *) &config->gimp_reserved_8, 1, user_data))
 
491
    goto cleanup;
 
492
  if (! wire_read_int8 (channel,
 
493
                        (guint8 *) &config->install_cmap, 1, user_data))
 
494
    goto cleanup;
 
495
  if (! wire_read_int8 (channel,
 
496
                        (guint8 *) &config->show_tool_tips, 1, user_data))
 
497
    goto cleanup;
 
498
  if (! wire_read_int32 (channel,
 
499
                         (guint32 *) &config->min_colors, 1, user_data))
 
500
    goto cleanup;
 
501
  if (! wire_read_int32 (channel,
 
502
                         (guint32 *) &config->gdisp_ID, 1, user_data))
 
503
    goto cleanup;
 
504
 
 
505
  if (! wire_read_string (channel,
 
506
                          &config->app_name, 1, user_data))
 
507
    goto cleanup;
 
508
  if (! wire_read_string (channel,
 
509
                          &config->wm_class, 1, user_data))
 
510
    goto cleanup;
 
511
  if (! wire_read_string (channel,
 
512
                          &config->display_name, 1, user_data))
 
513
    goto cleanup;
 
514
  if (! wire_read_int32 (channel,
 
515
                         (guint32 *) &config->monitor_number, 1, user_data))
 
516
    goto cleanup;
 
517
 
 
518
  msg->data = config;
 
519
  return;
 
520
 
 
521
 cleanup:
 
522
  g_free (config->app_name);
 
523
  g_free (config->wm_class);
 
524
  g_free (config->display_name);
 
525
  g_free (config);
 
526
}
 
527
 
 
528
static void
 
529
_gp_config_write (GIOChannel  *channel,
 
530
                  WireMessage *msg,
 
531
                  gpointer     user_data)
 
532
{
 
533
  GPConfig *config;
 
534
 
 
535
  config = msg->data;
 
536
  if (! wire_write_int32 (channel, &config->version, 1, user_data))
 
537
    return;
 
538
  if (! wire_write_int32 (channel, &config->tile_width, 1, user_data))
 
539
    return;
 
540
  if (! wire_write_int32 (channel, &config->tile_height, 1, user_data))
 
541
    return;
 
542
  if (! wire_write_int32 (channel, (guint32*) &config->shm_ID, 1, user_data))
 
543
    return;
 
544
  if (! wire_write_int8 (channel, (guint8*) &config->check_size, 1, user_data))
 
545
    return;
 
546
  if (! wire_write_int8 (channel, (guint8*) &config->check_type, 1, user_data))
 
547
    return;
 
548
  if (! wire_write_int8 (channel, (guint8*) &config->show_help_button, 1, user_data))
 
549
    return;
 
550
  if (! wire_write_int8 (channel, (guint8*) &config->gimp_reserved_4, 1, user_data))
 
551
    return;
 
552
  if (! wire_write_int8 (channel, (guint8*) &config->gimp_reserved_5, 1, user_data))
 
553
    return;
 
554
  if (! wire_write_int8 (channel, (guint8*) &config->gimp_reserved_6, 1, user_data))
 
555
    return;
 
556
  if (! wire_write_int8 (channel, (guint8*) &config->gimp_reserved_7, 1, user_data))
 
557
    return;
 
558
  if (! wire_write_int8 (channel, (guint8*) &config->gimp_reserved_8, 1, user_data))
 
559
    return;
 
560
  if (! wire_write_int8 (channel, (guint8*) &config->install_cmap, 1, user_data))
 
561
    return;
 
562
  if (! wire_write_int8 (channel, (guint8*) &config->show_tool_tips, 1, user_data))
 
563
    return;
 
564
  if (! wire_write_int32 (channel, (guint32*) &config->min_colors, 1, user_data))
 
565
    return;
 
566
  if (! wire_write_int32 (channel, (guint32*) &config->gdisp_ID, 1, user_data))
 
567
    return;
 
568
  if (! wire_write_string (channel, &config->app_name, 1, user_data))
 
569
    return;
 
570
  if (! wire_write_string (channel, &config->wm_class, 1, user_data))
 
571
    return;
 
572
  if (! wire_write_string (channel, &config->display_name, 1, user_data))
 
573
    return;
 
574
  if (! wire_write_int32 (channel, (guint32*) &config->monitor_number, 1, user_data))
 
575
    return;
 
576
}
 
577
 
 
578
static void
 
579
_gp_config_destroy (WireMessage *msg)
 
580
{
 
581
  GPConfig *config;
 
582
 
 
583
  config = msg->data;
 
584
 
 
585
  g_free (config->app_name);
 
586
  g_free (config->wm_class);
 
587
  g_free (config->display_name);
 
588
  g_free (config);
 
589
}
 
590
 
 
591
/*  tile_req  */
 
592
 
 
593
static void
 
594
_gp_tile_req_read (GIOChannel  *channel,
 
595
                   WireMessage *msg,
 
596
                   gpointer     user_data)
 
597
{
 
598
  GPTileReq *tile_req;
 
599
 
 
600
  tile_req = g_new0 (GPTileReq, 1);
 
601
 
 
602
  if (! wire_read_int32 (channel, (guint32*) &tile_req->drawable_ID, 1,
 
603
                         user_data))
 
604
    goto cleanup;
 
605
  if (! wire_read_int32 (channel, &tile_req->tile_num, 1, user_data))
 
606
    goto cleanup;
 
607
  if (! wire_read_int32 (channel, &tile_req->shadow, 1, user_data))
 
608
    goto cleanup;
 
609
 
 
610
  msg->data = tile_req;
 
611
  return;
 
612
 
 
613
 cleanup:
 
614
  g_free (tile_req);
 
615
}
 
616
 
 
617
static void
 
618
_gp_tile_req_write (GIOChannel  *channel,
 
619
                    WireMessage *msg,
 
620
                    gpointer     user_data)
 
621
{
 
622
  GPTileReq *tile_req;
 
623
 
 
624
  tile_req = msg->data;
 
625
  if (! wire_write_int32 (channel, (guint32*) &tile_req->drawable_ID, 1,
 
626
                          user_data))
 
627
    return;
 
628
  if (! wire_write_int32 (channel, &tile_req->tile_num, 1, user_data))
 
629
    return;
 
630
  if (! wire_write_int32 (channel, &tile_req->shadow, 1, user_data))
 
631
    return;
 
632
}
 
633
 
 
634
static void
 
635
_gp_tile_req_destroy (WireMessage *msg)
 
636
{
 
637
  g_free (msg->data);
 
638
}
 
639
 
 
640
/*  tile_ack  */
 
641
 
 
642
static void
 
643
_gp_tile_ack_read (GIOChannel  *channel,
 
644
                   WireMessage *msg,
 
645
                   gpointer     user_data)
 
646
{
 
647
}
 
648
 
 
649
static void
 
650
_gp_tile_ack_write (GIOChannel  *channel,
 
651
                    WireMessage *msg,
 
652
                    gpointer     user_data)
 
653
{
 
654
}
 
655
 
 
656
static void
 
657
_gp_tile_ack_destroy (WireMessage *msg)
 
658
{
 
659
}
 
660
 
 
661
/*  tile_data  */
 
662
 
 
663
static void
 
664
_gp_tile_data_read (GIOChannel  *channel,
 
665
                    WireMessage *msg,
 
666
                    gpointer     user_data)
 
667
{
 
668
  GPTileData *tile_data;
 
669
  guint length;
 
670
 
 
671
  tile_data = g_new0 (GPTileData, 1);
 
672
 
 
673
  if (! wire_read_int32 (channel, (guint32*) &tile_data->drawable_ID, 1,
 
674
                         user_data))
 
675
    goto cleanup;
 
676
  if (! wire_read_int32 (channel, &tile_data->tile_num, 1, user_data))
 
677
    goto cleanup;
 
678
  if (! wire_read_int32 (channel, &tile_data->shadow, 1, user_data))
 
679
    goto cleanup;
 
680
  if (! wire_read_int32 (channel, &tile_data->bpp, 1, user_data))
 
681
    goto cleanup;
 
682
  if (! wire_read_int32 (channel, &tile_data->width, 1, user_data))
 
683
    goto cleanup;
 
684
  if (! wire_read_int32 (channel, &tile_data->height, 1, user_data))
 
685
    goto cleanup;
 
686
  if (! wire_read_int32 (channel, &tile_data->use_shm, 1, user_data))
 
687
    goto cleanup;
 
688
 
 
689
  if (!tile_data->use_shm)
 
690
    {
 
691
      length = tile_data->width * tile_data->height * tile_data->bpp;
 
692
      tile_data->data = g_new (guchar, length);
 
693
 
 
694
      if (! wire_read_int8 (channel, (guint8*) tile_data->data, length,
 
695
                            user_data))
 
696
        goto cleanup;
 
697
    }
 
698
 
 
699
  msg->data = tile_data;
 
700
  return;
 
701
 
 
702
 cleanup:
 
703
  g_free (tile_data->data);
 
704
  g_free (tile_data);
 
705
}
 
706
 
 
707
static void
 
708
_gp_tile_data_write (GIOChannel  *channel,
 
709
                     WireMessage *msg,
 
710
                     gpointer     user_data)
 
711
{
 
712
  GPTileData *tile_data;
 
713
  guint length;
 
714
 
 
715
  tile_data = msg->data;
 
716
  if (! wire_write_int32 (channel, (guint32*) &tile_data->drawable_ID, 1,
 
717
                          user_data))
 
718
    return;
 
719
  if (! wire_write_int32 (channel, &tile_data->tile_num, 1, user_data))
 
720
    return;
 
721
  if (! wire_write_int32 (channel, &tile_data->shadow, 1, user_data))
 
722
    return;
 
723
  if (! wire_write_int32 (channel, &tile_data->bpp, 1, user_data))
 
724
    return;
 
725
  if (! wire_write_int32 (channel, &tile_data->width, 1, user_data))
 
726
    return;
 
727
  if (! wire_write_int32 (channel, &tile_data->height, 1, user_data))
 
728
    return;
 
729
  if (! wire_write_int32 (channel, &tile_data->use_shm, 1, user_data))
 
730
    return;
 
731
 
 
732
  if (!tile_data->use_shm)
 
733
    {
 
734
      length = tile_data->width * tile_data->height * tile_data->bpp;
 
735
      if (! wire_write_int8 (channel, (guint8*) tile_data->data, length,
 
736
                             user_data))
 
737
        return;
 
738
    }
 
739
}
 
740
 
 
741
static void
 
742
_gp_tile_data_destroy (WireMessage *msg)
 
743
{
 
744
  GPTileData *tile_data;
 
745
 
 
746
  tile_data = msg->data;
 
747
 
 
748
  g_free (tile_data->data);
 
749
  g_free (tile_data);
 
750
}
 
751
 
 
752
/*  proc_run  */
 
753
 
 
754
static void
 
755
_gp_proc_run_read (GIOChannel  *channel,
 
756
                   WireMessage *msg,
 
757
                   gpointer     user_data)
 
758
{
 
759
  GPProcRun *proc_run;
 
760
 
 
761
  proc_run = g_new0 (GPProcRun, 1);
 
762
 
 
763
  if (! wire_read_string (channel, &proc_run->name, 1, user_data))
 
764
    goto cleanup;
 
765
 
 
766
  _gp_params_read (channel,
 
767
                   &proc_run->params, (guint*) &proc_run->nparams,
 
768
                   user_data);
 
769
 
 
770
  msg->data = proc_run;
 
771
  return;
 
772
 
 
773
 cleanup:
 
774
  g_free (proc_run);
 
775
}
 
776
 
 
777
static void
 
778
_gp_proc_run_write (GIOChannel  *channel,
 
779
                    WireMessage *msg,
 
780
                    gpointer     user_data)
 
781
{
 
782
  GPProcRun *proc_run;
 
783
 
 
784
  proc_run = msg->data;
 
785
 
 
786
  if (! wire_write_string (channel, &proc_run->name, 1, user_data))
 
787
    return;
 
788
 
 
789
  _gp_params_write (channel, proc_run->params, proc_run->nparams, user_data);
 
790
}
 
791
 
 
792
static void
 
793
_gp_proc_run_destroy (WireMessage *msg)
 
794
{
 
795
  GPProcRun *proc_run;
 
796
 
 
797
  proc_run = msg->data;
 
798
  _gp_params_destroy (proc_run->params, proc_run->nparams);
 
799
 
 
800
  g_free (proc_run->name);
 
801
  g_free (proc_run);
 
802
}
 
803
 
 
804
/*  proc_return  */
 
805
 
 
806
static void
 
807
_gp_proc_return_read (GIOChannel  *channel,
 
808
                      WireMessage *msg,
 
809
                      gpointer     user_data)
 
810
{
 
811
  GPProcReturn *proc_return;
 
812
 
 
813
  proc_return = g_new0 (GPProcReturn, 1);
 
814
 
 
815
  if (! wire_read_string (channel, &proc_return->name, 1, user_data))
 
816
    goto cleanup;
 
817
 
 
818
  _gp_params_read (channel,
 
819
                   &proc_return->params, (guint*) &proc_return->nparams,
 
820
                   user_data);
 
821
 
 
822
  msg->data = proc_return;
 
823
  return;
 
824
 
 
825
 cleanup:
 
826
  g_free (proc_return);
 
827
}
 
828
 
 
829
static void
 
830
_gp_proc_return_write (GIOChannel  *channel,
 
831
                       WireMessage *msg,
 
832
                       gpointer     user_data)
 
833
{
 
834
  GPProcReturn *proc_return;
 
835
 
 
836
  proc_return = msg->data;
 
837
 
 
838
  if (! wire_write_string (channel, &proc_return->name, 1, user_data))
 
839
    return;
 
840
 
 
841
  _gp_params_write (channel, proc_return->params, proc_return->nparams,
 
842
                    user_data);
 
843
}
 
844
 
 
845
static void
 
846
_gp_proc_return_destroy (WireMessage *msg)
 
847
{
 
848
  GPProcReturn *proc_return;
 
849
 
 
850
  proc_return = msg->data;
 
851
  _gp_params_destroy (proc_return->params, proc_return->nparams);
 
852
 
 
853
  g_free (proc_return->name);
 
854
  g_free (proc_return);
 
855
}
 
856
 
 
857
/*  temp_proc_run  */
 
858
 
 
859
static void
 
860
_gp_temp_proc_run_read (GIOChannel  *channel,
 
861
                        WireMessage *msg,
 
862
                        gpointer     user_data)
 
863
{
 
864
  _gp_proc_run_read (channel, msg, user_data);
 
865
}
 
866
 
 
867
static void
 
868
_gp_temp_proc_run_write (GIOChannel  *channel,
 
869
                         WireMessage *msg,
 
870
                         gpointer     user_data)
 
871
{
 
872
  _gp_proc_run_write (channel, msg, user_data);
 
873
}
 
874
 
 
875
static void
 
876
_gp_temp_proc_run_destroy (WireMessage *msg)
 
877
{
 
878
  _gp_proc_run_destroy (msg);
 
879
}
 
880
 
 
881
/*  temp_proc_return  */
 
882
 
 
883
static void
 
884
_gp_temp_proc_return_read (GIOChannel  *channel,
 
885
                           WireMessage *msg,
 
886
                           gpointer     user_data)
 
887
{
 
888
  _gp_proc_return_read (channel, msg, user_data);
 
889
}
 
890
 
 
891
static void
 
892
_gp_temp_proc_return_write (GIOChannel  *channel,
 
893
                            WireMessage *msg,
 
894
                            gpointer     user_data)
 
895
{
 
896
  _gp_proc_return_write (channel, msg, user_data);
 
897
}
 
898
 
 
899
static void
 
900
_gp_temp_proc_return_destroy (WireMessage *msg)
 
901
{
 
902
  _gp_proc_return_destroy (msg);
 
903
}
 
904
 
 
905
/*  proc_install  */
 
906
 
 
907
static void
 
908
_gp_proc_install_read (GIOChannel  *channel,
 
909
                       WireMessage *msg,
 
910
                       gpointer     user_data)
 
911
{
 
912
  GPProcInstall *proc_install;
 
913
  gint i;
 
914
 
 
915
  proc_install = g_new0 (GPProcInstall, 1);
 
916
 
 
917
  if (! wire_read_string (channel, &proc_install->name, 1, user_data))
 
918
    goto cleanup;
 
919
  if (! wire_read_string (channel, &proc_install->blurb, 1, user_data))
 
920
    goto cleanup;
 
921
  if (! wire_read_string (channel, &proc_install->help, 1, user_data))
 
922
    goto cleanup;
 
923
  if (! wire_read_string (channel, &proc_install->author, 1, user_data))
 
924
    goto cleanup;
 
925
  if (! wire_read_string (channel, &proc_install->copyright, 1, user_data))
 
926
    goto cleanup;
 
927
  if (! wire_read_string (channel, &proc_install->date, 1, user_data))
 
928
    goto cleanup;
 
929
  if (! wire_read_string (channel, &proc_install->menu_path, 1, user_data))
 
930
    goto cleanup;
 
931
  if (! wire_read_string (channel, &proc_install->image_types, 1, user_data))
 
932
    goto cleanup;
 
933
 
 
934
  if (! wire_read_int32 (channel, &proc_install->type, 1, user_data))
 
935
    goto cleanup;
 
936
  if (! wire_read_int32 (channel, &proc_install->nparams, 1, user_data))
 
937
    goto cleanup;
 
938
  if (! wire_read_int32 (channel, &proc_install->nreturn_vals, 1, user_data))
 
939
    goto cleanup;
 
940
 
 
941
  proc_install->params = g_new0 (GPParamDef, proc_install->nparams);
 
942
 
 
943
  for (i = 0; i < proc_install->nparams; i++)
 
944
    {
 
945
      if (! wire_read_int32 (channel,
 
946
                             (guint32*) &proc_install->params[i].type, 1,
 
947
                             user_data))
 
948
        goto cleanup;
 
949
      if (! wire_read_string (channel,
 
950
                              &proc_install->params[i].name, 1,
 
951
                              user_data))
 
952
        goto cleanup;
 
953
      if (! wire_read_string (channel,
 
954
                              &proc_install->params[i].description, 1,
 
955
                              user_data))
 
956
        goto cleanup;
 
957
    }
 
958
 
 
959
  proc_install->return_vals = g_new0 (GPParamDef, proc_install->nreturn_vals);
 
960
 
 
961
  for (i = 0; i < proc_install->nreturn_vals; i++)
 
962
    {
 
963
      if (! wire_read_int32 (channel,
 
964
                             (guint32*) &proc_install->return_vals[i].type, 1,
 
965
                             user_data))
 
966
        goto cleanup;
 
967
      if (! wire_read_string (channel,
 
968
                              &proc_install->return_vals[i].name, 1,
 
969
                              user_data))
 
970
        goto cleanup;
 
971
      if (! wire_read_string (channel,
 
972
                              &proc_install->return_vals[i].description, 1,
 
973
                              user_data))
 
974
        goto cleanup;
 
975
    }
 
976
 
 
977
  msg->data = proc_install;
 
978
  return;
 
979
 
 
980
 cleanup:
 
981
  g_free (proc_install->name);
 
982
  g_free (proc_install->blurb);
 
983
  g_free (proc_install->help);
 
984
  g_free (proc_install->author);
 
985
  g_free (proc_install->copyright);
 
986
  g_free (proc_install->date);
 
987
  g_free (proc_install->menu_path);
 
988
  g_free (proc_install->image_types);
 
989
 
 
990
  if (proc_install->params)
 
991
    {
 
992
      for (i = 0; i < proc_install->nparams; i++)
 
993
        {
 
994
          if (!proc_install->params[i].name)
 
995
            break;
 
996
 
 
997
          g_free (proc_install->params[i].name);
 
998
          g_free (proc_install->params[i].description);
 
999
        }
 
1000
 
 
1001
      g_free (proc_install->params);
 
1002
    }
 
1003
 
 
1004
  if (proc_install->return_vals)
 
1005
    {
 
1006
      for (i = 0; i < proc_install->nreturn_vals; i++)
 
1007
        {
 
1008
          if (!proc_install->return_vals[i].name)
 
1009
            break;
 
1010
 
 
1011
          g_free (proc_install->return_vals[i].name);
 
1012
          g_free (proc_install->return_vals[i].description);
 
1013
        }
 
1014
 
 
1015
      g_free (proc_install->return_vals);
 
1016
    }
 
1017
 
 
1018
  g_free (proc_install);
 
1019
}
 
1020
 
 
1021
static void
 
1022
_gp_proc_install_write (GIOChannel  *channel,
 
1023
                        WireMessage *msg,
 
1024
                        gpointer     user_data)
 
1025
{
 
1026
  GPProcInstall *proc_install;
 
1027
  gint i;
 
1028
 
 
1029
  proc_install = msg->data;
 
1030
 
 
1031
  if (! wire_write_string (channel, &proc_install->name, 1, user_data))
 
1032
    return;
 
1033
  if (! wire_write_string (channel, &proc_install->blurb, 1, user_data))
 
1034
    return;
 
1035
  if (! wire_write_string (channel, &proc_install->help, 1, user_data))
 
1036
    return;
 
1037
  if (! wire_write_string (channel, &proc_install->author, 1, user_data))
 
1038
    return;
 
1039
  if (! wire_write_string (channel, &proc_install->copyright, 1, user_data))
 
1040
    return;
 
1041
  if (! wire_write_string (channel, &proc_install->date, 1, user_data))
 
1042
    return;
 
1043
  if (! wire_write_string (channel, &proc_install->menu_path, 1, user_data))
 
1044
    return;
 
1045
  if (! wire_write_string (channel, &proc_install->image_types, 1, user_data))
 
1046
    return;
 
1047
 
 
1048
  if (! wire_write_int32 (channel, &proc_install->type, 1, user_data))
 
1049
    return;
 
1050
  if (! wire_write_int32 (channel, &proc_install->nparams, 1, user_data))
 
1051
    return;
 
1052
  if (! wire_write_int32 (channel, &proc_install->nreturn_vals, 1, user_data))
 
1053
    return;
 
1054
 
 
1055
  for (i = 0; i < proc_install->nparams; i++)
 
1056
    {
 
1057
      if (! wire_write_int32 (channel,
 
1058
                              (guint32*) &proc_install->params[i].type, 1,
 
1059
                              user_data))
 
1060
        return;
 
1061
      if (! wire_write_string (channel,
 
1062
                               &proc_install->params[i].name, 1,
 
1063
                               user_data))
 
1064
        return;
 
1065
      if (! wire_write_string (channel,
 
1066
                               &proc_install->params[i].description, 1,
 
1067
                               user_data))
 
1068
        return;
 
1069
    }
 
1070
 
 
1071
  for (i = 0; i < proc_install->nreturn_vals; i++)
 
1072
    {
 
1073
      if (! wire_write_int32 (channel,
 
1074
                              (guint32*) &proc_install->return_vals[i].type, 1,
 
1075
                              user_data))
 
1076
        return;
 
1077
      if (! wire_write_string (channel,
 
1078
                               &proc_install->return_vals[i].name, 1,
 
1079
                               user_data))
 
1080
        return;
 
1081
      if (! wire_write_string (channel,
 
1082
                               &proc_install->return_vals[i].description, 1,
 
1083
                               user_data))
 
1084
        return;
 
1085
    }
 
1086
}
 
1087
 
 
1088
static void
 
1089
_gp_proc_install_destroy (WireMessage *msg)
 
1090
{
 
1091
  GPProcInstall *proc_install;
 
1092
  gint i;
 
1093
 
 
1094
  proc_install = msg->data;
 
1095
 
 
1096
  g_free (proc_install->name);
 
1097
  g_free (proc_install->blurb);
 
1098
  g_free (proc_install->help);
 
1099
  g_free (proc_install->author);
 
1100
  g_free (proc_install->copyright);
 
1101
  g_free (proc_install->date);
 
1102
  g_free (proc_install->menu_path);
 
1103
  g_free (proc_install->image_types);
 
1104
 
 
1105
  for (i = 0; i < proc_install->nparams; i++)
 
1106
    {
 
1107
      g_free (proc_install->params[i].name);
 
1108
      g_free (proc_install->params[i].description);
 
1109
    }
 
1110
 
 
1111
  for (i = 0; i < proc_install->nreturn_vals; i++)
 
1112
    {
 
1113
      g_free (proc_install->return_vals[i].name);
 
1114
      g_free (proc_install->return_vals[i].description);
 
1115
    }
 
1116
 
 
1117
  g_free (proc_install->params);
 
1118
  g_free (proc_install->return_vals);
 
1119
  g_free (proc_install);
 
1120
}
 
1121
 
 
1122
/*  proc_uninstall  */
 
1123
 
 
1124
static void
 
1125
_gp_proc_uninstall_read (GIOChannel  *channel,
 
1126
                         WireMessage *msg,
 
1127
                         gpointer     user_data)
 
1128
{
 
1129
  GPProcUninstall *proc_uninstall;
 
1130
 
 
1131
  proc_uninstall = g_new0 (GPProcUninstall, 1);
 
1132
 
 
1133
  if (! wire_read_string (channel, &proc_uninstall->name, 1, user_data))
 
1134
    goto cleanup;
 
1135
 
 
1136
  msg->data = proc_uninstall;
 
1137
  return;
 
1138
 
 
1139
 cleanup:
 
1140
  g_free (proc_uninstall);
 
1141
}
 
1142
 
 
1143
static void
 
1144
_gp_proc_uninstall_write (GIOChannel  *channel,
 
1145
                          WireMessage *msg,
 
1146
                          gpointer     user_data)
 
1147
{
 
1148
  GPProcUninstall *proc_uninstall;
 
1149
 
 
1150
  proc_uninstall = msg->data;
 
1151
 
 
1152
  if (! wire_write_string (channel, &proc_uninstall->name, 1, user_data))
 
1153
    return;
 
1154
}
 
1155
 
 
1156
static void
 
1157
_gp_proc_uninstall_destroy (WireMessage *msg)
 
1158
{
 
1159
  GPProcUninstall *proc_uninstall;
 
1160
 
 
1161
  proc_uninstall = msg->data;
 
1162
 
 
1163
  g_free (proc_uninstall->name);
 
1164
  g_free (proc_uninstall);
 
1165
}
 
1166
 
 
1167
/*  extension_ack  */
 
1168
 
 
1169
static void
 
1170
_gp_extension_ack_read (GIOChannel  *channel,
 
1171
                        WireMessage *msg,
 
1172
                        gpointer     user_data)
 
1173
{
 
1174
}
 
1175
 
 
1176
static void
 
1177
_gp_extension_ack_write (GIOChannel  *channel,
 
1178
                         WireMessage *msg,
 
1179
                         gpointer     user_data)
 
1180
{
 
1181
}
 
1182
 
 
1183
static void
 
1184
_gp_extension_ack_destroy (WireMessage *msg)
 
1185
{
 
1186
}
 
1187
 
 
1188
/*  params  */
 
1189
 
 
1190
static void
 
1191
_gp_params_read (GIOChannel  *channel,
 
1192
                 GPParam    **params,
 
1193
                 guint       *nparams,
 
1194
                 gpointer     user_data)
 
1195
{
 
1196
  gint i, j;
 
1197
 
 
1198
  if (! wire_read_int32 (channel, (guint32*) nparams, 1, user_data))
 
1199
    return;
 
1200
 
 
1201
  if (*nparams == 0)
 
1202
    {
 
1203
      *params = NULL;
 
1204
      return;
 
1205
    }
 
1206
 
 
1207
  *params = g_new0 (GPParam, *nparams);
 
1208
 
 
1209
  for (i = 0; i < *nparams; i++)
 
1210
    {
 
1211
      if (! wire_read_int32 (channel,
 
1212
                             (guint32*) &(*params)[i].type, 1,
 
1213
                             user_data))
 
1214
        goto cleanup;
 
1215
 
 
1216
      switch ((*params)[i].type)
 
1217
        {
 
1218
        case GIMP_PDB_INT32:
 
1219
          if (! wire_read_int32 (channel,
 
1220
                                 (guint32*) &(*params)[i].data.d_int32, 1,
 
1221
                                 user_data))
 
1222
            goto cleanup;
 
1223
          break;
 
1224
 
 
1225
        case GIMP_PDB_INT16:
 
1226
          if (! wire_read_int16 (channel,
 
1227
                                 (guint16*) &(*params)[i].data.d_int16, 1,
 
1228
                                 user_data))
 
1229
            goto cleanup;
 
1230
          break;
 
1231
 
 
1232
        case GIMP_PDB_INT8:
 
1233
          if (! wire_read_int8 (channel,
 
1234
                                (guint8*) &(*params)[i].data.d_int8, 1,
 
1235
                                user_data))
 
1236
            goto cleanup;
 
1237
          break;
 
1238
 
 
1239
        case GIMP_PDB_FLOAT:
 
1240
          if (! wire_read_double (channel,
 
1241
                                  &(*params)[i].data.d_float, 1,
 
1242
                                  user_data))
 
1243
            goto cleanup;
 
1244
          break;
 
1245
 
 
1246
        case GIMP_PDB_STRING:
 
1247
          if (! wire_read_string (channel,
 
1248
                                  &(*params)[i].data.d_string, 1,
 
1249
                                  user_data))
 
1250
            goto cleanup;
 
1251
          break;
 
1252
 
 
1253
        case GIMP_PDB_INT32ARRAY:
 
1254
          (*params)[i-1].data.d_int32 = MAX(0, (*params)[i-1].data.d_int32);
 
1255
          (*params)[i].data.d_int32array =
 
1256
            g_new (gint32, (*params)[i-1].data.d_int32);
 
1257
          if (! wire_read_int32 (channel,
 
1258
                                 (guint32*) (*params)[i].data.d_int32array,
 
1259
                                 (*params)[i-1].data.d_int32,
 
1260
                                 user_data))
 
1261
            {
 
1262
              g_free ((*params)[i].data.d_int32array);
 
1263
              goto cleanup;
 
1264
            }
 
1265
          break;
 
1266
 
 
1267
        case GIMP_PDB_INT16ARRAY:
 
1268
          (*params)[i-1].data.d_int32 = MAX(0, (*params)[i-1].data.d_int32);
 
1269
          (*params)[i].data.d_int16array =
 
1270
            g_new (gint16, (*params)[i-1].data.d_int32);
 
1271
          if (! wire_read_int16 (channel,
 
1272
                                 (guint16*) (*params)[i].data.d_int16array,
 
1273
                                 (*params)[i-1].data.d_int32,
 
1274
                                 user_data))
 
1275
            {
 
1276
              g_free ((*params)[i].data.d_int16array);
 
1277
              goto cleanup;
 
1278
            }
 
1279
          break;
 
1280
 
 
1281
        case GIMP_PDB_INT8ARRAY:
 
1282
          (*params)[i-1].data.d_int32 = MAX(0, (*params)[i-1].data.d_int32);
 
1283
          (*params)[i].data.d_int8array =
 
1284
            g_new (gint8, (*params)[i-1].data.d_int32);
 
1285
          if (! wire_read_int8 (channel,
 
1286
                                (guint8*) (*params)[i].data.d_int8array,
 
1287
                                (*params)[i-1].data.d_int32,
 
1288
                                user_data))
 
1289
            {
 
1290
              g_free ((*params)[i].data.d_int8array);
 
1291
              goto cleanup;
 
1292
            }
 
1293
          break;
 
1294
 
 
1295
        case GIMP_PDB_FLOATARRAY:
 
1296
          (*params)[i-1].data.d_int32 = MAX(0, (*params)[i-1].data.d_int32);
 
1297
          (*params)[i].data.d_floatarray =
 
1298
            g_new (gdouble, (*params)[i-1].data.d_int32);
 
1299
          if (! wire_read_double (channel,
 
1300
                                  (*params)[i].data.d_floatarray,
 
1301
                                  (*params)[i-1].data.d_int32,
 
1302
                                  user_data))
 
1303
            {
 
1304
              g_free ((*params)[i].data.d_floatarray);
 
1305
              goto cleanup;
 
1306
            }
 
1307
          break;
 
1308
 
 
1309
        case GIMP_PDB_STRINGARRAY:
 
1310
          (*params)[i-1].data.d_int32 = MAX(0, (*params)[i-1].data.d_int32);
 
1311
          (*params)[i].data.d_stringarray =
 
1312
            g_new0 (gchar*, (*params)[i-1].data.d_int32);
 
1313
          if (! wire_read_string (channel,
 
1314
                                  (*params)[i].data.d_stringarray,
 
1315
                                  (*params)[i-1].data.d_int32,
 
1316
                                  user_data))
 
1317
            {
 
1318
              for (j = 0; j < (*params)[i-1].data.d_int32; j++)
 
1319
                g_free (((*params)[i].data.d_stringarray)[j]);
 
1320
              g_free ((*params)[i].data.d_stringarray);
 
1321
              goto cleanup;
 
1322
            }
 
1323
          break;
 
1324
 
 
1325
        case GIMP_PDB_COLOR:
 
1326
          if (! wire_read_double (channel,
 
1327
                                  &(*params)[i].data.d_color.r, 1,
 
1328
                                  user_data))
 
1329
            goto cleanup;
 
1330
          if (! wire_read_double (channel,
 
1331
                                  &(*params)[i].data.d_color.g, 1,
 
1332
                                  user_data))
 
1333
            goto cleanup;
 
1334
          if (! wire_read_double (channel,
 
1335
                                  &(*params)[i].data.d_color.b, 1,
 
1336
                                  user_data))
 
1337
            goto cleanup;
 
1338
          if (! wire_read_double (channel,
 
1339
                                  &(*params)[i].data.d_color.a, 1,
 
1340
                                  user_data))
 
1341
            goto cleanup;
 
1342
          break;
 
1343
 
 
1344
        case GIMP_PDB_REGION:
 
1345
          break;
 
1346
 
 
1347
        case GIMP_PDB_DISPLAY:
 
1348
          if (! wire_read_int32 (channel,
 
1349
                                 (guint32*) &(*params)[i].data.d_display, 1,
 
1350
                                 user_data))
 
1351
            goto cleanup;
 
1352
          break;
 
1353
 
 
1354
        case GIMP_PDB_IMAGE:
 
1355
          if (! wire_read_int32 (channel,
 
1356
                                 (guint32*) &(*params)[i].data.d_image, 1,
 
1357
                                 user_data))
 
1358
            goto cleanup;
 
1359
          break;
 
1360
 
 
1361
        case GIMP_PDB_LAYER:
 
1362
          if (! wire_read_int32 (channel,
 
1363
                                 (guint32*) &(*params)[i].data.d_layer, 1,
 
1364
                                 user_data))
 
1365
            goto cleanup;
 
1366
          break;
 
1367
 
 
1368
        case GIMP_PDB_CHANNEL:
 
1369
          if (! wire_read_int32 (channel,
 
1370
                                 (guint32*) &(*params)[i].data.d_channel, 1,
 
1371
                                 user_data))
 
1372
            goto cleanup;
 
1373
          break;
 
1374
 
 
1375
        case GIMP_PDB_DRAWABLE:
 
1376
          if (! wire_read_int32 (channel,
 
1377
                                 (guint32*) &(*params)[i].data.d_drawable, 1,
 
1378
                                 user_data))
 
1379
            goto cleanup;
 
1380
          break;
 
1381
 
 
1382
        case GIMP_PDB_SELECTION:
 
1383
          if (! wire_read_int32 (channel,
 
1384
                                 (guint32*) &(*params)[i].data.d_selection, 1,
 
1385
                                 user_data))
 
1386
            goto cleanup;
 
1387
          break;
 
1388
 
 
1389
        case GIMP_PDB_BOUNDARY:
 
1390
          if (! wire_read_int32 (channel,
 
1391
                                 (guint32*) &(*params)[i].data.d_boundary, 1,
 
1392
                                 user_data))
 
1393
            goto cleanup;
 
1394
          break;
 
1395
 
 
1396
        case GIMP_PDB_PATH:
 
1397
          if (! wire_read_int32 (channel,
 
1398
                                 (guint32*) &(*params)[i].data.d_path, 1,
 
1399
                                 user_data))
 
1400
            goto cleanup;
 
1401
          break;
 
1402
 
 
1403
        case GIMP_PDB_PARASITE:
 
1404
          if (! wire_read_string (channel,
 
1405
                                  &(*params)[i].data.d_parasite.name, 1,
 
1406
                                  user_data))
 
1407
            goto cleanup;
 
1408
          if ((*params)[i].data.d_parasite.name == NULL)
 
1409
            {
 
1410
              /* we have a null parasite */
 
1411
              (*params)[i].data.d_parasite.data = NULL;
 
1412
              break;
 
1413
            }
 
1414
          if (! wire_read_int32 (channel,
 
1415
                                 &((*params)[i].data.d_parasite.flags), 1,
 
1416
                                 user_data))
 
1417
            goto cleanup;
 
1418
          if (! wire_read_int32 (channel,
 
1419
                                 &((*params)[i].data.d_parasite.size), 1,
 
1420
                                 user_data))
 
1421
            goto cleanup;
 
1422
          if ((*params)[i].data.d_parasite.size > 0)
 
1423
            {
 
1424
              (*params)[i].data.d_parasite.data = g_malloc ((*params)[i].data.d_parasite.size);
 
1425
              if (! wire_read_int8 (channel,
 
1426
                                    (*params)[i].data.d_parasite.data,
 
1427
                                    (*params)[i].data.d_parasite.size,
 
1428
                                    user_data))
 
1429
                {
 
1430
                  g_free ((*params)[i].data.d_parasite.data);
 
1431
                  goto cleanup;
 
1432
                }
 
1433
            }
 
1434
          else
 
1435
            (*params)[i].data.d_parasite.data = NULL;
 
1436
          break;
 
1437
 
 
1438
        case GIMP_PDB_STATUS:
 
1439
          if (! wire_read_int32 (channel,
 
1440
                                 (guint32*) &(*params)[i].data.d_status, 1,
 
1441
                                 user_data))
 
1442
            goto cleanup;
 
1443
          break;
 
1444
 
 
1445
        case GIMP_PDB_END:
 
1446
          break;
 
1447
        }
 
1448
    }
 
1449
 
 
1450
  return;
 
1451
 
 
1452
 cleanup:
 
1453
  *nparams = 0;
 
1454
  g_free (*params);
 
1455
  *params = NULL;
 
1456
}
 
1457
 
 
1458
static void
 
1459
_gp_params_write (GIOChannel *channel,
 
1460
                  GPParam    *params,
 
1461
                  gint        nparams,
 
1462
                  gpointer    user_data)
 
1463
{
 
1464
  gint i;
 
1465
 
 
1466
  if (! wire_write_int32 (channel, (guint32*) &nparams, 1, user_data))
 
1467
    return;
 
1468
 
 
1469
  for (i = 0; i < nparams; i++)
 
1470
    {
 
1471
      if (! wire_write_int32 (channel,
 
1472
                              (guint32*) &params[i].type, 1,
 
1473
                              user_data))
 
1474
        return;
 
1475
 
 
1476
      switch (params[i].type)
 
1477
        {
 
1478
        case GIMP_PDB_INT32:
 
1479
          if (! wire_write_int32 (channel,
 
1480
                                  (guint32*) &params[i].data.d_int32, 1,
 
1481
                                  user_data))
 
1482
            return;
 
1483
          break;
 
1484
 
 
1485
        case GIMP_PDB_INT16:
 
1486
          if (! wire_write_int16 (channel,
 
1487
                                  (guint16*) &params[i].data.d_int16, 1,
 
1488
                                  user_data))
 
1489
            return;
 
1490
          break;
 
1491
 
 
1492
        case GIMP_PDB_INT8:
 
1493
          if (! wire_write_int8 (channel,
 
1494
                                 (guint8*) &params[i].data.d_int8, 1,
 
1495
                                 user_data))
 
1496
            return;
 
1497
          break;
 
1498
 
 
1499
        case GIMP_PDB_FLOAT:
 
1500
          if (! wire_write_double (channel,
 
1501
                                   &params[i].data.d_float, 1,
 
1502
                                   user_data))
 
1503
            return;
 
1504
          break;
 
1505
 
 
1506
        case GIMP_PDB_STRING:
 
1507
          if (! wire_write_string (channel,
 
1508
                                   &params[i].data.d_string, 1,
 
1509
                                   user_data))
 
1510
            return;
 
1511
          break;
 
1512
 
 
1513
        case GIMP_PDB_INT32ARRAY:
 
1514
          if (! wire_write_int32 (channel,
 
1515
                                  (guint32*) params[i].data.d_int32array,
 
1516
                                  params[i-1].data.d_int32,
 
1517
                                  user_data))
 
1518
            return;
 
1519
          break;
 
1520
 
 
1521
        case GIMP_PDB_INT16ARRAY:
 
1522
          if (! wire_write_int16 (channel,
 
1523
                                  (guint16*) params[i].data.d_int16array,
 
1524
                                  params[i-1].data.d_int32,
 
1525
                                  user_data))
 
1526
            return;
 
1527
          break;
 
1528
 
 
1529
        case GIMP_PDB_INT8ARRAY:
 
1530
          if (! wire_write_int8 (channel,
 
1531
                                 (guint8*) params[i].data.d_int8array,
 
1532
                                 params[i-1].data.d_int32,
 
1533
                                 user_data))
 
1534
            return;
 
1535
          break;
 
1536
 
 
1537
        case GIMP_PDB_FLOATARRAY:
 
1538
          if (! wire_write_double (channel,
 
1539
                                   params[i].data.d_floatarray,
 
1540
                                   params[i-1].data.d_int32,
 
1541
                                   user_data))
 
1542
            return;
 
1543
          break;
 
1544
 
 
1545
        case GIMP_PDB_STRINGARRAY:
 
1546
          if (! wire_write_string (channel,
 
1547
                                   params[i].data.d_stringarray,
 
1548
                                   params[i-1].data.d_int32,
 
1549
                                   user_data))
 
1550
            return;
 
1551
          break;
 
1552
 
 
1553
        case GIMP_PDB_COLOR:
 
1554
          {
 
1555
            GimpRGB *color = (GimpRGB *) &params[i].data.d_color;
 
1556
            if (! wire_write_double (channel, &color->r, 1, user_data))
 
1557
              return;
 
1558
            if (! wire_write_double (channel, &color->g, 1, user_data))
 
1559
              return;
 
1560
            if (! wire_write_double (channel, &color->b, 1, user_data))
 
1561
              return;
 
1562
            if (! wire_write_double (channel, &color->a, 1, user_data))
 
1563
              return;
 
1564
          }
 
1565
          break;
 
1566
 
 
1567
        case GIMP_PDB_REGION:
 
1568
          break;
 
1569
 
 
1570
        case GIMP_PDB_DISPLAY:
 
1571
          if (! wire_write_int32 (channel,
 
1572
                                  (guint32*) &params[i].data.d_display, 1,
 
1573
                                  user_data))
 
1574
            return;
 
1575
          break;
 
1576
 
 
1577
        case GIMP_PDB_IMAGE:
 
1578
          if (! wire_write_int32 (channel,
 
1579
                                  (guint32*) &params[i].data.d_image, 1,
 
1580
                                  user_data))
 
1581
            return;
 
1582
          break;
 
1583
 
 
1584
        case GIMP_PDB_LAYER:
 
1585
          if (! wire_write_int32 (channel,
 
1586
                                  (guint32*) &params[i].data.d_layer, 1,
 
1587
                                  user_data))
 
1588
            return;
 
1589
          break;
 
1590
 
 
1591
        case GIMP_PDB_CHANNEL:
 
1592
          if (! wire_write_int32 (channel,
 
1593
                                  (guint32*) &params[i].data.d_channel, 1,
 
1594
                                  user_data))
 
1595
            return;
 
1596
          break;
 
1597
 
 
1598
        case GIMP_PDB_DRAWABLE:
 
1599
          if (! wire_write_int32 (channel,
 
1600
                                  (guint32*) &params[i].data.d_drawable, 1,
 
1601
                                  user_data))
 
1602
            return;
 
1603
          break;
 
1604
 
 
1605
        case GIMP_PDB_SELECTION:
 
1606
          if (! wire_write_int32 (channel,
 
1607
                                  (guint32*) &params[i].data.d_selection, 1,
 
1608
                                  user_data))
 
1609
            return;
 
1610
          break;
 
1611
 
 
1612
        case GIMP_PDB_BOUNDARY:
 
1613
          if (! wire_write_int32 (channel,
 
1614
                                  (guint32*) &params[i].data.d_boundary, 1,
 
1615
                                  user_data))
 
1616
            return;
 
1617
          break;
 
1618
 
 
1619
        case GIMP_PDB_PATH:
 
1620
          if (! wire_write_int32 (channel,
 
1621
                                  (guint32*) &params[i].data.d_path, 1,
 
1622
                                  user_data))
 
1623
            return;
 
1624
          break;
 
1625
 
 
1626
        case GIMP_PDB_PARASITE:
 
1627
          {
 
1628
            GimpParasite *p = (GimpParasite *) &params[i].data.d_parasite;
 
1629
            if (p->name == NULL)
 
1630
              {
 
1631
                /* write a null string to signifly a null parasite */
 
1632
                wire_write_string (channel,  &p->name, 1, user_data);
 
1633
                break;
 
1634
              }
 
1635
            if (! wire_write_string (channel, &p->name, 1, user_data))
 
1636
              return;
 
1637
            if (! wire_write_int32 (channel, &p->flags, 1, user_data))
 
1638
              return;
 
1639
            if (! wire_write_int32 (channel, &p->size, 1, user_data))
 
1640
              return;
 
1641
            if (p->size > 0)
 
1642
              {
 
1643
                if (! wire_write_int8 (channel, p->data, p->size, user_data))
 
1644
                  return;
 
1645
              }
 
1646
          }
 
1647
          break;
 
1648
 
 
1649
        case GIMP_PDB_STATUS:
 
1650
          if (! wire_write_int32 (channel,
 
1651
                                  (guint32*) &params[i].data.d_status, 1,
 
1652
                                  user_data))
 
1653
            return;
 
1654
          break;
 
1655
 
 
1656
        case GIMP_PDB_END:
 
1657
          break;
 
1658
        }
 
1659
    }
 
1660
}
 
1661
 
 
1662
void
 
1663
_gp_params_destroy (GPParam *params,
 
1664
                    gint     nparams)
 
1665
{
 
1666
  gint count;
 
1667
  gint i, j;
 
1668
 
 
1669
  for (i = 0; i < nparams; i++)
 
1670
    {
 
1671
      switch (params[i].type)
 
1672
        {
 
1673
        case GIMP_PDB_INT32:
 
1674
        case GIMP_PDB_INT16:
 
1675
        case GIMP_PDB_INT8:
 
1676
        case GIMP_PDB_FLOAT:
 
1677
        case GIMP_PDB_COLOR:
 
1678
        case GIMP_PDB_REGION:
 
1679
        case GIMP_PDB_DISPLAY:
 
1680
        case GIMP_PDB_IMAGE:
 
1681
        case GIMP_PDB_LAYER:
 
1682
        case GIMP_PDB_CHANNEL:
 
1683
        case GIMP_PDB_DRAWABLE:
 
1684
        case GIMP_PDB_SELECTION:
 
1685
        case GIMP_PDB_BOUNDARY:
 
1686
        case GIMP_PDB_PATH:
 
1687
        case GIMP_PDB_STATUS:
 
1688
          break;
 
1689
 
 
1690
        case GIMP_PDB_STRING:
 
1691
          g_free (params[i].data.d_string);
 
1692
          break;
 
1693
 
 
1694
        case GIMP_PDB_INT32ARRAY:
 
1695
          g_free (params[i].data.d_int32array);
 
1696
          break;
 
1697
 
 
1698
        case GIMP_PDB_INT16ARRAY:
 
1699
          g_free (params[i].data.d_int16array);
 
1700
          break;
 
1701
 
 
1702
        case GIMP_PDB_INT8ARRAY:
 
1703
          g_free (params[i].data.d_int8array);
 
1704
          break;
 
1705
 
 
1706
        case GIMP_PDB_FLOATARRAY:
 
1707
          g_free (params[i].data.d_floatarray);
 
1708
          break;
 
1709
 
 
1710
        case GIMP_PDB_STRINGARRAY:
 
1711
          if ((i > 0) && (params[i-1].type == GIMP_PDB_INT32))
 
1712
            {
 
1713
              count = params[i-1].data.d_int32;
 
1714
              for (j = 0; j < count; j++)
 
1715
                g_free (params[i].data.d_stringarray[j]);
 
1716
              g_free (params[i].data.d_stringarray);
 
1717
            }
 
1718
          break;
 
1719
 
 
1720
        case GIMP_PDB_PARASITE:
 
1721
          if (params[i].data.d_parasite.name)
 
1722
            g_free(params[i].data.d_parasite.name);
 
1723
          if (params[i].data.d_parasite.data)
 
1724
            g_free(params[i].data.d_parasite.data);
 
1725
          break;
 
1726
 
 
1727
        case GIMP_PDB_END:
 
1728
          break;
 
1729
        }
 
1730
    }
 
1731
 
 
1732
  g_free (params);
 
1733
}
 
1734
 
 
1735
/* has_init */
 
1736
 
 
1737
static void
 
1738
_gp_has_init_read (GIOChannel  *channel,
 
1739
                   WireMessage *msg,
 
1740
                   gpointer     user_data)
 
1741
{
 
1742
}
 
1743
 
 
1744
static void
 
1745
_gp_has_init_write (GIOChannel  *channel,
 
1746
                    WireMessage *msg,
 
1747
                    gpointer     user_data)
 
1748
{
 
1749
}
 
1750
 
 
1751
static void
 
1752
_gp_has_init_destroy (WireMessage *msg)
 
1753
{
 
1754
}
 
1755