Browse Source

- added delay when windows is resuming from sleep to reopen the db
- allow wild card characters in ip/machine name matching for what to put in clipboard

git-svn-id: svn://svn.code.sf.net/p/ditto-cp/code/trunk@788 595ec19a-5cb4-439b-94a8-42fb3063c22c

sabrogden 10 years ago
parent
commit
643d2b146c
5 changed files with 47 additions and 10 deletions
  1. 2 2
      DittoSetup/BuildDitto.bld
  2. 5 2
      MainFrm.cpp
  3. 10 0
      Options.cpp
  4. 3 0
      Options.h
  5. 27 6
      Server.cpp

+ 2 - 2
DittoSetup/BuildDitto.bld

@@ -1,5 +1,5 @@
 <?xml version='1.0' encoding='utf-8'?>
-<project version='7' encrypted='1'>
+<project version='8' encrypted='1'>
 	<steps type='0'>
 		<step action='Set Macro'>
 			<MacroName>LOGFILE</MacroName>
@@ -334,7 +334,7 @@ var sc_security="b3f57099";
 			<Repository>/p/ditto-cp/code/</Repository>
 			<SVNPath>C:\Program Files (x86)\SlikSvn\bin</SVNPath>
 			<Subcommand>log</Subcommand>
-			<Switches>-r {2015-01-10}:{2016-12-31}</Switches>
+			<Switches>-r {2015-08-5}:{2016-12-31}</Switches>
 			<Username>sabrogden</Username>
 			<indent type='3'>2</indent>
 			<name>SVN Log Messages</name>

+ 5 - 2
MainFrm.cpp

@@ -1211,16 +1211,19 @@ LRESULT CMainFrame::OnReAddTaskBarIcon(WPARAM wParam, LPARAM lParam)
 
 LRESULT CMainFrame::OnReOpenDatabase(WPARAM wParam, LPARAM lParam)
 {
-	Log(StrF(_T("OnReOpenDatabase, closing and reopening database")));
+	Log(StrF(_T("OnReOpenDatabase, Start closing and reopening database Delay: %d"), CGetSetOptions::GetWindowsResumeDelayReOpenDbMS()));
 
-	try
+	try 
 	{
+		Sleep(CGetSetOptions::GetWindowsResumeDelayReOpenDbMS());
 		m_quickPaste.CloseQPasteWnd();
 		theApp.m_db.close();
 		OpenDatabase(CGetSetOptions::GetDBPath());
 	}
 	CATCH_SQLITE_EXCEPTION
 
+	Log(StrF(_T("OnReOpenDatabase, End closing and reopening database Delay: %d"), CGetSetOptions::GetWindowsResumeDelayReOpenDbMS()));
+
 	return TRUE;
 }
 

+ 10 - 0
Options.cpp

@@ -2247,4 +2247,14 @@ void CGetSetOptions::SetCopyReasonTimeoutMS(int val)
 int CGetSetOptions::GetCopyReasonTimeoutMS()
 {
 	return GetProfileLong(_T("CopyReasonTimeoutMS"), 1000);
+}
+
+void CGetSetOptions::SetWindowsResumeDelayReOpenDbMS(int val)
+{
+	SetProfileLong(_T("WindowsResumeDelayReOpenDbMS"), val);
+}
+
+int CGetSetOptions::GetWindowsResumeDelayReOpenDbMS()
+{
+	return GetProfileLong(_T("WindowsResumeDelayReOpenDbMS"), 2000);
 }

+ 3 - 0
Options.h

@@ -489,6 +489,9 @@ public:
 
 	static void SetCopyReasonTimeoutMS(int val);
 	static int GetCopyReasonTimeoutMS();
+
+	static void SetWindowsResumeDelayReOpenDbMS(int val);
+	static int GetWindowsResumeDelayReOpenDbMS();
 };
 
 // global for easy access and for initialization of fast access variables

+ 27 - 6
Server.cpp

@@ -5,6 +5,8 @@
 #include "stdafx.h"
 #include "cp_main.h"
 #include "Server.h"
+#include "Shared\Tokenizer.h"
+#include "WildCardMatch.h"
 
 #ifdef _DEBUG
 #undef THIS_FILE
@@ -190,12 +192,31 @@ void CServer::OnStart(CSendInfo &info)
 	}
 	
 	m_bSetToClipBoard = FALSE;
-
-	if(g_Opt.m_csIPListToPutOnClipboard.Find(m_csIP) >= 0)
-		m_bSetToClipBoard = TRUE;
-
-	if(g_Opt.m_csIPListToPutOnClipboard.Find(m_csComputerName) >= 0)
-		m_bSetToClipBoard = TRUE;
+
+	CTokenizer token(g_Opt.m_csIPListToPutOnClipboard, ",");
+	CString line;
+
+	while(token.Next(line))
+	{
+		if(line != "")
+		{
+			if(CWildCardMatch::WildMatch(line, m_csIP, ""))
+			{
+				LogSendRecieveInfo(StrF(_T("Found ip match, placing on clipboard Found Match %s - %s"), line, m_csIP));
+
+				m_bSetToClipBoard = TRUE;
+				break;
+			}
+
+			if(CWildCardMatch::WildMatch(line, m_csComputerName, ""))
+			{
+				LogSendRecieveInfo(StrF(_T("Found machine match, placing on clipboard Found Match %s - %s"), line, m_csIP));
+
+				m_bSetToClipBoard = TRUE;
+				break;
+			}
+		}
+	}
 	
 	info.m_cDesc[20] = 0;
 	LogSendRecieveInfo(StrF(_T("::START %s %s %s"), m_csDesc, m_csComputerName, m_csIP));