TemporaryAuthorization::TemporaryAuthorization(PolkitTemporaryAuthorization *pkTemporaryAuthorization) : d(new Data) { g_type_init(); d->id = QString::fromUtf8(polkit_temporary_authorization_get_id(pkTemporaryAuthorization)); d->actionId = QString::fromUtf8(polkit_temporary_authorization_get_action_id(pkTemporaryAuthorization)); d->subject = Subject::fromString(polkit_subject_to_string(polkit_temporary_authorization_get_subject(pkTemporaryAuthorization))); d->timeObtained = QDateTime::fromTime_t(polkit_temporary_authorization_get_time_obtained(pkTemporaryAuthorization)); d->timeExpires = QDateTime::fromTime_t(polkit_temporary_authorization_get_time_expires(pkTemporaryAuthorization)); g_object_unref(pkTemporaryAuthorization); }
static void update_temporary_authorization_icon_real (void) { #if 0 GList *l; g_debug ("have %d tmp authorizations", g_list_length (current_temporary_authorizations)); for (l = current_temporary_authorizations; l != NULL; l = l->next) { PolkitTemporaryAuthorization *authz = POLKIT_TEMPORARY_AUTHORIZATION (l->data); g_debug ("have tmp authz for action %s (subject %s) with id %s (obtained %d, expires %d)", polkit_temporary_authorization_get_action_id (authz), polkit_subject_to_string (polkit_temporary_authorization_get_subject (authz)), polkit_temporary_authorization_get_id (authz), (gint) polkit_temporary_authorization_get_time_obtained (authz), (gint) polkit_temporary_authorization_get_time_expires (authz)); } #endif /* TODO: * * - we could do something fancy like displaying a window with the tmp authz * when the icon is clicked... * * - we could do some work using polkit_subject_exists() to ignore tmp authz * for subjects that no longer exists.. this is because temporary authorizations * are only valid for the subject that trigger the authentication dialog. * * Maybe the authority could do this, would probably involve some polling, but * it seems cleaner to do this server side. */ if (current_temporary_authorizations != NULL) { /* show icon */ if (status_icon == NULL) { status_icon = gtk_status_icon_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION); gtk_status_icon_set_tooltip_text (status_icon, _("Click the icon to drop all elevated privileges")); g_signal_connect (status_icon, "activate", G_CALLBACK (on_status_icon_activate), NULL); g_signal_connect (status_icon, "popup-menu", G_CALLBACK (on_status_icon_popup_menu), NULL); } } else { /* hide icon */ if (status_icon != NULL) { gtk_status_icon_set_visible (status_icon, FALSE); g_object_unref (status_icon); status_icon = NULL; } } }