annotate gui/src/qirc/IRCClientImpl.cpp @ 13592:83e83a704383

IRC traffic in console.
author Jacob Dawid <jacob.dawid@googlemail.com>
date Thu, 04 Aug 2011 10:43:27 +0200
parents b2ee41559bff
children fe30859fb540
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13583
057ec114ac15 Added GPL headers.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13581
diff changeset
1 /* OctaveGUI - A graphical user interface for Octave
057ec114ac15 Added GPL headers.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13581
diff changeset
2 * Copyright (C) 2011 Jacob Dawid
057ec114ac15 Added GPL headers.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13581
diff changeset
3 * jacob.dawid@googlemail.com
057ec114ac15 Added GPL headers.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13581
diff changeset
4 *
057ec114ac15 Added GPL headers.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13581
diff changeset
5 * This program is free software: you can redistribute it and/or modify
057ec114ac15 Added GPL headers.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13581
diff changeset
6 * it under the terms of the GNU General Public License as published by
057ec114ac15 Added GPL headers.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13581
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
057ec114ac15 Added GPL headers.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13581
diff changeset
8 * (at your option) any later version.
057ec114ac15 Added GPL headers.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13581
diff changeset
9 *
057ec114ac15 Added GPL headers.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13581
diff changeset
10 * This program is distributed in the hope that it will be useful,
057ec114ac15 Added GPL headers.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13581
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
057ec114ac15 Added GPL headers.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13581
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
057ec114ac15 Added GPL headers.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13581
diff changeset
13 * GNU General Public License for more details.
057ec114ac15 Added GPL headers.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13581
diff changeset
14 *
057ec114ac15 Added GPL headers.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13581
diff changeset
15 * You should have received a copy of the GNU General Public License
057ec114ac15 Added GPL headers.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13581
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
057ec114ac15 Added GPL headers.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13581
diff changeset
17 */
057ec114ac15 Added GPL headers.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13581
diff changeset
18
13579
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
19 #include "IRCClientImpl.h"
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
20
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
21 IRCServerMessage::IRCServerMessage (const QString& serverMessage)
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
22 {
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
23 const char *message = serverMessage.toStdString().c_str();
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
24 char prefix[512];
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
25 int index = 0;
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
26
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
27 m_nick = "";
13585
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
28 m_user = "";
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
29 m_host = "";
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
30 m_parameters.reserve (16);
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
31
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
32 if (message[0] == CHR_COLON)
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
33 {
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
34 index++;
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
35 strcpy (prefix,
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
36 getStringToken (message, index).toStdString ().c_str ());
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
37
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
38 int etapa = 0;
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
39 for (unsigned int i = 0; i < strlen (prefix); i++)
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
40 {
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
41 switch (prefix[i])
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
42 {
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
43 case '!':
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
44 etapa = 1;
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
45 break;
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
46 case '@':
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
47 etapa = 2;
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
48 break;
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
49 default:
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
50 switch (etapa)
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
51 {
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
52 case 0:
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
53 m_nick += prefix[i];
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
54 break;
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
55 case 1:
13585
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
56 m_user += prefix[i];
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
57 break;
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
58 default:
13585
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
59 m_host += prefix[i];
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
60 break;
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
61 }
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
62 }
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
63 }
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
64 }
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
65
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
66 m_command = getStringToken (message, index);
13585
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
67 m_command = m_command.toUpper ();
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
68
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
69 while (message[index] != 0)
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
70 {
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
71 if ((message[index] == CHR_COLON))
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
72 {
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
73
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
74 if (message[index] == CHR_COLON)
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
75 {
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
76 index++;
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
77 }
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
78
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
79 m_parameters.append ( (const char *) (message + index));
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
80 index += strlen (message + index);
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
81 }
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
82 else
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
83 {
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
84 m_parameters.append (getStringToken (message, index));
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
85 }
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
86 }
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
87
13585
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
88 if (strlen (m_command.toStdString ().c_str ()) ==
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
89 strspn (m_command.toStdString ().c_str (), DIGITS))
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
90 {
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
91 m_isNumeric = true;
13585
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
92 m_codeNumber = atoi (m_command.toStdString ().c_str ());
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
93 }
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
94 else
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
95 {
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
96 m_isNumeric = false;
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
97 }
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
98 }
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
99
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
100 int
13585
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
101 IRCServerMessage::numericValue ()
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
102 {
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
103 if (m_isNumeric)
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
104 return m_codeNumber;
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
105 return -1;
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
106 }
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
107
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
108 QString
13585
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
109 IRCServerMessage::parameter (int index)
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
110 {
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
111 if (index >= 0 && index < m_parameters.size ())
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
112 return m_parameters.at (index);
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
113 return "";
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
114 }
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
115
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
116 int
13585
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
117 IRCServerMessage::skipSpaces (const char *line, int &index)
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
118 {
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
119 while (line[index] == CHR_SPACE)
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
120 {
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
121 index++;
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
122 }
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
123 return index;
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
124 }
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
125
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
126 QString
13585
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
127 IRCServerMessage::getStringToken (const char *line, int &index)
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
128 {
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
129 QString token ("");
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
130 skipSpaces (line, index);
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
131 while ((line[index] != CHR_SPACE) && (line[index] != CHR_ZERO))
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
132 {
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
133 token += line[index];
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
134 index++;
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
135 }
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
136
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
137 skipSpaces (line, index);
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
138 return token;
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
139 }
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
140
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
141 QString
13585
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
142 IRCServerMessage::getStringToken (QString line, int &index)
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
143 {
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
144 return getStringToken (line.toStdString ().c_str (), index);
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
145 }
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
146
13585
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
147 IRCChannelProxy::IRCChannelProxy ()
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
148 : IRCChannelProxyInterface ()
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
149 {
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
150
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
151 }
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
152
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
153 QTextDocument *
13588
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
154 IRCChannelProxy::conversationModel ()
13585
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
155 {
13588
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
156 return &m_conversationModel;
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
157 }
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
158
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
159 QStringListModel *
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
160 IRCChannelProxy::userListModel ()
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
161 {
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
162 return &m_userListModel;
13585
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
163 }
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
164
13579
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
165 IRCClientImpl::IRCClientImpl ()
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
166 : IRCClientInterface ()
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
167 {
13580
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
168 connect (&m_tcpSocket, SIGNAL (connected ()), this, SLOT (handleConnected ()));
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
169 connect (&m_tcpSocket, SIGNAL (disconnected ()), this, SLOT (handleDisconnected ()));
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
170 connect (&m_tcpSocket, SIGNAL (readyRead ()), this, SLOT (handleReadyRead ()));
13579
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
171 }
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
172
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
173 void
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
174 IRCClientImpl::connectToHost (const QHostAddress& host, int port, const QString& initialNick)
13579
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
175 {
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
176 m_host = host;
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
177 m_nickname = initialNick;
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
178 m_tcpSocket.connectToHost(host, port);
13579
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
179 }
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
180
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
181 void
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
182 IRCClientImpl::disconnect ()
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
183 {
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
184 m_tcpSocket.disconnect ();
13579
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
185 }
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
186
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
187 void
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
188 IRCClientImpl::reconnect ()
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
189 {
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
190 disconnect ();
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
191 connectToHost (m_host, m_port, m_nickname);
13579
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
192 }
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
193
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
194 bool
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
195 IRCClientImpl::isConnected ()
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
196 {
13580
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
197 return m_connected;
13579
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
198 }
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
199
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
200 const QHostAddress&
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
201 IRCClientImpl::host()
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
202 {
13580
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
203 return m_host;
13579
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
204 }
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
205
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
206 int
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
207 IRCClientImpl::port()
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
208 {
13580
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
209 return m_port;
13579
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
210 }
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
211
13585
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
212 IRCChannelProxyInterface *
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
213 IRCClientImpl::ircChannelProxy (const QString &channel)
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
214 {
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
215 if (m_channels.contains (channel))
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
216 return m_channels[channel];
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
217 return 0;
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
218 }
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
219
13579
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
220 void
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
221 IRCClientImpl::sendJoinRequest (const QString& channel)
13579
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
222 {
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
223 sendIRCCommand (IRCCommand::Join, QStringList (channel));
13579
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
224 }
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
225
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
226 void
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
227 IRCClientImpl::leaveChannel (const QString& channel, const QString& reason)
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
228 {
13580
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
229 Q_UNUSED (channel);
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
230 Q_UNUSED (reason);
13579
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
231 }
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
232
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
233 void
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
234 IRCClientImpl::focusChannel (const QString& channel)
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
235 {
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
236 m_focussedChannel = channel;
13579
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
237 }
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
238
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
239 void
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
240 IRCClientImpl::sendNicknameChangeRequest (const QString &nickname)
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
241 {
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
242 sendIRCCommand (IRCCommand::Nick, QStringList (nickname));
13579
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
243 }
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
244
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
245 void
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
246 IRCClientImpl::sendPublicMessage (const QString& message)
13579
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
247 {
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
248 QStringList arguments;
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
249 arguments << m_focussedChannel;
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
250 arguments << message;
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
251 sendIRCCommand (IRCCommand::PrivateMessage, arguments);
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
252 }
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
253
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
254 void
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
255 IRCClientImpl::sendPrivateMessage (const QString &recipient, const QString &message)
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
256 {
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
257 QStringList arguments;
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
258 arguments << recipient;
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
259 arguments << message;
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
260 sendIRCCommand (IRCCommand::PrivateMessage, arguments);
13579
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
261 }
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
262
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
263 const QString&
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
264 IRCClientImpl::nickname ()
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
265 {
13580
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
266 return m_nickname;
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
267 }
13579
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
268
13580
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
269 void
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
270 IRCClientImpl::handleConnected ()
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
271 {
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
272 m_connected = true;
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
273 QStringList arguments;
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
274 arguments << "na" << "0" << "0" << "na";
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
275 sendIRCCommand (IRCCommand::User, arguments);
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
276 sendNicknameChangeRequest (m_nickname);
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
277 emit connected (m_host.toString ());
13579
6568fccb8940 Updated russian and ukrainian translation files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
278 }
13580
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
279
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
280 void
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
281 IRCClientImpl::handleDisconnected ()
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
282 {
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
283 m_connected = false;
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
284 emit disconnected ();
13580
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
285 }
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
286
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
287 void
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
288 IRCClientImpl::handleReadyRead ()
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
289 {
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
290 QByteArray line;
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
291 do
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
292 {
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
293 line = m_tcpSocket.readLine();
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
294 if (line.size ())
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
295 handleIncomingLine(QString(line));
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
296 else
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
297 break;
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
298 }
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
299 while (true);
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
300 }
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
301
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
302 void
13585
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
303 IRCClientImpl::handleNicknameChanged (const QString &oldNick, const QString &newNick)
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
304 {
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
305 emit nicknameChanged (oldNick, newNick);
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
306 }
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
307
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
308 void
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
309 IRCClientImpl::handleUserJoined (const QString &nick, const QString &channel)
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
310 {
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
311 emit userJoined (nick, channel);
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
312 }
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
313
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
314 void
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
315 IRCClientImpl::handleUserQuit (const QString &nick, const QString &reason)
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
316 {
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
317 emit userQuit (nick, reason);
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
318 }
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
319
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
320 void
13580
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
321 IRCClientImpl::handleIncomingLine (const QString &line)
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
322 {
13592
83e83a704383 IRC traffic in console.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13591
diff changeset
323 emit debugMessage (QString (">>>recv: \"%1\"").arg (line));
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
324 if (m_connected && !line.isEmpty())
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
325 {
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
326 IRCServerMessage ircEvent(line);
13585
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
327 if (ircEvent.isNumericValue () == true)
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
328 {
13585
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
329 switch (ircEvent.numericValue ())
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
330 {
13588
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
331 case IRCReply::Welcome:
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
332 emit loggedIn (nickname ());
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
333 break;
13588
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
334 case IRCError::NicknameInUse:
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
335 case IRCError::NickCollision:
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
336 emit debugMessage ("FIXME: Received nickname in use reply.");
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
337 break;
13588
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
338 case IRCError::PasswordMismatch:
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
339 emit debugMessage ("FIXME: Received password mismatch reply.");
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
340 break;
13588
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
341 case IRCReply::MessageOfTheDayStart:
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
342 case IRCReply::MessageOfTheDay:
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
343 case IRCReply::MessageOfTheDayEnd:
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
344 case IRCError::NoMessageOfTheDay:
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
345 break;
13588
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
346 case IRCReply::NoTopic:
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
347 case IRCReply::Topic:
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
348 break;
13588
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
349 case IRCReply::NameReply:
13592
83e83a704383 IRC traffic in console.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13591
diff changeset
350 emit debugMessage (QString ("LINKME: (NameReply) \'%1\'").arg (ircEvent.parameter (3)));
13585
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
351 //m_nickList = event->getParam (3).split (QRegExp ("\\s+"), QString::SkipEmptyParts);
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
352 break;
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
353 }
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
354 }
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
355 else
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
356 {
13585
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
357 QString command = ircEvent.command ();
13588
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
358 if (command == IRCCommand::Nick)
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
359 {
13585
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
360 handleNicknameChanged (ircEvent.parameter (0), ircEvent.parameter (1));
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
361 }
13588
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
362 else if (command == IRCCommand::Quit)
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
363 {
13585
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
364 handleUserQuit (ircEvent.nick (), ircEvent.parameter (0));
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
365 }
13588
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
366 else if (command == IRCCommand::Join)
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
367 {
13585
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
368 handleUserJoined(ircEvent.nick (), ircEvent.parameter (0));
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
369 }
13588
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
370 else if (command == IRCCommand::Part)
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
371 {
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
372 emit debugMessage ("WRITEME: Received part.");
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
373 //emit part (ircEvent.getNick ().toStdString ().c_str (),
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
374 // ircEvent.getParam (0).toStdString ().c_str (),
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
375 // ircEvent.getParam (1).toStdString ().c_str ());
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
376 }
13588
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
377 else if (command == IRCCommand::Mode)
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
378 {
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
379 emit debugMessage ("WRITEME: Received mode.");
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
380 //emit mode (&ircEvent);
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
381 }
13588
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
382 else if (command == IRCCommand::Topic)
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
383 {
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
384 emit debugMessage ("WRITEME: Received topic.");
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
385 //emit topic (ircEvent.getNick ().toStdString ().c_str (),
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
386 // ircEvent.getParam (0).toStdString ().c_str (),
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
387 // ircEvent.getParam (1).toStdString ().c_str ());
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
388 }
13588
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
389 else if (command == IRCCommand::Kick)
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
390 {
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
391 emit debugMessage ("WRITEME: Received kick.");
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
392 //emit kick (ircEvent.getNick ().toStdString ().c_str (),
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
393 // ircEvent.getParam (0).toStdString ().c_str (),
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
394 // ircEvent.getParam (1).toStdString ().c_str (),
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
395 // ircEvent.getParam (2).toStdString ().c_str ());
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
396 }
13588
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
397 else if (command == IRCCommand::Invite)
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
398 {
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
399 emit debugMessage ("WRITEME: Received invite.");
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
400 //emit invite (ircEvent.getNick ().toStdString ().c_str (),
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
401 // ircEvent.getParam (1).toStdString ().c_str ());
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
402 }
13588
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
403 else if (command == IRCCommand::PrivateMessage)
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
404 {
13585
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
405 emit message (ircEvent.parameter (0), ircEvent.nick (), ircEvent.parameter (1));
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
406 }
13588
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
407 else if (command == IRCCommand::Notice)
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
408 {
13585
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
409 emit notification (ircEvent.nick ().toStdString ().c_str (),
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
410 ircEvent.parameter (1).toStdString ().c_str ());
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
411 }
13588
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
412 else if (command == IRCCommand::Ping)
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
413 {
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
414 sendIRCCommand (IRCCommand::Pong, QStringList (m_nickname));
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
415 }
13588
52fd3b9ea848 Changed all #defines for IRC Codes to constants, as it should be. Assorted them in namespaces and gave them better readable names.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13585
diff changeset
416 else if (command == IRCCommand::Error)
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
417 {
13585
f0d6f2ff45de Now making correct use of the interface for the IRC Interface.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13583
diff changeset
418 emit error (ircEvent.parameter (0));
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
419 }
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
420 else
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
421 {
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
422 emit debugMessage (QString("FIXME: Received unknown reply: %1").arg(command));
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
423 // not recognized.
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
424 }
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
425 }
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
426 }
13580
64a3a1f23718 Further developed new IRC class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13579
diff changeset
427 }
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
428
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
429 void
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
430 IRCClientImpl::sendLine (const QString &line)
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
431 {
13592
83e83a704383 IRC traffic in console.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13591
diff changeset
432 emit debugMessage (QString ("<<<send: \"%1\"").arg (line));
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
433 if (m_connected)
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
434 m_tcpSocket.write ((line + "\r\n").toStdString ().c_str ());
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
435 }
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
436
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
437 void
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
438 IRCClientImpl::sendIRCCommand (const QString &command, const QStringList &arguments)
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
439 {
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
440 QString line = command;
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
441 for (int i = 0; i < arguments.size (); i++)
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
442 {
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
443 bool applyColon = false;
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
444 // Usually all parameters are separated by spaces.
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
445 // The last parameter of the message may contain spaces, it is usually used
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
446 // to transmit messages. In order to parse it correctly, if needs to be prefixed
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
447 // with a colon, so the server knows to ignore all forthcoming spaces and has to treat
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
448 // all remaining characters as a single parameter. If we detect any whitespace in the
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
449 // last argument, prefix it with a colon:
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
450 if ((i == arguments.size () - 1) && arguments.at (i).contains (QRegExp("\\s")))
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
451 applyColon = true;
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
452 line += QString (" %1%2").arg (applyColon ? ":" : "").arg (arguments.at (i));
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
453 }
13591
b2ee41559bff Refactored IRC code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13588
diff changeset
454 sendLine (line);
13581
3e5a8ef9c76d Completely rewrote IRC client backend to make it platform-independent. Not all functionality has been reimplemented as of yet, though.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13580
diff changeset
455 }