comparison src/plugin.c @ 12704:69713c02a702

[gaim-migrate @ 15047] Add an error message for plugin magic mismatches. Translate the user-visible plugin error messages (the ones in the debug log are still in English, for us). committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Tue, 03 Jan 2006 20:30:22 +0000
parents df49362e0378
children 2c4f20ff387c
comparison
equal deleted inserted replaced
12703:df49362e0378 12704:69713c02a702
259 #endif 259 #endif
260 260
261 if (plugin->handle == NULL) 261 if (plugin->handle == NULL)
262 { 262 {
263 const char *error = g_module_error(); 263 const char *error = g_module_error();
264 if (error == NULL) 264 if (error != NULL && gaim_str_has_prefix(error, filename))
265 error = "Unknown error";
266 else if (gaim_str_has_prefix(error, filename))
267 { 265 {
268 error = error + strlen(filename); 266 error = error + strlen(filename);
269 267
270 /* These are just so we don't crash. If we 268 /* These are just so we don't crash. If we
271 * got this far, they should always be true. */ 269 * got this far, they should always be true. */
272 if (*error == ':') 270 if (*error == ':')
273 error++; 271 error++;
274 if (*error == ' ') 272 if (*error == ' ')
275 error++; 273 error++;
276
277 /* This shouldn't ever be necessary. */
278 if (!*error)
279 error = "Unknown error";
280 } 274 }
281 plugin->error = g_strdup(error); 275
282 276 if (error == NULL || !*error)
283 gaim_debug_error("plugins", "%s is unloadable: %s\n", 277 {
284 plugin->path, plugin->error); 278 plugin->error = g_strdup(_("Unknown error"));
285 279 gaim_debug_error("plugins", "%s is unloadable: Unknown error\n",
280 plugin->path);
281 }
282 else
283 {
284 plugin->error = g_strdup(error);
285 gaim_debug_error("plugins", "%s is unloadable: %s\n",
286 plugin->path, plugin->error);
287 }
286 #if GLIB_CHECK_VERSION(2,3,3) 288 #if GLIB_CHECK_VERSION(2,3,3)
287 plugin->handle = g_module_open(filename, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL); 289 plugin->handle = g_module_open(filename, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
288 #else 290 #else
289 plugin->handle = g_module_open(filename, G_MODULE_BIND_LAZY); 291 plugin->handle = g_module_open(filename, G_MODULE_BIND_LAZY);
290 #endif 292 #endif
355 } 357 }
356 358
357 /* Really old plugins. */ 359 /* Really old plugins. */
358 if (plugin->info->magic != GAIM_PLUGIN_MAGIC) 360 if (plugin->info->magic != GAIM_PLUGIN_MAGIC)
359 { 361 {
360 gaim_debug_error("plugins", "%s is unloadable: plugin magic mismatch %d (need %d)\n",
361 plugin->path, plugin->info->magic, GAIM_PLUGIN_MAGIC);
362
363 if (plugin->info->magic >= 2 && plugin->info->magic <= 4) 362 if (plugin->info->magic >= 2 && plugin->info->magic <= 4)
364 { 363 {
365 struct _GaimPluginInfo2 364 struct _GaimPluginInfo2
366 { 365 {
367 unsigned int api_version; 366 unsigned int api_version;
416 plugin->info->prefs_info = info2->prefs_info; 415 plugin->info->prefs_info = info2->prefs_info;
417 416
418 if (info2->api_version >= 4) 417 if (info2->api_version >= 4)
419 plugin->info->actions = info2->actions; 418 plugin->info->actions = info2->actions;
420 419
420
421 plugin->error = g_strdup_printf(_("Plugin magic mismatch %d (need %d)"),
422 plugin->info->magic, GAIM_PLUGIN_MAGIC);
423 gaim_debug_error("plugins", "%s is unloadable: Plugin magic mismatch %d (need %d)\n",
424 plugin->path, plugin->info->magic, GAIM_PLUGIN_MAGIC);
421 plugin->unloadable = TRUE; 425 plugin->unloadable = TRUE;
422 return plugin; 426 return plugin;
423 } 427 }
424 428
429 gaim_debug_error("plugins", "%s is unloadable: Plugin magic mismatch %d (need %d)\n",
430 plugin->path, plugin->info->magic, GAIM_PLUGIN_MAGIC);
425 gaim_plugin_destroy(plugin); 431 gaim_plugin_destroy(plugin);
426 return NULL; 432 return NULL;
427 } 433 }
428 434
429 if (plugin->info->major_version != GAIM_MAJOR_VERSION || 435 if (plugin->info->major_version != GAIM_MAJOR_VERSION ||
430 plugin->info->minor_version > GAIM_MINOR_VERSION) 436 plugin->info->minor_version > GAIM_MINOR_VERSION)
431 { 437 {
432 plugin->error = g_strdup_printf("ABI version mismatch %d.%d.x (need %d.%d.x)", 438 plugin->error = g_strdup_printf(_("ABI version mismatch %d.%d.x (need %d.%d.x)"),
433 plugin->info->major_version, plugin->info->minor_version, 439 plugin->info->major_version, plugin->info->minor_version,
434 GAIM_MAJOR_VERSION, GAIM_MINOR_VERSION); 440 GAIM_MAJOR_VERSION, GAIM_MINOR_VERSION);
435 gaim_debug_error("plugins", "%s is unloadable: %s\n", plugin->path, plugin->error); 441 gaim_debug_error("plugins", "%s is unloadable: ABI version mismatch %d.%d.x (need %d.%d.x)\n",
442 plugin->path, plugin->info->major_version, plugin->info->minor_version,
443 GAIM_MAJOR_VERSION, GAIM_MINOR_VERSION);
436 plugin->unloadable = TRUE; 444 plugin->unloadable = TRUE;
437 return plugin; 445 return plugin;
438 } 446 }
439 447
440 /* If plugin is a PRPL, make sure it implements the required functions */ 448 /* If plugin is a PRPL, make sure it implements the required functions */
441 if ((plugin->info->type == GAIM_PLUGIN_PROTOCOL) && ( 449 if ((plugin->info->type == GAIM_PLUGIN_PROTOCOL) && (
442 (GAIM_PLUGIN_PROTOCOL_INFO(plugin)->list_icon == NULL) || 450 (GAIM_PLUGIN_PROTOCOL_INFO(plugin)->list_icon == NULL) ||
443 (GAIM_PLUGIN_PROTOCOL_INFO(plugin)->login == NULL) || 451 (GAIM_PLUGIN_PROTOCOL_INFO(plugin)->login == NULL) ||
444 (GAIM_PLUGIN_PROTOCOL_INFO(plugin)->close == NULL))) 452 (GAIM_PLUGIN_PROTOCOL_INFO(plugin)->close == NULL)))
445 { 453 {
446 plugin->error = g_strdup("Does not implement all required functions"); 454 plugin->error = g_strdup(_("Plugin does not implement all required functions"));
447 gaim_debug_error("plugins", "%s is unloadable: %s\n", plugin->path, plugin->error); 455 gaim_debug_error("plugins", "%s is unloadable: Plugin does not implement all required functions\n",
456 plugin->path);
448 plugin->unloadable = TRUE; 457 plugin->unloadable = TRUE;
449 return plugin; 458 return plugin;
450 } 459 }
451 460
452 return plugin; 461 return plugin;