Browse Source

- removed u3 checks
- added checks for running as a windows app, use ini in app data and db in app data

Scott Brogden 9 years ago
parent
commit
f88cf89619
8 changed files with 58 additions and 210 deletions
  1. 2 52
      CP_Main.cpp
  2. 19 26
      DatabaseUtilities.cpp
  3. 2 16
      InternetUpdate.cpp
  4. 31 89
      Options.cpp
  5. 2 1
      Options.h
  6. 1 14
      OptionsGeneral.cpp
  7. 1 5
      OptionsTypes.cpp
  8. 0 7
      ProcessPaste.cpp

+ 2 - 52
CP_Main.cpp

@@ -29,9 +29,6 @@ public:
 	{
 		m_bDisconnect = FALSE;
 		m_bConnect = FALSE;
-		m_bU3 = FALSE;
-		m_bU3Stop = FALSE;
-		m_bU3Install = FALSE;
 		m_uacPID = 0;
 		m_bOpenWindow = FALSE;
 		m_bCloseWindow = FALSE;
@@ -49,18 +46,6 @@ public:
   			{
   				m_bDisconnect = TRUE;
   			}
-  			else if(STRICMP(pszParam, _T("U3")) == 0)
-  			{
-  				m_bU3 = TRUE;
-  			}
-  			else if(STRICMP(pszParam, _T("U3appStop")) == 0)
-  			{
-  				m_bU3Stop = TRUE;
-  			}
-  			else if(STRICMP(pszParam, _T("U3Install")) == 0)
-  			{
-  				m_bU3Install = TRUE;
-  			}
 			else if(wcsncmp(pszParam, _T("uacpaste"), 8) == 0)
 			{
 				CString pidCommand(pszParam);
@@ -86,9 +71,6 @@ public:
 
 	BOOL m_bDisconnect;
 	BOOL m_bConnect;
-	BOOL m_bU3;
-	BOOL m_bU3Stop;
-	BOOL m_bU3Install;
 	int m_uacPID;
 	BOOL m_bCloseWindow;
 	BOOL m_bOpenWindow;
@@ -171,10 +153,6 @@ BOOL CCP_MainApp::InitInstance()
 	DittoCommandLineInfo cmdInfo;
 	ParseCommandLine(cmdInfo);
 
-	//if starting from a u3 device we will pass in -U3Start
-	if(cmdInfo.m_bU3)
-		g_Opt.m_bU3 = cmdInfo.m_bU3 ? TRUE : FALSE;
-
 	g_Opt.LoadSettings();
 
 	if(cmdInfo.m_uacPID > 0)
@@ -277,14 +255,7 @@ BOOL CCP_MainApp::InitInstance()
 	Log(cs);
 
 	CString csMutex("Ditto Is Now Running");
-	if(g_Opt.m_bU3)
-	{
-		//If running from a U3 device then allow other ditto's to run
-		//only prevent Ditto from running from the same device
-		csMutex += " ";
-		csMutex += GETENV(_T("U3_DEVICE_SERIAL"));
-	}
-	else if(g_Opt.GetIsPortableDitto())
+	if(g_Opt.GetIsPortableDitto() || g_Opt.GetIsWindowsApp())
 	{
 		csMutex += " ";
 		csMutex += g_Opt.GetExeFileName();
@@ -311,17 +282,6 @@ BOOL CCP_MainApp::InitInstance()
 		m_Language.LoadLanguageFile(_T("English.xml"));
 	}
 
-	//The first time we run Ditto on U3 show a web page about ditto
-	if(g_Opt.m_bU3)
-	{
-		if(FileExists(CGetSetOptions::GetDBPath()) == FALSE)
-		{
-			CString csFile = CGetSetOptions::GetPath(PATH_HELP);
-			csFile += "U3_Install.htm";
-			CHyperLink::GotoURL(csFile, SW_SHOW);
-		}
-	}
-
 	int nRet = CheckDBExists(CGetSetOptions::GetDBPath());
 	if(nRet == FALSE)
 	{
@@ -345,12 +305,6 @@ void CCP_MainApp::AfterMainCreate()
 	ASSERT( ::IsWindow(m_MainhWnd) );
 	g_Opt.SetMainHWND((long)m_MainhWnd);
 
-	//Save the HWND so the stop app can send us a close message
-	if(g_Opt.m_bU3)
-	{
-		CGetSetOptions::WriteU3Hwnd(m_MainhWnd);
-	}
-
 	g_HotKeys.Init(m_MainhWnd);
 
 	// create hotkeys here.  They are automatically deleted on exit
@@ -562,11 +516,7 @@ CClipTypes* CCP_MainApp::LoadTypesFromDB()
 		pTypes->Add(RegisterClipboardFormat(CF_RTF));
 		pTypes->Add(CF_UNICODETEXT);
 		pTypes->Add(CF_HDROP);
-
-		if(g_Opt.m_bU3 == false)
-		{
-			pTypes->Add(CF_DIB);
-		}
+		pTypes->Add(CF_DIB);
 	}
 
 	return pTypes;

+ 19 - 26
DatabaseUtilities.cpp

@@ -69,40 +69,33 @@ CString GetOLDDefaultDBName()
 CString GetDefaultDBName()
 {
 	CString csDefaultPath = _T("c:\\program files\\Ditto\\");
-
-	if(g_Opt.m_bU3)
+	
+	//If portable then default to the running path
+	if(CGetSetOptions::GetIsPortableDitto())
 	{
-		csDefaultPath = CGetSetOptions::GetPath(PATH_DATABASE);
+		csDefaultPath.Empty();
 	}
 	else
-	{	
-		//If portable then default to the running path
-		if(CGetSetOptions::GetIsPortableDitto())
-		{
-			csDefaultPath.Empty();
-		}
-		else
-		{
-			LPMALLOC pMalloc;
+	{
+		LPMALLOC pMalloc;
 		
-			if(SUCCEEDED(::SHGetMalloc(&pMalloc))) 
-			{ 
-				LPITEMIDLIST pidlPrograms;
+		if(SUCCEEDED(::SHGetMalloc(&pMalloc))) 
+		{ 
+			LPITEMIDLIST pidlPrograms;
 				
-				SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidlPrograms);
+			SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidlPrograms);
 				
-				TCHAR string[MAX_PATH];
-				SHGetPathFromIDList(pidlPrograms, string);
+			TCHAR string[MAX_PATH];
+			SHGetPathFromIDList(pidlPrograms, string);
 				
-				pMalloc->Free(pidlPrograms);
-				pMalloc->Release();
+			pMalloc->Free(pidlPrograms);
+			pMalloc->Release();
 				
-				csDefaultPath = string;		
-			}
-
-			FIX_CSTRING_PATH(csDefaultPath);
-			csDefaultPath += "Ditto\\";
+			csDefaultPath = string;		
 		}
+
+		FIX_CSTRING_PATH(csDefaultPath);
+		csDefaultPath += "Ditto\\";
 	}
 
 	CString csTempName = csDefaultPath + "Ditto.db";
@@ -120,7 +113,7 @@ CString GetDefaultDBName()
 BOOL CheckDBExists(CString csDBPath)
 {
 	//If this is the first time running this version then convert the old database to the new db
-	if(csDBPath.IsEmpty() && g_Opt.m_bU3 == false)
+	if(csDBPath.IsEmpty())
 	{
 		csDBPath = GetDefaultDBName();
 

+ 2 - 16
InternetUpdate.cpp

@@ -174,14 +174,7 @@ long CInternetUpdate::GetUpdateVersion()
 	//if nothing there get the default
 	if(csPath.IsEmpty())
 	{
-		if(g_Opt.m_bU3)
-		{
-			csPath = "ditto-cp.sourceforge.net/U3/DittoVersion.txt";
-		}
-		else
-		{
-			csPath = "ditto-cp.sourceforge.net/Update3/DittoVersion.txt";
-		}
+		csPath = "ditto-cp.sourceforge.net/Update3/DittoVersion.txt";
 	}
 	
 	CString csUrl = "http://" + csPath;
@@ -282,14 +275,7 @@ CString CInternetUpdate::DownloadUpdate()
 	//if nothing there get the default
 	if(csPath.IsEmpty())
 	{
-		if(g_Opt.m_bU3)
-		{
-			csPath = "ditto-cp.sourceforge.net/U3/DittoSetup.exe";
-		}
-		else
-		{
-			csPath = "ditto-cp.sourceforge.net/U3/DittoSetup.exe";
-		}
+		csPath = "ditto-cp.sourceforge.net/U3/DittoSetup.exe";
 	}
 		
 

+ 31 - 89
Options.cpp

@@ -56,10 +56,10 @@ long CGetSetOptions::m_lProcessDrawClipboardDelay;
 BOOL CGetSetOptions::m_bEnableDebugLogging;
 BOOL CGetSetOptions::m_bEnsureConnectToClipboard;
 bool CGetSetOptions::m_bOutputDebugString;
-bool CGetSetOptions::m_bU3 = false;
 bool CGetSetOptions::m_bInConversion = false;
 bool CGetSetOptions::m_bFromIni = false;
 bool CGetSetOptions::m_portable = false;
+bool CGetSetOptions::m_windowsApp = false;
 CString CGetSetOptions::m_csIniFileName;
 __int64 CGetSetOptions::nLastDbWriteTime = 0;
 CTheme CGetSetOptions::m_Theme;
@@ -78,23 +78,31 @@ CGetSetOptions::~CGetSetOptions()
 
 void CGetSetOptions::LoadSettings()
 {
-	m_csIniFileName = GetIniFileName(true);
+	CString exeDir = CGetSetOptions::GetExeFileName();
+	exeDir = GetFilePath(exeDir);
+	FIX_CSTRING_PATH(exeDir);
 
-	CString portable = GetFilePath(m_csIniFileName);
-	portable += _T("portable");
-	if(FileExists(portable)) 
-	{
-		m_portable = true;
-	}
-
-	if(m_bU3)
+	CString windowsAppFile = exeDir += _T("WindowsApp");
+	if (FileExists(windowsAppFile))
 	{
+		m_windowsApp = true;
 		m_bFromIni = true;
+		//always use the ini file in the app data folder for windows store
+		m_csIniFileName = GetIniFileName(false);
 	}
 	else
 	{
+		m_csIniFileName = GetIniFileName(true);
+
+		CString portable = GetFilePath(m_csIniFileName);
+		portable += _T("portable");
+		if (FileExists(portable))
+		{
+			m_portable = true;
+		}
+
 		//first check if ini file is in app directory
-		if(m_portable || FileExists(m_csIniFileName))
+		if (m_portable || FileExists(m_csIniFileName))
 		{
 			m_bFromIni = true;
 		}
@@ -102,7 +110,7 @@ void CGetSetOptions::LoadSettings()
 		{
 			//next check if it's in app data
 			m_csIniFileName = GetIniFileName(false);
-			if(FileExists(m_csIniFileName))
+			if (FileExists(m_csIniFileName))
 			{
 				m_bFromIni = true;
 			}
@@ -174,43 +182,6 @@ void CGetSetOptions::LoadSettings()
 
 	GetClientSendCount();
 
-
-	//If running from a U3 device and no language file as been asigned
-	//then use the language defined by the U3 launcher
-	if(m_bU3)
-	{
-		CString csLanguage = GetLanguageFile();
-		if(csLanguage.IsEmpty())
-		{
-			CString csLanguage = GETENV(_T("U3_ENV_LANGUAGE"));
-			long lLanguage = ATOI(csLanguage);
-			csLanguage.Empty();
-			switch(lLanguage)
-			{
-			case 1036: //French
-				csLanguage = _T("Français");
-				break;
-
-			case 1040: //Italian
-				csLanguage = _T("Italiano");
-				break;
-
-			case 1031: //German
-				csLanguage = _T("German");
-				break;
-
-			case 3082: //German
-				csLanguage = _T("Español");
-				break;
-			}
-
-			if(csLanguage.IsEmpty() == FALSE)
-			{
-				SetLanguageFile(csLanguage);
-			}
-		}
-	}
-
 	m_Theme.Load(GetTheme());
 }
 
@@ -318,21 +289,14 @@ void CGetSetOptions::ConverSettingsToIni()
 CString CGetSetOptions::GetIniFileName(bool bLocalIniFile)
 {
 	CString csPath = _T("c:\\program files\\Ditto\\");
-
-	if(m_bU3)
+	
+	if(bLocalIniFile)
 	{
-		csPath = CGetSetOptions::GetPath(PATH_INI);
+		csPath = GetFilePath(GetExeFileName());
 	}
 	else
-	{	
-		if(bLocalIniFile)
-		{
-			csPath = GetFilePath(GetExeFileName());
-		}
-		else
-		{
-			csPath = GetAppDataPath();
-		}
+	{
+		csPath = GetAppDataPath();
 	}
 
 	csPath += "Ditto.Settings";
@@ -702,10 +666,6 @@ BOOL CGetSetOptions::GetRunOnStartUp()
 
 void CGetSetOptions::SetRunOnStartUp(BOOL bRun)
 {
-	//Can't set auto run when running from U3 device
-	if(m_bU3)
-		return;
-
 	if(bRun == GetRunOnStartUp())
 		return;
 
@@ -860,22 +820,7 @@ BOOL CGetSetOptions::SetDBPath(CString csPath)
 CString CGetSetOptions::GetDBPath()
 {
 	CString csDBPath;
-	if(m_bU3)
-	{
-		csDBPath = GetProfileString("DBPath3", "");
-		if(csDBPath.IsEmpty())
-		{
-			csDBPath = GetDefaultDBName();
-		}
-
-		CPath ExistingPath(csDBPath);
-		csDBPath = CGetSetOptions::GetPath(PATH_DATABASE);
-		csDBPath += ExistingPath.GetName();
-	}
-	else
-	{
-		csDBPath = GetProfileString("DBPath3", "");
-	}
+	csDBPath = GetProfileString("DBPath3", "");
 
 	return csDBPath;
 }
@@ -888,8 +833,6 @@ void CGetSetOptions::SetCheckForMaxEntries(BOOL bVal)
 BOOL CGetSetOptions::GetCheckForMaxEntries()
 {
 	BOOL bDefault = FALSE;
-	if(m_bU3)
-		bDefault = TRUE;
 	if(GetIsPortableDitto())
 		bDefault = TRUE;
 
@@ -914,8 +857,6 @@ void CGetSetOptions::SetMaxEntries(long lVal)
 long CGetSetOptions::GetMaxEntries()
 {
 	long lMax = 500;
-	if(m_bU3)
-		lMax = 75;
 	if(GetIsPortableDitto())
 		lMax = 100;
 	return GetProfileLong("MaxEntries", lMax);
@@ -1310,8 +1251,6 @@ long CGetSetOptions::GetPort()
 BOOL CGetSetOptions::GetDisableRecieve()
 {
 	BOOL bDefault = FALSE;
-	if(m_bU3)
-		bDefault = TRUE;
 	if(GetIsPortableDitto())
 		bDefault = TRUE;
 
@@ -1398,8 +1337,6 @@ void CGetSetOptions::SetDrawThumbnail(long bDraw)
 BOOL CGetSetOptions::GetDrawThumbnail()
 {
 	BOOL bDrawThumbnails = TRUE;
-	if(g_Opt.m_bU3)
-		bDrawThumbnails = FALSE;
 
 	return GetProfileLong("DrawThumbnail", bDrawThumbnails);
 }
@@ -1790,6 +1727,11 @@ bool CGetSetOptions::GetIsPortableDitto()
 	return m_portable;
 }
 
+bool CGetSetOptions::GetIsWindowsApp()
+{
+	return m_windowsApp;
+}
+
 CString CGetSetOptions::GetPasteString(CString csAppName)
 {
 	CString csString = GetProfileString(csAppName, _T(""), _T("PasteStrings"));

+ 2 - 1
Options.h

@@ -71,9 +71,9 @@ public:
 	static bool m_bFromIni;
 	static CString m_csIniFileName;
 	static bool m_bInConversion;
-	static bool m_bU3;
 	static CTheme m_Theme;
 	static bool m_portable;
+	static bool m_windowsApp;
 
 	static void LoadSettings();
 	static CString GetIniFileName(bool bLocalIniFile);
@@ -374,6 +374,7 @@ public:
 	static bool GetAllowFriends();
 
 	static bool		GetIsPortableDitto();
+	static bool		GetIsWindowsApp();
 
 	static long		GetAutoMaxDelay();
 	static void		SetAutoMaxDelay(long lDelay);

+ 1 - 14
OptionsGeneral.cpp

@@ -138,19 +138,6 @@ BOOL COptionsGeneral::OnInitDialog()
 
 	UpdateData(FALSE);
 
-	if(g_Opt.m_bU3)
-	{
-		//If running from a U3 device then don't allow them to set
-		//-run on startup
-		//-db path
-		m_btRunOnStartup.ShowWindow(SW_HIDE);
-		m_ePath.EnableWindow(FALSE);
-		m_btSetDatabasePath.EnableWindow(FALSE);
-		m_btGetPath.EnableWindow(FALSE);
-		m_ePath.SetWindowText(_T("U3 Device"));
-		::ShowWindow(::GetDlgItem(m_hWnd, IDC_CHECK_FOR_UPDATES), SW_HIDE);
-	}
-
 	theApp.m_Language.UpdateOptionGeneral(this);
 	return TRUE;
 }
@@ -250,7 +237,7 @@ BOOL COptionsGeneral::OnApply()
 	m_MaxClipSize.GetWindowText(csMax);
 	g_Opt.SetMaxClipSizeInBytes(ATOI(csMax));
 
-	if(!g_Opt.m_bU3 && m_btSetDatabasePath.GetCheck() == BST_CHECKED)
+	if(m_btSetDatabasePath.GetCheck() == BST_CHECKED)
 	{
 		CString csPath;
 		m_ePath.GetWindowText(csPath);

+ 1 - 5
OptionsTypes.cpp

@@ -91,11 +91,7 @@ BOOL COptionsTypes::OnInitDialog()
 			m_List.AddString(GetFormatName(RegisterClipboardFormat(CF_RTF)));
 			m_List.AddString(_T("CF_UNICODETEXT"));
 			m_List.AddString(_T("CF_HDROP"));
-
-			if(g_Opt.m_bU3 == false)
-			{
-				m_List.AddString(_T("CF_DIB"));
-			}
+			m_List.AddString(_T("CF_DIB"));
 		}
 
 		while(q.eof() == false)

+ 0 - 7
ProcessPaste.cpp

@@ -112,13 +112,6 @@ UINT CProcessPaste::MarkAsPastedThread(LPVOID pParam)
 
 	Log(_T("Start of MarkAsPastedThread"));
 
-	//If running from a U3 device then wait a little before updating the db
-	//updating the db can take a second or two and it delays the act of pasting
-	if(g_Opt.m_bU3)
-	{
-		Sleep(350);
-	}
-
 	BOOL bRet = FALSE;
 	int clipId = 0;