added GIMP_CONFIG_ERROR_VERSION to GimpConfigError enum.

2003-11-08  Sven Neumann  <sven@gimp.org>

	* app/config/gimpconfig-error.h: added GIMP_CONFIG_ERROR_VERSION
	to GimpConfigError enum.

	* libgimpbase/gimpprotocol.h: renamed GP_VERSION to
	GIMP_PROTOCOL_VERSION.

	* libgimp/gimp.c
	* app/plug-in/plug-in-run.c: changed accordingly.

	* app/plug-in/plug-in-rc.[ch]: write the protocol version to the
	pluginrc and stop parsing when a wrong protocol version is found.

	* app/plug-in/plug-ins.c: pass a GError to plug_in_rc_parse().
This commit is contained in:
Sven Neumann
2003-11-07 23:47:35 +00:00
committed by Sven Neumann
parent a868b35310
commit 74c8218a3f
16 changed files with 116 additions and 45 deletions

View File

@ -1,3 +1,19 @@
2003-11-08 Sven Neumann <sven@gimp.org>
* app/config/gimpconfig-error.h: added GIMP_CONFIG_ERROR_VERSION
to GimpConfigError enum.
* libgimpbase/gimpprotocol.h: renamed GP_VERSION to
GIMP_PROTOCOL_VERSION.
* libgimp/gimp.c
* app/plug-in/plug-in-run.c: changed accordingly.
* app/plug-in/plug-in-rc.[ch]: write the protocol version to the
pluginrc and stop parsing when a wrong protocol version is found.
* app/plug-in/plug-ins.c: pass a GError to plug_in_rc_parse().
2003-11-07 Michael Natterer <mitch@gimp.org> 2003-11-07 Michael Natterer <mitch@gimp.org>
* libgimpbase/gimpprotocol.[ch]: added "wm_name", "wm_class", * libgimpbase/gimpprotocol.[ch]: added "wm_name", "wm_class",

View File

@ -24,10 +24,11 @@
typedef enum typedef enum
{ {
GIMP_CONFIG_ERROR_OPEN, /* open failed */ GIMP_CONFIG_ERROR_OPEN, /* open failed */
GIMP_CONFIG_ERROR_OPEN_ENOENT, /* file does not exist */ GIMP_CONFIG_ERROR_OPEN_ENOENT, /* file does not exist */
GIMP_CONFIG_ERROR_WRITE, /* write failed */ GIMP_CONFIG_ERROR_WRITE, /* write failed */
GIMP_CONFIG_ERROR_PARSE /* parser error */ GIMP_CONFIG_ERROR_PARSE, /* parser error */
GIMP_CONFIG_ERROR_VERSION /* parser failed due to version mismatch */
} GimpConfigError; } GimpConfigError;
#define GIMP_CONFIG_ERROR (gimp_config_error_quark ()) #define GIMP_CONFIG_ERROR (gimp_config_error_quark ())

View File

@ -94,7 +94,7 @@ plug_in_run (Gimp *gimp,
goto done; goto done;
} }
config.version = GP_VERSION; config.version = GIMP_PROTOCOL_VERSION;
config.tile_width = TILE_WIDTH; config.tile_width = TILE_WIDTH;
config.tile_height = TILE_HEIGHT; config.tile_height = TILE_HEIGHT;
config.shm_ID = plug_in_shm_get_ID (gimp); config.shm_ID = plug_in_shm_get_ID (gimp);

View File

@ -94,7 +94,7 @@ plug_in_run (Gimp *gimp,
goto done; goto done;
} }
config.version = GP_VERSION; config.version = GIMP_PROTOCOL_VERSION;
config.tile_width = TILE_WIDTH; config.tile_width = TILE_WIDTH;
config.tile_height = TILE_HEIGHT; config.tile_height = TILE_HEIGHT;
config.shm_ID = plug_in_shm_get_ID (gimp); config.shm_ID = plug_in_shm_get_ID (gimp);

View File

@ -94,6 +94,7 @@ plug_ins_init (Gimp *gimp,
gdouble n_plugins; gdouble n_plugins;
gdouble n_extensions; gdouble n_extensions;
gdouble nth; gdouble nth;
GError *error = NULL;
g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (status_callback != NULL); g_return_if_fail (status_callback != NULL);
@ -131,7 +132,12 @@ plug_ins_init (Gimp *gimp,
} }
(* status_callback) (_("Resource configuration"), filename, -1); (* status_callback) (_("Resource configuration"), filename, -1);
plug_in_rc_parse (gimp, filename);
if (! plug_in_rc_parse (gimp, filename, &error))
{
g_message (error->message);
g_error_free (error);
}
/* Query any plug-ins that have changed since we last wrote out /* Query any plug-ins that have changed since we last wrote out
* the pluginrc file. * the pluginrc file.

View File

@ -23,8 +23,12 @@
#include <glib-object.h> #include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpbase/gimpprotocol.h"
#include "plug-in-types.h" #include "plug-in-types.h"
#include "config/gimpconfig-error.h"
#include "config/gimpconfigwriter.h" #include "config/gimpconfigwriter.h"
#include "config/gimpscanner.h" #include "config/gimpscanner.h"
@ -59,7 +63,8 @@ static GTokenType plug_in_has_init_deserialize (GScanner *scanner,
enum enum
{ {
PLUG_IN_DEF = 1, PROTOCOL_VERSION = 1,
PLUG_IN_DEF,
PROC_DEF, PROC_DEF,
LOCALE_DEF, LOCALE_DEF,
HELP_DEF, HELP_DEF,
@ -69,21 +74,27 @@ enum
gboolean gboolean
plug_in_rc_parse (Gimp *gimp, plug_in_rc_parse (Gimp *gimp,
const gchar *filename) const gchar *filename,
GError **error)
{ {
GScanner *scanner; GScanner *scanner;
GTokenType token; GTokenType token;
GError *error = NULL; gboolean retval = FALSE;
gint version = GIMP_PROTOCOL_VERSION;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE); g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
g_return_val_if_fail (filename != NULL, FALSE); g_return_val_if_fail (filename != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
scanner = gimp_scanner_new_file (filename, &error); scanner = gimp_scanner_new_file (filename, error);
if (! scanner) if (! scanner)
return TRUE; return TRUE;
g_scanner_scope_add_symbol (scanner, 0,
"protocol-version",
GINT_TO_POINTER (PROTOCOL_VERSION));
g_scanner_scope_add_symbol (scanner, 0, g_scanner_scope_add_symbol (scanner, 0,
"plug-in-def", GINT_TO_POINTER (PLUG_IN_DEF)); "plug-in-def", GINT_TO_POINTER (PLUG_IN_DEF));
g_scanner_scope_add_symbol (scanner, PLUG_IN_DEF, g_scanner_scope_add_symbol (scanner, PLUG_IN_DEF,
@ -99,7 +110,8 @@ plug_in_rc_parse (Gimp *gimp,
token = G_TOKEN_LEFT_PAREN; token = G_TOKEN_LEFT_PAREN;
while (g_scanner_peek_next_token (scanner) == token) while (version == GIMP_PROTOCOL_VERSION &&
g_scanner_peek_next_token (scanner) == token)
{ {
token = g_scanner_get_next_token (scanner); token = g_scanner_get_next_token (scanner);
@ -110,13 +122,22 @@ plug_in_rc_parse (Gimp *gimp,
break; break;
case G_TOKEN_SYMBOL: case G_TOKEN_SYMBOL:
if (scanner->value.v_symbol == GINT_TO_POINTER (PLUG_IN_DEF)) switch (GPOINTER_TO_INT (scanner->value.v_symbol))
{ {
case PROTOCOL_VERSION:
token = G_TOKEN_INT;
if (gimp_scanner_parse_int (scanner, &version))
token = G_TOKEN_RIGHT_PAREN;
break;
case PLUG_IN_DEF:
g_scanner_set_scope (scanner, PLUG_IN_DEF); g_scanner_set_scope (scanner, PLUG_IN_DEF);
token = plug_in_def_deserialize (gimp, scanner); token = plug_in_def_deserialize (gimp, scanner);
g_scanner_set_scope (scanner, 0); g_scanner_set_scope (scanner, 0);
break;
default:
break;
} }
break; break;
case G_TOKEN_RIGHT_PAREN: case G_TOKEN_RIGHT_PAREN:
token = G_TOKEN_LEFT_PAREN; token = G_TOKEN_LEFT_PAREN;
@ -127,19 +148,26 @@ plug_in_rc_parse (Gimp *gimp,
} }
} }
if (token != G_TOKEN_LEFT_PAREN) if (version != GIMP_PROTOCOL_VERSION)
{
g_set_error (error,
GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_VERSION,
_("Skipping '%s': wrong GIMP protocol version."), filename);
}
else if (token != G_TOKEN_LEFT_PAREN)
{ {
g_scanner_get_next_token (scanner); g_scanner_get_next_token (scanner);
g_scanner_unexp_token (scanner, token, NULL, NULL, NULL, g_scanner_unexp_token (scanner, token, NULL, NULL, NULL,
_("fatal parse error"), TRUE); _("fatal parse error"), TRUE);
}
g_message (error->message); else
g_clear_error (&error); {
retval = TRUE;
} }
gimp_scanner_destroy (scanner); gimp_scanner_destroy (scanner);
return (token != G_TOKEN_EOF); return retval;
} }
static GTokenType static GTokenType
@ -407,6 +435,11 @@ plug_in_rc_write (GSList *plug_in_defs,
if (!writer) if (!writer)
return FALSE; return FALSE;
gimp_config_writer_open (writer, "protocol-version");
gimp_config_writer_printf (writer, "%d", GIMP_PROTOCOL_VERSION);
gimp_config_writer_close (writer);
gimp_config_writer_linefeed (writer);
for (list = plug_in_defs; list; list = list->next) for (list = plug_in_defs; list; list = list->next)
{ {
plug_in_def = list->data; plug_in_def = list->data;

View File

@ -24,7 +24,8 @@
gboolean plug_in_rc_parse (Gimp *gimp, gboolean plug_in_rc_parse (Gimp *gimp,
const gchar *filename); const gchar *filename,
GError **error);
gboolean plug_in_rc_write (GSList *proc_defs, gboolean plug_in_rc_write (GSList *proc_defs,
const gchar *filename, const gchar *filename,
GError **error); GError **error);

View File

@ -94,7 +94,7 @@ plug_in_run (Gimp *gimp,
goto done; goto done;
} }
config.version = GP_VERSION; config.version = GIMP_PROTOCOL_VERSION;
config.tile_width = TILE_WIDTH; config.tile_width = TILE_WIDTH;
config.tile_height = TILE_HEIGHT; config.tile_height = TILE_HEIGHT;
config.shm_ID = plug_in_shm_get_ID (gimp); config.shm_ID = plug_in_shm_get_ID (gimp);

View File

@ -94,6 +94,7 @@ plug_ins_init (Gimp *gimp,
gdouble n_plugins; gdouble n_plugins;
gdouble n_extensions; gdouble n_extensions;
gdouble nth; gdouble nth;
GError *error = NULL;
g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (status_callback != NULL); g_return_if_fail (status_callback != NULL);
@ -131,7 +132,12 @@ plug_ins_init (Gimp *gimp,
} }
(* status_callback) (_("Resource configuration"), filename, -1); (* status_callback) (_("Resource configuration"), filename, -1);
plug_in_rc_parse (gimp, filename);
if (! plug_in_rc_parse (gimp, filename, &error))
{
g_message (error->message);
g_error_free (error);
}
/* Query any plug-ins that have changed since we last wrote out /* Query any plug-ins that have changed since we last wrote out
* the pluginrc file. * the pluginrc file.

View File

@ -1,3 +1,8 @@
2003-11-08 Sven Neumann <sven@gimp.org>
* libgimpbase/libgimpbase-sections.txt
* libgimpbase/tmpl/gimpprotocol.sgml: GIMP_PROTOCOL_VERSION.
2003-11-07 Sven Neumann <sven@gimp.org> 2003-11-07 Sven Neumann <sven@gimp.org>
* app/app-docs.sgml * app/app-docs.sgml

View File

@ -8,7 +8,9 @@
<bookinfo> <bookinfo>
<title>GIMP Application Reference Manual</title> <title>GIMP Application Reference Manual</title>
<releaseinfo>for GIMP &version;</releaseinfo> <releaseinfo>
for GIMP <xi:include href="version" parse="text"/>
</releaseinfo>
</bookinfo> </bookinfo>
<part id="app-hierarchy-part"> <part id="app-hierarchy-part">

View File

@ -70,7 +70,7 @@ gimp_pixpipe_params_build
<SECTION> <SECTION>
<FILE>gimpprotocol</FILE> <FILE>gimpprotocol</FILE>
GP_VERSION GIMP_PROTOCOL_VERSION
GPConfig GPConfig
GPTileReq GPTileReq
GPTileAck GPTileAck

View File

@ -15,7 +15,7 @@ The communication protocol between GIMP and it's plug-ins.
#libgimp-gimpwire #libgimp-gimpwire
</para> </para>
<!-- ##### MACRO GP_VERSION ##### --> <!-- ##### MACRO GIMP_PROTOCOL_VERSION ##### -->
<para> <para>
</para> </para>

View File

@ -1551,7 +1551,7 @@ gimp_loop (void)
static void static void
gimp_config (GPConfig *config) gimp_config (GPConfig *config)
{ {
if (config->version < GP_VERSION) if (config->version < GIMP_PROTOCOL_VERSION)
{ {
g_message ("Could not execute plug-in \"%s\"\n(%s)\n" g_message ("Could not execute plug-in \"%s\"\n(%s)\n"
"because the GIMP is using an older version of the " "because the GIMP is using an older version of the "
@ -1559,7 +1559,7 @@ gimp_config (GPConfig *config)
g_get_prgname (), progname); g_get_prgname (), progname);
gimp_quit (); gimp_quit ();
} }
else if (config->version > GP_VERSION) else if (config->version > GIMP_PROTOCOL_VERSION)
{ {
g_message ("Could not execute plug-in \"%s\"\n(%s)\n" g_message ("Could not execute plug-in \"%s\"\n(%s)\n"
"because it uses an obsolete version of the " "because it uses an obsolete version of the "

View File

@ -27,7 +27,7 @@ G_BEGIN_DECLS
/* Increment every time the protocol changes /* Increment every time the protocol changes
*/ */
#define GP_VERSION 0x000F #define GIMP_PROTOCOL_VERSION 0x000F
enum enum

View File

@ -24,10 +24,11 @@
typedef enum typedef enum
{ {
GIMP_CONFIG_ERROR_OPEN, /* open failed */ GIMP_CONFIG_ERROR_OPEN, /* open failed */
GIMP_CONFIG_ERROR_OPEN_ENOENT, /* file does not exist */ GIMP_CONFIG_ERROR_OPEN_ENOENT, /* file does not exist */
GIMP_CONFIG_ERROR_WRITE, /* write failed */ GIMP_CONFIG_ERROR_WRITE, /* write failed */
GIMP_CONFIG_ERROR_PARSE /* parser error */ GIMP_CONFIG_ERROR_PARSE, /* parser error */
GIMP_CONFIG_ERROR_VERSION /* parser failed due to version mismatch */
} GimpConfigError; } GimpConfigError;
#define GIMP_CONFIG_ERROR (gimp_config_error_quark ()) #define GIMP_CONFIG_ERROR (gimp_config_error_quark ())