Browse Source

Receive empty calls (no sound nor video)

pull/3/head
Tux3 / Mlkj / !Lev.uXFMLA 11 years ago
parent
commit
5784b58610
  1. 84
      core.cpp
  2. 21
      core.h
  3. 65
      widget/form/chatform.cpp
  4. 11
      widget/form/chatform.h
  5. 7
      widget/widget.cpp

84
core.cpp

@ -875,57 +875,109 @@ void Core::sendAllFileData(Core *core, ToxFile* file) @@ -875,57 +875,109 @@ void Core::sendAllFileData(Core *core, ToxFile* file)
removeFileFromQueue(true, file->friendId, file->fileNum);
}
void Core::onAvInvite(int32_t call_index, void* toxav)
void Core::onAvInvite(int32_t call_index, void* core)
{
qDebug() << "Core: AV invite";
int friendId = toxav_get_peer_id(static_cast<Core*>(core)->toxav, call_index, 0);
if (friendId < 0)
{
qWarning() << "Core: Received invalid AV invite";
return;
}
qDebug() << QString("Core: AV invite from %1").arg(friendId);
emit static_cast<Core*>(core)->avInvite(friendId, call_index);
}
void Core::onAvStart(int32_t call_index, void* toxav)
void Core::onAvStart(int32_t call_index, void* core)
{
qDebug() << "Core: AV start";
int friendId = toxav_get_peer_id(static_cast<Core*>(core)->toxav, call_index, 0);
if (friendId < 0)
{
qWarning() << "Core: Received invalid AV start";
return;
}
qDebug() << QString("Core: AV start from %1").arg(friendId);
void Core::onAvCancel(int32_t call_index, void* toxav)
emit static_cast<Core*>(core)->avStart(friendId, call_index);
}
void Core::onAvCancel(int32_t call_index, void* core)
{
int friendId = toxav_get_peer_id(static_cast<Core*>(core)->toxav, call_index, 0);
if (friendId < 0)
{
qDebug() << "Core: AV cancel";
qWarning() << "Core: Received invalid AV cancel";
return;
}
qDebug() << QString("Core: AV cancel from %1").arg(friendId);
void Core::onAvReject(int32_t call_index, void* toxav)
emit static_cast<Core*>(core)->avCancel(friendId, call_index);
}
void Core::onAvReject(int32_t call_index, void* core)
{
qDebug() << "Core: AV reject";
}
void Core::onAvEnd(int32_t call_index, void* toxav)
void Core::onAvEnd(int32_t call_index, void* core)
{
int friendId = toxav_get_peer_id(static_cast<Core*>(core)->toxav, call_index, 0);
if (friendId < 0)
{
qDebug() << "Core: AV end";
qWarning() << "Core: Received invalid AV end";
return;
}
qDebug() << QString("Core: AV end from %1").arg(friendId);
emit static_cast<Core*>(core)->avEnd(friendId, call_index);
}
void Core::onAvRinging(int32_t call_index, void* toxav)
void Core::onAvRinging(int32_t call_index, void* core)
{
qDebug() << "Core: AV ringing";
}
void Core::onAvStarting(int32_t call_index, void* toxav)
void Core::onAvStarting(int32_t call_index, void* core)
{
qDebug() << "Core: AV starting";
}
void Core::onAvEnding(int32_t call_index, void* toxav)
void Core::onAvEnding(int32_t call_index, void* core)
{
int friendId = toxav_get_peer_id(static_cast<Core*>(core)->toxav, call_index, 0);
if (friendId < 0)
{
qDebug() << "Core: AV ending";
qWarning() << "Core: Received invalid AV ending";
return;
}
qDebug() << QString("Core: AV ending from %1").arg(friendId);
emit static_cast<Core*>(core)->avEnding(friendId, call_index);
}
void Core::onAvError(int32_t call_index, void* toxav)
void Core::onAvError(int32_t call_index, void* core)
{
qDebug() << "Core: AV error";
}
void Core::onAvRequestTimeout(int32_t call_index, void* toxav)
void Core::onAvRequestTimeout(int32_t call_index, void* core)
{
qDebug() << "Core: AV request timeout";
}
void Core::onAvPeerTimeout(int32_t call_index, void* toxav)
void Core::onAvPeerTimeout(int32_t call_index, void* core)
{
qDebug() << "Core: AV peer timeout";
}
void Core::answerCall(int callId)
{
qDebug() << QString("Core: answering call %1").arg(callId);
toxav_answer(toxav, callId, TypeAudio);
}
void Core::hangupCall(int callId)
{
qDebug() << QString("Core: hanging up call %1").arg(callId);
toxav_hangup(toxav, callId);
}

21
core.h

@ -85,6 +85,8 @@ public: @@ -85,6 +85,8 @@ public:
public slots:
void start();
void process();
void bootstrapDht();
void acceptFriendRequest(const QString& userId);
void requestFriendship(const QString& friendAddress, const QString& message);
@ -92,6 +94,10 @@ public slots: @@ -92,6 +94,10 @@ public slots:
void removeFriend(int friendId);
void removeGroup(int groupId);
void setUsername(const QString& username);
void setStatusMessage(const QString& message);
void setStatus(Status status);
void sendMessage(int friendId, const QString& message);
void sendGroupMessage(int groupId, const QString& message);
void sendAction(int friendId, const QString& action);
@ -105,13 +111,8 @@ public slots: @@ -105,13 +111,8 @@ public slots:
void pauseResumeFileSend(int friendId, int fileNum);
void pauseResumeFileRecv(int friendId, int fileNum);
void setUsername(const QString& username);
void setStatusMessage(const QString& message);
void setStatus(Status status);
void process();
void bootstrapDht();
void answerCall(int callId);
void hangupCall(int callId);
signals:
void connected();
@ -166,6 +167,12 @@ signals: @@ -166,6 +167,12 @@ signals:
void fileTransferPaused(int FriendId, int FileNum, ToxFile::FileDirection direction);
void fileTransferInfo(int FriendId, int FileNum, int Filesize, int BytesSent, ToxFile::FileDirection direction);
void avInvite(int friendId, int callIndex);
void avStart(int friendId, int callIndex);
void avCancel(int friendId, int callIndex);
void avEnd(int friendId, int callIndex);
void avEnding(int friendId, int callIndex);
private:
static void onFriendRequest(Tox* tox, const uint8_t* cUserId, const uint8_t* cMessage, uint16_t cMessageSize, void* core);
static void onFriendMessage(Tox* tox, int friendId, uint8_t* cMessage, uint16_t cMessageSize, void* core);

65
widget/form/chatform.cpp

@ -80,6 +80,7 @@ ChatForm::ChatForm(Friend* chatFriend) @@ -80,6 +80,7 @@ ChatForm::ChatForm(Friend* chatFriend)
connect(Widget::getInstance()->getCore(), &Core::fileSendStarted, this, &ChatForm::startFileSend);
connect(sendButton, SIGNAL(clicked()), this, SLOT(onSendTriggered()));
connect(fileButton, SIGNAL(clicked()), this, SLOT(onAttachClicked()));
connect(callButton, SIGNAL(clicked()), this, SLOT(onCallTriggered()));
connect(msgEdit, SIGNAL(enterPressed()), this, SLOT(onSendTriggered()));
connect(chatArea->verticalScrollBar(), SIGNAL(rangeChanged(int,int)), this, SLOT(onSliderRangeChanged()));
}
@ -256,9 +257,71 @@ void ChatForm::onFileRecvRequest(ToxFile file) @@ -256,9 +257,71 @@ void ChatForm::onFileRecvRequest(ToxFile file)
connect(Widget::getInstance()->getCore(), &Core::fileTransferFinished, fileTrans, &FileTransfertWidget::onFileTransferFinished);
}
void ChatForm::onCallReceived()
void ChatForm::onAvInvite(int FriendId, int CallId)
{
if (FriendId != f->friendId)
return;
callId = CallId;
QPalette callinvitePal;
callinvitePal.setColor(QPalette::Button, QColor(206, 191, 69)); // Call invite orange
callButton->setPalette(callinvitePal);
callButton->disconnect();
connect(callButton, SIGNAL(clicked()), this, SLOT(onAnswerCallTriggered()));
}
void ChatForm::onAvStart(int FriendId, int CallId)
{
if (FriendId != f->friendId)
return;
callId = CallId;
QPalette toxred;
toxred.setColor(QPalette::Button, QColor(200,78,78)); // Tox Red
callButton->setPalette(toxred);
callButton->disconnect();
connect(callButton, SIGNAL(clicked()), this, SLOT(onHangupCallTriggered()));
}
void ChatForm::onAvCancel(int FriendId, int)
{
if (FriendId != f->friendId)
return;
QPalette toxgreen;
toxgreen.setColor(QPalette::Button, QColor(107,194,96)); // Tox Green
callButton->setPalette(toxgreen);
callButton->disconnect();
connect(callButton, SIGNAL(clicked()), this, SLOT(onCallTriggered()));
}
void ChatForm::onAvEnd(int FriendId, int)
{
if (FriendId != f->friendId)
return;
QPalette toxgreen;
toxgreen.setColor(QPalette::Button, QColor(107,194,96)); // Tox Green
callButton->setPalette(toxgreen);
callButton->disconnect();
connect(callButton, SIGNAL(clicked()), this, SLOT(onCallTriggered()));
}
void ChatForm::onAvEnding(int FriendId, int)
{
if (FriendId != f->friendId)
return;
QPalette toxgreen;
toxgreen.setColor(QPalette::Button, QColor(107,194,96)); // Tox Green
callButton->setPalette(toxgreen);
callButton->disconnect();
connect(callButton, SIGNAL(clicked()), this, SLOT(onCallTriggered()));
}
void ChatForm::onAnswerCallTriggered()
{
emit answerCall(callId);
}
void ChatForm::onHangupCallTriggered()
{
emit hangupCall(callId);
}
void ChatForm::onCallTriggered()

11
widget/form/chatform.h

@ -36,17 +36,25 @@ signals: @@ -36,17 +36,25 @@ signals:
void sendMessage(int, QString);
void sendFile(int32_t friendId, QString, QByteArray);
void startCall(int friendId);
void answerCall(int callId);
void hangupCall(int callId);
public slots:
void startFileSend(ToxFile file);
void onFileRecvRequest(ToxFile file);
void onCallReceived();
void onAvInvite(int FriendId, int CallId);
void onAvStart(int FriendId, int CallId);
void onAvCancel(int FriendId, int CallId);
void onAvEnd(int FriendId, int CallId);
void onAvEnding(int FriendId, int CallId);
private slots:
void onSendTriggered();
void onAttachClicked();
void onSliderRangeChanged();
void onCallTriggered();
void onAnswerCallTriggered();
void onHangupCallTriggered();
private:
Friend* f;
@ -61,6 +69,7 @@ private: @@ -61,6 +69,7 @@ private:
QString previousName;
int curRow;
bool lockSliderToBottom;
int callId;
};
#endif // CHATFORM_H

7
widget/widget.cpp

@ -229,7 +229,14 @@ void Widget::addFriend(int friendId, const QString &userId) @@ -229,7 +229,14 @@ void Widget::addFriend(int friendId, const QString &userId)
connect(newfriend->widget, SIGNAL(removeFriend(int)), this, SLOT(removeFriend(int)));
connect(newfriend->chatForm, SIGNAL(sendMessage(int,QString)), core, SLOT(sendMessage(int,QString)));
connect(newfriend->chatForm, SIGNAL(sendFile(int32_t,QString,QByteArray)), core, SLOT(sendFile(int32_t,QString,QByteArray)));
connect(newfriend->chatForm, SIGNAL(answerCall(int)), core, SLOT(answerCall(int)));
connect(newfriend->chatForm, SIGNAL(hangupCall(int)), core, SLOT(hangupCall(int)));
connect(core, &Core::fileReceiveRequested, newfriend->chatForm, &ChatForm::onFileRecvRequest);
connect(core, &Core::avInvite, newfriend->chatForm, &ChatForm::onAvInvite);
connect(core, &Core::avStart, newfriend->chatForm, &ChatForm::onAvStart);
connect(core, &Core::avCancel, newfriend->chatForm, &ChatForm::onAvCancel);
connect(core, &Core::avEnd, newfriend->chatForm, &ChatForm::onAvEnd);
connect(core, &Core::avEnding, newfriend->chatForm, &ChatForm::onAvEnding);
}
void Widget::addFriendFailed(const QString&)

Loading…
Cancel
Save