ethumb: make exists client API async.
[framework/uifw/ethumb.git] / src / bin / ethumbd_client.c
index 351eff4..57950e3 100644 (file)
@@ -157,12 +157,38 @@ _finished_thumb(void *data __UNUSED__, Ethumb_Client *client __UNUSED__, int id
 }
 
 static void
-_connected(void *data, Ethumb_Client *c, Eina_Bool success)
+_exists(Ethumb_Client *c, __UNUSED__ Ethumb_Exists *thread, Eina_Bool exists, void *data)
 {
    struct options *opts = data;
    const char *thumb_path, *thumb_key;
    long id;
 
+   if (exists)
+     {
+        ethumb_client_thumb_path_get(c, &thumb_path, &thumb_key);
+        _thumb_report
+          ("EXISTS", opts->src_path, opts->src_key, thumb_path, thumb_key);
+        ecore_main_loop_quit();
+        return;
+     }
+
+   id = ethumb_client_generate(c, _finished_thumb, NULL, NULL);
+   if (id < 0)
+     {
+       fputs("ERROR: could not request thumbnail to be generated.\n", stderr);
+       ecore_main_loop_quit();
+       return;
+     }
+   printf("request id=%ld, file='%s', key='%s'\n",
+         id, opts->src_path, opts->src_key ? opts->src_key : "");
+
+}
+
+static void
+_connected(void *data, Ethumb_Client *c, Eina_Bool success)
+{
+   struct options *opts = data;
+
    if (!success)
      {
        fputs("ERROR: could not connect to DBus server.\n", stderr);
@@ -196,24 +222,7 @@ _connected(void *data, Ethumb_Client *c, Eina_Bool success)
      }
 
    ethumb_client_thumb_path_set(c, opts->thumb_path, opts->thumb_key);
-   ethumb_client_thumb_path_get(c, &thumb_path, &thumb_key);
-   if (ethumb_client_thumb_exists(c))
-     {
-       _thumb_report
-         ("EXISTS", opts->src_path, opts->src_key, thumb_path, thumb_key);
-       ecore_main_loop_quit();
-       return;
-     }
-
-   id = ethumb_client_generate(c, _finished_thumb, NULL, NULL);
-   if (id < 0)
-     {
-       fputs("ERROR: could not request thumbnail to be generated.\n", stderr);
-       ecore_main_loop_quit();
-       return;
-     }
-   printf("request id=%ld, file='%s', key='%s'\n",
-         id, opts->src_path, opts->src_key ? opts->src_key : "");
+   ethumb_client_thumb_exists(c, _exists, opts);
 }
 
 int