From f9913fa28a27f23fde2d4956c62cbb2fb2bc2ee8 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Thu, 21 Nov 2013 22:16:57 +0100 Subject: Boost/C++11 shared pointers. --- src/security/sasl/SASLContext.cpp | 24 ++++++++++++------------ src/security/sasl/SASLMechanismFactory.cpp | 8 ++++---- src/security/sasl/SASLSession.cpp | 26 +++++++++++++------------- src/security/sasl/SASLSocket.cpp | 2 +- src/security/sasl/builtinSASLMechanism.cpp | 8 ++++---- src/security/sasl/defaultSASLAuthenticator.cpp | 24 ++++++++++++------------ 6 files changed, 46 insertions(+), 46 deletions(-) (limited to 'src/security/sasl') diff --git a/src/security/sasl/SASLContext.cpp b/src/security/sasl/SASLContext.cpp index 7b24f1e3..c4d60bd9 100644 --- a/src/security/sasl/SASLContext.cpp +++ b/src/security/sasl/SASLContext.cpp @@ -62,27 +62,27 @@ SASLContext::~SASLContext() } -ref SASLContext::createSession +shared_ptr SASLContext::createSession (const string& serviceName, - ref auth, ref mech) + shared_ptr auth, shared_ptr mech) { - return vmime::create - (serviceName, thisRef().dynamicCast (), auth, mech); + return make_shared + (serviceName, dynamicCast (shared_from_this()), auth, mech); } -ref SASLContext::createMechanism(const string& name) +shared_ptr SASLContext::createMechanism(const string& name) { return SASLMechanismFactory::getInstance()->create - (thisRef().dynamicCast (), name); + (dynamicCast (shared_from_this()), name); } -ref SASLContext::suggestMechanism - (const std::vector >& mechs) +shared_ptr SASLContext::suggestMechanism + (const std::vector >& mechs) { if (mechs.empty()) - return 0; + return null; std::ostringstream oss; @@ -102,7 +102,7 @@ ref SASLContext::suggestMechanism } } - return 0; + return null; } @@ -113,7 +113,7 @@ void SASLContext::decodeB64(const string& input, byte_t** output, long* outputLe utility::inputStreamStringAdapter is(input); utility::outputStreamStringAdapter os(res); - ref dec = + shared_ptr dec = utility::encoder::encoderFactory::getInstance()->create("base64"); dec->decode(is, os); @@ -134,7 +134,7 @@ const string SASLContext::encodeB64(const byte_t* input, const long inputLen) utility::inputStreamByteBufferAdapter is(input, inputLen); utility::outputStreamStringAdapter os(res); - ref enc = + shared_ptr enc = utility::encoder::encoderFactory::getInstance()->create("base64"); enc->encode(is, os); diff --git a/src/security/sasl/SASLMechanismFactory.cpp b/src/security/sasl/SASLMechanismFactory.cpp index 0f2dd3af..255a13f1 100644 --- a/src/security/sasl/SASLMechanismFactory.cpp +++ b/src/security/sasl/SASLMechanismFactory.cpp @@ -68,15 +68,15 @@ SASLMechanismFactory* SASLMechanismFactory::getInstance() } -ref SASLMechanismFactory::create - (ref ctx, const string& name_) +shared_ptr SASLMechanismFactory::create + (shared_ptr ctx, const string& name_) { const string name(utility::stringUtils::toUpper(name_)); // Check for built-in mechanisms if (isMechanismSupported(name)) { - return vmime::create (ctx, name); + return make_shared (ctx, name); } // Check for registered mechanisms else @@ -88,7 +88,7 @@ ref SASLMechanismFactory::create } throw exceptions::no_such_mechanism(name); - return 0; + return null; } diff --git a/src/security/sasl/SASLSession.cpp b/src/security/sasl/SASLSession.cpp index c34bdd7f..1bdd0889 100644 --- a/src/security/sasl/SASLSession.cpp +++ b/src/security/sasl/SASLSession.cpp @@ -43,8 +43,8 @@ namespace security { namespace sasl { -SASLSession::SASLSession(const string& serviceName, ref ctx, - ref auth, ref mech) +SASLSession::SASLSession(const string& serviceName, shared_ptr ctx, + shared_ptr auth, shared_ptr mech) : m_serviceName(serviceName), m_context(ctx), m_auth(auth), m_mech(mech), m_gsaslContext(0), m_gsaslSession(0) { @@ -61,38 +61,38 @@ SASLSession::SASLSession(const string& serviceName, ref ctx, SASLSession::~SASLSession() { gsasl_finish(m_gsaslSession); - m_gsaslSession = 0; + m_gsaslSession = NULL; gsasl_done(m_gsaslContext); - m_gsaslContext = 0; + m_gsaslContext = NULL; } void SASLSession::init() { - ref saslAuth = m_auth.dynamicCast (); + shared_ptr saslAuth = dynamicCast (m_auth); if (saslAuth) { saslAuth->setSASLMechanism(m_mech); - saslAuth->setSASLSession(thisRef().dynamicCast ()); + saslAuth->setSASLSession(dynamicCast (shared_from_this())); } } -ref SASLSession::getAuthenticator() +shared_ptr SASLSession::getAuthenticator() { return m_auth; } -ref SASLSession::getMechanism() +shared_ptr SASLSession::getMechanism() { return m_mech; } -ref SASLSession::getContext() +shared_ptr SASLSession::getContext() { return m_context; } @@ -102,14 +102,14 @@ bool SASLSession::evaluateChallenge (const byte_t* challenge, const long challengeLen, byte_t** response, long* responseLen) { - return m_mech->step(thisRef().dynamicCast (), + return m_mech->step(dynamicCast (shared_from_this()), challenge, challengeLen, response, responseLen); } -ref SASLSession::getSecuredSocket(ref sok) +shared_ptr SASLSession::getSecuredSocket(shared_ptr sok) { - return vmime::create (thisRef().dynamicCast (), sok); + return make_shared (dynamicCast (shared_from_this()), sok); } @@ -126,7 +126,7 @@ int SASLSession::gsaslCallback SASLSession* sess = reinterpret_cast (gsasl_callback_hook_get(ctx)); if (!sess) return GSASL_AUTHENTICATION_ERROR; - ref auth = sess->getAuthenticator(); + shared_ptr auth = sess->getAuthenticator(); try { diff --git a/src/security/sasl/SASLSocket.cpp b/src/security/sasl/SASLSocket.cpp index b6b1d272..37e297dc 100644 --- a/src/security/sasl/SASLSocket.cpp +++ b/src/security/sasl/SASLSocket.cpp @@ -43,7 +43,7 @@ namespace sasl { -SASLSocket::SASLSocket(ref sess, ref wrapped) +SASLSocket::SASLSocket(shared_ptr sess, shared_ptr wrapped) : m_session(sess), m_wrapped(wrapped), m_pendingBuffer(0), m_pendingPos(0), m_pendingLen(0) { diff --git a/src/security/sasl/builtinSASLMechanism.cpp b/src/security/sasl/builtinSASLMechanism.cpp index 86b429bf..e7bd723e 100644 --- a/src/security/sasl/builtinSASLMechanism.cpp +++ b/src/security/sasl/builtinSASLMechanism.cpp @@ -45,7 +45,7 @@ namespace security { namespace sasl { -builtinSASLMechanism::builtinSASLMechanism(ref ctx, const string& name) +builtinSASLMechanism::builtinSASLMechanism(shared_ptr ctx, const string& name) : m_context(ctx), m_name(name), m_complete(false) { } @@ -63,7 +63,7 @@ const string builtinSASLMechanism::getName() const bool builtinSASLMechanism::step - (ref sess, const byte_t* challenge, const long challengeLen, + (shared_ptr sess, const byte_t* challenge, const long challengeLen, byte_t** response, long* responseLen) { char* output = 0; @@ -121,7 +121,7 @@ bool builtinSASLMechanism::isComplete() const void builtinSASLMechanism::encode - (ref sess, const byte_t* input, const long inputLen, + (shared_ptr sess, const byte_t* input, const long inputLen, byte_t** output, long* outputLen) { char* coutput = 0; @@ -154,7 +154,7 @@ void builtinSASLMechanism::encode void builtinSASLMechanism::decode - (ref sess, const byte_t* input, const long inputLen, + (shared_ptr sess, const byte_t* input, const long inputLen, byte_t** output, long* outputLen) { char* coutput = 0; diff --git a/src/security/sasl/defaultSASLAuthenticator.cpp b/src/security/sasl/defaultSASLAuthenticator.cpp index bb72e56f..7fe9b3eb 100644 --- a/src/security/sasl/defaultSASLAuthenticator.cpp +++ b/src/security/sasl/defaultSASLAuthenticator.cpp @@ -51,14 +51,14 @@ defaultSASLAuthenticator::~defaultSASLAuthenticator() } -const std::vector > +const std::vector > defaultSASLAuthenticator::getAcceptableMechanisms - (const std::vector >& available, - ref suggested) const + (const std::vector >& available, + shared_ptr suggested) const { if (suggested) { - std::vector > res; + std::vector > res; res.push_back(suggested); @@ -103,42 +103,42 @@ const string defaultSASLAuthenticator::getAnonymousToken() const const string defaultSASLAuthenticator::getServiceName() const { - return m_saslSession.acquire()->getServiceName(); + return m_saslSession.lock()->getServiceName(); } -void defaultSASLAuthenticator::setService(ref serv) +void defaultSASLAuthenticator::setService(shared_ptr serv) { m_service = serv; m_default.setService(serv); } -weak_ref defaultSASLAuthenticator::getService() const +weak_ptr defaultSASLAuthenticator::getService() const { return m_service; } -void defaultSASLAuthenticator::setSASLSession(ref sess) +void defaultSASLAuthenticator::setSASLSession(shared_ptr sess) { m_saslSession = sess; } -ref defaultSASLAuthenticator::getSASLSession() const +shared_ptr defaultSASLAuthenticator::getSASLSession() const { - return m_saslSession.acquire().constCast (); + return constCast (m_saslSession.lock()); } -void defaultSASLAuthenticator::setSASLMechanism(ref mech) +void defaultSASLAuthenticator::setSASLMechanism(shared_ptr mech) { m_saslMech = mech; } -ref defaultSASLAuthenticator::getSASLMechanism() const +shared_ptr defaultSASLAuthenticator::getSASLMechanism() const { return m_saslMech; } -- cgit v1.2.3