From 3b39d8b75cc4b16176c3cfb37d49803441dd99fd Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Tue, 25 Oct 2011 11:09:15 +0000 Subject: [PATCH] No longer requiring any value returned by the "destroy" callback in plug-ins --- include/Phone/plugin.h | 2 +- src/phone.c | 4 ++-- src/plugins/blacklist.c | 5 ++--- src/plugins/debug.c | 5 ++--- src/plugins/engineering.c | 5 ++--- src/plugins/gprs.c | 5 ++--- src/plugins/openmoko.c | 5 ++--- src/plugins/oss.c | 7 +++---- src/plugins/panel.c | 6 +++--- src/plugins/profiles.c | 5 ++--- src/plugins/smscrypt.c | 5 ++--- src/plugins/systray.c | 6 +++--- 12 files changed, 26 insertions(+), 34 deletions(-) diff --git a/include/Phone/plugin.h b/include/Phone/plugin.h index 375b90b..1752bd0 100644 --- a/include/Phone/plugin.h +++ b/include/Phone/plugin.h @@ -51,7 +51,7 @@ struct _PhonePlugin char const * name; char const * icon; int (*init)(PhonePlugin * plugin); - int (*destroy)(PhonePlugin * plugin); + void (*destroy)(PhonePlugin * plugin); int (*event)(PhonePlugin * plugin, PhoneEvent * event); void (*settings)(PhonePlugin * plugin); void * priv; diff --git a/src/phone.c b/src/phone.c index 73c8d7f..a1d03eb 100644 --- a/src/phone.c +++ b/src/phone.c @@ -3685,8 +3685,8 @@ static int _phone_unload(Phone * phone, PhonePlugin * plugin) fprintf(stderr, "DEBUG: %s() plugin %lu\n", __func__, (unsigned long)i); #endif - if(plugin->destroy != NULL && plugin->destroy(plugin) != 0) - phone_error(phone, error_get(), 0); + if(plugin->destroy != NULL) + plugin->destroy(plugin); plugin_delete(phone->plugins[i].p); memmove(&phone->plugins[i], &phone->plugins[i + 1], sizeof(*phone->plugins) diff --git a/src/plugins/blacklist.c b/src/plugins/blacklist.c index 3a50341..d8c9528 100644 --- a/src/plugins/blacklist.c +++ b/src/plugins/blacklist.c @@ -36,7 +36,7 @@ typedef struct _Blacklist /* prototypes */ static int _blacklist_init(PhonePlugin * plugin); -static int _blacklist_destroy(PhonePlugin * plugin); +static void _blacklist_destroy(PhonePlugin * plugin); static int _blacklist_event(PhonePlugin * plugin, PhoneEvent * event); static void _blacklist_settings(PhonePlugin * plugin); @@ -88,14 +88,13 @@ static void _init_foreach(char const * variable, char const * value, /* blacklist_destroy */ -static int _blacklist_destroy(PhonePlugin * plugin) +static void _blacklist_destroy(PhonePlugin * plugin) { Blacklist * blacklist = plugin->priv; if(blacklist->window != NULL) gtk_widget_destroy(blacklist->window); object_delete(blacklist); - return 0; } diff --git a/src/plugins/debug.c b/src/plugins/debug.c index dd96a71..5c24d9c 100644 --- a/src/plugins/debug.c +++ b/src/plugins/debug.c @@ -87,7 +87,7 @@ static DebugPhoneEvents _debug_phone_events[] = /* prototypes */ /* plug-in */ static int _debug_init(PhonePlugin * plugin); -static int _debug_destroy(PhonePlugin * plugin); +static void _debug_destroy(PhonePlugin * plugin); static int _debug_event(PhonePlugin * plugin, PhoneEvent * event); static void _debug_settings(PhonePlugin * plugin); @@ -213,13 +213,12 @@ static void _on_debug_queue_execute(gpointer data) /* debug_destroy */ -static int _debug_destroy(PhonePlugin * plugin) +static void _debug_destroy(PhonePlugin * plugin) { Debug * debug = plugin->priv; gtk_widget_destroy(debug->window); object_delete(debug); - return 0; } diff --git a/src/plugins/engineering.c b/src/plugins/engineering.c index b113a04..8c1d570 100644 --- a/src/plugins/engineering.c +++ b/src/plugins/engineering.c @@ -159,7 +159,7 @@ static struct /* prototypes */ static int _engineering_init(PhonePlugin * plugin); -static int _engineering_destroy(PhonePlugin * plugin); +static void _engineering_destroy(PhonePlugin * plugin); static double _engineering_get_frequency(unsigned int arfcn); @@ -326,7 +326,7 @@ static int _engineering_init(PhonePlugin * plugin) /* engineering_destroy */ -static int _engineering_destroy(PhonePlugin * plugin) +static void _engineering_destroy(PhonePlugin * plugin) { Engineering * engineering = plugin->priv; @@ -334,7 +334,6 @@ static int _engineering_destroy(PhonePlugin * plugin) g_source_remove(engineering->source); gtk_widget_destroy(engineering->window); free(engineering); - return 0; } diff --git a/src/plugins/gprs.c b/src/plugins/gprs.c index 5b746f4..8c1a567 100644 --- a/src/plugins/gprs.c +++ b/src/plugins/gprs.c @@ -55,7 +55,7 @@ typedef struct _GPRS /* prototypes */ /* plugins */ static int _gprs_init(PhonePlugin * plugin); -static int _gprs_destroy(PhonePlugin * plugin); +static void _gprs_destroy(PhonePlugin * plugin); static int _gprs_event(PhonePlugin * plugin, PhoneEvent * event); static void _gprs_settings(PhonePlugin * plugin); @@ -132,7 +132,7 @@ static int _gprs_init(PhonePlugin * plugin) /* gprs_destroy */ -static int _gprs_destroy(PhonePlugin * plugin) +static void _gprs_destroy(PhonePlugin * plugin) { GPRS * gprs = plugin->priv; @@ -144,7 +144,6 @@ static int _gprs_destroy(PhonePlugin * plugin) if(gprs->window != NULL) gtk_widget_destroy(gprs->window); object_delete(gprs); - return 0; } diff --git a/src/plugins/openmoko.c b/src/plugins/openmoko.c index 330daee..6db26af 100644 --- a/src/plugins/openmoko.c +++ b/src/plugins/openmoko.c @@ -70,7 +70,7 @@ typedef struct _Openmoko /* prototypes */ /* plug-in */ static int _openmoko_init(PhonePlugin * plugin); -static int _openmoko_destroy(PhonePlugin * plugin); +static void _openmoko_destroy(PhonePlugin * plugin); static int _openmoko_event(PhonePlugin * plugin, PhoneEvent * event); static void _openmoko_deepsleep(PhonePlugin * plugin); static void _openmoko_queue(PhonePlugin * plugin, char const * command); @@ -117,7 +117,7 @@ static int _openmoko_init(PhonePlugin * plugin) /* openmoko_destroy */ -static int _openmoko_destroy(PhonePlugin * plugin) +static void _openmoko_destroy(PhonePlugin * plugin) { Openmoko * openmoko = plugin->priv; @@ -125,7 +125,6 @@ static int _openmoko_destroy(PhonePlugin * plugin) if(openmoko->window != NULL) gtk_widget_destroy(openmoko->window); object_delete(openmoko); - return 0; } diff --git a/src/plugins/oss.c b/src/plugins/oss.c index 86a5d20..2160417 100644 --- a/src/plugins/oss.c +++ b/src/plugins/oss.c @@ -54,7 +54,7 @@ typedef struct _OSS /* prototypes */ static int _oss_init(PhonePlugin * plugin); -static int _oss_destroy(PhonePlugin * plugin); +static void _oss_destroy(PhonePlugin * plugin); static int _oss_event(PhonePlugin * plugin, PhoneEvent * event); static int _oss_open(PhonePlugin * plugin); static void _oss_settings(PhonePlugin * plugin); @@ -93,7 +93,7 @@ static int _oss_init(PhonePlugin * plugin) /* oss_destroy */ -static int _oss_destroy(PhonePlugin * plugin) +static void _oss_destroy(PhonePlugin * plugin) { OSS * oss = plugin->priv; @@ -101,8 +101,7 @@ static int _oss_destroy(PhonePlugin * plugin) close(oss->fd); if(oss->window != NULL) gtk_widget_destroy(oss->window); - free(oss); - return 0; + object_delete(oss); } diff --git a/src/plugins/panel.c b/src/plugins/panel.c index 9fbf52d..13300a2 100644 --- a/src/plugins/panel.c +++ b/src/plugins/panel.c @@ -82,7 +82,7 @@ typedef struct _Panel /* prototypes */ static int _panel_init(PhonePlugin * plugin); -static int _panel_destroy(PhonePlugin * plugin); +static void _panel_destroy(PhonePlugin * plugin); static int _panel_event(PhonePlugin * plugin, PhoneEvent * event); static void _panel_settings(PhonePlugin * plugin); @@ -245,7 +245,7 @@ static gboolean _on_battery_timeout(gpointer data) /* panel_destroy */ -static int _panel_destroy(PhonePlugin * plugin) +static void _panel_destroy(PhonePlugin * plugin) { Panel * panel = plugin->priv; @@ -254,7 +254,7 @@ static int _panel_destroy(PhonePlugin * plugin) if(panel->timeout != 0) g_source_remove(panel->timeout); gtk_widget_destroy(panel->hbox); - return 0; + object_delete(panel); } diff --git a/src/plugins/profiles.c b/src/plugins/profiles.c index 7b93012..8490a98 100644 --- a/src/plugins/profiles.c +++ b/src/plugins/profiles.c @@ -91,7 +91,7 @@ static ProfileDefinition _profiles_definitions[] = /* prototypes */ static int _profiles_init(PhonePlugin * plugin); -static int _profiles_destroy(PhonePlugin * plugin); +static void _profiles_destroy(PhonePlugin * plugin); static int _profiles_event(PhonePlugin * plugin, PhoneEvent * event); static void _profiles_settings(PhonePlugin * plugin); @@ -189,7 +189,7 @@ static gboolean _init_idle(gpointer data) /* profiles_destroy */ -static int _profiles_destroy(PhonePlugin * plugin) +static void _profiles_destroy(PhonePlugin * plugin) { Profiles * profiles = plugin->priv; @@ -206,7 +206,6 @@ static int _profiles_destroy(PhonePlugin * plugin) pa_context_unref(profiles->pac); pa_threaded_mainloop_free(profiles->pam); object_delete(profiles); - return 0; } diff --git a/src/plugins/smscrypt.c b/src/plugins/smscrypt.c index 56ec197..67a7994 100644 --- a/src/plugins/smscrypt.c +++ b/src/plugins/smscrypt.c @@ -44,7 +44,7 @@ typedef struct _SMSCrypt static void _smscrypt_clear(PhonePlugin * plugin); static gboolean _smscrypt_confirm(PhonePlugin * plugin, char const * message); static int _smscrypt_init(PhonePlugin * plugin); -static int _smscrypt_destroy(PhonePlugin * plugin); +static void _smscrypt_destroy(PhonePlugin * plugin); static int _smscrypt_event(PhonePlugin * plugin, PhoneEvent * event); static int _smscrypt_secret(PhonePlugin * plugin, char const * number); static void _smscrypt_settings(PhonePlugin * plugin); @@ -132,14 +132,13 @@ static void _init_foreach(char const * variable, char const * value, /* smscrypt_destroy */ -static int _smscrypt_destroy(PhonePlugin * plugin) +static void _smscrypt_destroy(PhonePlugin * plugin) { SMSCrypt * smscrypt = plugin->priv; if(smscrypt->window != NULL) gtk_widget_destroy(smscrypt->window); free(smscrypt); - return 0; } diff --git a/src/plugins/systray.c b/src/plugins/systray.c index 208758e..d741c38 100644 --- a/src/plugins/systray.c +++ b/src/plugins/systray.c @@ -38,7 +38,7 @@ typedef struct _Systray /* prototypes */ /* plug-in */ static int _systray_init(PhonePlugin * plugin); -static int _systray_destroy(PhonePlugin * plugin); +static void _systray_destroy(PhonePlugin * plugin); /* callbacks */ #if GTK_CHECK_VERSION(2, 10, 0) @@ -94,12 +94,12 @@ static int _systray_init(PhonePlugin * plugin) /* systray_destroy */ -static int _systray_destroy(PhonePlugin * plugin) +static void _systray_destroy(PhonePlugin * plugin) { Systray * systray = plugin->priv; g_object_unref(systray->icon); - return 0; + object_delete(systray); }