Skip to content

Commit

Permalink
add default avatar automatically at initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
emonq committed Sep 1, 2021
1 parent 217b1be commit 1ad9727
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion XMYChatServer/xmy_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ bool XMY_database::init_db()
QSqlQuery query;
query.exec("DROP TABLE users");
query.prepare("CREATE TABLE users(u_email TEXT PRIMARY KEY, u_password TEXT NOT NULL, u_username TEXT, is_banned INT DEFAULT 0, is_waiting_verification INT NOT NULL DEFAULT 1, u_verification_code INT, u_friends TEXT)");
// query.bindValue(":avatar",default_avatar);
if(!query.exec()) {
emit new_log(query.lastError().text());
return false;
Expand Down
2 changes: 1 addition & 1 deletion XMYChatServer/xmy_database.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef XMY_DATABASE_H
#define XMY_DATABASE_H

#define DB_FILE "test.db"
#define DB_FILE "xmychat.db"

#include "../XMYChatShare/xmy_basic.h"

Expand Down
5 changes: 5 additions & 0 deletions XMYChatServer/xmy_tcpserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ XMY_tcpserver::XMY_tcpserver(QObject *parent) : QTcpServer(parent)
{
db=new XMY_database;
connect(db,&XMY_database::new_log,this,&XMY_tcpserver::new_log);
if(!QFile(".avatar\\default.png").exists()) {
QString default_avatar="iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAIAAAD2HxkiAAAM0klEQVR4nO3dbW/ixhqAYZc5dWoEgtqBvIgNK0Xa//97NtooqCkQiCmU1Oxanep8sLTdbjbJ2Nh+Zuz7+nSkI3UfRb494xfgp81m4wGQ05EeAGg7IgSEESEgjAgBYUQICCNCQBgRAsKIEBBGhIAwIgSEESEgjAgBYUQICCNCQBgRAsKIEBBGhIAwIgSEESEgjAgBYUQICCNCQBgRAsKIEBBGhIAwIgSEESEgjAgBYUQICCNC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Kz0F3HN3d+fEl5U4EOFsNuNRBIq5v7+XHuFttkc4n8+5F4rCDoeD/ReHVkeYpul6vZaeAm5bLpeWv1FsdYSO/tA0bLNYLKRHeI29EWqteS8UpYjj2Oazub0R8mooSvTw8CA9wovsjXC320mPgOaw+XCyNEKtNTdFUaLD4WDtxsrSCG0+b8FR1h5Ulkb4+fNn6RHQNNYeVJZG+PT0JD0Cmsbag8rSCIH2sDRCa6+h4S5rDypLI+TWKEpn7UFlaYRAexAhIIwIAWGWRtjpWDoY3GXtQWXpWG34VTrUzNqDytIIgfawNEJrT1pwl7UHlaURuviLArCctQeVpRE693MCsJ+1B5WlEfq+HwSB9BRojiAIWAlzc/2XH2EVmw8nqyO09sEO3NLpdIiwCKXU1dWV9BRogqurK6WU9BQvsjdCz/PCMOz1etJTwG29Xi8MQ+kpXmN1hJ7nXV9fc4cGhQVBcH19LT3FG2yPUCn14cMHOkQBQRB8+PDB5o1oxvYIPc9TSrEeIi9XCvTc+rns+Xy+XC6lp4ADzs/PLy8vpacw5VKEnuclSbJer+M4lh4EloqiaDQaWfua6A85FmEmTdPVavX4+PjPP/9IzwIrdDqd09PT8Xhs7Wsxr3Aywq/SNH16etrv91++fPEs/mJJlC57dnVyctLv93u9novtfeV2hEADOHB3FGg2IgSEESEgjAgBYUQICCNCQBgRAsKIEBBGhIAwIgSEESEgjAgBYUQICCNCQBgRAsKIEBBGhIAwIgSEESEgjAgBYUQICCNCQBgRAsKIEBBGhIAwIgSEESEgjAgBYUQICCNCQBgRAsKIEBBGhIAwIgSEESEgjAgBYUQICCNCQBgRAsKIEBBGhIAwIgSEESEgjAgBYUQICCNCQBgRAsKIEBD2fz0a4i5T03AEAAAAAElFTkSuQmCC";
XMY_Utilities::checkDir(".avatar");
XMY_Utilities::save_pic_from_base64(default_avatar,".avatar\\default.png");
}
}

QList<QHostAddress> XMY_tcpserver::get_addr()
Expand Down
2 changes: 1 addition & 1 deletion XMYChatShare/xmy_utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ bool XMY_Utilities::checkDir(QString path)
if(dir.exists()) {
return true;
}
else return dir.mkpath(path);
else return QDir(".").mkpath(path);
}

void XMY_Utilities::save_pic_from_base64(QString base64, QString filename)
Expand Down

0 comments on commit 1ad9727

Please sign in to comment.