Options.cpp 64 KB

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