1
/* LIBGIMP - The GIMP Library
2
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
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.
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.
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.
22
#include <glib-object.h>
24
#include "gimpbasetypes.h"
26
#include "gimpparasite.h"
27
#include "gimpprotocol.h"
31
static void _gp_quit_read (GIOChannel *channel,
34
static void _gp_quit_write (GIOChannel *channel,
37
static void _gp_quit_destroy (WireMessage *msg);
39
static void _gp_config_read (GIOChannel *channel,
42
static void _gp_config_write (GIOChannel *channel,
45
static void _gp_config_destroy (WireMessage *msg);
47
static void _gp_tile_req_read (GIOChannel *channel,
50
static void _gp_tile_req_write (GIOChannel *channel,
53
static void _gp_tile_req_destroy (WireMessage *msg);
55
static void _gp_tile_ack_read (GIOChannel *channel,
58
static void _gp_tile_ack_write (GIOChannel *channel,
61
static void _gp_tile_ack_destroy (WireMessage *msg);
63
static void _gp_tile_data_read (GIOChannel *channel,
66
static void _gp_tile_data_write (GIOChannel *channel,
69
static void _gp_tile_data_destroy (WireMessage *msg);
71
static void _gp_proc_run_read (GIOChannel *channel,
74
static void _gp_proc_run_write (GIOChannel *channel,
77
static void _gp_proc_run_destroy (WireMessage *msg);
79
static void _gp_proc_return_read (GIOChannel *channel,
82
static void _gp_proc_return_write (GIOChannel *channel,
85
static void _gp_proc_return_destroy (WireMessage *msg);
87
static void _gp_temp_proc_run_read (GIOChannel *channel,
90
static void _gp_temp_proc_run_write (GIOChannel *channel,
93
static void _gp_temp_proc_run_destroy (WireMessage *msg);
95
static void _gp_temp_proc_return_read (GIOChannel *channel,
98
static void _gp_temp_proc_return_write (GIOChannel *channel,
101
static void _gp_temp_proc_return_destroy (WireMessage *msg);
103
static void _gp_proc_install_read (GIOChannel *channel,
106
static void _gp_proc_install_write (GIOChannel *channel,
109
static void _gp_proc_install_destroy (WireMessage *msg);
111
static void _gp_proc_uninstall_read (GIOChannel *channel,
114
static void _gp_proc_uninstall_write (GIOChannel *channel,
117
static void _gp_proc_uninstall_destroy (WireMessage *msg);
119
static void _gp_extension_ack_read (GIOChannel *channel,
122
static void _gp_extension_ack_write (GIOChannel *channel,
125
static void _gp_extension_ack_destroy (WireMessage *msg);
127
static void _gp_params_read (GIOChannel *channel,
131
static void _gp_params_write (GIOChannel *channel,
136
/* used by gimp.c:gimp_destroy_params() */
137
void _gp_params_destroy (GPParam *params,
140
static void _gp_has_init_read (GIOChannel *channel,
143
static void _gp_has_init_write (GIOChannel *channel,
146
static void _gp_has_init_destroy (WireMessage *msg);
153
wire_register (GP_QUIT,
157
wire_register (GP_CONFIG,
161
wire_register (GP_TILE_REQ,
164
_gp_tile_req_destroy);
165
wire_register (GP_TILE_ACK,
168
_gp_tile_ack_destroy);
169
wire_register (GP_TILE_DATA,
172
_gp_tile_data_destroy);
173
wire_register (GP_PROC_RUN,
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,
204
_gp_has_init_destroy);
208
gp_quit_write (GIOChannel *channel,
216
if (! wire_write_msg (channel, &msg, user_data))
218
if (! wire_flush (channel, user_data))
224
gp_config_write (GIOChannel *channel,
230
msg.type = GP_CONFIG;
233
if (! wire_write_msg (channel, &msg, user_data))
235
if (! wire_flush (channel, user_data))
241
gp_tile_req_write (GIOChannel *channel,
247
msg.type = GP_TILE_REQ;
250
if (! wire_write_msg (channel, &msg, user_data))
252
if (! wire_flush (channel, user_data))
258
gp_tile_ack_write (GIOChannel *channel,
263
msg.type = GP_TILE_ACK;
266
if (! wire_write_msg (channel, &msg, user_data))
268
if (! wire_flush (channel, user_data))
274
gp_tile_data_write (GIOChannel *channel,
275
GPTileData *tile_data,
280
msg.type = GP_TILE_DATA;
281
msg.data = tile_data;
283
if (! wire_write_msg (channel, &msg, user_data))
285
if (! wire_flush (channel, user_data))
291
gp_proc_run_write (GIOChannel *channel,
297
msg.type = GP_PROC_RUN;
300
if (! wire_write_msg (channel, &msg, user_data))
302
if (! wire_flush (channel, user_data))
308
gp_proc_return_write (GIOChannel *channel,
309
GPProcReturn *proc_return,
314
msg.type = GP_PROC_RETURN;
315
msg.data = proc_return;
317
if (! wire_write_msg (channel, &msg, user_data))
319
if (! wire_flush (channel, user_data))
325
gp_temp_proc_run_write (GIOChannel *channel,
331
msg.type = GP_TEMP_PROC_RUN;
334
if (! wire_write_msg (channel, &msg, user_data))
336
if (! wire_flush (channel, user_data))
342
gp_temp_proc_return_write (GIOChannel *channel,
343
GPProcReturn *proc_return,
348
msg.type = GP_TEMP_PROC_RETURN;
349
msg.data = proc_return;
351
if (! wire_write_msg (channel, &msg, user_data))
353
if (! wire_flush (channel, user_data))
359
gp_proc_install_write (GIOChannel *channel,
360
GPProcInstall *proc_install,
365
msg.type = GP_PROC_INSTALL;
366
msg.data = proc_install;
368
if (! wire_write_msg (channel, &msg, user_data))
370
if (! wire_flush (channel, user_data))
376
gp_proc_uninstall_write (GIOChannel *channel,
377
GPProcUninstall *proc_uninstall,
382
msg.type = GP_PROC_UNINSTALL;
383
msg.data = proc_uninstall;
385
if (! wire_write_msg (channel, &msg, user_data))
387
if (! wire_flush (channel, user_data))
393
gp_extension_ack_write (GIOChannel *channel,
398
msg.type = GP_EXTENSION_ACK;
401
if (! wire_write_msg (channel, &msg, user_data))
403
if (! wire_flush (channel, user_data))
409
gp_has_init_write (GIOChannel *channel,
414
msg.type = GP_HAS_INIT;
417
if (! wire_write_msg (channel, &msg, user_data))
419
if (! wire_flush (channel, user_data))
427
_gp_quit_read (GIOChannel *channel,
434
_gp_quit_write (GIOChannel *channel,
441
_gp_quit_destroy (WireMessage *msg)
448
_gp_config_read (GIOChannel *channel,
454
config = g_new0 (GPConfig, 1);
456
if (! wire_read_int32 (channel,
457
&config->version, 1, user_data))
459
if (! wire_read_int32 (channel,
460
&config->tile_width, 1, user_data))
462
if (! wire_read_int32 (channel,
463
&config->tile_height, 1, user_data))
465
if (! wire_read_int32 (channel,
466
(guint32 *) &config->shm_ID, 1, user_data))
468
if (! wire_read_int8 (channel,
469
(guint8 *) &config->check_size, 1, user_data))
471
if (! wire_read_int8 (channel,
472
(guint8 *) &config->check_type, 1, user_data))
474
if (! wire_read_int8 (channel,
475
(guint8 *) &config->show_help_button, 1, user_data))
477
if (! wire_read_int8 (channel,
478
(guint8 *) &config->gimp_reserved_4, 1, user_data))
480
if (! wire_read_int8 (channel,
481
(guint8 *) &config->gimp_reserved_5, 1, user_data))
483
if (! wire_read_int8 (channel,
484
(guint8 *) &config->gimp_reserved_6, 1, user_data))
486
if (! wire_read_int8 (channel,
487
(guint8 *) &config->gimp_reserved_7, 1, user_data))
489
if (! wire_read_int8 (channel,
490
(guint8 *) &config->gimp_reserved_8, 1, user_data))
492
if (! wire_read_int8 (channel,
493
(guint8 *) &config->install_cmap, 1, user_data))
495
if (! wire_read_int8 (channel,
496
(guint8 *) &config->show_tool_tips, 1, user_data))
498
if (! wire_read_int32 (channel,
499
(guint32 *) &config->min_colors, 1, user_data))
501
if (! wire_read_int32 (channel,
502
(guint32 *) &config->gdisp_ID, 1, user_data))
505
if (! wire_read_string (channel,
506
&config->app_name, 1, user_data))
508
if (! wire_read_string (channel,
509
&config->wm_class, 1, user_data))
511
if (! wire_read_string (channel,
512
&config->display_name, 1, user_data))
514
if (! wire_read_int32 (channel,
515
(guint32 *) &config->monitor_number, 1, user_data))
522
g_free (config->app_name);
523
g_free (config->wm_class);
524
g_free (config->display_name);
529
_gp_config_write (GIOChannel *channel,
536
if (! wire_write_int32 (channel, &config->version, 1, user_data))
538
if (! wire_write_int32 (channel, &config->tile_width, 1, user_data))
540
if (! wire_write_int32 (channel, &config->tile_height, 1, user_data))
542
if (! wire_write_int32 (channel, (guint32*) &config->shm_ID, 1, user_data))
544
if (! wire_write_int8 (channel, (guint8*) &config->check_size, 1, user_data))
546
if (! wire_write_int8 (channel, (guint8*) &config->check_type, 1, user_data))
548
if (! wire_write_int8 (channel, (guint8*) &config->show_help_button, 1, user_data))
550
if (! wire_write_int8 (channel, (guint8*) &config->gimp_reserved_4, 1, user_data))
552
if (! wire_write_int8 (channel, (guint8*) &config->gimp_reserved_5, 1, user_data))
554
if (! wire_write_int8 (channel, (guint8*) &config->gimp_reserved_6, 1, user_data))
556
if (! wire_write_int8 (channel, (guint8*) &config->gimp_reserved_7, 1, user_data))
558
if (! wire_write_int8 (channel, (guint8*) &config->gimp_reserved_8, 1, user_data))
560
if (! wire_write_int8 (channel, (guint8*) &config->install_cmap, 1, user_data))
562
if (! wire_write_int8 (channel, (guint8*) &config->show_tool_tips, 1, user_data))
564
if (! wire_write_int32 (channel, (guint32*) &config->min_colors, 1, user_data))
566
if (! wire_write_int32 (channel, (guint32*) &config->gdisp_ID, 1, user_data))
568
if (! wire_write_string (channel, &config->app_name, 1, user_data))
570
if (! wire_write_string (channel, &config->wm_class, 1, user_data))
572
if (! wire_write_string (channel, &config->display_name, 1, user_data))
574
if (! wire_write_int32 (channel, (guint32*) &config->monitor_number, 1, user_data))
579
_gp_config_destroy (WireMessage *msg)
585
g_free (config->app_name);
586
g_free (config->wm_class);
587
g_free (config->display_name);
594
_gp_tile_req_read (GIOChannel *channel,
600
tile_req = g_new0 (GPTileReq, 1);
602
if (! wire_read_int32 (channel, (guint32*) &tile_req->drawable_ID, 1,
605
if (! wire_read_int32 (channel, &tile_req->tile_num, 1, user_data))
607
if (! wire_read_int32 (channel, &tile_req->shadow, 1, user_data))
610
msg->data = tile_req;
618
_gp_tile_req_write (GIOChannel *channel,
624
tile_req = msg->data;
625
if (! wire_write_int32 (channel, (guint32*) &tile_req->drawable_ID, 1,
628
if (! wire_write_int32 (channel, &tile_req->tile_num, 1, user_data))
630
if (! wire_write_int32 (channel, &tile_req->shadow, 1, user_data))
635
_gp_tile_req_destroy (WireMessage *msg)
643
_gp_tile_ack_read (GIOChannel *channel,
650
_gp_tile_ack_write (GIOChannel *channel,
657
_gp_tile_ack_destroy (WireMessage *msg)
664
_gp_tile_data_read (GIOChannel *channel,
668
GPTileData *tile_data;
671
tile_data = g_new0 (GPTileData, 1);
673
if (! wire_read_int32 (channel, (guint32*) &tile_data->drawable_ID, 1,
676
if (! wire_read_int32 (channel, &tile_data->tile_num, 1, user_data))
678
if (! wire_read_int32 (channel, &tile_data->shadow, 1, user_data))
680
if (! wire_read_int32 (channel, &tile_data->bpp, 1, user_data))
682
if (! wire_read_int32 (channel, &tile_data->width, 1, user_data))
684
if (! wire_read_int32 (channel, &tile_data->height, 1, user_data))
686
if (! wire_read_int32 (channel, &tile_data->use_shm, 1, user_data))
689
if (!tile_data->use_shm)
691
length = tile_data->width * tile_data->height * tile_data->bpp;
692
tile_data->data = g_new (guchar, length);
694
if (! wire_read_int8 (channel, (guint8*) tile_data->data, length,
699
msg->data = tile_data;
703
g_free (tile_data->data);
708
_gp_tile_data_write (GIOChannel *channel,
712
GPTileData *tile_data;
715
tile_data = msg->data;
716
if (! wire_write_int32 (channel, (guint32*) &tile_data->drawable_ID, 1,
719
if (! wire_write_int32 (channel, &tile_data->tile_num, 1, user_data))
721
if (! wire_write_int32 (channel, &tile_data->shadow, 1, user_data))
723
if (! wire_write_int32 (channel, &tile_data->bpp, 1, user_data))
725
if (! wire_write_int32 (channel, &tile_data->width, 1, user_data))
727
if (! wire_write_int32 (channel, &tile_data->height, 1, user_data))
729
if (! wire_write_int32 (channel, &tile_data->use_shm, 1, user_data))
732
if (!tile_data->use_shm)
734
length = tile_data->width * tile_data->height * tile_data->bpp;
735
if (! wire_write_int8 (channel, (guint8*) tile_data->data, length,
742
_gp_tile_data_destroy (WireMessage *msg)
744
GPTileData *tile_data;
746
tile_data = msg->data;
748
g_free (tile_data->data);
755
_gp_proc_run_read (GIOChannel *channel,
761
proc_run = g_new0 (GPProcRun, 1);
763
if (! wire_read_string (channel, &proc_run->name, 1, user_data))
766
_gp_params_read (channel,
767
&proc_run->params, (guint*) &proc_run->nparams,
770
msg->data = proc_run;
778
_gp_proc_run_write (GIOChannel *channel,
784
proc_run = msg->data;
786
if (! wire_write_string (channel, &proc_run->name, 1, user_data))
789
_gp_params_write (channel, proc_run->params, proc_run->nparams, user_data);
793
_gp_proc_run_destroy (WireMessage *msg)
797
proc_run = msg->data;
798
_gp_params_destroy (proc_run->params, proc_run->nparams);
800
g_free (proc_run->name);
807
_gp_proc_return_read (GIOChannel *channel,
811
GPProcReturn *proc_return;
813
proc_return = g_new0 (GPProcReturn, 1);
815
if (! wire_read_string (channel, &proc_return->name, 1, user_data))
818
_gp_params_read (channel,
819
&proc_return->params, (guint*) &proc_return->nparams,
822
msg->data = proc_return;
826
g_free (proc_return);
830
_gp_proc_return_write (GIOChannel *channel,
834
GPProcReturn *proc_return;
836
proc_return = msg->data;
838
if (! wire_write_string (channel, &proc_return->name, 1, user_data))
841
_gp_params_write (channel, proc_return->params, proc_return->nparams,
846
_gp_proc_return_destroy (WireMessage *msg)
848
GPProcReturn *proc_return;
850
proc_return = msg->data;
851
_gp_params_destroy (proc_return->params, proc_return->nparams);
853
g_free (proc_return->name);
854
g_free (proc_return);
860
_gp_temp_proc_run_read (GIOChannel *channel,
864
_gp_proc_run_read (channel, msg, user_data);
868
_gp_temp_proc_run_write (GIOChannel *channel,
872
_gp_proc_run_write (channel, msg, user_data);
876
_gp_temp_proc_run_destroy (WireMessage *msg)
878
_gp_proc_run_destroy (msg);
881
/* temp_proc_return */
884
_gp_temp_proc_return_read (GIOChannel *channel,
888
_gp_proc_return_read (channel, msg, user_data);
892
_gp_temp_proc_return_write (GIOChannel *channel,
896
_gp_proc_return_write (channel, msg, user_data);
900
_gp_temp_proc_return_destroy (WireMessage *msg)
902
_gp_proc_return_destroy (msg);
908
_gp_proc_install_read (GIOChannel *channel,
912
GPProcInstall *proc_install;
915
proc_install = g_new0 (GPProcInstall, 1);
917
if (! wire_read_string (channel, &proc_install->name, 1, user_data))
919
if (! wire_read_string (channel, &proc_install->blurb, 1, user_data))
921
if (! wire_read_string (channel, &proc_install->help, 1, user_data))
923
if (! wire_read_string (channel, &proc_install->author, 1, user_data))
925
if (! wire_read_string (channel, &proc_install->copyright, 1, user_data))
927
if (! wire_read_string (channel, &proc_install->date, 1, user_data))
929
if (! wire_read_string (channel, &proc_install->menu_path, 1, user_data))
931
if (! wire_read_string (channel, &proc_install->image_types, 1, user_data))
934
if (! wire_read_int32 (channel, &proc_install->type, 1, user_data))
936
if (! wire_read_int32 (channel, &proc_install->nparams, 1, user_data))
938
if (! wire_read_int32 (channel, &proc_install->nreturn_vals, 1, user_data))
941
proc_install->params = g_new0 (GPParamDef, proc_install->nparams);
943
for (i = 0; i < proc_install->nparams; i++)
945
if (! wire_read_int32 (channel,
946
(guint32*) &proc_install->params[i].type, 1,
949
if (! wire_read_string (channel,
950
&proc_install->params[i].name, 1,
953
if (! wire_read_string (channel,
954
&proc_install->params[i].description, 1,
959
proc_install->return_vals = g_new0 (GPParamDef, proc_install->nreturn_vals);
961
for (i = 0; i < proc_install->nreturn_vals; i++)
963
if (! wire_read_int32 (channel,
964
(guint32*) &proc_install->return_vals[i].type, 1,
967
if (! wire_read_string (channel,
968
&proc_install->return_vals[i].name, 1,
971
if (! wire_read_string (channel,
972
&proc_install->return_vals[i].description, 1,
977
msg->data = proc_install;
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);
990
if (proc_install->params)
992
for (i = 0; i < proc_install->nparams; i++)
994
if (!proc_install->params[i].name)
997
g_free (proc_install->params[i].name);
998
g_free (proc_install->params[i].description);
1001
g_free (proc_install->params);
1004
if (proc_install->return_vals)
1006
for (i = 0; i < proc_install->nreturn_vals; i++)
1008
if (!proc_install->return_vals[i].name)
1011
g_free (proc_install->return_vals[i].name);
1012
g_free (proc_install->return_vals[i].description);
1015
g_free (proc_install->return_vals);
1018
g_free (proc_install);
1022
_gp_proc_install_write (GIOChannel *channel,
1026
GPProcInstall *proc_install;
1029
proc_install = msg->data;
1031
if (! wire_write_string (channel, &proc_install->name, 1, user_data))
1033
if (! wire_write_string (channel, &proc_install->blurb, 1, user_data))
1035
if (! wire_write_string (channel, &proc_install->help, 1, user_data))
1037
if (! wire_write_string (channel, &proc_install->author, 1, user_data))
1039
if (! wire_write_string (channel, &proc_install->copyright, 1, user_data))
1041
if (! wire_write_string (channel, &proc_install->date, 1, user_data))
1043
if (! wire_write_string (channel, &proc_install->menu_path, 1, user_data))
1045
if (! wire_write_string (channel, &proc_install->image_types, 1, user_data))
1048
if (! wire_write_int32 (channel, &proc_install->type, 1, user_data))
1050
if (! wire_write_int32 (channel, &proc_install->nparams, 1, user_data))
1052
if (! wire_write_int32 (channel, &proc_install->nreturn_vals, 1, user_data))
1055
for (i = 0; i < proc_install->nparams; i++)
1057
if (! wire_write_int32 (channel,
1058
(guint32*) &proc_install->params[i].type, 1,
1061
if (! wire_write_string (channel,
1062
&proc_install->params[i].name, 1,
1065
if (! wire_write_string (channel,
1066
&proc_install->params[i].description, 1,
1071
for (i = 0; i < proc_install->nreturn_vals; i++)
1073
if (! wire_write_int32 (channel,
1074
(guint32*) &proc_install->return_vals[i].type, 1,
1077
if (! wire_write_string (channel,
1078
&proc_install->return_vals[i].name, 1,
1081
if (! wire_write_string (channel,
1082
&proc_install->return_vals[i].description, 1,
1089
_gp_proc_install_destroy (WireMessage *msg)
1091
GPProcInstall *proc_install;
1094
proc_install = msg->data;
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);
1105
for (i = 0; i < proc_install->nparams; i++)
1107
g_free (proc_install->params[i].name);
1108
g_free (proc_install->params[i].description);
1111
for (i = 0; i < proc_install->nreturn_vals; i++)
1113
g_free (proc_install->return_vals[i].name);
1114
g_free (proc_install->return_vals[i].description);
1117
g_free (proc_install->params);
1118
g_free (proc_install->return_vals);
1119
g_free (proc_install);
1122
/* proc_uninstall */
1125
_gp_proc_uninstall_read (GIOChannel *channel,
1129
GPProcUninstall *proc_uninstall;
1131
proc_uninstall = g_new0 (GPProcUninstall, 1);
1133
if (! wire_read_string (channel, &proc_uninstall->name, 1, user_data))
1136
msg->data = proc_uninstall;
1140
g_free (proc_uninstall);
1144
_gp_proc_uninstall_write (GIOChannel *channel,
1148
GPProcUninstall *proc_uninstall;
1150
proc_uninstall = msg->data;
1152
if (! wire_write_string (channel, &proc_uninstall->name, 1, user_data))
1157
_gp_proc_uninstall_destroy (WireMessage *msg)
1159
GPProcUninstall *proc_uninstall;
1161
proc_uninstall = msg->data;
1163
g_free (proc_uninstall->name);
1164
g_free (proc_uninstall);
1170
_gp_extension_ack_read (GIOChannel *channel,
1177
_gp_extension_ack_write (GIOChannel *channel,
1184
_gp_extension_ack_destroy (WireMessage *msg)
1191
_gp_params_read (GIOChannel *channel,
1198
if (! wire_read_int32 (channel, (guint32*) nparams, 1, user_data))
1207
*params = g_new0 (GPParam, *nparams);
1209
for (i = 0; i < *nparams; i++)
1211
if (! wire_read_int32 (channel,
1212
(guint32*) &(*params)[i].type, 1,
1216
switch ((*params)[i].type)
1218
case GIMP_PDB_INT32:
1219
if (! wire_read_int32 (channel,
1220
(guint32*) &(*params)[i].data.d_int32, 1,
1225
case GIMP_PDB_INT16:
1226
if (! wire_read_int16 (channel,
1227
(guint16*) &(*params)[i].data.d_int16, 1,
1233
if (! wire_read_int8 (channel,
1234
(guint8*) &(*params)[i].data.d_int8, 1,
1239
case GIMP_PDB_FLOAT:
1240
if (! wire_read_double (channel,
1241
&(*params)[i].data.d_float, 1,
1246
case GIMP_PDB_STRING:
1247
if (! wire_read_string (channel,
1248
&(*params)[i].data.d_string, 1,
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,
1262
g_free ((*params)[i].data.d_int32array);
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,
1276
g_free ((*params)[i].data.d_int16array);
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,
1290
g_free ((*params)[i].data.d_int8array);
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,
1304
g_free ((*params)[i].data.d_floatarray);
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,
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);
1325
case GIMP_PDB_COLOR:
1326
if (! wire_read_double (channel,
1327
&(*params)[i].data.d_color.r, 1,
1330
if (! wire_read_double (channel,
1331
&(*params)[i].data.d_color.g, 1,
1334
if (! wire_read_double (channel,
1335
&(*params)[i].data.d_color.b, 1,
1338
if (! wire_read_double (channel,
1339
&(*params)[i].data.d_color.a, 1,
1344
case GIMP_PDB_REGION:
1347
case GIMP_PDB_DISPLAY:
1348
if (! wire_read_int32 (channel,
1349
(guint32*) &(*params)[i].data.d_display, 1,
1354
case GIMP_PDB_IMAGE:
1355
if (! wire_read_int32 (channel,
1356
(guint32*) &(*params)[i].data.d_image, 1,
1361
case GIMP_PDB_LAYER:
1362
if (! wire_read_int32 (channel,
1363
(guint32*) &(*params)[i].data.d_layer, 1,
1368
case GIMP_PDB_CHANNEL:
1369
if (! wire_read_int32 (channel,
1370
(guint32*) &(*params)[i].data.d_channel, 1,
1375
case GIMP_PDB_DRAWABLE:
1376
if (! wire_read_int32 (channel,
1377
(guint32*) &(*params)[i].data.d_drawable, 1,
1382
case GIMP_PDB_SELECTION:
1383
if (! wire_read_int32 (channel,
1384
(guint32*) &(*params)[i].data.d_selection, 1,
1389
case GIMP_PDB_BOUNDARY:
1390
if (! wire_read_int32 (channel,
1391
(guint32*) &(*params)[i].data.d_boundary, 1,
1397
if (! wire_read_int32 (channel,
1398
(guint32*) &(*params)[i].data.d_path, 1,
1403
case GIMP_PDB_PARASITE:
1404
if (! wire_read_string (channel,
1405
&(*params)[i].data.d_parasite.name, 1,
1408
if ((*params)[i].data.d_parasite.name == NULL)
1410
/* we have a null parasite */
1411
(*params)[i].data.d_parasite.data = NULL;
1414
if (! wire_read_int32 (channel,
1415
&((*params)[i].data.d_parasite.flags), 1,
1418
if (! wire_read_int32 (channel,
1419
&((*params)[i].data.d_parasite.size), 1,
1422
if ((*params)[i].data.d_parasite.size > 0)
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,
1430
g_free ((*params)[i].data.d_parasite.data);
1435
(*params)[i].data.d_parasite.data = NULL;
1438
case GIMP_PDB_STATUS:
1439
if (! wire_read_int32 (channel,
1440
(guint32*) &(*params)[i].data.d_status, 1,
1459
_gp_params_write (GIOChannel *channel,
1466
if (! wire_write_int32 (channel, (guint32*) &nparams, 1, user_data))
1469
for (i = 0; i < nparams; i++)
1471
if (! wire_write_int32 (channel,
1472
(guint32*) ¶ms[i].type, 1,
1476
switch (params[i].type)
1478
case GIMP_PDB_INT32:
1479
if (! wire_write_int32 (channel,
1480
(guint32*) ¶ms[i].data.d_int32, 1,
1485
case GIMP_PDB_INT16:
1486
if (! wire_write_int16 (channel,
1487
(guint16*) ¶ms[i].data.d_int16, 1,
1493
if (! wire_write_int8 (channel,
1494
(guint8*) ¶ms[i].data.d_int8, 1,
1499
case GIMP_PDB_FLOAT:
1500
if (! wire_write_double (channel,
1501
¶ms[i].data.d_float, 1,
1506
case GIMP_PDB_STRING:
1507
if (! wire_write_string (channel,
1508
¶ms[i].data.d_string, 1,
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,
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,
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,
1537
case GIMP_PDB_FLOATARRAY:
1538
if (! wire_write_double (channel,
1539
params[i].data.d_floatarray,
1540
params[i-1].data.d_int32,
1545
case GIMP_PDB_STRINGARRAY:
1546
if (! wire_write_string (channel,
1547
params[i].data.d_stringarray,
1548
params[i-1].data.d_int32,
1553
case GIMP_PDB_COLOR:
1555
GimpRGB *color = (GimpRGB *) ¶ms[i].data.d_color;
1556
if (! wire_write_double (channel, &color->r, 1, user_data))
1558
if (! wire_write_double (channel, &color->g, 1, user_data))
1560
if (! wire_write_double (channel, &color->b, 1, user_data))
1562
if (! wire_write_double (channel, &color->a, 1, user_data))
1567
case GIMP_PDB_REGION:
1570
case GIMP_PDB_DISPLAY:
1571
if (! wire_write_int32 (channel,
1572
(guint32*) ¶ms[i].data.d_display, 1,
1577
case GIMP_PDB_IMAGE:
1578
if (! wire_write_int32 (channel,
1579
(guint32*) ¶ms[i].data.d_image, 1,
1584
case GIMP_PDB_LAYER:
1585
if (! wire_write_int32 (channel,
1586
(guint32*) ¶ms[i].data.d_layer, 1,
1591
case GIMP_PDB_CHANNEL:
1592
if (! wire_write_int32 (channel,
1593
(guint32*) ¶ms[i].data.d_channel, 1,
1598
case GIMP_PDB_DRAWABLE:
1599
if (! wire_write_int32 (channel,
1600
(guint32*) ¶ms[i].data.d_drawable, 1,
1605
case GIMP_PDB_SELECTION:
1606
if (! wire_write_int32 (channel,
1607
(guint32*) ¶ms[i].data.d_selection, 1,
1612
case GIMP_PDB_BOUNDARY:
1613
if (! wire_write_int32 (channel,
1614
(guint32*) ¶ms[i].data.d_boundary, 1,
1620
if (! wire_write_int32 (channel,
1621
(guint32*) ¶ms[i].data.d_path, 1,
1626
case GIMP_PDB_PARASITE:
1628
GimpParasite *p = (GimpParasite *) ¶ms[i].data.d_parasite;
1629
if (p->name == NULL)
1631
/* write a null string to signifly a null parasite */
1632
wire_write_string (channel, &p->name, 1, user_data);
1635
if (! wire_write_string (channel, &p->name, 1, user_data))
1637
if (! wire_write_int32 (channel, &p->flags, 1, user_data))
1639
if (! wire_write_int32 (channel, &p->size, 1, user_data))
1643
if (! wire_write_int8 (channel, p->data, p->size, user_data))
1649
case GIMP_PDB_STATUS:
1650
if (! wire_write_int32 (channel,
1651
(guint32*) ¶ms[i].data.d_status, 1,
1663
_gp_params_destroy (GPParam *params,
1669
for (i = 0; i < nparams; i++)
1671
switch (params[i].type)
1673
case GIMP_PDB_INT32:
1674
case GIMP_PDB_INT16:
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:
1687
case GIMP_PDB_STATUS:
1690
case GIMP_PDB_STRING:
1691
g_free (params[i].data.d_string);
1694
case GIMP_PDB_INT32ARRAY:
1695
g_free (params[i].data.d_int32array);
1698
case GIMP_PDB_INT16ARRAY:
1699
g_free (params[i].data.d_int16array);
1702
case GIMP_PDB_INT8ARRAY:
1703
g_free (params[i].data.d_int8array);
1706
case GIMP_PDB_FLOATARRAY:
1707
g_free (params[i].data.d_floatarray);
1710
case GIMP_PDB_STRINGARRAY:
1711
if ((i > 0) && (params[i-1].type == GIMP_PDB_INT32))
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);
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);
1738
_gp_has_init_read (GIOChannel *channel,
1745
_gp_has_init_write (GIOChannel *channel,
1752
_gp_has_init_destroy (WireMessage *msg)