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 "AINewMessagePromptController.h"
18 #import <Adium/AIChatControllerProtocol.h>
19 #import <Adium/AIInterfaceControllerProtocol.h>
21 #define NEW_MESSAGE_PROMPT_NIB @"NewMessagePrompt"
23 static AINewMessagePromptController *sharedNewMessageInstance = nil;
26 * @class AINewMessagePromptController
27 * @brief Controller for the New Message prompt, which allows messaging an arbitrary contact
29 @implementation AINewMessagePromptController
32 * @brief Return our shared instance
33 * @result The shared instance
37 return sharedNewMessageInstance;
41 * @brief Create the shared instance
42 * @result The shared instance
44 + (id)createSharedInstance
46 sharedNewMessageInstance = [[self alloc] initWithWindowNibName:NEW_MESSAGE_PROMPT_NIB];
48 return sharedNewMessageInstance;
52 * @brief Destroy the shared instance
54 + (void)destroySharedInstance
56 [sharedNewMessageInstance autorelease];
57 sharedNewMessageInstance = nil;
61 * @brief Window did load
65 [super windowDidLoad];
67 [label_from setLocalizedString:AILocalizedString(@"From:",nil)];
68 [label_to setLocalizedString:AILocalizedString(@"To:",nil)];
70 [button_okay setLocalizedString:AILocalizedStringFromTable(@"Message", @"Buttons", "Button title to open a message window the specific contact from the 'New Chat' window")];
72 [[self window] setTitle:AILocalizedString(@"New Message",nil)];
76 * @brief Open a chat with the desired contact
78 - (IBAction)okay:(id)sender
80 AIListContact *contact;
82 if ((contact = [self contactFromTextField])) {
83 //Initiate the message - the contact is on the right account
86 [[adium interfaceController] setActiveChat:[[adium chatController] openChatWithContact:contact
87 onPreferredAccount:NO]];
90 [[self class] closeSharedInstance];
94 - (NSString *)lastAccountIDKey
96 return @"NewMessagePrompt";