lastactivity.h
/*
Copyright (c) 2005-2023 by Jakob Schröter <js@camaya.net>
This file is part of the gloox library. http://camaya.net/gloox
This software is distributed under a license. The full license
agreement can be found in the file LICENSE in this distribution.
This software may not be copied, modified, sold or distributed
other than expressed in the named license agreement.
This software is distributed without any warranty.
*/
#ifndef LASTACTIVITY_H__
#define LASTACTIVITY_H__
#include "iqhandler.h"
#include <ctime>
namespace gloox
{
class JID;
class ClientBase;
class LastActivityHandler;
class GLOOX_API LastActivity : public IqHandler
{
public:
class GLOOX_API Query : public StanzaExtension
{
public:
Query( const Tag* tag = 0 );
Query( const std::string& status, long seconds );
virtual ~Query();
long seconds() const { return m_seconds; }
const std::string& status() const { return m_status; }
// reimplemented from StanzaExtension
virtual const std::string& filterString() const;
// reimplemented from StanzaExtension
virtual StanzaExtension* newInstance( const Tag* tag ) const
{
return new Query( tag );
}
// reimplemented from StanzaExtension
virtual Tag* tag() const;
// reimplemented from StanzaExtension
virtual StanzaExtension* clone() const
{
return new Query( *this );
}
private:
long m_seconds;
std::string m_status;
};
LastActivity( ClientBase* parent );
virtual ~LastActivity();
void query( const JID& jid );
void registerLastActivityHandler( LastActivityHandler* lah ) { m_lastActivityHandler = lah; }
void removeLastActivityHandler() { m_lastActivityHandler = 0; }
void resetIdleTimer();
// reimplemented from IqHandler
virtual bool handleIq( const IQ& iq );
// reimplemented from IqHandler
virtual void handleIqID( const IQ& iq, int context );
private:
#ifdef LASTACTIVITY_TEST
public:
#endif
LastActivityHandler* m_lastActivityHandler;
ClientBase* m_parent;
time_t m_active;
};
}
#endif // LASTACTIVITY_H__
gloox::ClientBase
This is the common base class for a Jabber/XMPP Client and a Jabber Component.
Definition clientbase.h:79
gloox::IQ
An abstraction of an IQ stanza.
Definition iq.h:34
gloox::IqHandler
A virtual interface which can be reimplemented to receive IQ stanzas.
Definition iqhandler.h:32
gloox::JID
An abstraction of a JID.
Definition jid.h:31
gloox::LastActivityHandler
This is an virtual interface that, once reimplemented, allows to receive the results of Last-Activity...
Definition lastactivityhandler.h:31
gloox::LastActivity::Query::seconds
long seconds() const
Definition lastactivity.h:78
gloox::LastActivity::Query::clone
virtual StanzaExtension * clone() const
Definition lastactivity.h:100
gloox::LastActivity::Query::newInstance
virtual StanzaExtension * newInstance(const Tag *tag) const
Definition lastactivity.h:91
gloox::LastActivity::Query::Query
Query(const Tag *tag=0)
Definition lastactivity.cpp:28
gloox::LastActivity::Query::status
const std::string & status() const
Definition lastactivity.h:85
gloox::LastActivity::Query::tag
virtual Tag * tag() const
Definition lastactivity.cpp:57
gloox::LastActivity
This is an implementation of XEP-0012 (Last Activity) for both clients and components.
Definition lastactivity.h:40
gloox::LastActivity::removeLastActivityHandler
void removeLastActivityHandler()
Definition lastactivity.h:139
gloox::LastActivity::LastActivity
LastActivity(ClientBase *parent)
Definition lastactivity.cpp:68
gloox::LastActivity::registerLastActivityHandler
void registerLastActivityHandler(LastActivityHandler *lah)
Definition lastactivity.h:134
gloox::StanzaExtension::StanzaExtension
StanzaExtension(int type)
Definition stanzaextension.h:211
gloox::Tag
This is an abstraction of an XML element.
Definition tag.h:47
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28