Changeset View
Changeset View
Standalone View
Standalone View
source/lobby/glooxwrapper/glooxwrapper.h
/* Copyright (C) 2018 Wildfire Games. | /* Copyright (C) 2019 Wildfire Games. | ||||
* 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 570 Lines • ▼ Show 20 Lines | public: | ||||
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 | ||||
}; | }; | ||||
/** | |||||
* See XEP-0166: Jingle and https://camaya.net/api/gloox/namespacegloox_1_1Jingle.html. | |||||
*/ | |||||
namespace Jingle | namespace Jingle | ||||
{ | { | ||||
class GLOOXWRAPPER_API Plugin | class GLOOXWRAPPER_API Plugin | ||||
{ | { | ||||
protected: | protected: | ||||
const gloox::Jingle::Plugin* m_Wrapped; | const gloox::Jingle::Plugin* m_Wrapped; | ||||
bool m_Owned; | bool m_Owned; | ||||
public: | public: | ||||
Plugin(const gloox::Jingle::Plugin* wrapped, bool owned) : m_Wrapped(wrapped), m_Owned(owned) {} | Plugin(const gloox::Jingle::Plugin* wrapped, bool owned) : m_Wrapped(wrapped), m_Owned(owned) {} | ||||
virtual ~Plugin(); | virtual ~Plugin(); | ||||
const Plugin findPlugin(int type) const; | const Plugin findPlugin(int type) const; | ||||
const gloox::Jingle::Plugin* getWrapped() const { return m_Wrapped; } | const gloox::Jingle::Plugin* getWrapped() const { return m_Wrapped; } | ||||
}; | }; | ||||
typedef list<const Plugin*> PluginList; | typedef list<const Plugin*> PluginList; | ||||
class GLOOXWRAPPER_API Content : public Plugin | /** | ||||
{ | * See XEP-0176: Jingle ICE-UDP Transport Method | ||||
public: | */ | ||||
Content(const string& name, const PluginList& plugins); | class GLOOXWRAPPER_API ICEUDP | ||||
Content(); | |||||
}; | |||||
class GLOOXWRAPPER_API ICEUDP : public Plugin | |||||
{ | { | ||||
public: | public: | ||||
struct Candidate { | struct Candidate { | ||||
string ip; | string ip; | ||||
int port; | int port; | ||||
}; | }; | ||||
private: | |||||
typedef std::list<Candidate> CandidateList; | // Class not implemented as it is not used. | ||||
ICEUDP() = delete; | |||||
ICEUDP(CandidateList& candidates); | |||||
ICEUDP(); | |||||
const CandidateList candidates() const; | |||||
}; | }; | ||||
class GLOOXWRAPPER_API Session | class GLOOXWRAPPER_API Session | ||||
{ | { | ||||
protected: | protected: | ||||
gloox::Jingle::Session* m_Wrapped; | gloox::Jingle::Session* m_Wrapped; | ||||
bool m_Owned; | bool m_Owned; | ||||
public: | public: | ||||
class GLOOXWRAPPER_API Jingle | class GLOOXWRAPPER_API Jingle | ||||
{ | { | ||||
private: | private: | ||||
const gloox::Jingle::Session::Jingle* m_Wrapped; | const gloox::Jingle::Session::Jingle* m_Wrapped; | ||||
bool m_Owned; | bool m_Owned; | ||||
elexis: This was the unused variable from D2090 fixed by the `~Session` conditionally deleting… | |||||
public: | public: | ||||
Jingle(const gloox::Jingle::Session::Jingle* wrapped, bool owned) : m_Wrapped(wrapped), m_Owned(owned) {} | Jingle(const gloox::Jingle::Session::Jingle* wrapped, bool owned) : m_Wrapped(wrapped), m_Owned(owned) {} | ||||
const PluginList plugins() const; | |||||
ICEUDP::Candidate getCandidate() const; | ICEUDP::Candidate getCandidate() const; | ||||
}; | }; | ||||
Session(gloox::Jingle::Session* wrapped, bool owned) : m_Wrapped(wrapped), m_Owned(owned) {} | Session(gloox::Jingle::Session* wrapped, bool owned); | ||||
~Session(); | |||||
bool sessionInitiate(char* ipStr, uint16_t port); | bool sessionInitiate(char* ipStr, uint16_t port); | ||||
}; | }; | ||||
class GLOOXWRAPPER_API SessionHandler | class GLOOXWRAPPER_API SessionHandler | ||||
{ | { | ||||
public: | public: | ||||
virtual ~SessionHandler() {} | virtual ~SessionHandler() {} | ||||
virtual void handleSessionAction(gloox::Jingle::Action action, Session* session, const Session::Jingle* jingle) = 0; | virtual void handleSessionAction(gloox::Jingle::Action action, Session& session, const Session::Jingle& jingle) = 0; | ||||
}; | }; | ||||
} | } | ||||
class GLOOXWRAPPER_API SessionManager | class GLOOXWRAPPER_API SessionManager | ||||
{ | { | ||||
private: | private: | ||||
gloox::Jingle::SessionManager* m_Wrapped; | gloox::Jingle::SessionManager* m_Wrapped; | ||||
Show All 12 Lines |
Wildfire Games · Phabricator
This was the unused variable from D2090 fixed by the ~Session conditionally deleting m_Wrapped.
The leak didn't occur because it's only use is with m_Owned = false (and rightly so as gloox creates the message, calls this XmppClient implemented handleSessionAction with this session and deletes it afterwards).