mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 07:23:41 +02:00
Added. Added. Added. Added. Added. Added. Added. Added. Added. Added.
2008-03-14 Alexander Larsson <alexl@redhat.com> * Makefile.am: * fen/Makefile.am: Added. * fen/fen-data.[ch]: Added. * fen/fen-dump.[ch]: Added. * fen/fen-helper.[ch]: Added. * fen/fen-kernel.[ch]: Added. * fen/fen-missing.[ch]: Added. * fen/fen-node.[ch]: Added. * fen/fen-sub.[ch]: Added. * fen/gfendirectorymonitor.[ch]: Added. * fen/gfenfilemonitor.[ch]: Added. * giomodule.c: Added Solaris FEN file notification backend. Patch from Lin Ma <Lin.Ma@Sun.COM> svn path=/trunk/; revision=6702
This commit is contained in:
committed by
Alexander Larsson
parent
553b3b613b
commit
7dc75d707c
114
gio/fen/fen-missing.c
Normal file
114
gio/fen/fen-missing.c
Normal file
@@ -0,0 +1,114 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim:set expandtab ts=4 shiftwidth=4: */
|
||||
/*
|
||||
* Copyright (C) 2008 Sun Microsystem.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors: Lin Ma <lin.ma@sun.com>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <glib.h>
|
||||
#include "fen-data.h"
|
||||
#include "fen-missing.h"
|
||||
|
||||
G_LOCK_EXTERN (fen_lock);
|
||||
#define SCAN_MISSING_INTERVAL 4000 /* in milliseconds */
|
||||
#define FM_W if (fm_debug_enabled) g_warning
|
||||
|
||||
/* global data structure for scan missing files */
|
||||
gboolean fm_debug_enabled = TRUE;
|
||||
static GList *missing_list = NULL;
|
||||
static guint scan_missing_source_id = 0;
|
||||
|
||||
static gboolean scan_missing_list (gpointer data);
|
||||
|
||||
static gboolean
|
||||
scan_missing_list (gpointer data)
|
||||
{
|
||||
GList *existing_list = NULL;
|
||||
GList *idx = NULL;
|
||||
fdata *f;
|
||||
gboolean ret = TRUE;
|
||||
|
||||
G_LOCK (fen_lock);
|
||||
|
||||
for (idx = missing_list; idx; idx = idx->next) {
|
||||
f = (fdata*)idx->data;
|
||||
|
||||
if (port_add (&f->fobj, &f->len, f)) {
|
||||
/* TODO - emit CREATE event */
|
||||
fdata_emit_events (f, FN_EVENT_CREATED);
|
||||
existing_list = g_list_prepend (existing_list, idx);
|
||||
}
|
||||
}
|
||||
|
||||
for (idx = existing_list; idx; idx = idx->next) {
|
||||
missing_list = g_list_remove_link (missing_list, (GList *)idx->data);
|
||||
g_list_free_1 ((GList *)idx->data);
|
||||
}
|
||||
g_list_free (existing_list);
|
||||
|
||||
if (missing_list == NULL) {
|
||||
scan_missing_source_id = 0;
|
||||
ret = FALSE;
|
||||
}
|
||||
|
||||
G_UNLOCK (fen_lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* missing_add
|
||||
*
|
||||
* Unsafe, need lock fen_lock.
|
||||
*/
|
||||
void
|
||||
missing_add (fdata *f)
|
||||
{
|
||||
GList *idx;
|
||||
|
||||
g_assert (!is_ported (f));
|
||||
|
||||
if (g_list_find (missing_list, f) != NULL) {
|
||||
FM_W ("%s is ALREADY added %s\n", __func__, FN_NAME(f));
|
||||
return;
|
||||
}
|
||||
FM_W ("%s is added %s\n", __func__, FN_NAME(f));
|
||||
|
||||
missing_list = g_list_prepend (missing_list, f);
|
||||
|
||||
/* if doesn't scan, then start */
|
||||
if (scan_missing_source_id == 0) {
|
||||
scan_missing_source_id = g_timeout_add (SCAN_MISSING_INTERVAL,
|
||||
scan_missing_list,
|
||||
NULL);
|
||||
g_assert (scan_missing_source_id > 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* missing_remove
|
||||
*
|
||||
* Unsafe, need lock fen_lock.
|
||||
*/
|
||||
void
|
||||
missing_remove (fdata *f)
|
||||
{
|
||||
FM_W ("%s %s\n", __func__, FN_NAME(f));
|
||||
missing_list = g_list_remove (missing_list, f);
|
||||
}
|
Reference in New Issue
Block a user