Options.cpp 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654
  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. void CGetSetOptions::WriteU3Hwnd(HWND hWnd)
  1324. {
  1325. CString csIniFile = GetPath(PATH_U3_HWND_INI);
  1326. csIniFile += _T("DittohWnd.ini");
  1327. WritePrivateProfileInt(_T("Ditto"), _T("MainhWnd"), (int)hWnd, csIniFile);
  1328. }
  1329. long CGetSetOptions::GetDittoRestoreClipboardDelay()
  1330. {
  1331. return GetProfileLong("RestoreClipboardDelay", 750);
  1332. }
  1333. void CGetSetOptions::SetDittoRestoreClipboardDelay(long lDelay)
  1334. {
  1335. SetProfileLong("RestoreClipboardDelay", lDelay);
  1336. }
  1337. void CGetSetOptions::GetCopyBufferItem(int nPos, CCopyBufferItem &Item)
  1338. {
  1339. Item.m_lCopyHotKey = GetProfileLong(StrF(_T("CopyBufferCopyHotKey_%d"), nPos), 0);
  1340. Item.m_lPasteHotKey = GetProfileLong(StrF(_T("CopyBufferPasteHotKey_%d"), nPos), 0);
  1341. Item.m_lCutHotKey = GetProfileLong(StrF(_T("CopyBufferCutHotKey_%d"), nPos), 0);
  1342. Item.m_bPlaySoundOnCopy = GetProfileLong(StrF(_T("CopyBufferPlaySound_%d"), nPos), 0);
  1343. }
  1344. void CGetSetOptions::SetCopyBufferItem(int nPos, CCopyBufferItem &Item)
  1345. {
  1346. SetProfileLong(StrF(_T("CopyBufferCopyHotKey_%d"), nPos), Item.m_lCopyHotKey);
  1347. SetProfileLong(StrF(_T("CopyBufferPasteHotKey_%d"), nPos), Item.m_lPasteHotKey);
  1348. SetProfileLong(StrF(_T("CopyBufferCutHotKey_%d"), nPos), Item.m_lCutHotKey);
  1349. SetProfileLong(StrF(_T("CopyBufferPlaySound_%d"), nPos), Item.m_bPlaySoundOnCopy);
  1350. }