summaryrefslogtreecommitdiffstats
path: root/agent
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 /agent
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 'agent')
-rw-r--r--agent/listeneradapter.cpp10
-rw-r--r--agent/listeneradapter.h2
-rw-r--r--agent/polkit-tqt-agent-listener.cpp10
-rw-r--r--agent/polkit-tqt-agent-listener.h4
-rw-r--r--agent/polkit-tqt-agent-session.cpp8
-rw-r--r--agent/polkit-tqt-agent-session.h8
-rw-r--r--agent/polkit-tqt-listener.cpp6
7 files changed, 23 insertions, 25 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);
}