Fri, 25 Apr 2003 06:47:33 +0000
[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.
| 2495 | 1 | #define GAIM_PLUGINS |
| 2 | #include "gaim.h" | |
| 3 | #include "prpl.h" | |
| 4 | #ifdef MAX | |
| 5 | #undef MAX | |
| 6 | #undef MIN | |
| 7 | #endif | |
|
2824
e95a1b97a4f1
[gaim-migrate @ 2837]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2495
diff
changeset
|
8 | #include "protocols/jabber/jabber.h" |
| 2495 | 9 | |
| 10 | static GtkWidget *window = NULL; | |
| 11 | static GtkWidget *optmenu = NULL; | |
| 12 | static struct gaim_connection *gc = NULL; | |
| 13 | static GModule *me = NULL; | |
| 14 | ||
| 15 | /* this is an evil hack. | |
| 16 | * gc->proto_data for Jabber connections can be cast to a jconn *. | |
| 17 | * gc->proto_data for MSN, TOC, and IRC connections can be cast to an int *. | |
| 18 | */ | |
| 19 | ||
| 3551 | 20 | struct gaim_plugin_description desc; |
| 21 | struct gaim_plugin_description *gaim_plugin_desc() { | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4655
diff
changeset
|
22 | desc.api_version = GAIM_PLUGIN_API_VERSION; |
| 3551 | 23 | desc.name = g_strdup("Raw Input"); |
| 24 | desc.version = g_strdup(VERSION); | |
| 25 | desc.description = g_strdup("Lets you send raw input to text-vased protocols (Jabber, MSN, IRC, TOC). Hit 'Enter' in the entry box to send. Watch the debug window."); | |
| 26 | desc.authors = g_strdup("Eric Warmehoven <eric@warmenhoven.org>"); | |
| 27 | desc.url = g_strdup(WEBSITE); | |
| 28 | return &desc; | |
| 29 | } | |
| 30 | ||
| 31 | ||
| 2495 | 32 | char *name() |
| 33 | { | |
| 34 | return "Raw"; | |
| 35 | } | |
| 36 | ||
| 37 | char *description() | |
| 38 | { | |
| 39 | return "Lets you send raw XML to Jabber, or raw commands to MSN, IRC, and TOC." | |
| 40 | " Not very useful except for debugging. Hit 'enter' in the entry to send." | |
| 41 | " Watch the debug window."; | |
| 42 | } | |
| 43 | ||
| 44 | static int goodbye() | |
| 45 | { | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4655
diff
changeset
|
46 | gaim_plugin_unload_self(me); |
| 2495 | 47 | return FALSE; |
| 48 | } | |
| 49 | ||
| 50 | static void send_it(GtkEntry *entry) | |
| 51 | { | |
| 4655 | 52 | const char *txt; |
| 2495 | 53 | if (!gc) return; |
| 54 | txt = gtk_entry_get_text(entry); | |
| 55 | switch (gc->protocol) { | |
| 56 | case PROTO_TOC: | |
| 57 | { | |
| 58 | int *a = (int *)gc->proto_data; | |
| 59 | unsigned short seqno = htons(a[1]++ & 0xffff); | |
| 60 | unsigned short len = htons(strlen(txt) + 1); | |
| 61 | write(*a, "*\002", 2); | |
| 62 | write(*a, &seqno, 2); | |
| 63 | write(*a, &len, 2); | |
| 64 | write(*a, txt, ntohs(len)); | |
| 65 | debug_printf("TOC C: %s\n", txt); | |
| 66 | } | |
| 67 | break; | |
| 68 | case PROTO_MSN: | |
| 69 | write(*(int *)gc->proto_data, txt, strlen(txt)); | |
| 70 | write(*(int *)gc->proto_data, "\r\n", 2); | |
| 71 | debug_printf("MSN C: %s\n", txt); | |
| 72 | break; | |
| 73 | case PROTO_IRC: | |
| 74 | write(*(int *)gc->proto_data, txt, strlen(txt)); | |
| 75 | write(*(int *)gc->proto_data, "\r\n", 2); | |
| 76 | debug_printf("IRC C: %s\n", txt); | |
| 77 | break; | |
| 78 | case PROTO_JABBER: | |
| 79 | jab_send_raw(*(jconn *)gc->proto_data, txt); | |
| 80 | break; | |
| 81 | } | |
| 82 | gtk_entry_set_text(entry, ""); | |
| 83 | } | |
| 84 | ||
| 85 | static void set_gc(gpointer d, struct gaim_connection *c) | |
| 86 | { | |
| 87 | gc = c; | |
| 88 | } | |
| 89 | ||
| 90 | static void redo_optmenu(struct gaim_connection *arg, gpointer x) | |
| 91 | { | |
| 92 | GtkWidget *menu; | |
| 93 | GSList *g = connections; | |
| 94 | struct gaim_connection *c; | |
| 95 | ||
| 96 | menu = gtk_menu_new(); | |
| 97 | gc = NULL; | |
| 98 | ||
| 99 | while (g) { | |
| 100 | char buf[256]; | |
| 101 | GtkWidget *opt; | |
| 102 | c = (struct gaim_connection *)g->data; | |
| 103 | g = g->next; | |
| 104 | if (x && c == arg) | |
| 105 | continue; | |
| 106 | if (c->protocol != PROTO_TOC && c->protocol != PROTO_MSN && | |
| 107 | c->protocol != PROTO_IRC && c->protocol != PROTO_JABBER) | |
| 108 | continue; | |
| 109 | if (!gc) | |
| 110 | gc = c; | |
| 4655 | 111 | g_snprintf(buf, sizeof buf, "%s (%s)", c->username, c->prpl->name); |
| 2495 | 112 | opt = gtk_menu_item_new_with_label(buf); |
|
4165
9d849f3a4dff
[gaim-migrate @ 4394]
Christian Hammond <chipx86@chipx86.com>
parents:
3551
diff
changeset
|
113 | g_signal_connect(GTK_OBJECT(opt), "activate", G_CALLBACK(set_gc), c); |
| 2495 | 114 | gtk_widget_show(opt); |
| 4655 | 115 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), opt); |
| 2495 | 116 | } |
| 117 | ||
| 118 | gtk_option_menu_remove_menu(GTK_OPTION_MENU(optmenu)); | |
| 119 | gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu); | |
| 120 | gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), 0); | |
| 121 | } | |
| 122 | ||
| 123 | char *gaim_plugin_init(GModule *h) | |
| 124 | { | |
| 125 | GtkWidget *hbox; | |
| 126 | GtkWidget *entry; | |
| 127 | ||
| 128 | me = h; | |
| 129 | ||
| 130 | gaim_signal_connect(h, event_signon, redo_optmenu, NULL); | |
| 131 | gaim_signal_connect(h, event_signoff, redo_optmenu, me); | |
| 132 | ||
| 133 | window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
|
4165
9d849f3a4dff
[gaim-migrate @ 4394]
Christian Hammond <chipx86@chipx86.com>
parents:
3551
diff
changeset
|
134 | g_signal_connect(GTK_OBJECT(window), "delete_event", G_CALLBACK(goodbye), NULL); |
| 2495 | 135 | |
| 136 | hbox = gtk_hbox_new(FALSE, 0); | |
| 137 | gtk_container_add(GTK_CONTAINER(window), hbox); | |
| 138 | ||
| 139 | optmenu = gtk_option_menu_new(); | |
| 140 | gtk_box_pack_start(GTK_BOX(hbox), optmenu, FALSE, FALSE, 5); | |
| 141 | ||
| 142 | redo_optmenu(NULL, NULL); | |
| 143 | ||
| 144 | entry = gtk_entry_new(); | |
| 145 | gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 5); | |
|
4165
9d849f3a4dff
[gaim-migrate @ 4394]
Christian Hammond <chipx86@chipx86.com>
parents:
3551
diff
changeset
|
146 | g_signal_connect(GTK_OBJECT(entry), "activate", G_CALLBACK(send_it), NULL); |
| 2495 | 147 | |
| 148 | gtk_widget_show_all(window); | |
| 149 | ||
| 150 | return NULL; | |
| 151 | } | |
| 152 | ||
| 153 | void gaim_plugin_remove() | |
| 154 | { | |
| 155 | if (window) | |
| 156 | gtk_widget_destroy(window); | |
| 157 | window = NULL; | |
| 158 | me = NULL; | |
| 159 | } |