Options.cpp 71 KB

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