libpurple.framework 2.3.1 as before but with HAVE_OPENSSL defined, which enables...
[adiumx.git] / Source / AIMessageWindow.m
blob155b47d79b2009da34ba3de62f07f9289b598c62
1 //
2 //  AIMessageWindow.m
3 //  Adium
4 //
5 //  Created by Evan Schoenberg on 12/26/05.
6 //
8 #import "AIMessageWindow.h"
9 #import "AIClickThroughThemeDocumentButton.h"
10 #import <AIUtilities/AIApplicationAdditions.h>
11 #import "AIMessageWindowController.h"
12 #import "AIInterfaceControllerProtocol.h"
14 /*!
15  * @class AIMessageWindow
16  * @brief This AIDockingWindow subclass serves message windows.
17  *
18  * It overrides the standardWindowButton:forStyleMask: class method to provide
19  * AIClickThroughThemeDocumentButton objects for NSWindowDocumentIconButton requests on 10.4 and earlier.
20  * Delegate methods in 10.5+ handle what we need.
21  */
22 @implementation AIMessageWindow
24 - (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation
26         if (!(self = [super initWithContentRect:contentRect styleMask:styleMask backing:bufferingType defer:deferCreation]))
27                 return nil;
28         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(scriptedWindowDidClose:) name:NSWindowWillCloseNotification object:nil];
29         return self;
32 /*!
33  * @brief Return the standard window button for a mask
34  *
35  * We return AIClickThroughThemeDocumentButton instead of NSThemeDocumentButton to provide
36  * click-through dragging behavior on 10.4 and earlier.
37  */
38 + (NSButton *)standardWindowButton:(NSWindowButton)button forStyleMask:(unsigned int)styleMask
40         NSButton *standardWindowButton = [super standardWindowButton:button forStyleMask:styleMask];
42         if (![NSApp isOnLeopardOrBetter]) {
43                 if (button == NSWindowDocumentIconButton) {
44                         [NSKeyedArchiver setClassName:@"AIClickThroughThemeDocumentButton" forClass:[NSThemeDocumentButton class]];
45                         standardWindowButton = [NSKeyedUnarchiver unarchiveObjectWithData:[NSKeyedArchiver archivedDataWithRootObject:standardWindowButton]];
46                         
47                         [[standardWindowButton retain] autorelease];
48                 }
49         }
50         
51         return standardWindowButton;
54 - (NSScriptObjectSpecifier *)objectSpecifier
56         NSScriptClassDescription *containerClassDesc = (NSScriptClassDescription *)[NSScriptClassDescription classDescriptionForClass:[NSApp class]];
57         return [[NSUniqueIDSpecifier alloc]
58                         initWithContainerClassDescription:containerClassDesc
59                         containerSpecifier:nil key:@"chatWindows"
60                         uniqueID:[NSValue valueWithPointer:self]];
63 - (NSArray *)chats
65         return [(AIMessageWindowController *)[self windowController] containedChats];
68 - (id)handleCloseScriptCommand:(NSCloseCommand *)command
70         [command suspendExecution];
71         rememberedScriptCommand = command;
72         
73         //get a list of all the chats in this window
74         NSArray *chatsInThisWindow = [self chats];
75         for (int i=[chatsInThisWindow count]-1;i>=0;i--)
76                 [[[AIObject sharedAdiumInstance] interfaceController] closeChat:[chatsInThisWindow objectAtIndex:i]];
77         return nil;
79 - (void)scriptedWindowDidClose:(NSNotification *)notification
81         [rememberedScriptCommand resumeExecutionWithResult:nil];
82         rememberedScriptCommand = nil;
84 @end