Mercurial > pidgin.yaz
comparison HACKING @ 639:9a01b3fb1a9d
[gaim-migrate @ 649]
added a file to help people try to hack gaim
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Tue, 08 Aug 2000 20:55:17 +0000 |
parents | |
children | b29c92be568b |
comparison
equal
deleted
inserted
replaced
638:525c566741da | 639:9a01b3fb1a9d |
---|---|
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 | |
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 | |
5 things, then what you'll find in each of the source files. Hopefully | |
6 that's enough to get most of you going. | |
7 | |
8 There's one little thing that's just a pet peeve, and it's really stupid. | |
9 In ./configure there's and --enable-debug option. This does two things: | |
10 compiles with -Wall, and prints debugging information to stdout. The | |
11 debugging information is printed to the debug window (which can be turned | |
12 on in the preferences) whether or not --enable-debug was selected. Most | |
13 of the information that's printed is useless anyway though; so the | |
14 --enable-debug option really doesn't do a whole lot. | |
15 | |
16 | |
17 PROGRAM FLOW | |
18 ============ | |
19 | |
20 Before gaim does anything you can see, it initializes itself, which is | |
21 mostly just reading .gaimrc (handled by the functions in gaimrc.c). It | |
22 then draws the login window by calling show_login, and waits for input. | |
23 | |
24 At the login window, when "signon" is clicked, dologin() is called. This | |
25 in turn calls serv_login, which checks to see if you want to use Oscar or | |
26 TOC, and calls oscar_login or toc_login appropriately. We'll assume TOC | |
27 for the rest of this discussion; Oscar has a lot of bad hacks to get it | |
28 working that I don't even want to think about. | |
29 | |
30 After you're signed in (I'll skip that discussion - I doubt many people | |
31 are going to change the login process, since it pretty much just folows | |
32 PROTOCOL), Gaim draws the buddy list by calling show_buddy_list, and | |
33 waits for input from two places: the server and the user. The first place | |
34 it gets input from after signon is invariably the server, when the server | |
35 tells Gaim which buddies are signed on. | |
36 | |
37 When there is information ready to be read from the server, toc_callback | |
38 is called (by GDK) to parse the incoming information. On an UPDATE, | |
39 serv_got_update is called, which takes care of things like notifying | |
40 conversation windows of the update if need be; notifying the plugins; | |
41 and finally, calling set_buddy. | |
42 | |
43 set_buddy is one of the most frequently called functions in gaim, one of | |
44 the largest functions in gaim, and probably one of the buggiest functions | |
45 in gaim. It is responsible for updating the pixmaps in the buddy list; | |
46 notifying plugins of various events; updating the tooltips for buddies; | |
47 making sounds; and updating the ticker. It's also called once per online | |
48 buddy every 20 seconds (by GTK through update_all_buddies). | |
49 | |
50 When the user opens a new conversation window, new_conversation is called. | |
51 That's easy enough. If there isn't a conversation with the person already | |
52 open (checked by calling find_conversation), show_conv is called to | |
53 create the new window. All sorts of neat things happen there, but it's | |
54 mostly drawing the window. show_conv is the best place to edit the UI. Be | |
55 prepared for some incredibly bad GTK programming. (Rob's fixing this as | |
56 we speak no doubt.) | |
57 | |
58 That's pretty much it for the quick tutorial. I know it wasn't much but | |
59 it's enough to get you started. Make sure you know GTK before you get too | |
60 involved. Most of the back-end stuff is pretty basic; most of gaim is GTK. | |
61 | |
62 | |
63 SOURCE FILES | |
64 ============ | |
65 | |
66 about.c: | |
67 Not much to say here, just a few basic functions. | |
68 | |
69 aim.c: | |
70 This is where the main() function is. It takes care of a lot of the | |
71 initialization stuff, and showing the login window. It's pretty tiny | |
72 and there's not really much to edit in it. Watch out for bad Oscar | |
73 sign in hacks. | |
74 | |
75 away.c: | |
76 This takes care of most of the away stuff: setting the away message | |
77 (do_im_away); coming back (do_im_back); drawing the away window; | |
78 etc. To be honest I haven't looked at this file in months. | |
79 | |
80 browser.c: | |
81 Code for opening a browser window. Most of the code is trying to deal | |
82 with Netscape. The most important function here is open_url. Have fun. | |
83 | |
84 buddy.c: | |
85 This takes care of not only nearly everything buddy-related (the buddy | |
86 list, the permit/deny lists, and the window), but also a lot of the | |
87 code flow and util functions. Look for good things like find_buddy, | |
88 set_buddy, and signoff() here. | |
89 | |
90 buddy_chat.c: | |
91 This takes care of the buddy chat stuff. This used to be a lot bigger | |
92 until the chat and IM windows got merged in the code. Now it mostly | |
93 just takes care of chat-specific stuff, like ignoring people and | |
94 keeping track of who's in the room. This is also where the chat window | |
95 is created. | |
96 | |
97 conversation.c: | |
98 This is where most of the functions dealing with the IM and chat windows | |
99 are hidden. It tries to abstract things as much as possible, but doesn't | |
100 do a very good job. This is also where things like "Enter sends" and | |
101 "Ctrl-{B/I/U/S}" options get carried out (look for send_callback). The | |
102 chat and IM toolbar (with the B/I/U/S buttons) are both built from the | |
103 same function, build_conv_toolbar. | |
104 | |
105 dialogs.c: | |
106 A massive file with a lot of little utility functions. This is where | |
107 all of those little dialog windows are created. Things like the warn | |
108 dialog and the add buddy dialog are here. Not all of the dialogs in | |
109 gaim are in this file, though. But most of them are. This is also | |
110 where do_import is housed, to import buddy lists. | |
111 | |
112 gaimrc.c: | |
113 This controls everything about the .gaimrc file. There's not really much | |
114 to say about it; this is probably one of the better designed and easier | |
115 to follow files in gaim. The important functions are towards the bottom. | |
116 | |
117 gnome_applet_mgr.c: | |
118 A hideous creation from the days before I started working on gaim. Most | |
119 of it works, but it has functionsLikeThis. I hate looking at this | |
120 file, but I'm too lazy to change the functions. The best functions | |
121 are things like set_applet_draw_open, whose sole purpose is to set a | |
122 global variable to TRUE. | |
123 | |
124 gtkhtml.c: | |
125 This is really just one big hack. It started off as an HTML widget that | |
126 was written for Gnome as far as I can tell. The current version is | |
127 huge, requires way too many libs, and is too hard to upgrade to. But | |
128 we've managed to hack this poor old version into basically what we | |
129 need it for. I recommend not looking at this file if you want to save | |
130 your sanity. | |
131 | |
132 gtkticker.c: | |
133 Syd, our resident GTK God, wrote a GtkWidget, GtkTicker. This is that | |
134 widget. It's cool, and it's tiny. | |
135 | |
136 html.c: | |
137 Don't ask my why this is called html.c. Most of it is just grab_url, | |
138 which does like the name says; it downloads a URL to show in the | |
139 GtkHTML widget. http.c would be a more appropriate name, but that's OK. | |
140 | |
141 idle.c: | |
142 There is a very good reason why this file is still on version 1.1 | |
143 in CVS. The entire thing is #if 0'd out. I haven't ever really taken | |
144 a good look at it, but I think what it was supposed to have done is | |
145 set you as being away when a screensaver came on. | |
146 | |
147 network.c: | |
148 This has two functions: get_address and connect_address, both of which | |
149 call proxy functions. If you want to see how these are used, look at | |
150 toc.c and/or rvous.c. These are really just front-ends to the proxy | |
151 stuff; use these instead of calling the proxy functions. | |
152 | |
153 oscar.c: | |
154 One big hack of copied code. This is supposed to be the libfaim tie-in | |
155 in gaim. Most of it is just copied straight from faimtest, the small | |
156 program that comes with libfaim. I'm not even sure how half of it works, | |
157 if that makes you feel any better. | |
158 | |
159 perl.c: | |
160 This was basically copied straight from X-Chat through the power of | |
161 the GPL. Perl is the biggest, most confusing piece of C code I've ever | |
162 seen in my life (and keep in mind I'm a gaim hacker). I have a basic | |
163 idea of what's going on in it, but I couldn't tell you exactly. The | |
164 top half sets up perl and tells it what's going on and the bottom half | |
165 implements the AIM module. | |
166 | |
167 plugins.c: | |
168 This is the "plugin plug", as the file states. This file is probably | |
169 the only file in all of gaim that at the top has all of the functions | |
170 and global and static variables named out for you. It makes reading | |
171 it a little easier, but not by much. A lot of the code in here deals | |
172 with the plugin window rather than the plugins themselves. | |
173 | |
174 prefs.c: | |
175 The important function in here is build_prefs, but the most useful | |
176 function is gaim_button. build_prefs draws the window, and calls | |
177 gaim_button probably 30 or 40 times. (I don't really wanna run grep | |
178 | wc to count.) This is where you add the toggle button for gaim | |
179 preferences. It's very simple, and if you look at a couple of the | |
180 calls to gaim_button you'll figure it out right away. | |
181 | |
182 proxy.c: | |
183 This is where the bulk of the actual networking code is done. The big | |
184 function here is proxy_connect, which will connect through the proxy | |
185 setup you've chosen (most of which don't work...) or just regularly. | |
186 | |
187 rvous.c: | |
188 This was originally going to be the stuff for all of the Buddy Icon | |
189 and Voice Chat stuff, but I got really sick of protocol hacking really | |
190 quick. Now it only houses the file transfer stuff, which only works | |
191 for TOC. | |
192 | |
193 server.c: | |
194 This is where all of the differentiation between TOC and Oscar is | |
195 done. Nearly everything that's network related goes through here | |
196 at one point or another. This has good things like serv_send_im and | |
197 serv_got_update. Most of it should be pretty self-explanatory. | |
198 | |
199 sound.c: | |
200 The big important function is play_sound, which plays one of 4 (actually | |
201 6) sounds. One of the sounds is called in 3 different events, which | |
202 is why there are actually 6 sounds. This then calls play which then | |
203 checks for esd, then nas if that's not available, then falls back | |
204 to /dev/audio. | |
205 | |
206 ticker.c: | |
207 Syd is just so cool. I really can't get over it. He let me come | |
208 visit him at Netscape one day, and I got to see all of their toys | |
209 (don't worry, I'm under an NDA). Anyway, this file is for the buddy | |
210 ticker. This is also a damn cool file because it's got all of the | |
211 functions that you'd want right up at the top. Someday I want to be | |
212 as cool as Syd. | |
213 | |
214 toc.c: | |
215 This handles everything TOC-related, including parsing gaim's buddy | |
216 list. Most of this file is toc_callback, which parses the incoming | |
217 information from the server. I really don't like TOC though. | |
218 | |
219 util.c: | |
220 There's not really a lot of cohesion to this file; it's just a lot of | |
221 stuff that happened to be thrown into it for no apparent reason. None | |
222 of it is particularly tasty; it's all just utility functions. Just | |
223 like the name says. | |
224 | |
225 | |
226 So that's our little tour of the internals of Gaim. It's really not | |
227 difficult to figure out if you've spent any time with GTK. I'm looking | |
228 forward to getting all of your patches :) |