libqutim
0.3.1.0
|
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 CHATUNIT_H 00027 #define CHATUNIT_H 00028 00029 #include "menucontroller.h" 00030 #include <QMetaType> 00031 #include <QEvent> 00032 00033 namespace qutim_sdk_0_3 00034 { 00035 00036 class MetaContact; 00037 class Account; 00038 class Message; 00039 class ChatUnit; 00040 class ChatUnitPrivate; 00041 class Contact; 00042 typedef QList<ChatUnit *> ChatUnitList; 00043 00044 enum ChatState 00045 { 00046 ChatStateActive = 0, // User is actively participating in the chat session. 00047 ChatStateInActive, // User has not been actively participating in the chat session. 00048 ChatStateGone, // User has effectively ended their participation in the chat session. 00049 ChatStateComposing, // User is composing a message. 00050 ChatStatePaused // User had been composing but now has stopped. 00051 }; 00052 00056 class LIBQUTIM_EXPORT ChatUnit : public MenuController 00057 { 00058 Q_DECLARE_PRIVATE(ChatUnit) 00059 Q_OBJECT 00060 Q_PROPERTY(QString id READ id CONSTANT) 00061 Q_PROPERTY(QString title READ title NOTIFY titleChanged) 00062 Q_PROPERTY(ChatState chatState READ chatState WRITE setChatState NOTIFY chatStateChanged) 00063 Q_PROPERTY(qutim_sdk_0_3::Account* account READ account CONSTANT) 00064 Q_PROPERTY(bool conference READ isConference CONSTANT) 00065 public: 00071 ChatUnit(Account *account); 00081 ChatUnit(ChatUnitPrivate &d, Account *account); 00085 virtual ~ChatUnit(); 00091 virtual QString id() const = 0; 00097 virtual QString title() const; 00103 Account *account(); 00109 const Account *account() const; 00110 bool isConference() const; 00116 virtual bool sendMessage(const qutim_sdk_0_3::Message &message) = 0; 00117 00118 Q_INVOKABLE bool send(const qutim_sdk_0_3::Message &message); 00124 Q_INVOKABLE virtual QList<qutim_sdk_0_3::ChatUnit*> lowerUnits(); 00130 Q_INVOKABLE virtual qutim_sdk_0_3::ChatUnit *upperUnit(); 00136 ChatUnit *buddy(); 00137 const ChatUnit *buddy() const; 00143 ChatUnit *metaContact(); 00144 const ChatUnit *metaContact() const; 00145 virtual const ChatUnit *getHistoryUnit() const; 00146 public slots: 00147 quint64 sendMessage(const QString &text); 00153 void setChatState(qutim_sdk_0_3::ChatState state); 00154 qutim_sdk_0_3::ChatState chatState() const; 00155 signals: 00160 void titleChanged(const QString ¤t, const QString &previous); 00164 void lowerUnitAdded(ChatUnit *unit); 00165 void chatStateChanged(qutim_sdk_0_3::ChatState current,qutim_sdk_0_3::ChatState previous); 00166 }; 00167 00171 class LIBQUTIM_EXPORT ChatStateEvent : public QEvent 00172 { 00173 public: 00179 ChatStateEvent(ChatState state); 00185 inline ChatState chatState() const { return m_state; } 00191 static QEvent::Type eventType(); 00192 protected: 00193 ChatState m_state; 00194 }; 00195 } 00196 00197 Q_DECLARE_METATYPE(qutim_sdk_0_3::ChatUnit*) 00198 Q_DECLARE_METATYPE(QList<qutim_sdk_0_3::ChatUnit*>) 00199 Q_ENUMS(qutim_sdk_0_3::ChatState) 00200 00201 #endif // CHATUNIT_H 00202