|
|
|
|
@ -2936,73 +2936,73 @@ void on_enable_disable_clicked(GtkButton *, main_window *widgets){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// standard functions
|
|
|
|
|
gboolean on_unelevate(main_window* widgets);
|
|
|
|
|
gboolean on_unelevate(main_window* widgets){
|
|
|
|
|
yon_ubl_status_box_render(UNAUTHTORIZED_LABEL,BACKGROUND_IMAGE_INFO_TYPE);
|
|
|
|
|
gtk_widget_set_sensitive(widgets->UpgradePermissionsMenuItem,1);
|
|
|
|
|
g_object_unref(main_config.authorization_result);
|
|
|
|
|
main_config.authorization_result=NULL;
|
|
|
|
|
return G_SOURCE_REMOVE;
|
|
|
|
|
}
|
|
|
|
|
gboolean yon_timeoutcheck_authtorization(gpointer widgets);
|
|
|
|
|
gboolean yon_timeoutcheck_authtorization(gpointer widgets){
|
|
|
|
|
|
|
|
|
|
if (!polkit_authorization_result_get_is_authorized(main_config.authorization_result)){
|
|
|
|
|
gdk_threads_add_idle((GSourceFunc)on_unelevate,widgets);
|
|
|
|
|
return G_SOURCE_REMOVE;
|
|
|
|
|
}
|
|
|
|
|
return G_SOURCE_CONTINUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void *yon_authorized_loop(void*);
|
|
|
|
|
void *yon_authorized_loop(void*){
|
|
|
|
|
while (polkit_authorization_result_get_is_authorized(main_config.authorization_result)){
|
|
|
|
|
g_mutex_lock(&main_config.authorized_mutex);
|
|
|
|
|
if (main_config.queue){
|
|
|
|
|
for (int i=0;i<main_config.queue_size;i++){
|
|
|
|
|
G_SOURCE_FUNC(main_config.queue[i]->func)(main_config.queue[i]->data);
|
|
|
|
|
}
|
|
|
|
|
free(main_config.queue);
|
|
|
|
|
main_config.queue=NULL;
|
|
|
|
|
main_config.queue_size=0;
|
|
|
|
|
}
|
|
|
|
|
g_mutex_unlock(&main_config.authorized_mutex);
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
// gboolean on_unelevate(main_window* widgets);
|
|
|
|
|
// gboolean on_unelevate(main_window* widgets){
|
|
|
|
|
// yon_ubl_status_box_render(UNAUTHTORIZED_LABEL,BACKGROUND_IMAGE_INFO_TYPE);
|
|
|
|
|
// gtk_widget_set_sensitive(widgets->UpgradePermissionsMenuItem,1);
|
|
|
|
|
// g_object_unref(main_config.authorization_result);
|
|
|
|
|
// main_config.authorization_result=NULL;
|
|
|
|
|
// return G_SOURCE_REMOVE;
|
|
|
|
|
// }
|
|
|
|
|
// gboolean yon_timeoutcheck_authtorization(gpointer widgets);
|
|
|
|
|
// gboolean yon_timeoutcheck_authtorization(gpointer widgets){
|
|
|
|
|
|
|
|
|
|
// if (!polkit_authorization_result_get_is_authorized(main_config.authorization_result)){
|
|
|
|
|
// gdk_threads_add_idle((GSourceFunc)on_unelevate,widgets);
|
|
|
|
|
// return G_SOURCE_REMOVE;
|
|
|
|
|
// }
|
|
|
|
|
// return G_SOURCE_CONTINUE;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
void authorize_callback(GObject *source, GAsyncResult *res, main_window *widgets);
|
|
|
|
|
void authorize_callback(GObject *source, GAsyncResult *res, main_window *widgets){
|
|
|
|
|
GError *err = NULL;
|
|
|
|
|
main_config.authorization_result = polkit_authority_check_authorization_finish(POLKIT_AUTHORITY(source),res,&err);
|
|
|
|
|
if (err){
|
|
|
|
|
// void *yon_authorized_loop(void*);
|
|
|
|
|
// void *yon_authorized_loop(void*){
|
|
|
|
|
// while (polkit_authorization_result_get_is_authorized(main_config.authorization_result)){
|
|
|
|
|
// g_mutex_lock(&main_config.authorized_mutex);
|
|
|
|
|
// if (main_config.queue){
|
|
|
|
|
// for (int i=0;i<main_config.queue_size;i++){
|
|
|
|
|
// G_SOURCE_FUNC(main_config.queue[i]->func)(main_config.queue[i]->data);
|
|
|
|
|
// }
|
|
|
|
|
// free(main_config.queue);
|
|
|
|
|
// main_config.queue=NULL;
|
|
|
|
|
// main_config.queue_size=0;
|
|
|
|
|
// }
|
|
|
|
|
// g_mutex_unlock(&main_config.authorized_mutex);
|
|
|
|
|
// }
|
|
|
|
|
// return NULL;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// void authorize_callback(GObject *source, GAsyncResult *res, main_window *widgets);
|
|
|
|
|
// void authorize_callback(GObject *source, GAsyncResult *res, main_window *widgets){
|
|
|
|
|
// GError *err = NULL;
|
|
|
|
|
// main_config.authorization_result = polkit_authority_check_authorization_finish(POLKIT_AUTHORITY(source),res,&err);
|
|
|
|
|
// if (err){
|
|
|
|
|
|
|
|
|
|
g_thread_new("auth_loop",(GThreadFunc)yon_authorized_loop,NULL);
|
|
|
|
|
yon_ubl_status_box_render(AUTHTORIZED_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
g_timeout_add(10000, (GSourceFunc)yon_timeoutcheck_authtorization,widgets);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// g_thread_new("auth_loop",(GThreadFunc)yon_authorized_loop,NULL);
|
|
|
|
|
// yon_ubl_status_box_render(AUTHTORIZED_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
// g_timeout_add(10000, (GSourceFunc)yon_timeoutcheck_authtorization,widgets);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
void on_permissions_changed(GtkMenuItem *,main_window *widgets){
|
|
|
|
|
PolkitAuthority *authority;
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
authority = polkit_authority_get_sync(NULL,&error);
|
|
|
|
|
if (!authority){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
polkit_authority_check_authorization(
|
|
|
|
|
authority,
|
|
|
|
|
main_config.process,
|
|
|
|
|
"org.freedesktop.policykit.exec",
|
|
|
|
|
NULL,
|
|
|
|
|
POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
|
|
|
|
|
NULL,
|
|
|
|
|
(GAsyncReadyCallback)authorize_callback,
|
|
|
|
|
widgets
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
// void on_permissions_changed(GtkMenuItem *,main_window *widgets){
|
|
|
|
|
// PolkitAuthority *authority;
|
|
|
|
|
// GError *error = NULL;
|
|
|
|
|
// authority = polkit_authority_get_sync(NULL,&error);
|
|
|
|
|
// if (!authority){
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// polkit_authority_check_authorization(
|
|
|
|
|
// authority,
|
|
|
|
|
// main_config.process,
|
|
|
|
|
// "org.freedesktop.policykit.exec",
|
|
|
|
|
// NULL,
|
|
|
|
|
// POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
|
|
|
|
|
// NULL,
|
|
|
|
|
// (GAsyncReadyCallback)authorize_callback,
|
|
|
|
|
// widgets
|
|
|
|
|
// );
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
void config_init(){
|
|
|
|
|
main_config.always_open_documentation=0;
|
|
|
|
|
@ -3019,7 +3019,7 @@ void config_init(){
|
|
|
|
|
main_config.save_config=1;
|
|
|
|
|
main_config.queue=NULL;
|
|
|
|
|
main_config.queue_size=0;
|
|
|
|
|
main_config.process = polkit_unix_process_new_for_owner(getpid(),0,getuid());
|
|
|
|
|
// main_config.process = polkit_unix_process_new_for_owner(getpid(),0,getuid());
|
|
|
|
|
pid_t parent_pid;
|
|
|
|
|
parent_pid = getppid ();
|
|
|
|
|
if (parent_pid == 1)
|
|
|
|
|
@ -3228,7 +3228,7 @@ void yon_main_window_complete(template_main_window **window){
|
|
|
|
|
g_signal_connect(G_OBJECT(widgets->LoadLocalMenuItem),"activate",G_CALLBACK(on_load_local),NULL);
|
|
|
|
|
g_signal_connect(G_OBJECT(widgets->LoadCustomMenuItem),"activate",G_CALLBACK(on_config_custom_load),NULL);
|
|
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(widgets->UpgradePermissionsMenuItem),"activate",G_CALLBACK(on_permissions_changed),widgets);
|
|
|
|
|
// g_signal_connect(G_OBJECT(widgets->UpgradePermissionsMenuItem),"activate",G_CALLBACK(on_permissions_changed),widgets);
|
|
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(widgets->MainTree),"cursor-changed",G_CALLBACK(on_main_window_tree_selection_changed),widgets);
|
|
|
|
|
g_signal_connect(G_OBJECT(widgets->ServicesTree),"cursor-changed",G_CALLBACK(on_main_window_services_tree_selection_changed),widgets);
|
|
|
|
|
|