2019-08-14 14:54:46 +00:00
|
|
|
/*
|
|
|
|
* Squawk messenger.
|
|
|
|
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-03-29 14:54:34 +00:00
|
|
|
#include "ui/squawk.h"
|
|
|
|
#include "core/squawk.h"
|
2019-04-02 21:58:43 +00:00
|
|
|
#include "signalcatcher.h"
|
2019-03-29 14:54:34 +00:00
|
|
|
#include <QtWidgets/QApplication>
|
|
|
|
#include <QtCore/QThread>
|
|
|
|
#include <QtCore/QObject>
|
2019-04-02 21:58:43 +00:00
|
|
|
#include <QSettings>
|
2019-10-05 11:27:39 +00:00
|
|
|
#include <QTranslator>
|
|
|
|
#include <QLibraryInfo>
|
2019-03-29 14:54:34 +00:00
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2019-04-11 14:58:59 +00:00
|
|
|
qRegisterMetaType<Shared::Message>("Shared::Message");
|
2019-05-15 17:36:37 +00:00
|
|
|
qRegisterMetaType<std::list<Shared::Message>>("std::list<Shared::Message>");
|
2019-06-15 15:29:15 +00:00
|
|
|
qRegisterMetaType<QSet<QString>>("QSet<QString>");
|
2019-04-09 22:01:25 +00:00
|
|
|
|
2019-03-29 14:54:34 +00:00
|
|
|
QApplication app(argc, argv);
|
2019-04-02 21:58:43 +00:00
|
|
|
SignalCatcher sc(&app);
|
|
|
|
|
|
|
|
QCoreApplication::setOrganizationName("Macaw");
|
|
|
|
QCoreApplication::setOrganizationDomain("macaw.me");
|
|
|
|
QCoreApplication::setApplicationName("Squawk");
|
2019-10-05 11:27:39 +00:00
|
|
|
QCoreApplication::setApplicationVersion("0.0.4");
|
|
|
|
|
|
|
|
QTranslator qtTranslator;
|
|
|
|
qtTranslator.load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
|
|
|
app.installTranslator(&qtTranslator);
|
|
|
|
|
|
|
|
QTranslator myappTranslator;
|
|
|
|
myappTranslator.load(QLocale(), QLatin1String("squawk"), ".");
|
|
|
|
app.installTranslator(&myappTranslator);
|
2019-04-02 21:58:43 +00:00
|
|
|
|
2019-06-22 20:37:22 +00:00
|
|
|
QIcon icon;
|
|
|
|
icon.addFile(":images/logo.svg", QSize(16, 16));
|
|
|
|
icon.addFile(":images/logo.svg", QSize(24, 24));
|
|
|
|
icon.addFile(":images/logo.svg", QSize(32, 32));
|
|
|
|
icon.addFile(":images/logo.svg", QSize(48, 48));
|
|
|
|
icon.addFile(":images/logo.svg", QSize(64, 64));
|
|
|
|
icon.addFile(":images/logo.svg", QSize(96, 96));
|
|
|
|
icon.addFile(":images/logo.svg", QSize(128, 128));
|
|
|
|
icon.addFile(":images/logo.svg", QSize(256, 256));
|
|
|
|
icon.addFile(":images/logo.svg", QSize(512, 512));
|
|
|
|
QApplication::setWindowIcon(icon);
|
|
|
|
|
2019-03-29 14:54:34 +00:00
|
|
|
Squawk w;
|
|
|
|
w.show();
|
|
|
|
|
|
|
|
Core::Squawk* squawk = new Core::Squawk();
|
|
|
|
QThread* coreThread = new QThread();
|
|
|
|
squawk->moveToThread(coreThread);
|
|
|
|
|
2019-03-30 20:13:13 +00:00
|
|
|
QObject::connect(coreThread, SIGNAL(started()), squawk, SLOT(start()));
|
2019-04-02 21:58:43 +00:00
|
|
|
QObject::connect(&app, SIGNAL(aboutToQuit()), squawk, SLOT(stop()));
|
|
|
|
QObject::connect(squawk, SIGNAL(quit()), coreThread, SLOT(quit()));
|
|
|
|
QObject::connect(coreThread, SIGNAL(finished()), squawk, SLOT(deleteLater()));
|
2019-03-30 20:13:13 +00:00
|
|
|
|
|
|
|
QObject::connect(&w, SIGNAL(newAccountRequest(const QMap<QString, QVariant>&)), squawk, SLOT(newAccountRequest(const QMap<QString, QVariant>&)));
|
2019-05-24 14:46:34 +00:00
|
|
|
QObject::connect(&w, SIGNAL(modifyAccountRequest(const QString&, const QMap<QString, QVariant>&)),
|
|
|
|
squawk, SLOT(modifyAccountRequest(const QString&, const QMap<QString, QVariant>&)));
|
2019-05-29 15:05:54 +00:00
|
|
|
QObject::connect(&w, SIGNAL(removeAccountRequest(const QString&)), squawk, SLOT(removeAccountRequest(const QString&)));
|
2019-03-31 21:05:09 +00:00
|
|
|
QObject::connect(&w, SIGNAL(connectAccount(const QString&)), squawk, SLOT(connectAccount(const QString&)));
|
|
|
|
QObject::connect(&w, SIGNAL(disconnectAccount(const QString&)), squawk, SLOT(disconnectAccount(const QString&)));
|
2019-04-07 20:14:15 +00:00
|
|
|
QObject::connect(&w, SIGNAL(changeState(int)), squawk, SLOT(changeState(int)));
|
2019-04-11 14:58:59 +00:00
|
|
|
QObject::connect(&w, SIGNAL(sendMessage(const QString&, const Shared::Message&)), squawk, SLOT(sendMessage(const QString&, const Shared::Message&)));
|
2019-05-24 14:46:34 +00:00
|
|
|
QObject::connect(&w, SIGNAL(requestArchive(const QString&, const QString&, int, const QString&)),
|
|
|
|
squawk, SLOT(requestArchive(const QString&, const QString&, int, const QString&)));
|
2019-06-12 17:18:18 +00:00
|
|
|
QObject::connect(&w, SIGNAL(subscribeContact(const QString&, const QString&, const QString&)),
|
|
|
|
squawk, SLOT(subscribeContact(const QString&, const QString&, const QString&)));
|
|
|
|
QObject::connect(&w, SIGNAL(unsubscribeContact(const QString&, const QString&, const QString&)),
|
|
|
|
squawk, SLOT(unsubscribeContact(const QString&, const QString&, const QString&)));
|
2019-06-15 15:29:15 +00:00
|
|
|
QObject::connect(&w, SIGNAL(addContactRequest(const QString&, const QString&, const QString&, const QSet<QString>&)),
|
|
|
|
squawk, SLOT(addContactRequest(const QString&, const QString&, const QString&, const QSet<QString>&)));
|
|
|
|
QObject::connect(&w, SIGNAL(removeContactRequest(const QString&, const QString&)),
|
|
|
|
squawk, SLOT(removeContactRequest(const QString&, const QString&)));
|
2019-08-29 14:19:35 +00:00
|
|
|
QObject::connect(&w, SIGNAL(setRoomJoined(const QString&, const QString&, bool)), squawk, SLOT(setRoomJoined(const QString&, const QString&, bool)));
|
|
|
|
QObject::connect(&w, SIGNAL(setRoomAutoJoin(const QString&, const QString&, bool)), squawk, SLOT(setRoomAutoJoin(const QString&, const QString&, bool)));
|
|
|
|
|
2019-09-03 20:28:58 +00:00
|
|
|
QObject::connect(&w, SIGNAL(removeRoomRequest(const QString&, const QString&)),
|
|
|
|
squawk, SLOT(removeRoomRequest(const QString&, const QString&)));
|
2019-09-04 16:38:52 +00:00
|
|
|
QObject::connect(&w, SIGNAL(addRoomRequest(const QString&, const QString&, const QString&, const QString&, bool)),
|
|
|
|
squawk, SLOT(addRoomRequest(const QString&, const QString&, const QString&, const QString&, bool)));
|
2019-09-12 20:54:44 +00:00
|
|
|
QObject::connect(&w, SIGNAL(fileLocalPathRequest(const QString&, const QString&)), squawk, SLOT(fileLocalPathRequest(const QString&, const QString&)));
|
2019-09-17 15:16:09 +00:00
|
|
|
QObject::connect(&w, SIGNAL(downloadFileRequest(const QString&, const QString&)), squawk, SLOT(downloadFileRequest(const QString&, const QString&)));
|
2019-09-28 14:30:16 +00:00
|
|
|
QObject::connect(&w, &Squawk::addContactToGroupRequest, squawk, &Core::Squawk::addContactToGroupRequest);
|
|
|
|
QObject::connect(&w, &Squawk::removeContactFromGroupRequest, squawk, &Core::Squawk::removeContactFromGroupRequest);
|
2019-10-01 08:47:40 +00:00
|
|
|
QObject::connect(&w, &Squawk::renameContactRequest, squawk, &Core::Squawk::renameContactRequest);
|
2019-09-03 20:28:58 +00:00
|
|
|
|
2019-03-30 20:13:13 +00:00
|
|
|
QObject::connect(squawk, SIGNAL(newAccount(const QMap<QString, QVariant>&)), &w, SLOT(newAccount(const QMap<QString, QVariant>&)));
|
2019-04-07 20:14:15 +00:00
|
|
|
QObject::connect(squawk, SIGNAL(addContact(const QString&, const QString&, const QString&, const QMap<QString, QVariant>&)),
|
|
|
|
&w, SLOT(addContact(const QString&, const QString&, const QString&, const QMap<QString, QVariant>&)));
|
2019-05-24 14:46:34 +00:00
|
|
|
QObject::connect(squawk, SIGNAL(changeAccount(const QString&, const QMap<QString, QVariant>&)),
|
|
|
|
&w, SLOT(changeAccount(const QString&, const QMap<QString, QVariant>&)));
|
2019-05-29 15:05:54 +00:00
|
|
|
QObject::connect(squawk, SIGNAL(removeAccount(const QString&)), &w, SLOT(removeAccount(const QString&)));
|
2019-04-03 21:23:51 +00:00
|
|
|
QObject::connect(squawk, SIGNAL(addGroup(const QString&, const QString&)), &w, SLOT(addGroup(const QString&, const QString&)));
|
|
|
|
QObject::connect(squawk, SIGNAL(removeGroup(const QString&, const QString&)), &w, SLOT(removeGroup(const QString&, const QString&)));
|
2019-04-06 10:14:32 +00:00
|
|
|
QObject::connect(squawk, SIGNAL(removeContact(const QString&, const QString&)), &w, SLOT(removeContact(const QString&, const QString&)));
|
|
|
|
QObject::connect(squawk, SIGNAL(removeContact(const QString&, const QString&, const QString&)), &w, SLOT(removeContact(const QString&, const QString&, const QString&)));
|
2019-04-07 20:14:15 +00:00
|
|
|
QObject::connect(squawk, SIGNAL(changeContact(const QString&, const QString&, const QMap<QString, QVariant>&)),
|
|
|
|
&w, SLOT(changeContact(const QString&, const QString&, const QMap<QString, QVariant>&)));
|
2019-04-07 14:02:41 +00:00
|
|
|
QObject::connect(squawk, SIGNAL(addPresence(const QString&, const QString&, const QString&, const QMap<QString, QVariant>&)),
|
|
|
|
&w, SLOT(addPresence(const QString&, const QString&, const QString&, const QMap<QString, QVariant>&)));
|
|
|
|
QObject::connect(squawk, SIGNAL(removePresence(const QString&, const QString&, const QString&)), &w, SLOT(removePresence(const QString&, const QString&, const QString&)));
|
2019-04-07 20:14:15 +00:00
|
|
|
QObject::connect(squawk, SIGNAL(stateChanged(int)), &w, SLOT(stateChanged(int)));
|
2019-04-11 14:58:59 +00:00
|
|
|
QObject::connect(squawk, SIGNAL(accountMessage(const QString&, const Shared::Message&)), &w, SLOT(accountMessage(const QString&, const Shared::Message&)));
|
2019-05-15 17:36:37 +00:00
|
|
|
QObject::connect(squawk, SIGNAL(responseArchive(const QString&, const QString&, const std::list<Shared::Message>&)),
|
|
|
|
&w, SLOT(responseArchive(const QString&, const QString&, const std::list<Shared::Message>&)));
|
2019-03-30 20:13:13 +00:00
|
|
|
|
2019-07-11 08:51:52 +00:00
|
|
|
QObject::connect(squawk, SIGNAL(addRoom(const QString&, const QString&, const QMap<QString, QVariant>&)),
|
|
|
|
&w, SLOT(addRoom(const QString&, const QString&, const QMap<QString, QVariant>&)));
|
|
|
|
QObject::connect(squawk, SIGNAL(changeRoom(const QString&, const QString&, const QMap<QString, QVariant>&)),
|
|
|
|
&w, SLOT(changeRoom(const QString&, const QString&, const QMap<QString, QVariant>&)));
|
|
|
|
QObject::connect(squawk, SIGNAL(removeRoom(const QString&, const QString&)), &w, SLOT(removeRoom(const QString&, const QString&)));
|
2019-09-02 11:17:28 +00:00
|
|
|
QObject::connect(squawk, SIGNAL(addRoomParticipant(const QString&, const QString&, const QString&, const QMap<QString, QVariant>&)),
|
|
|
|
&w, SLOT(addRoomParticipant(const QString&, const QString&, const QString&, const QMap<QString, QVariant>&)));
|
|
|
|
QObject::connect(squawk, SIGNAL(changeRoomParticipant(const QString&, const QString&, const QString&, const QMap<QString, QVariant>&)),
|
|
|
|
&w, SLOT(changeRoomParticipant(const QString&, const QString&, const QString&, const QMap<QString, QVariant>&)));
|
|
|
|
QObject::connect(squawk, SIGNAL(removeRoomParticipant(const QString&, const QString&, const QString&)),
|
|
|
|
&w, SLOT(removeRoomParticipant(const QString&, const QString&, const QString&)));
|
2019-09-12 20:54:44 +00:00
|
|
|
QObject::connect(squawk, SIGNAL(fileLocalPathResponse(const QString&, const QString&)), &w, SLOT(fileLocalPathResponse(const QString&, const QString&)));
|
2019-09-17 15:16:09 +00:00
|
|
|
QObject::connect(squawk, SIGNAL(downloadFileProgress(const QString&, qreal)), &w, SLOT(downloadFileProgress(const QString&, qreal)));
|
2019-09-18 13:27:47 +00:00
|
|
|
QObject::connect(squawk, SIGNAL(downloadFileError(const QString&, const QString&)), &w, SLOT(downloadFileError(const QString&, const QString&)));
|
2019-09-12 20:54:44 +00:00
|
|
|
|
2019-07-11 08:51:52 +00:00
|
|
|
|
2019-04-14 20:37:02 +00:00
|
|
|
//qDebug() << QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
|
|
|
|
|
2019-03-29 14:54:34 +00:00
|
|
|
coreThread->start();
|
|
|
|
|
2019-04-02 21:58:43 +00:00
|
|
|
int result = app.exec();
|
|
|
|
coreThread->wait(500); //TODO hate doing that but settings for some reason don't get saved to the disk
|
|
|
|
|
|
|
|
return result;
|
2019-03-29 14:54:34 +00:00
|
|
|
}
|
|
|
|
|