mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
cleanup
This commit is contained in:
parent
b0ef7e8152
commit
02092c9a90
@ -63,8 +63,31 @@ HistoryKeeper::HistoryKeeper(const QString &path, bool encr) :
|
|||||||
db.open();
|
db.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
DB format
|
||||||
|
chats:
|
||||||
|
* name -> id map
|
||||||
|
id -- auto-incrementing number
|
||||||
|
name -- chat's name (for user to user conversation it is opposite user public key)
|
||||||
|
ctype -- chat type, reserved for group chats
|
||||||
|
|
||||||
|
alisases:
|
||||||
|
* user_id -> id map
|
||||||
|
id -- auto-incrementing number
|
||||||
|
name -- user's public key
|
||||||
|
|
||||||
|
history:
|
||||||
|
id -- auto-incrementing number
|
||||||
|
timestamp
|
||||||
|
profile_id -- profile ID (resolves from aliases table)
|
||||||
|
chat_id -- current chat ID (resolves from chats table)
|
||||||
|
sender -- sender's ID (resolves from aliases table)
|
||||||
|
mtype -- type of message (message, action, etc) (UNUSED now)
|
||||||
|
message
|
||||||
|
*/
|
||||||
|
|
||||||
db.exec(QString("CREATE TABLE IF NOT EXISTS history (id INTEGER PRIMARY KEY AUTOINCREMENT, timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, ") +
|
db.exec(QString("CREATE TABLE IF NOT EXISTS history (id INTEGER PRIMARY KEY AUTOINCREMENT, timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, ") +
|
||||||
QString("profile_id INTEGER NOT NULL, chat_id INTEGER NOT NULL, sender INTERGER NOT NULL, message TEXT NOT NULL);"));
|
QString("profile_id INTEGER NOT NULL, chat_id INTEGER NOT NULL, sender INTERGER NOT NULL, mtype INTEGER NOT NULL, message TEXT NOT NULL);"));
|
||||||
db.exec(QString("CREATE TABLE IF NOT EXISTS aliases (id INTEGER PRIMARY KEY AUTOINCREMENT, user_id TEXT UNIQUE NOT NULL);"));
|
db.exec(QString("CREATE TABLE IF NOT EXISTS aliases (id INTEGER PRIMARY KEY AUTOINCREMENT, user_id TEXT UNIQUE NOT NULL);"));
|
||||||
db.exec(QString("CREATE TABLE IF NOT EXISTS chats (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT UNIQUE NOT NULL, ctype INTEGER NOT NULL);"));
|
db.exec(QString("CREATE TABLE IF NOT EXISTS chats (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT UNIQUE NOT NULL, ctype INTEGER NOT NULL);"));
|
||||||
|
|
||||||
@ -83,7 +106,7 @@ void HistoryKeeper::addChatEntry(const QString& chat, const QString& message, co
|
|||||||
int sender_id = getAliasID(sender);
|
int sender_id = getAliasID(sender);
|
||||||
int profile_id = getCurrentProfileID();
|
int profile_id = getCurrentProfileID();
|
||||||
|
|
||||||
db.exec(QString("INSERT INTO history (profile_id, chat_id, sender, message) VALUES (%1, %2, %3, '%4');")
|
db.exec(QString("INSERT INTO history (profile_id, chat_id, sender, mtype, message) VALUES (%1, %2, %3, 0, '%4');")
|
||||||
.arg(profile_id).arg(chat_id).arg(sender_id).arg(wrapMessage(message)));
|
.arg(profile_id).arg(chat_id).arg(sender_id).arg(wrapMessage(message)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +244,7 @@ void HistoryKeeper::syncToDisk()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// encryption there
|
// encryption here
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
// warning
|
// warning
|
||||||
|
@ -184,8 +184,3 @@ void ChatAreaWidget::clearChatArea()
|
|||||||
insertMessage(message);
|
insertMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatAreaWidget::rerenderContent()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -31,7 +31,6 @@ public:
|
|||||||
virtual ~ChatAreaWidget();
|
virtual ~ChatAreaWidget();
|
||||||
void insertMessage(ChatAction *msgAction);
|
void insertMessage(ChatAction *msgAction);
|
||||||
QList<ChatAction*>& getMesages() {return messages;}
|
QList<ChatAction*>& getMesages() {return messages;}
|
||||||
void rerenderContent();
|
|
||||||
|
|
||||||
int nameColWidth() {return nameWidth;}
|
int nameColWidth() {return nameWidth;}
|
||||||
void setNameColWidth(int w);
|
void setNameColWidth(int w);
|
||||||
|
@ -228,7 +228,7 @@ void GenericChatForm::clearChatArea(bool notinform)
|
|||||||
previousName = "";
|
previousName = "";
|
||||||
|
|
||||||
if (!notinform)
|
if (!notinform)
|
||||||
addSystemInfoMessage(tr("Cleared"), "green");
|
addSystemInfoMessage(tr("Cleared"), "white");
|
||||||
|
|
||||||
if (earliestMessage)
|
if (earliestMessage)
|
||||||
{
|
{
|
||||||
|
@ -13,11 +13,14 @@
|
|||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Load History Dialog</string>
|
<string>Load History Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="modal">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="fromLabel">
|
<widget class="QLabel" name="fromLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>From Date</string>
|
<string>Load history from:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -23,21 +23,6 @@ ActionAction::ActionAction(const QString &author, const QString &message, const
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionAction::setup(QTextCursor cursor, QTextEdit *)
|
|
||||||
{
|
|
||||||
// When this function is called, we're supposed to only update ourselve when needed
|
|
||||||
// Nobody should ask us to do anything with our content, we're on our own
|
|
||||||
// Except we never udpate on our own, so we can safely free our resources
|
|
||||||
|
|
||||||
(void) cursor;
|
|
||||||
// message.clear();
|
|
||||||
// message.squeeze();
|
|
||||||
// name.clear();
|
|
||||||
// name.squeeze();
|
|
||||||
// date.clear();
|
|
||||||
// date.squeeze();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ActionAction::getName()
|
QString ActionAction::getName()
|
||||||
{
|
{
|
||||||
return QString("<div class=action>*</div>");
|
return QString("<div class=action>*</div>");
|
||||||
|
@ -26,7 +26,7 @@ public:
|
|||||||
virtual ~ActionAction(){;}
|
virtual ~ActionAction(){;}
|
||||||
virtual QString getMessage();
|
virtual QString getMessage();
|
||||||
virtual QString getName();
|
virtual QString getName();
|
||||||
virtual void setup(QTextCursor cursor, QTextEdit*) override;
|
virtual void setup(QTextCursor, QTextEdit*) override {;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString message;
|
QString message;
|
||||||
|
@ -74,17 +74,6 @@ void FileTransferAction::updateHtml()
|
|||||||
|
|
||||||
// restore old slider value
|
// restore old slider value
|
||||||
edit->verticalScrollBar()->setValue(vSliderVal);
|
edit->verticalScrollBar()->setValue(vSliderVal);
|
||||||
|
|
||||||
// Free our ressources if we'll never need to update again
|
|
||||||
if (w->getState() == FileTransferInstance::TransfState::tsCanceled
|
|
||||||
|| w->getState() == FileTransferInstance::TransfState::tsFinished)
|
|
||||||
{
|
|
||||||
// name.clear();
|
|
||||||
// name.squeeze();
|
|
||||||
// date.clear();
|
|
||||||
// date.squeeze();
|
|
||||||
// cur = QTextCursor();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileTransferAction::isInteractive()
|
bool FileTransferAction::isInteractive()
|
||||||
|
@ -23,21 +23,6 @@ MessageAction::MessageAction(const QString &author, const QString &message, cons
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageAction::setup(QTextCursor cursor, QTextEdit *)
|
|
||||||
{
|
|
||||||
// When this function is called, we're supposed to only update ourselve when needed
|
|
||||||
// Nobody should ask us to do anything with our content, we're on our own
|
|
||||||
// Except we never udpate on our own, so we can safely free our resources
|
|
||||||
|
|
||||||
(void) cursor;
|
|
||||||
// message.clear();
|
|
||||||
// message.squeeze();
|
|
||||||
// name.clear();
|
|
||||||
// name.squeeze();
|
|
||||||
// date.clear();
|
|
||||||
// date.squeeze();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString MessageAction::getMessage()
|
QString MessageAction::getMessage()
|
||||||
{
|
{
|
||||||
QString message_ = SmileyPack::getInstance().smileyfied(toHtmlChars(message));
|
QString message_ = SmileyPack::getInstance().smileyfied(toHtmlChars(message));
|
||||||
|
@ -25,7 +25,7 @@ public:
|
|||||||
MessageAction(const QString &author, const QString &message, const QString &date, const bool &me);
|
MessageAction(const QString &author, const QString &message, const QString &date, const bool &me);
|
||||||
virtual ~MessageAction(){;}
|
virtual ~MessageAction(){;}
|
||||||
virtual QString getMessage();
|
virtual QString getMessage();
|
||||||
virtual void setup(QTextCursor cursor, QTextEdit*) override;
|
virtual void setup(QTextCursor, QTextEdit*) override {;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString message;
|
QString message;
|
||||||
|
@ -27,20 +27,3 @@ QString SystemMessageAction::getMessage()
|
|||||||
{
|
{
|
||||||
return QString("<table width=100%><tr><td align=center><div class=" + type + ">" + message + "</td><tr></div></table>");
|
return QString("<table width=100%><tr><td align=center><div class=" + type + ">" + message + "</td><tr></div></table>");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemMessageAction::setup(QTextCursor cursor, QTextEdit *)
|
|
||||||
{
|
|
||||||
// When this function is called, we're supposed to only update ourselve when needed
|
|
||||||
// Nobody should ask us to do anything with our content, we're on our own
|
|
||||||
// Except we never udpate on our own, so we can safely free our resources
|
|
||||||
|
|
||||||
(void) cursor;
|
|
||||||
// message.clear();
|
|
||||||
// message.squeeze();
|
|
||||||
// name.clear();
|
|
||||||
// name.squeeze();
|
|
||||||
// date.clear();
|
|
||||||
// date.squeeze();
|
|
||||||
// type.clear();
|
|
||||||
// type.squeeze();
|
|
||||||
}
|
|
||||||
|
@ -24,7 +24,7 @@ class SystemMessageAction : public ChatAction
|
|||||||
public:
|
public:
|
||||||
SystemMessageAction(const QString &message, const QString& type, const QString &date);
|
SystemMessageAction(const QString &message, const QString& type, const QString &date);
|
||||||
virtual ~SystemMessageAction(){;}
|
virtual ~SystemMessageAction(){;}
|
||||||
virtual void setup(QTextCursor cursor, QTextEdit*) override;
|
virtual void setup(QTextCursor, QTextEdit*) override {;}
|
||||||
|
|
||||||
virtual QString getName() {return QString();}
|
virtual QString getName() {return QString();}
|
||||||
virtual QString getMessage();
|
virtual QString getMessage();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user