From 83c4314c8c69495a071a4d656fe6a6f0659f6bde Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sat, 14 Sep 2013 09:39:17 +0800 Subject: [PATCH] Usermode/IRC - Added JOIN/PART message suppor --- Usermode/Applications/irc_src/main.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/Usermode/Applications/irc_src/main.c b/Usermode/Applications/irc_src/main.c index a11487ff..190f66dc 100755 --- a/Usermode/Applications/irc_src/main.c +++ b/Usermode/Applications/irc_src/main.c @@ -32,7 +32,7 @@ typedef struct sWindow { struct sWindow *Next; tMessage *Messages; - tServer *Server; //!< Canoical server (can be NULL) + tServer *Server; //!< Canonical server (can be NULL) int ActivityLevel; char Name[]; // Channel name / remote user } tWindow; @@ -228,6 +228,8 @@ void Cmd_join(char *ArgString) if( gpCurrentWindow->Server ) { + gpCurrentWindow = Window_Create(gpCurrentWindow->Server, channel_name); + Redraw_Screen(); writef(gpCurrentWindow->Server->FD, "JOIN :%s\n", channel_name); } } @@ -409,7 +411,8 @@ tMessage *Message_Append(tServer *Server, int Type, const char *Source, const ch } } if( !win ) { - win = Window_Create(Server, Dest); + //win = Window_Create(Server, Dest); + win = &gWindow_Status; // Stick it in the status window, just in case } } #if 0 @@ -567,7 +570,7 @@ void ParseServerLine(tServer *Server, char *Line) int pos = 0; char *ident, *cmd; -// _SysDebug("[%s] %s", Server->Name, Line); + _SysDebug("[%s] %s", Server->Name, Line); // Message? if( *Line == ':' ) @@ -676,14 +679,24 @@ void ParseServerLine(tServer *Server, char *Line) { char *channel; channel = Line + pos + 1; - Window_Create(Server, channel); + + Message_AppendF(Server, MSG_TYPE_JOIN, "", channel, "%s has joined", ident); + //Window_Create(Server, channel); + } + else if( strcmp(cmd, "PART" ) == 0 ) + { + char *channel; + channel = Line + pos + 1; + + Message_AppendF(Server, MSG_TYPE_PART, "", channel, "%s has left", ident); + //Window_Create(Server, channel); } else { Message_AppendF(Server, MSG_TYPE_SERVER, "", "", "Unknown message %s (%s)", cmd, Line+pos); } } - else { + else { cmd = GetValue(Line, &pos); if( strcmp(cmd, "PING") == 0 ) { -- 2.20.1