Commit Graph

65 Commits

Author SHA1 Message Date
J-P Nurmi
5880bb4180 Add CMessage::GetType() 2015-09-07 00:00:25 +02:00
J-P Nurmi
2bee156316 CString CMessage::GetParams(): keep the colon, even at the beginning 2015-09-07 00:00:25 +02:00
J-P Nurmi
58fc0e91d7 Add CCTCPMessage::IsReply() 2015-09-07 00:00:24 +02:00
J-P Nurmi
ec952024d7 Add CModeMessage 2015-09-07 00:00:24 +02:00
J-P Nurmi
fa894a86b0 Add CNumericMessage 2015-09-07 00:00:24 +02:00
J-P Nurmi
50ed9adf8a Fix CMessage::GetParams() crash - thanks kerio 2015-09-05 23:45:26 +02:00
Alexey Sokolov
78ba391d70 Merge branch 'master' of github.com:znc/znc 2015-09-04 20:33:12 +01:00
Alexey Sokolov
1cc4626226 Add a test for --makeconf 2015-09-04 20:32:13 +01:00
J-P Nurmi
a79acacfad Add missing CModules::OnCTCPReplyMessage() 2015-09-02 00:51:05 +02:00
J-P Nurmi
491fb50045 Cleanup MessageTest
Use CMessage::Parse(), which wasn't public when the tests were
originally written, to avoid the ugly static_casts.
2015-09-01 23:37:22 +02:00
J-P Nurmi
94055c1c82 Add ModulesTest
Just a simple unit test for CModules that checks that the legacy hooks
get called and any modifications flow back to the original CMessage
object as appropriate.
2015-08-31 00:24:30 +02:00
J-P Nurmi
55385a5d58 Add CTargetMessage: a base class for "targeted" priv/chan messages
This will be useful for implementing the upcoming OnUserXxxMessage()
module hooks, that are allowed to modify the message target.
2015-08-30 15:50:12 +02:00
J-P Nurmi
320abef756 Merge CChanMessage & CPrivMessage to... CTextMessage
This naming is a bit hairy. I chose CTextMessage because this type of
message carries a text argument. Alternatively, it could be also called
CPrivateMessage, because the IRC protocol calls it PRIVMSG. On the other
hand, ZNC module hooks use the "Priv" naming convention for private
messages. It would look a bit weird to have OnChanMsg(CPrivMessage)...

More details and reasoning of the merge in the previous commit message.
2015-08-30 15:50:12 +02:00
J-P Nurmi
3976651c35 Merge CChan+PrivAction, CChan+PrivCTCP, CChan+PrivNotice
OnUserAction(), OnUserCTCP(), and OnUserNotice() don't separate private
private and channel messages. A module could even redirect a message by
modifying its target, so technically, if they were two distinct types,
the type of a message could change on the way.

The original reason for the separation was that at some point during
CMessage development, GetChan() didn't exist in CPrivXxx, but only in
CChanXxx message types. To achieve cleaner implementation, the getter
was later promoted to CMessage and made return nullptr for non-channel
specific messages. From this point of view, the separation is also no
longer necessary since the CPrivXxx and CChanXxx types are API-wise
identical with each other.
2015-08-30 15:50:12 +02:00
J-P Nurmi
0ecc0d464f Make params optiona for the CMessage(CNick, CString, ...) ctor
Also fixes the build for Clang <= 3.4, broken by 9a7df7c.
2015-08-27 13:21:45 +02:00
J-P Nurmi
37cd61a667 Fix CMessage to prefix also empty last params with a colon 2015-08-27 12:33:47 +02:00
J-P Nurmi
9a7df7cbbe MessageTest: test also CMessage(CNick, CString, ...) 2015-08-27 12:31:57 +02:00
J-P Nurmi
e1ae565e6f Fix GetText() for CTCP [ACTION]
Just like the recent problem with smileys; TrimLeft() is not the same
than TrimPrefix(), and TrimRight() is not the same than TrimSuffix().
2015-08-23 00:48:35 +02:00
J-P Nurmi
2ad2ee5620 Bring back the smileys - part II 2015-08-22 11:54:33 +02:00
J-P Nurmi
b8088a5b02 Fix CMessage::ToString() to ':' -prefix the last param when appropriate
Close #1037
2015-08-21 22:08:16 +02:00
J-P Nurmi
ff181a4a85 Add specialized types and hooks for the most common msgs
PRIVMSG, NOTICE, JOIN, PART, QUIT, NICK, KICK, TOPIC
2015-08-15 12:27:06 +02:00
J-P Nurmi
a06bf1c985 Introduce a Message type (#506) 2015-08-15 12:26:16 +02:00
J-P Nurmi
51caa5c4cf Add CUtils::ParseServerTime() 2015-08-15 12:26:16 +02:00
J-P Nurmi
87ae630046 Merge pull request #991 from jpnurmi/initializer_list
Add initializer_list ctors for CString & MCString
2015-07-31 22:08:43 +02:00
J-P Nurmi
d5cefbfb71 Fix StringTest
- EXPECT_EQ() takes the expected value first
2015-07-13 20:22:03 +02:00
J-P Nurmi
1aba508298 Add initializer_list ctors for CString & MCString 2015-07-13 19:04:14 +02:00
J-P Nurmi
56a92d4c0b Fix NetworkTest
- fix signed vs. unsigned comparison warning
- EXPECT_EQ() takes the expected value first
2015-07-13 18:32:27 +02:00
Alexey Sokolov
da279f9622 Setup continuous testing on cygwin using AppVeyor 2015-05-04 10:17:58 +01:00
J-P Nurmi
75b210e841 Search'n'replace remaining NULL occurrences (#816) 2015-02-26 20:58:01 +01:00
Alexey Sokolov
962cb945eb Merge pull request #869 from jpnurmi/wildcmp
CString::WildCmp(): add an optional case-sensitivity argument
2015-02-23 00:05:25 -08:00
J-P Nurmi
afaf255246 CString::WildCmp(): add an optional case-sensitivity argument
It's getting a common pattern to call AsLower() or MakeLower() on
the arguments passed to WildCmp(), we might as well add this for
convenience. It's tempting to make it case-insensitive by default,
since pretty much any IRC related comparison should be, but that
could potentially break some existing code.
2015-02-23 08:45:52 +01:00
J-P Nurmi
7345a6ee3a Fix CIRCNetwork::FindChans() and FindQueries() to be case-insensitive
The playback module failed to clear a buffer, because it tried to
clear "NickServ" whereas ZNC had internally stored it has "nickserv".
2015-02-19 08:45:58 +01:00
Falk Seidel
2e29d49a53 Welcome to 2015 2014-12-31 11:28:38 +01:00
J-P Nurmi
8d77faa260 Allow clients to specify an ID via PASS or USER
- PASS [user[@identifier][/network]:]password
- USER user[@identifier][/network] ...

NOTE: There's a slight ambiguosity with the '@' character, which happens
to be a valid character in usernames, but also acts as a marker for the
identifier. Therefore, '@' is considered as part of the username if it's
followed by non-word characters (as in an email address), otherwise as
a marker for an identifier.

This is only an enabler for #343. The rest can be done with modules:
- managing client ID specific playback buffers
- filtering channels based on the client ID

The reason this should be part of ZNC core is that only global modules
have access to OnUnknownUserRaw(), which is needed to capture USER/PASS.
First of all, the aforementioned modules shouldn't be global. Furthermore,
it would be possible to have only one module that parsed and removed the
client ID so that ZNC core woulnd't choke.
2014-11-04 00:42:28 +01:00
J-P Nurmi
8fdf51dfeb Fix CNick::Parse()
If the mask started with ':', the following '!' was included to nick.
2014-11-01 13:17:32 +01:00
Alexey Sokolov
213c3839a8 Merge pull request #693 from jpnurmi/tags
Valueless & escaped message tags
2014-09-29 23:53:55 +01:00
J-P Nurmi
e20ac1a31e Add CString::Contains() for convenience
This is more convenient and readable than comparing Find() to npos,
which is a common task:

$ git grep "find(" | grep "npos" | wc -l
49
2014-09-30 00:15:34 +02:00
J-P Nurmi
5507e9a290 Add CString::Find() with case sensitivity support 2014-09-30 00:15:22 +02:00
J-P Nurmi
92c9a2e6ae Escape message tag values (ref #684) 2014-09-30 00:02:22 +02:00
J-P Nurmi
65f739980d CString::Starts/EndsWith(): allow specifying case sensitivity 2014-09-29 16:41:07 +02:00
J-P Nurmi
e86f43d841 Introduce CaseSensitivity enum class
The enum is a bit more verbose, but leads to more readable code:

str.Equals("foo", true)
// vs.
str.Equals("foo", CString::CaseSensitive)

Deprecate the old Equals() and leave out the length parameter
from the new version => use StartsWith() or StrCmp() instead.
2014-09-29 16:30:45 +02:00
J-P Nurmi
615801c40e Fix valueless message tags (closes #684) 2014-09-29 14:06:41 +02:00
Uli Schlachter
74fdd97a52 CJob: Even cancel finished jobs
When a job was cancelled after its runThread() method finished, but before the
main thread noticed this and reacted, we would just run runMain() before and
pretend the job finished normally.

However, with CModuleJob this means that runMain() might get called for a module
which is currently being destructed. This has bad effects with virtual functions
and thus causes problems. It's better to just really cancel the job instead.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-08-11 09:09:38 +02:00
Uli Schlachter
1d67e87d90 CThreadPool: Add cancellation support
This adds CThreadPool::cancelJob() and cancelJobs() which can cancel a set of
jobs synchronously. These functions only return when the job was successfully
cancelled.

It tries to cancel the jobs as quickly as possible, skipping any callbacks on
CJob that were not yet called. A job that is already running can use
CJob::wasCancelled() to check if it should quit.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-08-06 15:15:57 +02:00
Uli Schlachter
0e057702db Add a ThreadTest to the testsuite
Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-08-06 14:50:59 +02:00
Uli Schlachter
d4fefd1888 StringTest: Make a local function static
Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-08-06 14:50:58 +02:00
Alexey Sokolov
5237e89bc3 Fix message tags parser and add test of it 2014-03-03 22:35:56 +00:00
Alexey Sokolov
0696a6ed23 Cleanup old tests (pre-gtest) 2014-03-03 21:38:18 +00:00
Falk Seidel
f19b4caa43 Welcome to 2014 - year 10 with ZNC 2013-12-31 10:10:55 +01:00
Alexey Sokolov
256be59ffe Test CConfig too 2013-10-13 21:00:44 +04:00