Options.cpp 73 KB

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