Debian Codegraph @

Dekko/server/messageserver.h

raw symbols SCIP
1 /****************************************************************************
2 **
3 ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the Qt Messaging Framework.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef MESSAGESERVER_H
43 #define MESSAGESERVER_H
44
45 #include <qmailmessageserver.h>
46 #include <QObject>
47 #include <QSet>
48 #include <QSocketNotifier>
49 #include <qcopadaptor.h>
50 #include <QDateTime>
51 #ifdef SERVER_AS_QTHREAD
52 #include <QThread>
53 #include <QEventLoop>
54 #endif
55
56 class ServiceHandler;
57 class MailMessageClient;
58 class QDSData;
59 class QMailMessageMetaData;
60 class QNetworkState;
61 class NewCountNotifier;
62
63 #if defined(SERVER_AS_DLL)
64 class QMFUTIL_EXPORT MessageServer : public QObject
65 #else
66 class MessageServer : public QObject
67 #endif
68 {
69 Q_OBJECT
70
71 public:
72 MessageServer(QObject *parent = 0);
73 ~MessageServer();
74
75 #if defined(Q_OS_UNIX)
76 static void hupSignalHandler(int unused); // Unix SIGHUP signal handler
77 #endif
78
79 signals:
80 void messageCountUpdated();
81 #if defined(Q_OS_UNIX)
82 public slots:
83 void handleSigHup(); // Qt signal handler for UNIX SIGHUP signal.
84 #endif
85
86 private slots:
87 void retrievalCompleted(quint64 action);
88
89 void transmissionCompleted(quint64 action);
90
91 void response(bool handled);
92 void error(const QString &message);
93
94 void messagesAdded(const QMailMessageIdList &ids);
95 void messagesUpdated(const QMailMessageIdList &ids);
96 void messagesRemoved(const QMailMessageIdList &ids);
97 void reportNewCounts();
98 void acknowledgeNewMessages(const QMailMessageTypeList&);
99
100 void cleanupTemporaryMessages();
101 void notifyNewMessages(const QMailMessageIdList &ids);
102
103 private:
104 int newMessageCount(QMailMessage::MessageType type) const;
105
106 void updateNewMessageCounts();
107
108
109 ServiceHandler *handler;
110 MailMessageClient *client;
111 QMailMessageCountMap messageCounts;
112
113 QCopAdaptor messageCountUpdate;
114 QMap<NewCountNotifier*, QMailMessage::MessageType> actionType;
115 int newMessageTotal;
116
117 QSet<QMailMessageId> completionList;
118 bool completionAttempted;
119 #if defined(Q_OS_UNIX)
120 static int sighupFd[2];
121 QSocketNotifier *snHup;
122 #endif
123 QDateTime m_started;
124 };
125
126 #ifdef SERVER_AS_QTHREAD
127 class MessageServerThread : public QThread
128 {
129 Q_OBJECT
130 public:
131 MessageServerThread();
132 ~MessageServerThread();
133 void run();
134 signals:
135 void messageServerStarted();
136 };
137 #endif
138 #endif