adium 4333:6e7db5aeabcc: Reviewed and acepted patch from Aragos ...
commits at adium.im
commits at adium.im
Thu Dec 1 04:21:06 UTC 2011
details: http://hg.adium.im/adium/rev/6e7db5aeabcc
revision: 4333:6e7db5aeabcc
branch: (none)
author: Stephen Holt <sholt at adium.im>
date: Wed Nov 30 20:19:10 2011 -0800
Reviewed and acepted patch from Aragos that fixes some AppleScript issues. Fixes #15234.
diffs (161 lines):
diff -r 5ed9926aff50 -r 6e7db5aeabcc Frameworks/Adium Framework/Source/AIAccount.m
--- a/Frameworks/Adium Framework/Source/AIAccount.m Thu Dec 01 00:47:31 2011 +0100
+++ b/Frameworks/Adium Framework/Source/AIAccount.m Wed Nov 30 20:19:10 2011 -0800
@@ -1152,7 +1152,8 @@
[[NSScriptCommand currentCommand] setScriptErrorString:@"Can't create a chat without a contact!"];
return nil;
}
- if (![resolvedKeyDictionary objectForKey:@"newChatWindow"] && ![resolvedKeyDictionary objectForKey:@"Location"]) {
+ if (![resolvedKeyDictionary objectForKey:@"newChatWindow"] && ![resolvedKeyDictionary objectForKey:@"Location"]
+ && ![resolvedKeyDictionary objectForKey:@"inWindow"]) {
[[NSScriptCommand currentCommand] setScriptErrorNumber:errOSACantAssign];
[[NSScriptCommand currentCommand] setScriptErrorString:@"Can't create a chat without specifying its containing window."];
return nil;
@@ -1166,16 +1167,19 @@
return nil;
}
AIMessageWindowController *chatWindowController = nil;
- NSInteger idx = -1; //at end by default
+ NSInteger index = -1; //at end by default
if ([resolvedKeyDictionary objectForKey:@"newChatWindow"]) {
//I need to put this in a new chat window
chatWindowController = [adium.interfaceController openContainerWithID:nil name:nil];
+ } else if ([resolvedKeyDictionary objectForKey:@"inWindow"]) {
+ AIMessageWindow *chatWindow = [resolvedKeyDictionary objectForKey:@"inWindow"];
+ index = [[chatWindow chats] count];
+ chatWindowController = (AIMessageWindowController *)[chatWindow windowController];
} else {
- //I need to figure out to which chat window the location specifier is referring.
- //NSLog(@"Here is the info about the location specifier: %@",[resolvedKeyDictionary objectForKey:@"Location"]);
+ //I need to figure out to which chat window the location specifier is referring.
NSPositionalSpecifier *location = [resolvedKeyDictionary objectForKey:@"Location"];
AIMessageWindow *chatWindow = [location insertionContainer];
- idx = [location insertionIndex];
+ index = [location insertionIndex];
chatWindowController = (AIMessageWindowController *)[chatWindow windowController];
}
@@ -1186,8 +1190,8 @@
}
AIChat *newChat = [adium.chatController chatWithContact:contact];
-// NSLog(@"Making new chat %@ in chat window %@:%@",newChat,chatWindowController,[chatWindowController containerID]);
- [adium.interfaceController openChat:newChat inContainerWithID:[chatWindowController containerID] atIndex:idx];
+ // NSLog(@"Making new chat %@ in chat window %@:%@",newChat,chatWindowController,[chatWindowController containerID]);
+ [adium.interfaceController openChat:newChat inContainerWithID:[chatWindowController containerID] atIndex:index];
return newChat;
} else {
if (![self.service canCreateGroupChats]) {
diff -r 5ed9926aff50 -r 6e7db5aeabcc Frameworks/Adium Framework/Source/AIChat.m
--- a/Frameworks/Adium Framework/Source/AIChat.m Thu Dec 01 00:47:31 2011 +0100
+++ b/Frameworks/Adium Framework/Source/AIChat.m Wed Nov 30 20:19:10 2011 -0800
@@ -912,12 +912,19 @@
- (NSScriptObjectSpecifier *)objectSpecifier
{
- //the chat may not be in a window! Just reference it from the application...
- //get my window
- NSScriptClassDescription *containerClassDesc = (NSScriptClassDescription *)[NSScriptClassDescription classDescriptionForClass:[NSApp class]];
+ AIMessageWindowController *windowController = self.chatContainer.windowController;
+ NSScriptClassDescription *containerClassDesc;
+ NSScriptObjectSpecifier *containerRef;
+ if (windowController) {
+ containerRef = [[windowController window] objectSpecifier];
+ containerClassDesc = [containerRef keyClassDescription];
+ } else {
+ containerClassDesc = (NSScriptClassDescription *)[NSScriptClassDescription classDescriptionForClass:[NSApp class]];
+ }
+
return [[[NSUniqueIDSpecifier allocWithZone:[self zone]]
initWithContainerClassDescription:containerClassDesc
- containerSpecifier:nil key:@"chats" uniqueID:[self uniqueChatID]] autorelease];
+ containerSpecifier:containerRef key:@"chats" uniqueID:[self uniqueChatID]] autorelease];
}
- (unsigned int)index
@@ -1037,6 +1044,16 @@
return nil;
}
+/*!
+ * @brief Applescript command to make this chat active
+ */
+- (id)goActiveScriptCommand:(NSScriptCommand *)command
+{
+ [adium.interfaceController setActiveChat:self];
+ return nil;
+}
+
+
- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len
{
return [self.containedObjects countByEnumeratingWithState:state objects:stackbuf count:len];
diff -r 5ed9926aff50 -r 6e7db5aeabcc Resources/Adium.sdef
--- a/Resources/Adium.sdef Thu Dec 01 00:47:31 2011 +0100
+++ b/Resources/Adium.sdef Wed Nov 30 20:19:10 2011 -0800
@@ -129,6 +129,9 @@
<responds-to name="send">
<cocoa method="sendScriptCommand:"/>
</responds-to>
+ <responds-to command="become active">
+ <cocoa method="goActiveScriptCommand:"/>
+ </responds-to>
</class>
<enumeration name="status types" code="Esta">
<enumerator name="offline" code="Soff" description="Account is offline."/>
@@ -339,6 +342,9 @@
<parameter name="new chat window" code="Pncw" description="If this is true, then a new chat window will be created when creating a chat." type="boolean" optional="yes">
<cocoa key="newChatWindow"/>
</parameter>
+ <parameter name="in window" code="Piwd" description="If set, will create the new chat within the passed chat window" type="chat window" optional="yes">
+ <cocoa key="inWindow"/>
+ </parameter>
<result description="to the new object" type="specifier"/>
</command>
@@ -361,6 +367,11 @@
<cocoa key="withFile"/>
</parameter>
</command>
+
+ <command name="become active" code="Adumactv" description="Set a chat to active.">
+ <cocoa class="NSScriptCommand"/>
+ <direct-parameter type="chat" description="The chat that should become active."/>
+ </command>
</suite>
<suite name="Text Suite" code="TEXT" description="A set of basic classes for text processing.">
diff -r 5ed9926aff50 -r 6e7db5aeabcc Source/AIApplication.m
--- a/Source/AIApplication.m Thu Dec 01 00:47:31 2011 +0100
+++ b/Source/AIApplication.m Wed Nov 30 20:19:10 2011 -0800
@@ -82,7 +82,7 @@
{
for (NSWindow *window in [self orderedWindows])
if ([window isKindOfClass:[AIMessageWindow class]])
- if ([window hash] == [uniqueID unsignedIntValue])
+ if ([uniqueID isEqualToNumber:[NSNumber numberWithInteger:[window windowNumber]]])
return (AIMessageWindow *)window;
return nil;
}
diff -r 5ed9926aff50 -r 6e7db5aeabcc Source/AIMessageWindow.h
--- a/Source/AIMessageWindow.h Thu Dec 01 00:47:31 2011 +0100
+++ b/Source/AIMessageWindow.h Wed Nov 30 20:19:10 2011 -0800
@@ -21,4 +21,6 @@
id rememberedScriptCommand;
}
+ at property (readonly) NSArray *chats;
+
@end
diff -r 5ed9926aff50 -r 6e7db5aeabcc Source/AIMessageWindow.m
--- a/Source/AIMessageWindow.m Thu Dec 01 00:47:31 2011 +0100
+++ b/Source/AIMessageWindow.m Wed Nov 30 20:19:10 2011 -0800
@@ -39,7 +39,7 @@
return [[[NSUniqueIDSpecifier alloc]
initWithContainerClassDescription:containerClassDesc
containerSpecifier:nil key:@"chatWindows"
- uniqueID:[NSNumber numberWithUnsignedInteger:[self hash]]] autorelease];
+ uniqueID:[NSNumber numberWithInteger:[self windowNumber]]] autorelease];
}
- (void)dealloc
More information about the commits
mailing list