Options.cpp 71 KB

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