Put NSAutoreleasePool usage around other distributed notification observer methods
[adiumx.git] / Source / AINewMessagePromptController.m
blob43fbf21197f6f52937bea20b16499ec4dbba32ba
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 "AINewMessagePromptController.h"
18 #import <Adium/AIChatControllerProtocol.h>
19 #import <Adium/AIInterfaceControllerProtocol.h>
21 #define NEW_MESSAGE_PROMPT_NIB  @"NewMessagePrompt"
23 static AINewMessagePromptController *sharedNewMessageInstance = nil;
25 /*!
26  * @class AINewMessagePromptController
27  * @brief Controller for the New Message prompt, which allows messaging an arbitrary contact
28  */
29 @implementation AINewMessagePromptController
31 /*!
32  * @brief Return our shared instance
33  * @result The shared instance
34  */
35 + (id)sharedInstance 
37         return sharedNewMessageInstance;
40 /*!
41  * @brief Create the shared instance
42  * @result The shared instance
43  */
44 + (id)createSharedInstance 
46         sharedNewMessageInstance = [[self alloc] initWithWindowNibName:NEW_MESSAGE_PROMPT_NIB];
47         
48         return sharedNewMessageInstance;
51 /*!
52  * @brief Destroy the shared instance
53  */
54 + (void)destroySharedInstance 
56         [sharedNewMessageInstance autorelease]; 
57         sharedNewMessageInstance = nil;
60 /*!
61  * @brief Window did load
62  */
63 - (void)windowDidLoad
65         [super windowDidLoad];
66         
67         [label_from setLocalizedString:AILocalizedString(@"From:",nil)];
68         [label_to setLocalizedString:AILocalizedString(@"To:",nil)];
69         
70         [button_okay setLocalizedString:AILocalizedStringFromTable(@"Message", @"Buttons", "Button title to open a message window the specific contact from the 'New Chat' window")];
71         
72         [[self window] setTitle:AILocalizedString(@"New Message",nil)];
75 /*!
76  * @brief Open a chat with the desired contact
77  */
78 - (IBAction)okay:(id)sender
80         AIListContact   *contact;
81         
82     if ((contact = [self contactFromTextField])) {
83         //Initiate the message - the contact is on the right account
84                 [super okay:sender];
86         [[adium interfaceController] setActiveChat:[[adium chatController] openChatWithContact:contact
87                                                                                                                                                         onPreferredAccount:NO]];
88                 
89                 //Close the prompt
90         [[self class] closeSharedInstance];
91     }
94 - (NSString *)lastAccountIDKey
96         return @"NewMessagePrompt";
99 @end