annotate plugins/HOWTO @ 93:5ca21b68eb29

[gaim-migrate @ 103] Notes on how to do plugins with gaim (note that this hasn't been implemented completely yet, this is just how it *should* work). committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Sun, 09 Apr 2000 08:25:15 +0000
parents
children 9f6ce50ffb78
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
93
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 Ok, this howto is going to be really short and sweet and to the point.
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 First off, before you do anything else, in all of the files for your plugin,
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 put the lines
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 #define GAIM_PLUGIN
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 #include "gaim.h"
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 I mean this. Without this, all kinds of things will not work correctly. If you
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 really want to know exactly what this does, read ../src/gaim.h and learn. But
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 if you don't want to do that, just know that it's important.
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 Now that you've put that there, make sure gaim.h is in your include path.
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 Ok, now you're ready to write the plugin.
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 The only function that is required is gaim_plugin_init(). This gets called as
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 soon as it gets loaded (sort of - man dlopen for more details). If your
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 function never returns, it will crash gaim! If your plugin uses up all the
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 memory in the system, it will crash gaim! Once your plugin gets loaded, it
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 effectively becomes a part of gaim, and anything that goes wrong will look
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 like it is a problem with gaim itself. I write bugfree code! :) Therefore, it
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 is your problem, not mine.
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 You can basically do anything you want in the plugin. You can make function
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 calls, change public widgets, display new widgets, things like that. But the
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 really need thing is you can do things at events. For example, when one of
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 your buddies signs on, you can instantly send them a message. You can modify
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 the incoming and outgoing text. You can do all kinds of crazy things. Whatever
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 you want. Check out SIGNALS and CRAZY for more information and ideas.
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 Plugins can share globals with gaim, but will not share with other plugins.
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 This is so if you have a global variable GtkWidget *window in your plugin and
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 J. Random Hacker also has the same name on a global variable, you won't be
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 constantly overwriting each others' variables. Unfortunately, this also means
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 that plugins will have difficulty working together. But then again, that's
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 what shared memory is for.
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 When your plugin gets unloaded, gaim will try to call gaim_plugin_remove(). It
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 doesn't have to be there, but it's nice if, say, you create a window, and when
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 the plugin gets unloaded, it removes the window.
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42
5ca21b68eb29 [gaim-migrate @ 103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 There are a few examples in this directory. Enjoy.