Skip to content

Commit

Permalink
Improvements.
Browse files Browse the repository at this point in the history
— Redesigned command index. Tab completion now has only access to the commands Textual provides instead of allowing users to use "AUTHENTICATE" or other commands use only internally. This does not stop them from manually entering them. We will forward to server if they do.
— Added -destroyAllEvidence to IRCWorld. Equivalent of the CLEARALL command.
— As part of our command index rebuild the defines IRCCommandIndex<command> are now nonexistent. Please see IRC.h if you use these within a plugin.
— Fixed bundled scripts being favored over custom ones. (Fixes #294)
  • Loading branch information
emsquared committed Jul 20, 2012
1 parent fc85b73 commit 03420f8
Show file tree
Hide file tree
Showing 22 changed files with 716 additions and 673 deletions.
8 changes: 4 additions & 4 deletions Classes/Controllers/TXMasterController.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ - (void)awakeFromNib

[TPCPreferences setMasterController:self];
[TPCPreferences initPreferences];

[self.text setBackgroundColor:[NSColor clearColor]];

[_NSNotificationCenter() addObserver:self selector:@selector(themeStyleDidChange:) name:TXThemePreferenceChangedNotification object:nil];
Expand Down Expand Up @@ -464,7 +464,7 @@ - (void)sendText:(NSString *)command

- (void)textEntered
{
[self sendText:IRCCommandIndexPrivmsg];
[self sendText:IRCPrivateCommandIndex("privmsg")];
}

- (void)showMemberListSplitView:(BOOL)showList
Expand Down Expand Up @@ -831,7 +831,7 @@ - (void)completeNick:(BOOL)forward
if (commandMode) {
choices = [NSMutableArray array];

for (NSString *command in [TPCPreferences commandIndexList].allKeys) {
for (NSString *command in [TPCPreferences publicIRCCommandList]) {
[choices safeAddObject:[command lowercaseString]];
}

Expand Down Expand Up @@ -1186,7 +1186,7 @@ - (void)shiftTab:(NSEvent *)e

- (void)sendMsgAction:(NSEvent *)e
{
[self sendText:IRCCommandIndexAction];
[self sendText:IRCPrivateCommandIndex("action")];
}

- (void)_moveInputHistory:(BOOL)up checkScroller:(BOOL)scroll event:(NSEvent *)event
Expand Down
56 changes: 31 additions & 25 deletions Classes/Controllers/TXMenuController.m
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ - (void)showServerChannelList:(id)sender
if (_noClient || _notConnected) return;

[u createChannelListDialog];
[u send:IRCCommandIndexList, nil];
[u send:IRCPrivateCommandIndex("list"), nil];
}

- (void)addServer:(id)sender
Expand Down Expand Up @@ -1000,7 +1000,7 @@ - (void)topicSheet:(TDCTopicSheet *)sender onOK:(NSString *)topic
if (_noClientOrChannel || _isClient || _isQuery) return;

if ([u encryptOutgoingMessage:&topic channel:c] == YES) {
[u send:IRCCommandIndexTopic, c.name, topic, nil];
[u send:IRCPrivateCommandIndex("topic"), c.name, topic, nil];
}
}

Expand Down Expand Up @@ -1042,7 +1042,7 @@ - (void)modeSheetOnOK:(TDCModeSheet *)sender
NSString *changeStr = [c.mode getChangeCommand:sender.mode];

if (NSObjectIsNotEmpty(changeStr)) {
[u sendLine:[NSString stringWithFormat:@"%@ %@ %@", IRCCommandIndexMode, c.name, changeStr]];
[u sendLine:[NSString stringWithFormat:@"%@ %@ %@", IRCPrivateCommandIndex("mode"), c.name, changeStr]];
}
}

Expand Down Expand Up @@ -1263,7 +1263,7 @@ - (void)inviteSheet:(TDCInviteSheet *)sender onSelectChannel:(NSString *)channel

if (u && NSObjectIsNotEmpty(channelName)) {
for (NSString *nick in sender.nicks) {
[u send:IRCCommandIndexInvite, nick, channelName, nil];
[u send:IRCPrivateCommandIndex("invite"), nick, channelName, nil];
}
}
}
Expand Down Expand Up @@ -1295,7 +1295,7 @@ - (void)memberSendCTCPTime:(id)sender
if (_noClient || _isClient) return;

for (IRCUser *m in [self selectedMembers:sender]) {
[u sendCTCPQuery:m.nick command:IRCCommandIndexTime text:nil];
[u sendCTCPQuery:m.nick command:IRCPrivateCommandIndex("ctcp_time") text:nil];
}

[self deselectMembers:sender];
Expand All @@ -1309,7 +1309,7 @@ - (void)memberSendCTCPVersion:(id)sender
if (_noClient || _isClient) return;

for (IRCUser *m in [self selectedMembers:sender]) {
[u sendCTCPQuery:m.nick command:IRCCommandIndexVersion text:nil];
[u sendCTCPQuery:m.nick command:IRCPrivateCommandIndex("ctcp_version") text:nil];
}

[self deselectMembers:sender];
Expand All @@ -1323,7 +1323,7 @@ - (void)memberSendCTCPUserinfo:(id)sender
if (_noClient || _isClient) return;

for (IRCUser *m in [self selectedMembers:sender]) {
[u sendCTCPQuery:m.nick command:IRCCommandIndexUserinfo text:nil];
[u sendCTCPQuery:m.nick command:IRCPrivateCommandIndex("ctcp_userinfo") text:nil];
}

[self deselectMembers:sender];
Expand All @@ -1337,7 +1337,7 @@ - (void)memberSendCTCPClientInfo:(id)sender
if (_noClient || _isClient) return;

for (IRCUser *m in [self selectedMembers:sender]) {
[u sendCTCPQuery:m.nick command:IRCCommandIndexClientinfo text:nil];
[u sendCTCPQuery:m.nick command:IRCPrivateCommandIndex("ctcp_clientinfo") text:nil];
}

[self deselectMembers:sender];
Expand Down Expand Up @@ -1420,33 +1420,33 @@ - (void)processModeChange:(id)sender mode:(NSString *)tmode
}

- (void)memberModeChangeOp:(id)sender
{
[self processModeChange:sender mode:@"OP"];
{
[self processModeChange:sender mode:IRCPublicCommandIndex("op")];
}

- (void)memberModeChangeDeop:(id)sender
{
[self processModeChange:sender mode:@"DEOP"];
[self processModeChange:sender mode:IRCPublicCommandIndex("deop")];
}

- (void)memberModeChangeHalfop:(id)sender
{
[self processModeChange:sender mode:@"HALFOP"];
[self processModeChange:sender mode:IRCPublicCommandIndex("halfop")];
}

- (void)memberModeChangeDehalfop:(id)sender
{
[self processModeChange:sender mode:@"DEHALFOP"];
[self processModeChange:sender mode:IRCPublicCommandIndex("dehalfop")];
}

- (void)memberModeChangeVoice:(id)sender
{
[self processModeChange:sender mode:@"VOICE"];
[self processModeChange:sender mode:IRCPublicCommandIndex("voice")];
}

- (void)memberModeChangeDevoice:(id)sender
{
[self processModeChange:sender mode:@"DEVOICE"];
[self processModeChange:sender mode:IRCPublicCommandIndex("devoice")];
}

- (void)memberKickFromChannel:(id)sender
Expand All @@ -1471,7 +1471,7 @@ - (void)memberBanFromServer:(id)sender
if (_noClientOrChannel || _isClient || _isQuery) return;

for (IRCUser *m in [self selectedMembers:sender]) {
[u sendCommand:[NSString stringWithFormat:@"BAN %@", m.nick] completeTarget:YES target:c.name];
[u sendCommand:[NSString stringWithFormat:@"%@ %@", IRCPublicCommandIndex("ban"), m.nick] completeTarget:YES target:c.name];
}

[self deselectMembers:sender];
Expand All @@ -1485,7 +1485,8 @@ - (void)memberKickbanFromChannel:(id)sender
if (_noClientOrChannel || _isClient || _isQuery) return;

for (IRCUser *m in [self selectedMembers:sender]) {
[u sendCommand:[NSString stringWithFormat:@"KICKBAN %@ %@", m.nick, [TPCPreferences defaultKickMessage]]
[u sendCommand:[NSString stringWithFormat:@"%@ %@ %@",
IRCPublicCommandIndex("kickban"), m.nick, [TPCPreferences defaultKickMessage]]
completeTarget:YES target:c.name];
}

Expand All @@ -1500,7 +1501,8 @@ - (void)memberKillFromServer:(id)sender
if (_noClientOrChannel || _isClient) return;

for (IRCUser *m in [self selectedMembers:sender]) {
[u sendCommand:[NSString stringWithFormat:@"KILL %@ %@", m.nick, [TPCPreferences IRCopDefaultKillMessage]]];
[u sendCommand:[NSString stringWithFormat:@"%@ %@ %@",
IRCPublicCommandIndex("kill"), m.nick, [TPCPreferences IRCopDefaultKillMessage]]];
}

[self deselectMembers:sender];
Expand All @@ -1517,7 +1519,8 @@ - (void)memberGlineFromServer:(id)sender
if ([m.nick isEqualNoCase:u.myNick]) {
[u printDebugInformation:TXTFLS(@"SelfBanDetectedMessage", u.serverHostname) channel:c];
} else {
[u sendCommand:[NSString stringWithFormat:@"GLINE %@ %@", m.nick, [TPCPreferences IRCopDefaultGlineMessage]]];
[u sendCommand:[NSString stringWithFormat:@"%@ %@ %@",
IRCPublicCommandIndex("gline"), m.nick, [TPCPreferences IRCopDefaultGlineMessage]]];
}
}

Expand All @@ -1532,7 +1535,8 @@ - (void)memberShunFromServer:(id)sender
if (_noClientOrChannel || _isClient) return;

for (IRCUser *m in [self selectedMembers:sender]) {
[u sendCommand:[NSString stringWithFormat:@"SHUN %@ %@", m.nick, [TPCPreferences IRCopDefaultShunMessage]]];
[u sendCommand:[NSString stringWithFormat:@"%@ %@ %@",
IRCPublicCommandIndex("shun"), m.nick, [TPCPreferences IRCopDefaultShunMessage]]];
}

[self deselectMembers:sender];
Expand Down Expand Up @@ -1623,7 +1627,7 @@ - (void)showChannelBanList:(id)sender
if (_noChannel || _isClient || _isQuery) return;

[[self.world selectedClient] createChanBanListDialog];
[[self.world selectedClient] send:IRCCommandIndexMode, [c name], @"+b", nil];
[[self.world selectedClient] send:IRCPrivateCommandIndex("mode"), [c name], @"+b", nil];
}

- (void)showChannelBanExceptionList:(id)sender
Expand All @@ -1633,7 +1637,7 @@ - (void)showChannelBanExceptionList:(id)sender
if (_noChannel || _isClient || _isQuery) return;

[[self.world selectedClient] createChanBanExceptionListDialog];
[[self.world selectedClient] send:IRCCommandIndexMode, [c name], @"+e", nil];
[[self.world selectedClient] send:IRCPrivateCommandIndex("mode"), [c name], @"+e", nil];
}

- (void)showChannelInviteExceptionList:(id)sender
Expand All @@ -1643,7 +1647,7 @@ - (void)showChannelInviteExceptionList:(id)sender
if (_noChannel || _isClient || _isQuery) return;

[[self.world selectedClient] createChanInviteExceptionListDialog];
[[self.world selectedClient] send:IRCCommandIndexMode, [c name], @"+I", nil];
[[self.world selectedClient] send:IRCPrivateCommandIndex("mode"), [c name], @"+I", nil];
}

- (void)openHelpMenuLinkItem:(id)sender
Expand Down Expand Up @@ -1757,7 +1761,8 @@ - (void)toggleChannelModerationMode:(id)sender

if (_noChannel || _isClient || _isQuery) return;

[[self.world selectedClient] sendCommand:[NSString stringWithFormat:@"MODE %@ %@", [c name], (([sender tag] == 1) ? @"-m" : @"+m")]];
[[self.world selectedClient] sendCommand:[NSString stringWithFormat:@"%@ %@ %@",
IRCPublicCommandIndex("mode"), [c name], (([sender tag] == 1) ? @"-m" : @"+m")]];
}

- (void)toggleChannelInviteMode:(id)sender
Expand All @@ -1766,7 +1771,8 @@ - (void)toggleChannelInviteMode:(id)sender

if (_noChannel || _isClient || _isQuery) return;

[[self.world selectedClient] sendCommand:[NSString stringWithFormat:@"MODE %@ %@", [c name], (([sender tag] == 1) ? @"-i" : @"+i")]];
[[self.world selectedClient] sendCommand:[NSString stringWithFormat:@"%@ %@ %@",
IRCPublicCommandIndex("mode"), [c name], (([sender tag] == 1) ? @"-i" : @"+i")]];
}

- (void)toggleDeveloperMode:(id)sender
Expand Down
6 changes: 2 additions & 4 deletions Classes/Dialogs/Preferences/TDCPreferencesController.m
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,7 @@ - (void)onChangedTheme:(id)sender
newRenderVersion = self.world.viewTheme.other.renderingEngineVersion;

if (NSDissimilarObjects(oldRenderVersion, newRenderVersion)) {
for (IRCClient *u in self.world.clients) {
[u sendCommand:@"CLEARALL"];
}
[self.world destroyAllEvidence];
}
}

Expand All @@ -550,7 +548,7 @@ - (void)changeItemFont:(NSFontManager *)sender
[TPCPreferences setThemeChannelViewFontName:[newFont fontName]];
[TPCPreferences setThemeChannelViewFontSize:[newFont pointSize]];

[self setValue:[newFont fontName] forKey:@"themeChannelViewFontName"];
[self setValue: [newFont fontName] forKey:@"themeChannelViewFontName"];
[self setValue:@([newFont pointSize]) forKey:@"themeChannelViewFontSize"];

[self onStyleChanged:nil];
Expand Down
114 changes: 13 additions & 101 deletions Classes/Headers/IRC.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,106 +37,18 @@

#import "TextualApplication.h"

#define IRCCommandIndexAction @"ACTION"
#define IRCCommandIndexAdchat @"ADCHAT"
#define IRCCommandIndexAuthenticate @"AUTHENTICATE"
#define IRCCommandIndexAme @"AME"
#define IRCCommandIndexAmsg @"AMSG"
#define IRCCommandIndexAway @"AWAY"
#define IRCCommandIndexBan @"BAN"
#define IRCCommandIndexChatops @"CHATOPS"
#define IRCCommandIndexCap @"CAP"
#define IRCCommandIndexCaps @"CAPS"
#define IRCCommandIndexClear @"CLEAR"
#define IRCCommandIndexClearall @"CLEARALL"
#define IRCCommandIndexClientinfo @"CLIENTINFO"
#define IRCCommandIndexClose @"CLOSE"
#define IRCCommandIndexConn @"CONN"
#define IRCCommandIndexConnect @"CONN"
#define IRCCommandIndexCtcp @"CTCP"
#define IRCCommandIndexCtcpreply @"CTCPREPLY"
#define IRCCommandIndexCycle @"CYCLE"
#define IRCCommandIndexDcc @"DCC"
#define IRCCommandIndexDebug @"DEBUG"
#define IRCCommandIndexDehalfop @"DEHALFOP"
#define IRCCommandIndexDeop @"DEOP"
#define IRCCommandIndexDevoice @"DEVOICE"
#define IRCCommandIndexEcho @"ECHO"
#define IRCCommandIndexError @"ERROR"
#define IRCCommandIndexGline @"GLINE"
#define IRCCommandIndexGzline @"GZLINE"
#define IRCCommandIndexGlobops @"GLOBOPS"
#define IRCCommandIndexHalfop @"HALFOP"
#define IRCCommandIndexHop @"HOP"
#define IRCCommandIndexIcbadge @"ICBADGE"
#define IRCCommandIndexCcbadge @"CCBADGE"
#define IRCCommandIndexIgnore @"IGNORE"
#define IRCCommandIndexInvite @"INVITE"
#define IRCCommandIndexIson @"ISON"
#define IRCCommandIndexJ @"J"
#define IRCCommandIndexJoin @"JOIN"
#define IRCCommandIndexKb @"KB"
#define IRCCommandIndexKick @"KICK"
#define IRCCommandIndexKickban @"KICKBAN"
#define IRCCommandIndexKill @"KILL"
#define IRCCommandIndexLeave @"LEAVE"
#define IRCCommandIndexLagcheck @"LAGCHECK"
#define IRCCommandIndexList @"LIST"
#define IRCCommandIndexLoadPlugins @"LOAD_PLUGINS"
#define IRCCommandIndexLocops @"LOCOPS"
#define IRCCommandIndexM @"M"
#define IRCCommandIndexMe @"ME"
#define IRCCommandIndexMode @"MODE"
#define IRCCommandIndexMsg @"MSG"
#define IRCCommandIndexMute @"MUTE"
#define IRCCommandIndexMylag @"MYLAG"
#define IRCCommandIndexMyversion @"MYVERSION"
#define IRCCommandIndexNachat @"NACHAT"
#define IRCCommandIndexNames @"NAMES"
#define IRCCommandIndexNick @"NICK"
#define IRCCommandIndexNncoloreset @"NNCOLORESET"
#define IRCCommandIndexNotice @"NOTICE"
#define IRCCommandIndexOmsg @"OMSG"
#define IRCCommandIndexOnotice @"ONOTICE"
#define IRCCommandIndexOp @"OP"
#define IRCCommandIndexPart @"PART"
#define IRCCommandIndexPass @"PASS"
#define IRCCommandIndexPing @"PING"
#define IRCCommandIndexPong @"PONG"
#define IRCCommandIndexPrivmsg @"PRIVMSG"
#define IRCCommandIndexQuery @"QUERY"
#define IRCCommandIndexQuit @"QUIT"
#define IRCCommandIndexQuote @"QUOTE"
#define IRCCommandIndexRaw @"RAW"
#define IRCCommandIndexRejoin @"REJOIN"
#define IRCCommandIndexRemove @"REMOVE"
#define IRCCommandIndexSend @"SEND"
#define IRCCommandIndexServer @"SERVER"
#define IRCCommandIndexShun @"SHUN"
#define IRCCommandIndexSslcontext @"SSLCONTEXT"
#define IRCCommandIndexT @"T"
#define IRCCommandIndexTempshun @"TEMPSHUN"
#define IRCCommandIndexTime @"TIME"
#define IRCCommandIndexTimer @"TIMER"
#define IRCCommandIndexTopic @"TOPIC"
#define IRCCommandIndexUmode @"UMODE"
#define IRCCommandIndexUnban @"UNBAN"
#define IRCCommandIndexUnignore @"UNIGNORE"
#define IRCCommandIndexUnloadPlugins @"UNLOAD_PLUGINS"
#define IRCCommandIndexUnmute @"UNMUTE"
#define IRCCommandIndexUser @"USER"
#define IRCCommandIndexUserinfo @"USERINFO"
#define IRCCommandIndexVersion @"VERSION"
#define IRCCommandIndexVoice @"VOICE"
#define IRCCommandIndexWallops @"WALLOPS"
#define IRCCommandIndexWatch @"WATCH"
#define IRCCommandIndexWeights @"WEIGHTS"
#define IRCCommandIndexWho @"WHO"
#define IRCCommandIndexWhois @"WHOIS"
#define IRCCommandIndexWhowas @"WHOWAS"
#define IRCCommandIndexZline @"ZLINE"
#define IRCCommandIndexSme @"SME"
#define IRCCommandIndexSmsg @"SMSG"

#define TXMaximumIRCBodyLength 520
#define TXMaximumNodesPerModeCommand 4

/* Historically, we used a few dozen "IRCCommandIndex<command>" defines to match
a define against the actual IRC command it represents. Instead, we now hand a
key sent to IRC[*]CommandIndex() down to our lower level APIs to match the key
against the actual IRC Command. The key does not necessarily match the actual
command being sent either. For example, CTCP commands have the ctcp_ prefix.
This thing is overly complex for no good reasons… */

TEXTUAL_EXTERN NSString *IRCCommandIndex(const char *key) TEXTUAL_DEPRECATED;

TEXTUAL_EXTERN NSString *IRCPrivateCommandIndex(const char *key);
TEXTUAL_EXTERN NSString *IRCPublicCommandIndex(const char *key);
2 changes: 2 additions & 0 deletions Classes/Headers/IRCWorld.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,7 @@
- (void)clearContentsOfClient:(IRCClient *)u;
- (void)clearContentsOfChannel:(IRCChannel *)c inClient:(IRCClient *)u;

- (void)destroyAllEvidence;

- (TVCLogController *)createLogWithClient:(IRCClient *)client channel:(IRCChannel *)channel;
@end
Loading

0 comments on commit 03420f8

Please sign in to comment.