summaryrefslogtreecommitdiff
path: root/src/lib/eio
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2018-06-26 18:20:37 -0400
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2018-06-28 18:08:45 +0200
commit7ed4b407e7eea8edd8014a13ffd451babb38e40e (patch)
treeaff708c22f8a617223426fae0b1bbc3f06f18233 /src/lib/eio
parenta8a55870f92734076e62eb76165b55b2a161098e (diff)
eio: add method for determining if a monitor is using the fallback mechanism
the fallback method of calling stat() on the monitored paths does not allow for various eio events to be emitted, meaning that any application which relies on those events can never receive them this provides a method for checking a monitor to determine which functionality is available, and also provides more explicit documentation regarding events that are not provided by fallback monitoring this method is marked as beta @feature Differential Revision: https://phab.enlightenment.org/D6447
Diffstat (limited to 'src/lib/eio')
-rw-r--r--src/lib/eio/Eio_Legacy.h20
-rw-r--r--src/lib/eio/eio_monitor_poll.c7
-rw-r--r--src/lib/eio/eio_sentry.c14
-rw-r--r--src/lib/eio/eio_sentry.eo16
4 files changed, 51 insertions, 6 deletions
diff --git a/src/lib/eio/Eio_Legacy.h b/src/lib/eio/Eio_Legacy.h
index d7e9a446ab..adb78b6389 100644
--- a/src/lib/eio/Eio_Legacy.h
+++ b/src/lib/eio/Eio_Legacy.h
@@ -1174,12 +1174,12 @@ EAPI Eio_File *eio_eet_write_cipher(Eet_File *ef,
1174EAPI extern int EIO_MONITOR_FILE_CREATED; /**< A new file was created in a watched directory */ 1174EAPI extern int EIO_MONITOR_FILE_CREATED; /**< A new file was created in a watched directory */
1175EAPI extern int EIO_MONITOR_FILE_DELETED; /**< A watched file was deleted, or a file in a watched directory was deleted */ 1175EAPI extern int EIO_MONITOR_FILE_DELETED; /**< A watched file was deleted, or a file in a watched directory was deleted */
1176EAPI extern int EIO_MONITOR_FILE_MODIFIED; /**< A file was modified in a watched directory */ 1176EAPI extern int EIO_MONITOR_FILE_MODIFIED; /**< A file was modified in a watched directory */
1177EAPI extern int EIO_MONITOR_FILE_CLOSED; /**< A file was closed in a watched directory. This event is never sent on Windows and OSX */ 1177EAPI extern int EIO_MONITOR_FILE_CLOSED; /**< A file was closed in a watched directory. This event is never sent on Windows and OSX, or for non-fallback monitors */
1178EAPI extern int EIO_MONITOR_DIRECTORY_CREATED; /**< A new directory was created in a watched directory */ 1178EAPI extern int EIO_MONITOR_DIRECTORY_CREATED; /**< A new directory was created in a watched directory */
1179EAPI extern int EIO_MONITOR_DIRECTORY_DELETED; /**< A directory has been deleted: this can be either a watched directory or one of its subdirectories */ 1179EAPI extern int EIO_MONITOR_DIRECTORY_DELETED; /**< A directory has been deleted: this can be either a watched directory or one of its subdirectories */
1180EAPI extern int EIO_MONITOR_DIRECTORY_MODIFIED; /**< A directory has been modified in a watched directory */ 1180EAPI extern int EIO_MONITOR_DIRECTORY_MODIFIED; /**< A directory has been modified in a watched directory */
1181EAPI extern int EIO_MONITOR_DIRECTORY_CLOSED; /**< A directory has been closed in a watched directory. This event is never sent on Windows and OSX */ 1181EAPI extern int EIO_MONITOR_DIRECTORY_CLOSED; /**< A directory has been closed in a watched directory. This event is never sent on Windows and OSX, or for non-fallback monitors */
1182EAPI extern int EIO_MONITOR_SELF_RENAME; /**< The monitored path has been renamed, an error could happen just after if the renamed path doesn't exist. This event is never sent on OSX */ 1182EAPI extern int EIO_MONITOR_SELF_RENAME; /**< The monitored path has been renamed, an error could happen just after if the renamed path doesn't exist. This event is never sent on OSX, or for non-fallback monitors */
1183EAPI extern int EIO_MONITOR_SELF_DELETED; /**< The monitored path has been removed. This event is never sent on OSX */ 1183EAPI extern int EIO_MONITOR_SELF_DELETED; /**< The monitored path has been removed. This event is never sent on OSX */
1184EAPI extern int EIO_MONITOR_ERROR; /**< During operation the monitor failed and will no longer work. eio_monitor_del must be called on it. */ 1184EAPI extern int EIO_MONITOR_ERROR; /**< During operation the monitor failed and will no longer work. eio_monitor_del must be called on it. */
1185 1185
@@ -1241,6 +1241,20 @@ EAPI void eio_monitor_del(Eio_Monitor *monitor);
1241 */ 1241 */
1242EAPI const char *eio_monitor_path_get(Eio_Monitor *monitor); 1242EAPI const char *eio_monitor_path_get(Eio_Monitor *monitor);
1243 1243
1244#ifdef EFL_BETA_API_SUPPORT
1245/**
1246 * @brief Check whether a monitor is using the fallback backend
1247 * @param monitor The Eio_Monitor to check
1248 * @return EINA_TRUE only if the monitor is valid and is using the fallback monitoring mechanism
1249 *
1250 * Fallback monitors are unable to provide the CLOSED or RENAME events. It's important
1251 * to check whether a monitor is a fallback monitor before relying on these events.
1252 *
1253 * @since 1.21
1254 * @beta
1255 */
1256EAPI Eina_Bool eio_monitor_fallback_check(const Eio_Monitor *monitor);
1257#endif
1244/** 1258/**
1245 * @} 1259 * @}
1246 */ 1260 */
diff --git a/src/lib/eio/eio_monitor_poll.c b/src/lib/eio/eio_monitor_poll.c
index 392b2151e9..2133b3fe45 100644
--- a/src/lib/eio/eio_monitor_poll.c
+++ b/src/lib/eio/eio_monitor_poll.c
@@ -391,3 +391,10 @@ eio_monitoring_interval_set(double interval)
391 ecore_timer_interval_set(timer, fallback_interval); 391 ecore_timer_interval_set(timer, fallback_interval);
392 eina_iterator_free(it); 392 eina_iterator_free(it);
393} 393}
394
395EAPI Eina_Bool
396eio_monitor_fallback_check(const Eio_Monitor *monitor)
397{
398 EINA_SAFETY_ON_NULL_RETURN_VAL(monitor, EINA_FALSE);
399 return monitor->fallback;
400}
diff --git a/src/lib/eio/eio_sentry.c b/src/lib/eio/eio_sentry.c
index d6b10dd5ea..cf2b166d4b 100644
--- a/src/lib/eio/eio_sentry.c
+++ b/src/lib/eio/eio_sentry.c
@@ -21,6 +21,7 @@
21# include <config.h> 21# include <config.h>
22#endif 22#endif
23 23
24#define EIO_SENTRY_BETA 1
24 25
25#include <Eo.h> 26#include <Eo.h>
26#include "Ecore.h" 27#include "Ecore.h"
@@ -145,6 +146,19 @@ _eio_sentry_remove(Eo *obj EINA_UNUSED, Eio_Sentry_Data *pd, const char *path)
145 eina_hash_del(pd->targets, path, NULL); 146 eina_hash_del(pd->targets, path, NULL);
146} 147}
147 148
149Eina_Bool
150_eio_sentry_fallback_check(const Eo *obj EINA_UNUSED, Eio_Sentry_Data *pd, const char *path)
151{
152 Eio_Monitor *monitor;
153
154 EINA_SAFETY_ON_NULL_RETURN_VAL(path, EINA_FALSE);
155 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, EINA_FALSE);
156
157 monitor = eina_hash_find(pd->targets, path);
158 EINA_SAFETY_ON_NULL_RETURN_VAL(monitor, EINA_FALSE);
159 return eio_monitor_fallback_check(monitor);
160}
161
148Efl_Object * _eio_sentry_efl_object_constructor(Eo *obj, Eio_Sentry_Data *pd) 162Efl_Object * _eio_sentry_efl_object_constructor(Eo *obj, Eio_Sentry_Data *pd)
149{ 163{
150 obj = efl_constructor(efl_super(obj, EIO_SENTRY_CLASS)); 164 obj = efl_constructor(efl_super(obj, EIO_SENTRY_CLASS));
diff --git a/src/lib/eio/eio_sentry.eo b/src/lib/eio/eio_sentry.eo
index 8f87a29025..7dbebbc76b 100644
--- a/src/lib/eio/eio_sentry.eo
+++ b/src/lib/eio/eio_sentry.eo
@@ -23,17 +23,27 @@ class Eio.Sentry (Efl.Object)
23 @in path: string; [[Path to remove from monitoring]] 23 @in path: string; [[Path to remove from monitoring]]
24 } 24 }
25 } 25 }
26 fallback_check @const @beta {
27 [[Return if the sentry is using the fallback monitoring method
28
29 The fallback method of monitoring cannot provide certain events.
30 ]]
31 params {
32 @in path: string; [[Path to check for fallback monitoring]]
33 }
34 return : bool; [[$true only if the sentry is using the fallback mechanism]]
35 }
26 } 36 }
27 events { 37 events {
28 file,created: Eio.Sentry.Event; [[Called when a file was created]] 38 file,created: Eio.Sentry.Event; [[Called when a file was created]]
29 file,deleted: Eio.Sentry.Event; [[Called when a file was deleted]] 39 file,deleted: Eio.Sentry.Event; [[Called when a file was deleted]]
30 file,modified: Eio.Sentry.Event; [[Called when a file was modified]] 40 file,modified: Eio.Sentry.Event; [[Called when a file was modified]]
31 file,closed: Eio.Sentry.Event; [[Called when a file was closed]] 41 file,closed: Eio.Sentry.Event; [[Called for non-fallback sentries when a file was closed]]
32 directory,created: Eio.Sentry.Event; [[Called when a directory was created]] 42 directory,created: Eio.Sentry.Event; [[Called when a directory was created]]
33 directory,deleted: Eio.Sentry.Event; [[Called when a directory was deleted]] 43 directory,deleted: Eio.Sentry.Event; [[Called when a directory was deleted]]
34 directory,modified: Eio.Sentry.Event; [[called when a directory was modified]] 44 directory,modified: Eio.Sentry.Event; [[called when a directory was modified]]
35 directory,closed: Eio.Sentry.Event; [[Called when a directory was closed]] 45 directory,closed: Eio.Sentry.Event; [[Called for non-fallback sentries when a directory was closed]]
36 self,rename: Eio.Sentry.Event; [[Called when the object was renamed]] 46 self,rename: Eio.Sentry.Event; [[Called for non-fallback sentries when the object was renamed]]
37 self,deleted: Eio.Sentry.Event; [[Called when the object was deleted]] 47 self,deleted: Eio.Sentry.Event; [[Called when the object was deleted]]
38 error: Eio.Sentry.Event; [[Called in case of an error]] 48 error: Eio.Sentry.Event; [[Called in case of an error]]
39 } 49 }