gloox
1.0
|
00001 /* 00002 Copyright (c) 2005-2009 by Jakob Schroeter <js@camaya.net> 00003 This file is part of the gloox library. http://camaya.net/gloox 00004 00005 This software is distributed under a license. The full license 00006 agreement can be found in the file LICENSE in this distribution. 00007 This software may not be copied, modified, sold or distributed 00008 other than expressed in the named license agreement. 00009 00010 This software is distributed without any warranty. 00011 */ 00012 00013 00014 #ifndef LASTACTIVITY_H__ 00015 #define LASTACTIVITY_H__ 00016 00017 #include "iqhandler.h" 00018 00019 #include <ctime> 00020 00021 namespace gloox 00022 { 00023 00024 class JID; 00025 class ClientBase; 00026 class LastActivityHandler; 00027 00039 class GLOOX_API LastActivity : public IqHandler 00040 { 00041 public: 00052 class GLOOX_API Query : public StanzaExtension 00053 { 00054 public: 00059 Query( const Tag* tag = 0 ); 00060 00066 Query( const std::string& status, long seconds ); 00067 00071 virtual ~Query(); 00072 00078 long seconds() const { return m_seconds; } 00079 00085 const std::string& status() const { return m_status; } 00086 00087 // reimplemented from StanzaExtension 00088 virtual const std::string& filterString() const; 00089 00090 // reimplemented from StanzaExtension 00091 virtual StanzaExtension* newInstance( const Tag* tag ) const 00092 { 00093 return new Query( tag ); 00094 } 00095 00096 // reimplemented from StanzaExtension 00097 virtual Tag* tag() const; 00098 00099 // reimplemented from StanzaExtension 00100 virtual StanzaExtension* clone() const 00101 { 00102 return new Query( *this ); 00103 } 00104 00105 private: 00106 long m_seconds; 00107 std::string m_status; 00108 00109 }; 00110 00115 LastActivity( ClientBase* parent ); 00116 00120 virtual ~LastActivity(); 00121 00127 void query( const JID& jid ); 00128 00134 void registerLastActivityHandler( LastActivityHandler* lah ) { m_lastActivityHandler = lah; } 00135 00139 void removeLastActivityHandler() { m_lastActivityHandler = 0; } 00140 00145 void resetIdleTimer(); 00146 00147 // reimplemented from IqHandler 00148 virtual bool handleIq( const IQ& iq ); 00149 00150 // reimplemented from IqHandler 00151 virtual void handleIqID( const IQ& iq, int context ); 00152 00153 private: 00154 #ifdef LASTACTIVITY_TEST 00155 public: 00156 #endif 00157 LastActivityHandler* m_lastActivityHandler; 00158 ClientBase* m_parent; 00159 00160 time_t m_active; 00161 00162 }; 00163 00164 } 00165 00166 #endif // LASTACTIVITY_H__