diff --git a/CustomModels/emojismodel.cpp b/CustomModels/emojismodel.cpp index 0ac3b3dc29fe67fcfda19aaea735797efbb2c1e8..06da05fcbc10765a67eae2003314a54fd3a5dca3 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 c419895d6330c4624f29086e0f0bbba497415d38..4254bf2155677fed42328a2297bb201955246ea1 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 e721c42454bda1b34114de3cee619178f74e31b9..c5bd3b2f89ea4cc22d466c2f96079f7515d6051f 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 28ef0fe7e5caea84987ef6a2b4ac558d317c0829..2b4c1cfae9efa3d8f473c158a775ddce996fe0a8 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 58a53080f2bc72e458e026c148cc10963826a607..6d6ab95a54d664bec64bfdeb51a65e72259eac01 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 fe4631470e16a0c2c151a026a2c305e2c7567dfe..e3f30a3af92458b1a5408c33b812f39a8b608de6 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 10e14cb306343a1f3926649cde3289c60c075656..fe3a9d32c4fe68a8052ef3d8b0890837fc9c87c6 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 e055c2a7dcca1090c4e50e3d95d522c8eec3260c..b2029f3b634ee36fc26bcb9f42e091b94f9024bf 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 610bf73a6d8c52d29dce000be980f1520d47cd1b..b03c9f6a8a88cb64e8dce15dec235c336339ab21 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 f3e0f679700985aea221f849034c9330f6b834db..15ecdfccccac724760b50d13189fb9ecd5b96bd2 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 c26d48035ad64c9bbed0d63571a0a131c6f9b35b..f327a477041d2c1a0448d1a00b83ce72dc7e8666 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 b7722bc9c40481ba9eb6f123547903cb06cc12e4..7e06c20b2bcd1f4fab04a1613e03dc3d92a22477 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 490a9e54af25dee747a24bb34a4121e7691767cf..08c994576b24f21e48da1af0cd226400ad649b53 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 aede2901d5ea45fc1807a25c08cfdc33e848489c..bebccf996c17b1600957e650709fc24ec87ca79b 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 2f05186e41ead1234badfd5596a0a1e0158e7bb5..4508b6bc6959f983a2a66aa4019a7366fb1bab8a 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 a71d576e11424fc6ed7b67aa2c4f093f5a5c9cfa..eb5f3c188a422fea27be69afb27124e552d58e05 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 61d1dd9b140d82b211dd2e8a39f250d1fae9171b..765db7b888f51441540afc96a6244735efda9a2a 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 66e097e2643f6000bab59651e974ca2dde2008cf..f7e795d3ca08c5141bcac29867919220431d3345 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 6ead949baf4bc991cab2247e3f632d4838af2880..9b585c9c1c1e685dd7c7a4bb38d116ab1a794134 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 c43d64f0c49f284eda88aa350d4f201e11c5e6cc..b14f88bf798d4776fdf3ae86eb7a9aa14b7089ec 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(); - -}*/