Notices


Reply
Thread Tools
b666m's Avatar
Posts: 1,090 | Thanked: 476 times | Joined on Jan 2010 @ Ingolstadt, Germany
#51
ok... now i need help.

the dbus signal from pidgin looks like:
Code:
void (*received_im_msg)(PurpleAccount *account, char *sender, char *message, PurpleConversation *conv, PurpleMessageFlags flags);
my dbus-monitor says:
Code:
signal sender=:1.12 -> dest=(null destination) serial=4223 path=/im/pidgin/purple/PurpleObject; interface=im.pidgin.purple.PurpleInterface; member=ReceivedImMsg
   int32 1100
   string "240597622"
   string "outsch"
   int32 43000
   uint32 2
so the structs "PurpleAccount" and "PurpleConversation" are broken down to an INT32 on dbus(?!?!?!?)

so my marshaller has to look like:
Code:
/* 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);
which after adding and connecting to the signal leads to my callback:
Code:
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)
where we see that my account_id and conv_id is INT.

that's why i can't use these three very cool functions:
Code:
const char *purple_account_get_alias(const PurpleAccount *account);
const char *purple_account_get_buddy_icon_path(const PurpleAccount *account);
const char *purple_account_get_protocol_name(const PurpleAccount *account);
just because they want a STRUCT and not an INT as parameter.

has anyone any idea how to solve this problem? :/

why does pidgin say that it sends a struct and my monitor recognizes an integer?

and are there maybe any cool G_TYPE_xxx for getting structs from dbus?
 
Posts: 42 | Thanked: 1 time | Joined on Jun 2010
#52
I only just got my N900 and I'm totally new to Pidgin. It's mostly fine, I just have one little annoyance.

When I move away from the app (for example, if I switch to do something else, or even just when the screen goes off to save the battery), it changes my status to 'Away'.

This really annoys me. I want my status to read 'Available' even if I don't have the app on the screen at the moment (it's running, I'm just looking at something else). Is there any way to make it keep my status as 'Available' all the time?
 
b666m's Avatar
Posts: 1,090 | Thanked: 476 times | Joined on Jan 2010 @ Ingolstadt, Germany
#53
Originally Posted by Bookishwitch View Post
This really annoys me. I want my status to read 'Available' even if I don't have the app on the screen at the moment (it's running, I'm just looking at something else). Is there any way to make it keep my status as 'Available' all the time?
mhm... don't know why this is happening... but maybe there's a function which sets your status to idle when losing focus or screen goes off...

then you could try to set your away-status:
when you see your buddylist do a CTRL + P on your keyboard.
this will open up the preferences.
now click with your finger on the dot on the right side of the screen (on the right side of "proxy").
then the list should scroll to the right where you can find a tab called "status/idle".
just uncheck the box next to "change to this status when idle".

does that work?! (:
 
Posts: 42 | Thanked: 1 time | Joined on Jun 2010
#54
Originally Posted by b666m View Post
mhm... don't know why this is happening... but maybe there's a function which sets your status to idle when losing focus or screen goes off...

then you could try to set your away-status:
when you see your buddylist do a CTRL + P on your keyboard.
this will open up the preferences.
now click with your finger on the dot on the right side of the screen (on the right side of "proxy").
then the list should scroll to the right where you can find a tab called "status/idle".
just uncheck the box next to "change to this status when idle".

does that work?! (:

Ahhh, that seems to have done the trick! Thankyou so much, I didn't realise there were extra tabs after the "proxy" one!
 
qwerty12's Avatar
Posts: 4,274 | Thanked: 5,358 times | Joined on Sep 2007 @ Looking at y'all and sighing
#55
Originally Posted by b666m View Post
just because they want a STRUCT and not an INT as parameter.

has anyone any idea how to solve this problem? :/

why does pidgin say that it sends a struct and my monitor recognizes an integer?

and are there maybe any cool G_TYPE_xxx for getting structs from dbus?
You're taking the API documentation too seriously. The page states that some changes will have to be made and, indeed, the equivalent D-Bus method call for, say, purple_account_get_protocol_name is PurpleAccountGetProtocolName.

Here's the major difference: The function takes a struct; the method call takes an PurpleAccount in the form of an int32, which is what the RecievedImMsg signal gives you.

Try, in X Terminal: dbus-send --session --type=method_call --print-reply --dest=im.pidgin.purple.PurpleService /im/pidgin/purple/PurpleObject im.pidgin.purple.PurpleInterface.PurpleAccountGetP rotocolName int32:1100

and you should realise what I mean.
 

The Following User Says Thank You to qwerty12 For This Useful Post:
Posts: 323 | Thanked: 76 times | Joined on Jan 2010
#56
just updated pidgin ! problem solved
 
b666m's Avatar
Posts: 1,090 | Thanked: 476 times | Joined on Jan 2010 @ Ingolstadt, Germany
#57
Originally Posted by qwerty12 View Post
Here's the major difference: The function takes a struct; the method call takes an PurpleAccount in the form of an int32, which is what the RecievedImMsg signal gives you.
omg ^^

mhm... if you want to you can take the C-code and improve it *laugh*

i have already rewritten the code with the use of python and it's much easier, cleaner and smaller

here's what i've got so far:
Code:
#!/usr/bin/env python

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

def my_func(account, sender, message, conversation, flags):
	
	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)

	print name, "("+sender+") said \""+message+"\" with icon at", icon_path

        # 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, "\""+message+"\"", icon_path)
        # -------------------------
        # 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", "com.nokia.osso_browser /com/nokia/osso_browser com.nokia.osso_browser open_new_window string:\"callto://666\"")
	#n.add_action("default", "call", cb)
        # 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()
for example save it as "pidginnotifyd.py".
then you can run it via "python pidginnotifyd.py" in your console.
(if you have the right packages installed of course ^^)

that's what the output looks like:
Code:
b666m@xb666mx:~/pidgin$ python python/pidginnotifyd.py 
ICH (xxx597xxx) said "test 123" with icon at /home/b666m/.purple/icons/5b9c4725ac17458f93a6960b0e05368ec9fa382f.jpg
as you can see we have the alias, the account(id), the message and the icon path.
so we can create a nice notification with "Alias (Account)" on top and with "Message" below.
of course we can use the buddys icon/avatar as picture for the notification.
(maybe the icon requires some more work when you can't give the notification absolute paths - but i have some ideas in mind of how to solve it)

Last edited by b666m; 2010-06-24 at 18:32.
 

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
#58
one picture before falling into my bed:



0. the notification is only shown when conversation hasn't focus.

1. callback function when notification is clicked doesn't work / isn't called - only the notification closes (would be cool if we could get the conversation window to foreground)

2. the buddy avatars are stored as ".jpg" - maybe pynotify only accepts ".png"?! - using the pidgin icon instead

3. icq looks ok but msn sends formatted messages like ""<FONT FACE="Times"><FONT COLOR="#000000">Hi!</FONT></FONT>" so there is some work needed to extract the message. haven't tested xmpp and other protocols yet.

4. notification has fixed width - so long messages are getting cut off. maybe a shorten-function would be cool to fit the size - like: "too long messages will be cut" -> "too long messag..."
 
qwerty12's Avatar
Posts: 4,274 | Thanked: 5,358 times | Joined on Sep 2007 @ Looking at y'all and sighing
#59
Originally Posted by b666m View Post
0. the notification is only shown when conversation hasn't focus.
I guess Pidgin isn't emitting the signal in that case. Are there alternatives?

Originally Posted by b666m View Post
1. callback function when notification is clicked doesn't work / isn't called - only the notification closes (would be cool if we could get the conversation window to foreground)
I couldn't find a function to show the window corresponding to the conversation. Notifications under Maemo *only* support a D-Bus callback. You could implement a service in the script, too, and set up the callback to point to your service which'd go through the windows and bring it to the top with the Xlib API... :\
Only thing is, python-xlib is lame so you'd have to resort to ctypes and I have no idea how to implement a D-Bus service in python-dbus (dbus-glib, however ); but I think Totem has a Python plugin implementing a remote control service in python-dbus.

Originally Posted by b666m View Post
2. the buddy avatars are stored as ".jpg" - maybe pynotify only accepts ".png"?! - using the pidgin icon instead
According to the Icon Theme Specification, only PNG, XPM and SVG are supported.

Originally Posted by b666m View Post
3. icq looks ok but msn sends formatted messages like ""<FONT FACE="Times"><FONT COLOR="#000000">Hi!</FONT></FONT>" so there is some work needed to extract the message. haven't tested xmpp and other protocols yet.
I believe this is using a workaround for the same issue: http://ubuntuforums.org/showthread.php?t=1201310

Originally Posted by b666m View Post
4. notification has fixed width - so long messages are getting cut off. maybe a shorten-function would be cool to fit the size - like: "too long messages will be cut" -> "too long messag..."
Python probably has such a function to shorten. The sad thing here is that the small notification is able to display more characters than the one in the Dashboard so it's a compromise. :\
 
b666m's Avatar
Posts: 1,090 | Thanked: 476 times | Joined on Jan 2010 @ Ingolstadt, Germany
#60
first of all: thanks for your reply - again

Originally Posted by qwerty12 View Post
I guess Pidgin isn't emitting the signal in that case. Are there alternatives?
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 ^^)

I couldn't find a function to show the window corresponding to the conversation.
don't know if this is the one:
void purple_conversation_present (PurpleConversation *conv)
Present a conversation to the user.

there is already a plugin where you can bring the window to the foreground when someone wrote you - always. and that's the annoying part of it.
i think i will try to catch the dbus signal via dbus-monitor and look if i could use it.

Notifications under Maemo *only* support a D-Bus callback.
oh man... :/
isn't there any dbus-method which i can pass an argument like the window-title or window-id and then it brings the window to foreground?! ://

You could implement a service in the script, too, and set up the callback to point to your service which'd go through the windows and bring it to the top with the Xlib API... :\
Only thing is, python-xlib is lame so you'd have to resort to ctypes and I have no idea how to implement a D-Bus service in python-dbus (dbus-glib, however ); but I think Totem has a Python plugin implementing a remote control service in python-dbus.
that's not good. ^^

According to the Icon Theme Specification, only PNG, XPM and SVG are supported.

is there a chance to convert JPG into PNG?
any api or cli tool available for fremantle?

I believe this is using a workaround for the same issue: http://ubuntuforums.org/showthread.php?t=1201310
just something like that:
pidgin_set_msn_message(' '.join(sys.argv[1:]))
but only the other way around ^^
(i already used str() for getting the right name for getting the buddy-object which is necessary to get all other values (like alias and icon-path and so on))

Python probably has such a function to shorten. The sad thing here is that the small notification is able to display more characters than the one in the Dashboard so it's a compromise. :\
python has to have such a function. ;D
but mhm... i don't know if it's necessary... it would look prettier in my opinion but it's no must-have-feature ^^
 

The Following User Says Thank You to b666m For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 23:29.