Applescript Status of Contacts not working properly

An instant messenger which can connect to AIM, GTalk, Jabber, ICQ, and more.
Post Reply
match.wolf
Harmless
Posts: 20
Joined: Mon Mar 06, 2006 7:15 pm
Location: Kaiserslautern, Germany

Applescript Status of Contacts not working properly

Post by match.wolf »

I'm having some trouble retrieving the status of contacts on my contact list using Applescript. I couldn't find anything (useful) about this topic here or on trac. So I'm asking if it's just me (or my stupid applescript) or if it is a bug in Adium.
What I want to do is getting the current status of a specific contact as a string. I tried the following code:

Code: Select all

tell application "Adium"
	set contactStatus to status of first contact whose ID is theID
end tell
This code just gives me an error (something about: it can't be converted to reference). "theID" is some ID I defined earlier in my code. I also tried:

Code: Select all

tell application "Adium"
	set contactStatus to status of first contact whose ID is theID as text
end tell
.. but it gives me the same error. On the other hand retrieving other information about the contact does work (like idle time etc). The only other thing not working is "status message". Also it does not give me the same error, it just gives me back an empty variable. So this is the next problem on my list.
But if I try the same with my own status (which seems to be implementet differently) it works:

Code: Select all

tell application "Adium"
	set myStatus to (my status type) as string
end tell
So I'm asking: anybody ever got the same problem? Can it be fixed, is it a bug in Adium?

PS: I'm actually implementing some adium-features for salling clicker. I'd like to see who of my contacts is online/away/... and what message they left.
User avatar
memark
Frappa
Posts: 163
Joined: Sat May 28, 2005 8:44 am
Location: Sweden, Göteborg

Post by memark »

I briefly tried getting the status message in the same way, and I recall running into errors like you describe.
Regards
Magnus Erik Markling
match.wolf
Harmless
Posts: 20
Joined: Mon Mar 06, 2006 7:15 pm
Location: Kaiserslautern, Germany

Post by match.wolf »

Addition:
I tried this:

Code: Select all

tell application "Adium"
	set contactProps to properties of (first contact whose ID is theID)
end tell
return contactProps
it gives me this:

Code: Select all

{display name:"***", visible:true, image:missing value, long display name:"***", serviceClass:"AIM-compatible", UID:"*****", id:"ICQ.****", class:contact, notes:missing value, idle time:0, status message:missing value, serviceID:"ICQ", online:true, status:available}
So the status is definitly there. But why can't I access it? I tried to access it in the resulting list, but it still resulted in an error. So what the f*** is going on here?
match.wolf
Harmless
Posts: 20
Joined: Mon Mar 06, 2006 7:15 pm
Location: Kaiserslautern, Germany

Post by match.wolf »

Oh, and another addition. I used the same as described above, this time for an away and idle contact:

Code: Select all

{display name:"***", visible:true, image:«data ***», long display name:"***", serviceClass:"AIM-compatible", UID:"***", id:"ICQ.***", class:contact, notes:missing value, idle time:412, serviceID:"ICQ", online:true, status:away and idle}
Get the same errors. But the weird thing is time is: the contact has no status message. Not even a missing value (The contact has an away message on my contact list).
match.wolf
Harmless
Posts: 20
Joined: Mon Mar 06, 2006 7:15 pm
Location: Kaiserslautern, Germany

Post by match.wolf »

memark wrote:I briefly tried getting the status message in the same way, and I recall running into errors like you describe.
Well, at least you got the same error. If I can't get this to work soon I'll file a bug report. I'll also have a look into the source, also I don't think it will help me: I have no idea how Applescriptsupport is implemented ...
User avatar
evands
Cocoaforge Admin
Posts: 3152
Joined: Thu Dec 02, 2004 10:55 pm
Location: Decatur, GA
Contact:

Post by evands »

match.wolf wrote:I have no idea how Applescriptsupport is implemented ...
Poorly.
The duck still burns.
--
My company: Saltatory Software. Check it out :)
match.wolf
Harmless
Posts: 20
Joined: Mon Mar 06, 2006 7:15 pm
Location: Kaiserslautern, Germany

Post by match.wolf »

evands wrote:Poorly.
You are so right. I wasted the last 1.5 h of my life to understand the Applescript implementation in Adium (and to understand applescript implementations at all, since I've never seen one before). I'll try to look into that again tomorrow. Perhaps I can at least file a proper bug report ...
User avatar
evands
Cocoaforge Admin
Posts: 3152
Joined: Thu Dec 02, 2004 10:55 pm
Location: Decatur, GA
Contact:

Post by evands »

Most of it is actually pretty good, but the status related stuff is bad for several reasons... in large part because I don't understand the intricacies of Applescript at all. Someone who does -- or has the interest and time to learn -- really needs to rewrite or bugfix the status support for applescript.
The duck still burns.
--
My company: Saltatory Software. Check it out :)
match.wolf
Harmless
Posts: 20
Joined: Mon Mar 06, 2006 7:15 pm
Location: Kaiserslautern, Germany

Post by match.wolf »

I had some time now to study the applescript implementation. I don't know yet why the status of contacts is not working (also I think I have clue, but I'll test that before I post it here).
But what I did find out is why you can't retrieve the status message of a contact via applescript.
The reason is, that the status message is retrieved with the "statusMessage" function at the AIListObject. Applescript wants a NSString here (as also stated in the AdiumSuite.scriptsuite file). But the function gives back a NSAttributedString, which applescript can't handle. Since some other code relies on the NSAttributedString, I created a new function:

Code: Select all

- (NSString *)statusMessageString;
{
	return [[self statusObjectForKey:@"StatusMessage"] string];
}
and changed the according entries in the AdiumSuite.scriptsuite and AdiumSuite.scriptTerminology files from statusMessage to statusMessageString. Afterwards I could retrieve the status messages of my contacts.
I did all this on the 0.89 code, since the last 1.0svn didn't run on my machine (don't know why). But all this should work with 1.0svn, too.
What shall I do now? I never contributed code via svn. Or shall I post a ticket on trac with the solution?
User avatar
evands
Cocoaforge Admin
Posts: 3152
Joined: Thu Dec 02, 2004 10:55 pm
Location: Decatur, GA
Contact:

Post by evands »

Cool :) http://trac.adiumx.com/wiki/ContributingCode describes the best way to submit a patch.

Patches generally need to be against 1.0svn since that's where the development happens... we can help you get that up and running since you're working on fixing things. What does it do when you run it?
The duck still burns.
--
My company: Saltatory Software. Check it out :)
match.wolf
Harmless
Posts: 20
Joined: Mon Mar 06, 2006 7:15 pm
Location: Kaiserslautern, Germany

Post by match.wolf »

Just read that part on contributing code. Since I'm at work I can't check out the 1.0, but I'll do that tonight. I also think I'm on a good way with the other problem I described. If I can figure that out, I'll also have a look at the rest of the status code ...
match.wolf
Harmless
Posts: 20
Joined: Mon Mar 06, 2006 7:15 pm
Location: Kaiserslautern, Germany

Post by match.wolf »

Posted the mentioned solution to trac
http://trac.adiumx.com/ticket/3397
But it still doesn't compile on 1.0svn on my machine. It seems it's searching for some libgaim files. I thought you don't need the libgaim sources to compile?
match.wolf
Harmless
Posts: 20
Joined: Mon Mar 06, 2006 7:15 pm
Location: Kaiserslautern, Germany

Post by match.wolf »

I tried again to compile the 1.0 svn. So I still don't know if my patch really works with it (it should, since the source of .89 and 1.0 is the same). When I try to compile I get an error: Libgaim/libgaim.h not found. Obviously XCode tries to compile the Gaim bundle. Should it do that? As I understand the Getting Source part on trac it shouldn't do that...
It's annoying ...
User avatar
evands
Cocoaforge Admin
Posts: 3152
Joined: Thu Dec 02, 2004 10:55 pm
Location: Decatur, GA
Contact:

Post by evands »

First guess, and not your fault because the documentation needs to be updated to reflect this bug in the compile process...

Have you checked out svn to a path which includes one or more spaces? That will cause a compile failure in the Gaim plugin.

(And FYI, no, you don't need the Libgaim sources to compile Adium... the failure is while compiling the Adium side of the Gaim interaction, Gaim.AdiumPlugin, which imports the Libgaim header file).
The duck still burns.
--
My company: Saltatory Software. Check it out :)
match.wolf
Harmless
Posts: 20
Joined: Mon Mar 06, 2006 7:15 pm
Location: Kaiserslautern, Germany

Post by match.wolf »

Ah, yes ... I think that's it ... since I already had an "adium" folder, containing the 0.89 ... I created an "adium 1.0svn" folder ... you really should update the documentation there....
but after all: my patch works. I'll get working on that other issue now ...
User avatar
Catfish_Man
Cocoaforge Admin
Posts: 1203
Joined: Thu Dec 02, 2004 6:30 am
Location: Portland, Oregon
Contact:

Post by Catfish_Man »

match.wolf wrote:Ah, yes ... I think that's it ... since I already had an "adium" folder, containing the 0.89 ... I created an "adium 1.0svn" folder ... you really should update the documentation there....
but after all: my patch works. I'll get working on that other issue now ...
Documentation updated.

<edit>
The patch appears to apply cleanly to 1.0, and I can't see anything wrong with it (looking at it a bit closer than I did the last external patch I committed...). Anyone have objections to me committing it? If not, how would you like to be credited in the commit log?
</edit>
match.wolf
Harmless
Posts: 20
Joined: Mon Mar 06, 2006 7:15 pm
Location: Kaiserslautern, Germany

Post by match.wolf »

You can credit me with my e-mail, if you want. But I really don't insinst on credit ...[/b]
User avatar
Catfish_Man
Cocoaforge Admin
Posts: 1203
Joined: Thu Dec 02, 2004 6:30 am
Location: Portland, Oregon
Contact:

Post by Catfish_Man »

match.wolf wrote:You can credit me with my e-mail, if you want. But I really don't insinst on credit ...[/b]
Done. Crediting contributors is just project policy :)
match.wolf
Harmless
Posts: 20
Joined: Mon Mar 06, 2006 7:15 pm
Location: Kaiserslautern, Germany

Post by match.wolf »

Filed a ticket and solution (3423) for the status of contact error I reported. I'll have some more looks on the status implementation in Applescript next weekend. Would do it sooner, but gotta go on a conference this week.
Enjoyed contributing. Great program. Keep up the good work.
Post Reply