summaryrefslogtreecommitdiffabout
path: root/BigBrotherDoc.h
blob: 3343e18cd2428afd43468fad1cf4f97d0a2d2864 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
// BigBrotherDoc.h : interface of the CBigBrotherDoc class
//
/////////////////////////////////////////////////////////////////////////////

class CLogEntry : public CObject {
public:
	enum	{
		flagsSeparator=1
	};
	UINT flags;
	virtual void Serialize(CArchive& ar);
	CLogEntry(CLogEntry& src);
	CLogEntry& operator=(CLogEntry& src);
	BOOL m_bReached;
	CString m_Status;
	ULONG m_RTT;
	CTime m_Time;

	CLogEntry();
	DECLARE_SERIAL(CLogEntry)
};

typedef	CTypedPtrList<CObList,CLogEntry*>	CLogList;

class CBrother;
class CAction	: public CObject {
public:
	static CString FormatLine(LPCTSTR fmt,CBrother *b);
	BOOL operator!=(CAction& a);
	BOOL operator==(CAction& a);
	virtual void Serialize(CArchive& ar);
	void PerformAction(CBrother *b);
	static BOOL PlayASound(LPCTSTR sound);
	CAction& operator=(CAction& src);
	void CleanUp();
	enum	{
		flagsPlayASound = 1,
		flagsRunCustom = 2
	};
	UINT flags;
	CString m_Sound;
	CString m_Custom;

	CAction();
	DECLARE_SERIAL(CAction)
};

class CBrother	: public CObject	{
public:
	void AppendSeparator();
	CBrother& operator=(CBrother& b);
	BOOL operator!=(CBrother& b);
	BOOL operator==(CBrother& b);
	BOOL m_bToKill;
	void Suicide();
	virtual void Serialize(CArchive& ar);
	BOOL m_bUp;
	CRect m_rc;
	BOOL IsValuable();
	~CBrother();
	UINT m_HowDown;
	BOOL m_bPinging;
	UINT Check();
	CDocument* m_Doc;
	static UINT DoCheck(LPVOID pParam);
	BOOL m_bIsUp;
	BOOL m_bPending;
	CTime m_Pinged;
	BOOL m_bPinged;
	CLogList m_Log;
	HTREEITEM m_Item;
	void ParentalAdjust(BOOL cleanUp=FALSE);
	void CleanUp();
	CBrother(CBrother* daddy);
	CBrother* m_Daddy;
	UINT m_Retries;
	DWORD m_TimeOut;
	UINT m_IntervalBad;
	UINT m_IntervalGood;
	BOOL m_bLog;
	CAction m_Down;
	CAction m_Up;
	enum	{
		flagsOverrideIntervals=1,
		flagsOverrideTimeout=2,
		flagsOverrideRetries=4,
		flagsOverrideActions=8,
		flagsOverrideLogging=16,
		flagsExpandedTree=32,
		flagsCurrentBrother=64
	};
	UINT flags;
	CString m_Desc;
	CString m_Host;

	CBrother();
	DECLARE_SERIAL(CBrother)
};

typedef	CTypedPtrList<CObList,CBrother*>	CBrotherList;
typedef	CMap<DWORD,DWORD,CBrother*,CBrother*>	CThisMap;

class CBigBrotherView;
class CActivityView;
class CBigBrotherDoc : public CDocument
{
protected: // create from serialization only
	CBigBrotherDoc();
	DECLARE_SERIAL(CBigBrotherDoc)

// Attributes
public:
	BOOL m_bStoreLastActivity;
	enum	{
		flagsSuspended=1,
		flagsShowProps=2
	};
	UINT flags;
	CTime m_AutoSaved;
	void LogLine(LPCTSTR str);
	CTimeSpan m_AutoSave;
	BOOL m_bSaveOnShutdown;
	CThisMap m_ThisMap;
	CString m_LogFile;
	void GetFamily(CBrother *b,CBrotherList *bh);
	CBrother* GetCurrentBrother();
	void CleanUp();
	UINT m_PingSize;
	int m_MaxThreads;
	int m_Threads;
	void TryBrother(CBrother *b);
	BOOL CheckPendingBrother(CBrother* b,CTime& currentTime,CTime& nearestCheck,BOOL nearested);
	void CheckPendingQueue();
	CTimeSpan m_MaxLogTime;
	CActivityView *m_AView;
	CBigBrotherView* m_BBView;
	CBrotherList m_Brotherhood;
	CBrother* m_RootBrother;

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CBigBrotherDoc)
	public:
	virtual BOOL OnNewDocument();
	virtual void Serialize(CArchive& ar);
	virtual void OnChangedViewList();
	virtual void DeleteContents();
	virtual void OnCloseDocument();
	protected:
	virtual BOOL SaveModified();
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CBigBrotherDoc();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
	//{{AFX_MSG(CBigBrotherDoc)
	afx_msg void OnBrothersNew();
	afx_msg void OnUpdateBrothersAddbrother(CCmdUI* pCmdUI);
	afx_msg void OnBrothersAddbrother();
	afx_msg void OnUpdateBrothersDelete(CCmdUI* pCmdUI);
	afx_msg void OnBrothersDelete();
	afx_msg void OnFilePreferences();
	afx_msg void OnUpdateFilePause(CCmdUI* pCmdUI);
	afx_msg void OnFilePause();
	afx_msg void OnUpdateViewHostproperties(CCmdUI* pCmdUI);
	afx_msg void OnViewHostproperties();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////