Code improvements based on c++11 standard (ranged for loops and nullptr).

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/1/head
Michele Calgaro 3 years ago
parent 416bed9bc1
commit 82b07f1a3c
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -34,7 +34,7 @@ namespace Agent
// ListenerAdapter // ListenerAdapter
//-------------------------------------- //--------------------------------------
ListenerAdapter *ListenerAdapter::m_theListenerAdapter = NULL; ListenerAdapter *ListenerAdapter::m_theListenerAdapter = nullptr;
ListenerAdapter *ListenerAdapter::instance() ListenerAdapter *ListenerAdapter::instance()
{ {
@ -51,17 +51,15 @@ ListenerAdapter::ListenerAdapter(TQObject *parent) : TQObject(parent)
Listener* ListenerAdapter::findListener(PolkitAgentListener *listener) Listener* ListenerAdapter::findListener(PolkitAgentListener *listener)
{ {
TQValueList<Listener*>::iterator listerIt; for (Listener *&listItem : m_listeners)
for (listerIt = m_listeners.begin(); listerIt != m_listeners.end(); ++listerIt)
{ {
Listener *listItem = *listerIt;
if (listItem && listItem->listener() == listener) if (listItem && listItem->listener() == listener)
{ {
return listItem; return listItem;
} }
} }
return NULL; return nullptr;
} }
void ListenerAdapter::polkit_tqt_listener_initiate_authentication(PolkitAgentListener *listener, void ListenerAdapter::polkit_tqt_listener_initiate_authentication(PolkitAgentListener *listener,
@ -74,7 +72,7 @@ void ListenerAdapter::polkit_tqt_listener_initiate_authentication(PolkitAgentLis
Identity::List idents; Identity::List idents;
Details dets(details); Details dets(details);
GList *identity; GList *identity;
for (identity = g_list_first(identities); identity != NULL; identity = g_list_next(identity)) for (identity = g_list_first(identities); identity != nullptr; identity = g_list_next(identity))
{ {
idents.append(Identity((PolkitIdentity*)identity->data)); idents.append(Identity((PolkitIdentity*)identity->data));
} }

@ -73,7 +73,7 @@ class ListenerAdapter : public TQObject
void removeListener(Listener *listener); void removeListener(Listener *listener);
Listener* findListener(PolkitAgentListener *listener); Listener* findListener(PolkitAgentListener *listener);
explicit ListenerAdapter(TQObject *parent = 0); explicit ListenerAdapter(TQObject *parent = nullptr);
TQValueList<Listener*> m_listeners; TQValueList<Listener*> m_listeners;
// Disable copy // Disable copy

@ -64,7 +64,7 @@ Listener::~Listener()
{ {
polkit_agent_listener_unregister(d->registeredHandle); polkit_agent_listener_unregister(d->registeredHandle);
} }
if (d->listener != NULL) if (d->listener != nullptr)
{ {
g_object_unref(d->listener); g_object_unref(d->listener);
} }
@ -72,19 +72,19 @@ Listener::~Listener()
bool Listener::registerListener(const PolkitTQt::Subject &subject, const TQString &objectPath) bool Listener::registerListener(const PolkitTQt::Subject &subject, const TQString &objectPath)
{ {
GError *error = NULL; GError *error = nullptr;
d->registeredHandle = polkit_agent_listener_register(d->listener, d->registeredHandle = polkit_agent_listener_register(d->listener,
POLKIT_AGENT_REGISTER_FLAGS_NONE, subject.subject(), objectPath.ascii(), NULL, &error); POLKIT_AGENT_REGISTER_FLAGS_NONE, subject.subject(), objectPath.ascii(), nullptr, &error);
if (error != NULL) if (error != nullptr)
{ {
tqWarning(TQString("Cannot register authentication agent: %1").arg(error->message)); tqWarning(TQString("Cannot register authentication agent: %1").arg(error->message));
g_error_free(error); g_error_free(error);
return false; return false;
} }
if (d->registeredHandle == NULL) if (d->registeredHandle == nullptr)
{ {
tqWarning(TQString("Cannot register authentication agent!")); tqWarning(TQString("Cannot register authentication agent!"));
return false; return false;

@ -63,7 +63,7 @@ class POLKIT_TQT_EXPORT Listener : public TQObject
/** /**
* \brief Constructor of Listener class * \brief Constructor of Listener class
*/ */
Listener(TQObject *parent = 0); Listener(TQObject *parent = nullptr);
/** /**
* \brief Constructor of Listener class from PolkitAgentListener * \brief Constructor of Listener class from PolkitAgentListener
@ -73,7 +73,7 @@ class POLKIT_TQT_EXPORT Listener : public TQObject
* \param listener Pointer to the PolkitAgentListener * \param listener Pointer to the PolkitAgentListener
* \param parent * \param parent
*/ */
explicit Listener(PolkitAgentListener *listener, TQObject *parent = 0); explicit Listener(PolkitAgentListener *listener, TQObject *parent = nullptr);
virtual ~Listener(); virtual ~Listener();

@ -66,7 +66,7 @@ void Session::Private::completed(PolkitAgentSession *s, gboolean gained_authoriz
{ {
g_object_unref(session->d->polkitAgentSession); g_object_unref(session->d->polkitAgentSession);
} }
session->d->polkitAgentSession = 0; session->d->polkitAgentSession = nullptr;
} }
void Session::Private::request(PolkitAgentSession *s, gchar *request, gboolean echo_on, void Session::Private::request(PolkitAgentSession *s, gchar *request, gboolean echo_on,
@ -168,7 +168,7 @@ AsyncResult::~AsyncResult()
void AsyncResult::setCompleted() void AsyncResult::setCompleted()
{ {
if (d->result == NULL) if (d->result == nullptr)
{ {
return; return;
} }
@ -178,12 +178,12 @@ void AsyncResult::setCompleted()
{ {
g_object_unref(d->result); g_object_unref(d->result);
} }
d->result = NULL; d->result = nullptr;
} }
void AsyncResult::setError(const TQString &text) void AsyncResult::setError(const TQString &text)
{ {
if (d->result == NULL) if (d->result == nullptr)
{ {
return; return;
} }

@ -95,8 +95,8 @@ class POLKIT_TQT_EXPORT Session : public TQObject
* \param result Result of the authentication action. Must be finished using complete() method. * \param result Result of the authentication action. Must be finished using complete() method.
* \param parent * \param parent
*/ */
Session(const Identity &identity, const TQString &cookie, AsyncResult *result = 0, Session(const Identity &identity, const TQString &cookie, AsyncResult *result = nullptr,
TQObject *parent = 0); TQObject *parent = nullptr);
/** /**
* Create a new authentication session from PolkitAgentSession object * Create a new authentication session from PolkitAgentSession object
@ -106,7 +106,7 @@ class POLKIT_TQT_EXPORT Session : public TQObject
* \param pkAgentSession PolkitAgentSession object * \param pkAgentSession PolkitAgentSession object
* \param parent * \param parent
*/ */
explicit Session(PolkitAgentSession *pkAgentSession, TQObject *parent = 0); explicit Session(PolkitAgentSession *pkAgentSession, TQObject *parent = nullptr);
/** /**
* Destroy authentication session. * Destroy authentication session.
@ -136,7 +136,7 @@ class POLKIT_TQT_EXPORT Session : public TQObject
/** /**
* Get AsyncResult that can be used to finish authentication operation * Get AsyncResult that can be used to finish authentication operation
* *
* \return AsyncResult object or NULL if it is not set * \return AsyncResult object or nullptr if it is not set
*/ */
AsyncResult *result(); AsyncResult *result();

@ -53,7 +53,7 @@ static void polkit_tqt_listener_init(PolkitTQtListener *listener)
static void polkit_tqt_listener_finalize(GObject *object) static void polkit_tqt_listener_finalize(GObject *object)
{ {
PolkitTQtListener *listener = POLKIT_TQT_LISTENER(object); PolkitTQtListener *listener = POLKIT_TQT_LISTENER(object);
if (G_OBJECT_CLASS(polkit_tqt_listener_parent_class)->finalize != NULL) if (G_OBJECT_CLASS(polkit_tqt_listener_parent_class)->finalize != nullptr)
{ {
G_OBJECT_CLASS(polkit_tqt_listener_parent_class)->finalize(object); G_OBJECT_CLASS(polkit_tqt_listener_parent_class)->finalize(object);
} }
@ -72,7 +72,7 @@ static void polkit_tqt_listener_class_init(PolkitTQtListenerClass *klass)
PolkitAgentListener *polkit_tqt_listener_new(void) PolkitAgentListener *polkit_tqt_listener_new(void)
{ {
return POLKIT_AGENT_LISTENER(g_object_new(POLKIT_TQT_TYPE_LISTENER, NULL)); return POLKIT_AGENT_LISTENER(g_object_new(POLKIT_TQT_TYPE_LISTENER, nullptr));
} }
static void cancelled_cb(GCancellable *cancellable, gpointer user_data) static void cancelled_cb(GCancellable *cancellable, gpointer user_data)
@ -95,7 +95,7 @@ static void polkit_tqt_listener_initiate_authentication(PolkitAgentListener *age
ListenerAdapter::instance()->polkit_tqt_listener_initiate_authentication(agent_listener, ListenerAdapter::instance()->polkit_tqt_listener_initiate_authentication(agent_listener,
action_id, message, icon_name, details, cookie, identities, cancellable, result); action_id, message, icon_name, details, cookie, identities, cancellable, result);
if (cancellable != NULL) if (cancellable != nullptr)
{ {
g_signal_connect(cancellable, "cancelled", G_CALLBACK(cancelled_cb), agent_listener); g_signal_connect(cancellable, "cancelled", G_CALLBACK(cancelled_cb), agent_listener);
} }

@ -33,7 +33,7 @@ namespace PolkitTQt
// General functions // General functions
//-------------------------------------- //--------------------------------------
Authority *Authority::m_theAuthority = NULL; Authority *Authority::m_theAuthority = nullptr;
Authority* Authority::instance(PolkitAuthority *authority) Authority* Authority::instance(PolkitAuthority *authority)
{ {
@ -83,7 +83,7 @@ ActionDescription::List actionsToListAndFree(GList *glist)
class Authority::Private class Authority::Private
{ {
public: public:
Private(Authority *qq) : q(qq), pkAuthority(NULL), m_hasError(false) Private(Authority *qq) : q(qq), pkAuthority(nullptr), m_hasError(false)
{ {
} }
@ -169,11 +169,11 @@ void Authority::Private::init()
m_revokeTemporaryAuthorizationsCancellable = g_cancellable_new(); m_revokeTemporaryAuthorizationsCancellable = g_cancellable_new();
m_revokeTemporaryAuthorizationCancellable = g_cancellable_new(); m_revokeTemporaryAuthorizationCancellable = g_cancellable_new();
GError *gerror = NULL; GError *gerror = nullptr;
if (pkAuthority == NULL) if (pkAuthority == nullptr)
{ {
pkAuthority = polkit_authority_get_sync(NULL, &gerror); pkAuthority = polkit_authority_get_sync(nullptr, &gerror);
if (gerror != NULL) if (gerror != nullptr)
{ {
setError(E_GetAuthority, gerror->message); setError(E_GetAuthority, gerror->message);
g_error_free(gerror); g_error_free(gerror);
@ -181,13 +181,13 @@ void Authority::Private::init()
} }
} }
if (pkAuthority == NULL) if (pkAuthority == nullptr)
{ {
return; return;
} }
// connect changed signal // connect changed signal
g_signal_connect(G_OBJECT(pkAuthority), "changed", G_CALLBACK(pk_config_changed), NULL); g_signal_connect(G_OBJECT(pkAuthority), "changed", G_CALLBACK(pk_config_changed), nullptr);
} }
void Authority::Private::setError(Authority::ErrorCode code, const TQString &details, bool recover) void Authority::Private::setError(Authority::ErrorCode code, const TQString &details, bool recover)
@ -271,11 +271,11 @@ Authority::Result Authority::checkAuthorizationSync(const TQString &actionId,
return Unknown; return Unknown;
} }
GError *error = NULL; GError *error = nullptr;
PolkitAuthorizationResult *pk_result = polkit_authority_check_authorization_sync(d->pkAuthority, PolkitAuthorizationResult *pk_result = polkit_authority_check_authorization_sync(d->pkAuthority,
subject.subject(), actionId.ascii(), NULL, (PolkitCheckAuthorizationFlags)(int)flags, subject.subject(), actionId.ascii(), nullptr, (PolkitCheckAuthorizationFlags)(int)flags,
NULL, &error); nullptr, &error);
if (error != NULL) if (error != nullptr)
{ {
d->setError(E_CheckFailed, error->message); d->setError(E_CheckFailed, error->message);
g_error_free(error); g_error_free(error);
@ -308,7 +308,7 @@ void Authority::checkAuthorization(const TQString &actionId, const Subject &subj
return; return;
} }
polkit_authority_check_authorization(d->pkAuthority, subject.subject(), actionId.ascii(), NULL, polkit_authority_check_authorization(d->pkAuthority, subject.subject(), actionId.ascii(), nullptr,
(PolkitCheckAuthorizationFlags)(int)flags, d->m_checkAuthorizationCancellable, (PolkitCheckAuthorizationFlags)(int)flags, d->m_checkAuthorizationCancellable,
d->checkAuthorizationCallback, this); d->checkAuthorizationCallback, this);
} }
@ -321,10 +321,10 @@ void Authority::Private::checkAuthorizationCallback(GObject *object, GAsyncResul
return; return;
} }
GError *error = NULL; GError *error = nullptr;
PolkitAuthorizationResult *pkResult = polkit_authority_check_authorization_finish( PolkitAuthorizationResult *pkResult = polkit_authority_check_authorization_finish(
(PolkitAuthority*)object, result, &error); (PolkitAuthority*)object, result, &error);
if (error != NULL) if (error != nullptr)
{ {
// We don't want to set error if this is cancellation of some action // We don't want to set error if this is cancellation of some action
if (error->code != 1) if (error->code != 1)
@ -334,7 +334,7 @@ void Authority::Private::checkAuthorizationCallback(GObject *object, GAsyncResul
g_error_free(error); g_error_free(error);
return; return;
} }
if (pkResult != NULL) if (pkResult != nullptr)
{ {
emit authority->checkAuthorizationFinished(polkitResultToResult(pkResult)); emit authority->checkAuthorizationFinished(polkitResultToResult(pkResult));
g_object_unref(pkResult); g_object_unref(pkResult);
@ -360,9 +360,9 @@ ActionDescription::List Authority::enumerateActionsSync()
return ActionDescription::List(); return ActionDescription::List();
} }
GError *error = NULL; GError *error = nullptr;
GList *glist = polkit_authority_enumerate_actions_sync(d->pkAuthority, NULL, &error); GList *glist = polkit_authority_enumerate_actions_sync(d->pkAuthority, nullptr, &error);
if (error != NULL) if (error != nullptr)
{ {
d->setError(E_EnumFailed, error->message); d->setError(E_EnumFailed, error->message);
g_error_free(error); g_error_free(error);
@ -390,9 +390,9 @@ void Authority::Private::enumerateActionsCallback(GObject *object, GAsyncResult
{ {
return; return;
} }
GError *error = NULL; GError *error = nullptr;
GList *list = polkit_authority_enumerate_actions_finish((PolkitAuthority*)object, result, &error); GList *list = polkit_authority_enumerate_actions_finish((PolkitAuthority*)object, result, &error);
if (error != NULL) if (error != nullptr)
{ {
// We don't want to set error if this is cancellation of some action // We don't want to set error if this is cancellation of some action
if (error->code != 1) if (error->code != 1)
@ -428,9 +428,9 @@ bool Authority::registerAuthenticationAgentSync(const Subject &subject, const TQ
return false; return false;
} }
GError *error = NULL; GError *error = nullptr;
gboolean result = polkit_authority_register_authentication_agent_sync(d->pkAuthority, gboolean result = polkit_authority_register_authentication_agent_sync(d->pkAuthority,
subject.subject(), locale.ascii(), objectPath.ascii(), NULL, &error); subject.subject(), locale.ascii(), objectPath.ascii(), nullptr, &error);
if (error) if (error)
{ {
d->setError(E_RegisterFailed, error->message); d->setError(E_RegisterFailed, error->message);
@ -468,9 +468,9 @@ void Authority::Private::registerAuthenticationAgentCallback(GObject *object, GA
{ {
return; return;
} }
GError *error = NULL; GError *error = nullptr;
bool res = polkit_authority_register_authentication_agent_finish((PolkitAuthority*)object, result, &error); bool res = polkit_authority_register_authentication_agent_finish((PolkitAuthority*)object, result, &error);
if (error != NULL) if (error != nullptr)
{ {
// We don't want to set error if this is cancellation of some action // We don't want to set error if this is cancellation of some action
if (error->code != 1) if (error->code != 1)
@ -505,10 +505,10 @@ bool Authority::unregisterAuthenticationAgentSync(const Subject &subject, const
return false; return false;
} }
GError *error = NULL; GError *error = nullptr;
bool result = polkit_authority_unregister_authentication_agent_sync(d->pkAuthority, bool result = polkit_authority_unregister_authentication_agent_sync(d->pkAuthority,
subject.subject(), objectPath.utf8().data(), NULL, &error); subject.subject(), objectPath.utf8().data(), nullptr, &error);
if (error != NULL) if (error != nullptr)
{ {
d->setError(E_UnregisterFailed, error->message); d->setError(E_UnregisterFailed, error->message);
g_error_free(error); g_error_free(error);
@ -544,10 +544,10 @@ void Authority::Private::unregisterAuthenticationAgentCallback(GObject *object,
{ {
return; return;
} }
GError *error = NULL; GError *error = nullptr;
bool res = polkit_authority_unregister_authentication_agent_finish((PolkitAuthority*)object, bool res = polkit_authority_unregister_authentication_agent_finish((PolkitAuthority*)object,
result, &error); result, &error);
if (error != NULL) if (error != nullptr)
{ {
// We don't want to set error if this is cancellation of some action // We don't want to set error if this is cancellation of some action
if (error->code != 1) if (error->code != 1)
@ -582,10 +582,10 @@ bool Authority::authenticationAgentResponseSync(const TQString &cookie, const Id
return false; return false;
} }
GError *error = NULL; GError *error = nullptr;
bool result = polkit_authority_authentication_agent_response_sync(d->pkAuthority, bool result = polkit_authority_authentication_agent_response_sync(d->pkAuthority,
cookie.utf8().data(), identity.identity(), NULL, &error); cookie.utf8().data(), identity.identity(), nullptr, &error);
if (error != NULL) if (error != nullptr)
{ {
d->setError(E_AgentResponseFailed, error->message); d->setError(E_AgentResponseFailed, error->message);
g_error_free(error); g_error_free(error);
@ -621,10 +621,10 @@ void Authority::Private::authenticationAgentResponseCallback(GObject *object, GA
{ {
return; return;
} }
GError *error = NULL; GError *error = nullptr;
bool res = polkit_authority_authentication_agent_response_finish((PolkitAuthority*)object, result, bool res = polkit_authority_authentication_agent_response_finish((PolkitAuthority*)object, result,
&error); &error);
if (error != NULL) if (error != nullptr)
{ {
// We don't want to set error if this is cancellation of some action // We don't want to set error if this is cancellation of some action
if (error->code != 1) if (error->code != 1)
@ -650,10 +650,10 @@ TemporaryAuthorization::List Authority::enumerateTemporaryAuthorizationsSync(con
{ {
TemporaryAuthorization::List result; TemporaryAuthorization::List result;
GError *error = NULL; GError *error = nullptr;
GList *glist = polkit_authority_enumerate_temporary_authorizations_sync(d->pkAuthority, GList *glist = polkit_authority_enumerate_temporary_authorizations_sync(d->pkAuthority,
subject.subject(), NULL, &error); subject.subject(), nullptr, &error);
if (error != NULL) if (error != nullptr)
{ {
d->setError(E_EnumFailed, error->message); d->setError(E_EnumFailed, error->message);
g_error_free(error); g_error_free(error);
@ -661,7 +661,7 @@ TemporaryAuthorization::List Authority::enumerateTemporaryAuthorizationsSync(con
} }
GList *glist2; GList *glist2;
for (glist2 = glist; glist2 != NULL; glist2 = g_list_next(glist2)) for (glist2 = glist; glist2 != nullptr; glist2 = g_list_next(glist2))
{ {
result.append(TemporaryAuthorization((PolkitTemporaryAuthorization*)glist2->data)); result.append(TemporaryAuthorization((PolkitTemporaryAuthorization*)glist2->data));
if (glist2->data) if (glist2->data)
@ -682,10 +682,10 @@ void Authority::Private::enumerateTemporaryAuthorizationsCallback(GObject *objec
return; return;
} }
GError *error = NULL; GError *error = nullptr;
GList *glist = polkit_authority_enumerate_temporary_authorizations_finish((PolkitAuthority*)object, GList *glist = polkit_authority_enumerate_temporary_authorizations_finish((PolkitAuthority*)object,
result, &error); result, &error);
if (error != NULL) if (error != nullptr)
{ {
// We don't want to set error if this is cancellation of some action // We don't want to set error if this is cancellation of some action
if (error->code != 1) if (error->code != 1)
@ -697,7 +697,7 @@ void Authority::Private::enumerateTemporaryAuthorizationsCallback(GObject *objec
} }
TemporaryAuthorization::List res; TemporaryAuthorization::List res;
GList *glist2; GList *glist2;
for (glist2 = glist; glist2 != NULL; glist2 = g_list_next(glist2)) for (glist2 = glist; glist2 != nullptr; glist2 = g_list_next(glist2))
{ {
res.append(TemporaryAuthorization((PolkitTemporaryAuthorization*)glist2->data)); res.append(TemporaryAuthorization((PolkitTemporaryAuthorization*)glist2->data));
if (glist2->data) if (glist2->data)
@ -724,10 +724,10 @@ bool Authority::revokeTemporaryAuthorizationsSync(const Subject &subject)
return false; return false;
} }
GError *error = NULL; GError *error = nullptr;
bool result = polkit_authority_revoke_temporary_authorizations_sync(d->pkAuthority, bool result = polkit_authority_revoke_temporary_authorizations_sync(d->pkAuthority,
subject.subject(), NULL, &error); subject.subject(), nullptr, &error);
if (error != NULL) if (error != nullptr)
{ {
d->setError(E_RevokeFailed, error->message); d->setError(E_RevokeFailed, error->message);
g_error_free(error); g_error_free(error);
@ -757,9 +757,9 @@ void Authority::Private::revokeTemporaryAuthorizationsCallback(GObject *object,
return; return;
} }
GError *error = NULL; GError *error = nullptr;
bool res = polkit_authority_revoke_temporary_authorizations_finish((PolkitAuthority*)object, result, &error); bool res = polkit_authority_revoke_temporary_authorizations_finish((PolkitAuthority*)object, result, &error);
if (error != NULL) if (error != nullptr)
{ {
// We don't want to set error if this is cancellation of some action // We don't want to set error if this is cancellation of some action
if (error->code != 1) if (error->code != 1)
@ -788,10 +788,10 @@ bool Authority::revokeTemporaryAuthorizationSync(const TQString &id)
return false; return false;
} }
GError *error = NULL; GError *error = nullptr;
bool result = polkit_authority_revoke_temporary_authorization_by_id_sync(d->pkAuthority, bool result = polkit_authority_revoke_temporary_authorization_by_id_sync(d->pkAuthority,
id.utf8().data(), NULL, &error); id.utf8().data(), nullptr, &error);
if (error != NULL) if (error != nullptr)
{ {
d->setError(E_RevokeFailed, error->message); d->setError(E_RevokeFailed, error->message);
g_error_free(error); g_error_free(error);
@ -821,10 +821,10 @@ void Authority::Private::revokeTemporaryAuthorizationCallback(GObject *object,
return; return;
} }
GError *error = NULL; GError *error = nullptr;
bool res = polkit_authority_revoke_temporary_authorization_by_id_finish((PolkitAuthority*)object, bool res = polkit_authority_revoke_temporary_authorization_by_id_finish((PolkitAuthority*)object,
result, &error); result, &error);
if (error != NULL) if (error != nullptr)
{ {
// We don't want to set error if this is cancellation of some action // We don't want to set error if this is cancellation of some action
if (error->code != 1) if (error->code != 1)

@ -137,7 +137,7 @@ class POLKIT_TQT_EXPORT Authority : public TQObject
* *
* \return The current authority instance * \return The current authority instance
*/ */
static Authority* instance(PolkitAuthority *authority = NULL); static Authority* instance(PolkitAuthority *authority = nullptr);
~Authority(); ~Authority();
@ -513,7 +513,7 @@ class POLKIT_TQT_EXPORT Authority : public TQObject
Authority(const Authority&); Authority(const Authority&);
Authority& operator=(const Authority&); Authority& operator=(const Authority&);
Authority(TQObject *parent = NULL); Authority(TQObject *parent = nullptr);
static Authority *m_theAuthority; static Authority *m_theAuthority;

@ -37,7 +37,7 @@ namespace PolkitTQt
class Details::Data : public TQShared class Details::Data : public TQShared
{ {
public: public:
Data() : details(NULL) Data() : details(nullptr)
{ {
} }
@ -111,7 +111,7 @@ Details::~Details()
TQString Details::lookup(const TQString &key) const TQString Details::lookup(const TQString &key) const
{ {
const gchar *result = polkit_details_lookup(d->details, key.utf8().data()); const gchar *result = polkit_details_lookup(d->details, key.utf8().data());
if (result != NULL) if (result != nullptr)
{ {
return TQString::fromUtf8(result); return TQString::fromUtf8(result);
} }

@ -36,7 +36,7 @@ namespace PolkitTQt
class Identity::Data : public TQShared class Identity::Data : public TQShared
{ {
public: public:
Data() : identity(NULL) Data() : identity(nullptr)
{ {
} }
@ -108,7 +108,7 @@ Identity::~Identity()
bool Identity::isValid() const bool Identity::isValid() const
{ {
return (d->identity != NULL); return (d->identity != nullptr);
} }
PolkitIdentity* Identity::identity() const PolkitIdentity* Identity::identity() const
@ -149,9 +149,9 @@ Identity Identity::fromString(const TQString &string)
return Identity(); return Identity();
} }
GError *error = NULL; GError *error = nullptr;
PolkitIdentity *poliden = polkit_identity_from_string(string.utf8().data(), &error); PolkitIdentity *poliden = polkit_identity_from_string(string.utf8().data(), &error);
if (error != NULL) if (error != nullptr)
{ {
tqWarning(TQString("Cannot create valid Identity from string: %1").arg(error->message)); tqWarning(TQString("Cannot create valid Identity from string: %1").arg(error->message));
return Identity(); return Identity();
@ -166,12 +166,12 @@ Identity Identity::fromString(const TQString &string)
UnixUserIdentity::UnixUserIdentity(const TQString &name) : Identity() UnixUserIdentity::UnixUserIdentity(const TQString &name) : Identity()
{ {
GError *error = NULL; GError *error = nullptr;
setIdentity(polkit_unix_user_new_for_name(name.utf8().data(), &error)); setIdentity(polkit_unix_user_new_for_name(name.utf8().data(), &error));
if (error != NULL) if (error != nullptr)
{ {
tqWarning(TQString("Cannot create UnixUserIdentity: %1").arg(error->message)); tqWarning(TQString("Cannot create UnixUserIdentity: %1").arg(error->message));
setIdentity(NULL); setIdentity(nullptr);
} }
} }
@ -201,12 +201,12 @@ void UnixUserIdentity::setUid(uid_t uid)
UnixGroupIdentity::UnixGroupIdentity(const TQString &name) : Identity() UnixGroupIdentity::UnixGroupIdentity(const TQString &name) : Identity()
{ {
GError *error = NULL; GError *error = nullptr;
setIdentity(polkit_unix_group_new_for_name(name.utf8().data(), &error)); setIdentity(polkit_unix_group_new_for_name(name.utf8().data(), &error));
if (error != NULL) if (error != nullptr)
{ {
tqWarning(TQString("Cannot create UnixGroupIdentity: %1").arg(error->message)); tqWarning(TQString("Cannot create UnixGroupIdentity: %1").arg(error->message));
setIdentity(NULL); setIdentity(nullptr);
} }
} }

@ -36,7 +36,7 @@ namespace PolkitTQt
class Subject::Data : public TQShared class Subject::Data : public TQShared
{ {
public: public:
Data() : subject(NULL) Data() : subject(nullptr)
{ {
} }
@ -108,7 +108,7 @@ Subject::~Subject()
bool Subject::isValid() const bool Subject::isValid() const
{ {
return (d->subject != NULL); return (d->subject != nullptr);
} }
PolkitSubject* Subject::subject() const PolkitSubject* Subject::subject() const
@ -149,9 +149,9 @@ Subject Subject::fromString(const TQString &string)
return Subject(); return Subject();
} }
GError *error = NULL; GError *error = nullptr;
PolkitSubject *polsub = polkit_subject_from_string(string.utf8().data(), &error); PolkitSubject *polsub = polkit_subject_from_string(string.utf8().data(), &error);
if (error != NULL) if (error != nullptr)
{ {
tqWarning(TQString("Cannot create valid Subject from string: %1").arg(error->message)); tqWarning(TQString("Cannot create valid Subject from string: %1").arg(error->message));
return Subject(); return Subject();
@ -229,12 +229,12 @@ UnixSessionSubject::UnixSessionSubject(const TQString &sessionId) : Subject()
UnixSessionSubject::UnixSessionSubject(TQ_LONG pid) : Subject() UnixSessionSubject::UnixSessionSubject(TQ_LONG pid) : Subject()
{ {
GError *error = NULL; GError *error = nullptr;
setSubject(polkit_unix_session_new_for_process_sync(pid, NULL, &error)); setSubject(polkit_unix_session_new_for_process_sync(pid, nullptr, &error));
if (error != NULL) if (error != nullptr)
{ {
tqWarning(TQString("Cannot create unix session subject from pid: %1").arg(error->message)); tqWarning(TQString("Cannot create unix session subject from pid: %1").arg(error->message));
setSubject(NULL); setSubject(nullptr);
} }
} }

@ -48,12 +48,12 @@ using namespace PolkitTQt;
using namespace PolkitTQt::Gui; using namespace PolkitTQt::Gui;
PkExample::PkExample() : TQMainWindow(0, "Polkit tqt example application", WDestructiveClose) PkExample::PkExample() : TQMainWindow(nullptr, "Polkit tqt example application", WDestructiveClose)
{ {
TQWidget *privateLayoutWidget = new TQWidget(this, "qt_central_widget"); TQWidget *privateLayoutWidget = new TQWidget(this, "qt_central_widget");
setCentralWidget(privateLayoutWidget); setCentralWidget(privateLayoutWidget);
grid = new TQGridLayout(0, 9, 1, 0, 6, "grid"); grid = new TQGridLayout(nullptr, 9, 1, 0, 6, "grid");
grid->setColSpacing(0, 700); grid->setColSpacing(0, 700);
grid->setColSpacing(1, 200); grid->setColSpacing(1, 200);

@ -42,17 +42,14 @@ void TQtListener::initiateAuthentication(const TQString &actionId, const TQStrin
tqDebug("Initiate authentication for " + actionId + " with message " + message); tqDebug("Initiate authentication for " + actionId + " with message " + message);
tqDebug(" iconName " + iconName); tqDebug(" iconName " + iconName);
TQStringList dkeys = details.keys(); TQStringList dkeys = details.keys();
TQStringList::Iterator dkIt; for (const TQString &dkey : dkeys)
for (dkIt = dkeys.begin(); dkIt != dkeys.end(); ++dkIt)
{ {
tqDebug(" key " + (*dkIt)); tqDebug(" key " + dkey);
} }
tqDebug(" cookie " + cookie); tqDebug(" cookie " + cookie);
PolkitTQt::Identity::List::ConstIterator iIt; for (const PolkitTQt::Identity &identity : identities)
for (iIt = identities.begin(); iIt != identities.end(); ++iIt)
{ {
PolkitTQt::Identity identity = *iIt;
tqDebug(identity.toString()); tqDebug(identity.toString());
Session *session = new Session(identity, cookie, result); Session *session = new Session(identity, cookie, result);
connect(session, TQT_SIGNAL(request(const TQString&, bool)), this, connect(session, TQT_SIGNAL(request(const TQString&, bool)), this,
@ -83,7 +80,7 @@ void TQtListener::request(const TQString &request, bool echo)
Session *session = (Session*)sender(); Session *session = (Session*)sender();
bool ok; bool ok;
TQString text = TQInputDialog::getText("TQt Agent", "Enter authorization password:", TQString text = TQInputDialog::getText("TQt Agent", "Enter authorization password:",
TQLineEdit::Password, TQString::null, &ok, NULL ); TQLineEdit::Password, TQString::null, &ok, nullptr );
if (ok && !text.isEmpty()) if (ok && !text.isEmpty())
{ {
session->setResponse(text); session->setResponse(text);

@ -40,7 +40,7 @@ class TQtListener : public PolkitTQt::Agent::Listener
Q_OBJECT Q_OBJECT
public: public:
TQtListener(TQObject *parent = 0); TQtListener(TQObject *parent = nullptr);
public slots: public slots:
void initiateAuthentication(const TQString &actionId, const TQString &message, void initiateAuthentication(const TQString &actionId, const TQString &message,

@ -77,7 +77,7 @@ class POLKIT_TQT_EXPORT Action : public TQAction
* \param actionId the PolicyKit action Id (e.g.: org.freedesktop.policykit.read) * \param actionId the PolicyKit action Id (e.g.: org.freedesktop.policykit.read)
* \param parent the object parent * \param parent the object parent
*/ */
explicit Action(const TQString& actionId = TQString::null, TQObject *parent = 0); explicit Action(const TQString& actionId = TQString::null, TQObject *parent = nullptr);
~Action(); ~Action();

@ -92,10 +92,8 @@ void ActionButton::streamClicked()
void ActionButton::updateButton() void ActionButton::updateButton()
{ {
TQValueList<TQButton*>::iterator butIt; for (TQButton *&ent : d->buttons)
for (butIt = d->buttons.begin(); butIt != d->buttons.end(); ++butIt)
{ {
TQButton *ent = *butIt;
if (isVisible()) if (isVisible())
{ {
ent->show(); ent->show();
@ -128,10 +126,8 @@ void ActionButton::updateButton()
bool ActionButton::activate() bool ActionButton::activate()
{ {
bool tg = false; bool tg = false;
TQValueList<TQButton*>::iterator butIt; for (TQButton *&ent : d->buttons)
for (butIt = d->buttons.begin(); butIt != d->buttons.end(); ++butIt)
{ {
TQButton *ent = *butIt;
if (ent->isToggleButton()) if (ent->isToggleButton())
{ {
// we set the the current Action state // we set the the current Action state

@ -72,7 +72,7 @@ class POLKIT_TQT_EXPORT ActionButton : public Action
* \param parent the parent object * \param parent the parent object
*/ */
explicit ActionButton(TQButton *button, const TQString &actionId = TQString::null, explicit ActionButton(TQButton *button, const TQString &actionId = TQString::null,
TQObject *parent = 0); TQObject *parent = nullptr);
virtual ~ActionButton(); virtual ~ActionButton();
/** /**
@ -131,7 +131,7 @@ class POLKIT_TQT_EXPORT ActionButton : public Action
void clicked(TQButton *button, bool checked = false); void clicked(TQButton *button, bool checked = false);
protected: protected:
ActionButton(ActionButtonPrivate &dd, const TQString &actionId, TQObject *parent = 0); ActionButton(ActionButtonPrivate &dd, const TQString &actionId, TQObject *parent = nullptr);
ActionButtonPrivate *const d; ActionButtonPrivate *const d;

@ -32,7 +32,7 @@ namespace PolkitTQt
namespace Gui namespace Gui
{ {
ActionButtons::ActionButtons(const TQValueList<TQButton*> &buttons, const TQString &actionId, ActionButtons::ActionButtons(TQValueList<TQButton*> &buttons, const TQString &actionId,
TQObject *parent) : ActionButton(*new ActionButtonPrivate(), actionId, parent) TQObject *parent) : ActionButton(*new ActionButtonPrivate(), actionId, parent)
{ {
setButtons(buttons); setButtons(buttons);
@ -42,17 +42,15 @@ ActionButtons::~ActionButtons()
{ {
} }
void ActionButtons::setButtons(const TQValueList<TQButton*> &buttons) void ActionButtons::setButtons(TQValueList<TQButton*> &buttons)
{ {
TQValueList<TQButton*>::iterator butIt; for (TQButton *&ent : buttons)
for (butIt = d->buttons.begin(); butIt != d->buttons.end(); ++butIt)
{ {
TQButton *ent = *butIt;
addButton(ent); addButton(ent);
} }
} }
TQValueList<TQButton *> ActionButtons::buttons() const TQValueList<TQButton*> ActionButtons::buttons() const
{ {
return d->buttons; return d->buttons;
} }

@ -62,8 +62,8 @@ class ActionButtons : public ActionButton
* \param actionId the action Id to create the underlying Action * \param actionId the action Id to create the underlying Action
* \param parent the parent object * \param parent the parent object
*/ */
explicit ActionButtons(const TQValueList<TQButton*> &buttons, explicit ActionButtons(TQValueList<TQButton*> &buttons,
const TQString &actionId = TQString::null, TQObject *parent = 0); const TQString &actionId = TQString::null, TQObject *parent = nullptr);
virtual ~ActionButtons(); virtual ~ActionButtons();
/** /**
@ -80,7 +80,7 @@ class ActionButtons : public ActionButton
* *
* \param buttons the new buttons associated with the underlying action * \param buttons the new buttons associated with the underlying action
*/ */
void setButtons(const TQValueList<TQButton*> &buttons); void setButtons(TQValueList<TQButton*> &buttons);
/** /**
* Returns the current buttons list * Returns the current buttons list

@ -27,12 +27,11 @@ int main(void)
} }
// Check whether enumerateAction returns at least example actions // Check whether enumerateAction returns at least example actions
int count = 0; int count = 0;
ActionDescription::List::const_iterator adIt; for (const ActionDescription &actionDesc : list)
for (adIt = list.begin(); adIt != list.end(); ++adIt)
{ {
if (((*adIt).actionId() == "org.tqt.policykit.examples.kick") || if ((actionDesc.actionId() == "org.tqt.policykit.examples.kick") ||
((*adIt).actionId() == "org.tqt.policykit.examples.cry") || (actionDesc.actionId() == "org.tqt.policykit.examples.cry") ||
((*adIt).actionId() == "org.tqt.policykit.examples.bleed")) (actionDesc.actionId() == "org.tqt.policykit.examples.bleed"))
{ {
count++; count++;
} }

Loading…
Cancel
Save