X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcommon%2Fircuser.h;h=a880d4bc195a48b9240ca47255f95050c67aeed2;hb=f9efdde7f3a6004af8f834c409cfa6ae1d877692;hp=aa90f477b872d3876820d6cc9a9c2eee0824ac5f;hpb=d272e4719d2770a018f9a2856b61d9847eb24201;p=quassel.git diff --git a/src/common/ircuser.h b/src/common/ircuser.h index aa90f477..a880d4bc 100644 --- a/src/common/ircuser.h +++ b/src/common/ircuser.h @@ -18,8 +18,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#ifndef IRCUSER_H -#define IRCUSER_H +#pragma once + +#include "common-export.h" #include #include @@ -34,10 +35,10 @@ class SignalProxy; class Network; class IrcChannel; -class IrcUser : public SyncableObject +class COMMON_EXPORT IrcUser : public SyncableObject { - SYNCABLE_OBJECT Q_OBJECT + SYNCABLE_OBJECT Q_PROPERTY(QString user READ user WRITE setUser) Q_PROPERTY(QString host READ host WRITE setHost) @@ -50,9 +51,6 @@ class IrcUser : public SyncableObject Q_PROPERTY(QDateTime loginTime READ loginTime WRITE setLoginTime) Q_PROPERTY(QString server READ server WRITE setServer) Q_PROPERTY(QString ircOperator READ ircOperator WRITE setIrcOperator) - // lastAwayMessage is only set by legacy (pre-0.13) cores, which automatically gets converted to - // the appropriate lastAwayMessageTime. Do not use this in new code. - Q_PROPERTY(int lastAwayMessage WRITE setLastAwayMessage) Q_PROPERTY(QDateTime lastAwayMessageTime READ lastAwayMessageTime WRITE setLastAwayMessageTime) Q_PROPERTY(QString whoisServiceReply READ whoisServiceReply WRITE setWhoisServiceReply) Q_PROPERTY(QString suserHost READ suserHost WRITE setSuserHost) @@ -62,8 +60,7 @@ class IrcUser : public SyncableObject Q_PROPERTY(QString userModes READ userModes WRITE setUserModes) public : - IrcUser(const QString &hostmask, Network *network); - virtual ~IrcUser(); + IrcUser(const QString &hostmask, Network *network); inline QString user() const { return _user; } inline QString host() const { return _host; } @@ -109,6 +106,31 @@ public : inline QDateTime lastSpokenTo(BufferId id) const { return _lastSpokenTo.value(id); } void setLastSpokenTo(BufferId id, const QDateTime &time); + /** + * Gets whether or not the away state has changed since it was last acknowledged + * + * Away state is marked as changed by any modification to away status (away/here, message) + * + * NOTE: On servers lacking support for IRCv3 away-notify, this won't update until an autoWHO- + * run for away/here changes, or until sending a message to the user for away message changes. + * + * @see IrcUser::acknowledgeAwayChanged() + * + * @return True if current away state is unchanged from last acknowledgement, otherwise false + */ + inline bool hasAwayChanged() const { return _awayChanged; } + + /** + * Sets the last away state change as acknowledged + * + * @see IrcUser::hasAwayChanged() + */ + inline void acknowledgeAwayChanged() + { + // Don't sync this as individual clients may suppress different kinds of behaviors + _awayChanged = false; + } + public slots: void setUser(const QString &user); void setHost(const QString &host); @@ -120,7 +142,7 @@ public slots: * @param[in] account Account name if logged in, * if logged out, or empty string if unknown */ void setAccount(const QString &account); - void setAway(const bool &away); + void setAway(bool away); void setAwayMessage(const QString &awayMessage); void setIdleTime(const QDateTime &idleTime); void setLoginTime(const QDateTime &loginTime); @@ -128,7 +150,7 @@ public slots: void setIrcOperator(const QString &ircOperator); // setLastAwayMessage is only called by legacy (pre-0.13) cores, which automatically gets // converted to setting the appropriate lastAwayMessageTime. Do not use this in new code. - void setLastAwayMessage(const int &lastAwayMessage); + void setLastAwayMessage(int lastAwayMessage); void setLastAwayMessageTime(const QDateTime &lastAwayMessageTime); void setWhoisServiceReply(const QString &whoisServiceReply); void setSuserHost(const QString &suserHost); @@ -194,6 +216,15 @@ private: return (_nick.toLower() == nickname.toLower()); } + /** + * Sets the last away state change as unacknowledged + * + * @see IrcUser::hasAwayChanged() + */ + inline void markAwayChanged() + { + _awayChanged = true; + } bool _initialized; @@ -225,7 +256,8 @@ private: QHash _lastActivity; QHash _lastSpokenTo; -}; - -#endif + // Given it's never been acknowledged, assume changes exist on IrcUser creation + /// Tracks if changes in away state (away/here, message) have yet to be acknowledged + bool _awayChanged = true; +};