Commit 63577437 authored by Jody Goldberg's avatar Jody Goldberg

- Return enum from init_plugin.

- Suppress some warnings.
parent f8206c57
1999-12-29 Jody Goldberg <jgoldberg@home.com>
* src/main.c : Include print-info.h to suppess some warnings.
* src/workbook-view.c (command_context_gui,
gui_splits_array,
gui_plugin_problem,
......@@ -17,6 +19,8 @@
* plugins/*/*.c (init_plugin): Take a CmdContext for error reporting.
Call plugin_version_mismatch to do some minimal version matching for
plugins and the running application.
Return an enum to clearly differentiate between error reporting
reqs.
* src/Gnumeric.idl : Add PluginProblem.
......
1999-12-29 Jody Goldberg <jgoldberg@home.com>
* src/main.c : Include print-info.h to suppess some warnings.
* src/workbook-view.c (command_context_gui,
gui_splits_array,
gui_plugin_problem,
......@@ -17,6 +19,8 @@
* plugins/*/*.c (init_plugin): Take a CmdContext for error reporting.
Call plugin_version_mismatch to do some minimal version matching for
plugins and the running application.
Return an enum to clearly differentiate between error reporting
reqs.
* src/Gnumeric.idl : Add PluginProblem.
......
......@@ -442,13 +442,13 @@ dif_cleanup_plugin (PluginData *pd)
}
int
PluginInitResult
init_plugin (CmdContext *context, PluginData * pd)
{
char *desc;
if (plugin_version_mismatch (context, pd, GNUMERIC_VERSION))
return -2;
return PLUGIN_QUIET_ERROR;
desc = _("Data Interchange Format (DIF) import");
file_format_register_open (1, desc, NULL, dif_read_workbook);
......@@ -461,5 +461,5 @@ init_plugin (CmdContext *context, PluginData * pd)
pd->can_unload = dif_can_unload;
pd->cleanup_plugin = dif_cleanup_plugin;
return 0;
return PLUGIN_OK;
}
......@@ -13,6 +13,6 @@
#include "sheet.h"
#include "plugin.h"
int init_plugin (CmdContext *context, PluginData *pd);
PluginInitResult init_plugin (CmdContext *context, PluginData *pd);
#endif /* GNUMERIC_DIF_H */
......@@ -274,13 +274,13 @@ csv_cleanup_plugin (PluginData *pd)
}
int
PluginInitResult
init_plugin (CmdContext *context, PluginData *pd)
{
char *desc;
if (plugin_version_mismatch (context, pd, GNUMERIC_VERSION))
return -2;
return PLUGIN_QUIET_ERROR;
desc = _("Comma Separated Value (CSV) import");
file_format_register_open (1, desc, NULL, csv_read_workbook);
......@@ -293,5 +293,5 @@ init_plugin (CmdContext *context, PluginData *pd)
pd->can_unload = csv_can_unload;
pd->cleanup_plugin = csv_cleanup_plugin;
return 0;
return PLUGIN_OK;
}
......@@ -13,6 +13,6 @@
#include "sheet.h"
#include "plugin.h"
int init_plugin (CmdContext *context, PluginData *pd);
PluginInitResult init_plugin (CmdContext *context, PluginData *pd);
#endif /* GNUMERIC_CSV_IO_H */
......@@ -262,17 +262,18 @@ cleanup_plugin (PluginData *pd)
}
int
PluginInitResult
init_plugin(CmdContext *context, PluginData* pd)
{
g_print("plugin-gda: init_plugin called\n");
if (plugin_version_mismatch (context, pd, GNUMERIC_VERSION))
return -2;
return PLUGIN_QUIET_ERROR;
install_symbols(plugin_functionp, "GDA Plugin");
pd->can_unload = can_unload;
pd->cleanup_plugin = cleanup_plugin;
pd->title = g_strdup("Database Access");
return 0;
return PLUGIN_OK;
}
......@@ -476,14 +476,14 @@ no_unloading_for_me (PluginData *pd)
return 0;
}
int
PluginInitResult
init_plugin (CmdContext *context, PluginData *pd)
{
FunctionCategory *cat;
char *init_file_name;
if (plugin_version_mismatch (context, pd, GNUMERIC_VERSION))
return -2;
return PLUGIN_QUIET_ERROR;
/* Initialize just in case. */
eval_pos = NULL;
......@@ -509,5 +509,5 @@ init_plugin (CmdContext *context, PluginData *pd)
scm_cons(scm_makfrom0str(init_file_name), SCM_EOL),
SCM_EOL);
return 0;
return PLUGIN_OK;
}
......@@ -93,16 +93,18 @@ html_init (void)
/*
* called by gnumeric to load the plugin
*/
int
PluginInitResult
init_plugin (CmdContext *context, PluginData *pd)
{
if (plugin_version_mismatch (context, pd, GNUMERIC_VERSION))
return -2;
return PLUGIN_QUIET_ERROR;
html_init ();
pd->can_unload = html_can_unload;
pd->cleanup_plugin = html_cleanup_plugin;
pd->title = g_strdup (_("HTML (simple html export/import plugin)"));
return 0;
return PLUGIN_OK;
}
......@@ -26,6 +26,6 @@
#include "gnumeric-util.h"
#include "../../src/plugin.h"
int init_plugin (CmdContext *context, PluginData *pd);
PluginInitResult init_plugin (CmdContext *context, PluginData *pd);
#endif
......@@ -83,13 +83,13 @@ lotus_cleanup_plugin (PluginData *pd)
g_free (pd->title);
}
int
PluginInitResult
init_plugin (CmdContext *context, PluginData *pd)
{
char *descr = _("Lotus (*.wk1) file format");
if (plugin_version_mismatch (context, pd, GNUMERIC_VERSION))
return -2;
return PLUGIN_QUIET_ERROR;
file_format_register_open (50, descr, lotus_probe, lotus_load);
......@@ -97,5 +97,5 @@ init_plugin (CmdContext *context, PluginData *pd)
pd->cleanup_plugin = lotus_cleanup_plugin;
pd->title = g_strdup (_("Lotus 123 file import/export plugin"));
return 0;
return PLUGIN_OK;
}
......@@ -83,13 +83,13 @@ oleo_cleanup_plugin (PluginData *pd)
g_free (pd->title);
}
int
PluginInitResult
init_plugin (CmdContext *context, PluginData *pd)
{
char *descr = _("GNU Oleo (*.oleo) file format");
if (plugin_version_mismatch (context, pd, GNUMERIC_VERSION))
return -2;
return PLUGIN_QUIET_ERROR;
file_format_register_open (100, descr, oleo_probe, oleo_load);
......@@ -97,5 +97,5 @@ init_plugin (CmdContext *context, PluginData *pd)
pd->cleanup_plugin = oleo_cleanup_plugin;
pd->title = g_strdup (_("GNU Oleo import plugin"));
return 0;
return PLUGIN_OK;
}
......@@ -24,14 +24,14 @@ no_unloading_for_me (PluginData *pd)
return 0;
}
int
PluginInitResult
init_plugin (CmdContext *context, PluginData *pd)
{
char *argv[] = { "", NULL, NULL, NULL };
char *arg;
if (plugin_version_mismatch (context, pd, GNUMERIC_VERSION))
return -2;
return PLUGIN_QUIET_ERROR;
/* Initialize Gnumeric plugin information. */
pd->can_unload = no_unloading_for_me;
......@@ -47,5 +47,5 @@ init_plugin (CmdContext *context, PluginData *pd)
perl_parse(gnumeric_perl_interp, xs_init, 3, argv, NULL);
perl_run(gnumeric_perl_interp);
return 0;
return PLUGIN_OK;
}
......@@ -932,13 +932,13 @@ pln_cleanup_plugin (PluginData *pd)
}
int
PluginInitResult
init_plugin (CmdContext *context, PluginData * pd)
{
char *desc;
if (plugin_version_mismatch (context, pd, GNUMERIC_VERSION))
return -2;
return PLUGIN_QUIET_ERROR;
desc = _("Plan Perfect Format (PLN) import");
file_format_register_open (1, desc, NULL, pln_read_workbook);
......@@ -948,5 +948,5 @@ init_plugin (CmdContext *context, PluginData * pd)
pd->can_unload = pln_can_unload;
pd->cleanup_plugin = pln_cleanup_plugin;
return 0;
return PLUGIN_OK;
}
......@@ -13,6 +13,6 @@
#include "sheet.h"
#include "plugin.h"
int init_plugin (CmdContext *context, PluginData *pd);
PluginInitResult init_plugin (CmdContext *context, PluginData *pd);
#endif /* GNUMERIC_PLN_H */
......@@ -175,11 +175,11 @@ no_unloading_for_me (PluginData *pd)
return 0;
}
int
PluginInitResult
init_plugin (CmdContext *context, PluginData * pd)
{
if (plugin_version_mismatch (context, pd, GNUMERIC_VERSION))
return -2;
return PLUGIN_QUIET_ERROR;
pd->can_unload = no_unloading_for_me;
pd->title = g_strdup (_("Python Plugin"));
......@@ -191,8 +191,12 @@ init_plugin (CmdContext *context, PluginData * pd)
/* setup standard functions */
initgnumeric ();
if (PyErr_Occurred ()) {
/* FIXME : If I knew how to get the string representation of the
* error I'd use gnumeric_error_plugin_problem()
* We need a maintainer for this code that knows python.
*/
PyErr_Print ();
return -1;
return PLUGIN_ERROR;
}
/* plugin stuff */
......@@ -211,5 +215,5 @@ init_plugin (CmdContext *context, PluginData * pd)
g_free(name);
}
return 0;
return PLUGIN_OK;
}
......@@ -37,13 +37,13 @@ cleanup_plugin (PluginData *pd)
symbol_unref (sym);
}
int
PluginInitResult
init_plugin (CmdContext *context, PluginData *pd)
{
FunctionCategory *cat;
if (plugin_version_mismatch (context, pd, GNUMERIC_VERSION))
return -2;
return PLUGIN_QUIET_ERROR;
cat = function_get_category (_("Sample Plugin"));
function_add_args (cat, "plusone", "f", "number", NULL, func_plusone);
......@@ -52,6 +52,6 @@ init_plugin (CmdContext *context, PluginData *pd)
pd->cleanup_plugin = cleanup_plugin;
pd->title = g_strdup ("PlusOne Plugin");
return 0;
return PLUGIN_OK;
}
......@@ -447,7 +447,7 @@ sc_cleanup_plugin (PluginData *pd)
}
int
PluginInitResult
init_plugin (CmdContext *context, PluginData * pd)
{
const char *desc = _("SC/xspread file import");
......@@ -455,7 +455,7 @@ init_plugin (CmdContext *context, PluginData * pd)
g_return_val_if_fail (pd, -1);
if (plugin_version_mismatch (context, pd, GNUMERIC_VERSION))
return -2;
return PLUGIN_QUIET_ERROR;
file_format_register_open (1, desc, NULL, sc_read_workbook);
......@@ -463,6 +463,6 @@ init_plugin (CmdContext *context, PluginData * pd)
pd->cleanup_plugin = sc_cleanup_plugin;
pd->title = g_strdup (desc);
return 0;
return PLUGIN_OK;
}
......@@ -19,15 +19,15 @@ cleanup_plugin (PluginData *pd)
g_free (pd->title);
}
int
PluginInitResult
init_plugin (CmdContext *context, PluginData *pd)
{
if (plugin_version_mismatch (context, pd, GNUMERIC_VERSION))
return -2;
return PLUGIN_QUIET_ERROR;
pd->can_unload = can_unload;
pd->cleanup_plugin = cleanup_plugin;
pd->title = g_strdup (_("OLD Statistics Plugin, not required anymore"));
return 0;
return PLUGIN_OK;
}
......@@ -7,6 +7,6 @@
#include "../../src/func.h"
#include "../../src/plugin.h"
int init_plugin (CmdContext *context, PluginData *pd);
PluginInitResult init_plugin (CmdContext *context, PluginData *pd);
#endif /* GNUMERIC_STAT_H */
......@@ -496,11 +496,11 @@ sylk_cleanup_plugin (PluginData *pd)
}
int
PluginInitResult
init_plugin (CmdContext *context, PluginData * pd)
{
if (plugin_version_mismatch (context, pd, GNUMERIC_VERSION))
return -2;
return PLUGIN_QUIET_ERROR;
file_format_register_open (1, _("MultiPlan (SYLK) import"),
sylk_probe, sylk_read_workbook);
......@@ -508,5 +508,6 @@ init_plugin (CmdContext *context, PluginData * pd)
pd->can_unload = sylk_can_unload;
pd->cleanup_plugin = sylk_cleanup_plugin;
pd->title = g_strdup (_("MultiPlan (SYLK) file import module"));
return 0;
return PLUGIN_OK;
}
......@@ -449,11 +449,11 @@ text_can_unload (PluginData *pd)
return TRUE;
}
int
PluginInitResult
init_plugin (CmdContext *context, PluginData *pd)
{
if (plugin_version_mismatch (context, pd, GNUMERIC_VERSION))
return -2;
return PLUGIN_QUIET_ERROR;
text_init ();
......@@ -461,5 +461,5 @@ init_plugin (CmdContext *context, PluginData *pd)
pd->cleanup_plugin = text_cleanup_plugin;
pd->title = g_strdup (_("TXT (simple text import/export plugin)"));
return 0;
return PLUGIN_OK;
}
......@@ -15,6 +15,6 @@
#include "../../src/gnumeric-util.h"
#include "../../src/plugin.h"
int init_plugin (CmdContext *context, PluginData *pd);
PluginInitResult init_plugin (CmdContext *context, PluginData *pd);
#endif /* GNUMERIC_TEXT_IO_H */
......@@ -202,13 +202,13 @@ xbase_cleanup_plugin (PluginData *pd)
g_free (pd->title);
}
int
PluginInitResult
init_plugin (CmdContext *context, PluginData *pd)
{
char *descr = _("Xbase (*.dbf) file format");
if (plugin_version_mismatch (context, pd, GNUMERIC_VERSION))
return -2;
return PLUGIN_QUIET_ERROR;
/* We register XBase format with a precendence of 100 */
file_format_register_open (100, descr, xbase_probe, xbase_load);
......@@ -217,5 +217,5 @@ init_plugin (CmdContext *context, PluginData *pd)
pd->cleanup_plugin = xbase_cleanup_plugin;
pd->title = g_strdup (_("XBase file import/export plugin"));
return 0;
return PLUGIN_OK;
}
......@@ -17,6 +17,7 @@
#include "main.h"
#include "func.h"
#include "application.h"
#include "print-info.h"
#include "global-gnome-font.h"
#include "../plugins/excel/boot.h"
......
......@@ -17,6 +17,7 @@
#include "main.h"
#include "func.h"
#include "application.h"
#include "print-info.h"
#include "global-gnome-font.h"
#include "../plugins/excel/boot.h"
......
......@@ -15,6 +15,8 @@
#include "gnumeric.h"
#include "gnumeric-util.h"
#include "plugin.h"
#include "workbook-view.h"
#include "command-context.h"
GList *plugin_list = NULL;
......@@ -51,7 +53,7 @@ plugin_load (Workbook *wb, const gchar *modfile)
CmdContext *context = command_context_gui (wb);
PluginData *data;
int res;
PluginInitResult res;
g_return_val_if_fail (modfile != NULL, NULL);
......@@ -80,9 +82,9 @@ plugin_load (Workbook *wb, const gchar *modfile)
}
res = data->init_plugin (NULL, data);
if (res < 0) {
if (res != PLUGIN_OK) {
/* Avoid displaying 2 error boxes */
if (res == -1)
if (res == PLUGIN_ERROR)
gnumeric_error_plugin_problem (context,
_("init_plugin returned error"));
goto error;
......
......@@ -7,11 +7,18 @@ typedef struct _PluginData PluginData;
#include "sheet.h"
#include <gmodule.h>
typedef enum {
PLUGIN_OK,
PLUGIN_ERROR, /* Display an error */
PLUGIN_QUIET_ERROR /* Plugin has already displayed an error */
} PluginInitResult;
struct _PluginData
{
gchar *file_name;
GModule *handle;
int (*init_plugin) (CmdContext *, PluginData *);
PluginInitResult (*init_plugin) (CmdContext *, PluginData *);
int (*can_unload) (PluginData *);
void (*cleanup_plugin) (PluginData *);
gchar *title;
......@@ -23,7 +30,7 @@ struct _PluginData
extern GList *plugin_list;
/* Each plugin must have this one function */
extern int init_plugin (CmdContext *cmd, PluginData *pd);
extern PluginInitResult init_plugin (CmdContext *cmd, PluginData *pd);
void plugins_init (void);
PluginData *plugin_load (Workbook *wb, const gchar *filename);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment