From b0b8c0465c6640819e93df0098250dd535b6213c Mon Sep 17 00:00:00 2001 From: Armin Felder <armin.felder@osalliance.com> Date: Fri, 30 Nov 2018 23:47:14 +0100 Subject: [PATCH] ds --- CustomModels/emojismodel.cpp | 4 - CustomModels/loginmethodsmodel.h | 1 + CustomModels/models.cpp | 4 +- engine.pro | 4 +- fileuploader.cpp | 2 +- fileuploader.h | 2 +- persistancelayer.cpp | 44 +++---- persistancelayer.h | 2 +- repos/channelrepository.cpp | 2 +- repos/channelrepository.h | 2 +- repos/emojirepo.cpp | 2 +- repos/emojirepo.h | 2 +- rocketchat.cpp | 65 +++++++--- rocketchatserver.cpp | 165 +++++++++++++------------- rocketchatserver.h | 3 +- services/messageservice.cpp | 4 +- services/messageservice.h | 2 +- services/rocketchatchannelservice.cpp | 2 +- services/rocketchatchannelservice.h | 2 +- websocket/websocket.cpp | 11 -- 20 files changed, 174 insertions(+), 151 deletions(-) diff --git a/CustomModels/emojismodel.cpp b/CustomModels/emojismodel.cpp index 0ac3b3d..06da05f 100644 --- a/CustomModels/emojismodel.cpp +++ b/CustomModels/emojismodel.cpp @@ -92,10 +92,6 @@ void EmojisModel::addEmoji( const QSharedPointer<Emoji> &pEmoji ) void EmojisModel::addEmojisByCategory( const QString &pCategory, const QList<QSharedPointer<Emoji> > &pList ) { - static int counter = 0; - qDebug() << "called: " << counter++; - qDebug() << "category: " << pCategory; - if ( mCurrentCategory == pCategory ) { beginResetModel(); } diff --git a/CustomModels/loginmethodsmodel.h b/CustomModels/loginmethodsmodel.h index c419895..4254bf2 100644 --- a/CustomModels/loginmethodsmodel.h +++ b/CustomModels/loginmethodsmodel.h @@ -38,6 +38,7 @@ class LoginMethodsModel : public QAbstractListModel }; explicit LoginMethodsModel( QObject *parent = nullptr ); + public slots: Q_INVOKABLE QVariantMap get( int row ); Q_INVOKABLE void clear(); diff --git a/CustomModels/models.cpp b/CustomModels/models.cpp index e721c42..c5bd3b2 100644 --- a/CustomModels/models.cpp +++ b/CustomModels/models.cpp @@ -53,7 +53,9 @@ RoomSearchResultsModel *Models::getRoomSearchModel() void Models::resetModels() { mDirectChannelsModel->clear(); - mLoginMethodsModel->clear(); + QMetaObject::invokeMethod( mLoginMethodsModel, "clear" ); + + // mLoginMethodsModel->clear(); mPublicGroupsModel->clear(); mPrivateGroupsModel->clear(); mMessagesSearchModel->clear(); diff --git a/engine.pro b/engine.pro index 28ef0fe..2b4c1cf 100644 --- a/engine.pro +++ b/engine.pro @@ -277,9 +277,7 @@ CONFIG(release, debug|release) { CONFIG += ltcg # compiler options: O3 optimize linux:!android{ - QMAKE_CXXFLAGS += -Ofast -flto -funroll-loops -fno-signed-zeros -fno-trapping-math -fopenmp -D_GLIBCXX_PARALLEL - LIBS += -fopenmp - + QMAKE_CXXFLAGS += -Ofast -flto -funroll-loops -fno-signed-zeros -fno-trapping-math } android:{ QMAKE_CXXFLAGS += -Ofast -flto -funroll-loops -fno-signed-zeros -fno-trapping-math diff --git a/fileuploader.cpp b/fileuploader.cpp index 58a5308..6d6ab95 100755 --- a/fileuploader.cpp +++ b/fileuploader.cpp @@ -22,7 +22,7 @@ #include "fileuploader.h" -FileUploader::FileUploader( RocketChatServerData *pServer, const QUrl &pUri, const QString &pChannelId ) +FileUploader::FileUploader( QObject *parent, RocketChatServerData *pServer, const QUrl &pUri, const QString &pChannelId ): QObject( parent ) { this->mServer = pServer; this->mUri = pUri; diff --git a/fileuploader.h b/fileuploader.h index fe46314..e3f30a3 100755 --- a/fileuploader.h +++ b/fileuploader.h @@ -39,7 +39,7 @@ class FileUploader : public QObject { Q_OBJECT public: - FileUploader( RocketChatServerData *pServer, const QUrl &pUri, const QString &pChannelId ); + FileUploader( QObject *parent, RocketChatServerData *pServer, const QUrl &pUri, const QString &pChannelId ); void upload( const std::function<void( void )> & ); void cancel( void ); QString getFileId() const; diff --git a/persistancelayer.cpp b/persistancelayer.cpp index 10e14cb..fe3a9d3 100755 --- a/persistancelayer.cpp +++ b/persistancelayer.cpp @@ -263,6 +263,7 @@ void PersistanceLayer::initShema() } } } + } void PersistanceLayer::upgradeSchema() @@ -1432,32 +1433,35 @@ PersistanceLayer::~PersistanceLayer() void PersistanceLayer::init() { - QString directory = QStandardPaths::writableLocation( QStandardPaths::AppLocalDataLocation ); - QString filePath = directory + QStringLiteral( "/data.sqlite" ); - qDebug() << "SQLITE: " << filePath; - mDb.setDatabaseName( filePath ); - QDir dbPath( directory ); - - if ( !dbPath.exists() ) { - dbPath.mkpath( directory ); - } + if ( !mDbReady ) { + QString directory = QStandardPaths::writableLocation( QStandardPaths::AppLocalDataLocation ); + QString filePath = directory + QStringLiteral( "/data.sqlite" ); + qDebug() << "SQLITE: " << filePath; + mDb.setDatabaseName( filePath ); + QDir dbPath( directory ); - QFile file( filePath ); + if ( !dbPath.exists() ) { + dbPath.mkpath( directory ); + } - if ( !file.exists() ) { - file.open( QIODevice::ReadWrite ); - file.close(); - } + QFile file( filePath ); - if ( !mDb.open() ) { - qDebug() << mDb.lastError().text() + "file used:" + filePath; - throw std::runtime_error( mDb.lastError().text().toStdString() + "file used:" + filePath.toStdString() ); - } + if ( !file.exists() ) { + file.open( QIODevice::ReadWrite ); + file.close(); + } - initShema(); + if ( !mDb.open() ) { + qDebug() << mDb.lastError().text() + "file used:" + filePath; + throw std::runtime_error( mDb.lastError().text().toStdString() + "file used:" + filePath.toStdString() ); + } - if ( !mDbReady ) { mDbReady = true; + initShema(); + emit( ready() ); + + + } else { emit( ready() ); } } diff --git a/persistancelayer.h b/persistancelayer.h index e055c2a..b2029f3 100755 --- a/persistancelayer.h +++ b/persistancelayer.h @@ -92,6 +92,7 @@ class PersistanceLayer : public QObject void init(); void close(); + bool mDbReady = false; private: PersistanceLayer() {} @@ -99,7 +100,6 @@ class PersistanceLayer : public QObject QMimeDatabase mMimeDb; QMutex mMutex; QAtomicInt counter = 0; - bool mDbReady = false; void initShema(); void upgradeSchema(); diff --git a/repos/channelrepository.cpp b/repos/channelrepository.cpp index 610bf73..b03c9f6 100755 --- a/repos/channelrepository.cpp +++ b/repos/channelrepository.cpp @@ -21,7 +21,7 @@ #include "channelrepository.h" -ChannelRepository::ChannelRepository( ): +ChannelRepository::ChannelRepository( QObject *parent ): QObject( parent ), mChannelsModel( Models::getPublicGroupsModel() ), mGroupsModel( Models::getPublicGroupsModel() ), mDirectModel( Models::getDirectChannelsModel() ), mMessagesModel( Models::getMessagesModel() ) { mElements.reserve( 50 ); diff --git a/repos/channelrepository.h b/repos/channelrepository.h index f3e0f67..15ecdfc 100755 --- a/repos/channelrepository.h +++ b/repos/channelrepository.h @@ -39,7 +39,7 @@ class ChannelRepository : public QObject, public AbstractBaseRepository<RocketCh Q_OBJECT public: - explicit ChannelRepository( ); + explicit ChannelRepository( QObject *parent = nullptr ); unsigned long getYoungestMessageDate() const; unsigned long getOldestMessageDate() const; bool add( const QString &id, const QSharedPointer<RocketChatChannel> & ); diff --git a/repos/emojirepo.cpp b/repos/emojirepo.cpp index c26d480..f327a47 100644 --- a/repos/emojirepo.cpp +++ b/repos/emojirepo.cpp @@ -22,7 +22,7 @@ #include "emojirepo.h" -EmojiRepo::EmojiRepo() +EmojiRepo::EmojiRepo( QObject *parent ): QObject( parent ) { mElements.reserve( 3000 ); } diff --git a/repos/emojirepo.h b/repos/emojirepo.h index b7722bc..7e06c20 100644 --- a/repos/emojirepo.h +++ b/repos/emojirepo.h @@ -33,7 +33,7 @@ class EmojiRepo : public QObject, public AbstractBaseRepository<Emoji> { public: - EmojiRepo(); + EmojiRepo( QObject *parent = nullptr ); bool add( const QSharedPointer<Emoji> &pEmoji ); bool add( const QString &pId, const QSharedPointer<Emoji> &pEmoji ); diff --git a/rocketchat.cpp b/rocketchat.cpp index 490a9e5..08c9945 100755 --- a/rocketchat.cpp +++ b/rocketchat.cpp @@ -42,6 +42,39 @@ /** * @brief RocketChat::RocketChat */ + +void customOutput( QtMsgType type, const QMessageLogContext &context, const QString &msg ) +{ + QByteArray localMsg = msg.toLocal8Bit(); + + if ( msg.contains( "QObject::connect: Cannot queue arguments of type 'QQmlChangeSet'" ) ) { + qDebug() << "break"; + } + + switch ( type ) { + case QtDebugMsg: + fprintf( stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function ); + break; + + case QtInfoMsg: + fprintf( stderr, "Info: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function ); + break; + + case QtWarningMsg: + fprintf( stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function ); + break; + + case QtCriticalMsg: + fprintf( stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function ); + break; + + case QtFatalMsg: + fprintf( stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function ); + abort(); + } +} + + RocketChat::RocketChat( QGuiApplication *app ) { #ifdef Q_OS_IOS @@ -58,6 +91,7 @@ RocketChat::RocketChat( QGuiApplication *app ) #endif qRegisterMetaType<ConnectionState>( "ConnectionState" ); qRegisterMetaType<Qt::ApplicationState>( "Qt::ApplicationState" ); + qInstallMessageHandler( customOutput ); } RocketChat::~RocketChat() @@ -253,27 +287,21 @@ bool RocketChat::newServerByDomain( const QString &domain, bool pUnsecure = fals if ( !mServerMap.isEmpty() ) { auto firstServer = mServerMap.first(); - mServerMap.remove( firstServer->getServerId() ); + mServerMap.clear(); - auto self = this; - connect( firstServer, &RocketChatServerData::destroyed, [ &, self, domain, pUnsecure]() { - qDebug() << "domain: " << domain; - QString protocol = QStringLiteral( "https://" ); + if ( firstServer != nullptr ) { + connect( firstServer, &RocketChatServerData::destroyed, [ = ]() { + qDebug() << "domain: " << domain; - if ( pUnsecure ) { - protocol = QStringLiteral( "http://" ); - } - - QString apiUri = protocol + domain + QStringLiteral( "/api/v1" ); + Models::resetModels(); - Models::resetModels(); + RocketChatServerData *server = new RocketChatServerData( domain, domain, pUnsecure ); - RocketChatServerData *server = new RocketChatServerData( domain, domain, pUnsecure ); - - registerServer( server ); - newServerMutex.unlock(); - } ); - QMetaObject::invokeMethod( firstServer, "deleteLater" ); + registerServer( server ); + newServerMutex.unlock(); + } ); + QMetaObject::invokeMethod( firstServer, "deleteLater" ); + } } else { QString protocol = QStringLiteral( "https://" ); @@ -559,7 +587,8 @@ void RocketChat::addLoginMethod( const QMap<QString, QVariant> &pMethod ) void RocketChat::resetLoginMethods() { - Models::getLoginMethodsModel()->clear(); + QMetaObject::invokeMethod( Models::getLoginMethodsModel(), "clear" ); + //Models::getLoginMethodsModel()->clear(); } void RocketChat::openIosFile( const QString &fileName ) diff --git a/rocketchatserver.cpp b/rocketchatserver.cpp index aede290..bebccf9 100755 --- a/rocketchatserver.cpp +++ b/rocketchatserver.cpp @@ -31,108 +31,114 @@ RocketChatServerData::RocketChatServerData( QString pId, QString pBaseUrl, bool mUnsecureConnection = pUnsecure; - QString protocol = QStringLiteral( "https://" ); - - if ( pUnsecure ) { - protocol = QStringLiteral( "http://" ); - } - mApiUri = QStringLiteral( "/api/v1" ); - mEmojiRepo = new EmojiRepo; + mEmojiRepo = new EmojiRepo( this ); - setRestApi( new RestApi( this, protocol + mBaseUrl ) ); } void RocketChatServerData::init() +{ + initDb(); +} + +void RocketChatServerData::initDb() { mStorage = PersistanceLayer::instance(); - connect( mStorage, &PersistanceLayer::ready, [ = ]() { - historyLoaded = [ = ]( QMultiMap<QString, QSharedPointer<RocketChatMessage>> *messages ) { - if ( messages ) { - mStorage->transaction(); + connect( mStorage, &PersistanceLayer::ready, this, &RocketChatServerData::initConnections, Qt::UniqueConnection ); + mStorage->init(); +} - for ( const auto &key : messages->uniqueKeys() ) { - if ( Q_LIKELY( mChannels->contains( key ) && !mChannels->get( key ).isNull() ) ) { - MessageList messageList = messages->values( key ); - mChannels->get( key )->addMessages( messageList ); - mMessageService->persistMessages( messageList ); - } +void RocketChatServerData::initConnections() +{ + historyLoaded = [ = ]( QMultiMap<QString, QSharedPointer<RocketChatMessage>> *messages ) { + if ( messages ) { + mStorage->transaction(); + + for ( const auto &key : messages->uniqueKeys() ) { + if ( Q_LIKELY( mChannels->contains( key ) && !mChannels->get( key ).isNull() ) ) { + MessageList messageList = messages->values( key ); + mChannels->get( key )->addMessages( messageList ); + mMessageService->persistMessages( messageList ); } + } - mStorage->commit(); + mStorage->commit(); - if ( messages != nullptr ) { - delete messages; - } + if ( messages != nullptr ) { + delete messages; } - }; - mFileService = new FileService( this ); - mEmojiService = new EmojiService( this, mFileService, mStorage ); + } + }; + QString protocol = QStringLiteral( "https://" ); - mDdpApi = new MeteorDDP( this, mBaseUrl, mUnsecureConnection ); + if ( mUnsecureConnection ) { + protocol = QStringLiteral( "http://" ); + } - mRestApi->moveToThread( QThread::currentThread() ); - mDdpApi->moveToThread( QThread::currentThread() ); + setRestApi( new RestApi( this, protocol + mBaseUrl ) ); + mFileService = new FileService( this ); + mEmojiService = new EmojiService( this, mFileService, mStorage ); - mChannels = new ChannelRepository( ); + mDdpApi = new MeteorDDP( this, mBaseUrl, mUnsecureConnection ); - RocketChatServerConfig::init(); + mRestApi->moveToThread( QThread::currentThread() ); + mDdpApi->moveToThread( QThread::currentThread() ); - QMetaObject::invokeMethod( mRestApi, "init" ); + mChannels = new ChannelRepository( this ); - mDdpApi->registerMessageHandler( this ); - connect( mDdpApi, &MeteorDDP::ddpConnected, this, &RocketChatServerData::onDDPConnected, Qt::UniqueConnection ); - connect( mDdpApi, &MeteorDDP::ddpDisconnected, this, &RocketChatServerData::onDDPDisonnected, Qt::UniqueConnection ); + RocketChatServerConfig::init(); - QPair<QString, uint> tokenDb = mStorage->getToken(); - QString token = tokenDb.first; - QString userDb = mStorage->getUserName(); + QMetaObject::invokeMethod( mRestApi, "init" ); - if ( !token.isEmpty() && !userDb.isEmpty() ) { - emit offlineMode(); - } + mDdpApi->registerMessageHandler( this ); + connect( mDdpApi, &MeteorDDP::ddpConnected, this, &RocketChatServerData::onDDPConnected, Qt::UniqueConnection ); + connect( mDdpApi, &MeteorDDP::ddpDisconnected, this, &RocketChatServerData::onDDPDisonnected, Qt::UniqueConnection ); + + QPair<QString, uint> tokenDb = mStorage->getToken(); + QString token = tokenDb.first; + QString userDb = mStorage->getUserName(); - setUserId( mStorage->getUserId() ); - mUsername = mStorage->getUserName(); + if ( !token.isEmpty() && !userDb.isEmpty() ) { + emit offlineMode(); + } - loadEmojis(); + setUserId( mStorage->getUserId() ); + mUsername = mStorage->getUserName(); - mMessageService = new MessageService( mStorage, this, mEmojiRepo ); - mChannelService = new RocketChatChannelService( this, mMessageService ); - mChannelService->setDdp( mDdpApi ); - mChannelService->setChannels( mChannels ); - connect( mChannelService, &RocketChatChannelService::channelsLoaded, this, &RocketChatServerData::onChannelsLoaded, Qt::UniqueConnection ); - connect( mChannelService, &RocketChatChannelService::usersLoaded, this, &RocketChatServerData::onUsersLoaded, Qt::UniqueConnection ); - connect( mChannelService, &RocketChatChannelService::directChannelReady, this, &RocketChatServerData::switchChannelByName, Qt::UniqueConnection ); - connect( channelsModel, &ChannelModel::unreadMessagesChanged, this, &RocketChatServerData::onUnreadCountChanged, Qt::UniqueConnection ); - connect( directModel, &ChannelModel::unreadMessagesChanged, this, &RocketChatServerData::onUnreadCountChanged, Qt::UniqueConnection ); - connect( groupsModel, &ChannelModel::unreadMessagesChanged, this, &RocketChatServerData::onUnreadCountChanged, Qt::UniqueConnection ); + loadEmojis(); + mMessageService = new MessageService( this, mStorage, this, mEmojiRepo ); + mChannelService = new RocketChatChannelService( this, this, mMessageService ); + mChannelService->setDdp( mDdpApi ); + mChannelService->setChannels( mChannels ); + connect( mChannelService, &RocketChatChannelService::channelsLoaded, this, &RocketChatServerData::onChannelsLoaded, Qt::UniqueConnection ); + connect( mChannelService, &RocketChatChannelService::usersLoaded, this, &RocketChatServerData::onUsersLoaded, Qt::UniqueConnection ); + connect( mChannelService, &RocketChatChannelService::directChannelReady, this, &RocketChatServerData::switchChannelByName, Qt::UniqueConnection ); + connect( channelsModel, &ChannelModel::unreadMessagesChanged, this, &RocketChatServerData::onUnreadCountChanged, Qt::UniqueConnection ); + connect( directModel, &ChannelModel::unreadMessagesChanged, this, &RocketChatServerData::onUnreadCountChanged, Qt::UniqueConnection ); + connect( groupsModel, &ChannelModel::unreadMessagesChanged, this, &RocketChatServerData::onUnreadCountChanged, Qt::UniqueConnection ); - QString lastServer = mStorage->getSetting( QStringLiteral( "currentServer" ) ); - if ( lastServer == mBaseUrl ) { - QPair<QString, uint> tokenDb = mStorage->getToken(); - QString userDb = mStorage->getUserName(); - QDateTime currentTime = QDateTime::currentDateTime(); + QString lastServer = mStorage->getSetting( QStringLiteral( "currentServer" ) ); - if ( !tokenDb.first.isEmpty() && tokenDb.second > currentTime.toTime_t() ) { - loginWithToken( userDb, tokenDb.first ); - } else { - mStorage->wipeDb(); - emit loggedOut( mServerId ); - } - } else if ( !lastServer.isEmpty() ) { + if ( lastServer == mBaseUrl ) { + QPair<QString, uint> tokenDb = mStorage->getToken(); + QString userDb = mStorage->getUserName(); + QDateTime currentTime = QDateTime::currentDateTime(); + + if ( !tokenDb.first.isEmpty() && tokenDb.second > currentTime.toTime_t() ) { + loginWithToken( userDb, tokenDb.first ); + } else { mStorage->wipeDb(); emit loggedOut( mServerId ); } + } else if ( !lastServer.isEmpty() ) { + mStorage->wipeDb(); + emit loggedOut( mServerId ); + } - emit readyToCheckForPendingNotification(); - mChannelService->loadJoinedChannelsFromDb(); - - } ); - mStorage->init(); - + emit readyToCheckForPendingNotification(); + mChannelService->loadJoinedChannelsFromDb(); } void RocketChatServerData::setRestApi( RestApi *pNewRestApi ) @@ -462,11 +468,13 @@ void RocketChatServerData::setUserId( const QString &userId ) QMetaObject::invokeMethod( userModel, "addUser", Q_ARG( User, user ) ); } - mUserId = userId; + if ( !user.isNull() && !userId.isEmpty() ) { + mUserId = userId; - connect( user.data(), &RocketChatUser::statusChanged, this, [ = ]() { - emit userStatusChanged( static_cast<int>( user->getStatus() ) ); - } ); + connect( user.data(), &RocketChatUser::statusChanged, this, [ = ]() { + emit userStatusChanged( static_cast<int>( user->getStatus() ) ); + } ); + } } void RocketChatServerData::disconnectFromServer() @@ -575,11 +583,6 @@ void RocketChatServerData::offlineLogin() } } -RocketChatServerData::~RocketChatServerData() -{ - mStorage->close(); -} - QSharedPointer<RocketChatUser> RocketChatServerData::getOwnUser() const { return mOwnUser; @@ -1744,7 +1747,7 @@ void RocketChatServerData::uploadFile( const QString &pChannelId, const QString file.close(); } - auto uploader = new FileUploader( this, uri, pChannelId ); + auto uploader = new FileUploader( this, this, uri, pChannelId ); std::function<void( void )> success = [ = ]() { emit fileUploadFinished( uploader->getFileId() ); delete uploader; diff --git a/rocketchatserver.h b/rocketchatserver.h index 2f05186..4508b6b 100755 --- a/rocketchatserver.h +++ b/rocketchatserver.h @@ -123,6 +123,8 @@ class RocketChatServerData : public MessageListener public slots: void init(); + void initDb(); + void initConnections(); void createPublicGroup( const QString &pChannelName, const QStringList &pUsers, bool pReadonly ); void createPrivateGroup( const QString &pChannelName, const QStringList &pUsers, bool pReadonly ); @@ -245,7 +247,6 @@ class RocketChatServerData : public MessageListener protected: RocketChatServerData(); - ~RocketChatServerData(); ConnectionState mConnectionState = ConnectionState::OFFLINE; QString mUsername = ""; QString mUserId = ""; diff --git a/services/messageservice.cpp b/services/messageservice.cpp index a71d576..eb5f3c1 100644 --- a/services/messageservice.cpp +++ b/services/messageservice.cpp @@ -34,9 +34,9 @@ // this->mServer = pServer; //} -MessageService::MessageService( PersistanceLayer *pPersistanceLayer, +MessageService::MessageService( QObject *parent, PersistanceLayer *pPersistanceLayer, RocketChatServerData *pServer, - EmojiRepo *pEmojiRepo ): mReplyRegeEx( "\\[ \\]\\(.*\\)</a>" ), mEmojiRepo( pEmojiRepo ), mMessagesModel( Models::getMessagesModel() ), + EmojiRepo *pEmojiRepo ): QObject( parent ), mReplyRegeEx( "\\[ \\]\\(.*\\)</a>" ), mEmojiRepo( pEmojiRepo ), mMessagesModel( Models::getMessagesModel() ), mSearchResults( Models::getMessagesSearchModel() ), mReplyReplyRegeEx( "\\[ \\]\\(.*\\)" ) { this->mPersistanceLayer = pPersistanceLayer; diff --git a/services/messageservice.h b/services/messageservice.h index 61d1dd9..765db7b 100644 --- a/services/messageservice.h +++ b/services/messageservice.h @@ -51,7 +51,7 @@ class MessageService : public QObject Q_OBJECT public: // MessageService(PersistanceLayer *pPersistanceLayer, RocketChatServerData* pServer, const QHash<QString, QString> &pEmojisMap); - MessageService( PersistanceLayer *pPersistanceLayer, RocketChatServerData *pServer, EmojiRepo *mEmojiRepo ); + MessageService( QObject *parent, PersistanceLayer *pPersistanceLayer, RocketChatServerData *pServer, EmojiRepo *mEmojiRepo ); void loadHistory( const QSharedPointer<LoadHistoryServiceRequest> & ); void checkForMissingMessages( const QSharedPointer<LoadMissedMessageServiceRequest> &pRequest ); void sendMessage( const QSharedPointer<RocketChatMessage> &pMessage ); diff --git a/services/rocketchatchannelservice.cpp b/services/rocketchatchannelservice.cpp index 66e097e..f7e795d 100755 --- a/services/rocketchatchannelservice.cpp +++ b/services/rocketchatchannelservice.cpp @@ -26,7 +26,7 @@ -RocketChatChannelService::RocketChatChannelService( RocketChatServerData *pServer, MessageService *pMessageService ) +RocketChatChannelService::RocketChatChannelService( QObject *parent, RocketChatServerData *pServer, MessageService *pMessageService ): QObject( parent ) { this->mServer = pServer; this->mMessageService = pMessageService; diff --git a/services/rocketchatchannelservice.h b/services/rocketchatchannelservice.h index 6ead949..9b585c9 100755 --- a/services/rocketchatchannelservice.h +++ b/services/rocketchatchannelservice.h @@ -55,7 +55,7 @@ class RocketChatChannelService : public QObject { Q_OBJECT public: - RocketChatChannelService( RocketChatServerData *pServer, MessageService *pMessageService ); + RocketChatChannelService( QObject *parent, RocketChatServerData *pServer, MessageService *pMessageService ); RestApi *getRestApi() const; void setRestApi( RestApi *pValue ); diff --git a/websocket/websocket.cpp b/websocket/websocket.cpp index c43d64f..b14f88b 100755 --- a/websocket/websocket.cpp +++ b/websocket/websocket.cpp @@ -74,14 +74,3 @@ void Websocket::updateConnectionStatus() mConnectionStatus = true; emit( connected() ); } -/* -Websocket::~Websocket(){ - qDebug()<<"destroying websocket instance"; - disconnect(mWebsocketInstance,&WebsocketAbstract::connected,this,&Websocket::connected); - disconnect(mWebsocketInstance,&WebsocketAbstract::textMessageReceived,this,&Websocket::textMessageReceived); - disconnect(mWebsocketInstance,&WebsocketAbstract::error,this,&Websocket::error); - disconnect(mWebsocketInstance,&WebsocketAbstract::closed,this,&Websocket::closed); - mWebsocketInstance->close(); - mWebsocketInstance->deleteLater(); - -}*/ -- GitLab