00001 #include "ParserOut.h"
00002 #include "Connessione.h"
00003 #include "ClientGui.h"
00004
00005 ParserOut::ParserOut(Connessione* connection): connessione(connection)
00006 {
00007 alias["/s"] = "/SERVER";
00008 alias["/j"] = "/JOIN";
00009 alias["/q"] = "/QUIT";
00010 alias["/Q"] = "/QUIT";
00011 }
00012
00013 ParserOut::~ParserOut() {}
00014
00015
00016 void ParserOut::sendMessage(wxString strIn, const wxString &myname)
00017 {
00018 wxChar dcmd = strIn.GetChar(0);
00019 if(dcmd == '/')
00020 {
00021 wxStringTokenizer tz(strIn, ' ');
00022
00023 wxString token;
00024 token = tz.GetNextToken();
00025
00026
00027 if(alias[token] != "" )
00028 {
00029 strIn.Replace(token, alias[token]);
00030 wxStringTokenizer tz1(strIn, ' ');
00031 token = tz1.GetNextToken();
00032 strIn.Replace("/", "");
00033 #ifdef TESTING
00034 wxMessageBox( token , _("token="));
00035 #endif
00036 }
00037
00038
00039 if(!token.CmpNoCase("/CLOSE") || !token.CmpNoCase("/PART"))
00040 {
00041 connessione->GetTerminal(myname)->Close();
00042 }
00043 else if(!token.CmpNoCase("/QUIT"))
00044 {
00045 strIn.Replace("/", "");
00046 connessione->sendCommand(strIn);
00047 ClientGui* client = ClientGui::Instance(NULL);
00048 client->DeleteConnection(connessione);
00049 }
00050
00051
00052
00053 else
00054 {
00055
00056 alias.erase(token);
00057 strIn.Replace("/", "");
00058 connessione->sendCommand(strIn);
00059 }
00060
00061 #ifdef TESTING
00062 wxMessageBox( strIn , _("strIn::"));
00063 #endif
00064
00065 }
00066
00067
00068 else
00069 {
00070 wxString out = "PRIVMSG ";
00071 out.Append(myname);
00072 out.Append(" :");
00073 out.Append(strIn);
00074 connessione->sendCommand(out);
00075 }
00076
00077 }