Adium

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  
    1515 */ 
    1616 
    1717#import <Cocoa/Cocoa.h> 
     18#import "AIAdium.h" 
    1819 
    1920typedef enum{ 
    2021        XML_STATE_NONE, 
     
    2425        XML_STATE_STATUS_MESSAGE 
    2526} chatLogState; 
    2627 
     28@protocol AIAdium; 
     29 
    2730@interface GBChatlogHTMLConverter : NSObject { 
    2831        CFXMLParserRef  parser; 
    2932        NSString                *inputFileString; 
     
    3235        chatLogState    state; 
    3336        NSString                *sender; 
    3437        NSString                *mySN; 
     38        NSString                *service; 
    3539        NSCalendarDate  *date; 
    3640        int                             messageStart; 
    3741        BOOL                    autoResponse; 
     
    3943         
    4044        NSMutableString *output; 
    4145        NSDictionary    *statusLookup; 
     46         
     47        NSObject<AIAdium> *adium; 
    4248} 
    4349 
    4450+ (NSString *)readFile:(NSString *)filePath; 
  • Source/GBChatlogHTMLConverter.m

    old new  
    1717#import "GBChatlogHTMLConverter.h" 
    1818#import <AIUtilities/NSCalendarDate+ISO8601Parsing.h> 
    1919#import <AIUtilities/AIDateFormatterAdditions.h> 
     20#import <Adium/AIListContact.h> 
     21#import "AIStandardListWindowController.h" 
    2022 
    2123static void *createStructure(CFXMLParserRef parser, CFXMLNodeRef node, void *context); 
    2224static void addChild(CFXMLParserRef parser, void *parent, void *child, void *context); 
     
    4749        parser = NULL; 
    4850        status = nil; 
    4951         
     52        adium = [AIObject sharedAdiumInstance]; 
     53         
    5054        statusLookup = [[NSDictionary alloc] initWithObjectsAndKeys: 
    5155                AILocalizedString(@"Online", nil), @"online", 
    5256                AILocalizedString(@"Offline", nil), @"offline", 
     
    127131                        if([name isEqualToString:@"chat"]) 
    128132                        { 
    129133                                mySN = [[attributes objectForKey:@"account"] retain]; 
     134                                service = [[attributes objectForKey:@"service"] retain]; 
     135 
    130136                                state = XML_STATE_CHAT; 
    131137                        } 
    132138                        break; 
     
    197203                                NSString *message = nil; 
    198204                                if(!empty) 
    199205                                        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                                } 
    200234                                //NSLog(@"%i: %i, %i - %i - 11 = %i; %@",empty,messageStart,end,messageStart, end - messageStart - 11,message); 
    201235                                [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, 
    203237                                        [date descriptionWithCalendarFormat:[NSDateFormatter localizedDateFormatStringShowingSeconds:YES 
    204238                                                                                                                                                                                                   showingAMorPM:YES] 
    205239                                                                                           timeZone:nil 
    206                                                                                                 locale:nil], 
    207                                         sender,  
     240                                                                                          locale:nil], 
     241                                        shownSender,  
    208242                                        (autoResponse ? AILocalizedString(@" (Autoreply)",nil) : @""), 
    209243                                        message]; 
    210244                                state = XML_STATE_CHAT;