comparison plugins/HOWTO @ 2327:f74eefb55a78

[gaim-migrate @ 2337] removed CRAZY, it was outdated. various other touch-ups. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Thu, 20 Sep 2001 18:36:15 +0000
parents e4c34ca88d9b
children 258c19be6d84
comparison
equal deleted inserted replaced
2326:1add424e5544 2327:f74eefb55a78
12 12
13 Now that you've put that there, make sure gaim.h is in your include path. 13 Now that you've put that there, make sure gaim.h is in your include path.
14 14
15 Ok, now you're ready to write the plugin. 15 Ok, now you're ready to write the plugin.
16 16
17 The only function that is required is gaim_plugin_init(void *). This gets 17 The only function that is required is gaim_plugin_init(GModule *). This gets
18 called as soon as it gets loaded (sort of - man dlopen for more details). If 18 called as soon as it gets loaded (sort of - man dlopen for more details). If
19 your function never returns, it will crash gaim! If your plugin uses up all 19 your function never returns, it will crash gaim! If your plugin uses up all
20 the memory in the system, it will crash gaim! Once your plugin gets loaded, 20 the memory in the system, it will crash gaim! Once your plugin gets loaded,
21 it effectively becomes a part of gaim, and anything that goes wrong will look 21 it effectively becomes a part of gaim, and anything that goes wrong will look
22 like it is a problem with gaim itself. I write bugfree code! :) Therefore, it 22 like it is a problem with gaim itself. I write bugfree code! :) Therefore, it
23 is your problem, not mine. (I'm usually nice and willing to help you with your 23 is your problem, not mine. (I'm usually nice and willing to help you with your
24 problems though.) 24 problems though.)
25 25
26 The void * that gets passed to gaim_plugin_init is the handle for the plugin. 26 The GModule* that gets passed to gaim_plugin_init is the handle for the plugin.
27 DO NOT CHANGE THIS POINTER! Bad things will happen. You've been warned. It's 27 DO NOT CHANGE THIS POINTER! Bad things will happen. You've been warned. It's
28 needed for connecting to signals and things. It's a good idea to remember it 28 needed for connecting to signals and things. It's a good idea to remember it
29 somehow. 29 somehow.
30 30
31 gaim_plugin_init should return an int. If the int returned is less than 0, it 31 gaim_plugin_init should return a char*. If the char* returned is not NULL, it
32 is interpreted as an error, and gaim_plugin_error is called. See the ChangeLog 32 is interpreted as an error, and used as an error message. See the ChangeLog
33 file in this directory for more details, and error.c for an example. 33 file in this directory for more details.
34 34
35 You can basically do anything you want in the plugin. You can make function 35 You can basically do anything you want in the plugin. You can make function
36 calls, change public widgets, display new widgets, things like that. But the 36 calls, change public widgets, display new widgets, things like that. But the
37 really neat thing is you can do things at events. For example, when one of 37 really neat thing is you can do things at events. For example, when one of
38 your buddies signs on, you can instantly send them a message. You can modify 38 your buddies signs on, you can instantly send them a message. You can modify
39 the incoming and outgoing text. You can do all kinds of crazy things. Whatever 39 the incoming and outgoing text. You can do all kinds of crazy things. Whatever
40 you want. Check out SIGNALS and CRAZY for more information and ideas. 40 you want. Check out SIGNALS for more information.
41 41
42 Plugins can share globals with gaim, but will not share with other plugins. 42 Plugins can share globals with gaim, but will not share with other plugins.
43 This is so if you have a global variable GtkWidget *window in your plugin and 43 This is so if you have a global variable GtkWidget *window in your plugin and
44 J. Random Hacker also has the same name on a global variable, you won't be 44 J. Random Hacker also has the same name on a global variable, you won't be
45 constantly overwriting each others' variables. Unfortunately, this also means 45 constantly overwriting each others' variables. Unfortunately, this also means
46 that plugins will have difficulty working together. But then again, that's 46 that plugins will have difficulty working together. But then again, that's
47 what shared memory is for. 47 what shared memory is for.
48 48
49 Plugins can be configured. This makes is so they don't have to be recompiled 49 Plugins can be configured. This makes it so they don't have to be recompiled
50 in order to change things internal to them, and it's also just a cool feature 50 in order to change things internal to them, and it's also just a cool feature
51 to have :). It's optional; to allow your plugin to be configured, add a 51 to have :). It's optional; to allow your plugin to be configured, add a
52 function called gaim_plugin_config(). The advised course of action is to have 52 function called gaim_plugin_config(). The advised course of action is to have
53 it pop up a dialog window; but it's your plugin. 53 it pop up a dialog window; but it's your plugin.
54 54
55 When your plugin gets unloaded, gaim will try to call gaim_plugin_remove(). It 55 When your plugin gets unloaded, gaim will try to call gaim_plugin_remove(). It
56 doesn't have to be there, but it's nice if, say, you create a window, and when 56 doesn't have to be there, but it's nice if, say, you create a window, and when
57 the plugin gets unloaded, it removes the window. Also, all the callbacks you 57 the plugin gets unloaded, it removes the window. Also, all the callbacks you
58 have attached to gaim signals will be removed. 58 have attached to gaim signals will be removed.
59 59
60 Plugins can also unload themselves. To do this, call gaim_plugin_unload(void *) 60 Plugins can also unload themselves. To do this, call gaim_plugin_unload(GModule *)
61 (the void* is the handle passed to gaim_plugin_init). When your plugin gets 61 (the GModule* is the handle passed to gaim_plugin_init). When your plugin gets
62 unloaded, gaim will remove all of your callbacks. It will not call your 62 unloaded, gaim will remove all of your callbacks. It will not call your
63 gaim_plugin_remove function, however, since it will assume you have already 63 gaim_plugin_remove function, however, since it will assume you have already
64 done the necessary cleanup. 64 done the necessary cleanup.
65 65
66 Compilation of the plugins is fairly straight-forward; there is a Makefile in 66 Compilation of the plugins is fairly straight-forward; there is a Makefile in