4 * Copyright (C) 2009 by ProFUSION embedded systems
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library;
18 * if not, see <http://www.gnu.org/licenses/>.
20 * @author Rafael Antognolli <antognolli@profusion.mobi>
31 #include <Ethumb_Client.h>
33 #include <Ecore_Getopt.h>
37 _on_server_die_cb(void *data __UNUSED__, Ethumb_Client *client __UNUSED__)
39 ecore_main_loop_quit();
43 _queue_add_cb(void *data __UNUSED__, Ethumb_Client *client __UNUSED__, int id, const char *file, const char *key __UNUSED__, const char *thumb_path, const char *thumb_key __UNUSED__, Eina_Bool success)
45 fprintf(stderr, ">>> %hhu file ready: %s; thumb ready: %s; id = %d\n", success, file, thumb_path, id);
49 _request_thumbnails(Ethumb_Client *client, void *data)
51 const char *path = data;
59 fprintf(stderr, "ERROR: could not open directory: %s\n", path);
63 ethumb_client_format_set(client, ETHUMB_THUMB_JPEG);
64 ethumb_client_aspect_set(client, ETHUMB_THUMB_CROP);
65 ethumb_client_crop_align_set(client, 0.2, 0.2);
66 ethumb_client_size_set(client, 192, 192);
67 ethumb_client_category_set(client, "custom");
69 while ((de = readdir(dir)))
71 if (de->d_type != DT_REG)
73 snprintf(buf, sizeof(buf), "%s/%s", path, de->d_name);
74 ethumb_client_file_set(client, buf, NULL);
75 ethumb_client_generate(client, _queue_add_cb, NULL, NULL);
82 _connect_cb(void *data, Ethumb_Client *client, Eina_Bool success)
84 fprintf(stderr, "connected: %d\n", success);
87 ecore_main_loop_quit();
91 _request_thumbnails(client, data);
95 main(int argc, char *argv[])
97 Ethumb_Client *client;
101 fprintf(stderr, "ERROR: directory not specified.\n");
102 fprintf(stderr, "usage:\n\tethumb_dbus <images directory>\n");
106 ethumb_client_init();
107 client = ethumb_client_connect(_connect_cb, argv[1], NULL);
110 fprintf(stderr, "ERROR: couldn't connect to server.\n");
111 ethumb_client_shutdown();
114 ethumb_client_on_server_die_callback_set(client, _on_server_die_cb, NULL, NULL);
116 fprintf(stderr, "*** debug\n");
117 ecore_main_loop_begin();
119 ethumb_client_disconnect(client);
121 ethumb_client_shutdown();