Diffstat (limited to 'noncore/net/opieirc/ircmessage.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircmessage.cpp | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/noncore/net/opieirc/ircmessage.cpp b/noncore/net/opieirc/ircmessage.cpp index d823ad1..d0b2652 100644 --- a/noncore/net/opieirc/ircmessage.cpp +++ b/noncore/net/opieirc/ircmessage.cpp | |||
@@ -1,4 +1,7 @@ | |||
1 | #include <qtextstream.h> | 1 | #include <qtextstream.h> |
2 | #include <qstring.h> | ||
3 | #include <qstringlist.h> | ||
4 | |||
2 | #include "ircmessage.h" | 5 | #include "ircmessage.h" |
3 | 6 | ||
4 | /* | 7 | /* |
@@ -64,8 +67,8 @@ IRCMessage::IRCMessage(QString line) { | |||
64 | m_ctcp = FALSE; | 67 | m_ctcp = FALSE; |
65 | } | 68 | } |
66 | 69 | ||
67 | /* | 70 | /* |
68 | -- Uncomment to debug -- | 71 | //-- Uncomment to debug -- |
69 | 72 | ||
70 | printf("Parsed : '%s'\n", line.ascii()); | 73 | printf("Parsed : '%s'\n", line.ascii()); |
71 | printf("Prefix : '%s'\n", m_prefix.ascii()); | 74 | printf("Prefix : '%s'\n", m_prefix.ascii()); |
@@ -76,7 +79,8 @@ IRCMessage::IRCMessage(QString line) { | |||
76 | } | 79 | } |
77 | printf("CTCP Command : '%s'\n", m_ctcpCommand.latin1()); | 80 | printf("CTCP Command : '%s'\n", m_ctcpCommand.latin1()); |
78 | printf("CTCP Destination : '%s'\n", m_ctcpDestination.latin1()); | 81 | printf("CTCP Destination : '%s'\n", m_ctcpDestination.latin1()); |
79 | printf("CTCP param count is : '%i'\n", m_parameters.count()); | 82 | printf("CTCP param count is : '%i'\n", m_parameters.count()); |
83 | |||
80 | */ | 84 | */ |
81 | } | 85 | } |
82 | 86 | ||
@@ -84,6 +88,31 @@ QString IRCMessage::param(int param) { | |||
84 | return m_parameters[param]; | 88 | return m_parameters[param]; |
85 | } | 89 | } |
86 | 90 | ||
91 | QStringList IRCMessage::params(const QString ¶mstring) const { | ||
92 | QStringList params, retvalue; | ||
93 | params = QStringList::split(',', paramstring); | ||
94 | QStringList::Iterator end = params.end(); | ||
95 | |||
96 | for (QStringList::Iterator it = params.begin(); it != end; ++it) { | ||
97 | int pos = (*it).find(':'); | ||
98 | if(pos < 0) { | ||
99 | if((*it).toInt() < m_parameters.count()) | ||
100 | retvalue << m_parameters[(*it).toInt()]; | ||
101 | } | ||
102 | |||
103 | else { | ||
104 | int start, end; | ||
105 | start = (*it).left(pos).toInt(); | ||
106 | end = (*it).mid(pos+1).toInt(); | ||
107 | for (int i=start;i<=end && i < m_parameters.count() ;++i) { | ||
108 | retvalue << m_parameters[i]; | ||
109 | } | ||
110 | } | ||
111 | } | ||
112 | |||
113 | return retvalue; | ||
114 | } | ||
115 | |||
87 | QString IRCMessage::prefix() { | 116 | QString IRCMessage::prefix() { |
88 | return m_prefix; | 117 | return m_prefix; |
89 | } | 118 | } |