gnome-packagekit r194 - trunk/src
- From: rhughes svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-packagekit r194 - trunk/src
- Date: Wed, 30 Apr 2008 14:30:03 +0100 (BST)
Author: rhughes
Date: Wed Apr 30 13:30:03 2008
New Revision: 194
URL: http://svn.gnome.org/viewvc/gnome-packagekit?rev=194&view=rev
Log:
from git
Added:
trunk/src/gpk-client-eula.c
trunk/src/gpk-client-eula.h
trunk/src/gpk-client-signature.c
trunk/src/gpk-client-signature.h
trunk/src/gpk-client-untrusted.c
trunk/src/gpk-client-untrusted.h
Added: trunk/src/gpk-client-eula.c
==============================================================================
--- (empty file)
+++ trunk/src/gpk-client-eula.c Wed Apr 30 13:30:03 2008
@@ -0,0 +1,146 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <string.h>
+#include <gtk/gtk.h>
+#include <glade/glade.h>
+
+#include <pk-debug.h>
+#include <pk-package-id.h>
+#include "gpk-gnome.h"
+
+static gboolean has_agreed_eula = FALSE;
+
+/**
+ * gpk_client_eula_button_agree_cb:
+ **/
+static void
+gpk_client_eula_button_agree_cb (GtkWidget *widget_button, gpointer data)
+{
+ has_agreed_eula = TRUE;
+ gtk_main_quit ();
+}
+
+/**
+ * gpk_client_eula_button_help_cb:
+ **/
+static void
+gpk_client_eula_button_help_cb (GtkWidget *widget, gpointer data)
+{
+ /* FIXME: need a whole section on this! */
+ gpk_gnome_help (NULL);
+}
+
+/**
+ * gpk_client_eula_show:
+ *
+ * Return value: if we agreed
+ * TODO: Add in gconf checks to see if we've already agreed
+ **/
+gboolean
+gpk_client_eula_show (const gchar *eula_id, const gchar *package_id,
+ const gchar *vendor_name, const gchar *license_agreement)
+{
+ GladeXML *glade_xml;
+ GtkWidget *widget;
+ GtkTextBuffer *buffer;
+ gchar *text;
+ PkPackageId *ident;
+
+ g_return_val_if_fail (eula_id != NULL, FALSE);
+ g_return_val_if_fail (package_id != NULL, FALSE);
+ g_return_val_if_fail (vendor_name != NULL, FALSE);
+ g_return_val_if_fail (license_agreement != NULL, FALSE);
+
+ glade_xml = glade_xml_new (PK_DATA "/gpk-eula.glade", NULL, NULL);
+
+ /* connect up default actions */
+ widget = glade_xml_get_widget (glade_xml, "window_eula");
+ g_signal_connect_swapped (widget, "delete_event", G_CALLBACK (gtk_main_quit), NULL);
+ widget = glade_xml_get_widget (glade_xml, "button_cancel");
+ g_signal_connect_swapped (widget, "clicked", G_CALLBACK (gtk_main_quit), NULL);
+
+ /* set icon name */
+ widget = glade_xml_get_widget (glade_xml, "window_eula");
+ gtk_window_set_icon_name (GTK_WINDOW (widget), "system-software-installer");
+
+ /* connect up buttons */
+ widget = glade_xml_get_widget (glade_xml, "button_agree");
+ g_signal_connect (widget, "clicked", G_CALLBACK (gpk_client_eula_button_agree_cb), NULL);
+ widget = glade_xml_get_widget (glade_xml, "button_help");
+ g_signal_connect (widget, "clicked", G_CALLBACK (gpk_client_eula_button_help_cb), NULL);
+
+ /* title */
+ widget = glade_xml_get_widget (glade_xml, "label_title");
+ ident = pk_package_id_new_from_string (package_id);
+ text = g_strdup_printf ("<b><big>License required for %s by %s</big></b>", ident->name, vendor_name);
+ gtk_label_set_label (GTK_LABEL (widget), text);
+ pk_package_id_free (ident);
+ g_free (text);
+
+ buffer = gtk_text_buffer_new (NULL);
+ gtk_text_buffer_insert_at_cursor (buffer, license_agreement, strlen (license_agreement));
+ widget = glade_xml_get_widget (glade_xml, "textview_details");
+ gtk_text_view_set_buffer (GTK_TEXT_VIEW (widget), buffer);
+
+ /* set minimum size a bit bigger */
+ gtk_widget_set_size_request (widget, 100, 200);
+
+ /* show window */
+ widget = glade_xml_get_widget (glade_xml, "window_eula");
+ gtk_widget_show (widget);
+
+ /* wait for button press */
+ has_agreed_eula = FALSE;
+ gtk_main ();
+
+ /* hide window */
+ if (GTK_IS_WIDGET (widget)) {
+ gtk_widget_hide (widget);
+ }
+ g_object_unref (glade_xml);
+ g_object_unref (buffer);
+
+ return has_agreed_eula;
+}
+
+/***************************************************************************
+ *** MAKE CHECK TESTS ***
+ ***************************************************************************/
+#ifdef PK_BUILD_TESTS
+#include <libselftest.h>
+
+void
+gpk_client_eula_self_test (gpointer data)
+{
+ LibSelfTest *test = (LibSelfTest *) data;
+
+ if (libst_start (test, "GpkClientEula", CLASS_AUTO) == FALSE) {
+ return;
+ }
+ libst_end (test);
+}
+#endif
+
Added: trunk/src/gpk-client-eula.h
==============================================================================
--- (empty file)
+++ trunk/src/gpk-client-eula.h Wed Apr 30 13:30:03 2008
@@ -0,0 +1,38 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GPK_CLIENT_EULA_H
+#define __GPK_CLIENT_EULA_H
+
+#include <glib-object.h>
+#include <pk-enum.h>
+
+G_BEGIN_DECLS
+
+void gpk_client_eula_self_test (gpointer data);
+gboolean gpk_client_eula_show (const gchar *eula_id,
+ const gchar *package_id,
+ const gchar *vendor_name,
+ const gchar *license_agreement);
+
+G_END_DECLS
+
+#endif /* __GPK_CLIENT_EULA_H */
Added: trunk/src/gpk-client-signature.c
==============================================================================
--- (empty file)
+++ trunk/src/gpk-client-signature.c Wed Apr 30 13:30:03 2008
@@ -0,0 +1,133 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <string.h>
+#include <gtk/gtk.h>
+#include <glade/glade.h>
+
+#include <pk-debug.h>
+#include <pk-package-id.h>
+#include "gpk-gnome.h"
+
+static gboolean has_imported_signature = FALSE;
+
+/**
+ * gpk_client_signature_button_yes_cb:
+ **/
+static void
+gpk_client_signature_button_yes_cb (GtkWidget *widget_button, gpointer data)
+{
+ has_imported_signature = TRUE;
+ gtk_main_quit ();
+}
+
+/**
+ * gpk_client_signature_button_help_cb:
+ **/
+static void
+gpk_client_signature_button_help_cb (GtkWidget *widget, gpointer data)
+{
+ /* FIXME: need a whole section on this! */
+ gpk_gnome_help (NULL);
+}
+
+/**
+ * gpk_client_signature_show:
+ *
+ * Return value: if we agreed
+ **/
+gboolean
+gpk_client_signature_show (const gchar *package_id, const gchar *repository_name,
+ const gchar *key_url, const gchar *key_userid, const gchar *key_id,
+ const gchar *key_fingerprint, const gchar *key_timestamp)
+{
+ GtkWidget *widget;
+ GladeXML *glade_xml;
+
+ g_return_val_if_fail (package_id != NULL, FALSE);
+
+ glade_xml = glade_xml_new (PK_DATA "/gpk-signature.glade", NULL, NULL);
+
+ /* connect up default actions */
+ widget = glade_xml_get_widget (glade_xml, "window_gpg");
+ g_signal_connect_swapped (widget, "delete_event", G_CALLBACK (gtk_main_quit), NULL);
+ widget = glade_xml_get_widget (glade_xml, "button_no");
+ g_signal_connect_swapped (widget, "clicked", G_CALLBACK (gtk_main_quit), NULL);
+
+ /* set icon name */
+ widget = glade_xml_get_widget (glade_xml, "window_gpg");
+ gtk_window_set_icon_name (GTK_WINDOW (widget), "system-software-installer");
+
+ /* connect up buttons */
+ widget = glade_xml_get_widget (glade_xml, "button_yes");
+ g_signal_connect (widget, "clicked", G_CALLBACK (gpk_client_signature_button_yes_cb), NULL);
+ widget = glade_xml_get_widget (glade_xml, "button_help");
+ g_signal_connect (widget, "clicked", G_CALLBACK (gpk_client_signature_button_help_cb), NULL);
+
+ /* show correct text */
+ widget = glade_xml_get_widget (glade_xml, "label_name");
+ gtk_label_set_label (GTK_LABEL (widget), repository_name);
+ widget = glade_xml_get_widget (glade_xml, "label_url");
+ gtk_label_set_label (GTK_LABEL (widget), key_url);
+ widget = glade_xml_get_widget (glade_xml, "label_user");
+ gtk_label_set_label (GTK_LABEL (widget), key_userid);
+ widget = glade_xml_get_widget (glade_xml, "label_id");
+ gtk_label_set_label (GTK_LABEL (widget), key_id);
+
+ /* show window */
+ widget = glade_xml_get_widget (glade_xml, "window_gpg");
+ gtk_widget_show (widget);
+
+ /* wait for button press */
+ has_imported_signature = FALSE;
+ gtk_main ();
+
+ /* hide window */
+ if (GTK_IS_WIDGET (widget)) {
+ gtk_widget_hide (widget);
+ }
+ g_object_unref (glade_xml);
+
+ return has_imported_signature;
+}
+
+/***************************************************************************
+ *** MAKE CHECK TESTS ***
+ ***************************************************************************/
+#ifdef PK_BUILD_TESTS
+#include <libselftest.h>
+
+void
+gpk_client_signature_self_test (gpointer data)
+{
+ LibSelfTest *test = (LibSelfTest *) data;
+
+ if (libst_start (test, "GpkClientEula", CLASS_AUTO) == FALSE) {
+ return;
+ }
+ libst_end (test);
+}
+#endif
+
Added: trunk/src/gpk-client-signature.h
==============================================================================
--- (empty file)
+++ trunk/src/gpk-client-signature.h Wed Apr 30 13:30:03 2008
@@ -0,0 +1,41 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GPK_CLIENT_SIGNATURE_H
+#define __GPK_CLIENT_SIGNATURE_H
+
+#include <glib-object.h>
+#include <pk-enum.h>
+
+G_BEGIN_DECLS
+
+void gpk_client_signature_self_test (gpointer data);
+gboolean gpk_client_signature_show (const gchar *package_id,
+ const gchar *repository_name,
+ const gchar *key_url,
+ const gchar *key_userid,
+ const gchar *key_id,
+ const gchar *key_fingerprint,
+ const gchar *key_timestamp);
+
+G_END_DECLS
+
+#endif /* __GPK_CLIENT_SIGNATURE_H */
Added: trunk/src/gpk-client-untrusted.c
==============================================================================
--- (empty file)
+++ trunk/src/gpk-client-untrusted.c Wed Apr 30 13:30:03 2008
@@ -0,0 +1,152 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <string.h>
+#include <gtk/gtk.h>
+#include <glade/glade.h>
+#include <polkit-gnome/polkit-gnome.h>
+
+#include <pk-debug.h>
+#include <pk-enum.h>
+#include <pk-package-id.h>
+#include "gpk-gnome.h"
+#include "gpk-common.h"
+
+static gboolean retry_untrusted = FALSE;
+
+/**
+ * gpk_client_untrusted_button_cb:
+ **/
+static void
+gpk_client_untrusted_button_cb (PolKitGnomeAction *action, gpointer data)
+{
+ pk_debug ("need to retry...");
+ retry_untrusted = TRUE;
+ gtk_main_quit ();
+}
+
+/**
+ * gpk_client_untrusted_show:
+ *
+ * Return value: if we agreed
+ * TODO: Add in gconf checks to see if we've already agreed
+ **/
+gboolean
+gpk_client_untrusted_show (PkErrorCodeEnum code)
+{
+ GtkWidget *widget;
+ GtkWidget *button;
+ PolKitAction *pk_action;
+ GladeXML *glade_xml;
+ gchar *text;
+ const gchar *title;
+ const gchar *message;
+ PolKitGnomeAction *update_system_action;
+
+ title = gpk_error_enum_to_localised_text (code);
+ message = _("Malicious software can damage your computer or cause other harm. "
+ "Are you <b>sure</b> you want to install this package?");
+
+ glade_xml = glade_xml_new (PK_DATA "/gpk-error.glade", NULL, NULL);
+
+ /* connect up actions */
+ widget = glade_xml_get_widget (glade_xml, "window_error");
+ g_signal_connect_swapped (widget, "delete_event", G_CALLBACK (gtk_main_quit), NULL);
+
+ /* set icon name */
+ widget = glade_xml_get_widget (glade_xml, "window_error");
+ gtk_window_set_icon_name (GTK_WINDOW (widget), "system-software-installer");
+
+ /* close button */
+ widget = glade_xml_get_widget (glade_xml, "button_close");
+ g_signal_connect_swapped (widget, "clicked", G_CALLBACK (gtk_main_quit), NULL);
+
+ /* title */
+ widget = glade_xml_get_widget (glade_xml, "label_title");
+ text = g_strdup_printf ("<b><big>%s</big></b>", title);
+ gtk_label_set_label (GTK_LABEL (widget), text);
+ g_free (text);
+
+ /* message */
+ widget = glade_xml_get_widget (glade_xml, "label_message");
+ gtk_label_set_markup (GTK_LABEL (widget), message);
+
+ /* don't show text in the expander */
+ widget = glade_xml_get_widget (glade_xml, "expander_details");
+ gtk_widget_hide (widget);
+
+ /* add the extra button and connect up to a Policykit action */
+ pk_action = polkit_action_new ();
+ polkit_action_set_action_id (pk_action, "org.freedesktop.packagekit.localinstall-untrusted");
+ update_system_action = polkit_gnome_action_new_default ("localinstall-untrusted", pk_action,
+ _("_Force install"),
+ _("Force installing package"));
+ g_object_set (update_system_action,
+ "no-icon-name", GTK_STOCK_APPLY,
+ "auth-icon-name", GTK_STOCK_APPLY,
+ "yes-icon-name", GTK_STOCK_APPLY,
+ "self-blocked-icon-name", GTK_STOCK_APPLY,
+ NULL);
+ polkit_action_unref (pk_action);
+ g_signal_connect (update_system_action, "activate",
+ G_CALLBACK (gpk_client_untrusted_button_cb), NULL);
+ button = polkit_gnome_action_create_button (update_system_action);
+ widget = glade_xml_get_widget (glade_xml, "hbuttonbox2");
+ gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0);
+ gtk_box_reorder_child (GTK_BOX (widget), button, 0);
+
+ /* show window */
+ widget = glade_xml_get_widget (glade_xml, "window_error");
+ gtk_widget_show (widget);
+
+ /* wait for button press */
+ gtk_main ();
+
+ /* hide window */
+ if (GTK_IS_WIDGET (widget)) {
+ gtk_widget_hide (widget);
+ }
+ g_object_unref (glade_xml);
+ return retry_untrusted;
+}
+
+/***************************************************************************
+ *** MAKE CHECK TESTS ***
+ ***************************************************************************/
+#ifdef PK_BUILD_TESTS
+#include <libselftest.h>
+
+void
+gpk_client_untrusted_self_test (gpointer data)
+{
+ LibSelfTest *test = (LibSelfTest *) data;
+
+ if (libst_start (test, "GpkClientUntrusted", CLASS_AUTO) == FALSE) {
+ return;
+ }
+ libst_end (test);
+}
+#endif
+
Added: trunk/src/gpk-client-untrusted.h
==============================================================================
--- (empty file)
+++ trunk/src/gpk-client-untrusted.h Wed Apr 30 13:30:03 2008
@@ -0,0 +1,35 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GPK_CLIENT_UNTRUSTED_H
+#define __GPK_CLIENT_UNTRUSTED_H
+
+#include <glib-object.h>
+#include <pk-enum.h>
+
+G_BEGIN_DECLS
+
+void gpk_client_untrusted_self_test (gpointer data);
+gboolean gpk_client_untrusted_show (PkErrorCodeEnum code);
+
+G_END_DECLS
+
+#endif /* __GPK_CLIENT_UNTRUSTED_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]