# HG changeset patch # User William Bowling # Date 1257246347 -39600 # Node ID 5c84365567910e3e29316ec212bd21bffb40b8a8 # Parent 4758aba8104ad44c683e987131e84fa3daddd9ba Cleaned up handleNotifyFormattedWithTitle diff -r 4758aba8104ad44c683e987131e84fa3daddd9ba -r 5c84365567910e3e29316ec212bd21bffb40b8a8 Plugins/Purple Service/SLPurpleCocoaAdapter.m --- a/Plugins/Purple Service/SLPurpleCocoaAdapter.m Tue Nov 03 15:33:33 2009 +1100 +++ b/Plugins/Purple Service/SLPurpleCocoaAdapter.m Tue Nov 03 22:05:47 2009 +1100 @@ -730,47 +730,26 @@ return NULL; } -/* XXX ugly */ -- (void *)handleNotifyFormattedWithTitle:(const char *)title primary:(const char *)primary secondary:(const char *)secondary text:(const char *)text + +- (void *)handleNotifyFormattedWithTitle:(const char *)title + primary:(const char *)primary + secondary:(const char *)secondary + text:(const char *)text { - NSString *titleString = (title ? [NSString stringWithUTF8String:title] : nil); - NSString *primaryString = (primary ? [NSString stringWithUTF8String:primary] : nil); + NSString *titleString = (title ? [NSString stringWithUTF8String:title] : @""); + NSString *primaryString = (primary ? [NSString stringWithUTF8String:primary] : @""); + NSString *secondaryString = (secondary ? [NSString stringWithUTF8String:secondary] : @""); - if (!titleString) { - titleString = primaryString; - primaryString = nil; - } + NSString *textString = (text ? [NSString stringWithUTF8String:text] : @""); + textString = [[[AIHTMLDecoder decoder] decodeHTML:textString] string]; - NSString *secondaryString = (secondary ? [NSString stringWithUTF8String:secondary] : nil); - if (!primaryString) { - primaryString = secondaryString; - secondaryString = nil; - } + NSString *description = [NSString stringWithFormat:@"%@\n\n%@",secondaryString,textString]; + description = [description stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; - static AIHTMLDecoder *notifyFormattedHTMLDecoder = nil; - if (!notifyFormattedHTMLDecoder) notifyFormattedHTMLDecoder = [[AIHTMLDecoder decoder] retain]; - - NSString *textString = (text ? [NSString stringWithUTF8String:text] : nil); - if (textString) textString = [[notifyFormattedHTMLDecoder decodeHTML:textString] string]; + [adium.interfaceController handleMessage:primaryString + withDescription:description + withWindowTitle:titleString]; - NSString *description = nil; - if ([textString length] && [secondaryString length]) { - description = [NSString stringWithFormat:@"%@\n\n%@",secondaryString,textString]; - - } else if (textString) { - description = textString; - - } else if (secondaryString) { - description = secondaryString; - - } - - NSString *message = primaryString; - - [adium.interfaceController handleMessage:(message ? message : @"") - withDescription:(description ? description : @"") - withWindowTitle:(titleString ? titleString : @"")]; - return NULL; }