adium 3344:dc4039a09c76: Patch from Albert Zeyer to add support ...
commits at adium.im
commits at adium.im
Tue Sep 28 22:07:17 UTC 2010
details: http://hg.adium.im/adium/rev/dc4039a09c76
revision: 3344:dc4039a09c76
author: Frank Dowsett <wixardy at adium.im>
date: Tue Sep 28 18:06:11 2010 -0400
Patch from Albert Zeyer to add support for staying in a chat when the window is closed. Fixes #12068
diffs (526 lines):
diff -r 66c25ac8eecc -r dc4039a09c76 Copyright.txt
--- a/Copyright.txt Sat Sep 25 08:20:37 2010 -0400
+++ b/Copyright.txt Tue Sep 28 18:06:11 2010 -0400
@@ -97,5 +97,6 @@
Jay Weatherstone
Robby Weinberg
Ofri Wolfus
+Albert Zeyer
-If you have contributed to Adium and are not on this list, please contact us.
\ No newline at end of file
+If you have contributed to Adium and are not on this list, please contact us.
diff -r 66c25ac8eecc -r dc4039a09c76 Frameworks/Adium Framework/Source/AIContactControllerProtocol.h
--- a/Frameworks/Adium Framework/Source/AIContactControllerProtocol.h Sat Sep 25 08:20:37 2010 -0400
+++ b/Frameworks/Adium Framework/Source/AIContactControllerProtocol.h Tue Sep 28 18:06:11 2010 -0400
@@ -30,6 +30,7 @@
#define PREF_GROUP_NOTES @"Notes" //Preference group to store notes in
#define PREF_GROUP_ADDRESSBOOK @"Address Book"
#define PREF_GROUP_ALWAYS_VISIBLE @"Always Visible"
+#define PREF_GROUP_STAY_IN_CHAT @"Stay in chat"
#define KEY_EXPANDED @"IsExpanded"
diff -r 66c25ac8eecc -r dc4039a09c76 Frameworks/Adium Framework/Source/AIListBookmark.m
--- a/Frameworks/Adium Framework/Source/AIListBookmark.m Sat Sep 25 08:20:37 2010 -0400
+++ b/Frameworks/Adium Framework/Source/AIListBookmark.m Tue Sep 28 18:06:11 2010 -0400
@@ -353,7 +353,12 @@
[self notifyOfChangedPropertiesSilently:YES];
if (self.account.online && [[self preferenceForKey:KEY_AUTO_JOIN group:GROUP_LIST_BOOKMARK] boolValue]) {
- [self openChatWithoutActivating];
+ AIChat* chat = [self openChatWithoutActivating];
+
+ if ([self stayInChat]) {
+ // close chat will only close it from the interfacePlugin, i.e. remove the message tab
+ [adium.interfaceController closeChat:chat];
+ }
}
}
}
diff -r 66c25ac8eecc -r dc4039a09c76 Frameworks/Adium Framework/Source/AIListObject.h
--- a/Frameworks/Adium Framework/Source/AIListObject.h Sat Sep 25 08:20:37 2010 -0400
+++ b/Frameworks/Adium Framework/Source/AIListObject.h Tue Sep 28 18:06:11 2010 -0400
@@ -108,6 +108,7 @@
//Visibility
@property (readwrite, nonatomic) BOOL alwaysVisible;
+ at property (readwrite, nonatomic) BOOL stayInChat;
//Grouping
//Not recommended for most uses. Use -groups and -metaContact instead unless you really need both
diff -r 66c25ac8eecc -r dc4039a09c76 Frameworks/Adium Framework/Source/AIListObject.m
--- a/Frameworks/Adium Framework/Source/AIListObject.m Sat Sep 25 08:20:37 2010 -0400
+++ b/Frameworks/Adium Framework/Source/AIListObject.m Tue Sep 28 18:06:11 2010 -0400
@@ -34,6 +34,7 @@
#define DisplayServiceID @"DisplayServiceID"
#define FormattedUID @"FormattedUID"
#define AlwaysVisible @"AlwaysVisible"
+#define StayInChat @"StayInChat"
@interface AIListObject ()
- (void)setContainingGroup:(AIListGroup *)inGroup;
@@ -156,6 +157,27 @@
return [self boolValueForProperty:AlwaysVisible];
}
+/*!
+ * @brief Sets if the chat will stay open in the background when it's closed
+ */
+- (void)setStayInChat:(BOOL)stay
+{
+ [self setPreference:[NSNumber numberWithBool:stay]
+ forKey:StayInChat
+ group:PREF_GROUP_STAY_IN_CHAT];
+}
+
+/*!
+ * @brief Should we keep the chat around when the tab is closed?
+ *
+ * @returns If chat should stick around
+ */
+- (BOOL)stayInChat
+{
+ return [[self preferenceForKey:StayInChat group:PREF_GROUP_STAY_IN_CHAT] boolValue];
+}
+
+
//Grouping / Ownership -------------------------------------------------------------------------------------------------
#pragma mark Grouping / Ownership
diff -r 66c25ac8eecc -r dc4039a09c76 Resources/en.lproj/AIAdvancedInspectorPane.nib/classes.nib
--- a/Resources/en.lproj/AIAdvancedInspectorPane.nib/classes.nib Sat Sep 25 08:20:37 2010 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,286 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>IBClasses</key>
- <array>
- <dict>
- <key>CLASS</key>
- <string>NSApplication</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>NSResponder</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>RBSplitView</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>OUTLETS</key>
- <dict>
- <key>delegate</key>
- <string>id</string>
- </dict>
- <key>SUPERCLASS</key>
- <string>RBSplitSubview</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>NSTextField</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>NSControl</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>RBSplitSubview</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>NSView</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>NSMenu</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>NSObject</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>AIPlasticPlusButton</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>AIPlasticButton</string>
- </dict>
- <dict>
- <key>ACTIONS</key>
- <dict>
- <key>adiumPrint</key>
- <string>id</string>
- <key>didAdjustSubviews</key>
- <string>RBSplitView</string>
- <key>prefsWindowWillClose</key>
- <string>SS_PrefsController</string>
- <key>toggleFindPanel</key>
- <string>id</string>
- <key>willAdjustSubviews</key>
- <string>RBSplitView</string>
- </dict>
- <key>CLASS</key>
- <string>NSObject</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>AILocalizationButton</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>OUTLETS</key>
- <dict>
- <key>view_anchorToLeftSide</key>
- <string>NSView</string>
- <key>view_anchorToRightSide</key>
- <string>NSView</string>
- <key>window_anchorOnLeftSide</key>
- <string>NSWindow</string>
- <key>window_anchorOnRightSide</key>
- <string>NSWindow</string>
- </dict>
- <key>SUPERCLASS</key>
- <string>NSButton</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>NSWindow</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>NSResponder</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>NSScrollView</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>NSView</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>AIPlasticMinusButton</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>AIPlasticButton</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>NSView</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>NSResponder</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>NSMenuItem</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>NSObject</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>FirstResponder</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>NSObject</string>
- </dict>
- <dict>
- <key>ACTIONS</key>
- <dict>
- <key>removeSelectedGroups</key>
- <string>id</string>
- <key>selectAccount</key>
- <string>id</string>
- <key>selectedEncryptionPreference</key>
- <string>id</string>
- <key>setAutoJoin</key>
- <string>id</string>
- <key>setVisible</key>
- <string>id</string>
- </dict>
- <key>CLASS</key>
- <string>AIAdvancedInspectorPane</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>OUTLETS</key>
- <dict>
- <key>button_addGroup</key>
- <string>NSButton</string>
- <key>button_removeGroup</key>
- <string>NSButton</string>
- <key>checkBox_alwaysShow</key>
- <string>NSButton</string>
- <key>checkBox_autoJoin</key>
- <string>NSButton</string>
- <key>inspectorContentView</key>
- <string>NSView</string>
- <key>label_account</key>
- <string>NSTextField</string>
- <key>label_contact</key>
- <string>NSTextField</string>
- <key>label_encryption</key>
- <string>NSTextField</string>
- <key>popUp_accounts</key>
- <string>NSPopUpButton</string>
- <key>popUp_contact</key>
- <string>NSPopUpButton</string>
- <key>popUp_encryption</key>
- <string>NSPopUpButton</string>
- <key>tableView_groups</key>
- <string>NSTableView</string>
- </dict>
- <key>SUPERCLASS</key>
- <string>NSObject</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>NSCell</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>NSObject</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>NSButton</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>NSControl</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>AIPlasticButton</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>NSButton</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>NSPopUpButton</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>NSButton</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>NSPopUpButtonCell</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>NSMenuItemCell</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>AILocalizationTextField</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>OUTLETS</key>
- <dict>
- <key>view_anchorToLeftSide</key>
- <string>NSView</string>
- <key>view_anchorToRightSide</key>
- <string>NSView</string>
- <key>window_anchorOnLeftSide</key>
- <string>NSWindow</string>
- <key>window_anchorOnRightSide</key>
- <string>NSWindow</string>
- </dict>
- <key>SUPERCLASS</key>
- <string>NSTextField</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>NSButtonCell</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>NSActionCell</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>SS_PrefsController</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>OUTLETS</key>
- <dict>
- <key>delegate</key>
- <string>id</string>
- </dict>
- <key>SUPERCLASS</key>
- <string>NSObject</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>NSTableView</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>NSControl</string>
- </dict>
- </array>
- <key>IBVersion</key>
- <string>1</string>
-</dict>
-</plist>
diff -r 66c25ac8eecc -r dc4039a09c76 Resources/en.lproj/AIAdvancedInspectorPane.nib/info.nib
--- a/Resources/en.lproj/AIAdvancedInspectorPane.nib/info.nib Sat Sep 25 08:20:37 2010 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>IBFramework Version</key>
- <string>677</string>
- <key>IBLastKnownRelativeProjectPath</key>
- <string>../../Adium.xcodeproj</string>
- <key>IBOldestOS</key>
- <integer>5</integer>
- <key>IBOpenObjects</key>
- <array>
- <integer>67</integer>
- </array>
- <key>IBSystem Version</key>
- <string>9G55</string>
- <key>targetFramework</key>
- <string>IBCocoaFramework</string>
-</dict>
-</plist>
diff -r 66c25ac8eecc -r dc4039a09c76 Resources/en.lproj/AIAdvancedInspectorPane.nib/keyedobjects.nib
Binary file Resources/en.lproj/AIAdvancedInspectorPane.nib/keyedobjects.nib has changed
diff -r 66c25ac8eecc -r dc4039a09c76 Source/AIAdvancedInspectorPane.h
--- a/Source/AIAdvancedInspectorPane.h Sat Sep 25 08:20:37 2010 -0400
+++ b/Source/AIAdvancedInspectorPane.h Tue Sep 28 18:06:11 2010 -0400
@@ -31,6 +31,7 @@
IBOutlet NSButton *checkBox_alwaysShow;
IBOutlet NSButton *checkBox_autoJoin;
+ IBOutlet NSButton *checkBox_stayInChat;
BOOL switchingContacts;
@@ -50,6 +51,7 @@
- (IBAction)selectedEncryptionPreference:(id)sender;
- (IBAction)setVisible:(id)sender;
- (IBAction)setAutoJoin:(id)sender;
+- (IBAction)setStayInChat:(id)sender;
- (void)removeSelectedGroups:(id)sender;
@end
diff -r 66c25ac8eecc -r dc4039a09c76 Source/AIAdvancedInspectorPane.m
--- a/Source/AIAdvancedInspectorPane.m Sat Sep 25 08:20:37 2010 -0400
+++ b/Source/AIAdvancedInspectorPane.m Tue Sep 28 18:06:11 2010 -0400
@@ -123,6 +123,8 @@
[checkBox_autoJoin setEnabled:[inObject isKindOfClass:[AIListBookmark class]]];
[checkBox_autoJoin setState:[[inObject preferenceForKey:KEY_AUTO_JOIN group:GROUP_LIST_BOOKMARK] boolValue]];
+
+ [checkBox_stayInChat setState:inObject.stayInChat];
[popUp_accounts setEnabled:![inObject isKindOfClass:[AIListGroup class]]];
[popUp_contact setEnabled:![inObject isKindOfClass:[AIListGroup class]]];
@@ -150,6 +152,11 @@
group:GROUP_LIST_BOOKMARK];
}
+- (IBAction)setStayInChat:(id)sender
+{
+ [displayedObject setStayInChat:[checkBox_stayInChat state]];
+}
+
#pragma mark Menus
-(void)reloadPopup
{
diff -r 66c25ac8eecc -r dc4039a09c76 Source/AIChatController.m
--- a/Source/AIChatController.m Sat Sep 25 08:20:37 2010 -0400
+++ b/Source/AIChatController.m Tue Sep 28 18:06:11 2010 -0400
@@ -507,7 +507,7 @@
*/
- (BOOL)closeChat:(AIChat *)inChat
{
- BOOL shouldRemove;
+ BOOL shouldRemove, stayInChat;
/* If we are currently passing a content object for this chat through our content filters, don't remove it from
* our openChats set as it will become needed soon. If we were to remove it, and a second message came in which was
@@ -515,7 +515,22 @@
* chat, generating a duplicate.
*/
shouldRemove = ![adium.contentController chatIsReceivingContent:inChat];
-
+
+ {
+ AIListObject* listObject;
+
+ if (inChat.isGroupChat)
+ listObject = [adium.contactController existingBookmarkForChat:inChat];
+ else
+ listObject = inChat.listObject;
+
+ // If we want to stay in the chat keep the AIChat open
+ stayInChat = (listObject != NULL && [listObject stayInChat]);
+
+ // If we are quitting don't stay in chat
+ stayInChat &= !adium.isQuitting;
+ }
+
[inChat retain];
if (mostRecentChat == inChat) {
@@ -527,7 +542,7 @@
[[NSNotificationCenter defaultCenter] postNotificationName:Chat_WillClose object:inChat userInfo:nil];
//Remove the chat
- if (shouldRemove) {
+ if (shouldRemove && !stayInChat) {
/* If we didn't remove the chat because we're waiting for it to reopen, don't cause the account
* to close down the chat.
*/
diff -r 66c25ac8eecc -r dc4039a09c76 Source/AIContentController.m
--- a/Source/AIContentController.m Sat Sep 25 08:20:37 2010 -0400
+++ b/Source/AIContentController.m Tue Sep 28 18:06:11 2010 -0400
@@ -506,9 +506,10 @@
(![inObject isOutgoing]));
shouldPostContentReceivedEvents = contentReceived && [inObject trackContent];
- if (![chat isOpen]) {
+ if (![chat isOpen] && !chat.isGroupChat) {
/* Tell the interface to open the chat
* For incoming messages, we don't open the chat until we're sure that new content is being received.
+ * For group chats, we only open the chat for an unviewed mention. This is done in AIMentionEventPlugin.m.
*/
[adium.interfaceController openChat:chat];
}
diff -r 66c25ac8eecc -r dc4039a09c76 Source/AIMentionEventPlugin.m
--- a/Source/AIMentionEventPlugin.m Sat Sep 25 08:20:37 2010 -0400
+++ b/Source/AIMentionEventPlugin.m Tue Sep 28 18:06:11 2010 -0400
@@ -88,6 +88,13 @@
if([predicate evaluateWithObject:messageString]) {
if(message.trackContent && adium.interfaceController.activeChat != chat) {
[chat incrementUnviewedMentionCount];
+
+ if (![chat isOpen]) {
+ /* See related code at AIContentController.m in finishDisplayContentObject.
+ * We only want to open group chats if someone mentions us.
+ */
+ [adium.interfaceController openChat:chat];
+ }
}
[message addDisplayClass:@"mention"];
break;
More information about the commits
mailing list