diff -u --recursive --new-file --exclude-from=/tmp/cvs.exclude gphoto.orig/Makefile.am gphoto/Makefile.am --- gphoto.orig/Makefile.am Sun Sep 10 18:21:57 2000 +++ gphoto/Makefile.am Sun Sep 10 18:27:41 2000 @@ -2,7 +2,7 @@ SUBDIRS = barbie canon casio digita dimera directory fuji gallery jd11 kodak \ kodak_generic konica konica_qmxxx man minolta mustek nikon \ -philips photopc polaroid ricoh samsung sony src +philips photopc polaroid ricoh samsung sony dummy src gphotodocdir = $(datadir)/gphoto/doc diff -u --recursive --new-file --exclude-from=/tmp/cvs.exclude gphoto.orig/configure.in gphoto/configure.in --- gphoto.orig/configure.in Sun Sep 10 18:21:57 2000 +++ gphoto/configure.in Sun Sep 10 18:27:41 2000 @@ -111,6 +111,7 @@ digita/Makefile \ dimera/Makefile \ directory/Makefile \ +dummy/Makefile \ fuji/Makefile \ gallery/Makefile \ gallery/CSStheme/Makefile \ diff -u --recursive --new-file --exclude-from=/tmp/cvs.exclude gphoto.orig/dummy/Makefile.am gphoto/dummy/Makefile.am --- gphoto.orig/dummy/Makefile.am Thu Jan 1 01:00:00 1970 +++ gphoto/dummy/Makefile.am Sun Sep 10 18:27:41 2000 @@ -0,0 +1,12 @@ +drivers_LTLIBRARIES = libgphoto_dummy.la + +CFLAGS = @CFLAGS@ @GDK_IMLIB_CFLAGS@ \ + @GNOME_INCLUDEDIR@ -DUNIX -DINT16=short \ + -I$(top_srcdir)/src + +libgphoto_dummy_la_SOURCES = dummy.c + +libgphoto_dummy_la_LDFLAGS = -version-info 0:0:0 + +dummydir = $(datadir)/gphoto/dummy +dummy_DATA = dummy_image.jpg dummy_thumb.jpg diff -u --recursive --new-file --exclude-from=/tmp/cvs.exclude gphoto.orig/dummy/dummy.c gphoto/dummy/dummy.c --- gphoto.orig/dummy/dummy.c Thu Jan 1 01:00:00 1970 +++ gphoto/dummy/dummy.c Sun Sep 10 18:42:25 2000 @@ -0,0 +1,279 @@ +/* gPhoto - fake camera module. + * + * Copyright (C) 2000 The Free Software Foundation + * + * Author: Fabrice Bellet + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + +#include +#include +#include +#include +#include +#include + +#include + +#include "gphoto.h" + +#define DUMMY_NB_OF_PIX 16 +#define DUMMY_IMAGE_FILENAME "dummy_image.jpg" +#define DUMMY_THUMB_FILENAME "dummy_thumb.jpg" + +typedef struct _DummyPicture DummyPicture; + +struct _DummyPicture { + gchar *name; + guint len; + gpointer data; +}; + +typedef struct _DummyPhoto DummyPhoto; + +struct _DummyPhoto { + struct _DummyPicture image; + struct _DummyPicture thumb; + struct _DummyPhoto *next; +}; + +typedef struct _DummyDevice DummyDevice; + +struct _DummyDevice { + guint nb_of_images; + DummyPhoto *images; +}; + +DummyDevice dummy; + +static void +dummy_load_image (DummyPicture *p) +{ + int fd; + struct stat buf; + int ret; + guint size; + gchar *ptr; + gchar *filename; + + g_assert (p != NULL); + filename=p->name; + g_assert (filename != NULL); + + /* + * Here we do image cacheing. We only load it + * at the first call. + */ + if (p->data) + return; + + ret = stat (filename, &buf); + if (ret==-1) { + perror ("dummy_load_image(): stat() failed\n"); + return; + } + size = buf.st_size; + g_assert (size>0); + + fd=open (filename, O_RDONLY); + if (fd==-1) { + perror ("dummy_load_image(): open() failed\n"); + return; + } + p->name = g_strdup (filename); + p->len = size; + p->data = (char *)g_malloc(size); + if (p->data==NULL) { + g_message ("dummy_load_image(): g_malloc() failed\n"); + return; + } + ptr=p->data; + while ((ret = read (fd, ptr, size))>0) { + size -= ret; + ptr += size; + }; + if (ret==-1) { + perror ("dummy_load_image(): read() failed\n"); + g_free (p->data); + return; + }; + close(fd); +} + +static void +dummy_init_image (DummyPhoto *p) +{ + DIR *dp; + gchar *dummy_file; + gchar *dummy_dir = gnome_unconditional_datadir_file("gphoto"); + + if ((dp = opendir(dummy_dir))==NULL) { + g_free(dummy_dir); + return; + } + + dummy_file = g_strconcat (dummy_dir, "/dummy/", DUMMY_IMAGE_FILENAME, NULL); + p->image.name = g_strdup (dummy_file); + p->image.len=0; + p->image.data=NULL; + g_free (dummy_file); + + dummy_file = g_strconcat (dummy_dir, "/dummy/", DUMMY_THUMB_FILENAME, NULL); + p->thumb.name = g_strdup (dummy_file); + p->thumb.len=0; + p->thumb.data=NULL; + g_free (dummy_file); + g_free (dummy_dir); + +} + +int +dummy_initialize () +{ + DummyPhoto *p1, *p2; + guint i; + + dummy.nb_of_images = DUMMY_NB_OF_PIX; + for (i = 0, p1 = NULL, p2 = NULL; + i < DUMMY_NB_OF_PIX; + i++, p1->next = p2, p2 = p1) { + p1 = (DummyPhoto *)g_malloc(sizeof(DummyPhoto)); + dummy_init_image (p1); + } + dummy.images = p2; + return 1; +} + +int +dummy_open_camera () +{ + return 1; +} + +void +dummy_close_camera () +{ +} + +int +dummy_number_of_pictures () +{ + g_assert (dummy.nb_of_images>=0); + return dummy.nb_of_images; +} + +int +dummy_take_picture () +{ + g_message ("dummy_take_picture() not implemented. FIXME"); + return dummy_number_of_pictures(); +} + +/* + * Reads image #picNum. + * If thumbnail == TRUE, if returns the thumbnail data. + * else it returns the whole image. + */ +struct Image * +dummy_get_picture (int picNum, int thumbnail) +{ + DummyPhoto *p; + guint i; + struct Image *im; + + g_assert (picNum-1 <= dummy.nb_of_images); + for (p = dummy.images, i=1; i < picNum; i++, p = p->next); + g_assert (p != NULL); + + im = (struct Image *)g_malloc(sizeof (struct Image)); + if (thumbnail) { + dummy_load_image (&p->thumb); + im->image = g_malloc(p->thumb.len); + memcpy (im->image, p->thumb.data, p->thumb.len); + im->image_size = p->thumb.len; + } else { + dummy_load_image (&p->image); + im->image = g_malloc(p->image.len); + memcpy (im->image, p->image.data, p->image.len); + im->image_size = p->image.len; + } + im->image_info_size = 0; + strcpy (im->image_type, "jpg"); + return im; +} + +struct Image * +dummy_get_preview () +{ + return dummy_get_picture (1,1); +} + +int +dummy_configure () +{ + g_message ("dummy_configure() not implemented. FIXME"); + return 1; +} + +int +dummy_delete_picture (int picNum) +{ + DummyPhoto *p1, *p2; + guint i; + + g_assert (picNum-1 <= dummy.nb_of_images); + g_assert (dummy.nb_of_images > 0); + for (p1 = dummy.images, p2 = NULL, i=1; i < picNum; i++, p2 = p1, p1 = p1->next); + g_assert (p1 != NULL); + + g_free (p1->thumb.data); + g_free (p1->image.data); + if (p2) + p2->next = p1->next; + else + dummy.images = p1->next; + g_free(p1); + dummy.nb_of_images--; + return 1; +} + +char * +dummy_summary() +{ + static gchar *dummy_summary_text = NULL; + + if (dummy_summary_text) + g_free (dummy_summary_text); + dummy_summary_text = g_strdup_printf ("Frames Taken: %lu\n",dummy.nb_of_images); + return dummy_summary_text; +} + +char * +dummy_description () { + return ( +"Fake/Dummy Digital Camera Support +Fabrice Bellet "); +} + +struct _Camera dummy_camera = {dummy_initialize, + dummy_get_picture, + dummy_get_preview, + dummy_delete_picture, + dummy_take_picture, + dummy_number_of_pictures, + dummy_configure, + dummy_summary, + dummy_description}; diff -u --recursive --new-file --exclude-from=/tmp/cvs.exclude gphoto.orig/src/Makefile.am gphoto/src/Makefile.am --- gphoto.orig/src/Makefile.am Sun Sep 10 18:27:29 2000 +++ gphoto/src/Makefile.am Sun Sep 10 18:27:41 2000 @@ -60,7 +60,8 @@ ../samsung/libgphoto_samsung.la \ ../sony/libgphoto_sony_dscf1.la \ ../sony/dscf55/libgphoto_sony_dscf55.la \ - ../directory/libgphoto_dir.la + ../directory/libgphoto_dir.la \ + ../dummy/libgphoto_dummy.la gphoto_LDADD = \ $(gphoto_libs) \ diff -u --recursive --new-file --exclude-from=/tmp/cvs.exclude gphoto.orig/src/cameras.h gphoto/src/cameras.h --- gphoto.orig/src/cameras.h Sun Sep 10 18:21:57 2000 +++ gphoto/src/cameras.h Sun Sep 10 18:27:41 2000 @@ -5,6 +5,7 @@ extern struct _Camera canon; extern struct _Camera casio_qv; extern struct _Camera coolpix600; +extern struct _Camera dummy_camera; extern struct _Camera philips; extern struct _Camera fuji; extern struct _Camera kodak_dc2x; @@ -26,6 +27,7 @@ struct Model cameras[] = { {"Browse Directory", &directory, 0, 0}, + {"Fake/Dummy Camera", &dummy_camera, 0, 0}, {"Agfa ePhoto 307", &olympus, 0, 0}, {"Agfa ePhoto 780", &olympus, 0, 0}, {"Agfa ePhoto 780C", &olympus, 0, 0},