Skip to content

Commit

Permalink
Changes.
Browse files Browse the repository at this point in the history
TVCLogLine.nickInfo deprecated and removed. TVCLogLine.nick is now formatted upon request. See TVCLogLine.h.
TVCLogLine.time deprecated and removed. TVCLogLine.receivedAt is now formatted upon request.
TVCLogLine.identified deprecated and removed. Historically did nothing. Deprecates a few IRCClient print* methods.

—

Write the logLine value of print: using our new TLOFileLogger implementation.

Setting stage so that messages can be re-rendered when a theme changes.
  • Loading branch information
emsquared committed Aug 4, 2012
1 parent 1f6ac95 commit de0b65a
Show file tree
Hide file tree
Showing 11 changed files with 327 additions and 122 deletions.
12 changes: 9 additions & 3 deletions Classes/Headers/IRCClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ typedef enum IRCDisconnectType : NSInteger {
- (IRCChannel *)findChannelOrCreate:(NSString *)name;
- (IRCChannel *)findChannelOrCreate:(NSString *)name useTalk:(BOOL)doTalk;

- (NSString *)formatNick:(NSString *)nick channel:(IRCChannel *)channel;

- (void)sendPrivmsgToSelectedChannel:(NSString *)message;

- (BOOL)printRawHTMLToCurrentChannel:(NSString *)text receivedAt:(NSDate *)receivedAt;
Expand All @@ -196,11 +198,11 @@ typedef enum IRCDisconnectType : NSInteger {

- (BOOL)printBoth:(id)chan type:(TVCLogLineType)type text:(NSString *)text;
- (BOOL)printBoth:(id)chan type:(TVCLogLineType)type text:(NSString *)text receivedAt:(NSDate *)receivedAt;
- (BOOL)printBoth:(id)chan type:(TVCLogLineType)type nick:(NSString *)nick text:(NSString *)text identified:(BOOL)identified;
- (BOOL)printBoth:(id)chan type:(TVCLogLineType)type nick:(NSString *)nick text:(NSString *)text identified:(BOOL)identified receivedAt:(NSDate *)receivedAt;
- (BOOL)printBoth:(id)chan type:(TVCLogLineType)type nick:(NSString *)nick text:(NSString *)text;
- (BOOL)printBoth:(id)chan type:(TVCLogLineType)type nick:(NSString *)nick text:(NSString *)text receivedAt:(NSDate *)receivedAt;
- (BOOL)printChannel:(IRCChannel *)channel type:(TVCLogLineType)type text:(NSString *)text receivedAt:(NSDate *)receivedAt;
- (BOOL)printAndLog:(TVCLogLine *)line withHTML:(BOOL)rawHTML;
- (BOOL)printChannel:(IRCChannel *)channel type:(TVCLogLineType)type nick:(NSString *)nick text:(NSString *)text identified:(BOOL)identified receivedAt:(NSDate *)receivedAt;
- (BOOL)printChannel:(IRCChannel *)channel type:(TVCLogLineType)type nick:(NSString *)nick text:(NSString *)text receivedAt:(NSDate *)receivedAt;
- (void)printSystem:(id)channel text:(NSString *)text;
- (void)printSystem:(id)channel text:(NSString *)text receivedAt:(NSDate *)receivedAt;
- (void)printSystemBoth:(id)channel text:(NSString *)text;
Expand All @@ -221,4 +223,8 @@ typedef enum IRCDisconnectType : NSInteger {
- (void)populateISONTrackedUsersList:(NSMutableArray *)ignores;

- (BOOL)outputRuleMatchedInMessage:(NSString *)raw inChannel:(IRCChannel *)chan withLineType:(TVCLogLineType)type;

- (BOOL)printBoth:(id)chan type:(TVCLogLineType)type nick:(NSString *)nick text:(NSString *)text identified:(BOOL)identified TEXTUAL_DEPRECATED;
- (BOOL)printBoth:(id)chan type:(TVCLogLineType)type nick:(NSString *)nick text:(NSString *)text identified:(BOOL)identified receivedAt:(NSDate *)receivedAt TEXTUAL_DEPRECATED;
- (BOOL)printChannel:(IRCChannel *)channel type:(TVCLogLineType)type nick:(NSString *)nick text:(NSString *)text identified:(BOOL)identified receivedAt:(NSDate *)receivedAt TEXTUAL_DEPRECATED;
@end
3 changes: 2 additions & 1 deletion Classes/Headers/NSDictionaryHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@

#import "TextualApplication.h"

#define NSDictionaryObjectKeyValueCompare(o,n,s) (id)(([o containsKey:n]) ? [o objectForKey:n] : s)
#define NSDictionaryObjectKeyValueCompare(o,n,s) (id)(([o containsKey:n]) ? [o objectForKey:n] : s)
#define NSDictionaryIntegerKeyValueCompare(o,n,s) (NSInteger)(([o containsKey:n]) ? [o integerForKey:n] : s)
#define NSDictionaryBOOLKeyValueCompare(o,n,s) (BOOL)(([o containsKey:n]) ? [o boolForKey:n] : s)

@interface NSDictionary (TXDictionaryHelper)
- (BOOL)boolForKey:(NSString *)key;
Expand Down
4 changes: 4 additions & 0 deletions Classes/Headers/TLOFileLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
- (void)reset;
- (void)reopenIfNeeded;

- (id)data; // Types: (NSData if writePlainText == YES),
// (NSDictionary if writePlainText == NO)
// or nil

- (NSString *)buildPath;

- (void)writePlainTextLine:(NSString *)s;
Expand Down
1 change: 1 addition & 0 deletions Classes/Headers/TPCPreferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ typedef enum TXHostmaskBanFormat : NSInteger {
+ (NSDictionary *)textualInfoPlist;
+ (NSDictionary *)systemInfoPlist;

+ (NSString *)whereTemporaryPath;
+ (NSString *)whereScriptsPath;
+ (NSString *)whereApplicationSupportPath;
+ (NSString *)whereThemesPath;
Expand Down
9 changes: 6 additions & 3 deletions Classes/Headers/TVCLogLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,20 @@ typedef enum TVCLogMemberType : NSInteger {

@interface TVCLogLine : NSObject
@property (nonatomic, strong) NSDate *receivedAt;
@property (nonatomic, strong) NSString *time;
@property (nonatomic, strong) NSString *nick;
@property (nonatomic, strong) NSString *body;
@property (nonatomic, assign) TVCLogLineType lineType;
@property (nonatomic, assign) TVCLogMemberType memberType;
@property (nonatomic, strong) NSString *nickInfo;
@property (nonatomic, assign) BOOL identified;
@property (nonatomic, assign) NSInteger nickColorNumber;
@property (nonatomic, strong) NSArray *keywords;
@property (nonatomic, strong) NSArray *excludeWords;

- (NSString *)formattedTimestamp;
- (NSString *)formattedNickname:(IRCChannel *)owner;

+ (NSString *)lineTypeString:(TVCLogLineType)type;
+ (NSString *)memberTypeString:(TVCLogMemberType)type;

- (id)initWithDictionary:(NSDictionary *)dic; // For internal use only. A plugin should not call.
- (NSDictionary *)dictionaryValue; // For internal use only. A plugin should not call.
@end
82 changes: 30 additions & 52 deletions Classes/IRC/IRCClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -1466,7 +1466,7 @@ - (void)sendText:(NSAttributedString *)str command:(NSString *)command channel:(
channel:channel.name
hostmask:self.myHost];

[self printBoth:channel type:type nick:self.myNick text:newstr identified:YES];
[self printBoth:channel type:type nick:self.myNick text:newstr];

if ([self encryptOutgoingMessage:&newstr channel:channel] == NO) {
continue;
Expand Down Expand Up @@ -1877,7 +1877,7 @@ - (BOOL)sendCommand:(id)str completeTarget:(BOOL)completeTarget target:(NSString
}

if (c) {
[self printBoth:c type:type nick:self.myNick text:t identified:YES];
[self printBoth:c type:type nick:self.myNick text:t];

if ([self encryptOutgoingMessage:&t channel:c] == NO) {
continue;
Expand Down Expand Up @@ -3220,22 +3220,22 @@ - (void)setUnreadState:(id)t

- (BOOL)printBoth:(id)chan type:(TVCLogLineType)type text:(NSString *)text
{
return [self printBoth:chan type:type nick:nil text:text identified:NO];
return [self printBoth:chan type:type nick:nil text:text];
}

- (BOOL)printBoth:(id)chan type:(TVCLogLineType)type text:(NSString *)text receivedAt:(NSDate *)receivedAt
{
return [self printBoth:chan type:type nick:nil text:text identified:NO receivedAt:receivedAt];
return [self printBoth:chan type:type nick:nil text:text receivedAt:receivedAt];
}

- (BOOL)printBoth:(id)chan type:(TVCLogLineType)type nick:(NSString *)nick text:(NSString *)text identified:(BOOL)identified
- (BOOL)printBoth:(id)chan type:(TVCLogLineType)type nick:(NSString *)nick text:(NSString *)text
{
return [self printBoth:chan type:type nick:nick text:text identified:identified receivedAt:[NSDate date]];
return [self printBoth:chan type:type nick:nick text:text receivedAt:[NSDate date]];
}

- (BOOL)printBoth:(id)chan type:(TVCLogLineType)type nick:(NSString *)nick text:(NSString *)text identified:(BOOL)identified receivedAt:(NSDate *)receivedAt
- (BOOL)printBoth:(id)chan type:(TVCLogLineType)type nick:(NSString *)nick text:(NSString *)text receivedAt:(NSDate *)receivedAt
{
return [self printChannel:chan type:type nick:nick text:text identified:identified receivedAt:receivedAt];
return [self printChannel:chan type:type nick:nick text:text receivedAt:receivedAt];
}

- (NSString *)formatNick:(NSString *)nick channel:(IRCChannel *)channel
Expand Down Expand Up @@ -3278,14 +3278,14 @@ - (NSString *)formatNick:(NSString *)nick channel:(IRCChannel *)channel
return format;
}

- (BOOL)printChannel:(id)chan type:(TVCLogLineType)type nick:(NSString *)nick text:(NSString *)text identified:(BOOL)identified
- (BOOL)printChannel:(id)chan type:(TVCLogLineType)type nick:(NSString *)nick text:(NSString *)text
{
return [self printChannel:chan type:type nick:nil text:text identified:identified receivedAt:[NSDate date]];
return [self printChannel:chan type:type nick:nil text:text receivedAt:[NSDate date]];
}

- (BOOL)printChannel:(id)chan type:(TVCLogLineType)type text:(NSString *)text receivedAt:(NSDate *)receivedAt
{
return [self printChannel:chan type:type nick:nil text:text identified:NO receivedAt:receivedAt];
return [self printChannel:chan type:type nick:nil text:text receivedAt:receivedAt];
}

- (BOOL)printAndLog:(TVCLogLine *)line withHTML:(BOOL)rawHTML
Expand Down Expand Up @@ -3335,14 +3335,7 @@ - (BOOL)printRawHTMLToCurrentChannel:(NSString *)text withTimestamp:(BOOL)showTi
c.memberType = TVCLogMemberNormalType;

if (showTime) {
NSString *time = TXFormattedTimestampWithOverride(receivedAt, [TPCPreferences themeTimestampFormat],
self.world.viewTheme.other.timestampFormat);

if (NSObjectIsNotEmpty(time)) {
time = [time stringByAppendingString:NSStringWhitespacePlaceholder];
}

c.time = time;
c.receivedAt = receivedAt;
}

if (channel) {
Expand All @@ -3352,16 +3345,12 @@ - (BOOL)printRawHTMLToCurrentChannel:(NSString *)text withTimestamp:(BOOL)showTi
}
}

- (BOOL)printChannel:(id)chan type:(TVCLogLineType)type nick:(NSString *)nick text:(NSString *)text identified:(BOOL)identified receivedAt:(NSDate *)receivedAt
- (BOOL)printChannel:(id)chan type:(TVCLogLineType)type nick:(NSString *)nick text:(NSString *)text receivedAt:(NSDate *)receivedAt
{
if ([self outputRuleMatchedInMessage:text inChannel:chan withLineType:type] == YES) {
return NO;
}

NSString *nickStr = nil;
NSString *time = TXFormattedTimestampWithOverride(receivedAt, [TPCPreferences themeTimestampFormat],
self.world.viewTheme.other.timestampFormat);

IRCChannel *channel = nil;

TVCLogMemberType memberType = TVCLogMemberNormalType;
Expand Down Expand Up @@ -3412,36 +3401,22 @@ - (BOOL)printChannel:(id)chan type:(TVCLogLineType)type nick:(NSString *)nick te
type = TVCLogLinePrivateMessageType;
}

if (NSObjectIsNotEmpty(time)) {
time = [time stringByAppendingString:NSStringWhitespacePlaceholder];
}

if (NSObjectIsNotEmpty(nick)) {
if (type == TVCLogLineActionType) {
nickStr = [NSString stringWithFormat:TXLogLineActionNicknameFormat, nick];
} else if (type == TVCLogLineNoticeType) {
nickStr = [NSString stringWithFormat:TXLogLineNoticeNicknameFormat, nick];
} else {
nickStr = [self formatNick:nick channel:channel];
}
}

if (nick && channel && (type == TVCLogLinePrivateMessageType || type == TVCLogLineActionType)) {
if (nick && channel && (type == TVCLogLinePrivateMessageType
|| type == TVCLogLineActionType)) {

IRCUser *user = [channel findMember:nick];

if (user) {
colorNumber = user.colorNumber;
}
}

c.time = time;
c.nick = nickStr;
c.body = text;
c.body = text;
c.nick = nick;
c.receivedAt = receivedAt;

c.lineType = type;
c.memberType = memberType;
c.nickInfo = nick;
c.identified = identified;
c.nickColorNumber = colorNumber;

c.keywords = keywords;
Expand All @@ -3453,7 +3428,10 @@ - (BOOL)printChannel:(id)chan type:(TVCLogLineType)type nick:(NSString *)nick te
[self.world.window isOnCurrentWorkspace] == NO) {

if (channel.isUnread == NO) {
if (type == TVCLogLinePrivateMessageType || type == TVCLogLineActionType || type == TVCLogLineNoticeType) {
if (type == TVCLogLinePrivateMessageType ||
type == TVCLogLineActionType ||
type == TVCLogLineNoticeType) {

[channel.log unmark];
[channel.log mark];
}
Expand Down Expand Up @@ -3598,19 +3576,19 @@ - (void)receivePrivmsgAndNotice:(IRCMessage *)m
if ([[text uppercaseString] hasPrefix:@"ACTION "]) {
text = [text safeSubstringFromIndex:7];

[self receiveText:m command:IRCPrivateCommandIndex("action") text:text identified:identified];
[self receiveText:m command:IRCPrivateCommandIndex("action") text:text];
} else {
[self receiveCTCPQuery:m text:text];
}
} else {
[self receiveCTCPReply:m text:text];
}
} else {
[self receiveText:m command:m.command text:text identified:identified];
[self receiveText:m command:m.command text:text];
}
}

- (void)receiveText:(IRCMessage *)m command:(NSString *)cmd text:(NSString *)text identified:(BOOL)identified
- (void)receiveText:(IRCMessage *)m command:(NSString *)cmd text:(NSString *)text
{
NSString *anick = m.sender.nick;
NSString *target = [m paramAt:0];
Expand Down Expand Up @@ -3663,11 +3641,11 @@ - (void)receiveText:(IRCMessage *)m command:(NSString *)cmd text:(NSString *)tex
[self decryptIncomingMessage:&text channel:c];

if (type == TVCLogLineNoticeType) {
[self printBoth:c type:type nick:anick text:text identified:identified receivedAt:m.receivedAt];
[self printBoth:c type:type nick:anick text:text receivedAt:m.receivedAt];

[self notifyText:TXNotificationChannelNoticeType lineType:type target:c nick:anick text:text];
} else {
BOOL highlight = [self printBoth:c type:type nick:anick text:text identified:identified receivedAt:m.receivedAt];
BOOL highlight = [self printBoth:c type:type nick:anick text:text receivedAt:m.receivedAt];
BOOL postevent = NO;

if (highlight) {
Expand Down Expand Up @@ -3817,7 +3795,7 @@ - (void)receiveText:(IRCMessage *)m command:(NSString *)cmd text:(NSString *)tex
c = [self.world selectedChannelOn:self];
}

[self printBoth:c type:type nick:anick text:text identified:identified receivedAt:m.receivedAt];
[self printBoth:c type:type nick:anick text:text receivedAt:m.receivedAt];

if ([anick isEqualNoCase:@"NickServ"]) {
if ([text hasPrefix:@"This nickname is registered"]) {
Expand Down Expand Up @@ -3860,7 +3838,7 @@ - (void)receiveText:(IRCMessage *)m command:(NSString *)cmd text:(NSString *)tex
[self notifyText:TXNotificationQueryNoticeType lineType:type target:c nick:anick text:text];
}
} else {
BOOL highlight = [self printBoth:c type:type nick:anick text:text identified:identified receivedAt:m.receivedAt];
BOOL highlight = [self printBoth:c type:type nick:anick text:text receivedAt:m.receivedAt];
BOOL postevent = NO;

if (highlight) {
Expand Down
Loading

0 comments on commit de0b65a

Please sign in to comment.