attaching messages fix, bad alloc fix
This commit is contained in:
parent
6657dc79ce
commit
b50ce146b8
@ -1377,6 +1377,7 @@ void Core::Account::addNewRoom(const QString& jid, const QString& nick, const QS
|
|||||||
{"avatars", conf->getAllAvatars()}
|
{"avatars", conf->getAllAvatars()}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Archive::AvatarInfo info;
|
Archive::AvatarInfo info;
|
||||||
bool hasAvatar = conf->readAvatarInfo(info);
|
bool hasAvatar = conf->readAvatarInfo(info);
|
||||||
if (hasAvatar) {
|
if (hasAvatar) {
|
||||||
|
@ -817,15 +817,16 @@ void Core::Archive::readAllResourcesAvatars(std::map<QString, AvatarInfo>& data)
|
|||||||
mdb_txn_begin(environment, NULL, MDB_RDONLY, &txn);
|
mdb_txn_begin(environment, NULL, MDB_RDONLY, &txn);
|
||||||
mdb_cursor_open(txn, avatars, &cursor);
|
mdb_cursor_open(txn, avatars, &cursor);
|
||||||
rc = mdb_cursor_get(cursor, &lmdbKey, &lmdbData, MDB_FIRST);
|
rc = mdb_cursor_get(cursor, &lmdbKey, &lmdbData, MDB_FIRST);
|
||||||
|
if (rc == 0) { //the db might be empty yet
|
||||||
do {
|
do {
|
||||||
std::string sId((char*)lmdbKey.mv_data, lmdbKey.mv_size);
|
std::string sId((char*)lmdbKey.mv_data, lmdbKey.mv_size);
|
||||||
QString res(sId.c_str());
|
QString res(sId.c_str());
|
||||||
if (res != jid) {
|
if (res != jid) {
|
||||||
data.emplace(res, AvatarInfo());
|
data.emplace(res, AvatarInfo());
|
||||||
data[res].deserialize((char*)lmdbData.mv_data, lmdbData.mv_size);
|
data[res].deserialize((char*)lmdbData.mv_data, lmdbData.mv_size);
|
||||||
}
|
}
|
||||||
} while (mdb_cursor_get(cursor, &lmdbKey, &lmdbData, MDB_NEXT) == 0);
|
} while (mdb_cursor_get(cursor, &lmdbKey, &lmdbData, MDB_NEXT) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
mdb_cursor_close(cursor);
|
mdb_cursor_close(cursor);
|
||||||
mdb_txn_abort(txn);
|
mdb_txn_abort(txn);
|
||||||
|
@ -61,19 +61,14 @@ void Chat::updateState()
|
|||||||
statusIcon->setToolTip(Shared::Global::getName(av));
|
statusIcon->setToolTip(Shared::Global::getName(av));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Chat::handleSendMessage(const QString& text)
|
Shared::Message Chat::createMessage() const
|
||||||
{
|
{
|
||||||
Shared::Message msg(Shared::Message::chat);
|
Shared::Message msg = Conversation::createMessage();
|
||||||
|
msg.setType(Shared::Message::chat);
|
||||||
msg.setFrom(account->getFullJid());
|
msg.setFrom(account->getFullJid());
|
||||||
msg.setToJid(palJid);
|
msg.setToJid(palJid);
|
||||||
msg.setToResource(activePalResource);
|
msg.setToResource(activePalResource);
|
||||||
msg.setBody(text);
|
return msg;
|
||||||
msg.setOutgoing(true);
|
|
||||||
msg.generateRandomId();
|
|
||||||
msg.setCurrentTime();
|
|
||||||
msg.setState(Shared::Message::State::pending);
|
|
||||||
addMessage(msg);
|
|
||||||
emit sendMessage(msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Chat::addMessage(const Shared::Message& data)
|
void Chat::addMessage(const Shared::Message& data)
|
||||||
|
@ -43,7 +43,7 @@ protected slots:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setName(const QString & name) override;
|
void setName(const QString & name) override;
|
||||||
void handleSendMessage(const QString & text) override;
|
Shared::Message createMessage() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateState();
|
void updateState();
|
||||||
|
@ -208,22 +208,14 @@ void Conversation::onEnterPressed()
|
|||||||
|
|
||||||
if (body.size() > 0) {
|
if (body.size() > 0) {
|
||||||
m_ui->messageEditor->clear();
|
m_ui->messageEditor->clear();
|
||||||
handleSendMessage(body);
|
Shared::Message msg = createMessage();
|
||||||
|
msg.setBody(body);
|
||||||
|
addMessage(msg);
|
||||||
|
emit sendMessage(msg);
|
||||||
}
|
}
|
||||||
if (filesToAttach.size() > 0) {
|
if (filesToAttach.size() > 0) {
|
||||||
for (Badge* badge : filesToAttach) {
|
for (Badge* badge : filesToAttach) {
|
||||||
Shared::Message msg;
|
Shared::Message msg = createMessage();
|
||||||
if (isMuc) {
|
|
||||||
msg.setType(Shared::Message::groupChat);
|
|
||||||
} else {
|
|
||||||
msg.setType(Shared::Message::chat);
|
|
||||||
msg.setToResource(activePalResource);
|
|
||||||
}
|
|
||||||
msg.setFrom(account->getFullJid());
|
|
||||||
msg.setToJid(palJid);
|
|
||||||
msg.setOutgoing(true);
|
|
||||||
msg.generateRandomId();
|
|
||||||
msg.setCurrentTime();
|
|
||||||
line->appendMessageWithUpload(msg, badge->id);
|
line->appendMessageWithUpload(msg, badge->id);
|
||||||
usleep(1000); //this is required for the messages not to have equal time when appending into messageline
|
usleep(1000); //this is required for the messages not to have equal time when appending into messageline
|
||||||
}
|
}
|
||||||
@ -486,6 +478,16 @@ void Conversation::dropEvent(QDropEvent* event)
|
|||||||
overlay->hide();
|
overlay->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Shared::Message Conversation::createMessage() const
|
||||||
|
{
|
||||||
|
Shared::Message msg;
|
||||||
|
msg.setOutgoing(true);
|
||||||
|
msg.generateRandomId();
|
||||||
|
msg.setCurrentTime();
|
||||||
|
msg.setState(Shared::Message::State::pending);
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
bool VisibilityCatcher::eventFilter(QObject* obj, QEvent* event)
|
bool VisibilityCatcher::eventFilter(QObject* obj, QEvent* event)
|
||||||
{
|
{
|
||||||
if (event->type() == QEvent::Show) {
|
if (event->type() == QEvent::Show) {
|
||||||
|
@ -102,7 +102,7 @@ signals:
|
|||||||
protected:
|
protected:
|
||||||
virtual void setName(const QString& name);
|
virtual void setName(const QString& name);
|
||||||
void applyVisualEffects();
|
void applyVisualEffects();
|
||||||
virtual void handleSendMessage(const QString& text) = 0;
|
virtual Shared::Message createMessage() const;
|
||||||
void setStatus(const QString& status);
|
void setStatus(const QString& status);
|
||||||
void addAttachedFile(const QString& path);
|
void addAttachedFile(const QString& path);
|
||||||
void removeAttachedFile(Badge* badge);
|
void removeAttachedFile(Badge* badge);
|
||||||
|
@ -46,20 +46,14 @@ Room::~Room()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Room::handleSendMessage(const QString& text)
|
Shared::Message Room::createMessage() const
|
||||||
{
|
{
|
||||||
Shared::Message msg(Shared::Message::groupChat);
|
Shared::Message msg = Conversation::createMessage();
|
||||||
|
msg.setType(Shared::Message::groupChat);
|
||||||
msg.setFromJid(room->getJid());
|
msg.setFromJid(room->getJid());
|
||||||
msg.setFromResource(room->getNick());
|
msg.setFromResource(room->getNick());
|
||||||
msg.setToJid(palJid);
|
msg.setToJid(palJid);
|
||||||
//msg.setToResource(activePalResource);
|
return msg;
|
||||||
msg.setBody(text);
|
|
||||||
msg.setOutgoing(true);
|
|
||||||
msg.generateRandomId();
|
|
||||||
msg.setCurrentTime();
|
|
||||||
msg.setState(Shared::Message::State::pending);
|
|
||||||
addMessage(msg);
|
|
||||||
emit sendMessage(msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Room::autoJoined() const
|
bool Room::autoJoined() const
|
||||||
|
@ -40,7 +40,7 @@ protected slots:
|
|||||||
void onParticipantLeft(const QString& name);
|
void onParticipantLeft(const QString& name);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void handleSendMessage(const QString & text) override;
|
Shared::Message createMessage() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Models::Room* room;
|
Models::Room* room;
|
||||||
|
Loading…
Reference in New Issue
Block a user