|
|
|
@ -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)
|
|
|
|
|