Code cleanup.
This commit is contained in:
parent
7dd9132176
commit
febff558fd
|
@ -34,9 +34,6 @@ Controller::~Controller() {
|
||||||
|
|
||||||
void Controller::login() {
|
void Controller::login() {
|
||||||
if (!isLogin) {
|
if (!isLogin) {
|
||||||
qDebug() << "UserID:" << userID;
|
|
||||||
qDebug() << "Token:" << token;
|
|
||||||
|
|
||||||
m_connection->setHomeserver(QUrl(homeserver));
|
m_connection->setHomeserver(QUrl(homeserver));
|
||||||
m_connection->connectWithToken(userID, token, "");
|
m_connection->connectWithToken(userID, token, "");
|
||||||
}
|
}
|
||||||
|
@ -45,29 +42,22 @@ void Controller::login() {
|
||||||
void Controller::loginWithCredentials(QString serverAddr, QString user,
|
void Controller::loginWithCredentials(QString serverAddr, QString user,
|
||||||
QString pass) {
|
QString pass) {
|
||||||
if (!isLogin) {
|
if (!isLogin) {
|
||||||
qDebug() << "Server:" << serverAddr;
|
|
||||||
qDebug() << "User:" << user;
|
|
||||||
qDebug() << "Pass:" << pass;
|
|
||||||
|
|
||||||
if (!user.isEmpty() && !pass.isEmpty()) {
|
if (!user.isEmpty() && !pass.isEmpty()) {
|
||||||
qDebug() << "Using given credential.";
|
|
||||||
m_connection->setHomeserver(QUrl(serverAddr));
|
m_connection->setHomeserver(QUrl(serverAddr));
|
||||||
m_connection->connectToServer(user, pass, "");
|
m_connection->connectToServer(user, pass, "");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "You are already logged in.";
|
qCritical() << "You are already logged in.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::logout() {
|
void Controller::logout() {
|
||||||
qDebug() << "Logging out.";
|
|
||||||
setUserID("");
|
setUserID("");
|
||||||
setToken("");
|
setToken("");
|
||||||
setIsLogin(false);
|
setIsLogin(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::connected() {
|
void Controller::connected() {
|
||||||
qDebug() << "Logged in.";
|
|
||||||
setHomeserver(m_connection->homeserver().toString());
|
setHomeserver(m_connection->homeserver().toString());
|
||||||
setUserID(m_connection->userId());
|
setUserID(m_connection->userId());
|
||||||
setToken(m_connection->accessToken());
|
setToken(m_connection->accessToken());
|
||||||
|
@ -77,7 +67,6 @@ void Controller::connected() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::resync() {
|
void Controller::resync() {
|
||||||
qDebug() << "Syncing Matrix.";
|
|
||||||
m_connection->sync(30000);
|
m_connection->sync(30000);
|
||||||
m_connection->saveState();
|
m_connection->saveState();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@ void RoomListModel::setConnection(QMatrixClient::Connection* connection) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RoomListModel::doResetModel() {
|
void RoomListModel::doResetModel() {
|
||||||
qDebug() << "Resetting room list model.";
|
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
m_rooms.clear();
|
m_rooms.clear();
|
||||||
for (auto r : m_connection->roomMap()) doAddRoom(r);
|
for (auto r : m_connection->roomMap()) doAddRoom(r);
|
||||||
|
@ -51,8 +50,6 @@ void RoomListModel::doAddRoom(QMatrixClient::Room* r) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RoomListModel::connectRoomSignals(QMatrixClient::Room* room) {
|
void RoomListModel::connectRoomSignals(QMatrixClient::Room* room) {
|
||||||
qDebug() << "Connecting signal for room" << room->displayName();
|
|
||||||
|
|
||||||
connect(room, &QMatrixClient::Room::displaynameChanged, this,
|
connect(room, &QMatrixClient::Room::displaynameChanged, this,
|
||||||
[=] { namesChanged(room); });
|
[=] { namesChanged(room); });
|
||||||
connect(room, &QMatrixClient::Room::unreadMessagesChanged, this,
|
connect(room, &QMatrixClient::Room::unreadMessagesChanged, this,
|
||||||
|
|
Loading…
Reference in New Issue