libqutim  0.3.1.0
chatunit.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** qutIM - instant messenger
4 **
5 ** Copyright © 2011 Ruslan Nigmatullin <euroelessar@yandex.ru>
6 **
7 *****************************************************************************
8 **
9 ** $QUTIM_BEGIN_LICENSE$
10 ** This program is free software: you can redistribute it and/or modify
11 ** it under the terms of the GNU General Public License as published by
12 ** the Free Software Foundation, either version 3 of the License, or
13 ** (at your option) any later version.
14 **
15 ** This program is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 ** See the GNU General Public License for more details.
19 **
20 ** You should have received a copy of the GNU General Public License
21 ** along with this program. If not, see http://www.gnu.org/licenses/.
22 ** $QUTIM_END_LICENSE$
23 **
24 ****************************************************************************/
25 
26 #ifndef CHATUNIT_H
27 #define CHATUNIT_H
28 
29 #include "menucontroller.h"
30 #include <QMetaType>
31 #include <QEvent>
32 #include <QDateTime>
33 
34 namespace qutim_sdk_0_3
35 {
36 
37 class MetaContact;
38 class Account;
39 class Message;
40 class ChatUnit;
41 class ChatUnitPrivate;
42 class Contact;
43 typedef QList<ChatUnit *> ChatUnitList;
44 
46 {
47  ChatStateActive = 0, // User is actively participating in the chat session.
48  ChatStateInActive, // User has not been actively participating in the chat session.
49  ChatStateGone, // User has effectively ended their participation in the chat session.
50  ChatStateComposing, // User is composing a message.
51  ChatStatePaused // User had been composing but now has stopped.
52 };
53 
58 {
59  Q_DECLARE_PRIVATE(ChatUnit)
60  Q_OBJECT
61  Q_PROPERTY(QString id READ id CONSTANT)
62  Q_PROPERTY(QString title READ title NOTIFY titleChanged)
63  Q_PROPERTY(ChatState chatState READ chatState WRITE setChatState NOTIFY chatStateChanged)
64  Q_PROPERTY(QDateTime lastActivity READ lastActivity NOTIFY lastActivityChanged)
65  Q_PROPERTY(qutim_sdk_0_3::Account* account READ account CONSTANT)
66  Q_PROPERTY(bool conference READ isConference CONSTANT)
67 public:
73  ChatUnit(Account *account);
83  ChatUnit(ChatUnitPrivate &d, Account *account);
87  virtual ~ChatUnit();
93  virtual QString id() const = 0;
99  virtual QString title() const;
105  Account *account();
111  const Account *account() const;
112  bool isConference() const;
118  virtual bool sendMessage(const qutim_sdk_0_3::Message &message) = 0;
119 
120  Q_INVOKABLE bool send(const qutim_sdk_0_3::Message &message);
126  Q_INVOKABLE virtual QList<qutim_sdk_0_3::ChatUnit*> lowerUnits();
132  Q_INVOKABLE virtual qutim_sdk_0_3::ChatUnit *upperUnit();
138  ChatUnit *buddy();
139  const ChatUnit *buddy() const;
145  ChatUnit *metaContact();
146  const ChatUnit *metaContact() const;
147  virtual const ChatUnit *getHistoryUnit() const;
148  QDateTime lastActivity() const;
149  void setLastActivity(const QDateTime &time = QDateTime::currentDateTime());
155  void setChatState(qutim_sdk_0_3::ChatState state);
156  qutim_sdk_0_3::ChatState chatState() const;
157 public slots:
158  quint64 sendMessage(const QString &text);
159 signals:
164  void titleChanged(const QString &current, const QString &previous);
168  void lowerUnitAdded(ChatUnit *unit);
169  void chatStateChanged(qutim_sdk_0_3::ChatState current,qutim_sdk_0_3::ChatState previous);
170  void lastActivityChanged(const QDateTime &current, const QDateTime &previous);
171 };
172 
176 class LIBQUTIM_EXPORT ChatStateEvent : public QEvent
177 {
178 public:
184  ChatStateEvent(ChatState state);
190  inline ChatState chatState() const { return m_state; }
196  static QEvent::Type eventType();
197 protected:
199 };
200 }
201 
203 Q_DECLARE_METATYPE(QList<qutim_sdk_0_3::ChatUnit*>)
204 Q_ENUMS(qutim_sdk_0_3::ChatState)
205 
206 #endif // CHATUNIT_H
207 

Generated by Doxygen