1
0
forked from mirrors/0ad

Store the glooxRegistration inside the XmppClient

This commit is contained in:
phosit
2026-03-27 19:51:03 +01:00
parent 4a5b5ddfad
commit 1da954d455
2 changed files with 6 additions and 8 deletions
+5 -7
View File
@@ -139,7 +139,7 @@ XmppClient::XmppClient(const ScriptInterface* scriptInterface, const std::string
// If we are registering, only use the server name // If we are registering, only use the server name
m_client{CreateClient(regOpt, sUsername, m_server, sPassword)}, m_client{CreateClient(regOpt, sUsername, m_server, sPassword)},
m_mucRoom{CreateMucRoom(this, regOpt, m_client, sRoom, m_server, sNick)}, m_mucRoom{CreateMucRoom(this, regOpt, m_client, sRoom, m_server, sNick)},
m_registration(nullptr), m_registration{&m_client},
m_sessionManager{&m_client, this}, m_sessionManager{&m_client, this},
m_regOpt(regOpt), m_regOpt(regOpt),
m_username(sUsername), m_username(sUsername),
@@ -190,8 +190,7 @@ XmppClient::XmppClient(const ScriptInterface* scriptInterface, const std::string
m_client.registerMessageHandler(this); m_client.registerMessageHandler(this);
m_registration = new gloox::Registration(&m_client); m_registration.registerRegistrationHandler(this);
m_registration->registerRegistrationHandler(this);
// Uncomment to see the raw stanzas // Uncomment to see the raw stanzas
// m_client.logInstance().registerLogHandler(gloox::LogLevelDebug, gloox::LogAreaAll, this); // m_client.logInstance().registerLogHandler(gloox::LogLevelDebug, gloox::LogAreaAll, this);
@@ -212,7 +211,6 @@ XmppClient::~XmppClient()
this->disconnect(); this->disconnect();
DbgXMPP("XmppClient destroyed"); DbgXMPP("XmppClient destroyed");
delete m_registration;
// Workaround for memory leak in gloox 1.0/1.0.1 // Workaround for memory leak in gloox 1.0/1.0.1
m_client.removePresenceExtension(gloox::ExtCaps); m_client.removePresenceExtension(gloox::ExtCaps);
@@ -264,7 +262,7 @@ void XmppClient::onConnect()
} }
if (m_regOpt) if (m_regOpt)
m_registration->fetchRegistrationFields(); m_registration.fetchRegistrationFields();
} }
/** /**
@@ -537,7 +535,7 @@ void XmppClient::handleRegistrationFields(const gloox::JID&, int fields, std::st
gloox::RegistrationFields vals; gloox::RegistrationFields vals;
vals.username = m_username; vals.username = m_username;
vals.password = m_password; vals.password = m_password;
m_registration->createAccount(fields, vals); m_registration.createAccount(fields, vals);
} }
#if GLOOXVERSION >= 0x010100 #if GLOOXVERSION >= 0x010100
@@ -1213,7 +1211,7 @@ std::string XmppClient::GetUsername() const
*/ */
void XmppClient::ChangePassword(const std::string& newPassword) void XmppClient::ChangePassword(const std::string& newPassword)
{ {
m_registration->changePassword(m_client.jid().username(), newPassword); m_registration.changePassword(m_client.jid().username(), newPassword);
} }
/** /**
+1 -1
View File
@@ -49,7 +49,7 @@ private:
// Components // Components
gloox::Client m_client; gloox::Client m_client;
std::optional<gloox::MUCRoom> m_mucRoom; std::optional<gloox::MUCRoom> m_mucRoom;
gloox::Registration* m_registration; gloox::Registration m_registration;
gloox::Jingle::SessionManager m_sessionManager; gloox::Jingle::SessionManager m_sessionManager;
// Account infos // Account infos