CP_Main.h 5.6 KB

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