Don't need the English form of these
[adiumx.git] / Source / AIStatusController.h
blobf52b5932557ca4a46e7a4c5ac96d10b56a67ca1e
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.
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 "AIStatus.h"
19 @class AIService;
20 @protocol AIListObjectObserver;
22 //Status State Notifications
23 #define AIStatusStateArrayChangedNotification @"AIStatusStateArrayChangedNotification"
24 #define AIStatusActiveStateChangedNotification @"AIStatusActiveStateChangedNotification"
25 #define AIStatusStateMenuSelectionsChangedNotification @"AIStatusStateMenuSelectionsChangedNotification"
27 //Idle Notifications
28 #define AIMachineIsIdleNotification @"AIMachineIsIdleNotification"
29 #define AIMachineIsActiveNotification @"AIMachineIsActiveNotification"
30 #define AIMachineIdleUpdateNotification @"AIMachineIdleUpdateNotification"
32 //Preferences
33 #define PREF_GROUP_SAVED_STATUS @"Saved Status"
34 #define KEY_SAVED_STATUS @"Saved Status Array"
36 #define KEY_STATUS_NAME @"Status Name"
37 #define KEY_STATUS_DESCRIPTION @"Status Description"
38 #define KEY_STATUS_TYPE @"Status Type"
40 #define PREF_GROUP_STATUS_PREFERENCES @"Status Preferences"
41 #define KEY_STATUS_REPORT_IDLE @"Report Idle"
42 #define KEY_STATUS_REPORT_IDLE_INTERVAL @"Report Idle Interval"
43 #define KEY_STATUS_AUTO_AWAY @"Auto Away"
44 #define KEY_STATUS_ATUO_AWAY_STATUS_STATE_ID @"Auto Away Status State ID"
45 #define KEY_STATUS_FUS @"Fast User Switching Auto Away"
46 #define KEY_STATUS_FUS_STATUS_STATE_ID @"Fast User Switching Status State ID"
47 #define KEY_STATUS_AUTO_AWAY_INTERVAL @"Auto Away Interval"
48 #define KEY_STATUS_SHOW_STATUS_WINDOW @"Show Status Window"
50 //Built-in names and descriptions, which services should use when they support identical or approximately identical states
51 #define STATUS_NAME_AVAILABLE @"Generic Available"
52 #define STATUS_DESCRIPTION_AVAILABLE AILocalizedString(@"Available", nil)
53 #define STATUS_NAME_FREE_FOR_CHAT @"Free for Chat"
54 #define STATUS_DESCRIPTION_FREE_FOR_CHAT AILocalizedString(@"Free for chat", nil)
55 #define STATUS_NAME_AVAILABLE_FRIENDS_ONLY @"Available for Friends Only"
56 #define STATUS_DESCRIPTION_AVAILABLE_FRIENDS_ONLY AILocalizedString(@"Available for friends only",nil)
58 #define STATUS_NAME_AWAY @"Generic Away"
59 #define STATUS_DESCRIPTION_AWAY AILocalizedString(@"Away", nil)
60 #define STATUS_NAME_EXTENDED_AWAY @"Extended Away"
61 #define STATUS_DESCRIPTION_EXTENDED_AWAY AILocalizedString(@"Extended away",nil)
62 #define STATUS_NAME_AWAY_FRIENDS_ONLY @"Away for Friends Only"
63 #define STATUS_DESCRIPTION_AWAY_FRIENDS_ONLY AILocalizedString(@"Away for friends only",nil)
64 #define STATUS_NAME_DND @"DND"
65 #define STATUS_DESCRIPTION_DND AILocalizedString(@"Do not disturb", nil)
66 #define STATUS_NAME_NOT_AVAILABLE @"Not Available"
67 #define STATUS_DESCRIPTION_NOT_AVAILABLE AILocalizedString(@"Not available", nil)
68 #define STATUS_NAME_OCCUPIED @"Occupied"
69 #define STATUS_DESCRIPTION_OCCUPIED AILocalizedString(@"Occupied", nil)
70 #define STATUS_NAME_BRB @"BRB"
71 #define STATUS_DESCRIPTION_BRB AILocalizedString(@"Be right back",nil)
72 #define STATUS_NAME_BUSY @"Busy"
73 #define STATUS_DESCRIPTION_BUSY AILocalizedString(@"Busy",nil)
74 #define STATUS_NAME_PHONE @"Phone"
75 #define STATUS_DESCRIPTION_PHONE AILocalizedString(@"On the phone",nil)
76 #define STATUS_NAME_LUNCH @"Lunch"
77 #define STATUS_DESCRIPTION_LUNCH AILocalizedString(@"Out to lunch",nil)
78 #define STATUS_NAME_NOT_AT_HOME @"Not At Home"
79 #define STATUS_DESCRIPTION_NOT_AT_HOME AILocalizedString(@"Not at home",nil)
80 #define STATUS_NAME_NOT_AT_DESK @"Not At Desk"
81 #define STATUS_DESCRIPTION_NOT_AT_DESK AILocalizedString(@"Not at my desk",nil)
82 #define STATUS_NAME_NOT_IN_OFFICE @"Not In Office"
83 #define STATUS_DESCRIPTION_NOT_IN_OFFICE AILocalizedString(@"Not in the office",nil)
84 #define STATUS_NAME_VACATION @"Vacation"
85 #define STATUS_DESCRIPTION_VACATION AILocalizedString(@"On vacation",nil)
86 #define STATUS_NAME_STEPPED_OUT @"Stepped Out"
87 #define STATUS_DESCRIPTION_STEPPED_OUT AILocalizedString(@"Stepped out",nil)
89 #define STATUS_NAME_INVISIBLE @"Invisible"
90 #define STATUS_DESCRIPTION_INVISIBLE AILocalizedString(@"Invisible",nil)
92 #define STATUS_NAME_OFFLINE @"Offline"
93 #define STATUS_DESCRIPTION_OFFLINE AILocalizedString(@"Offline",nil)
95 //Current version state ID string
96 #define STATE_SAVED_STATE @"State"
98 //Protocol for state menu display
99 @protocol StateMenuPlugin <NSObject>
100 - (void)addStateMenuItems:(NSArray *)menuItemArray;
101 - (void)removeStateMenuItems:(NSArray *)menuItemArray;
102 @end
104 @interface AIStatusController : NSObject<AIListObjectObserver> {
105 IBOutlet AIAdium *adium;
107 //Status states
108 NSMutableArray *stateArray;
109 NSMutableArray *builtInStateArray;
111 AIStatus *offlineStatusState; //Shared state used to symbolize the offline 'status'
113 AIStatus *_activeStatusState; //Cached active status state
114 NSMutableSet *_allActiveStatusStates; //Cached all active status states
115 NSMutableDictionary *statusDictsByServiceCodeUniqueID[STATUS_TYPES_COUNT];
116 NSMutableSet *builtInStatusTypes[STATUS_TYPES_COUNT];
118 NSMutableSet *accountsToConnect;
119 BOOL isProcessingGlobalChange;
121 //Machine idle tracking
122 BOOL machineIsIdle;
123 double lastSeenIdle;
124 NSTimer *idleTimer;
126 //State menu support
127 NSMutableArray *stateMenuPluginsArray;
128 NSMutableDictionary *stateMenuItemArraysDict;
129 int stateMenuUpdateDelays;
130 NSArray *_sortedFullStateArray;
132 NSMutableSet *stateMenuItemsNeedingUpdating;
135 - (void)initController;
136 - (void)beginClosing;
137 - (void)closeController;
138 - (void)finishIniting;
140 - (NSNumber *)nextUniqueStatusID;
142 - (void)registerStatus:(NSString *)statusName
143 withDescription:(NSString *)description
144 ofType:(AIStatusType)type
145 forService:(AIService *)service;
146 - (NSMenu *)menuOfStatusesForService:(AIService *)service withTarget:(id)target;
148 - (NSArray *)stateArray;
149 - (NSArray *)sortedFullStateArray;
150 - (AIStatus *)offlineStatusState;
151 - (AIStatus *)statusStateWithUniqueStatusID:(NSNumber *)uniqueStatusID;
153 - (void)setActiveStatusState:(AIStatus *)state;
154 - (void)applyState:(AIStatus *)statusState toAccounts:(NSArray *)accountArray;
155 - (AIStatus *)activeStatusState;
156 - (NSSet *)allActiveStatusStates;
157 - (AIStatusType)activeStatusTypeTreatingInvisibleAsAway:(BOOL)invisibleIsAway;
158 - (NSSet *)activeUnavailableStatusesAndType:(AIStatusType *)activeUnvailableStatusType
159 withName:(NSString **)activeUnvailableStatusName
160 allOnlineAccountsAreUnvailable:(BOOL *)allOnlineAccountsAreUnvailable;
161 - (AIStatus *)defaultInitialStatusState;
163 - (NSString *)descriptionForStateOfStatus:(AIStatus *)statusState;
164 - (NSString *)localizedDescriptionForCoreStatusName:(NSString *)statusName;
165 - (NSString *)localizedDescriptionForStatusName:(NSString *)statusName statusType:(AIStatusType)statusType;
166 - (NSString *)defaultStatusNameForType:(AIStatusType)statusType;
168 //State Editing
169 - (void)addStatusState:(AIStatus *)state;
170 - (void)removeStatusState:(AIStatus *)state;
171 - (void)replaceExistingStatusState:(AIStatus *)oldState withStatusState:(AIStatus *)newState;
172 - (int)moveStatusState:(AIStatus *)state toIndex:(int)destIndex;
173 - (void)statusStateDidSetUniqueStatusID;
175 //Machine Idle
176 - (double)currentMachineIdle;
178 //State menu support
179 - (void)registerStateMenuPlugin:(id <StateMenuPlugin>)stateMenuPlugin;
180 - (void)unregisterStateMenuPlugin:(id <StateMenuPlugin>)stateMenuPlugin;
181 - (void)rebuildAllStateMenus;
182 - (void)rebuildAllStateMenusForPlugin:(id <StateMenuPlugin>)stateMenuPlugin;
183 - (void)updateAllStateMenuSelections;
184 - (void)updateStateMenuSelectionForPlugin:(id <StateMenuPlugin>)stateMenuPlugin;
185 - (void)plugin:(id <StateMenuPlugin>)stateMenuPlugin didAddMenuItems:(NSArray *)addedMenuItems;
186 - (void)removeAllMenuItemsForPlugin:(id <StateMenuPlugin>)stateMenuPlugin;
187 - (void)setDelayStateMenuUpdates:(BOOL)shouldDelay;
189 - (NSMenu *)statusStatesMenu;
192 @end