Skip to content

Commit

Permalink
polkitagent: Turn PolicyKitAgent into a singleton
Browse files Browse the repository at this point in the history
We only have one instance of it anyway.

Issue: #146
  • Loading branch information
plfiorini committed Feb 25, 2014
1 parent f4370ae commit 48e0d23
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/daemons/polkitagent/policykitagent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@

#include <unistd.h>

Q_GLOBAL_STATIC(PolicyKitAgent, s_agent)

QT_USE_NAMESPACE_ACCOUNTSSERVICE

/*
Expand Down Expand Up @@ -74,6 +76,11 @@ PolicyKitAgent::~PolicyKitAgent()
delete d_ptr;
}

PolicyKitAgent *PolicyKitAgent::instance()
{
return s_agent();
}

void PolicyKitAgent::initiateAuthentication(const QString &actionId,
const QString &message,
const QString &iconName,
Expand Down
2 changes: 2 additions & 0 deletions src/daemons/polkitagent/policykitagent.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class PolicyKitAgent : public PolkitQt1::Agent::Listener
explicit PolicyKitAgent(QObject *parent = 0);
~PolicyKitAgent();

static PolicyKitAgent *instance();

constexpr static const char *name() { return "PolicyKitAgent"; }

Q_SIGNALS:
Expand Down

0 comments on commit 48e0d23

Please sign in to comment.