分类: LINUX
2009-09-25 11:43:43
(1)准备
安装libpurple,它包含很多开发用的文件,当然还要安装Pidgin或者Finch
sudo apt-get build-dep pidgin
mkdir ~/development
cd ~/development
tar xvf pidgin-2.6.2.tar.bz2
cd pidgin-2.6.2
./configure
make
(2) 第一个插件程序
cd ~/development/pidgin-2.6.2/libpurple/plugins
vim helloworldbysam.c
#ifdef HAVE_CONFIG_H
#
include
#endif
#ifndef PURPLE_PLUGINS
# define PURPLE_PLUGINS
#endif
#include
#ifndef G_GNUC_NULL_TERMINATED
# if __GNUC__ >= 4
# define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
# else
# define G_GNUC_NULL_TERMINATED
# endif
#endif
#include
#include
#include
PurplePlugin *helloworld_plugin = NULL;
static void
plugin_action_test_cb(PurplePluginAction *action)
{
purple_notify_message(helloworld_plugin, PURPLE_NOTIFY_MSG_INFO,
"Plugin Actions Test", "This is a plugin actions test :)", NULL, NULL, NULL);
}
static GList *
plugin_actions(PurplePlugin *plugin, gpointer context)
{
GList *list = NULL;
PurplePluginAction *action = NULL;
action = purple_plugin_action_new("Plugin Action Test", plugin_action_test_cb);
list = g_list_append(list, action);
return list;
}
static gboolean
plugin_load(PurplePlugin *plugin)
{
purple_notify_message(plugin, PURPLE_NOTIFY_MSG_INFO, "Hello World!",
"This is the Hello World! plugin :)", NULL, NULL, NULL);
helloworld_plugin = plugin;
return TRUE;
}
static PurplePluginInfo info = {
PURPLE_PLUGIN_MAGIC,
PURPLE_MAJOR_VERSION,
PURPLE_MINOR_VERSION,
PURPLE_PLUGIN_STANDARD,
NULL,
0,
NULL,
PURPLE_PRIORITY_DEFAULT,
"core-hello_world",
"Hello World!",
DISPLAY_VERSION,
"Hello World Plugin",
"Hello World Plugin",
"Sam
Shen
"http://blog.chinaunix.net/u2/78437/",
plugin_load,
NULL,
NULL,
NULL,
NULL,
NULL,
plugin_actions,
NULL,
NULL,
NULL,
NULL,
};
static void
init_plugin(PurlePlugin *plugin)
{
}
PURPLE_INIT_PLUGIN(hello_world, init_plugin, info)
编译
make helloworldbysam.so
安装
mkdir ~/.purple/plugins
cp helloworldbysam.so ~/.purple/plugins
测试
打开工具->插件,启用新创建的插件,然后重启pidgin