diff --git a/backends/libcommuni/session.h b/backends/libcommuni/session.h index 2e65f7a6812fcf297f3928df240c2cc8f3f1777f..0d819cb0f9f9192c04f4981a36242bf9dd622189 100644 --- a/backends/libcommuni/session.h +++ b/backends/libcommuni/session.h @@ -15,6 +15,7 @@ #include #include "Swiften/Swiften.h" #include +#include using namespace Transport; @@ -27,14 +28,26 @@ class MyIrcSession : public IrcSession public: class AutoJoinChannel { public: - AutoJoinChannel(const std::string &channel = "", const std::string &password = "") : m_channel(channel), m_password(password) {} + AutoJoinChannel(const std::string &channel = "", const std::string &password = "", int awayCycle = 12) : m_channel(channel), m_password(password), + m_awayCycle(awayCycle), m_currentAwayTick(0) {} virtual ~AutoJoinChannel() {} const std::string &getChannel() { return m_channel; } const std::string &getPassword() { return m_password; } + bool shouldAskWho() { + if (m_currentAwayTick == m_awayCycle) { + m_currentAwayTick = 0; + return true; + } + m_currentAwayTick++; + return false; + } + private: std::string m_channel; std::string m_password; + int m_awayCycle; + int m_currentAwayTick; }; class IRCBuddy { @@ -55,11 +68,12 @@ public: typedef std::map > IRCBuddyMap; MyIrcSession(const std::string &user, IRCNetworkPlugin *np, const std::string &suffix = "", QObject* parent = 0); + virtual ~MyIrcSession(); std::string suffix; int rooms; void addAutoJoinChannel(const std::string &channel, const std::string &password) { - m_autoJoin[channel] = boost::make_shared(channel, password); + m_autoJoin[channel] = boost::make_shared(channel, password, 12 + m_autoJoin.size()); } void removeAutoJoinChannel(const std::string &channel) { @@ -104,6 +118,7 @@ protected Q_SLOTS: void on_socketError(QAbstractSocket::SocketError error); void onMessageReceived(IrcMessage* message); + void awayTimeout(); protected: IRCNetworkPlugin *np; @@ -115,6 +130,7 @@ protected: std::list m_rooms; std::list m_names; IRCBuddyMap m_buddies; + QTimer *m_awayTimer; }; #endif // SESSION_H