Control a computer?

An instant messenger which can connect to AIM, GTalk, Jabber, ICQ, and more.
Post Reply
BrilliantWinter
Harmless
Posts: 4
Joined: Thu Jan 15, 2009 8:07 pm

Control a computer?

Post by BrilliantWinter »

Hey guys,

Bit of a strange request for you... Can anyone point me towards some information on controlling a computer (my home server more specifically) through adium? I am sure SOMEONE has done this before.

Basically I have a home server, and I have adium on it, as when someone is VNCed into it, we can then chat, but while I am at university, I would rather not bypass all of their security and networks just to change something on my server. They block all ports except for chat protocols, and web browsing, so its a bit hard to connect to my house on ports for things like transmission, websites, ftp, etc... So I want to send a command like "/torrent off" or "/control torrent-off" and have it stop my torrents. I began working on a plugin on my own for this (plus, good learning experience) but I have yet to find the info I need for adium to filter out commands that it RECEIVES (as opposed to me typing /nudge and it nudging someone)

Any help would be greatly appreciated!
Spenser
dreeves
Harmless
Posts: 7
Joined: Thu Jan 08, 2009 12:23 am
Location: New York
Contact:

Re: Control a computer?

Post by dreeves »

I recommend Toby's Plugin Guide: http://trac.adiumx.com/wiki/TobysGuideToPluginAuthoring
I actually updated that with a couple things that tripped us up when writing our plugin ( http://yootles.com/nims ).
Let me know if there's anything on Toby's Guide that doesn't work for you.
We're happy to share the source code for our plugin, btw.
BrilliantWinter
Harmless
Posts: 4
Joined: Thu Jan 15, 2009 8:07 pm

Re: Control a computer?

Post by BrilliantWinter »

I managed to get the base of a plugin coded, but I was having trouble making it read incoming messages, and block them if need be... So I went on IRC and Catfish_Man helped me integrate it directly into adium for now and I may change it to a plugin later.

So... in your plugin, am I able to use it, but my friends don't need it? they will just see it numbered so they know if one was missed, but they don't get auto-notified?
redkaa
Harmless
Posts: 4
Joined: Wed Feb 04, 2009 2:05 pm

Re: Control a computer?

Post by redkaa »

Hello! Do you have any idea how do I get the last message's contents through an apple script? Actually I am trying to solve the similar problem: I need to parse the new message to send it as an SMS. Or any other ways to create a new text file with the message inside it each time adium receives it.
I have the sms part up and working, now it's the adium part - do not know how to arrange all this.
BrilliantWinter
Harmless
Posts: 4
Joined: Thu Jan 15, 2009 8:07 pm

Re: Control a computer?

Post by BrilliantWinter »

What I ended up doing was a custom build of adium with everything coded inside of that... I can't remember the exact file, but if you hop on the IRC servers, they will tell you exactly where to go. Or I can try and find it after school if you still need it by then
mtimmsj
Frappa
Posts: 144
Joined: Wed Jun 08, 2005 6:55 pm
Location: Olympia, WA

Re: Control a computer?

Post by mtimmsj »

@redkaa: At this point in time chat contents (i.e. messages) are not exposed to AppleScript. Please see: http://trac.adiumx.com/ticket/6214
redkaa
Harmless
Posts: 4
Joined: Wed Feb 04, 2009 2:05 pm

Re: Control a computer?

Post by redkaa »

@mtimmsj: that's a pity. are there any other ways to fetch the contents (other than through applescript)? Any ready-made plugins? Actually I just need to put each new message into a separate file after I switch on this feature...
redkaa
Harmless
Posts: 4
Joined: Wed Feb 04, 2009 2:05 pm

Re: Control a computer?

Post by redkaa »

BrilliantWinter, I'd be glad if your plugin could really help me.
BrilliantWinter
Harmless
Posts: 4
Joined: Thu Jan 15, 2009 8:07 pm

Re: Control a computer?

Post by BrilliantWinter »

Okay, go grab the 1.3 trunk (or whatever its called) off of the svn for adium, then load it up in xcode, and look for a file named CBActionSupportPlugin.m. Once you find that, go look for "filterAttributedString" (its a function) and add some code in there! I will add my hacked up code as an example :P

Code: Select all

- (NSAttributedString *)filterAttributedString:(NSAttributedString *)inAttributedString context:(id)context;
{
	if( inAttributedString &&
	    [inAttributedString length] &&
	    [[inAttributedString string] rangeOfString:@"/me "
										   options:NSCaseInsensitiveSearch].location == 0 ) {
		NSMutableAttributedString *ourAttributedString = [[inAttributedString mutableCopy] autorelease];
		NSAttributedString *dots = [[[NSAttributedString alloc] initWithString:@"*" attributes:[ourAttributedString attributesAtIndex:[ourAttributedString length] - 1 effectiveRange:NULL]] autorelease];
		[ourAttributedString replaceCharactersInRange:NSMakeRange(0, 4)
										   withString:@"*"];
		[ourAttributedString appendAttributedString:dots];
		[ourAttributedString addAttribute:AIActionMessageAttributeName
									value:[NSNumber numberWithBool:YES]
									range:NSMakeRange(0, [ourAttributedString length])];
		return ourAttributedString;
	} else if( inAttributedString &&
			 [inAttributedString length] &&
			 [[inAttributedString string] rangeOfString:@"/controlme "
												options:NSCaseInsensitiveSearch].location == 0 ) {
		NSMutableAttributedString *ourAttributedString = [[inAttributedString mutableCopy] autorelease];
		[ourAttributedString deleteCharactersInRange:NSMakeRange(0, 11)];
		NSTask *task = [[NSTask alloc] init];
		[task setLaunchPath: @"/usr/bin/osascript"];
		NSArray *arguments = [[NSArray arrayWithObject:@"/AdiumControl.scpt"] arrayByAddingObjectsFromArray: [[ourAttributedString string] componentsSeparatedByString:@" "]];
		[task setArguments: arguments];
		[task launch];
		return ourAttributedString;
	}
	return inAttributedString;
}
Basically that takes anything after a message that starts with /controlme and it will hand it to an applescript, which does everything else...
redkaa
Harmless
Posts: 4
Joined: Wed Feb 04, 2009 2:05 pm

Re: Control a computer?

Post by redkaa »

Thank you for your reply, but this is a bit different from what I need. Besides, I am not that good in programming and I guess I won't cope with it :-(
All I need is putting a button to Adium contact list that would switch on the feature: take the first 100 symbols of each new message (after the feature is turned on) and put these symbols into a separate file (which will trigger sending an sms).
Post Reply