Options.cpp 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359
  1. #include "stdafx.h"
  2. #include "Options.h"
  3. #include "AlphaBlend.h"
  4. #include "Misc.h"
  5. #include "shared/TextConvert.h"
  6. #include "sqlite\CppSQLite3.h"
  7. #include "Path.h"
  8. #include "CP_Main.h"
  9. #include "ActionEnums.h"
  10. using namespace nsPath;
  11. UINT WritePrivateProfileInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, INT nValue, LPCTSTR lpFileName)
  12. {
  13. // Locals
  14. TCHAR szBuff[25];
  15. // Format
  16. SPRINTF(szBuff, _T("%d"), nValue);
  17. // Write
  18. return WritePrivateProfileString(lpAppName, lpKeyName, szBuff, lpFileName);
  19. }
  20. long CGetSetOptions::m_nLinesPerRow;
  21. BOOL CGetSetOptions::m_bUseCtrlNumAccel;
  22. BOOL CGetSetOptions::m_bAllowDuplicates;
  23. BOOL CGetSetOptions::m_bUpdateTimeOnPaste;
  24. BOOL CGetSetOptions::m_bSaveMultiPaste;
  25. BOOL CGetSetOptions::m_bShowPersistent;
  26. long CGetSetOptions::m_bDescTextSize;
  27. BOOL CGetSetOptions::m_bDescShowLeadingWhiteSpace;
  28. BOOL CGetSetOptions::m_bAllwaysShowDescription;
  29. long CGetSetOptions::m_bDoubleClickingOnCaptionDoes;
  30. BOOL CGetSetOptions::m_bPrompForNewGroupName;
  31. BOOL CGetSetOptions::m_bSendPasteOnFirstTenHotKeys;
  32. CSendClients CGetSetOptions::m_SendClients[MAX_SEND_CLIENTS];
  33. long CGetSetOptions::m_lAutoSendClientCount;
  34. CString CGetSetOptions::m_csIPListToPutOnClipboard;
  35. BOOL CGetSetOptions::m_bLogSendReceiveErrors;
  36. BOOL CGetSetOptions::m_HideDittoOnHotKeyIfAlreadyShown;
  37. long CGetSetOptions::m_lPort;
  38. BOOL CGetSetOptions::m_bDrawThumbnail;
  39. CStringA CGetSetOptions::m_csPassword;
  40. BOOL CGetSetOptions::m_bDrawRTF;
  41. BOOL CGetSetOptions::m_bMultiPasteReverse;
  42. CString CGetSetOptions::m_csPlaySoundOnCopy;
  43. CStringArray CGetSetOptions::m_csNetworkPasswordArray;
  44. BOOL CGetSetOptions::m_bSendPasteMessageAfterSelection;
  45. BOOL CGetSetOptions::m_bFindAsYouType;
  46. BOOL CGetSetOptions::m_bEnsureEntireWindowCanBeSeen;
  47. BOOL CGetSetOptions::m_bShowAllClipsInMainList;
  48. long CGetSetOptions::m_lMaxClipSizeInBytes;
  49. DWORD CGetSetOptions::m_dwSaveClipDelay;
  50. long CGetSetOptions::m_lProcessDrawClipboardDelay;
  51. BOOL CGetSetOptions::m_bEnableDebugLogging;
  52. BOOL CGetSetOptions::m_bEnsureConnectToClipboard;
  53. bool CGetSetOptions::m_bOutputDebugString;
  54. bool CGetSetOptions::m_bU3 = false;
  55. bool CGetSetOptions::m_bInConversion = false;
  56. bool CGetSetOptions::m_bFromIni = false;
  57. bool CGetSetOptions::m_portable = false;
  58. CString CGetSetOptions::m_csIniFileName;
  59. __int64 CGetSetOptions::nLastDbWriteTime = 0;
  60. CTheme CGetSetOptions::m_Theme;
  61. BOOL CGetSetOptions::m_showScrollBar = false;
  62. CGetSetOptions g_Opt;
  63. BOOL CGetSetOptions::m_bShowAlwaysOnTopWarning = TRUE;
  64. CGetSetOptions::CGetSetOptions()
  65. {
  66. }
  67. CGetSetOptions::~CGetSetOptions()
  68. {
  69. }
  70. void CGetSetOptions::LoadSettings()
  71. {
  72. m_csIniFileName = GetIniFileName(true);
  73. CString portable = GetFilePath(m_csIniFileName);
  74. portable += _T("portable");
  75. if(FileExists(portable))
  76. {
  77. m_portable = true;
  78. }
  79. if(m_bU3)
  80. {
  81. m_bFromIni = true;
  82. }
  83. else
  84. {
  85. //first check if ini file is in app directory
  86. if(m_portable || FileExists(m_csIniFileName))
  87. {
  88. m_bFromIni = true;
  89. }
  90. else
  91. {
  92. //next check if it's in app data
  93. m_csIniFileName = GetIniFileName(false);
  94. if(FileExists(m_csIniFileName))
  95. {
  96. m_bFromIni = true;
  97. }
  98. }
  99. }
  100. if(m_bFromIni)
  101. {
  102. CString csPath = GetFilePath(m_csIniFileName);
  103. if(FileExists(csPath) == FALSE)
  104. CreateDirectory(csPath, NULL);
  105. }
  106. /*CString cs = GetDBPath();
  107. SetDBPath(_T("some path"));
  108. CString cs2 = GetDBPath();*/
  109. GetSetCurrentDirectory();
  110. //First time we run, set some defaults
  111. if (GetDBPath() == _T("") &&
  112. GetTotalCopyCount() == 0)
  113. {
  114. SetCheckForMaxEntries(TRUE);
  115. SetSimpleTextSearch(TRUE);
  116. }
  117. m_nLinesPerRow = GetLinesPerRow();
  118. m_bUseCtrlNumAccel = GetUseCtrlNumForFirstTenHotKeys();
  119. m_bAllowDuplicates = GetAllowDuplicates();
  120. m_bUpdateTimeOnPaste = GetUpdateTimeOnPaste();
  121. m_bSaveMultiPaste = GetSaveMultiPaste();
  122. m_bShowPersistent = GetShowPersistent();
  123. m_bDescTextSize = GetDescTextSize();
  124. m_bDescShowLeadingWhiteSpace = GetDescShowLeadingWhiteSpace();
  125. m_bAllwaysShowDescription = GetAllwaysShowDescription();
  126. m_bDoubleClickingOnCaptionDoes = GetDoubleClickingOnCaptionDoes();
  127. m_bPrompForNewGroupName = GetPrompForNewGroupName();
  128. m_bSendPasteOnFirstTenHotKeys = GetSendPasteOnFirstTenHotKeys();
  129. m_csIPListToPutOnClipboard = GetListToPutOnClipboard();
  130. m_bLogSendReceiveErrors = GetLogSendReceiveErrors();
  131. m_HideDittoOnHotKeyIfAlreadyShown = GetHideDittoOnHotKeyIfAlreadyShown();
  132. m_lPort = GetPort();
  133. m_bDrawThumbnail = GetDrawThumbnail();
  134. m_csPassword = GetNetworkPassword();
  135. m_bDrawRTF = GetDrawRTF();
  136. m_bMultiPasteReverse = GetMultiPasteReverse();
  137. m_csPlaySoundOnCopy = GetPlaySoundOnCopy();
  138. m_bSendPasteMessageAfterSelection = GetSendPasteAfterSelection();
  139. m_bFindAsYouType = GetFindAsYouType();
  140. m_bEnsureEntireWindowCanBeSeen = GetEnsureEntireWindowCanBeSeen();
  141. m_bShowAllClipsInMainList = GetShowAllClipsInMainList();
  142. m_lMaxClipSizeInBytes = GetMaxClipSizeInBytes();
  143. m_dwSaveClipDelay = GetSaveClipDelay();
  144. m_lProcessDrawClipboardDelay = GetProcessDrawClipboardDelay();
  145. m_bEnableDebugLogging = GetEnableDebugLogging();
  146. m_bEnsureConnectToClipboard = GetEnsureConnectToClipboard();
  147. m_bOutputDebugString = false;
  148. m_showScrollBar = GetShowScrollBar();
  149. m_bShowAlwaysOnTopWarning = GetShowAlwaysOnTopWarning();
  150. GetExtraNetworkPassword(true);
  151. for(int i = 0; i < MAX_SEND_CLIENTS; i++)
  152. {
  153. GetSendClients(i);
  154. }
  155. GetClientSendCount();
  156. //If running from a U3 device and no language file as been asigned
  157. //then use the language defined by the U3 launcher
  158. if(m_bU3)
  159. {
  160. CString csLanguage = GetLanguageFile();
  161. if(csLanguage.IsEmpty())
  162. {
  163. CString csLanguage = GETENV(_T("U3_ENV_LANGUAGE"));
  164. long lLanguage = ATOI(csLanguage);
  165. csLanguage.Empty();
  166. switch(lLanguage)
  167. {
  168. case 1036: //French
  169. csLanguage = _T("Français");
  170. break;
  171. case 1040: //Italian
  172. csLanguage = _T("Italiano");
  173. break;
  174. case 1031: //German
  175. csLanguage = _T("German");
  176. break;
  177. case 3082: //German
  178. csLanguage = _T("Español");
  179. break;
  180. }
  181. if(csLanguage.IsEmpty() == FALSE)
  182. {
  183. SetLanguageFile(csLanguage);
  184. }
  185. }
  186. }
  187. m_Theme.Load(GetTheme());
  188. }
  189. void CGetSetOptions::ConverSettingsToIni()
  190. {
  191. m_bInConversion = true;
  192. CSize sz;
  193. CPoint pt;
  194. GetQuickPasteSize(sz);
  195. SetQuickPasteSize(sz);
  196. GetQuickPastePoint(pt);
  197. SetQuickPastePoint(pt);
  198. GetEditWndSize(sz);
  199. SetEditWndSize(sz);
  200. GetEditWndPoint(pt);
  201. SetEditWndPoint(pt);
  202. SetShowIconInSysTray(GetShowIconInSysTray());
  203. SetRunOnStartUp(GetRunOnStartUp());
  204. SetEnableTransparency(GetEnableTransparency());
  205. SetTransparencyPercent(GetTransparencyPercent());
  206. SetLinesPerRow(GetLinesPerRow());
  207. SetQuickPastePosition(GetQuickPastePosition());
  208. SetCopyGap(GetCopyGap());
  209. SetDBPath(GetDBPath());
  210. SetCheckForMaxEntries(GetCheckForMaxEntries());
  211. SetCheckForExpiredEntries(GetCheckForExpiredEntries());
  212. SetMaxEntries(GetMaxEntries());
  213. SetExpiredEntries(GetExpiredEntries());
  214. SetTripCopyCount(GetTripCopyCount());
  215. SetTripPasteCount(GetTripPasteCount());
  216. SetTripDate(GetTripDate());
  217. SetTotalCopyCount(GetTotalCopyCount());
  218. SetTotalPasteCount(GetTotalPasteCount());
  219. SetTotalDate(GetTotalDate());
  220. SetUpdateFilePath(GetUpdateFilePath());
  221. SetUpdateInstallPath(GetUpdateInstallPath());
  222. SetLastUpdate(GetLastUpdate());
  223. SetCheckForUpdates(GetCheckForUpdates());
  224. SetUseCtrlNumForFirstTenHotKeys(GetUseCtrlNumForFirstTenHotKeys());
  225. SetAllowDuplicates(GetAllowDuplicates());
  226. SetUpdateTimeOnPaste(GetUpdateTimeOnPaste());
  227. SetSaveMultiPaste(GetSaveMultiPaste());
  228. SetShowPersistent(GetShowPersistent());
  229. SetShowTextForFirstTenHotKeys(GetShowTextForFirstTenHotKeys());
  230. SetMainHWND(GetMainHWND());
  231. SetCaptionPos(GetCaptionPos());
  232. SetAutoHide(GetAutoHide());
  233. SetDescTextSize(GetDescTextSize());
  234. SetDescShowLeadingWhiteSpace(GetDescShowLeadingWhiteSpace());
  235. SetAllwaysShowDescription(GetAllwaysShowDescription());
  236. SetDoubleClickingOnCaptionDoes(GetDoubleClickingOnCaptionDoes());
  237. SetPrompForNewGroupName(GetPrompForNewGroupName());
  238. SetSendPasteOnFirstTenHotKeys(GetSendPasteOnFirstTenHotKeys());
  239. for(int i = 0; i < MAX_SEND_CLIENTS; i++)
  240. {
  241. GetSendClients(i);
  242. SetSendClients(m_SendClients[i], i);
  243. }
  244. SetListToPutOnClipboard(GetListToPutOnClipboard());
  245. SetLogSendReceiveErrors(GetLogSendReceiveErrors());
  246. SetHideDittoOnHotKeyIfAlreadyShown(GetHideDittoOnHotKeyIfAlreadyShown());
  247. SetPort(GetPort());
  248. SetDisableRecieve(GetDisableRecieve());
  249. LOGFONT font;
  250. GetFont(font);
  251. SetFont(font);
  252. SetDrawThumbnail(GetDrawThumbnail());
  253. CStringA PassA = GetNetworkPassword();
  254. CString PassW = PassA;
  255. SetNetworkPassword(PassW);
  256. SetDrawRTF(GetDrawRTF());
  257. SetMultiPasteReverse(GetMultiPasteReverse());
  258. SetPlaySoundOnCopy(GetPlaySoundOnCopy());
  259. SetSendPasteAfterSelection(GetSendPasteAfterSelection());
  260. SetFindAsYouType(GetFindAsYouType());
  261. SetEnsureEntireWindowCanBeSeen(GetEnsureEntireWindowCanBeSeen());
  262. SetShowAllClipsInMainList(GetShowAllClipsInMainList());
  263. SetExtraNetworkPassword(GetExtraNetworkPassword(false));
  264. SetMaxClipSizeInBytes(GetMaxClipSizeInBytes());
  265. SetLanguageFile(GetLanguageFile());
  266. SetSaveClipDelay(GetSaveClipDelay());
  267. SetProcessDrawClipboardDelay(GetProcessDrawClipboardDelay());
  268. SetEnableDebugLogging(GetEnableDebugLogging());
  269. SetEnsureConnectToClipboard(GetEnsureConnectToClipboard());
  270. SetPromptWhenDeletingClips(GetPromptWhenDeletingClips());
  271. SetLastImportDir(GetLastImportDir());
  272. SetLastExportDir(GetLastExportDir());
  273. SetUpdateDescWhenSavingClip(GetUpdateDescWhenSavingClip());
  274. m_bInConversion = false;
  275. }
  276. CString CGetSetOptions::GetIniFileName(bool bLocalIniFile)
  277. {
  278. CString csPath = _T("c:\\program files\\Ditto\\");
  279. if(m_bU3)
  280. {
  281. csPath = CGetSetOptions::GetPath(PATH_INI);
  282. }
  283. else
  284. {
  285. if(bLocalIniFile)
  286. {
  287. csPath = GetFilePath(GetExeFileName());
  288. }
  289. else
  290. {
  291. csPath = GetAppDataPath();
  292. }
  293. }
  294. csPath += "Ditto.Settings";
  295. return csPath;
  296. }
  297. CString CGetSetOptions::GetAppDataPath()
  298. {
  299. CString csPath;
  300. LPMALLOC pMalloc;
  301. if(SUCCEEDED(::SHGetMalloc(&pMalloc)))
  302. {
  303. LPITEMIDLIST pidlPrograms;
  304. SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidlPrograms);
  305. TCHAR string[MAX_PATH];
  306. SHGetPathFromIDList(pidlPrograms, string);
  307. pMalloc->Free(pidlPrograms);
  308. pMalloc->Release();
  309. csPath = string;
  310. }
  311. FIX_CSTRING_PATH(csPath);
  312. csPath += "Ditto\\";
  313. return csPath;
  314. }
  315. long CGetSetOptions::GetResolutionProfileLong(CString csName, long lDefaultValue, CString csNewPath)
  316. {
  317. CString resName;
  318. resName.Format(_T("(%dx%d)_%s"), GetScreenWidth(), GetScreenHeight(), csName);
  319. long value = GetProfileLong(resName, INT_MIN, csNewPath);
  320. if(value == INT_MIN)
  321. {
  322. value = GetProfileLong(csName, lDefaultValue, csNewPath);
  323. }
  324. return value;
  325. }
  326. BOOL CGetSetOptions::SetResolutionProfileLong(CString csName, long lValue)
  327. {
  328. CString resName;
  329. resName.Format(_T("(%dx%d)_%s"), GetScreenWidth(), GetScreenHeight(), csName);
  330. return SetProfileLong(resName, lValue);
  331. }
  332. long CGetSetOptions::GetProfileLong(CString csName, long lDefaultValue, CString csNewPath)
  333. {
  334. if(m_bFromIni && !m_bInConversion)
  335. {
  336. CString csApp(_T("Ditto"));
  337. if(csNewPath.IsEmpty() == FALSE)
  338. {
  339. csApp = csNewPath;
  340. }
  341. return GetPrivateProfileInt(csApp, csName, lDefaultValue, m_csIniFileName);
  342. }
  343. CString csPath(_T(REG_PATH));
  344. if(csNewPath.IsEmpty() == FALSE)
  345. {
  346. csPath += "\\" + csNewPath;
  347. }
  348. HKEY hkKey;
  349. long lResult = RegOpenKeyEx(HKEY_CURRENT_USER, csPath, NULL, KEY_READ, &hkKey);
  350. if(lResult != ERROR_SUCCESS)
  351. return lDefaultValue;
  352. DWORD buffer;
  353. DWORD len = sizeof(buffer);
  354. DWORD type;
  355. lResult = ::RegQueryValueEx(hkKey, csName, 0, &type, (LPBYTE)&buffer, &len);
  356. RegCloseKey(hkKey);
  357. if(lResult == ERROR_SUCCESS)
  358. return (long)buffer;
  359. return lDefaultValue;
  360. }
  361. CString CGetSetOptions::GetProfileString(CString csName, CString csDefault, CString csNewPath)
  362. {
  363. if(m_bFromIni && !m_bInConversion)
  364. {
  365. CString csApp(_T("Ditto"));
  366. if(csNewPath.IsEmpty() == FALSE)
  367. {
  368. csApp = csNewPath;
  369. }
  370. TCHAR cString[MAX_PATH];
  371. GetPrivateProfileString(csApp, csName, csDefault, cString, sizeof(cString), m_csIniFileName);
  372. return cString;
  373. }
  374. CString csPath(_T(REG_PATH));
  375. if(csNewPath.IsEmpty() == FALSE)
  376. {
  377. csPath += "\\" + csNewPath;
  378. }
  379. HKEY hkKey;
  380. long lResult = RegOpenKeyEx(HKEY_CURRENT_USER, csPath, NULL, KEY_READ, &hkKey);
  381. TCHAR szString[256];
  382. ZeroMemory(szString, sizeof(szString));
  383. DWORD dwBufLen = 256;
  384. lResult = ::RegQueryValueEx(hkKey , csName, NULL, NULL, (LPBYTE)szString, &dwBufLen);
  385. RegCloseKey(hkKey);
  386. if(lResult != ERROR_SUCCESS)
  387. return csDefault;
  388. return szString;
  389. }
  390. BOOL CGetSetOptions::SetProfileLong(CString csName, long lValue)
  391. {
  392. if(m_bFromIni)
  393. {
  394. return WritePrivateProfileInt(_T("Ditto"), csName, lValue, m_csIniFileName);
  395. }
  396. HKEY hkKey;
  397. DWORD dWord;
  398. long lResult = RegCreateKeyEx(HKEY_CURRENT_USER, _T(REG_PATH), NULL,
  399. NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
  400. NULL, &hkKey, &dWord);
  401. if(lResult != ERROR_SUCCESS)
  402. return FALSE;
  403. DWORD val = (DWORD)lValue;
  404. lResult = ::RegSetValueEx(hkKey, csName, 0, REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
  405. RegCloseKey(hkKey);
  406. return lResult == ERROR_SUCCESS;
  407. }
  408. BOOL CGetSetOptions::SetProfileString(CString csName, CString csValue)
  409. {
  410. if(m_bFromIni)
  411. {
  412. return WritePrivateProfileString(_T("Ditto"), csName, csValue, m_csIniFileName);
  413. }
  414. HKEY hkKey;
  415. DWORD dWord;
  416. long lResult = RegCreateKeyEx(HKEY_CURRENT_USER, _T(REG_PATH), NULL,
  417. NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
  418. NULL, &hkKey, &dWord);
  419. if(lResult != ERROR_SUCCESS)
  420. return FALSE;
  421. ::RegSetValueEx(hkKey, csName, NULL, REG_SZ,
  422. (BYTE*)(LPCTSTR)csValue, csValue.GetLength()*sizeof(TCHAR));
  423. RegCloseKey(hkKey);
  424. return lResult == ERROR_SUCCESS;
  425. }
  426. BOOL CGetSetOptions::SetProfileData(CString csName, LPVOID lpData, DWORD dwLength)
  427. {
  428. if(m_bFromIni)
  429. {
  430. ASSERT(!"SetProfileData not supported in .ini settings");
  431. return FALSE;
  432. }
  433. HKEY hkKey;
  434. DWORD dWord;
  435. long lResult = RegCreateKeyEx(HKEY_CURRENT_USER, _T(REG_PATH), NULL,
  436. NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
  437. NULL, &hkKey, &dWord);
  438. if(lResult != ERROR_SUCCESS)
  439. return FALSE;
  440. ::RegSetValueEx(hkKey, csName, NULL, REG_BINARY,
  441. (BYTE*)lpData, dwLength);
  442. RegCloseKey(hkKey);
  443. return lResult == ERROR_SUCCESS;
  444. }
  445. BOOL CGetSetOptions::GetProfileFont(CString csSection, LOGFONT &font)
  446. {
  447. font.lfHeight = GetPrivateProfileInt(csSection, _T("Height"), 0, m_csIniFileName);
  448. font.lfWidth = GetPrivateProfileInt(csSection, _T("Width"), 0, m_csIniFileName);
  449. font.lfEscapement = GetPrivateProfileInt(csSection, _T("Escapement"), 0, m_csIniFileName);
  450. font.lfOrientation = GetPrivateProfileInt(csSection, _T("Orientation"), 0, m_csIniFileName);
  451. font.lfWeight = GetPrivateProfileInt(csSection, _T("Weight"), 0, m_csIniFileName);
  452. font.lfItalic = GetPrivateProfileInt(csSection, _T("Italic"), 0, m_csIniFileName);
  453. font.lfUnderline = GetPrivateProfileInt(csSection, _T("Underline"), 0, m_csIniFileName);
  454. font.lfStrikeOut = GetPrivateProfileInt(csSection, _T("StrikeOut"), 0, m_csIniFileName);
  455. font.lfCharSet = GetPrivateProfileInt(csSection, _T("CharSet"), 0, m_csIniFileName);
  456. font.lfOutPrecision = GetPrivateProfileInt(csSection, _T("OutPrecision"), 0, m_csIniFileName);
  457. font.lfClipPrecision = GetPrivateProfileInt(csSection, _T("ClipPrecision"), 0, m_csIniFileName);
  458. font.lfQuality = GetPrivateProfileInt(csSection, _T("Quality"), 0, m_csIniFileName);
  459. font.lfPitchAndFamily = GetPrivateProfileInt(csSection, _T("PitchAndFamily"), 0, m_csIniFileName);
  460. GetPrivateProfileString(csSection, _T("FaceName"), _T(""), font.lfFaceName, sizeof(font.lfFaceName), m_csIniFileName);
  461. return TRUE;
  462. }
  463. BOOL CGetSetOptions::SetProfileFont(CString csSection, LOGFONT &font)
  464. {
  465. WritePrivateProfileInt(csSection, _T("Height"), font.lfHeight, m_csIniFileName);
  466. WritePrivateProfileInt(csSection, _T("Width"), font.lfWidth, m_csIniFileName);
  467. WritePrivateProfileInt(csSection, _T("Escapement"), font.lfEscapement, m_csIniFileName);
  468. WritePrivateProfileInt(csSection, _T("Orientation"), font.lfOrientation, m_csIniFileName);
  469. WritePrivateProfileInt(csSection, _T("Weight"), font.lfWeight, m_csIniFileName);
  470. WritePrivateProfileInt(csSection, _T("Italic"), font.lfItalic, m_csIniFileName);
  471. WritePrivateProfileInt(csSection, _T("Underline"), font.lfUnderline, m_csIniFileName);
  472. WritePrivateProfileInt(csSection, _T("StrikeOut"), font.lfStrikeOut, m_csIniFileName);
  473. WritePrivateProfileInt(csSection, _T("CharSet"), font.lfCharSet, m_csIniFileName);
  474. WritePrivateProfileInt(csSection, _T("OutPrecision"), font.lfOutPrecision, m_csIniFileName);
  475. WritePrivateProfileInt(csSection, _T("ClipPrecision"), font.lfClipPrecision, m_csIniFileName);
  476. WritePrivateProfileInt(csSection, _T("Quality"), font.lfQuality, m_csIniFileName);
  477. WritePrivateProfileInt(csSection, _T("PitchAndFamily"), font.lfPitchAndFamily, m_csIniFileName);
  478. WritePrivateProfileString(csSection, _T("FaceName"), font.lfFaceName, m_csIniFileName);
  479. return TRUE;
  480. }
  481. LPVOID CGetSetOptions::GetProfileData(CString csName, DWORD &dwLength)
  482. {
  483. if(m_bFromIni && !m_bInConversion)
  484. {
  485. ASSERT(!"GetProfileData not supported in .ini settings");
  486. return NULL;
  487. }
  488. HKEY hkKey;
  489. long lResult = RegOpenKeyEx(HKEY_CURRENT_USER, _T(REG_PATH),
  490. NULL, KEY_READ, &hkKey);
  491. lResult = ::RegQueryValueEx(hkKey , csName, NULL, NULL, NULL, &dwLength);
  492. if(lResult != ERROR_SUCCESS)
  493. return NULL;
  494. LPVOID lpVoid = new BYTE[dwLength];
  495. lResult = ::RegQueryValueEx(hkKey , csName, NULL, NULL, (LPBYTE)lpVoid, &dwLength);
  496. RegCloseKey(hkKey);
  497. if(lResult != ERROR_SUCCESS)
  498. return NULL;
  499. return lpVoid;
  500. }
  501. BOOL CGetSetOptions::GetShowIconInSysTray()
  502. {
  503. return GetProfileLong("ShowIconInSystemTray", TRUE);
  504. }
  505. BOOL CGetSetOptions::SetShowIconInSysTray(BOOL bShow)
  506. {
  507. return SetProfileLong("ShowIconInSystemTray", bShow);
  508. }
  509. BOOL CGetSetOptions::SetEnableTransparency(BOOL bCheck)
  510. {
  511. return SetProfileLong("EnableTransparency", bCheck);
  512. }
  513. BOOL CGetSetOptions::GetEnableTransparency()
  514. {
  515. return GetProfileLong("EnableTransparency", FALSE);
  516. }
  517. BOOL CGetSetOptions::SetTransparencyPercent(long lPercent)
  518. {
  519. #ifdef AFTER_98
  520. if(lPercent > OPACITY_MAX)
  521. lPercent = OPACITY_MAX;
  522. if(lPercent < 0)
  523. lPercent = 0;
  524. return SetProfileLong("TransparencyPercent", lPercent);
  525. #endif
  526. return FALSE;
  527. }
  528. long CGetSetOptions::GetTransparencyPercent()
  529. {
  530. #ifdef AFTER_98
  531. long lValue = GetProfileLong("TransparencyPercent", 14);
  532. if(lValue > OPACITY_MAX) lValue = OPACITY_MAX;
  533. if(lValue < 0) lValue = 0;
  534. return lValue;
  535. #endif
  536. return 0;
  537. }
  538. BOOL CGetSetOptions::SetLinesPerRow(long lLines)
  539. {
  540. m_nLinesPerRow = lLines;
  541. return SetProfileLong("LinesPerRow", lLines);
  542. }
  543. long CGetSetOptions::GetLinesPerRow()
  544. {
  545. return GetProfileLong("LinesPerRow", 2);
  546. }
  547. BOOL CGetSetOptions::GetRunOnStartUp()
  548. {
  549. HKEY hkRun;
  550. LONG nResult = RegOpenKeyEx(HKEY_CURRENT_USER,
  551. _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"),
  552. NULL, KEY_READ, &hkRun);
  553. if(nResult != ERROR_SUCCESS)
  554. return FALSE;
  555. nResult = RegQueryValueEx(hkRun, GetAppName(), NULL, NULL, NULL, NULL);
  556. RegCloseKey(hkRun);
  557. return nResult == ERROR_SUCCESS;
  558. }
  559. void CGetSetOptions::SetRunOnStartUp(BOOL bRun)
  560. {
  561. //Can't set auto run when running from U3 device
  562. if(m_bU3)
  563. return;
  564. if(bRun == GetRunOnStartUp())
  565. return;
  566. HKEY hkRun;
  567. LONG nResult = RegOpenKeyEx(HKEY_CURRENT_USER,
  568. _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"),
  569. NULL, KEY_ALL_ACCESS, &hkRun);
  570. if(nResult != ERROR_SUCCESS)
  571. return;
  572. if(bRun)
  573. {
  574. CString sExeName = GetExeFileName();
  575. ::RegSetValueEx(hkRun, GetAppName(), NULL, REG_SZ,
  576. (BYTE*)(LPCTSTR)sExeName, sExeName.GetLength()*sizeof(TCHAR));
  577. }
  578. else
  579. {
  580. ::RegDeleteValue(hkRun, GetAppName());
  581. }
  582. ::RegCloseKey(hkRun);
  583. }
  584. CString CGetSetOptions::GetExeFileName()
  585. {
  586. CString sExeName;
  587. GetModuleFileName(NULL, sExeName.GetBuffer(_MAX_PATH),_MAX_PATH);
  588. sExeName.ReleaseBuffer();
  589. return sExeName;
  590. }
  591. CString CGetSetOptions::GetAppName()
  592. {
  593. return "Ditto";
  594. }
  595. BOOL CGetSetOptions::SetQuickPastePosition(long lPosition)
  596. {
  597. return SetProfileLong("ShowQuickPastePosition", lPosition);
  598. }
  599. long CGetSetOptions::GetQuickPastePosition()
  600. {
  601. return GetProfileLong("ShowQuickPastePosition", POS_AT_CURSOR);
  602. }
  603. BOOL CGetSetOptions::SetQuickPasteSize(CSize size)
  604. {
  605. BOOL bRet = SetResolutionProfileLong("QuickPasteCX", size.cx);
  606. bRet = SetResolutionProfileLong("QuickPasteCY", size.cy);
  607. return bRet;
  608. }
  609. void CGetSetOptions::GetQuickPasteSize(CSize &size)
  610. {
  611. size.cx = GetResolutionProfileLong("QuickPasteCX", 300);
  612. size.cy = GetResolutionProfileLong("QuickPasteCY", 300);
  613. if(size.cx <= 0 && size.cy <= 0)
  614. {
  615. size.cx = 300;
  616. size.cy = 300;
  617. }
  618. }
  619. BOOL CGetSetOptions::SetQuickPastePoint(CPoint point)
  620. {
  621. BOOL bRet = SetResolutionProfileLong("QuickPasteX", point.x);
  622. bRet = SetResolutionProfileLong("QuickPasteY", point.y);
  623. return bRet;
  624. }
  625. void CGetSetOptions::GetQuickPastePoint(CPoint &point)
  626. {
  627. point.x = GetResolutionProfileLong("QuickPasteX", 300);
  628. point.y = GetResolutionProfileLong("QuickPasteY", 300);
  629. if(point.x <= 0 && point.y <= 0)
  630. {
  631. point.x = 300;
  632. point.y = 300;
  633. }
  634. }
  635. BOOL CGetSetOptions::SetEditWndSize(CSize size)
  636. {
  637. BOOL bRet = SetResolutionProfileLong("EditWndCX", size.cx);
  638. bRet = SetResolutionProfileLong("EditWndCY", size.cy);
  639. return bRet;
  640. }
  641. void CGetSetOptions::GetEditWndSize(CSize &size)
  642. {
  643. size.cx = GetResolutionProfileLong("EditWndCX", 600);
  644. size.cy = GetResolutionProfileLong("EditWndCY", 600);
  645. if(size.cx <= 0 && size.cy <= 0)
  646. {
  647. size.cx = 600;
  648. size.cy = 600;
  649. }
  650. }
  651. BOOL CGetSetOptions::SetEditWndPoint(CPoint point)
  652. {
  653. BOOL bRet = SetResolutionProfileLong("EditWndX", point.x);
  654. bRet = SetResolutionProfileLong("EditWndY", point.y);
  655. return bRet;
  656. }
  657. void CGetSetOptions::GetEditWndPoint(CPoint &point)
  658. {
  659. point.x = GetResolutionProfileLong("EditWndX", 100);
  660. point.y = GetResolutionProfileLong("EditWndY", 100);
  661. if(point.x <= 0 && point.y <= 0)
  662. {
  663. point.x = 100;
  664. point.y = 100;
  665. }
  666. }
  667. long CGetSetOptions::GetCopyGap()
  668. {
  669. return GetProfileLong("CopyGap", 150);
  670. }
  671. void CGetSetOptions::SetCopyGap(long lGap)
  672. {
  673. SetProfileLong("CopyGap", lGap);
  674. }
  675. BOOL CGetSetOptions::SetDBPathOld(CString csPath)
  676. {
  677. return SetProfileString("DBPath", csPath);
  678. }
  679. CString CGetSetOptions::GetDBPathOld()
  680. {
  681. return GetProfileString("DBPath", "");
  682. }
  683. BOOL CGetSetOptions::SetDBPath(CString csPath)
  684. {
  685. return SetProfileString("DBPath3", csPath);
  686. }
  687. CString CGetSetOptions::GetDBPath()
  688. {
  689. CString csDBPath;
  690. if(m_bU3)
  691. {
  692. csDBPath = GetProfileString("DBPath3", "");
  693. if(csDBPath.IsEmpty())
  694. {
  695. csDBPath = GetDefaultDBName();
  696. }
  697. CPath ExistingPath(csDBPath);
  698. csDBPath = CGetSetOptions::GetPath(PATH_DATABASE);
  699. csDBPath += ExistingPath.GetName();
  700. }
  701. else
  702. {
  703. csDBPath = GetProfileString("DBPath3", "");
  704. }
  705. return csDBPath;
  706. }
  707. void CGetSetOptions::SetCheckForMaxEntries(BOOL bVal)
  708. {
  709. SetProfileLong("CheckForMaxEntries", bVal);
  710. }
  711. BOOL CGetSetOptions::GetCheckForMaxEntries()
  712. {
  713. BOOL bDefault = FALSE;
  714. if(m_bU3)
  715. bDefault = TRUE;
  716. if(GetIsPortableDitto())
  717. bDefault = TRUE;
  718. return GetProfileLong("CheckForMaxEntries", bDefault);
  719. }
  720. void CGetSetOptions::SetCheckForExpiredEntries(BOOL bVal)
  721. {
  722. SetProfileLong("CheckForExpiredEntries", bVal);
  723. }
  724. BOOL CGetSetOptions::GetCheckForExpiredEntries()
  725. {
  726. return GetProfileLong("CheckForExpiredEntries", FALSE);
  727. }
  728. void CGetSetOptions::SetMaxEntries(long lVal)
  729. {
  730. SetProfileLong("MaxEntries", lVal);
  731. }
  732. long CGetSetOptions::GetMaxEntries()
  733. {
  734. long lMax = 500;
  735. if(m_bU3)
  736. lMax = 75;
  737. if(GetIsPortableDitto())
  738. lMax = 100;
  739. return GetProfileLong("MaxEntries", lMax);
  740. }
  741. void CGetSetOptions::SetExpiredEntries(long lVal)
  742. {
  743. SetProfileLong("ExpiredEntries", lVal);
  744. }
  745. long CGetSetOptions::GetExpiredEntries()
  746. {
  747. return GetProfileLong("ExpiredEntries", 5);
  748. }
  749. void CGetSetOptions::SetTripCopyCount(long lVal)
  750. {
  751. // negative means a relative offset
  752. if(lVal < 0)
  753. lVal = GetTripCopyCount() - lVal; // add the absolute value
  754. if(GetTripDate() == 0)
  755. SetTripDate(-1);
  756. SetProfileLong("TripCopies", lVal);
  757. }
  758. long CGetSetOptions::GetTripCopyCount()
  759. {
  760. return GetProfileLong("TripCopies", 0);
  761. }
  762. void CGetSetOptions::SetTripPasteCount(long lVal)
  763. {
  764. // negative means a relative offset
  765. if(lVal < 0)
  766. lVal = GetTripPasteCount() - lVal; // add the absolute value
  767. if(GetTripDate() == 0)
  768. SetTripDate(-1);
  769. SetProfileLong("TripPastes", lVal);
  770. }
  771. long CGetSetOptions::GetTripPasteCount()
  772. {
  773. return GetProfileLong("TripPastes", 0);
  774. }
  775. void CGetSetOptions::SetTripDate(long lDate)
  776. {
  777. if(lDate == -1)
  778. lDate = (long)CTime::GetCurrentTime().GetTime();
  779. SetProfileLong("TripDate", lDate);
  780. }
  781. long CGetSetOptions::GetTripDate()
  782. {
  783. return GetProfileLong("TripDate", 0);
  784. }
  785. void CGetSetOptions::SetTotalCopyCount(long lVal)
  786. {
  787. // negative means a relative offset
  788. if(lVal < 0)
  789. lVal = GetTotalCopyCount() - lVal; // add the absolute value
  790. if(GetTotalDate() == 0)
  791. SetTotalDate(-1);
  792. SetProfileLong("TotalCopies", lVal);
  793. }
  794. long CGetSetOptions::GetTotalCopyCount()
  795. {
  796. return GetProfileLong("TotalCopies", 0);
  797. }
  798. void CGetSetOptions::SetTotalPasteCount(long lVal)
  799. {
  800. // negative means a relative offset
  801. if(lVal < 0)
  802. lVal = GetTotalPasteCount() - lVal; // add the absolute value
  803. if(GetTotalDate() == 0)
  804. SetTotalDate(-1);
  805. SetProfileLong("TotalPastes", lVal);
  806. }
  807. long CGetSetOptions::GetTotalPasteCount()
  808. {
  809. return GetProfileLong("TotalPastes", 0);
  810. }
  811. void CGetSetOptions::SetTotalDate(long lDate)
  812. {
  813. if(lDate == -1)
  814. lDate = (long)CTime::GetCurrentTime().GetTime();
  815. SetProfileLong("TotalDate", lDate);
  816. }
  817. long CGetSetOptions::GetTotalDate()
  818. {
  819. return GetProfileLong("TotalDate", 0);
  820. }
  821. CString CGetSetOptions::GetUpdateFilePath()
  822. {
  823. return GetProfileString("UpdateFilePath", "");
  824. }
  825. BOOL CGetSetOptions::SetUpdateFilePath(CString cs)
  826. {
  827. return SetProfileString("UpdateFilePath", cs);
  828. }
  829. CString CGetSetOptions::GetUpdateInstallPath()
  830. {
  831. return GetProfileString("UpdateInstallPath", "");
  832. }
  833. BOOL CGetSetOptions::SetUpdateInstallPath(CString cs)
  834. {
  835. return SetProfileString("UpdateInstallPath", cs);
  836. }
  837. long CGetSetOptions::GetLastUpdate()
  838. {
  839. return GetProfileLong("LastUpdateDay", 0);
  840. }
  841. long CGetSetOptions::SetLastUpdate(long lValue)
  842. {
  843. return SetProfileLong("LastUpdateDay", lValue);
  844. }
  845. BOOL CGetSetOptions::GetCheckForUpdates()
  846. {
  847. return GetProfileLong("CheckForUpdates", TRUE);
  848. }
  849. BOOL CGetSetOptions::SetCheckForUpdates(BOOL bCheck)
  850. {
  851. return SetProfileLong("CheckForUpdates", bCheck);
  852. }
  853. void CGetSetOptions::SetUseCtrlNumForFirstTenHotKeys(BOOL bVal)
  854. {
  855. SetProfileLong("UseCtrlNumForFirstTenHotKeys", bVal);
  856. m_bUseCtrlNumAccel = bVal;
  857. }
  858. BOOL CGetSetOptions::GetUseCtrlNumForFirstTenHotKeys()
  859. {
  860. return GetProfileLong("UseCtrlNumForFirstTenHotKeys", 0);
  861. }
  862. void CGetSetOptions::SetAllowDuplicates(BOOL bVal)
  863. {
  864. SetProfileLong("AllowDuplicates", bVal);
  865. m_bAllowDuplicates = bVal;
  866. }
  867. BOOL CGetSetOptions::GetAllowDuplicates()
  868. {
  869. return GetProfileLong("AllowDuplicates", 0);
  870. }
  871. void CGetSetOptions::SetUpdateTimeOnPaste(BOOL bVal)
  872. {
  873. SetProfileLong("UpdateTimeOnPaste", bVal);
  874. m_bUpdateTimeOnPaste = bVal;
  875. }
  876. BOOL CGetSetOptions::GetUpdateTimeOnPaste()
  877. {
  878. return GetProfileLong("UpdateTimeOnPaste", TRUE);
  879. }
  880. void CGetSetOptions::SetSaveMultiPaste(BOOL bVal)
  881. {
  882. SetProfileLong("SaveMultiPaste", bVal);
  883. m_bSaveMultiPaste = bVal;
  884. }
  885. BOOL CGetSetOptions::GetSaveMultiPaste()
  886. {
  887. return GetProfileLong("SaveMultiPaste", 0);
  888. }
  889. void CGetSetOptions::SetShowPersistent(BOOL bVal)
  890. {
  891. SetProfileLong("ShowPersistent", bVal);
  892. m_bShowPersistent = bVal;
  893. }
  894. BOOL CGetSetOptions::GetShowPersistent()
  895. {
  896. return GetProfileLong("ShowPersistent", 0);
  897. }
  898. void CGetSetOptions::SetShowTextForFirstTenHotKeys(BOOL bVal)
  899. {
  900. SetProfileLong("ShowTextForFirstTenHotKeys", bVal);
  901. }
  902. BOOL CGetSetOptions::GetShowTextForFirstTenHotKeys()
  903. {
  904. return GetProfileLong("ShowTextForFirstTenHotKeys", TRUE);
  905. }
  906. void CGetSetOptions::SetMainHWND(long lhWnd)
  907. {
  908. SetProfileLong("MainhWnd", lhWnd);
  909. }
  910. BOOL CGetSetOptions::GetMainHWND()
  911. {
  912. return GetProfileLong("MainhWnd", 0);
  913. }
  914. void CGetSetOptions::SetCaptionPos(long lPos)
  915. {
  916. SetProfileLong("CaptionPos", lPos);
  917. }
  918. long CGetSetOptions::GetCaptionPos()
  919. {
  920. return GetProfileLong("CaptionPos", CAPTION_RIGHT);
  921. }
  922. void CGetSetOptions::SetAutoHide(BOOL bAutoHide)
  923. {
  924. SetProfileLong("AutoHide", bAutoHide);
  925. }
  926. BOOL CGetSetOptions::GetAutoHide()
  927. {
  928. return GetProfileLong("AutoHide", FALSE);
  929. }
  930. void CGetSetOptions::SetDescTextSize(long lSize)
  931. {
  932. SetProfileLong("DescTextSize", lSize);
  933. m_bDescTextSize = lSize;
  934. }
  935. long CGetSetOptions::GetDescTextSize()
  936. {
  937. return GetProfileLong("DescTextSize", 500);
  938. }
  939. void CGetSetOptions::SetDescShowLeadingWhiteSpace(BOOL bVal)
  940. {
  941. SetProfileLong("DescShowLeadingWhiteSpace", bVal);
  942. m_bDescShowLeadingWhiteSpace = bVal;
  943. }
  944. BOOL CGetSetOptions::GetDescShowLeadingWhiteSpace()
  945. {
  946. return GetProfileLong("DescShowLeadingWhiteSpace", FALSE);
  947. }
  948. void CGetSetOptions::SetAllwaysShowDescription(long bShow)
  949. {
  950. SetProfileLong("AllwaysShowDescription", bShow);
  951. m_bAllwaysShowDescription = bShow;
  952. }
  953. BOOL CGetSetOptions::GetAllwaysShowDescription()
  954. {
  955. return GetProfileLong("AllwaysShowDescription", FALSE);
  956. }
  957. void CGetSetOptions::SetDoubleClickingOnCaptionDoes(long lOption)
  958. {
  959. SetProfileLong("DoubleClickingOnCaptionDoes", lOption);
  960. m_bDoubleClickingOnCaptionDoes = lOption;
  961. }
  962. long CGetSetOptions::GetDoubleClickingOnCaptionDoes()
  963. {
  964. return GetProfileLong("DoubleClickingOnCaptionDoes", TOGGLES_ALLWAYS_ON_TOP);
  965. }
  966. void CGetSetOptions::SetPrompForNewGroupName(BOOL bOption)
  967. {
  968. SetProfileLong("PrompForNewGroupName", bOption);
  969. m_bPrompForNewGroupName = bOption;
  970. }
  971. BOOL CGetSetOptions::GetPrompForNewGroupName()
  972. {
  973. return GetProfileLong("PrompForNewGroupName", TRUE);
  974. }
  975. void CGetSetOptions::SetSendPasteOnFirstTenHotKeys(BOOL bOption)
  976. {
  977. SetProfileLong("SendPasteOnFirstTenHotKeys", bOption);
  978. m_bSendPasteOnFirstTenHotKeys = bOption;
  979. }
  980. BOOL CGetSetOptions::GetSendPasteOnFirstTenHotKeys()
  981. {
  982. return GetProfileLong("SendPasteOnFirstTenHotKeys", TRUE);
  983. }
  984. void CGetSetOptions::SetSendClients(CSendClients Client, int nPos)
  985. {
  986. CString cs;
  987. cs.Format(_T("sendclient_ip_%d"), nPos);
  988. SetProfileString(cs, Client.csIP);
  989. cs.Format(_T("sendclient_autosend_%d"), nPos);
  990. SetProfileLong(cs, Client.bSendAll);
  991. cs.Format(_T("sendclient_description_%d"), nPos);
  992. SetProfileString(cs, Client.csDescription);
  993. Client.bShownFirstError = m_SendClients[nPos].bShownFirstError;
  994. m_SendClients[nPos] = Client;
  995. }
  996. CSendClients CGetSetOptions::GetSendClients(int nPos)
  997. {
  998. CSendClients Client;
  999. CString cs;
  1000. cs.Format(_T("sendclient_ip_%d"), nPos);
  1001. Client.csIP = GetProfileString(cs, "");
  1002. cs.Format(_T("sendclient_autosend_%d"), nPos);
  1003. Client.bSendAll = GetProfileLong(cs, FALSE);
  1004. cs.Format(_T("sendclient_description_%d"), nPos);
  1005. Client.csDescription = GetProfileString(cs, "");
  1006. m_SendClients[nPos] = Client;
  1007. return Client;
  1008. }
  1009. void CGetSetOptions::GetClientSendCount()
  1010. {
  1011. m_lAutoSendClientCount = 0;
  1012. for(int i = 0; i < MAX_SEND_CLIENTS; i++)
  1013. {
  1014. if(m_SendClients[i].csIP.GetLength() > 0)
  1015. {
  1016. if(m_SendClients[i].bSendAll)
  1017. m_lAutoSendClientCount++;
  1018. }
  1019. }
  1020. }
  1021. CString CGetSetOptions::GetListToPutOnClipboard()
  1022. {
  1023. CString cs = GetProfileString("ListToPutOnClipboard", "");
  1024. cs.MakeUpper();
  1025. return cs;
  1026. }
  1027. BOOL CGetSetOptions::SetListToPutOnClipboard(CString cs)
  1028. {
  1029. cs.MakeUpper();
  1030. m_csIPListToPutOnClipboard = cs;
  1031. return SetProfileString("ListToPutOnClipboard", cs);
  1032. }
  1033. void CGetSetOptions::SetLogSendReceiveErrors(BOOL bOption)
  1034. {
  1035. m_bLogSendReceiveErrors = bOption;
  1036. SetProfileLong("LogSendReceiveErrors", bOption);
  1037. }
  1038. BOOL CGetSetOptions::GetLogSendReceiveErrors()
  1039. {
  1040. return GetProfileLong("LogSendReceiveErrors", FALSE);
  1041. }
  1042. BOOL CGetSetOptions::GetHideDittoOnHotKeyIfAlreadyShown()
  1043. {
  1044. return GetProfileLong("HideDittoOnHotKeyIfAlreadyShown", TRUE);
  1045. }
  1046. void CGetSetOptions::SetHideDittoOnHotKeyIfAlreadyShown(BOOL bVal)
  1047. {
  1048. m_HideDittoOnHotKeyIfAlreadyShown = bVal;
  1049. SetProfileLong("HideDittoOnHotKeyIfAlreadyShown", bVal);
  1050. }
  1051. void CGetSetOptions::SetPort(long lPort)
  1052. {
  1053. m_lPort = lPort;
  1054. SetProfileLong("SendRecvPort", lPort);
  1055. }
  1056. long CGetSetOptions::GetPort()
  1057. {
  1058. return GetProfileLong("SendRecvPort", 23443);
  1059. }
  1060. BOOL CGetSetOptions::GetDisableRecieve()
  1061. {
  1062. BOOL bDefault = FALSE;
  1063. if(m_bU3)
  1064. bDefault = TRUE;
  1065. if(GetIsPortableDitto())
  1066. bDefault = TRUE;
  1067. return GetProfileLong("DisableRecieve", bDefault);
  1068. }
  1069. void CGetSetOptions::SetDisableRecieve(BOOL bVal)
  1070. {
  1071. SetProfileLong("DisableRecieve", bVal);
  1072. }
  1073. BOOL CGetSetOptions::GetFont(LOGFONT &font)
  1074. {
  1075. if(m_bFromIni && !m_bInConversion)
  1076. {
  1077. GetProfileFont("DisplayFont", font);
  1078. //Return true if there is a font name
  1079. //other wise load the default font below
  1080. if(font.lfFaceName[0] != 0)
  1081. {
  1082. return TRUE;
  1083. }
  1084. }
  1085. else
  1086. {
  1087. DWORD dwLength = 0;
  1088. #ifdef _UNICODE
  1089. LPVOID lpVoid = GetProfileData("DisplayFont3", dwLength);
  1090. #else
  1091. LPVOID lpVoid = GetProfileData("DisplayFont", dwLength);
  1092. #endif
  1093. if(lpVoid)
  1094. {
  1095. if(sizeof(font) == dwLength)
  1096. {
  1097. memcpy(&font, lpVoid, dwLength);
  1098. delete[] lpVoid;
  1099. lpVoid = NULL;
  1100. return TRUE;
  1101. }
  1102. else
  1103. {
  1104. ASSERT(!"invalid font struct size");
  1105. }
  1106. delete[] lpVoid;
  1107. lpVoid = NULL;
  1108. }
  1109. }
  1110. ZeroMemory(&font, sizeof(font));
  1111. font.lfHeight = -theApp.m_metrics.PointsToPixels(8);
  1112. font.lfWeight = 400;
  1113. font.lfCharSet = 1;
  1114. STRCPY(font.lfFaceName, _T("Arial Unicode MS"));
  1115. return TRUE;
  1116. }
  1117. void CGetSetOptions::SetFont(LOGFONT &font)
  1118. {
  1119. if(m_bFromIni)
  1120. {
  1121. SetProfileFont("DisplayFont", font);
  1122. }
  1123. else
  1124. {
  1125. #ifdef _UNICODE
  1126. CString csParam = "DisplayFont3";
  1127. #else
  1128. CString csParam = "DisplayFont";
  1129. #endif
  1130. SetProfileData(csParam, &font, sizeof(LOGFONT));
  1131. }
  1132. }
  1133. void CGetSetOptions::SetDrawThumbnail(long bDraw)
  1134. {
  1135. SetProfileLong("DrawThumbnail", bDraw);
  1136. m_bDrawThumbnail = bDraw;
  1137. }
  1138. BOOL CGetSetOptions::GetDrawThumbnail()
  1139. {
  1140. BOOL bDrawThumbnails = TRUE;
  1141. if(g_Opt.m_bU3)
  1142. bDrawThumbnails = FALSE;
  1143. return GetProfileLong("DrawThumbnail", bDrawThumbnails);
  1144. }
  1145. void CGetSetOptions::SetExtraNetworkPassword(CString csPassword)
  1146. {
  1147. SetProfileString("NetworkExtraPassword", csPassword);
  1148. }
  1149. CString CGetSetOptions::GetExtraNetworkPassword(bool bFillArray)
  1150. {
  1151. CString cs = GetProfileString("NetworkExtraPassword", "");
  1152. if(bFillArray)
  1153. {
  1154. m_csNetworkPasswordArray.RemoveAll();
  1155. TCHAR seps[] = _T(",");
  1156. TCHAR *token;
  1157. TCHAR *pString = cs.GetBuffer(cs.GetLength());
  1158. /* Establish string and get the first token: */
  1159. token = STRTOK(pString, seps);
  1160. while(token != NULL)
  1161. {
  1162. CString cs(token);
  1163. cs.TrimLeft();
  1164. cs.TrimRight();
  1165. m_csNetworkPasswordArray.Add(cs);
  1166. // Get next token
  1167. token = STRTOK(NULL, seps);
  1168. }
  1169. cs.ReleaseBuffer();
  1170. }
  1171. return cs;
  1172. }
  1173. void CGetSetOptions::SetNetworkPassword(CString csPassword)
  1174. {
  1175. CTextConvert Con;
  1176. Con.ConvertToUTF8(csPassword, m_csPassword);
  1177. SetProfileString("NetworkStringPassword", csPassword);
  1178. }
  1179. CStringA CGetSetOptions::GetNetworkPassword()
  1180. {
  1181. CString cs = GetProfileString("NetworkStringPassword", "LetMeIn");
  1182. CTextConvert Con;
  1183. CStringA csReturn;
  1184. Con.ConvertToUTF8(cs, csReturn);
  1185. return csReturn;
  1186. }
  1187. void CGetSetOptions::SetDrawRTF(long bDraw)
  1188. {
  1189. SetProfileLong("DrawRTF", bDraw);
  1190. m_bDrawRTF = bDraw;
  1191. }
  1192. BOOL CGetSetOptions::GetDrawRTF()
  1193. {
  1194. return GetProfileLong("DrawRTF", FALSE);
  1195. }
  1196. void CGetSetOptions::SetMultiPasteReverse(BOOL bVal)
  1197. {
  1198. SetProfileLong("MultiPasteReverse", bVal);
  1199. m_bMultiPasteReverse = bVal;
  1200. }
  1201. BOOL CGetSetOptions::GetMultiPasteReverse()
  1202. {
  1203. return GetProfileLong("MultiPasteReverse", TRUE);
  1204. }
  1205. void CGetSetOptions::SetPlaySoundOnCopy(CString cs)
  1206. {
  1207. m_csPlaySoundOnCopy = cs;
  1208. SetProfileString("PlaySoundOnCopy", cs);
  1209. }
  1210. CString CGetSetOptions::GetPlaySoundOnCopy()
  1211. {
  1212. return GetProfileString("PlaySoundOnCopy", "");
  1213. }
  1214. void CGetSetOptions::SetSendPasteAfterSelection(BOOL bVal)
  1215. {
  1216. m_bSendPasteMessageAfterSelection = bVal;
  1217. SetProfileLong("SendPasteMessageAfterSelection", bVal);
  1218. }
  1219. BOOL CGetSetOptions::GetSendPasteAfterSelection()
  1220. {
  1221. return GetProfileLong("SendPasteMessageAfterSelection", TRUE);
  1222. }
  1223. void CGetSetOptions::SetFindAsYouType(BOOL bVal)
  1224. {
  1225. m_bFindAsYouType = bVal;
  1226. SetProfileLong("FindAsYouType", bVal);
  1227. }
  1228. BOOL CGetSetOptions::GetFindAsYouType()
  1229. {
  1230. return GetProfileLong("FindAsYouType", TRUE);
  1231. }
  1232. void CGetSetOptions::SetEnsureEntireWindowCanBeSeen(BOOL bVal)
  1233. {
  1234. m_bEnsureEntireWindowCanBeSeen = bVal;
  1235. SetProfileLong("EnsureEntireWindowCanBeSeen", bVal);
  1236. }
  1237. BOOL CGetSetOptions::GetEnsureEntireWindowCanBeSeen()
  1238. {
  1239. return GetProfileLong("EnsureEntireWindowCanBeSeen", TRUE);
  1240. }
  1241. void CGetSetOptions::SetShowAllClipsInMainList(BOOL bVal)
  1242. {
  1243. m_bShowAllClipsInMainList = bVal;
  1244. SetProfileLong("ShowAllClipsInMainList", bVal);
  1245. }
  1246. BOOL CGetSetOptions::GetShowAllClipsInMainList()
  1247. {
  1248. return GetProfileLong("ShowAllClipsInMainList", TRUE);
  1249. }
  1250. long CGetSetOptions::GetMaxClipSizeInBytes()
  1251. {
  1252. return GetProfileLong("MaxClipSizeInBytes", 0);
  1253. }
  1254. void CGetSetOptions::SetMaxClipSizeInBytes(long lSize)
  1255. {
  1256. m_lMaxClipSizeInBytes = lSize;
  1257. SetProfileLong("MaxClipSizeInBytes", lSize);
  1258. }
  1259. CString CGetSetOptions::GetLanguageFile()
  1260. {
  1261. return GetProfileString("LanguageFile", "");
  1262. }
  1263. void CGetSetOptions::SetLanguageFile(CString csLanguage)
  1264. {
  1265. SetProfileString("LanguageFile", csLanguage);
  1266. }
  1267. ULONG CGetSetOptions::GetSaveClipDelay()
  1268. {
  1269. return (ULONG)GetProfileLong("SaveClipDelay", 500);
  1270. }
  1271. void CGetSetOptions::SetSaveClipDelay(DWORD dwDelay)
  1272. {
  1273. m_dwSaveClipDelay = dwDelay;
  1274. SetProfileLong("SaveClipDelay", dwDelay);
  1275. }
  1276. long CGetSetOptions::GetProcessDrawClipboardDelay()
  1277. {
  1278. return GetProfileLong("ProcessDrawClipboardDelay", 100);
  1279. }
  1280. void CGetSetOptions::SetProcessDrawClipboardDelay(long lDelay)
  1281. {
  1282. m_lProcessDrawClipboardDelay = lDelay;
  1283. SetProfileLong("ProcessDrawClipboardDelay", lDelay);
  1284. }
  1285. BOOL CGetSetOptions::GetEnableDebugLogging()
  1286. {
  1287. return GetProfileLong("EnableDebugLogging", FALSE);
  1288. }
  1289. void CGetSetOptions::SetEnableDebugLogging(BOOL bEnable)
  1290. {
  1291. m_bEnableDebugLogging = bEnable;
  1292. SetProfileLong("EnableDebugLogging", bEnable);
  1293. }
  1294. BOOL CGetSetOptions::GetEnsureConnectToClipboard()
  1295. {
  1296. return GetProfileLong("EnsureConnected", TRUE);
  1297. }
  1298. void CGetSetOptions::SetEnsureConnectToClipboard(BOOL bSet)
  1299. {
  1300. m_bEnsureConnectToClipboard = bSet;
  1301. SetProfileLong("EnsureConnected", bSet);
  1302. }
  1303. BOOL CGetSetOptions::GetPromptWhenDeletingClips()
  1304. {
  1305. return GetProfileLong("PromptWhenDeletingClips", TRUE);
  1306. }
  1307. void CGetSetOptions::SetPromptWhenDeletingClips(BOOL bSet)
  1308. {
  1309. SetProfileLong("PromptWhenDeletingClips", bSet);
  1310. }
  1311. CString CGetSetOptions::GetLastImportDir()
  1312. {
  1313. return GetProfileString("LastImportDir", "");
  1314. }
  1315. void CGetSetOptions::SetLastImportDir(CString csDir)
  1316. {
  1317. SetProfileString("LastImportDir", csDir);
  1318. }
  1319. CString CGetSetOptions::GetLastExportDir()
  1320. {
  1321. return GetProfileString("LastExportDir", "");
  1322. }
  1323. void CGetSetOptions::SetLastExportDir(CString csDir)
  1324. {
  1325. SetProfileString("LastExportDir", csDir);
  1326. }
  1327. BOOL CGetSetOptions::GetUpdateDescWhenSavingClip()
  1328. {
  1329. return GetProfileLong("UpdateDescWhenSaving", TRUE);
  1330. }
  1331. void CGetSetOptions::SetUpdateDescWhenSavingClip(BOOL bSet)
  1332. {
  1333. SetProfileLong("UpdateDescWhenSaving", bSet);
  1334. }
  1335. CString CGetSetOptions::GetPath(long lPathID)
  1336. {
  1337. CString csDir = CGetSetOptions::GetExeFileName();
  1338. csDir = GetFilePath(csDir);
  1339. FIX_CSTRING_PATH(csDir);
  1340. //U3_APP_DATA_PATH - <U3_DEVICE_PATH>\System\Apps\{app_unique_id}\Data
  1341. //U3_HOST_EXEC_PATH - %APPDATA%\U3\{device_serial_number}\{app_unique_id}\Exec
  1342. //U3_DEVICE_EXEC_PATH - <U3_DEVICE_PATH>\System\Apps\{app_unique_id}\Exec
  1343. switch(lPathID)
  1344. {
  1345. case PATH_HELP:
  1346. csDir += "Help\\";
  1347. break;
  1348. case PATH_LANGUAGE:
  1349. csDir += "language\\";
  1350. break;
  1351. case PATH_THEMES:
  1352. csDir += "Themes\\";
  1353. break;
  1354. case PATH_LOG_FILE:if(CGetSetOptions::GetIsPortableDitto() == false)
  1355. csDir = GetAppDataPath();
  1356. break;
  1357. case PATH_UPDATE_FILE:
  1358. //same path as the executable
  1359. break;
  1360. case PATH_DATABASE:
  1361. break;
  1362. case PATH_INI:
  1363. break;
  1364. case PATH_U3_HWND_INI:
  1365. break;
  1366. case PATH_ADDINS:
  1367. csDir += "Addins\\";
  1368. break;
  1369. case PATH_REMOTE_FILES:
  1370. if (CGetSetOptions::GetIsPortableDitto() == false)
  1371. {
  1372. wchar_t wchPath[MAX_PATH];
  1373. if (GetTempPathW(MAX_PATH, wchPath))
  1374. {
  1375. csDir = wchPath;
  1376. csDir += _T("Ditto\\");
  1377. }
  1378. }
  1379. csDir += "ReceivedFiles\\";
  1380. break;
  1381. case PATH_DRAG_FILES:
  1382. if (CGetSetOptions::GetIsPortableDitto() == false)
  1383. {
  1384. wchar_t wchPath[MAX_PATH];
  1385. if (GetTempPathW(MAX_PATH, wchPath))
  1386. {
  1387. csDir = wchPath;
  1388. csDir += _T("Ditto\\");
  1389. }
  1390. }
  1391. csDir += "DragFiles\\";
  1392. break;
  1393. case PATH_CLIP_DIFF:
  1394. if (CGetSetOptions::GetIsPortableDitto() == false)
  1395. {
  1396. wchar_t wchPath[MAX_PATH];
  1397. if (GetTempPathW(MAX_PATH, wchPath))
  1398. {
  1399. csDir = wchPath;
  1400. csDir += _T("Ditto\\");
  1401. }
  1402. }
  1403. csDir += _T("ClipCompare\\");
  1404. break;
  1405. }
  1406. CreateDirectory(csDir, NULL);
  1407. return csDir;
  1408. }
  1409. void CGetSetOptions::WriteU3Hwnd(HWND hWnd)
  1410. {
  1411. CString csIniFile = GetPath(PATH_U3_HWND_INI);
  1412. csIniFile += _T("DittohWnd.ini");
  1413. WritePrivateProfileInt(_T("Ditto"), _T("MainhWnd"), (int)hWnd, csIniFile);
  1414. }
  1415. long CGetSetOptions::GetDittoRestoreClipboardDelay()
  1416. {
  1417. return GetProfileLong("RestoreClipboardDelay", 750);
  1418. }
  1419. void CGetSetOptions::SetDittoRestoreClipboardDelay(long lDelay)
  1420. {
  1421. SetProfileLong("RestoreClipboardDelay", lDelay);
  1422. }
  1423. void CGetSetOptions::GetCopyBufferItem(int nPos, CCopyBufferItem &Item)
  1424. {
  1425. Item.m_lCopyHotKey = GetProfileLong(StrF(_T("CopyBufferCopyHotKey_%d"), nPos), 0);
  1426. Item.m_lPasteHotKey = GetProfileLong(StrF(_T("CopyBufferPasteHotKey_%d"), nPos), 0);
  1427. Item.m_lCutHotKey = GetProfileLong(StrF(_T("CopyBufferCutHotKey_%d"), nPos), 0);
  1428. Item.m_bPlaySoundOnCopy = GetProfileLong(StrF(_T("CopyBufferPlaySound_%d"), nPos), 0);
  1429. }
  1430. void CGetSetOptions::SetCopyBufferItem(int nPos, CCopyBufferItem &Item)
  1431. {
  1432. SetProfileLong(StrF(_T("CopyBufferCopyHotKey_%d"), nPos), Item.m_lCopyHotKey);
  1433. SetProfileLong(StrF(_T("CopyBufferPasteHotKey_%d"), nPos), Item.m_lPasteHotKey);
  1434. SetProfileLong(StrF(_T("CopyBufferCutHotKey_%d"), nPos), Item.m_lCutHotKey);
  1435. SetProfileLong(StrF(_T("CopyBufferPlaySound_%d"), nPos), Item.m_bPlaySoundOnCopy);
  1436. }
  1437. CString CGetSetOptions::GetMultiPasteSeparator(bool bConvertToLineFeeds)
  1438. {
  1439. CString csSep = GetProfileString(_T("MultiPasteSeparator"), _T("[LF]"));
  1440. if(bConvertToLineFeeds)
  1441. {
  1442. CString csLineFeed(_T("\r\n"));
  1443. csSep.Replace(_T("[LF]"), csLineFeed);
  1444. csSep.Replace(_T("[lf]"), csLineFeed);
  1445. }
  1446. return csSep;
  1447. }
  1448. void CGetSetOptions::SetMultiPasteSeparator(CString csSep)
  1449. {
  1450. SetProfileString(_T("MultiPasteSeparator"), csSep);
  1451. }
  1452. BOOL CGetSetOptions::GetSetCurrentDirectory()
  1453. {
  1454. if(m_portable)
  1455. {
  1456. CString csExePath = GetFilePath(GetExeFileName());
  1457. FIX_CSTRING_PATH(csExePath);
  1458. ::SetCurrentDirectory(csExePath);
  1459. }
  1460. return m_portable == true;
  1461. }
  1462. bool CGetSetOptions::GetIsPortableDitto()
  1463. {
  1464. return m_portable;
  1465. }
  1466. CString CGetSetOptions::GetPasteString(CString csAppName)
  1467. {
  1468. CString csString = GetProfileString(csAppName, _T(""), _T("PasteStrings"));
  1469. if(csString.IsEmpty())
  1470. return GetDefaultPasteString();
  1471. return csString;
  1472. }
  1473. CString CGetSetOptions::GetDefaultPasteString()
  1474. {
  1475. return GetProfileString(_T("DefaultPasteString"), _T("^v"));
  1476. }
  1477. CString CGetSetOptions::GetCopyString(CString csAppName)
  1478. {
  1479. CString csString = GetProfileString(csAppName, _T(""), _T("CopyStrings"));
  1480. if(csString.IsEmpty())
  1481. return GetDefaultCopyString();
  1482. return csString;
  1483. }
  1484. CString CGetSetOptions::GetDefaultCopyString()
  1485. {
  1486. return GetProfileString(_T("DefaultCopyString"), _T("^c"));
  1487. }
  1488. CString CGetSetOptions::GetCutString(CString csAppName)
  1489. {
  1490. CString csString = GetProfileString(csAppName, _T(""), _T("CutStrings"));
  1491. if(csString.IsEmpty())
  1492. return GetDefaultCutString();
  1493. return csString;
  1494. }
  1495. CString CGetSetOptions::GetDefaultCutString()
  1496. {
  1497. return GetProfileString(_T("DefaultCutString"), _T("^x"));
  1498. }
  1499. BOOL CGetSetOptions::GetEditWordWrap()
  1500. {
  1501. return GetProfileLong(_T("EditWordWrap"), TRUE);
  1502. }
  1503. void CGetSetOptions::SetEditWordWrap(BOOL bSet)
  1504. {
  1505. SetProfileLong(_T("EditWordWrap"), bSet);
  1506. }
  1507. bool CGetSetOptions::GetAllowFriends()
  1508. {
  1509. return (GetProfileLong("AllowFriends", TRUE) == TRUE);
  1510. }
  1511. long CGetSetOptions::GetAutoMaxDelay()
  1512. {
  1513. return GetProfileLong(_T("AutoMaxDelaySeconds"), 2);
  1514. }
  1515. void CGetSetOptions::SetAutoMaxDelay(long lDelay)
  1516. {
  1517. SetProfileLong(_T("AutoMaxDelaySeconds"), lDelay);
  1518. }
  1519. void CGetSetOptions::SetTheme(CString csTheme)
  1520. {
  1521. SetProfileString(_T("Theme"), csTheme);
  1522. }
  1523. CString CGetSetOptions::GetTheme()
  1524. {
  1525. return GetProfileString(_T("Theme"), "");
  1526. }
  1527. long CGetSetOptions::GetKeyStateWaitTimerCount()
  1528. {
  1529. return GetProfileLong(_T("KeyStateWaitTimerCount"), 20);
  1530. }
  1531. long CGetSetOptions::GetKeyStatePasteDelay()
  1532. {
  1533. return GetProfileLong(_T("KeyStatePasteDelay"), 200);
  1534. }
  1535. DWORD CGetSetOptions::GetDittoHotKey()
  1536. {
  1537. return (DWORD)GetProfileLong(_T("DittoHotKey"), 704);
  1538. }
  1539. DWORD CGetSetOptions::SendKeysDelay()
  1540. {
  1541. return (DWORD)GetProfileLong(_T("SendKeysDelay"), 50);
  1542. }
  1543. DWORD CGetSetOptions::WaitForActiveWndTimeout()
  1544. {
  1545. return (DWORD)GetProfileLong(_T("WaitForActiveWndTimeout"), 100);
  1546. }
  1547. DWORD CGetSetOptions::FocusChangedDelay()
  1548. {
  1549. return (DWORD)GetProfileLong(_T("FocusChangedDelay"), 100);
  1550. }
  1551. DWORD CGetSetOptions::FocusWndTimerTimeout()
  1552. {
  1553. return (DWORD)GetProfileLong(_T("FocusWndTimerTimeout"), 2000);
  1554. }
  1555. BOOL CGetSetOptions::GetConnectedToClipboard()
  1556. {
  1557. return GetProfileLong("ConnectedToClipboard", TRUE);
  1558. }
  1559. void CGetSetOptions::SetConnectedToClipboard(BOOL val)
  1560. {
  1561. SetProfileLong("ConnectedToClipboard", val);
  1562. }
  1563. DWORD CGetSetOptions::GetTextOnlyRestoreDelay()
  1564. {
  1565. return (DWORD)GetProfileLong(_T("TextOnlyRestoreDelay"), 2000);
  1566. }
  1567. DWORD CGetSetOptions::GetTextOnlyPasteDelay()
  1568. {
  1569. return (DWORD)GetProfileLong(_T("TextOnlyPasteDelay"), 0);
  1570. }
  1571. BOOL CGetSetOptions::GetSetFocusToApp(CString csAppName)
  1572. {
  1573. CString focusCheck;
  1574. focusCheck = "SetFocus_";
  1575. focusCheck += csAppName;
  1576. return GetProfileLong(focusCheck, FALSE);
  1577. }
  1578. DWORD CGetSetOptions::SelectedIndex()
  1579. {
  1580. return (DWORD)GetProfileLong(_T("SelectedIndex"), 0);
  1581. }
  1582. void CGetSetOptions::SetCopyAppInclude(CString csAppName)
  1583. {
  1584. SetProfileString(_T("CopyAppInclude"), csAppName);
  1585. }
  1586. CString CGetSetOptions::GetCopyAppInclude()
  1587. {
  1588. CString includeApp = GetProfileString(_T("CopyAppInclude"), "*");
  1589. if(includeApp == "")
  1590. {
  1591. includeApp = "*";
  1592. }
  1593. return includeApp;
  1594. }
  1595. void CGetSetOptions::SetCopyAppExclude(CString csAppName)
  1596. {
  1597. SetProfileString(_T("CopyAppExclude"), csAppName);
  1598. }
  1599. CString CGetSetOptions::GetCopyAppExclude()
  1600. {
  1601. return GetProfileString(_T("CopyAppExclude"), "");
  1602. }
  1603. CString CGetSetOptions::GetCopyAppSeparator()
  1604. {
  1605. return GetProfileString(_T("CopyAppSeparator"), ";");
  1606. }
  1607. DWORD CGetSetOptions::GetNoFormatsRetryDelay()
  1608. {
  1609. return GetProfileLong(_T("NoFormatsRetryDelay"), 200);
  1610. }
  1611. DWORD CGetSetOptions::GetMainDeletesDeleteCount()
  1612. {
  1613. return GetProfileLong(_T("MainDeletesDeleteCount"), 100);
  1614. }
  1615. DWORD CGetSetOptions::GetIdleSecondsBeforeDelete()
  1616. {
  1617. return GetProfileLong(_T("IdleSecondsBeforeDelete"), 60*10);
  1618. }
  1619. DWORD CGetSetOptions::GetDbTimeout()
  1620. {
  1621. return GetProfileLong(_T("DbTimeout"), 5000);
  1622. }
  1623. DWORD CGetSetOptions::GetFunnyTickCountAdjustment()
  1624. {
  1625. return GetProfileLong(_T("FunnyTickCountAdjustment"), 300001);
  1626. }
  1627. DWORD CGetSetOptions::GetMinIdleTimeBeforeTrackFocus()
  1628. {
  1629. return GetProfileLong(_T("MinIdleTimeBeforeTrackFocus"), 100);
  1630. }
  1631. DWORD CGetSetOptions::GetTimeBeforeExpandWindow()
  1632. {
  1633. return GetProfileLong(_T("TimeBeforeExpandWindow"), 250);
  1634. }
  1635. DWORD CGetSetOptions::GetUseGuiThreadInfoForFocus()
  1636. {
  1637. return GetProfileLong(_T("UseGuiThreadInfoForFocus"), 1);
  1638. }
  1639. void CGetSetOptions::SetSearchDescription(BOOL val)
  1640. {
  1641. SetProfileLong(_T("SearchDescription"), val);
  1642. }
  1643. BOOL CGetSetOptions::GetSearchDescription()
  1644. {
  1645. return GetProfileLong(_T("SearchDescription"), 1);
  1646. }
  1647. void CGetSetOptions::SetSearchFullText(BOOL val)
  1648. {
  1649. SetProfileLong(_T("SearchFullText"), val);
  1650. }
  1651. BOOL CGetSetOptions::GetSearchFullText()
  1652. {
  1653. return GetProfileLong(_T("SearchFullText"), 0);
  1654. }
  1655. void CGetSetOptions::SetSearchQuickPaste(BOOL val)
  1656. {
  1657. SetProfileLong(_T("SearchQuickPaste"), val);
  1658. }
  1659. BOOL CGetSetOptions::GetSearchQuickPaste()
  1660. {
  1661. return GetProfileLong(_T("SearchQuickPaste"), 0);
  1662. }
  1663. void CGetSetOptions::SetSimpleTextSearch(BOOL val)
  1664. {
  1665. SetProfileLong(_T("SimpleTextSearch"), val);
  1666. }
  1667. BOOL CGetSetOptions::GetSimpleTextSearch()
  1668. {
  1669. return GetProfileLong(_T("SimpleTextSearch"), 0);
  1670. }
  1671. void CGetSetOptions::SetRegExTextSearch(BOOL val)
  1672. {
  1673. SetProfileLong(_T("RegExTextSearch"), val);
  1674. }
  1675. BOOL CGetSetOptions::GetRegExTextSearch()
  1676. {
  1677. return GetProfileLong(_T("RegExTextSearch"), 0);
  1678. }
  1679. void CGetSetOptions::SetMoveClipsOnGlobal10(BOOL val)
  1680. {
  1681. SetProfileLong(_T("MoveClipsOnGlobal10"), val);
  1682. }
  1683. BOOL CGetSetOptions::GetMoveClipsOnGlobal10()
  1684. {
  1685. return GetProfileLong(_T("MoveClipsOnGlobal10"), 0);
  1686. }
  1687. void CGetSetOptions::SetShowScrollBar(BOOL val)
  1688. {
  1689. m_showScrollBar = val;
  1690. SetProfileLong(_T("ShowScrollBar"), val);
  1691. }
  1692. BOOL CGetSetOptions::GetShowScrollBar()
  1693. {
  1694. return GetProfileLong(_T("ShowScrollBar"), 0);
  1695. }
  1696. void CGetSetOptions::SetPasteAsAdmin(BOOL val)
  1697. {
  1698. SetProfileLong(_T("PasteAsAdmin"), val);
  1699. }
  1700. BOOL CGetSetOptions::GetPasteAsAdmin()
  1701. {
  1702. return GetProfileLong(_T("PasteAsAdmin"), 1);
  1703. }
  1704. void CGetSetOptions::SetRememberDescPos(BOOL val)
  1705. {
  1706. SetProfileLong(_T("RememberDescPos"), val);
  1707. }
  1708. BOOL CGetSetOptions::GetRememberDescPos()
  1709. {
  1710. return GetProfileLong(_T("RememberDescPos"), FALSE);
  1711. }
  1712. void CGetSetOptions::SetSizeDescWindowToContent(BOOL val)
  1713. {
  1714. SetProfileLong(_T("SizeDescWindowToContent"), val);
  1715. }
  1716. BOOL CGetSetOptions::GetSizeDescWindowToContent()
  1717. {
  1718. return GetProfileLong(_T("SizeDescWindowToContent"), TRUE);
  1719. }
  1720. void CGetSetOptions::SetScaleImagesToDescWindow(BOOL val)
  1721. {
  1722. SetProfileLong(_T("ScaleImagesToDescWindow"), val);
  1723. }
  1724. BOOL CGetSetOptions::GetScaleImagesToDescWindow()
  1725. {
  1726. return GetProfileLong(_T("ScaleImagesToDescWindow"), TRUE);
  1727. }
  1728. void CGetSetOptions::SetDescWndPoint(CPoint point)
  1729. {
  1730. SetResolutionProfileLong("DescWndX", point.x);
  1731. SetResolutionProfileLong("DescWndY", point.y);
  1732. }
  1733. void CGetSetOptions::GetDescWndPoint(CPoint &point)
  1734. {
  1735. point.x = GetResolutionProfileLong("DescWndX", 100);
  1736. point.y = GetResolutionProfileLong("DescWndY", 100);
  1737. }
  1738. void CGetSetOptions::GetDescWndSize(CSize &size)
  1739. {
  1740. size.cx = GetResolutionProfileLong("DescWndCX", 300);
  1741. size.cy = GetResolutionProfileLong("DescWndCY", 300);
  1742. if(size.cx <= 0 && size.cy <= 0)
  1743. {
  1744. size.cx = 300;
  1745. size.cy = 300;
  1746. }
  1747. }
  1748. void CGetSetOptions::SetDescWndSize(CSize size)
  1749. {
  1750. SetResolutionProfileLong("DescWndCX", size.cx);
  1751. SetResolutionProfileLong("DescWndCY", size.cy);
  1752. }
  1753. void CGetSetOptions::SetShowInTaskBar(BOOL val)
  1754. {
  1755. SetProfileLong(_T("ShowInTaskBar"), val);
  1756. }
  1757. BOOL CGetSetOptions::GetShowInTaskBar()
  1758. {
  1759. return GetProfileLong(_T("ShowInTaskBar"), FALSE);
  1760. }
  1761. void CGetSetOptions::SetDiffApp(CString val)
  1762. {
  1763. SetProfileString(_T("DiffApp"), val);
  1764. }
  1765. CString CGetSetOptions::GetDiffApp()
  1766. {
  1767. return GetProfileString(_T("DiffApp"), _T(""));
  1768. }
  1769. void CGetSetOptions::SetQRCodeBorderPixels(int val)
  1770. {
  1771. SetProfileLong(_T("QRCodeBorderPixels"), val);
  1772. }
  1773. int CGetSetOptions::GetQRCodeBorderPixels()
  1774. {
  1775. return GetProfileLong(_T("QRCodeBorderPixels"), 30);
  1776. }
  1777. CString CGetSetOptions::GetTranslateUrl()
  1778. {
  1779. return GetProfileString(_T("TranslateUrl"), _T("https://translate.google.com/?tl=en#auto/en/%s"));
  1780. }
  1781. void CGetSetOptions::SetNetworkReadTimeoutMS(int val)
  1782. {
  1783. SetProfileLong(_T("NetworkReadTimeoutMS"), val);
  1784. }
  1785. int CGetSetOptions::GetNetworkReadTimeoutMS()
  1786. {
  1787. return GetProfileLong(_T("NetworkReadTimeoutMS"), 30000);
  1788. }
  1789. void CGetSetOptions::SetRequestFilesUsingIP(int val)
  1790. {
  1791. SetProfileLong(_T("RequestFilesUsingIP"), val);
  1792. }
  1793. int CGetSetOptions::GetRequestFilesUsingIP()
  1794. {
  1795. return GetProfileLong(_T("RequestFilesUsingIP"), 0);
  1796. }
  1797. int CGetSetOptions::ReadRandomFileInterval()
  1798. {
  1799. return GetProfileLong(_T("ReadRandomFileInterval"), 60);
  1800. }
  1801. int CGetSetOptions::ReadRandomFileIdleMin()
  1802. {
  1803. return GetProfileLong(_T("ReadRandomFileIdleMin"), 30);
  1804. }
  1805. BOOL CGetSetOptions::GetShowGroupsInMainList()
  1806. {
  1807. return GetProfileLong(_T("ShowGroupsInMainList"), 0);
  1808. }
  1809. void CGetSetOptions::SetShowGroupsInMainList(BOOL val)
  1810. {
  1811. SetProfileLong(_T("ShowGroupsInMainList"), val);
  1812. }
  1813. void CGetSetOptions::SetGroupDoubleClickTimeMS(int val)
  1814. {
  1815. SetProfileLong(_T("GroupDoubleClickTimeMS"), val);
  1816. }
  1817. int CGetSetOptions::GetGroupDoubleClickTimeMS()
  1818. {
  1819. return GetProfileLong(_T("GroupDoubleClickTimeMS"), 500);
  1820. }
  1821. void CGetSetOptions::SetSaveToGroupTimeoutMS(int val)
  1822. {
  1823. SetProfileLong(_T("SaveToGroupTimeoutMS"), val);
  1824. }
  1825. int CGetSetOptions::GetSaveToGroupTimeoutMS()
  1826. {
  1827. return GetProfileLong(_T("SaveToGroupTimeoutMS"), 1000);
  1828. }
  1829. void CGetSetOptions::SetCopyReasonTimeoutMS(int val)
  1830. {
  1831. SetProfileLong(_T("CopyReasonTimeoutMS"), val);
  1832. }
  1833. int CGetSetOptions::GetCopyReasonTimeoutMS()
  1834. {
  1835. return GetProfileLong(_T("CopyReasonTimeoutMS"), 1000);
  1836. }
  1837. void CGetSetOptions::SetWindowsResumeDelayReOpenDbMS(int val)
  1838. {
  1839. SetProfileLong(_T("WindowsResumeDelayReOpenDbMS"), val);
  1840. }
  1841. int CGetSetOptions::GetWindowsResumeDelayReOpenDbMS()
  1842. {
  1843. return GetProfileLong(_T("WindowsResumeDelayReOpenDbMS"), 2000);
  1844. }
  1845. BOOL CGetSetOptions::GetShowMsgWndOnCopyToGroup()
  1846. {
  1847. return GetProfileLong(_T("ShowMsgWndOnCopyToGroup"), TRUE);
  1848. }
  1849. void CGetSetOptions::SetShowMsgWndOnCopyToGroup(BOOL val)
  1850. {
  1851. SetProfileLong(_T("ShowMsgWndOnCopyToGroup"), val);
  1852. }
  1853. int CGetSetOptions::GetActionShortCutA(DWORD action, int pos)
  1854. {
  1855. CString actionText;
  1856. actionText.Format(_T("QP_ShortCut_%d_%d_A"), action, pos);
  1857. int ret = GetProfileLong(actionText, -1);
  1858. if (ret == -1)
  1859. {
  1860. ret = ActionEnums::GetDefaultShortCutKeyA((ActionEnums::ActionEnumValues)action, pos);
  1861. }
  1862. return ret;
  1863. }
  1864. void CGetSetOptions::SetActionShortCutA(int action, DWORD shortcut, int pos)
  1865. {
  1866. CString actionText;
  1867. actionText.Format(_T("QP_ShortCut_%d_%d_A"), action, pos);
  1868. SetProfileLong(actionText, shortcut);
  1869. }
  1870. int CGetSetOptions::GetActionShortCutB(DWORD action, int pos)
  1871. {
  1872. CString actionText;
  1873. actionText.Format(_T("QP_ShortCut_%d_%d_B"), action, pos);
  1874. int ret = GetProfileLong(actionText, -1);
  1875. if (ret == -1)
  1876. {
  1877. ret = ActionEnums::GetDefaultShortCutKeyB((ActionEnums::ActionEnumValues)action, pos);
  1878. }
  1879. return ret;
  1880. }
  1881. void CGetSetOptions::SetActionShortCutB(int action, DWORD shortcut, int pos)
  1882. {
  1883. CString actionText;
  1884. actionText.Format(_T("QP_ShortCut_%d_%d_B"), action, pos);
  1885. SetProfileLong(actionText, shortcut);
  1886. }
  1887. BOOL CGetSetOptions::GetShowAlwaysOnTopWarning()
  1888. {
  1889. return GetProfileLong(_T("ShowAlwaysOnTopWarning"), TRUE);
  1890. }
  1891. void CGetSetOptions::SetShowAlwaysOnTopWarning(BOOL show)
  1892. {
  1893. m_bShowAlwaysOnTopWarning = show;
  1894. SetProfileLong(_T("ShowAlwaysOnTopWarning"), show);
  1895. }
  1896. BOOL CGetSetOptions::GetUseIPFromAccept()
  1897. {
  1898. return GetProfileLong(_T("UseIPFromAccept"), TRUE);
  1899. }
  1900. void CGetSetOptions::SetUseIPFromAccept(BOOL useAccept)
  1901. {
  1902. SetProfileLong(_T("UseIPFromAccept"), useAccept);
  1903. }
  1904. int CGetSetOptions::GetDragId()
  1905. {
  1906. return GetProfileLong(_T("DragId"), 1);
  1907. }
  1908. void CGetSetOptions::SetDragId(int id)
  1909. {
  1910. SetProfileLong(_T("DragId"), id);
  1911. }
  1912. BOOL CGetSetOptions::GetShowIfClipWasPasted()
  1913. {
  1914. return GetProfileLong(_T("ShowIfClipWasPasted"), TRUE);
  1915. }
  1916. void CGetSetOptions::SetShowIfClipWasPasted(BOOL val)
  1917. {
  1918. SetProfileLong(_T("ShowIfClipWasPasted"), val);
  1919. }
  1920. int CGetSetOptions::GetLastGroupToggle()
  1921. {
  1922. return GetProfileLong(_T("LastGroupToggle"), -2);
  1923. }
  1924. void CGetSetOptions::SetLastGroupToggle(int val)
  1925. {
  1926. SetProfileLong(_T("LastGroupToggle"), val);
  1927. }