4 * Copyright (C) 2009 by ProFUSION embedded systems
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or (at your
9 * option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 * @author Rafael Antognolli <antognolli@profusion.mobi>
30 #include <Ethumb_Client.h>
32 #include <Ecore_Getopt.h>
36 _on_server_die_cb(void *data __UNUSED__, Ethumb_Client *client __UNUSED__)
38 ecore_main_loop_quit();
42 _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)
44 fprintf(stderr, ">>> %hhu file ready: %s; thumb ready: %s; id = %d\n", success, file, thumb_path, id);
48 _request_thumbnails(Ethumb_Client *client, void *data)
50 const char *path = data;
58 fprintf(stderr, "ERROR: could not open directory: %s\n", path);
62 ethumb_client_format_set(client, ETHUMB_THUMB_JPEG);
63 ethumb_client_aspect_set(client, ETHUMB_THUMB_CROP);
64 ethumb_client_crop_align_set(client, 0.2, 0.2);
65 ethumb_client_size_set(client, 192, 192);
66 ethumb_client_category_set(client, "custom");
68 while ((de = readdir(dir)))
70 if (de->d_type != DT_REG)
72 snprintf(buf, sizeof(buf), "%s/%s", path, de->d_name);
73 ethumb_client_file_set(client, buf, NULL);
74 ethumb_client_generate(client, _queue_add_cb, NULL, NULL);
81 _connect_cb(void *data, Ethumb_Client *client, Eina_Bool success)
83 fprintf(stderr, "connected: %d\n", success);
86 ecore_main_loop_quit();
90 _request_thumbnails(client, data);
94 main(int argc, char *argv[])
96 Ethumb_Client *client;
100 fprintf(stderr, "ERROR: directory not specified.\n");
101 fprintf(stderr, "usage:\n\tethumb_dbus <images directory>\n");
105 ethumb_client_init();
106 client = ethumb_client_connect(_connect_cb, argv[1], NULL);
109 fprintf(stderr, "ERROR: couldn't connect to server.\n");
110 ethumb_client_shutdown();
113 ethumb_client_on_server_die_callback_set(client, _on_server_die_cb, NULL, NULL);
115 fprintf(stderr, "*** debug\n");
116 ecore_main_loop_begin();
118 ethumb_client_disconnect(client);
120 ethumb_client_shutdown();