diff options
author | David Reveman <davidr@novell.com> | 2007-09-04 01:05:15 +0200 |
---|---|---|
committer | David Reveman <davidr@novell.com> | 2007-09-04 01:05:15 +0200 |
commit | 36b283d33788e3d3899294704029a206e9c1943a (patch) | |
tree | 046c60478fee11fdfb922bdf41cb07aa364ec339 /plugins | |
parent | 4b30118ecb74d7c876e5f829f83027eac80a9b3e (diff) |
Move file watch interface to core object.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/dbus.c | 11 | ||||
-rw-r--r-- | plugins/ini.c | 4 | ||||
-rw-r--r-- | plugins/inotify.c | 109 | ||||
-rw-r--r-- | plugins/kconfig.cpp | 4 |
4 files changed, 61 insertions, 67 deletions
diff --git a/plugins/dbus.c b/plugins/dbus.c index 09de402c..5e61f507 100644 --- a/plugins/dbus.c +++ b/plugins/dbus.c @@ -2453,14 +2453,12 @@ dbusInitDisplay (CompPlugin *p, mask = NOTIFY_CREATE_MASK | NOTIFY_DELETE_MASK | NOTIFY_MOVE_MASK; dd->fileWatch[DBUS_FILE_WATCH_CURRENT] = - addFileWatch (d, - ".", + addFileWatch (".", mask, dbusSendPluginsChangedSignal, (void *) d); dd->fileWatch[DBUS_FILE_WATCH_PLUGIN] = - addFileWatch (d, - PLUGINDIR, + addFileWatch (PLUGINDIR, mask, dbusSendPluginsChangedSignal, (void *) d); @@ -2475,8 +2473,7 @@ dbusInitDisplay (CompPlugin *p, sprintf (plugindir, "%s/%s", home, HOME_PLUGINDIR); dd->fileWatch[DBUS_FILE_WATCH_HOME] = - addFileWatch (d, - plugindir, + addFileWatch (plugindir, mask, dbusSendPluginsChangedSignal, (void *) d); @@ -2527,7 +2524,7 @@ dbusFiniDisplay (CompPlugin *p, } for (i = 0; i < DBUS_FILE_WATCH_NUM; i++) - removeFileWatch (d, dd->fileWatch[i]); + removeFileWatch (dd->fileWatch[i]); compRemoveWatchFd (dd->watchFdHandle); diff --git a/plugins/ini.c b/plugins/ini.c index a033fc12..9044df25 100644 --- a/plugins/ini.c +++ b/plugins/ini.c @@ -1154,7 +1154,7 @@ iniInitDisplay (CompPlugin *p, CompDisplay *d) if (iniGetHomeDir (&homeDir)) { - id->directoryWatch = addFileWatch (d, homeDir, + id->directoryWatch = addFileWatch (homeDir, NOTIFY_DELETE_MASK | NOTIFY_CREATE_MASK | NOTIFY_MODIFY_MASK, @@ -1171,7 +1171,7 @@ iniFiniDisplay (CompPlugin *p, CompDisplay *d) INI_DISPLAY (d); if (id->directoryWatch) - removeFileWatch (d, id->directoryWatch); + removeFileWatch (id->directoryWatch); iniFreeFileData (d); diff --git a/plugins/inotify.c b/plugins/inotify.c index 7fd5a048..e9ce6751 100644 --- a/plugins/inotify.c +++ b/plugins/inotify.c @@ -32,7 +32,7 @@ static CompMetadata inotifyMetadata; -static int displayPrivateIndex; +static int corePrivateIndex; typedef struct _CompInotifyWatch { struct _CompInotifyWatch *next; @@ -40,32 +40,31 @@ typedef struct _CompInotifyWatch { int wd; } CompInotifyWatch; -typedef struct _InotifyDisplay { +typedef struct _InotifyCore { int fd; CompInotifyWatch *watch; CompWatchFdHandle watchFdHandle; FileWatchAddedProc fileWatchAdded; FileWatchRemovedProc fileWatchRemoved; -} InotifyDisplay; +} InotifyCore; -#define GET_INOTIFY_DISPLAY(d) \ - ((InotifyDisplay *) (d)->object.privates[displayPrivateIndex].ptr) +#define GET_INOTIFY_CORE(c) \ + ((InotifyCore *) (c)->object.privates[corePrivateIndex].ptr) -#define INOTIFY_DISPLAY(d) \ - InotifyDisplay *id = GET_INOTIFY_DISPLAY (d) +#define INOTIFY_CORE(c) \ + InotifyCore *ic = GET_INOTIFY_CORE (c) static Bool inotifyProcessEvents (void *data) { - char buf[256 * (sizeof (struct inotify_event) + 16)]; - CompDisplay *d = (CompDisplay *) data; - int len; + char buf[256 * (sizeof (struct inotify_event) + 16)]; + int len; - INOTIFY_DISPLAY (d); + INOTIFY_CORE (&core); - len = read (id->fd, buf, sizeof (buf)); + len = read (ic->fd, buf, sizeof (buf)); if (len < 0) { perror ("read"); @@ -81,13 +80,13 @@ inotifyProcessEvents (void *data) { event = (struct inotify_event *) &buf[i]; - for (iw = id->watch; iw; iw = iw->next) + for (iw = ic->watch; iw; iw = iw->next) if (iw->wd == event->wd) break; if (iw) { - for (fw = d->fileWatch; fw; fw = fw->next) + for (fw = core.fileWatch; fw; fw = fw->next) if (fw->handle == iw->handle) break; @@ -128,19 +127,19 @@ inotifyMask (CompFileWatch *fileWatch) } static void -inotifyFileWatchAdded (CompDisplay *d, +inotifyFileWatchAdded (CompCore *c, CompFileWatch *fileWatch) { CompInotifyWatch *iw; - INOTIFY_DISPLAY (d); + INOTIFY_CORE (c); iw = malloc (sizeof (CompInotifyWatch)); if (!iw) return; iw->handle = fileWatch->handle; - iw->wd = inotify_add_watch (id->fd, + iw->wd = inotify_add_watch (ic->fd, fileWatch->path, inotifyMask (fileWatch)); if (iw->wd < 0) @@ -150,19 +149,19 @@ inotifyFileWatchAdded (CompDisplay *d, return; } - iw->next = id->watch; - id->watch = iw; + iw->next = ic->watch; + ic->watch = iw; } static void -inotifyFileWatchRemoved (CompDisplay *d, +inotifyFileWatchRemoved (CompCore *c, CompFileWatch *fileWatch) { CompInotifyWatch *p = 0, *iw; - INOTIFY_DISPLAY (d); + INOTIFY_CORE (c); - for (iw = id->watch; iw; iw = iw->next) + for (iw = ic->watch; iw; iw = iw->next) { if (iw->handle == fileWatch->handle) break; @@ -175,9 +174,9 @@ inotifyFileWatchRemoved (CompDisplay *d, if (p) p->next = iw->next; else - id->watch = iw->next; + ic->watch = iw->next; - if (inotify_rm_watch (id->fd, iw->wd)) + if (inotify_rm_watch (ic->fd, iw->wd)) perror ("inotify_rm_watch"); free (iw); @@ -185,59 +184,59 @@ inotifyFileWatchRemoved (CompDisplay *d, } static Bool -inotifyInitDisplay (CompPlugin *p, - CompDisplay *d) +inotifyInitCore (CompPlugin *p, + CompCore *c) { - InotifyDisplay *id; - CompFileWatch *fw; + InotifyCore *ic; + CompFileWatch *fw; if (!checkPluginABI ("core", CORE_ABIVERSION)) return FALSE; - id = malloc (sizeof (InotifyDisplay)); - if (!id) + ic = malloc (sizeof (InotifyCore)); + if (!ic) return FALSE; - id->fd = inotify_init (); - if (id->fd < 0) + ic->fd = inotify_init (); + if (ic->fd < 0) { perror ("inotify_init"); - free (id); + free (ic); return FALSE; } - id->watch = NULL; + ic->watch = NULL; - id->watchFdHandle = compAddWatchFd (id->fd, + ic->watchFdHandle = compAddWatchFd (ic->fd, POLLIN | POLLPRI | POLLHUP | POLLERR, inotifyProcessEvents, - d); + NULL); - WRAP (id, d, fileWatchAdded, inotifyFileWatchAdded); - WRAP (id, d, fileWatchRemoved, inotifyFileWatchRemoved); + WRAP (ic, c, fileWatchAdded, inotifyFileWatchAdded); + WRAP (ic, c, fileWatchRemoved, inotifyFileWatchRemoved); - d->object.privates[displayPrivateIndex].ptr = id; + c->object.privates[corePrivateIndex].ptr = ic; - for (fw = d->fileWatch; fw; fw = fw->next) - inotifyFileWatchAdded (d, fw); + for (fw = c->fileWatch; fw; fw = fw->next) + inotifyFileWatchAdded (c, fw); return TRUE; } static void -inotifyFiniDisplay (CompPlugin *p, - CompDisplay *d) +inotifyFiniCore (CompPlugin *p, + CompCore *c) { - INOTIFY_DISPLAY (d); + INOTIFY_CORE (c); - compRemoveWatchFd (id->watchFdHandle); + compRemoveWatchFd (ic->watchFdHandle); - close (id->fd); + close (ic->fd); - UNWRAP (id, d, fileWatchAdded); - UNWRAP (id, d, fileWatchRemoved); + UNWRAP (ic, c, fileWatchAdded); + UNWRAP (ic, c, fileWatchRemoved); - free (id); + free (ic); } static CompBool @@ -245,8 +244,7 @@ inotifyInitObject (CompPlugin *p, CompObject *o) { static InitPluginObjectProc dispTab[] = { - (InitPluginObjectProc) 0, /* InitCore */ - (InitPluginObjectProc) inotifyInitDisplay + (InitPluginObjectProc) inotifyInitCore }; RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), TRUE, (p, o)); @@ -257,8 +255,7 @@ inotifyFiniObject (CompPlugin *p, CompObject *o) { static FiniPluginObjectProc dispTab[] = { - (FiniPluginObjectProc) 0, /* FiniCore */ - (FiniPluginObjectProc) inotifyFiniDisplay + (FiniPluginObjectProc) inotifyFiniCore }; DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), (p, o)); @@ -271,8 +268,8 @@ inotifyInit (CompPlugin *p) 0, 0, 0, 0)) return FALSE; - displayPrivateIndex = allocateDisplayPrivateIndex (); - if (displayPrivateIndex < 0) + corePrivateIndex = allocateCorePrivateIndex (); + if (corePrivateIndex < 0) { compFiniMetadata (&inotifyMetadata); return FALSE; @@ -286,7 +283,7 @@ inotifyInit (CompPlugin *p) static void inotifyFini (CompPlugin *p) { - freeDisplayPrivateIndex (displayPrivateIndex); + freeCorePrivateIndex (corePrivateIndex); compFiniMetadata (&inotifyMetadata); } diff --git a/plugins/kconfig.cpp b/plugins/kconfig.cpp index b0cff6e5..1238e521 100644 --- a/plugins/kconfig.cpp +++ b/plugins/kconfig.cpp @@ -756,7 +756,7 @@ kconfigInitDisplay (CompPlugin *p, if (QFile::exists (dir)) { - kd->fileWatch = addFileWatch (d, dir.ascii (), ~0, kconfigRcChanged, + kd->fileWatch = addFileWatch (dir.ascii (), ~0, kconfigRcChanged, (void *) d); } else @@ -790,7 +790,7 @@ kconfigFiniDisplay (CompPlugin *p, } if (kd->fileWatch) - removeFileWatch (d, kd->fileWatch); + removeFileWatch (kd->fileWatch); freeScreenPrivateIndex (d, kd->screenPrivateIndex); |