Mercurial > pidgin
diff src/buddy.c @ 5205:fefad67de2c7
[gaim-migrate @ 5573]
I had a damn good commit message, but it was eaten. Let's try it again.
Announcing, Gaim Plugin API version 2.0, or GPAPIV2.0 for short.
There are lots'a cool thingies here.
Okay now, this isn't as cool as the previous message, but:
1) There's now a single entry function for all plugin types. It returns a
detailed information structure on the plugin. This removes a lot of the
ugliness from old plugins. Oh yeah, libicq wasn't converted to this, so
if you use it, well, you shouldn't have used it anyway, but now you
can't! bwahahaha. Use AIM/ICQ.
2) There are now 3 types of plugins: Standard, Loader, and Protocol
plugins.
Standard plugins are, well, standard, compiled plugins.
Loader plugins load other plugins. For example, the perl support is now
a loader plugin. It loads perl scripts. In the future, we'll have
Ruby and Python loader plugins.
Protocol plugins are, well, protocol plugins... yeah...
3) Plugins have unique IDs, so they can be referred to or automatically
updated from a plugin database in the future. Neat, huh?
4) Plugins will have dependency support in the future, and can be hidden,
so if you have, say, a logging core plugin, it won't have to show up,
but then you load the GTK+ logging plugin and it'll auto-load the core
plugin. Core/UI split plugins!
5) There will eventually be custom plugin signals and RPC of some sort, for
the core/ui split plugins.
So, okay, back up .gaimrc.
I'd like to thank my parents for their support, javabsp for helping convert
a bunch of protocol plugins, and Etan for helping convert a bunch of
standard plugins.
Have fun. If you have any problems, please let me know, but you probably
won't have anything major happen. You will have to convert your plugins,
though, and I'm not guaranteeing that all perl scripts will still work.
I'll end up changing the perl script API eventually, so I know they won't
down the road. Don't worry, though. It'll be mass cool.
faceprint wants me to just commit the damn code already. So, here we go!!!
..
..
I need a massage. From a young, cute girl. Are there any young, cute girls
in the audience? IM me plz k thx.
committer: Tailor Script <tailor@pidgin.im>
| author | Christian Hammond <chipx86@chipx86.com> |
|---|---|
| date | Fri, 25 Apr 2003 06:47:33 +0000 |
| parents | b81e3c496598 |
| children | 0241d6b6702d |
line wrap: on
line diff
--- a/src/buddy.c Thu Apr 24 03:52:25 2003 +0000 +++ b/src/buddy.c Fri Apr 25 06:47:33 2003 +0000 @@ -315,7 +315,8 @@ GtkWidget *menu, *menuitem; GtkTreeSelection *sel; GList *list; - struct prpl *prpl; + GaimPlugin *prpl = NULL; + GaimPluginProtocolInfo *prpl_info = NULL; if (event->button != 3) return FALSE; @@ -334,9 +335,12 @@ gaim_new_item_from_stock(menu, _("_Rename"), NULL, G_CALLBACK(show_rename_group), node, 0, 0, NULL); } else if (GAIM_BLIST_NODE_IS_BUDDY(node)) { /* Protocol specific options */ - prpl = find_prpl(((struct buddy*)node)->account->protocol); + prpl = gaim_find_prpl(((struct buddy*)node)->account->protocol); - if (prpl && prpl->get_info) + if (prpl != NULL) + prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); + + if (prpl && prpl_info->get_info) gaim_new_item_from_stock(menu, _("_Get Info"), GAIM_STOCK_INFO, G_CALLBACK(gtk_blist_menu_info_cb), node, 0, 0, NULL); gaim_new_item_from_stock(menu, _("_IM"), GAIM_STOCK_IM, G_CALLBACK(gtk_blist_menu_im_cb), node, 0, 0, NULL); @@ -344,7 +348,7 @@ gaim_new_item_from_stock(menu, _("View _Log"), NULL, G_CALLBACK(gtk_blist_menu_showlog_cb), node, 0, 0, NULL); if (prpl) { - list = prpl->buddy_menu(((struct buddy*)node)->account->gc, ((struct buddy*)node)->name); + list = prpl_info->buddy_menu(((struct buddy*)node)->account->gc, ((struct buddy*)node)->name); while (list) { struct proto_buddy_menu *pbm = list->data; menuitem = gtk_menu_item_new_with_mnemonic(pbm->label); @@ -355,7 +359,7 @@ } } - plugin_event (event_draw_menu, menu, ((struct buddy *) node)->name); + gaim_event_broadcast (event_draw_menu, menu, ((struct buddy *) node)->name); gaim_separator(menu); gaim_new_item_from_stock(menu, _("_Alias"), GAIM_STOCK_EDIT, G_CALLBACK(gtk_blist_menu_alias_cb), node, 0, 0, NULL); @@ -676,15 +680,19 @@ static char *gaim_get_tooltip_text(struct buddy *b) { + GaimPlugin *prpl; + GaimPluginProtocolInfo *prpl_info = NULL; char *text = NULL; - struct prpl* prpl = find_prpl(b->account->protocol); char *statustext = NULL; char *aliastext = NULL, *nicktext = NULL; char *warning = NULL, *idletime = NULL; - if (prpl->tooltip_text) { + prpl = gaim_find_prpl(b->account->protocol); + prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); + + if (prpl_info->tooltip_text) { const char *end; - statustext = prpl->tooltip_text(b); + statustext = prpl_info->tooltip_text(b); if(statustext && !g_utf8_validate(statustext, -1, &end)) { char *new = g_strndup(statustext, @@ -760,15 +768,20 @@ int scalesize = 30; - struct prpl* prpl = find_prpl(b->account->protocol); + GaimPlugin *prpl; + GaimPluginProtocolInfo *prpl_info = NULL; + + prpl = gaim_find_prpl(b->account->protocol); if (!prpl) return NULL; - if (prpl->list_icon) - protoname = prpl->list_icon(b->account, b); - if (b->present != GAIM_BUDDY_SIGNING_OFF && prpl->list_emblems) - prpl->list_emblems(b, &se, &sw, &nw, &ne); + prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); + + if (prpl_info->list_icon) + protoname = prpl_info->list_icon(b->account, b); + if (b->present != GAIM_BUDDY_SIGNING_OFF && prpl_info->list_emblems) + prpl_info->list_emblems(b, &se, &sw, &nw, &ne); if (size == GAIM_STATUS_ICON_SMALL) { scalesize = 15; @@ -929,14 +942,19 @@ { char *name = gaim_get_buddy_alias(b); char *esc = g_markup_escape_text(name, strlen(name)), *text = NULL; - struct prpl* prpl = find_prpl(b->account->protocol); - + GaimPlugin *prpl; + GaimPluginProtocolInfo *prpl_info = NULL; /* XXX Clean up this crap */ int ihrs, imin; char *idletime = NULL, *warning = NULL, *statustext = NULL; time_t t; + prpl = gaim_find_prpl(b->account->protocol); + + if (prpl != NULL) + prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); + if (!(blist_options & OPT_BLIST_SHOW_ICONS)) { if ((b->idle && blist_options & OPT_BLIST_GREY_IDLERS && !selected) || !GAIM_BUDDY_IS_ONLINE(b)) { text = g_strdup_printf("<span color='dim grey'>%s</span>", @@ -952,8 +970,8 @@ ihrs = (t - b->idle) / 3600; imin = ((t - b->idle) / 60) % 60; - if (prpl && prpl->status_text) { - char *tmp = prpl->status_text(b); + if (prpl && prpl_info->status_text) { + char *tmp = prpl_info->status_text(b); const char *end; if(tmp && !g_utf8_validate(tmp, -1, &end)) { @@ -1755,61 +1773,36 @@ GdkPixbuf * create_prpl_icon(struct gaim_account *account) { - struct prpl *prpl = find_prpl(account->protocol); + GaimPlugin *prpl; + GaimPluginProtocolInfo *prpl_info = NULL; GdkPixbuf *status = NULL; char *filename = NULL; const char *protoname = NULL; + char buf[256]; - /* this is so we can get the icon when the prpl isn't loaded. - * it's not as bad as it looks, since most of the time this function - * is called, the prpl is already loaded, so it'll just increment and - * decrement the refcount, won't have to go through the hassle of - * actually loading and unloading the prpl. the few times it actually - * does that, it saves us from crashing */ - if(prpl && prpl->list_icon) { - ref_protocol(prpl); - protoname = prpl->list_icon(account, NULL); - unref_protocol(prpl); + prpl = gaim_find_prpl(account->protocol); + + if (prpl != NULL) { + prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); + + if (prpl_info->list_icon != NULL) + protoname = prpl_info->list_icon(account, NULL); } - if (!protoname) + if (protoname == NULL) return NULL; - /* "Hey, what's all this crap?" you ask. Status icons will be themeable too, and - then it will look up protoname from the theme */ - if (!strcmp(protoname, "aim")) { - filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "aim.png", NULL); - status = gdk_pixbuf_new_from_file(filename,NULL); - g_free(filename); - } else if (!strcmp(protoname, "yahoo")) { - filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "yahoo.png", NULL); - status = gdk_pixbuf_new_from_file(filename,NULL); - g_free(filename); - } else if (!strcmp(protoname, "msn")) { - filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "msn.png", NULL); - status = gdk_pixbuf_new_from_file(filename,NULL); - g_free(filename); - } else if (!strcmp(protoname, "jabber")) { - filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "jabber.png", NULL); - status = gdk_pixbuf_new_from_file(filename,NULL); - g_free(filename); - } else if (!strcmp(protoname, "icq")) { - filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "icq.png", NULL); - status = gdk_pixbuf_new_from_file(filename,NULL); - g_free(filename); - } else if (!strcmp(protoname, "gadu-gadu")) { - filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "gadu-gadu.png", NULL); - status = gdk_pixbuf_new_from_file(filename,NULL); - g_free(filename); - } else if (!strcmp(protoname, "napster")) { - filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "napster.png", NULL); - status = gdk_pixbuf_new_from_file(filename,NULL); - g_free(filename); - } else if (!strcmp(protoname, "irc")) { - filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "irc.png", NULL); - status = gdk_pixbuf_new_from_file(filename,NULL); - g_free(filename); - } + /* + * Status icons will be themeable too, and then it will look up + * protoname from the theme + */ + g_snprintf(buf, sizeof(buf), "%s.png", protoname); + + filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", + "default", buf, NULL); + status = gdk_pixbuf_new_from_file(filename, NULL); + g_free(filename); + return status; }
