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