Merged [15040]: Trying some magic: 5 seconds after the last unreachable host is repor...
[adiumx.git] / Source / AIDockBehaviorPlugin.m
blob83e421f8bb37fe59474ce455e9a3fdb5769d391a
1 /* 
2  * Adium is the legal property of its developers, whose names are listed in the copyright file included
3  * with this source distribution.
4  * 
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.
8  * 
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.
12  * 
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.
15  */
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;
30 @end
32 /*!
33  * @class AIDockBehaviorPlugin
34  * @brief Bounce Dock action component
35  */
36 @implementation AIDockBehaviorPlugin
38 /*!
39  * @brief Install
40  */
41 - (void)installPlugin
43         //Install our contact alert
44         [[adium contactAlertsController] registerActionID:DOCK_BEHAVIOR_ALERT_IDENTIFIER withHandler:self];
47 /*!
48  * @brief Short description
49  * @result A short localized description of the action
50  */
51 - (NSString *)shortDescriptionForActionID:(NSString *)actionID
53         return(DOCK_BEHAVIOR_ALERT_SHORT);
56 /*!
57  * @brief Long description
58  * @result A longer localized description of the action which should take into account the details dictionary as appropraite.
59  */
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]]);
66 /*!
67  * @brief Image
68  */
69 - (NSImage *)imageForActionID:(NSString *)actionID
71         return([NSImage imageNamed:@"DockAlert" forClass:[self class]]);
74 /*!
75  * @brief Details pane
76  * @result An <tt>AIModularPane</tt> to use for configuring this action, or nil if no configuration is possible.
77  */
78 - (AIModularPane *)detailsPaneForActionID:(NSString *)actionID
80         return([ESDockAlertDetailPane actionDetailsPane]);
83 /*!
84  * @brief Perform an action
85  *
86  * Bounce the dock icon
87  *
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.
93  */
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]];
99 /*!
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.
107  */
108 - (BOOL)allowMultipleActionsWithID:(NSString *)actionID
110         return(NO);
113 @end