Chinaunix首页 | 论坛 | 博客
  • 博客访问: 343846
  • 博文数量: 72
  • 博客积分: 2130
  • 博客等级: 大尉
  • 技术积分: 857
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-05 16:10
文章分类

全部博文(72)

文章存档

2010年(5)

2009年(14)

2008年(53)

分类: 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

阅读(1089) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~