Mon, 31 Mar 2014 13:05:42 +0200
PurpleSmileyTheme: abstract implementation
--- a/libpurple/Makefile.am Sat Mar 29 18:14:02 2014 +0100 +++ b/libpurple/Makefile.am Mon Mar 31 13:05:42 2014 +0200 @@ -102,6 +102,7 @@ server.c \ signals.c \ smiley-list.c \ + smiley-theme.c \ smiley.c \ dnsquery.c \ dnssrv.c\ @@ -178,6 +179,7 @@ server.h \ signals.h \ smiley-list.h \ + smiley-theme.h \ smiley.h \ dnsquery.h \ dnssrv.h \
--- a/libpurple/core.c Sat Mar 29 18:14:02 2014 +0100 +++ b/libpurple/core.c Mon Mar 31 13:05:42 2014 +0200 @@ -41,7 +41,7 @@ #include "proxy.h" #include "savedstatuses.h" #include "signals.h" -#include "smiley.h" +#include "smiley-theme.h" #include "sound.h" #include "sound-theme-loader.h" #include "sslconn.h" @@ -256,9 +256,7 @@ purple_plugins_unload(PURPLE_PLUGIN_STANDARD); /* Save .xml files, remove signals, etc. */ -#if 0 - purple_smileys_uninit(); -#endif + purple_smiley_theme_uninit(); purple_http_uninit(); purple_idle_uninit(); purple_pounces_uninit();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libpurple/smiley-theme.c Mon Mar 31 13:05:42 2014 +0200 @@ -0,0 +1,91 @@ +/* purple + * + * Purple is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * source distribution. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA + */ + +#include "smiley-theme.h" + +#include "dbus-maybe.h" +#include "debug.h" + +static PurpleSmileyTheme *current = NULL; + +/******************************************************************************* + * API implementation + ******************************************************************************/ + +PurpleSmileyList * +purple_smiley_theme_get_smileys(PurpleSmileyTheme *theme, gpointer ui_data) +{ + PurpleSmileyThemeClass *klass; + + g_return_val_if_fail(PURPLE_IS_SMILEY_THEME(theme), NULL); + klass = PURPLE_SMILEY_THEME_GET_CLASS(theme); + g_return_val_if_fail(klass != NULL, NULL); + g_return_val_if_fail(klass->get_smileys != NULL, NULL); + + return klass->get_smileys(theme, ui_data); +} + +void +purple_smiley_theme_set_current(PurpleSmileyTheme *theme) +{ + g_return_if_fail(theme == NULL || PURPLE_IS_SMILEY_THEME(theme)); + + if (theme) + g_object_ref(theme); + if (current) + g_object_unref(current); + current = theme; +} + +PurpleSmileyTheme * +purple_smiley_theme_get_current(void) +{ + return current; +} + +void +purple_smiley_theme_uninit(void) +{ + purple_smiley_theme_set_current(NULL); +} + + +/******************************************************************************* + * Object stuff + ******************************************************************************/ + +GType +purple_smiley_theme_get_type(void) +{ + static GType type = 0; + + if (G_UNLIKELY(type == 0)) { + static const GTypeInfo info = { + .class_size = sizeof(PurpleSmileyThemeClass), + .instance_size = sizeof(PurpleSmileyTheme), + }; + + type = g_type_register_static(G_TYPE_OBJECT, + "PurpleSmileyTheme", &info, G_TYPE_FLAG_ABSTRACT); + } + + return type; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libpurple/smiley-theme.h Mon Mar 31 13:05:42 2014 +0200 @@ -0,0 +1,90 @@ +/* purple + * + * Purple is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * source distribution. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA + */ + +#ifndef _PURPLE_SMILEY_THEME_H_ +#define _PURPLE_SMILEY_THEME_H_ + +#include <glib-object.h> + +#include "smiley.h" +#include "smiley-list.h" + +typedef struct _PurpleSmileyTheme PurpleSmileyTheme; +typedef struct _PurpleSmileyThemeClass PurpleSmileyThemeClass; + +#define PURPLE_TYPE_SMILEY_THEME (purple_smiley_theme_get_type()) +#define PURPLE_SMILEY_THEME(smiley) (G_TYPE_CHECK_INSTANCE_CAST((smiley), PURPLE_TYPE_SMILEY_THEME, PurpleSmileyTheme)) +#define PURPLE_SMILEY_THEME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_SMILEY_THEME, PurpleSmileyThemeClass)) +#define PURPLE_IS_SMILEY_THEME(smiley) (G_TYPE_CHECK_INSTANCE_TYPE((smiley), PURPLE_TYPE_SMILEY_THEME)) +#define PURPLE_IS_SMILEY_THEME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_SMILEY_THEME)) +#define PURPLE_SMILEY_THEME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_SMILEY_THEME, PurpleSmileyThemeClass)) + +/** + * PurpleSmileyTheme: + * + * A list of smileys. + */ +struct _PurpleSmileyTheme +{ + /*< private >*/ + GObject parent; +}; + +struct _PurpleSmileyThemeClass +{ + /*< private >*/ + GObjectClass parent_class; + + PurpleSmileyList * (*get_smileys)(PurpleSmileyTheme *theme, + gpointer ui_data); + + void (*purple_reserved1)(void); + void (*purple_reserved2)(void); + void (*purple_reserved3)(void); + void (*purple_reserved4)(void); +}; + +G_BEGIN_DECLS + +/** + * purple_smiley_theme_get_type: + * + * Returns: The #GType for a smiley list. + */ +GType +purple_smiley_theme_get_type(void); + +PurpleSmileyList * +purple_smiley_theme_get_smileys(PurpleSmileyTheme *theme, gpointer ui_data); + +void +purple_smiley_theme_set_current(PurpleSmileyTheme *theme); + +PurpleSmileyTheme * +purple_smiley_theme_get_current(void); + +void +purple_smiley_theme_uninit(void); + +G_END_DECLS + +#endif /* _PURPLE_SMILEY_H_ */ +