linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #05378
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2870: Fix discrepancies in the /conn chat command
------------------------------------------------------------
revno: 2870
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Tue 2012-02-21 23:11:22 +0100
message:
Fix discrepancies in the /conn chat command
modified:
changelog.txt
dcpp/ConnectivityManager.cpp
dcpp/ConnectivityManager.h
dcpp/MappingManager.cpp
dcpp/MappingManager.h
win32/AspectChat.h
win32/HubFrame.cpp
win32/PrivateFrame.cpp
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'changelog.txt'
--- changelog.txt 2012-02-17 23:34:33 +0000
+++ changelog.txt 2012-02-21 22:11:22 +0000
@@ -21,6 +21,7 @@
* [L#923612] Show the last chat line in taskbar previews (poy)
* Show chat logs with a dim text color (poy)
* Re-add lost user information tooltips (poy)
+* Fix discrepancies in the /conn chat command (poy)
-- 0.791 2012-01-14 --
* Update translations
=== modified file 'dcpp/ConnectivityManager.cpp'
--- dcpp/ConnectivityManager.cpp 2012-01-13 20:55:20 +0000
+++ dcpp/ConnectivityManager.cpp 2012-02-21 22:11:22 +0000
@@ -115,9 +115,7 @@
autoSettings[SettingsManager::INCOMING_CONNECTIONS] = SettingsManager::INCOMING_FIREWALL_UPNP;
log(_("Local network with possible NAT detected, trying to map the ports..."));
- if(!MappingManager::getInstance()->open()) {
- running = false;
- }
+ startMapping();
}
void ConnectivityManager::setup(bool settingsChanged) {
@@ -134,9 +132,9 @@
MappingManager::getInstance()->close();
}
startSocket();
- } else if(SETTING(INCOMING_CONNECTIONS) == SettingsManager::INCOMING_FIREWALL_UPNP && !MappingManager::getInstance()->getOpened()) {
+ } else if(SETTING(INCOMING_CONNECTIONS) == SettingsManager::INCOMING_FIREWALL_UPNP && !running) {
// previous mappings had failed; try again
- MappingManager::getInstance()->open();
+ startMapping();
}
}
}
@@ -158,6 +156,10 @@
}
string ConnectivityManager::getInformation() const {
+ if(running) {
+ return _("Connectivity settings are being configured; try again later");
+ }
+
string autoStatus = ok() ? str(F_("enabled - %1%") % getStatus()) : _("disabled");
string mode;
@@ -170,7 +172,8 @@
}
case SettingsManager::INCOMING_FIREWALL_UPNP:
{
- mode = str(F_("Connection behind a router that %1% has configured with %2%") % APPNAME % SETTING(MAPPER));
+ mode = str(F_("Active mode behind a router that %1% can configure; port mapping status: %2%") %
+ APPNAME % MappingManager::getInstance()->getStatus());
break;
}
case SettingsManager::INCOMING_FIREWALL_NAT:
@@ -201,6 +204,13 @@
ConnectionManager::getInstance()->getSecurePort() % SearchManager::getInstance()->getPort());
}
+void ConnectivityManager::startMapping() {
+ running = true;
+ if(!MappingManager::getInstance()->open()) {
+ running = false;
+ }
+}
+
void ConnectivityManager::mappingFinished(const string& mapper) {
if(BOOLSETTING(AUTO_DETECT_CONNECTION)) {
if(mapper.empty()) {
@@ -235,8 +245,8 @@
listen();
// must be done after listen calls; otherwise ports won't be set
- if(SETTING(INCOMING_CONNECTIONS) == SettingsManager::INCOMING_FIREWALL_UPNP)
- MappingManager::getInstance()->open();
+ if(SETTING(INCOMING_CONNECTIONS) == SettingsManager::INCOMING_FIREWALL_UPNP && !running)
+ startMapping();
}
}
=== modified file 'dcpp/ConnectivityManager.h'
--- dcpp/ConnectivityManager.h 2012-01-13 20:55:20 +0000
+++ dcpp/ConnectivityManager.h 2012-02-21 22:11:22 +0000
@@ -71,6 +71,7 @@
ConnectivityManager();
virtual ~ConnectivityManager() { }
+ void startMapping();
void mappingFinished(const string& mapper);
void log(string&& message);
=== modified file 'dcpp/MappingManager.cpp'
--- dcpp/MappingManager.cpp 2012-01-13 20:55:20 +0000
+++ dcpp/MappingManager.cpp 2012-02-21 22:11:22 +0000
@@ -82,6 +82,15 @@
return working.get();
}
+string MappingManager::getStatus() const {
+ if(working.get()) {
+ auto& mapper = *working;
+ return str(F_("Successfully created port mappings on the %1% device with the %2% interface") %
+ deviceString(mapper) % mapper.getName());
+ }
+ return _("Failed to create port mappings");
+}
+
int MappingManager::run() {
ScopedFunctor([this] { busy.clear(); });
=== modified file 'dcpp/MappingManager.h'
--- dcpp/MappingManager.h 2012-01-23 20:18:58 +0000
+++ dcpp/MappingManager.h 2012-02-21 22:11:22 +0000
@@ -60,7 +60,11 @@
bool open();
void close();
+ /** whether a working port mapping implementation is currently in use. */
bool getOpened() const;
+ /** get information about the currently working implementation, if there is one; or a status
+ string stating otherwise. */
+ string getStatus() const;
private:
friend class Singleton<MappingManager>;
=== modified file 'win32/AspectChat.h'
--- win32/AspectChat.h 2012-02-17 20:56:23 +0000
+++ win32/AspectChat.h 2012-02-21 22:11:22 +0000
@@ -72,9 +72,9 @@
virtual ~AspectChat() { }
- /// add a chat message and call addedChat.
+ /// add a chat message with some formatting and call addedChat.
void addChat(const tstring& message) {
- addChatPlain(message);
+ addChatPlain(Text::toT("[" + Util::getShortTimeString() + "] ") + message);
t().addedChat(message);
}
@@ -84,7 +84,7 @@
t().addedChat(Text::toT(message.message));
}
- /// add a plain text message.
+ /// add a plain text string directly, with no formatting.
void addChatPlain(const tstring& message) {
addChatRTF(dwt::RichTextBox::rtfEscape(message));
}
@@ -102,7 +102,6 @@
addChatRTF(HtmlToRtf::convert(message, chat));
}
-protected:
void readLog(const string& logPath, const unsigned setting) {
if(setting == 0)
return;
=== modified file 'win32/HubFrame.cpp'
--- win32/HubFrame.cpp 2012-02-17 20:56:23 +0000
+++ win32/HubFrame.cpp 2012-02-21 22:11:22 +0000
@@ -431,7 +431,7 @@
showUsers->setChecked(!showUsers->getChecked());
handleShowUsersClicked();
} else if(Util::stricmp(cmd.c_str(), _T("conn")) == 0 || Util::stricmp(cmd.c_str(), _T("connection")) == 0) {
- addChat(Text::toT(ConnectivityManager::getInstance()->getInformation()));
+ addChat(_T("*** ") + Text::toT(ConnectivityManager::getInstance()->getInformation()));
} else if((Util::stricmp(cmd.c_str(), _T("favorite")) == 0) || (Util::stricmp(cmd.c_str(), _T("fav")) == 0)) {
addAsFavorite();
} else if((Util::stricmp(cmd.c_str(), _T("removefavorite")) == 0) || (Util::stricmp(cmd.c_str(), _T("removefav")) == 0)) {
@@ -536,16 +536,14 @@
}
void HubFrame::addStatus(const tstring& text, bool legitimate /* = true */) {
- auto message = Text::toT("[" + Util::getShortTimeString() + "] ") + text;
-
- status->setText(STATUS_STATUS, message);
+ status->setText(STATUS_STATUS, Text::toT("[" + Util::getShortTimeString() + "] ") + text);
if(legitimate) {
if(BOOLSETTING(STATUS_IN_CHAT)) {
- addChatPlain(_T("*** ") + message);
- addedChat(text); // addedChat expects a message with no timestamp
- } else
+ addChat(_T("*** ") + text);
+ } else {
setDirty(SettingsManager::BOLD_HUB);
+ }
}
if(BOOLSETTING(LOG_STATUS_MESSAGES)) {
@@ -577,14 +575,14 @@
UserTask& u = static_cast<UserTask&>(*i->second);
if(updateUser(u)) {
if (showJoins || (favShowJoins && FavoriteManager::getInstance()->isFavoriteUser(u.user))) {
- addStatus(str(TF_("*** Joins: %1%") % Text::toT(u.identity.getNick())));
+ addStatus(str(TF_("Joins: %1%") % Text::toT(u.identity.getNick())));
}
}
} else if(i->first == REMOVE_USER) {
UserTask& u = static_cast<UserTask&>(*i->second);
removeUser(u.user);
if (showJoins || (favShowJoins && FavoriteManager::getInstance()->isFavoriteUser(u.user))) {
- addStatus(str(TF_("*** Parts: %1%") % Text::toT(u.identity.getNick())));
+ addStatus(str(TF_("Parts: %1%") % Text::toT(u.identity.getNick())));
}
}
}
=== modified file 'win32/PrivateFrame.cpp'
--- win32/PrivateFrame.cpp 2012-02-17 20:56:23 +0000
+++ win32/PrivateFrame.cpp 2012-02-21 22:11:22 +0000
@@ -209,13 +209,12 @@
}
void PrivateFrame::addStatus(const tstring& text) {
- auto message = Text::toT("[" + Util::getShortTimeString() + "] ") + text;
-
- status->setText(STATUS_STATUS, message);
+ status->setText(STATUS_STATUS, Text::toT("[" + Util::getShortTimeString() + "] ") + text);
if(BOOLSETTING(STATUS_IN_CHAT)) {
- addChatPlain(_T("*** ") + message);
- addedChat(text); // addedChat expects a message with no timestamp
+ addChat(_T("*** ") + text);
+ } else {
+ setDirty(SettingsManager::BOLD_PM);
}
}
@@ -342,7 +341,7 @@
} else if(Util::stricmp(cmd.c_str(), _T("log")) == 0) {
openLog();
} else if(Util::stricmp(cmd.c_str(), _T("help")) == 0) {
- addStatus(_T("*** ") + WinUtil::commands + _T(", /getlist, /grant, /close, /favorite, /ignore, /unignore, /log <system, downloads, uploads>"));
+ addChat(_T("*** ") + WinUtil::commands + _T(", /getlist, /grant, /close, /favorite, /ignore, /unignore, /log <system, downloads, uploads>"));
} else {
send = true;
}