libpurple/protocols/zephyr/zephyr.c

branch
soc.2013.gobjectification.plugins
changeset 36535
66c2fb23888f
parent 34864
0e292d8887de
child 36536
07f8c9889257
equal deleted inserted replaced
36534:c582c94a71ac 36535:66c2fb23888f
29 #include "libpurple/internal.h" 29 #include "libpurple/internal.h"
30 30
31 #include "accountopt.h" 31 #include "accountopt.h"
32 #include "debug.h" 32 #include "debug.h"
33 #include "notify.h" 33 #include "notify.h"
34 #include "plugins.h"
34 #include "prpl.h" 35 #include "prpl.h"
35 #include "server.h" 36 #include "server.h"
36 #include "util.h" 37 #include "util.h"
37 #include "cmds.h" 38 #include "cmds.h"
38 #include "version.h" 39 #include "version.h"
2795 /* XXX handle unsubscriptions */ 2796 /* XXX handle unsubscriptions */
2796 return 1; 2797 return 1;
2797 } 2798 }
2798 2799
2799 2800
2800 static void zephyr_action_resubscribe(PurplePluginAction *action) 2801 static void zephyr_action_resubscribe(PurpleProtocolAction *action)
2801 { 2802 {
2802 2803
2803 PurpleConnection *gc = (PurpleConnection *) action->context; 2804 PurpleConnection *gc = action->connection;
2804 zephyr_resubscribe(gc); 2805 zephyr_resubscribe(gc);
2805 } 2806 }
2806 2807
2807 2808
2808 static void zephyr_action_get_subs_from_server(PurplePluginAction *action) 2809 static void zephyr_action_get_subs_from_server(PurpleProtocolAction *action)
2809 { 2810 {
2810 PurpleConnection *gc = (PurpleConnection *) action->context; 2811 PurpleConnection *gc = action->connection;
2811 zephyr_account *zephyr = purple_connection_get_protocol_data(gc); 2812 zephyr_account *zephyr = purple_connection_get_protocol_data(gc);
2812 gchar *title; 2813 gchar *title;
2813 int retval, nsubs, one,i; 2814 int retval, nsubs, one,i;
2814 ZSubscription_t subs; 2815 ZSubscription_t subs;
2815 if (use_zeph02(zephyr)) { 2816 if (use_zeph02(zephyr)) {
2848 purple_notify_error(gc,"","tzc doesn't support this action",NULL); 2849 purple_notify_error(gc,"","tzc doesn't support this action",NULL);
2849 } 2850 }
2850 } 2851 }
2851 2852
2852 2853
2853 static GList *zephyr_actions(PurplePlugin *plugin, gpointer context) 2854 static GList *zephyr_get_actions(PurpleConnection *gc)
2854 { 2855 {
2855 GList *list = NULL; 2856 GList *list = NULL;
2856 PurplePluginAction *act = NULL; 2857 PurpleProtocolAction *act = NULL;
2857 2858
2858 act = purple_plugin_action_new(_("Resubscribe"), zephyr_action_resubscribe); 2859 act = purple_protocol_action_new(_("Resubscribe"), zephyr_action_resubscribe);
2859 list = g_list_append(list, act); 2860 list = g_list_append(list, act);
2860 2861
2861 act = purple_plugin_action_new(_("Retrieve subscriptions from server"), zephyr_action_get_subs_from_server); 2862 act = purple_protocol_action_new(_("Retrieve subscriptions from server"), zephyr_action_get_subs_from_server);
2862 list = g_list_append(list,act); 2863 list = g_list_append(list,act);
2863 2864
2864 return list; 2865 return list;
2865 } 2866 }
2866 2867
2867 static PurplePlugin *my_protocol = NULL; 2868 static PurplePluginProtocolInfo *my_protocol = NULL;
2868 2869
2869 static PurplePluginProtocolInfo prpl_info = { 2870 static PurplePluginProtocolInfo prpl_info = {
2871 "prpl-zephyr", /* id */
2872 "Zephyr", /* name */
2870 sizeof(PurplePluginProtocolInfo), /* struct_size */ 2873 sizeof(PurplePluginProtocolInfo), /* struct_size */
2871 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_NO_PASSWORD, 2874 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_NO_PASSWORD,
2872 NULL, /* ??? user_splits */ 2875 NULL, /* ??? user_splits */
2873 NULL, /* ??? protocol_options */ 2876 NULL, /* ??? protocol_options */
2874 NO_BUDDY_ICONS, 2877 NO_BUDDY_ICONS,
2878 zephyr_get_actions,
2875 zephyr_list_icon, 2879 zephyr_list_icon,
2876 NULL, /* ??? list_emblems */ 2880 NULL, /* ??? list_emblems */
2877 NULL, /* ??? status_text */ 2881 NULL, /* ??? status_text */
2878 NULL, /* ??? tooltip_text */ 2882 NULL, /* ??? tooltip_text */
2879 zephyr_status_types, /* status_types */ 2883 zephyr_status_types, /* status_types */
2939 NULL, /* get_moods */ 2943 NULL, /* get_moods */
2940 NULL, /* set_public_alias */ 2944 NULL, /* set_public_alias */
2941 NULL /* get_public_alias */ 2945 NULL /* get_public_alias */
2942 }; 2946 };
2943 2947
2944 static PurplePluginInfo info = { 2948 static PurplePluginInfo *plugin_query(GError **error)
2945 PURPLE_PLUGIN_MAGIC, 2949 {
2946 PURPLE_MAJOR_VERSION, 2950 return purple_plugin_info_new(
2947 PURPLE_MINOR_VERSION, 2951 "id", "prpl-zephyr",
2948 PURPLE_PLUGIN_PROTOCOL, /**< type */ 2952 "name", "Zephyr",
2949 NULL, /**< ui_requirement */ 2953 "version", DISPLAY_VERSION,
2950 0, /**< flags */ 2954 "category", N_("Protocol"),
2951 NULL, /**< dependencies */ 2955 "summary", N_("Zephyr Protocol Plugin"),
2952 PURPLE_PRIORITY_DEFAULT, /**< priority */ 2956 "description", N_("Zephyr Protocol Plugin"),
2953 2957 "website", PURPLE_WEBSITE,
2954 "prpl-zephyr", /**< id */ 2958 "abi-version", PURPLE_ABI_VERSION,
2955 "Zephyr", /**< name */ 2959 NULL
2956 DISPLAY_VERSION, /**< version */ 2960 );
2957 /** summary */ 2961 }
2958 N_("Zephyr Protocol Plugin"), 2962
2959 /** description */ 2963 static gboolean plugin_load(PurplePlugin *plugin, GError **error)
2960 N_("Zephyr Protocol Plugin"),
2961 NULL, /**< author */
2962 PURPLE_WEBSITE, /**< homepage */
2963
2964 NULL, /**< load */
2965 NULL, /**< unload */
2966 NULL, /**< destroy */
2967
2968 NULL, /**< ui_info */
2969 &prpl_info, /**< extra_info */
2970 NULL,
2971 zephyr_actions,
2972
2973 /* padding */
2974 NULL,
2975 NULL,
2976 NULL,
2977 NULL
2978 };
2979
2980 static void init_plugin(PurplePlugin * plugin)
2981 { 2964 {
2982 PurpleAccountOption *option; 2965 PurpleAccountOption *option;
2983 char *tmp = get_exposure_level(); 2966 char *tmp = get_exposure_level();
2984 2967
2985 option = purple_account_option_bool_new(_("Use tzc"), "use_tzc", FALSE); 2968 option = purple_account_option_bool_new(_("Use tzc"), "use_tzc", FALSE);
3007 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); 2990 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
3008 2991
3009 option = purple_account_option_string_new(_("Encoding"), "encoding", ZEPHYR_FALLBACK_CHARSET); 2992 option = purple_account_option_string_new(_("Encoding"), "encoding", ZEPHYR_FALLBACK_CHARSET);
3010 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); 2993 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
3011 2994
3012 my_protocol = plugin; 2995 my_protocol = &prpl_info;
3013 zephyr_register_slash_commands(); 2996 zephyr_register_slash_commands();
3014 } 2997
3015 2998 purple_protocols_add(my_protocol);
3016 PURPLE_INIT_PLUGIN(zephyr, init_plugin, info); 2999 return TRUE;
3000 }
3001
3002 static gboolean plugin_unload(PurplePlugin *plugin, GError **error)
3003 {
3004 purple_protocols_remove(my_protocol);
3005 return TRUE;
3006 }
3007
3008 PURPLE_PLUGIN_INIT(zephyr, plugin_query, plugin_load, plugin_unload);

mercurial