So follows my plan for updating Adium's AppleScript support. A link to my blog with my current problems/successes is here:

A request for #7483 has asked for iCal to integrate with Adium in a cool way. Well, because of the advancement of the AppleScript support, you now can. See the attached files for an example script.

Class Hierarchy

the application class for Adium, implemented in AIApplication (the model, always the model). Handles top-level elements, like windows and services, plus allows access to application preferences.
Elements: windows, services, accounts
Properties: forthcoming
Any NSWindow is a window that the application can manipulate. Tracks common window things, like order, titles, bounds, etc.
chat windows
Those NSWindows that are actually AIMessageWindows, which manage a bunch of chats.
Elements: chats
Properties: forthcoming
The AIChats inside the chat windows. These keep track of their contents, and who is talking at the moment.
The AIAccounts the user has registered. Keeps track of username (UID), and service-specific details.
The AIServices Adium supports. Keeps track of the accounts registered under that service, as well as the various service-specific options.
Elements: accounts

Features & Unit Tests

A note about unit testing: There isn't a unit test framework for AS. My 'unit tests' fall into one of two categories: things that should work and things that should throw some kind of error (no silent dying!). In either case, if I've been doing my job and the unit test succeeds, there should be no warning or error and your Adium setup should be intact. If some error is thrown, then the unit test failed. The errors will always be the generic AS error, -2700, with some message. If I'm testing for something that should error, I'll catch any error but -2700. Here's an example:

tell application "Adium"
		set name to "dummy" -- this should throw an error. If it does, we jump to the catch with some error number (8, I think)
		error "Assertion Failed!" -- this is a problem! We shouldn't get here! If we do, we throw error -2700
	on error number num --we catch all errors
		if num is -2700 then error --and if the number is -2700, we re-throw it.
	end try


Utility Scripts

script HandyAdiumMethods
	property tempAccount : missing value
	on init()
		set my tempAccount to missing value
	on makeTemporaryAccount(tempService)
		tell application "Adium"
			tell tempService
				set my tempAccount to (make new account with properties {name:my generateNewAccountUID()})
			end tell
		end tell
		return my tempAccount
	end makeTemporaryAccount
	on cleanUp()
		if (my tempAccount is not missing value) then
			tell my tempAccount's service to delete tempAccount
		end if
	end cleanUp
	on generateNewAccountUID()
		local x
		set x to 1
		tell application "Adium"
				if not (exists account ("temp" & x)) then return ("temp" & x)
			end repeat
		end tell
	end generateNewAccountUID
end script

Unit Tests


The SDEF so far


Attachments (1)

Download all attachments as: .zip

Page last modified by applmak, 7 years ago