← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 3343: close the PM conn when switching back to a hub

 

------------------------------------------------------------
revno: 3343
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Mon 2013-08-19 23:01:34 +0200
message:
  close the PM conn when switching back to a hub
modified:
  help/window_pm.html
  win32/PrivateFrame.cpp
  win32/PrivateFrame.h


--
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 'help/window_pm.html'
--- help/window_pm.html	2013-08-19 20:13:24 +0000
+++ help/window_pm.html	2013-08-19 21:01:34 +0000
@@ -63,6 +63,7 @@
 <ul>
 	<li>Click the "Communication channel" part of the status bar and select the
 	"<placeholder>Disconnect the direct encrypted channel</placeholder>" menu command.</li>
+	<li>Click the "Communication channel" part of the status bar and select a hub.</li>
 	<li>Close the private message window.</li>
 	<li>Disconnect the transfer from the
 	<placeholder><a href="window_transfers.html">Transfers</a></placeholder> list.</li>

=== modified file 'win32/PrivateFrame.cpp'
--- win32/PrivateFrame.cpp	2013-08-19 20:13:24 +0000
+++ win32/PrivateFrame.cpp	2013-08-19 21:01:34 +0000
@@ -281,7 +281,7 @@
 		updateChannel();
 
 		if(online && SETTING(ALWAYS_CCPM) && !ccReady()) {
-			startCC();
+			startCC(true);
 		}
 	}
 }
@@ -292,9 +292,9 @@
 	status->setText(STATUS_CHANNEL, channel, true);
 }
 
-void PrivateFrame::startCC() {
+void PrivateFrame::startCC(bool silent) {
 	if(ccReady()) {
-		addStatus(T_("A direct encrypted channel is already available"));
+		if(!silent) { addStatus(T_("A direct encrypted channel is already available")); }
 		return;
 	}
 
@@ -302,7 +302,7 @@
 		auto lock = ClientManager::getInstance()->lock();
 		auto ou = ClientManager::getInstance()->findOnlineUser(replyTo.getUser());
 		if(!ou) {
-			addStatus(T_("User offline"));
+			if(!silent) { addStatus(T_("User offline")); }
 			return;
 		}
 
@@ -310,21 +310,21 @@
 			!ou->getClient().isSecure() ? T_("The connection to the ADC hub used to initiate the channel must be encrypted") :
 			!ou->getIdentity().supports(AdcHub::CCPM_FEATURE) ? T_("The user does not support the CCPM ADC extension") : _T("");
 		if(!err.empty()) {
-			addStatus(str(TF_("Cannot start the direct encrypted channel: %1%") % err));
+			if(!silent) { addStatus(str(TF_("Cannot start the direct encrypted channel: %1%") % err)); }
 			return;
 		}
 	}
 
-	addStatus(T_("Establishing a direct encrypted channel..."));
+	if(!silent) { addStatus(T_("Establishing a direct encrypted channel...")); }
 	ClientManager::getInstance()->connect(replyTo.getUser(), ConnectionManager::pmToken);
 }
 
-void PrivateFrame::closeCC() {
+void PrivateFrame::closeCC(bool silent) {
 	if(ccReady()) {
-		addStatus(T_("Disconnecting the direct encrypted channel..."));
+		if(!silent) { addStatus(T_("Disconnecting the direct encrypted channel...")); }
 		ConnectionManager::getInstance()->disconnect(replyTo.getUser(), ConnectionQueueItem::TYPE_PM);
 	} else {
-		addStatus(T_("No direct encrypted channel available"));
+		if(!silent) { addStatus(T_("No direct encrypted channel available")); }
 	}
 }
 
@@ -481,11 +481,13 @@
 		menu->appendItem(T_("(User offline)"), nullptr, nullptr, false);
 
 	} else {
+		auto cc = ccReady();
+
 		for(auto& hub: hubs) {
 			auto url = hub.first;
-			auto current = url == replyTo.getUser().hint;
+			auto current = !cc && url == replyTo.getUser().hint;
 			auto pos = menu->appendItem(dwt::util::escapeMenu(Text::toT(hub.second)),
-				[this, url] { replyTo.getUser().hint = url; updateChannel(); }, nullptr, !current);
+				[this, url] { closeCC(true); replyTo.getUser().hint = url; updateChannel(); }, nullptr, !current);
 			if(current) {
 				menu->checkItem(pos);
 			}
@@ -494,7 +496,7 @@
 		if(SETTING(ENABLE_CCPM)) {
 			menu->appendSeparator();
 
-			if(ccReady()) {
+			if(cc) {
 				menu->appendItem(T_("Disconnect the direct encrypted channel"), [this] { closeCC(); });
 			} else {
 				menu->appendItem(T_("Start a direct encrypted channel"), [this] { startCC(); }, WinUtil::menuIcon(IDI_SECURE));

=== modified file 'win32/PrivateFrame.h'
--- win32/PrivateFrame.h	2013-08-19 20:13:24 +0000
+++ win32/PrivateFrame.h	2013-08-19 21:01:34 +0000
@@ -100,8 +100,8 @@
 	void addStatus(const tstring& text);
 	void updateOnlineStatus(bool newChannel = false);
 	void updateChannel();
-	void startCC();
-	void closeCC();
+	void startCC(bool silent = false);
+	void closeCC(bool silent = false);
 	bool ccReady() const;
 
 	bool handleChatContextMenu(dwt::ScreenCoordinate pt);