Index: dcpp/AdcHub.cpp
===================================================================
--- dcpp/AdcHub.cpp (revision 1000)
+++ dcpp/AdcHub.cpp (working copy)
@@ -136,8 +136,8 @@
if(!c.getParam("NI", 0, nick)) {
nick = "[nick unknown]";
}
- fire(ClientListener::StatusMessage(), this, u->getIdentity().getNick() + " (" + u->getIdentity().getSIDString() +
- ") has same CID {" + cid + "} as " + nick + " (" + AdcCommand::fromSID(c.getFrom()) + "), ignoring.");
+ fire(ClientListener::Message(), this, ClientListener::STATUS_MESSAGE, str(F_("%1% (%2%) has same CID {%3%} as %4% (%5%), ignoring")
+ % u->getIdentity().getNick() % u->getIdentity().getSIDString() % cid % nick % AdcCommand::fromSID(c.getFrom())));
return;
}
} else {
@@ -203,13 +203,13 @@
}
if(!baseOk) {
- fire(ClientListener::StatusMessage(), this, "Failed to negotiate base protocol"); // @todo internationalize
+ fire(ClientListener::Message(), this, ClientListener::STATUS_MESSAGE, _("Failed to negotiate base protocol"));
socket->disconnect(false);
return;
} else if(!tigrOk) {
oldPassword = true;
// Some hubs fake BASE support without TIGR support =/
- fire(ClientListener::StatusMessage(), this, "Hub probably uses an old version of ADC, please encourage the owner to upgrade");
+ fire(ClientListener::Message(), this, ClientListener::STATUS_MESSAGE, _("Hub probably uses an old version of ADC, please encourage the owner to upgrade"));
}
}
@@ -248,7 +248,7 @@
fire(ClientListener::PrivateMessage(), this, *from, *to, *replyTo, c.getParam(0), c.hasFlag("ME", 1));
} else {
- fire(ClientListener::Message(), this, *from, c.getParam(0), c.hasFlag("ME", 1));
+ fire(ClientListener::Message(), this, ClientListener::MESSAGE, Util::formatMessage((*from).getIdentity().getNick(), c.getParam(0), c.hasFlag("ME", 1)));
}
}
@@ -267,7 +267,7 @@
string tmp;
if(c.getParam("MS", 1, tmp)) {
- fire(ClientListener::StatusMessage(), this, tmp);
+ fire(ClientListener::Message(), this, ClientListener::STATUS_MESSAGE, tmp);
}
if(s == sid) {
@@ -454,7 +454,7 @@
ConnectionManager::getInstance()->force(u->getUser());
}
}
- fire(ClientListener::Message(), this, *u, c.getParam(1));
+ fire(ClientListener::Message(), this, ClientListener::MESSAGE, Util::formatMessage((*u).getIdentity().getNick(), c.getParam(1)));
}
void AdcHub::handle(AdcCommand::SCH, AdcCommand& c) throw() {
@@ -760,7 +760,7 @@
Client::on(l, aLine);
if(BOOLSETTING(ADC_DEBUG)) {
- fire(ClientListener::StatusMessage(), this, "" + aLine + "");
+ fire(ClientListener::Message(), this, ClientListener::STATUS_MESSAGE, "" + aLine + "");
}
dispatch(aLine);
}
Index: dcpp/ClientListener.h
===================================================================
--- dcpp/ClientListener.h (revision 1000)
+++ dcpp/ClientListener.h (working copy)
@@ -21,14 +21,19 @@
typedef X<8> GetPassword;
typedef X<9> HubUpdated;
typedef X<11> Message;
- typedef X<12> StatusMessage;
- typedef X<13> PrivateMessage;
- typedef X<14> HubUserCommand;
- typedef X<15> HubFull;
- typedef X<16> NickTaken;
- typedef X<17> SearchFlood;
- typedef X<18> NmdcSearch;
- typedef X<19> AdcSearch;
+ typedef X<12> PrivateMessage;
+ typedef X<13> HubUserCommand;
+ typedef X<14> HubFull;
+ typedef X<15> NickTaken;
+ typedef X<16> SearchFlood;
+ typedef X<17> NmdcSearch;
+ typedef X<18> AdcSearch;
+
+ enum MessageType {
+ MESSAGE,
+ STATUS_MESSAGE,
+ SILENT_STATUS_MESSAGE
+ };
virtual void on(Connecting, Client*) throw() { }
virtual void on(Connected, Client*) throw() { }
@@ -39,8 +44,7 @@
virtual void on(Failed, Client*, const string&) throw() { }
virtual void on(GetPassword, Client*) throw() { }
virtual void on(HubUpdated, Client*) throw() { }
- virtual void on(Message, Client*, const OnlineUser&, const string&, bool = false) throw() { }
- virtual void on(StatusMessage, Client*, const string&) throw() { }
+ virtual void on(Message, Client*, MessageType messageType, const string&) throw() { }
virtual void on(PrivateMessage, Client*, const OnlineUser&, const OnlineUser&, const OnlineUser&, const string&, bool = false) throw() { }
virtual void on(HubUserCommand, Client*, int, int, const string&, const string&) throw() { }
virtual void on(HubFull, Client*) throw() { }
Index: dcpp/NmdcHub.cpp
===================================================================
--- dcpp/NmdcHub.cpp (revision 1000)
+++ dcpp/NmdcHub.cpp (working copy)
@@ -181,12 +181,12 @@
}
string line = toUtf8(aLine);
if(line[0] != '<') {
- fire(ClientListener::StatusMessage(), this, unescape(line));
+ fire(ClientListener::Message(), this, ClientListener::STATUS_MESSAGE, unescape(line));
return;
}
string::size_type i = line.find('>', 2);
if(i == string::npos) {
- fire(ClientListener::StatusMessage(), this, unescape(line));
+ fire(ClientListener::Message(), this, ClientListener::STATUS_MESSAGE, unescape(line));
return;
}
string nick = line.substr(1, i-1);
@@ -194,13 +194,23 @@
if((line.length()-1) > i) {
message = line.substr(i+2);
} else {
- fire(ClientListener::StatusMessage(), this, unescape(line));
+ fire(ClientListener::Message(), this, ClientListener::STATUS_MESSAGE, unescape(line));
return;
}
+ if(SETTING(FILTER_MESSAGES)) {
+ if((line.find("Hub-Security") != string::npos) && (line.find("was kicked by") != string::npos)) {
+ // Do nothing...
+ return;
+ } else if((line.find("is kicking") != string::npos) && (line.find("because:") != string::npos)) {
+ fire(ClientListener::Message(), this, ClientListener::SILENT_STATUS_MESSAGE, unescape(line));
+ return;
+ }
+ }
+
OnlineUser* ou = findUser(nick);
if(ou) {
- fire(ClientListener::Message(), this, *ou, unescape(message));
+ fire(ClientListener::Message(), this, ClientListener::MESSAGE, Util::formatMessage((*ou).getIdentity().getNick(), unescape(message)));
} else {
OnlineUser& o = getUser(nick);
// Assume that messages from unknown users come from the hub
@@ -208,7 +218,7 @@
o.getIdentity().setHidden(true);
fire(ClientListener::UserUpdated(), this, o);
- fire(ClientListener::Message(), this, o, unescape(message));
+ fire(ClientListener::Message(), this, ClientListener::MESSAGE, Util::formatMessage(o.getIdentity().getNick(), unescape(message)));
}
return;
}
Index: dcpp/Util.h
===================================================================
--- dcpp/Util.h (revision 1000)
+++ dcpp/Util.h (working copy)
@@ -183,7 +183,7 @@
static string cleanPathChars(string aNick);
static string formatBytes(const string& aString) { return formatBytes(toInt64(aString)); }
- static string formatMessage(const string& nick, const string& message, bool thirdPerson);
+ static string formatMessage(const string& nick, const string& message, bool thirdPerson = false);
static string getShortTimeString(time_t t = time(NULL) );
Index: win32/HubFrame.cpp
===================================================================
--- win32/HubFrame.cpp (revision 1000)
+++ win32/HubFrame.cpp (working copy)
@@ -876,24 +876,18 @@
speak(SET_WINDOW_TITLE, hubName);
}
-void HubFrame::on(Message, Client*, const OnlineUser& from, const string& msg, bool thirdPerson) throw() {
- if(SETTING(FILTER_MESSAGES)) {
- if((msg.find("Hub-Security") != string::npos) && (msg.find("was kicked by") != string::npos)) {
- // Do nothing...
- } else if((msg.find("is kicking") != string::npos) && (msg.find("because:") != string::npos)) {
- speak(ADD_SILENT_STATUS_LINE, msg);
- } else {
- speak(ADD_CHAT_LINE, Util::formatMessage(from.getIdentity().getNick(), msg, thirdPerson));
- }
+void HubFrame::on(Message, Client*, ClientListener::MessageType messageType, const string& msg) throw() {
+ if(messageType == ClientListener::MESSAGE) {
+ speak(ADD_CHAT_LINE, msg);
+ } else if(messageType == ClientListener::STATUS_MESSAGE) {
+ speak(ADD_STATUS_LINE, msg);
+ } else if(messageType == ClientListener::SILENT_STATUS_MESSAGE) {
+ speak(ADD_SILENT_STATUS_LINE, msg);
} else {
- speak(ADD_CHAT_LINE, Util::formatMessage(from.getIdentity().getNick(), msg, thirdPerson));
+ // Should never get here, leaves room for future additions to MessageType
}
}
-void HubFrame::on(StatusMessage, Client*, const string& line) throw() {
- speak(ADD_CHAT_LINE, line);
-}
-
void HubFrame::on(PrivateMessage, Client*, const OnlineUser& from, const OnlineUser& to, const OnlineUser& replyTo, const string& line, bool thirdPerson) throw() {
speak(from, to, replyTo, Util::formatMessage(from.getIdentity().getNick(), line, thirdPerson));
}
Index: win32/HubFrame.h
===================================================================
--- win32/HubFrame.h (revision 1000)
+++ win32/HubFrame.h (working copy)
@@ -274,8 +274,7 @@
virtual void on(Failed, Client*, const string&) throw();
virtual void on(GetPassword, Client*) throw();
virtual void on(HubUpdated, Client*) throw();
- virtual void on(Message, Client*, const OnlineUser&, const string&, bool = false) throw();
- virtual void on(StatusMessage, Client*, const string&) throw();
+ virtual void on(Message, Client*, ClientListener::MessageType messageType, const string&) throw();
virtual void on(PrivateMessage, Client*, const OnlineUser&, const OnlineUser&, const OnlineUser&, const string&, bool = false) throw();
virtual void on(NickTaken, Client*) throw();
virtual void on(SearchFlood, Client*, const string&) throw();