annotate plugins/error.c @ 1032:643a4d81c18a

[gaim-migrate @ 1042] buddy list menus are based on connections/protocol. pretty spiffy. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 31 Oct 2000 06:09:47 +0000
parents 59d97cd251ff
children ece2d1543b20
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
391
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 #define GAIM_PLUGINS
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 #include "gaim.h"
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 #include <stdlib.h>
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 #include <time.h>
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 int gaim_plugin_init(void *handle) {
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 int error;
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 /* so here, we load any callbacks, do the normal stuff */
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 srand(time(NULL));
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 error = rand() % 3;
398
59d97cd251ff [gaim-migrate @ 408]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 396
diff changeset
14 error -= 2;
391
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 /* there's a 1 in 3 chance there *won't* be an error :) */
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 return error;
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 }
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 void gaim_plugin_remove() {
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 /* this only gets called if we get loaded successfully, and then
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 * unloaded. */
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 }
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 char *gaim_plugin_error(int error) {
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 /* by the time we've gotten here, all our callbacks are removed.
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 * we just have to deal with what the error was (as defined by us)
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 * and do any other clean-up stuff we need to do. */
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 switch (error) {
398
59d97cd251ff [gaim-migrate @ 408]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 396
diff changeset
29 case -1:
391
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 do_error_dialog("I'm calling the error myself", "MY BAD");
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 return NULL;
398
59d97cd251ff [gaim-migrate @ 408]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 396
diff changeset
32 case -2:
391
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 return "Internal plugin error: exiting.";
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 }
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 /* we should never get here */
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 return NULL;
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 }
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 char *name() {
396
b1d5c6ab7b0d [gaim-migrate @ 406]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 393
diff changeset
40 return "Error Tester " VERSION ;
391
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 }
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 char *description() {
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 return "A nice little program that causes error messages";
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 }