1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge branch 'v1.17-dev'

This commit is contained in:
Anthony Bilinski 2019-12-02 08:46:04 -08:00
commit f252816f55
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
19 changed files with 121 additions and 52 deletions

View File

@ -63,6 +63,10 @@
<url type="homepage">https://qtox.github.io</url> <url type="homepage">https://qtox.github.io</url>
<update_contact>barrdetwix@gmail.com</update_contact> <update_contact>barrdetwix@gmail.com</update_contact>
<project_group>qTox</project_group> <project_group>qTox</project_group>
<content_rating type="oars-1.0">
<content_attribute id="social-chat">intense</content_attribute>
<content_attribute id="social-audio">intense</content_attribute>
</content_rating>
<releases> <releases>
<release version="1.16.3" date="2018-07-21"/> <release version="1.16.3" date="2018-07-21"/>
</releases> </releases>

View File

@ -95,9 +95,9 @@ void CoreFile::sendAvatarFile(uint32_t friendId, const QByteArray& data)
uint8_t *file_id = nullptr; uint8_t *file_id = nullptr;
uint8_t *file_name = nullptr; uint8_t *file_name = nullptr;
size_t nameLength = 0; size_t nameLength = 0;
uint8_t avatarHash[TOX_HASH_LENGTH];
if (!data.isEmpty()) { if (!data.isEmpty()) {
static_assert(TOX_HASH_LENGTH <= TOX_FILE_ID_LENGTH, "TOX_HASH_LENGTH > TOX_FILE_ID_LENGTH!"); static_assert(TOX_HASH_LENGTH <= TOX_FILE_ID_LENGTH, "TOX_HASH_LENGTH > TOX_FILE_ID_LENGTH!");
uint8_t avatarHash[TOX_HASH_LENGTH];
tox_hash(avatarHash, (uint8_t*)data.data(), data.size()); tox_hash(avatarHash, (uint8_t*)data.data(), data.size());
filesize = data.size(); filesize = data.size();
file_id = avatarHash; file_id = avatarHash;

View File

@ -22,6 +22,7 @@
#include "src/model/dialogs/idialogsmanager.h" #include "src/model/dialogs/idialogsmanager.h"
#include "src/model/friend.h" #include "src/model/friend.h"
#include "src/model/group.h" #include "src/model/group.h"
#include "src/model/status.h"
#include "src/persistence/settings.h" #include "src/persistence/settings.h"
#include "src/widget/contentdialog.h" #include "src/widget/contentdialog.h"
@ -67,7 +68,7 @@ void FriendChatroom::setActive(bool _active)
bool FriendChatroom::canBeInvited() const bool FriendChatroom::canBeInvited() const
{ {
return frnd->isOnline(); return Status::isOnline(frnd->getStatus());
} }
int FriendChatroom::getCircleId() const int FriendChatroom::getCircleId() const

View File

@ -25,6 +25,7 @@
#include "src/model/dialogs/idialogsmanager.h" #include "src/model/dialogs/idialogsmanager.h"
#include "src/model/friend.h" #include "src/model/friend.h"
#include "src/model/group.h" #include "src/model/group.h"
#include "src/model/status.h"
#include "src/persistence/settings.h" #include "src/persistence/settings.h"
GroupChatroom::GroupChatroom(Group* group, IDialogsManager* dialogsManager) GroupChatroom::GroupChatroom(Group* group, IDialogsManager* dialogsManager)
@ -64,7 +65,7 @@ void GroupChatroom::inviteFriend(const ToxPk& pk)
const Friend* frnd = FriendList::findFriend(pk); const Friend* frnd = FriendList::findFriend(pk);
const auto friendId = frnd->getId(); const auto friendId = frnd->getId();
const auto groupId = group->getId(); const auto groupId = group->getId();
const auto canInvite = frnd->isOnline(); const auto canInvite = Status::isOnline(frnd->getStatus());
if (canInvite) { if (canInvite) {
Core::getInstance()->groupInviteFriend(friendId, groupId); Core::getInstance()->groupInviteFriend(friendId, groupId);

View File

@ -152,8 +152,15 @@ bool Friend::getEventFlag() const
void Friend::setStatus(Status::Status s) void Friend::setStatus(Status::Status s)
{ {
if (friendStatus != s) { if (friendStatus != s) {
auto oldStatus = friendStatus;
friendStatus = s; friendStatus = s;
emit statusChanged(friendPk, friendStatus); emit statusChanged(friendPk, friendStatus);
if (!Status::isOnline(oldStatus) && Status::isOnline(friendStatus)) {
emit onlineOfflineChanged(friendPk, true);
} else if (Status::isOnline(oldStatus) && !Status::isOnline(friendStatus)) {
emit onlineOfflineChanged(friendPk, false);
}
} }
} }
@ -162,11 +169,6 @@ Status::Status Friend::getStatus() const
return friendStatus; return friendStatus;
} }
bool Friend::isOnline() const
{
return friendStatus != Status::Status::Offline && friendStatus != Status::Status::Blocked;
}
bool Friend::useHistory() const bool Friend::useHistory() const
{ {
return true; return true;

View File

@ -53,14 +53,13 @@ public:
void setStatus(Status::Status s); void setStatus(Status::Status s);
Status::Status getStatus() const; Status::Status getStatus() const;
bool isOnline() const;
bool useHistory() const final; bool useHistory() const final;
signals: signals:
void nameChanged(const ToxPk& friendId, const QString& name); void nameChanged(const ToxPk& friendId, const QString& name);
void aliasChanged(const ToxPk& friendId, QString alias); void aliasChanged(const ToxPk& friendId, QString alias);
void statusChanged(const ToxPk& friendId, Status::Status status); void statusChanged(const ToxPk& friendId, Status::Status status);
void onlineOfflineChanged(const ToxPk& friendId, bool isOnline);
void statusMessageChanged(const ToxPk& friendId, const QString& message); void statusMessageChanged(const ToxPk& friendId, const QString& message);
void loadChatHistory(); void loadChatHistory();

View File

@ -19,6 +19,7 @@
#include "friendmessagedispatcher.h" #include "friendmessagedispatcher.h"
#include "src/persistence/settings.h" #include "src/persistence/settings.h"
#include "src/model/status.h"
namespace { namespace {
@ -49,7 +50,7 @@ FriendMessageDispatcher::FriendMessageDispatcher(Friend& f_, MessageProcessor pr
, offlineMsgEngine(&f_, &messageSender_) , offlineMsgEngine(&f_, &messageSender_)
, processor(std::move(processor_)) , processor(std::move(processor_))
{ {
connect(&f, &Friend::statusChanged, this, &FriendMessageDispatcher::onFriendStatusChange); connect(&f, &Friend::onlineOfflineChanged, this, &FriendMessageDispatcher::onFriendOnlineOfflineChanged);
} }
/** /**
@ -69,7 +70,7 @@ FriendMessageDispatcher::sendMessage(bool isAction, const QString& content)
bool messageSent = false; bool messageSent = false;
if (f.isOnline()) { if (Status::isOnline(f.getStatus())) {
messageSent = sendMessageToCore(messageSender, f, message, receipt); messageSent = sendMessageToCore(messageSender, f, message, receipt);
} }
@ -107,9 +108,9 @@ void FriendMessageDispatcher::onReceiptReceived(ReceiptNum receipt)
* @brief Handles status change for friend * @brief Handles status change for friend
* @note Parameters just to fit slot api * @note Parameters just to fit slot api
*/ */
void FriendMessageDispatcher::onFriendStatusChange(const ToxPk&, Status::Status) void FriendMessageDispatcher::onFriendOnlineOfflineChanged(const ToxPk&, bool isOnline)
{ {
if (f.isOnline()) { if (isOnline) {
offlineMsgEngine.deliverOfflineMsgs(); offlineMsgEngine.deliverOfflineMsgs();
} }
} }

View File

@ -44,7 +44,7 @@ public:
void onReceiptReceived(ReceiptNum receipt); void onReceiptReceived(ReceiptNum receipt);
void clearOutgoingMessages(); void clearOutgoingMessages();
private slots: private slots:
void onFriendStatusChange(const ToxPk& key, Status::Status status); void onFriendOnlineOfflineChanged(const ToxPk& key, bool isOnline);
private: private:
Friend& f; Friend& f;

View File

@ -75,4 +75,9 @@ namespace Status
return ":/img/status/" + statusSuffix + eventSuffix + ".svg"; return ":/img/status/" + statusSuffix + eventSuffix + ".svg";
} }
} }
bool isOnline(Status status)
{
return status != Status::Offline && status != Status::Blocked;
}
} // namespace Status } // namespace Status

View File

@ -38,6 +38,7 @@ namespace Status
QString getIconPath(Status status, bool event = false); QString getIconPath(Status status, bool event = false);
QString getTitle(Status status); QString getTitle(Status status);
QString getAssetSuffix(Status status); QString getAssetSuffix(Status status);
bool isOnline(Status status);
} }
#endif // STATUS_H #endif // STATUS_H

View File

@ -195,10 +195,11 @@ bool dbSchema3to4(RawDatabase& db)
/** /**
* @brief Upgrade the db schema * @brief Upgrade the db schema
* @return True if the schema upgrade succeded, false otherwise
* @note On future alterations of the database all you have to do is bump the SCHEMA_VERSION * @note On future alterations of the database all you have to do is bump the SCHEMA_VERSION
* variable and add another case to the switch statement below. Make sure to fall through on each case. * variable and add another case to the switch statement below. Make sure to fall through on each case.
*/ */
void dbSchemaUpgrade(std::shared_ptr<RawDatabase>& db) bool dbSchemaUpgrade(std::shared_ptr<RawDatabase>& db)
{ {
int64_t databaseSchemaVersion; int64_t databaseSchemaVersion;
@ -206,19 +207,17 @@ void dbSchemaUpgrade(std::shared_ptr<RawDatabase>& db)
databaseSchemaVersion = row[0].toLongLong(); databaseSchemaVersion = row[0].toLongLong();
}))) { }))) {
qCritical() << "History failed to read user_version"; qCritical() << "History failed to read user_version";
db.reset(); return false;
return;
} }
if (databaseSchemaVersion > SCHEMA_VERSION) { if (databaseSchemaVersion > SCHEMA_VERSION) {
qWarning().nospace() << "Database version (" << databaseSchemaVersion << qWarning().nospace() << "Database version (" << databaseSchemaVersion <<
") is newer than we currently support (" << SCHEMA_VERSION << "). Please upgrade qTox"; ") is newer than we currently support (" << SCHEMA_VERSION << "). Please upgrade qTox";
// We don't know what future versions have done, we have to disable db access until we re-upgrade // We don't know what future versions have done, we have to disable db access until we re-upgrade
db.reset(); return false;
return;
} else if (databaseSchemaVersion == SCHEMA_VERSION) { } else if (databaseSchemaVersion == SCHEMA_VERSION) {
// No work to do // No work to do
return; return true;
} }
switch (databaseSchemaVersion) { switch (databaseSchemaVersion) {
@ -231,22 +230,19 @@ void dbSchemaUpgrade(std::shared_ptr<RawDatabase>& db)
const bool newDb = isNewDb(db, success); const bool newDb = isNewDb(db, success);
if (!success) { if (!success) {
qCritical() << "Failed to create current db schema"; qCritical() << "Failed to create current db schema";
db.reset(); return false;
return;
} }
if (newDb) { if (newDb) {
if (!createCurrentSchema(*db)) { if (!createCurrentSchema(*db)) {
qCritical() << "Failed to create current db schema"; qCritical() << "Failed to create current db schema";
db.reset(); return false;
return;
} }
qDebug() << "Database created at schema version" << SCHEMA_VERSION; qDebug() << "Database created at schema version" << SCHEMA_VERSION;
break; // new db is the only case where we don't incrementally upgrade through each version break; // new db is the only case where we don't incrementally upgrade through each version
} else { } else {
if (!dbSchema0to1(*db)) { if (!dbSchema0to1(*db)) {
qCritical() << "Failed to upgrade db to schema version 1, aborting"; qCritical() << "Failed to upgrade db to schema version 1, aborting";
db.reset(); return false;
return;
} }
qDebug() << "Database upgraded incrementally to schema version 1"; qDebug() << "Database upgraded incrementally to schema version 1";
} }
@ -255,23 +251,20 @@ void dbSchemaUpgrade(std::shared_ptr<RawDatabase>& db)
case 1: case 1:
if (!dbSchema1to2(*db)) { if (!dbSchema1to2(*db)) {
qCritical() << "Failed to upgrade db to schema version 2, aborting"; qCritical() << "Failed to upgrade db to schema version 2, aborting";
db.reset(); return false;
return;
} }
qDebug() << "Database upgraded incrementally to schema version 2"; qDebug() << "Database upgraded incrementally to schema version 2";
//fallthrough //fallthrough
case 2: case 2:
if (!dbSchema2to3(*db)) { if (!dbSchema2to3(*db)) {
qCritical() << "Failed to upgrade db to schema version 3, aborting"; qCritical() << "Failed to upgrade db to schema version 3, aborting";
db.reset(); return false;
return;
} }
qDebug() << "Database upgraded incrementally to schema version 3"; qDebug() << "Database upgraded incrementally to schema version 3";
case 3: case 3:
if (!dbSchema3to4(*db)) { if (!dbSchema3to4(*db)) {
qCritical() << "Failed to upgrade db to schema version 4, aborting"; qCritical() << "Failed to upgrade db to schema version 4, aborting";
db.reset(); return false;
return;
} }
qDebug() << "Database upgraded incrementally to schema version 4"; qDebug() << "Database upgraded incrementally to schema version 4";
// etc. // etc.
@ -279,6 +272,8 @@ void dbSchemaUpgrade(std::shared_ptr<RawDatabase>& db)
qInfo() << "Database upgrade finished (databaseSchemaVersion" << databaseSchemaVersion qInfo() << "Database upgrade finished (databaseSchemaVersion" << databaseSchemaVersion
<< "->" << SCHEMA_VERSION << ")"; << "->" << SCHEMA_VERSION << ")";
} }
return true;
} }
MessageState getMessageState(bool isPending, bool isBroken) MessageState getMessageState(bool isPending, bool isBroken)
@ -318,18 +313,19 @@ FileDbInsertionData::FileDbInsertionData()
* @brief Prepares the database to work with the history. * @brief Prepares the database to work with the history.
* @param db This database will be prepared for use with the history. * @param db This database will be prepared for use with the history.
*/ */
History::History(std::shared_ptr<RawDatabase> db) History::History(std::shared_ptr<RawDatabase> db_)
: db(db) : db(db_)
{ {
if (!isValid()) { if (!isValid()) {
qWarning() << "Database not open, init failed"; qWarning() << "Database not open, init failed";
return; return;
} }
dbSchemaUpgrade(db); const auto upgradeSucceeded = dbSchemaUpgrade(db);
// dbSchemaUpgrade may have put us in an invalid state // dbSchemaUpgrade may have put us in an invalid state
if (!isValid()) { if (!upgradeSucceeded) {
db.reset();
return; return;
} }
@ -370,6 +366,10 @@ bool History::isValid()
*/ */
bool History::historyExists(const ToxPk& friendPk) bool History::historyExists(const ToxPk& friendPk)
{ {
if (historyAccessBlocked()) {
return false;
}
return !getMessagesForFriend(friendPk, 0, 1).empty(); return !getMessagesForFriend(friendPk, 0, 1).empty();
} }
@ -588,6 +588,10 @@ void History::addNewFileMessage(const QString& friendPk, const QString& fileId,
const QString& fileName, const QString& filePath, int64_t size, const QString& fileName, const QString& filePath, int64_t size,
const QString& sender, const QDateTime& time, QString const& dispName) const QString& sender, const QDateTime& time, QString const& dispName)
{ {
if (historyAccessBlocked()) {
return;
}
// This is an incredibly far from an optimal way of implementing this, // This is an incredibly far from an optimal way of implementing this,
// but given the frequency that people are going to be initiating a file // but given the frequency that people are going to be initiating a file
// transfer we can probably live with it. // transfer we can probably live with it.
@ -644,11 +648,7 @@ void History::addNewMessage(const QString& friendPk, const QString& message, con
const QDateTime& time, bool isDelivered, QString dispName, const QDateTime& time, bool isDelivered, QString dispName,
const std::function<void(RowId)>& insertIdCallback) const std::function<void(RowId)>& insertIdCallback)
{ {
if (!Settings::getInstance().getEnableLogging()) { if (historyAccessBlocked()) {
qWarning() << "Blocked a message from being added to database while history is disabled";
return;
}
if (!isValid()) {
return; return;
} }
@ -659,6 +659,10 @@ void History::addNewMessage(const QString& friendPk, const QString& message, con
void History::setFileFinished(const QString& fileId, bool success, const QString& filePath, void History::setFileFinished(const QString& fileId, bool success, const QString& filePath,
const QByteArray& fileHash) const QByteArray& fileHash)
{ {
if (historyAccessBlocked()) {
return;
}
auto& fileInfo = fileInfos[fileId]; auto& fileInfo = fileInfos[fileId];
if (fileInfo.fileId.get() == -1) { if (fileInfo.fileId.get() == -1) {
fileInfo.finished = true; fileInfo.finished = true;
@ -674,11 +678,19 @@ void History::setFileFinished(const QString& fileId, bool success, const QString
size_t History::getNumMessagesForFriend(const ToxPk& friendPk) size_t History::getNumMessagesForFriend(const ToxPk& friendPk)
{ {
if (historyAccessBlocked()) {
return 0;
}
return getNumMessagesForFriendBeforeDate(friendPk, QDateTime()); return getNumMessagesForFriendBeforeDate(friendPk, QDateTime());
} }
size_t History::getNumMessagesForFriendBeforeDate(const ToxPk& friendPk, const QDateTime& date) size_t History::getNumMessagesForFriendBeforeDate(const ToxPk& friendPk, const QDateTime& date)
{ {
if (historyAccessBlocked()) {
return 0;
}
QString queryText = QString("SELECT COUNT(history.id) " QString queryText = QString("SELECT COUNT(history.id) "
"FROM history " "FROM history "
"JOIN peers chat ON chat_id = chat.id " "JOIN peers chat ON chat_id = chat.id "
@ -704,6 +716,10 @@ size_t History::getNumMessagesForFriendBeforeDate(const ToxPk& friendPk, const Q
QList<History::HistMessage> History::getMessagesForFriend(const ToxPk& friendPk, size_t firstIdx, QList<History::HistMessage> History::getMessagesForFriend(const ToxPk& friendPk, size_t firstIdx,
size_t lastIdx) size_t lastIdx)
{ {
if (historyAccessBlocked()) {
return {};
}
QList<HistMessage> messages; QList<HistMessage> messages;
// Don't forget to update the rowCallback if you change the selected columns! // Don't forget to update the rowCallback if you change the selected columns!
@ -763,6 +779,10 @@ QList<History::HistMessage> History::getMessagesForFriend(const ToxPk& friendPk,
QList<History::HistMessage> History::getUndeliveredMessagesForFriend(const ToxPk& friendPk) QList<History::HistMessage> History::getUndeliveredMessagesForFriend(const ToxPk& friendPk)
{ {
if (historyAccessBlocked()) {
return {};
}
auto queryText = auto queryText =
QString("SELECT history.id, faux_offline_pending.id, timestamp, chat.public_key, " QString("SELECT history.id, faux_offline_pending.id, timestamp, chat.public_key, "
"aliases.display_name, sender.public_key, message, broken_messages.id " "aliases.display_name, sender.public_key, message, broken_messages.id "
@ -809,6 +829,10 @@ QList<History::HistMessage> History::getUndeliveredMessagesForFriend(const ToxPk
QDateTime History::getDateWhereFindPhrase(const QString& friendPk, const QDateTime& from, QDateTime History::getDateWhereFindPhrase(const QString& friendPk, const QDateTime& from,
QString phrase, const ParameterSearch& parameter) QString phrase, const ParameterSearch& parameter)
{ {
if (historyAccessBlocked()) {
return QDateTime();
}
QDateTime result; QDateTime result;
auto rowCallback = [&result](const QVector<QVariant>& row) { auto rowCallback = [&result](const QVector<QVariant>& row) {
result = QDateTime::fromMSecsSinceEpoch(row[0].toLongLong()); result = QDateTime::fromMSecsSinceEpoch(row[0].toLongLong());
@ -903,6 +927,10 @@ QList<History::DateIdx> History::getNumMessagesForFriendBeforeDateBoundaries(con
const QDate& from, const QDate& from,
size_t maxNum) size_t maxNum)
{ {
if (historyAccessBlocked()) {
return {};
}
auto friendPkString = friendPk.toString(); auto friendPkString = friendPk.toString();
// No guarantee that this is the most efficient way to do this... // No guarantee that this is the most efficient way to do this...
@ -954,9 +982,29 @@ QList<History::DateIdx> History::getNumMessagesForFriendBeforeDateBoundaries(con
*/ */
void History::markAsDelivered(RowId messageId) void History::markAsDelivered(RowId messageId)
{ {
if (!isValid()) { if (historyAccessBlocked()) {
return; return;
} }
db->execLater(QString("DELETE FROM faux_offline_pending WHERE id=%1;").arg(messageId.get())); db->execLater(QString("DELETE FROM faux_offline_pending WHERE id=%1;").arg(messageId.get()));
} }
/**
* @brief Determines if history access should be blocked
* @return True if history should not be accessed
*/
bool History::historyAccessBlocked()
{
if (!Settings::getInstance().getEnableLogging()) {
assert(false);
qCritical() << "Blocked history access while history is disabled";
return true;
}
if (!isValid()) {
return true;
}
return false;
}

View File

@ -201,6 +201,7 @@ private slots:
void onFileInserted(RowId dbId, QString fileId); void onFileInserted(RowId dbId, QString fileId);
private: private:
bool historyAccessBlocked();
static RawDatabase::Query generateFileFinished(RowId fileId, bool success, static RawDatabase::Query generateFileFinished(RowId fileId, bool success,
const QString& filePath, const QByteArray& fileHash); const QString& filePath, const QByteArray& fileHash);
std::shared_ptr<RawDatabase> db; std::shared_ptr<RawDatabase> db;

View File

@ -23,6 +23,7 @@
#include "src/nexus.h" #include "src/nexus.h"
#include "src/persistence/profile.h" #include "src/persistence/profile.h"
#include "src/persistence/settings.h" #include "src/persistence/settings.h"
#include "src/model/status.h"
#include <QMutexLocker> #include <QMutexLocker>
#include <QTimer> #include <QTimer>
#include <QCoreApplication> #include <QCoreApplication>
@ -91,7 +92,7 @@ void OfflineMsgEngine::deliverOfflineMsgs()
{ {
QMutexLocker ml(&mutex); QMutexLocker ml(&mutex);
if (!f->isOnline()) { if (!Status::isOnline(f->getStatus())) {
return; return;
} }
@ -138,8 +139,8 @@ void OfflineMsgEngine::removeAllMessages()
void OfflineMsgEngine::completeMessage(QMap<ReceiptNum, OfflineMessage>::iterator msgIt) void OfflineMsgEngine::completeMessage(QMap<ReceiptNum, OfflineMessage>::iterator msgIt)
{ {
msgIt->completionFn(); msgIt->completionFn();
sentMessages.erase(msgIt);
receivedReceipts.removeOne(msgIt.key()); receivedReceipts.removeOne(msgIt.key());
sentMessages.erase(msgIt);
} }
void OfflineMsgEngine::checkForCompleteMessages(ReceiptNum receipt) void OfflineMsgEngine::checkForCompleteMessages(ReceiptNum receipt)

View File

@ -92,7 +92,7 @@ void AboutFriendForm::onAutoAcceptDirClicked()
void AboutFriendForm::onAutoAcceptDirChanged(const QString& path) void AboutFriendForm::onAutoAcceptDirChanged(const QString& path)
{ {
const bool enabled = path.isNull(); const bool enabled = !path.isNull();
ui->autoacceptfile->setChecked(enabled); ui->autoacceptfile->setChecked(enabled);
ui->selectSaveDir->setEnabled(enabled); ui->selectSaveDir->setEnabled(enabled);
ui->selectSaveDir->setText(enabled ? path : tr("Auto-accept for this contact is disabled")); ui->selectSaveDir->setText(enabled ? path : tr("Auto-accept for this contact is disabled"));

View File

@ -404,7 +404,7 @@ void ChatForm::updateCallButtons()
CoreAV* av = Core::getInstance()->getAv(); CoreAV* av = Core::getInstance()->getAv();
const bool audio = av->isCallActive(f); const bool audio = av->isCallActive(f);
const bool video = av->isCallVideoEnabled(f); const bool video = av->isCallVideoEnabled(f);
const bool online = f->isOnline(); const bool online = Status::isOnline(f->getStatus());
headWidget->updateCallButtons(online, audio, video); headWidget->updateCallButtons(online, audio, video);
updateMuteMicButton(); updateMuteMicButton();
updateMuteVolButton(); updateMuteVolButton();
@ -431,7 +431,7 @@ void ChatForm::onFriendStatusChanged(uint32_t friendId, Status::Status status)
return; return;
} }
if (!f->isOnline()) { if (!Status::isOnline(f->getStatus())) {
// Hide the "is typing" message when a friend goes offline // Hide the "is typing" message when a friend goes offline
setFriendTyping(false); setFriendTyping(false);
} }

View File

@ -980,6 +980,10 @@ void GenericChatForm::searchInBegin(const QString& phrase, const ParameterSearch
return; return;
} }
if (messages.size() == 0) {
return;
}
if (chatLog.getNextIdx() == messages.rbegin()->first + 1) { if (chatLog.getNextIdx() == messages.rbegin()->first + 1) {
disableSearchText(); disableSearchText();
} else { } else {

View File

@ -307,7 +307,7 @@ void GroupChatForm::dropEvent(QDropEvent* ev)
int friendId = frnd->getId(); int friendId = frnd->getId();
int groupId = group->getId(); int groupId = group->getId();
if (frnd->isOnline()) { if (Status::isOnline(frnd->getStatus())) {
Core::getInstance()->groupInviteFriend(friendId, groupId); Core::getInstance()->groupInviteFriend(friendId, groupId);
} }
} }

View File

@ -1228,7 +1228,7 @@ void Widget::onFriendStatusChanged(int friendId, Status::Status status)
FriendWidget* widget = friendWidgets[f->getPublicKey()]; FriendWidget* widget = friendWidgets[f->getPublicKey()];
if (isActualChange) { if (isActualChange) {
if (!f->isOnline()) { if (!Status::isOnline(f->getStatus())) {
contactListWidget->moveWidget(widget, Status::Status::Online); contactListWidget->moveWidget(widget, Status::Status::Online);
} else if (status == Status::Status::Offline) { } else if (status == Status::Status::Offline) {
contactListWidget->moveWidget(widget, Status::Status::Offline); contactListWidget->moveWidget(widget, Status::Status::Offline);

View File

@ -19,6 +19,7 @@
#include "src/core/core.h" #include "src/core/core.h"
#include "src/model/friend.h" #include "src/model/friend.h"
#include "src/model/status.h"
#include "src/persistence/offlinemsgengine.h" #include "src/persistence/offlinemsgengine.h"
#include <QtTest/QtTest> #include <QtTest/QtTest>
@ -35,7 +36,7 @@ public:
} }
bool sendMessage(uint32_t friendId, const QString& message, ReceiptNum& receipt) override bool sendMessage(uint32_t friendId, const QString& message, ReceiptNum& receipt) override
{ {
if (f->isOnline()) { if (Status::isOnline(f->getStatus())) {
receipt.get() = receiptNum++; receipt.get() = receiptNum++;
if (!dropReceipts) { if (!dropReceipts) {
msgs.push_back(message); msgs.push_back(message);
@ -45,7 +46,7 @@ public:
} else { } else {
numMessagesFailed++; numMessagesFailed++;
} }
return f->isOnline(); return Status::isOnline(f->getStatus());
} }
signals: signals: