CP_Main.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. #pragma once
  2. #ifndef __AFXWIN_H__
  3. #error include 'stdafx.h' before including this file for PCH
  4. #endif
  5. #include "../resource.h" // main symbols
  6. #include "Clip.h"
  7. #include "DatabaseUtilities.h"
  8. #include "Misc.h"
  9. #include "Options.h"
  10. #include "..\Shared\ArrayEx.h"
  11. #include "MainFrm.h"
  12. #include "ProcessPaste.h"
  13. #include "MultiLanguage.h"
  14. #include "CopyThread.h"
  15. #include "ClipboardSaveRestore.h"
  16. #include "DittoCopyBuffer.h"
  17. #include "sqlite\CppSQLite3.h"
  18. #include "DittoAddins.h"
  19. #include "externalwindowtracker.h"
  20. #include "HotKeys.h"
  21. #include "UAC_Thread.h"
  22. #include "ICU_String.h"
  23. #include "ClipEditThread.h"
  24. extern class CCP_MainApp theApp;
  25. class CCP_MainApp : public CWinApp
  26. {
  27. public:
  28. CCP_MainApp();
  29. ~CCP_MainApp();
  30. CppSQLite3DB m_db;
  31. bool m_databaseOnNetworkShare;
  32. HANDLE m_hMutex; // for singleton app
  33. HANDLE m_adminPasteMutex;
  34. // track stages of startup / shutdown
  35. bool m_bAppRunning;
  36. bool m_bAppExiting;
  37. int m_connectOnStartup;
  38. bool m_bExitServerThread;
  39. // MainFrame
  40. HWND m_MainhWnd;
  41. CMainFrame* m_pMainFrame;
  42. CFrameWnd* m_pNoDbMainFrame;
  43. void AfterMainCreate(); // called after main window creation
  44. void BeforeMainClose(); // called before main window close
  45. // System-wide HotKeys
  46. CHotKey* m_pDittoHotKey; // activate ditto's qpaste window
  47. CHotKey* m_pDittoHotKey2; // activate ditto's qpaste window
  48. CHotKey* m_pDittoHotKey3; // activate ditto's qpaste window
  49. CHotKey* m_pPosOne;
  50. CHotKey* m_pPosTwo;
  51. CHotKey* m_pPosThree;
  52. CHotKey* m_pPosFour;
  53. CHotKey* m_pPosFive;
  54. CHotKey* m_pPosSix;
  55. CHotKey* m_pPosSeven;
  56. CHotKey* m_pPosEight;
  57. CHotKey* m_pPosNine;
  58. CHotKey* m_pPosTen;
  59. CHotKey* m_pCopyBuffer1;
  60. CHotKey* m_pPasteBuffer1;
  61. CHotKey* m_pCutBuffer1;
  62. CHotKey* m_pCopyBuffer2;
  63. CHotKey* m_pPasteBuffer2;
  64. CHotKey* m_pCutBuffer2;
  65. CHotKey* m_pCopyBuffer3;
  66. CHotKey* m_pPasteBuffer3;
  67. CHotKey* m_pCutBuffer3;
  68. CHotKey* m_pCopyBuffer4;
  69. CHotKey* m_pPasteBuffer4;
  70. CHotKey* m_pCutBuffer4;
  71. CHotKey* m_pCopyBuffer5;
  72. CHotKey* m_pPasteBuffer5;
  73. CHotKey* m_pCutBuffer5;
  74. CHotKey* m_pTextOnlyPaste;
  75. CHotKey* m_pSaveClipboard;
  76. CHotKey* m_pCopyAndSaveClipboard;
  77. ExternalWindowTracker m_activeWnd;
  78. CClipEditThread m_editThread;
  79. // CopyThread and ClipViewer (Copy and Paste Management)
  80. CCopyThread m_CopyThread;
  81. void StartCopyThread();
  82. void StopCopyThread();
  83. // for posting messages
  84. HWND GetClipboardViewer() { return m_CopyThread.m_pClipboardViewer->m_hWnd; }
  85. bool EnableCbCopy(bool bState) { return m_CopyThread.SetCopyOnChange(bState); }
  86. bool IsClipboardViewerConnected() { return m_CopyThread.IsClipboardViewerConnected(); }
  87. bool GetConnectCV() { return m_CopyThread.GetConnectCV(); }
  88. void SetConnectCV(bool bConnect);
  89. bool ToggleConnectCV();
  90. void UpdateMenuConnectCV(CMenu* pMenu, UINT nMenuID);
  91. bool ImportClips(HWND hWnd);
  92. void LoadGlobalClips();
  93. void OnDeleteID(long lID);
  94. BOOL GetClipData(long lID, CClipFormat& Clip);
  95. bool EditItems(CClipIDs& Ids, bool bShowError, bool forceTextEdit);
  96. CClipTypes* LoadTypesFromDB(); // returns a "new" allocated object
  97. void ReloadTypes();
  98. void RefreshView(CopyReasonEnum::CopyReason copyReason = CopyReasonEnum::COPY_TO_UNKOWN); // refreshes the view if it is visible
  99. void RefreshClipInUI(int clipId, int updateFlags);
  100. void OnCopyCompleted(long lLastID, int count = 1, CopyReasonEnum::CopyReason copyReason = CopyReasonEnum::COPY_TO_UNKOWN);
  101. void OnPasteCompleted();
  102. // Groups
  103. long m_GroupDefaultID; // new clips are saved to this group
  104. long m_GroupID; // current group
  105. long m_GroupParentID; // current group's parent
  106. CString m_GroupText; // current group's description
  107. long m_oldGroupID;
  108. long m_oldGroupParentID;
  109. CString m_oldGroupText;
  110. void SaveCurrentGroupState();
  111. void ClearOldGroupState();
  112. BOOL TryEnterOldGroupState();
  113. BOOL EnterGroupID(long lID, BOOL clearOldGroupState = TRUE, BOOL saveCurrentGroupState = FALSE);
  114. long GetValidGroupID(); // returns a valid id (not negative)
  115. void SetGroupDefaultID(long lID); // sets a valid id
  116. // Window States
  117. // the ID given focus by CQPasteWnd::FillList
  118. long m_FocusID;
  119. bool m_bShowingQuickPaste;
  120. bool m_bRefreshView;
  121. CString m_Status;
  122. CQPasteWnd* QPasteWnd();
  123. HWND QPastehWnd();
  124. void SetStatus(const TCHAR* status = NULL, bool bRepaintImmediately = false);
  125. void ShowPersistent(bool bVal);
  126. bool m_bAsynchronousRefreshView;
  127. //Socket Info
  128. SOCKET m_sSocket;
  129. void StartStopServerThread();
  130. void StopServerThread();
  131. long m_lClipsSent;
  132. long m_lClipsRecieved;
  133. long m_lLastGoodIndexForNextworkPassword;
  134. CLIPFORMAT m_cfIgnoreClipboard; // used by CClip::LoadFromClipboard
  135. CLIPFORMAT m_excludeClipboardContentFromMonitorProcessing;
  136. CLIPFORMAT m_canIncludeInClipboardHistory;
  137. CLIPFORMAT m_cfDelaySavingData;
  138. CLIPFORMAT m_PingFormat;
  139. CLIPFORMAT m_HTML_Format;
  140. CLIPFORMAT m_RemoteCF_HDROP;
  141. CLIPFORMAT m_RTFFormat;
  142. CLIPFORMAT m_DittoFileData;
  143. CLIPFORMAT m_PNG_Format;
  144. COleDateTime m_oldtStartUp;
  145. CMultiLanguage m_Language;
  146. CDittoCopyBuffer m_CopyBuffer;
  147. void PumpMessageEx(HWND hWnd = NULL);
  148. CDittoAddins m_Addins;
  149. ULONG_PTR m_gdiplusToken;
  150. bool UACPaste();
  151. bool UACCopy();
  152. bool UACCut();
  153. bool UACThreadRunning();
  154. void RefreshShowInTaskBar();
  155. void SetActiveGroupId(int groupId);
  156. int GetActiveGroupId();
  157. void SetCopyReason(CopyReasonEnum::CopyReason copyReason);
  158. CopyReasonEnum::CopyReason GetCopyReason();
  159. void CreateMainWnd();
  160. void CloseNoDbWindow();
  161. CICU_String m_icuString;
  162. public:
  163. virtual BOOL InitInstance();
  164. virtual int ExitInstance();
  165. afx_msg void OnAppAbout();
  166. DECLARE_MESSAGE_MAP()
  167. virtual BOOL OnIdle(LONG lCount);
  168. protected:
  169. void ShowCommandLineError(CString csTitle, CString csMessage);
  170. CUAC_Thread* m_pUacPasteThread;
  171. int m_activeGroupId;
  172. DWORD m_activeGroupStartTime;
  173. CopyReasonEnum::CopyReason m_copyReason;
  174. DWORD m_copyReasonStartTime;
  175. };