Options.cpp 69 KB

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