qTox
Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
|
Interacts with the profile database to save the chat history. More...
#include <history.h>
Classes | |
struct | DateIdx |
struct | FileInfo |
struct | HistMessage |
Signals | |
void | fileInserted (RowId dbId, QString fileId) |
Public Member Functions | |
History (std::shared_ptr< RawDatabase > db) | |
Prepares the database to work with the history. More... | |
~History () | |
bool | isValid () |
Checks if the database was opened successfully. More... | |
bool | historyExists (const ToxPk &friendPk) |
Checks if a friend has chat history. More... | |
void | eraseHistory () |
Erases all the chat history from the database. More... | |
void | removeFriendHistory (const ToxPk &friendPk) |
Erases the chat history with one friend. More... | |
void | addNewMessage (const ToxPk &friendPk, const QString &message, const ToxPk &sender, const QDateTime &time, bool isDelivered, ExtensionSet extensions, QString dispName, const std::function< void(RowId)> &insertIdCallback={}) |
Saves a chat message in the database. More... | |
void | addNewFileMessage (const ToxPk &friendPk, const QString &fileId, const QString &fileName, const QString &filePath, int64_t size, const ToxPk &sender, const QDateTime &time, QString const &dispName) |
void | addNewSystemMessage (const ToxPk &friendPk, const SystemMessage &systemMessage) |
void | setFileFinished (const QString &fileId, bool success, const QString &filePath, const QByteArray &fileHash) |
size_t | getNumMessagesForFriend (const ToxPk &friendPk) |
size_t | getNumMessagesForFriendBeforeDate (const ToxPk &friendPk, const QDateTime &date) |
QList< HistMessage > | getMessagesForFriend (const ToxPk &friendPk, size_t firstIdx, size_t lastIdx) |
QList< HistMessage > | getUndeliveredMessagesForFriend (const ToxPk &friendPk) |
QDateTime | getDateWhereFindPhrase (const ToxPk &friendPk, const QDateTime &from, QString phrase, const ParameterSearch ¶meter) |
Search phrase in chat messages. More... | |
QList< DateIdx > | getNumMessagesForFriendBeforeDateBoundaries (const ToxPk &friendPk, const QDate &from, size_t maxNum) |
Gets date boundaries in conversation with friendPk. History doesn't model conversation indexes, but we can count messages between us and friendPk to effectively give us an index. This function returns how many messages have happened between us <-> friendPk each time the date changes. More... | |
void | markAsDelivered (RowId messageId) |
Marks a message as delivered. Removing message from the faux-offline pending messages list. More... | |
void | markAsBroken (RowId messageId, BrokenMessageReason reason) |
Private Slots | |
void | onFileInserted (RowId dbId, QString fileId) |
Private Member Functions | |
QVector< RawDatabase::Query > | generateNewFileTransferQueries (const ToxPk &friendPk, const ToxPk &sender, const QDateTime &time, const QString &dispName, const FileDbInsertionData &insertionData) |
bool | historyAccessBlocked () |
Determines if history access should be blocked. More... | |
int64_t | getPeerId (ToxPk const &pk) |
Static Private Member Functions | |
static RawDatabase::Query | generateFileFinished (RowId fileId, bool success, const QString &filePath, const QByteArray &fileHash) |
Private Attributes | |
std::shared_ptr< RawDatabase > | db |
QHash< QString, FileInfo > | fileInfos |
Interacts with the profile database to save the chat history.
|
explicit |
Prepares the database to work with the history.
db | This database will be prepared for use with the history. |
Definition at line 710 of file history.cpp.
History::~History | ( | ) |
void History::addNewFileMessage | ( | const ToxPk & | friendPk, |
const QString & | fileId, | ||
const QString & | fileName, | ||
const QString & | filePath, | ||
int64_t | size, | ||
const ToxPk & | sender, | ||
const QDateTime & | time, | ||
QString const & | dispName | ||
) |
Definition at line 915 of file history.cpp.
void History::addNewMessage | ( | const ToxPk & | friendPk, |
const QString & | message, | ||
const ToxPk & | sender, | ||
const QDateTime & | time, | ||
bool | isDelivered, | ||
ExtensionSet | extensionSet, | ||
QString | dispName, | ||
const std::function< void(RowId)> & | insertIdCallback = {} |
||
) |
Saves a chat message in the database.
friendPk | Friend publick key to save. |
message | Message to save. |
sender | Sender to save. |
time | Time of message sending. |
isDelivered | True if message was already delivered. |
dispName | Name, which should be displayed. |
insertIdCallback | Function, called after query execution. |
Definition at line 977 of file history.cpp.
void History::addNewSystemMessage | ( | const ToxPk & | friendPk, |
const SystemMessage & | systemMessage | ||
) |
Definition at line 957 of file history.cpp.
void History::eraseHistory | ( | ) |
Erases all the chat history from the database.
Definition at line 771 of file history.cpp.
|
signal |
|
staticprivate |
|
private |
QDateTime History::getDateWhereFindPhrase | ( | const ToxPk & | friendPk, |
const QDateTime & | from, | ||
QString | phrase, | ||
const ParameterSearch & | parameter | ||
) |
Search phrase in chat messages.
friendPk | Friend public key |
from | a date message where need to start a search |
phrase | what need to find |
parameter | for search |
Definition at line 1211 of file history.cpp.
QList< History::HistMessage > History::getMessagesForFriend | ( | const ToxPk & | friendPk, |
size_t | firstIdx, | ||
size_t | lastIdx | ||
) |
Definition at line 1046 of file history.cpp.
size_t History::getNumMessagesForFriend | ( | const ToxPk & | friendPk | ) |
Definition at line 1009 of file history.cpp.
size_t History::getNumMessagesForFriendBeforeDate | ( | const ToxPk & | friendPk, |
const QDateTime & | date | ||
) |
Definition at line 1018 of file history.cpp.
QList< History::DateIdx > History::getNumMessagesForFriendBeforeDateBoundaries | ( | const ToxPk & | friendPk, |
const QDate & | from, | ||
size_t | maxNum | ||
) |
Gets date boundaries in conversation with friendPk. History doesn't model conversation indexes, but we can count messages between us and friendPk to effectively give us an index. This function returns how many messages have happened between us <-> friendPk each time the date changes.
[in] | friendPk | ToxPk of conversation to retrieve |
[in] | from | Start date to look from |
[in] | maxNum | Maximum number of date boundaries to retrieve |
Definition at line 1313 of file history.cpp.
|
private |
QList< History::HistMessage > History::getUndeliveredMessagesForFriend | ( | const ToxPk & | friendPk | ) |
Definition at line 1158 of file history.cpp.
|
private |
Determines if history access should be blocked.
Definition at line 1387 of file history.cpp.
bool History::historyExists | ( | const ToxPk & | friendPk | ) |
Checks if a friend has chat history.
friendPk |
Definition at line 759 of file history.cpp.
bool History::isValid | ( | ) |
Checks if the database was opened successfully.
Definition at line 749 of file history.cpp.
void History::markAsBroken | ( | RowId | messageId, |
BrokenMessageReason | reason | ||
) |
Definition at line 1402 of file history.cpp.
void History::markAsDelivered | ( | RowId | messageId | ) |
Marks a message as delivered. Removing message from the faux-offline pending messages list.
id | Message ID. |
Definition at line 1374 of file history.cpp.
|
privateslot |
Definition at line 833 of file history.cpp.
void History::removeFriendHistory | ( | const ToxPk & | friendPk | ) |
Erases the chat history with one friend.
friendPk | Friend public key to erase. |
Definition at line 792 of file history.cpp.
void History::setFileFinished | ( | const QString & | fileId, |
bool | success, | ||
const QString & | filePath, | ||
const QByteArray & | fileHash | ||
) |
Definition at line 989 of file history.cpp.
|
private |