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)
removeFileFromQueue(true, file->friendId, file->fileNum); 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);
emit static_cast<Core*>(core)->avStart(friendId, call_index);
} }
void Core::onAvCancel(int32_t call_index, void* toxav) void Core::onAvCancel(int32_t call_index, void* core)
{ {
qDebug() << "Core: AV cancel"; int friendId = toxav_get_peer_id(static_cast<Core*>(core)->toxav, call_index, 0);
if (friendId < 0)
{
qWarning() << "Core: Received invalid AV cancel";
return;
}
qDebug() << QString("Core: AV cancel from %1").arg(friendId);
emit static_cast<Core*>(core)->avCancel(friendId, call_index);
} }
void Core::onAvReject(int32_t call_index, void* toxav) void Core::onAvReject(int32_t call_index, void* core)
{ {
qDebug() << "Core: AV reject"; qDebug() << "Core: AV reject";
} }
void Core::onAvEnd(int32_t call_index, void* toxav) void Core::onAvEnd(int32_t call_index, void* core)
{ {
qDebug() << "Core: AV end"; int friendId = toxav_get_peer_id(static_cast<Core*>(core)->toxav, call_index, 0);
if (friendId < 0)
{
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"; 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"; qDebug() << "Core: AV starting";
} }
void Core::onAvEnding(int32_t call_index, void* toxav) void Core::onAvEnding(int32_t call_index, void* core)
{ {
qDebug() << "Core: AV ending"; int friendId = toxav_get_peer_id(static_cast<Core*>(core)->toxav, call_index, 0);
if (friendId < 0)
{
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"; 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"; 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"; 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:
public slots: public slots:
void start(); void start();
void process();
void bootstrapDht();
void acceptFriendRequest(const QString& userId); void acceptFriendRequest(const QString& userId);
void requestFriendship(const QString& friendAddress, const QString& message); void requestFriendship(const QString& friendAddress, const QString& message);
@ -92,6 +94,10 @@ public slots:
void removeFriend(int friendId); void removeFriend(int friendId);
void removeGroup(int groupId); 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 sendMessage(int friendId, const QString& message);
void sendGroupMessage(int groupId, const QString& message); void sendGroupMessage(int groupId, const QString& message);
void sendAction(int friendId, const QString& action); void sendAction(int friendId, const QString& action);
@ -105,13 +111,8 @@ public slots:
void pauseResumeFileSend(int friendId, int fileNum); void pauseResumeFileSend(int friendId, int fileNum);
void pauseResumeFileRecv(int friendId, int fileNum); void pauseResumeFileRecv(int friendId, int fileNum);
void setUsername(const QString& username); void answerCall(int callId);
void setStatusMessage(const QString& message); void hangupCall(int callId);
void setStatus(Status status);
void process();
void bootstrapDht();
signals: signals:
void connected(); void connected();
@ -166,6 +167,12 @@ signals:
void fileTransferPaused(int FriendId, int FileNum, ToxFile::FileDirection direction); void fileTransferPaused(int FriendId, int FileNum, ToxFile::FileDirection direction);
void fileTransferInfo(int FriendId, int FileNum, int Filesize, int BytesSent, 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: private:
static void onFriendRequest(Tox* tox, const uint8_t* cUserId, const uint8_t* cMessage, uint16_t cMessageSize, void* core); 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); 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)
connect(Widget::getInstance()->getCore(), &Core::fileSendStarted, this, &ChatForm::startFileSend); connect(Widget::getInstance()->getCore(), &Core::fileSendStarted, this, &ChatForm::startFileSend);
connect(sendButton, SIGNAL(clicked()), this, SLOT(onSendTriggered())); connect(sendButton, SIGNAL(clicked()), this, SLOT(onSendTriggered()));
connect(fileButton, SIGNAL(clicked()), this, SLOT(onAttachClicked())); connect(fileButton, SIGNAL(clicked()), this, SLOT(onAttachClicked()));
connect(callButton, SIGNAL(clicked()), this, SLOT(onCallTriggered()));
connect(msgEdit, SIGNAL(enterPressed()), this, SLOT(onSendTriggered())); connect(msgEdit, SIGNAL(enterPressed()), this, SLOT(onSendTriggered()));
connect(chatArea->verticalScrollBar(), SIGNAL(rangeChanged(int,int)), this, SLOT(onSliderRangeChanged())); connect(chatArea->verticalScrollBar(), SIGNAL(rangeChanged(int,int)), this, SLOT(onSliderRangeChanged()));
} }
@ -256,9 +257,71 @@ void ChatForm::onFileRecvRequest(ToxFile file)
connect(Widget::getInstance()->getCore(), &Core::fileTransferFinished, fileTrans, &FileTransfertWidget::onFileTransferFinished); 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() void ChatForm::onCallTriggered()

11
widget/form/chatform.h

@ -36,17 +36,25 @@ signals:
void sendMessage(int, QString); void sendMessage(int, QString);
void sendFile(int32_t friendId, QString, QByteArray); void sendFile(int32_t friendId, QString, QByteArray);
void startCall(int friendId); void startCall(int friendId);
void answerCall(int callId);
void hangupCall(int callId);
public slots: public slots:
void startFileSend(ToxFile file); void startFileSend(ToxFile file);
void onFileRecvRequest(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: private slots:
void onSendTriggered(); void onSendTriggered();
void onAttachClicked(); void onAttachClicked();
void onSliderRangeChanged(); void onSliderRangeChanged();
void onCallTriggered(); void onCallTriggered();
void onAnswerCallTriggered();
void onHangupCallTriggered();
private: private:
Friend* f; Friend* f;
@ -61,6 +69,7 @@ private:
QString previousName; QString previousName;
int curRow; int curRow;
bool lockSliderToBottom; bool lockSliderToBottom;
int callId;
}; };
#endif // CHATFORM_H #endif // CHATFORM_H

7
widget/widget.cpp

@ -229,7 +229,14 @@ void Widget::addFriend(int friendId, const QString &userId)
connect(newfriend->widget, SIGNAL(removeFriend(int)), this, SLOT(removeFriend(int))); 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(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(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::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&) void Widget::addFriendFailed(const QString&)

Loading…
Cancel
Save