Mercurial > pidgin.yaz
comparison libpurple/plugins/debug_example.c @ 19908:0715328a0be3
Add the debug example plugin
author | John Bailey <rekkanoryo@rekkanoryo.org> |
---|---|
date | Sat, 08 Sep 2007 04:16:05 +0000 |
parents | |
children | bdffee131b80 |
comparison
equal
deleted
inserted
replaced
19907:9500ab76c8dc | 19908:0715328a0be3 |
---|---|
1 /* | |
2 * Debug Example Plugin | |
3 * | |
4 * Copyright (C) 2007, John Bailey <rekkanoryo@pidgin.im> | |
5 * | |
6 * This program is free software; you can redistribute it and/or | |
7 * modify it under the terms of the GNU General Public License as | |
8 * published by the Free Software Foundation; either version 2 of the | |
9 * License, or (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, but | |
12 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 * General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | |
19 * 02111-1301, USA. | |
20 * | |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 # include <config.h> | |
25 #endif | |
26 | |
27 /* We're including glib.h again for the gboolean type. */ | |
28 #include <glib.h> | |
29 | |
30 /* This is the required definition of PURPLE_PLUGINS as required for a plugin, | |
31 * but we protect it with an #ifndef because config.h may define it for us | |
32 * already and this would cause an unneeded compiler warning. */ | |
33 #ifndef PURPLE_PLUGINS | |
34 # define PURPLE_PLUGINS | |
35 #endif | |
36 | |
37 /* Here we're including the necessary libpurple headers for this plugin. Note | |
38 * that we're including them in alphabetical order. This isn't necessary but | |
39 * we do this throughout our source for consistency. */ | |
40 #include "debug.h" | |
41 #include "plugin.h" | |
42 #include "version.h" | |
43 | |
44 /* It's more convenient to type PLUGIN_ID all the time than it is to type | |
45 * "core-debugexample", so define this convenience macro. */ | |
46 #define PLUGIN_ID "core-debugexample" | |
47 | |
48 /* Common practice in third-party plugins is to define convenience macros for | |
49 * many of the fields of the plugin info struct, so we'll do that for the | |
50 * purposes of demonstration. */ | |
51 #define PLUGIN_AUTHOR "John Bailey <rekkanoryo@ipidgin.im>" | |
52 | |
53 /* As we've covered before, libpurple calls this function, if present, when it | |
54 * loads the plugin. Here we're using it to show off the capabilities of the | |
55 * debug API and just blindly returning TRUE to tell libpurple it's safe to | |
56 * continue loading. */ | |
57 static gboolean | |
58 plugin_load(PurplePlugin *plugin) | |
59 { | |
60 /* Define these for convenience--we're just using them to show the | |
61 * similarities of the debug functions to the standard printf(). */ | |
62 gint i = 256; | |
63 gfloat f = 512.1024; | |
64 const gchar *s = "example string"; | |
65 | |
66 /* Introductory message */ | |
67 purple_debug_info(PLUGIN_ID, | |
68 "Called plugin_load. Beginning debug demonstration\n"); | |
69 | |
70 /* Show off the debug API a bit */ | |
71 purple_debug_misc(PLUGIN_ID, | |
72 "MISC level debug message. i = %d, f = %f, s = %s\n", i, f, s); | |
73 | |
74 purple_debug_info(PLUGIN_ID, | |
75 "INFO level debug message. i = %d, f = %f, s = %s\n", i, f, s); | |
76 | |
77 purple_debug_warning(PLUGIN_ID, | |
78 "WARNING level debug message. i = %d, f = %f, s = %s\n", i, f, s); | |
79 | |
80 purple_debug_error(PLUGIN_ID, | |
81 "ERROR level debug message. i = %d, f = %f, s = %s\n", i, f, s); | |
82 | |
83 purple_debug_fatal(PLUGIN_ID, | |
84 "FATAL level debug message. i = %d, f = %f, s = %s\n", i, f, s); | |
85 | |
86 /* Now just return TRUE to tell libpurple to finish loading. */ | |
87 return TRUE; | |
88 } | |
89 | |
90 static PurplePluginInfo info = { | |
91 PURPLE_PLUGIN_MAGIC, /* magic number */ | |
92 PURPLE_MAJOR_VERSION, /* purple major */ | |
93 PURPLE_MINOR_VERSION, /* purple minor */ | |
94 PURPLE_PLUGIN_STANDARD, /* plugin type */ | |
95 NULL, /* UI requirement */ | |
96 0, /* flags */ | |
97 NULL, /* dependencies */ | |
98 PURPLE_PRIORITY_DEFAULT, /* priority */ | |
99 | |
100 PLUGIN_ID, /* id */ | |
101 "Debug API Example", /* name */ | |
102 VERSION, /* version */ | |
103 "Debug API Example", /* summary */ | |
104 "Debug API Example", /* description */ | |
105 PLUGIN_AUTHOR, /* author */ | |
106 "http://pidgin.im", /* homepage */ | |
107 | |
108 plugin_load, /* load */ | |
109 NULL, /* unload */ | |
110 NULL, /* destroy */ | |
111 | |
112 NULL, /* ui info */ | |
113 NULL, /* extra info */ | |
114 NULL, /* prefs info */ | |
115 NULL, /* actions */ | |
116 NULL, /* reserved */ | |
117 NULL, /* reserved */ | |
118 NULL, /* reserved */ | |
119 NULL /* reserved */ | |
120 }; | |
121 | |
122 static void | |
123 init_plugin(PurplePlugin *plugin) | |
124 { | |
125 } | |
126 | |
127 PURPLE_INIT_PLUGIN(debugexample, init_plugin, info) | |
128 |