~ubuntu-core-dev/update-notifier/ubuntu

« back to all changes in this revision

Viewing changes to src/hooks.c

  • Committer: mvo
  • Date: 2005-07-08 05:50:30 UTC
  • Revision ID: gustavo@niemeyer.net-20050708055030-bac954d412dcc559
* debian/dirs:
  - added /etc/update-notifier
* debian/changelog, configure.in:
  - new version 0.40.1
* src/hooks.c:
  - support a global seen file
* TODO:
  - some cleanups

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
 
13
13
/* relative to the home dir */
14
14
#define HOOKS_SEEN ".update-notifier/hooks_seen"
15
 
 
 
15
#define GLOBAL_HOOKS_SEEN "/etc/update-notifier/hooks_seen"
16
16
 
17
17
#define HOOK_DEBUG 0
18
18
 
426
426
   return TRUE;
427
427
}
428
428
 
429
 
 
430
 
gboolean init_already_seen_hooks(TrayApplet *ta)
 
429
GList* hook_read_seen_file(const char* filename)
431
430
{
432
 
   HookDialog* hook_dialog = (HookDialog*)ta->user_data;
433
 
 
434
431
   GList *seen = NULL;
435
 
   char *filename = g_strdup_printf("%s/"HOOKS_SEEN,g_get_home_dir());
 
432
 
436
433
   char buf[512];
437
434
   int time, was_run;
438
435
   FILE *f = fopen(filename, "r");
439
436
   if(f==NULL)
440
 
      return TRUE;
 
437
      return seen;
 
438
 
 
439
   g_debug("reading hook_file: %s \n", filename);
 
440
 
441
441
   while(fscanf(f, "%s %i %i",buf,&time,&was_run) == 3) {
442
442
      HookFile *t = g_new0(HookFile, 1);
443
443
      t->filename = strdup(buf);
448
448
      
449
449
      g_debug("got: %s %i %i ",buf,time,was_run);
450
450
   }
 
451
   fclose(f);
 
452
 
 
453
   return seen;
 
454
}
 
455
 
 
456
gboolean init_already_seen_hooks(TrayApplet *ta)
 
457
{
 
458
   HookDialog* hook_dialog = (HookDialog*)ta->user_data;
 
459
   char *filename;
 
460
 
 
461
   GList *seen = NULL;
 
462
 
 
463
   // read global hook file
 
464
   seen = g_list_concat(seen, hook_read_seen_file(GLOBAL_HOOKS_SEEN));
 
465
 
 
466
   // read user hook file
 
467
   filename = g_strdup_printf("%s/%s", g_get_home_dir(),HOOKS_SEEN);
 
468
   seen = g_list_concat(seen, hook_read_seen_file(filename));
451
469
   g_free(filename);
452
 
   fclose(f);
 
470
 
453
471
 
454
472
   // init the list of hook files with the list of already seens ones
455
473
   hook_dialog->hook_files = seen;