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 "AIDockBehaviorPlugin.h"
18 #import "AIDockController.h"
19 #import "ESContactAlertsController.h"
20 #import "ESDockAlertDetailPane.h"
21 #import <AIUtilities/ESImageAdditions.h>
23 #define DOCK_BEHAVIOR_ALERT_SHORT AILocalizedString(@"Bounce the dock icon",nil)
24 #define DOCK_BEHAVIOR_ALERT_LONG AILocalizedString(@"Bounce the dock icon %@",nil)
26 @interface AIDockBehaviorPlugin (PRIVATE)
27 - (void)preferencesChanged:(NSNotification *)notification;
28 - (void)eventNotification:(NSNotification *)notification;
29 - (BOOL)_upgradeCustomDockBehavior;
33 * @class AIDockBehaviorPlugin
34 * @brief Bounce Dock action component
36 @implementation AIDockBehaviorPlugin
43 //Install our contact alert
44 [[adium contactAlertsController] registerActionID:DOCK_BEHAVIOR_ALERT_IDENTIFIER withHandler:self];
48 * @brief Short description
49 * @result A short localized description of the action
51 - (NSString *)shortDescriptionForActionID:(NSString *)actionID
53 return(DOCK_BEHAVIOR_ALERT_SHORT);
57 * @brief Long description
58 * @result A longer localized description of the action which should take into account the details dictionary as appropraite.
60 - (NSString *)longDescriptionForActionID:(NSString *)actionID withDetails:(NSDictionary *)details
62 int behavior = [[details objectForKey:KEY_DOCK_BEHAVIOR_TYPE] intValue];
63 return([NSString stringWithFormat:DOCK_BEHAVIOR_ALERT_LONG, [[[adium dockController] descriptionForBehavior:behavior] lowercaseString]]);
69 - (NSImage *)imageForActionID:(NSString *)actionID
71 return([NSImage imageNamed:@"DockAlert" forClass:[self class]]);
76 * @result An <tt>AIModularPane</tt> to use for configuring this action, or nil if no configuration is possible.
78 - (AIModularPane *)detailsPaneForActionID:(NSString *)actionID
80 return([ESDockAlertDetailPane actionDetailsPane]);
84 * @brief Perform an action
86 * Bounce the dock icon
88 * @param actionID The ID of the action to perform
89 * @param listObject The listObject associated with the event triggering the action. It may be nil
90 * @param details If set by the details pane when the action was created, the details dictionary for this particular action
91 * @param eventID The eventID which triggered this action
92 * @param userInfo Additional information associated with the event; userInfo's type will vary with the actionID.
94 - (void)performActionID:(NSString *)actionID forListObject:(AIListObject *)listObject withDetails:(NSDictionary *)details triggeringEventID:(NSString *)eventID userInfo:(id)userInfo
96 [[adium dockController] performBehavior:[[details objectForKey:KEY_DOCK_BEHAVIOR_TYPE] intValue]];
100 * @brief Allow multiple actions?
102 * If this method returns YES, every one of this action associated with the triggering event will be executed.
103 * If this method returns NO, only the first will be.
105 * Don't allow multiple dock actions to occur. While a series of "Bounce every 5 seconds," "Bounce every 10 seconds,"
106 * and so on actions could be combined sanely, a series of "Bounce once" would make the dock go crazy.
108 - (BOOL)allowMultipleActionsWithID:(NSString *)actionID