maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Pidgin Notification Script or Plugin (https://talk.maemo.org/showthread.php?t=57346)

b666m 2010-06-28 16:10

Pidgin Notification Script or Plugin
 
I will try to cut my development out of this thread:
http://talk.maemo.org/showthread.php?t=38483&page=7

So the python script is ready to use - the source code is posted some lines under this introduction.

This python source should be the base for porting it to C/C++ to make it a full pidgin plugin because an extern script isn't good enough. ;)

Code:

#!/usr/bin/env python

def cb (Notification=None, action=None, Data=None):
        pass

def my_func(account, sender, message, conversation, flags):

        if bus.pidginbus.PurpleConversationHasFocus(conversation) == 0:

                name = str(sender.split("@")[0])
                buddy = bus.pidginbus.PurpleFindBuddy(account,name)
                alias = bus.pidginbus.PurpleBuddyGetAlias(buddy)
                #icon = bus.pidginbus.PurpleBuddyGetIcon(buddy)
                #icon_path = bus.pidginbus.PurpleBuddyIconGetFullPath(icon)
                proto = bus.pidginbus.PurpleAccountGetProtocolName(account)
                #proid = bus.pidginbus.PurpleAccountGetProtocolId(account)
                conv = str(conversation)

                if alias == "":
                        alias = name

                msg = message

                if proto == "XMPP":
                        msg = msg[6:-7]
               
                elif proto == "MSN":
                        col = msg.find("COLOR")
                        if col > -1:
                                msg = msg[col+16:-14]

                msg = msg.replace("\n"," ")
                msg = "\""+msg
                if len(msg) > 32:
                        msg = msg[:33]+"...\""
                else:
                        msg = msg+"\""                       

                print alias, "("+sender+") said \""+message+"\" in proto", proto
                #with icon at", icon_path, "in conv", conv

                # it's only commented out for test-reasons because i only try it on ubuntu and console with print
                pynotify.init(os.path.splitext(os.path.basename(sys.argv[0]))[0])
                n = pynotify.Notification(alias+" ("+proto+")",msg,"pidgin")
                # -------------------------
                # maybe the next two lines can be used for bringing the conversation window to the foreground
                # when the notification is being clicked by the user
                # if that is not possible: comment them out or delete them (no use for them)
                n.set_hint_string("dbus-callback-default","im.pidgin.purple.PurpleService /im/pidgin/purple/PurpleObject im.pidgin.purple.PurpleInterface purple_conversation_present int32:"+conv)
#                n.set_hint_string("dbus-callback-default","com.nokia.osso_browser /com/nokia/osso_browser com.nokia.osso_browser open_new_window string:\"callto://666\"")
                n.add_action("default", "im", cb)
                n.set_timeout(3000)
                # or do i have to make an "add_action" for the notification?
                # maybe i can just put three NULL arguments there ^^
                # ------------------------
                n.show()

import os
import sys
import gobject, dbus
import pynotify

from dbus.mainloop.glib import DBusGMainLoop

dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
obj = bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject")
bus.pidginbus = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface")

bus.add_signal_receiver(my_func,
                        dbus_interface="im.pidgin.purple.PurpleInterface",
                        signal_name="ReceivedImMsg")

loop = gobject.MainLoop()
loop.run()

screenshot:
http://img85.imageshack.us/img85/527...0062612374.png

b666m 2010-06-28 18:10

Re: Pidgin Notification Script or Plugin
 
can someone upload the "hildon-notification.h" please? :)

b666m 2010-06-28 18:30

Re: Pidgin Notification Script or Plugin
 
and one more question:

Quote:

In practice, this means that applications using libnotify (or any other compliant client library) will have their notifications shown on Hildon Desktop!
http://lucasr.org/2007/02/13/hildon-...reedesktoporg/

doesn't that mean that the pidgin-libnotify plugin (which is available and implemented in normal (not-maemo) pidgin) should also work on the n900 without changing anything!? (:

i was just taking a look into the source code:
http://sourceforge.net/projects/gaim-libnotify/files/

and it seems that the adaption to hildon-notification isn't hard at all - if needed because it should/could work "out of the box" as the page above states.

volt 2010-06-28 19:16

Re: Pidgin Notification Script or Plugin
 
Well, this is an interesting project. Do you think you'll make an plugin and put it in maemo-devel? I know that would be a bit more ambitious, but it might broaden the target user base. And maybe inspire similar projects.

b666m 2010-06-28 19:23

Re: Pidgin Notification Script or Plugin
 
tried to port some functions from python to c++ in a very quick way.

but unfortunately i get MANY warnings and errors - i think i miss something IMPORTant ^^

the main-loop is running - only the things in my callback-function aren't working at all - BUT: that would be how it should look in the end :)

c++/glib: (ONLY(!) the basic how-it-should-look/run ^^)
Code:

#include <glib.h>
#include <glib-object.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
#include <libpurple/purple.h>
#include <string.h>
//#include <hildon/hildon-notification.h>

#include "marshal.h"  /* The file generated from marshal.list via tool glib-genmarshal */

/* pidgin dbus station name */
#define DBUS_SERVICE_PURPLE      "im.pidgin.purple.PurpleService"
#define DBUS_PATH_PURPLE        "/im/pidgin/purple/PurpleObject"
#define DBUS_INTERFACE_PURPLE    "im.pidgin.purple.PurpleInterface"

/* global dbus instance */
DBusGConnection *bus;
DBusGProxy *purple_proxy;

/* Main event loop */
GMainLoop *loop = NULL;

/* Signal callback handling routing */
void received_im_msg_cb( DBusGProxy *purple_proxy, int account_id,
                        const char *sender, const char *message,
                        int conv_id, unsigned int flags,
                        gpointer user_data )
{
        g_print( "Account %d receives msg \"%s\" from %s\n", account_id, message, sender );       

        char name;
        char buddy;
        char alias;
        char proto;
        char msg;
        int  pos;
        int hasfocus;

        hasfocus = purple_conversation_has_focus(conv_id);

        if( hasfocus == 0 )
        {
                pos = sender.find("@");
                name = sender.erase(pos,(sender.length()-pos));
                buddy = purple_find_buddy(account_id,name);
                alias = purple_buddy_get_alias(buddy);
                proto = purple_account_get_protocol_name(account_id);

                // if alias is empty use the account-id/-number
                if( alias == "" ) alias = name;
       
                msg = message;

                // in XMPP remove the <BODY> and </BODY> tag
                if( proto == "XMPP" ) msg = msg.substr(6,(msg.length()-7));
                // in MSN remove the <FONT...> and </FONT> tags
                else if( proto == "MSN" )
                {
                        pos = msg.find("COLOR");
                        if( pos > -1 ) msg = msg.substr((pos+16),(msg.length()-14))
                }

                // replace all new line stringacters with spaces
                pos = msg.find("\"");
                while( pos )
                {               
                        msg = msg.replace(pos,pos," ");
                        pos = msg.find("\"");
                }

                // append " to the front of the message
                msg = msg.insert(0,"\"");
                // shorten a long message and append ..."
                if( msg.length > 32 ) (msg.substr(0,33)).append("...\"");
                // or just append "
                else msg.append("\"");
               
                // output to the console
                g_print("%s (%s) said \"%s\"", name, proto, msg);

                HildonNotification *n = NULL;

            n = hildon_notification_new( sender, message, "pidgin", "network" );
   
            // maybe someone can find an dbus call for bringing the current conversation
        // window to foreground when being clicked - using the "com.nokia.SOMETHING" interface
            // an example for using the pidgin interface - not tried yet ^^
            // hildon_notification_add_dbus_action( n, "default", "pidgin",
        // DBUS_SERVICE_PURPLE,
        // DBUS_PATH_PURPLE,
        // DBUS_INTERFACE_PURPLE,
        // "$METHOD", // see http://developer.pidgin.im/wiki/DbusHowto#CallingPidginmethods for methods?!
        // G_TYPE_NONE, NULL,
        // -1 );

                g_timeout_add_seconds( 2, close_notification, n );
            notify_notification_show( NOTIFY_NOTIFICATION( n ), NULL );
        }       
}

/*
 * The main process, loop waiting for any signals
 */
int main (int argc, string **argv)
{
    GError *error = NULL;
   
    g_type_init ();

    /* Get the bus */
    bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
    if (bus == NULL) {
        g_printerr("Failed to open connection to bus: %s", error->message);
        g_error_free(error);
        return -1;
    }

    /* Create a proxy object for the bus driver */
    purple_proxy = dbus_g_proxy_new_for_name (bus,
                                              DBUS_SERVICE_PURPLE,
                                              DBUS_PATH_PURPLE,
                                              DBUS_INTERFACE_PURPLE);
   
    if (!purple_proxy) {
        g_printerr("Couldn't connect to the Purple Service: %s", error->message);
        g_error_free(error);
        return -1;
    }

    /* Create the main loop instance */
    loop = g_main_loop_new (NULL, FALSE);

    /* Register dbus signal marshaller */
    dbus_g_object_register_marshaller(marshal_VOID__INT_STRING_STRING_INT_UINT,
                                      G_TYPE_NONE, G_TYPE_INT, G_TYPE_STRING,
                                      G_TYPE_STRING, G_TYPE_INT, G_TYPE_UINT,
                                      G_TYPE_INVALID);
       
    /* Add the signal to the proxy */
    dbus_g_proxy_add_signal(purple_proxy, "ReceivedImMsg",
                            G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING,
                            G_TYPE_INT, G_TYPE_UINT, G_TYPE_INVALID);

    /* Connect the signal handler to the proxy */
    dbus_g_proxy_connect_signal(purple_proxy, "ReceivedImMsg",
                                G_CALLBACK(received_im_msg_cb), bus, NULL);

    /* Main loop */
    g_main_loop_run (loop);

    return 0;
}


b666m 2010-06-28 19:25

Re: Pidgin Notification Script or Plugin
 
and because i had some time for looking into the gaim-notify source code (thx @ the author - http://sourceforge.net/projects/gaim-libnotify/files/) i tried to adapt the code a little bit. i'm just curious if the "gtk pixbuf" is working on the n900 - if not: that should be kicked from the code :P

c++/plugin: (first part)
Code:

*
 * Pidgin-hildonnotify - Provides a hildonnotify interface for Pidgin
 * Copyright (C) 2010-2011 Bastian Modauer
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "gln_intl.h"

#ifndef PURPLE_PLUGINS
#define PURPLE_PLUGINS
#endif

#include <pidgin.h>
#include <version.h>
#include <debug.h>
#include <util.h>
#include <privacy.h>

/* for pidgin_create_prpl_icon */
#include <gtkutils.h>

#include <hildon/hildon-notification.h>

#include <string.h>

#define PLUGIN_ID "pidgin-hildonnotify"

static GHashTable *buddy_hash;

static PurplePluginPrefFrame *
get_plugin_pref_frame (PurplePlugin *plugin)
{
        PurplePluginPrefFrame *frame;
        PurplePluginPref *ppref;

        frame = purple_plugin_pref_frame_new ();

        ppref = purple_plugin_pref_new_with_name_and_label (
                            "/plugins/gtk/hildonnotify/newmsg",
                            _("New messages"));
        purple_plugin_pref_frame_add (frame, ppref);

        ppref = purple_plugin_pref_new_with_name_and_label (
                            "/plugins/gtk/hildonnotify/newconvonly",
                            _("Only new conversations"));
        purple_plugin_pref_frame_add (frame, ppref);

        ppref = purple_plugin_pref_new_with_name_and_label (
                            "/plugins/gtk/hildonnotify/blocked",
                            _("Ignore events from blocked users"));
        purple_plugin_pref_frame_add (frame, ppref);

        ppref = purple_plugin_pref_new_with_name_and_label (
                            "/plugins/gtk/hildonnotify/signon",
                            _("Buddy signs on"));
        purple_plugin_pref_frame_add (frame, ppref);

        ppref = purple_plugin_pref_new_with_name_and_label (
                            "/plugins/gtk/hildonnotify/signoff",
                            _("Buddy signs off"));
        purple_plugin_pref_frame_add (frame, ppref);

        ppref = purple_plugin_pref_new_with_name_and_label (
                            "/plugins/gtk/hildonnotify/only_available",
                            _("Only when available"));
        purple_plugin_pref_frame_add (frame, ppref);

        return frame;
}

/* Signon flood be gone! - thanks to the guifications devs */
static GList *just_signed_on_accounts = NULL;

static gboolean
event_connection_throttle_cb (gpointer data)
{
        PurpleAccount *account;

        account = (PurpleAccount *)data;

        if (!account)
                return FALSE;

        if (!purple_account_get_connection (account)) {
                just_signed_on_accounts = g_list_remove (just_signed_on_accounts, account);
                return FALSE;
        }

        if (!purple_account_is_connected (account))
                return TRUE;

        just_signed_on_accounts = g_list_remove (just_signed_on_accounts, account);
        return FALSE;
}

static void
event_connection_throttle (PurpleConnection *conn, gpointer data)
{
        PurpleAccount *account;

        /* TODO: this function gets called after buddy signs on for GTalk
          users who have themselves as a buddy */
        purple_debug_info (PLUGIN_ID, "event_connection_throttle() called\n");

        if (!conn)
                return;

        account = purple_connection_get_account(conn);
        if (!account)
                return;

        just_signed_on_accounts = g_list_prepend (just_signed_on_accounts, account);
        g_timeout_add (5000, event_connection_throttle_cb, (gpointer)account);
}

/* do NOT g_free() the string returned by this function */
static gchar *
best_name (PurpleBuddy *buddy)
{
        if (buddy->alias) {
                return buddy->alias;
        } else if (buddy->server_alias) {
                return buddy->server_alias;
        } else {
                return buddy->name;
        }
}

static GdkPixbuf *
pixbuf_from_buddy_icon (PurpleBuddyIcon *buddy_icon)
{
        GdkPixbuf *icon;
        const guchar *data;
        size_t len;
        GdkPixbufLoader *loader;

        data = purple_buddy_icon_get_data (buddy_icon, &len);

        loader = gdk_pixbuf_loader_new ();
        gdk_pixbuf_loader_set_size (loader, 48, 48);
        gdk_pixbuf_loader_write (loader, data, len, NULL);
        gdk_pixbuf_loader_close (loader, NULL);

        icon = gdk_pixbuf_loader_get_pixbuf (loader);

        if (icon) {
                g_object_ref (icon);
        }

        g_object_unref (loader);

        return icon;
}

static void
action_cb (NotifyNotification *notification,
                  gchar *action, gpointer user_data)
{
        PurpleBuddy *buddy = NULL;
        PurpleConversation *conv = NULL;

        purple_debug_info (PLUGIN_ID, "action_cb(), "
                                        "notification: 0x%x, action: '%s'", notification, action);

        buddy = (PurpleBuddy *)g_object_get_data (G_OBJECT(notification), "buddy");

        if (!buddy) {
                purple_debug_warning (PLUGIN_ID, "Got no buddy!");
                return;
        }

        conv = purple_find_conversation_with_account (PURPLE_CONV_TYPE_ANY, buddy->name, buddy->account);

        if (!conv) {
                conv = purple_conversation_new (PURPLE_CONV_TYPE_IM,
                                                                          buddy->account,
                                                                          buddy->name);
        }
        conv->ui_ops->present (conv);

        notify_notification_close (notification, NULL);
}

static gboolean
closed_cb (NotifyNotification *notification)
{
        PurpleContact *contact;

        purple_debug_info (PLUGIN_ID, "closed_cb(), notification: 0x%x\n", notification);

        contact = (PurpleContact *)g_object_get_data (G_OBJECT(notification), "contact");
        if (contact)
                g_hash_table_remove (buddy_hash, contact);

        g_object_unref (G_OBJECT(notification));

        return FALSE;
}

/* you must g_free the returned string
 * num_chars is utf-8 characters */
static gchar *
truncate_escape_string (const gchar *str,
                                                int num_chars)
{
        gchar *escaped_str;

        if (g_utf8_strlen (str, num_chars*2+1) > num_chars) {
                gchar *truncated_str;
                gchar *str2;

                /* allocate number of bytes and not number of utf-8 chars */
                str2 = g_malloc ((num_chars-1) * 2 * sizeof(gchar));

                g_utf8_strncpy (str2, str, num_chars-2);
                truncated_str = g_strdup_printf ("%s..", str2);
                escaped_str = g_markup_escape_text (truncated_str, strlen (truncated_str));
                g_free (str2);
                g_free (truncated_str);
        } else {
                escaped_str = g_markup_escape_text (str, strlen (str));
        }

        return escaped_str;
}

static gboolean
should_notify_unavailable (PurpleAccount *account)
{
        PurpleStatus *status;

        if (!purple_prefs_get_bool ("/plugins/gtk/hildonnotify/only_available"))
                return TRUE;

        status = purple_account_get_active_status (account);

        return purple_status_is_online (status) && purple_status_is_available (status);
}

static void
notify (const gchar *title,
                const gchar *body,
                PurpleBuddy *buddy)
{
        HildonNotification *notification = NULL;
        GdkPixbuf *icon;
        PurpleBuddyIcon *buddy_icon;
        gchar *tr_body;
        PurpleContact *contact;

        contact = purple_buddy_get_contact (buddy);

        if (body)
                tr_body = truncate_escape_string (body, 60);
        else
                tr_body = NULL;

        notification = g_hash_table_lookup (buddy_hash, contact);

        if (notification != NULL) {
                notify_notification_update (notification, title, tr_body, NULL);
                /* this shouldn't be necessary, file a bug */
                notify_notification_show (notification, NULL);

                purple_debug_info (PLUGIN_ID, "notify(), update: "
                                                "title: '%s', body: '%s', buddy: '%s'\n",
                                                title, tr_body, best_name (buddy));

                g_free (tr_body);
                return;
        }
        notification = hildon_notification_new (title, tr_body, NULL, NULL);
        purple_debug_info (PLUGIN_ID, "notify(), new: "
                                        "title: '%s', body: '%s', buddy: '%s'\n",
                                        title, tr_body, best_name (buddy));

        g_free (tr_body);

        buddy_icon = purple_buddy_get_icon (buddy);
        if (buddy_icon) {
                icon = pixbuf_from_buddy_icon (buddy_icon);
                purple_debug_info (PLUGIN_ID, "notify(), has a buddy icon.\n");
        } else {
                icon = pidgin_create_prpl_icon (buddy->account, 1);
                purple_debug_info (PLUGIN_ID, "notify(), has a prpl icon.\n");
        }

        if (icon) {
                notify_notification_set_icon_from_pixbuf (notification, icon);
                g_object_unref (icon);
        } else {
                purple_debug_warning (PLUGIN_ID, "notify(), couldn't find any icon!\n");
        }

        g_hash_table_insert (buddy_hash, contact, notification);

        g_object_set_data (G_OBJECT(notification), "contact", contact);

        g_signal_connect (notification, "closed", G_CALLBACK(closed_cb), NULL);

        notify_notification_set_urgency (notification, NOTIFY_URGENCY_NORMAL);

        notify_notification_add_action (notification, "show", _("Show"), action_cb, NULL, NULL);

        if (!notify_notification_show (notification, NULL)) {
                purple_debug_error (PLUGIN_ID, "notify(), failed to send notification\n");
        }

}


b666m 2010-06-28 19:26

Re: Pidgin Notification Script or Plugin
 
c++/plugin: (second part)
Code:

static void
notify_buddy_signon_cb (PurpleBuddy *buddy,
                                                gpointer data)
{
        gchar *tr_name, *title;
        gboolean blocked;

        g_return_if_fail (buddy);

        if (!purple_prefs_get_bool ("/plugins/gtk/hildonnotify/signon"))
                return;

        if (g_list_find (just_signed_on_accounts, buddy->account))
                return;

        blocked = purple_prefs_get_bool ("/plugins/gtk/hildonnotify/blocked");
        if (!purple_privacy_check (buddy->account, buddy->name) && blocked)
                return;

        if (!should_notify_unavailable (purple_buddy_get_account (buddy)))
                return;

        tr_name = truncate_escape_string (best_name (buddy), 25);

        title = g_strdup_printf (_("%s signed on"), tr_name);

        notify (title, NULL, buddy);

        g_free (tr_name);
        g_free (title);
}

static void
notify_buddy_signoff_cb (PurpleBuddy *buddy,
                                                gpointer data)
{
        gchar *tr_name, *title;
        gboolean blocked;

        g_return_if_fail (buddy);

        if (!purple_prefs_get_bool ("/plugins/gtk/hildonnotify/signoff"))
                return;

        if (g_list_find (just_signed_on_accounts, buddy->account))
                return;

        blocked = purple_prefs_get_bool ("/plugins/gtk/hildonnotify/blocked");
        if (!purple_privacy_check (buddy->account, buddy->name) && blocked)
                return;

        if (!should_notify_unavailable (purple_buddy_get_account (buddy)))
                return;

        tr_name = truncate_escape_string (best_name (buddy), 25);

        title = g_strdup_printf (_("%s signed off"), tr_name);

        notify (title, NULL, buddy);

        g_free (tr_name);
        g_free (title);
}

static void
notify_msg_sent (PurpleAccount *account,
                                const gchar *sender,
                                const gchar *message)
{
        PurpleBuddy *buddy;
        gchar *title, *body, *tr_name;
        gboolean blocked;

        buddy = purple_find_buddy (account, sender);
        if (!buddy)
                return;

        blocked = purple_prefs_get_bool ("/plugins/gtk/hildonnotify/blocked");
        if (!purple_privacy_check(account, sender) && blocked)
                return;

        tr_name = truncate_escape_string (best_name (buddy), 25);

        title = g_strdup_printf (_("%s says:"), tr_name);
        body = purple_markup_strip_html (message);

        notify (title, body, buddy);

        g_free (tr_name);
        g_free (title);
        g_free (body);
}

static void
notify_new_message_cb (PurpleAccount *account,
                                          const gchar *sender,
                                          const gchar *message,
                                          int flags,
                                          gpointer data)
{
        PurpleConversation *conv;

        if (!purple_prefs_get_bool ("/plugins/gtk/hildonnotify/newmsg"))
                return;

        conv = purple_find_conversation_with_account (PURPLE_CONV_TYPE_IM, sender, account);

#ifndef DEBUG /* in debug mode, always show notifications */
        if (conv && purple_conversation_has_focus (conv)) {
                purple_debug_info (PLUGIN_ID, "Conversation has focus 0x%x\n", conv);
                return;
        }
#endif

        if (conv && purple_prefs_get_bool ("/plugins/gtk/hildonnotify/newconvonly")) {
                purple_debug_info (PLUGIN_ID, "Conversation is not new 0x%x\n", conv);
                return;
        }

        if (!should_notify_unavailable (account))
                return;

        notify_msg_sent (account, sender, message);
}

static void
notify_chat_nick (PurpleAccount *account,
                                  const gchar *sender,
                                  const gchar *message,
                                  PurpleConversation *conv,
                                  gpointer data)
{
        gchar *nick;

        nick = (gchar *)purple_conv_chat_get_nick (PURPLE_CONV_CHAT(conv));
        if (nick && !strcmp (sender, nick))
                return;

        if (!g_strstr_len (message, strlen(message), nick))
                return;

        notify_msg_sent (account, sender, message);
}

static gboolean
plugin_load (PurplePlugin *plugin)
{
        void *conv_handle, *blist_handle, *conn_handle;

        if (!notify_is_initted () && !notify_init ("Pidgin")) {
                purple_debug_error (PLUGIN_ID, "hildonnotify not running!\n");
                return FALSE;
        }

        conv_handle = purple_conversations_get_handle ();
        blist_handle = purple_blist_get_handle ();
        conn_handle = purple_connections_get_handle();

        buddy_hash = g_hash_table_new (NULL, NULL);

        purple_signal_connect (blist_handle, "buddy-signed-on", plugin,
                                                PURPLE_CALLBACK(notify_buddy_signon_cb), NULL);

        purple_signal_connect (blist_handle, "buddy-signed-off", plugin,
                                                PURPLE_CALLBACK(notify_buddy_signoff_cb), NULL);

        purple_signal_connect (conv_handle, "received-im-msg", plugin,
                                                PURPLE_CALLBACK(notify_new_message_cb), NULL);

        purple_signal_connect (conv_handle, "received-chat-msg", plugin,
                                                PURPLE_CALLBACK(notify_chat_nick), NULL);

        /* used just to not display the flood of guifications we'd get */
        purple_signal_connect (conn_handle, "signed-on", plugin,
                                                PURPLE_CALLBACK(event_connection_throttle), NULL);

        return TRUE;
}

static gboolean
plugin_unload (PurplePlugin *plugin)
{
        void *conv_handle, *blist_handle, *conn_handle;

        conv_handle = purple_conversations_get_handle ();
        blist_handle = purple_blist_get_handle ();
        conn_handle = purple_connections_get_handle();

        purple_signal_disconnect (blist_handle, "buddy-signed-on", plugin,
                                                        PURPLE_CALLBACK(notify_buddy_signon_cb));

        purple_signal_disconnect (blist_handle, "buddy-signed-off", plugin,
                                                        PURPLE_CALLBACK(notify_buddy_signoff_cb));

        purple_signal_disconnect (conv_handle, "received-im-msg", plugin,
                                                        PURPLE_CALLBACK(notify_new_message_cb));

        purple_signal_disconnect (conv_handle, "received-chat-msg", plugin,
                                                        PURPLE_CALLBACK(notify_chat_nick));

        purple_signal_disconnect (conn_handle, "signed-on", plugin,
                                                        PURPLE_CALLBACK(event_connection_throttle));

        g_hash_table_destroy (buddy_hash);

        notify_uninit ();

        return TRUE;
}

static PurplePluginUiInfo prefs_info = {
    get_plugin_pref_frame,
    0,                                                /* page num (Reserved) */
    NULL                                        /* frame (Reserved) */
};

static PurplePluginInfo info = {
    PURPLE_PLUGIN_MAGIC,                                                                                /* api version */
    PURPLE_MAJOR_VERSION,
    PURPLE_MINOR_VERSION,
    PURPLE_PLUGIN_STANDARD,                                                                        /* type */
    0,                                                                                                                /* ui requirement */
    0,                                                                                                                /* flags */
    NULL,                                                                                                        /* dependencies */
    PURPLE_PRIORITY_DEFAULT,                                                                        /* priority */
   
    PLUGIN_ID,                                                                                                /* id */
    NULL,                                                                                                        /* name */
    VERSION,                                                                                                /* version */
    NULL,                                                                                                        /* summary */
    NULL,                                                                                                        /* description */
   
    "Bastian Modauer <b666mg@googlemail.com>",                /* author */
    "http://talk.maemo.org/showthread.php?p=732839",                /* homepage */
   
    plugin_load,                        /* load */
    plugin_unload,                        /* unload */
    NULL,                                        /* destroy */
    NULL,                                        /* ui info */
    NULL,                                        /* extra info */
    &prefs_info                                /* prefs info */
};

static void
init_plugin (PurplePlugin *plugin)
{
        bindtextdomain (PACKAGE, LOCALEDIR);
        bind_textdomain_codeset (PACKAGE, "UTF-8");

        info.name = _("hildonnotify Popups");
        info.summary = _("Displays popups via hildonnotify.");
        info.description = _("Pidgin-hildonnotify:\nDisplays popups via hildonnotify.");

        purple_prefs_add_none ("/plugins/gtk/hildonnotify");
        purple_prefs_add_bool ("/plugins/gtk/hildonnotify/newmsg", TRUE);
        purple_prefs_add_bool ("/plugins/gtk/hildonnotify/blocked", TRUE);
        purple_prefs_add_bool ("/plugins/gtk/hildonnotify/newconvonly", FALSE);
        purple_prefs_add_bool ("/plugins/gtk/hildonnotify/signon", TRUE);
        purple_prefs_add_bool ("/plugins/gtk/hildonnotify/signoff", FALSE);
        purple_prefs_add_bool ("/plugins/gtk/hildonnotify/only_available", FALSE);
}

PURPLE_INIT_PLUGIN(notify, init_plugin, info)


b666m 2010-06-28 19:27

Re: Pidgin Notification Script or Plugin
 
these are just some code snippets if anybody is interested to look into it.

right now it would be very helpful if someone could upload the "hildon-notification.h" for me :)

Joorin 2010-06-28 19:31

Re: Pidgin Notification Script or Plugin
 
GTK+ and PixBuf works as intended, no problem there.

Bizzey 2010-07-22 10:41

Re: Pidgin Notification Script or Plugin
 
to bad this project got into a slow down, i would help but got zero knowledge about programmin or so

Scorpius 2010-09-11 00:46

Re: Pidgin Notification Script or Plugin
 
I modified the pidgin-libnotify plugin (since Maemo uses a libnotify compatible notification daemon) so it shows the very same notifications the python script does and also makes the phone vibrate.

I guess if anyone is interested I could create a .deb package an upload it to extras-devel or extra-testing.

Changegames 2010-09-12 11:21

Re: Pidgin Notification Script or Plugin
 
Quote:

Originally Posted by Scorpius (Post 813135)
I modified the pidgin-libnotify plugin (since Maemo uses a libnotify compatible notification daemon) so it shows the very same notifications the python script does and also makes the phone vibrate.

I guess if anyone is interested I could create a .deb package an upload it to extras-devel or extra-testing.

please do... i hope that it shows as a notification like how we get it on conversations.

Scorpius 2010-09-12 17:49

Re: Pidgin Notification Script or Plugin
 
Care to test it first? Just copy the pidgin-libnotify.so in /usr/lib/pidgin in your Maemo device, and activate it in pidgin in Tools -> Plugins.

http://rapidshare.com/files/41865374...n-libnotify.so

I will do some others optimizations/testing before packaging, but you could try it out.

Changegames 2010-09-13 02:56

Re: Pidgin Notification Script or Plugin
 
Quote:

Originally Posted by Scorpius (Post 814268)
Care to test it first? Just copy the pidgin-libnotify.so in /usr/lib/pidgin in your Maemo device, and activate it in pidgin in Tools -> Plugins.

http://rapidshare.com/files/41865374...n-libnotify.so

I will do some others optimizations/testing before packaging, but you could try it out.

tried it but it doesnt show any notification when theres a new message only when a buddy signs in and out....
is there a way to use the notification light for this too?

Scorpius 2010-09-13 15:40

Re: Pidgin Notification Script or Plugin
 
Did you check your settings selecting the plugin and pressing the "Configure Plugin" button?

You can select the notification you want to receive there. Right now I have selected "Vibrate" and "New messages" and I receive the notification when I receive a message from a pidgin window that is not focused.

NightShift79 2010-09-13 16:13

Re: Pidgin Notification Script or Plugin
 
it works for me.
wonder what kind of optimizations you got in mind.

Good to move it to repo.

Scorpius 2010-09-13 16:18

Re: Pidgin Notification Script or Plugin
 
Well we could release this as a first version 0.14.1.

I was thinking for example: right now the notification is auto-closed in 3 seconds. I was thinking to put an option to not close the notifications but if you click on them instead it goes to the pidgin window that sent the notification.

I think that's the Conversations behavior. To me it's really annoying because if you receive a lot of messages from different people you have to click on them to close them & go to the window. But maybe there's people out there that like that.

BTW the original maintainer of the plugin looks like he abandoned it in 2008. It's still his software that's why he's on the credits, I just added a few lines to port it to Maemo.

Changegames 2010-09-14 03:35

Re: Pidgin Notification Script or Plugin
 
Quote:

Originally Posted by Scorpius (Post 814968)
Did you check your settings selecting the plugin and pressing the "Configure Plugin" button?

You can select the notification you want to receive there. Right now I have selected "Vibrate" and "New messages" and I receive the notification when I receive a message from a pidgin window that is not focused.

it works now i dont know why it didnt work before...
is there a way you can make the notification stay till it gets clicked?

ravoori 2010-09-16 12:20

Re: Pidgin Notification Script or Plugin
 
Quote:

Originally Posted by Scorpius (Post 814998)
Well we could release this as a first version 0.14.1.

I was thinking for example: right now the notification is auto-closed in 3 seconds. I was thinking to put an option to not close the notifications but if you click on them instead it goes to the pidgin window that sent the notification.

I think that's the Conversations behavior. To me it's really annoying because if you receive a lot of messages from different people you have to click on them to close them & go to the window. But maybe there's people out there that like that.

BTW the original maintainer of the plugin looks like he abandoned it in 2008. It's still his software that's why he's on the credits, I just added a few lines to port it to Maemo.

the option to not close the notification would be a nice thing to have

b666m 2010-09-16 21:38

Re: Pidgin Notification Script or Plugin
 
first of all:
nice porting. the plugin works as it should. thank you. :)

Quote:

Originally Posted by ravoori (Post 817822)
the option to not close the notification would be a nice thing to have

would be a nice feature.

for me the best solution is to let the user set the popup-timeout.
and make a checkbox if a click on the popup brings the conversation to foreground or just removes the popup. (:

samsul 2010-09-18 22:45

Re: Pidgin Notification Script or Plugin
 
Where can i download pidgin-libnotify.so from?

Scorpius 2010-09-20 23:20

Re: Pidgin Notification Script or Plugin
 
I just released the version 0.14.2 of the pidgin-libnotify plugin. It now includes autoclose as an option, as well as the led alert.

So if you have the led option enabled when you receive an alert it will blink the led (just like it does when you receive an SMS) until the notification is closed.

If autoclose is enabled, the notification will be closed automatically in 3 seconds. Otherwise it stays open. If you click on it, it'll focus the IM window of the buddy that talked to you (and caused the notification). If that window was previously closed, it'll reopen it.

I'm waiting for the upload permission on the repo, so if you're one of the first 10 people that read this post, you can download it from:

http://rapidshare.com/files/42024550....2-1_armel.deb

Install with dpkg -i pidgin-libnotify_0.14.2-1_armel.deb

Hariainm 2010-09-21 00:13

Re: Pidgin Notification Script or Plugin
 
can you release this for other MSN plugins? (i have Pecan on my N900). That would be great! See this:
http://talk.maemo.org/showthread.php?t=62492

Scorpius 2010-09-21 00:33

Re: Pidgin Notification Script or Plugin
 
Quote:

Originally Posted by Hariainm (Post 821910)
can you release this for other MSN plugins? (i have Pecan on my N900). That would be great! See this:
http://talk.maemo.org/showthread.php?t=62492

Do you mean for the Conversations software? I thought it had all kind of notifications implemented.

I think Conversations is closed source software anyway. You could edit the MSN Pecan plugin to add notifications for it but if you want them in Skype or any other that's closed you would be in trouble.

I also use MSN pecan but for pidgin. Since Conversations and pidgin use libpurple their protocols can be used in both.

pidgin > Conversations

Changegames 2010-09-21 00:57

Re: Pidgin Notification Script or Plugin
 
scorpius it says incompatible application package

Scorpius 2010-09-21 03:46

Re: Pidgin Notification Script or Plugin
 
Quote:

Originally Posted by Changegames (Post 821927)
scorpius it says incompatible application package

It should say what exactly is incompatible when you try to install it .DBus version maybe?

I think you need Maemo 5 Fremantle for it to work and maybe on a N900...

llBlackenedll 2010-09-21 11:28

Re: Pidgin Notification Script or Plugin
 
Quote:

Originally Posted by Scorpius (Post 821888)
I just released the version 0.14.2 of the pidgin-libnotify plugin. It now includes autoclose as an option, as well as the led alert.

So if you have the led option enabled when you receive an alert it will blink the led (just like it does when you receive an SMS) until the notification is closed.

If autoclose is enabled, the notification will be closed automatically in 3 seconds. Otherwise it stays open. If you click on it, it'll focus the IM window of the buddy that talked to you (and caused the notification). If that window was previously closed, it'll reopen it.

I'm waiting for the upload permission on the repo, so if you're one of the first 10 people that read this post, you can download it from:

http://rapidshare.com/files/42024550....2-1_armel.deb

Install with dpkg -i pidgin-libnotify_0.14.2-1_armel.deb

I'd love to try this out myself - however I can't get it from RS (it doesn't say anything about the download limit though). Just wondering if you could possibly upload it to the thread itself? I believe that is possible...

Hariainm 2010-09-21 11:58

Re: Pidgin Notification Script or Plugin
 
Quote:

Originally Posted by Scorpius (Post 821918)
Do you mean for the Conversations software? I thought it had all kind of notifications implemented.

I think Conversations is closed source software anyway. You could edit the MSN Pecan plugin to add notifications for it but if you want them in Skype or any other that's closed you would be in trouble.

I also use MSN pecan but for pidgin. Since Conversations and pidgin use libpurple their protocols can be used in both.

pidgin > Conversations

Well, yes, but would be great if we can get notifications of status changes (this contact gets online, this other gets offline and so).

Quote:

Originally Posted by MohammadAG (Post 819824)
http://wiki.maemo.org/Phone_control#...ication_dialog for notifications, a C equivalent of the code is welcome, I need it for something :P
Empathy (based on Telepahty) notifies about online/offline contacts, so I guess telepathy sends dbus signals when a user goes online/offline, so it should be doable with a daemon.

What do you think? Is this possible?

Changegames 2010-10-12 09:02

Re: Pidgin Notification Script or Plugin
 
I'd love this script but is there a way that i can enable autoclose but still get the led light on? because if i enabled autoclose the led light blinks twice and then gone so it didnt really notify me anything, i want to be able to get new messages without having to close each additional window open... thanks :)

Scorpius 2010-10-12 14:53

Re: Pidgin Notification Script or Plugin
 
Quote:

Originally Posted by Changegames (Post 839073)
I'd love this script but is there a way that i can enable autoclose but still get the led light on? because if i enabled autoclose the led light blinks twice and then gone so it didnt really notify me anything, i want to be able to get new messages without having to close each additional window open... thanks :)

The problem is where do you put the code that makes the LED stop blinking? Right now is when the notification is closed.

I can't put the code when the message window is focused because it's autofocused when you receive a message so it would be the same behavior. Maybe when you answer the message but if you don't want to answer: same problem.

lasman 2010-11-15 16:57

Re: Pidgin Notification Script or Plugin
 
Hello,

I have used the plugin in pidgin. Good work. I wonder if it is possible/easy enough to implement, so that the user can set the time for the autoclose option; eg autoclose in 5, 10 or whatever seconds.
Thanks

Scorpius 2010-11-15 17:02

Re: Pidgin Notification Script or Plugin
 
Quote:

Originally Posted by lasman (Post 874230)
Hello,

I have used the plugin in pidgin. Good work. I wonder if it is possible/easy enough to implement, so that the user can set the time for the autoclose option; eg autoclose in 5, 10 or whatever seconds.
Thanks

Yes that's very easy to implement. It can be done.

Right now I'm beta testing the version 0.12.4. In this version notifications are autoclosed if you focus the conversation window that triggered the notification, so you don't have to close all notifications because it can get really annoying all those open notifications.

I'm also thinking a sound alert as an option as well (like the email does), sometimes I put my phone in the bed and people talk to me and I don't notice because I can't feel the vibration.

HtheB 2010-11-17 01:54

Re: Pidgin Notification Script or Plugin
 
Will there be an option for this plugin to just vibrate without any other notifications? (Just Vibrate on any incoming messages, without showing any yellow "balloon" notifications or blinking leds)

It'll be great to have the ability to turn this feature on/off.

Scorpius 2010-11-17 16:20

Re: Pidgin Notification Script or Plugin
 
Quote:

Originally Posted by HtheB (Post 875680)
Will there be an option for this plugin to just vibrate without any other notifications? (Just Vibrate on any incoming messages, without showing any yellow "balloon" notifications or blinking leds)

It'll be great to have the ability to turn this feature on/off.

Heh well, no. It's a libnotify plugin, and libnotify is a library to communicate to the notification daemon that creates all those balloon notifications. Turning that off is taking off the essence of the plugin.

Anyway if you use the autoclose and turn off the led notification you would get (more or less) what you want.

figaro 2010-12-20 08:29

Re: Pidgin Notification Script or Plugin
 
Quote:

Originally Posted by HtheB (Post 875680)
Will there be an option for this plugin to just vibrate without any other notifications? (Just Vibrate on any incoming messages, without showing any yellow "balloon" notifications or blinking leds)

It'll be great to have the ability to turn this feature on/off.

I second this

I want to preserve the LED blink and vibrate, but not the yellow balloon thing. And the next time I get focus to the conversation window, the LED will just stop blinking (right now I still have to tap the new message notification to stop the LED)

but then, this is a great plug-in I've been searching for a while. Thanks a lot

edit.
oops, you're just saying that you're still beta testing 0.12.4 while I'm already using 0.14.2 now
is this the same plug-in as in http://maemo.org/packages/view/pidgin-libnotify/ or was I posting to the wrong thread? :D

bibounefr 2010-12-20 10:40

Re: Pidgin Notification Script or Plugin
 
I can not have the LED notification? how to implement it?

zwadar 2011-01-08 23:12

Re: Pidgin Notification Script or Plugin
 
Quote:

Originally Posted by Scorpius (Post 874233)

I'm also thinking a sound alert as an option as well (like the email does), sometimes I put my phone in the bed and people talk to me and I don't notice because I can't feel the vibration.

Hey, great plugin, I was really missing that in pidgin. Any news on sound implementation anyways? Also it would be really great if this settings could be connected with general profile settings on N900: use default IM alert sound, vibrations settings.

bobsikus 2011-11-07 20:58

Re: Pidgin Notification Script or Plugin
 
Hi Scorpius.

I have question, if all options can be switched separately on seperate events ? I want to auto close option disabled for message, but enabled for contact signing in ... Is that possible ?


All times are GMT. The time now is 17:54.

vBulletin® Version 3.8.8