139
142
static GTypeModuleClass* parent_class = NULL;
140
143
static guint plugin_signals [LAST_SIGNAL] = { 0 };
146
brasero_plugin_error_free (BraseroPluginError *error)
148
g_free (error->detail);
153
brasero_plugin_add_error (BraseroPlugin *plugin,
154
BraseroPluginErrorType type,
157
BraseroPluginError *error;
158
BraseroPluginPrivate *priv;
160
g_return_if_fail (BRASERO_IS_PLUGIN (plugin));
162
priv = BRASERO_PLUGIN_PRIVATE (plugin);
164
error = g_new0 (BraseroPluginError, 1);
165
error->detail = g_strdup (detail);
168
priv->errors = g_slist_prepend (priv->errors, error);
172
brasero_plugin_test_gstreamer_plugin (BraseroPlugin *plugin,
177
/* Let's see if we've got the plugins we need */
178
element = gst_element_factory_make (name, NULL);
180
brasero_plugin_add_error (plugin,
181
BRASERO_PLUGIN_ERROR_MISSING_GSTREAMER_PLUGIN,
184
gst_object_unref (element);
188
brasero_plugin_test_app (BraseroPlugin *plugin,
190
const gchar *version_arg,
191
const gchar *version_format,
194
gchar *standard_output = NULL;
195
gchar *standard_error = NULL;
196
guint major, minor, sub;
202
/* First see if this plugin can be used, i.e. if cdrecord is in
204
prog_path = g_find_program_in_path (name);
206
brasero_plugin_add_error (plugin,
207
BRASERO_PLUGIN_ERROR_MISSING_APP,
212
if (!g_file_test (prog_path, G_FILE_TEST_IS_EXECUTABLE)) {
214
brasero_plugin_add_error (plugin,
215
BRASERO_PLUGIN_ERROR_MISSING_APP,
220
/* make sure that's not a symlink pointing to something with another
222
* NOTE: we used to test the target and see if it had the same name as
223
* the symlink with GIO. The problem is, when the symlink pointed to
224
* another symlink, then GIO didn't follow that other symlink. And in
225
* the end it didn't work. So forbid all symlink. */
226
if (g_file_test (prog_path, G_FILE_TEST_IS_SYMLINK)) {
227
brasero_plugin_add_error (plugin,
228
BRASERO_PLUGIN_ERROR_SYMBOLIC_LINK_APP,
233
/* Make sure it's a regular file */
234
else if (!g_file_test (prog_path, G_FILE_TEST_IS_REGULAR)) {
235
brasero_plugin_add_error (plugin,
236
BRASERO_PLUGIN_ERROR_MISSING_APP,
248
argv = g_ptr_array_new ();
249
g_ptr_array_add (argv, prog_path);
250
g_ptr_array_add (argv, (gchar *) version_arg);
251
g_ptr_array_add (argv, NULL);
253
res = g_spawn_sync (NULL,
254
(gchar **) argv->pdata,
264
g_ptr_array_free (argv, TRUE);
268
brasero_plugin_add_error (plugin,
269
BRASERO_PLUGIN_ERROR_WRONG_APP_VERSION,
274
for (i = 0; i < 3 && version [i] >= 0; i++);
276
if ((standard_output && sscanf (standard_output, version_format, &major, &minor, &sub) == i)
277
|| (standard_error && sscanf (standard_error, version_format, &major, &minor, &sub) == i)) {
278
if (major < version [0]
279
|| (version [1] >= 0 && minor < version [1])
280
|| (version [2] >= 0 && sub < version [2]))
281
brasero_plugin_add_error (plugin,
282
BRASERO_PLUGIN_ERROR_WRONG_APP_VERSION,
286
brasero_plugin_add_error (plugin,
287
BRASERO_PLUGIN_ERROR_WRONG_APP_VERSION,
290
g_free (standard_output);
291
g_free (standard_error);
143
295
brasero_plugin_set_compulsory (BraseroPlugin *self,
144
296
gboolean compulsory)
480
634
return priv->group;
484
brasero_plugin_get_error (BraseroPlugin *self)
486
BraseroPluginPrivate *priv;
488
priv = BRASERO_PLUGIN_PRIVATE (self);
638
* brasero_plugin_get_errors:
639
* @plugin: a #BraseroPlugin.
641
* This function returns a list of all errors that
642
* prevents the plugin from working properly.
644
* Returns: a #GSList of #BraseroPluginError structures or %NULL.
645
* It must not be freed.
649
brasero_plugin_get_errors (BraseroPlugin *plugin)
651
BraseroPluginPrivate *priv;
653
g_return_val_if_fail (BRASERO_IS_PLUGIN (plugin), NULL);
654
priv = BRASERO_PLUGIN_PRIVATE (plugin);
659
brasero_plugin_get_error_string (BraseroPlugin *plugin)
661
gchar *error_string = NULL;
662
BraseroPluginPrivate *priv;
666
g_return_val_if_fail (BRASERO_IS_PLUGIN (plugin), NULL);
668
priv = BRASERO_PLUGIN_PRIVATE (plugin);
670
string = g_string_new (NULL);
671
for (iter = priv->errors; iter; iter = iter->next) {
672
BraseroPluginError *error;
675
switch (error->type) {
676
case BRASERO_PLUGIN_ERROR_MISSING_APP:
677
g_string_append_c (string, '\n');
678
g_string_append_printf (string, _("\"%s\" could not be found in the path"), error->detail);
680
case BRASERO_PLUGIN_ERROR_MISSING_GSTREAMER_PLUGIN:
681
g_string_append_c (string, '\n');
682
g_string_append_printf (string, _("\"%s\" Gstreamer plugin could not be found"), error->detail);
684
case BRASERO_PLUGIN_ERROR_WRONG_APP_VERSION:
685
g_string_append_c (string, '\n');
686
g_string_append_printf (string, _("The version of \"%s\" is too old"), error->detail);
688
case BRASERO_PLUGIN_ERROR_SYMBOLIC_LINK_APP:
689
g_string_append_c (string, '\n');
690
g_string_append_printf (string, _("\"%s\" is a symbolic link pointing to another program"), error->detail);
692
case BRASERO_PLUGIN_ERROR_MISSING_LIBRARY:
693
g_string_append_c (string, '\n');
694
g_string_append_printf (string, _("\"%s\" could not be found"), error->detail);
696
case BRASERO_PLUGIN_ERROR_LIBRARY_VERSION:
697
g_string_append_c (string, '\n');
698
g_string_append_printf (string, _("The version of \"%s\" is too old"), error->detail);
700
case BRASERO_PLUGIN_ERROR_MODULE:
701
g_string_append_c (string, '\n');
702
g_string_append (string, error->detail);
710
error_string = string->str;
711
g_string_free (string, FALSE);
492
715
static BraseroPluginFlags *
1000
1220
priv->priority = gconf_value_get_int (value);
1002
is_active = brasero_plugin_get_active (self);
1222
is_active = brasero_plugin_get_active (self, FALSE);
1004
1224
g_object_notify (G_OBJECT (self), "priority");
1005
if (is_active != brasero_plugin_get_active (self))
1225
if (is_active != brasero_plugin_get_active (self, FALSE))
1006
1226
g_signal_emit (self,
1007
1227
plugin_signals [ACTIVATED_SIGNAL],
1009
brasero_plugin_get_active (self));
1232
typedef void (* BraseroPluginCheckConfig) (BraseroPlugin *plugin);
1235
* brasero_plugin_check_plugin_ready:
1236
* @plugin: a #BraseroPlugin.
1238
* Ask a plugin to check whether it can operate.
1239
* brasero_plugin_can_operate () should be called
1240
* afterwards to know whether it can operate or not.
1244
brasero_plugin_check_plugin_ready (BraseroPlugin *plugin)
1247
BraseroPluginPrivate *priv;
1248
BraseroPluginCheckConfig function = NULL;
1250
g_return_if_fail (BRASERO_IS_PLUGIN (plugin));
1251
priv = BRASERO_PLUGIN_PRIVATE (plugin);
1254
g_slist_foreach (priv->errors, (GFunc) brasero_plugin_error_free, NULL);
1255
g_slist_free (priv->errors);
1256
priv->errors = NULL;
1259
handle = g_module_open (priv->path, 0);
1261
brasero_plugin_add_error (plugin, BRASERO_PLUGIN_ERROR_MODULE, g_module_error ());
1262
BRASERO_BURN_LOG ("Module %s can't be loaded: g_module_open failed ()", priv->name);
1266
if (!g_module_symbol (handle, "brasero_plugin_check_config", (gpointer) &function)) {
1267
g_module_close (handle);
1268
BRASERO_BURN_LOG ("Module %s has no check config function", priv->name);
1272
function (BRASERO_PLUGIN (plugin));
1273
g_module_close (handle);
1018
1282
GConfClient *client;
1019
1283
gchar *priority_path;
1020
1284
BraseroPluginPrivate *priv;
1021
BraseroPluginRegisterType function;
1285
BraseroPluginRegisterType function = NULL;
1023
1287
priv = BRASERO_PLUGIN_PRIVATE (object);
1025
1289
g_type_module_set_name (G_TYPE_MODULE (object), priv->name);
1027
handle = g_module_open (priv->name, 0);
1291
handle = g_module_open (priv->path, 0);
1029
BRASERO_BURN_LOG ("Module can't be loaded: g_module_open failed");
1293
brasero_plugin_add_error (object, BRASERO_PLUGIN_ERROR_MODULE, g_module_error ());
1294
BRASERO_BURN_LOG ("Module %s (at %s) can't be loaded: g_module_open failed ()", priv->name, priv->path);
1033
1298
if (!g_module_symbol (handle, "brasero_plugin_register", (gpointer) &function)) {
1034
1299
g_module_close (handle);
1035
BRASERO_BURN_LOG ("Module can't be loaded: no register function");
1300
BRASERO_BURN_LOG ("Module %s can't be loaded: no register function, priv->name", priv->name);
1039
priv->type = function (BRASERO_PLUGIN (object), &priv->error);
1304
priv->type = function (object);
1040
1305
if (priv->type == G_TYPE_NONE) {
1041
1306
g_module_close (handle);
1042
BRASERO_BURN_LOG ("Module encountered an error while registering its capabilities:\n%s",
1043
priv->error ? priv->error:"unknown error");
1307
BRASERO_BURN_LOG ("Module %s encountered an error while registering its capabilities", priv->name);
1047
BRASERO_BURN_LOG ("Module %s successfully loaded", priv->name);
1048
g_module_close (handle);
1050
1311
/* now see if we need to override the hardcoded priority of the plugin */
1051
1312
client = gconf_client_get_default ();
1052
1313
priority_path = brasero_plugin_get_gconf_priority_key (object);