Options.cpp 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375
  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_bU3 = false;
  55. bool CGetSetOptions::m_bInConversion = false;
  56. bool CGetSetOptions::m_bFromIni = false;
  57. bool CGetSetOptions::m_portable = false;
  58. CString CGetSetOptions::m_csIniFileName;
  59. __int64 CGetSetOptions::nLastDbWriteTime = 0;
  60. CTheme CGetSetOptions::m_Theme;
  61. BOOL CGetSetOptions::m_showScrollBar = false;
  62. CGetSetOptions g_Opt;
  63. BOOL CGetSetOptions::m_bShowAlwaysOnTopWarning = TRUE;
  64. CGetSetOptions::CGetSetOptions()
  65. {
  66. }
  67. CGetSetOptions::~CGetSetOptions()
  68. {
  69. }
  70. void CGetSetOptions::LoadSettings()
  71. {
  72. m_csIniFileName = GetIniFileName(true);
  73. CString portable = GetFilePath(m_csIniFileName);
  74. portable += _T("portable");
  75. if(FileExists(portable))
  76. {
  77. m_portable = true;
  78. }
  79. if(m_bU3)
  80. {
  81. m_bFromIni = true;
  82. }
  83. else
  84. {
  85. //first check if ini file is in app directory
  86. if(m_portable || FileExists(m_csIniFileName))
  87. {
  88. m_bFromIni = true;
  89. }
  90. else
  91. {
  92. //next check if it's in app data
  93. m_csIniFileName = GetIniFileName(false);
  94. if(FileExists(m_csIniFileName))
  95. {
  96. m_bFromIni = true;
  97. }
  98. }
  99. }
  100. if(m_bFromIni)
  101. {
  102. CString csPath = GetFilePath(m_csIniFileName);
  103. if(FileExists(csPath) == FALSE)
  104. CreateDirectory(csPath, NULL);
  105. }
  106. GetSetCurrentDirectory();
  107. //First time we run, set some defaults
  108. if (GetDBPath() == _T("") &&
  109. GetTotalCopyCount() == 0)
  110. {
  111. SetCheckForMaxEntries(TRUE);
  112. SetSimpleTextSearch(TRUE);
  113. }
  114. m_nLinesPerRow = GetLinesPerRow();
  115. m_bUseCtrlNumAccel = GetUseCtrlNumForFirstTenHotKeys();
  116. m_bAllowDuplicates = GetAllowDuplicates();
  117. m_bUpdateTimeOnPaste = GetUpdateTimeOnPaste();
  118. m_bSaveMultiPaste = GetSaveMultiPaste();
  119. m_bShowPersistent = GetShowPersistent();
  120. m_bDescTextSize = GetDescTextSize();
  121. m_bDescShowLeadingWhiteSpace = GetDescShowLeadingWhiteSpace();
  122. m_bAllwaysShowDescription = GetAllwaysShowDescription();
  123. m_bDoubleClickingOnCaptionDoes = GetDoubleClickingOnCaptionDoes();
  124. m_bPrompForNewGroupName = GetPrompForNewGroupName();
  125. m_bSendPasteOnFirstTenHotKeys = GetSendPasteOnFirstTenHotKeys();
  126. m_csIPListToPutOnClipboard = GetListToPutOnClipboard();
  127. m_bLogSendReceiveErrors = GetLogSendReceiveErrors();
  128. m_HideDittoOnHotKeyIfAlreadyShown = GetHideDittoOnHotKeyIfAlreadyShown();
  129. m_lPort = GetPort();
  130. m_bDrawThumbnail = GetDrawThumbnail();
  131. m_csPassword = GetNetworkPassword();
  132. m_bDrawRTF = GetDrawRTF();
  133. m_bMultiPasteReverse = GetMultiPasteReverse();
  134. m_csPlaySoundOnCopy = GetPlaySoundOnCopy();
  135. m_bSendPasteMessageAfterSelection = GetSendPasteAfterSelection();
  136. m_bFindAsYouType = GetFindAsYouType();
  137. m_bEnsureEntireWindowCanBeSeen = GetEnsureEntireWindowCanBeSeen();
  138. m_bShowAllClipsInMainList = GetShowAllClipsInMainList();
  139. m_lMaxClipSizeInBytes = GetMaxClipSizeInBytes();
  140. m_dwSaveClipDelay = GetSaveClipDelay();
  141. m_lProcessDrawClipboardDelay = GetProcessDrawClipboardDelay();
  142. m_bEnableDebugLogging = GetEnableDebugLogging();
  143. m_bEnsureConnectToClipboard = GetEnsureConnectToClipboard();
  144. m_bOutputDebugString = false;
  145. m_showScrollBar = GetShowScrollBar();
  146. m_bShowAlwaysOnTopWarning = GetShowAlwaysOnTopWarning();
  147. GetExtraNetworkPassword(true);
  148. for(int i = 0; i < MAX_SEND_CLIENTS; i++)
  149. {
  150. GetSendClients(i);
  151. }
  152. GetClientSendCount();
  153. //If running from a U3 device and no language file as been asigned
  154. //then use the language defined by the U3 launcher
  155. if(m_bU3)
  156. {
  157. CString csLanguage = GetLanguageFile();
  158. if(csLanguage.IsEmpty())
  159. {
  160. CString csLanguage = GETENV(_T("U3_ENV_LANGUAGE"));
  161. long lLanguage = ATOI(csLanguage);
  162. csLanguage.Empty();
  163. switch(lLanguage)
  164. {
  165. case 1036: //French
  166. csLanguage = _T("Français");
  167. break;
  168. case 1040: //Italian
  169. csLanguage = _T("Italiano");
  170. break;
  171. case 1031: //German
  172. csLanguage = _T("German");
  173. break;
  174. case 3082: //German
  175. csLanguage = _T("Español");
  176. break;
  177. }
  178. if(csLanguage.IsEmpty() == FALSE)
  179. {
  180. SetLanguageFile(csLanguage);
  181. }
  182. }
  183. }
  184. m_Theme.Load(GetTheme());
  185. }
  186. void CGetSetOptions::ConverSettingsToIni()
  187. {
  188. m_bInConversion = true;
  189. CSize sz;
  190. CPoint pt;
  191. GetQuickPasteSize(sz);
  192. SetQuickPasteSize(sz);
  193. GetQuickPastePoint(pt);
  194. SetQuickPastePoint(pt);
  195. GetEditWndSize(sz);
  196. SetEditWndSize(sz);
  197. GetEditWndPoint(pt);
  198. SetEditWndPoint(pt);
  199. SetShowIconInSysTray(GetShowIconInSysTray());
  200. SetRunOnStartUp(GetRunOnStartUp());
  201. SetEnableTransparency(GetEnableTransparency());
  202. SetTransparencyPercent(GetTransparencyPercent());
  203. SetLinesPerRow(GetLinesPerRow());
  204. SetQuickPastePosition(GetQuickPastePosition());
  205. SetCopyGap(GetCopyGap());
  206. SetDBPath(GetDBPath());
  207. SetCheckForMaxEntries(GetCheckForMaxEntries());
  208. SetCheckForExpiredEntries(GetCheckForExpiredEntries());
  209. SetMaxEntries(GetMaxEntries());
  210. SetExpiredEntries(GetExpiredEntries());
  211. SetTripCopyCount(GetTripCopyCount());
  212. SetTripPasteCount(GetTripPasteCount());
  213. SetTripDate(GetTripDate());
  214. SetTotalCopyCount(GetTotalCopyCount());
  215. SetTotalPasteCount(GetTotalPasteCount());
  216. SetTotalDate(GetTotalDate());
  217. SetUpdateFilePath(GetUpdateFilePath());
  218. SetUpdateInstallPath(GetUpdateInstallPath());
  219. SetLastUpdate(GetLastUpdate());
  220. SetCheckForUpdates(GetCheckForUpdates());
  221. SetUseCtrlNumForFirstTenHotKeys(GetUseCtrlNumForFirstTenHotKeys());
  222. SetAllowDuplicates(GetAllowDuplicates());
  223. SetUpdateTimeOnPaste(GetUpdateTimeOnPaste());
  224. SetSaveMultiPaste(GetSaveMultiPaste());
  225. SetShowPersistent(GetShowPersistent());
  226. SetShowTextForFirstTenHotKeys(GetShowTextForFirstTenHotKeys());
  227. SetMainHWND(GetMainHWND());
  228. SetCaptionPos(GetCaptionPos());
  229. SetAutoHide(GetAutoHide());
  230. SetDescTextSize(GetDescTextSize());
  231. SetDescShowLeadingWhiteSpace(GetDescShowLeadingWhiteSpace());
  232. SetAllwaysShowDescription(GetAllwaysShowDescription());
  233. SetDoubleClickingOnCaptionDoes(GetDoubleClickingOnCaptionDoes());
  234. SetPrompForNewGroupName(GetPrompForNewGroupName());
  235. SetSendPasteOnFirstTenHotKeys(GetSendPasteOnFirstTenHotKeys());
  236. for(int i = 0; i < MAX_SEND_CLIENTS; i++)
  237. {
  238. GetSendClients(i);
  239. SetSendClients(m_SendClients[i], i);
  240. }
  241. SetListToPutOnClipboard(GetListToPutOnClipboard());
  242. SetLogSendReceiveErrors(GetLogSendReceiveErrors());
  243. SetHideDittoOnHotKeyIfAlreadyShown(GetHideDittoOnHotKeyIfAlreadyShown());
  244. SetPort(GetPort());
  245. SetDisableRecieve(GetDisableRecieve());
  246. LOGFONT font;
  247. GetFont(font);
  248. SetFont(font);
  249. SetDrawThumbnail(GetDrawThumbnail());
  250. CStringA PassA = GetNetworkPassword();
  251. CString PassW = PassA;
  252. SetNetworkPassword(PassW);
  253. SetDrawRTF(GetDrawRTF());
  254. SetMultiPasteReverse(GetMultiPasteReverse());
  255. SetPlaySoundOnCopy(GetPlaySoundOnCopy());
  256. SetSendPasteAfterSelection(GetSendPasteAfterSelection());
  257. SetFindAsYouType(GetFindAsYouType());
  258. SetEnsureEntireWindowCanBeSeen(GetEnsureEntireWindowCanBeSeen());
  259. SetShowAllClipsInMainList(GetShowAllClipsInMainList());
  260. SetExtraNetworkPassword(GetExtraNetworkPassword(false));
  261. SetMaxClipSizeInBytes(GetMaxClipSizeInBytes());
  262. SetLanguageFile(GetLanguageFile());
  263. SetSaveClipDelay(GetSaveClipDelay());
  264. SetProcessDrawClipboardDelay(GetProcessDrawClipboardDelay());
  265. SetEnableDebugLogging(GetEnableDebugLogging());
  266. SetEnsureConnectToClipboard(GetEnsureConnectToClipboard());
  267. SetPromptWhenDeletingClips(GetPromptWhenDeletingClips());
  268. SetLastImportDir(GetLastImportDir());
  269. SetLastExportDir(GetLastExportDir());
  270. SetUpdateDescWhenSavingClip(GetUpdateDescWhenSavingClip());
  271. m_bInConversion = false;
  272. }
  273. CString CGetSetOptions::GetIniFileName(bool bLocalIniFile)
  274. {
  275. CString csPath = _T("c:\\program files\\Ditto\\");
  276. if(m_bU3)
  277. {
  278. csPath = CGetSetOptions::GetPath(PATH_INI);
  279. }
  280. else
  281. {
  282. if(bLocalIniFile)
  283. {
  284. csPath = GetFilePath(GetExeFileName());
  285. }
  286. else
  287. {
  288. csPath = GetAppDataPath();
  289. }
  290. }
  291. csPath += "Ditto.Settings";
  292. return csPath;
  293. }
  294. CString CGetSetOptions::GetAppDataPath()
  295. {
  296. CString csPath;
  297. LPMALLOC pMalloc;
  298. if(SUCCEEDED(::SHGetMalloc(&pMalloc)))
  299. {
  300. LPITEMIDLIST pidlPrograms;
  301. SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidlPrograms);
  302. TCHAR string[MAX_PATH];
  303. SHGetPathFromIDList(pidlPrograms, string);
  304. pMalloc->Free(pidlPrograms);
  305. pMalloc->Release();
  306. csPath = string;
  307. }
  308. FIX_CSTRING_PATH(csPath);
  309. csPath += "Ditto\\";
  310. return csPath;
  311. }
  312. long CGetSetOptions::GetResolutionProfileLong(CString csName, long lDefaultValue, CString csNewPath)
  313. {
  314. CString resName;
  315. resName.Format(_T("(%dx%d)_%s"), GetScreenWidth(), GetScreenHeight(), csName);
  316. long value = GetProfileLong(resName, INT_MIN, csNewPath);
  317. if(value == INT_MIN)
  318. {
  319. value = GetProfileLong(csName, lDefaultValue, csNewPath);
  320. }
  321. return value;
  322. }
  323. BOOL CGetSetOptions::SetResolutionProfileLong(CString csName, long lValue)
  324. {
  325. CString resName;
  326. resName.Format(_T("(%dx%d)_%s"), GetScreenWidth(), GetScreenHeight(), csName);
  327. return SetProfileLong(resName, lValue);
  328. }
  329. long CGetSetOptions::GetProfileLong(CString csName, long lDefaultValue, CString csNewPath)
  330. {
  331. if(m_bFromIni && !m_bInConversion)
  332. {
  333. CString csApp(_T("Ditto"));
  334. if(csNewPath.IsEmpty() == FALSE)
  335. {
  336. csApp = csNewPath;
  337. }
  338. return GetPrivateProfileInt(csApp, csName, lDefaultValue, m_csIniFileName);
  339. }
  340. CString csPath(_T(REG_PATH));
  341. if(csNewPath.IsEmpty() == FALSE)
  342. {
  343. csPath += "\\" + csNewPath;
  344. }
  345. HKEY hkKey;
  346. long lResult = RegOpenKeyEx(HKEY_CURRENT_USER, csPath, NULL, KEY_READ, &hkKey);
  347. if(lResult != ERROR_SUCCESS)
  348. return lDefaultValue;
  349. DWORD buffer;
  350. DWORD len = sizeof(buffer);
  351. DWORD type;
  352. lResult = ::RegQueryValueEx(hkKey, csName, 0, &type, (LPBYTE)&buffer, &len);
  353. RegCloseKey(hkKey);
  354. if(lResult == ERROR_SUCCESS)
  355. return (long)buffer;
  356. return lDefaultValue;
  357. }
  358. CString CGetSetOptions::GetProfileString(CString csName, CString csDefault, CString csNewPath)
  359. {
  360. if(m_bFromIni && !m_bInConversion)
  361. {
  362. CString csApp(_T("Ditto"));
  363. if(csNewPath.IsEmpty() == FALSE)
  364. {
  365. csApp = csNewPath;
  366. }
  367. TCHAR cString[MAX_PATH];
  368. GetPrivateProfileString(csApp, csName, csDefault, cString, sizeof(cString), m_csIniFileName);
  369. return cString;
  370. }
  371. CString csPath(_T(REG_PATH));
  372. if(csNewPath.IsEmpty() == FALSE)
  373. {
  374. csPath += "\\" + csNewPath;
  375. }
  376. HKEY hkKey;
  377. long lResult = RegOpenKeyEx(HKEY_CURRENT_USER, csPath, NULL, KEY_READ, &hkKey);
  378. TCHAR szString[256];
  379. ZeroMemory(szString, sizeof(szString));
  380. DWORD dwBufLen = 256;
  381. lResult = ::RegQueryValueEx(hkKey , csName, NULL, NULL, (LPBYTE)szString, &dwBufLen);
  382. RegCloseKey(hkKey);
  383. if(lResult != ERROR_SUCCESS)
  384. return csDefault;
  385. return szString;
  386. }
  387. BOOL CGetSetOptions::SetProfileLong(CString csName, long lValue)
  388. {
  389. if(m_bFromIni)
  390. {
  391. return WritePrivateProfileInt(_T("Ditto"), csName, lValue, m_csIniFileName);
  392. }
  393. HKEY hkKey;
  394. DWORD dWord;
  395. long lResult = RegCreateKeyEx(HKEY_CURRENT_USER, _T(REG_PATH), NULL,
  396. NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
  397. NULL, &hkKey, &dWord);
  398. if(lResult != ERROR_SUCCESS)
  399. return FALSE;
  400. DWORD val = (DWORD)lValue;
  401. lResult = ::RegSetValueEx(hkKey, csName, 0, REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
  402. RegCloseKey(hkKey);
  403. return lResult == ERROR_SUCCESS;
  404. }
  405. BOOL CGetSetOptions::SetProfileString(CString csName, CString csValue)
  406. {
  407. if(m_bFromIni)
  408. {
  409. return WritePrivateProfileString(_T("Ditto"), csName, csValue, m_csIniFileName);
  410. }
  411. HKEY hkKey;
  412. DWORD dWord;
  413. long lResult = RegCreateKeyEx(HKEY_CURRENT_USER, _T(REG_PATH), NULL,
  414. NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
  415. NULL, &hkKey, &dWord);
  416. if(lResult != ERROR_SUCCESS)
  417. return FALSE;
  418. ::RegSetValueEx(hkKey, csName, NULL, REG_SZ,
  419. (BYTE*)(LPCTSTR)csValue, csValue.GetLength()*sizeof(TCHAR));
  420. RegCloseKey(hkKey);
  421. return lResult == ERROR_SUCCESS;
  422. }
  423. BOOL CGetSetOptions::SetProfileData(CString csName, LPVOID lpData, DWORD dwLength)
  424. {
  425. if(m_bFromIni)
  426. {
  427. ASSERT(!"SetProfileData not supported in .ini settings");
  428. return FALSE;
  429. }
  430. HKEY hkKey;
  431. DWORD dWord;
  432. long lResult = RegCreateKeyEx(HKEY_CURRENT_USER, _T(REG_PATH), NULL,
  433. NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
  434. NULL, &hkKey, &dWord);
  435. if(lResult != ERROR_SUCCESS)
  436. return FALSE;
  437. ::RegSetValueEx(hkKey, csName, NULL, REG_BINARY,
  438. (BYTE*)lpData, dwLength);
  439. RegCloseKey(hkKey);
  440. return lResult == ERROR_SUCCESS;
  441. }
  442. BOOL CGetSetOptions::GetProfileFont(CString csSection, LOGFONT &font)
  443. {
  444. font.lfHeight = GetPrivateProfileInt(csSection, _T("Height"), 0, m_csIniFileName);
  445. font.lfWidth = GetPrivateProfileInt(csSection, _T("Width"), 0, m_csIniFileName);
  446. font.lfEscapement = GetPrivateProfileInt(csSection, _T("Escapement"), 0, m_csIniFileName);
  447. font.lfOrientation = GetPrivateProfileInt(csSection, _T("Orientation"), 0, m_csIniFileName);
  448. font.lfWeight = GetPrivateProfileInt(csSection, _T("Weight"), 0, m_csIniFileName);
  449. font.lfItalic = GetPrivateProfileInt(csSection, _T("Italic"), 0, m_csIniFileName);
  450. font.lfUnderline = GetPrivateProfileInt(csSection, _T("Underline"), 0, m_csIniFileName);
  451. font.lfStrikeOut = GetPrivateProfileInt(csSection, _T("StrikeOut"), 0, m_csIniFileName);
  452. font.lfCharSet = GetPrivateProfileInt(csSection, _T("CharSet"), 0, m_csIniFileName);
  453. font.lfOutPrecision = GetPrivateProfileInt(csSection, _T("OutPrecision"), 0, m_csIniFileName);
  454. font.lfClipPrecision = GetPrivateProfileInt(csSection, _T("ClipPrecision"), 0, m_csIniFileName);
  455. font.lfQuality = GetPrivateProfileInt(csSection, _T("Quality"), 0, m_csIniFileName);
  456. font.lfPitchAndFamily = GetPrivateProfileInt(csSection, _T("PitchAndFamily"), 0, m_csIniFileName);
  457. GetPrivateProfileString(csSection, _T("FaceName"), _T(""), font.lfFaceName, sizeof(font.lfFaceName), m_csIniFileName);
  458. return TRUE;
  459. }
  460. BOOL CGetSetOptions::SetProfileFont(CString csSection, LOGFONT &font)
  461. {
  462. WritePrivateProfileInt(csSection, _T("Height"), font.lfHeight, m_csIniFileName);
  463. WritePrivateProfileInt(csSection, _T("Width"), font.lfWidth, m_csIniFileName);
  464. WritePrivateProfileInt(csSection, _T("Escapement"), font.lfEscapement, m_csIniFileName);
  465. WritePrivateProfileInt(csSection, _T("Orientation"), font.lfOrientation, m_csIniFileName);
  466. WritePrivateProfileInt(csSection, _T("Weight"), font.lfWeight, m_csIniFileName);
  467. WritePrivateProfileInt(csSection, _T("Italic"), font.lfItalic, m_csIniFileName);
  468. WritePrivateProfileInt(csSection, _T("Underline"), font.lfUnderline, m_csIniFileName);
  469. WritePrivateProfileInt(csSection, _T("StrikeOut"), font.lfStrikeOut, m_csIniFileName);
  470. WritePrivateProfileInt(csSection, _T("CharSet"), font.lfCharSet, m_csIniFileName);
  471. WritePrivateProfileInt(csSection, _T("OutPrecision"), font.lfOutPrecision, m_csIniFileName);
  472. WritePrivateProfileInt(csSection, _T("ClipPrecision"), font.lfClipPrecision, m_csIniFileName);
  473. WritePrivateProfileInt(csSection, _T("Quality"), font.lfQuality, m_csIniFileName);
  474. WritePrivateProfileInt(csSection, _T("PitchAndFamily"), font.lfPitchAndFamily, m_csIniFileName);
  475. WritePrivateProfileString(csSection, _T("FaceName"), font.lfFaceName, m_csIniFileName);
  476. return TRUE;
  477. }
  478. LPVOID CGetSetOptions::GetProfileData(CString csName, DWORD &dwLength)
  479. {
  480. if(m_bFromIni && !m_bInConversion)
  481. {
  482. ASSERT(!"GetProfileData not supported in .ini settings");
  483. return NULL;
  484. }
  485. HKEY hkKey;
  486. long lResult = RegOpenKeyEx(HKEY_CURRENT_USER, _T(REG_PATH),
  487. NULL, KEY_READ, &hkKey);
  488. lResult = ::RegQueryValueEx(hkKey , csName, NULL, NULL, NULL, &dwLength);
  489. if(lResult != ERROR_SUCCESS)
  490. return NULL;
  491. LPVOID lpVoid = new BYTE[dwLength];
  492. lResult = ::RegQueryValueEx(hkKey , csName, NULL, NULL, (LPBYTE)lpVoid, &dwLength);
  493. RegCloseKey(hkKey);
  494. if(lResult != ERROR_SUCCESS)
  495. return NULL;
  496. return lpVoid;
  497. }
  498. BOOL CGetSetOptions::GetShowIconInSysTray()
  499. {
  500. return GetProfileLong("ShowIconInSystemTray", TRUE);
  501. }
  502. BOOL CGetSetOptions::SetShowIconInSysTray(BOOL bShow)
  503. {
  504. return SetProfileLong("ShowIconInSystemTray", bShow);
  505. }
  506. BOOL CGetSetOptions::SetEnableTransparency(BOOL bCheck)
  507. {
  508. return SetProfileLong("EnableTransparency", bCheck);
  509. }
  510. BOOL CGetSetOptions::GetEnableTransparency()
  511. {
  512. return GetProfileLong("EnableTransparency", FALSE);
  513. }
  514. BOOL CGetSetOptions::SetTransparencyPercent(long lPercent)
  515. {
  516. #ifdef AFTER_98
  517. if(lPercent > OPACITY_MAX)
  518. lPercent = OPACITY_MAX;
  519. if(lPercent < 0)
  520. lPercent = 0;
  521. return SetProfileLong("TransparencyPercent", lPercent);
  522. #endif
  523. return FALSE;
  524. }
  525. long CGetSetOptions::GetTransparencyPercent()
  526. {
  527. #ifdef AFTER_98
  528. long lValue = GetProfileLong("TransparencyPercent", 14);
  529. if(lValue > OPACITY_MAX) lValue = OPACITY_MAX;
  530. if(lValue < 0) lValue = 0;
  531. return lValue;
  532. #endif
  533. return 0;
  534. }
  535. BOOL CGetSetOptions::SetLinesPerRow(long lLines)
  536. {
  537. m_nLinesPerRow = lLines;
  538. return SetProfileLong("LinesPerRow", lLines);
  539. }
  540. long CGetSetOptions::GetLinesPerRow()
  541. {
  542. return GetProfileLong("LinesPerRow", 2);
  543. }
  544. BOOL CGetSetOptions::GetRunOnStartUp()
  545. {
  546. HKEY hkRun;
  547. LONG nResult = RegOpenKeyEx(HKEY_CURRENT_USER,
  548. _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"),
  549. NULL, KEY_READ, &hkRun);
  550. if(nResult != ERROR_SUCCESS)
  551. return FALSE;
  552. nResult = RegQueryValueEx(hkRun, GetAppName(), NULL, NULL, NULL, NULL);
  553. RegCloseKey(hkRun);
  554. return nResult == ERROR_SUCCESS;
  555. }
  556. void CGetSetOptions::SetRunOnStartUp(BOOL bRun)
  557. {
  558. //Can't set auto run when running from U3 device
  559. if(m_bU3)
  560. return;
  561. if(bRun == GetRunOnStartUp())
  562. return;
  563. HKEY hkRun;
  564. LONG nResult = RegOpenKeyEx(HKEY_CURRENT_USER,
  565. _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"),
  566. NULL, KEY_ALL_ACCESS, &hkRun);
  567. if(nResult != ERROR_SUCCESS)
  568. return;
  569. if(bRun)
  570. {
  571. CString sExeName = GetExeFileName();
  572. ::RegSetValueEx(hkRun, GetAppName(), NULL, REG_SZ,
  573. (BYTE*)(LPCTSTR)sExeName, sExeName.GetLength()*sizeof(TCHAR));
  574. }
  575. else
  576. {
  577. ::RegDeleteValue(hkRun, GetAppName());
  578. }
  579. ::RegCloseKey(hkRun);
  580. }
  581. CString CGetSetOptions::GetExeFileName()
  582. {
  583. CString sExeName;
  584. GetModuleFileName(NULL, sExeName.GetBuffer(_MAX_PATH),_MAX_PATH);
  585. sExeName.ReleaseBuffer();
  586. return sExeName;
  587. }
  588. CString CGetSetOptions::GetAppName()
  589. {
  590. return "Ditto";
  591. }
  592. BOOL CGetSetOptions::SetQuickPastePosition(long lPosition)
  593. {
  594. return SetProfileLong("ShowQuickPastePosition", lPosition);
  595. }
  596. long CGetSetOptions::GetQuickPastePosition()
  597. {
  598. return GetProfileLong("ShowQuickPastePosition", POS_AT_CURSOR);
  599. }
  600. BOOL CGetSetOptions::SetQuickPasteSize(CSize size)
  601. {
  602. BOOL bRet = SetResolutionProfileLong("QuickPasteCX", size.cx);
  603. bRet = SetResolutionProfileLong("QuickPasteCY", size.cy);
  604. return bRet;
  605. }
  606. void CGetSetOptions::GetQuickPasteSize(CSize &size)
  607. {
  608. size.cx = GetResolutionProfileLong("QuickPasteCX", 300);
  609. size.cy = GetResolutionProfileLong("QuickPasteCY", 300);
  610. if(size.cx <= 0 && size.cy <= 0)
  611. {
  612. size.cx = 300;
  613. size.cy = 300;
  614. }
  615. }
  616. BOOL CGetSetOptions::SetQuickPastePoint(CPoint point)
  617. {
  618. BOOL bRet = SetResolutionProfileLong("QuickPasteX", point.x);
  619. bRet = SetResolutionProfileLong("QuickPasteY", point.y);
  620. return bRet;
  621. }
  622. void CGetSetOptions::GetQuickPastePoint(CPoint &point)
  623. {
  624. point.x = GetResolutionProfileLong("QuickPasteX", 300);
  625. point.y = GetResolutionProfileLong("QuickPasteY", 300);
  626. if(point.x <= 0 && point.y <= 0)
  627. {
  628. point.x = 300;
  629. point.y = 300;
  630. }
  631. }
  632. BOOL CGetSetOptions::SetEditWndSize(CSize size)
  633. {
  634. BOOL bRet = SetResolutionProfileLong("EditWndCX", size.cx);
  635. bRet = SetResolutionProfileLong("EditWndCY", size.cy);
  636. return bRet;
  637. }
  638. void CGetSetOptions::GetEditWndSize(CSize &size)
  639. {
  640. size.cx = GetResolutionProfileLong("EditWndCX", 600);
  641. size.cy = GetResolutionProfileLong("EditWndCY", 600);
  642. if(size.cx <= 0 && size.cy <= 0)
  643. {
  644. size.cx = 600;
  645. size.cy = 600;
  646. }
  647. }
  648. BOOL CGetSetOptions::SetEditWndPoint(CPoint point)
  649. {
  650. BOOL bRet = SetResolutionProfileLong("EditWndX", point.x);
  651. bRet = SetResolutionProfileLong("EditWndY", point.y);
  652. return bRet;
  653. }
  654. void CGetSetOptions::GetEditWndPoint(CPoint &point)
  655. {
  656. point.x = GetResolutionProfileLong("EditWndX", 100);
  657. point.y = GetResolutionProfileLong("EditWndY", 100);
  658. if(point.x <= 0 && point.y <= 0)
  659. {
  660. point.x = 100;
  661. point.y = 100;
  662. }
  663. }
  664. long CGetSetOptions::GetCopyGap()
  665. {
  666. return GetProfileLong("CopyGap", 150);
  667. }
  668. void CGetSetOptions::SetCopyGap(long lGap)
  669. {
  670. SetProfileLong("CopyGap", lGap);
  671. }
  672. BOOL CGetSetOptions::SetDBPathOld(CString csPath)
  673. {
  674. return SetProfileString("DBPath", csPath);
  675. }
  676. CString CGetSetOptions::GetDBPathOld()
  677. {
  678. return GetProfileString("DBPath", "");
  679. }
  680. BOOL CGetSetOptions::SetDBPath(CString csPath)
  681. {
  682. return SetProfileString("DBPath3", csPath);
  683. }
  684. CString CGetSetOptions::GetDBPath()
  685. {
  686. CString csDBPath;
  687. if(m_bU3)
  688. {
  689. csDBPath = GetProfileString("DBPath3", "");
  690. if(csDBPath.IsEmpty())
  691. {
  692. csDBPath = GetDefaultDBName();
  693. }
  694. CPath ExistingPath(csDBPath);
  695. csDBPath = CGetSetOptions::GetPath(PATH_DATABASE);
  696. csDBPath += ExistingPath.GetName();
  697. }
  698. else
  699. {
  700. csDBPath = GetProfileString("DBPath3", "");
  701. }
  702. return csDBPath;
  703. }
  704. void CGetSetOptions::SetCheckForMaxEntries(BOOL bVal)
  705. {
  706. SetProfileLong("CheckForMaxEntries", bVal);
  707. }
  708. BOOL CGetSetOptions::GetCheckForMaxEntries()
  709. {
  710. BOOL bDefault = FALSE;
  711. if(m_bU3)
  712. bDefault = TRUE;
  713. if(GetIsPortableDitto())
  714. bDefault = TRUE;
  715. return GetProfileLong("CheckForMaxEntries", bDefault);
  716. }
  717. void CGetSetOptions::SetCheckForExpiredEntries(BOOL bVal)
  718. {
  719. SetProfileLong("CheckForExpiredEntries", bVal);
  720. }
  721. BOOL CGetSetOptions::GetCheckForExpiredEntries()
  722. {
  723. return GetProfileLong("CheckForExpiredEntries", FALSE);
  724. }
  725. void CGetSetOptions::SetMaxEntries(long lVal)
  726. {
  727. SetProfileLong("MaxEntries", lVal);
  728. }
  729. long CGetSetOptions::GetMaxEntries()
  730. {
  731. long lMax = 500;
  732. if(m_bU3)
  733. lMax = 75;
  734. if(GetIsPortableDitto())
  735. lMax = 100;
  736. return GetProfileLong("MaxEntries", lMax);
  737. }
  738. void CGetSetOptions::SetExpiredEntries(long lVal)
  739. {
  740. SetProfileLong("ExpiredEntries", lVal);
  741. }
  742. long CGetSetOptions::GetExpiredEntries()
  743. {
  744. return GetProfileLong("ExpiredEntries", 5);
  745. }
  746. void CGetSetOptions::SetTripCopyCount(long lVal)
  747. {
  748. // negative means a relative offset
  749. if(lVal < 0)
  750. lVal = GetTripCopyCount() - lVal; // add the absolute value
  751. if(GetTripDate() == 0)
  752. SetTripDate(-1);
  753. SetProfileLong("TripCopies", lVal);
  754. }
  755. long CGetSetOptions::GetTripCopyCount()
  756. {
  757. return GetProfileLong("TripCopies", 0);
  758. }
  759. void CGetSetOptions::SetTripPasteCount(long lVal)
  760. {
  761. // negative means a relative offset
  762. if(lVal < 0)
  763. lVal = GetTripPasteCount() - lVal; // add the absolute value
  764. if(GetTripDate() == 0)
  765. SetTripDate(-1);
  766. SetProfileLong("TripPastes", lVal);
  767. }
  768. long CGetSetOptions::GetTripPasteCount()
  769. {
  770. return GetProfileLong("TripPastes", 0);
  771. }
  772. void CGetSetOptions::SetTripDate(long lDate)
  773. {
  774. if(lDate == -1)
  775. lDate = (long)CTime::GetCurrentTime().GetTime();
  776. SetProfileLong("TripDate", lDate);
  777. }
  778. long CGetSetOptions::GetTripDate()
  779. {
  780. return GetProfileLong("TripDate", 0);
  781. }
  782. void CGetSetOptions::SetTotalCopyCount(long lVal)
  783. {
  784. // negative means a relative offset
  785. if(lVal < 0)
  786. lVal = GetTotalCopyCount() - lVal; // add the absolute value
  787. if(GetTotalDate() == 0)
  788. SetTotalDate(-1);
  789. SetProfileLong("TotalCopies", lVal);
  790. }
  791. long CGetSetOptions::GetTotalCopyCount()
  792. {
  793. return GetProfileLong("TotalCopies", 0);
  794. }
  795. void CGetSetOptions::SetTotalPasteCount(long lVal)
  796. {
  797. // negative means a relative offset
  798. if(lVal < 0)
  799. lVal = GetTotalPasteCount() - lVal; // add the absolute value
  800. if(GetTotalDate() == 0)
  801. SetTotalDate(-1);
  802. SetProfileLong("TotalPastes", lVal);
  803. }
  804. long CGetSetOptions::GetTotalPasteCount()
  805. {
  806. return GetProfileLong("TotalPastes", 0);
  807. }
  808. void CGetSetOptions::SetTotalDate(long lDate)
  809. {
  810. if(lDate == -1)
  811. lDate = (long)CTime::GetCurrentTime().GetTime();
  812. SetProfileLong("TotalDate", lDate);
  813. }
  814. long CGetSetOptions::GetTotalDate()
  815. {
  816. return GetProfileLong("TotalDate", 0);
  817. }
  818. CString CGetSetOptions::GetUpdateFilePath()
  819. {
  820. return GetProfileString("UpdateFilePath", "");
  821. }
  822. BOOL CGetSetOptions::SetUpdateFilePath(CString cs)
  823. {
  824. return SetProfileString("UpdateFilePath", cs);
  825. }
  826. CString CGetSetOptions::GetUpdateInstallPath()
  827. {
  828. return GetProfileString("UpdateInstallPath", "");
  829. }
  830. BOOL CGetSetOptions::SetUpdateInstallPath(CString cs)
  831. {
  832. return SetProfileString("UpdateInstallPath", cs);
  833. }
  834. long CGetSetOptions::GetLastUpdate()
  835. {
  836. return GetProfileLong("LastUpdateDay", 0);
  837. }
  838. long CGetSetOptions::SetLastUpdate(long lValue)
  839. {
  840. return SetProfileLong("LastUpdateDay", lValue);
  841. }
  842. BOOL CGetSetOptions::GetCheckForUpdates()
  843. {
  844. return GetProfileLong("CheckForUpdates", TRUE);
  845. }
  846. BOOL CGetSetOptions::SetCheckForUpdates(BOOL bCheck)
  847. {
  848. return SetProfileLong("CheckForUpdates", bCheck);
  849. }
  850. void CGetSetOptions::SetUseCtrlNumForFirstTenHotKeys(BOOL bVal)
  851. {
  852. SetProfileLong("UseCtrlNumForFirstTenHotKeys", bVal);
  853. m_bUseCtrlNumAccel = bVal;
  854. }
  855. BOOL CGetSetOptions::GetUseCtrlNumForFirstTenHotKeys()
  856. {
  857. return GetProfileLong("UseCtrlNumForFirstTenHotKeys", 0);
  858. }
  859. void CGetSetOptions::SetAllowDuplicates(BOOL bVal)
  860. {
  861. SetProfileLong("AllowDuplicates", bVal);
  862. m_bAllowDuplicates = bVal;
  863. }
  864. BOOL CGetSetOptions::GetAllowDuplicates()
  865. {
  866. return GetProfileLong("AllowDuplicates", 0);
  867. }
  868. void CGetSetOptions::SetUpdateTimeOnPaste(BOOL bVal)
  869. {
  870. SetProfileLong("UpdateTimeOnPaste", bVal);
  871. m_bUpdateTimeOnPaste = bVal;
  872. }
  873. BOOL CGetSetOptions::GetUpdateTimeOnPaste()
  874. {
  875. return GetProfileLong("UpdateTimeOnPaste", TRUE);
  876. }
  877. void CGetSetOptions::SetSaveMultiPaste(BOOL bVal)
  878. {
  879. SetProfileLong("SaveMultiPaste", bVal);
  880. m_bSaveMultiPaste = bVal;
  881. }
  882. BOOL CGetSetOptions::GetSaveMultiPaste()
  883. {
  884. return GetProfileLong("SaveMultiPaste", 0);
  885. }
  886. void CGetSetOptions::SetShowPersistent(BOOL bVal)
  887. {
  888. SetProfileLong("ShowPersistent", bVal);
  889. m_bShowPersistent = bVal;
  890. }
  891. BOOL CGetSetOptions::GetShowPersistent()
  892. {
  893. return GetProfileLong("ShowPersistent", 0);
  894. }
  895. void CGetSetOptions::SetShowTextForFirstTenHotKeys(BOOL bVal)
  896. {
  897. SetProfileLong("ShowTextForFirstTenHotKeys", bVal);
  898. }
  899. BOOL CGetSetOptions::GetShowTextForFirstTenHotKeys()
  900. {
  901. return GetProfileLong("ShowTextForFirstTenHotKeys", TRUE);
  902. }
  903. void CGetSetOptions::SetMainHWND(long lhWnd)
  904. {
  905. SetProfileLong("MainhWnd", lhWnd);
  906. }
  907. BOOL CGetSetOptions::GetMainHWND()
  908. {
  909. return GetProfileLong("MainhWnd", 0);
  910. }
  911. void CGetSetOptions::SetCaptionPos(long lPos)
  912. {
  913. SetProfileLong("CaptionPos", lPos);
  914. }
  915. long CGetSetOptions::GetCaptionPos()
  916. {
  917. return GetProfileLong("CaptionPos", CAPTION_RIGHT);
  918. }
  919. void CGetSetOptions::SetAutoHide(BOOL bAutoHide)
  920. {
  921. SetProfileLong("AutoHide", bAutoHide);
  922. }
  923. BOOL CGetSetOptions::GetAutoHide()
  924. {
  925. return GetProfileLong("AutoHide", FALSE);
  926. }
  927. void CGetSetOptions::SetDescTextSize(long lSize)
  928. {
  929. SetProfileLong("DescTextSize", lSize);
  930. m_bDescTextSize = lSize;
  931. }
  932. long CGetSetOptions::GetDescTextSize()
  933. {
  934. return GetProfileLong("DescTextSize", 500);
  935. }
  936. void CGetSetOptions::SetDescShowLeadingWhiteSpace(BOOL bVal)
  937. {
  938. SetProfileLong("DescShowLeadingWhiteSpace", bVal);
  939. m_bDescShowLeadingWhiteSpace = bVal;
  940. }
  941. BOOL CGetSetOptions::GetDescShowLeadingWhiteSpace()
  942. {
  943. return GetProfileLong("DescShowLeadingWhiteSpace", FALSE);
  944. }
  945. void CGetSetOptions::SetAllwaysShowDescription(long bShow)
  946. {
  947. SetProfileLong("AllwaysShowDescription", bShow);
  948. m_bAllwaysShowDescription = bShow;
  949. }
  950. BOOL CGetSetOptions::GetAllwaysShowDescription()
  951. {
  952. return GetProfileLong("AllwaysShowDescription", FALSE);
  953. }
  954. void CGetSetOptions::SetDoubleClickingOnCaptionDoes(long lOption)
  955. {
  956. SetProfileLong("DoubleClickingOnCaptionDoes", lOption);
  957. m_bDoubleClickingOnCaptionDoes = lOption;
  958. }
  959. long CGetSetOptions::GetDoubleClickingOnCaptionDoes()
  960. {
  961. return GetProfileLong("DoubleClickingOnCaptionDoes", TOGGLES_ALLWAYS_ON_TOP);
  962. }
  963. void CGetSetOptions::SetPrompForNewGroupName(BOOL bOption)
  964. {
  965. SetProfileLong("PrompForNewGroupName", bOption);
  966. m_bPrompForNewGroupName = bOption;
  967. }
  968. BOOL CGetSetOptions::GetPrompForNewGroupName()
  969. {
  970. return GetProfileLong("PrompForNewGroupName", TRUE);
  971. }
  972. void CGetSetOptions::SetSendPasteOnFirstTenHotKeys(BOOL bOption)
  973. {
  974. SetProfileLong("SendPasteOnFirstTenHotKeys", bOption);
  975. m_bSendPasteOnFirstTenHotKeys = bOption;
  976. }
  977. BOOL CGetSetOptions::GetSendPasteOnFirstTenHotKeys()
  978. {
  979. return GetProfileLong("SendPasteOnFirstTenHotKeys", TRUE);
  980. }
  981. void CGetSetOptions::SetSendClients(CSendClients Client, int nPos)
  982. {
  983. CString cs;
  984. cs.Format(_T("sendclient_ip_%d"), nPos);
  985. SetProfileString(cs, Client.csIP);
  986. cs.Format(_T("sendclient_autosend_%d"), nPos);
  987. SetProfileLong(cs, Client.bSendAll);
  988. cs.Format(_T("sendclient_description_%d"), nPos);
  989. SetProfileString(cs, Client.csDescription);
  990. Client.bShownFirstError = m_SendClients[nPos].bShownFirstError;
  991. m_SendClients[nPos] = Client;
  992. }
  993. CSendClients CGetSetOptions::GetSendClients(int nPos)
  994. {
  995. CSendClients Client;
  996. CString cs;
  997. cs.Format(_T("sendclient_ip_%d"), nPos);
  998. Client.csIP = GetProfileString(cs, "");
  999. cs.Format(_T("sendclient_autosend_%d"), nPos);
  1000. Client.bSendAll = GetProfileLong(cs, FALSE);
  1001. cs.Format(_T("sendclient_description_%d"), nPos);
  1002. Client.csDescription = GetProfileString(cs, "");
  1003. m_SendClients[nPos] = Client;
  1004. return Client;
  1005. }
  1006. void CGetSetOptions::GetClientSendCount()
  1007. {
  1008. m_lAutoSendClientCount = 0;
  1009. for(int i = 0; i < MAX_SEND_CLIENTS; i++)
  1010. {
  1011. if(m_SendClients[i].csIP.GetLength() > 0)
  1012. {
  1013. if(m_SendClients[i].bSendAll)
  1014. m_lAutoSendClientCount++;
  1015. }
  1016. }
  1017. }
  1018. CString CGetSetOptions::GetListToPutOnClipboard()
  1019. {
  1020. CString cs = GetProfileString("ListToPutOnClipboard", "");
  1021. cs.MakeUpper();
  1022. return cs;
  1023. }
  1024. BOOL CGetSetOptions::SetListToPutOnClipboard(CString cs)
  1025. {
  1026. cs.MakeUpper();
  1027. m_csIPListToPutOnClipboard = cs;
  1028. return SetProfileString("ListToPutOnClipboard", cs);
  1029. }
  1030. void CGetSetOptions::SetLogSendReceiveErrors(BOOL bOption)
  1031. {
  1032. m_bLogSendReceiveErrors = bOption;
  1033. SetProfileLong("LogSendReceiveErrors", bOption);
  1034. }
  1035. BOOL CGetSetOptions::GetLogSendReceiveErrors()
  1036. {
  1037. return GetProfileLong("LogSendReceiveErrors", FALSE);
  1038. }
  1039. BOOL CGetSetOptions::GetHideDittoOnHotKeyIfAlreadyShown()
  1040. {
  1041. return GetProfileLong("HideDittoOnHotKeyIfAlreadyShown", TRUE);
  1042. }
  1043. void CGetSetOptions::SetHideDittoOnHotKeyIfAlreadyShown(BOOL bVal)
  1044. {
  1045. m_HideDittoOnHotKeyIfAlreadyShown = bVal;
  1046. SetProfileLong("HideDittoOnHotKeyIfAlreadyShown", bVal);
  1047. }
  1048. void CGetSetOptions::SetPort(long lPort)
  1049. {
  1050. m_lPort = lPort;
  1051. SetProfileLong("SendRecvPort", lPort);
  1052. }
  1053. long CGetSetOptions::GetPort()
  1054. {
  1055. return GetProfileLong("SendRecvPort", 23443);
  1056. }
  1057. BOOL CGetSetOptions::GetDisableRecieve()
  1058. {
  1059. BOOL bDefault = FALSE;
  1060. if(m_bU3)
  1061. bDefault = TRUE;
  1062. if(GetIsPortableDitto())
  1063. bDefault = TRUE;
  1064. return GetProfileLong("DisableRecieve", bDefault);
  1065. }
  1066. void CGetSetOptions::SetDisableRecieve(BOOL bVal)
  1067. {
  1068. SetProfileLong("DisableRecieve", bVal);
  1069. }
  1070. BOOL CGetSetOptions::GetFont(LOGFONT &font)
  1071. {
  1072. if(m_bFromIni && !m_bInConversion)
  1073. {
  1074. GetProfileFont("DisplayFont", font);
  1075. //Return true if there is a font name
  1076. //other wise load the default font below
  1077. if(font.lfFaceName[0] != 0)
  1078. {
  1079. return TRUE;
  1080. }
  1081. }
  1082. else
  1083. {
  1084. DWORD dwLength = 0;
  1085. #ifdef _UNICODE
  1086. LPVOID lpVoid = GetProfileData("DisplayFont3", dwLength);
  1087. #else
  1088. LPVOID lpVoid = GetProfileData("DisplayFont", dwLength);
  1089. #endif
  1090. if(lpVoid)
  1091. {
  1092. if(sizeof(font) == dwLength)
  1093. {
  1094. memcpy(&font, lpVoid, dwLength);
  1095. delete[] lpVoid;
  1096. lpVoid = NULL;
  1097. return TRUE;
  1098. }
  1099. else
  1100. {
  1101. ASSERT(!"invalid font struct size");
  1102. }
  1103. delete[] lpVoid;
  1104. lpVoid = NULL;
  1105. }
  1106. }
  1107. ZeroMemory(&font, sizeof(font));
  1108. font.lfHeight = -theApp.m_metrics.PointsToPixels(8);
  1109. font.lfWeight = 400;
  1110. font.lfCharSet = 1;
  1111. STRCPY(font.lfFaceName, _T("Arial Unicode MS"));
  1112. return TRUE;
  1113. }
  1114. void CGetSetOptions::SetFont(LOGFONT &font)
  1115. {
  1116. if(m_bFromIni)
  1117. {
  1118. SetProfileFont("DisplayFont", font);
  1119. }
  1120. else
  1121. {
  1122. #ifdef _UNICODE
  1123. CString csParam = "DisplayFont3";
  1124. #else
  1125. CString csParam = "DisplayFont";
  1126. #endif
  1127. SetProfileData(csParam, &font, sizeof(LOGFONT));
  1128. }
  1129. }
  1130. void CGetSetOptions::SetDrawThumbnail(long bDraw)
  1131. {
  1132. SetProfileLong("DrawThumbnail", bDraw);
  1133. m_bDrawThumbnail = bDraw;
  1134. }
  1135. BOOL CGetSetOptions::GetDrawThumbnail()
  1136. {
  1137. BOOL bDrawThumbnails = TRUE;
  1138. if(g_Opt.m_bU3)
  1139. bDrawThumbnails = FALSE;
  1140. return GetProfileLong("DrawThumbnail", bDrawThumbnails);
  1141. }
  1142. void CGetSetOptions::SetExtraNetworkPassword(CString csPassword)
  1143. {
  1144. SetProfileString("NetworkExtraPassword", csPassword);
  1145. }
  1146. CString CGetSetOptions::GetExtraNetworkPassword(bool bFillArray)
  1147. {
  1148. CString cs = GetProfileString("NetworkExtraPassword", "");
  1149. if(bFillArray)
  1150. {
  1151. m_csNetworkPasswordArray.RemoveAll();
  1152. TCHAR seps[] = _T(",");
  1153. TCHAR *token;
  1154. TCHAR *pString = cs.GetBuffer(cs.GetLength());
  1155. /* Establish string and get the first token: */
  1156. token = STRTOK(pString, seps);
  1157. while(token != NULL)
  1158. {
  1159. CString cs(token);
  1160. cs.TrimLeft();
  1161. cs.TrimRight();
  1162. m_csNetworkPasswordArray.Add(cs);
  1163. // Get next token
  1164. token = STRTOK(NULL, seps);
  1165. }
  1166. cs.ReleaseBuffer();
  1167. }
  1168. return cs;
  1169. }
  1170. void CGetSetOptions::SetNetworkPassword(CString csPassword)
  1171. {
  1172. CTextConvert Con;
  1173. Con.ConvertToUTF8(csPassword, m_csPassword);
  1174. SetProfileString("NetworkStringPassword", csPassword);
  1175. }
  1176. CStringA CGetSetOptions::GetNetworkPassword()
  1177. {
  1178. CString cs = GetProfileString("NetworkStringPassword", "LetMeIn");
  1179. CTextConvert Con;
  1180. CStringA csReturn;
  1181. Con.ConvertToUTF8(cs, csReturn);
  1182. return csReturn;
  1183. }
  1184. void CGetSetOptions::SetDrawRTF(long bDraw)
  1185. {
  1186. SetProfileLong("DrawRTF", bDraw);
  1187. m_bDrawRTF = bDraw;
  1188. }
  1189. BOOL CGetSetOptions::GetDrawRTF()
  1190. {
  1191. return GetProfileLong("DrawRTF", FALSE);
  1192. }
  1193. void CGetSetOptions::SetMultiPasteReverse(BOOL bVal)
  1194. {
  1195. SetProfileLong("MultiPasteReverse", bVal);
  1196. m_bMultiPasteReverse = bVal;
  1197. }
  1198. BOOL CGetSetOptions::GetMultiPasteReverse()
  1199. {
  1200. return GetProfileLong("MultiPasteReverse", TRUE);
  1201. }
  1202. void CGetSetOptions::SetPlaySoundOnCopy(CString cs)
  1203. {
  1204. m_csPlaySoundOnCopy = cs;
  1205. SetProfileString("PlaySoundOnCopy", cs);
  1206. }
  1207. CString CGetSetOptions::GetPlaySoundOnCopy()
  1208. {
  1209. return GetProfileString("PlaySoundOnCopy", "");
  1210. }
  1211. void CGetSetOptions::SetSendPasteAfterSelection(BOOL bVal)
  1212. {
  1213. m_bSendPasteMessageAfterSelection = bVal;
  1214. SetProfileLong("SendPasteMessageAfterSelection", bVal);
  1215. }
  1216. BOOL CGetSetOptions::GetSendPasteAfterSelection()
  1217. {
  1218. return GetProfileLong("SendPasteMessageAfterSelection", TRUE);
  1219. }
  1220. void CGetSetOptions::SetFindAsYouType(BOOL bVal)
  1221. {
  1222. m_bFindAsYouType = bVal;
  1223. SetProfileLong("FindAsYouType", bVal);
  1224. }
  1225. BOOL CGetSetOptions::GetFindAsYouType()
  1226. {
  1227. return GetProfileLong("FindAsYouType", TRUE);
  1228. }
  1229. void CGetSetOptions::SetEnsureEntireWindowCanBeSeen(BOOL bVal)
  1230. {
  1231. m_bEnsureEntireWindowCanBeSeen = bVal;
  1232. SetProfileLong("EnsureEntireWindowCanBeSeen", bVal);
  1233. }
  1234. BOOL CGetSetOptions::GetEnsureEntireWindowCanBeSeen()
  1235. {
  1236. return GetProfileLong("EnsureEntireWindowCanBeSeen", TRUE);
  1237. }
  1238. void CGetSetOptions::SetShowAllClipsInMainList(BOOL bVal)
  1239. {
  1240. m_bShowAllClipsInMainList = bVal;
  1241. SetProfileLong("ShowAllClipsInMainList", bVal);
  1242. }
  1243. BOOL CGetSetOptions::GetShowAllClipsInMainList()
  1244. {
  1245. return GetProfileLong("ShowAllClipsInMainList", TRUE);
  1246. }
  1247. long CGetSetOptions::GetMaxClipSizeInBytes()
  1248. {
  1249. return GetProfileLong("MaxClipSizeInBytes", 0);
  1250. }
  1251. void CGetSetOptions::SetMaxClipSizeInBytes(long lSize)
  1252. {
  1253. m_lMaxClipSizeInBytes = lSize;
  1254. SetProfileLong("MaxClipSizeInBytes", lSize);
  1255. }
  1256. CString CGetSetOptions::GetLanguageFile()
  1257. {
  1258. return GetProfileString("LanguageFile", "");
  1259. }
  1260. void CGetSetOptions::SetLanguageFile(CString csLanguage)
  1261. {
  1262. SetProfileString("LanguageFile", csLanguage);
  1263. }
  1264. ULONG CGetSetOptions::GetSaveClipDelay()
  1265. {
  1266. return (ULONG)GetProfileLong("SaveClipDelay", 500);
  1267. }
  1268. void CGetSetOptions::SetSaveClipDelay(DWORD dwDelay)
  1269. {
  1270. m_dwSaveClipDelay = dwDelay;
  1271. SetProfileLong("SaveClipDelay", dwDelay);
  1272. }
  1273. long CGetSetOptions::GetProcessDrawClipboardDelay()
  1274. {
  1275. return GetProfileLong("ProcessDrawClipboardDelay", 100);
  1276. }
  1277. void CGetSetOptions::SetProcessDrawClipboardDelay(long lDelay)
  1278. {
  1279. m_lProcessDrawClipboardDelay = lDelay;
  1280. SetProfileLong("ProcessDrawClipboardDelay", lDelay);
  1281. }
  1282. BOOL CGetSetOptions::GetEnableDebugLogging()
  1283. {
  1284. return GetProfileLong("EnableDebugLogging", FALSE);
  1285. }
  1286. void CGetSetOptions::SetEnableDebugLogging(BOOL bEnable)
  1287. {
  1288. m_bEnableDebugLogging = bEnable;
  1289. SetProfileLong("EnableDebugLogging", bEnable);
  1290. }
  1291. BOOL CGetSetOptions::GetEnsureConnectToClipboard()
  1292. {
  1293. return GetProfileLong("EnsureConnected", TRUE);
  1294. }
  1295. void CGetSetOptions::SetEnsureConnectToClipboard(BOOL bSet)
  1296. {
  1297. m_bEnsureConnectToClipboard = bSet;
  1298. SetProfileLong("EnsureConnected", bSet);
  1299. }
  1300. BOOL CGetSetOptions::GetPromptWhenDeletingClips()
  1301. {
  1302. return GetProfileLong("PromptWhenDeletingClips", TRUE);
  1303. }
  1304. void CGetSetOptions::SetPromptWhenDeletingClips(BOOL bSet)
  1305. {
  1306. SetProfileLong("PromptWhenDeletingClips", bSet);
  1307. }
  1308. CString CGetSetOptions::GetLastImportDir()
  1309. {
  1310. return GetProfileString("LastImportDir", "");
  1311. }
  1312. void CGetSetOptions::SetLastImportDir(CString csDir)
  1313. {
  1314. SetProfileString("LastImportDir", csDir);
  1315. }
  1316. CString CGetSetOptions::GetLastExportDir()
  1317. {
  1318. return GetProfileString("LastExportDir", "");
  1319. }
  1320. void CGetSetOptions::SetLastExportDir(CString csDir)
  1321. {
  1322. SetProfileString("LastExportDir", csDir);
  1323. }
  1324. BOOL CGetSetOptions::GetUpdateDescWhenSavingClip()
  1325. {
  1326. return GetProfileLong("UpdateDescWhenSaving", TRUE);
  1327. }
  1328. void CGetSetOptions::SetUpdateDescWhenSavingClip(BOOL bSet)
  1329. {
  1330. SetProfileLong("UpdateDescWhenSaving", bSet);
  1331. }
  1332. CString CGetSetOptions::GetPath(long lPathID)
  1333. {
  1334. CString csDir = CGetSetOptions::GetExeFileName();
  1335. csDir = GetFilePath(csDir);
  1336. FIX_CSTRING_PATH(csDir);
  1337. //U3_APP_DATA_PATH - <U3_DEVICE_PATH>\System\Apps\{app_unique_id}\Data
  1338. //U3_HOST_EXEC_PATH - %APPDATA%\U3\{device_serial_number}\{app_unique_id}\Exec
  1339. //U3_DEVICE_EXEC_PATH - <U3_DEVICE_PATH>\System\Apps\{app_unique_id}\Exec
  1340. switch(lPathID)
  1341. {
  1342. case PATH_HELP:
  1343. if(m_bU3)
  1344. {
  1345. csDir = GETENV(_T("U3_DEVICE_EXEC_PATH"));
  1346. FIX_CSTRING_PATH(csDir);
  1347. }
  1348. csDir += "Help\\";
  1349. break;
  1350. case PATH_LANGUAGE:
  1351. if(m_bU3)
  1352. {
  1353. csDir = GETENV(_T("U3_DEVICE_EXEC_PATH"));
  1354. FIX_CSTRING_PATH(csDir);
  1355. }
  1356. csDir += "language\\";
  1357. break;
  1358. case PATH_THEMES:
  1359. if(m_bU3)
  1360. {
  1361. csDir = GETENV(_T("U3_DEVICE_EXEC_PATH"));
  1362. FIX_CSTRING_PATH(csDir);
  1363. }
  1364. csDir += "Themes\\";
  1365. break;
  1366. case PATH_REMOTE_FILES:
  1367. if(m_bU3)
  1368. {
  1369. csDir = GETENV(_T("U3_HOST_EXEC_PATH"));
  1370. FIX_CSTRING_PATH(csDir);
  1371. }
  1372. else if(CGetSetOptions::GetIsPortableDitto() == false)
  1373. {
  1374. csDir = GetAppDataPath();
  1375. }
  1376. csDir += "ReceivedFiles\\";
  1377. break;
  1378. case PATH_LOG_FILE:
  1379. if(m_bU3)
  1380. {
  1381. csDir = GETENV(_T("U3_HOST_EXEC_PATH"));
  1382. FIX_CSTRING_PATH(csDir);
  1383. }
  1384. else if(CGetSetOptions::GetIsPortableDitto() == false)
  1385. {
  1386. csDir = GetAppDataPath();
  1387. }
  1388. break;
  1389. case PATH_UPDATE_FILE:
  1390. //same path as the executable
  1391. break;
  1392. case PATH_DATABASE:
  1393. if(m_bU3)
  1394. {
  1395. csDir = GETENV(_T("U3_APP_DATA_PATH"));
  1396. FIX_CSTRING_PATH(csDir);
  1397. }
  1398. break;
  1399. case PATH_INI:
  1400. if(m_bU3)
  1401. {
  1402. csDir = GETENV(_T("U3_APP_DATA_PATH"));
  1403. FIX_CSTRING_PATH(csDir);
  1404. }
  1405. break;
  1406. case PATH_U3_HWND_INI:
  1407. if(m_bU3)
  1408. {
  1409. csDir = GETENV(_T("U3_HOST_EXEC_PATH"));
  1410. FIX_CSTRING_PATH(csDir);
  1411. }
  1412. break;
  1413. case PATH_ADDINS:
  1414. if(m_bU3)
  1415. {
  1416. csDir = GETENV(_T("U3_DEVICE_EXEC_PATH"));
  1417. FIX_CSTRING_PATH(csDir);
  1418. }
  1419. csDir += "Addins\\";
  1420. break;
  1421. case PATH_DRAG_FILES:
  1422. if (m_bU3)
  1423. {
  1424. csDir = GETENV(_T("U3_HOST_EXEC_PATH"));
  1425. FIX_CSTRING_PATH(csDir);
  1426. }
  1427. else if (CGetSetOptions::GetIsPortableDitto() == false)
  1428. {
  1429. csDir = GetAppDataPath();
  1430. }
  1431. csDir += "DragFiles\\";
  1432. break;
  1433. }
  1434. CreateDirectory(csDir, NULL);
  1435. return csDir;
  1436. }
  1437. void CGetSetOptions::WriteU3Hwnd(HWND hWnd)
  1438. {
  1439. CString csIniFile = GetPath(PATH_U3_HWND_INI);
  1440. csIniFile += _T("DittohWnd.ini");
  1441. WritePrivateProfileInt(_T("Ditto"), _T("MainhWnd"), (int)hWnd, csIniFile);
  1442. }
  1443. long CGetSetOptions::GetDittoRestoreClipboardDelay()
  1444. {
  1445. return GetProfileLong("RestoreClipboardDelay", 750);
  1446. }
  1447. void CGetSetOptions::SetDittoRestoreClipboardDelay(long lDelay)
  1448. {
  1449. SetProfileLong("RestoreClipboardDelay", lDelay);
  1450. }
  1451. void CGetSetOptions::GetCopyBufferItem(int nPos, CCopyBufferItem &Item)
  1452. {
  1453. Item.m_lCopyHotKey = GetProfileLong(StrF(_T("CopyBufferCopyHotKey_%d"), nPos), 0);
  1454. Item.m_lPasteHotKey = GetProfileLong(StrF(_T("CopyBufferPasteHotKey_%d"), nPos), 0);
  1455. Item.m_lCutHotKey = GetProfileLong(StrF(_T("CopyBufferCutHotKey_%d"), nPos), 0);
  1456. Item.m_bPlaySoundOnCopy = GetProfileLong(StrF(_T("CopyBufferPlaySound_%d"), nPos), 0);
  1457. }
  1458. void CGetSetOptions::SetCopyBufferItem(int nPos, CCopyBufferItem &Item)
  1459. {
  1460. SetProfileLong(StrF(_T("CopyBufferCopyHotKey_%d"), nPos), Item.m_lCopyHotKey);
  1461. SetProfileLong(StrF(_T("CopyBufferPasteHotKey_%d"), nPos), Item.m_lPasteHotKey);
  1462. SetProfileLong(StrF(_T("CopyBufferCutHotKey_%d"), nPos), Item.m_lCutHotKey);
  1463. SetProfileLong(StrF(_T("CopyBufferPlaySound_%d"), nPos), Item.m_bPlaySoundOnCopy);
  1464. }
  1465. CString CGetSetOptions::GetMultiPasteSeparator(bool bConvertToLineFeeds)
  1466. {
  1467. CString csSep = GetProfileString(_T("MultiPasteSeparator"), _T("[LF]"));
  1468. if(bConvertToLineFeeds)
  1469. {
  1470. CString csLineFeed(_T("\r\n"));
  1471. csSep.Replace(_T("[LF]"), csLineFeed);
  1472. csSep.Replace(_T("[lf]"), csLineFeed);
  1473. }
  1474. return csSep;
  1475. }
  1476. void CGetSetOptions::SetMultiPasteSeparator(CString csSep)
  1477. {
  1478. SetProfileString(_T("MultiPasteSeparator"), csSep);
  1479. }
  1480. BOOL CGetSetOptions::GetSetCurrentDirectory()
  1481. {
  1482. if(m_portable)
  1483. {
  1484. CString csExePath = GetFilePath(GetExeFileName());
  1485. FIX_CSTRING_PATH(csExePath);
  1486. ::SetCurrentDirectory(csExePath);
  1487. }
  1488. return m_portable == true;
  1489. }
  1490. bool CGetSetOptions::GetIsPortableDitto()
  1491. {
  1492. return m_portable;
  1493. }
  1494. CString CGetSetOptions::GetPasteString(CString csAppName)
  1495. {
  1496. CString csString = GetProfileString(csAppName, _T(""), _T("PasteStrings"));
  1497. if(csString.IsEmpty())
  1498. return GetDefaultPasteString();
  1499. return csString;
  1500. }
  1501. CString CGetSetOptions::GetDefaultPasteString()
  1502. {
  1503. return GetProfileString(_T("DefaultPasteString"), _T("^v"));
  1504. }
  1505. CString CGetSetOptions::GetCopyString(CString csAppName)
  1506. {
  1507. CString csString = GetProfileString(csAppName, _T(""), _T("CopyStrings"));
  1508. if(csString.IsEmpty())
  1509. return GetDefaultCopyString();
  1510. return csString;
  1511. }
  1512. CString CGetSetOptions::GetDefaultCopyString()
  1513. {
  1514. return GetProfileString(_T("DefaultCopyString"), _T("^c"));
  1515. }
  1516. CString CGetSetOptions::GetCutString(CString csAppName)
  1517. {
  1518. CString csString = GetProfileString(csAppName, _T(""), _T("CutStrings"));
  1519. if(csString.IsEmpty())
  1520. return GetDefaultCutString();
  1521. return csString;
  1522. }
  1523. CString CGetSetOptions::GetDefaultCutString()
  1524. {
  1525. return GetProfileString(_T("DefaultCutString"), _T("^x"));
  1526. }
  1527. BOOL CGetSetOptions::GetEditWordWrap()
  1528. {
  1529. return GetProfileLong(_T("EditWordWrap"), TRUE);
  1530. }
  1531. void CGetSetOptions::SetEditWordWrap(BOOL bSet)
  1532. {
  1533. SetProfileLong(_T("EditWordWrap"), bSet);
  1534. }
  1535. bool CGetSetOptions::GetAllowFriends()
  1536. {
  1537. return (GetProfileLong("AllowFriends", TRUE) == TRUE);
  1538. }
  1539. long CGetSetOptions::GetAutoMaxDelay()
  1540. {
  1541. return GetProfileLong(_T("AutoMaxDelaySeconds"), 2);
  1542. }
  1543. void CGetSetOptions::SetAutoMaxDelay(long lDelay)
  1544. {
  1545. SetProfileLong(_T("AutoMaxDelaySeconds"), lDelay);
  1546. }
  1547. void CGetSetOptions::SetTheme(CString csTheme)
  1548. {
  1549. SetProfileString(_T("Theme"), csTheme);
  1550. }
  1551. CString CGetSetOptions::GetTheme()
  1552. {
  1553. return GetProfileString(_T("Theme"), "");
  1554. }
  1555. long CGetSetOptions::GetKeyStateWaitTimerCount()
  1556. {
  1557. return GetProfileLong(_T("KeyStateWaitTimerCount"), 20);
  1558. }
  1559. long CGetSetOptions::GetKeyStatePasteDelay()
  1560. {
  1561. return GetProfileLong(_T("KeyStatePasteDelay"), 200);
  1562. }
  1563. DWORD CGetSetOptions::GetDittoHotKey()
  1564. {
  1565. return (DWORD)GetProfileLong(_T("DittoHotKey"), 704);
  1566. }
  1567. DWORD CGetSetOptions::SendKeysDelay()
  1568. {
  1569. return (DWORD)GetProfileLong(_T("SendKeysDelay"), 50);
  1570. }
  1571. DWORD CGetSetOptions::WaitForActiveWndTimeout()
  1572. {
  1573. return (DWORD)GetProfileLong(_T("WaitForActiveWndTimeout"), 100);
  1574. }
  1575. DWORD CGetSetOptions::FocusChangedDelay()
  1576. {
  1577. return (DWORD)GetProfileLong(_T("FocusChangedDelay"), 100);
  1578. }
  1579. DWORD CGetSetOptions::FocusWndTimerTimeout()
  1580. {
  1581. return (DWORD)GetProfileLong(_T("FocusWndTimerTimeout"), 2000);
  1582. }
  1583. BOOL CGetSetOptions::GetConnectedToClipboard()
  1584. {
  1585. return GetProfileLong("ConnectedToClipboard", TRUE);
  1586. }
  1587. void CGetSetOptions::SetConnectedToClipboard(BOOL val)
  1588. {
  1589. SetProfileLong("ConnectedToClipboard", val);
  1590. }
  1591. DWORD CGetSetOptions::GetTextOnlyRestoreDelay()
  1592. {
  1593. return (DWORD)GetProfileLong(_T("TextOnlyRestoreDelay"), 2000);
  1594. }
  1595. DWORD CGetSetOptions::GetTextOnlyPasteDelay()
  1596. {
  1597. return (DWORD)GetProfileLong(_T("TextOnlyPasteDelay"), 0);
  1598. }
  1599. BOOL CGetSetOptions::GetSetFocusToApp(CString csAppName)
  1600. {
  1601. CString focusCheck;
  1602. focusCheck = "SetFocus_";
  1603. focusCheck += csAppName;
  1604. return GetProfileLong(focusCheck, FALSE);
  1605. }
  1606. DWORD CGetSetOptions::SelectedIndex()
  1607. {
  1608. return (DWORD)GetProfileLong(_T("SelectedIndex"), 0);
  1609. }
  1610. void CGetSetOptions::SetCopyAppInclude(CString csAppName)
  1611. {
  1612. SetProfileString(_T("CopyAppInclude"), csAppName);
  1613. }
  1614. CString CGetSetOptions::GetCopyAppInclude()
  1615. {
  1616. CString includeApp = GetProfileString(_T("CopyAppInclude"), "*");
  1617. if(includeApp == "")
  1618. {
  1619. includeApp = "*";
  1620. }
  1621. return includeApp;
  1622. }
  1623. void CGetSetOptions::SetCopyAppExclude(CString csAppName)
  1624. {
  1625. SetProfileString(_T("CopyAppExclude"), csAppName);
  1626. }
  1627. CString CGetSetOptions::GetCopyAppExclude()
  1628. {
  1629. return GetProfileString(_T("CopyAppExclude"), "");
  1630. }
  1631. CString CGetSetOptions::GetCopyAppSeparator()
  1632. {
  1633. return GetProfileString(_T("CopyAppSeparator"), ";");
  1634. }
  1635. DWORD CGetSetOptions::GetNoFormatsRetryDelay()
  1636. {
  1637. return GetProfileLong(_T("NoFormatsRetryDelay"), 200);
  1638. }
  1639. DWORD CGetSetOptions::GetMainDeletesDeleteCount()
  1640. {
  1641. return GetProfileLong(_T("MainDeletesDeleteCount"), 100);
  1642. }
  1643. DWORD CGetSetOptions::GetIdleSecondsBeforeDelete()
  1644. {
  1645. return GetProfileLong(_T("IdleSecondsBeforeDelete"), 60*10);
  1646. }
  1647. DWORD CGetSetOptions::GetDbTimeout()
  1648. {
  1649. return GetProfileLong(_T("DbTimeout"), 5000);
  1650. }
  1651. DWORD CGetSetOptions::GetFunnyTickCountAdjustment()
  1652. {
  1653. return GetProfileLong(_T("FunnyTickCountAdjustment"), 300001);
  1654. }
  1655. DWORD CGetSetOptions::GetMinIdleTimeBeforeTrackFocus()
  1656. {
  1657. return GetProfileLong(_T("MinIdleTimeBeforeTrackFocus"), 100);
  1658. }
  1659. DWORD CGetSetOptions::GetTimeBeforeExpandWindow()
  1660. {
  1661. return GetProfileLong(_T("TimeBeforeExpandWindow"), 250);
  1662. }
  1663. DWORD CGetSetOptions::GetUseGuiThreadInfoForFocus()
  1664. {
  1665. return GetProfileLong(_T("UseGuiThreadInfoForFocus"), 1);
  1666. }
  1667. void CGetSetOptions::SetSearchDescription(BOOL val)
  1668. {
  1669. SetProfileLong(_T("SearchDescription"), val);
  1670. }
  1671. BOOL CGetSetOptions::GetSearchDescription()
  1672. {
  1673. return GetProfileLong(_T("SearchDescription"), 1);
  1674. }
  1675. void CGetSetOptions::SetSearchFullText(BOOL val)
  1676. {
  1677. SetProfileLong(_T("SearchFullText"), val);
  1678. }
  1679. BOOL CGetSetOptions::GetSearchFullText()
  1680. {
  1681. return GetProfileLong(_T("SearchFullText"), 0);
  1682. }
  1683. void CGetSetOptions::SetSearchQuickPaste(BOOL val)
  1684. {
  1685. SetProfileLong(_T("SearchQuickPaste"), val);
  1686. }
  1687. BOOL CGetSetOptions::GetSearchQuickPaste()
  1688. {
  1689. return GetProfileLong(_T("SearchQuickPaste"), 0);
  1690. }
  1691. void CGetSetOptions::SetSimpleTextSearch(BOOL val)
  1692. {
  1693. SetProfileLong(_T("SimpleTextSearch"), val);
  1694. }
  1695. BOOL CGetSetOptions::GetSimpleTextSearch()
  1696. {
  1697. return GetProfileLong(_T("SimpleTextSearch"), 0);
  1698. }
  1699. void CGetSetOptions::SetRegExTextSearch(BOOL val)
  1700. {
  1701. SetProfileLong(_T("RegExTextSearch"), val);
  1702. }
  1703. BOOL CGetSetOptions::GetRegExTextSearch()
  1704. {
  1705. return GetProfileLong(_T("RegExTextSearch"), 0);
  1706. }
  1707. void CGetSetOptions::SetMoveClipsOnGlobal10(BOOL val)
  1708. {
  1709. SetProfileLong(_T("MoveClipsOnGlobal10"), val);
  1710. }
  1711. BOOL CGetSetOptions::GetMoveClipsOnGlobal10()
  1712. {
  1713. return GetProfileLong(_T("MoveClipsOnGlobal10"), 0);
  1714. }
  1715. void CGetSetOptions::SetShowScrollBar(BOOL val)
  1716. {
  1717. m_showScrollBar = val;
  1718. SetProfileLong(_T("ShowScrollBar"), val);
  1719. }
  1720. BOOL CGetSetOptions::GetShowScrollBar()
  1721. {
  1722. return GetProfileLong(_T("ShowScrollBar"), 0);
  1723. }
  1724. void CGetSetOptions::SetPasteAsAdmin(BOOL val)
  1725. {
  1726. SetProfileLong(_T("PasteAsAdmin"), val);
  1727. }
  1728. BOOL CGetSetOptions::GetPasteAsAdmin()
  1729. {
  1730. return GetProfileLong(_T("PasteAsAdmin"), 1);
  1731. }
  1732. void CGetSetOptions::SetRememberDescPos(BOOL val)
  1733. {
  1734. SetProfileLong(_T("RememberDescPos"), val);
  1735. }
  1736. BOOL CGetSetOptions::GetRememberDescPos()
  1737. {
  1738. return GetProfileLong(_T("RememberDescPos"), FALSE);
  1739. }
  1740. void CGetSetOptions::SetSizeDescWindowToContent(BOOL val)
  1741. {
  1742. SetProfileLong(_T("SizeDescWindowToContent"), val);
  1743. }
  1744. BOOL CGetSetOptions::GetSizeDescWindowToContent()
  1745. {
  1746. return GetProfileLong(_T("SizeDescWindowToContent"), TRUE);
  1747. }
  1748. void CGetSetOptions::SetScaleImagesToDescWindow(BOOL val)
  1749. {
  1750. SetProfileLong(_T("ScaleImagesToDescWindow"), val);
  1751. }
  1752. BOOL CGetSetOptions::GetScaleImagesToDescWindow()
  1753. {
  1754. return GetProfileLong(_T("ScaleImagesToDescWindow"), TRUE);
  1755. }
  1756. void CGetSetOptions::SetDescWndPoint(CPoint point)
  1757. {
  1758. SetResolutionProfileLong("DescWndX", point.x);
  1759. SetResolutionProfileLong("DescWndY", point.y);
  1760. }
  1761. void CGetSetOptions::GetDescWndPoint(CPoint &point)
  1762. {
  1763. point.x = GetResolutionProfileLong("DescWndX", 100);
  1764. point.y = GetResolutionProfileLong("DescWndY", 100);
  1765. }
  1766. void CGetSetOptions::GetDescWndSize(CSize &size)
  1767. {
  1768. size.cx = GetResolutionProfileLong("DescWndCX", 300);
  1769. size.cy = GetResolutionProfileLong("DescWndCY", 300);
  1770. if(size.cx <= 0 && size.cy <= 0)
  1771. {
  1772. size.cx = 300;
  1773. size.cy = 300;
  1774. }
  1775. }
  1776. void CGetSetOptions::SetDescWndSize(CSize size)
  1777. {
  1778. SetResolutionProfileLong("DescWndCX", size.cx);
  1779. SetResolutionProfileLong("DescWndCY", size.cy);
  1780. }
  1781. void CGetSetOptions::SetShowInTaskBar(BOOL val)
  1782. {
  1783. SetProfileLong(_T("ShowInTaskBar"), val);
  1784. }
  1785. BOOL CGetSetOptions::GetShowInTaskBar()
  1786. {
  1787. return GetProfileLong(_T("ShowInTaskBar"), FALSE);
  1788. }
  1789. void CGetSetOptions::SetDiffApp(CString val)
  1790. {
  1791. SetProfileString(_T("DiffApp"), val);
  1792. }
  1793. CString CGetSetOptions::GetDiffApp()
  1794. {
  1795. return GetProfileString(_T("DiffApp"), _T(""));
  1796. }
  1797. void CGetSetOptions::SetQRCodeBorderPixels(int val)
  1798. {
  1799. SetProfileLong(_T("QRCodeBorderPixels"), val);
  1800. }
  1801. int CGetSetOptions::GetQRCodeBorderPixels()
  1802. {
  1803. return GetProfileLong(_T("QRCodeBorderPixels"), 30);
  1804. }
  1805. CString CGetSetOptions::GetTranslateUrl()
  1806. {
  1807. return GetProfileString(_T("TranslateUrl"), _T("https://translate.google.com/?tl=en#auto/en/%s"));
  1808. }
  1809. void CGetSetOptions::SetNetworkReadTimeoutMS(int val)
  1810. {
  1811. SetProfileLong(_T("NetworkReadTimeoutMS"), val);
  1812. }
  1813. int CGetSetOptions::GetNetworkReadTimeoutMS()
  1814. {
  1815. return GetProfileLong(_T("NetworkReadTimeoutMS"), 30000);
  1816. }
  1817. void CGetSetOptions::SetRequestFilesUsingIP(int val)
  1818. {
  1819. SetProfileLong(_T("RequestFilesUsingIP"), val);
  1820. }
  1821. int CGetSetOptions::GetRequestFilesUsingIP()
  1822. {
  1823. return GetProfileLong(_T("RequestFilesUsingIP"), 0);
  1824. }
  1825. int CGetSetOptions::ReadRandomFileInterval()
  1826. {
  1827. return GetProfileLong(_T("ReadRandomFileInterval"), 60);
  1828. }
  1829. int CGetSetOptions::ReadRandomFileIdleMin()
  1830. {
  1831. return GetProfileLong(_T("ReadRandomFileIdleMin"), 30);
  1832. }
  1833. BOOL CGetSetOptions::GetShowGroupsInMainList()
  1834. {
  1835. return GetProfileLong(_T("ShowGroupsInMainList"), 0);
  1836. }
  1837. void CGetSetOptions::SetShowGroupsInMainList(BOOL val)
  1838. {
  1839. SetProfileLong(_T("ShowGroupsInMainList"), val);
  1840. }
  1841. void CGetSetOptions::SetGroupDoubleClickTimeMS(int val)
  1842. {
  1843. SetProfileLong(_T("GroupDoubleClickTimeMS"), val);
  1844. }
  1845. int CGetSetOptions::GetGroupDoubleClickTimeMS()
  1846. {
  1847. return GetProfileLong(_T("GroupDoubleClickTimeMS"), 500);
  1848. }
  1849. void CGetSetOptions::SetSaveToGroupTimeoutMS(int val)
  1850. {
  1851. SetProfileLong(_T("SaveToGroupTimeoutMS"), val);
  1852. }
  1853. int CGetSetOptions::GetSaveToGroupTimeoutMS()
  1854. {
  1855. return GetProfileLong(_T("SaveToGroupTimeoutMS"), 1000);
  1856. }
  1857. void CGetSetOptions::SetCopyReasonTimeoutMS(int val)
  1858. {
  1859. SetProfileLong(_T("CopyReasonTimeoutMS"), val);
  1860. }
  1861. int CGetSetOptions::GetCopyReasonTimeoutMS()
  1862. {
  1863. return GetProfileLong(_T("CopyReasonTimeoutMS"), 1000);
  1864. }
  1865. void CGetSetOptions::SetWindowsResumeDelayReOpenDbMS(int val)
  1866. {
  1867. SetProfileLong(_T("WindowsResumeDelayReOpenDbMS"), val);
  1868. }
  1869. int CGetSetOptions::GetWindowsResumeDelayReOpenDbMS()
  1870. {
  1871. return GetProfileLong(_T("WindowsResumeDelayReOpenDbMS"), 2000);
  1872. }
  1873. BOOL CGetSetOptions::GetShowMsgWndOnCopyToGroup()
  1874. {
  1875. return GetProfileLong(_T("ShowMsgWndOnCopyToGroup"), TRUE);
  1876. }
  1877. void CGetSetOptions::SetShowMsgWndOnCopyToGroup(BOOL val)
  1878. {
  1879. SetProfileLong(_T("ShowMsgWndOnCopyToGroup"), val);
  1880. }
  1881. int CGetSetOptions::GetActionShortCutA(DWORD action, int pos)
  1882. {
  1883. CString actionText;
  1884. actionText.Format(_T("%d_%d_A"), action, pos);
  1885. int ret = GetProfileLong(actionText, -1);
  1886. if (ret == -1)
  1887. {
  1888. ret = ActionEnums::GetDefaultShortCutKeyA((ActionEnums::ActionEnumValues)action, pos);
  1889. }
  1890. return ret;
  1891. }
  1892. void CGetSetOptions::SetActionShortCutA(int action, DWORD shortcut, int pos)
  1893. {
  1894. CString actionText;
  1895. actionText.Format(_T("%d_%d_A"), action, pos);
  1896. SetProfileLong(actionText, shortcut);
  1897. }
  1898. int CGetSetOptions::GetActionShortCutB(DWORD action, int pos)
  1899. {
  1900. CString actionText;
  1901. actionText.Format(_T("%d_%d_B"), action, pos);
  1902. int ret = GetProfileLong(actionText, -1);
  1903. if (ret == -1)
  1904. {
  1905. ret = ActionEnums::GetDefaultShortCutKeyB((ActionEnums::ActionEnumValues)action, pos);
  1906. }
  1907. return ret;
  1908. }
  1909. void CGetSetOptions::SetActionShortCutB(int action, DWORD shortcut, int pos)
  1910. {
  1911. CString actionText;
  1912. actionText.Format(_T("%d_%d_B"), action, pos);
  1913. SetProfileLong(actionText, shortcut);
  1914. }
  1915. BOOL CGetSetOptions::GetShowAlwaysOnTopWarning()
  1916. {
  1917. return GetProfileLong(_T("ShowAlwaysOnTopWarning"), TRUE);
  1918. }
  1919. void CGetSetOptions::SetShowAlwaysOnTopWarning(BOOL show)
  1920. {
  1921. m_bShowAlwaysOnTopWarning = show;
  1922. SetProfileLong(_T("ShowAlwaysOnTopWarning"), show);
  1923. }
  1924. BOOL CGetSetOptions::GetUseIPFromAccept()
  1925. {
  1926. return GetProfileLong(_T("UseIPFromAccept"), TRUE);
  1927. }
  1928. void CGetSetOptions::SetUseIPFromAccept(BOOL useAccept)
  1929. {
  1930. SetProfileLong(_T("UseIPFromAccept"), useAccept);
  1931. }
  1932. int CGetSetOptions::GetDragId()
  1933. {
  1934. return GetProfileLong(_T("DragId"), 1);
  1935. }
  1936. void CGetSetOptions::SetDragId(int id)
  1937. {
  1938. SetProfileLong(_T("DragId"), id);
  1939. }