Options.cpp 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779
  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_ADDINS:
  1425. csDir += "Addins\\";
  1426. break;
  1427. case PATH_REMOTE_FILES:
  1428. if (CGetSetOptions::GetIsPortableDitto() == false)
  1429. {
  1430. csDir = GetTempFilePath();
  1431. }
  1432. csDir += "ReceivedFiles\\";
  1433. break;
  1434. case PATH_DRAG_FILES:
  1435. if (CGetSetOptions::GetIsPortableDitto() == false)
  1436. {
  1437. csDir = GetTempFilePath();
  1438. }
  1439. csDir += "DragFiles\\";
  1440. break;
  1441. case PATH_CLIP_DIFF:
  1442. if (CGetSetOptions::GetIsPortableDitto() == false)
  1443. {
  1444. csDir = GetTempFilePath();
  1445. }
  1446. csDir += _T("ClipCompare\\");
  1447. break;
  1448. case PATH_RESTORE_TEMP:
  1449. if (CGetSetOptions::GetIsPortableDitto() == false)
  1450. {
  1451. csDir = GetTempFilePath();
  1452. }
  1453. csDir += _T("RestoreDb\\");
  1454. break;
  1455. }
  1456. CreateDirectory(csDir, NULL);
  1457. return csDir;
  1458. }
  1459. long CGetSetOptions::GetDittoRestoreClipboardDelay()
  1460. {
  1461. return GetProfileLong("RestoreClipboardDelay", 750);
  1462. }
  1463. void CGetSetOptions::SetDittoRestoreClipboardDelay(long lDelay)
  1464. {
  1465. SetProfileLong("RestoreClipboardDelay", lDelay);
  1466. }
  1467. void CGetSetOptions::GetCopyBufferItem(int nPos, CCopyBufferItem &Item)
  1468. {
  1469. Item.m_lCopyHotKey = GetProfileLong(StrF(_T("CopyBufferCopyHotKey_%d"), nPos), 0);
  1470. Item.m_lPasteHotKey = GetProfileLong(StrF(_T("CopyBufferPasteHotKey_%d"), nPos), 0);
  1471. Item.m_lCutHotKey = GetProfileLong(StrF(_T("CopyBufferCutHotKey_%d"), nPos), 0);
  1472. Item.m_bPlaySoundOnCopy = GetProfileLong(StrF(_T("CopyBufferPlaySound_%d"), nPos), 0);
  1473. }
  1474. void CGetSetOptions::SetCopyBufferItem(int nPos, CCopyBufferItem &Item)
  1475. {
  1476. SetProfileLong(StrF(_T("CopyBufferCopyHotKey_%d"), nPos), Item.m_lCopyHotKey);
  1477. SetProfileLong(StrF(_T("CopyBufferPasteHotKey_%d"), nPos), Item.m_lPasteHotKey);
  1478. SetProfileLong(StrF(_T("CopyBufferCutHotKey_%d"), nPos), Item.m_lCutHotKey);
  1479. SetProfileLong(StrF(_T("CopyBufferPlaySound_%d"), nPos), Item.m_bPlaySoundOnCopy);
  1480. }
  1481. CString CGetSetOptions::GetMultiPasteSeparator(bool bConvertToLineFeeds)
  1482. {
  1483. CString csSep = GetProfileString(_T("MultiPasteSeparator"), _T("[LF]"));
  1484. if(bConvertToLineFeeds)
  1485. {
  1486. CString csLineFeed(_T("\r\n"));
  1487. csSep.Replace(_T("[LF]"), csLineFeed);
  1488. csSep.Replace(_T("[lf]"), csLineFeed);
  1489. }
  1490. return csSep;
  1491. }
  1492. void CGetSetOptions::SetMultiPasteSeparator(CString csSep)
  1493. {
  1494. SetProfileString(_T("MultiPasteSeparator"), csSep);
  1495. }
  1496. BOOL CGetSetOptions::GetSetCurrentDirectory()
  1497. {
  1498. if(m_portable)
  1499. {
  1500. CString csExePath = GetFilePath(GetExeFileName());
  1501. FIX_CSTRING_PATH(csExePath);
  1502. ::SetCurrentDirectory(csExePath);
  1503. }
  1504. return m_portable == true;
  1505. }
  1506. bool CGetSetOptions::GetIsPortableDitto()
  1507. {
  1508. return m_portable;
  1509. }
  1510. bool CGetSetOptions::GetIsWindowsApp()
  1511. {
  1512. return m_windowsApp;
  1513. }
  1514. bool CGetSetOptions::GetIsChocolateyApp()
  1515. {
  1516. return m_chocolateyApp;
  1517. }
  1518. CString CGetSetOptions::GetPasteString(CString csAppName)
  1519. {
  1520. CString csString = GetProfileString(csAppName, _T(""), _T("PasteStrings"));
  1521. if (csString.IsEmpty())
  1522. {
  1523. //edge is really slow to set focus so add a delay before sending the paste
  1524. if (csAppName == L"MicrosoftEdge.exe")
  1525. {
  1526. return _T("{DELAY 500}^{VKEY86}");
  1527. }
  1528. return GetDefaultPasteString();
  1529. }
  1530. return csString;
  1531. }
  1532. CString CGetSetOptions::GetDefaultPasteString()
  1533. {
  1534. //ascii value for v
  1535. //for other language keyboards v gets converted to something else so send the base ascii value
  1536. return GetProfileString(_T("DefaultPasteString"), _T("^{VKEY86}"));
  1537. }
  1538. void CGetSetOptions::SetDefaultPasteString(CString val)
  1539. {
  1540. SetProfileString(_T("DefaultPasteString"), val);
  1541. }
  1542. CString CGetSetOptions::GetCopyString(CString csAppName)
  1543. {
  1544. CString csString = GetProfileString(csAppName, _T(""), _T("CopyStrings"));
  1545. if(csString.IsEmpty())
  1546. return GetDefaultCopyString();
  1547. return csString;
  1548. }
  1549. CString CGetSetOptions::GetDefaultCopyString()
  1550. {
  1551. //ascii value for c
  1552. //for other language keyboards c gets converted to something else so send the base ascii value
  1553. return GetProfileString(_T("DefaultCopyString"), _T("^{VKEY67}"));
  1554. }
  1555. void CGetSetOptions::SetDefaultCopyString(CString val)
  1556. {
  1557. SetProfileString(_T("DefaultCopyString"), val);
  1558. }
  1559. CString CGetSetOptions::GetCutString(CString csAppName)
  1560. {
  1561. CString csString = GetProfileString(csAppName, _T(""), _T("CutStrings"));
  1562. if(csString.IsEmpty())
  1563. return GetDefaultCutString();
  1564. return csString;
  1565. }
  1566. CString CGetSetOptions::GetDefaultCutString()
  1567. {
  1568. //ascii value for x
  1569. //for other language keyboards x gets converted to something else so send the base ascii value
  1570. return GetProfileString(_T("DefaultCutString"), _T("^{VKEY88}"));
  1571. }
  1572. void CGetSetOptions::SetDefaultCutString(CString val)
  1573. {
  1574. SetProfileString(_T("DefaultCutString"), val);
  1575. }
  1576. BOOL CGetSetOptions::GetEditWordWrap()
  1577. {
  1578. return GetProfileLong(_T("EditWordWrap"), TRUE);
  1579. }
  1580. void CGetSetOptions::SetEditWordWrap(BOOL bSet)
  1581. {
  1582. SetProfileLong(_T("EditWordWrap"), bSet);
  1583. }
  1584. bool CGetSetOptions::GetAllowFriends()
  1585. {
  1586. return (GetProfileLong("AllowFriends", TRUE) == TRUE);
  1587. }
  1588. long CGetSetOptions::GetAutoMaxDelay()
  1589. {
  1590. return GetProfileLong(_T("AutoMaxDelaySeconds"), 2);
  1591. }
  1592. void CGetSetOptions::SetAutoMaxDelay(long lDelay)
  1593. {
  1594. SetProfileLong(_T("AutoMaxDelaySeconds"), lDelay);
  1595. }
  1596. void CGetSetOptions::SetTheme(CString csTheme)
  1597. {
  1598. SetProfileString(_T("Theme2"), csTheme);
  1599. }
  1600. CString CGetSetOptions::GetTheme()
  1601. {
  1602. return GetProfileString(_T("Theme2"), "");
  1603. }
  1604. long CGetSetOptions::GetKeyStateWaitTimerCount()
  1605. {
  1606. return GetProfileLong(_T("KeyStateWaitTimerCount"), 20);
  1607. }
  1608. long CGetSetOptions::GetKeyStatePasteDelay()
  1609. {
  1610. return GetProfileLong(_T("KeyStatePasteDelay"), 200);
  1611. }
  1612. DWORD CGetSetOptions::GetDittoHotKey()
  1613. {
  1614. return (DWORD)GetProfileLong(_T("DittoHotKey"), 704);
  1615. }
  1616. DWORD CGetSetOptions::SendKeysDelay()
  1617. {
  1618. return (DWORD)GetProfileLong(_T("SendKeysDelay"), 100);
  1619. }
  1620. void CGetSetOptions::SetSendKeysDelay(DWORD val)
  1621. {
  1622. SetProfileLong(_T("SendKeysDelay"), val);
  1623. }
  1624. DWORD CGetSetOptions::WaitForActiveWndTimeout()
  1625. {
  1626. return (DWORD)GetProfileLong(_T("WaitForActiveWndTimeout"), 500);
  1627. }
  1628. DWORD CGetSetOptions::FocusChangedDelay()
  1629. {
  1630. return (DWORD)GetProfileLong(_T("FocusChangedDelay"), 100);
  1631. }
  1632. DWORD CGetSetOptions::FocusWndTimerTimeout()
  1633. {
  1634. return (DWORD)GetProfileLong(_T("FocusWndTimerTimeout"), 2000);
  1635. }
  1636. BOOL CGetSetOptions::GetConnectedToClipboard()
  1637. {
  1638. return GetProfileLong("ConnectedToClipboard", TRUE);
  1639. }
  1640. void CGetSetOptions::SetConnectedToClipboard(BOOL val)
  1641. {
  1642. SetProfileLong("ConnectedToClipboard", val);
  1643. }
  1644. DWORD CGetSetOptions::GetTextOnlyRestoreDelay()
  1645. {
  1646. return (DWORD)GetProfileLong(_T("TextOnlyRestoreDelay"), 2000);
  1647. }
  1648. DWORD CGetSetOptions::GetTextOnlyPasteDelay()
  1649. {
  1650. return (DWORD)GetProfileLong(_T("TextOnlyPasteDelay"), 0);
  1651. }
  1652. BOOL CGetSetOptions::GetSetFocusToApp(CString csAppName)
  1653. {
  1654. CString focusCheck;
  1655. focusCheck = "SetFocus_";
  1656. focusCheck += csAppName;
  1657. return GetProfileLong(focusCheck, FALSE);
  1658. }
  1659. DWORD CGetSetOptions::SelectedIndex()
  1660. {
  1661. return (DWORD)GetProfileLong(_T("SelectedIndex"), 0);
  1662. }
  1663. void CGetSetOptions::SetSelectedIndex(int val)
  1664. {
  1665. SetProfileLong(_T("SelectedIndex"), val);
  1666. }
  1667. void CGetSetOptions::SetCopyAppInclude(CString csAppName)
  1668. {
  1669. SetProfileString(_T("CopyAppInclude"), csAppName);
  1670. }
  1671. CString CGetSetOptions::GetCopyAppInclude()
  1672. {
  1673. CString includeApp = GetProfileString(_T("CopyAppInclude"), "*");
  1674. if(includeApp == "")
  1675. {
  1676. includeApp = "*";
  1677. }
  1678. return includeApp;
  1679. }
  1680. void CGetSetOptions::SetCopyAppExclude(CString csAppName)
  1681. {
  1682. SetProfileString(_T("CopyAppExclude"), csAppName);
  1683. }
  1684. CString CGetSetOptions::GetCopyAppExclude()
  1685. {
  1686. return GetProfileString(_T("CopyAppExclude"), "");
  1687. }
  1688. CString CGetSetOptions::GetCopyAppSeparator()
  1689. {
  1690. return GetProfileString(_T("CopyAppSeparator"), ";");
  1691. }
  1692. DWORD CGetSetOptions::GetNoFormatsRetryDelay()
  1693. {
  1694. return GetProfileLong(_T("NoFormatsRetryDelay"), 200);
  1695. }
  1696. DWORD CGetSetOptions::GetMainDeletesDeleteCount()
  1697. {
  1698. return GetProfileLong(_T("MainDeletesDeleteCount"), 100);
  1699. }
  1700. DWORD CGetSetOptions::GetIdleSecondsBeforeDelete()
  1701. {
  1702. return GetProfileLong(_T("IdleSecondsBeforeDelete"), 60*10);
  1703. }
  1704. DWORD CGetSetOptions::GetDbTimeout()
  1705. {
  1706. return GetProfileLong(_T("DbTimeout"), 5000);
  1707. }
  1708. DWORD CGetSetOptions::GetFunnyTickCountAdjustment()
  1709. {
  1710. return GetProfileLong(_T("FunnyTickCountAdjustment"), 300001);
  1711. }
  1712. DWORD CGetSetOptions::GetMinIdleTimeBeforeTrackFocus()
  1713. {
  1714. return GetProfileLong(_T("MinIdleTimeBeforeTrackFocus"), 100);
  1715. }
  1716. DWORD CGetSetOptions::GetTimeBeforeExpandWindow()
  1717. {
  1718. return GetProfileLong(_T("TimeBeforeExpandWindow"), 250);
  1719. }
  1720. DWORD CGetSetOptions::GetUseGuiThreadInfoForFocus()
  1721. {
  1722. return GetProfileLong(_T("UseGuiThreadInfoForFocus"), 1);
  1723. }
  1724. void CGetSetOptions::SetSearchDescription(BOOL val)
  1725. {
  1726. SetProfileLong(_T("SearchDescription"), val);
  1727. }
  1728. BOOL CGetSetOptions::GetSearchDescription()
  1729. {
  1730. return GetProfileLong(_T("SearchDescription"), 1);
  1731. }
  1732. void CGetSetOptions::SetSearchFullText(BOOL val)
  1733. {
  1734. SetProfileLong(_T("SearchFullText"), val);
  1735. }
  1736. BOOL CGetSetOptions::GetSearchFullText()
  1737. {
  1738. return GetProfileLong(_T("SearchFullText"), 0);
  1739. }
  1740. void CGetSetOptions::SetSearchQuickPaste(BOOL val)
  1741. {
  1742. SetProfileLong(_T("SearchQuickPaste"), val);
  1743. }
  1744. BOOL CGetSetOptions::GetSearchQuickPaste()
  1745. {
  1746. return GetProfileLong(_T("SearchQuickPaste"), 0);
  1747. }
  1748. void CGetSetOptions::SetSimpleTextSearch(BOOL val)
  1749. {
  1750. SetProfileLong(_T("SimpleTextSearch"), val);
  1751. }
  1752. BOOL CGetSetOptions::GetSimpleTextSearch()
  1753. {
  1754. return GetProfileLong(_T("SimpleTextSearch"), 0);
  1755. }
  1756. void CGetSetOptions::SetRegExTextSearch(BOOL val)
  1757. {
  1758. SetProfileLong(_T("RegExTextSearch"), val);
  1759. }
  1760. BOOL CGetSetOptions::GetRegExTextSearch()
  1761. {
  1762. return GetProfileLong(_T("RegExTextSearch"), 0);
  1763. }
  1764. void CGetSetOptions::SetMoveClipsOnGlobal10(BOOL val)
  1765. {
  1766. SetProfileLong(_T("MoveClipsOnGlobal10"), val);
  1767. }
  1768. BOOL CGetSetOptions::GetMoveClipsOnGlobal10()
  1769. {
  1770. return GetProfileLong(_T("MoveClipsOnGlobal10"), 0);
  1771. }
  1772. void CGetSetOptions::SetShowScrollBar(BOOL val)
  1773. {
  1774. m_showScrollBar = val;
  1775. SetProfileLong(_T("ShowScrollBar"), val);
  1776. }
  1777. BOOL CGetSetOptions::GetShowScrollBar()
  1778. {
  1779. return GetProfileLong(_T("ShowScrollBar"), 0);
  1780. }
  1781. void CGetSetOptions::SetPasteAsAdmin(BOOL val)
  1782. {
  1783. SetProfileLong(_T("PasteAsAdmin"), val);
  1784. }
  1785. BOOL CGetSetOptions::GetPasteAsAdmin()
  1786. {
  1787. return GetProfileLong(_T("PasteAsAdmin"), 1);
  1788. }
  1789. void CGetSetOptions::SetRememberDescPos(BOOL val)
  1790. {
  1791. SetProfileLong(_T("RememberDescPos"), val);
  1792. }
  1793. BOOL CGetSetOptions::GetRememberDescPos()
  1794. {
  1795. return GetProfileLong(_T("RememberDescPos"), FALSE);
  1796. }
  1797. void CGetSetOptions::SetSizeDescWindowToContent(BOOL val)
  1798. {
  1799. SetProfileLong(_T("SizeDescWindowToContent"), val);
  1800. }
  1801. BOOL CGetSetOptions::GetSizeDescWindowToContent()
  1802. {
  1803. return GetProfileLong(_T("SizeDescWindowToContent"), TRUE);
  1804. }
  1805. void CGetSetOptions::SetScaleImagesToDescWindow(BOOL val)
  1806. {
  1807. SetProfileLong(_T("ScaleImagesToDescWindow"), val);
  1808. }
  1809. BOOL CGetSetOptions::GetScaleImagesToDescWindow()
  1810. {
  1811. return GetProfileLong(_T("ScaleImagesToDescWindow"), TRUE);
  1812. }
  1813. void CGetSetOptions::SetDescWndPoint(CPoint point)
  1814. {
  1815. SetResolutionProfileLong("DescWndX", point.x);
  1816. SetResolutionProfileLong("DescWndY", point.y);
  1817. }
  1818. void CGetSetOptions::GetDescWndPoint(CPoint &point)
  1819. {
  1820. point.x = GetResolutionProfileLong("DescWndX", 100);
  1821. point.y = GetResolutionProfileLong("DescWndY", 100);
  1822. }
  1823. void CGetSetOptions::GetDescWndSize(CSize &size)
  1824. {
  1825. size.cx = GetResolutionProfileLong("DescWndCX", 300);
  1826. size.cy = GetResolutionProfileLong("DescWndCY", 300);
  1827. if(size.cx <= 0 && size.cy <= 0)
  1828. {
  1829. size.cx = 300;
  1830. size.cy = 300;
  1831. }
  1832. }
  1833. void CGetSetOptions::SetDescWndSize(CSize size)
  1834. {
  1835. SetResolutionProfileLong("DescWndCX", size.cx);
  1836. SetResolutionProfileLong("DescWndCY", size.cy);
  1837. }
  1838. void CGetSetOptions::SetShowInTaskBar(BOOL val)
  1839. {
  1840. SetProfileLong(_T("ShowInTaskBar"), val);
  1841. }
  1842. BOOL CGetSetOptions::GetShowInTaskBar()
  1843. {
  1844. return GetProfileLong(_T("ShowInTaskBar"), FALSE);
  1845. }
  1846. void CGetSetOptions::SetDiffApp(CString val)
  1847. {
  1848. SetProfileString(_T("DiffApp"), val);
  1849. }
  1850. CString CGetSetOptions::GetDiffApp()
  1851. {
  1852. return GetProfileString(_T("DiffApp"), _T(""));
  1853. }
  1854. void CGetSetOptions::SetQRCodeBorderPixels(int val)
  1855. {
  1856. SetProfileLong(_T("QRCodeBorderPixels"), val);
  1857. }
  1858. int CGetSetOptions::GetQRCodeBorderPixels()
  1859. {
  1860. return GetProfileLong(_T("QRCodeBorderPixels"), 30);
  1861. }
  1862. CString CGetSetOptions::GetTranslateUrl()
  1863. {
  1864. return GetProfileString(_T("TranslateUrl"), _T("https://translate.google.com/?tl=en#auto/en/%s"));
  1865. }
  1866. void CGetSetOptions::SetNetworkReadTimeoutMS(int val)
  1867. {
  1868. SetProfileLong(_T("NetworkReadTimeoutMS"), val);
  1869. }
  1870. int CGetSetOptions::GetNetworkReadTimeoutMS()
  1871. {
  1872. return GetProfileLong(_T("NetworkReadTimeoutMS"), 30000);
  1873. }
  1874. void CGetSetOptions::SetRequestFilesUsingIP(int val)
  1875. {
  1876. SetProfileLong(_T("RequestFilesUsingIP"), val);
  1877. }
  1878. int CGetSetOptions::GetRequestFilesUsingIP()
  1879. {
  1880. return GetProfileLong(_T("RequestFilesUsingIP"), 0);
  1881. }
  1882. int CGetSetOptions::ReadRandomFileInterval()
  1883. {
  1884. return GetProfileLong(_T("ReadRandomFileInterval"), 60);
  1885. }
  1886. int CGetSetOptions::ReadRandomFileIdleMin()
  1887. {
  1888. return GetProfileLong(_T("ReadRandomFileIdleMin"), 30);
  1889. }
  1890. BOOL CGetSetOptions::GetShowGroupsInMainList()
  1891. {
  1892. return GetProfileLong(_T("ShowGroupsInMainList"), 0);
  1893. }
  1894. void CGetSetOptions::SetShowGroupsInMainList(BOOL val)
  1895. {
  1896. SetProfileLong(_T("ShowGroupsInMainList"), val);
  1897. }
  1898. void CGetSetOptions::SetGroupDoubleClickTimeMS(int val)
  1899. {
  1900. SetProfileLong(_T("GroupDoubleClickTimeMS"), val);
  1901. }
  1902. int CGetSetOptions::GetGroupDoubleClickTimeMS()
  1903. {
  1904. return GetProfileLong(_T("GroupDoubleClickTimeMS"), 500);
  1905. }
  1906. void CGetSetOptions::SetSaveToGroupTimeoutMS(int val)
  1907. {
  1908. SetProfileLong(_T("SaveToGroupTimeoutMS"), val);
  1909. }
  1910. int CGetSetOptions::GetSaveToGroupTimeoutMS()
  1911. {
  1912. return GetProfileLong(_T("SaveToGroupTimeoutMS"), 1000);
  1913. }
  1914. void CGetSetOptions::SetCopyReasonTimeoutMS(int val)
  1915. {
  1916. SetProfileLong(_T("CopyReasonTimeoutMS"), val);
  1917. }
  1918. int CGetSetOptions::GetCopyReasonTimeoutMS()
  1919. {
  1920. return GetProfileLong(_T("CopyReasonTimeoutMS"), 1000);
  1921. }
  1922. void CGetSetOptions::SetWindowsResumeDelayReOpenDbMS(int val)
  1923. {
  1924. SetProfileLong(_T("WindowsResumeDelayReOpenDbMS"), val);
  1925. }
  1926. int CGetSetOptions::GetWindowsResumeDelayReOpenDbMS()
  1927. {
  1928. return GetProfileLong(_T("WindowsResumeDelayReOpenDbMS"), 2000);
  1929. }
  1930. BOOL CGetSetOptions::GetShowMsgWndOnCopyToGroup()
  1931. {
  1932. return GetProfileLong(_T("ShowMsgWndOnCopyToGroup"), TRUE);
  1933. }
  1934. void CGetSetOptions::SetShowMsgWndOnCopyToGroup(BOOL val)
  1935. {
  1936. SetProfileLong(_T("ShowMsgWndOnCopyToGroup"), val);
  1937. }
  1938. int CGetSetOptions::GetActionShortCutA(DWORD action, int pos, CString refData)
  1939. {
  1940. CString actionText;
  1941. if (refData != _T(""))
  1942. {
  1943. actionText.Format(_T("QP_ShortCut_%d_%s_%d_A"), action, refData, pos);
  1944. }
  1945. else
  1946. {
  1947. actionText.Format(_T("QP_ShortCut_%d_%d_A"), action, pos);
  1948. }
  1949. int ret = GetProfileLong(actionText, -1);
  1950. if (ret == -1)
  1951. {
  1952. ret = ActionEnums::GetDefaultShortCutKeyA((ActionEnums::ActionEnumValues)action, pos);
  1953. }
  1954. return ret;
  1955. }
  1956. void CGetSetOptions::SetActionShortCutA(int action, DWORD shortcut, int pos, CString refData)
  1957. {
  1958. CString actionText;
  1959. if (refData != _T(""))
  1960. {
  1961. actionText.Format(_T("QP_ShortCut_%d_%s_%d_A"), action, refData, pos);
  1962. }
  1963. else
  1964. {
  1965. actionText.Format(_T("QP_ShortCut_%d_%d_A"), action, pos);
  1966. }
  1967. SetProfileLong(actionText, shortcut);
  1968. }
  1969. int CGetSetOptions::GetActionShortCutB(DWORD action, int pos, CString refData)
  1970. {
  1971. CString actionText;
  1972. if (refData != _T(""))
  1973. {
  1974. actionText.Format(_T("QP_ShortCut_%d_%s_%d_B"), action, refData, pos);
  1975. }
  1976. else
  1977. {
  1978. actionText.Format(_T("QP_ShortCut_%d_%d_B"), action, pos);
  1979. }
  1980. int ret = GetProfileLong(actionText, -1);
  1981. if (ret == -1)
  1982. {
  1983. ret = ActionEnums::GetDefaultShortCutKeyB((ActionEnums::ActionEnumValues)action, pos);
  1984. }
  1985. return ret;
  1986. }
  1987. void CGetSetOptions::SetActionShortCutB(int action, DWORD shortcut, int pos, CString refData)
  1988. {
  1989. CString actionText;
  1990. if (refData != _T(""))
  1991. {
  1992. actionText.Format(_T("QP_ShortCut_%d_%s_%d_B"), action, refData, pos);
  1993. }
  1994. else
  1995. {
  1996. actionText.Format(_T("QP_ShortCut_%d_%d_B"), action, pos);
  1997. }
  1998. SetProfileLong(actionText, shortcut);
  1999. }
  2000. BOOL CGetSetOptions::GetShowAlwaysOnTopWarning()
  2001. {
  2002. return GetProfileLong(_T("ShowAlwaysOnTopWarning"), TRUE);
  2003. }
  2004. void CGetSetOptions::SetShowAlwaysOnTopWarning(BOOL show)
  2005. {
  2006. m_bShowAlwaysOnTopWarning = show;
  2007. SetProfileLong(_T("ShowAlwaysOnTopWarning"), show);
  2008. }
  2009. BOOL CGetSetOptions::GetUseIPFromAccept()
  2010. {
  2011. return GetProfileLong(_T("UseIPFromAccept"), TRUE);
  2012. }
  2013. void CGetSetOptions::SetUseIPFromAccept(BOOL useAccept)
  2014. {
  2015. SetProfileLong(_T("UseIPFromAccept"), useAccept);
  2016. }
  2017. int CGetSetOptions::GetDragId()
  2018. {
  2019. return GetProfileLong(_T("DragId"), 1);
  2020. }
  2021. void CGetSetOptions::SetDragId(int id)
  2022. {
  2023. SetProfileLong(_T("DragId"), id);
  2024. }
  2025. BOOL CGetSetOptions::GetShowIfClipWasPasted()
  2026. {
  2027. return GetProfileLong(_T("ShowIfClipWasPasted"), TRUE);
  2028. }
  2029. void CGetSetOptions::SetShowIfClipWasPasted(BOOL val)
  2030. {
  2031. SetProfileLong(_T("ShowIfClipWasPasted"), val);
  2032. }
  2033. int CGetSetOptions::GetLastGroupToggle()
  2034. {
  2035. return GetProfileLong(_T("LastGroupToggle"), -2);
  2036. }
  2037. void CGetSetOptions::SetLastGroupToggle(int val)
  2038. {
  2039. SetProfileLong(_T("LastGroupToggle"), val);
  2040. }
  2041. BOOL CGetSetOptions::GetMouseClickHidesDescription()
  2042. {
  2043. return GetProfileLong(_T("MouseClickHidesDescription"), TRUE);
  2044. }
  2045. void CGetSetOptions::SetMouseClickHidesDescription(int val)
  2046. {
  2047. SetProfileLong(_T("MouseClickHidesDescription"), val);
  2048. }
  2049. BOOL CGetSetOptions::GetWrapDescriptionText()
  2050. {
  2051. return GetProfileLong(_T("WrapDescriptionText"), FALSE);
  2052. }
  2053. void CGetSetOptions::SetWrapDescriptionText(int val)
  2054. {
  2055. SetProfileLong(_T("WrapDescriptionText"), val);
  2056. }
  2057. BOOL CGetSetOptions::GetUseUISelectedGroupForLastTenCopies()
  2058. {
  2059. return GetProfileLong(_T("UseUISelectedGroupForLastTenCopies"), FALSE);
  2060. }
  2061. void CGetSetOptions::SetUseUISelectedGroupForLastTenCopies(int val)
  2062. {
  2063. SetProfileLong(_T("UseUISelectedGroupForLastTenCopies"), val);
  2064. }
  2065. int CGetSetOptions::GetDelayRenderLockout()
  2066. {
  2067. return GetProfileLong(_T("DelayRenderLockout"), 1000);
  2068. }
  2069. void CGetSetOptions::SetDelayRenderLockout(int val)
  2070. {
  2071. SetProfileLong(_T("DelayRenderLockout"), val);
  2072. }
  2073. BOOL CGetSetOptions::GetAdjustClipsForCRC()
  2074. {
  2075. return GetProfileLong(_T("AdjustClipsForCRC"), TRUE);
  2076. }
  2077. void CGetSetOptions::SetAdjustClipsForCRC(int val)
  2078. {
  2079. SetProfileLong(_T("AdjustClipsForCRC"), val);
  2080. }
  2081. BOOL CGetSetOptions::GetCheckMd5OnFileTransfers()
  2082. {
  2083. return GetProfileLong(_T("CheckMd5OnFileTransfers"), TRUE);
  2084. }
  2085. void CGetSetOptions::SetCheckMd5OnFileTransfers(int val)
  2086. {
  2087. SetProfileLong(_T("CheckMd5OnFileTransfers"), val);
  2088. }
  2089. int CGetSetOptions::GetBalloonTimeout()
  2090. {
  2091. return GetProfileLong(_T("BalloonTimeout"), 2500);
  2092. }
  2093. void CGetSetOptions::SetBalloonTimeout(int val)
  2094. {
  2095. SetProfileLong(_T("BalloonTimeout"), val);
  2096. }
  2097. void CGetSetOptions::SetCustomSendToList(CString val)
  2098. {
  2099. SetProfileString(_T("CustomSendToList2"), val);
  2100. }
  2101. CString CGetSetOptions::GetCustomSendToList()
  2102. {
  2103. return GetProfileString("CustomSendToList2", "");
  2104. }
  2105. int CGetSetOptions::GetMaxFileContentsSize()
  2106. {
  2107. return GetProfileLong(_T("MaxFileContentsSize"), 64000000);
  2108. }
  2109. void CGetSetOptions::SetMaxFileContentsSize(int val)
  2110. {
  2111. SetProfileLong(_T("MaxFileContentsSize"), val);
  2112. }
  2113. int CGetSetOptions::GetErrorMsgPopupTimeout()
  2114. {
  2115. return GetProfileLong(_T("ErrorMsgPopupTimeout"), 3500);
  2116. }
  2117. void CGetSetOptions::SetErrorMsgPopupTimeout(int val)
  2118. {
  2119. SetProfileLong(_T("ErrorMsgPopupTimeout"), val);
  2120. }
  2121. void CGetSetOptions::SetRegexFilter(CString val, int pos)
  2122. {
  2123. CString cs;
  2124. cs.Format(_T("RegexFilter_%d"), pos);
  2125. m_regexHelper.SetRegEx(pos, std::wstring(val));
  2126. SetProfileString(cs, val);
  2127. }
  2128. CString CGetSetOptions::GetRegexFilter(int pos)
  2129. {
  2130. CString cs;
  2131. cs.Format(_T("RegexFilter_%d"), pos);
  2132. return GetProfileString(cs, "");
  2133. }
  2134. void CGetSetOptions::SetRegexFilterByProcessName(CString val, int pos)
  2135. {
  2136. CString cs;
  2137. cs.Format(_T("RegexFilterByProcessName_%d"), pos);
  2138. m_regexHelper.SetProcessFilter(pos, val);
  2139. SetProfileString(cs, val);
  2140. }
  2141. CString CGetSetOptions::GetRegexFilterByProcessName(int pos)
  2142. {
  2143. CString cs;
  2144. cs.Format(_T("RegexFilterByProcessName_%d"), pos);
  2145. return GetProfileString(cs, "");
  2146. }
  2147. BOOL CGetSetOptions::GetOpenToGroupByActiveExe()
  2148. {
  2149. return GetProfileLong(_T("OpenToGroupByActiveExe"), TRUE);
  2150. }
  2151. void CGetSetOptions::SetOpenToGroupByActiveExe(int val)
  2152. {
  2153. SetProfileLong(_T("OpenToGroupByActiveExe"), val);
  2154. }
  2155. BOOL CGetSetOptions::GetExcludeCF_DIBInExcel()
  2156. {
  2157. return GetProfileLong(_T("ExcludeCF_DIBInExcel"), TRUE);
  2158. }
  2159. void CGetSetOptions::SetExcludeCF_DIBInExcel(int val)
  2160. {
  2161. m_excludeCF_DIBInExcel = val;
  2162. SetProfileLong(_T("ExcludeCF_DIBInExcel"), val);
  2163. }
  2164. BOOL CGetSetOptions::GetShowStartupMessage()
  2165. {
  2166. return GetProfileLong(_T("ShowStartupMessage"), TRUE);
  2167. }
  2168. void CGetSetOptions::SetShowStartupMessage(int val)
  2169. {
  2170. SetProfileLong(_T("ShowStartupMessage"), val);
  2171. }
  2172. CString CGetSetOptions::GetCopyScriptsXml()
  2173. {
  2174. return GetProfileString("CopyScriptsXml", "");
  2175. }
  2176. void CGetSetOptions::SetCopyScriptsXml(CString val)
  2177. {
  2178. m_copyScripts.Load(val);
  2179. SetProfileString(_T("CopyScriptsXml"), val);
  2180. }
  2181. CString CGetSetOptions::GetPasteScriptsXml()
  2182. {
  2183. return GetProfileString("PasteScriptsXml", "");
  2184. }
  2185. void CGetSetOptions::SetPasteScriptsXml(CString val)
  2186. {
  2187. m_pasteScripts.Load(val);
  2188. SetProfileString(_T("PasteScriptsXml"), val);
  2189. }
  2190. long CGetSetOptions::GetToolTipTimeout()
  2191. {
  2192. return GetProfileLong("ToolTipTimeout", -1);
  2193. }
  2194. void CGetSetOptions::SetToolTipTimeout(long val)
  2195. {
  2196. m_tooltipTimeout = val;
  2197. SetProfileLong("ToolTipTimeout", val);
  2198. }
  2199. CString CGetSetOptions::GetPastSearchXml()
  2200. {
  2201. return GetProfileString("PastSearchXml", "");
  2202. }
  2203. void CGetSetOptions::SetPastSearchXml(CString val)
  2204. {
  2205. SetProfileString(_T("PastSearchXml"), val);
  2206. }
  2207. BOOL CGetSetOptions::GetShowMsgWhenReceivingManualSentClip()
  2208. {
  2209. return GetProfileLong("ShowMsgWhenReceivingManualSentClip", TRUE);
  2210. }
  2211. void CGetSetOptions::SetShowMsgWhenReceivingManualSentClip(BOOL val)
  2212. {
  2213. SetProfileLong("ShowMsgWhenReceivingManualSentClip", val);
  2214. }
  2215. BOOL CGetSetOptions::GetCleanRTFBeforeDrawing()
  2216. {
  2217. return GetProfileLong("CleanRTFBeforeDrawing", TRUE);
  2218. }
  2219. void CGetSetOptions::SetCleanRTFBeforeDrawing(BOOL val)
  2220. {
  2221. m_cleanRTFBeforeDrawing = true;
  2222. SetProfileLong("CleanRTFBeforeDrawing", val);
  2223. }
  2224. BOOL CGetSetOptions::GetDisableExpireClipsConfig()
  2225. {
  2226. return GetProfileLong("DisableExpireClipsConfig", FALSE);
  2227. }
  2228. void CGetSetOptions::SetDisableExpireClipsConfig(BOOL val)
  2229. {
  2230. SetProfileLong("DisableExpireClipsConfig", val);
  2231. }
  2232. BOOL CGetSetOptions::GetRevertToTopLevelGroup()
  2233. {
  2234. return GetProfileLong("RevertToTopLevelGroup", FALSE);
  2235. }
  2236. void CGetSetOptions::SetRevertToTopLevelGroup(BOOL val)
  2237. {
  2238. SetProfileLong("RevertToTopLevelGroup", val);
  2239. }
  2240. BOOL CGetSetOptions::GetUpdateClipOrderOnCtrlC()
  2241. {
  2242. return GetProfileLong("UpdateClipOrderOnCtrlC", FALSE);
  2243. }
  2244. void CGetSetOptions::SetUpdateClipOrderOnCtrlC(BOOL val)
  2245. {
  2246. SetProfileLong("UpdateClipOrderOnCtrlC", val);
  2247. }
  2248. int CGetSetOptions::GetMaxToolTipLines()
  2249. {
  2250. return GetProfileLong("MaxToolTipLines", 30);
  2251. }
  2252. void CGetSetOptions::SetMaxToolTipLines(int val)
  2253. {
  2254. SetProfileLong("MaxToolTipLines", val);
  2255. }
  2256. int CGetSetOptions::GetMaxToolTipCharacters()
  2257. {
  2258. return GetProfileLong("MaxToolTipCharacters", 1000);
  2259. }
  2260. void CGetSetOptions::SetMaxToolTipCharacters(int val)
  2261. {
  2262. SetProfileLong("MaxToolTipCharacters", val);
  2263. }