Notices


Reply
Thread Tools
qwerty12's Avatar
Posts: 4,274 | Thanked: 5,358 times | Joined on Sep 2007 @ Looking at y'all and sighing
#61
Originally Posted by b666m View Post
i meant that i have already implemented this function.
(i know... because of the numbers in front it looks like all of these points where "to do" - sorry for that ^^)


Originally Posted by b666m View Post
don't know if this is the one:
void purple_conversation_present (PurpleConversation *conv)
Present a conversation to the user.
That's the one! It works!

dbus-send --session --type=method_call --print-reply --dest=im.pidgin.purple.PurpleService /im/pidgin/purple/PurpleObject im.pidgin.purple.PurpleInterface.PurpleConversatio nPresent int32:2889 works here
Will get back to you with the PythonNotification conversion soon.

Originally Posted by b666m View Post

is there a chance to convert JPG into PNG?
any api or cli tool available for fremantle?
GdkPixbuf comes to mind... else, if ImageMagick is installed, you could probably spawn that
 

The Following User Says Thank You to qwerty12 For This Useful Post:
b666m's Avatar
Posts: 1,090 | Thanked: 476 times | Joined on Jan 2010 @ Ingolstadt, Germany
#62
come on ://
am i too dumb for this one?!

$ n.set_hint_string("dbus-callback-default","im.pidgin.purple.PurpleService /im/pidgin/purple/PurpleObject im.pidgin.purple.PurpleInterface.PurpleConversatio nPresent int32:"+conv)

doesn't seem to do anything at all... when i use the dbus-send in the console with the same conv-id everything works fine.

in the dbus-monitor i see that the notification has the correct strings.

maybe "bus-callback-default" is the wrong value/type/whatever for this action?! :/
 
b666m's Avatar
Posts: 1,090 | Thanked: 476 times | Joined on Jan 2010 @ Ingolstadt, Germany
#63
NEW STUFF INCLUDED:
- only showing notification if conversation hasn't focus
- notification timeout is set to 3 seconds
- replacing new-line-characters with spaces
- if the length exceeds the maximum a "..." will be added at the end

THINGS THAT WILL NOT BE DONE:
- no buddy avatar in notification (can't convert the image to .png). the pidgin-icon is used
- clicking the notification only closes it - can't send any useful dbus-message (but if someone has an idea - just tell me ^^)

OPEN POINT LIST:
- msn: cut the formatting string from messages
- xmpp: cut the <body> </body> tag from messages

SCREENSHOT:


CURRENT CODE:
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:
	
		buddy = bus.pidginbus.PurpleFindBuddy(account,str(sender.split("@")[0]))
		name = bus.pidginbus.PurpleBuddyGetAlias(buddy)
		#icon = bus.pidginbus.PurpleBuddyGetIcon(buddy)
		#icon_path = bus.pidginbus.PurpleBuddyIconGetFullPath(icon)
		conv = str(conversation)
		
		msg = message.replace("\n"," ")
		msg = "\""+msg
		if len(msg) > 32:
			msg = msg[:32]+"...\""

		print name, "("+sender+") said \""+message+"\""
		#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(name+" ("+sender+")",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()
attention: start pidgin first (or the script won't run)!
you can run this script in xterm via "python scriptname".
you maybe could autorun it via upstart if pidgin sends something when launching (just look for "event.d" or "upstart" here in the forum)
and maybe someone could wrap up a package for installing via packagemanager (:
 

The Following User Says Thank You to b666m For This Useful Post:
b666m's Avatar
Posts: 1,090 | Thanked: 476 times | Joined on Jan 2010 @ Ingolstadt, Germany
#64
i think the script is pretty done now.

last changes:
- notification uses the alias of the contact
-> if no alias is defined/available (when the contact isn't in your list for example) the account/id will be used - in icq: the number; in msn and xmpp: the first part of the email (@... is cut off)
- the protocol now is set into brackets behind the alias/account/id
- the messages are now clear of formatting. xmpp: <body> tag is removed; msn: <FONT> tag is removed
(the rest is the same as mentioned above in the new stuff area)

SCREENSHOT:


and here's the code:
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, proid 
		#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()
i think i will take a look into how to autostart/end the script on pidgin start/end.

BTW: it also works on my ubuntu-laptop


Last edited by b666m; 2010-06-26 at 12:20.
 

The Following 3 Users Say Thank You to b666m For This Useful Post:
b666m's Avatar
Posts: 1,090 | Thanked: 476 times | Joined on Jan 2010 @ Ingolstadt, Germany
#65
mhm... is it a good idea to start a script on bootup which checks if pidgin is running every X seconds with the "sleep X" command in between?

or will "sleep" drain the battery faster? :/

EDIT: if it's running it could start the pidginnotify python script and if it isn't running anymore it could kill it (:

Last edited by b666m; 2010-06-27 at 18:59.
 
Posts: 47 | Thanked: 21 times | Joined on Jan 2010
#66
b666m i'm following this closely! I don't like my 150 msn contacts to clutter my phone contacts.

Could you create a short tutorial on how to use ur script? Would love to test it!

Also, do you know of something to make pidgin vibrate? thats one thing i'm still missing!

Thanks for you're work!
 
qwerty12's Avatar
Posts: 4,274 | Thanked: 5,358 times | Joined on Sep 2007 @ Looking at y'all and sighing
#67
Originally Posted by b666m View Post
mhm... is it a good idea to start a script on bootup which checks if pidgin is running every X seconds with the "sleep X" command in between?

or will "sleep" drain the battery faster? :/
(:
I really think you'd be best off just making it a Pidgin plugin. Yes, one can only be made in C but I'll help with the DBus-GLib
 

The Following User Says Thank You to qwerty12 For This Useful Post:
b666m's Avatar
Posts: 1,090 | Thanked: 476 times | Joined on Jan 2010 @ Ingolstadt, Germany
#68
Originally Posted by dof250 View Post
Could you create a short tutorial on how to use ur script? Would love to test it!
1. just copy the code from above in a textfile and name it whatever you want. (for example "pidginnotifyd.py")
2. copy it over to your phone (for example to the "Documents" folder)
3. start pidgin
4. open up xterm on your phone and type "cd MyDocs/.documents"
5. type "python pidginnotifyd.py"
now the script should be running
(everytime you close pidgin you have to restart the script too)

Also, do you know of something to make pidgin vibrate? thats one thing i'm still missing!
there are some dbus-commands which can make the phone vibrate - will take a look at it

Thanks for you're work!
no problem - i mainly do it for my own - for learning new programming languages and making pidgin on the n900 smarter ^^

I really think you'd be best off just making it a Pidgin plugin. Yes, one can only be made in C but I'll help with the DBus-GLib
after programming the whole thing in python it should be no problem to port it - now that i know how everything's working

but your help is - of course - very appreciated!
 

The Following 2 Users Say Thank You to b666m For This Useful Post:
volt's Avatar
Posts: 1,309 | Thanked: 1,187 times | Joined on Nov 2008
#69
Are you guys sure you don't ought to create a new thread for this app or hack or plugin or what it is you're making? Or maybe change the thread title a bit.
 
b666m's Avatar
Posts: 1,090 | Thanked: 476 times | Joined on Jan 2010 @ Ingolstadt, Germany
#70
Originally Posted by volt View Post
Are you guys sure you don't ought to create a new thread for this app or hack or plugin or what it is you're making? Or maybe change the thread title a bit.
my thought was only to develop a python script - which i've already done. it's working pretty well.

but you're right. if we want to port the python source to C/C++ we should make this in an extra thread... so... here we go:
http://talk.maemo.org/showthread.php...839#post732839

everyone who likes to support this porting-project can take a look there. (:
 
Reply


 
Forum Jump


All times are GMT. The time now is 22:46.