adium 2390:9099dc0ec476: Instead of storing the pic.im informati...
commits at adium.im
commits at adium.im
Fri May 29 05:07:15 UTC 2009
details: http://hg.adium.im/adium/rev/9099dc0ec476
revision: 2390:9099dc0ec476
author: Zachary West <zacw at adium.im>
date: Fri May 29 01:07:08 2009 -0400
Instead of storing the pic.im information in the chat, store it in a single dictionary.
This way, an upload can happen in any chat, and any Tweet which includes it will reference it.
diffs (84 lines):
diff -r 9b5721fa5865 -r 9099dc0ec476 Plugins/Image Uploading Plugin/AIPicImImageUploader.m
--- a/Plugins/Image Uploading Plugin/AIPicImImageUploader.m Thu May 28 23:57:35 2009 -0400
+++ b/Plugins/Image Uploading Plugin/AIPicImImageUploader.m Fri May 29 01:07:08 2009 -0400
@@ -192,9 +192,8 @@
} else if ([[status objectForKey:@"result"] isCaseInsensitivelyEqualToString:@"ok"]) {
[uploader uploadedURL:[[trim objectForKey:@"url"] objectForKey:@"value"] forChat:chat];
- NSMutableDictionary *dict = [chat valueForProperty:@"PicImReferences"] ?: [NSMutableDictionary dictionary];
- [dict setObject:[[trim objectForKey:@"reference"] objectForKey:@"value"] forKey:[[trim objectForKey:@"url"] objectForKey:@"value"]];
- [chat setValue:dict forProperty:@"PicImReferences" notify:NotifyNever];
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"AIPicImImageAdded"
+ object:trim];
} else {
[uploader errorWithMessage:AILocalizedString(@"Unable to upload", nil) forChat:chat];
}
diff -r 9b5721fa5865 -r 9099dc0ec476 Plugins/Twitter Plugin/AITwitterStatusFollowup.h
--- a/Plugins/Twitter Plugin/AITwitterStatusFollowup.h Thu May 28 23:57:35 2009 -0400
+++ b/Plugins/Twitter Plugin/AITwitterStatusFollowup.h Fri May 29 01:07:08 2009 -0400
@@ -7,7 +7,7 @@
//
@interface AITwitterStatusFollowup : AIPlugin {
-
+ NSMutableDictionary *references;
}
@end
diff -r 9b5721fa5865 -r 9099dc0ec476 Plugins/Twitter Plugin/AITwitterStatusFollowup.m
--- a/Plugins/Twitter Plugin/AITwitterStatusFollowup.m Thu May 28 23:57:35 2009 -0400
+++ b/Plugins/Twitter Plugin/AITwitterStatusFollowup.m Fri May 29 01:07:08 2009 -0400
@@ -14,6 +14,7 @@
@interface AITwitterStatusFollowup()
- (void)twitterStatusPosted:(NSNotification *)notification;
+- (void)imageAdded:(NSNotification *)notification;
- (void)linkTweetID:(NSString *)tweetID
tweet:(NSString *)tweetText
username:(NSString *)username
@@ -24,10 +25,17 @@
@implementation AITwitterStatusFollowup
- (void)installPlugin
{
+ references = [[NSMutableDictionary alloc] init];
+
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(twitterStatusPosted:)
name:AITwitterNotificationPostedStatus
object:nil];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(imageAdded:)
+ name:@"AIPicImImageAdded"
+ object:nil];
}
- (void)uninstallPlugin
@@ -35,12 +43,26 @@
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
+- (void)dealloc
+{
+ [references release];
+
+ [super dealloc];
+}
+
+- (void)imageAdded:(NSNotification *)notification
+{
+ NSDictionary *trim = notification.object;
+
+ [references setObject:[[trim objectForKey:@"reference"] objectForKey:@"value"]
+ forKey:[[trim objectForKey:@"url"] objectForKey:@"value"]];
+}
+
- (void)twitterStatusPosted:(NSNotification *)notification
{
NSDictionary *update = notification.object;
AIChat *chat = [[notification userInfo] objectForKey:@"AIChat"];
NSString *updateText = [update objectForKey:TWITTER_STATUS_TEXT];
- NSDictionary *references = [chat valueForProperty:@"PicImReferences"];
// Don't link direct messages.
if ([updateText hasPrefix:@"d "]) {
More information about the commits
mailing list