Mercurial > pidgin
comparison HACKING @ 1063:e1408fb04c36
[gaim-migrate @ 1073]
updated HACKING to describe gaim_connection/aim_user/prpl.
updated FAQ to answer some questions about multiple connections.
made it so you're not able to send a message in a chat room that you're no longer in (i.e. when you were in the room but sign off)
free'd the buddy list when the connection is destroyed
tried to prevent set_buddy from being called before the buddy list is drawn
i think there was something else
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sat, 04 Nov 2000 03:08:54 +0000 |
parents | daad2440a642 |
children | 4416ead31db7 |
comparison
equal
deleted
inserted
replaced
1062:9446ac58745e | 1063:e1408fb04c36 |
---|---|
1 A lot of people have tried to hack gaim, but haven't been able to because | 1 A lot of people have tried to hack gaim, but haven't been able to because |
2 the code is just so horrid. Well, the code isn't getting better anytime | 2 the code is just so horrid. Well, the code isn't getting better anytime |
3 soon, so to help all you would-be hackers help out gaim, here's a brief | 3 soon, so to help all you would-be hackers help out gaim, here's a brief |
4 tutorial on how gaim works. I'll quickly describe the logical flow of | 4 tutorial on how gaim works. I'll quickly describe the logical flow of |
5 things, then what you'll find in each of the source files. Hopefully | 5 things, then what you'll find in each of the source files. As an added |
6 that's enough to get most of you going. | 6 bonus, I'll try and describe as best I can how multiple connections and |
7 multiple protocols work. Hopefully that's enough to get most of you going. | |
7 | 8 |
8 If you're going to hack gaim, PLEASE, PLEASE PLEASE PLEASE send patches | 9 If you're going to hack gaim, PLEASE, PLEASE PLEASE PLEASE send patches |
9 against the absolute latest CVS. I get really annoyed when I get patches | 10 against the absolute latest CVS. I get really annoyed when I get patches |
10 against the last released version, especially since I don't usually have | 11 against the last released version, especially since I don't usually have |
11 a copy of it on my computer, and gaim tends to change a lot between | 12 a copy of it on my computer, and gaim tends to change a lot between |
32 debugging information is printed to the debug window (which can be turned | 33 debugging information is printed to the debug window (which can be turned |
33 on in the preferences) whether or not --enable-debug was selected. Most | 34 on in the preferences) whether or not --enable-debug was selected. Most |
34 of the information that's printed is useless anyway though; so the | 35 of the information that's printed is useless anyway though; so the |
35 --enable-debug option really doesn't do a whole lot. | 36 --enable-debug option really doesn't do a whole lot. |
36 | 37 |
37 This file was last modified by $Author: warmenhoven $ on $Date: 2000-10-31 05:49:53 -0500 (Tue, 31 Oct 2000) $. | 38 This file was last modified by $Author: warmenhoven $ on $Date: 2000-11-03 22:08:54 -0500 (Fri, 03 Nov 2000) $. |
38 | 39 |
39 | 40 |
40 PROGRAM FLOW | 41 PROGRAM FLOW |
41 ============ | 42 ============ |
42 | 43 |
266 stuff that happened to be thrown into it for no apparent reason. None | 267 stuff that happened to be thrown into it for no apparent reason. None |
267 of it is particularly tasty; it's all just utility functions. Just | 268 of it is particularly tasty; it's all just utility functions. Just |
268 like the name says. | 269 like the name says. |
269 | 270 |
270 | 271 |
271 So that's our little tour of the internals of Gaim. It's really not | 272 MULTIPLE CONNECTIONS AND PRPLS |
272 difficult to figure out if you've spent any time with GTK. I'm looking | 273 ============================== |
273 forward to getting all of your patches :) | 274 |
275 OK, let's start with the basics. There are users. Each user is contained | |
276 in an aim_user struct, and kept track of in the aim_users GList (GSList?). | |
277 Each aim_user has certain features: a username, a password, and user_info. | |
278 It also has certain options, and the protocol it uses to sign on (kept as | |
279 an int which is #define'd in prpl.h). The way the management of the users | |
280 works is, there will (hopefully) only be one user for a given screenname/ | |
281 protocol pair (i.e. you may have two user warmenhoven's, but they'll both | |
282 have a different protocol number). | |
283 | |
284 Now then, there are protocols that gaim knows about. Each protocol is in | |
285 a prpl struct and kept track of in the protocols GSList. The way the | |
286 management of the protocols is, there will only ever be one prpl per numeric | |
287 protocol. Each prpl defines a basic set of functions: login, logout, send_im, | |
288 etc. The prpl is responsible not only for handling these functions, but also | |
289 for calling the appropriate serv_got functions (e.g. serv_got_update when a | |
290 buddy comes online/goes offline/goes idle/etc). It handles each of these on | |
291 a per-connection basis. | |
292 | |
293 So why's it called a PRPL? It stands for PRotocol PLugin. That means that | |
294 it's possible to dynamically add new protocols to gaim. However, all protocols | |
295 must be implemented the same way: by using a prpl struct and being loaded, | |
296 regardless of whether they are static or dynamic. | |
297 | |
298 Here's how struct gaim_connection fits into all of this. At some point the | |
299 User (capitalized to indicate a person and not a name) will try to sign on | |
300 one of Their users. serv_login is then called for that user. It searches for | |
301 the prpl that is assigned to that user, and calls that prpl's login function, | |
302 passing it the aim_user struct that is attempting to sign on. The prpl is then | |
303 responsible for seeing that the gaim_connection is created (by calling | |
304 new_gaim_connection), and registering it as being online (by calling | |
305 account_online and passing it the aim_user and gaim_connection structs). At | |
306 that point, the aim_user and gaim_connection structs have pointers to each | |
307 other, and the gaim_connection struct has a pointer to the prpl struct that | |
308 it is using. The gaim_connections are stored in the connections GSList. | |
309 The way connection management works is, there will always only be one | |
310 gaim_connection per user, and the prpl that the gaim_connection uses will be | |
311 constant for the gaim_connection's life. | |
312 | |
313 So at certain points the User is going to want to do certain things, like | |
314 send a message. They must send the message on a connection. So the UI figures | |
315 out which gaim_connection the User want to send a message on (for our example), | |
316 and calls serv_send_im, telling it which gaim_connection to use, and the | |
317 necessary information (who to send it to, etc). The serv_ function then | |
318 calls the handler of the prpl of the connection for that event (that was way | |
319 too many prepositions). OK, each prpl has a send_im function. Each connection | |
320 has a prpl. so you call gc->prpl->send_im and pass it the connection and all | |
321 the necessary info. And that's how things get done. | |
322 | |
323 I hope some of that made sense. Looking back at it it makes absolutely no | |
324 sense to me. Thank god I wrote the code; otherwise I'm sure I'd be lost. |