libqutim 0.3.1.0
messagehandler.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** qutIM - instant messenger
00004 **
00005 ** Copyright © 2011 Ruslan Nigmatullin <euroelessar@yandex.ru>
00006 **
00007 *****************************************************************************
00008 **
00009 ** $QUTIM_BEGIN_LICENSE$
00010 ** This program is free software: you can redistribute it and/or modify
00011 ** it under the terms of the GNU General Public License as published by
00012 ** the Free Software Foundation, either version 3 of the License, or
00013 ** (at your option) any later version.
00014 **
00015 ** This program is distributed in the hope that it will be useful,
00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00018 ** See the GNU General Public License for more details.
00019 **
00020 ** You should have received a copy of the GNU General Public License
00021 ** along with this program.  If not, see http://www.gnu.org/licenses/.
00022 ** $QUTIM_END_LICENSE$
00023 **
00024 ****************************************************************************/
00025 
00026 #ifndef MESSAGEHANDLER_H
00027 #define MESSAGEHANDLER_H
00028 
00029 #include "message.h"
00030 
00031 namespace qutim_sdk_0_3
00032 {
00033 
00034 class LIBQUTIM_EXPORT MessageHandler
00035 {
00036 public:
00037     enum Result
00038     {
00039         Accept,
00040         Reject,
00041         Error
00042     };
00043     enum Priority
00044     {
00045         LowPriority       = 0x00000100,
00046         ChatInPriority    = 0x00008000,
00047         NormalPriortity   = 0x00010000,
00048         ChatOutPriority   = 0x00020000,
00049         HighPriority      = 0x01000000,
00050         SenderPriority    = 0x02000000
00051     };
00052 
00053     virtual ~MessageHandler();
00054     
00055     static void registerHandler(MessageHandler *handler,
00056                                 int incomingPriority = NormalPriortity,
00057                                 int outgoingPriority = NormalPriortity);
00058     static void registerHandler(MessageHandler *handler, const QString &name,
00059                                 int incomingPriority = NormalPriortity,
00060                                 int outgoingPriority = NormalPriortity);
00061     static void unregisterHandler(MessageHandler *handler);
00062     static Result handle(Message &message, QString *reason = 0);
00063     static void traceHandlers();
00064     
00065 protected:
00066     virtual Result doHandle(Message &message, QString *reason) = 0;
00067 };
00068 
00069 }
00070 
00071 #endif // MESSAGEHANDLER_H
00072