Changeset View
Changeset View
Standalone View
Standalone View
source/lobby/glooxwrapper/glooxwrapper.h
/* Copyright (C) 2014 Wildfire Games. | /* Copyright (C) 2017 Wildfire Games. | ||||
elexis: 2017 | |||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | |||||
// Prevent gloox pulling in windows.h | // Prevent gloox pulling in windows.h | ||||
# define _WINDOWS_ | # define _WINDOWS_ | ||||
#endif | #endif | ||||
#include <gloox/client.h> | #include <gloox/client.h> | ||||
#include <gloox/mucroom.h> | #include <gloox/mucroom.h> | ||||
#include <gloox/registration.h> | #include <gloox/registration.h> | ||||
#include <gloox/message.h> | #include <gloox/message.h> | ||||
#include <gloox/jinglecontent.h> | |||||
#include <gloox/jingleiceudp.h> | |||||
#include <gloox/jinglesessionhandler.h> | |||||
#include <gloox/jinglesessionmanager.h> | |||||
#include <cstring> | #include <cstring> | ||||
#if OS_WIN | #if OS_WIN | ||||
#define GLOOXWRAPPER_API __declspec(dllexport) | #define GLOOXWRAPPER_API __declspec(dllexport) | ||||
#else | #else | ||||
#define GLOOXWRAPPER_API | #define GLOOXWRAPPER_API | ||||
#endif | #endif | ||||
Show All 13 Lines | namespace glooxwrapper | ||||
class OOB; | class OOB; | ||||
class Presence; | class Presence; | ||||
class StanzaError; | class StanzaError; | ||||
class StanzaExtension; | class StanzaExtension; | ||||
class Tag; | class Tag; | ||||
class ClientImpl; | class ClientImpl; | ||||
class MUCRoomHandlerWrapper; | class MUCRoomHandlerWrapper; | ||||
class SessionHandlerWrapper; | |||||
GLOOXWRAPPER_API void* glooxwrapper_alloc(size_t size); | GLOOXWRAPPER_API void* glooxwrapper_alloc(size_t size); | ||||
GLOOXWRAPPER_API void glooxwrapper_free(void* p); | GLOOXWRAPPER_API void glooxwrapper_free(void* p); | ||||
class string | class string | ||||
{ | { | ||||
private: | private: | ||||
size_t m_Size; | size_t m_Size; | ||||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | void clear() | ||||
while (n) | while (n) | ||||
{ | { | ||||
node* next = n->m_Next; | node* next = n->m_Next; | ||||
glooxwrapper_free(n); | glooxwrapper_free(n); | ||||
n = next; | n = next; | ||||
} | } | ||||
m_Head = m_Tail = NULL; | m_Head = m_Tail = NULL; | ||||
} | } | ||||
const T& front() const | |||||
{ | |||||
return *begin(); | |||||
} | |||||
}; | }; | ||||
typedef glooxwrapper::list<Tag*> TagList; | typedef glooxwrapper::list<Tag*> TagList; | ||||
typedef glooxwrapper::list<const Tag*> ConstTagList; | typedef glooxwrapper::list<const Tag*> ConstTagList; | ||||
struct CertInfo | struct CertInfo | ||||
{ | { | ||||
int status; | int status; | ||||
▲ Show 20 Lines • Show All 299 Lines • ▼ Show 20 Lines | public: | ||||
bool setXmlns(const string& xmlns); | bool setXmlns(const string& xmlns); | ||||
string xml() const; | string xml() const; | ||||
void addChild(Tag* child); | void addChild(Tag* child); | ||||
string name() const; | string name() const; | ||||
string cdata() const; | string cdata() const; | ||||
const Tag* findTag_clone(const string& expression) const; // like findTag but must be Tag::free()d | const Tag* findTag_clone(const string& expression) const; // like findTag but must be Tag::free()d | ||||
ConstTagList findTagList_clone(const string& expression) const; // like findTagList but each tag must be Tag::free()d | ConstTagList findTagList_clone(const string& expression) const; // like findTagList but each tag must be Tag::free()d | ||||
}; | }; | ||||
namespace Jingle | |||||
{ | |||||
class GLOOXWRAPPER_API Plugin | |||||
{ | |||||
protected: | |||||
const gloox::Jingle::Plugin* m_Wrapped; | |||||
bool m_Owned; | |||||
public: | |||||
Plugin(const gloox::Jingle::Plugin* wrapped, bool owned) : m_Wrapped(wrapped), m_Owned(owned) {} | |||||
virtual ~Plugin(); | |||||
const Plugin findPlugin(int type) const; | |||||
const gloox::Jingle::Plugin* getWrapped() const { return m_Wrapped; } | |||||
}; | |||||
typedef list<const Plugin*> PluginList; | |||||
class GLOOXWRAPPER_API Content : public Plugin | |||||
{ | |||||
public: | |||||
Content(const string& name, const PluginList& plugins); | |||||
Content(); | |||||
}; | |||||
class GLOOXWRAPPER_API ICEUDP : public Plugin | |||||
{ | |||||
public: | |||||
struct Candidate { | |||||
string ip; | |||||
int port; | |||||
}; | |||||
typedef std::list<Candidate> CandidateList; | |||||
ICEUDP(CandidateList& candidates); | |||||
ICEUDP(); | |||||
const CandidateList candidates() const; | |||||
}; | |||||
class GLOOXWRAPPER_API Session | |||||
{ | |||||
protected: | |||||
gloox::Jingle::Session* m_Wrapped; | |||||
bool m_Owned; | |||||
public: | |||||
class GLOOXWRAPPER_API Jingle | |||||
{ | |||||
private: | |||||
const gloox::Jingle::Session::Jingle* m_Wrapped; | |||||
bool m_Owned; | |||||
public: | |||||
Jingle(const gloox::Jingle::Session::Jingle* wrapped, bool owned) : m_Wrapped(wrapped), m_Owned(owned) {} | |||||
const PluginList plugins() const; | |||||
ICEUDP::Candidate getCandidate() const; | |||||
}; | |||||
Session(gloox::Jingle::Session* wrapped, bool owned) : m_Wrapped(wrapped), m_Owned(owned) {} | |||||
bool sessionInitiate(char* ipStr, uint16_t port); | |||||
}; | |||||
class GLOOXWRAPPER_API SessionHandler | |||||
{ | |||||
public: | |||||
virtual ~SessionHandler() {} | |||||
virtual void handleSessionAction(gloox::Jingle::Action action, Session *session, const Session::Jingle *jingle) = 0; | |||||
}; | |||||
} | |||||
class GLOOXWRAPPER_API SessionManager | |||||
{ | |||||
private: | |||||
gloox::Jingle::SessionManager* m_Wrapped; | |||||
SessionHandlerWrapper* m_HandlerWrapper; | |||||
public: | |||||
SessionManager(Client* parent, Jingle::SessionHandler* sh); | |||||
~SessionManager(); | |||||
void registerPlugins(); | |||||
Jingle::Session createSession(const JID& callee); | |||||
}; | |||||
} | } | ||||
#endif // INCLUDED_GLOOXWRAPPER_H | #endif // INCLUDED_GLOOXWRAPPER_H |
Wildfire Games · Phabricator
2017