2 * Adium is the legal property of its developers, whose names are listed in the copyright file included
3 * with this source distribution.
5 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
6 * General Public License as published by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
10 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11 * Public License for more details.
13 * You should have received a copy of the GNU General Public License along with this program; if not,
14 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 #import "AIAccountController.h"
18 #import "AIContactController.h"
19 #import "AIContentController.h"
20 #import "AIInterfaceController.h"
21 #import "AIPreferenceController.h"
22 #import "AIStatusController.h"
23 #import "ESApplescriptabilityController.h"
24 #import <AIUtilities/AIAttributedStringAdditions.h>
25 #import <Adium/AIAccount.h>
26 #import <Adium/AIContentMessage.h>
27 #import <Adium/AIHTMLDecoder.h>
29 @implementation ESApplescriptabilityController
32 - (void)initController
38 - (void)closeController
43 #pragma mark Convenience
46 return ([[adium accountController] accountArray]);
50 return ([[adium contactController] allContactsInGroup:nil
56 return ([[[adium contentController] openChats] allObjects]);
59 #pragma mark Attributes
60 #warning Quite a bit in here is broken and needs to be rewritten for the new status system -eds
61 - (NSTimeInterval)myIdleTime
63 NSDate *idleSince = [[adium preferenceController] preferenceForKey:@"IdleSince" group:GROUP_ACCOUNT_STATUS];
64 return (-[idleSince timeIntervalSinceNow]);
66 - (void)setMyIdleTime:(NSTimeInterval)timeInterval
68 [[adium notificationCenter] postNotificationName:Adium_RequestSetManualIdleTime
69 object:(timeInterval ? [NSNumber numberWithDouble:timeInterval] : nil)
73 - (NSData *)defaultImageData
75 return ([[adium preferenceController] preferenceForKey:KEY_USER_ICON
76 group:GROUP_ACCOUNT_STATUS]);
79 - (void)setDefaultImageData:(NSData *)newDefaultImageData
81 [[adium preferenceController] setPreference:newDefaultImageData
83 group:GROUP_ACCOUNT_STATUS];
86 - (AIStatus *)myStatus
88 return [[adium statusController] activeStatusState];
91 //Incomplete - make AIStatus scriptable, pass that in
92 - (void)setMyStatus:(AIStatus *)newStatus
94 [[adium statusController] setActiveStatusState:newStatus];
97 - (AIStatusTypeApplescript)myStatusTypeApplescript
99 return [[self myStatus] statusTypeApplescript];
103 - (void)setMyStatusTypeApplescript:(AIStatusTypeApplescript)newStatusType
105 AIStatus *newStatus = [[self myStatus] mutableCopy];
107 [newStatus setStatusTypeApplescript:newStatusType];
108 [self setMyStatus:newStatus];
113 - (NSString *)myStatusMessageString
115 return [[self myStatus] statusMessageString];
118 - (void)setMyStatusMessageString:(NSString *)inString
120 AIStatus *newStatus = [[self myStatus] mutableCopy];
122 [newStatus setStatusMessageString:inString];
123 [self setMyStatus:newStatus];
128 #pragma mark Controller convenience
129 - (AIInterfaceController *)interfaceController{
130 return([adium interfaceController]);
134 - (AIChat *)createChatCommand:(NSScriptCommand *)command
136 NSDictionary *evaluatedArguments = [command evaluatedArguments];
137 NSString *UID = [evaluatedArguments objectForKey:@"UID"];
138 NSString *serviceID = [evaluatedArguments objectForKey:@"serviceID"];
139 AIListContact *contact;
142 contact = [[adium contactController] preferredContactWithUID:UID
143 andServiceID:serviceID
144 forSendingContentType:CONTENT_MESSAGE_TYPE];
147 //Open the chat and set it as active
148 chat = [[adium contentController] openChatWithContact:contact];
149 [[adium interfaceController] setActiveChat:chat];