Options.cpp 66 KB

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