2 <one line to give the library's name and an idea of what it does.>
3 Copyright (C) 2011 Vojta Kulicka <vojtechkulicka@gmail.com>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef MAKNETOLIB_SESSION_H
22 #define MAKNETOLIB_SESSION_H
24 #include <QtCore/QObject>
28 #include <TelepathyQt4/Contact>
29 #include <TelepathyQt4/Constants>
30 #include <TelepathyQt4/Types>
31 #include <TelepathyQt4/FileTransferChannel>
32 #include <TelepathyQt4/PendingChannelRequest>
34 #include "voip/callparticipant.h"
35 #include "makneto-backend.h"
42 class PendingOperation
;
44 class ReceivedMessage
;
48 namespace MaknetoBackend
{
50 class CallChannelHandler
;
52 class MAKNETO_EXPORT Session
: public QObject
{
55 Q_ENUMS(SessionType FileTransferState ChatState
)
56 Q_PROPERTY(SesstionTypes sessionType READ getSessionType NOTIFY sessionTypeChanged
)
60 SessionTypeNone
= 0x0, // 00000
61 SessionTypeText
= 0x1, // 00001
62 SessionTypeMuc
= 0x2, // 00010
63 SessionTypeAudio
= 0x4, // 00100
64 SessionTypeVideo
= 0x8, // 01000
65 SessionTypeCallPending
= 0x10 // 10000
68 Q_DECLARE_FLAGS(SesstionTypes
, SessionType
)
70 enum FileTransferState
{
72 fileTransferCancelled
,
73 fileTransferCompleted
,
78 ChatStateComposing
= Tp::ChannelChatStateComposing
,
79 ChatStateActive
= Tp::ChannelChatStateActive
,
80 ChatStateInactive
= Tp::ChannelChatStateInactive
,
81 ChatStateGone
= Tp::ChannelChatStateGone
,
82 ChatStatePaused
= Tp::ChannelChatStatePaused
86 Session(const Tp::ChannelPtr
&, SesstionTypes
, QObject
*parent
= 0);
87 Session(const Tp::AccountPtr
&, const Tp::ContactPtr
&, SesstionTypes
, QObject
*parent
= 0);
91 QString
getUniqueName();
95 SesstionTypes
getSessionType();
99 void startMediaCall(bool);
100 void startTextChatroom(const QString
&);
101 void startFileTransfer(const QString
&);
103 static QString
sessionNameForChannel(const Tp::AccountPtr
&, const Tp::ChannelPtr
&);
104 static QString
sessionNameForMuc(const Tp::AccountPtr
&, const QString
&);
105 static QString
sessionName(const Tp::AccountPtr
&, const Tp::ContactPtr
&);
109 void onAddCapability(SessionType chatType
);
111 void onTextChannelReady(Tp::TextChannelPtr
&textChannel
, bool);
112 void onMessageReceived(const Tp::ReceivedMessage
&);
113 void sendMessage(const QString
&text
);
114 void onMessageSent(Tp::PendingOperation
*);
115 void onChatStateChanged(Tp::ContactPtr
, Tp::ChannelChatState
);
116 void changeChatState(MaknetoBackend::Session::ChatState
);
119 void onIncomingCallChannel(Tp::StreamedMediaChannelPtr
&mediaChannel
, SessionType mediaType
);
122 void onCallEnded(const QString
&);
124 void onCallError(const QString
&);
125 void callChannelRequestFinished(Tp::PendingOperation
*);
126 void onCallParticipantLeft(CallParticipant
*participant
);
127 void onCallParticipantJoined(CallParticipant
*participant
);
128 void onVideoStreamAdded(CallParticipant
*participant
);
129 void onVideoStreamRemoved(CallParticipant
*participant
);
130 void onAudioStreamAdded(CallParticipant
*participant
);
133 void onFileTransfer(Tp::FileTransferChannelPtr
&fileTransferChannel
);
134 void onAcceptFileTransfer(bool accept
, QString filename
= QString());
135 void onFileTransferStateChanged(Tp::FileTransferState
, Tp::FileTransferStateChangeReason
);
136 void onFileTransferTransferredBytesChanged(qulonglong
);
141 void messageReceived(const QString
&, const QString
&);
142 void messageSent(const QString
&message
); // outgoing message was successfully send
143 void sendingError(const QString
&message
, const QString
&errorMessage
); // outgoing message sending failed
144 void chatStateChanged(MaknetoBackend::Session::ChatState
, const QString
&);
145 void sessionTypeChanged();
150 void callEnded(const QString
&);
151 void callError(const QString
&);
152 void videoPreviewAvailable(QGst::ElementPtr videoOutElemPtr
);
153 void videoAvailable(QGst::ElementPtr videoOutElemPtr
);
154 void videoPreviewRemoved(QGst::ElementPtr videoOutElemPtr
);
155 void videoRemoved(QGst::ElementPtr videoOutElemPtr
);
156 void remoteAudioStreamAdded(); // signaling that application should stop beeping
159 void incomingFileTransfer(const QString
&filename
);
160 void fileTransferCreated();
161 void fileTransferStateChanged(FileTransferState
);
162 void fileTransferAlreadyInProgress();
163 void fileTransferTransferredBytesChanged(qulonglong
);
166 Tp::TextChannelPtr m_textChannel
;
167 Tp::StreamedMediaChannelPtr m_mediaChannel
;
168 Tp::FileTransferChannelPtr m_fileTransferChannel
;
170 Tp::AccountPtr m_account
;
171 Tp::ContactPtr m_myContact
;
172 Tp::ContactPtr m_contact
;
173 QSet
<Tp::ContactPtr
> *m_contacts
;
175 QFile m_fileTransferFile
;
176 QString m_sessionName
;
177 QString m_uniqueSessionName
;
178 CallChannelHandler
*m_callChannelHandler
;
179 Tp::PendingChannelRequest
*m_pendingCallRequest
;
180 SesstionTypes m_chatType
;
181 QList
<QString
> _outgoingQueue
;
182 bool chatStateReported
;
186 Q_DECLARE_OPERATORS_FOR_FLAGS(Session::SesstionTypes
)
190 #endif // MAKNETOLIB_SESSION_H