[packagekit] packagekit: Branch 'master' - 4 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Wed Feb 20 15:07:29 PST 2008
client/pk-console.c | 59 ++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 51 insertions(+), 8 deletions(-)
New commits:
commit 84d936e6e1020af661a12c7a76e837ef020d290d
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Feb 20 23:06:57 2008 +0000
keep gcc happy2
diff --git a/client/pk-console.c b/client/pk-console.c
index 625ffa2..055d042 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -484,7 +484,7 @@ pk_console_remove_only (PkClient *client, const gchar *package_id, gboolean forc
gboolean
pk_console_get_prompt (const gchar *question, gboolean defaultyes)
{
- gchar answer;
+ gchar answer = '\0';
gint retval;
/* pretty print */
commit 5a30202ba501d5f6c9ca7b3e549f0ebce0d42b26
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Feb 20 23:06:29 2008 +0000
keep gcc happy
diff --git a/client/pk-console.c b/client/pk-console.c
index b5f18d6..625ffa2 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -485,6 +485,7 @@ gboolean
pk_console_get_prompt (const gchar *question, gboolean defaultyes)
{
gchar answer;
+ gint retval;
/* pretty print */
g_print ("%s", question);
@@ -496,7 +497,7 @@ pk_console_get_prompt (const gchar *question, gboolean defaultyes)
do {
/* get one char */
- scanf("%c", &answer);
+ retval = scanf("%c", &answer);
/* positive */
if (answer == 'y' || answer == 'Y') {
commit 13ededb5454e7eed6a345ee142831fe599666f18
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Feb 20 22:56:36 2008 +0000
only exit pkcon if the daemon disconnected, not either
diff --git a/client/pk-console.c b/client/pk-console.c
index da43cdb..b5f18d6 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -1004,8 +1004,10 @@ static void
pk_connection_changed_cb (PkConnection *pconnection, gboolean connected, gpointer data)
{
/* if the daemon crashed, don't hang around */
- g_print ("The daemon crashed mid transaction. This is bad\n");
- exit (2);
+ if (connected == FALSE) {
+ g_print ("The daemon crashed mid transaction. This is bad\n");
+ exit (2);
+ }
}
/**
commit 45e03ec5746bb9e72921abcefaa504c41b4a21af
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Feb 20 22:55:19 2008 +0000
add the user check dep removal funtionality
diff --git a/client/pk-console.c b/client/pk-console.c
index 7eed863..da43cdb 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -479,6 +479,48 @@ pk_console_remove_only (PkClient *client, const gchar *package_id, gboolean forc
}
/**
+ * pk_console_get_prompt:
+ **/
+gboolean
+pk_console_get_prompt (const gchar *question, gboolean defaultyes)
+{
+ gchar answer;
+
+ /* pretty print */
+ g_print ("%s", question);
+ if (defaultyes == TRUE) {
+ g_print (" [Y/n] ");
+ } else {
+ g_print (" [N/y] ");
+ }
+
+ do {
+ /* get one char */
+ scanf("%c", &answer);
+
+ /* positive */
+ if (answer == 'y' || answer == 'Y') {
+ return TRUE;
+ }
+ /* negative */
+ if (answer == 'n' || answer == 'N') {
+ return FALSE;
+ }
+
+ /* default choice */
+ if (answer == '\n' && defaultyes == TRUE) {
+ return TRUE;
+ }
+ if (answer == '\n' && defaultyes == FALSE) {
+ return FALSE;
+ }
+ } while (TRUE);
+
+ /* keep GCC happy */
+ return FALSE;
+}
+
+/**
* pk_console_remove_package:
**/
static gboolean
@@ -533,19 +575,17 @@ pk_console_remove_package (PkClient *client, const gchar *package)
pk_package_id_free (ident);
}
- /* check for user input */
- g_print ("Okay to remove additional packages? [N/y]\n");
-
- /* TODO: prompt the user */
- remove = FALSE;
+ /* get user input */
+ remove = pk_console_get_prompt ("Okay to remove additional packages?", FALSE);
+ /* we chickened out */
if (remove == FALSE) {
g_print ("Cancelled!\n");
g_free (package_id);
return FALSE;
}
- pk_debug ("You agreed, remove with deps");
+ /* remove all the stuff */
pk_console_remove_only (client, package_id, TRUE);
g_free (package_id);
More information about the PackageKit
mailing list