summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircmessage.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/noncore/net/opieirc/ircmessage.cpp b/noncore/net/opieirc/ircmessage.cpp
index 1b7072e..da8db77 100644
--- a/noncore/net/opieirc/ircmessage.cpp
+++ b/noncore/net/opieirc/ircmessage.cpp
@@ -31,87 +31,87 @@ IRCMessage::IRCMessage(QString line) {
31 m_allParameters = line.right(line.length() - m_prefix.length() - m_command.length() - 3); 31 m_allParameters = line.right(line.length() - m_prefix.length() - m_command.length() - 3);
32 } else { 32 } else {
33 m_command = temp.upper(); 33 m_command = temp.upper();
34 m_allParameters = line.right(line.length() - m_command.length() - 1); 34 m_allParameters = line.right(line.length() - m_command.length() - 1);
35 } 35 }
36 36
37 /* Create a list of all parameters */ 37 /* Create a list of all parameters */
38 while(!(stream.atEnd())) { 38 while(!(stream.atEnd())) {
39 stream >> temp; 39 stream >> temp;
40 if (temp.startsWith(":")) { 40 if (temp.startsWith(":")) {
41 /* last parameter */ 41 /* last parameter */
42 m_trailing = line.right(line.length() - line.find(QChar(':'), 1) - 1); 42 m_trailing = line.right(line.length() - line.find(QChar(':'), 1) - 1);
43 m_parameters << m_trailing; 43 m_parameters << m_trailing;
44 break; 44 break;
45 } else { 45 } else {
46 m_parameters << temp; 46 m_parameters << temp;
47 } 47 }
48 } 48 }
49 49
50 50
51 m_commandNumber = m_command.toInt(&m_isNumerical); 51 m_commandNumber = m_command.toInt(&m_isNumerical);
52 /* Is this a CTCP command */ 52 /* Is this a CTCP command */
53 if ((m_command == "PRIVMSG" || m_command == "NOTICE") && m_trailing.length()>0 && m_trailing.left(1) == QChar(1)) { 53 if ((m_command == "PRIVMSG" || m_command == "NOTICE") && m_trailing.length()>0 && m_trailing.left(1) == QChar(1)) {
54 m_ctcp = TRUE; 54 m_ctcp = TRUE;
55 if (m_command == "PRIVMSG") { 55
56 m_ctcpRequest = TRUE; 56 m_ctcpRequest = (m_command == "PRIVMSG");
57 }
58 else {
59 m_ctcpRequest = FALSE;
60 }
61 57
62 /* Strip CTCP \001 characters */ 58 /* Strip CTCP \001 characters */
63 m_allParameters = m_allParameters.replace(QRegExp(QChar(1)), ""); 59 m_allParameters = m_allParameters.replace(QRegExp(QChar(1)), "");
64 QTextIStream ctcpStream(&m_allParameters); 60 QTextIStream ctcpStream(&m_allParameters);
65 ctcpStream >> m_ctcpDestination; 61 ctcpStream >> m_ctcpDestination;
66 ctcpStream >> temp; 62 ctcpStream >> temp;
67 m_ctcpCommand = temp.upper().right(temp.length()-1); 63 m_ctcpCommand = temp.upper().right(temp.length()-1);
68 m_parameters.clear(); 64 m_parameters.clear();
69 int length = m_allParameters.length() - m_ctcpCommand.length() - 1; 65 int length = m_allParameters.length() - m_ctcpCommand.length() - 1;
70 length -= m_ctcpDestination.length() + 1; 66 length -= m_ctcpDestination.length() + 1;
71 if (length <= 0) { 67 if (length <= 0) {
72 m_allParameters = ""; 68 m_allParameters = "";
73 } 69 }
74 else { 70 else {
75 m_allParameters = m_allParameters.right(length); 71 m_allParameters = m_allParameters.right(length);
76 m_parameters << m_allParameters; 72 m_parameters << m_allParameters;
77 } 73 }
78 } 74 }
79 else { 75 else {
80 m_ctcp = FALSE; 76 m_ctcp = FALSE;
81 } 77 }
82 78
83 79
84 odebug << "Parsed: " << line << oendl; 80 odebug << "Parsed: " << line << oendl;
85 odebug << "Prefix: " << m_prefix << oendl; 81 odebug << "Prefix: " << m_prefix << oendl;
86 odebug << "Command: " << m_command << oendl; 82 odebug << "Command: " << m_command << oendl;
87 odebug << "Allparameters: " << m_allParameters << oendl; 83 odebug << "Allparameters: " << m_allParameters << oendl;
84
88 for (unsigned int i=0; i<m_parameters.count(); i++) { 85 for (unsigned int i=0; i<m_parameters.count(); i++) {
89 odebug << "Parameter " << i << ":" << m_parameters[i] << oendl; 86 odebug << "Parameter " << i << ":" << m_parameters[i] << oendl;
90 } 87 }
91 odebug << "CTCP Command: " << m_ctcpCommand << oendl; 88
92 odebug << "CTCP Destination: " << m_ctcpDestination << oendl; 89 if(m_ctcp) {
93 odebug << "CTCP param count is: " << m_parameters.count() << oendl; 90 odebug << "CTCP " << (m_ctcpRequest? "Request" : "Reply") << ": " << m_ctcpCommand << oendl;
91 odebug << "CTCP Destination: " << m_ctcpDestination << oendl;
92 odebug << "CTCP param count is: " << m_parameters.count() << oendl;
93 }
94 94
95} 95}
96 96
97QString IRCMessage::param(int param) { 97QString IRCMessage::param(int param) {
98 return m_parameters[param]; 98 return m_parameters[param];
99} 99}
100 100
101QStringList IRCMessage::params(const QString &paramstring) const { 101QStringList IRCMessage::params(const QString &paramstring) const {
102 QStringList params, retvalue; 102 QStringList params, retvalue;
103 params = QStringList::split(',', paramstring); 103 params = QStringList::split(',', paramstring);
104 QStringList::Iterator end = params.end(); 104 QStringList::Iterator end = params.end();
105 105
106 for (QStringList::Iterator it = params.begin(); it != end; ++it) { 106 for (QStringList::Iterator it = params.begin(); it != end; ++it) {
107 int pos = (*it).find(':'); 107 int pos = (*it).find(':');
108 if(pos < 0) { 108 if(pos < 0) {
109 if((*it).toUInt() < m_parameters.count()) 109 if((*it).toUInt() < m_parameters.count())
110 retvalue << m_parameters[(*it).toUInt()]; 110 retvalue << m_parameters[(*it).toUInt()];
111 } 111 }
112 112
113 else { 113 else {
114 unsigned int start, end; 114 unsigned int start, end;
115 start = (*it).left(pos).toUInt(); 115 start = (*it).left(pos).toUInt();
116 end = (*it).mid(pos+1).toUInt(); 116 end = (*it).mid(pos+1).toUInt();
117 for (unsigned int i=start;i<=end && i < m_parameters.count() ;++i) { 117 for (unsigned int i=start;i<=end && i < m_parameters.count() ;++i) {