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 <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"
28 * @class AIAccountMenuAccessPlugin
29 * @brief Provide menu access to account connection/disconnect
31 @implementation AIAccountMenuAccessPlugin
34 * @brief Install the plugin
38 accountMenu = [[AIAccountMenu accountMenuWithDelegate:self submenuType:AIAccountOptionsSubmenu showTitleVerbs:YES] retain];
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]
42 action:@selector(showGuestAccountWindow:)
44 [[adium menuController] addMenuItem:menuItem toLocation:LOC_File_Additions];
49 * @brief Uninstall Plugin
51 - (void)uninstallPlugin
53 [accountMenu release];
57 * @brief Add account menu items to our location
59 * Implemented as required by the AccountMenuPlugin protocol.
61 * @param menuItemArray An <tt>NSArray</tt> of <tt>NSMenuItem</tt> objects to be added to the menu
63 - (void)accountMenu:(AIAccountMenu *)inAccountMenu didRebuildMenuItems:(NSArray *)menuItems
65 NSEnumerator *enumerator;
68 //Remove any existing menu items
69 enumerator = [installedMenuItems objectEnumerator];
70 while ((menuItem = [enumerator nextObject])) {
71 [[adium menuController] removeMenuItem:menuItem];
74 //Add the new menu items
75 enumerator = [menuItems objectEnumerator];
76 while ((menuItem = [enumerator nextObject])) {
77 [[adium menuController] addMenuItem:menuItem toLocation:LOC_File_Accounts];
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
93 - (BOOL)accountMenuShouldIncludeDisabledAccountsMenu:(AIAccountMenu *)inAccountMenu
98 - (BOOL)accountMenuShouldIncludeConnectAllMenuItem:(AIAccountMenu *)inAccountMenu
103 #pragma mark Guest account access
104 - (void)showGuestAccountWindow:(id)sender
106 [AIGuestAccountWindowController showGuestAccountWindow];