diff options
author | Michele Calgaro <[email protected]> | 2021-12-28 20:45:45 +0900 |
---|---|---|
committer | Michele Calgaro <[email protected]> | 2021-12-28 20:45:45 +0900 |
commit | 82b07f1a3cc29b9785c292174343b464a774a722 (patch) | |
tree | 7a3501a01cf6e6d645929063ac601f4d3eb91edb | |
parent | 416bed9bc124e24cc1351c7d8e5810ca7570a023 (diff) | |
download | polkit-tqt-82b07f1a3cc29b9785c292174343b464a774a722.tar.gz polkit-tqt-82b07f1a3cc29b9785c292174343b464a774a722.zip |
Code improvements based on c++11 standard (ranged for loops and nullptr).
Signed-off-by: Michele Calgaro <[email protected]>
-rw-r--r-- | agent/listeneradapter.cpp | 10 | ||||
-rw-r--r-- | agent/listeneradapter.h | 2 | ||||
-rw-r--r-- | agent/polkit-tqt-agent-listener.cpp | 10 | ||||
-rw-r--r-- | agent/polkit-tqt-agent-listener.h | 4 | ||||
-rw-r--r-- | agent/polkit-tqt-agent-session.cpp | 8 | ||||
-rw-r--r-- | agent/polkit-tqt-agent-session.h | 8 | ||||
-rw-r--r-- | agent/polkit-tqt-listener.cpp | 6 | ||||
-rw-r--r-- | core/polkit-tqt-authority.cpp | 104 | ||||
-rw-r--r-- | core/polkit-tqt-authority.h | 4 | ||||
-rw-r--r-- | core/polkit-tqt-details.cpp | 4 | ||||
-rw-r--r-- | core/polkit-tqt-identity.cpp | 20 | ||||
-rw-r--r-- | core/polkit-tqt-subject.cpp | 16 | ||||
-rw-r--r-- | examples/PkExample.cpp | 4 | ||||
-rw-r--r-- | examples/agent/tqtlistener.cpp | 11 | ||||
-rw-r--r-- | examples/agent/tqtlistener.h | 2 | ||||
-rw-r--r-- | gui/polkit-tqt-gui-action.h | 2 | ||||
-rw-r--r-- | gui/polkit-tqt-gui-actionbutton.cpp | 8 | ||||
-rw-r--r-- | gui/polkit-tqt-gui-actionbutton.h | 4 | ||||
-rw-r--r-- | gui/polkit-tqt-gui-actionbuttons.cpp | 10 | ||||
-rw-r--r-- | gui/polkit-tqt-gui-actionbuttons.h | 6 | ||||
-rw-r--r-- | tests/test_auth_enum_actions.cpp | 9 |
21 files changed, 120 insertions, 132 deletions
diff --git a/agent/listeneradapter.cpp b/agent/listeneradapter.cpp index ad4730ed5..39e7e8d36 100644 --- a/agent/listeneradapter.cpp +++ b/agent/listeneradapter.cpp @@ -34,7 +34,7 @@ namespace Agent // ListenerAdapter //-------------------------------------- -ListenerAdapter *ListenerAdapter::m_theListenerAdapter = NULL; +ListenerAdapter *ListenerAdapter::m_theListenerAdapter = nullptr; ListenerAdapter *ListenerAdapter::instance() { @@ -51,17 +51,15 @@ ListenerAdapter::ListenerAdapter(TQObject *parent) : TQObject(parent) Listener* ListenerAdapter::findListener(PolkitAgentListener *listener) { - TQValueList<Listener*>::iterator listerIt; - for (listerIt = m_listeners.begin(); listerIt != m_listeners.end(); ++listerIt) + for (Listener *&listItem : m_listeners) { - Listener *listItem = *listerIt; if (listItem && listItem->listener() == listener) { return listItem; } } - return NULL; + return nullptr; } void ListenerAdapter::polkit_tqt_listener_initiate_authentication(PolkitAgentListener *listener, @@ -74,7 +72,7 @@ void ListenerAdapter::polkit_tqt_listener_initiate_authentication(PolkitAgentLis Identity::List idents; Details dets(details); 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)); } diff --git a/agent/listeneradapter.h b/agent/listeneradapter.h index b05d9966f..18d36d60b 100644 --- a/agent/listeneradapter.h +++ b/agent/listeneradapter.h @@ -73,7 +73,7 @@ class ListenerAdapter : public TQObject void removeListener(Listener *listener); Listener* findListener(PolkitAgentListener *listener); - explicit ListenerAdapter(TQObject *parent = 0); + explicit ListenerAdapter(TQObject *parent = nullptr); TQValueList<Listener*> m_listeners; // Disable copy diff --git a/agent/polkit-tqt-agent-listener.cpp b/agent/polkit-tqt-agent-listener.cpp index 2ff78eaf6..8e41c7c3b 100644 --- a/agent/polkit-tqt-agent-listener.cpp +++ b/agent/polkit-tqt-agent-listener.cpp @@ -64,7 +64,7 @@ Listener::~Listener() { polkit_agent_listener_unregister(d->registeredHandle); } - if (d->listener != NULL) + if (d->listener != nullptr) { g_object_unref(d->listener); } @@ -72,19 +72,19 @@ Listener::~Listener() bool Listener::registerListener(const PolkitTQt::Subject &subject, const TQString &objectPath) { - GError *error = NULL; + GError *error = nullptr; 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)); g_error_free(error); return false; } - if (d->registeredHandle == NULL) + if (d->registeredHandle == nullptr) { tqWarning(TQString("Cannot register authentication agent!")); return false; diff --git a/agent/polkit-tqt-agent-listener.h b/agent/polkit-tqt-agent-listener.h index 30115dd8e..639382761 100644 --- a/agent/polkit-tqt-agent-listener.h +++ b/agent/polkit-tqt-agent-listener.h @@ -63,7 +63,7 @@ class POLKIT_TQT_EXPORT Listener : public TQObject /** * \brief Constructor of Listener class */ - Listener(TQObject *parent = 0); + Listener(TQObject *parent = nullptr); /** * \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 parent */ - explicit Listener(PolkitAgentListener *listener, TQObject *parent = 0); + explicit Listener(PolkitAgentListener *listener, TQObject *parent = nullptr); virtual ~Listener(); diff --git a/agent/polkit-tqt-agent-session.cpp b/agent/polkit-tqt-agent-session.cpp index eb8460be4..3d0da6153 100644 --- a/agent/polkit-tqt-agent-session.cpp +++ b/agent/polkit-tqt-agent-session.cpp @@ -66,7 +66,7 @@ void Session::Private::completed(PolkitAgentSession *s, gboolean gained_authoriz { 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, @@ -168,7 +168,7 @@ AsyncResult::~AsyncResult() void AsyncResult::setCompleted() { - if (d->result == NULL) + if (d->result == nullptr) { return; } @@ -178,12 +178,12 @@ void AsyncResult::setCompleted() { g_object_unref(d->result); } - d->result = NULL; + d->result = nullptr; } void AsyncResult::setError(const TQString &text) { - if (d->result == NULL) + if (d->result == nullptr) { return; } diff --git a/agent/polkit-tqt-agent-session.h b/agent/polkit-tqt-agent-session.h index 9f3e813d8..a122654a2 100644 --- a/agent/polkit-tqt-agent-session.h +++ b/agent/polkit-tqt-agent-session.h @@ -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 parent */ - Session(const Identity &identity, const TQString &cookie, AsyncResult *result = 0, - TQObject *parent = 0); + Session(const Identity &identity, const TQString &cookie, AsyncResult *result = nullptr, + TQObject *parent = nullptr); /** * Create a new authentication session from PolkitAgentSession object @@ -106,7 +106,7 @@ class POLKIT_TQT_EXPORT Session : public TQObject * \param pkAgentSession PolkitAgentSession object * \param parent */ - explicit Session(PolkitAgentSession *pkAgentSession, TQObject *parent = 0); + explicit Session(PolkitAgentSession *pkAgentSession, TQObject *parent = nullptr); /** * Destroy authentication session. @@ -136,7 +136,7 @@ class POLKIT_TQT_EXPORT Session : public TQObject /** * 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(); diff --git a/agent/polkit-tqt-listener.cpp b/agent/polkit-tqt-listener.cpp index 269dcf7ec..9275e0783 100644 --- a/agent/polkit-tqt-listener.cpp +++ b/agent/polkit-tqt-listener.cpp @@ -53,7 +53,7 @@ static void polkit_tqt_listener_init(PolkitTQtListener *listener) static void polkit_tqt_listener_finalize(GObject *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); } @@ -72,7 +72,7 @@ static void polkit_tqt_listener_class_init(PolkitTQtListenerClass *klass) 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) @@ -95,7 +95,7 @@ static void polkit_tqt_listener_initiate_authentication(PolkitAgentListener *age ListenerAdapter::instance()->polkit_tqt_listener_initiate_authentication(agent_listener, 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); } diff --git a/core/polkit-tqt-authority.cpp b/core/polkit-tqt-authority.cpp index d8e4aa297..abe776245 100644 --- a/core/polkit-tqt-authority.cpp +++ b/core/polkit-tqt-authority.cpp @@ -33,7 +33,7 @@ namespace PolkitTQt // General functions //-------------------------------------- -Authority *Authority::m_theAuthority = NULL; +Authority *Authority::m_theAuthority = nullptr; Authority* Authority::instance(PolkitAuthority *authority) { @@ -83,7 +83,7 @@ ActionDescription::List actionsToListAndFree(GList *glist) class Authority::Private { 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_revokeTemporaryAuthorizationCancellable = g_cancellable_new(); - GError *gerror = NULL; - if (pkAuthority == NULL) + GError *gerror = nullptr; + if (pkAuthority == nullptr) { - pkAuthority = polkit_authority_get_sync(NULL, &gerror); - if (gerror != NULL) + pkAuthority = polkit_authority_get_sync(nullptr, &gerror); + if (gerror != nullptr) { setError(E_GetAuthority, gerror->message); g_error_free(gerror); @@ -181,13 +181,13 @@ void Authority::Private::init() } } - if (pkAuthority == NULL) + if (pkAuthority == nullptr) { return; } // 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) @@ -271,11 +271,11 @@ Authority::Result Authority::checkAuthorizationSync(const TQString &actionId, return Unknown; } - GError *error = NULL; + GError *error = nullptr; PolkitAuthorizationResult *pk_result = polkit_authority_check_authorization_sync(d->pkAuthority, - subject.subject(), actionId.ascii(), NULL, (PolkitCheckAuthorizationFlags)(int)flags, - NULL, &error); - if (error != NULL) + subject.subject(), actionId.ascii(), nullptr, (PolkitCheckAuthorizationFlags)(int)flags, + nullptr, &error); + if (error != nullptr) { d->setError(E_CheckFailed, error->message); g_error_free(error); @@ -308,7 +308,7 @@ void Authority::checkAuthorization(const TQString &actionId, const Subject &subj 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, d->checkAuthorizationCallback, this); } @@ -321,10 +321,10 @@ void Authority::Private::checkAuthorizationCallback(GObject *object, GAsyncResul return; } - GError *error = NULL; + GError *error = nullptr; PolkitAuthorizationResult *pkResult = polkit_authority_check_authorization_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 if (error->code != 1) @@ -334,7 +334,7 @@ void Authority::Private::checkAuthorizationCallback(GObject *object, GAsyncResul g_error_free(error); return; } - if (pkResult != NULL) + if (pkResult != nullptr) { emit authority->checkAuthorizationFinished(polkitResultToResult(pkResult)); g_object_unref(pkResult); @@ -360,9 +360,9 @@ ActionDescription::List Authority::enumerateActionsSync() return ActionDescription::List(); } - GError *error = NULL; - GList *glist = polkit_authority_enumerate_actions_sync(d->pkAuthority, NULL, &error); - if (error != NULL) + GError *error = nullptr; + GList *glist = polkit_authority_enumerate_actions_sync(d->pkAuthority, nullptr, &error); + if (error != nullptr) { d->setError(E_EnumFailed, error->message); g_error_free(error); @@ -390,9 +390,9 @@ void Authority::Private::enumerateActionsCallback(GObject *object, GAsyncResult { return; } - GError *error = NULL; + GError *error = nullptr; 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 if (error->code != 1) @@ -428,9 +428,9 @@ bool Authority::registerAuthenticationAgentSync(const Subject &subject, const TQ return false; } - GError *error = NULL; + GError *error = nullptr; 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) { d->setError(E_RegisterFailed, error->message); @@ -468,9 +468,9 @@ void Authority::Private::registerAuthenticationAgentCallback(GObject *object, GA { return; } - GError *error = NULL; + GError *error = nullptr; 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 if (error->code != 1) @@ -505,10 +505,10 @@ bool Authority::unregisterAuthenticationAgentSync(const Subject &subject, const return false; } - GError *error = NULL; + GError *error = nullptr; bool result = polkit_authority_unregister_authentication_agent_sync(d->pkAuthority, - subject.subject(), objectPath.utf8().data(), NULL, &error); - if (error != NULL) + subject.subject(), objectPath.utf8().data(), nullptr, &error); + if (error != nullptr) { d->setError(E_UnregisterFailed, error->message); g_error_free(error); @@ -544,10 +544,10 @@ void Authority::Private::unregisterAuthenticationAgentCallback(GObject *object, { return; } - GError *error = NULL; + GError *error = nullptr; bool res = polkit_authority_unregister_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 if (error->code != 1) @@ -582,10 +582,10 @@ bool Authority::authenticationAgentResponseSync(const TQString &cookie, const Id return false; } - GError *error = NULL; + GError *error = nullptr; bool result = polkit_authority_authentication_agent_response_sync(d->pkAuthority, - cookie.utf8().data(), identity.identity(), NULL, &error); - if (error != NULL) + cookie.utf8().data(), identity.identity(), nullptr, &error); + if (error != nullptr) { d->setError(E_AgentResponseFailed, error->message); g_error_free(error); @@ -621,10 +621,10 @@ void Authority::Private::authenticationAgentResponseCallback(GObject *object, GA { return; } - GError *error = NULL; + GError *error = nullptr; bool res = polkit_authority_authentication_agent_response_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 if (error->code != 1) @@ -650,10 +650,10 @@ TemporaryAuthorization::List Authority::enumerateTemporaryAuthorizationsSync(con { TemporaryAuthorization::List result; - GError *error = NULL; + GError *error = nullptr; GList *glist = polkit_authority_enumerate_temporary_authorizations_sync(d->pkAuthority, - subject.subject(), NULL, &error); - if (error != NULL) + subject.subject(), nullptr, &error); + if (error != nullptr) { d->setError(E_EnumFailed, error->message); g_error_free(error); @@ -661,7 +661,7 @@ TemporaryAuthorization::List Authority::enumerateTemporaryAuthorizationsSync(con } 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)); if (glist2->data) @@ -682,10 +682,10 @@ void Authority::Private::enumerateTemporaryAuthorizationsCallback(GObject *objec return; } - GError *error = NULL; + GError *error = nullptr; GList *glist = polkit_authority_enumerate_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 if (error->code != 1) @@ -697,7 +697,7 @@ void Authority::Private::enumerateTemporaryAuthorizationsCallback(GObject *objec } TemporaryAuthorization::List res; 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)); if (glist2->data) @@ -724,10 +724,10 @@ bool Authority::revokeTemporaryAuthorizationsSync(const Subject &subject) return false; } - GError *error = NULL; + GError *error = nullptr; bool result = polkit_authority_revoke_temporary_authorizations_sync(d->pkAuthority, - subject.subject(), NULL, &error); - if (error != NULL) + subject.subject(), nullptr, &error); + if (error != nullptr) { d->setError(E_RevokeFailed, error->message); g_error_free(error); @@ -757,9 +757,9 @@ void Authority::Private::revokeTemporaryAuthorizationsCallback(GObject *object, return; } - GError *error = NULL; + GError *error = nullptr; 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 if (error->code != 1) @@ -788,10 +788,10 @@ bool Authority::revokeTemporaryAuthorizationSync(const TQString &id) return false; } - GError *error = NULL; + GError *error = nullptr; bool result = polkit_authority_revoke_temporary_authorization_by_id_sync(d->pkAuthority, - id.utf8().data(), NULL, &error); - if (error != NULL) + id.utf8().data(), nullptr, &error); + if (error != nullptr) { d->setError(E_RevokeFailed, error->message); g_error_free(error); @@ -821,10 +821,10 @@ void Authority::Private::revokeTemporaryAuthorizationCallback(GObject *object, return; } - GError *error = NULL; + GError *error = nullptr; bool res = polkit_authority_revoke_temporary_authorization_by_id_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 if (error->code != 1) diff --git a/core/polkit-tqt-authority.h b/core/polkit-tqt-authority.h index 4df6a8a02..d4e0e0b53 100644 --- a/core/polkit-tqt-authority.h +++ b/core/polkit-tqt-authority.h @@ -137,7 +137,7 @@ class POLKIT_TQT_EXPORT Authority : public TQObject * * \return The current authority instance */ - static Authority* instance(PolkitAuthority *authority = NULL); + static Authority* instance(PolkitAuthority *authority = nullptr); ~Authority(); @@ -513,7 +513,7 @@ class POLKIT_TQT_EXPORT Authority : public TQObject Authority(const Authority&); Authority& operator=(const Authority&); - Authority(TQObject *parent = NULL); + Authority(TQObject *parent = nullptr); static Authority *m_theAuthority; diff --git a/core/polkit-tqt-details.cpp b/core/polkit-tqt-details.cpp index 245ce2577..5b2a80d64 100644 --- a/core/polkit-tqt-details.cpp +++ b/core/polkit-tqt-details.cpp @@ -37,7 +37,7 @@ namespace PolkitTQt class Details::Data : public TQShared { public: - Data() : details(NULL) + Data() : details(nullptr) { } @@ -111,7 +111,7 @@ Details::~Details() TQString Details::lookup(const TQString &key) const { const gchar *result = polkit_details_lookup(d->details, key.utf8().data()); - if (result != NULL) + if (result != nullptr) { return TQString::fromUtf8(result); } diff --git a/core/polkit-tqt-identity.cpp b/core/polkit-tqt-identity.cpp index 1415d5d7f..713c61c37 100644 --- a/core/polkit-tqt-identity.cpp +++ b/core/polkit-tqt-identity.cpp @@ -36,7 +36,7 @@ namespace PolkitTQt class Identity::Data : public TQShared { public: - Data() : identity(NULL) + Data() : identity(nullptr) { } @@ -108,7 +108,7 @@ Identity::~Identity() bool Identity::isValid() const { - return (d->identity != NULL); + return (d->identity != nullptr); } PolkitIdentity* Identity::identity() const @@ -149,9 +149,9 @@ Identity Identity::fromString(const TQString &string) return Identity(); } - GError *error = NULL; + GError *error = nullptr; 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)); return Identity(); @@ -166,12 +166,12 @@ Identity Identity::fromString(const TQString &string) UnixUserIdentity::UnixUserIdentity(const TQString &name) : Identity() { - GError *error = NULL; + GError *error = nullptr; 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)); - setIdentity(NULL); + setIdentity(nullptr); } } @@ -201,12 +201,12 @@ void UnixUserIdentity::setUid(uid_t uid) UnixGroupIdentity::UnixGroupIdentity(const TQString &name) : Identity() { - GError *error = NULL; + GError *error = nullptr; 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)); - setIdentity(NULL); + setIdentity(nullptr); } } diff --git a/core/polkit-tqt-subject.cpp b/core/polkit-tqt-subject.cpp index 3d9e99b7a..fe51e5265 100644 --- a/core/polkit-tqt-subject.cpp +++ b/core/polkit-tqt-subject.cpp @@ -36,7 +36,7 @@ namespace PolkitTQt class Subject::Data : public TQShared { public: - Data() : subject(NULL) + Data() : subject(nullptr) { } @@ -108,7 +108,7 @@ Subject::~Subject() bool Subject::isValid() const { - return (d->subject != NULL); + return (d->subject != nullptr); } PolkitSubject* Subject::subject() const @@ -149,9 +149,9 @@ Subject Subject::fromString(const TQString &string) return Subject(); } - GError *error = NULL; + GError *error = nullptr; 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)); return Subject(); @@ -229,12 +229,12 @@ UnixSessionSubject::UnixSessionSubject(const TQString &sessionId) : Subject() UnixSessionSubject::UnixSessionSubject(TQ_LONG pid) : Subject() { - GError *error = NULL; - setSubject(polkit_unix_session_new_for_process_sync(pid, NULL, &error)); - if (error != NULL) + GError *error = nullptr; + setSubject(polkit_unix_session_new_for_process_sync(pid, nullptr, &error)); + if (error != nullptr) { tqWarning(TQString("Cannot create unix session subject from pid: %1").arg(error->message)); - setSubject(NULL); + setSubject(nullptr); } } diff --git a/examples/PkExample.cpp b/examples/PkExample.cpp index 4491dadd3..99c0e641f 100644 --- a/examples/PkExample.cpp +++ b/examples/PkExample.cpp @@ -48,12 +48,12 @@ using namespace PolkitTQt; 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"); 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(1, 200); diff --git a/examples/agent/tqtlistener.cpp b/examples/agent/tqtlistener.cpp index e915eabce..59cfd40f2 100644 --- a/examples/agent/tqtlistener.cpp +++ b/examples/agent/tqtlistener.cpp @@ -42,17 +42,14 @@ void TQtListener::initiateAuthentication(const TQString &actionId, const TQStrin tqDebug("Initiate authentication for " + actionId + " with message " + message); tqDebug(" iconName " + iconName); TQStringList dkeys = details.keys(); - TQStringList::Iterator dkIt; - for (dkIt = dkeys.begin(); dkIt != dkeys.end(); ++dkIt) + for (const TQString &dkey : dkeys) { - tqDebug(" key " + (*dkIt)); + tqDebug(" key " + dkey); } tqDebug(" cookie " + cookie); - PolkitTQt::Identity::List::ConstIterator iIt; - for (iIt = identities.begin(); iIt != identities.end(); ++iIt) + for (const PolkitTQt::Identity &identity : identities) { - PolkitTQt::Identity identity = *iIt; tqDebug(identity.toString()); Session *session = new Session(identity, cookie, result); 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(); bool ok; 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()) { session->setResponse(text); diff --git a/examples/agent/tqtlistener.h b/examples/agent/tqtlistener.h index 202efa278..420915839 100644 --- a/examples/agent/tqtlistener.h +++ b/examples/agent/tqtlistener.h @@ -40,7 +40,7 @@ class TQtListener : public PolkitTQt::Agent::Listener Q_OBJECT public: - TQtListener(TQObject *parent = 0); + TQtListener(TQObject *parent = nullptr); public slots: void initiateAuthentication(const TQString &actionId, const TQString &message, diff --git a/gui/polkit-tqt-gui-action.h b/gui/polkit-tqt-gui-action.h index 4f5bb2e2d..21c10100b 100644 --- a/gui/polkit-tqt-gui-action.h +++ b/gui/polkit-tqt-gui-action.h @@ -77,7 +77,7 @@ class POLKIT_TQT_EXPORT Action : public TQAction * \param actionId the PolicyKit action Id (e.g.: org.freedesktop.policykit.read) * \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(); diff --git a/gui/polkit-tqt-gui-actionbutton.cpp b/gui/polkit-tqt-gui-actionbutton.cpp index ffcdc2f28..48a0d1494 100644 --- a/gui/polkit-tqt-gui-actionbutton.cpp +++ b/gui/polkit-tqt-gui-actionbutton.cpp @@ -92,10 +92,8 @@ void ActionButton::streamClicked() void ActionButton::updateButton() { - TQValueList<TQButton*>::iterator butIt; - for (butIt = d->buttons.begin(); butIt != d->buttons.end(); ++butIt) + for (TQButton *&ent : d->buttons) { - TQButton *ent = *butIt; if (isVisible()) { ent->show(); @@ -128,10 +126,8 @@ void ActionButton::updateButton() bool ActionButton::activate() { bool tg = false; - TQValueList<TQButton*>::iterator butIt; - for (butIt = d->buttons.begin(); butIt != d->buttons.end(); ++butIt) + for (TQButton *&ent : d->buttons) { - TQButton *ent = *butIt; if (ent->isToggleButton()) { // we set the the current Action state diff --git a/gui/polkit-tqt-gui-actionbutton.h b/gui/polkit-tqt-gui-actionbutton.h index 7ec45f296..6ab25577c 100644 --- a/gui/polkit-tqt-gui-actionbutton.h +++ b/gui/polkit-tqt-gui-actionbutton.h @@ -72,7 +72,7 @@ class POLKIT_TQT_EXPORT ActionButton : public Action * \param parent the parent object */ explicit ActionButton(TQButton *button, const TQString &actionId = TQString::null, - TQObject *parent = 0); + TQObject *parent = nullptr); virtual ~ActionButton(); /** @@ -131,7 +131,7 @@ class POLKIT_TQT_EXPORT ActionButton : public Action void clicked(TQButton *button, bool checked = false); protected: - ActionButton(ActionButtonPrivate &dd, const TQString &actionId, TQObject *parent = 0); + ActionButton(ActionButtonPrivate &dd, const TQString &actionId, TQObject *parent = nullptr); ActionButtonPrivate *const d; diff --git a/gui/polkit-tqt-gui-actionbuttons.cpp b/gui/polkit-tqt-gui-actionbuttons.cpp index 78aced5d6..f4e72d54f 100644 --- a/gui/polkit-tqt-gui-actionbuttons.cpp +++ b/gui/polkit-tqt-gui-actionbuttons.cpp @@ -32,7 +32,7 @@ namespace PolkitTQt 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) { 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 (butIt = d->buttons.begin(); butIt != d->buttons.end(); ++butIt) + for (TQButton *&ent : buttons) { - TQButton *ent = *butIt; addButton(ent); } } -TQValueList<TQButton *> ActionButtons::buttons() const +TQValueList<TQButton*> ActionButtons::buttons() const { return d->buttons; } diff --git a/gui/polkit-tqt-gui-actionbuttons.h b/gui/polkit-tqt-gui-actionbuttons.h index b85b632be..43b80bb93 100644 --- a/gui/polkit-tqt-gui-actionbuttons.h +++ b/gui/polkit-tqt-gui-actionbuttons.h @@ -62,8 +62,8 @@ class ActionButtons : public ActionButton * \param actionId the action Id to create the underlying Action * \param parent the parent object */ - explicit ActionButtons(const TQValueList<TQButton*> &buttons, - const TQString &actionId = TQString::null, TQObject *parent = 0); + explicit ActionButtons(TQValueList<TQButton*> &buttons, + const TQString &actionId = TQString::null, TQObject *parent = nullptr); virtual ~ActionButtons(); /** @@ -80,7 +80,7 @@ class ActionButtons : public ActionButton * * \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 diff --git a/tests/test_auth_enum_actions.cpp b/tests/test_auth_enum_actions.cpp index d7c992a97..8a9030ff7 100644 --- a/tests/test_auth_enum_actions.cpp +++ b/tests/test_auth_enum_actions.cpp @@ -27,12 +27,11 @@ int main(void) } // Check whether enumerateAction returns at least example actions int count = 0; - ActionDescription::List::const_iterator adIt; - for (adIt = list.begin(); adIt != list.end(); ++adIt) + for (const ActionDescription &actionDesc : list) { - if (((*adIt).actionId() == "org.tqt.policykit.examples.kick") || - ((*adIt).actionId() == "org.tqt.policykit.examples.cry") || - ((*adIt).actionId() == "org.tqt.policykit.examples.bleed")) + if ((actionDesc.actionId() == "org.tqt.policykit.examples.kick") || + (actionDesc.actionId() == "org.tqt.policykit.examples.cry") || + (actionDesc.actionId() == "org.tqt.policykit.examples.bleed")) { count++; } |