mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge pull request #3442
Jeanbon (1): feat(autoAnswer): add auto answer feature
This commit is contained in:
commit
610e21169a
|
@ -112,6 +112,13 @@ can have different nicknames, status messages and friends.
|
||||||
+ __Change password:__ Allows you to either change an existing password, or
|
+ __Change password:__ Allows you to either change an existing password, or
|
||||||
create a new password if your profile does not have one.
|
create a new password if your profile does not have one.
|
||||||
|
|
||||||
|
## Friends' options
|
||||||
|
In the friend's window you can customize some options for this friend specifically.
|
||||||
|
* _Auto answer:_ chooses the way to autoaccept audio and video calls.
|
||||||
|
* _Manual:_ All calls must be manually accepted.
|
||||||
|
* _Audio:_ Only audio calls will be automatically accepted. Video calls must be manually accepted.
|
||||||
|
* _Audio + video:_ All calls will be automatically accepted.
|
||||||
|
|
||||||
## Settings
|
## Settings
|
||||||
### General
|
### General
|
||||||
|
|
||||||
|
|
|
@ -380,6 +380,11 @@ void Settings::loadPersonal(Profile* profile)
|
||||||
fp.alias = ps.value("alias").toString();
|
fp.alias = ps.value("alias").toString();
|
||||||
fp.note = ps.value("note").toString();
|
fp.note = ps.value("note").toString();
|
||||||
fp.autoAcceptDir = ps.value("autoAcceptDir").toString();
|
fp.autoAcceptDir = ps.value("autoAcceptDir").toString();
|
||||||
|
|
||||||
|
if(fp.autoAcceptDir == "")
|
||||||
|
fp.autoAcceptDir = ps.value("autoAccept").toString();
|
||||||
|
|
||||||
|
fp.autoAcceptCall = Settings::AutoAcceptCallFlags(QFlag(ps.value("autoAcceptCall", 0).toInt()));
|
||||||
fp.circleID = ps.value("circle", -1).toInt();
|
fp.circleID = ps.value("circle", -1).toInt();
|
||||||
|
|
||||||
if (getEnableLogging())
|
if (getEnableLogging())
|
||||||
|
@ -662,6 +667,7 @@ void Settings::savePersonal(QString profileName, const QString &password)
|
||||||
ps.setValue("alias", frnd.alias);
|
ps.setValue("alias", frnd.alias);
|
||||||
ps.setValue("note", frnd.note);
|
ps.setValue("note", frnd.note);
|
||||||
ps.setValue("autoAcceptDir", frnd.autoAcceptDir);
|
ps.setValue("autoAcceptDir", frnd.autoAcceptDir);
|
||||||
|
ps.setValue("autoAcceptCall", static_cast<int>(frnd.autoAcceptCall));
|
||||||
ps.setValue("circle", frnd.circleID);
|
ps.setValue("circle", frnd.circleID);
|
||||||
|
|
||||||
if (getEnableLogging())
|
if (getEnableLogging())
|
||||||
|
@ -1437,6 +1443,31 @@ void Settings::setAutoAcceptDir(const ToxId &id, const QString& dir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Settings::AutoAcceptCallFlags Settings::getAutoAcceptCall(const ToxId &id) const
|
||||||
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
|
QString key = id.publicKey;
|
||||||
|
|
||||||
|
auto it = friendLst.find(key);
|
||||||
|
if (it != friendLst.end())
|
||||||
|
return it->autoAcceptCall;
|
||||||
|
|
||||||
|
return Settings::AutoAcceptCallFlags();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::setAutoAcceptCall(const ToxId& id, AutoAcceptCallFlags accept)
|
||||||
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
|
QString key = id.publicKey;
|
||||||
|
|
||||||
|
auto it = friendLst.find(key);
|
||||||
|
if(it != friendLst.end())
|
||||||
|
{
|
||||||
|
it->autoAcceptCall = accept;
|
||||||
|
emit autoAcceptCallChanged(id, accept);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString Settings::getContactNote(const ToxId &id) const
|
QString Settings::getContactNote(const ToxId &id) const
|
||||||
{
|
{
|
||||||
QMutexLocker locker{&bigLock};
|
QMutexLocker locker{&bigLock};
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QDate>
|
#include <QDate>
|
||||||
#include <QNetworkProxy>
|
#include <QNetworkProxy>
|
||||||
|
#include <QFlags>
|
||||||
#include "src/core/corestructs.h"
|
#include "src/core/corestructs.h"
|
||||||
|
|
||||||
class ToxId;
|
class ToxId;
|
||||||
|
@ -131,6 +132,14 @@ class Settings : public QObject
|
||||||
public:
|
public:
|
||||||
enum class ProxyType {ptNone = 0, ptSOCKS5 = 1, ptHTTP = 2};
|
enum class ProxyType {ptNone = 0, ptSOCKS5 = 1, ptHTTP = 2};
|
||||||
enum class StyleType {NONE = 0, WITH_CHARS = 1, WITHOUT_CHARS = 2};
|
enum class StyleType {NONE = 0, WITH_CHARS = 1, WITHOUT_CHARS = 2};
|
||||||
|
enum class AutoAcceptCall
|
||||||
|
{
|
||||||
|
None = 0x00,
|
||||||
|
Audio = 0x01,
|
||||||
|
Video = 0x02,
|
||||||
|
AV = Audio | Video
|
||||||
|
};
|
||||||
|
Q_DECLARE_FLAGS(AutoAcceptCallFlags, AutoAcceptCall);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Settings& getInstance();
|
static Settings& getInstance();
|
||||||
|
@ -194,6 +203,7 @@ signals:
|
||||||
void globalAutoAcceptDirChanged(const QString& path);
|
void globalAutoAcceptDirChanged(const QString& path);
|
||||||
void checkUpdatesChanged(bool enabled);
|
void checkUpdatesChanged(bool enabled);
|
||||||
void widgetDataChanged(const QString& key);
|
void widgetDataChanged(const QString& key);
|
||||||
|
void autoAcceptCallChanged(const ToxId& id, AutoAcceptCallFlags accept);
|
||||||
|
|
||||||
// GUI
|
// GUI
|
||||||
void autoLoginChanged(bool enabled);
|
void autoLoginChanged(bool enabled);
|
||||||
|
@ -399,6 +409,9 @@ public:
|
||||||
QString getAutoAcceptDir(const ToxId& id) const;
|
QString getAutoAcceptDir(const ToxId& id) const;
|
||||||
void setAutoAcceptDir(const ToxId& id, const QString& dir);
|
void setAutoAcceptDir(const ToxId& id, const QString& dir);
|
||||||
|
|
||||||
|
AutoAcceptCallFlags getAutoAcceptCall(const ToxId& id) const;
|
||||||
|
void setAutoAcceptCall(const ToxId& id, AutoAcceptCallFlags accept);
|
||||||
|
|
||||||
QString getGlobalAutoAcceptDir() const;
|
QString getGlobalAutoAcceptDir() const;
|
||||||
void setGlobalAutoAcceptDir(const QString& dir);
|
void setGlobalAutoAcceptDir(const QString& dir);
|
||||||
|
|
||||||
|
@ -622,6 +635,7 @@ private:
|
||||||
QString note;
|
QString note;
|
||||||
int circleID = -1;
|
int circleID = -1;
|
||||||
QDate activity = QDate();
|
QDate activity = QDate();
|
||||||
|
AutoAcceptCallFlags autoAcceptCall;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct circleProp
|
struct circleProp
|
||||||
|
@ -642,4 +656,5 @@ private:
|
||||||
static QThread* settingsThread;
|
static QThread* settingsThread;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_OPERATORS_FOR_FLAGS(Settings::AutoAcceptCallFlags)
|
||||||
#endif // SETTINGS_HPP
|
#endif // SETTINGS_HPP
|
||||||
|
|
|
@ -17,16 +17,20 @@ AboutUser::AboutUser(ToxId &toxId, QWidget *parent) :
|
||||||
ui->aliases->hide();
|
ui->aliases->hide();
|
||||||
|
|
||||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &AboutUser::onAcceptedClicked);
|
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &AboutUser::onAcceptedClicked);
|
||||||
connect(ui->autoaccept, &QCheckBox::clicked, this, &AboutUser::onAutoAcceptClicked);
|
connect(ui->autoacceptfile, &QCheckBox::clicked, this, &AboutUser::onAutoAcceptDirClicked);
|
||||||
|
connect(ui->autoacceptcall, SIGNAL(activated(int)), this, SLOT(onAutoAcceptCallClicked(void)));
|
||||||
connect(ui->selectSaveDir, &QPushButton::clicked, this, &AboutUser::onSelectDirClicked);
|
connect(ui->selectSaveDir, &QPushButton::clicked, this, &AboutUser::onSelectDirClicked);
|
||||||
connect(ui->removeHistory, &QPushButton::clicked, this, &AboutUser::onRemoveHistoryClicked);
|
connect(ui->removeHistory, &QPushButton::clicked, this, &AboutUser::onRemoveHistoryClicked);
|
||||||
|
|
||||||
this->toxId = toxId;
|
this->toxId = toxId;
|
||||||
QString dir = Settings::getInstance().getAutoAcceptDir(this->toxId);
|
QString dir = Settings::getInstance().getAutoAcceptDir(this->toxId);
|
||||||
ui->autoaccept->setChecked(!dir.isEmpty());
|
ui->autoacceptfile->setChecked(!dir.isEmpty());
|
||||||
ui->selectSaveDir->setEnabled(ui->autoaccept->isChecked());
|
|
||||||
|
|
||||||
if(ui->autoaccept->isChecked())
|
ui->autoacceptcall->setCurrentIndex(Settings::getInstance().getAutoAcceptCall(this->toxId));
|
||||||
|
|
||||||
|
ui->selectSaveDir->setEnabled(ui->autoacceptfile->isChecked());
|
||||||
|
|
||||||
|
if(ui->autoacceptfile->isChecked())
|
||||||
ui->selectSaveDir->setText(Settings::getInstance().getAutoAcceptDir(this->toxId));
|
ui->selectSaveDir->setText(Settings::getInstance().getAutoAcceptDir(this->toxId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,17 +52,17 @@ void AboutUser::setFriend(Friend *f)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AboutUser::onAutoAcceptClicked()
|
void AboutUser::onAutoAcceptDirClicked()
|
||||||
{
|
{
|
||||||
QString dir;
|
QString dir;
|
||||||
if (!ui->autoaccept->isChecked())
|
if (!ui->autoacceptfile->isChecked())
|
||||||
{
|
{
|
||||||
dir = QDir::homePath();
|
dir = QDir::homePath();
|
||||||
ui->autoaccept->setChecked(false);
|
ui->autoacceptfile->setChecked(false);
|
||||||
Settings::getInstance().setAutoAcceptDir(this->toxId, "");
|
Settings::getInstance().setAutoAcceptDir(this->toxId, "");
|
||||||
ui->selectSaveDir->setText(tr("Auto accept for this contact is disabled"));
|
ui->selectSaveDir->setText(tr("Auto accept for this contact is disabled"));
|
||||||
}
|
}
|
||||||
else if (ui->autoaccept->isChecked())
|
else if (ui->autoacceptfile->isChecked())
|
||||||
{
|
{
|
||||||
dir = QFileDialog::getExistingDirectory(this,
|
dir = QFileDialog::getExistingDirectory(this,
|
||||||
tr("Choose an auto accept directory", "popup title"),
|
tr("Choose an auto accept directory", "popup title"),
|
||||||
|
@ -66,14 +70,20 @@ void AboutUser::onAutoAcceptClicked()
|
||||||
QFileDialog::DontUseNativeDialog);
|
QFileDialog::DontUseNativeDialog);
|
||||||
if(dir.isEmpty())
|
if(dir.isEmpty())
|
||||||
{
|
{
|
||||||
ui->autoaccept->setChecked(false);
|
ui->autoacceptfile->setChecked(false);
|
||||||
return; // user canellced
|
return; // user canellced
|
||||||
}
|
}
|
||||||
Settings::getInstance().setAutoAcceptDir(this->toxId, dir);
|
Settings::getInstance().setAutoAcceptDir(this->toxId, dir);
|
||||||
ui->selectSaveDir->setText(Settings::getInstance().getAutoAcceptDir(this->toxId));
|
ui->selectSaveDir->setText(Settings::getInstance().getAutoAcceptDir(this->toxId));
|
||||||
}
|
}
|
||||||
Settings::getInstance().saveGlobal();
|
Settings::getInstance().saveGlobal();
|
||||||
ui->selectSaveDir->setEnabled(ui->autoaccept->isChecked());
|
ui->selectSaveDir->setEnabled(ui->autoacceptfile->isChecked());
|
||||||
|
}
|
||||||
|
|
||||||
|
void AboutUser::onAutoAcceptCallClicked()
|
||||||
|
{
|
||||||
|
Settings::getInstance().setAutoAcceptCall(this->toxId,Settings::AutoAcceptCallFlags(QFlag(ui->autoacceptcall->currentIndex())));
|
||||||
|
Settings::getInstance().savePersonal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AboutUser::onSelectDirClicked()
|
void AboutUser::onSelectDirClicked()
|
||||||
|
@ -83,9 +93,9 @@ void AboutUser::onSelectDirClicked()
|
||||||
tr("Choose an auto accept directory", "popup title"),
|
tr("Choose an auto accept directory", "popup title"),
|
||||||
dir,
|
dir,
|
||||||
QFileDialog::DontUseNativeDialog);
|
QFileDialog::DontUseNativeDialog);
|
||||||
ui->autoaccept->setChecked(true);
|
ui->autoacceptfile->setChecked(true);
|
||||||
Settings::getInstance().setAutoAcceptDir(this->toxId, dir);
|
Settings::getInstance().setAutoAcceptDir(this->toxId, dir);
|
||||||
Settings::getInstance().saveGlobal();
|
Settings::getInstance().savePersonal();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -24,7 +24,8 @@ private:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onAcceptedClicked();
|
void onAcceptedClicked();
|
||||||
void onAutoAcceptClicked();
|
void onAutoAcceptDirClicked();
|
||||||
|
void onAutoAcceptCallClicked();
|
||||||
void onSelectDirClicked();
|
void onSelectDirClicked();
|
||||||
void onRemoveHistoryClicked();
|
void onRemoveHistoryClicked();
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>465</width>
|
<width>465</width>
|
||||||
<height>406</height>
|
<height>460</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -164,27 +164,57 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="5" column="0" colspan="2">
|
||||||
|
<widget class="QCheckBox" name="autoacceptfile">
|
||||||
|
<property name="text">
|
||||||
|
<string>Auto accept file</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Default directory to save files:</string>
|
<string>Default directory to save files:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="8" column="1">
|
||||||
<widget class="QPushButton" name="selectSaveDir">
|
<widget class="QPushButton" name="selectSaveDir">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Auto accept for this contact is disabled</string>
|
<string>Auto accept for this contact is disabled</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" colspan="2">
|
<item row="3" column="0" colspan="2">
|
||||||
<widget class="QCheckBox" name="autoaccept">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Auto accept files</string>
|
<string>Auto accept call :</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="autoacceptcall">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Manual</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Audio</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Audio + Video</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|
|
@ -282,8 +282,21 @@ void ChatForm::onAvInvite(uint32_t FriendId, bool video)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qDebug() << "onAvInvite";
|
qDebug() << "onAvInvite";
|
||||||
|
|
||||||
disableCallButtons();
|
disableCallButtons();
|
||||||
|
insertChatMessage(ChatMessage::createChatInfoMessage(tr("%1 calling").arg(f->getDisplayedName()),
|
||||||
|
ChatMessage::INFO,
|
||||||
|
QDateTime::currentDateTime()));
|
||||||
|
/* AutoAcceptCall is set for this friend */
|
||||||
|
if ((video && Settings::getInstance().getAutoAcceptCall(f->getToxId()).testFlag(Settings::AutoAcceptCall::Video)) ||
|
||||||
|
(!video && Settings::getInstance().getAutoAcceptCall(f->getToxId()).testFlag(Settings::AutoAcceptCall::Audio)))
|
||||||
|
{
|
||||||
|
uint32_t friendId = f->getFriendID();
|
||||||
|
qDebug() << "automatic call answer";
|
||||||
|
QMetaObject::invokeMethod(coreav, "answerCall", Qt::QueuedConnection, Q_ARG(uint32_t, friendId));
|
||||||
|
onAvStart(friendId,video);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (video)
|
if (video)
|
||||||
{
|
{
|
||||||
callConfirm = new CallConfirmWidget(videoButton, *f);
|
callConfirm = new CallConfirmWidget(videoButton, *f);
|
||||||
|
@ -307,15 +320,12 @@ void ChatForm::onAvInvite(uint32_t FriendId, bool video)
|
||||||
connect(callConfirm, &CallConfirmWidget::accepted, this, &ChatForm::onAnswerCallTriggered);
|
connect(callConfirm, &CallConfirmWidget::accepted, this, &ChatForm::onAnswerCallTriggered);
|
||||||
connect(callConfirm, &CallConfirmWidget::rejected, this, &ChatForm::onRejectCallTriggered);
|
connect(callConfirm, &CallConfirmWidget::rejected, this, &ChatForm::onRejectCallTriggered);
|
||||||
|
|
||||||
insertChatMessage(ChatMessage::createChatInfoMessage(tr("%1 calling").arg(f->getDisplayedName()),
|
|
||||||
ChatMessage::INFO,
|
|
||||||
QDateTime::currentDateTime()));
|
|
||||||
|
|
||||||
Widget::getInstance()->newFriendMessageAlert(FriendId, false);
|
Widget::getInstance()->newFriendMessageAlert(FriendId, false);
|
||||||
Audio& audio = Audio::getInstance();
|
Audio& audio = Audio::getInstance();
|
||||||
audio.startLoop();
|
audio.startLoop();
|
||||||
audio.playMono16Sound(QStringLiteral(":/audio/ToxicIncomingCall.pcm"));
|
audio.playMono16Sound(QStringLiteral(":/audio/ToxicIncomingCall.pcm"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ChatForm::onAvStart(uint32_t FriendId, bool video)
|
void ChatForm::onAvStart(uint32_t FriendId, bool video)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user