2008-03-03 22:52:07 +00:00
|
|
|
//////////////////////////////////////////////////
|
|
|
|
// Blabber [JabberSpeak.h]
|
|
|
|
// This monolith talks the jabber language!
|
|
|
|
//////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef JABBER_SPEAK_H
|
|
|
|
#define JABBER_SPEAK_H
|
|
|
|
|
2019-06-21 18:55:03 +00:00
|
|
|
#include <gloox/bookmarkstorage.h>
|
2019-06-10 12:52:31 +00:00
|
|
|
#include <gloox/client.h>
|
2019-06-04 19:31:00 +00:00
|
|
|
#include <gloox/connectionlistener.h>
|
2019-06-22 11:02:08 +00:00
|
|
|
#include <gloox/presence.h>
|
2020-11-22 17:16:46 +00:00
|
|
|
#include <gloox/pubsubmanager.h>
|
2019-09-27 19:27:39 +00:00
|
|
|
#include <gloox/registration.h>
|
2019-07-13 14:30:41 +00:00
|
|
|
#include <gloox/softwareversion.h>
|
2020-11-21 21:05:56 +00:00
|
|
|
#include <gloox/vcardhandler.h>
|
|
|
|
#include <gloox/vcardmanager.h>
|
2019-06-04 19:31:00 +00:00
|
|
|
|
2019-09-28 08:28:24 +00:00
|
|
|
#include "../network/BookmarkManager.h"
|
|
|
|
|
2019-06-04 19:31:00 +00:00
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
#include <Looper.h>
|
|
|
|
#include "Agent.h"
|
|
|
|
#include "AgentList.h"
|
|
|
|
#include "BlabberSettings.h"
|
2020-08-21 09:49:53 +00:00
|
|
|
#include "../ui/TalkView.h"
|
2019-06-04 19:31:00 +00:00
|
|
|
#include "UserID.h"
|
|
|
|
#include "XMLReader.h"
|
|
|
|
|
2019-09-29 18:55:34 +00:00
|
|
|
enum {
|
2020-11-21 21:05:56 +00:00
|
|
|
kAuthenticationFailed = 'Aerr',
|
|
|
|
kVCardReceived = 'vcrd'
|
2019-09-29 18:55:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class JabberSpeak : public BHandler, public XMLReader,
|
2020-11-21 21:05:56 +00:00
|
|
|
public gloox::ConnectionListener, public gloox::IqHandler,
|
|
|
|
public gloox::VCardHandler
|
2019-06-04 19:31:00 +00:00
|
|
|
{
|
2008-03-03 22:52:07 +00:00
|
|
|
public:
|
|
|
|
enum iq_intent {LOGIN, ROSTER, AGENTS, REGISTER, SEND_REGISTER, UNREGISTER, SEND_UNREGISTER, NEW_USER, MESSAGE, CHAT};
|
|
|
|
|
|
|
|
typedef map<string, iq_intent> IQMap;
|
|
|
|
typedef map<string, iq_intent>::iterator IQIter;
|
|
|
|
typedef map<string, iq_intent>::const_iterator ConstIQIter;
|
|
|
|
|
|
|
|
public:
|
|
|
|
// CREATORS
|
|
|
|
static JabberSpeak *Instance();
|
|
|
|
~JabberSpeak();
|
|
|
|
|
2019-06-05 20:41:00 +00:00
|
|
|
void Reset();
|
2008-03-03 22:52:07 +00:00
|
|
|
void JabberSpeakReset();
|
|
|
|
|
|
|
|
// OUTGOING COMMUNICATION
|
2019-09-27 19:27:39 +00:00
|
|
|
void SendConnect(string username = "", string password = "", string realname = "", bool suppress_auto_connect = false);
|
2008-03-03 22:52:07 +00:00
|
|
|
void SendDisconnect();
|
|
|
|
void SendSubscriptionRequest(string username);
|
|
|
|
void SendUnsubscriptionRequest(string username);
|
2019-09-28 20:54:27 +00:00
|
|
|
void SetFriendlyName(const gloox::JID& who, BString name);
|
2008-03-03 22:52:07 +00:00
|
|
|
void RemoveFromRoster(const UserID *removed_user);
|
2019-07-14 10:26:38 +00:00
|
|
|
void SendMessage(const gloox::Message::MessageType type,
|
2020-08-12 12:37:19 +00:00
|
|
|
const gloox::JID&, string message,
|
2019-07-14 10:26:38 +00:00
|
|
|
string thread_id);
|
|
|
|
void SendMessage(const gloox::Message::MessageType type,
|
|
|
|
string group_room, string message);
|
2019-06-22 11:02:08 +00:00
|
|
|
void SendPresence(gloox::Presence::PresenceType = gloox::Presence::Probe, string status = "");
|
2008-03-03 22:52:07 +00:00
|
|
|
void SendLastPresence();
|
|
|
|
void SendGroupUnvitation(string _group_room, string _group_username);
|
|
|
|
|
|
|
|
void _SendUserRegistration(string username, string password, string resource);
|
|
|
|
void RegisterWithAgent(string agent);
|
|
|
|
void UnregisterWithAgent(string agent);
|
2020-11-21 21:05:56 +00:00
|
|
|
|
|
|
|
void RequestVCard(const gloox::JID& jid);
|
2020-11-22 17:16:46 +00:00
|
|
|
void RequestPubSubItem(const gloox::JID& jid,
|
|
|
|
const std::string& node, const std::string& subid,
|
|
|
|
gloox::PubSub::ResultHandler* handler);
|
2008-03-03 22:52:07 +00:00
|
|
|
|
|
|
|
// INCOMING COMMUNICATION
|
|
|
|
void OnTag(XMLEntity *entity);
|
|
|
|
|
|
|
|
// SELECTORS
|
|
|
|
const string CurrentRealName() const;
|
|
|
|
const string CurrentLogin() const;
|
|
|
|
|
2008-03-15 12:29:17 +00:00
|
|
|
string GetRealServer();
|
|
|
|
int GetRealPort();
|
2019-06-04 19:31:00 +00:00
|
|
|
|
2020-08-13 19:40:06 +00:00
|
|
|
// gloox::ConnectionListener
|
2019-06-04 19:31:00 +00:00
|
|
|
void onConnect() final;
|
|
|
|
void onDisconnect(gloox::ConnectionError e) final;
|
|
|
|
bool onTLSConnect(const gloox::CertInfo& info) final;
|
|
|
|
|
2020-08-13 19:40:06 +00:00
|
|
|
// gloox::IqHandler
|
|
|
|
bool handleIq(const gloox::IQ&) final;
|
|
|
|
void handleIqID(const gloox::IQ&, int) final;
|
|
|
|
|
2020-11-21 21:05:56 +00:00
|
|
|
// gloox::VCardHandler
|
|
|
|
void handleVCard(const gloox::JID& jid, const gloox::VCard* vcard) final;
|
|
|
|
void handleVCardResult(VCardContext context,
|
|
|
|
const gloox::JID& jid, gloox::StanzaError se) final;
|
|
|
|
|
2019-07-13 17:42:59 +00:00
|
|
|
gloox::Client* GlooxClient() { return fClient; }
|
2019-06-21 18:55:03 +00:00
|
|
|
|
2008-03-03 22:52:07 +00:00
|
|
|
protected:
|
|
|
|
// CREATORS
|
|
|
|
JabberSpeak();
|
|
|
|
|
|
|
|
private:
|
2019-06-04 19:31:00 +00:00
|
|
|
static int32 _SpawnConnectionThread(void *obj);
|
|
|
|
void _ConnectionThread();
|
2008-03-03 22:52:07 +00:00
|
|
|
|
|
|
|
// OUTGOING COMMUNICATION
|
2019-07-13 14:30:41 +00:00
|
|
|
void _ProcessVersionRequest(void);
|
2008-03-03 22:52:07 +00:00
|
|
|
|
|
|
|
// INCOMING COMMUNICATION
|
|
|
|
void _ParseAgentList(XMLEntity *iq_agent_entity);
|
|
|
|
|
|
|
|
// pointer to the singleton
|
|
|
|
BlabberSettings *_blabber_settings;
|
|
|
|
|
|
|
|
// some information about the current login status
|
|
|
|
string _curr_realname;
|
|
|
|
string _curr_login;
|
|
|
|
string _password;
|
2008-03-10 01:13:03 +00:00
|
|
|
|
2008-03-03 22:52:07 +00:00
|
|
|
bool _am_logged_in;
|
|
|
|
bool _reconnecting;
|
|
|
|
|
|
|
|
bool _got_some_agent_info;
|
|
|
|
|
|
|
|
// communication state information
|
|
|
|
IQMap _iq_map;
|
|
|
|
|
|
|
|
// CREATORS
|
|
|
|
static JabberSpeak *_instance;
|
|
|
|
|
|
|
|
// threading
|
|
|
|
thread_id _connection_thread_id;
|
|
|
|
|
2019-06-10 12:52:31 +00:00
|
|
|
gloox::Client* fClient;
|
2019-09-27 19:27:39 +00:00
|
|
|
gloox::Registration* fRegistration;
|
2020-11-21 21:05:56 +00:00
|
|
|
gloox::VCardManager* fVCardManager;
|
2020-11-22 17:16:46 +00:00
|
|
|
gloox::PubSub::Manager* fPubSubManager;
|
2008-03-03 22:52:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|