Options.cpp 67 KB

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