Options.cpp 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637
  1. #include "stdafx.h"
  2. #include "Options.h"
  3. #include "AlphaBlend.h"
  4. #include "Misc.h"
  5. #include "TextConvert.h"
  6. #include "sqlite\CppSQLite3.h"
  7. UINT WritePrivateProfileInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, INT nValue, LPCTSTR lpFileName)
  8. {
  9. // Locals
  10. TCHAR szBuff[25];
  11. // Format
  12. SPRINTF(szBuff, _T("%d"), nValue);
  13. // Write
  14. return WritePrivateProfileString(lpAppName, lpKeyName, szBuff, lpFileName);
  15. }
  16. long CGetSetOptions::m_nLinesPerRow;
  17. BOOL CGetSetOptions::m_bUseCtrlNumAccel;
  18. BOOL CGetSetOptions::m_bAllowDuplicates;
  19. BOOL CGetSetOptions::m_bUpdateTimeOnPaste;
  20. BOOL CGetSetOptions::m_bSaveMultiPaste;
  21. BOOL CGetSetOptions::m_bShowPersistent;
  22. BOOL CGetSetOptions::m_bHistoryStartTop;
  23. long CGetSetOptions::m_bDescTextSize;
  24. BOOL CGetSetOptions::m_bDescShowLeadingWhiteSpace;
  25. BOOL CGetSetOptions::m_bAllwaysShowDescription;
  26. long CGetSetOptions::m_bDoubleClickingOnCaptionDoes;
  27. BOOL CGetSetOptions::m_bPrompForNewGroupName;
  28. BOOL CGetSetOptions::m_bSendPasteOnFirstTenHotKeys;
  29. CSendClients CGetSetOptions::m_SendClients[MAX_SEND_CLIENTS];
  30. long CGetSetOptions::m_lAutoSendClientCount;
  31. CString CGetSetOptions::m_csIPListToPutOnClipboard;
  32. BOOL CGetSetOptions::m_bLogSendReceiveErrors;
  33. BOOL CGetSetOptions::m_bUseHookDllForFocus;
  34. BOOL CGetSetOptions::m_HideDittoOnHotKeyIfAlreadyShown;
  35. long CGetSetOptions::m_lPort;
  36. BOOL CGetSetOptions::m_bDrawThumbnail;
  37. CStringA CGetSetOptions::m_csPassword;
  38. BOOL CGetSetOptions::m_bDrawRTF;
  39. BOOL CGetSetOptions::m_bMultiPasteReverse;
  40. CString CGetSetOptions::m_csPlaySoundOnCopy;
  41. CStringArray CGetSetOptions::m_csNetworkPasswordArray;
  42. BOOL CGetSetOptions::m_bSendPasteMessageAfterSelection;
  43. BOOL CGetSetOptions::m_bFindAsYouType;
  44. BOOL CGetSetOptions::m_bEnsureEntireWindowCanBeSeen;
  45. BOOL CGetSetOptions::m_bShowAllClipsInMainList;
  46. long CGetSetOptions::m_lMaxClipSizeInBytes;
  47. DWORD CGetSetOptions::m_dwSaveClipDelay;
  48. long CGetSetOptions::m_lProcessDrawClipboardDelay;
  49. BOOL CGetSetOptions::m_bEnableDebugLogging;
  50. BOOL CGetSetOptions::m_bEnsureConnectToClipboard;
  51. bool CGetSetOptions::m_bOutputDebugString;
  52. bool CGetSetOptions::m_bU3 = false;
  53. bool CGetSetOptions::m_bInConversion = false;
  54. bool CGetSetOptions::m_bFromIni = false;
  55. CString CGetSetOptions::m_csIniFileName;
  56. __int64 CGetSetOptions::nLastDbWriteTime = 0;
  57. CGetSetOptions g_Opt;
  58. CGetSetOptions::CGetSetOptions()
  59. {
  60. }
  61. CGetSetOptions::~CGetSetOptions()
  62. {
  63. }
  64. void CGetSetOptions::LoadSettings()
  65. {
  66. m_csIniFileName = GetIniFileName();
  67. if(m_bU3)
  68. m_bFromIni = true;
  69. if(!m_bU3)
  70. {
  71. // m_bInConversion = true;
  72. //
  73. // //If there is a variable in the registry for the db path but no .ini file
  74. // //then we need to convert the registry settings to .ini settings
  75. //
  76. // CString csDB = GetDBPath();
  77. // if(csDB.IsEmpty())
  78. // csDB = GetDBPathOld();
  79. // if(csDB.IsEmpty() == FALSE && FileExists(m_csIniFileName) == FALSE)
  80. // {
  81. // ConverSettingsToIni();
  82. // }
  83. //
  84. // m_bInConversion = false;
  85. }
  86. m_nLinesPerRow = GetLinesPerRow();
  87. m_bUseCtrlNumAccel = GetUseCtrlNumForFirstTenHotKeys();
  88. m_bAllowDuplicates = GetAllowDuplicates();
  89. m_bUpdateTimeOnPaste = GetUpdateTimeOnPaste();
  90. m_bSaveMultiPaste = GetSaveMultiPaste();
  91. m_bShowPersistent = GetShowPersistent();
  92. m_bHistoryStartTop = GetHistoryStartTop();
  93. m_bDescTextSize = GetDescTextSize();
  94. m_bDescShowLeadingWhiteSpace = GetDescShowLeadingWhiteSpace();
  95. m_bAllwaysShowDescription = GetAllwaysShowDescription();
  96. m_bDoubleClickingOnCaptionDoes = GetDoubleClickingOnCaptionDoes();
  97. m_bPrompForNewGroupName = GetPrompForNewGroupName();
  98. m_bSendPasteOnFirstTenHotKeys = GetSendPasteOnFirstTenHotKeys();
  99. m_csIPListToPutOnClipboard = GetListToPutOnClipboard();
  100. m_bLogSendReceiveErrors = GetLogSendReceiveErrors();
  101. //If running from U3 then we can't use the hook dll because we are unable
  102. //to delete the hook dll, it's loaded by other processes
  103. if(m_bU3)
  104. m_bUseHookDllForFocus = GetProfileLong("UseHookDllForFocus", FALSE);
  105. else
  106. m_bUseHookDllForFocus = GetProfileLong("UseHookDllForFocus", TRUE);
  107. m_HideDittoOnHotKeyIfAlreadyShown = GetHideDittoOnHotKeyIfAlreadyShown();
  108. m_lPort = GetPort();
  109. m_bDrawThumbnail = GetDrawThumbnail();
  110. m_csPassword = GetNetworkPassword();
  111. m_bDrawRTF = GetDrawRTF();
  112. m_bMultiPasteReverse = GetMultiPasteReverse();
  113. m_csPlaySoundOnCopy = GetPlaySoundOnCopy();
  114. m_bSendPasteMessageAfterSelection = GetSendPasteAfterSelection();
  115. m_bFindAsYouType = GetFindAsYouType();
  116. m_bEnsureEntireWindowCanBeSeen = GetEnsureEntireWindowCanBeSeen();
  117. m_bShowAllClipsInMainList = GetShowAllClipsInMainList();
  118. m_lMaxClipSizeInBytes = GetMaxClipSizeInBytes();
  119. m_dwSaveClipDelay = GetSaveClipDelay();
  120. m_lProcessDrawClipboardDelay = GetProcessDrawClipboardDelay();
  121. m_bEnableDebugLogging = GetEnableDebugLogging();
  122. m_bEnsureConnectToClipboard = GetEnsureConnectToClipboard();
  123. m_bOutputDebugString = false;
  124. GetExtraNetworkPassword(true);
  125. #ifdef _DEBUG
  126. m_bUseHookDllForFocus = FALSE;
  127. #endif
  128. for(int i = 0; i < MAX_SEND_CLIENTS; i++)
  129. {
  130. GetSendClients(i);
  131. }
  132. GetClientSendCount();
  133. //If running from a U3 device and no language file as been asigned
  134. //then use the language defined by the U3 launcher
  135. if(m_bU3)
  136. {
  137. CString csLanguage = GetLanguageFile();
  138. if(csLanguage.IsEmpty())
  139. {
  140. CString csLanguage = GETENV(_T("U3_ENV_LANGUAGE"));
  141. long lLanguage = ATOI(csLanguage);
  142. csLanguage.Empty();
  143. switch(lLanguage)
  144. {
  145. case 1036: //French
  146. csLanguage = _T("Français");
  147. break;
  148. case 1040: //Italian
  149. csLanguage = _T("Italiano");
  150. break;
  151. case 1031: //German
  152. csLanguage = _T("German");
  153. break;
  154. case 3082: //German
  155. csLanguage = _T("Español");
  156. break;
  157. }
  158. if(csLanguage.IsEmpty() == FALSE)
  159. {
  160. SetLanguageFile(csLanguage);
  161. }
  162. }
  163. }
  164. }
  165. void CGetSetOptions::ConverSettingsToIni()
  166. {
  167. m_bInConversion = true;
  168. CSize sz;
  169. CPoint pt;
  170. GetQuickPasteSize(sz);
  171. SetQuickPasteSize(sz);
  172. GetQuickPastePoint(pt);
  173. SetQuickPastePoint(pt);
  174. GetEditWndSize(sz);
  175. SetEditWndSize(sz);
  176. GetEditWndPoint(pt);
  177. SetEditWndPoint(pt);
  178. SetShowIconInSysTray(GetShowIconInSysTray());
  179. SetRunOnStartUp(GetRunOnStartUp());
  180. SetEnableTransparency(GetEnableTransparency());
  181. SetTransparencyPercent(GetTransparencyPercent());
  182. SetLinesPerRow(GetLinesPerRow());
  183. SetQuickPastePosition(GetQuickPastePosition());
  184. SetCopyGap(GetCopyGap());
  185. SetDBPath(GetDBPath());
  186. SetCheckForMaxEntries(GetCheckForMaxEntries());
  187. SetCheckForExpiredEntries(GetCheckForExpiredEntries());
  188. SetMaxEntries(GetMaxEntries());
  189. SetExpiredEntries(GetExpiredEntries());
  190. SetTripCopyCount(GetTripCopyCount());
  191. SetTripPasteCount(GetTripPasteCount());
  192. SetTripDate(GetTripDate());
  193. SetTotalCopyCount(GetTotalCopyCount());
  194. SetTotalPasteCount(GetTotalPasteCount());
  195. SetTotalDate(GetTotalDate());
  196. SetUpdateFilePath(GetUpdateFilePath());
  197. SetUpdateInstallPath(GetUpdateInstallPath());
  198. SetLastUpdate(GetLastUpdate());
  199. SetCheckForUpdates(GetCheckForUpdates());
  200. SetUseCtrlNumForFirstTenHotKeys(GetUseCtrlNumForFirstTenHotKeys());
  201. SetAllowDuplicates(GetAllowDuplicates());
  202. SetUpdateTimeOnPaste(GetUpdateTimeOnPaste());
  203. SetSaveMultiPaste(GetSaveMultiPaste());
  204. SetShowPersistent(GetShowPersistent());
  205. SetHistoryStartTop(GetHistoryStartTop());
  206. SetShowTextForFirstTenHotKeys(GetShowTextForFirstTenHotKeys());
  207. SetMainHWND(GetMainHWND());
  208. SetCaptionPos(GetCaptionPos());
  209. SetAutoHide(GetAutoHide());
  210. SetDescTextSize(GetDescTextSize());
  211. SetDescShowLeadingWhiteSpace(GetDescShowLeadingWhiteSpace());
  212. SetAllwaysShowDescription(GetAllwaysShowDescription());
  213. SetDoubleClickingOnCaptionDoes(GetDoubleClickingOnCaptionDoes());
  214. SetPrompForNewGroupName(GetPrompForNewGroupName());
  215. SetSendPasteOnFirstTenHotKeys(GetSendPasteOnFirstTenHotKeys());
  216. for(int i = 0; i < MAX_SEND_CLIENTS; i++)
  217. {
  218. GetSendClients(i);
  219. SetSendClients(m_SendClients[i], i);
  220. }
  221. SetListToPutOnClipboard(GetListToPutOnClipboard());
  222. SetLogSendReceiveErrors(GetLogSendReceiveErrors());
  223. SetHideDittoOnHotKeyIfAlreadyShown(GetHideDittoOnHotKeyIfAlreadyShown());
  224. SetPort(GetPort());
  225. SetDisableRecieve(GetDisableRecieve());
  226. LOGFONT font;
  227. GetFont(font);
  228. SetFont(font);
  229. SetDrawThumbnail(GetDrawThumbnail());
  230. CStringA PassA = GetNetworkPassword();
  231. CString PassW = PassA;
  232. SetNetworkPassword(PassW);
  233. SetDrawRTF(GetDrawRTF());
  234. SetMultiPasteReverse(GetMultiPasteReverse());
  235. SetPlaySoundOnCopy(GetPlaySoundOnCopy());
  236. SetSendPasteAfterSelection(GetSendPasteAfterSelection());
  237. SetFindAsYouType(GetFindAsYouType());
  238. SetEnsureEntireWindowCanBeSeen(GetEnsureEntireWindowCanBeSeen());
  239. SetShowAllClipsInMainList(GetShowAllClipsInMainList());
  240. SetExtraNetworkPassword(GetExtraNetworkPassword(false));
  241. SetMaxClipSizeInBytes(GetMaxClipSizeInBytes());
  242. SetLanguageFile(GetLanguageFile());
  243. SetSaveClipDelay(GetSaveClipDelay());
  244. SetProcessDrawClipboardDelay(GetProcessDrawClipboardDelay());
  245. SetEnableDebugLogging(GetEnableDebugLogging());
  246. SetEnsureConnectToClipboard(GetEnsureConnectToClipboard());
  247. SetPromptWhenDeletingClips(GetPromptWhenDeletingClips());
  248. SetLastImportDir(GetLastImportDir());
  249. SetLastExportDir(GetLastExportDir());
  250. SetUpdateDescWhenSavingClip(GetUpdateDescWhenSavingClip());
  251. m_bInConversion = false;
  252. }
  253. CString CGetSetOptions::GetIniFileName()
  254. {
  255. CString csPath = _T("c:\\program files\\Ditto\\");
  256. if(m_bU3)
  257. {
  258. csPath = CGetSetOptions::GetPath(PATH_INI);
  259. }
  260. else
  261. {
  262. LPMALLOC pMalloc;
  263. if(SUCCEEDED(::SHGetMalloc(&pMalloc)))
  264. {
  265. LPITEMIDLIST pidlPrograms;
  266. SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidlPrograms);
  267. TCHAR string[MAX_PATH];
  268. SHGetPathFromIDList(pidlPrograms, string);
  269. pMalloc->Free(pidlPrograms);
  270. pMalloc->Release();
  271. csPath = string;
  272. }
  273. FIX_CSTRING_PATH(csPath);
  274. csPath += "Ditto\\";
  275. }
  276. if(FileExists(csPath) == FALSE)
  277. CreateDirectory(csPath, NULL);
  278. csPath = csPath + "Ditto.Settings";
  279. return csPath;
  280. }
  281. long CGetSetOptions::GetProfileLong(CString csName, long lDefaultValue)
  282. {
  283. if(m_bFromIni && !m_bInConversion)
  284. {
  285. return GetPrivateProfileInt(_T("Ditto"), csName, lDefaultValue, m_csIniFileName);
  286. }
  287. HKEY hkKey;
  288. long lResult = RegOpenKeyEx(HKEY_CURRENT_USER, _T(REG_PATH),
  289. NULL, KEY_READ, &hkKey);
  290. if(lResult != ERROR_SUCCESS)
  291. return lDefaultValue;
  292. DWORD buffer;
  293. DWORD len = sizeof(buffer);
  294. DWORD type;
  295. lResult = ::RegQueryValueEx(hkKey, csName, 0, &type, (LPBYTE)&buffer, &len);
  296. RegCloseKey(hkKey);
  297. if(lResult == ERROR_SUCCESS)
  298. return (long)buffer;
  299. return lDefaultValue;
  300. }
  301. CString CGetSetOptions::GetProfileString(CString csName, CString csDefault)
  302. {
  303. if(m_bFromIni && !m_bInConversion)
  304. {
  305. TCHAR cString[MAX_PATH];
  306. GetPrivateProfileString(_T("Ditto"), csName, csDefault, cString, sizeof(cString), m_csIniFileName);
  307. return cString;
  308. }
  309. HKEY hkKey;
  310. long lResult = RegOpenKeyEx(HKEY_CURRENT_USER, _T(REG_PATH),
  311. NULL, KEY_READ, &hkKey);
  312. TCHAR szString[256];
  313. ZeroMemory(szString, sizeof(szString));
  314. DWORD dwBufLen = 256;
  315. lResult = ::RegQueryValueEx(hkKey , csName, NULL, NULL, (LPBYTE)szString, &dwBufLen);
  316. RegCloseKey(hkKey);
  317. if(lResult != ERROR_SUCCESS)
  318. return csDefault;
  319. return szString;
  320. }
  321. BOOL CGetSetOptions::SetProfileLong(CString csName, long lValue)
  322. {
  323. if(m_bFromIni)
  324. {
  325. return WritePrivateProfileInt(_T("Ditto"), csName, lValue, m_csIniFileName);
  326. }
  327. HKEY hkKey;
  328. DWORD dWord;
  329. long lResult = RegCreateKeyEx(HKEY_CURRENT_USER, _T(REG_PATH), NULL,
  330. NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
  331. NULL, &hkKey, &dWord);
  332. if(lResult != ERROR_SUCCESS)
  333. return FALSE;
  334. DWORD val = (DWORD)lValue;
  335. lResult = ::RegSetValueEx(hkKey, csName, 0, REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
  336. RegCloseKey(hkKey);
  337. return lResult == ERROR_SUCCESS;
  338. }
  339. BOOL CGetSetOptions::SetProfileString(CString csName, CString csValue)
  340. {
  341. if(m_bFromIni)
  342. {
  343. return WritePrivateProfileString(_T("Ditto"), csName, csValue, m_csIniFileName);
  344. }
  345. HKEY hkKey;
  346. DWORD dWord;
  347. long lResult = RegCreateKeyEx(HKEY_CURRENT_USER, _T(REG_PATH), NULL,
  348. NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
  349. NULL, &hkKey, &dWord);
  350. if(lResult != ERROR_SUCCESS)
  351. return FALSE;
  352. ::RegSetValueEx(hkKey, csName, NULL, REG_SZ,
  353. (BYTE*)(LPCTSTR)csValue, csValue.GetLength()*sizeof(TCHAR));
  354. RegCloseKey(hkKey);
  355. return lResult == ERROR_SUCCESS;
  356. }
  357. BOOL CGetSetOptions::SetProfileData(CString csName, LPVOID lpData, DWORD dwLength)
  358. {
  359. if(m_bFromIni)
  360. {
  361. ASSERT(!"SetProfileData not supported in .ini settings");
  362. return FALSE;
  363. }
  364. HKEY hkKey;
  365. DWORD dWord;
  366. long lResult = RegCreateKeyEx(HKEY_CURRENT_USER, _T(REG_PATH), NULL,
  367. NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
  368. NULL, &hkKey, &dWord);
  369. if(lResult != ERROR_SUCCESS)
  370. return FALSE;
  371. ::RegSetValueEx(hkKey, csName, NULL, REG_BINARY,
  372. (BYTE*)lpData, dwLength);
  373. RegCloseKey(hkKey);
  374. return lResult == ERROR_SUCCESS;
  375. }
  376. BOOL CGetSetOptions::GetProfileFont(CString csSection, LOGFONT &font)
  377. {
  378. font.lfHeight = GetPrivateProfileInt(csSection, _T("Height"), 0, m_csIniFileName);
  379. font.lfWidth = GetPrivateProfileInt(csSection, _T("Width"), 0, m_csIniFileName);
  380. font.lfEscapement = GetPrivateProfileInt(csSection, _T("Escapement"), 0, m_csIniFileName);
  381. font.lfOrientation = GetPrivateProfileInt(csSection, _T("Orientation"), 0, m_csIniFileName);
  382. font.lfWeight = GetPrivateProfileInt(csSection, _T("Weight"), 0, m_csIniFileName);
  383. font.lfItalic = GetPrivateProfileInt(csSection, _T("Italic"), 0, m_csIniFileName);
  384. font.lfUnderline = GetPrivateProfileInt(csSection, _T("Underline"), 0, m_csIniFileName);
  385. font.lfStrikeOut = GetPrivateProfileInt(csSection, _T("StrikeOut"), 0, m_csIniFileName);
  386. font.lfCharSet = GetPrivateProfileInt(csSection, _T("CharSet"), 0, m_csIniFileName);
  387. font.lfOutPrecision = GetPrivateProfileInt(csSection, _T("OutPrecision"), 0, m_csIniFileName);
  388. font.lfClipPrecision = GetPrivateProfileInt(csSection, _T("ClipPrecision"), 0, m_csIniFileName);
  389. font.lfQuality = GetPrivateProfileInt(csSection, _T("Quality"), 0, m_csIniFileName);
  390. font.lfPitchAndFamily = GetPrivateProfileInt(csSection, _T("PitchAndFamily"), 0, m_csIniFileName);
  391. GetPrivateProfileString(csSection, _T("FaceName"), _T(""), font.lfFaceName, sizeof(font.lfFaceName), m_csIniFileName);
  392. return TRUE;
  393. }
  394. BOOL CGetSetOptions::SetProfileFont(CString csSection, LOGFONT &font)
  395. {
  396. WritePrivateProfileInt(csSection, _T("Height"), font.lfHeight, m_csIniFileName);
  397. WritePrivateProfileInt(csSection, _T("Width"), font.lfWidth, m_csIniFileName);
  398. WritePrivateProfileInt(csSection, _T("Escapement"), font.lfEscapement, m_csIniFileName);
  399. WritePrivateProfileInt(csSection, _T("Orientation"), font.lfOrientation, m_csIniFileName);
  400. WritePrivateProfileInt(csSection, _T("Weight"), font.lfWeight, m_csIniFileName);
  401. WritePrivateProfileInt(csSection, _T("Italic"), font.lfItalic, m_csIniFileName);
  402. WritePrivateProfileInt(csSection, _T("Underline"), font.lfUnderline, m_csIniFileName);
  403. WritePrivateProfileInt(csSection, _T("StrikeOut"), font.lfStrikeOut, m_csIniFileName);
  404. WritePrivateProfileInt(csSection, _T("CharSet"), font.lfCharSet, m_csIniFileName);
  405. WritePrivateProfileInt(csSection, _T("OutPrecision"), font.lfOutPrecision, m_csIniFileName);
  406. WritePrivateProfileInt(csSection, _T("ClipPrecision"), font.lfClipPrecision, m_csIniFileName);
  407. WritePrivateProfileInt(csSection, _T("Quality"), font.lfQuality, m_csIniFileName);
  408. WritePrivateProfileInt(csSection, _T("PitchAndFamily"), font.lfPitchAndFamily, m_csIniFileName);
  409. WritePrivateProfileString(csSection, _T("FaceName"), font.lfFaceName, m_csIniFileName);
  410. return TRUE;
  411. }
  412. LPVOID CGetSetOptions::GetProfileData(CString csName, DWORD &dwLength)
  413. {
  414. if(m_bFromIni && !m_bInConversion)
  415. {
  416. ASSERT(!"GetProfileData not supported in .ini settings");
  417. return NULL;
  418. }
  419. HKEY hkKey;
  420. long lResult = RegOpenKeyEx(HKEY_CURRENT_USER, _T(REG_PATH),
  421. NULL, KEY_READ, &hkKey);
  422. lResult = ::RegQueryValueEx(hkKey , csName, NULL, NULL, NULL, &dwLength);
  423. if(lResult != ERROR_SUCCESS)
  424. return NULL;
  425. LPVOID lpVoid = new BYTE[dwLength];
  426. lResult = ::RegQueryValueEx(hkKey , csName, NULL, NULL, (LPBYTE)lpVoid, &dwLength);
  427. RegCloseKey(hkKey);
  428. if(lResult != ERROR_SUCCESS)
  429. return NULL;
  430. return lpVoid;
  431. }
  432. BOOL CGetSetOptions::GetShowIconInSysTray()
  433. {
  434. return GetProfileLong("ShowIconInSystemTray", TRUE);
  435. }
  436. BOOL CGetSetOptions::SetShowIconInSysTray(BOOL bShow)
  437. {
  438. return SetProfileLong("ShowIconInSystemTray", bShow);
  439. }
  440. BOOL CGetSetOptions::SetEnableTransparency(BOOL bCheck)
  441. {
  442. return SetProfileLong("EnableTransparency", bCheck);
  443. }
  444. BOOL CGetSetOptions::GetEnableTransparency()
  445. {
  446. return GetProfileLong("EnableTransparency", FALSE);
  447. }
  448. BOOL CGetSetOptions::SetTransparencyPercent(long lPercent)
  449. {
  450. #ifdef AFTER_98
  451. if(lPercent > OPACITY_MAX)
  452. lPercent = OPACITY_MAX;
  453. if(lPercent < 0)
  454. lPercent = 0;
  455. return SetProfileLong("TransparencyPercent", lPercent);
  456. #endif
  457. return FALSE;
  458. }
  459. long CGetSetOptions::GetTransparencyPercent()
  460. {
  461. #ifdef AFTER_98
  462. long lValue = GetProfileLong("TransparencyPercent", 14);
  463. if(lValue > OPACITY_MAX) lValue = OPACITY_MAX;
  464. if(lValue < 0) lValue = 0;
  465. return lValue;
  466. #endif
  467. return 0;
  468. }
  469. BOOL CGetSetOptions::SetLinesPerRow(long lLines)
  470. {
  471. m_nLinesPerRow = lLines;
  472. return SetProfileLong("LinesPerRow", lLines);
  473. }
  474. long CGetSetOptions::GetLinesPerRow()
  475. {
  476. return GetProfileLong("LinesPerRow", 2);
  477. }
  478. BOOL CGetSetOptions::GetRunOnStartUp()
  479. {
  480. HKEY hkRun;
  481. LONG nResult = RegOpenKeyEx(HKEY_CURRENT_USER,
  482. _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"),
  483. NULL, KEY_READ, &hkRun);
  484. if(nResult != ERROR_SUCCESS)
  485. return FALSE;
  486. nResult = RegQueryValueEx(hkRun, GetAppName(), NULL, NULL, NULL, NULL);
  487. RegCloseKey(hkRun);
  488. return nResult == ERROR_SUCCESS;
  489. }
  490. void CGetSetOptions::SetRunOnStartUp(BOOL bRun)
  491. {
  492. //Can't set auto run when running from U3 device
  493. if(m_bU3)
  494. return;
  495. if(bRun == GetRunOnStartUp())
  496. return;
  497. HKEY hkRun;
  498. LONG nResult = RegOpenKeyEx(HKEY_CURRENT_USER,
  499. _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"),
  500. NULL, KEY_ALL_ACCESS, &hkRun);
  501. if(nResult != ERROR_SUCCESS)
  502. return;
  503. if(bRun)
  504. {
  505. CString sExeName = GetExeFileName();
  506. ::RegSetValueEx(hkRun, GetAppName(), NULL, REG_SZ,
  507. (BYTE*)(LPCTSTR)sExeName, sExeName.GetLength()*sizeof(TCHAR));
  508. }
  509. else
  510. {
  511. ::RegDeleteValue(hkRun, GetAppName());
  512. }
  513. ::RegCloseKey(hkRun);
  514. }
  515. CString CGetSetOptions::GetExeFileName()
  516. {
  517. CString sExeName;
  518. GetModuleFileName(NULL, sExeName.GetBuffer(_MAX_PATH),_MAX_PATH);
  519. sExeName.ReleaseBuffer();
  520. return sExeName;
  521. }
  522. CString CGetSetOptions::GetAppName()
  523. {
  524. return "Ditto";
  525. }
  526. BOOL CGetSetOptions::SetQuickPastePosition(long lPosition)
  527. {
  528. return SetProfileLong("ShowQuickPastePosition", lPosition);
  529. }
  530. long CGetSetOptions::GetQuickPastePosition()
  531. {
  532. return GetProfileLong("ShowQuickPastePosition", POS_AT_PREVIOUS);
  533. }
  534. BOOL CGetSetOptions::SetQuickPasteSize(CSize size)
  535. {
  536. BOOL bRet = SetProfileLong("QuickPasteCX", size.cx);
  537. bRet = SetProfileLong("QuickPasteCY", size.cy);
  538. return bRet;
  539. }
  540. void CGetSetOptions::GetQuickPasteSize(CSize &size)
  541. {
  542. size.cx = GetProfileLong("QuickPasteCX", 300);
  543. size.cy = GetProfileLong("QuickPasteCY", 300);
  544. if(size.cx <= 0 && size.cy <= 0)
  545. {
  546. size.cx = 300;
  547. size.cy = 300;
  548. }
  549. }
  550. BOOL CGetSetOptions::SetQuickPastePoint(CPoint point)
  551. {
  552. BOOL bRet = SetProfileLong("QuickPasteX", point.x);
  553. bRet = SetProfileLong("QuickPasteY", point.y);
  554. return bRet;
  555. }
  556. void CGetSetOptions::GetQuickPastePoint(CPoint &point)
  557. {
  558. point.x = GetProfileLong("QuickPasteX", 300);
  559. point.y = GetProfileLong("QuickPasteY", 300);
  560. if(point.x <= 0 && point.y <= 0)
  561. {
  562. point.x = 300;
  563. point.y = 300;
  564. }
  565. }
  566. BOOL CGetSetOptions::SetEditWndSize(CSize size)
  567. {
  568. BOOL bRet = SetProfileLong("EditWndCX", size.cx);
  569. bRet = SetProfileLong("EditWndCY", size.cy);
  570. return bRet;
  571. }
  572. void CGetSetOptions::GetEditWndSize(CSize &size)
  573. {
  574. size.cx = GetProfileLong("EditWndCX", 600);
  575. size.cy = GetProfileLong("EditWndCY", 600);
  576. if(size.cx <= 0 && size.cy <= 0)
  577. {
  578. size.cx = 600;
  579. size.cy = 600;
  580. }
  581. }
  582. BOOL CGetSetOptions::SetEditWndPoint(CPoint point)
  583. {
  584. BOOL bRet = SetProfileLong("EditWndX", point.x);
  585. bRet = SetProfileLong("EditWndY", point.y);
  586. return bRet;
  587. }
  588. void CGetSetOptions::GetEditWndPoint(CPoint &point)
  589. {
  590. point.x = GetProfileLong("EditWndX", 100);
  591. point.y = GetProfileLong("EditWndY", 100);
  592. if(point.x <= 0 && point.y <= 0)
  593. {
  594. point.x = 100;
  595. point.y = 100;
  596. }
  597. }
  598. long CGetSetOptions::GetCopyGap()
  599. {
  600. return GetProfileLong("CopyGap", 150);
  601. }
  602. void CGetSetOptions::SetCopyGap(long lGap)
  603. {
  604. SetProfileLong("CopyGap", lGap);
  605. }
  606. BOOL CGetSetOptions::SetDBPathOld(CString csPath)
  607. {
  608. return SetProfileString("DBPath", csPath);
  609. }
  610. CString CGetSetOptions::GetDBPathOld()
  611. {
  612. return GetProfileString("DBPath", "");
  613. }
  614. BOOL CGetSetOptions::SetDBPath(CString csPath)
  615. {
  616. return SetProfileString("DBPath3", csPath);
  617. }
  618. CString CGetSetOptions::GetDBPath()
  619. {
  620. //First check the reg string
  621. CString csDBPath = GetProfileString("DBPath3", "");
  622. return csDBPath;
  623. }
  624. void CGetSetOptions::SetCheckForMaxEntries(BOOL bVal)
  625. {
  626. SetProfileLong("CheckForMaxEntries", bVal);
  627. }
  628. BOOL CGetSetOptions::GetCheckForMaxEntries()
  629. {
  630. BOOL bDefault = FALSE;
  631. if(m_bU3)
  632. bDefault = TRUE;
  633. return GetProfileLong("CheckForMaxEntries", bDefault);
  634. }
  635. void CGetSetOptions::SetCheckForExpiredEntries(BOOL bVal)
  636. {
  637. SetProfileLong("CheckForExpiredEntries", bVal);
  638. }
  639. BOOL CGetSetOptions::GetCheckForExpiredEntries()
  640. {
  641. return GetProfileLong("CheckForExpiredEntries", FALSE);
  642. }
  643. void CGetSetOptions::SetMaxEntries(long lVal)
  644. {
  645. SetProfileLong("MaxEntries", lVal);
  646. }
  647. long CGetSetOptions::GetMaxEntries()
  648. {
  649. long lMax = 500;
  650. if(m_bU3)
  651. lMax = 75;
  652. return GetProfileLong("MaxEntries", lMax);
  653. }
  654. void CGetSetOptions::SetExpiredEntries(long lVal)
  655. {
  656. SetProfileLong("ExpiredEntries", lVal);
  657. }
  658. long CGetSetOptions::GetExpiredEntries()
  659. {
  660. return GetProfileLong("ExpiredEntries", 5);
  661. }
  662. void CGetSetOptions::SetTripCopyCount(long lVal)
  663. {
  664. // negative means a relative offset
  665. if(lVal < 0)
  666. lVal = GetTripCopyCount() - lVal; // add the absolute value
  667. if(GetTripDate() == 0)
  668. SetTripDate(-1);
  669. SetProfileLong("TripCopies", lVal);
  670. }
  671. long CGetSetOptions::GetTripCopyCount()
  672. {
  673. return GetProfileLong("TripCopies", 0);
  674. }
  675. void CGetSetOptions::SetTripPasteCount(long lVal)
  676. {
  677. // negative means a relative offset
  678. if(lVal < 0)
  679. lVal = GetTripPasteCount() - lVal; // add the absolute value
  680. if(GetTripDate() == 0)
  681. SetTripDate(-1);
  682. SetProfileLong("TripPastes", lVal);
  683. }
  684. long CGetSetOptions::GetTripPasteCount()
  685. {
  686. return GetProfileLong("TripPastes", 0);
  687. }
  688. void CGetSetOptions::SetTripDate(long lDate)
  689. {
  690. if(lDate == -1)
  691. lDate = (long)CTime::GetCurrentTime().GetTime();
  692. SetProfileLong("TripDate", lDate);
  693. }
  694. long CGetSetOptions::GetTripDate()
  695. {
  696. return GetProfileLong("TripDate", 0);
  697. }
  698. void CGetSetOptions::SetTotalCopyCount(long lVal)
  699. {
  700. // negative means a relative offset
  701. if(lVal < 0)
  702. lVal = GetTotalCopyCount() - lVal; // add the absolute value
  703. if(GetTotalDate() == 0)
  704. SetTotalDate(-1);
  705. SetProfileLong("TotalCopies", lVal);
  706. }
  707. long CGetSetOptions::GetTotalCopyCount()
  708. {
  709. return GetProfileLong("TotalCopies", 0);
  710. }
  711. void CGetSetOptions::SetTotalPasteCount(long lVal)
  712. {
  713. // negative means a relative offset
  714. if(lVal < 0)
  715. lVal = GetTotalPasteCount() - lVal; // add the absolute value
  716. if(GetTotalDate() == 0)
  717. SetTotalDate(-1);
  718. SetProfileLong("TotalPastes", lVal);
  719. }
  720. long CGetSetOptions::GetTotalPasteCount()
  721. {
  722. return GetProfileLong("TotalPastes", 0);
  723. }
  724. void CGetSetOptions::SetTotalDate(long lDate)
  725. {
  726. if(lDate == -1)
  727. lDate = (long)CTime::GetCurrentTime().GetTime();
  728. SetProfileLong("TotalDate", lDate);
  729. }
  730. long CGetSetOptions::GetTotalDate()
  731. {
  732. return GetProfileLong("TotalDate", 0);
  733. }
  734. CString CGetSetOptions::GetUpdateFilePath()
  735. {
  736. return GetProfileString("UpdateFilePath", "");
  737. }
  738. BOOL CGetSetOptions::SetUpdateFilePath(CString cs)
  739. {
  740. return SetProfileString("UpdateFilePath", cs);
  741. }
  742. CString CGetSetOptions::GetUpdateInstallPath()
  743. {
  744. return GetProfileString("UpdateInstallPath", "");
  745. }
  746. BOOL CGetSetOptions::SetUpdateInstallPath(CString cs)
  747. {
  748. return SetProfileString("UpdateInstallPath", cs);
  749. }
  750. long CGetSetOptions::GetLastUpdate()
  751. {
  752. return GetProfileLong("LastUpdateDay", 0);
  753. }
  754. long CGetSetOptions::SetLastUpdate(long lValue)
  755. {
  756. return SetProfileLong("LastUpdateDay", lValue);
  757. }
  758. BOOL CGetSetOptions::GetCheckForUpdates()
  759. {
  760. return GetProfileLong("CheckForUpdates", TRUE);
  761. }
  762. BOOL CGetSetOptions::SetCheckForUpdates(BOOL bCheck)
  763. {
  764. return SetProfileLong("CheckForUpdates", bCheck);
  765. }
  766. void CGetSetOptions::SetUseCtrlNumForFirstTenHotKeys(BOOL bVal)
  767. {
  768. SetProfileLong("UseCtrlNumForFirstTenHotKeys", bVal);
  769. m_bUseCtrlNumAccel = bVal;
  770. }
  771. BOOL CGetSetOptions::GetUseCtrlNumForFirstTenHotKeys()
  772. {
  773. return GetProfileLong("UseCtrlNumForFirstTenHotKeys", 0);
  774. }
  775. void CGetSetOptions::SetAllowDuplicates(BOOL bVal)
  776. {
  777. SetProfileLong("AllowDuplicates", bVal);
  778. m_bAllowDuplicates = bVal;
  779. }
  780. BOOL CGetSetOptions::GetAllowDuplicates()
  781. {
  782. return GetProfileLong("AllowDuplicates", 0);
  783. }
  784. void CGetSetOptions::SetUpdateTimeOnPaste(BOOL bVal)
  785. {
  786. SetProfileLong("UpdateTimeOnPaste", bVal);
  787. m_bUpdateTimeOnPaste = bVal;
  788. }
  789. BOOL CGetSetOptions::GetUpdateTimeOnPaste()
  790. {
  791. return GetProfileLong("UpdateTimeOnPaste", TRUE);
  792. }
  793. void CGetSetOptions::SetSaveMultiPaste(BOOL bVal)
  794. {
  795. SetProfileLong("SaveMultiPaste", bVal);
  796. m_bSaveMultiPaste = bVal;
  797. }
  798. BOOL CGetSetOptions::GetSaveMultiPaste()
  799. {
  800. return GetProfileLong("SaveMultiPaste", 0);
  801. }
  802. void CGetSetOptions::SetShowPersistent(BOOL bVal)
  803. {
  804. SetProfileLong("ShowPersistent", bVal);
  805. m_bShowPersistent = bVal;
  806. }
  807. BOOL CGetSetOptions::GetShowPersistent()
  808. {
  809. return GetProfileLong("ShowPersistent", 0);
  810. }
  811. void CGetSetOptions::SetHistoryStartTop(BOOL bVal)
  812. {
  813. SetProfileLong("HistoryStartTop", bVal);
  814. m_bHistoryStartTop = bVal;
  815. }
  816. BOOL CGetSetOptions::GetHistoryStartTop()
  817. {
  818. return GetProfileLong("HistoryStartTop", TRUE);
  819. }
  820. void CGetSetOptions::SetShowTextForFirstTenHotKeys(BOOL bVal)
  821. {
  822. SetProfileLong("ShowTextForFirstTenHotKeys", bVal);
  823. }
  824. BOOL CGetSetOptions::GetShowTextForFirstTenHotKeys()
  825. {
  826. return GetProfileLong("ShowTextForFirstTenHotKeys", TRUE);
  827. }
  828. void CGetSetOptions::SetMainHWND(long lhWnd)
  829. {
  830. SetProfileLong("MainhWnd", lhWnd);
  831. }
  832. BOOL CGetSetOptions::GetMainHWND()
  833. {
  834. return GetProfileLong("MainhWnd", 0);
  835. }
  836. void CGetSetOptions::SetCaptionPos(long lPos)
  837. {
  838. SetProfileLong("CaptionPos", lPos);
  839. }
  840. long CGetSetOptions::GetCaptionPos()
  841. {
  842. return GetProfileLong("CaptionPos", CAPTION_RIGHT);
  843. }
  844. void CGetSetOptions::SetAutoHide(BOOL bAutoHide)
  845. {
  846. SetProfileLong("AutoHide", bAutoHide);
  847. }
  848. BOOL CGetSetOptions::GetAutoHide()
  849. {
  850. return GetProfileLong("AutoHide", FALSE);
  851. }
  852. void CGetSetOptions::SetDescTextSize(long lSize)
  853. {
  854. SetProfileLong("DescTextSize", lSize);
  855. m_bDescTextSize = lSize;
  856. }
  857. long CGetSetOptions::GetDescTextSize()
  858. {
  859. return GetProfileLong("DescTextSize", 500);
  860. }
  861. void CGetSetOptions::SetDescShowLeadingWhiteSpace(BOOL bVal)
  862. {
  863. SetProfileLong("DescShowLeadingWhiteSpace", bVal);
  864. m_bDescShowLeadingWhiteSpace = bVal;
  865. }
  866. BOOL CGetSetOptions::GetDescShowLeadingWhiteSpace()
  867. {
  868. return GetProfileLong("DescShowLeadingWhiteSpace", FALSE);
  869. }
  870. void CGetSetOptions::SetAllwaysShowDescription(long bShow)
  871. {
  872. SetProfileLong("AllwaysShowDescription", bShow);
  873. m_bAllwaysShowDescription = bShow;
  874. }
  875. BOOL CGetSetOptions::GetAllwaysShowDescription()
  876. {
  877. return GetProfileLong("AllwaysShowDescription", FALSE);
  878. }
  879. void CGetSetOptions::SetDoubleClickingOnCaptionDoes(long lOption)
  880. {
  881. SetProfileLong("DoubleClickingOnCaptionDoes", lOption);
  882. m_bDoubleClickingOnCaptionDoes = lOption;
  883. }
  884. long CGetSetOptions::GetDoubleClickingOnCaptionDoes()
  885. {
  886. return GetProfileLong("DoubleClickingOnCaptionDoes", TOGGLES_ALLWAYS_ON_TOP);
  887. }
  888. void CGetSetOptions::SetPrompForNewGroupName(BOOL bOption)
  889. {
  890. SetProfileLong("PrompForNewGroupName", bOption);
  891. m_bPrompForNewGroupName = bOption;
  892. }
  893. BOOL CGetSetOptions::GetPrompForNewGroupName()
  894. {
  895. return GetProfileLong("PrompForNewGroupName", TRUE);
  896. }
  897. void CGetSetOptions::SetSendPasteOnFirstTenHotKeys(BOOL bOption)
  898. {
  899. SetProfileLong("SendPasteOnFirstTenHotKeys", bOption);
  900. m_bSendPasteOnFirstTenHotKeys = bOption;
  901. }
  902. BOOL CGetSetOptions::GetSendPasteOnFirstTenHotKeys()
  903. {
  904. return GetProfileLong("SendPasteOnFirstTenHotKeys", TRUE);
  905. }
  906. void CGetSetOptions::SetSendClients(CSendClients Client, int nPos)
  907. {
  908. CString cs;
  909. cs.Format(_T("sendclient_ip_%d"), nPos);
  910. SetProfileString(cs, Client.csIP);
  911. cs.Format(_T("sendclient_autosend_%d"), nPos);
  912. SetProfileLong(cs, Client.bSendAll);
  913. cs.Format(_T("sendclient_description_%d"), nPos);
  914. SetProfileString(cs, Client.csDescription);
  915. Client.bShownFirstError = m_SendClients[nPos].bShownFirstError;
  916. m_SendClients[nPos] = Client;
  917. }
  918. CSendClients CGetSetOptions::GetSendClients(int nPos)
  919. {
  920. CSendClients Client;
  921. CString cs;
  922. cs.Format(_T("sendclient_ip_%d"), nPos);
  923. Client.csIP = GetProfileString(cs, "");
  924. cs.Format(_T("sendclient_autosend_%d"), nPos);
  925. Client.bSendAll = GetProfileLong(cs, FALSE);
  926. cs.Format(_T("sendclient_description_%d"), nPos);
  927. Client.csDescription = GetProfileString(cs, "");
  928. m_SendClients[nPos] = Client;
  929. return Client;
  930. }
  931. void CGetSetOptions::GetClientSendCount()
  932. {
  933. m_lAutoSendClientCount = 0;
  934. for(int i = 0; i < MAX_SEND_CLIENTS; i++)
  935. {
  936. if(m_SendClients[i].csIP.GetLength() > 0)
  937. {
  938. if(m_SendClients[i].bSendAll)
  939. m_lAutoSendClientCount++;
  940. }
  941. }
  942. }
  943. CString CGetSetOptions::GetListToPutOnClipboard()
  944. {
  945. CString cs = GetProfileString("ListToPutOnClipboard", "");
  946. cs.MakeUpper();
  947. return cs;
  948. }
  949. BOOL CGetSetOptions::SetListToPutOnClipboard(CString cs)
  950. {
  951. cs.MakeUpper();
  952. m_csIPListToPutOnClipboard = cs;
  953. return SetProfileString("ListToPutOnClipboard", cs);
  954. }
  955. void CGetSetOptions::SetLogSendReceiveErrors(BOOL bOption)
  956. {
  957. m_bLogSendReceiveErrors = bOption;
  958. SetProfileLong("LogSendReceiveErrors", bOption);
  959. }
  960. BOOL CGetSetOptions::GetLogSendReceiveErrors()
  961. {
  962. return GetProfileLong("LogSendReceiveErrors", FALSE);
  963. }
  964. BOOL CGetSetOptions::GetHideDittoOnHotKeyIfAlreadyShown()
  965. {
  966. return GetProfileLong("HideDittoOnHotKeyIfAlreadyShown", TRUE);
  967. }
  968. void CGetSetOptions::SetHideDittoOnHotKeyIfAlreadyShown(BOOL bVal)
  969. {
  970. m_HideDittoOnHotKeyIfAlreadyShown = bVal;
  971. SetProfileLong("HideDittoOnHotKeyIfAlreadyShown", bVal);
  972. }
  973. void CGetSetOptions::SetPort(long lPort)
  974. {
  975. m_lPort = lPort;
  976. SetProfileLong("SendRecvPort", lPort);
  977. }
  978. long CGetSetOptions::GetPort()
  979. {
  980. return GetProfileLong("SendRecvPort", 23443);
  981. }
  982. BOOL CGetSetOptions::GetDisableRecieve()
  983. {
  984. BOOL bDefault = FALSE;
  985. if(m_bU3)
  986. bDefault = TRUE;
  987. return GetProfileLong("DisableRecieve", bDefault);
  988. }
  989. void CGetSetOptions::SetDisableRecieve(BOOL bVal)
  990. {
  991. SetProfileLong("DisableRecieve", bVal);
  992. }
  993. BOOL CGetSetOptions::GetFont(LOGFONT &font)
  994. {
  995. if(m_bFromIni && !m_bInConversion)
  996. {
  997. GetProfileFont("DisplayFont", font);
  998. //Return true if there is a font name
  999. //other wise load the default font below
  1000. if(font.lfFaceName[0] != 0)
  1001. {
  1002. return TRUE;
  1003. }
  1004. }
  1005. else
  1006. {
  1007. DWORD dwLength = 0;
  1008. #ifdef _UNICODE
  1009. LPVOID lpVoid = GetProfileData("DisplayFont3", dwLength);
  1010. #else
  1011. LPVOID lpVoid = GetProfileData("DisplayFont", dwLength);
  1012. #endif
  1013. if(lpVoid)
  1014. {
  1015. if(sizeof(font) == dwLength)
  1016. {
  1017. memcpy(&font, lpVoid, dwLength);
  1018. delete[] lpVoid;
  1019. lpVoid = NULL;
  1020. return TRUE;
  1021. }
  1022. else
  1023. {
  1024. ASSERT(!"invalid font struct size");
  1025. }
  1026. delete[] lpVoid;
  1027. lpVoid = NULL;
  1028. }
  1029. }
  1030. ZeroMemory(&font, sizeof(font));
  1031. font.lfHeight = -11;
  1032. font.lfWeight = 400;
  1033. font.lfCharSet = 1;
  1034. STRCPY(font.lfFaceName, _T("@Arial Unicode MS"));
  1035. return TRUE;
  1036. }
  1037. void CGetSetOptions::SetFont(LOGFONT &font)
  1038. {
  1039. if(m_bFromIni)
  1040. {
  1041. SetProfileFont("DisplayFont", font);
  1042. }
  1043. else
  1044. {
  1045. #ifdef _UNICODE
  1046. CString csParam = "DisplayFont3";
  1047. #else
  1048. CString csParam = "DisplayFont";
  1049. #endif
  1050. SetProfileData(csParam, &font, sizeof(LOGFONT));
  1051. }
  1052. }
  1053. void CGetSetOptions::SetDrawThumbnail(long bDraw)
  1054. {
  1055. SetProfileLong("DrawThumbnail", bDraw);
  1056. m_bDrawThumbnail = bDraw;
  1057. }
  1058. BOOL CGetSetOptions::GetDrawThumbnail()
  1059. {
  1060. BOOL bDrawThumbnails = TRUE;
  1061. if(g_Opt.m_bU3)
  1062. bDrawThumbnails = FALSE;
  1063. return GetProfileLong("DrawThumbnail", bDrawThumbnails);
  1064. }
  1065. void CGetSetOptions::SetExtraNetworkPassword(CString csPassword)
  1066. {
  1067. SetProfileString("NetworkExtraPassword", csPassword);
  1068. }
  1069. CString CGetSetOptions::GetExtraNetworkPassword(bool bFillArray)
  1070. {
  1071. CString cs = GetProfileString("NetworkExtraPassword", "");
  1072. if(bFillArray)
  1073. {
  1074. m_csNetworkPasswordArray.RemoveAll();
  1075. TCHAR seps[] = _T(",");
  1076. TCHAR *token;
  1077. TCHAR *pString = cs.GetBuffer(cs.GetLength());
  1078. /* Establish string and get the first token: */
  1079. token = STRTOK(pString, seps);
  1080. while(token != NULL)
  1081. {
  1082. CString cs(token);
  1083. cs.TrimLeft();
  1084. cs.TrimRight();
  1085. m_csNetworkPasswordArray.Add(cs);
  1086. // Get next token
  1087. token = STRTOK(NULL, seps);
  1088. }
  1089. cs.ReleaseBuffer();
  1090. }
  1091. return cs;
  1092. }
  1093. void CGetSetOptions::SetNetworkPassword(CString csPassword)
  1094. {
  1095. CTextConvert Con;
  1096. Con.ConvertToUTF8(csPassword, m_csPassword);
  1097. SetProfileString("NetworkStringPassword", csPassword);
  1098. }
  1099. CStringA CGetSetOptions::GetNetworkPassword()
  1100. {
  1101. CString cs = GetProfileString("NetworkStringPassword", "LetMeIn");
  1102. CTextConvert Con;
  1103. CStringA csReturn;
  1104. Con.ConvertToUTF8(cs, csReturn);
  1105. return csReturn;
  1106. }
  1107. void CGetSetOptions::SetDrawRTF(long bDraw)
  1108. {
  1109. SetProfileLong("DrawRTF", bDraw);
  1110. m_bDrawRTF = bDraw;
  1111. }
  1112. BOOL CGetSetOptions::GetDrawRTF()
  1113. {
  1114. return GetProfileLong("DrawRTF", FALSE);
  1115. }
  1116. void CGetSetOptions::SetMultiPasteReverse(BOOL bVal)
  1117. {
  1118. SetProfileLong("MultiPasteReverse", bVal);
  1119. m_bMultiPasteReverse = bVal;
  1120. }
  1121. BOOL CGetSetOptions::GetMultiPasteReverse()
  1122. {
  1123. return GetProfileLong("MultiPasteReverse", TRUE);
  1124. }
  1125. void CGetSetOptions::SetPlaySoundOnCopy(CString cs)
  1126. {
  1127. m_csPlaySoundOnCopy = cs;
  1128. SetProfileString("PlaySoundOnCopy", cs);
  1129. }
  1130. CString CGetSetOptions::GetPlaySoundOnCopy()
  1131. {
  1132. return GetProfileString("PlaySoundOnCopy", "");
  1133. }
  1134. void CGetSetOptions::SetSendPasteAfterSelection(BOOL bVal)
  1135. {
  1136. m_bSendPasteMessageAfterSelection = bVal;
  1137. SetProfileLong("SendPasteMessageAfterSelection", bVal);
  1138. }
  1139. BOOL CGetSetOptions::GetSendPasteAfterSelection()
  1140. {
  1141. return GetProfileLong("SendPasteMessageAfterSelection", TRUE);
  1142. }
  1143. void CGetSetOptions::SetFindAsYouType(BOOL bVal)
  1144. {
  1145. m_bFindAsYouType = bVal;
  1146. SetProfileLong("FindAsYouType", bVal);
  1147. }
  1148. BOOL CGetSetOptions::GetFindAsYouType()
  1149. {
  1150. return GetProfileLong("FindAsYouType", TRUE);
  1151. }
  1152. void CGetSetOptions::SetEnsureEntireWindowCanBeSeen(BOOL bVal)
  1153. {
  1154. m_bEnsureEntireWindowCanBeSeen = bVal;
  1155. SetProfileLong("EnsureEntireWindowCanBeSeen", bVal);
  1156. }
  1157. BOOL CGetSetOptions::GetEnsureEntireWindowCanBeSeen()
  1158. {
  1159. return GetProfileLong("EnsureEntireWindowCanBeSeen", TRUE);
  1160. }
  1161. void CGetSetOptions::SetShowAllClipsInMainList(BOOL bVal)
  1162. {
  1163. m_bShowAllClipsInMainList = bVal;
  1164. SetProfileLong("ShowAllClipsInMainList", bVal);
  1165. }
  1166. BOOL CGetSetOptions::GetShowAllClipsInMainList()
  1167. {
  1168. return GetProfileLong("ShowAllClipsInMainList", TRUE);
  1169. }
  1170. long CGetSetOptions::GetMaxClipSizeInBytes()
  1171. {
  1172. return GetProfileLong("MaxClipSizeInBytes", 0);
  1173. }
  1174. void CGetSetOptions::SetMaxClipSizeInBytes(long lSize)
  1175. {
  1176. m_lMaxClipSizeInBytes = lSize;
  1177. SetProfileLong("MaxClipSizeInBytes", lSize);
  1178. }
  1179. CString CGetSetOptions::GetLanguageFile()
  1180. {
  1181. return GetProfileString("LanguageFile", "");
  1182. }
  1183. void CGetSetOptions::SetLanguageFile(CString csLanguage)
  1184. {
  1185. SetProfileString("LanguageFile", csLanguage);
  1186. }
  1187. ULONG CGetSetOptions::GetSaveClipDelay()
  1188. {
  1189. return (ULONG)GetProfileLong("SaveClipDelay", 500);
  1190. }
  1191. void CGetSetOptions::SetSaveClipDelay(DWORD dwDelay)
  1192. {
  1193. m_dwSaveClipDelay = dwDelay;
  1194. SetProfileLong("SaveClipDelay", dwDelay);
  1195. }
  1196. long CGetSetOptions::GetProcessDrawClipboardDelay()
  1197. {
  1198. return GetProfileLong("ProcessDrawClipboardDelay", 100);
  1199. }
  1200. void CGetSetOptions::SetProcessDrawClipboardDelay(long lDelay)
  1201. {
  1202. m_lProcessDrawClipboardDelay = lDelay;
  1203. SetProfileLong("ProcessDrawClipboardDelay", lDelay);
  1204. }
  1205. BOOL CGetSetOptions::GetEnableDebugLogging()
  1206. {
  1207. return GetProfileLong("EnableDebugLogging", FALSE);
  1208. }
  1209. void CGetSetOptions::SetEnableDebugLogging(BOOL bEnable)
  1210. {
  1211. m_bEnableDebugLogging = bEnable;
  1212. SetProfileLong("EnableDebugLogging", bEnable);
  1213. }
  1214. BOOL CGetSetOptions::GetEnsureConnectToClipboard()
  1215. {
  1216. return GetProfileLong("EnsureConnected", TRUE);
  1217. }
  1218. void CGetSetOptions::SetEnsureConnectToClipboard(BOOL bSet)
  1219. {
  1220. m_bEnsureConnectToClipboard = bSet;
  1221. SetProfileLong("EnsureConnected", bSet);
  1222. }
  1223. BOOL CGetSetOptions::GetPromptWhenDeletingClips()
  1224. {
  1225. return GetProfileLong("PromptWhenDeletingClips", TRUE);
  1226. }
  1227. void CGetSetOptions::SetPromptWhenDeletingClips(BOOL bSet)
  1228. {
  1229. SetProfileLong("PromptWhenDeletingClips", bSet);
  1230. }
  1231. CString CGetSetOptions::GetLastImportDir()
  1232. {
  1233. return GetProfileString("LastImportDir", "");
  1234. }
  1235. void CGetSetOptions::SetLastImportDir(CString csDir)
  1236. {
  1237. SetProfileString("LastImportDir", csDir);
  1238. }
  1239. CString CGetSetOptions::GetLastExportDir()
  1240. {
  1241. return GetProfileString("LastExportDir", "");
  1242. }
  1243. void CGetSetOptions::SetLastExportDir(CString csDir)
  1244. {
  1245. SetProfileString("LastExportDir", csDir);
  1246. }
  1247. BOOL CGetSetOptions::GetUpdateDescWhenSavingClip()
  1248. {
  1249. return GetProfileLong("UpdateDescWhenSaving", TRUE);
  1250. }
  1251. void CGetSetOptions::SetUpdateDescWhenSavingClip(BOOL bSet)
  1252. {
  1253. SetProfileLong("UpdateDescWhenSaving", bSet);
  1254. }
  1255. CString CGetSetOptions::GetPath(long lPathID)
  1256. {
  1257. CString csDir = CGetSetOptions::GetExeFileName();
  1258. csDir = GetFilePath(csDir);
  1259. FIX_CSTRING_PATH(csDir);
  1260. //U3_APP_DATA_PATH - <U3_DEVICE_PATH>\System\Apps\{app_unique_id}\Data
  1261. //U3_HOST_EXEC_PATH - %APPDATA%\U3\{device_serial_number}\{app_unique_id}\Exec
  1262. //U3_DEVICE_EXEC_PATH - <U3_DEVICE_PATH>\System\Apps\{app_unique_id}\Exec
  1263. switch(lPathID)
  1264. {
  1265. case PATH_HELP:
  1266. if(m_bU3)
  1267. {
  1268. csDir = GETENV(_T("U3_DEVICE_EXEC_PATH"));
  1269. FIX_CSTRING_PATH(csDir);
  1270. }
  1271. csDir += "Help\\";
  1272. break;
  1273. case PATH_LANGUAGE:
  1274. if(m_bU3)
  1275. {
  1276. csDir = GETENV(_T("U3_DEVICE_EXEC_PATH"));
  1277. FIX_CSTRING_PATH(csDir);
  1278. }
  1279. csDir += "language\\";
  1280. break;
  1281. case PATH_REMOTE_FILES:
  1282. if(m_bU3)
  1283. {
  1284. csDir = GETENV(_T("U3_HOST_EXEC_PATH"));
  1285. FIX_CSTRING_PATH(csDir);
  1286. }
  1287. csDir += "ReceivedFiles\\";
  1288. break;
  1289. case PATH_LOG_FILE:
  1290. if(m_bU3)
  1291. {
  1292. csDir = GETENV(_T("U3_HOST_EXEC_PATH"));
  1293. FIX_CSTRING_PATH(csDir);
  1294. }
  1295. break;
  1296. case PATH_UPDATE_FILE:
  1297. //same path as the executable
  1298. break;
  1299. case PATH_DATABASE:
  1300. if(m_bU3)
  1301. {
  1302. csDir = GETENV(_T("U3_APP_DATA_PATH"));
  1303. FIX_CSTRING_PATH(csDir);
  1304. }
  1305. break;
  1306. case PATH_INI:
  1307. if(m_bU3)
  1308. {
  1309. csDir = GETENV(_T("U3_APP_DATA_PATH"));
  1310. FIX_CSTRING_PATH(csDir);
  1311. }
  1312. break;
  1313. case PATH_U3_HWND_INI:
  1314. if(m_bU3)
  1315. {
  1316. csDir = GETENV(_T("U3_HOST_EXEC_PATH"));
  1317. FIX_CSTRING_PATH(csDir);
  1318. }
  1319. break;
  1320. }
  1321. return csDir;
  1322. }
  1323. bool CGetSetOptions::IsU3DeviceAvailable()
  1324. {
  1325. CString csAvailable = GETENV(_T("U3_IS_DEVICE_AVAILABLE"));
  1326. if(csAvailable == "true")
  1327. return true;
  1328. return false;
  1329. }
  1330. void CGetSetOptions::WriteU3Hwnd(HWND hWnd)
  1331. {
  1332. CString csIniFile = GetPath(PATH_U3_HWND_INI);
  1333. csIniFile += _T("DittohWnd.ini");
  1334. WritePrivateProfileInt(_T("Ditto"), _T("MainhWnd"), (int)hWnd, csIniFile);
  1335. }