summaryrefslogtreecommitdiffstats
path: root/kshowmail/kshowmail.h
blob: ed9ce7fe7c8d9f16a134c28f18be869cb7d4b847 (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
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
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
/***************************************************************************
                          kshowmail.h  -  description
                             -------------------
    begin                : Sat May  6 12:13:57 MEST 2000
    copyright            : (C) 2000-2001 by Eggert Ehmke
    email                : eggert.ehmke@berlin.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef KSHOWMAIL_H
#define KSHOWMAIL_H


#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

// include files for KDE
#include <tdeapplication.h>
#include <tdemainwindow.h>
#include <kuniqueapplication.h>
#include <tdeaction.h>
#include <kstdaction.h>
#include <tdelocale.h>
#include <kstatusbar.h>
#include <krun.h>
#include <kpassdlg.h>
#include <kdebug.h>
#include <kedittoolbar.h>
#include <kcmultidialog.h>


//include files for KShowMail
#include "configlist.h"
#include "alertdialog.h"
#include "showrecord.h"
#include "showlistviewitem.h"
#include "kshowmaildock.h"
#include "kfeedback.h"
#include "types.h"
#include "kshowmailview.h"
#include "kshowmaildoc.h"
#include "serverdialog.h"
#include "filterlog.h"
#include "filterlogview.h"


// forward declaration of the Kshowmail classes
class KshowmailDoc;
class KshowmailView;

using namespace Types;

/**
  * The base class for Kshowmail application windows. It sets up the main
  * window and reads the config file as well as providing a menubar, toolbar
  * and statusbar. An instance of KshowmailView creates your center view, which is connected
  * to the window's Doc object.
  * KShowMailApp reimplements the methods that TDEMainWindow provides for main window handling and supports
  * full session management as well as keyboard accelerator configuration by using TDEAccel.
  * @see TDEMainWindow
  * @see TDEApplication
  * @see TDEConfig
  * @see TDEAccel
  *
  * @author Source Framework Automatically Generated by KDevelop, (c) The KDevelop Team.
  * @version KDevelop version 0.4 code generation
  */
class KShowMailApp : public TDEMainWindow
{
  Q_OBJECT

  friend class KshowmailView;
  friend class KshowmailDock;
  friend class UniqueApp;


  private:

    /**
     * The central document of our application. Just contains the view (m_pView).
     */
    KshowmailDoc* m_pDoc;

    /**
     * Contains the account and messages list views.
     */
    KshowmailView *m_pView;

    /**
     * The setup dialog. Created and used by slotSetup().
     */
    KCMultiDialog* SetupDialog;

    /**
     * refresh messages action; connected with slotRefresh()
     */
    TDEAction* m_actionRefresh;

    /**
     * Contains the application and account settings. The account
     * settings are stored in ConfigElem objects.
     */
    ConfigList m_ConfigList;

    /**
     * Message box which will be shown, when new mail has arrived.
     */
    AlertDialog* m_pAlertDialog;

    /**
     * The window into the system tray.
     */
    KShowMailDock* m_pDockWindow;

    /**
     * The refresh timer. Its timeout signal is connected with slotRefresh().
     */
    TQTimer* m_pTimer;

    /**
     * Application state during the run time. Shows what KShowMail is doing :-) .
     */
     Types::State_Type m_state;

     /**
      * Number of seconds until the next refresh
      */
     unsigned long m_nSecondsToGo;

     /**
      * The filter log.
      */
     FilterLog fLog;


  public:
    /**
     * Constructor of KShowMailApp, calls all init functions to create the application.
     * @see initMenuBar initToolBar
     */
    KShowMailApp();

    /**
     * Destructor
     */
    ~KShowMailApp();

    /**
     * Contains information about KShowMail, including author, license, version etc.
     * This is accessed in main() when calling KShowMailApp::initMenuBar() to create the help menu.
     */
    static TDEAboutData* m_pAbout;

    /**
     * Delays the next refresh for one minute.
     */
    void delayNextRefresh();


  protected:

    /**
     * sets up the statusbar for the main window by initialzing a statuslabel.
     */
    void initStatusBar();

    /**
     * sets up the actions.
     */
    void initActions();

    /**
     * initializes the document object of the main window that is connected to the view in initView().
     * @see initView();
     */
    void initDocument();

    /**
     * creates the centerwidget of the TDEMainWindow instance and sets it as the view
     */
    void initView();

    /**
     * queryClose is called by TDEMainWindow on each closeEvent of a window. Against the
     * default implementation (only returns true), this calles saveModified() on the document object to ask
     * if the document should be saved if Modified; on cancel the closeEvent is rejected.
     * @see TDEMainWindow#queryClose
     * @see TDEMainWindow#closeEvent
     */
    virtual bool queryClose();

    /**
     * queryExit is called by TDEMainWindow when the last window of the app is going to be closed during the closeEvent().
     * Against the default implementation that just returns true, this calls saveOptions() to save the settings of
     * the last window's properties.
     * @see TDEMainWindow#queryExit
     * @see TDEMainWindow#closeEvent
     */
    virtual bool queryExit();

    /**
     * overwrite method of TQObject; will be invoked by the internal TQObject-Timer
     * the timer is set to 1 second in the construtor;
     * this method sets the time to the next refresh in the statusbar and
     * animates the "?" in the traybar, when the refresh is working
     */
    virtual void timerEvent( TQTimerEvent * );

    /**
     * overwrite method of TQWidget;
     * to hide the taskbar button
     */
    virtual bool event(TQEvent *e);

    /**
     * Starts the first refresh or starts the refresh timer
     * with the configured init time.
     */
    void initFirstRefresh();

    /**
     * Stops the refresh timer.
     */
    void stopRefreshTimer();

    /**
     * Starts the refresh timer for the next refresh.
     */
    void initNextRefresh();

    /**
     * Refreshes the status bar filter field.
     */
    void refreshFilterStatusBar();

  protected slots:

    /**
     * Changes the status message of the whole statusbar for two seconds,
     * then restores the last status. This is used to display
     * statusbar messages that give information about actions for toolbar
     * icons and menu entries.
     * @param text the text that is displayed in the statusbar
     */
    void slotStatusHelpMsg(const TQString &text);

    /**
     * Changes the contents in the left status bar item permanently,
     * used to indicate current actions. And sets the current time
     * in the right item.
     * @param text the text that is displayed in the statusbar
     */
    void slotStatusMsg(const TQString &text);

    /**
     * Connected with the setup dialog.
     * Reloads the configuration, if it was changed from the dialog.
     */
    void slotConfChanged();

    /**
     * Connected with action m_actionDelete.
     * Deletes all selected mails.
     */
    void slotDelete();

    /**
     * Connected with signal sigDeleteReady of m_ConfigList.
     * This signal will be emitted when one or many accounts have
     * ended a deletion.
     * This slot refreshes the view, sets the state to idle and sets
     * a normal cursor.
     */
    void slotDeletionReady();

    /**
     * Connected with action m_actionShowMessage.
     * Shows all selected mails.
     */
    void slotShowMessage();

    /**
     * Connected with signal sigShowBodiesReady of m_ConfigList.
     * This signal will be emitted when all accounts have downloaded
     * and shown the selected messages.
     * This slot sets the state to idle and sets a normal cursor.
     */
    void slotShowMessageReady();

    /**
     * Connected with signal sigMessageWindowOpened of m_ConfigList.
     * This signal will be emitted when a window to show a mail body
     * was opened.
     * Switches the cursor to normal view.
     */
    void slotNormalCursor();

    /**
     * Connected with signal sigAllMessageWindowsClosed of m_ConfigList.
     * This signal will be emitted when all windows to show a mail body
     * have been closed.
     * Switches the cursor to waiting view.
     */
    void slotWaitingCursor();

    /**
     * Connected with m_actionRefresh.
     * Refreshes the mail list.
     */
    void slotRefresh();

    /**
     * Connected with signal sigRefreshReady of m_ConfigList.
     * This signal will be emitted when all accounts have refreshed
     * their mail list.
     * This slot refreshes the mail view.
     */
    void slotRefreshReady();

    /**
     * Connected with signal destroyed of the alert message dialog.
     * Sets m_pAlertDialog to NULL, if the dialog was destroyed.
     * If m_pAlertDialog == NULL, slotRefreshReady will create a new instance of it.
     * @see m_pAlertDialog
     * @see slotRefreshReady()
     */
    void slotAlertDestroyed();

    /**
     * Connected with signal signalOk of the alert message dialog.
     * Switches the main window to normal view.
     * @see m_pAlertDialog;
     */
    void slotAlertOk ();

    /**
     * Refreshes the account and messages list view.
     */
    void slotRefreshView ();

    /**
     * If the application state is not "idle" it will stop all current running POP3 jobs.
     * Connected with m_actionStop().
     */
    void slotStop ();

    /**
     * Shows the headers of all selected mails.
     * Connected with action m_actionShowHeader.
     */
    void slotShowHeader();

    /**
     * Connected with standard action configureToolbars.
     * Opens a dialog to configure the icons of the toolbar.
     */
    void slotEditToolbars();

    /**
     * Saves GUI options, account and filter settings to the configuration file.
     */
    void slotSaveOptions();

    /**
     * Calls the close() method of KShowMailApp to exit the application. Uses askCloseConfirmation() to ask
     * the user (if configured). Sets m_bForceClose to TRUE, therefore queryClose() will be passed without
     * anything to do. After that in queryExit() slotSaveOptions() will be invoked.
     */
    void slotFileQuit();

    /**
     * Opens the setup dialog for the highlighted account. Connected with m_actionSetupAccount.
     */
    void slotSetupAccount();

    /**
     * Connected with the standard setup action.
     * If the application state is "idle" (m_state == idle) it will open the configuration dialog.
     */
    void slotSetup();

    /**
     * Shows the filter log.
     */
    void slotShowFilterLog();

    /**
     * Adds the sender of the selected mails to the whitelist
     */
    void slotAddToWhitelist();

    /**
     * Adds the sender of the selected mails to the blacklist
     */
    void slotAddToBlacklist();

    void slotAccountActivated(TQListViewItem*);
    void slotSendFeedbackMail();
    void slotForceClose();




private:

    bool m_bForceClose;


  protected:
    void addFeatureList(KFeedbackQuestion * question);
    bool askCloseConfirmation();

};

#endif // KSHOWMAIL_H