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 "ESApplescriptContactAlertPlugin.h"
18 #import <Adium/AIContactAlertsControllerProtocol.h>
19 #import "ESPanelApplescriptDetailPane.h"
20 #import "ESApplescriptabilityController.h"
21 #import <AIUtilities/AIImageAdditions.h>
23 #define APPLESCRIPT_ALERT_SHORT AILocalizedString(@"Run an AppleScript",nil)
24 #define APPLESCRIPT_ALERT_LONG AILocalizedString(@"Run the AppleScript \"%@\"","%@ will be replaced by the name of the AppleScript to run.")
27 * @class ESApplescriptContactAlertPlugin
28 * @brief Component which provides a "Run an Applescript" Action
30 @implementation ESApplescriptContactAlertPlugin
34 //Install our contact alert
35 [[adium contactAlertsController] registerActionID:APPLESCRIPT_CONTACT_ALERT_IDENTIFIER withHandler:self];
39 * @brief Short description
40 * @result A short localized description of the action
42 - (NSString *)shortDescriptionForActionID:(NSString *)actionID
44 return APPLESCRIPT_ALERT_SHORT;
48 * @brief Long description
49 * @result A longer localized description of the action which should take into account the details dictionary as appropraite.
51 - (NSString *)longDescriptionForActionID:(NSString *)actionID withDetails:(NSDictionary *)details
53 NSString *scriptName = [[[details objectForKey:KEY_APPLESCRIPT_TO_RUN] lastPathComponent] stringByDeletingPathExtension];
55 if (scriptName && [scriptName length]) {
56 return [NSString stringWithFormat:APPLESCRIPT_ALERT_LONG, scriptName];
58 return APPLESCRIPT_ALERT_SHORT;
65 - (NSImage *)imageForActionID:(NSString *)actionID
67 return [NSImage imageNamed:@"ApplescriptAlert" forClass:[self class]];
72 * @result An <tt>AIModularPane</tt> to use for configuring this action, or nil if no configuration is possible.
74 - (AIModularPane *)detailsPaneForActionID:(NSString *)actionID
76 return [ESPanelApplescriptDetailPane actionDetailsPane];
80 * @brief Perform an action
82 * @param actionID The ID of the action to perform
83 * @param listObject The listObject associated with the event triggering the action. It may be nil
84 * @param details If set by the details pane when the action was created, the details dictionary for this particular action
85 * @param eventID The eventID which triggered this action
86 * @param userInfo Additional information associated with the event; userInfo's type will vary with the actionID.
88 - (BOOL)performActionID:(NSString *)actionID forListObject:(AIListObject *)listObject withDetails:(NSDictionary *)details triggeringEventID:(NSString *)eventID userInfo:(id)userInfo
90 NSString *path = [details objectForKey:KEY_APPLESCRIPT_TO_RUN];
93 [[adium applescriptabilityController] runApplescriptAtPath:path
101 return (path != nil);
105 * @brief Allow multiple actions?
107 * If this method returns YES, every one of this action associated with the triggering event will be executed.
108 * If this method returns NO, only the first will be.
110 * Allow multiple applescript actions to be taken.
112 - (BOOL)allowMultipleActionsWithID:(NSString *)actionID