← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2821: Add a setting to enable away mode when Windows is locked

 

------------------------------------------------------------
revno: 2821
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sun 2012-01-15 17:08:29 +0100
message:
  Add a setting to enable away mode when Windows is locked
modified:
  changelog.txt
  dcpp/SettingsManager.cpp
  dcpp/SettingsManager.h
  dcpp/Util.cpp
  dcpp/Util.h
  help/chat_commands.html
  help/settings_advanced.html
  help/settings_appearance.html
  help/settings_general.html
  help/window_main.html
  win32/AdvancedPage.cpp
  win32/AppearancePage.cpp
  win32/GeneralPage.cpp
  win32/MainWindow.cpp
  win32/SConscript
  win32/WinUtil.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-01-15 13:52:55 +0000
+++ changelog.txt	2012-01-15 16:08:29 +0000
@@ -9,6 +9,7 @@
 * [L#804993] Improve multiple monitor support (poy)
 * Propose a default nick using the Win user account name (poy)
 * [L#914457] Fix missing tab icons (poy)
+* Add a setting to enable away mode when Windows is locked (poy)
 
 -- 0.791 2012-01-14 --
 * Update translations

=== modified file 'dcpp/SettingsManager.cpp'
--- dcpp/SettingsManager.cpp	2012-01-13 20:55:20 +0000
+++ dcpp/SettingsManager.cpp	2012-01-15 16:08:29 +0000
@@ -64,7 +64,7 @@
 	"MainWindowSizeX", "MainWindowSizeY", "MainWindowPosX", "MainWindowPosY",
 	"SettingsWidth", "SettingsHeight", "SettingsPage",
 	"SocksPort", "SocksResolve", "KeepLists", "AutoKick", "QueueFrameShowTree",
-	"CompressTransfers", "SFVCheck", "AutoAway",
+	"CompressTransfers", "SFVCheck", "AutoAway", "AwayCompLock",
 	"MaxCompression", "NoAwayMsgToBots", "SkipZeroByte", "AdlsBreakOnFirst",
 	"HubUserCommands", "AutoSearchAutoMatch", "LogSystem",
 	"LogFilelistTransfers", "SendUnknownCommands", "MaxHashSpeed", "OpenUserCmdHelp",
@@ -205,6 +205,7 @@
 	setDefault(COMPRESS_TRANSFERS, true);
 	setDefault(SFV_CHECK, true);
 	setDefault(AUTO_AWAY, false);
+	setDefault(AWAY_COMP_LOCK, false);
 	setDefault(DEFAULT_AWAY_MESSAGE, "I'm away. State your business and I might answer later if you're lucky.");
 	setDefault(TIME_STAMPS_FORMAT, "%H:%M");
 	setDefault(COUNTRY_FORMAT, "%[2code] - %[name]");

=== modified file 'dcpp/SettingsManager.h'
--- dcpp/SettingsManager.h	2012-01-13 20:55:20 +0000
+++ dcpp/SettingsManager.h	2012-01-15 16:08:29 +0000
@@ -82,7 +82,7 @@
 		MAIN_WINDOW_SIZE_X, MAIN_WINDOW_SIZE_Y, MAIN_WINDOW_POS_X, MAIN_WINDOW_POS_Y,
 		SETTINGS_WIDTH, SETTINGS_HEIGHT, SETTINGS_PAGE,
 		SOCKS_PORT, SOCKS_RESOLVE, KEEP_LISTS, AUTO_KICK, QUEUEFRAME_SHOW_TREE,
-		COMPRESS_TRANSFERS, SFV_CHECK, AUTO_AWAY,
+		COMPRESS_TRANSFERS, SFV_CHECK, AUTO_AWAY, AWAY_COMP_LOCK,
 		MAX_COMPRESSION, NO_AWAYMSG_TO_BOTS, SKIP_ZERO_BYTE, ADLS_BREAK_ON_FIRST,
 		HUB_USER_COMMANDS, AUTO_SEARCH_AUTO_MATCH, LOG_SYSTEM,
 		LOG_FILELIST_TRANSFERS, SEND_UNKNOWN_COMMANDS, MAX_HASH_SPEED, OPEN_USER_CMD_HELP,

=== modified file 'dcpp/Util.cpp'
--- dcpp/Util.cpp	2012-01-13 20:55:20 +0000
+++ dcpp/Util.cpp	2012-01-15 16:08:29 +0000
@@ -59,8 +59,7 @@
 wstring Util::emptyStringW;
 tstring Util::emptyStringT;
 
-bool Util::away = false;
-bool Util::manualAway = false;
+uint8_t Util::away = 0;
 string Util::awayMsg;
 time_t Util::awayTime;
 
@@ -1016,22 +1015,37 @@
 }
 
 bool Util::getAway() {
-	return away;
-}
-
-void Util::setAway(bool aAway) {
-	bool changed = aAway != away;
-
-	away = aAway;
-	if(away)
-		awayTime = time(NULL);
-
-	if(changed)
+	return away != 0;
+}
+
+void Util::incAway() {
+	setAwayCounter(away + 1);
+}
+
+void Util::decAway() {
+	setAwayCounter((away > 0) ? away - 1 : 0);
+}
+
+void Util::setAway(bool b) {
+	setAwayCounter(b ? (away + 1) : 0);
+}
+
+void Util::switchAway() {
+	setAway(!getAway());
+}
+
+void Util::setAwayCounter(uint8_t i) {
+	auto prev = getAway();
+
+	away = i;
+
+	if(getAway() != prev) {
+		if(getAway()) {
+			awayTime = time(0);
+		}
+		printf("updating away!!!!!!!!!!! b = %d\n", getAway());
 		ClientManager::getInstance()->infoUpdated();
-}
-
-void Util::switchAway() {
-	setAway(!away);
+	}
 }
 
 string Util::getTempPath() {

=== modified file 'dcpp/Util.h'
--- dcpp/Util.h	2012-01-13 20:55:20 +0000
+++ dcpp/Util.h	2012-01-15 16:08:29 +0000
@@ -422,12 +422,11 @@
 	static int strnicmp(const wstring& a, const wstring& b, size_t n) { return strnicmp(a.c_str(), b.c_str(), n); }
 
 	static bool getAway();
-	static void setAway(bool aAway);
+	static void incAway();
+	static void decAway();
+	static void setAway(bool b);
 	static void switchAway();
 
-	static bool getManualAway() { return manualAway; }
-	static void setManualAway(bool aManualAway) { manualAway = aManualAway;	}
-
 	static string getAwayMessage();
 	static void setAwayMessage(const string& aMsg) { awayMsg = aMsg; }
 
@@ -442,12 +441,12 @@
 
 	static string paths[PATH_LAST];
 
-	static bool away;
-	static bool manualAway;
+	static uint8_t away; // in away mode when != 0.
 	static string awayMsg;
 	static time_t awayTime;
 
 	static void loadBootConfig();
+	static void setAwayCounter(uint8_t i);
 };
 
 /** Case insensitive hash function for strings */

=== modified file 'help/chat_commands.html'
--- help/chat_commands.html	2011-12-18 17:04:43 +0000
+++ help/chat_commands.html	2012-01-15 16:08:29 +0000
@@ -92,7 +92,7 @@
   <dt id="awayback"><untranslated>/away [message]</untranslated></dt>
   <dd>Sets Away status. New private message windows will be
 responded to, once, with the message you specified, or the default away
-message configured in the <a href="settings_appearance.html#awaymsg">Appearance</a>
+message configured in the <a href="settings_general.html#awaymsg">Personal information</a>
 settings page.</dd>
   <dt><untranslated>/back</untranslated></dt>
   <dd>Un-sets Away status.</dd>

=== modified file 'help/settings_advanced.html'
--- help/settings_advanced.html	2012-01-02 10:59:22 +0000
+++ help/settings_advanced.html	2012-01-15 16:08:29 +0000
@@ -8,9 +8,6 @@
 <body>
 <h1>Advanced</h1>
 <dl style="margin-left: 40px;">
-  <dt id="autoaway">Auto-away on minimize (and back on restore)</dt>
-  <dd cshelp="IDH_SETTINGS_ADVANCED_AUTO_AWAY">Switch to away mode whenever the client is minimized (and to back
-whenever restored).</dd>
   <dt>Automatically follow redirects</dt>
   <dd cshelp="IDH_SETTINGS_ADVANCED_AUTO_FOLLOW">A connected hub can send out a redirect request, asking your
 client to disconnect from the current hub and joining another one.

=== modified file 'help/settings_appearance.html'
--- help/settings_appearance.html	2011-12-18 17:04:43 +0000
+++ help/settings_appearance.html	2012-01-15 16:08:29 +0000
@@ -54,15 +54,6 @@
 </dl>
 <h2>Miscellaneous</h2>
 <dl style="margin-left: 40px;">
-  <dt id="awaymsg">Default away message</dt>
-  <dd cshelp="IDH_SETTINGS_APPEARANCE_DEFAULT_AWAY_MESSAGE">This is the default away message that will appear when someone
-PMs you for the first time while you are in the away mode. You
-can activate away mode by using the <a
- href="chat_commands.html#awayback">/away
-&lt;message&gt; and /back chat commands</a> or <a
- href="settings_advanced.html#autoaway">Auto-away on Minimize option</a>.
-All time formatting variables are available, see <a
- href="settings_logs.html#timeformat">Logs</a>. Use Ctrl + Enter to create a new line. <br/>(default: "I'm away. State your business and I might answer later if you're lucky.")</dd>
   <dt id="timestamp_format">Timestamp format</dt>
   <dd cshelp="IDH_SETTINGS_APPEARANCE_TIMESTAMP_FORMAT">This lets you select the format of the time stamps that can
 appear in the chat and private message windows. For the available

=== modified file 'help/settings_general.html'
--- help/settings_general.html	2010-07-17 18:37:34 +0000
+++ help/settings_general.html	2012-01-15 16:08:29 +0000
@@ -6,7 +6,9 @@
 <link type="text/css" rel="stylesheet" href="style.css"/>
 </head>
 <body>
-<h2>Personal Information</h2>
+	<h1>Personal information</h1>
+
+<h2>Personal information</h2>
 <p cshelp="IDH_SETTINGS_GENERAL_PERSONAL_INFORMATION">
 This is general information about yourself. The nick is required,
 though it's suggested that you pick the correct upload line speed value as well.
@@ -26,5 +28,40 @@
 in your download speed; this setting is a measure of how fast a source 
 you are likely to be for other users. This value will be shown for the users on NMDC hubs only.</dd>
 </dl>
+
+<h2 id="away">Away mode</h2>
+<p cshelp="IDH_SETTINGS_GENERAL_AWAY_MODE">
+These settings control the away mode. It is a mode that DC++ can be switched to to signify that you
+are away from DC++ and unavailable at the time. You can activate away mode by using the
+<a href="window_main.html#awayindic">Away indicator in the status bar of the main window</a>, the
+<a href="chat_commands.html#awayback">/away &lt;message&gt; and /back chat commands</a>, the
+<a href="settings_general.html#autoaway">Auto-away on minimize option</a> or the
+<a href="settings_general.html#awaycomplock">Auto-away when Windows is locked option</a>.
+</p>
+
+<dl style="margin-left: 40px;">
+
+	<dt id="awaymsg">Default away message</dt>
+	<dd cshelp="IDH_SETTINGS_GENERAL_DEFAULT_AWAY_MESSAGE">
+	This is the default away message that will appear when someone PMs you for the first time while
+	you are in the away mode. All time formatting variables are available, see
+	<a href="settings_logs.html#timeformat">Logs</a>. Use Ctrl + Enter to create a new line. <br/>
+	(default: "I'm away. State your business and I might answer later if you're lucky.")
+	</dd>
+
+	<dt id="autoaway">Auto-away on minimize (and back on restore)</dt>
+	<dd cshelp="IDH_SETTINGS_GENERAL_AUTO_AWAY">
+	Switch to away mode whenever the client is minimized in the Windows taskbar or in the
+	notification area (and set away mode off whenever restored).
+	</dd>
+
+	<dt id="awaycomplock">Auto-away when Windows is locked (and back when unlocked)</dt>
+	<dd cshelp="IDH_SETTINGS_GENERAL_AWAY_COMP_LOCK">
+	Switch to away mode whenever the Windows session is locked (generally by Windows key + L or via
+	Ctrl + Alt + Del), and set away mode off when the session is unlocked.
+	</dd>
+
+</dl>
+
 </body>
 </html>

=== modified file 'help/window_main.html'
--- help/window_main.html	2011-12-03 20:40:54 +0000
+++ help/window_main.html	2012-01-15 16:08:29 +0000
@@ -318,8 +318,8 @@
     <dt>System messages</dt>
     <dd cshelp="IDH_MAIN_STATUS">The first part of the status bar contains the last system message with a timestamp. To see more from the recent system messages you can move the mouse pointer above the statusbar - the last 10 lines of the messages will be shown as a tooltip shortly. To see all system messages of the current session open the <a href="window_system_log.html">System Log</a> window from the <a href="#viewmenu">View menu</a> or simply double-click on this part of the status bar.</dd>
 
-    <dt><img src="User.ico" width="16" height="16" alt="Online user"/><img src="UserAway.ico" width="16" height="16" alt="Away user"/> Away indicator</dt>
-	<dd cshelp="IDH_MAIN_AWAY">The user icon turns from green to grey when DC++ is in <a href="settings_appearance.html#awaymsg">away mode</a>.<br/>
+    <dt id="awayindic"><img src="User.ico" width="16" height="16" alt="Online user"/><img src="UserAway.ico" width="16" height="16" alt="Away user"/> Away indicator</dt>
+	<dd cshelp="IDH_MAIN_AWAY">The user icon turns from green to grey when DC++ is in <a href="settings_general.html#away">away mode</a>.<br/>
 	Double-click to switch away mode on and off.</dd>
 
     <dt><img src="HubOn.ico" width="16" height="16" alt="Hubs"/> Hubs</dt>

=== modified file 'win32/AdvancedPage.cpp'
--- win32/AdvancedPage.cpp	2012-01-13 20:55:20 +0000
+++ win32/AdvancedPage.cpp	2012-01-15 16:08:29 +0000
@@ -29,7 +29,6 @@
 using dwt::GridInfo;
 
 AdvancedPage::ListItem AdvancedPage::listItems[] = {
-	{ SettingsManager::AUTO_AWAY, N_("Auto-away on minimize (and back on restore)"), IDH_SETTINGS_ADVANCED_AUTO_AWAY },
 	{ SettingsManager::AUTO_FOLLOW, N_("Automatically follow redirects"), IDH_SETTINGS_ADVANCED_AUTO_FOLLOW },
 	{ SettingsManager::CLEAR_SEARCH, N_("Clear search box after each search"), IDH_SETTINGS_ADVANCED_CLEAR_SEARCH },
 	{ SettingsManager::LIST_DUPES, N_("Keep duplicate files in your file list"), IDH_SETTINGS_ADVANCED_LIST_DUPES },

=== modified file 'win32/AppearancePage.cpp'
--- win32/AppearancePage.cpp	2012-01-13 20:55:20 +0000
+++ win32/AppearancePage.cpp	2012-01-15 16:08:29 +0000
@@ -51,7 +51,7 @@
 };
 
 AppearancePage::AppearancePage(dwt::Widget* parent) :
-PropPage(parent, 6, 1),
+PropPage(parent, 5, 1),
 options(0),
 languages(0)
 {
@@ -64,17 +64,6 @@
 	options = grid->addChild(GroupBox::Seed(T_("Options")))->addChild(WinUtil::Seeds::Dialog::optionsTable);
 
 	{
-		auto group = grid->addChild(GroupBox::Seed(T_("Default away message")));
-		group->setHelpId(IDH_SETTINGS_APPEARANCE_DEFAULT_AWAY_MESSAGE);
-
-		auto seed = WinUtil::Seeds::Dialog::textBox;
-		seed.style |= ES_MULTILINE | WS_VSCROLL | ES_WANTRETURN;
-		auto box = group->addChild(seed);
-		box->setHelpId(IDH_SETTINGS_APPEARANCE_DEFAULT_AWAY_MESSAGE);
-		items.push_back(Item(box, SettingsManager::DEFAULT_AWAY_MESSAGE, PropPage::T_STR));
-	}
-
-	{
 		auto cur = grid->addChild(Grid::Seed(1, 2));
 		cur->setSpacing(grid->getSpacing());
 

=== modified file 'win32/GeneralPage.cpp'
--- win32/GeneralPage.cpp	2012-01-14 18:08:07 +0000
+++ win32/GeneralPage.cpp	2012-01-15 16:08:29 +0000
@@ -32,47 +32,76 @@
 using dwt::Label;
 
 GeneralPage::GeneralPage(dwt::Widget* parent) :
-PropPage(parent, 1, 1),
+PropPage(parent, 2, 1),
 nick(0),
 connections(0)
 {
 	setHelpId(IDH_GENERALPAGE);
 
 	grid->column(0).mode = GridInfo::FILL;
-	grid->row(0).mode = GridInfo::FILL;
-	grid->row(0).align = GridInfo::STRETCH;
-
-	auto group = grid->addChild(GroupBox::Seed(T_("Personal Information")));
-	group->setHelpId(IDH_SETTINGS_GENERAL_PERSONAL_INFORMATION);
 
 	{
-		GridPtr grid = group->addChild(Grid::Seed(4, 2));
-		grid->column(0).align = GridInfo::BOTTOM_RIGHT;
-		grid->column(1).mode = GridInfo::FILL;
-
-		grid->addChild(Label::Seed(T_("Nick")))->setHelpId(IDH_SETTINGS_GENERAL_NICK);
-		nick = grid->addChild(WinUtil::Seeds::Dialog::textBox);
+		auto group = grid->addChild(GroupBox::Seed(T_("Personal information")));
+		group->setHelpId(IDH_SETTINGS_GENERAL_PERSONAL_INFORMATION);
+
+		auto cur = group->addChild(Grid::Seed(4, 2));
+		cur->column(0).align = GridInfo::BOTTOM_RIGHT;
+		cur->column(1).mode = GridInfo::FILL;
+		cur->setSpacing(grid->getSpacing());
+
+		cur->addChild(Label::Seed(T_("Nick")))->setHelpId(IDH_SETTINGS_GENERAL_NICK);
+		nick = cur->addChild(WinUtil::Seeds::Dialog::textBox);
 		items.push_back(Item(nick, SettingsManager::NICK, PropPage::T_STR));
 		nick->setHelpId(IDH_SETTINGS_GENERAL_NICK);
 
-		grid->addChild(Label::Seed(T_("E-Mail")))->setHelpId(IDH_SETTINGS_GENERAL_EMAIL);
-		TextBoxPtr box = grid->addChild(WinUtil::Seeds::Dialog::textBox);
+		cur->addChild(Label::Seed(T_("E-Mail")))->setHelpId(IDH_SETTINGS_GENERAL_EMAIL);
+		TextBoxPtr box = cur->addChild(WinUtil::Seeds::Dialog::textBox);
 		items.push_back(Item(box, SettingsManager::EMAIL, PropPage::T_STR));
 		box->setHelpId(IDH_SETTINGS_GENERAL_EMAIL);
 
-		grid->addChild(Label::Seed(T_("Description")))->setHelpId(IDH_SETTINGS_GENERAL_DESCRIPTION);
-		box = grid->addChild(WinUtil::Seeds::Dialog::textBox);
+		cur->addChild(Label::Seed(T_("Description")))->setHelpId(IDH_SETTINGS_GENERAL_DESCRIPTION);
+		box = cur->addChild(WinUtil::Seeds::Dialog::textBox);
 		items.push_back(Item(box, SettingsManager::DESCRIPTION, PropPage::T_STR));
 		box->setHelpId(IDH_SETTINGS_GENERAL_DESCRIPTION);
 
-		grid->addChild(Label::Seed(T_("Line speed (upload)")))->setHelpId(IDH_SETTINGS_GENERAL_CONNECTION);
-
-		GridPtr cur = grid->addChild(Grid::Seed(1, 2));
-
-		connections = cur->addChild(WinUtil::Seeds::Dialog::comboBox);
-		connections->setHelpId(IDH_SETTINGS_GENERAL_CONNECTION);
-
-		cur->addChild(Label::Seed(T_("MiBits/s")))->setHelpId(IDH_SETTINGS_GENERAL_CONNECTION);
+		cur->addChild(Label::Seed(T_("Line speed (upload)")))->setHelpId(IDH_SETTINGS_GENERAL_CONNECTION);
+
+		{
+			auto conn = cur->addChild(Grid::Seed(1, 2));
+			conn->setSpacing(cur->getSpacing());
+
+			connections = conn->addChild(WinUtil::Seeds::Dialog::comboBox);
+			connections->setHelpId(IDH_SETTINGS_GENERAL_CONNECTION);
+
+			conn->addChild(Label::Seed(T_("MiBits/s")))->setHelpId(IDH_SETTINGS_GENERAL_CONNECTION);
+		}
+	}
+
+	{
+		auto group = grid->addChild(GroupBox::Seed(T_("Away mode")));
+		group->setHelpId(IDH_SETTINGS_GENERAL_AWAY_MODE);
+
+		auto cur = group->addChild(Grid::Seed(3, 1));
+		cur->column(0).mode = GridInfo::FILL;
+		cur->setSpacing(grid->getSpacing());
+
+		{
+			group = cur->addChild(GroupBox::Seed(T_("Default away message")));
+			group->setHelpId(IDH_SETTINGS_GENERAL_DEFAULT_AWAY_MESSAGE);
+
+			auto seed = WinUtil::Seeds::Dialog::textBox;
+			seed.style |= ES_MULTILINE | WS_VSCROLL | ES_WANTRETURN;
+			items.push_back(Item(group->addChild(seed), SettingsManager::DEFAULT_AWAY_MESSAGE, PropPage::T_STR));
+		}
+
+		// dummy grid so that the check-box doesn't fill the whole row.
+		auto box = cur->addChild(Grid::Seed(1, 1))->addChild(CheckBox::Seed(T_("Auto-away on minimize (and back on restore)")));
+		box->setHelpId(IDH_SETTINGS_GENERAL_AUTO_AWAY);
+		items.push_back(Item(box, SettingsManager::AUTO_AWAY, PropPage::T_BOOL));
+
+		box = cur->addChild(Grid::Seed(1, 1))->addChild(CheckBox::Seed(T_("Auto-away when Windows is locked (and back when unlocked)")));
+		box->setHelpId(IDH_SETTINGS_GENERAL_AWAY_COMP_LOCK);
+		items.push_back(Item(box, SettingsManager::AWAY_COMP_LOCK, PropPage::T_BOOL));
 	}
 
 	PropPage::read(items);

=== modified file 'win32/MainWindow.cpp'
--- win32/MainWindow.cpp	2012-01-15 12:53:28 +0000
+++ win32/MainWindow.cpp	2012-01-15 16:08:29 +0000
@@ -82,6 +82,7 @@
 #ifdef HAVE_HTMLHELP_H
 #include <htmlhelp.h>
 #endif
+#include <wtsapi32.h>
 
 using dwt::Container;
 using dwt::Rebar;
@@ -180,6 +181,17 @@
 		showPortsError(e.getError());
 	}
 
+	// track when the computer is locked / unlocked.
+	::WTSRegisterSessionNotification(handle(), NOTIFY_FOR_THIS_SESSION);
+	onRaw([](WPARAM wParam, LPARAM) -> LRESULT {
+		switch(wParam) {
+		case WTS_SESSION_LOCK: if(BOOLSETTING(AWAY_COMP_LOCK)) Util::incAway(); break;
+		case WTS_SESSION_UNLOCK: if(BOOLSETTING(AWAY_COMP_LOCK)) Util::decAway(); break;
+		}
+		return 0;
+	}, dwt::Message(WM_WTSSESSION_CHANGE));
+	onDestroy([this] { ::WTSUnRegisterSessionNotification(handle()); });
+
 	{
 		bool skipHubCon = WinUtil::isShift();
 
@@ -811,8 +823,8 @@
 	if(sz.isMinimized) {
 		handleMinimized();
 	} else if(sz.isMaximized || sz.isRestored) {
-		if(BOOLSETTING(AUTO_AWAY) && !Util::getManualAway()) {
-			Util::setAway(false);
+		if(BOOLSETTING(AUTO_AWAY)) {
+			Util::decAway();
 		}
 		if(!BOOLSETTING(ALWAYS_TRAY)) {
 			notifier->setVisible(false);
@@ -822,8 +834,8 @@
 }
 
 void MainWindow::handleMinimized() {
-	if(BOOLSETTING(AUTO_AWAY) && !Util::getManualAway()) {
-		Util::setAway(true);
+	if(BOOLSETTING(AUTO_AWAY)) {
+		Util::incAway();
 	}
 	if(BOOLSETTING(MINIMIZE_TRAY) != WinUtil::isShift()) {
 		if(!BOOLSETTING(ALWAYS_TRAY)) {

=== modified file 'win32/SConscript'
--- win32/SConscript	2011-10-26 18:23:40 +0000
+++ win32/SConscript	2012-01-15 16:08:29 +0000
@@ -16,7 +16,7 @@
 	env.Append(LIBS='htmlhelp')
 
 env.Append(LIBS = ['comctl32', 'ws2_32', 'ole32', 'gdi32', 'comdlg32', 'iphlpapi', 'winmm',
-	'shlwapi', 'oleaut32', 'uuid', 'uxtheme'])
+	'shlwapi', 'oleaut32', 'uuid', 'uxtheme', 'wtsapi32'])
 
 # add libs for the crash logger.
 if 'g++' in env['LINK']: # MinGW

=== modified file 'win32/WinUtil.cpp'
--- win32/WinUtil.cpp	2012-01-13 20:55:20 +0000
+++ win32/WinUtil.cpp	2012-01-15 16:08:29 +0000
@@ -558,17 +558,14 @@
 	} else if(Util::stricmp(cmd.c_str(), _T("away")) == 0) {
 		if(Util::getAway() && param.empty()) {
 			Util::setAway(false);
-			Util::setManualAway(false);
 			status = T_("Away mode off");
 		} else {
 			Util::setAway(true);
-			Util::setManualAway(true);
 			Util::setAwayMessage(Text::fromT(param));
 			status = str(TF_("Away mode on: %1%") % Text::toT(Util::getAwayMessage()));
 		}
 	} else if(Util::stricmp(cmd.c_str(), _T("back")) == 0) {
 		Util::setAway(false);
-		Util::setManualAway(false);
 		status = T_("Away mode off");
 	} else if(Util::stricmp(cmd.c_str(), _T("g")) == 0) {
 		if(param.empty()) {