mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge branch 'thread' into corencryption
This commit is contained in:
commit
34bb83aca7
|
@ -9,4 +9,4 @@ Exec=qtox
|
|||
Icon=qtox
|
||||
Categories=InstantMessaging;;AudioVideo;Network;
|
||||
Terminal=false
|
||||
MimeType=x-scheme-handler/tox;
|
||||
MimeType=x-scheme-handler/tox;application/x-tox;
|
||||
|
|
15
src/core.cpp
15
src/core.cpp
|
@ -47,6 +47,8 @@ QList<ToxFile> Core::fileRecvQueue;
|
|||
Core::Core(Camera* cam, QThread *coreThread, QString loadPath) :
|
||||
tox(nullptr), camera(cam), loadPath(loadPath)
|
||||
{
|
||||
qDebug() << "Core: loading Tox from" << loadPath;
|
||||
|
||||
videobuf = new uint8_t[videobufsize];
|
||||
videoBusyness=0;
|
||||
|
||||
|
@ -590,7 +592,7 @@ void Core::onFileControlCallback(Tox* tox, int32_t friendnumber, uint8_t receive
|
|||
|
||||
uint64_t resumePos = *reinterpret_cast<const uint64_t*>(data);
|
||||
|
||||
if (resumePos >= file->filesize)
|
||||
if (resumePos >= (unsigned)file->filesize)
|
||||
{
|
||||
qWarning() << "Core::onFileControlCallback: invalid resume position";
|
||||
tox_file_send_control(tox, file->friendId, 0, file->fileNum, TOX_FILECONTROL_KILL, nullptr, 0); // don't sure about it
|
||||
|
@ -1218,8 +1220,15 @@ void Core::saveConfiguration(const QString& path)
|
|||
}
|
||||
}
|
||||
|
||||
void Core::switchConfiguration(QString profile)
|
||||
void Core::switchConfiguration(const QString& profile)
|
||||
{
|
||||
if (profile.isEmpty())
|
||||
{
|
||||
qWarning() << "Core: got null profile to switch to, not switching";
|
||||
return;
|
||||
}
|
||||
else
|
||||
qDebug() << "Core: switching from" << Settings::getInstance().getCurrentProfile() << "to" << profile;
|
||||
saveConfiguration();
|
||||
|
||||
toxTimer->stop();
|
||||
|
@ -1231,7 +1240,7 @@ void Core::switchConfiguration(QString profile)
|
|||
tox = nullptr;
|
||||
}
|
||||
emit selfAvatarChanged(QPixmap(":/img/contact_dark.png"));
|
||||
Widget::getInstance()->clearContactsList(); // we need this to block, so no signals for us
|
||||
emit blockingClearContacts(); // we need this to block, but signals are required for thread safety
|
||||
|
||||
loadPath = QDir(Settings::getSettingsDirPath()).filePath(profile + TOX_EXT);
|
||||
Settings::getInstance().setCurrentProfile(profile);
|
||||
|
|
|
@ -53,7 +53,6 @@ public:
|
|||
|
||||
void saveConfiguration();
|
||||
void saveConfiguration(const QString& path);
|
||||
void switchConfiguration(QString profile);
|
||||
|
||||
QString getIDString();
|
||||
|
||||
|
@ -64,10 +63,13 @@ public:
|
|||
void increaseVideoBusyness();
|
||||
void decreaseVideoBusyness();
|
||||
|
||||
bool anyActiveCalls();
|
||||
|
||||
public slots:
|
||||
void start();
|
||||
void process();
|
||||
void bootstrapDht();
|
||||
void switchConfiguration(const QString& profile);
|
||||
|
||||
void acceptFriendRequest(const QString& userId);
|
||||
void requestFriendship(const QString& friendAddress, const QString& message);
|
||||
|
@ -112,6 +114,7 @@ public slots:
|
|||
signals:
|
||||
void connected();
|
||||
void disconnected();
|
||||
void blockingClearContacts();
|
||||
|
||||
void friendRequestReceived(const QString& userId, const QString& message);
|
||||
void friendMessageReceived(int friendId, const QString& message, bool isAction);
|
||||
|
|
|
@ -28,6 +28,14 @@ ALCdevice* Core::alOutDev, *Core::alInDev;
|
|||
ALCcontext* Core::alContext;
|
||||
ALuint Core::alMainSource;
|
||||
|
||||
bool Core::anyActiveCalls()
|
||||
{
|
||||
for (auto& call : calls)
|
||||
if (call.active)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void Core::prepareCall(int friendId, int callId, ToxAv* toxav, bool videoEnabled)
|
||||
{
|
||||
qDebug() << QString("Core: preparing call %1").arg(callId);
|
||||
|
|
|
@ -34,7 +34,6 @@ Camera::Camera()
|
|||
|
||||
connect(workerThread, &QThread::started, worker, &CameraWorker::onStart);
|
||||
connect(workerThread, &QThread::finished, worker, &CameraWorker::deleteLater);
|
||||
connect(workerThread, &QThread::deleteLater, worker, &CameraWorker::deleteLater);
|
||||
connect(worker, &CameraWorker::started, this, &Camera::onWorkerStarted);
|
||||
connect(worker, &CameraWorker::newFrameAvailable, this, &Camera::onNewFrameAvailable);
|
||||
connect(worker, &CameraWorker::resProbingFinished, this, &Camera::onResProbingFinished);
|
||||
|
|
|
@ -108,7 +108,15 @@ void IdentityForm::setStatusMessage(const QString &msg)
|
|||
|
||||
void IdentityForm::onLoadClicked()
|
||||
{
|
||||
Core::getInstance()->switchConfiguration(bodyUI->profiles->currentText());
|
||||
if (bodyUI->profiles->currentText() != Settings::getInstance().getCurrentProfile())
|
||||
{
|
||||
if (Core::getInstance()->anyActiveCalls())
|
||||
QMessageBox::warning(this, tr("Call active", "popup title"),
|
||||
tr("You can't switch profiles while a call is active!", "popup text"));
|
||||
else
|
||||
emit Widget::getInstance()->changeProfile(bodyUI->profiles->currentText());
|
||||
// I think by directly calling the function, I may have been causing thread issues
|
||||
}
|
||||
}
|
||||
|
||||
void IdentityForm::onRenameClicked()
|
||||
|
@ -132,6 +140,7 @@ void IdentityForm::onExportClicked()
|
|||
QString path = QFileDialog::getSaveFileName(this, tr("Export profile", "save dialog title"),
|
||||
QDir::home().filePath(current),
|
||||
tr("Tox save file (*.tox)", "save dialog filter"));
|
||||
if (!path.isEmpty())
|
||||
QFile::copy(QDir(Settings::getSettingsDirPath()).filePath(current), path);
|
||||
}
|
||||
|
||||
|
@ -157,6 +166,8 @@ void IdentityForm::onDeleteClicked()
|
|||
void IdentityForm::onImportClicked()
|
||||
{
|
||||
QString path = QFileDialog::getOpenFileName(this, tr("Import profile", "import dialog title"), QDir::homePath(), tr("Tox save file (*.tox)", "import dialog filter"));
|
||||
if (path.isEmpty())
|
||||
return;
|
||||
QFileInfo info(path);
|
||||
QString profile = info.completeBaseName();
|
||||
QString profilePath = QDir(Settings::getSettingsDirPath()).filePath(profile + Core::TOX_EXT);
|
||||
|
|
|
@ -146,6 +146,7 @@ Widget::Widget(QWidget *parent)
|
|||
connect(core, &Core::groupNamelistChanged, this, &Widget::onGroupNamelistChanged);
|
||||
connect(core, &Core::emptyGroupCreated, this, &Widget::onEmptyGroupCreated);
|
||||
connect(core, &Core::avInvite, this, &Widget::playRingtone);
|
||||
connect(core, &Core::blockingClearContacts, this, &Widget::clearContactsList, Qt::BlockingQueuedConnection);
|
||||
|
||||
connect(core, SIGNAL(messageSentResult(int,QString,int)), this, SLOT(onMessageSendResult(int,QString,int)));
|
||||
connect(core, SIGNAL(groupSentResult(int,QString,int)), this, SLOT(onGroupSendResult(int,QString,int)));
|
||||
|
@ -153,6 +154,7 @@ Widget::Widget(QWidget *parent)
|
|||
connect(this, &Widget::statusSet, core, &Core::setStatus);
|
||||
connect(this, &Widget::friendRequested, core, &Core::requestFriendship);
|
||||
connect(this, &Widget::friendRequestAccepted, core, &Core::acceptFriendRequest);
|
||||
connect(this, &Widget::changeProfile, core, &Core::switchConfiguration);
|
||||
|
||||
connect(ui->addButton, SIGNAL(clicked()), this, SLOT(onAddClicked()));
|
||||
connect(ui->groupButton, SIGNAL(clicked()), this, SLOT(onGroupClicked()));
|
||||
|
|
|
@ -69,6 +69,7 @@ signals:
|
|||
void statusSelected(Status status);
|
||||
void usernameChanged(const QString& username);
|
||||
void statusMessageChanged(const QString& statusMessage);
|
||||
void changeProfile(const QString& profile);
|
||||
|
||||
private slots:
|
||||
void onConnected();
|
||||
|
|
Loading…
Reference in New Issue
Block a user