Ticket #6866: ticket6866-fix-rev1.diff
| File ticket6866-fix-rev1.diff, 4.2 kB (added by CalganX, 2 years ago) |
|---|
-
Source/GBChatlogHTMLConverter.h
old new 15 15 */ 16 16 17 17 #import <Cocoa/Cocoa.h> 18 #import "AIAdium.h" 18 19 19 20 typedef enum{ 20 21 XML_STATE_NONE, … … 24 25 XML_STATE_STATUS_MESSAGE 25 26 } chatLogState; 26 27 28 @protocol AIAdium; 29 27 30 @interface GBChatlogHTMLConverter : NSObject { 28 31 CFXMLParserRef parser; 29 32 NSString *inputFileString; … … 32 35 chatLogState state; 33 36 NSString *sender; 34 37 NSString *mySN; 38 NSString *service; 35 39 NSCalendarDate *date; 36 40 int messageStart; 37 41 BOOL autoResponse; … … 39 43 40 44 NSMutableString *output; 41 45 NSDictionary *statusLookup; 46 47 NSObject<AIAdium> *adium; 42 48 } 43 49 44 50 + (NSString *)readFile:(NSString *)filePath; -
Source/GBChatlogHTMLConverter.m
old new 17 17 #import "GBChatlogHTMLConverter.h" 18 18 #import <AIUtilities/NSCalendarDate+ISO8601Parsing.h> 19 19 #import <AIUtilities/AIDateFormatterAdditions.h> 20 #import <Adium/AIListContact.h> 21 #import "AIStandardListWindowController.h" 20 22 21 23 static void *createStructure(CFXMLParserRef parser, CFXMLNodeRef node, void *context); 22 24 static void addChild(CFXMLParserRef parser, void *parent, void *child, void *context); … … 47 49 parser = NULL; 48 50 status = nil; 49 51 52 adium = [AIObject sharedAdiumInstance]; 53 50 54 statusLookup = [[NSDictionary alloc] initWithObjectsAndKeys: 51 55 AILocalizedString(@"Online", nil), @"online", 52 56 AILocalizedString(@"Offline", nil), @"offline", … … 127 131 if([name isEqualToString:@"chat"]) 128 132 { 129 133 mySN = [[attributes objectForKey:@"account"] retain]; 134 service = [[attributes objectForKey:@"service"] retain]; 135 130 136 state = XML_STATE_CHAT; 131 137 } 132 138 break; … … 197 203 NSString *message = nil; 198 204 if(!empty) 199 205 message = [inputFileString substringWithRange:NSMakeRange(messageStart, end - messageStart - 11)]; // 10 for </message> and 1 for the index being off 206 NSString *shownSender; 207 NSString *cssClass; 208 if ([mySN isEqualToString:sender]) { 209 cssClass = [NSString stringWithString:@"send"]; 210 211 AIAccount *activeAccount; 212 if ((activeAccount = [AIStandardListWindowController activeAccountForDisplayNameGettingOnlineAccounts:nil ownDisplayNameAccounts:nil])) { 213 shownSender = [NSString stringWithFormat:@"%@ (%@)", [activeAccount displayName], sender]; 214 } else { 215 NSString *displayName = [[[[adium preferenceController] preferenceForKey:KEY_ACCOUNT_DISPLAY_NAME 216 group:GROUP_ACCOUNT_STATUS] attributedString] string]; 217 if (displayName) { 218 shownSender = [NSString stringWithFormat:@"%@ (%@)", displayName, sender]; 219 } else { 220 shownSender = [NSString stringWithFormat:@"%@", sender]; 221 } 222 } 223 } else { 224 cssClass = [NSString stringWithString:@"receive"]; 225 226 AIListObject *listObject = [[adium contactController] existingListObjectWithUniqueID:[AIListObject internalObjectIDForServiceID:service 227 UID:sender]]; 228 if ((listObject) && (![[listObject displayName] isEqualToString:sender])) { 229 shownSender = [NSString stringWithFormat:@"%@ (%@)", [listObject displayName], sender]; 230 } else { 231 shownSender = [NSString stringWithString:sender]; 232 } 233 } 200 234 //NSLog(@"%i: %i, %i - %i - 11 = %i; %@",empty,messageStart,end,messageStart, end - messageStart - 11,message); 201 235 [output appendFormat:@"<div class=\"%@\"><span class=\"timestamp\">%@</span> <span class=\"sender\">%@%@: </span><pre class=\"message\">%@</pre></div>\n", 202 ([mySN isEqualToString:sender] ? @"send" : @"receive"),236 cssClass, 203 237 [date descriptionWithCalendarFormat:[NSDateFormatter localizedDateFormatStringShowingSeconds:YES 204 238 showingAMorPM:YES] 205 239 timeZone:nil 206 locale:nil],207 s ender,240 locale:nil], 241 shownSender, 208 242 (autoResponse ? AILocalizedString(@" (Autoreply)",nil) : @""), 209 243 message]; 210 244 state = XML_STATE_CHAT;