Options.cpp 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899
  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_bInConversion = false;
  55. bool CGetSetOptions::m_bFromIni = false;
  56. bool CGetSetOptions::m_portable = false;
  57. bool CGetSetOptions::m_windowsApp = false;
  58. bool CGetSetOptions::m_chocolateyApp = false;
  59. CString CGetSetOptions::m_csIniFileName;
  60. __int64 CGetSetOptions::nLastDbWriteTime = 0;
  61. CTheme CGetSetOptions::m_Theme;
  62. BOOL CGetSetOptions::m_showScrollBar = false;
  63. CGetSetOptions g_Opt;
  64. BOOL CGetSetOptions::m_bShowAlwaysOnTopWarning = TRUE;
  65. CRegExFilterHelper CGetSetOptions::m_regexHelper;
  66. BOOL CGetSetOptions::m_excludeCF_DIBInExcel = TRUE;
  67. CChaiScriptXml CGetSetOptions::m_copyScripts;
  68. CChaiScriptXml CGetSetOptions::m_pasteScripts;
  69. long CGetSetOptions::m_tooltipTimeout;
  70. BOOL CGetSetOptions::m_cleanRTFBeforeDrawing = TRUE;
  71. int CGetSetOptions::m_doubleKeyStrokeTimeout = 350;
  72. int CGetSetOptions::m_firstTenHotKeysStart = 1;
  73. int CGetSetOptions::m_firstTenHotKeysFontSize = 5;
  74. BOOL CGetSetOptions::m_moveSelectionOnOpenHotkey = TRUE;
  75. BOOL CGetSetOptions::m_allowBackToBackDuplicates = FALSE;
  76. CGetSetOptions::CGetSetOptions()
  77. {
  78. }
  79. CGetSetOptions::~CGetSetOptions()
  80. {
  81. }
  82. void CGetSetOptions::LoadSettings()
  83. {
  84. CString exeDir = CGetSetOptions::GetExeFileName();
  85. exeDir = GetFilePath(exeDir);
  86. FIX_CSTRING_PATH(exeDir);
  87. CString windowsAppFile = exeDir + _T("WindowsApp");
  88. CString chocolateyAppFile = exeDir + _T("chocolatey");
  89. if (FileExists(windowsAppFile))
  90. {
  91. m_windowsApp = true;
  92. m_bFromIni = true;
  93. //always use the ini file in the app data folder for windows store
  94. m_csIniFileName = GetIniFileName(false);
  95. }
  96. else if (FileExists(chocolateyAppFile))
  97. {
  98. m_chocolateyApp = true;
  99. m_bFromIni = true;
  100. //always use the ini file in the app data folder for chocolatey portable
  101. m_csIniFileName = GetIniFileName(false);
  102. }
  103. else
  104. {
  105. m_csIniFileName = GetIniFileName(true);
  106. CString portable = GetFilePath(m_csIniFileName);
  107. portable += _T("portable");
  108. if (FileExists(portable))
  109. {
  110. m_portable = true;
  111. }
  112. //first check if ini file is in app directory
  113. if (m_portable || FileExists(m_csIniFileName))
  114. {
  115. m_bFromIni = true;
  116. }
  117. else
  118. {
  119. //next check if it's in app data
  120. m_csIniFileName = GetIniFileName(false);
  121. if (FileExists(m_csIniFileName))
  122. {
  123. m_bFromIni = true;
  124. }
  125. }
  126. }
  127. if(m_bFromIni)
  128. {
  129. CString csPath = GetFilePath(m_csIniFileName);
  130. if(FileExists(csPath) == FALSE)
  131. CreateDirectory(csPath, NULL);
  132. //create the ini file as unicode, this way we can save unicode string to the ini file
  133. //http://www.codeproject.com/Articles/9071/Using-Unicode-in-INI-files
  134. CreateIniFile(m_csIniFileName);
  135. }
  136. /*CString cs = GetDBPath();
  137. SetDBPath(_T("some path"));
  138. CString cs2 = GetDBPath();*/
  139. GetSetCurrentDirectory();
  140. //First time we run, set some defaults
  141. if (GetDBPath() == _T("") &&
  142. GetTotalCopyCount() == 0)
  143. {
  144. SetCheckForMaxEntries(TRUE);
  145. SetSimpleTextSearch(TRUE);
  146. }
  147. m_nLinesPerRow = GetLinesPerRow();
  148. m_bUseCtrlNumAccel = GetUseCtrlNumForFirstTenHotKeys();
  149. m_bAllowDuplicates = GetAllowDuplicates();
  150. m_bUpdateTimeOnPaste = GetUpdateTimeOnPaste();
  151. m_bSaveMultiPaste = GetSaveMultiPaste();
  152. m_bShowPersistent = GetShowPersistent();
  153. m_bDescTextSize = GetDescTextSize();
  154. m_bDescShowLeadingWhiteSpace = GetDescShowLeadingWhiteSpace();
  155. m_bAllwaysShowDescription = GetAllwaysShowDescription();
  156. m_bDoubleClickingOnCaptionDoes = GetDoubleClickingOnCaptionDoes();
  157. m_bPrompForNewGroupName = GetPrompForNewGroupName();
  158. m_bSendPasteOnFirstTenHotKeys = GetSendPasteOnFirstTenHotKeys();
  159. m_csIPListToPutOnClipboard = GetListToPutOnClipboard();
  160. m_bLogSendReceiveErrors = GetLogSendReceiveErrors();
  161. m_HideDittoOnHotKeyIfAlreadyShown = GetHideDittoOnHotKeyIfAlreadyShown();
  162. m_lPort = GetPort();
  163. m_bDrawThumbnail = GetDrawThumbnail();
  164. m_csPassword = GetNetworkPassword();
  165. m_bDrawRTF = GetDrawRTF();
  166. m_bMultiPasteReverse = GetMultiPasteReverse();
  167. m_csPlaySoundOnCopy = GetPlaySoundOnCopy();
  168. m_bSendPasteMessageAfterSelection = GetSendPasteAfterSelection();
  169. m_bFindAsYouType = GetFindAsYouType();
  170. m_bEnsureEntireWindowCanBeSeen = GetEnsureEntireWindowCanBeSeen();
  171. m_bShowAllClipsInMainList = GetShowAllClipsInMainList();
  172. m_lMaxClipSizeInBytes = GetMaxClipSizeInBytes();
  173. m_dwSaveClipDelay = GetSaveClipDelay();
  174. m_lProcessDrawClipboardDelay = GetProcessDrawClipboardDelay();
  175. m_bEnableDebugLogging = GetEnableDebugLogging();
  176. m_bEnsureConnectToClipboard = GetEnsureConnectToClipboard();
  177. m_bOutputDebugString = false;
  178. m_showScrollBar = GetShowScrollBar();
  179. m_bShowAlwaysOnTopWarning = GetShowAlwaysOnTopWarning();
  180. m_excludeCF_DIBInExcel = GetExcludeCF_DIBInExcel();
  181. m_doubleKeyStrokeTimeout = GetDoubleKeyStrokeTimeout();
  182. m_firstTenHotKeysStart = GetFirstTenHotKeysStart();
  183. m_firstTenHotKeysFontSize = GetFirstTenHotKeysFontSize();
  184. m_moveSelectionOnOpenHotkey = GetMoveSelectionOnOpenHotkey();
  185. m_allowBackToBackDuplicates = GetAllowBackToBackDuplicates();
  186. GetExtraNetworkPassword(true);
  187. for(int i = 0; i < MAX_SEND_CLIENTS; i++)
  188. {
  189. GetSendClients(i);
  190. }
  191. for (int i = 0; i < MAX_REGEX_FILTERS; i++)
  192. {
  193. CRegExFilterData data;
  194. data.m_regEx = GetRegexFilter(i);
  195. data.m_processFilters = GetRegexFilterByProcessName(i);
  196. m_regexHelper.Add(i, data);
  197. }
  198. GetClientSendCount();
  199. m_Theme.Load(GetTheme());
  200. m_copyScripts.Load(GetCopyScriptsXml());
  201. if (m_copyScripts.m_assignedGuidOnLoad)
  202. {
  203. SetCopyScriptsXml(m_copyScripts.Save());
  204. }
  205. m_pasteScripts.Load(GetPasteScriptsXml());
  206. if (m_pasteScripts.m_assignedGuidOnLoad)
  207. {
  208. SetPasteScriptsXml(m_pasteScripts.Save());
  209. }
  210. m_tooltipTimeout = GetToolTipTimeout();
  211. }
  212. void CGetSetOptions::CreateIniFile(CString path)
  213. {
  214. if (!::PathFileExists(path))
  215. {
  216. // UTF16-LE BOM(FFFE)
  217. WORD wBOM = 0xFEFF;
  218. DWORD NumberOfBytesWritten;
  219. HANDLE hFile = ::CreateFile(path, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
  220. ::WriteFile(hFile, &wBOM, sizeof(WORD), &NumberOfBytesWritten, NULL);
  221. //LPTSTR pszSectionB = _T("[StringTable]"); // section name with bracket
  222. //::WriteFile(hFile, pszSectionB, (_tcslen(pszSectionB) + 1)*(sizeof(TCHAR)), &NumberOfBytesWritten, NULL);
  223. ::CloseHandle(hFile);
  224. }
  225. }
  226. void CGetSetOptions::ConverSettingsToIni()
  227. {
  228. m_bInConversion = true;
  229. CSize sz;
  230. CPoint pt;
  231. GetQuickPasteSize(sz);
  232. SetQuickPasteSize(sz);
  233. GetQuickPastePoint(pt);
  234. SetQuickPastePoint(pt);
  235. GetEditWndSize(sz);
  236. SetEditWndSize(sz);
  237. GetEditWndPoint(pt);
  238. SetEditWndPoint(pt);
  239. SetShowIconInSysTray(GetShowIconInSysTray());
  240. SetRunOnStartUp(GetRunOnStartUp());
  241. SetEnableTransparency(GetEnableTransparency());
  242. SetTransparencyPercent(GetTransparencyPercent());
  243. SetLinesPerRow(GetLinesPerRow());
  244. SetQuickPastePosition(GetQuickPastePosition());
  245. SetCopyGap(GetCopyGap());
  246. SetDBPath(GetDBPath());
  247. SetCheckForMaxEntries(GetCheckForMaxEntries());
  248. SetCheckForExpiredEntries(GetCheckForExpiredEntries());
  249. SetMaxEntries(GetMaxEntries());
  250. SetExpiredEntries(GetExpiredEntries());
  251. SetTripCopyCount(GetTripCopyCount());
  252. SetTripPasteCount(GetTripPasteCount());
  253. SetTripDate(GetTripDate());
  254. SetTotalCopyCount(GetTotalCopyCount());
  255. SetTotalPasteCount(GetTotalPasteCount());
  256. SetTotalDate(GetTotalDate());
  257. SetUpdateFilePath(GetUpdateFilePath());
  258. SetUpdateInstallPath(GetUpdateInstallPath());
  259. SetLastUpdate(GetLastUpdate());
  260. SetCheckForUpdates(GetCheckForUpdates());
  261. SetUseCtrlNumForFirstTenHotKeys(GetUseCtrlNumForFirstTenHotKeys());
  262. SetAllowDuplicates(GetAllowDuplicates());
  263. SetUpdateTimeOnPaste(GetUpdateTimeOnPaste());
  264. SetSaveMultiPaste(GetSaveMultiPaste());
  265. SetShowPersistent(GetShowPersistent());
  266. SetShowTextForFirstTenHotKeys(GetShowTextForFirstTenHotKeys());
  267. SetMainHWND(GetMainHWND());
  268. SetCaptionPos(GetCaptionPos());
  269. SetAutoHide(GetAutoHide());
  270. SetDescTextSize(GetDescTextSize());
  271. SetDescShowLeadingWhiteSpace(GetDescShowLeadingWhiteSpace());
  272. SetAllwaysShowDescription(GetAllwaysShowDescription());
  273. SetDoubleClickingOnCaptionDoes(GetDoubleClickingOnCaptionDoes());
  274. SetPrompForNewGroupName(GetPrompForNewGroupName());
  275. SetSendPasteOnFirstTenHotKeys(GetSendPasteOnFirstTenHotKeys());
  276. for(int i = 0; i < MAX_SEND_CLIENTS; i++)
  277. {
  278. GetSendClients(i);
  279. SetSendClients(m_SendClients[i], i);
  280. }
  281. SetListToPutOnClipboard(GetListToPutOnClipboard());
  282. SetLogSendReceiveErrors(GetLogSendReceiveErrors());
  283. SetHideDittoOnHotKeyIfAlreadyShown(GetHideDittoOnHotKeyIfAlreadyShown());
  284. SetPort(GetPort());
  285. SetDisableRecieve(GetDisableRecieve());
  286. LOGFONT font;
  287. GetFont(font);
  288. SetFont(font);
  289. SetDrawThumbnail(GetDrawThumbnail());
  290. CStringA PassA = GetNetworkPassword();
  291. CString PassW = PassA;
  292. SetNetworkPassword(PassW);
  293. SetDrawRTF(GetDrawRTF());
  294. SetMultiPasteReverse(GetMultiPasteReverse());
  295. SetPlaySoundOnCopy(GetPlaySoundOnCopy());
  296. SetSendPasteAfterSelection(GetSendPasteAfterSelection());
  297. SetFindAsYouType(GetFindAsYouType());
  298. SetEnsureEntireWindowCanBeSeen(GetEnsureEntireWindowCanBeSeen());
  299. SetShowAllClipsInMainList(GetShowAllClipsInMainList());
  300. SetExtraNetworkPassword(GetExtraNetworkPassword(false));
  301. SetMaxClipSizeInBytes(GetMaxClipSizeInBytes());
  302. SetLanguageFile(GetLanguageFile());
  303. SetSaveClipDelay(GetSaveClipDelay());
  304. SetProcessDrawClipboardDelay(GetProcessDrawClipboardDelay());
  305. SetEnableDebugLogging(GetEnableDebugLogging());
  306. SetEnsureConnectToClipboard(GetEnsureConnectToClipboard());
  307. SetPromptWhenDeletingClips(GetPromptWhenDeletingClips());
  308. SetLastImportDir(GetLastImportDir());
  309. SetLastExportDir(GetLastExportDir());
  310. SetUpdateDescWhenSavingClip(GetUpdateDescWhenSavingClip());
  311. m_bInConversion = false;
  312. }
  313. CString CGetSetOptions::GetIniFileName(bool bLocalIniFile)
  314. {
  315. CString csPath = _T("c:\\program files\\Ditto\\");
  316. if(bLocalIniFile)
  317. {
  318. csPath = GetFilePath(GetExeFileName());
  319. }
  320. else
  321. {
  322. csPath = GetAppDataPath();
  323. }
  324. csPath += "Ditto.Settings";
  325. return csPath;
  326. }
  327. CString CGetSetOptions::GetAppDataPath()
  328. {
  329. CString csPath;
  330. LPMALLOC pMalloc;
  331. if (GetIsWindowsApp())
  332. {
  333. if (SUCCEEDED(::SHGetMalloc(&pMalloc)))
  334. {
  335. LPITEMIDLIST pidlPrograms;
  336. SHGetSpecialFolderLocation(NULL, CSIDL_LOCAL_APPDATA, &pidlPrograms);
  337. TCHAR string[MAX_PATH];
  338. SHGetPathFromIDList(pidlPrograms, string);
  339. pMalloc->Free(pidlPrograms);
  340. pMalloc->Release();
  341. csPath = string;
  342. }
  343. FIX_CSTRING_PATH(csPath);
  344. csPath += "Ditto_WindowsApp\\";
  345. }
  346. else if (GetIsChocolateyApp())
  347. {
  348. if (SUCCEEDED(::SHGetMalloc(&pMalloc)))
  349. {
  350. LPITEMIDLIST pidlPrograms;
  351. SHGetSpecialFolderLocation(NULL, CSIDL_LOCAL_APPDATA, &pidlPrograms);
  352. TCHAR string[MAX_PATH];
  353. SHGetPathFromIDList(pidlPrograms, string);
  354. pMalloc->Free(pidlPrograms);
  355. pMalloc->Release();
  356. csPath = string;
  357. }
  358. FIX_CSTRING_PATH(csPath);
  359. csPath += "Ditto_ChocolateyApp\\";
  360. }
  361. else
  362. {
  363. if (SUCCEEDED(::SHGetMalloc(&pMalloc)))
  364. {
  365. LPITEMIDLIST pidlPrograms;
  366. SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidlPrograms);
  367. TCHAR string[MAX_PATH];
  368. SHGetPathFromIDList(pidlPrograms, string);
  369. pMalloc->Free(pidlPrograms);
  370. pMalloc->Release();
  371. csPath = string;
  372. }
  373. FIX_CSTRING_PATH(csPath);
  374. csPath += "Ditto\\";
  375. }
  376. return csPath;
  377. }
  378. CString CGetSetOptions::GetTempFilePath()
  379. {
  380. CString csPath;
  381. wchar_t wchPath[MAX_PATH];
  382. if (GetTempPathW(MAX_PATH, wchPath))
  383. {
  384. csPath = wchPath;
  385. csPath += _T("Ditto\\");
  386. CreateDirectory(csPath, NULL);
  387. }
  388. return csPath;
  389. }
  390. long CGetSetOptions::GetResolutionProfileLong(CString csName, long lDefaultValue, CString csNewPath)
  391. {
  392. CString resName;
  393. resName.Format(_T("(%dx%d)_%s"), GetScreenWidth(), GetScreenHeight(), csName);
  394. long value = GetProfileLong(resName, INT_MIN, csNewPath);
  395. if(value == INT_MIN)
  396. {
  397. value = GetProfileLong(csName, lDefaultValue, csNewPath);
  398. }
  399. return value;
  400. }
  401. BOOL CGetSetOptions::SetResolutionProfileLong(CString csName, long lValue)
  402. {
  403. CString resName;
  404. resName.Format(_T("(%dx%d)_%s"), GetScreenWidth(), GetScreenHeight(), csName);
  405. return SetProfileLong(resName, lValue);
  406. }
  407. long CGetSetOptions::GetProfileLong(CString csName, long lDefaultValue, CString csNewPath)
  408. {
  409. if(m_bFromIni && !m_bInConversion)
  410. {
  411. CString csApp(_T("Ditto"));
  412. if(csNewPath.IsEmpty() == FALSE)
  413. {
  414. csApp = csNewPath;
  415. }
  416. return GetPrivateProfileInt(csApp, csName, lDefaultValue, m_csIniFileName);
  417. }
  418. CString csPath(_T(REG_PATH));
  419. if(csNewPath.IsEmpty() == FALSE)
  420. {
  421. csPath += "\\" + csNewPath;
  422. }
  423. HKEY hkKey;
  424. long lResult = RegOpenKeyEx(HKEY_CURRENT_USER, csPath, NULL, KEY_READ, &hkKey);
  425. if(lResult != ERROR_SUCCESS)
  426. return lDefaultValue;
  427. DWORD buffer;
  428. DWORD len = sizeof(buffer);
  429. DWORD type;
  430. lResult = ::RegQueryValueEx(hkKey, csName, 0, &type, (LPBYTE)&buffer, &len);
  431. RegCloseKey(hkKey);
  432. if(lResult == ERROR_SUCCESS)
  433. return (long)buffer;
  434. return lDefaultValue;
  435. }
  436. CString CGetSetOptions::GetProfileString(CString csName, CString csDefault, CString csNewPath, int maxSize)
  437. {
  438. CString returnString;
  439. DWORD dwBufLen = 0;
  440. if(m_bFromIni && !m_bInConversion)
  441. {
  442. CString csApp(_T("Ditto"));
  443. if(csNewPath.IsEmpty() == FALSE)
  444. {
  445. csApp = csNewPath;
  446. }
  447. bool doBreak = false;
  448. dwBufLen = 10000;
  449. bool setMaxSize = false;
  450. while (true)
  451. {
  452. if (maxSize > -1 && maxSize < dwBufLen)
  453. {
  454. dwBufLen = maxSize;
  455. setMaxSize = true;
  456. }
  457. TCHAR *szString = new TCHAR[dwBufLen];
  458. ZeroMemory(szString, dwBufLen);
  459. DWORD readLength = GetPrivateProfileString(csApp, csName, csDefault, szString, dwBufLen, m_csIniFileName);
  460. if (setMaxSize ||
  461. readLength < (dwBufLen - 1))
  462. {
  463. returnString = szString;
  464. doBreak = true; //delay break so we can delete the string
  465. }
  466. delete[] szString;
  467. dwBufLen = dwBufLen * 2;
  468. if (doBreak)
  469. {
  470. break;
  471. }
  472. }
  473. return returnString;
  474. }
  475. CString csPath(_T(REG_PATH));
  476. if(csNewPath.IsEmpty() == FALSE)
  477. {
  478. csPath += "\\" + csNewPath;
  479. }
  480. HKEY hkKey;
  481. long lResult = RegOpenKeyEx(HKEY_CURRENT_USER, csPath, NULL, KEY_READ, &hkKey);
  482. if (lResult == ERROR_SUCCESS)
  483. {
  484. lResult = ::RegQueryValueEx(hkKey, csName, NULL, NULL, NULL, &dwBufLen);
  485. if (lResult == ERROR_SUCCESS &&
  486. dwBufLen > 0)
  487. {
  488. if (maxSize > -1 && maxSize < dwBufLen)
  489. {
  490. dwBufLen = maxSize;
  491. }
  492. dwBufLen++;
  493. TCHAR *szString = new TCHAR[dwBufLen];
  494. ZeroMemory(szString, dwBufLen);
  495. lResult = ::RegQueryValueEx(hkKey, csName, NULL, NULL, (LPBYTE)szString, &dwBufLen);
  496. returnString = szString;
  497. delete[] szString;
  498. }
  499. RegCloseKey(hkKey);
  500. }
  501. if(lResult != ERROR_SUCCESS)
  502. return csDefault;
  503. return returnString;
  504. }
  505. BOOL CGetSetOptions::SetProfileLong(CString csName, long lValue)
  506. {
  507. if(m_bFromIni)
  508. {
  509. return WritePrivateProfileInt(_T("Ditto"), csName, lValue, m_csIniFileName);
  510. }
  511. HKEY hkKey;
  512. DWORD dWord;
  513. long lResult = RegCreateKeyEx(HKEY_CURRENT_USER, _T(REG_PATH), NULL,
  514. NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
  515. NULL, &hkKey, &dWord);
  516. if(lResult != ERROR_SUCCESS)
  517. return FALSE;
  518. DWORD val = (DWORD)lValue;
  519. lResult = ::RegSetValueEx(hkKey, csName, 0, REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
  520. RegCloseKey(hkKey);
  521. return lResult == ERROR_SUCCESS;
  522. }
  523. BOOL CGetSetOptions::SetProfileString(CString csName, CString csValue)
  524. {
  525. if(m_bFromIni)
  526. {
  527. return WritePrivateProfileString(_T("Ditto"), csName, csValue, m_csIniFileName);
  528. }
  529. HKEY hkKey;
  530. DWORD dWord;
  531. long lResult = RegCreateKeyEx(HKEY_CURRENT_USER, _T(REG_PATH), NULL,
  532. NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
  533. NULL, &hkKey, &dWord);
  534. if(lResult != ERROR_SUCCESS)
  535. return FALSE;
  536. ::RegSetValueEx(hkKey, csName, NULL, REG_SZ,
  537. (BYTE*)(LPCTSTR)csValue, csValue.GetLength()*sizeof(TCHAR));
  538. RegCloseKey(hkKey);
  539. return lResult == ERROR_SUCCESS;
  540. }
  541. BOOL CGetSetOptions::SetProfileData(CString csName, LPVOID lpData, DWORD dwLength)
  542. {
  543. if(m_bFromIni)
  544. {
  545. ASSERT(!"SetProfileData not supported in .ini settings");
  546. return FALSE;
  547. }
  548. HKEY hkKey;
  549. DWORD dWord;
  550. long lResult = RegCreateKeyEx(HKEY_CURRENT_USER, _T(REG_PATH), NULL,
  551. NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
  552. NULL, &hkKey, &dWord);
  553. if(lResult != ERROR_SUCCESS)
  554. return FALSE;
  555. ::RegSetValueEx(hkKey, csName, NULL, REG_BINARY,
  556. (BYTE*)lpData, dwLength);
  557. RegCloseKey(hkKey);
  558. return lResult == ERROR_SUCCESS;
  559. }
  560. BOOL CGetSetOptions::GetProfileFont(CString csSection, LOGFONT &font)
  561. {
  562. font.lfHeight = GetPrivateProfileInt(csSection, _T("Height"), 0, m_csIniFileName);
  563. font.lfWidth = GetPrivateProfileInt(csSection, _T("Width"), 0, m_csIniFileName);
  564. font.lfEscapement = GetPrivateProfileInt(csSection, _T("Escapement"), 0, m_csIniFileName);
  565. font.lfOrientation = GetPrivateProfileInt(csSection, _T("Orientation"), 0, m_csIniFileName);
  566. font.lfWeight = GetPrivateProfileInt(csSection, _T("Weight"), 0, m_csIniFileName);
  567. font.lfItalic = GetPrivateProfileInt(csSection, _T("Italic"), 0, m_csIniFileName);
  568. font.lfUnderline = GetPrivateProfileInt(csSection, _T("Underline"), 0, m_csIniFileName);
  569. font.lfStrikeOut = GetPrivateProfileInt(csSection, _T("StrikeOut"), 0, m_csIniFileName);
  570. font.lfCharSet = GetPrivateProfileInt(csSection, _T("CharSet"), 0, m_csIniFileName);
  571. font.lfOutPrecision = GetPrivateProfileInt(csSection, _T("OutPrecision"), 0, m_csIniFileName);
  572. font.lfClipPrecision = GetPrivateProfileInt(csSection, _T("ClipPrecision"), 0, m_csIniFileName);
  573. font.lfQuality = GetPrivateProfileInt(csSection, _T("Quality"), 0, m_csIniFileName);
  574. font.lfPitchAndFamily = GetPrivateProfileInt(csSection, _T("PitchAndFamily"), 0, m_csIniFileName);
  575. GetPrivateProfileString(csSection, _T("FaceName"), _T(""), font.lfFaceName, sizeof(font.lfFaceName), m_csIniFileName);
  576. return TRUE;
  577. }
  578. BOOL CGetSetOptions::SetProfileFont(CString csSection, LOGFONT &font)
  579. {
  580. WritePrivateProfileInt(csSection, _T("Height"), font.lfHeight, m_csIniFileName);
  581. WritePrivateProfileInt(csSection, _T("Width"), font.lfWidth, m_csIniFileName);
  582. WritePrivateProfileInt(csSection, _T("Escapement"), font.lfEscapement, m_csIniFileName);
  583. WritePrivateProfileInt(csSection, _T("Orientation"), font.lfOrientation, m_csIniFileName);
  584. WritePrivateProfileInt(csSection, _T("Weight"), font.lfWeight, m_csIniFileName);
  585. WritePrivateProfileInt(csSection, _T("Italic"), font.lfItalic, m_csIniFileName);
  586. WritePrivateProfileInt(csSection, _T("Underline"), font.lfUnderline, m_csIniFileName);
  587. WritePrivateProfileInt(csSection, _T("StrikeOut"), font.lfStrikeOut, m_csIniFileName);
  588. WritePrivateProfileInt(csSection, _T("CharSet"), font.lfCharSet, m_csIniFileName);
  589. WritePrivateProfileInt(csSection, _T("OutPrecision"), font.lfOutPrecision, m_csIniFileName);
  590. WritePrivateProfileInt(csSection, _T("ClipPrecision"), font.lfClipPrecision, m_csIniFileName);
  591. WritePrivateProfileInt(csSection, _T("Quality"), font.lfQuality, m_csIniFileName);
  592. WritePrivateProfileInt(csSection, _T("PitchAndFamily"), font.lfPitchAndFamily, m_csIniFileName);
  593. WritePrivateProfileString(csSection, _T("FaceName"), font.lfFaceName, m_csIniFileName);
  594. return TRUE;
  595. }
  596. LPVOID CGetSetOptions::GetProfileData(CString csName, DWORD &dwLength)
  597. {
  598. if(m_bFromIni && !m_bInConversion)
  599. {
  600. ASSERT(!"GetProfileData not supported in .ini settings");
  601. return NULL;
  602. }
  603. HKEY hkKey;
  604. long lResult = RegOpenKeyEx(HKEY_CURRENT_USER, _T(REG_PATH),
  605. NULL, KEY_READ, &hkKey);
  606. lResult = ::RegQueryValueEx(hkKey , csName, NULL, NULL, NULL, &dwLength);
  607. if(lResult != ERROR_SUCCESS)
  608. return NULL;
  609. LPVOID lpVoid = new BYTE[dwLength];
  610. lResult = ::RegQueryValueEx(hkKey , csName, NULL, NULL, (LPBYTE)lpVoid, &dwLength);
  611. RegCloseKey(hkKey);
  612. if(lResult != ERROR_SUCCESS)
  613. return NULL;
  614. return lpVoid;
  615. }
  616. BOOL CGetSetOptions::GetShowIconInSysTray()
  617. {
  618. return GetProfileLong("ShowIconInSystemTray", TRUE);
  619. }
  620. BOOL CGetSetOptions::SetShowIconInSysTray(BOOL bShow)
  621. {
  622. return SetProfileLong("ShowIconInSystemTray", bShow);
  623. }
  624. BOOL CGetSetOptions::SetEnableTransparency(BOOL bCheck)
  625. {
  626. return SetProfileLong("EnableTransparency", bCheck);
  627. }
  628. BOOL CGetSetOptions::GetEnableTransparency()
  629. {
  630. return GetProfileLong("EnableTransparency", FALSE);
  631. }
  632. BOOL CGetSetOptions::SetTransparencyPercent(long lPercent)
  633. {
  634. if(lPercent > OPACITY_MAX)
  635. lPercent = OPACITY_MAX;
  636. if(lPercent < 0)
  637. lPercent = 0;
  638. return SetProfileLong("TransparencyPercent", lPercent);
  639. }
  640. long CGetSetOptions::GetTransparencyPercent()
  641. {
  642. long lValue = GetProfileLong("TransparencyPercent", 14);
  643. if(lValue > OPACITY_MAX) lValue = OPACITY_MAX;
  644. if(lValue < 0) lValue = 0;
  645. return lValue;
  646. }
  647. BOOL CGetSetOptions::SetLinesPerRow(long lLines)
  648. {
  649. m_nLinesPerRow = lLines;
  650. return SetProfileLong("LinesPerRow", lLines);
  651. }
  652. long CGetSetOptions::GetLinesPerRow()
  653. {
  654. return GetProfileLong("LinesPerRow", 2);
  655. }
  656. BOOL CGetSetOptions::GetRunOnStartUp()
  657. {
  658. HKEY hkRun;
  659. LONG nResult = RegOpenKeyEx(HKEY_CURRENT_USER,
  660. _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"),
  661. NULL, KEY_READ, &hkRun);
  662. if(nResult != ERROR_SUCCESS)
  663. return FALSE;
  664. nResult = RegQueryValueEx(hkRun, GetAppName(), NULL, NULL, NULL, NULL);
  665. RegCloseKey(hkRun);
  666. return nResult == ERROR_SUCCESS;
  667. }
  668. void CGetSetOptions::SetRunOnStartUp(BOOL bRun)
  669. {
  670. HKEY hkRun;
  671. LONG nResult = RegOpenKeyEx(HKEY_CURRENT_USER,
  672. _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"),
  673. NULL, KEY_ALL_ACCESS, &hkRun);
  674. if(nResult != ERROR_SUCCESS)
  675. return;
  676. if(bRun)
  677. {
  678. CString sExeName = GetExeFileName();
  679. ::RegSetValueEx(hkRun, GetAppName(), NULL, REG_SZ,
  680. (BYTE*)(LPCTSTR)sExeName, sExeName.GetLength()*sizeof(TCHAR));
  681. }
  682. else
  683. {
  684. ::RegDeleteValue(hkRun, GetAppName());
  685. }
  686. ::RegCloseKey(hkRun);
  687. }
  688. CString CGetSetOptions::GetExeFileName()
  689. {
  690. CString sExeName;
  691. GetModuleFileName(NULL, sExeName.GetBuffer(_MAX_PATH),_MAX_PATH);
  692. sExeName.ReleaseBuffer();
  693. return sExeName;
  694. }
  695. CString CGetSetOptions::GetAppName()
  696. {
  697. return "Ditto";
  698. }
  699. BOOL CGetSetOptions::SetQuickPastePosition(long lPosition)
  700. {
  701. return SetProfileLong("ShowQuickPastePosition", lPosition);
  702. }
  703. long CGetSetOptions::GetQuickPastePosition()
  704. {
  705. return GetProfileLong("ShowQuickPastePosition", POS_AT_CARET);
  706. }
  707. BOOL CGetSetOptions::SetQuickPasteSize(CSize size)
  708. {
  709. BOOL bRet = SetResolutionProfileLong("QuickPasteCX", size.cx);
  710. bRet = SetResolutionProfileLong("QuickPasteCY", size.cy);
  711. return bRet;
  712. }
  713. void CGetSetOptions::GetQuickPasteSize(CSize &size)
  714. {
  715. size.cx = GetResolutionProfileLong("QuickPasteCX", 300);
  716. size.cy = GetResolutionProfileLong("QuickPasteCY", 300);
  717. if(size.cx <= 0 && size.cy <= 0)
  718. {
  719. size.cx = 300;
  720. size.cy = 300;
  721. }
  722. }
  723. BOOL CGetSetOptions::SetQuickPastePoint(CPoint point)
  724. {
  725. BOOL bRet = SetResolutionProfileLong("QuickPasteX", point.x);
  726. bRet = SetResolutionProfileLong("QuickPasteY", point.y);
  727. return bRet;
  728. }
  729. void CGetSetOptions::GetQuickPastePoint(CPoint &point)
  730. {
  731. point.x = GetResolutionProfileLong("QuickPasteX", 300);
  732. point.y = GetResolutionProfileLong("QuickPasteY", 300);
  733. /*if(point.x <= 0 && point.y <= 0)
  734. {
  735. point.x = 300;
  736. point.y = 300;
  737. }*/
  738. }
  739. BOOL CGetSetOptions::SetEditWndSize(CSize size)
  740. {
  741. BOOL bRet = SetResolutionProfileLong("EditWndCX", size.cx);
  742. bRet = SetResolutionProfileLong("EditWndCY", size.cy);
  743. return bRet;
  744. }
  745. void CGetSetOptions::GetEditWndSize(CSize &size)
  746. {
  747. size.cx = GetResolutionProfileLong("EditWndCX", 600);
  748. size.cy = GetResolutionProfileLong("EditWndCY", 600);
  749. if(size.cx <= 0 && size.cy <= 0)
  750. {
  751. size.cx = 600;
  752. size.cy = 600;
  753. }
  754. }
  755. BOOL CGetSetOptions::SetEditWndPoint(CPoint point)
  756. {
  757. BOOL bRet = SetResolutionProfileLong("EditWndX", point.x);
  758. bRet = SetResolutionProfileLong("EditWndY", point.y);
  759. return bRet;
  760. }
  761. void CGetSetOptions::GetEditWndPoint(CPoint &point)
  762. {
  763. point.x = GetResolutionProfileLong("EditWndX", 100);
  764. point.y = GetResolutionProfileLong("EditWndY", 100);
  765. if(point.x <= 0 && point.y <= 0)
  766. {
  767. point.x = 100;
  768. point.y = 100;
  769. }
  770. }
  771. long CGetSetOptions::GetCopyGap()
  772. {
  773. return GetProfileLong("CopyGap", 150);
  774. }
  775. void CGetSetOptions::SetCopyGap(long lGap)
  776. {
  777. SetProfileLong("CopyGap", lGap);
  778. }
  779. BOOL CGetSetOptions::SetDBPathOld(CString csPath)
  780. {
  781. return SetProfileString("DBPath", csPath);
  782. }
  783. CString CGetSetOptions::GetDBPathOld()
  784. {
  785. return GetProfileString("DBPath", "");
  786. }
  787. BOOL CGetSetOptions::SetDBPath(CString csPath)
  788. {
  789. return SetProfileString("DBPath3", csPath);
  790. }
  791. CString CGetSetOptions::ResolvePath(CString path)
  792. {
  793. CString dest;
  794. int newSize = max(path.GetLength() * 10, 1000);
  795. //path = _T("some string %COMPUTERNAME% test");
  796. ExpandEnvironmentStrings(path, dest.GetBuffer(newSize), newSize);
  797. dest.ReleaseBuffer();
  798. return dest;
  799. }
  800. CString CGetSetOptions::GetDBPath(bool resolvePath)
  801. {
  802. CString csDBPath;
  803. csDBPath = GetProfileString("DBPath3", "");
  804. if (resolvePath)
  805. {
  806. csDBPath = ResolvePath(csDBPath);
  807. }
  808. return csDBPath;
  809. }
  810. void CGetSetOptions::SetCheckForMaxEntries(BOOL bVal)
  811. {
  812. SetProfileLong("CheckForMaxEntries", bVal);
  813. }
  814. BOOL CGetSetOptions::GetCheckForMaxEntries()
  815. {
  816. BOOL bDefault = FALSE;
  817. if(GetIsPortableDitto())
  818. bDefault = TRUE;
  819. return GetProfileLong("CheckForMaxEntries", bDefault);
  820. }
  821. void CGetSetOptions::SetCheckForExpiredEntries(BOOL bVal)
  822. {
  823. SetProfileLong("CheckForExpiredEntries", bVal);
  824. }
  825. BOOL CGetSetOptions::GetCheckForExpiredEntries()
  826. {
  827. return GetProfileLong("CheckForExpiredEntries", FALSE);
  828. }
  829. void CGetSetOptions::SetMaxEntries(long lVal)
  830. {
  831. SetProfileLong("MaxEntries", lVal);
  832. }
  833. long CGetSetOptions::GetMaxEntries()
  834. {
  835. long lMax = 500;
  836. if(GetIsPortableDitto())
  837. lMax = 100;
  838. return GetProfileLong("MaxEntries", lMax);
  839. }
  840. void CGetSetOptions::SetExpiredEntries(long lVal)
  841. {
  842. SetProfileLong("ExpiredEntries", lVal);
  843. }
  844. long CGetSetOptions::GetExpiredEntries()
  845. {
  846. return GetProfileLong("ExpiredEntries", 5);
  847. }
  848. void CGetSetOptions::SetTripCopyCount(long lVal)
  849. {
  850. // negative means a relative offset
  851. if(lVal < 0)
  852. lVal = GetTripCopyCount() - lVal; // add the absolute value
  853. if(GetTripDate() == 0)
  854. SetTripDate(-1);
  855. SetProfileLong("TripCopies", lVal);
  856. }
  857. long CGetSetOptions::GetTripCopyCount()
  858. {
  859. return GetProfileLong("TripCopies", 0);
  860. }
  861. void CGetSetOptions::SetTripPasteCount(long lVal)
  862. {
  863. // negative means a relative offset
  864. if(lVal < 0)
  865. lVal = GetTripPasteCount() - lVal; // add the absolute value
  866. if(GetTripDate() == 0)
  867. SetTripDate(-1);
  868. SetProfileLong("TripPastes", lVal);
  869. }
  870. long CGetSetOptions::GetTripPasteCount()
  871. {
  872. return GetProfileLong("TripPastes", 0);
  873. }
  874. void CGetSetOptions::SetTripDate(long lDate)
  875. {
  876. if(lDate == -1)
  877. lDate = (long)CTime::GetCurrentTime().GetTime();
  878. SetProfileLong("TripDate", lDate);
  879. }
  880. long CGetSetOptions::GetTripDate()
  881. {
  882. return GetProfileLong("TripDate", 0);
  883. }
  884. void CGetSetOptions::SetTotalCopyCount(long lVal)
  885. {
  886. // negative means a relative offset
  887. if(lVal < 0)
  888. lVal = GetTotalCopyCount() - lVal; // add the absolute value
  889. if(GetTotalDate() == 0)
  890. SetTotalDate(-1);
  891. SetProfileLong("TotalCopies", lVal);
  892. }
  893. long CGetSetOptions::GetTotalCopyCount()
  894. {
  895. return GetProfileLong("TotalCopies", 0);
  896. }
  897. void CGetSetOptions::SetTotalPasteCount(long lVal)
  898. {
  899. // negative means a relative offset
  900. if(lVal < 0)
  901. lVal = GetTotalPasteCount() - lVal; // add the absolute value
  902. if(GetTotalDate() == 0)
  903. SetTotalDate(-1);
  904. SetProfileLong("TotalPastes", lVal);
  905. }
  906. long CGetSetOptions::GetTotalPasteCount()
  907. {
  908. return GetProfileLong("TotalPastes", 0);
  909. }
  910. void CGetSetOptions::SetTotalDate(long lDate)
  911. {
  912. if(lDate == -1)
  913. lDate = (long)CTime::GetCurrentTime().GetTime();
  914. SetProfileLong("TotalDate", lDate);
  915. }
  916. long CGetSetOptions::GetTotalDate()
  917. {
  918. return GetProfileLong("TotalDate", 0);
  919. }
  920. CString CGetSetOptions::GetUpdateFilePath()
  921. {
  922. return GetProfileString("UpdateFilePath", "");
  923. }
  924. BOOL CGetSetOptions::SetUpdateFilePath(CString cs)
  925. {
  926. return SetProfileString("UpdateFilePath", cs);
  927. }
  928. CString CGetSetOptions::GetUpdateInstallPath()
  929. {
  930. return GetProfileString("UpdateInstallPath", "");
  931. }
  932. BOOL CGetSetOptions::SetUpdateInstallPath(CString cs)
  933. {
  934. return SetProfileString("UpdateInstallPath", cs);
  935. }
  936. long CGetSetOptions::GetLastUpdate()
  937. {
  938. return GetProfileLong("LastUpdateDay", 0);
  939. }
  940. long CGetSetOptions::SetLastUpdate(long lValue)
  941. {
  942. return SetProfileLong("LastUpdateDay", lValue);
  943. }
  944. BOOL CGetSetOptions::GetCheckForUpdates()
  945. {
  946. return GetProfileLong("CheckForUpdates", TRUE);
  947. }
  948. BOOL CGetSetOptions::SetCheckForUpdates(BOOL bCheck)
  949. {
  950. return SetProfileLong("CheckForUpdates", bCheck);
  951. }
  952. void CGetSetOptions::SetUseCtrlNumForFirstTenHotKeys(BOOL bVal)
  953. {
  954. SetProfileLong("UseCtrlNumForFirstTenHotKeys", bVal);
  955. m_bUseCtrlNumAccel = bVal;
  956. }
  957. BOOL CGetSetOptions::GetUseCtrlNumForFirstTenHotKeys()
  958. {
  959. return GetProfileLong("UseCtrlNumForFirstTenHotKeys", 0);
  960. }
  961. void CGetSetOptions::SetAllowDuplicates(BOOL bVal)
  962. {
  963. SetProfileLong("AllowDuplicates", bVal);
  964. m_bAllowDuplicates = bVal;
  965. }
  966. BOOL CGetSetOptions::GetAllowDuplicates()
  967. {
  968. return GetProfileLong("AllowDuplicates", 0);
  969. }
  970. void CGetSetOptions::SetUpdateTimeOnPaste(BOOL bVal)
  971. {
  972. SetProfileLong("UpdateTimeOnPaste", bVal);
  973. m_bUpdateTimeOnPaste = bVal;
  974. }
  975. BOOL CGetSetOptions::GetUpdateTimeOnPaste()
  976. {
  977. return GetProfileLong("UpdateTimeOnPaste", TRUE);
  978. }
  979. void CGetSetOptions::SetSaveMultiPaste(BOOL bVal)
  980. {
  981. SetProfileLong("SaveMultiPaste", bVal);
  982. m_bSaveMultiPaste = bVal;
  983. }
  984. BOOL CGetSetOptions::GetSaveMultiPaste()
  985. {
  986. return GetProfileLong("SaveMultiPaste", 0);
  987. }
  988. void CGetSetOptions::SetShowPersistent(BOOL bVal)
  989. {
  990. SetProfileLong("ShowPersistent", bVal);
  991. m_bShowPersistent = bVal;
  992. }
  993. BOOL CGetSetOptions::GetShowPersistent()
  994. {
  995. return GetProfileLong("ShowPersistent", 0);
  996. }
  997. void CGetSetOptions::SetShowTextForFirstTenHotKeys(BOOL bVal)
  998. {
  999. SetProfileLong("ShowTextForFirstTenHotKeys", bVal);
  1000. }
  1001. BOOL CGetSetOptions::GetShowTextForFirstTenHotKeys()
  1002. {
  1003. return GetProfileLong("ShowTextForFirstTenHotKeys", TRUE);
  1004. }
  1005. void CGetSetOptions::SetMainHWND(long lhWnd)
  1006. {
  1007. SetProfileLong("MainhWnd", lhWnd);
  1008. }
  1009. long CGetSetOptions::GetMainHWND()
  1010. {
  1011. return GetProfileLong("MainhWnd", 0);
  1012. }
  1013. void CGetSetOptions::SetCaptionPos(long lPos)
  1014. {
  1015. SetProfileLong("CaptionPos", lPos);
  1016. }
  1017. long CGetSetOptions::GetCaptionPos()
  1018. {
  1019. return GetProfileLong("CaptionPos", CAPTION_RIGHT);
  1020. }
  1021. void CGetSetOptions::SetAutoHide(BOOL bAutoHide)
  1022. {
  1023. SetProfileLong("AutoHide", bAutoHide);
  1024. }
  1025. BOOL CGetSetOptions::GetAutoHide()
  1026. {
  1027. return GetProfileLong("AutoHide", FALSE);
  1028. }
  1029. void CGetSetOptions::SetDescTextSize(long lSize)
  1030. {
  1031. SetProfileLong("DescTextSize", lSize);
  1032. m_bDescTextSize = lSize;
  1033. }
  1034. long CGetSetOptions::GetDescTextSize()
  1035. {
  1036. return GetProfileLong("DescTextSize", 500);
  1037. }
  1038. void CGetSetOptions::SetDescShowLeadingWhiteSpace(BOOL bVal)
  1039. {
  1040. SetProfileLong("DescShowLeadingWhiteSpace", bVal);
  1041. m_bDescShowLeadingWhiteSpace = bVal;
  1042. }
  1043. BOOL CGetSetOptions::GetDescShowLeadingWhiteSpace()
  1044. {
  1045. return GetProfileLong("DescShowLeadingWhiteSpace", FALSE);
  1046. }
  1047. void CGetSetOptions::SetAllwaysShowDescription(long bShow)
  1048. {
  1049. SetProfileLong("AllwaysShowDescription", bShow);
  1050. m_bAllwaysShowDescription = bShow;
  1051. }
  1052. BOOL CGetSetOptions::GetAllwaysShowDescription()
  1053. {
  1054. return GetProfileLong("AllwaysShowDescription", FALSE);
  1055. }
  1056. void CGetSetOptions::SetDoubleClickingOnCaptionDoes(long lOption)
  1057. {
  1058. SetProfileLong("DoubleClickingOnCaptionDoes", lOption);
  1059. m_bDoubleClickingOnCaptionDoes = lOption;
  1060. }
  1061. long CGetSetOptions::GetDoubleClickingOnCaptionDoes()
  1062. {
  1063. return GetProfileLong("DoubleClickingOnCaptionDoes", TOGGLES_ALLWAYS_ON_TOP);
  1064. }
  1065. void CGetSetOptions::SetPrompForNewGroupName(BOOL bOption)
  1066. {
  1067. SetProfileLong("PrompForNewGroupName", bOption);
  1068. m_bPrompForNewGroupName = bOption;
  1069. }
  1070. BOOL CGetSetOptions::GetPrompForNewGroupName()
  1071. {
  1072. return GetProfileLong("PrompForNewGroupName", TRUE);
  1073. }
  1074. void CGetSetOptions::SetSendPasteOnFirstTenHotKeys(BOOL bOption)
  1075. {
  1076. SetProfileLong("SendPasteOnFirstTenHotKeys", bOption);
  1077. m_bSendPasteOnFirstTenHotKeys = bOption;
  1078. }
  1079. BOOL CGetSetOptions::GetSendPasteOnFirstTenHotKeys()
  1080. {
  1081. return GetProfileLong("SendPasteOnFirstTenHotKeys", TRUE);
  1082. }
  1083. void CGetSetOptions::SetSendClients(CSendClients Client, int nPos)
  1084. {
  1085. CString cs;
  1086. cs.Format(_T("sendclient_ip_%d"), nPos);
  1087. SetProfileString(cs, Client.csIP);
  1088. cs.Format(_T("sendclient_autosend_%d"), nPos);
  1089. SetProfileLong(cs, Client.bSendAll);
  1090. cs.Format(_T("sendclient_description_%d"), nPos);
  1091. SetProfileString(cs, Client.csDescription);
  1092. Client.bShownFirstError = m_SendClients[nPos].bShownFirstError;
  1093. m_SendClients[nPos] = Client;
  1094. }
  1095. CSendClients CGetSetOptions::GetSendClients(int nPos)
  1096. {
  1097. CSendClients Client;
  1098. CString cs;
  1099. cs.Format(_T("sendclient_ip_%d"), nPos);
  1100. Client.csIP = GetProfileString(cs, "");
  1101. cs.Format(_T("sendclient_autosend_%d"), nPos);
  1102. Client.bSendAll = GetProfileLong(cs, FALSE);
  1103. cs.Format(_T("sendclient_description_%d"), nPos);
  1104. Client.csDescription = GetProfileString(cs, "");
  1105. m_SendClients[nPos] = Client;
  1106. return Client;
  1107. }
  1108. void CGetSetOptions::GetClientSendCount()
  1109. {
  1110. m_lAutoSendClientCount = 0;
  1111. for(int i = 0; i < MAX_SEND_CLIENTS; i++)
  1112. {
  1113. if(m_SendClients[i].csIP.GetLength() > 0)
  1114. {
  1115. if(m_SendClients[i].bSendAll)
  1116. m_lAutoSendClientCount++;
  1117. }
  1118. }
  1119. }
  1120. CString CGetSetOptions::GetListToPutOnClipboard()
  1121. {
  1122. CString cs = GetProfileString("ListToPutOnClipboard", "");
  1123. cs.MakeUpper();
  1124. return cs;
  1125. }
  1126. BOOL CGetSetOptions::SetListToPutOnClipboard(CString cs)
  1127. {
  1128. cs.MakeUpper();
  1129. m_csIPListToPutOnClipboard = cs;
  1130. return SetProfileString("ListToPutOnClipboard", cs);
  1131. }
  1132. void CGetSetOptions::SetLogSendReceiveErrors(BOOL bOption)
  1133. {
  1134. m_bLogSendReceiveErrors = bOption;
  1135. SetProfileLong("LogSendReceiveErrors", bOption);
  1136. }
  1137. BOOL CGetSetOptions::GetLogSendReceiveErrors()
  1138. {
  1139. return GetProfileLong("LogSendReceiveErrors", FALSE);
  1140. }
  1141. BOOL CGetSetOptions::GetHideDittoOnHotKeyIfAlreadyShown()
  1142. {
  1143. return GetProfileLong("HideDittoOnHotKeyIfAlreadyShown", TRUE);
  1144. }
  1145. void CGetSetOptions::SetHideDittoOnHotKeyIfAlreadyShown(BOOL bVal)
  1146. {
  1147. m_HideDittoOnHotKeyIfAlreadyShown = bVal;
  1148. SetProfileLong("HideDittoOnHotKeyIfAlreadyShown", bVal);
  1149. }
  1150. void CGetSetOptions::SetPort(long lPort)
  1151. {
  1152. m_lPort = lPort;
  1153. SetProfileLong("SendRecvPort", lPort);
  1154. }
  1155. long CGetSetOptions::GetPort()
  1156. {
  1157. return GetProfileLong("SendRecvPort", 23443);
  1158. }
  1159. BOOL CGetSetOptions::GetDisableRecieve()
  1160. {
  1161. BOOL bDefault = FALSE;
  1162. if(GetIsPortableDitto())
  1163. bDefault = TRUE;
  1164. if(GetIsWindowsApp())
  1165. bDefault = TRUE;
  1166. return GetProfileLong("DisableRecieve", bDefault);
  1167. }
  1168. void CGetSetOptions::SetDisableRecieve(BOOL bVal)
  1169. {
  1170. SetProfileLong("DisableRecieve", bVal);
  1171. }
  1172. BOOL CGetSetOptions::GetFont(LOGFONT &font)
  1173. {
  1174. if(m_bFromIni && !m_bInConversion)
  1175. {
  1176. GetProfileFont("DisplayFont6", font);
  1177. //Return true if there is a font name
  1178. //other wise load the default font below
  1179. if(font.lfFaceName[0] != 0)
  1180. {
  1181. return TRUE;
  1182. }
  1183. }
  1184. else
  1185. {
  1186. DWORD dwLength = 0;
  1187. LPVOID lpVoid = GetProfileData("DisplayFont6", dwLength);
  1188. if(lpVoid)
  1189. {
  1190. if(sizeof(font) == dwLength)
  1191. {
  1192. memcpy(&font, lpVoid, dwLength);
  1193. delete[] lpVoid;
  1194. lpVoid = NULL;
  1195. return TRUE;
  1196. }
  1197. else
  1198. {
  1199. ASSERT(!"invalid font struct size");
  1200. }
  1201. delete[] lpVoid;
  1202. lpVoid = NULL;
  1203. }
  1204. }
  1205. ZeroMemory(&font, sizeof(font));
  1206. font.lfHeight = -13;
  1207. font.lfWeight = 400;
  1208. font.lfCharSet = 1;
  1209. STRCPY(font.lfFaceName, _T("Segoe UI"));
  1210. return TRUE;
  1211. }
  1212. void CGetSetOptions::SetFont(LOGFONT &font)
  1213. {
  1214. if(m_bFromIni)
  1215. {
  1216. SetProfileFont("DisplayFont6", font);
  1217. }
  1218. else
  1219. {
  1220. SetProfileData("DisplayFont6", &font, sizeof(LOGFONT));
  1221. }
  1222. }
  1223. void CGetSetOptions::SetDrawThumbnail(long bDraw)
  1224. {
  1225. SetProfileLong("DrawThumbnail", bDraw);
  1226. m_bDrawThumbnail = bDraw;
  1227. }
  1228. BOOL CGetSetOptions::GetDrawThumbnail()
  1229. {
  1230. BOOL bDrawThumbnails = TRUE;
  1231. return GetProfileLong("DrawThumbnail", bDrawThumbnails);
  1232. }
  1233. void CGetSetOptions::SetExtraNetworkPassword(CString csPassword)
  1234. {
  1235. SetProfileString("NetworkExtraPassword", csPassword);
  1236. }
  1237. CString CGetSetOptions::GetExtraNetworkPassword(bool bFillArray)
  1238. {
  1239. CString cs = GetProfileString("NetworkExtraPassword", "");
  1240. if(bFillArray)
  1241. {
  1242. m_csNetworkPasswordArray.RemoveAll();
  1243. TCHAR seps[] = _T(",");
  1244. TCHAR *token;
  1245. TCHAR *pString = cs.GetBuffer(cs.GetLength());
  1246. /* Establish string and get the first token: */
  1247. token = STRTOK(pString, seps);
  1248. while(token != NULL)
  1249. {
  1250. CString cs(token);
  1251. cs.TrimLeft();
  1252. cs.TrimRight();
  1253. m_csNetworkPasswordArray.Add(cs);
  1254. // Get next token
  1255. token = STRTOK(NULL, seps);
  1256. }
  1257. cs.ReleaseBuffer();
  1258. }
  1259. return cs;
  1260. }
  1261. void CGetSetOptions::SetNetworkPassword(CString csPassword)
  1262. {
  1263. CTextConvert Con;
  1264. Con.ConvertToUTF8(csPassword, m_csPassword);
  1265. SetProfileString("NetworkStringPassword", csPassword);
  1266. }
  1267. CStringA CGetSetOptions::GetNetworkPassword()
  1268. {
  1269. CString cs = GetProfileString("NetworkStringPassword", "LetMeIn");
  1270. CTextConvert Con;
  1271. CStringA csReturn;
  1272. Con.ConvertToUTF8(cs, csReturn);
  1273. return csReturn;
  1274. }
  1275. void CGetSetOptions::SetDrawRTF(long bDraw)
  1276. {
  1277. SetProfileLong("DrawRTF", bDraw);
  1278. m_bDrawRTF = bDraw;
  1279. }
  1280. BOOL CGetSetOptions::GetDrawRTF()
  1281. {
  1282. return GetProfileLong("DrawRTF", FALSE);
  1283. }
  1284. void CGetSetOptions::SetMultiPasteReverse(BOOL bVal)
  1285. {
  1286. SetProfileLong("MultiPasteReverse", bVal);
  1287. m_bMultiPasteReverse = bVal;
  1288. }
  1289. BOOL CGetSetOptions::GetMultiPasteReverse()
  1290. {
  1291. return GetProfileLong("MultiPasteReverse", TRUE);
  1292. }
  1293. void CGetSetOptions::SetPlaySoundOnCopy(CString cs)
  1294. {
  1295. m_csPlaySoundOnCopy = cs;
  1296. SetProfileString("PlaySoundOnCopy", cs);
  1297. }
  1298. CString CGetSetOptions::GetPlaySoundOnCopy()
  1299. {
  1300. return GetProfileString("PlaySoundOnCopy", "");
  1301. }
  1302. void CGetSetOptions::SetSendPasteAfterSelection(BOOL bVal)
  1303. {
  1304. m_bSendPasteMessageAfterSelection = bVal;
  1305. SetProfileLong("SendPasteMessageAfterSelection", bVal);
  1306. }
  1307. BOOL CGetSetOptions::GetSendPasteAfterSelection()
  1308. {
  1309. return GetProfileLong("SendPasteMessageAfterSelection", TRUE);
  1310. }
  1311. void CGetSetOptions::SetFindAsYouType(BOOL bVal)
  1312. {
  1313. m_bFindAsYouType = bVal;
  1314. SetProfileLong("FindAsYouType", bVal);
  1315. }
  1316. BOOL CGetSetOptions::GetFindAsYouType()
  1317. {
  1318. return GetProfileLong("FindAsYouType", TRUE);
  1319. }
  1320. void CGetSetOptions::SetEnsureEntireWindowCanBeSeen(BOOL bVal)
  1321. {
  1322. m_bEnsureEntireWindowCanBeSeen = bVal;
  1323. SetProfileLong("EnsureEntireWindowCanBeSeen", bVal);
  1324. }
  1325. BOOL CGetSetOptions::GetEnsureEntireWindowCanBeSeen()
  1326. {
  1327. return GetProfileLong("EnsureEntireWindowCanBeSeen", TRUE);
  1328. }
  1329. void CGetSetOptions::SetShowAllClipsInMainList(BOOL bVal)
  1330. {
  1331. m_bShowAllClipsInMainList = bVal;
  1332. SetProfileLong("ShowAllClipsInMainList", bVal);
  1333. }
  1334. BOOL CGetSetOptions::GetShowAllClipsInMainList()
  1335. {
  1336. return GetProfileLong("ShowAllClipsInMainList", TRUE);
  1337. }
  1338. long CGetSetOptions::GetMaxClipSizeInBytes()
  1339. {
  1340. return GetProfileLong("MaxClipSizeInBytes", 0);
  1341. }
  1342. void CGetSetOptions::SetMaxClipSizeInBytes(long lSize)
  1343. {
  1344. m_lMaxClipSizeInBytes = lSize;
  1345. SetProfileLong("MaxClipSizeInBytes", lSize);
  1346. }
  1347. CString CGetSetOptions::GetLanguageFile()
  1348. {
  1349. return GetProfileString("LanguageFile", "");
  1350. }
  1351. void CGetSetOptions::SetLanguageFile(CString csLanguage)
  1352. {
  1353. SetProfileString("LanguageFile", csLanguage);
  1354. }
  1355. ULONG CGetSetOptions::GetSaveClipDelay()
  1356. {
  1357. return (ULONG)GetProfileLong("SaveClipDelay", 500);
  1358. }
  1359. void CGetSetOptions::SetSaveClipDelay(DWORD dwDelay)
  1360. {
  1361. m_dwSaveClipDelay = dwDelay;
  1362. SetProfileLong("SaveClipDelay", dwDelay);
  1363. }
  1364. long CGetSetOptions::GetProcessDrawClipboardDelay()
  1365. {
  1366. return GetProfileLong("ProcessDrawClipboardDelay", 100);
  1367. }
  1368. void CGetSetOptions::SetProcessDrawClipboardDelay(long lDelay)
  1369. {
  1370. m_lProcessDrawClipboardDelay = lDelay;
  1371. SetProfileLong("ProcessDrawClipboardDelay", lDelay);
  1372. }
  1373. BOOL CGetSetOptions::GetEnableDebugLogging()
  1374. {
  1375. return GetProfileLong("EnableDebugLogging", FALSE);
  1376. }
  1377. void CGetSetOptions::SetEnableDebugLogging(BOOL bEnable)
  1378. {
  1379. m_bEnableDebugLogging = bEnable;
  1380. SetProfileLong("EnableDebugLogging", bEnable);
  1381. }
  1382. BOOL CGetSetOptions::GetEnsureConnectToClipboard()
  1383. {
  1384. return GetProfileLong("EnsureConnected2", FALSE);
  1385. }
  1386. void CGetSetOptions::SetEnsureConnectToClipboard(BOOL bSet)
  1387. {
  1388. m_bEnsureConnectToClipboard = bSet;
  1389. SetProfileLong("EnsureConnected2", bSet);
  1390. }
  1391. BOOL CGetSetOptions::GetPromptWhenDeletingClips()
  1392. {
  1393. return GetProfileLong("PromptWhenDeletingClips", TRUE);
  1394. }
  1395. void CGetSetOptions::SetPromptWhenDeletingClips(BOOL bSet)
  1396. {
  1397. SetProfileLong("PromptWhenDeletingClips", bSet);
  1398. }
  1399. CString CGetSetOptions::GetLastImportDir()
  1400. {
  1401. return GetProfileString("LastImportDir", "");
  1402. }
  1403. void CGetSetOptions::SetLastImportDir(CString csDir)
  1404. {
  1405. SetProfileString("LastImportDir", csDir);
  1406. }
  1407. CString CGetSetOptions::GetLastExportDir()
  1408. {
  1409. return GetProfileString("LastExportDir", "");
  1410. }
  1411. void CGetSetOptions::SetLastExportDir(CString csDir)
  1412. {
  1413. SetProfileString("LastExportDir", csDir);
  1414. }
  1415. BOOL CGetSetOptions::GetUpdateDescWhenSavingClip()
  1416. {
  1417. return GetProfileLong("UpdateDescWhenSaving", TRUE);
  1418. }
  1419. void CGetSetOptions::SetUpdateDescWhenSavingClip(BOOL bSet)
  1420. {
  1421. SetProfileLong("UpdateDescWhenSaving", bSet);
  1422. }
  1423. CString CGetSetOptions::GetPath(long lPathID)
  1424. {
  1425. CString csDir = CGetSetOptions::GetExeFileName();
  1426. csDir = GetFilePath(csDir);
  1427. FIX_CSTRING_PATH(csDir);
  1428. //U3_APP_DATA_PATH - <U3_DEVICE_PATH>\System\Apps\{app_unique_id}\Data
  1429. //U3_HOST_EXEC_PATH - %APPDATA%\U3\{device_serial_number}\{app_unique_id}\Exec
  1430. //U3_DEVICE_EXEC_PATH - <U3_DEVICE_PATH>\System\Apps\{app_unique_id}\Exec
  1431. switch(lPathID)
  1432. {
  1433. case PATH_HELP:
  1434. csDir += "Help\\";
  1435. break;
  1436. case PATH_LANGUAGE:
  1437. csDir += "language\\";
  1438. break;
  1439. case PATH_THEMES:
  1440. csDir += "Themes\\";
  1441. break;
  1442. case PATH_LOG_FILE:if(CGetSetOptions::GetIsPortableDitto() == false)
  1443. csDir = GetAppDataPath();
  1444. break;
  1445. case PATH_ADDINS:
  1446. csDir += "Addins\\";
  1447. break;
  1448. case PATH_REMOTE_FILES:
  1449. if (CGetSetOptions::GetIsPortableDitto() == false)
  1450. {
  1451. csDir = GetTempFilePath();
  1452. }
  1453. csDir += "ReceivedFiles\\";
  1454. break;
  1455. case PATH_DRAG_FILES:
  1456. if (CGetSetOptions::GetIsPortableDitto() == false)
  1457. {
  1458. csDir = GetTempFilePath();
  1459. }
  1460. csDir += "DragFiles\\";
  1461. break;
  1462. case PATH_CLIP_DIFF:
  1463. if (CGetSetOptions::GetIsPortableDitto() == false)
  1464. {
  1465. csDir = GetTempFilePath();
  1466. }
  1467. csDir += _T("ClipCompare\\");
  1468. break;
  1469. case PATH_RESTORE_TEMP:
  1470. if (CGetSetOptions::GetIsPortableDitto() == false)
  1471. {
  1472. csDir = GetTempFilePath();
  1473. }
  1474. csDir += _T("RestoreDb\\");
  1475. break;
  1476. }
  1477. CreateDirectory(csDir, NULL);
  1478. return csDir;
  1479. }
  1480. long CGetSetOptions::GetDittoRestoreClipboardDelay()
  1481. {
  1482. return GetProfileLong("RestoreClipboardDelay", 750);
  1483. }
  1484. void CGetSetOptions::SetDittoRestoreClipboardDelay(long lDelay)
  1485. {
  1486. SetProfileLong("RestoreClipboardDelay", lDelay);
  1487. }
  1488. void CGetSetOptions::GetCopyBufferItem(int nPos, CCopyBufferItem &Item)
  1489. {
  1490. Item.m_lCopyHotKey = GetProfileLong(StrF(_T("CopyBufferCopyHotKey_%d"), nPos), 0);
  1491. Item.m_lPasteHotKey = GetProfileLong(StrF(_T("CopyBufferPasteHotKey_%d"), nPos), 0);
  1492. Item.m_lCutHotKey = GetProfileLong(StrF(_T("CopyBufferCutHotKey_%d"), nPos), 0);
  1493. Item.m_bPlaySoundOnCopy = GetProfileLong(StrF(_T("CopyBufferPlaySound_%d"), nPos), 0);
  1494. }
  1495. void CGetSetOptions::SetCopyBufferItem(int nPos, CCopyBufferItem &Item)
  1496. {
  1497. SetProfileLong(StrF(_T("CopyBufferCopyHotKey_%d"), nPos), Item.m_lCopyHotKey);
  1498. SetProfileLong(StrF(_T("CopyBufferPasteHotKey_%d"), nPos), Item.m_lPasteHotKey);
  1499. SetProfileLong(StrF(_T("CopyBufferCutHotKey_%d"), nPos), Item.m_lCutHotKey);
  1500. SetProfileLong(StrF(_T("CopyBufferPlaySound_%d"), nPos), Item.m_bPlaySoundOnCopy);
  1501. }
  1502. CString CGetSetOptions::GetMultiPasteSeparator(bool bConvertToLineFeeds)
  1503. {
  1504. CString csSep = GetProfileString(_T("MultiPasteSeparator"), _T("[LF]"));
  1505. if(bConvertToLineFeeds)
  1506. {
  1507. CString csLineFeed(_T("\r\n"));
  1508. csSep.Replace(_T("[LF]"), csLineFeed);
  1509. csSep.Replace(_T("[lf]"), csLineFeed);
  1510. }
  1511. return csSep;
  1512. }
  1513. void CGetSetOptions::SetMultiPasteSeparator(CString csSep)
  1514. {
  1515. SetProfileString(_T("MultiPasteSeparator"), csSep);
  1516. }
  1517. BOOL CGetSetOptions::GetSetCurrentDirectory()
  1518. {
  1519. if(m_portable)
  1520. {
  1521. CString csExePath = GetFilePath(GetExeFileName());
  1522. FIX_CSTRING_PATH(csExePath);
  1523. ::SetCurrentDirectory(csExePath);
  1524. }
  1525. return m_portable == true;
  1526. }
  1527. bool CGetSetOptions::GetIsPortableDitto()
  1528. {
  1529. return m_portable;
  1530. }
  1531. bool CGetSetOptions::GetIsWindowsApp()
  1532. {
  1533. return m_windowsApp;
  1534. }
  1535. bool CGetSetOptions::GetIsChocolateyApp()
  1536. {
  1537. return m_chocolateyApp;
  1538. }
  1539. CString CGetSetOptions::GetPasteString(CString csAppName)
  1540. {
  1541. CString csString = GetProfileString(csAppName, _T(""), _T("PasteStrings"));
  1542. if (csString.IsEmpty())
  1543. {
  1544. //edge is really slow to set focus so add a delay before sending the paste
  1545. if (csAppName == L"MicrosoftEdge.exe")
  1546. {
  1547. return _T("{DELAY 500}^{VKEY86}");
  1548. }
  1549. return GetDefaultPasteString();
  1550. }
  1551. return csString;
  1552. }
  1553. CString CGetSetOptions::GetDefaultPasteString()
  1554. {
  1555. //ascii value for v
  1556. //for other language keyboards v gets converted to something else so send the base ascii value
  1557. return GetProfileString(_T("DefaultPasteString"), _T("^{VKEY86}"));
  1558. }
  1559. void CGetSetOptions::SetDefaultPasteString(CString val)
  1560. {
  1561. SetProfileString(_T("DefaultPasteString"), val);
  1562. }
  1563. CString CGetSetOptions::GetCopyString(CString csAppName)
  1564. {
  1565. CString csString = GetProfileString(csAppName, _T(""), _T("CopyStrings"));
  1566. if(csString.IsEmpty())
  1567. return GetDefaultCopyString();
  1568. return csString;
  1569. }
  1570. CString CGetSetOptions::GetDefaultCopyString()
  1571. {
  1572. //ascii value for c
  1573. //for other language keyboards c gets converted to something else so send the base ascii value
  1574. return GetProfileString(_T("DefaultCopyString"), _T("^{VKEY67}"));
  1575. }
  1576. void CGetSetOptions::SetDefaultCopyString(CString val)
  1577. {
  1578. SetProfileString(_T("DefaultCopyString"), val);
  1579. }
  1580. CString CGetSetOptions::GetCutString(CString csAppName)
  1581. {
  1582. CString csString = GetProfileString(csAppName, _T(""), _T("CutStrings"));
  1583. if(csString.IsEmpty())
  1584. return GetDefaultCutString();
  1585. return csString;
  1586. }
  1587. CString CGetSetOptions::GetDefaultCutString()
  1588. {
  1589. //ascii value for x
  1590. //for other language keyboards x gets converted to something else so send the base ascii value
  1591. return GetProfileString(_T("DefaultCutString"), _T("^{VKEY88}"));
  1592. }
  1593. void CGetSetOptions::SetDefaultCutString(CString val)
  1594. {
  1595. SetProfileString(_T("DefaultCutString"), val);
  1596. }
  1597. BOOL CGetSetOptions::GetEditWordWrap()
  1598. {
  1599. return GetProfileLong(_T("EditWordWrap"), TRUE);
  1600. }
  1601. void CGetSetOptions::SetEditWordWrap(BOOL bSet)
  1602. {
  1603. SetProfileLong(_T("EditWordWrap"), bSet);
  1604. }
  1605. bool CGetSetOptions::GetAllowFriends()
  1606. {
  1607. return (GetProfileLong("AllowFriends", TRUE) == TRUE);
  1608. }
  1609. long CGetSetOptions::GetAutoMaxDelay()
  1610. {
  1611. return GetProfileLong(_T("AutoMaxDelaySeconds"), 2);
  1612. }
  1613. void CGetSetOptions::SetAutoMaxDelay(long lDelay)
  1614. {
  1615. SetProfileLong(_T("AutoMaxDelaySeconds"), lDelay);
  1616. }
  1617. void CGetSetOptions::SetTheme(CString csTheme)
  1618. {
  1619. SetProfileString(_T("Theme2"), csTheme);
  1620. }
  1621. CString CGetSetOptions::GetTheme()
  1622. {
  1623. return GetProfileString(_T("Theme2"), "");
  1624. }
  1625. long CGetSetOptions::GetKeyStateWaitTimerCount()
  1626. {
  1627. return GetProfileLong(_T("KeyStateWaitTimerCount"), 20);
  1628. }
  1629. long CGetSetOptions::GetKeyStatePasteDelay()
  1630. {
  1631. return GetProfileLong(_T("KeyStatePasteDelay"), 200);
  1632. }
  1633. DWORD CGetSetOptions::GetDittoHotKey()
  1634. {
  1635. return (DWORD)GetProfileLong(_T("DittoHotKey"), 704);
  1636. }
  1637. DWORD CGetSetOptions::SendKeysDelay()
  1638. {
  1639. return (DWORD)GetProfileLong(_T("SendKeysDelay"), 100);
  1640. }
  1641. void CGetSetOptions::SetSendKeysDelay(DWORD val)
  1642. {
  1643. SetProfileLong(_T("SendKeysDelay"), val);
  1644. }
  1645. DWORD CGetSetOptions::RealSendKeysDelay()
  1646. {
  1647. return (DWORD)GetProfileLong(_T("RealSendKeysDelay"), 10);
  1648. }
  1649. void CGetSetOptions::SetRealSendKeysDelay(DWORD val)
  1650. {
  1651. SetProfileLong(_T("RealSendKeysDelay"), val);
  1652. }
  1653. DWORD CGetSetOptions::WaitForActiveWndTimeout()
  1654. {
  1655. return (DWORD)GetProfileLong(_T("WaitForActiveWndTimeout"), 500);
  1656. }
  1657. DWORD CGetSetOptions::FocusChangedDelay()
  1658. {
  1659. return (DWORD)GetProfileLong(_T("FocusChangedDelay"), 100);
  1660. }
  1661. DWORD CGetSetOptions::FocusWndTimerTimeout()
  1662. {
  1663. return (DWORD)GetProfileLong(_T("FocusWndTimerTimeout"), 2000);
  1664. }
  1665. BOOL CGetSetOptions::GetConnectedToClipboard()
  1666. {
  1667. return GetProfileLong("ConnectedToClipboard", TRUE);
  1668. }
  1669. void CGetSetOptions::SetConnectedToClipboard(BOOL val)
  1670. {
  1671. SetProfileLong("ConnectedToClipboard", val);
  1672. }
  1673. DWORD CGetSetOptions::GetTextOnlyRestoreDelay()
  1674. {
  1675. return (DWORD)GetProfileLong(_T("TextOnlyRestoreDelay"), 2000);
  1676. }
  1677. DWORD CGetSetOptions::GetTextOnlyPasteDelay()
  1678. {
  1679. return (DWORD)GetProfileLong(_T("TextOnlyPasteDelay"), 0);
  1680. }
  1681. BOOL CGetSetOptions::GetSetFocusToApp(CString csAppName)
  1682. {
  1683. CString focusCheck;
  1684. focusCheck = "SetFocus_";
  1685. focusCheck += csAppName;
  1686. return GetProfileLong(focusCheck, FALSE);
  1687. }
  1688. DWORD CGetSetOptions::SelectedIndex()
  1689. {
  1690. return (DWORD)GetProfileLong(_T("SelectedIndex"), 0);
  1691. }
  1692. void CGetSetOptions::SetSelectedIndex(int val)
  1693. {
  1694. SetProfileLong(_T("SelectedIndex"), val);
  1695. }
  1696. void CGetSetOptions::SetCopyAppInclude(CString csAppName)
  1697. {
  1698. SetProfileString(_T("CopyAppInclude"), csAppName);
  1699. }
  1700. CString CGetSetOptions::GetCopyAppInclude()
  1701. {
  1702. CString includeApp = GetProfileString(_T("CopyAppInclude"), "*");
  1703. if(includeApp == "")
  1704. {
  1705. includeApp = "*";
  1706. }
  1707. return includeApp;
  1708. }
  1709. void CGetSetOptions::SetCopyAppExclude(CString csAppName)
  1710. {
  1711. SetProfileString(_T("CopyAppExclude"), csAppName);
  1712. }
  1713. CString CGetSetOptions::GetCopyAppExclude()
  1714. {
  1715. return GetProfileString(_T("CopyAppExclude"), "");
  1716. }
  1717. CString CGetSetOptions::GetCopyAppSeparator()
  1718. {
  1719. return GetProfileString(_T("CopyAppSeparator"), ";");
  1720. }
  1721. DWORD CGetSetOptions::GetNoFormatsRetryDelay()
  1722. {
  1723. return GetProfileLong(_T("NoFormatsRetryDelay"), 200);
  1724. }
  1725. DWORD CGetSetOptions::GetMainDeletesDeleteCount()
  1726. {
  1727. return GetProfileLong(_T("MainDeletesDeleteCount"), 100);
  1728. }
  1729. DWORD CGetSetOptions::GetIdleSecondsBeforeDelete()
  1730. {
  1731. return GetProfileLong(_T("IdleSecondsBeforeDelete"), 60*10);
  1732. }
  1733. DWORD CGetSetOptions::GetDbTimeout()
  1734. {
  1735. return GetProfileLong(_T("DbTimeout"), 5000);
  1736. }
  1737. DWORD CGetSetOptions::GetFunnyTickCountAdjustment()
  1738. {
  1739. return GetProfileLong(_T("FunnyTickCountAdjustment"), 300001);
  1740. }
  1741. DWORD CGetSetOptions::GetMinIdleTimeBeforeTrackFocus()
  1742. {
  1743. return GetProfileLong(_T("MinIdleTimeBeforeTrackFocus"), 100);
  1744. }
  1745. DWORD CGetSetOptions::GetTimeBeforeExpandWindow()
  1746. {
  1747. return GetProfileLong(_T("TimeBeforeExpandWindow"), 250);
  1748. }
  1749. DWORD CGetSetOptions::GetUseGuiThreadInfoForFocus()
  1750. {
  1751. return GetProfileLong(_T("UseGuiThreadInfoForFocus"), 1);
  1752. }
  1753. void CGetSetOptions::SetSearchDescription(BOOL val)
  1754. {
  1755. SetProfileLong(_T("SearchDescription"), val);
  1756. }
  1757. BOOL CGetSetOptions::GetSearchDescription()
  1758. {
  1759. return GetProfileLong(_T("SearchDescription"), 1);
  1760. }
  1761. void CGetSetOptions::SetSearchFullText(BOOL val)
  1762. {
  1763. SetProfileLong(_T("SearchFullText"), val);
  1764. }
  1765. BOOL CGetSetOptions::GetSearchFullText()
  1766. {
  1767. return GetProfileLong(_T("SearchFullText"), 0);
  1768. }
  1769. void CGetSetOptions::SetSearchQuickPaste(BOOL val)
  1770. {
  1771. SetProfileLong(_T("SearchQuickPaste"), val);
  1772. }
  1773. BOOL CGetSetOptions::GetSearchQuickPaste()
  1774. {
  1775. return GetProfileLong(_T("SearchQuickPaste"), 0);
  1776. }
  1777. void CGetSetOptions::SetSimpleTextSearch(BOOL val)
  1778. {
  1779. SetProfileLong(_T("SimpleTextSearch"), val);
  1780. }
  1781. BOOL CGetSetOptions::GetSimpleTextSearch()
  1782. {
  1783. return GetProfileLong(_T("SimpleTextSearch"), 0);
  1784. }
  1785. void CGetSetOptions::SetRegExTextSearch(BOOL val)
  1786. {
  1787. SetProfileLong(_T("RegExTextSearch"), val);
  1788. }
  1789. BOOL CGetSetOptions::GetRegExTextSearch()
  1790. {
  1791. return GetProfileLong(_T("RegExTextSearch"), 0);
  1792. }
  1793. void CGetSetOptions::SetMoveClipsOnGlobal10(BOOL val)
  1794. {
  1795. SetProfileLong(_T("MoveClipsOnGlobal10"), val);
  1796. }
  1797. BOOL CGetSetOptions::GetMoveClipsOnGlobal10()
  1798. {
  1799. return GetProfileLong(_T("MoveClipsOnGlobal10"), 0);
  1800. }
  1801. void CGetSetOptions::SetShowScrollBar(BOOL val)
  1802. {
  1803. m_showScrollBar = val;
  1804. SetProfileLong(_T("ShowScrollBar"), val);
  1805. }
  1806. BOOL CGetSetOptions::GetShowScrollBar()
  1807. {
  1808. return GetProfileLong(_T("ShowScrollBar"), 0);
  1809. }
  1810. void CGetSetOptions::SetPasteAsAdmin(BOOL val)
  1811. {
  1812. SetProfileLong(_T("PasteAsAdmin"), val);
  1813. }
  1814. BOOL CGetSetOptions::GetPasteAsAdmin()
  1815. {
  1816. return GetProfileLong(_T("PasteAsAdmin"), 1);
  1817. }
  1818. void CGetSetOptions::SetRememberDescPos(BOOL val)
  1819. {
  1820. SetProfileLong(_T("RememberDescPos"), val);
  1821. }
  1822. BOOL CGetSetOptions::GetRememberDescPos()
  1823. {
  1824. return GetProfileLong(_T("RememberDescPos"), FALSE);
  1825. }
  1826. void CGetSetOptions::SetSizeDescWindowToContent(BOOL val)
  1827. {
  1828. SetProfileLong(_T("SizeDescWindowToContent"), val);
  1829. }
  1830. BOOL CGetSetOptions::GetSizeDescWindowToContent()
  1831. {
  1832. return GetProfileLong(_T("SizeDescWindowToContent"), TRUE);
  1833. }
  1834. void CGetSetOptions::SetScaleImagesToDescWindow(BOOL val)
  1835. {
  1836. SetProfileLong(_T("ScaleImagesToDescWindow"), val);
  1837. }
  1838. BOOL CGetSetOptions::GetScaleImagesToDescWindow()
  1839. {
  1840. return GetProfileLong(_T("ScaleImagesToDescWindow"), TRUE);
  1841. }
  1842. void CGetSetOptions::SetDescWndPoint(CPoint point)
  1843. {
  1844. SetResolutionProfileLong("DescWndX", point.x);
  1845. SetResolutionProfileLong("DescWndY", point.y);
  1846. }
  1847. void CGetSetOptions::GetDescWndPoint(CPoint &point)
  1848. {
  1849. point.x = GetResolutionProfileLong("DescWndX", 100);
  1850. point.y = GetResolutionProfileLong("DescWndY", 100);
  1851. }
  1852. void CGetSetOptions::GetDescWndSize(CSize &size)
  1853. {
  1854. size.cx = GetResolutionProfileLong("DescWndCX", 300);
  1855. size.cy = GetResolutionProfileLong("DescWndCY", 300);
  1856. if(size.cx <= 0 && size.cy <= 0)
  1857. {
  1858. size.cx = 300;
  1859. size.cy = 300;
  1860. }
  1861. }
  1862. void CGetSetOptions::SetDescWndSize(CSize size)
  1863. {
  1864. SetResolutionProfileLong("DescWndCX", size.cx);
  1865. SetResolutionProfileLong("DescWndCY", size.cy);
  1866. }
  1867. void CGetSetOptions::SetShowInTaskBar(BOOL val)
  1868. {
  1869. SetProfileLong(_T("ShowInTaskBar"), val);
  1870. }
  1871. BOOL CGetSetOptions::GetShowInTaskBar()
  1872. {
  1873. return GetProfileLong(_T("ShowInTaskBar"), FALSE);
  1874. }
  1875. void CGetSetOptions::SetDiffApp(CString val)
  1876. {
  1877. SetProfileString(_T("DiffApp"), val);
  1878. }
  1879. CString CGetSetOptions::GetDiffApp()
  1880. {
  1881. return GetProfileString(_T("DiffApp"), _T(""));
  1882. }
  1883. void CGetSetOptions::SetQRCodeBorderPixels(int val)
  1884. {
  1885. SetProfileLong(_T("QRCodeBorderPixels"), val);
  1886. }
  1887. int CGetSetOptions::GetQRCodeBorderPixels()
  1888. {
  1889. return GetProfileLong(_T("QRCodeBorderPixels"), 30);
  1890. }
  1891. CString CGetSetOptions::GetTranslateUrl()
  1892. {
  1893. return GetProfileString(_T("TranslateUrl"), _T("https://translate.google.com/?tl=en#auto/en/%s"));
  1894. }
  1895. void CGetSetOptions::SetNetworkReadTimeoutMS(int val)
  1896. {
  1897. SetProfileLong(_T("NetworkReadTimeoutMS"), val);
  1898. }
  1899. int CGetSetOptions::GetNetworkReadTimeoutMS()
  1900. {
  1901. return GetProfileLong(_T("NetworkReadTimeoutMS"), 30000);
  1902. }
  1903. void CGetSetOptions::SetRequestFilesUsingIP(int val)
  1904. {
  1905. SetProfileLong(_T("RequestFilesUsingIP"), val);
  1906. }
  1907. int CGetSetOptions::GetRequestFilesUsingIP()
  1908. {
  1909. return GetProfileLong(_T("RequestFilesUsingIP"), 0);
  1910. }
  1911. int CGetSetOptions::ReadRandomFileInterval()
  1912. {
  1913. return GetProfileLong(_T("ReadRandomFileInterval"), 60);
  1914. }
  1915. int CGetSetOptions::ReadRandomFileIdleMin()
  1916. {
  1917. return GetProfileLong(_T("ReadRandomFileIdleMin"), 30);
  1918. }
  1919. BOOL CGetSetOptions::GetShowGroupsInMainList()
  1920. {
  1921. return GetProfileLong(_T("ShowGroupsInMainList"), 0);
  1922. }
  1923. void CGetSetOptions::SetShowGroupsInMainList(BOOL val)
  1924. {
  1925. SetProfileLong(_T("ShowGroupsInMainList"), val);
  1926. }
  1927. void CGetSetOptions::SetGroupDoubleClickTimeMS(int val)
  1928. {
  1929. SetProfileLong(_T("GroupDoubleClickTimeMS"), val);
  1930. }
  1931. int CGetSetOptions::GetGroupDoubleClickTimeMS()
  1932. {
  1933. return GetProfileLong(_T("GroupDoubleClickTimeMS"), 500);
  1934. }
  1935. void CGetSetOptions::SetSaveToGroupTimeoutMS(int val)
  1936. {
  1937. SetProfileLong(_T("SaveToGroupTimeoutMS"), val);
  1938. }
  1939. int CGetSetOptions::GetSaveToGroupTimeoutMS()
  1940. {
  1941. return GetProfileLong(_T("SaveToGroupTimeoutMS"), 1000);
  1942. }
  1943. void CGetSetOptions::SetCopyReasonTimeoutMS(int val)
  1944. {
  1945. SetProfileLong(_T("CopyReasonTimeoutMS"), val);
  1946. }
  1947. int CGetSetOptions::GetCopyReasonTimeoutMS()
  1948. {
  1949. return GetProfileLong(_T("CopyReasonTimeoutMS"), 1000);
  1950. }
  1951. void CGetSetOptions::SetWindowsResumeDelayReOpenDbMS(int val)
  1952. {
  1953. SetProfileLong(_T("WindowsResumeDelayReOpenDbMS"), val);
  1954. }
  1955. int CGetSetOptions::GetWindowsResumeDelayReOpenDbMS()
  1956. {
  1957. return GetProfileLong(_T("WindowsResumeDelayReOpenDbMS"), 2000);
  1958. }
  1959. BOOL CGetSetOptions::GetShowMsgWndOnCopyToGroup()
  1960. {
  1961. return GetProfileLong(_T("ShowMsgWndOnCopyToGroup"), TRUE);
  1962. }
  1963. void CGetSetOptions::SetShowMsgWndOnCopyToGroup(BOOL val)
  1964. {
  1965. SetProfileLong(_T("ShowMsgWndOnCopyToGroup"), val);
  1966. }
  1967. int CGetSetOptions::GetActionShortCutA(DWORD action, int pos, CString refData)
  1968. {
  1969. CString actionText;
  1970. if (refData != _T(""))
  1971. {
  1972. actionText.Format(_T("QP_ShortCut_%d_%s_%d_A"), action, refData, pos);
  1973. }
  1974. else
  1975. {
  1976. actionText.Format(_T("QP_ShortCut_%d_%d_A"), action, pos);
  1977. }
  1978. int ret = GetProfileLong(actionText, -1);
  1979. if (ret == -1)
  1980. {
  1981. ret = ActionEnums::GetDefaultShortCutKeyA((ActionEnums::ActionEnumValues)action, pos);
  1982. }
  1983. return ret;
  1984. }
  1985. void CGetSetOptions::SetActionShortCutA(int action, DWORD shortcut, int pos, CString refData)
  1986. {
  1987. CString actionText;
  1988. if (refData != _T(""))
  1989. {
  1990. actionText.Format(_T("QP_ShortCut_%d_%s_%d_A"), action, refData, pos);
  1991. }
  1992. else
  1993. {
  1994. actionText.Format(_T("QP_ShortCut_%d_%d_A"), action, pos);
  1995. }
  1996. SetProfileLong(actionText, shortcut);
  1997. }
  1998. int CGetSetOptions::GetActionShortCutB(DWORD action, int pos, CString refData)
  1999. {
  2000. CString actionText;
  2001. if (refData != _T(""))
  2002. {
  2003. actionText.Format(_T("QP_ShortCut_%d_%s_%d_B"), action, refData, pos);
  2004. }
  2005. else
  2006. {
  2007. actionText.Format(_T("QP_ShortCut_%d_%d_B"), action, pos);
  2008. }
  2009. int ret = GetProfileLong(actionText, -1);
  2010. if (ret == -1)
  2011. {
  2012. ret = ActionEnums::GetDefaultShortCutKeyB((ActionEnums::ActionEnumValues)action, pos);
  2013. }
  2014. return ret;
  2015. }
  2016. void CGetSetOptions::SetActionShortCutB(int action, DWORD shortcut, int pos, CString refData)
  2017. {
  2018. CString actionText;
  2019. if (refData != _T(""))
  2020. {
  2021. actionText.Format(_T("QP_ShortCut_%d_%s_%d_B"), action, refData, pos);
  2022. }
  2023. else
  2024. {
  2025. actionText.Format(_T("QP_ShortCut_%d_%d_B"), action, pos);
  2026. }
  2027. SetProfileLong(actionText, shortcut);
  2028. }
  2029. BOOL CGetSetOptions::GetShowAlwaysOnTopWarning()
  2030. {
  2031. return GetProfileLong(_T("ShowAlwaysOnTopWarning"), TRUE);
  2032. }
  2033. void CGetSetOptions::SetShowAlwaysOnTopWarning(BOOL show)
  2034. {
  2035. m_bShowAlwaysOnTopWarning = show;
  2036. SetProfileLong(_T("ShowAlwaysOnTopWarning"), show);
  2037. }
  2038. BOOL CGetSetOptions::GetUseIPFromAccept()
  2039. {
  2040. return GetProfileLong(_T("UseIPFromAccept"), TRUE);
  2041. }
  2042. void CGetSetOptions::SetUseIPFromAccept(BOOL useAccept)
  2043. {
  2044. SetProfileLong(_T("UseIPFromAccept"), useAccept);
  2045. }
  2046. int CGetSetOptions::GetDragId()
  2047. {
  2048. return GetProfileLong(_T("DragId"), 1);
  2049. }
  2050. void CGetSetOptions::SetDragId(int id)
  2051. {
  2052. SetProfileLong(_T("DragId"), id);
  2053. }
  2054. BOOL CGetSetOptions::GetShowIfClipWasPasted()
  2055. {
  2056. return GetProfileLong(_T("ShowIfClipWasPasted"), TRUE);
  2057. }
  2058. void CGetSetOptions::SetShowIfClipWasPasted(BOOL val)
  2059. {
  2060. SetProfileLong(_T("ShowIfClipWasPasted"), val);
  2061. }
  2062. int CGetSetOptions::GetLastGroupToggle()
  2063. {
  2064. return GetProfileLong(_T("LastGroupToggle"), -2);
  2065. }
  2066. void CGetSetOptions::SetLastGroupToggle(int val)
  2067. {
  2068. SetProfileLong(_T("LastGroupToggle"), val);
  2069. }
  2070. BOOL CGetSetOptions::GetMouseClickHidesDescription()
  2071. {
  2072. return GetProfileLong(_T("MouseClickHidesDescription"), TRUE);
  2073. }
  2074. void CGetSetOptions::SetMouseClickHidesDescription(int val)
  2075. {
  2076. SetProfileLong(_T("MouseClickHidesDescription"), val);
  2077. }
  2078. BOOL CGetSetOptions::GetWrapDescriptionText()
  2079. {
  2080. return GetProfileLong(_T("WrapDescriptionText"), FALSE);
  2081. }
  2082. void CGetSetOptions::SetWrapDescriptionText(int val)
  2083. {
  2084. SetProfileLong(_T("WrapDescriptionText"), val);
  2085. }
  2086. BOOL CGetSetOptions::GetUseUISelectedGroupForLastTenCopies()
  2087. {
  2088. return GetProfileLong(_T("UseUISelectedGroupForLastTenCopies"), FALSE);
  2089. }
  2090. void CGetSetOptions::SetUseUISelectedGroupForLastTenCopies(int val)
  2091. {
  2092. SetProfileLong(_T("UseUISelectedGroupForLastTenCopies"), val);
  2093. }
  2094. int CGetSetOptions::GetDelayRenderLockout()
  2095. {
  2096. return GetProfileLong(_T("DelayRenderLockout"), 1000);
  2097. }
  2098. void CGetSetOptions::SetDelayRenderLockout(int val)
  2099. {
  2100. SetProfileLong(_T("DelayRenderLockout"), val);
  2101. }
  2102. BOOL CGetSetOptions::GetAdjustClipsForCRC()
  2103. {
  2104. return GetProfileLong(_T("AdjustClipsForCRC"), TRUE);
  2105. }
  2106. void CGetSetOptions::SetAdjustClipsForCRC(int val)
  2107. {
  2108. SetProfileLong(_T("AdjustClipsForCRC"), val);
  2109. }
  2110. BOOL CGetSetOptions::GetCheckMd5OnFileTransfers()
  2111. {
  2112. return GetProfileLong(_T("CheckMd5OnFileTransfers"), TRUE);
  2113. }
  2114. void CGetSetOptions::SetCheckMd5OnFileTransfers(int val)
  2115. {
  2116. SetProfileLong(_T("CheckMd5OnFileTransfers"), val);
  2117. }
  2118. int CGetSetOptions::GetBalloonTimeout()
  2119. {
  2120. return GetProfileLong(_T("BalloonTimeout"), 2500);
  2121. }
  2122. void CGetSetOptions::SetBalloonTimeout(int val)
  2123. {
  2124. SetProfileLong(_T("BalloonTimeout"), val);
  2125. }
  2126. void CGetSetOptions::SetCustomSendToList(CString val)
  2127. {
  2128. SetProfileString(_T("CustomSendToList2"), val);
  2129. }
  2130. CString CGetSetOptions::GetCustomSendToList()
  2131. {
  2132. return GetProfileString("CustomSendToList2", "");
  2133. }
  2134. int CGetSetOptions::GetMaxFileContentsSize()
  2135. {
  2136. return GetProfileLong(_T("MaxFileContentsSize"), 64000000);
  2137. }
  2138. void CGetSetOptions::SetMaxFileContentsSize(int val)
  2139. {
  2140. SetProfileLong(_T("MaxFileContentsSize"), val);
  2141. }
  2142. int CGetSetOptions::GetErrorMsgPopupTimeout()
  2143. {
  2144. return GetProfileLong(_T("ErrorMsgPopupTimeout"), 3500);
  2145. }
  2146. void CGetSetOptions::SetErrorMsgPopupTimeout(int val)
  2147. {
  2148. SetProfileLong(_T("ErrorMsgPopupTimeout"), val);
  2149. }
  2150. void CGetSetOptions::SetRegexFilter(CString val, int pos)
  2151. {
  2152. CString cs;
  2153. cs.Format(_T("RegexFilter_%d"), pos);
  2154. m_regexHelper.SetRegEx(pos, std::wstring(val));
  2155. SetProfileString(cs, val);
  2156. }
  2157. CString CGetSetOptions::GetRegexFilter(int pos)
  2158. {
  2159. CString cs;
  2160. cs.Format(_T("RegexFilter_%d"), pos);
  2161. return GetProfileString(cs, "");
  2162. }
  2163. void CGetSetOptions::SetRegexFilterByProcessName(CString val, int pos)
  2164. {
  2165. CString cs;
  2166. cs.Format(_T("RegexFilterByProcessName_%d"), pos);
  2167. m_regexHelper.SetProcessFilter(pos, val);
  2168. SetProfileString(cs, val);
  2169. }
  2170. CString CGetSetOptions::GetRegexFilterByProcessName(int pos)
  2171. {
  2172. CString cs;
  2173. cs.Format(_T("RegexFilterByProcessName_%d"), pos);
  2174. return GetProfileString(cs, "");
  2175. }
  2176. BOOL CGetSetOptions::GetOpenToGroupByActiveExe()
  2177. {
  2178. return GetProfileLong(_T("OpenToGroupByActiveExe"), FALSE);
  2179. }
  2180. void CGetSetOptions::SetOpenToGroupByActiveExe(int val)
  2181. {
  2182. SetProfileLong(_T("OpenToGroupByActiveExe"), val);
  2183. }
  2184. BOOL CGetSetOptions::GetExcludeCF_DIBInExcel()
  2185. {
  2186. return GetProfileLong(_T("ExcludeCF_DIBInExcel"), TRUE);
  2187. }
  2188. void CGetSetOptions::SetExcludeCF_DIBInExcel(int val)
  2189. {
  2190. m_excludeCF_DIBInExcel = val;
  2191. SetProfileLong(_T("ExcludeCF_DIBInExcel"), val);
  2192. }
  2193. BOOL CGetSetOptions::GetShowStartupMessage()
  2194. {
  2195. return GetProfileLong(_T("ShowStartupMessage"), TRUE);
  2196. }
  2197. void CGetSetOptions::SetShowStartupMessage(int val)
  2198. {
  2199. SetProfileLong(_T("ShowStartupMessage"), val);
  2200. }
  2201. CString CGetSetOptions::GetCopyScriptsXml()
  2202. {
  2203. return GetProfileString("CopyScriptsXml", "");
  2204. }
  2205. void CGetSetOptions::SetCopyScriptsXml(CString val)
  2206. {
  2207. m_copyScripts.Load(val);
  2208. SetProfileString(_T("CopyScriptsXml"), val);
  2209. }
  2210. CString CGetSetOptions::GetPasteScriptsXml()
  2211. {
  2212. return GetProfileString("PasteScriptsXml", "");
  2213. }
  2214. void CGetSetOptions::SetPasteScriptsXml(CString val)
  2215. {
  2216. m_pasteScripts.Load(val);
  2217. SetProfileString(_T("PasteScriptsXml"), val);
  2218. }
  2219. long CGetSetOptions::GetToolTipTimeout()
  2220. {
  2221. return GetProfileLong("ToolTipTimeout", -1);
  2222. }
  2223. void CGetSetOptions::SetToolTipTimeout(long val)
  2224. {
  2225. m_tooltipTimeout = val;
  2226. SetProfileLong("ToolTipTimeout", val);
  2227. }
  2228. CString CGetSetOptions::GetPastSearchXml()
  2229. {
  2230. //max this out at 1000, this should be more than the allowed length in SymbolEdit.cpp
  2231. //had reports of this being really large and causing memory issues, this will prevent us from this
  2232. return GetProfileString("PastSearchXml", "", "", 1000);
  2233. }
  2234. void CGetSetOptions::SetPastSearchXml(CString val)
  2235. {
  2236. SetProfileString(_T("PastSearchXml"), val);
  2237. }
  2238. BOOL CGetSetOptions::GetShowMsgWhenReceivingManualSentClip()
  2239. {
  2240. return GetProfileLong("ShowMsgWhenReceivingManualSentClip", TRUE);
  2241. }
  2242. void CGetSetOptions::SetShowMsgWhenReceivingManualSentClip(BOOL val)
  2243. {
  2244. SetProfileLong("ShowMsgWhenReceivingManualSentClip", val);
  2245. }
  2246. BOOL CGetSetOptions::GetCleanRTFBeforeDrawing()
  2247. {
  2248. return GetProfileLong("CleanRTFBeforeDrawing", TRUE);
  2249. }
  2250. void CGetSetOptions::SetCleanRTFBeforeDrawing(BOOL val)
  2251. {
  2252. m_cleanRTFBeforeDrawing = true;
  2253. SetProfileLong("CleanRTFBeforeDrawing", val);
  2254. }
  2255. BOOL CGetSetOptions::GetDisableExpireClipsConfig()
  2256. {
  2257. return GetProfileLong("DisableExpireClipsConfig", FALSE);
  2258. }
  2259. void CGetSetOptions::SetDisableExpireClipsConfig(BOOL val)
  2260. {
  2261. SetProfileLong("DisableExpireClipsConfig", val);
  2262. }
  2263. BOOL CGetSetOptions::GetRevertToTopLevelGroup()
  2264. {
  2265. return GetProfileLong("RevertToTopLevelGroup", FALSE);
  2266. }
  2267. void CGetSetOptions::SetRevertToTopLevelGroup(BOOL val)
  2268. {
  2269. SetProfileLong("RevertToTopLevelGroup", val);
  2270. }
  2271. BOOL CGetSetOptions::GetUpdateClipOrderOnCtrlC()
  2272. {
  2273. return GetProfileLong("UpdateClipOrderOnCtrlC", FALSE);
  2274. }
  2275. void CGetSetOptions::SetUpdateClipOrderOnCtrlC(BOOL val)
  2276. {
  2277. SetProfileLong("UpdateClipOrderOnCtrlC", val);
  2278. }
  2279. int CGetSetOptions::GetMaxToolTipLines()
  2280. {
  2281. return GetProfileLong("MaxToolTipLines", 30);
  2282. }
  2283. void CGetSetOptions::SetMaxToolTipLines(int val)
  2284. {
  2285. SetProfileLong("MaxToolTipLines", val);
  2286. }
  2287. int CGetSetOptions::GetMaxToolTipCharacters()
  2288. {
  2289. return GetProfileLong("MaxToolTipCharacters", 1000);
  2290. }
  2291. void CGetSetOptions::SetMaxToolTipCharacters(int val)
  2292. {
  2293. SetProfileLong("MaxToolTipCharacters", val);
  2294. }
  2295. int CGetSetOptions::GetDoubleKeyStrokeTimeout()
  2296. {
  2297. return GetProfileLong("DoubleKeyStrokeTimeout", 350);
  2298. }
  2299. void CGetSetOptions::SetDoubleKeyStrokeTimeout(int val)
  2300. {
  2301. m_doubleKeyStrokeTimeout = val;
  2302. SetProfileLong("DoubleKeyStrokeTimeout", val);
  2303. }
  2304. int CGetSetOptions::GetFirstTenHotKeysStart()
  2305. {
  2306. return GetProfileLong("FirstTenHotKeysStart", 1);
  2307. }
  2308. void CGetSetOptions::SetFirstTenHotKeysStart(int val)
  2309. {
  2310. m_firstTenHotKeysStart = val;
  2311. SetProfileLong("FirstTenHotKeysStart", val);
  2312. }
  2313. int CGetSetOptions::GetFirstTenHotKeysFontSize()
  2314. {
  2315. return GetProfileLong("FirstTenHotKeysFontSize", 5);
  2316. }
  2317. void CGetSetOptions::SetFirstTenHotKeysFontSize(int val)
  2318. {
  2319. m_firstTenHotKeysFontSize = val;
  2320. SetProfileLong("FirstTenHotKeysFontSize", val);
  2321. }
  2322. BOOL CGetSetOptions::GetAddCFHDROP_OnDrag()
  2323. {
  2324. return GetProfileLong(_T("AddCFHDROP_OnDrag"), TRUE);
  2325. }
  2326. void CGetSetOptions::SetAddCFHDROP_OnDrag(BOOL val)
  2327. {
  2328. SetProfileLong(_T("AddCFHDROP_OnDrag"), val);
  2329. }
  2330. int CGetSetOptions::GetCopyAndSveDelay()
  2331. {
  2332. return GetProfileLong("CopyAndSveDelay", 1000);
  2333. }
  2334. void CGetSetOptions::SetCopyAndSveDelay(int val)
  2335. {
  2336. SetProfileLong("CopyAndSveDelay", val);
  2337. }
  2338. int CGetSetOptions::GetEditorDefaultFontSize()
  2339. {
  2340. return GetProfileLong("EditorDefaultFontSize", 14);
  2341. }
  2342. void CGetSetOptions::SetEditorDefaultFontSize(int val)
  2343. {
  2344. SetProfileLong("EditorDefaultFontSize", val);
  2345. }
  2346. BOOL CGetSetOptions::GetMoveSelectionOnOpenHotkey()
  2347. {
  2348. return GetProfileLong("MoveSelectionOnOpenHotkey", TRUE);
  2349. }
  2350. void CGetSetOptions::SetMoveSelectionOnOpenHotkey(BOOL val)
  2351. {
  2352. m_moveSelectionOnOpenHotkey = val;
  2353. SetProfileLong("MoveSelectionOnOpenHotkey", val);
  2354. }
  2355. BOOL CGetSetOptions::GetAllowBackToBackDuplicates()
  2356. {
  2357. return GetProfileLong("AllowBackToBackDuplicates", FALSE);
  2358. }
  2359. void CGetSetOptions::SetAllowBackToBackDuplicates(BOOL val)
  2360. {
  2361. m_allowBackToBackDuplicates = val;
  2362. SetProfileLong("AllowBackToBackDuplicates", val);
  2363. }