2010-05-27 20:04:31 -05:00
|
|
|
/*
|
|
|
|
* Copyright 2010, Pier Luigi Fiorini. All rights reserved.
|
|
|
|
* Distributed under the terms of the GPL v2 License.
|
|
|
|
*/
|
2010-05-28 15:41:58 -05:00
|
|
|
#ifndef _JABBER_HANDLER_H
|
|
|
|
#define _JABBER_HANDLER_H
|
2010-05-27 20:04:31 -05:00
|
|
|
|
2010-05-29 23:26:36 -05:00
|
|
|
#include <Path.h>
|
2010-05-27 20:04:31 -05:00
|
|
|
#include <String.h>
|
|
|
|
|
|
|
|
#include <libgloox/client.h>
|
|
|
|
#include <libgloox/connectionlistener.h>
|
|
|
|
#include <libgloox/connectiontcpclient.h>
|
|
|
|
#include <libgloox/discohandler.h>
|
|
|
|
#include <libgloox/disco.h>
|
|
|
|
#include <libgloox/rostermanager.h>
|
|
|
|
#include <libgloox/loghandler.h>
|
|
|
|
#include <libgloox/logsink.h>
|
|
|
|
#include <libgloox/messagehandler.h>
|
|
|
|
#include <libgloox/message.h>
|
|
|
|
#include <libgloox/presence.h>
|
|
|
|
#include <libgloox/vcardhandler.h>
|
|
|
|
#include <libgloox/vcardmanager.h>
|
|
|
|
|
2010-05-29 23:26:36 -05:00
|
|
|
#include <CayaProtocol.h>
|
|
|
|
#include <CayaConstants.h>
|
|
|
|
|
|
|
|
class BList;
|
2010-05-27 20:04:31 -05:00
|
|
|
|
2010-05-28 15:41:58 -05:00
|
|
|
class JabberHandler : public CayaProtocol, gloox::RosterListener, gloox::ConnectionListener,
|
|
|
|
gloox::LogHandler, gloox::MessageHandler, gloox::VCardHandler {
|
2010-05-27 20:04:31 -05:00
|
|
|
public:
|
2010-05-28 15:41:58 -05:00
|
|
|
JabberHandler();
|
|
|
|
virtual ~JabberHandler();
|
2010-05-27 20:04:31 -05:00
|
|
|
|
|
|
|
virtual status_t Init(CayaProtocolMessengerInterface*);
|
|
|
|
|
|
|
|
virtual status_t Process(BMessage* msg);
|
|
|
|
|
|
|
|
virtual status_t Shutdown();
|
|
|
|
|
|
|
|
virtual const char* Signature() const;
|
|
|
|
virtual const char* FriendlySignature() const;
|
|
|
|
|
|
|
|
virtual status_t UpdateSettings(BMessage* msg);
|
|
|
|
|
|
|
|
virtual uint32 GetEncoding();
|
|
|
|
|
|
|
|
virtual CayaProtocolMessengerInterface*
|
|
|
|
MessengerInterface() const;
|
|
|
|
|
2010-05-28 15:41:58 -05:00
|
|
|
virtual void OverrideSettings() = 0;
|
|
|
|
virtual BString ComposeJID() const = 0;
|
|
|
|
|
|
|
|
protected:
|
2010-05-27 20:04:31 -05:00
|
|
|
BString fUsername;
|
|
|
|
BString fPassword;
|
|
|
|
BString fServer;
|
|
|
|
BString fResource;
|
2010-05-30 07:17:59 -05:00
|
|
|
uint16 fPort;
|
2010-05-27 20:04:31 -05:00
|
|
|
|
2010-05-28 15:41:58 -05:00
|
|
|
private:
|
2010-05-27 20:04:31 -05:00
|
|
|
CayaProtocolMessengerInterface*
|
|
|
|
fServerMessenger;
|
|
|
|
|
|
|
|
gloox::Client* fClient;
|
|
|
|
gloox::ConnectionTCPClient*
|
|
|
|
fConnection;
|
|
|
|
gloox::VCardManager* fVCardManager;
|
|
|
|
|
2010-05-30 07:17:59 -05:00
|
|
|
gloox::JID fJid;
|
2010-05-28 15:41:58 -05:00
|
|
|
thread_id fRecvThread;
|
|
|
|
|
2010-05-29 23:26:36 -05:00
|
|
|
BPath fCachePath;
|
|
|
|
BPath fAvatarCachePath;
|
|
|
|
BMessage fAvatarCache;
|
|
|
|
BList* fAvatars;
|
|
|
|
|
2010-05-28 15:41:58 -05:00
|
|
|
void _MessageSent(const char* id, const char* subject,
|
2010-05-27 20:04:31 -05:00
|
|
|
const char* body);
|
2010-05-28 15:41:58 -05:00
|
|
|
CayaStatus _GlooxStatusToCaya(gloox::Presence::PresenceType type);
|
2010-05-27 20:04:31 -05:00
|
|
|
|
2010-05-29 23:26:36 -05:00
|
|
|
status_t _SetupAvatarCache();
|
|
|
|
status_t _SaveAvatarCache();
|
|
|
|
void _CacheAvatar(const char* id, const char* binval, size_t length);
|
|
|
|
void _AvatarChanged(const char*id, const char* filename);
|
2010-05-30 07:17:59 -05:00
|
|
|
void _Progress(const char* title, const char* message, float progress);
|
2010-05-29 23:26:36 -05:00
|
|
|
|
2010-05-27 20:04:31 -05:00
|
|
|
virtual void onConnect();
|
|
|
|
virtual void onDisconnect(gloox::ConnectionError);
|
|
|
|
virtual bool onTLSConnect(const gloox::CertInfo&);
|
|
|
|
virtual void onResourceBindError(const gloox::Error*);
|
|
|
|
virtual void handleRoster(const gloox::Roster&);
|
|
|
|
virtual void handleMessage(const gloox::Message&, gloox::MessageSession*);
|
|
|
|
virtual void handleItemAdded(const gloox::JID&);
|
|
|
|
virtual void handleItemSubscribed(const gloox::JID&);
|
|
|
|
virtual void handleItemUnsubscribed(const gloox::JID&);
|
|
|
|
virtual void handleItemRemoved(const gloox::JID&);
|
|
|
|
virtual void handleItemUpdated(const gloox::JID&);
|
|
|
|
virtual void handleRosterPresence(const gloox::RosterItem&,
|
|
|
|
const std::string&, gloox::Presence::PresenceType,
|
|
|
|
const std::string&);
|
|
|
|
virtual void handleSelfPresence(const gloox::RosterItem&, const std::string&,
|
|
|
|
gloox::Presence::PresenceType, const std::string&);
|
|
|
|
virtual bool handleSubscriptionRequest(const gloox::JID&, const std::string&);
|
|
|
|
virtual bool handleUnsubscriptionRequest(const gloox::JID&, const std::string&);
|
|
|
|
virtual void handleNonrosterPresence(const gloox::Presence&);
|
|
|
|
virtual void handleRosterError(const gloox::IQ&);
|
|
|
|
virtual void handleLog(gloox::LogLevel, gloox::LogArea, const std::string&);
|
|
|
|
virtual void handleVCard(const gloox::JID&, const gloox::VCard*);
|
|
|
|
virtual void handleVCardResult(gloox::VCardHandler::VCardContext,
|
|
|
|
const gloox::JID&,
|
|
|
|
gloox::StanzaError);
|
|
|
|
};
|
|
|
|
|
|
|
|
extern const char* kProtocolSignature;
|
|
|
|
extern const char* kProtocolName;
|
|
|
|
|
2010-05-28 15:41:58 -05:00
|
|
|
#endif // _JABBER_HANDLER_H
|