Merged pidgin/main into default
[pidgin-git.git] / libpurple / plugins / debug_example.c
blob5a9aa2e703c4ca97db63aa225e27f99906f13e61
1 /*
2 * Debug Example Plugin
4 * Copyright (C) 2007, John Bailey <rekkanoryo@cpw.pidgin.im>
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.
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.
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.
23 /* When writing a third-party plugin, do not include libpurple's internal.h
24 * included below. This file is for internal libpurple use only. We're including
25 * it here for our own convenience. */
26 #include "internal.h"
28 /* This file defines PURPLE_PLUGINS and includes all the libpurple headers */
29 #include <purple.h>
31 /* It's more convenient to type PLUGIN_ID all the time than it is to type
32 * "core-debugexample", so define this convenience macro. */
33 #define PLUGIN_ID "core-debugexample"
35 /* Common practice in third-party plugins is to define convenience macros for
36 * many of the fields of the plugin info struct, so we'll do that for the
37 * purposes of demonstration. */
38 #define PLUGIN_AUTHORS { "John Bailey <rekkanoryo@cpw.pidgin.im>", NULL }
40 static PurplePluginInfo *
41 plugin_query(GError **error)
43 const gchar * const authors[] = PLUGIN_AUTHORS;
45 return purple_plugin_info_new(
46 "id", PLUGIN_ID,
47 "name", "Debug API Example",
48 "version", DISPLAY_VERSION,
49 "category", "Example",
50 "summary", "Debug API Example",
51 "description", "Debug API Example",
52 "authors", authors,
53 "website", "https://pidgin.im",
54 "abi-version", PURPLE_ABI_VERSION,
55 NULL
59 /* As we've covered before, this function is called when the plugin is loaded.
60 * Here we're using it to show off the capabilities of the debug API and just
61 * blindly returning TRUE to tell libpurple it's safe to continue loading. */
62 static gboolean
63 plugin_load(PurplePlugin *plugin, GError **error)
65 /* Define these for convenience--we're just using them to show the
66 * similarities of the debug functions to the standard printf(). */
67 gint i = 256;
68 gfloat f = 512.1024;
69 const gchar *s = "example string";
71 /* Introductory message */
72 purple_debug_info(PLUGIN_ID,
73 "Called plugin_load. Beginning debug demonstration\n");
75 /* Show off the debug API a bit */
76 purple_debug_misc(PLUGIN_ID,
77 "MISC level debug message. i = %d, f = %f, s = %s\n", i, f, s);
79 purple_debug_info(PLUGIN_ID,
80 "INFO level debug message. i = %d, f = %f, s = %s\n", i, f, s);
82 purple_debug_warning(PLUGIN_ID,
83 "WARNING level debug message. i = %d, f = %f, s = %s\n", i, f, s);
85 purple_debug_error(PLUGIN_ID,
86 "ERROR level debug message. i = %d, f = %f, s = %s\n", i, f, s);
88 purple_debug_fatal(PLUGIN_ID,
89 "FATAL level debug message. i = %d, f = %f, s = %s\n", i, f, s);
91 /* Now just return TRUE to tell libpurple to finish loading. */
92 return TRUE;
95 static gboolean
96 plugin_unload(PurplePlugin *plugin, GError **error)
98 return TRUE;
101 PURPLE_PLUGIN_INIT(debugexample, plugin_query, plugin_load, plugin_unload);