-
Notifications
You must be signed in to change notification settings - Fork 0
/
wxMsFrameh.h
368 lines (328 loc) · 13.2 KB
/
wxMsFrameh.h
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
//-------------------------------------------------------------------
// Name: wxMSFrameh.h
// Purpose: main frame header for wxMS Mail Screener
// Author: A. Wiegert
//
// Copyright:
// Licence: wxWidgets license
//-------------------------------------------------------------------
#ifndef _WX_MS_FRAME_H_
#define _WX_MS_FRAME_H_
// ------------------------------------------------------------------
#include "wxMsPreProcDefsh.h" // needs to be first
// ------------------------------------------------------------------
#include <wx/thread.h>
#include <wx/log.h>
#if defined( WANT_HELP )
#include "wx/cshelp.h"
#include "wx/html/helpctrl.h"
#endif
#include <wx/stdpaths.h>
#include "wxMsPop3MsgListh.h"
#include "wxMsh.h"
#include "wxMsBaseFrame.h"
#include "mimetic.h"
#include "utils.h"
using namespace std;
using namespace mimetic;
#include "curl/curl.h"
#include <wx/appprogress.h>
#include "wxMsExtendedAddressh.h"
// ------------------------------------------------------------------
// mail grid right click menu and control IDs
enum
{
wxID_CONTEXT_DELETE_MSG = wxID_HIGHEST,
wxID_CONTEXT_PREVIEW_MSG,
wxID_CONTEXT_MARK_DEL_MSG,
wxID_CONTEXT_MARK_BOUNCE_MSG,
wxID_CONTEXT_ADD_BLACK_MSG,
wxID_CONTEXT_ADD_FRIEND_MSG,
MAIL_CHECK_TIMER_ID,
MAIL_SERVER_CHECK_TIMER_ID,
MAIL_DISPLAY_TIMER_ID, // displays 'Last mail check .. minutes ago
POP3_MSG_UPDATE_EVENT, // this one gets sent from Pop3 Thread
// every TOP command executed
};
// ------------------------------------------------------------------
/**
* Structure containing all data for executing a POP3 server query.
* Intended to be filled in by caller, passed on to routine in thread
* main frame context for execution, which will parse it and return
* any collected data and the result code in the appropiate members.
*/
struct Pop3CommandData
{
wxString sm_wsAccountName;
wxString sm_wsPop3ServerUrl;
wxString sm_wsUserName;
wxString sm_wsUserPassword;
wxString sm_wsResultData;
wxArrayString sm_wasCommands; // command strings to execute in one call
long sm_lResultCode;
int sm_iAccountIndex; // index into account list corresp. to account name
bool sm_bSuccess;
Pop3CommandData() : // default ctor for the struct
sm_wsAccountName(wxEmptyString),
sm_wsPop3ServerUrl(wxEmptyString),
sm_wsUserName(wxEmptyString),
sm_wsUserPassword(wxEmptyString),
sm_wsResultData(wxEmptyString),
sm_lResultCode( -1l ),
sm_iAccountIndex( - 1 ),
sm_bSuccess( false )
{
};
};
// ------------------------------------------------------------------
class MyFrame : public MyFrameBase, public wxThreadHelper
{
public:
MyFrame( wxWindow* parent );
virtual ~MyFrame();
wxString m_frameProgName;
int m_iNIdleCalls;
bool m_bNeedStartupMailCheck;
bool m_bNeedStartupNewversionCheck;
#if defined( WANT_HELP )
wxHelpControllerHelpProvider* m_pProvider;
void OnKeywordSearch(wxCommandEvent & event);
void OnShowHelpContents(wxCommandEvent & event);
#if defined( WANT_ZIP_HELP )
wxHtmlHelpController m_msHtmlHelp;
wxHtmlHelpController * GetHelpController()
{
return &m_msHtmlHelp;
}
void OnShowSection_FileMenu(wxCommandEvent & event);
#else
#if defined( _MSC_VER )
wxCHMHelpController m_msHtmlHelp;
#else
wxHtmlHelpController m_msHtmlHelp;
wxHtmlHelpController& GetAdvancedHtmlHelpController()
{ return m_msHtmlHelp; }
#endif
void OnMenuShowHelpContents( wxCommandEvent& event );
void OnShowSection_FileMenu(wxCommandEvent & event);
// can't overload the next function
// void OnDialogContextHelp(wxCommandEvent & event);
wxHelpController * GetHelpController()
{
return &m_msHtmlHelp;
}
wxString m_wsCurHelpFile;
#endif
bool m_bFoundHelpFile;
#endif
bool m_bRunning;
bool m_bStop; // set true by stop button on GUI
// was the worker thread cancelled by user?
bool m_bCancelled;
wxCriticalSection m_csCancelled; // protects m_cancelled
// accessors for MyWorkerThread (called in its context!)
bool Cancelled();
#if defined( WANT_LOG_WIN )
wxLog *m_pLogOld;
wxWindow *m_pLogWindowSave; ///< ptr to log window when not shown
wxLogTextCtrl *m_pLogWin;
#endif
#if defined( WANT_LOG_CHAIN )
void OnDeleteLogFiles( wxCommandEvent& event );
#endif
struct MemoryStruct {
char *memory;
size_t size;
};
Pop3CommandData m_Pop3CommandData;
wxString m_wsCapabilities;
wxString m_wsStat;
static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp);
void ClearPop3CommandData();
bool ThreadCurlPop3ServerTest( Pop3CommandData &arr_Pop3CommandData );
void FrameCurlPop3GetNewMessages( Pop3CommandData &ar_Pop3CommandData );
void ThreadCurlPop3GetNewMessages( Pop3CommandData &ar_Pop3CommandData );
void ThreadParseUidlData( Pop3CommandData &ar_Pop3CommandData,
wxString wsUidls, wxArrayString &ar_wasUidls,
wxString wsListResult, wxArrayString &ar_wasList, wxArrayLong &ar_walSizes,
wxString wsStatResult );
void ThreadParseUidls( wxString a_wsUidlResult, wxArrayString &ar_wasUidls, wxString wsWhereFrom );
long GetSeqNoFromUidl( wxString wsUidl, wxArrayString &ar_wasUidls );
void ThreadGetCurlPop3OneMessageBody( Pop3CommandData &ar_Pop3CommandData );
void OnUpdateDisplay( wxThreadEvent& event);
void ThreadCurlPop3DeleteMessage( Pop3CommandData &ar_Pop3CommandData );
void OnOptionsSetupDlg(wxCommandEvent& WXUNUSED( event ));
void OnCheck4NewMail(wxCommandEvent& event);
void Check4NewMail();
void OnLaunchMailClient(wxCommandEvent& event);
void OnProcessMail(wxCommandEvent& event);
bool InvokeMailClient( wxString wsDestPath );
void OnMailCheckStop(wxCommandEvent& event);
void ExecutePop3Command( Pop3CommandData &m_Pop3CommandData );
bool MailServerConnectTest( Pop3CommandData &ar_Pop3CommandData );
bool CheckConnectivity();
void printMimeStructure( MimeEntity* pMe, int tabcount = 0, wxTextCtrl *pTextCtrl = NULL );
void MIMEExtractAll(mimetic::MimeEntity& entity, bool& found_plain_text_body, bool& found_html_body);
void MIMEExtractBody(mimetic::MimeEntity& entity, wxString& ar_wsOut, bool shall_recode);
wxString PrintTabs(int c);
std::list<ExtendedAddress> m_toArray;
std::list<ExtendedAddress> m_ccArray;
std::list<ExtendedAddress> m_bccArray;
bool m_found_plain_text_body;
bool m_found_html_body;
bool m_has_html_alternative;
wxString m_wsTextBody;
wxString m_wsHtmlBody;
int m_iNAttachments;
size_t m_sz2Delete;
// threadhelper stuff
void RunLibcurlThread();
void OnStopTask( wxCommandEvent& event );
void ClearMailGrid();
void DisplayMailList();
void AddOneMessageRow( size_t szIndex );
void Add1Pop3Header2MsgList( size_t szIndex, wxString wsAccount );
void GetMessageFilterStatus( long lIndex, std::list<MyPop3MsgElement>::iterator it,
bool& bDelete, wxString& wsStatus, wxString& wsColor );
size_t FormatSize( double dNumber, wxString &wsOutput );
double GetDepth( double dNumber, int& iDepth);
// threadhelper stuff
wxThread::ExitCode Entry();
std::list<MyPop3MsgElement> m_Pop3MsgList; ///< std::list holding all message data
long m_lNTopLines; ///< number of lines to request in TOP command
void ClearMessages(); ///< clear the message data array
// mail grid
void OnMailGridChar(wxKeyEvent& event);
void InitializeMailGrid();
void ResizeMailGrid();
void OnMailGridSize( wxSizeEvent& event);
void RestoreColWidths();
void SaveColWidths();
void RestoreColLabels();
void SaveColLabels();
wxArrayLong m_walColWidths;
wxArrayString m_wasColLabels;
void DeleteMarkedMessages();
void FrameDeleteMessage( wxString wsAccount, long lIndex, wxString wsUidl );
void BounceMarkedMessages();
// mail grid clicking
void OnMailGridCellLeftClick( wxGridEvent& event);
void OnMailGridCellChanging( wxGridEvent& event);
void OnMailGridCellChanged( wxGridEvent& event);
void OnMailGridEditorShown( wxGridEvent& event);
// main frame handlers
void CheckboxHandler( wxCommandEvent& event);
void OnEmailPreview( wxCommandEvent& event);
void PreviewMessage( wxString wsAccount, long lIndex );
void OnEmailDelMessage( wxCommandEvent& event );
void OnContextPreview( wxCommandEvent& event );
void OnMarkToBounceSelected( wxCommandEvent& event);
void OnMarkToBounceAll( wxCommandEvent& event);
void OnMarkToDeleteSelected( wxCommandEvent& event);
void OnMarkDeleteAll( wxCommandEvent& event);
void OnClearAllDelete( wxCommandEvent& event);
void OnClearAllBounce( wxCommandEvent& event);
void OnClearList(wxCommandEvent& event);
void OnMenuFilters(wxCommandEvent& event);
long ShowOptions( long lPage );
void OnMailGridRightClick( wxGridEvent& event);
int m_iRightClickRow;
void ShowContextMenu( const wxPoint& pos );
void OnContextDelMsg( wxCommandEvent& event );
bool GetAccountInfo();
void OnContextMarkDelMsg( wxCommandEvent& event );
void OnContextMarkBounceMsg( wxCommandEvent& event );
void OnContextAddBlackMsg( wxCommandEvent& event );
void OnContextAddFriendMsg( wxCommandEvent& event );
// OnUpdate handlers
void OnUpdateUiMailCheckStart( wxUpdateUIEvent& event);
void OnUpdateUiMailCheckStop( wxUpdateUIEvent& event);
void OnUpdateUiProcessMail( wxUpdateUIEvent& event);
void OnUpdateUiLaunchMailApp( wxUpdateUIEvent& event);
void OnUpdateUiFriendsListAddr( wxUpdateUIEvent& event);
void OnUpdateUiFriendsListDom( wxUpdateUIEvent& event);
void OnUpdateUiBlackListAddr( wxUpdateUIEvent& event);
void OnUpdateUiBlackListDom( wxUpdateUIEvent& event);
void OnUpdateUiMarkDelete( wxUpdateUIEvent& event);
void OnUpdateUiMarkBounce( wxUpdateUIEvent& event);
void OnUpdateUiPreview( wxUpdateUIEvent& event);
void OnUpdateUiMarkDeleteAll( wxUpdateUIEvent& event);
void OnUpdateUiMarkBounceAll( wxUpdateUIEvent& event);
void OnUpdateUiClearList( wxUpdateUIEvent& event);
void OnUpdateUiLogShow( wxUpdateUIEvent& event);
void OnUpdateUiLogClear( wxUpdateUIEvent& event);
void OnUpdateUiCheckNew( wxUpdateUIEvent& event);
void OnUpdateUiToolsCheckMsgs( wxUpdateUIEvent& event);
void OnUpdateUiToolsAccounts( wxUpdateUIEvent& event);
void OnUpdateUiToolsBlackFriends( wxUpdateUIEvent& event);
void OnUpdateUiToolsErrors( wxUpdateUIEvent& event);
void OnUpdateUIHelpMenu( wxUpdateUIEvent& event);
void OnUpdateUIHelpToolbar( wxUpdateUIEvent& event);
void OnCheck4Update( wxCommandEvent& event);
void OnUpdateUiClearAllBounce(wxUpdateUIEvent& event);
void OnUpdateUiClearAllDelete(wxUpdateUIEvent& event);
void OnUpdateUiToolsBlackFriendsList(wxUpdateUIEvent& event);
void OnUpdateUiToolsStop(wxUpdateUIEvent& event);
void OnUpdateUiEmailDelete(wxUpdateUIEvent& event);
bool Check4Update( bool bFromUser );
void OnLists(wxCommandEvent& event); // friends & black list handler
// mailcheck timer
void OnMailCheckTimer( wxTimerEvent& event );
// Clear the status field 0 after a suitable time
void OnMailDisplayTimer( wxTimerEvent& event );
void OnMailConnectTimer( wxTimerEvent& event );
int m_iWheelRotation;
#if defined( WANT_MSVC_INTERNET_TEST )
void OnIdle(wxIdleEvent& event);
#endif
#if defined( _MSC_VER )
// Note: this is intended to display progress in main task bar icon for this application
bool m_bHaveAppProgress;
wxAppProgressIndicator *m_pAppProgress;
wxAppProgressIndicator* GetAppProgressInd() { return m_pAppProgress; }
#endif
wxTimer *GetMailTimerPtr()
{
return &m_tMailCheckTimer;
}
#if defined( WANT_DBGRPRT )
void OnCauseException( wxCommandEvent& event );
#endif
bool m_bAnyAccountsActive;
private: //////////////////////////////////////////////////////
// Event handlers - these functions should _not_ be virtual)
void OnExit( wxCommandEvent& event);
void OnClose(wxCloseEvent& event );
void OnQuit( wxCommandEvent& event );
void OnAbout( wxCommandEvent &event );
void OnOptionsLogClear( wxCommandEvent& event );
void OnOptionsLogShow( wxCommandEvent& event );
void OnMenuAccounts( wxCommandEvent& event );
void OnMailGridColSize( wxGridSizeEvent& ev );
void OnMailGridMouseWheel(wxMouseEvent& event);
#if defined( WANT_AUTO_START )
HRESULT CreateLink(LPCWSTR lpszPathObj, LPCSTR lpszPathLink, LPCWSTR lpszDesc);
#endif
// the data for the Entry() routine,
// intended to protect the message list m_Pop3MsgList
// and m_bRunning
wxCriticalSection m_CS_Pop3MsgList;
// mail check timer
wxTimer m_tMailCheckTimer;
int m_iMailTimerTicks;
wxTimer m_tMailDisplayTimer;
wxTimer m_tMailServerConnectCheckTimer;
int m_iConnectCheckTimerTicks;
// Any class wishing to process wxWidgets events must use this macro
DECLARE_EVENT_TABLE()
};
// ------------------------------------------------------------------
//class wxMsBasePasswordPromptDlg;
class wxMsPasswordPromptDlg : public wxMsBasePasswordPromptDlg
{
public:
wxMsPasswordPromptDlg( wxWindow* parent);// { m_parent = parent; };
wxWindow* m_parent;
};
#endif // _WX_MS_FRAME_H_
// ------------------------------- eof ------------------------------