* Fixed the objectSpecifier of `AIStatusItem`s to be based on the unique ID rather...
[adiumx.git] / Source / AIAccountMenuAccessPlugin.m
blobf0cb286b642972ea94f165da0c683964f977bb47
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 <Adium/AIAccountControllerProtocol.h>
18 #import "AIAccountMenuAccessPlugin.h"
19 #import <Adium/AIMenuControllerProtocol.h>
20 #import <Adium/AIAccountMenu.h>
21 #import <Adium/AIAccount.h>
22 #import <AIUtilities/AIStringAdditions.h>
23 #import <AIUtilities/AIMenuAdditions.h>
25 #import "AIGuestAccountWindowController.h"
27 /*!
28  * @class AIAccountMenuAccessPlugin
29  * @brief Provide menu access to account connection/disconnect
30  */
31 @implementation AIAccountMenuAccessPlugin
33 /*!
34  * @brief Install the plugin
35  */
36 - (void)installPlugin
38         accountMenu = [[AIAccountMenu accountMenuWithDelegate:self submenuType:AIAccountOptionsSubmenu showTitleVerbs:YES] retain];
39         
40         NSMenuItem      *menuItem = [[NSMenuItem alloc] initWithTitle:[AILocalizedString(@"Connect a Guest Account", "Menu item title which opens the window for adding and connecting a guest (temporary) account") stringByAppendingEllipsis]
41                                                                                                            target:self
42                                                                                                            action:@selector(showGuestAccountWindow:)
43                                                                                                 keyEquivalent:@""];
44         [[adium menuController] addMenuItem:menuItem toLocation:LOC_File_Additions];
45         [menuItem release];
48 /*!
49  * @brief Uninstall Plugin
50  */
51 - (void)uninstallPlugin
53         [accountMenu release];
56 /*!
57  * @brief Add account menu items to our location
58  *
59  * Implemented as required by the AccountMenuPlugin protocol.
60  *
61  * @param menuItemArray An <tt>NSArray</tt> of <tt>NSMenuItem</tt> objects to be added to the menu
62  */
63 - (void)accountMenu:(AIAccountMenu *)inAccountMenu didRebuildMenuItems:(NSArray *)menuItems
65         NSEnumerator    *enumerator;
66         NSMenuItem              *menuItem;
68         //Remove any existing menu items
69         enumerator = [installedMenuItems objectEnumerator];
70     while ((menuItem = [enumerator nextObject])) { 
71                 [[adium menuController] removeMenuItem:menuItem];
72     }
73         
74         //Add the new menu items
75         enumerator = [menuItems objectEnumerator];
76     while ((menuItem = [enumerator nextObject])) {
77                 [[adium menuController] addMenuItem:menuItem toLocation:LOC_File_Accounts];
78     }
79         
80         //Remember the installed items so we can remove them later
81         [installedMenuItems release]; 
82         installedMenuItems = [menuItems retain];
84 - (void)accountMenu:(AIAccountMenu *)inAccountMenu didSelectAccount:(AIAccount *)inAccount {
85         [inAccount toggleOnline];
88 - (BOOL)accountMenuShouldIncludeAddAccountsMenu:(AIAccountMenu *)inAccountMenu
90         return YES;
93 - (BOOL)accountMenuShouldIncludeDisabledAccountsMenu:(AIAccountMenu *)inAccountMenu
95         return YES;
98 - (BOOL)accountMenuShouldIncludeConnectAllMenuItem:(AIAccountMenu *)inAccountMenu
100         return YES;
103 #pragma mark Guest account access
104 - (void)showGuestAccountWindow:(id)sender
106         [AIGuestAccountWindowController showGuestAccountWindow];
109 @end