summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2021-12-28 20:45:45 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2021-12-28 20:45:45 +0900
commit82b07f1a3cc29b9785c292174343b464a774a722 (patch)
tree7a3501a01cf6e6d645929063ac601f4d3eb91edb /core
parent416bed9bc124e24cc1351c7d8e5810ca7570a023 (diff)
downloadpolkit-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 <michele.calgaro@yahoo.it>
Diffstat (limited to 'core')
-rw-r--r--core/polkit-tqt-authority.cpp104
-rw-r--r--core/polkit-tqt-authority.h4
-rw-r--r--core/polkit-tqt-details.cpp4
-rw-r--r--core/polkit-tqt-identity.cpp20
-rw-r--r--core/polkit-tqt-subject.cpp16
5 files changed, 74 insertions, 74 deletions
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);
}
}