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 "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
31 static ESDebugController *sharedDebugController = nil;
33 - (void)initController
35 sharedDebugController = self;
37 //Contact list menu tem
38 NSMenuItem *menuItem = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:AILocalizedString(@"Debug Window",nil)
40 action:@selector(showDebugWindow:)
42 [[adium menuController] addMenuItem:menuItem toLocation:LOC_Adium_About];
45 debugLogArray = [[NSMutableArray alloc] init];
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];
54 - (void)closeController
56 //Save the open state of the debug window
57 [[adium preferenceController] setPreference:([ESDebugWindowController debugWindowIsOpen] ?
58 [NSNumber numberWithBool:YES] :
60 forKey:KEY_DEBUG_WINDOW_OPEN
62 [ESDebugWindowController closeDebugWindow];
65 + (ESDebugController *)sharedDebugController
67 return sharedDebugController;
72 [debugLogArray release];
73 sharedDebugController = nil;
77 - (void)showDebugWindow:(id)sender
79 [NSApp activateIgnoringOtherApps:YES];
80 [ESDebugWindowController showDebugWindow];
83 - (void)addMessage:(NSString *)actualMessage
85 [debugLogArray addObject:actualMessage];
87 //Keep debugLogArray to a reasonable size
88 if ([debugLogArray count] > CACHED_DEBUG_LOGS) [debugLogArray removeObjectAtIndex:0];
90 [ESDebugWindowController addedDebugMessage:actualMessage];
93 - (NSArray *)debugLogArray
95 return(debugLogArray);
99 - (void)initController {};
100 - (void)closeController {};
101 #endif /* DEBUG_BUILD */