CP_Main.h 5.4 KB

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