diff --git a/rocketchat.cpp b/rocketchat.cpp index 6223ee2c30ab81fa783b9ff2672d6774c93e8fa7..dc7de295efc8e9caa06971c30451ecb61c0adc36 100755 --- a/rocketchat.cpp +++ b/rocketchat.cpp @@ -739,6 +739,7 @@ void RocketChat::serverReadySlot() connect( &mNetworkConfiguration, &QNetworkConfigurationManager::onlineStateChanged, this, &RocketChat::onOnlineStateChanged, Qt::UniqueConnection ); connect( pServer, &RocketChatServerData::newLoginMethod, this, &RocketChat::addLoginMethod, Qt::UniqueConnection ); connect( pServer, &RocketChatServerData::resetLoginMethods, this, &RocketChat::resetLoginMethods, Qt::UniqueConnection ); + connect( pServer, &RocketChatServerData::offlineMode, this, &RocketChat::offlineMode, Qt::UniqueConnection ); QMetaObject::invokeMethod( pServer, "init" ); diff --git a/rocketchat.h b/rocketchat.h index 002515e42998ee9285e4a7220b08521cdb1c9eb1..b8e33388c682645bc3e310c5830ec3a84a7a0404 100755 --- a/rocketchat.h +++ b/rocketchat.h @@ -129,7 +129,6 @@ class RocketChat : public QObject Q_INVOKABLE void reportAbusiveContent( const QString &pMessageId, const QString &pAuthor ); - void registerServer( RocketChatServerData *pServer ); void addLoginMethod( const QMap<QString, QVariant> &pMethod ); @@ -245,7 +244,7 @@ class RocketChat : public QObject void channelUsersReady( QString users, QString channel ); void channelDetailsReady( QVariantMap details, QString channelId ); void noJitsiMeetAvailable(); - + void offlineMode(void); void pushTokenReceived( QString pToken ); void pushMessageReceived( QString pServer, QString pRid, QString pName, QString pType ); diff --git a/rocketchatserver.cpp b/rocketchatserver.cpp index 251cb5d1a4df1b96bd61a3af5a00ade31b76d9b4..67ea7d00f6616bdfd01bfa2dabad0fb6cda0889c 100755 --- a/rocketchatserver.cpp +++ b/rocketchatserver.cpp @@ -76,6 +76,13 @@ void RocketChatServerData::init() 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(); + if ( !token.isEmpty() && !userDb.isEmpty() ) { + emit offlineMode(); + } + mUserId = mStorage->getUserId(); mUsername = mStorage->getUserName(); @@ -831,6 +838,7 @@ void RocketChatServerData::onDDPConnected() if ( !token.isEmpty() && !userDb.isEmpty() ) { loginWithToken( userDb, token ); + emit offlineMode(); } } diff --git a/rocketchatserver.h b/rocketchatserver.h index e534a16323a625f127a037f2f73476997cbee699..4b028bc26ca98add904b3f84db508abb20eb672e 100755 --- a/rocketchatserver.h +++ b/rocketchatserver.h @@ -338,6 +338,7 @@ class RocketChatServerData : public QObject void unreadCountChanged( const QString &pServerId, uint pUnread ); void newLoginMethod( const QMap<QString, QVariant> &entry ); void resetLoginMethods(); + void offlineMode(void); }; diff --git a/services/authenticationservice.cpp b/services/authenticationservice.cpp new file mode 100644 index 0000000000000000000000000000000000000000..092d0ecabb3aa00492eeea9cc53723dcaf9dd8e6 --- /dev/null +++ b/services/authenticationservice.cpp @@ -0,0 +1,6 @@ +#include "authenticationservice.h" + +AuthenticationService::AuthenticationService(QObject *parent) : QObject(parent) +{ + +} diff --git a/services/authenticationservice.h b/services/authenticationservice.h new file mode 100644 index 0000000000000000000000000000000000000000..45c87ae67ebce11285662c91e4a98d7011dc635c --- /dev/null +++ b/services/authenticationservice.h @@ -0,0 +1,17 @@ +#ifndef AUTHENTICATIONSERVICE_H +#define AUTHENTICATIONSERVICE_H + +#include <QObject> + +class AuthenticationService : public QObject +{ + Q_OBJECT +public: + explicit AuthenticationService(QObject *parent = nullptr); + +signals: + +public slots: +}; + +#endif // AUTHENTICATIONSERVICE_H \ No newline at end of file