~cjcurran/indicator-session/apt-updates-bug

« back to all changes in this revision

Viewing changes to src/apt-watcher.c

  • Committer: Conor Curran
  • Date: 2011-07-22 17:00:09 UTC
  • mfrom: (161.3.3 device-menu-reorg)
  • Revision ID: conor.curran@canonical.com-20110722170009-cqv9pgg7ljjg60k8
apt item partially working

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include <gio/gio.h>
21
21
#include <glib/gi18n.h>
22
22
#include "apt-watcher.h"
23
 
#include "dbus-shared-names.h"
24
23
#include "apt-transaction.h"
25
24
 
26
25
static guint watcher_id;
235
234
  
236
235
  AptState state = (AptState)update;
237
236
  
238
 
  if ( state == UP_TO_DATE ){
 
237
  if (state == UP_TO_DATE){
239
238
    dbusmenu_menuitem_property_set (self->apt_item,
240
239
                                    DBUSMENU_MENUITEM_PROP_LABEL,
241
 
                                    _("Software Up to Date"));    
 
240
                                    _("Software Up to Date"));   
 
241
    // Simulations don't send a finished signal for some reason
 
242
    // Anyway from a simulation we just need one state update 
 
243
    // (updates available or not)
 
244
    if (apt_transaction_get_transaction_type (self->current_transaction)
 
245
        == SIMULATION){
 
246
      g_object_unref (G_OBJECT(self->current_transaction));
 
247
      self->current_transaction = NULL;
 
248
    }                                                                   
242
249
  }
243
 
  else if ( state == UPDATES_AVAILABLE ){
 
250
  else if (state == UPDATES_AVAILABLE){
244
251
    dbusmenu_menuitem_property_set (self->apt_item,
245
252
                                    DBUSMENU_MENUITEM_PROP_LABEL,
246
253
                                    _("Updates Available…"));    
 
254
    // Simulations don't send a finished signal for some reason
 
255
    // Anyway from a simulation we just need one state update 
 
256
    // (updates available or not)
 
257
    if (apt_transaction_get_transaction_type (self->current_transaction)
 
258
        == SIMULATION){
 
259
      g_object_unref (G_OBJECT(self->current_transaction));
 
260
      self->current_transaction = NULL;
 
261
    }                              
 
262
  }
 
263
  else if (state == UPGRADE_IN_PROGRESS){
 
264
    dbusmenu_menuitem_property_set (self->apt_item,
 
265
                                    DBUSMENU_MENUITEM_PROP_LABEL,
 
266
                                    _("Updates Installing…"));    
247
267
  }  
 
268
  else if (state == FINISHED){
 
269
    dbusmenu_menuitem_property_set (self->apt_item,
 
270
                                    DBUSMENU_MENUITEM_PROP_LABEL,
 
271
                                    _("Software Up to Date"));
 
272
    g_object_unref (G_OBJECT(self->current_transaction));
 
273
    self->current_transaction = NULL;                                    
 
274
  }
248
275
  self->current_state = state;
249
 
  g_object_unref (self->current_transaction);
250
 
  self->current_transaction = NULL;
251
276
252
277
 
253
278
static void
254
279
apt_watcher_manage_transactions (AptWatcher* self, gchar* transaction_id)
255
280
{
256
281
    if (self->current_transaction == NULL){
257
 
      self->current_transaction = apt_transaction_new (transaction_id);
258
 
      g_object_ref (self->current_transaction);
 
282
      self->current_transaction = apt_transaction_new (transaction_id, SIMULATION);
259
283
      g_signal_connect (G_OBJECT(self->current_transaction),
260
284
                        "state-update",
261
285
                        G_CALLBACK(apt_watcher_transaction_state_update_cb), self);
262
 
    }  
 
286
    }
263
287
}
264
288
 
265
289
// TODO - Ask MVO about this.
279
303
  if (g_strcmp0(signal_name, "ActiveTransactionsChanged") == 0){
280
304
    gchar* input = NULL;
281
305
    g_variant_get(value, "s", & input);
 
306
    if (g_str_has_prefix (input, "/org/debian/apt/transaction/") == TRUE){
 
307
      g_debug ("Active Transactions signal - input is null = %i", input == NULL);
 
308
      
 
309
      if (self->current_transaction != NULL)
 
310
      {
 
311
        g_object_unref (G_OBJECT(self->current_transaction));
 
312
        self->current_transaction = NULL;
 
313
      }
282
314
 
283
 
    g_debug ("Active Transactions signal - input is null = %i", input == NULL);
284
 
    // TODO don't call on null terminated input
285
 
    g_dbus_proxy_call (self->proxy,
286
 
                       "UpgradeSystem",
287
 
                       g_variant_new("(b)", TRUE),
288
 
                       G_DBUS_CALL_FLAGS_NONE,
289
 
                       -1,
290
 
                       NULL,
291
 
                       apt_watcher_upgrade_system_cb,
292
 
                       user_data);    
 
315
      self->current_transaction = apt_transaction_new (input, REAL);
 
316
      g_signal_connect (G_OBJECT(self->current_transaction),
 
317
                        "state-update",
 
318
                        G_CALLBACK(apt_watcher_transaction_state_update_cb), self);
 
319
      
 
320
          
 
321
    }
293
322
  }
294
323
  g_variant_unref (parameters);
295
324
}