Pages: [1]   Go Down
Author Topic: OS X: arduino + adium and gmail  (Read 772 times)
0 Members and 1 Guest are viewing this topic.
Karlsruhe, Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 79
¡Viva Arduino!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

hello!

basically what i want to do right now is have a led on the arduino flash when i either have unread mail in my gmail inbox, or when i have unread messages in adium.

my question: what is the best approach here?

i have been able to retrieve the number of unread messages in gmail using IMAP and the javax.mail library.

can i access adium through processing? using applescript, perhaps? it seems to be fairly easy to use, but i have no experience at all.

maybe someone has already done this, or something similar, and is able to share his/her code here? i would appreciate it!
thanks!
« Last Edit: February 20, 2009, 09:34:23 pm by formatc1702 » Logged


[size=20][ch12377][ch12372][ch12356][ch65281][/size]

Grenoble/Lyon - France
Offline Offline
Sr. Member
****
Karma: 0
Posts: 363
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

http://processing.org/hacks/hacks:applescript

http://trac.adiumx.com/wiki/AppleScript_Support_1.2
Logged


Karlsruhe, Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 79
¡Viva Arduino!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

hi!

thank you for the links, but i cannot seem to find a function in either of them that fits my needs.

method A:
if i use the myScript.execute command (first link), i see no way in the adium applescript page to determine whether i have unread messages. is there some sort of dictionary with ALL applescript functions adium supports?

or else: method B
if i configure adium to launch a certain applescript every time  a message is recieved (using the adium preferencs window) - how can i make my processing code react to that script? (the processing code needs to be already running because it also handles other events)
i would need some kind of event handler, or whatever it's called in processing.

method C:
...or the applescript could change some data which the processing code checks every 5 seconds or so and reacts to a change. but this is more of an indirect method and i would prefer A or B.

i hope you get what i mean, see the attached picture for a graphical representation  smiley-grin

any advice on this front?



thanks for advice!
« Last Edit: February 21, 2009, 07:21:25 am by formatc1702 » Logged


[size=20][ch12377][ch12372][ch12356][ch65281][/size]

Grenoble/Lyon - France
Offline Offline
Sr. Member
****
Karma: 0
Posts: 363
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

O Hai

Thinking fast, I guess the easiest way is the third.

First would be the best (that's what I thought about). I did not take time to browse the adium applescript doc, but I'll have a look at it later.

I'm not sure the second would be possible. I don't know if you can poll Java apps.

Gotta go, but I'll check it when I come back.

NB : you should post that lovely sketch to the "User Experience Sketches" group on flickr, they'll love that ^^
http://flickr.com/groups/uxsketches/pool/
Logged


Karlsruhe, Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 79
¡Viva Arduino!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

hey!

okay after some random clicking, i found the "open dictionary" menu item in the script editor. and turns out, there is an unread message count property.
i managed to write a script that displays the total number of unread messages.
now the question is: how do i call that script from processing?
do i do one myScript.execute() per line? or do i cram it all in one line? and where does the result (x) go?

here's the script, i just need to cram it into processing now  smiley-grin

Code:
tell application "Adium"
      set x to 0
      repeat with theChat in (every chat)
            set x to x + (unread message count of theChat)
      end repeat
      say "You have " & x & " unread messages"
end tell

i'll look into that flickr group as well, thanks hehehe
Logged


[size=20][ch12377][ch12372][ch12356][ch65281][/size]

Grenoble/Lyon - France
Offline Offline
Sr. Member
****
Karma: 0
Posts: 363
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here's a processing sketch that polls adium using the applescript you gave earlier.
It returns an integer.
Nobody never talks to me, so I always get 0, but it should work ^^

Code:
import com.apple.cocoa.foundation.*;

void setup() {
  size(400,400);
  int adiumUnread = runAS();
  println(adiumUnread);
}

void draw() {
  
}

public int runAS() {
  String script = "tell application \"Adium\"\n"
  +"  set x to 0\n"
  +"    repeat with theChat in (every chat)\n"
  +"    set x to x + (unread message count of theChat)\n"
  +"    end repeat\n"
  +"  end tell\n"
  +"  x";
  NSAppleScript myScript = new NSAppleScript(script);
  NSMutableDictionary errors = new NSMutableDictionary();
  NSAppleEventDescriptor result = myScript.execute(errors);
  return result.int32Value();
}
Logged


Karlsruhe, Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 79
¡Viva Arduino!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

hi!

thanks for that. however, it says it can't find the package com.apple.cocoa

where can i find it, and how can i make processing see it? i am already using javax.mail and i just had to copy it to the /code folder inside my sketch folder.
« Last Edit: February 21, 2009, 02:34:48 pm by formatc1702 » Logged


[size=20][ch12377][ch12372][ch12356][ch65281][/size]

Grenoble/Lyon - France
Offline Offline
Sr. Member
****
Karma: 0
Posts: 363
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry, I forgot about that.
The package is already present on macosx systems, but a bit find to hard.
Here's the way to have it working

http://processing.org/discourse/yabb_beta/YaBB.cgi?board=LibraryProblems;action=display;num=1225564736
Logged


Karlsruhe, Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 79
¡Viva Arduino!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

wonderful! it works perfectly! e-mail and adium notifications on the arduino!

thanks a lot for all the help... i'm slowly getting into processing after all! (and a bit of applescript on the way)
Logged


[size=20][ch12377][ch12372][ch12356][ch65281][/size]

Grenoble/Lyon - France
Offline Offline
Sr. Member
****
Karma: 0
Posts: 363
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You're welcome
Logged


Pages: [1]   Go Up
Jump to: