emotion: remove use of xattr.
authorcedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 20 Sep 2011 09:40:55 +0000 (09:40 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 20 Sep 2011 09:40:55 +0000 (09:40 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/emotion@63495 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

configure.ac
src/lib/emotion_smart.c

index fa12e68..08e1fa4 100644 (file)
@@ -185,29 +185,6 @@ case "$host_os" in
 esac
 AC_SUBST(lt_enable_auto_import)
 
-### Check for extended attribute
-
-AC_COMPILE_IFELSE(
-   [AC_LANG_PROGRAM(
-       [[
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/xattr.h>
-       ]],
-       [[
-size_t tmp = listxattr("/", NULL, 0);
-tmp = getxattr("/", "user.ethumb.md5", NULL, 0);
-setxattr("/", "user.ethumb.md5", NULL, 0, 0);
-       ]])],
-    [
-      AC_DEFINE(HAVE_XATTR, 1, [Define to 1 if you have 'listxattr', 'setxattr' and 'getxattr'])
-      have_xattr="yes"
-    ],
-    [have_xattr="no"])
-
-AC_MSG_CHECKING([for Xattr])
-AC_MSG_RESULT([${have_xattr}])
-
 ### Check for video4linux
 
 AC_COMPILE_IFELSE(
@@ -356,7 +333,6 @@ echo "  edje_cc..............: ${edje_cc}"
 echo
 echo "  Edje EXTERNAL support: ${have_edje_external}"
 echo
-echo "  Xattr................: ${have_xattr}"
 echo "  Eio..................: ${have_eio}"
 echo "  V4L2.................: ${have_v4l2}"
 echo
index 8205af5..161f467 100644 (file)
@@ -4,11 +4,6 @@
 #ifdef HAVE_EIO
 # include <math.h>
 # include <Eio.h>
-#else
-# ifdef HAVE_XATTR
-#  include <math.h>
-#  include <sys/xattr.h>
-# endif
 #endif
 
 #define E_SMART_OBJ_GET(smart, o, type) \
@@ -1272,19 +1267,11 @@ _eio_load_xattr_cleanup(Smart_Data *sd, Eio_File *handler)
 }
 
 static void
-_eio_load_xattr_done(void *data, Eio_File *handler, const char *xattr_data, unsigned int xattr_size)
+_eio_load_xattr_done(void *data, Eio_File *handler, double xattr_double)
 {
    Smart_Data *sd = data;
 
-   if (xattr_size < 128 && xattr_data[xattr_size - 1] == '\0')
-     {
-        long long int m = 0;
-        long int e = 0;
-
-        eina_convert_atod(xattr_data, xattr_size, &m, &e);
-        emotion_object_position_set(evas_object_smart_parent_get(sd->obj), ldexp((double)m, e));
-     }
-
+   emotion_object_position_set(evas_object_smart_parent_get(sd->obj), xattr_double);
    _eio_load_xattr_cleanup(sd, handler);
 }
 
@@ -1302,6 +1289,9 @@ emotion_object_last_position_load(Evas_Object *obj)
 {
    Smart_Data *sd;
    const char *tmp;
+#ifndef HAVE_EIO
+   double xattr;
+#endif
 
    E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
    if (!sd->file) return ;
@@ -1318,27 +1308,16 @@ emotion_object_last_position_load(Evas_Object *obj)
 
    EINA_REFCOUNT_REF(sd);
 
-   sd->load_xattr = eio_file_xattr_get(tmp,
-                                       "user.e.time_seek",
-                                       _eio_load_xattr_done,
-                                       _eio_load_xattr_error,
-                                       sd);
+   sd->load_xattr = eio_file_xattr_double_get(tmp,
+                                             "user.e.time_seek",
+                                             _eio_load_xattr_done,
+                                             _eio_load_xattr_error,
+                                             sd);
 #else
-# ifdef HAVE_XATTR
-   {
-      char double_to_string[128];
-      ssize_t sz;
-      long long int m = 0;
-      long int e = 0;
-
-      sz = getxattr(tmp, "user.e.time_seek", double_to_string, 128);
-      if (sz <= 0 || sz > 128 || double_to_string[sz] != '\0')
-        return ;
-
-      eina_convert_atod(double_to_string, 128, &m, &e);
-      emotion_object_position_set(obj, ldexp((double)m, e));
-   }
-# endif
+   if (eina_xattr_double_get(tmp, "user.e.time_seek", &xattr))
+     {
+        emotion_object_position_set(obj, xattr);
+     }
 #endif
 }
 
@@ -1359,7 +1338,6 @@ emotion_object_last_position_save(Evas_Object *obj)
 {
    Smart_Data *sd;
    const char *tmp;
-   char double_to_string[128];
 
    E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
    if (!sd->file) return ;
@@ -1371,16 +1349,11 @@ emotion_object_last_position_save(Evas_Object *obj)
    else
      return ;
 
-   eina_convert_dtoa(emotion_object_position_get(obj), double_to_string);
-
 #ifdef HAVE_EIO
-   eio_file_xattr_set(tmp, "user.e.time_seek",
-                     double_to_string, strlen(double_to_string) + 1, 0,
-                     _eio_save_xattr_done, _eio_save_xattr_error, sd);
+   eio_file_xattr_double_set(tmp, "user.e.time_seek", emotion_object_position_get(obj), 0,
+                            _eio_save_xattr_done, _eio_save_xattr_error, sd);
 #else
-# ifdef HAVE_XATTR
-   setxattr(tmp, "user.e.time_seek", double_to_string, strlen(double_to_string), 0);
-# endif
+   eina_xattr_double_set(tmp, "user.e.time_seek", emotion_object_position_get(obj), 0);
 #endif
 }