File indexing completed on 2023-05-30 11:40:28

0001 /*
0002     Class for displaying connection errors
0003     Copyright (C) 2011  Martin Klapetek <martin.klapetek@gmail.com>
0004 
0005     This library is free software; you can redistribute it and/or
0006     modify it under the terms of the GNU Lesser General Public
0007     License as published by the Free Software Foundation; either
0008     version 2.1 of the License, or (at your option) any later version.
0009 
0010     This library is distributed in the hope that it will be useful,
0011     but WITHOUT ANY WARRANTY; without even the implied warranty of
0012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013     Lesser General Public License for more details.
0014 
0015     You should have received a copy of the GNU Lesser General Public
0016     License along with this library; if not, write to the Free Software
0017     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0018 */
0019 
0020 
0021 #ifndef ERROR_HANDLER_H
0022 #define ERROR_HANDLER_H
0023 
0024 #include <QObject>
0025 
0026 #include <TelepathyQt/Constants>
0027 #include <TelepathyQt/Types>
0028 
0029 class ConnectionError;
0030 
0031 class ErrorHandler : public QObject
0032 {
0033     Q_OBJECT
0034 public:
0035     explicit ErrorHandler(QObject *parent = 0);
0036     virtual ~ErrorHandler();
0037 
0038     enum SystemMessageType {
0039         /*
0040          * this will show a system message to the user
0041          * but it will fade after short timout,
0042          * thus it should be used for non-important messages
0043          * like "Connecting..." etc.
0044          */
0045         SystemMessageInfo,
0046 
0047         /*
0048          * message with this class will stay visible until user
0049          * closes it and will have light-red background
0050          */
0051         SystemMessageError
0052     };
0053 
0054 public Q_SLOTS:
0055     /** Loop through all errors we have yet to show, and show anything*/
0056     void showErrorNotification();
0057 
0058 private Q_SLOTS:
0059     void onConnectionStatusChanged(const Tp::ConnectionStatus status);
0060     void onRequestedPresenceChanged();
0061     void onNewAccount(const Tp::AccountPtr &account);
0062     void onAccountRemoved();
0063 
0064 private:
0065     void showMessageToUser(const QString &text, const ErrorHandler::SystemMessageType type);
0066     QHash<Tp::AccountPtr, ConnectionError> m_errorMap;
0067 };
0068 
0069 #endif // ERROR_HANDLER_H