adium 3650:50dc6de6048f: Use the topic of an multi-user bookmark...
commits at adium.im
commits at adium.im
Sun Feb 13 00:20:02 UTC 2011
details: http://hg.adium.im/adium/rev/50dc6de6048f
revision: 3650:50dc6de6048f
author: Thijs Alkemade <thijsalkemade at gmail.com>
date: Sun Feb 13 01:16:33 2011 +0100
Use the topic of an multi-user bookmark as the status.
The number of unread messages/mentions is now listed in a seperate line on the tooltip.
Fixes #13928
diffs (418 lines):
diff -r 07b903e771ff -r 50dc6de6048f Adium.xcodeproj/project.pbxproj
--- a/Adium.xcodeproj/project.pbxproj Fri Feb 11 22:27:01 2011 -0500
+++ b/Adium.xcodeproj/project.pbxproj Sun Feb 13 01:16:33 2011 +0100
@@ -1439,6 +1439,7 @@
6EC1684D06C170A000F9FAD3 /* DCInviteToChatPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 6EC1684806C170A000F9FAD3 /* DCInviteToChatPlugin.m */; };
6EC1684F06C170A000F9FAD3 /* DCInviteToChatWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6EC1684A06C170A000F9FAD3 /* DCInviteToChatWindowController.m */; };
6EC1685006C170A000F9FAD3 /* InviteToChatWindow.nib in Resources */ = {isa = PBXBuildFile; fileRef = 6EC1684B06C170A000F9FAD3 /* InviteToChatWindow.nib */; };
+ 766ABAB61306D1020049FFB7 /* AIUnreadMessagesTooltip.m in Sources */ = {isa = PBXBuildFile; fileRef = 766ABAB51306D1020049FFB7 /* AIUnreadMessagesTooltip.m */; };
76889DEB12D3CA17007AEF00 /* GetInfo.png in Resources */ = {isa = PBXBuildFile; fileRef = 76889DEA12D3CA17007AEF00 /* GetInfo.png */; };
76889DEF12D3CA40007AEF00 /* Personal.png in Resources */ = {isa = PBXBuildFile; fileRef = 76889DEE12D3CA40007AEF00 /* Personal.png */; };
76C1AF9C125A906A00D269A9 /* AIAdiumURLProtocol.m in Sources */ = {isa = PBXBuildFile; fileRef = 76C1AF9B125A906A00D269A9 /* AIAdiumURLProtocol.m */; };
@@ -4707,6 +4708,8 @@
6FB330A20C7235BF00B001A8 /* EKEzvIncomingFileTransfer.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = EKEzvIncomingFileTransfer.m; path = Plugins/Bonjour/libezv/Classes/EKEzvIncomingFileTransfer.m; sourceTree = SOURCE_ROOT; };
6FB330A30C7235BF00B001A8 /* EKEzvOutgoingFileTransfer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = EKEzvOutgoingFileTransfer.h; path = Plugins/Bonjour/libezv/Classes/EKEzvOutgoingFileTransfer.h; sourceTree = SOURCE_ROOT; };
6FB330A40C7235BF00B001A8 /* EKEzvOutgoingFileTransfer.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = EKEzvOutgoingFileTransfer.m; path = Plugins/Bonjour/libezv/Classes/EKEzvOutgoingFileTransfer.m; sourceTree = SOURCE_ROOT; };
+ 766ABAB41306D1020049FFB7 /* AIUnreadMessagesTooltip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIUnreadMessagesTooltip.h; path = Source/AIUnreadMessagesTooltip.h; sourceTree = "<group>"; };
+ 766ABAB51306D1020049FFB7 /* AIUnreadMessagesTooltip.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AIUnreadMessagesTooltip.m; path = Source/AIUnreadMessagesTooltip.m; sourceTree = "<group>"; };
76889DEA12D3CA17007AEF00 /* GetInfo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = GetInfo.png; path = Resources/GetInfo.png; sourceTree = "<group>"; };
76889DEE12D3CA40007AEF00 /* Personal.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Personal.png; path = Resources/Personal.png; sourceTree = "<group>"; };
76C1AF9A125A906A00D269A9 /* AIAdiumURLProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIAdiumURLProtocol.h; path = "Plugins/WebKit Message View/AIAdiumURLProtocol.h"; sourceTree = "<group>"; };
@@ -5981,6 +5984,8 @@
347E7AA807CAF8EE00350507 /* SAContactOnlineForPlugin.m */,
112B49080F82FB1700690E84 /* AIGroupChatStatusTooltipPlugin.h */,
112B49090F82FB1700690E84 /* AIGroupChatStatusTooltipPlugin.m */,
+ 766ABAB41306D1020049FFB7 /* AIUnreadMessagesTooltip.h */,
+ 766ABAB51306D1020049FFB7 /* AIUnreadMessagesTooltip.m */,
);
name = Tooltips;
sourceTree = "<group>";
@@ -9609,7 +9614,6 @@
};
buildConfigurationList = DADE8E3A085507450062B664 /* Build configuration list for PBXProject "Adium" */;
compatibilityVersion = "Xcode 3.1";
- developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
en,
@@ -10755,6 +10759,7 @@
349062A2127F7E6900FC313F /* AITemporaryIRCAccountWindowController.m in Sources */,
5A80508512BE9F00007CDC1B /* scandate.m in Sources */,
1154F50B12E1476900B8CA27 /* AILogByAccountWindowController.m in Sources */,
+ 766ABAB61306D1020049FFB7 /* AIUnreadMessagesTooltip.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff -r 07b903e771ff -r 50dc6de6048f Frameworks/Adium Framework/Source/AIChat.h
--- a/Frameworks/Adium Framework/Source/AIChat.h Fri Feb 11 22:27:01 2011 -0500
+++ b/Frameworks/Adium Framework/Source/AIChat.h Sun Feb 13 01:16:33 2011 +0100
@@ -40,6 +40,9 @@
#define KEY_CHAT_TIMED_OUT @"Timed Out"
#define KEY_CHAT_CLOSED_WINDOW @"Closed Window"
+#define KEY_TOPIC @"topic"
+#define KEY_TOPIC_SETTER @"topicSetter"
+
typedef enum {
AIChatTimedOut = 0,
AIChatClosedWindow
@@ -104,9 +107,6 @@
BOOL hasSentOrReceivedContent;
NSMutableArray *pendingOutgoingContentObjects;
-
- NSString *topic;
- AIListContact *topicSetter;
BOOL hideUserIconAndStatus;
BOOL showJoinLeave;
@@ -148,6 +148,9 @@
NSDictionary *securityDetails;
BOOL secureMessagingLastEncryptedState;
+
+ NSString *topic;
+ AIListContact *topicSetter;
}
+ (id)chatForAccount:(AIAccount *)inAccount;
@@ -218,8 +221,6 @@
@property (readwrite, nonatomic) BOOL hideUserIconAndStatus;
@property (readonly, nonatomic) BOOL supportsTopic;
- at property (readwrite, retain, nonatomic) NSString *topic;
- at property (readwrite, retain, nonatomic) AIListContact *topicSetter;
- (void)updateTopic:(NSString *)inTopic withSource:(AIListContact *)contact;
diff -r 07b903e771ff -r 50dc6de6048f Frameworks/Adium Framework/Source/AIChat.m
--- a/Frameworks/Adium Framework/Source/AIChat.m Fri Feb 11 22:27:01 2011 -0500
+++ b/Frameworks/Adium Framework/Source/AIChat.m Sun Feb 13 01:16:33 2011 +0100
@@ -76,8 +76,6 @@
hasSentOrReceivedContent = NO;
showJoinLeave = YES;
pendingOutgoingContentObjects = [[NSMutableArray alloc] init];
-
- topic = @"";
AILog(@"[AIChat: %x initForAccount]",self);
}
@@ -102,7 +100,6 @@
[pendingOutgoingContentObjects release];
[uniqueChatID release]; uniqueChatID = nil;
[customEmoticons release]; customEmoticons = nil;
- [topic release]; [topicSetter release];
[tabStateIcon release]; tabStateIcon = nil;
[chatCreationInfo release]; chatCreationInfo = nil;
@@ -807,7 +804,7 @@
#pragma mark Group Chats
- at synthesize isGroupChat, showJoinLeave, hideUserIconAndStatus, topic, topicSetter;
+ at synthesize isGroupChat, showJoinLeave, hideUserIconAndStatus;
/*!
* @brief Does this chat support topics?
@@ -822,20 +819,19 @@
*/
- (void)updateTopic:(NSString *)inTopic withSource:(AIListContact *)contact
{
- [topic release];
- topic = [inTopic retain];
+ [self setValue:inTopic forProperty:KEY_TOPIC notify:NotifyNow];
- self.topicSetter = contact;
+ [self setValue:contact forProperty:KEY_TOPIC_SETTER notify:NotifyNow];
// Apply the new topic to the message view
AIContentTopic *contentTopic = [AIContentTopic topicInChat:self
withSource:contact
destination:nil
date:[NSDate date]
- message:[NSAttributedString stringWithString:topic ?: @""]];
+ message:[NSAttributedString stringWithString:[self valueForProperty:KEY_TOPIC] ?: @""]];
// The content controller has huge problems with blank messages being let through.
- if (!topic.length) {
+ if (![[self valueForProperty:KEY_TOPIC] length]) {
contentTopic.message = CONTENT_TOPIC_MESSAGE_ACTUALLY_EMPTY;
contentTopic.actuallyBlank = YES;
}
@@ -850,11 +846,11 @@
{
if (self.supportsTopic) {
// We mess with the topic, replacing nbsp with spaces; make sure we're not setting an identical one other than this.
- NSString *tempTopic = [topic stringByReplacingOccurrencesOfString:@"\u00A0" withString:@" "];
+ NSString *tempTopic = [[self valueForProperty:KEY_TOPIC] stringByReplacingOccurrencesOfString:@"\u00A0" withString:@" "];
if ([tempTopic isEqualToString:inTopic]) {
AILogWithSignature(@"Not setting topic for %@, already the same.", self);
} else {
- AILogWithSignature(@"Setting %@ topic to: %@", self, topic);
+ AILogWithSignature(@"Setting %@ topic to: %@", self, [self valueForProperty:KEY_TOPIC]);
[account setTopic:inTopic forChat:self];
}
} else {
diff -r 07b903e771ff -r 50dc6de6048f Frameworks/Adium Framework/Source/AIListBookmark.h
--- a/Frameworks/Adium Framework/Source/AIListBookmark.h Fri Feb 11 22:27:01 2011 -0500
+++ b/Frameworks/Adium Framework/Source/AIListBookmark.h Sun Feb 13 01:16:33 2011 +0100
@@ -10,6 +10,8 @@
#import <Adium/AIChatControllerProtocol.h>
#define KEY_AUTO_JOIN @"Automatically Join"
+#define KEY_UNREAD_STATUS @"Unread Status"
+
#define GROUP_LIST_BOOKMARK @"List Bookmark Settings"
@class AIChat;
diff -r 07b903e771ff -r 50dc6de6048f Frameworks/Adium Framework/Source/AIListBookmark.m
--- a/Frameworks/Adium Framework/Source/AIListBookmark.m Fri Feb 11 22:27:01 2011 -0500
+++ b/Frameworks/Adium Framework/Source/AIListBookmark.m Sun Feb 13 01:16:33 2011 +0100
@@ -30,6 +30,8 @@
- (void)restoreGrouping;
- (void)claimChatIfOurs:(AIChat *)chat;
+
+- (void)_updateUnreadMessagesStatusForChat:(AIChat *)inChat;
@end
@implementation AIListBookmark
@@ -80,6 +82,12 @@
dictionary:inChat.chatCreationDictionary
name:inChat.name])) {
[self setDisplayName:inChat.displayName];
+
+ if ([inChat valueForProperty:KEY_TOPIC]) {
+ [self setStatusMessage:[NSAttributedString stringWithString:[inChat valueForProperty:KEY_TOPIC]] notify:NotifyNow];
+ }
+
+ [self _updateUnreadMessagesStatusForChat:inChat];
}
return self;
@@ -365,40 +373,48 @@
- (NSSet *)updateChat:(AIChat *)inChat keys:(NSSet *)inModifiedKeys silent:(BOOL)silent
{
- if ([self chatIsOurs:inChat] && ([inModifiedKeys containsObject:KEY_UNVIEWED_CONTENT] || [inModifiedKeys containsObject:KEY_UNVIEWED_MENTION])) {
- NSString *statusMessage = nil;
+ if ([self chatIsOurs:inChat]) {
- if (inChat.unviewedMentionCount) {
- // We contain mentions; display both this and the content count.
- if (inChat.unviewedMentionCount > 1) {
- statusMessage = [NSString stringWithFormat:AILocalizedString(@"%d mentions, %d messages", "Status message for a bookmark (>1 mention, >1 messages)"),
- inChat.unviewedMentionCount, inChat.unviewedContentCount];
- } else if (inChat.unviewedContentCount > 1) {
- statusMessage = [NSString stringWithFormat:AILocalizedString(@"1 mention, %d messages", "Status message for a bookmark (1 mention, >1 messages)"),
- inChat.unviewedContentCount];
- } else {
- statusMessage = AILocalizedString(@"1 mention, 1 message", "Status message for a bookmark (1 mention, 1 message)");
- }
- } else if (inChat.unviewedContentCount) {
- // We don't contain mentions; display the content count.
- if (inChat.unviewedContentCount > 1) {
- statusMessage = [NSString stringWithFormat:AILocalizedString(@"%d messages", "Status message for a bookmark (>1 messages)"),
- inChat.unviewedContentCount];
- } else {
- statusMessage = AILocalizedString(@"1 message", "Status message for a bookmark (1 message)");
- }
+ if ([inModifiedKeys containsObject:KEY_TOPIC]) {
+ [self setStatusMessage:[NSAttributedString stringWithString:([inChat valueForProperty:KEY_TOPIC] ?: @"")] notify:NotifyNow];
}
-
- if (statusMessage) {
- [self setStatusMessage:[NSAttributedString stringWithString:statusMessage] notify:NotifyNow];
- } else {
- [self setStatusMessage:nil notify:NotifyNow];
+
+ if ([inModifiedKeys containsObject:KEY_UNVIEWED_CONTENT] || [inModifiedKeys containsObject:KEY_UNVIEWED_MENTION]) {
+ [self _updateUnreadMessagesStatusForChat:inChat];
}
}
return nil;
}
+- (void)_updateUnreadMessagesStatusForChat:(AIChat *)inChat
+{
+ NSString *statusMessage = nil;
+
+ if (inChat.unviewedMentionCount) {
+ // We contain mentions; display both this and the content count.
+ if (inChat.unviewedMentionCount > 1) {
+ statusMessage = [NSString stringWithFormat:AILocalizedString(@"%d mentions, %d messages", "Status message for a bookmark (>1 mention, >1 messages)"),
+ inChat.unviewedMentionCount, inChat.unviewedContentCount];
+ } else if (inChat.unviewedContentCount > 1) {
+ statusMessage = [NSString stringWithFormat:AILocalizedString(@"1 mention, %d messages", "Status message for a bookmark (1 mention, >1 messages)"),
+ inChat.unviewedContentCount];
+ } else {
+ statusMessage = AILocalizedString(@"1 mention, 1 message", "Status message for a bookmark (1 mention, 1 message)");
+ }
+ } else if (inChat.unviewedContentCount) {
+ // We don't contain mentions; display the content count.
+ if (inChat.unviewedContentCount > 1) {
+ statusMessage = [NSString stringWithFormat:AILocalizedString(@"%d messages", "Status message for a bookmark (>1 messages)"),
+ inChat.unviewedContentCount];
+ } else {
+ statusMessage = AILocalizedString(@"1 message", "Status message for a bookmark (1 message)");
+ }
+ }
+
+ [self setValue:statusMessage forProperty:KEY_UNREAD_STATUS notify:NotifyNow];
+}
+
#pragma mark -
- (NSString *)description
{
diff -r 07b903e771ff -r 50dc6de6048f Plugins/WebKit Message View/AIWebKitMessageViewController.m
--- a/Plugins/WebKit Message View/AIWebKitMessageViewController.m Fri Feb 11 22:27:01 2011 -0500
+++ b/Plugins/WebKit Message View/AIWebKitMessageViewController.m Sun Feb 13 01:16:33 2011 +0100
@@ -746,10 +746,10 @@
*/
- (void)updateTopic
{
- NSAttributedString *topic = [NSAttributedString stringWithString:(chat.topic ?: @"")];
+ NSAttributedString *topic = [NSAttributedString stringWithString:([chat valueForProperty:@"Topic"] ?: @"")];
AIContentTopic *contentTopic = [AIContentTopic topicInChat:chat
- withSource:chat.topicSetter
+ withSource:[chat valueForProperty:KEY_TOPIC_SETTER]
destination:nil
date:[NSDate date]
message:topic];
diff -r 07b903e771ff -r 50dc6de6048f Source/AIContactAwayPlugin.m
--- a/Source/AIContactAwayPlugin.m Fri Feb 11 22:27:01 2011 -0500
+++ b/Source/AIContactAwayPlugin.m Sun Feb 13 01:16:33 2011 +0100
@@ -19,6 +19,7 @@
#import "AIStatusController.h"
#import <Adium/AIListObject.h>
#import <AIUtilities/AIAttributedStringAdditions.h>
+#import <Adium/AIListBookmark.h>
#define AWAY AILocalizedString(@"Away",nil)
#define AWAY_MESSAGE_LABEL AILocalizedString(@"Away Message",nil)
@@ -78,9 +79,14 @@
//Get the status message
statusMessage = inObject.statusMessage;
- //Return the correct string
- if(statusMessage != nil && [statusMessage length] != 0){
- if (away) {
+ //Return the correct string
+ if (statusMessage != nil && [statusMessage length] != 0) {
+ if ([inObject isKindOfClass:[AIListBookmark class]]) {
+ /* It's actually a bookmark, show "Topic: " instead */
+
+ label = AILocalizedString(@"Topic", nil);
+
+ } else if (away) {
/* Away with a status message */
//Check to make sure we're not duplicating server display name information
diff -r 07b903e771ff -r 50dc6de6048f Source/AICoreComponentLoader.m
--- a/Source/AICoreComponentLoader.m Fri Feb 11 22:27:01 2011 -0500
+++ b/Source/AICoreComponentLoader.m Sun Feb 13 01:16:33 2011 +0100
@@ -155,6 +155,7 @@
@"AIGroupChatStatusTooltipPlugin",
@"AIRealNameTooltip",
@"AIUserHostTooltip",
+ @"AIUnreadMessagesTooltip",
@"AIIRCChannelLinker",
@"AIURLHandlerPlugin",
@"AIJumpControlPlugin",
diff -r 07b903e771ff -r 50dc6de6048f Source/AIUnreadMessagesTooltip.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Source/AIUnreadMessagesTooltip.h Sun Feb 13 01:16:33 2011 +0100
@@ -0,0 +1,24 @@
+/*
+ * Adium is the legal property of its developers, whose names are listed in the copyright file included
+ * with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program; if not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#import <Adium/AIInterfaceControllerProtocol.h>
+
+
+ at interface AIUnreadMessagesTooltip : AIPlugin <AIContactListTooltipEntry> {
+
+}
+
+ at end
diff -r 07b903e771ff -r 50dc6de6048f Source/AIUnreadMessagesTooltip.m
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Source/AIUnreadMessagesTooltip.m Sun Feb 13 01:16:33 2011 +0100
@@ -0,0 +1,63 @@
+/*
+ * Adium is the legal property of its developers, whose names are listed in the copyright file included
+ * with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program; if not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#import "AIUnreadMessagesTooltip.h"
+#import <AIUtilities/AIAttributedStringAdditions.h>
+#import <Adium/AIGroupChatStatusIcons.h>
+#import <Adium/AIChatControllerProtocol.h>
+#import <Adium/AIChat.h>
+#import <Adium/AIListBookmark.h>
+
+ at implementation AIUnreadMessagesTooltip
+
+- (void)installPlugin
+{
+ [adium.interfaceController registerContactListTooltipEntry:self secondaryEntry:YES];
+}
+
+- (void)uninstallPlugin
+{
+ [adium.interfaceController unregisterContactListTooltipEntry:self secondaryEntry:YES];
+}
+
+- (NSString *)labelForObject:(AIListObject *)inObject
+{
+ NSString *label = nil;
+
+ if ([inObject isKindOfClass:[AIListBookmark class]] && [inObject valueForProperty:KEY_UNREAD_STATUS]) {
+ label = AILocalizedString(@"Unread messages", nil);
+ }
+
+ return label;
+}
+
+- (NSAttributedString *)entryForObject:(AIListObject *)inObject
+{
+ NSAttributedString *entry = nil;
+
+ if ([inObject isKindOfClass:[AIListBookmark class]] && [inObject valueForProperty:KEY_UNREAD_STATUS]) {
+ entry = [NSAttributedString stringWithString:[inObject valueForProperty:KEY_UNREAD_STATUS]];
+ }
+
+ return entry;
+}
+
+- (BOOL)shouldDisplayInContactInspector
+{
+ return NO;
+}
+
+ at end
More information about the commits
mailing list