aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2011-07-21 20:48:52 +0100
committerConor Curran <conor.curran@canonical.com>2011-07-21 20:48:52 +0100
commitf94d6c4fe9c1ccb5a5e731b327fd57635c0ce326 (patch)
tree1d17896d8290bc0dc99b92d5d5f7e2a83044818f /src
parent7e6cf4cec8da62fc8e784d183af0baed8e7f905c (diff)
downloadayatana-indicator-session-f94d6c4fe9c1ccb5a5e731b327fd57635c0ce326.tar.gz
ayatana-indicator-session-f94d6c4fe9c1ccb5a5e731b327fd57635c0ce326.tar.bz2
ayatana-indicator-session-f94d6c4fe9c1ccb5a5e731b327fd57635c0ce326.zip
apt transactions working nicely
Diffstat (limited to 'src')
-rw-r--r--src/apt-transaction.c15
-rw-r--r--src/apt-watcher.c64
-rw-r--r--src/session-service.c4
3 files changed, 25 insertions, 58 deletions
diff --git a/src/apt-transaction.c b/src/apt-transaction.c
index 1a4aa47..e613507 100644
--- a/src/apt-transaction.c
+++ b/src/apt-transaction.c
@@ -74,7 +74,6 @@ static void
apt_transaction_class_init (AptTransactionClass *klass)
{
GObjectClass* object_class = G_OBJECT_CLASS (klass);
- //GObjectClass* parent_class = G_OBJECT_CLASS (klass);
object_class->finalize = apt_transaction_finalize;
signals[UPDATE] = g_signal_new("state-update",
@@ -99,20 +98,17 @@ apt_transaction_investigate(AptTransaction* self)
"org.debian.apt.transaction",
NULL, /* GCancellable */
&error);
- g_debug ("Just after creating the proxy for the transaction - id = %s",
- self->id);
if (error != NULL) {
g_warning ("unable to fetch proxy for transaction object path %s", self->id);
g_error_free (error);
return;
}
- g_debug ("connecting to the properties changed signal on the transaction object");
+
g_signal_connect (G_OBJECT(self->proxy),
"g-signal",
G_CALLBACK (apt_transaction_receive_signal),
self);
- g_debug ("calling simulate on the transaction object");
g_dbus_proxy_call (self->proxy,
"Simulate",
NULL,
@@ -133,14 +129,7 @@ apt_transaction_receive_signal (GDBusProxy * proxy,
g_return_if_fail (APT_IS_TRANSACTION (user_data));
AptTransaction* self = APT_TRANSACTION(user_data);
- if (g_strcmp0 (signal_name, "Finished") == 0){
- g_signal_emit (self,
- signals[UPDATE],
- 0,
- FINISHED_CHECKING);
-
- }
- else if (g_strcmp0(signal_name, "PropertyChanged") == 0)
+ if (g_strcmp0(signal_name, "PropertyChanged") == 0)
{
gchar* prop_name= NULL;
GVariant* value = NULL;
diff --git a/src/apt-watcher.c b/src/apt-watcher.c
index 844e273..546c733 100644
--- a/src/apt-watcher.c
+++ b/src/apt-watcher.c
@@ -185,8 +185,6 @@ apt_watcher_upgrade_system_cb (GObject * obj,
GAsyncResult * res,
gpointer user_data)
{
- g_debug ("UpgradeSystem apt callback");
-
g_return_if_fail (APT_IS_WATCHER (user_data));
AptWatcher* self = APT_WATCHER (user_data);
@@ -205,7 +203,7 @@ apt_watcher_upgrade_system_cb (GObject * obj,
g_variant_get (result, "(s)", &transaction_id);
if (transaction_id == NULL){
- g_debug ("apt_watcher_upgrade_system_cb - transaction id is null");
+ g_warning ("apt_watcher_upgrade_system_cb - transaction id is null");
return;
}
@@ -213,49 +211,17 @@ apt_watcher_upgrade_system_cb (GObject * obj,
}
-
-
-/*static void
-apt_watcher_determine_state (AptWatcher* self,
- GVariant* update)
-{
- g_debug ("WE GOT SOME ACTIVE TRANSACTIONS TO EXAMINE, type is %s",
- g_variant_get_type_string (update));
-
- gchar* first_param = NULL;
- gchar ** transactions = NULL;
-
- g_variant_get (update, "(sas)", &first_param, &transactions);
-
- g_debug ("apt_watcher_determine_state - the size is the string array %u",
- g_strv_length (transactions));
- g_debug ("apt_watcher_determine_state - first param = %s", first_param);
-
- if (first_param == NULL){
- if (self->current_state != UP_TO_DATE){
- dbusmenu_menuitem_property_set (self->apt_item,
- DBUSMENU_MENUITEM_PROP_LABEL,
- _("Software Up to Date"));
- }
- }
- else{
- gboolean updating = g_str_has_prefix (first_param,
- "/org/debian/apt/transaction/");
- if (updating == TRUE){
- self->current_state = UPDATES_IN_PROGRESS;
- dbusmenu_menuitem_property_set (self->apt_item,
- DBUSMENU_MENUITEM_PROP_LABEL,
- _("Updates Installing..."));
- }
- }
-}*/
-
static void
apt_watcher_show_apt_dialog (DbusmenuMenuitem * mi,
guint timestamp,
gchar * type)
{
-
+ GError * error = NULL;
+ if (!g_spawn_command_line_async("update-manager", &error))
+ {
+ g_warning("Unable to show update-manager: %s", error->message);
+ g_error_free(error);
+ }
}
static void
@@ -280,6 +246,8 @@ apt_watcher_transaction_state_update_cb (AptTransaction* trans,
_("Updates Available…"));
}
self->current_state = state;
+ g_object_unref (self->current_transaction);
+ self->current_transaction = NULL;
}
static void
@@ -287,6 +255,7 @@ apt_watcher_manage_transactions (AptWatcher* self, gchar* transaction_id)
{
if (self->current_transaction == NULL){
self->current_transaction = apt_transaction_new (transaction_id);
+ g_object_ref (self->current_transaction);
g_signal_connect (G_OBJECT(self->current_transaction),
"state-update",
G_CALLBACK(apt_watcher_transaction_state_update_cb), self);
@@ -310,8 +279,17 @@ static void apt_watcher_signal_cb ( GDBusProxy* proxy,
if (g_strcmp0(signal_name, "ActiveTransactionsChanged") == 0){
gchar* input = NULL;
g_variant_get(value, "s", & input);
- g_debug ("Active Transactions signal - input = %s", input);
- apt_watcher_manage_transactions (self, input);
+
+ g_debug ("Active Transactions signal - input is null = %i", input == NULL);
+ // TODO don't call on null terminated input
+ g_dbus_proxy_call (self->proxy,
+ "UpgradeSystem",
+ g_variant_new("(b)", TRUE),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ apt_watcher_upgrade_system_cb,
+ user_data);
}
g_variant_unref (parameters);
}
diff --git a/src/session-service.c b/src/session-service.c
index 22552dc..bb473e9 100644
--- a/src/session-service.c
+++ b/src/session-service.c
@@ -71,10 +71,10 @@ static GMainLoop * mainloop = NULL;
void
service_shutdown (IndicatorService * service, gpointer user_data)
{
- /*if (mainloop != NULL) {
+ if (mainloop != NULL) {
g_debug("Service shutdown");
g_main_loop_quit(mainloop);
- }*/
+ }
return;
}