ethumbd is a server waiting for requests of thumbnails via dbus. A client library is also provided, avoiding dbus burocracy (and with an API similar to ethumb). SVN revision: 40899devs/devilhorns/wayland_egl
parent
9c5a02a771
commit
aac69a080f
15 changed files with 3734 additions and 1 deletions
@ -0,0 +1,11 @@ |
||||
prefix=@prefix@ |
||||
exec_prefix=@exec_prefix@ |
||||
libdir=@libdir@ |
||||
includedir=@includedir@ |
||||
|
||||
Name: ethumb_client |
||||
Description: Thumbnail Client Library |
||||
Requires: @requirement_ethumb_client@ |
||||
Version: @VERSION@ |
||||
Libs: -L${libdir} -lethumb_client |
||||
Cflags: -I${includedir} |
@ -0,0 +1,3 @@ |
||||
[D-BUS Service] |
||||
Name=org.enlightenment.Ethumb |
||||
Exec=@prefix@/bin/ethumbd |
@ -1,3 +1,3 @@ |
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
SUBDIRS = lib bin plugins
|
||||
SUBDIRS = lib bin plugins tests
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,614 @@ |
||||
/**
|
||||
* @file |
||||
* |
||||
* Copyright (C) 2009 by ProFUSION embedded systems |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify it |
||||
* under the terms of the GNU Lesser General Public License as published by |
||||
* the Free Software Foundation; either version 3 of the License, or (at your |
||||
* option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, but |
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
||||
* for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General Public License |
||||
* along with this program; if not, write to the Free Software Foundation, |
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
||||
* USA. |
||||
* |
||||
* @author Rafael Antognolli <antognolli@profusion.mobi> |
||||
*/ |
||||
|
||||
#include <stdlib.h> |
||||
#include <unistd.h> |
||||
#include <limits.h> |
||||
#include <string.h> |
||||
#include <errno.h> |
||||
|
||||
#include <Ecore.h> |
||||
#include <Ethumb.h> |
||||
#include <Eina.h> |
||||
|
||||
#include "ethumbd_private.h" |
||||
|
||||
#define DBG(...) EINA_ERROR_PDBG(__VA_ARGS__) |
||||
#define INF(...) EINA_ERROR_PINFO(__VA_ARGS__) |
||||
#define WRN(...) EINA_ERROR_PWARN(__VA_ARGS__) |
||||
#define ERR(...) EINA_ERROR_PERR(__VA_ARGS__) |
||||
|
||||
#define NETHUMBS 100 |
||||
|
||||
struct _Ethumbd_Child |
||||
{ |
||||
Ecore_Fd_Handler *fd_handler; |
||||
Ethumb *ethumbt[NETHUMBS]; |
||||
int pipein, pipeout; |
||||
}; |
||||
|
||||
|
||||
int |
||||
_ec_read_safe(int fd, void *buf, ssize_t size) |
||||
{ |
||||
ssize_t todo; |
||||
char *p; |
||||
|
||||
todo = size; |
||||
p = buf; |
||||
|
||||
while (todo > 0) |
||||
{ |
||||
ssize_t r; |
||||
|
||||
r = read(fd, p, todo); |
||||
if (r > 0) |
||||
{ |
||||
todo -= r; |
||||
p += r; |
||||
} |
||||
else if (r == 0) |
||||
return 0; |
||||
else |
||||
{ |
||||
if (errno == EINTR || errno == EAGAIN) |
||||
continue; |
||||
else |
||||
{ |
||||
ERR("could not read from fd %d: %s", |
||||
fd, strerror(errno)); |
||||
return 0; |
||||
} |
||||
} |
||||
} |
||||
|
||||
return 1; |
||||
} |
||||
|
||||
int |
||||
_ec_write_safe(int fd, const void *buf, ssize_t size) |
||||
{ |
||||
ssize_t todo; |
||||
const char *p; |
||||
|
||||
todo = size; |
||||
p = buf; |
||||
|
||||
while (todo > 0) |
||||
{ |
||||
ssize_t r; |
||||
|
||||
r = write(fd, p, todo); |
||||
if (r > 0) |
||||
{ |
||||
todo -= r; |
||||
p += r; |
||||
} |
||||
else if (r == 0) |
||||
return 0; |
||||
else |
||||
{ |
||||
if (errno == EINTR || errno == EAGAIN) |
||||
continue; |
||||
else |
||||
{ |
||||
ERR("could not write to fd %d: %s", fd, strerror(errno)); |
||||
return 0; |
||||
} |
||||
} |
||||
} |
||||
|
||||
return 1; |
||||
} |
||||
|
||||
static int |
||||
_ec_pipe_str_read(struct _Ethumbd_Child *ec, char **str) |
||||
{ |
||||
int size; |
||||
int r; |
||||
char buf[PATH_MAX]; |
||||
|
||||
r = _ec_read_safe(ec->pipein, &size, sizeof(size)); |
||||
if (!r) |
||||
{ |
||||
*str = NULL; |
||||
return 0; |
||||
} |
||||
|
||||
if (!size) |
||||
{ |
||||
*str = NULL; |
||||
return 1; |
||||
} |
||||
|
||||
r = _ec_read_safe(ec->pipein, buf, size); |
||||
if (!r) |
||||
{ |
||||
*str = NULL; |
||||
return 0; |
||||
} |
||||
|
||||
*str = strdup(buf); |
||||
return 1; |
||||
} |
||||
|
||||
static void |
||||
_ec_pipe_str_write(struct _Ethumbd_Child *ec, const char *str) |
||||
{ |
||||
int size; |
||||
|
||||
if (!str) |
||||
size = 0; |
||||
else |
||||
size = strlen(str) + 1; |
||||
|
||||
_ec_write_safe(ec->pipeout, &size, sizeof(size)); |
||||
_ec_write_safe(ec->pipeout, str, size); |
||||
} |
||||
|
||||
static struct _Ethumbd_Child * |
||||
_ec_new(int pipein, int pipeout) |
||||
{ |
||||
struct _Ethumbd_Child *ec = calloc(1, sizeof(*ec)); |
||||
|
||||
ec->pipein = pipein; |
||||
ec->pipeout = pipeout; |
||||
|
||||
return ec; |
||||
} |
||||
|
||||
static void |
||||
_ec_free(struct _Ethumbd_Child *ec) |
||||
{ |
||||
int i; |
||||
|
||||
if (ec->fd_handler) |
||||
ecore_main_fd_handler_del(ec->fd_handler); |
||||
|
||||
for (i = 0; i < NETHUMBS; i++) |
||||
{ |
||||
if (ec->ethumbt[i]) |
||||
ethumb_free(ec->ethumbt[i]); |
||||
} |
||||
|
||||
free(ec); |
||||
} |
||||
|
||||
static int |
||||
_ec_op_new(struct _Ethumbd_Child *ec) |
||||
{ |
||||
int r; |
||||
int index; |
||||
|
||||
r = _ec_read_safe(ec->pipein, &index, sizeof(index)); |
||||
if (!r) |
||||
return 0; |
||||
|
||||
DBG("ethumbd new(). index = %d\n", index); |
||||
|
||||
ec->ethumbt[index] = ethumb_new(); |
||||
return 1; |
||||
} |
||||
|
||||
static int |
||||
_ec_op_del(struct _Ethumbd_Child *ec) |
||||
{ |
||||
int r; |
||||
int index; |
||||
|
||||
r = _ec_read_safe(ec->pipein, &index, sizeof(index)); |
||||
if (!r) |
||||
return 0; |
||||
|
||||
DBG("ethumbd del(). index = %d\n", index); |
||||
|
||||
ethumb_free(ec->ethumbt[index]); |
||||
ec->ethumbt[index] = NULL; |
||||
return 1; |
||||
} |
||||
|
||||
static void |
||||
_ec_op_generated_cb(Ethumb *e, Eina_Bool success, void *data) |
||||
{ |
||||
struct _Ethumbd_Child *ec = data; |
||||
const char *thumb_path, *thumb_key; |
||||
|
||||
DBG("thumb generated!\n"); |
||||
ethumb_thumb_path_get(e, &thumb_path, &thumb_key); |
||||
_ec_write_safe(ec->pipeout, &success, sizeof(success)); |
||||
|
||||
_ec_pipe_str_write(ec, thumb_path); |
||||
_ec_pipe_str_write(ec, thumb_key); |
||||
} |
||||
|
||||
static int |
||||
_ec_op_generate(struct _Ethumbd_Child *ec) |
||||
{ |
||||
int index; |
||||
char *path, *key, *thumb_path, *thumb_key; |
||||
int r; |
||||
|
||||
r = _ec_read_safe(ec->pipein, &index, sizeof(index)); |
||||
if (!r) |
||||
return 0; |
||||
|
||||
r = _ec_pipe_str_read(ec, &path); |
||||
if (!r) |
||||
return 0; |
||||
r = _ec_pipe_str_read(ec, &key); |
||||
if (!r) |
||||
return 0; |
||||
r = _ec_pipe_str_read(ec, &thumb_path); |
||||
if (!r) |
||||
return 0; |
||||
r = _ec_pipe_str_read(ec, &thumb_key); |
||||
if (!r) |
||||
return 0; |
||||
|
||||
ethumb_file_set(ec->ethumbt[index], path, key); |
||||
ethumb_thumb_path_set(ec->ethumbt[index], thumb_path, thumb_key); |
||||
ethumb_generate(ec->ethumbt[index], _ec_op_generated_cb, |
||||
ec); |
||||
|
||||
free(path); |
||||
free(key); |
||||
free(thumb_path); |
||||
free(thumb_key); |
||||
|
||||
return 1; |
||||
} |
||||
|
||||
static int |
||||
_ec_fdo_set(struct _Ethumbd_Child *ec, Ethumb *e) |
||||
{ |
||||
int r; |
||||
int value; |
||||
|
||||
r = _ec_read_safe(ec->pipein, &value, sizeof(value)); |
||||
if (!r) |
||||
return 0; |
||||
ethumb_thumb_fdo_set(e, value); |
||||
DBG("fdo = %d\n", value); |
||||
|
||||
return 1; |
||||
} |
||||
|
||||
static int |
||||
_ec_size_set(struct _Ethumbd_Child *ec, Ethumb *e) |
||||
{ |
||||
int r; |
||||
int w, h; |
||||
int type; |
||||
|
||||
r = _ec_read_safe(ec->pipein, &w, sizeof(w)); |
||||
if (!r) |
||||
return 0; |
||||
r = _ec_read_safe(ec->pipein, &type, sizeof(type)); |
||||
if (!r) |
||||
return 0; |
||||
r = _ec_read_safe(ec->pipein, &h, sizeof(h)); |
||||
if (!r) |
||||
return 0; |
||||
ethumb_thumb_size_set(e, w, h); |
||||
DBG("size = %dx%d\n", w, h); |
||||
|
||||
return 1; |
||||
} |
||||
|
||||
static int |
||||
_ec_format_set(struct _Ethumbd_Child *ec, Ethumb *e) |
||||
{ |
||||
int r; |
||||
int value; |
||||
|
||||
r = _ec_read_safe(ec->pipein, &value, sizeof(value)); |
||||
if (!r) |
||||
return 0; |
||||
ethumb_thumb_format_set(e, value); |
||||
DBG("format = %d\n", value); |
||||
|
||||
return 1; |
||||
} |
||||
|
||||
static int |
||||
_ec_aspect_set(struct _Ethumbd_Child *ec, Ethumb *e) |
||||
{ |
||||
int r; |
||||
int value; |
||||
|
||||
r = _ec_read_safe(ec->pipein, &value, sizeof(value)); |
||||
if (!r) |
||||
return 0; |
||||
ethumb_thumb_aspect_set(e, value); |
||||
DBG("aspect = %d\n", value); |
||||
|
||||
return 1; |
||||
} |
||||
|
||||
static int |
||||
_ec_crop_set(struct _Ethumbd_Child *ec, Ethumb *e) |
||||
{ |
||||
int r; |
||||
float x, y; |
||||
int type; |
||||
|
||||
r = _ec_read_safe(ec->pipein, &x, sizeof(x)); |
||||
if (!r) |
||||
return 0; |
||||
r = _ec_read_safe(ec->pipein, &type, sizeof(type)); |
||||
if (!r) |
||||
return 0; |
||||
r = _ec_read_safe(ec->pipein, &y, sizeof(y)); |
||||
if (!r) |
||||
return 0; |
||||
ethumb_thumb_crop_align_set(e, x, y); |
||||
DBG("crop = %fx%f\n", x, y); |
||||
|
||||
return 1; |
||||
} |
||||
|
||||
static int |
||||
_ec_frame_set(struct _Ethumbd_Child *ec, Ethumb *e) |
||||
{ |
||||
int r; |
||||
int type; |
||||
char *theme_file, *group, *swallow; |
||||
|
||||
r = _ec_pipe_str_read(ec, &theme_file); |
||||
if (!r) |
||||
return 0; |
||||
r = _ec_read_safe(ec->pipein, &type, sizeof(type)); |
||||
if (!r) |
||||
return 0; |
||||
r = _ec_pipe_str_read(ec, &group); |
||||
if (!r) |
||||
return 0; |
||||
r = _ec_read_safe(ec->pipein, &type, sizeof(type)); |
||||
if (!r) |
||||
return 0; |
||||
r = _ec_pipe_str_read(ec, &swallow); |
||||
if (!r) |
||||
return 0; |
||||
DBG("frame = %s:%s:%s\n", theme_file, group, swallow); |
||||
ethumb_frame_set(e, theme_file, group, swallow); |
||||
free(theme_file); |
||||
free(group); |
||||
free(swallow); |
||||
|
||||
return 1; |
||||
} |
||||
|
||||
static int |
||||
_ec_directory_set(struct _Ethumbd_Child *ec, Ethumb *e) |
||||
{ |
||||
int r; |
||||
char *directory; |
||||
|
||||
r = _ec_pipe_str_read(ec, &directory); |
||||
if (!r) |
||||
return 0; |
||||
ethumb_thumb_dir_path_set(e, directory); |
||||
DBG("directory = %s\n", directory); |
||||
free(directory); |
||||
|
||||
return 1; |
||||
} |
||||
|
||||
static int |
||||
_ec_category_set(struct _Ethumbd_Child *ec, Ethumb *e) |
||||
{ |
||||
int r; |
||||
char *category; |
||||
|
||||
r = _ec_pipe_str_read(ec, &category); |
||||
if (!r) |
||||
return 0; |
||||
ethumb_thumb_category_set(e, category); |
||||
DBG("category = %s\n", category); |
||||
free(category); |
||||
|
||||
return 1; |
||||
} |
||||
|
||||
static int |
||||
_ec_video_time_set(struct _Ethumbd_Child *ec, Ethumb *e) |
||||
{ |
||||
int r; |
||||
float value; |
||||
|
||||
r = _ec_read_safe(ec->pipein, &value, sizeof(value)); |
||||
if (!r) |
||||
return 0; |
||||
ethumb_video_time_set(e, value); |
||||
DBG("video_time = %f\n", value); |
||||
|
||||
return 1; |
||||
} |
||||
|
||||
static int |
||||
_ec_document_page_set(struct _Ethumbd_Child *ec, Ethumb *e) |
||||
{ |
||||
int r; |
||||
int value; |
||||
|
||||
r = _ec_read_safe(ec->pipein, &value, sizeof(value)); |
||||
if (!r) |
||||
return 0; |
||||
ethumb_document_page_set(e, value); |
||||
DBG("document_page = %d\n", value); |
||||
|
||||
return 1; |
||||
} |
||||
|
||||
static void |
||||
_ec_setup_process(struct _Ethumbd_Child *ec, int index, int type) |
||||
{ |
||||
Ethumb *e; |
||||
|
||||
e = ec->ethumbt[index]; |
||||
|
||||
switch (type) |
||||
{ |
||||
case ETHUMBD_FDO: |
||||
_ec_fdo_set(ec, e); |
||||
break; |
||||
case ETHUMBD_SIZE_W: |
||||
_ec_size_set(ec, e); |
||||
break; |
||||
case ETHUMBD_FORMAT: |
||||
_ec_format_set(ec, e); |
||||
break; |
||||
case ETHUMBD_ASPECT: |
||||
_ec_aspect_set(ec, e); |
||||
break; |
||||
case ETHUMBD_CROP_X: |
||||
_ec_crop_set(ec, e); |
||||
break; |
||||
case ETHUMBD_FRAME_FILE: |
||||
_ec_frame_set(ec, e); |
||||
break; |
||||
case ETHUMBD_DIRECTORY: |
||||
_ec_directory_set(ec, e); |
||||
break; |
||||
case ETHUMBD_CATEGORY: |
||||
_ec_category_set(ec, e); |
||||
break; |
||||
case ETHUMBD_VIDEO_TIME: |
||||
_ec_video_time_set(ec, e); |
||||
break; |
||||
case ETHUMBD_DOCUMENT_PAGE: |
||||
_ec_document_page_set(ec, e); |
||||
break; |
||||
default: |
||||
ERR("wrong type!\n"); |
||||
} |
||||
} |
||||
|
||||
static int |
||||
_ec_op_setup(struct _Ethumbd_Child *ec) |
||||
{ |
||||
int r; |
||||
int index; |
||||
int type; |
||||
|
||||
r = _ec_read_safe(ec->pipein, &index, sizeof(index)); |
||||
if (!r) |
||||
return 0; |
||||
|
||||
r = _ec_read_safe(ec->pipein, &type, sizeof(type)); |
||||
if (!r) |
||||
return 0; |
||||
while (type != ETHUMBD_SETUP_FINISHED) |
||||
{ |
||||
_ec_setup_process(ec, index, type); |
||||
r = _ec_read_safe(ec->pipein, &type, sizeof(type)); |
||||
if (!r) |
||||
return 0; |
||||
} |
||||
|
||||
return 1; |
||||
} |
||||
|
||||
static int |
||||
_ec_fd_handler(void *data, Ecore_Fd_Handler *fd_handler) |
||||
{ |
||||
struct _Ethumbd_Child *ec = data; |
||||
int op_id; |
||||
int r; |
||||
|
||||
if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_ERROR)) |
||||
{ |
||||
ERR("error on pipein! child exiting...\n"); |
||||
ec->fd_handler = NULL; |
||||
ecore_main_loop_quit(); |
||||
return 0; |
||||
} |
||||
|
||||
r = _ec_read_safe(ec->pipein, &op_id, sizeof(op_id)); |
||||
if (!r) |
||||
{ |
||||
DBG("ethumbd exited! child exiting...\n"); |
||||
ec->fd_handler = NULL; |
||||
ecore_main_loop_quit(); |
||||
return 0; |
||||
} |
||||
|
||||
DBG("received op: %d\n", op_id); |
||||
|
||||
r = 1; |
||||
switch (op_id) |
||||
{ |
||||
case ETHUMBD_OP_NEW: |
||||
r = _ec_op_new(ec); |
||||
break; |
||||
case ETHUMBD_OP_GENERATE: |
||||
r = _ec_op_generate(ec); |
||||
break; |
||||
case ETHUMBD_OP_SETUP: |
||||
r = _ec_op_setup(ec); |
||||
break; |
||||
case ETHUMBD_OP_DEL: |
||||
r = _ec_op_del(ec); |
||||
break; |
||||
default: |
||||
ERR("invalid operation: %d\n", op_id); |
||||
r = 0; |
||||
} |
||||
|
||||
if (!r) |
||||
{ |
||||
ERR("ethumbd exited! child exiting...\n"); |
||||
ec->fd_handler = NULL; |
||||
ecore_main_loop_quit(); |
||||
} |
||||
|
||||
return r; |
||||
} |
||||
|
||||
static void |
||||
_ec_setup(struct _Ethumbd_Child *ec) |
||||
{ |
||||
ec->fd_handler = ecore_main_fd_handler_add( |
||||
ec->pipein, ECORE_FD_READ | ECORE_FD_ERROR, |
||||
_ec_fd_handler, ec, NULL, NULL); |
||||
} |
||||
|
||||
void |
||||
ethumbd_child_start(int pipein, int pipeout) |
||||
{ |
||||
struct _Ethumbd_Child *ec; |
||||
|
||||
ethumb_init(); |
||||
|
||||
ec = _ec_new(pipein, pipeout); |
||||
|
||||
_ec_setup(ec); |
||||
|
||||
DBG("child started!\n"); |
||||
ecore_main_loop_begin(); |
||||
DBG("child finishing.\n"); |
||||
|
||||
_ec_free(ec); |
||||
|
||||
ethumb_shutdown(); |
||||
} |
@ -0,0 +1,34 @@ |
||||
#ifndef __ETHUMBD_PRIVATE_H__ |
||||
#define __ETHUMBD_PRIVATE_H__ 1 |
||||
|
||||
|
||||
enum Ethumbd_Operations |
||||
{ |
||||
ETHUMBD_OP_NEW, |
||||
ETHUMBD_OP_GENERATE, |
||||
ETHUMBD_OP_SETUP, |
||||
ETHUMBD_OP_DEL |
||||
}; |
||||
|
||||
enum Ethubmd_Setup_Option |
||||
{ |
||||
ETHUMBD_FDO, |
||||
ETHUMBD_SIZE_W, |
||||
ETHUMBD_SIZE_H, |
||||
ETHUMBD_FORMAT, |
||||
ETHUMBD_ASPECT, |
||||
ETHUMBD_CROP_X, |
||||
ETHUMBD_CROP_Y, |
||||
ETHUMBD_DIRECTORY, |
||||
ETHUMBD_CATEGORY, |
||||
ETHUMBD_FRAME_FILE, |
||||
ETHUMBD_FRAME_GROUP, |
||||
ETHUMBD_FRAME_SWALLOW, |
||||
ETHUMBD_VIDEO_TIME, |
||||
ETHUMBD_DOCUMENT_PAGE, |
||||
ETHUMBD_SETUP_FINISHED |
||||
}; |
||||
|
||||
void ethumbd_child_start(int pipein, int pipeout); |
||||
|
||||
#endif |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,85 @@ |
||||
#ifndef __ETHUMB_CLIENT_H__ |
||||
#define __ETHUMB_CLIENT_H__ 1 |
||||
|
||||
#ifndef EAPI |
||||
#ifdef _WIN32 |
||||
# ifdef EFL_EVAS_BUILD |
||||
# ifdef DLL_EXPORT |
||||
# define EAPI __declspec(dllexport) |
||||
# define GNUC_NULL_TERMINATED |
||||
# else |
||||
# define EAPI |
||||
# define GNUC_NULL_TERMINATED |
||||
# endif /* ! DLL_EXPORT */ |
||||
# else |
||||
# define EAPI __declspec(dllimport) |
||||
# define GNUC_NULL_TERMINATED |
||||
# endif /* ! EFL_EVAS_BUILD */ |
||||
#else |
||||
# ifdef __GNUC__ |
||||
# if __GNUC__ >= 4 |
||||
# define EAPI __attribute__ ((visibility("default"))) |
||||
# define GNUC_NULL_TERMINATED __attribute__((__sentinel__)) |
||||
# else |
||||
# define EAPI |
||||
# define GNUC_NULL_TERMINATED |
||||
# endif |
||||
# else |
||||
# define EAPI |
||||
# define GNUC_NULL_TERMINATED |
||||
# endif |
||||
#endif /* ! _WIN32 */ |
||||
#endif /* EAPI */ |
||||
|
||||
#include "Ethumb.h" |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
typedef struct _Ethumb_Client Ethumb_Client; |
||||
typedef void (*ec_connect_callback_t)(Ethumb_Client *client, Eina_Bool success, void *data); |
||||
typedef void (*generated_callback_t)(long id, const char *file, const char *key, Eina_Bool success, void *data); |
||||
|
||||
EAPI int ethumb_client_init(void); |
||||
EAPI int ethumb_client_shutdown(void); |
||||
|
||||
EAPI Ethumb_Client * ethumb_client_connect(ec_connect_callback_t connect_cb, void *data); |
||||
EAPI void ethumb_client_disconnect(Ethumb_Client *client); |
||||
EAPI void ethumb_client_on_server_die_callback_set(Ethumb_Client *client, void (*on_server_die_cb)(Ethumb_Client *client, void *data), void *data); |
||||
|
||||
EAPI void ethumb_client_queue_remove(Ethumb_Client *client, long id, void (*queue_remove_cb)(Eina_Bool success, void *data), void *data); |
||||
EAPI void ethumb_client_queue_clear(Ethumb_Client *client); |
||||
|
||||
EAPI void ethumb_client_fdo_set(Ethumb_Client *client, Ethumb_Thumb_FDO_Size s); |
||||
EAPI void ethumb_client_size_set(Ethumb_Client *client, int tw, int th); |
||||
EAPI void ethumb_client_size_get(const Ethumb_Client *client, int *tw, int *th); |
||||
EAPI void ethumb_client_format_set(Ethumb_Client *client, Ethumb_Thumb_Format f); |
||||
EAPI Ethumb_Thumb_Format ethumb_client_format_get(const Ethumb_Client *client); |
||||
EAPI void ethumb_client_aspect_set(Ethumb_Client *client, Ethumb_Thumb_Aspect a); |
||||
EAPI Ethumb_Thumb_Aspect ethumb_client_aspect_get(const Ethumb_Client *client); |
||||
EAPI void ethumb_client_crop_align_set(Ethumb_Client *client, float x, float y); |
||||
EAPI void ethumb_client_crop_align_get(const Ethumb_Client *client, float *x, float *y); |
||||
EAPI Eina_Bool ethumb_client_frame_set(Ethumb_Client *client, const char *file, const char *group, const char *swallow); |
||||
EAPI void ethumb_client_dir_path_set(Ethumb_Client *client, const char *path); |
||||
EAPI const char * ethumb_client_dir_path_get(const Ethumb_Client *client); |
||||
EAPI void ethumb_client_category_set(Ethumb_Client *client, const char *category); |
||||
EAPI const char * ethumb_client_category_get(const Ethumb_Client *client); |
||||
EAPI void ethumb_client_video_time_set(Ethumb_Client *client, float time); |
||||
EAPI void ethumb_client_document_page_set(Ethumb_Client *client, int page); |
||||
|
||||
EAPI void ethumb_client_ethumb_setup(Ethumb_Client *client); |
||||
|
||||
EAPI Eina_Bool ethumb_client_file_set(Ethumb_Client *client, const char *path, const char *key); |
||||
EAPI void ethumb_client_file_get(Ethumb_Client *client, const char **path, const char **key); |
||||
EAPI void ethumb_client_file_free(Ethumb_Client *client); |
||||
|
||||
EAPI void ethumb_client_thumb_path_set(Ethumb_Client *client, const char *path, const char *key); |
||||
EAPI void ethumb_client_thumb_path_get(Ethumb_Client *client, const char **path, const char **key); |
||||
EAPI Eina_Bool ethumb_client_thumb_exists(Ethumb_Client *client); |
||||
EAPI long ethumb_client_generate(Ethumb_Client *client, generated_callback_t generated_cb, void *data); |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif /* __ETHUMB_CLIENT_H__ */ |
@ -0,0 +1,21 @@ |
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_builddir) \
|
||||
-I$(top_srcdir)/src/lib \
|
||||
@EDBUS_CFLAGS@
|
||||
|
||||
include_HEADERS = Ethumb_Client.h
|
||||
|
||||
lib_LTLIBRARIES = libethumb_client.la
|
||||
|
||||
libethumb_client_la_SOURCES = \
|
||||
Ethumb_Client.c
|
||||
libethumb_client_la_DEPENDENCIES = $(top_builddir)/config.h
|
||||
libethumb_client_la_LIBADD = \
|
||||
$(top_builddir)/src/lib/libethumb.la \
|
||||
@EDBUS_LIBS@
|
||||
libethumb_client_la_LDFLAGS = -version-info @version_info@
|
||||
|
||||
# @EVAS_LIBS@ @ECORE_EVAS_LIBS@ @ECORE_FILE_LIBS@ @EDJE_LIBS@
|
@ -0,0 +1,22 @@ |
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/src/lib \
|
||||
-I$(top_srcdir)/src/lib/client \
|
||||
@EINA_CFLAGS@ @EVAS_CFLAGS@ @ECORE_CFLAGS@ @ECORE_EVAS_CFLAGS@ \
|
||||
@EDJE_CFLAGS@ @ECORE_FILE_CFLAGS@
|
||||
|
||||
check_PROGRAMS =
|
||||
|
||||
if USE_MODULE_ETHUMBD |
||||
|
||||
AM_CPPFLAGS += @EDBUS_CFLAGS@
|
||||
check_PROGRAMS += ethumb_dbus
|
||||
ethumb_dbus_SOURCES = ethumb_dbus.c
|
||||
ethumb_dbus_LDADD = \
|
||||
@EINA_LIBS@ @EVAS_LIBS@ @ECORE_LIBS@ @ECORE_EVAS_LIBS@ @EDJE_LIBS@ \
|
||||
@ECORE_FILE_LIBS@ @EDBUS_LIBS@ \
|
||||
$(top_builddir)/src/lib/libethumb.la \
|
||||
$(top_builddir)/src/lib/client/libethumb_client.la
|
||||
|
||||
endif |
@ -0,0 +1,135 @@ |
||||
/**
|
||||
* @file |
||||
* |
||||
* Copyright (C) 2009 by ProFUSION embedded systems |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify it |
||||
* under the terms of the GNU Lesser General Public License as published by |
||||
* the Free Software Foundation; either version 3 of the License, or (at your |
||||
* option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, but |
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
||||
* for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General Public License |
||||
* along with this program; if not, write to the Free Software Foundation, |
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
||||
* USA. |
||||
* |
||||
* @author Rafael Antognolli <antognolli@profusion.mobi> |
||||
*/ |
||||
#include <config.h> |
||||
#include <stdio.h> |
||||
#include <stdlib.h> |
||||
#include <string.h> |
||||
#include <limits.h> |
||||
#include <dirent.h> |
||||
#include <Ethumb.h> |
||||
#include <Ethumb_Client.h> |
||||
#include <Eina.h> |
||||
#include <Ecore_Getopt.h> |
||||
#include <Ecore.h> |
||||
|
||||
static void |
||||
_on_server_die_cb(Ethumb_Client *client, void *data) |
||||
{ |
||||
ecore_main_loop_quit(); |
||||
} |
||||
|
||||
static void |
||||
_queue_add_cb(long id, const char *file, const char *key, Eina_Bool success, void *data) |
||||
{ |
||||
fprintf(stderr, ">>> file ready: %s; id = %ld\n", file, id); |
||||
} |
||||
|
||||
static void |
||||
_disconnect(Ethumb_Client *client) |
||||
{ |
||||
ethumb_client_disconnect(client); |
||||
} |
||||
|
||||
static void |
||||
_request_thumbnails(Ethumb_Client *client, void *data) |
||||
{ |
||||
const char *path = data; |
||||
DIR *dir; |
||||
struct dirent *de; |
||||
char buf[PATH_MAX]; |
||||
int i; |
||||
|
||||
dir = opendir(path); |
||||
if (!dir) |
||||
{ |
||||
fprintf(stderr, "ERROR: could not open directory: %s\n", path); |
||||
return; |
||||
} |
||||
|
||||
ethumb_client_format_set(client, ETHUMB_THUMB_JPEG); |
||||
ethumb_client_aspect_set(client, ETHUMB_THUMB_CROP); |
||||
ethumb_client_crop_align_set(client, 0.2, 0.2); |
||||
ethumb_client_size_set(client, 192, 192); |
||||
ethumb_client_category_set(client, "custom"); |
||||
|
||||
while ((de = readdir(dir))) |
||||
{ |
||||
if (de->d_type != DT_REG) |
||||
continue; |
||||
snprintf(buf, sizeof(buf), "%s/%s", path, de->d_name); |
||||
ethumb_client_file_set(client, buf, NULL); |
||||
ethumb_client_generate(client, _queue_add_cb, NULL); |
||||
} |
||||
|
||||
for (i = 100; i < 200; i++) |
||||
{ |
||||
ethumb_client_queue_remove(client, i, NULL, NULL); |
||||
} |
||||
|
||||
closedir(dir); |
||||
} |
||||
|
||||
static void |
||||
_connect_cb(Ethumb_Client *client, Eina_Bool success, void *data) |
||||
{ |
||||
fprintf(stderr, "connected: %d\n", success); |
||||
if (!success) |
||||
{ |
||||
ecore_main_loop_quit(); |
||||
return; |
||||
} |
||||
|
||||
_request_thumbnails(client, data); |
||||
} |
||||
|
||||
int |
||||
main(int argc, char *argv[]) |
||||
{ |
||||
Ethumb_Client *client; |
||||
|
||||
if (argc < 2) |
||||
{ |
||||
fprintf(stderr, "ERROR: directory not specified.\n"); |
||||
fprintf(stderr, "usage:\n\tethumb_dbus <images directory>\n"); |
||||
return -2; |
||||
} |
||||
|
||||
ethumb_client_init(); |
||||
client = ethumb_client_connect(_connect_cb, argv[1]); |
||||
if (!client) |
||||
{ |
||||
fprintf(stderr, "ERROR: couldn't connect to server.\n"); |
||||
ethumb_client_shutdown(); |
||||
return -1; |
||||
} |
||||
ethumb_client_on_server_die_callback_set(client, _on_server_die_cb, NULL); |
||||
|
||||
fprintf(stderr, "*** debug\n"); |
||||
ecore_main_loop_begin(); |
||||
|
||||
_disconnect(client); |
||||
|
||||
ethumb_client_shutdown(); |
||||
|
||||
return 0; |
||||
} |
Loading…
Reference in new issue