comparison PRPL @ 1333:b332d8f46b84

[gaim-migrate @ 1343] oo, a fun new register button. oh yeah, and the buddy list stuff got moved back from toc.c to buddy.c. isn't that nice. now you can remove toc.c and rvous.c, comment out one line in prpl.c, and get rid of toc altogether. but you won't do that. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Wed, 20 Dec 2000 13:24:48 +0000
parents 0bbe3aaa6a3e
children a7bfb5dfab25
comparison
equal deleted inserted replaced
1332:bec4de31b3ad 1333:b332d8f46b84
1 Protocol Plugins. What EveryBuddy should have been. 1 Protocol Plugins. What EveryBuddy should have been.
2 2
3 Each PRPL needs to have a unique identifier. In the pre-PRPL system TOC was 0 and Oscar was 1. 3 Each PRPL needs to have a unique identifier. In the pre-PRPL system TOC
4 This identifier can be found in prpl.h. They are pre-assigned. PROTO_TOC is still 0, PROTO_OSCAR 4 was 0 and Oscar was 1. This identifier can be found in prpl.h. They
5 is still 1. The protocol_init function is expected to set the struct's protocol member to the 5 are pre-assigned. PROTO_TOC is still 0, PROTO_OSCAR is still 1. The
6 appropriate value. If you want to write a new PRPL for gaim, please email one of the maintainers 6 protocol_init function is expected to set the struct's protocol member to
7 with the name of the protocol. We'll then reserve a number for it. Please do not use a number 7 the appropriate value. If you want to write a new PRPL for gaim, please
8 that has not been assigned to your protocol. 8 email one of the maintainers with the name of the protocol. We'll then
9 reserve a number for it. Please do not use a number that has not been
10 assigned to your protocol.
9 11
10 The addition of PRPL to gaim means that gaim now supports multiple connections and multiple (and 12 The addition of PRPL to gaim means that gaim now supports multiple
11 dynamically loadable) protocols. 13 connections and multiple (and dynamically loadable) protocols.
12 14
13 ====== 15 ======
14 16
15 I guess I should document how to write a PRPL. 17 I guess I should document how to write a PRPL.
16 18
17 The first thing to do is to write your init function. It should be delcared 19 The first thing to do is to write your init function. It should be
20 delcared
18 21
19 void my_proto_init(struct prpl *p); 22 void my_proto_init(struct prpl *p);
20 23
21 You then fill in the members of the struct. See prpl.h for what they are. 24 You then fill in the members of the struct. See prpl.h for what they are.
22 25
23 If you're going to load your protocol dynamically, put the function gaim_plugin_init(void *) in the 26 If you're going to load your protocol dynamically, put the function
24 file, and have it call 27 gaim_plugin_init(void *) in the file, and have it call
25 28
26 load_protocol(my_proto_init); 29 load_protocol(my_proto_init);
27 30
28 and return NULL. Then compile as a plugin, load the .so file, and you're set. If you're going to 31 and return NULL. Then compile as a plugin, load the .so file, and you're
29 load it statically, extern the my_proto_init function, and in prpl.c, call load_protocol. 32 set. If you're going to load it statically, extern the my_proto_init
33 function, and in prpl.c, call load_protocol.
30 34
31 Your PRPL needs to have a login function, which ideally should set up a gdk_input watcher. When you 35 Your PRPL needs to have a login function, which ideally should set up a
32 want to indicate that the account is online, simply call account_online(struct gaim_connection *). 36 gdk_input watcher. When you want to indicate that the account is online,
33 When there is information from the server, you should call the appropriate serv_got function (see 37 simply call account_online(struct gaim_connection *). When there is
34 gaim.h for a (partial?) list). 38 information from the server, you should call the appropriate serv_got
39 function (see gaim.h for a (partial?) list).
35 40
36 When the UI wants to send something via the server, it will call the appropriate function that you set 41 When the UI wants to send something via the server, it will call the
37 in your PRPL, if it's non-NULL. The only function that is absolutely critical is name. Without name 42 appropriate function that you set in your PRPL, if it's non-NULL. The
38 gaim will probably crash. You don't even need login, just name. (You need login to do anything useful 43 only function that is absolutely critical is name. Without name gaim
39 though.) 44 will probably crash. You don't even need login, just name. (You need
45 login to do anything useful though.)
40 46
41 The best example to copy is probably Rob's IRC plugin, in plugins/irc.c. The most important functions 47 ======
42 for gaim interaction are at the bottom (irc_init, gaim_plugin_init, and gaim_plugin_remove). The
43 rest of it is the protocol implementation.
44 48
45 Sorry for the formatting. My Eterm is 105 characters wide. 49 Erg. Now the fun part. The part that you would have never guessed if you
50 weren't me. (I know that you wouldn't have guessed this stuff because
51 it isn't painfully obvious to me. Use the Source, Luke.)
52
53 Let's start with the basics. PRPLs shouldn't use GTK at all. That said,
54 they have to in no fewer than three functions: action_menu, user_opts, and
55 draw_new_user (probably do_new_user too). Fortunately, all of these are
56 optional. Unfortunatly, all of these are so incredibly useful that they
57 probably aren't optional. If you use GTK (other than gdk_input_add/remove
58 for the connections) in any function other than these three I will hunt
59 you down like the dog you are and kill you. (Oscar and TOC are excused
60 temporarily because they existed long before all the other PRPLs.)
61
62 You're probably wondering how you can do certain things without GTK. Well,
63 you're just going to have to make do. Rely on the UI, that's why it's
64 there. A PRPL should have absolutely ZERO interaction with the user,
65 it should all be handled by the UI. So far, about the only thing that's
66 been added to gaim to aid in this goal is do_ask_dialog. But at least
67 it's a start.
68
69 do_ask_dialogs is one of the worst creations ever to come from my ass. It
70 must have been very late in the morning, just before I went to sleep,
71 when I coded it. That's my excuse.
72
73 You pass it the question you want to ask, what to do on Yes, what to
74 do on No, and optional data. The logic actually isn't like that at
75 all. Given you call do_ask_dialog("Wanna?", mydata, yes_func, no_func),
76 the logic is:
77
78 if (clicked_yes)
79 yes_func();
80 no_func();
81
82 i.e. no_func() gets called regardless of what's clicked. So
83 it's best to use it for freeing mydata, and not freeing mydata in
84 yes_func. To be quite honest, I'm not sure no_func is needed. (I
85 also seem to think that yes_func isn't entirely necessary either,
86 except for the little part about it being the point of do_ask_dialog.)
87
88 Um. So that was interesting.