2 * Copyright (C) 2011 Lukáš Karas <lukas.karas@centrum.cz>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #include <QtCore/QObject>
21 #include <QAbstractListModel>
23 #include <TelepathyQt4/Account>
24 #include <TelepathyQt4/AccountManager>
25 #include <TelepathyQt4/TextChannel>
26 #include <TelepathyQt4/Types>
28 #include "../backend/telepathy-client.h"
29 #include "../backend/session.h"
31 #include "session-model-item.h"
32 #include "notifications-model.h"
34 #ifndef SESSIONMODEL_H
35 #define SESSIONMODEL_H
37 class SessionModel
: public QAbstractListModel
{
40 Q_DISABLE_COPY(SessionModel
)
43 Q_PROPERTY(int sessionCount READ sessionCount
)
48 ItemRole
= Qt::UserRole
,
54 SessionModel(MaknetoBackend::TelepathyClient
* client
, NotificationsModel
* notificationsModel
, QObject
*parent
= 0);
55 virtual ~SessionModel();
57 int sessionCount() const;
59 Q_INVOKABLE QVariant
data(int row
, int role
);
60 Q_INVOKABLE
int getSessionType(const QString
&sessionId
);
62 // virtual methods from QAbstractItemModel
63 virtual int rowCount(const QModelIndex
& index
) const;
64 virtual QVariant
data(const QModelIndex
& index
, int role
) const;
68 void onSessionCreated(MaknetoBackend::Session
*, bool extendsExisting
, bool requested
);
69 void onMessageEnqueued(const QString
&);
70 void onSendingError(const QString
&sessionId
, const QString
&message
, const QString
&errorMessage
);
72 void onIncomingCall(const QString
&);
73 void onCallError(const QString
&, const QString
&);
74 void onCallEnded(const QString
&);
75 void onCallReady(const QString
&sessionId
);
76 void onRemoteAudioStreamAdded(const QString
&sessionId
);
78 // slots for signals from QML
79 Q_INVOKABLE
void sendTextMessage(const QString
&sessionId
, const QString
&text
);
80 Q_INVOKABLE
void sendWhiteboardMessage(const QString
&sessionId
, const QString
&content
);
81 Q_INVOKABLE
void changeChatState(const QString
&sessionId
, int state
);
82 Q_INVOKABLE
void requestSession(const QString
&accountId
, const QString
&contactId
, int intType
);
83 Q_INVOKABLE
void closeSession(const QString
&sessionId
);
84 Q_INVOKABLE
void startCall(const QString
&sessionId
, bool video
);
85 Q_INVOKABLE
void hangup(const QString
&sessionId
);
87 void onAcceptCall(const QString
&sessionId
);
88 void onRejectCall(const QString
&sessionId
);
89 void onAcceptChat(const QString
&sessionId
);
90 void onRejectChat(const QString
&sessionId
);
91 void onNotificationRemoved(const QString
&sessionId
, NotificationItem::NotificationType type
);
94 void sessionOpened(QString sessionId
, bool updatedeExisting
, bool requested
);
95 void sessionClosed(QString sessionId
);
96 void whiteboardMessageReceived(const QString
&sessionId
, const QString
&text
, const QString
&contact
);
97 void textMessageReceived(const QString
&sessionId
, const QString
&text
, const QString
&contact
);
98 void sessionTypeChanged(const QString
&sessionId
, int types
);
99 void messageSent(const QString
&sessionId
, const QString
&message
);
100 void sendingError(const QString
&sessionId
, const QString
&message
, const QString
&errorMessage
);
101 void chatStateChanged(const QString
&sessionId
, int chatState
, const QString
&contact
);
103 void callReady(const QString
&);
104 void callEnded(const QString
&);
106 void videoPreviewAvailable(const QString
&sessionId
, QGst::ElementPtr videoOutElemPtr
);
107 void videoAvailable(const QString
&sessionId
, QGst::ElementPtr videoOutElemPtr
);
108 void videoPreviewRemoved(const QString
&sessionId
, QGst::ElementPtr videoOutElemPtr
);
109 void videoRemoved(const QString
&sessionId
, QGst::ElementPtr videoOutElemPtr
);
119 void stopBeeping(const QString
&sessionId
);
120 void stopRinging(const QString
&sessionId
);
121 void stopDialing(const QString
&sessionId
);
123 virtual void openSession(SessionModelItem
*);
125 MaknetoBackend::TelepathyClient
* _client
;
126 QList
<SessionModelItem
*> _items
;
127 QMap
<QString
, SessionModelItem
*> _itemsMap
;
128 QSet
<QString
> _beepingSessions
;
129 QSet
<QString
> _ringingSessions
;
130 QSet
<QString
> _dialingSessions
;
131 NotificationsModel
*_notificationsModel
;
134 #endif /* SESSIONMODEL_H */