Reverted ESFileTransfer in adium-0.8 to [14253]; we simply won't draw the arrow if...
[adiumx.git] / Source / ESDebugController.m
blobac1213e554e5655487c5ba72f79974d4adde66a4
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 "AIMenuController.h"
18 #import "AIPreferenceController.h"
19 #import "ESDebugController.h"
20 #import "ESDebugWindowController.h"
21 #import <AIUtilities/AIMenuAdditions.h>
23 #define CACHED_DEBUG_LOGS               100             //Number of logs to keep at any given time
24 #define KEY_DEBUG_WINDOW_OPEN   @"Debug Window Open"
25 #define GROUP_DEBUG                             @"Debug Group"
27 @implementation ESDebugController
29 #ifdef DEBUG_BUILD
31 static ESDebugController        *sharedDebugController = nil;
33 - (void)initController
35         sharedDebugController = self;
36         
37         //Contact list menu tem
38     NSMenuItem *menuItem = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:AILocalizedString(@"Debug Window",nil)
39                                                                                                                                                                 target:self
40                                                                                                                                                                 action:@selector(showDebugWindow:)
41                                                                                                                                                  keyEquivalent:@""];
42         [[adium menuController] addMenuItem:menuItem toLocation:LOC_Adium_About];
43         [menuItem release];
45         debugLogArray = [[NSMutableArray alloc] init];
46         
47         //Restore the debug window if it was open when we quit last time
48         if ([[[adium preferenceController] preferenceForKey:KEY_DEBUG_WINDOW_OPEN
49                                                                                                   group:GROUP_DEBUG] boolValue]){
50                 [ESDebugWindowController showDebugWindow];
51         }
54 - (void)closeController
56         //Save the open state of the debug window
57         [[adium preferenceController] setPreference:([ESDebugWindowController debugWindowIsOpen] ?
58                                                                                                  [NSNumber numberWithBool:YES] :
59                                                                                                  nil)
60                                                                                  forKey:KEY_DEBUG_WINDOW_OPEN
61                                                                                   group:GROUP_DEBUG];
62         [ESDebugWindowController closeDebugWindow];
65 + (ESDebugController *)sharedDebugController
67         return sharedDebugController;
70 - (void)dealloc
72         [debugLogArray release];
73         sharedDebugController = nil;
74         [super dealloc];
77 - (void)showDebugWindow:(id)sender
79         [NSApp activateIgnoringOtherApps:YES];
80         [ESDebugWindowController showDebugWindow];
83 - (void)addMessage:(NSString *)actualMessage
85         [debugLogArray addObject:actualMessage];
86         
87         //Keep debugLogArray to a reasonable size
88         if ([debugLogArray count] > CACHED_DEBUG_LOGS) [debugLogArray removeObjectAtIndex:0];
89         
90         [ESDebugWindowController addedDebugMessage:actualMessage];
93 - (NSArray *)debugLogArray
95         return(debugLogArray);
98 #else
99         - (void)initController {};
100         - (void)closeController {};
101 #endif /* DEBUG_BUILD */
103 @end