# HG changeset patch # User Eric Warmenhoven # Date 955268715 0 # Node ID 5ca21b68eb2926849f350245bfad1c71b82b083b # Parent f3c6cf79f651012a82bd2c73173228204355ad41 [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 diff -r f3c6cf79f651 -r 5ca21b68eb29 plugins/CRAZY --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/CRAZY Sun Apr 09 08:25:15 2000 +0000 @@ -0,0 +1,38 @@ +Figures out the other person's IP address if they also have the same +plugin loaded. + + This would be a really interesting and pretty useful plugin. It + could work possibly by sending 'hidden' text in the form of an + HTML tag or something, and if it receives the same hidden text, + it could then pass messages back and forth to send and receive + the IP addresses. + +Perform extra HTML-highlighting and HTML-stripping + + Ever get annoyed because gaim doesn't support some HTML markup? + Here's a work-around. (Although, if you're this determined, you + might as well just hack gaim and send us the patches ;-) .) + +Auto-reply + + If someone sends you a message, immediately send them a message + back. Add fun things to the message. Reverse their text, then + send it back to them. Play with fonts and colors and HTML tags. + Really annoy the hell out of them. :-) + +Control gaim by monitoring a file + + I have to admit, I blatently stole this idea from LICQ. But it + is a really interesting concept. What happens is it watches a + certain file to see if it's empty or not. If it's not, it reads + the contents and executes any commands stored in there (such as + send a message to someone). This can be nice for having remote + control of gaim. + + +These are just some of the ideas I came up with in about ten minutes. A +really nice thing about having plugins is as long as your code doesn't +segfault, you can keep testing and debugging without having to restart +gaim. Plus the plugins tend to be small, and quick and easy to compile, +so development should be quick. Try to have FUN with these plugins :-). +(BTW, dibs on the 'control by file' plugin. :-) .) diff -r f3c6cf79f651 -r 5ca21b68eb29 plugins/HOWTO --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/HOWTO Sun Apr 09 08:25:15 2000 +0000 @@ -0,0 +1,43 @@ +Ok, this howto is going to be really short and sweet and to the point. + +First off, before you do anything else, in all of the files for your plugin, +put the lines + +#define GAIM_PLUGIN +#include "gaim.h" + +I mean this. Without this, all kinds of things will not work correctly. If you +really want to know exactly what this does, read ../src/gaim.h and learn. But +if you don't want to do that, just know that it's important. + +Now that you've put that there, make sure gaim.h is in your include path. + +Ok, now you're ready to write the plugin. + +The only function that is required is gaim_plugin_init(). This gets called as +soon as it gets loaded (sort of - man dlopen for more details). If your +function never returns, it will crash gaim! If your plugin uses up all the +memory in the system, it will crash gaim! Once your plugin gets loaded, it +effectively becomes a part of gaim, and anything that goes wrong will look +like it is a problem with gaim itself. I write bugfree code! :) Therefore, it +is your problem, not mine. + +You can basically do anything you want in the plugin. You can make function +calls, change public widgets, display new widgets, things like that. But the +really need thing is you can do things at events. For example, when one of +your buddies signs on, you can instantly send them a message. You can modify +the incoming and outgoing text. You can do all kinds of crazy things. Whatever +you want. Check out SIGNALS and CRAZY for more information and ideas. + +Plugins can share globals with gaim, but will not share with other plugins. +This is so if you have a global variable GtkWidget *window in your plugin and +J. Random Hacker also has the same name on a global variable, you won't be +constantly overwriting each others' variables. Unfortunately, this also means +that plugins will have difficulty working together. But then again, that's +what shared memory is for. + +When your plugin gets unloaded, gaim will try to call gaim_plugin_remove(). It +doesn't have to be there, but it's nice if, say, you create a window, and when +the plugin gets unloaded, it removes the window. + +There are a few examples in this directory. Enjoy. diff -r f3c6cf79f651 -r 5ca21b68eb29 plugins/SIGNALS --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/SIGNALS Sun Apr 09 08:25:15 2000 +0000 @@ -0,0 +1,59 @@ +enum gaim_event { + event_signon = 0, + event_signoff, + event_im_recv, + event_im_send, + event_buddy_signon, + event_buddy_signoff, +}; + +To add a signal handler, call the fuction gaim_signal_connect with the +following arguments: + +enum gaim_event, void *, void * + +The first arg is hopefully obvious. +The second arg is a pointer to a function that takes various args + depending on which event you're dealing with. +The third arg is any data you want to send to your function, as a final + argument. + +So here are the args that get passed to your functions in various events: + +event_signon: + char *name + + 'name' is your username. (Note that this can be returned through + other methods.) + +event_signoff: + (none) + +event_im_recv: + char **who, char **text + + 'who' is the username of the person who sent the message. + 'text' is the actual strict text (with HTML tags and all) of the + message they sent. + + Note that you can modify these values. (You are encouraged to do so!) + +event_im_send: + char **who, char **text + + 'who' is the username of the person you're sending the message to. + 'text' is the actual strict text (with HTML tags and all) of the + message you're sending. + + Note that you can modify these values. (You are _not_ encouraged to + do so ;-) .) + +event_buddy_signon: + char *who + + 'who' is who signed on. + +event_buddy_signoff: + char *who + + 'who' is who signed off.