← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2932: PM: keep the hub hint in sync with the selected hub; fix log paths when offline

 

------------------------------------------------------------
revno: 2932
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Mon 2012-05-28 23:43:42 +0200
message:
  PM: keep the hub hint in sync with the selected hub; fix log paths when offline
modified:
  changelog.txt
  win32/PrivateFrame.cpp
  win32/PrivateFrame.h
  win32/UserInfoBase.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 'changelog.txt'
--- changelog.txt	2012-05-27 14:02:55 +0000
+++ changelog.txt	2012-05-28 21:43:42 +0000
@@ -1,5 +1,6 @@
 * Revamp favorite hub settings (poy)
 * Reduce resource consumption when slots are full
+* [L#984330] Make PM windows more aware of the selected hub
 
 -- 0.799 2012-05-05 --
 * Add icons (iceman50)

=== modified file 'win32/PrivateFrame.cpp'
--- win32/PrivateFrame.cpp	2012-05-15 23:26:22 +0000
+++ win32/PrivateFrame.cpp	2012-05-28 21:43:42 +0000
@@ -141,6 +141,7 @@
 grid(0),
 hubGrid(0),
 hubBox(0),
+initialHub(replyTo_.hint),
 replyTo(replyTo_),
 online(replyTo.getUser().user->isOnline())
 {
@@ -158,6 +159,11 @@
 	}
 	hubBox = hubGrid->addChild(WinUtil::Seeds::comboBox);
 	addWidget(hubBox);
+	hubBox->onSelectionChanged([this] {
+		replyTo.getUser().hint = hubs[hubBox->getSelected()].first;
+		if(replyTo.getUser().hint.empty())
+			replyTo.getUser().hint = initialHub;
+	});
 
 	hubGrid->setEnabled(false);
 	hubGrid->setVisible(false);
@@ -235,12 +241,10 @@
 }
 
 void PrivateFrame::fillLogParams(ParamMap& params) const {
-	const CID& cid = replyTo.getUser().user->getCID();
-	const string& hint = replyTo.getUser().hint;
-	params["hubNI"] = [&] { return Util::toString(ClientManager::getInstance()->getHubNames(cid, hint)); };
-	params["hubURL"] = [&] { return Util::toString(ClientManager::getInstance()->getHubUrls(cid, hint)); };
-	params["userCID"] = [&cid] { return cid.toBase32(); };
-	params["userNI"] = [&] { return ClientManager::getInstance()->getNicks(cid, hint)[0]; };
+	params["hubNI"] = [this] { return Text::fromT(hubName); };
+	params["hubURL"] = [this] { return replyTo.getUser().hint; };
+	params["userCID"] = [this] { return replyTo.getUser().user->getCID().toBase32(); };
+	params["userNI"] = [this] { return ClientManager::getInstance()->getNicks(replyTo.getUser())[0]; };
 	params["myCID"] = [] { return ClientManager::getInstance()->getMe()->getCID().toBase32(); };
 }
 
@@ -266,6 +270,7 @@
 	pair<tstring, bool> hubNames = WinUtil::getHubNames(cid, hint);
 
 	setText(WinUtil::getNicks(cid, hint) + _T(" - ") + hubNames.first);
+	hubName = move(hubNames.first);
 
 	online = hubNames.second;
 	setIcon(online ? IDI_PRIVATE : IDI_PRIVATE_OFF);
@@ -362,10 +367,7 @@
 }
 
 void PrivateFrame::sendMessage(const tstring& msg, bool thirdPerson) {
-	auto sel = hubBox->getSelected();
-
-	auto &url = sel >= 0 && static_cast<size_t>(sel) < hubs.size() ? hubs[static_cast<size_t>(sel)].first : replyTo.getUser().hint;
-	ClientManager::getInstance()->privateMessage(HintedUser(replyTo.getUser().user, url), Text::fromT(msg), thirdPerson);
+	ClientManager::getInstance()->privateMessage(replyTo.getUser(), Text::fromT(msg), thirdPerson);
 }
 
 PrivateFrame::UserInfoList PrivateFrame::selectedUsersImpl() {
@@ -387,8 +389,7 @@
 
 void PrivateFrame::tabMenuImpl(dwt::Menu* menu) {
 	appendUserItems(getParent(), menu, false, false);
-	prepareMenu(menu, UserCommand::CONTEXT_USER, ClientManager::getInstance()->getHubUrls(replyTo.getUser().user->getCID(),
-		replyTo.getUser().hint));
+	prepareMenu(menu, UserCommand::CONTEXT_USER, replyTo.getUser().hint);
 	menu->appendSeparator();
 }
 
@@ -401,8 +402,7 @@
 
 	menu->setTitle(escapeMenu(getText()), getParent()->getIcon(this));
 
-	prepareMenu(menu.get(), UserCommand::CONTEXT_USER, ClientManager::getInstance()->getHubUrls(replyTo.getUser().user->getCID(),
-		replyTo.getUser().hint));
+	prepareMenu(menu.get(), UserCommand::CONTEXT_USER, replyTo.getUser().hint);
 
 	menu->open(pt);
 	return true;

=== modified file 'win32/PrivateFrame.h'
--- win32/PrivateFrame.h	2012-05-15 23:26:22 +0000
+++ win32/PrivateFrame.h	2012-05-28 21:43:42 +0000
@@ -76,6 +76,8 @@
 	ComboBoxPtr hubBox;
 
 	StringPairList hubs;
+	string initialHub;
+	tstring hubName;
 	ParamMap ucLineParams;
 
 	UserInfoBase replyTo;

=== modified file 'win32/UserInfoBase.h'
--- win32/UserInfoBase.h	2012-05-15 23:26:22 +0000
+++ win32/UserInfoBase.h	2012-05-28 21:43:42 +0000
@@ -50,6 +50,7 @@
 	tstring getTooltip() const;
 
 	const HintedUser& getUser() const { return user; }
+	HintedUser& getUser() { return user; }
 
 protected:
 	HintedUser user;