? build ? barbie/.cvsignore ? digita/.cvsignore ? dimera/.cvsignore ? gallery/CSSjimmac/.cvsignore ? jd11/.cvsignore ? polaroid/.cvsignore Index: .cvsignore =================================================================== RCS file: /cvs/gnome/gphoto/.cvsignore,v retrieving revision 1.2.2.1 diff -u -r1.2.2.1 .cvsignore --- .cvsignore 1999/11/21 16:33:37 1.2.2.1 +++ .cvsignore 2000/07/20 22:28:00 @@ -18,3 +18,4 @@ install-sh missing mkinstalldirs +ChangeLog Index: autogen.sh =================================================================== RCS file: /cvs/gnome/gphoto/autogen.sh,v retrieving revision 1.4.2.3 diff -u -r1.4.2.3 autogen.sh --- autogen.sh 2000/06/08 12:36:13 1.4.2.3 +++ autogen.sh 2000/07/20 22:28:00 @@ -1,66 +1,17 @@ #!/bin/sh # Run this to generate all the initial makefiles, etc. -# This was lifted from the Gimp, and adapted slightly by -# Raph Levien . -DIE=0 +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. -PROJECT=gphoto +PKG_NAME="GPhoto" -(autoconf --version) < /dev/null > /dev/null 2>&1 || { - echo - echo "You must have autoconf installed to compile $PROJECT." - echo "Download the appropriate package for your distribution," - echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" - DIE=1 -} - -(libtool --version) < /dev/null > /dev/null 2>&1 || { - echo - echo "You must have libtool installed to compile $PROJECT." - echo "Get ftp://ftp.gnu.org/pub/gnu/libtool-1.2.tar.gz" - echo "(or a newer version if it is available)" - DIE=1 -} - -(automake --version) < /dev/null > /dev/null 2>&1 || { - echo - echo "You must have automake installed to compile $PROJECT." - echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.3.tar.gz" - echo "(or a newer version if it is available)" - DIE=1 -} - -if test "$DIE" -eq 1; then +(test -f $srcdir/configure.in \ + && test -f $srcdir/HACKING \ + && test -d $srcdir/photopc) || { + echo -n "**Error**: Directory "\`$srcdir\'" does not look like the" + echo " top-level GPhoto directory" exit 1 -fi - -test -f PROGRAMMERS || { - echo "You must run this script in the top-level gphoto directory" - exit 1 } - -if test -z "$*"; then - echo "I am going to run ./configure with no arguments - if you wish " - echo "to pass any to it, please specify them on the $0 command line." -fi - - -case $CC in -*xlc | *xlc\ * | *lcc | *lcc\ *) am_opt=--include-deps;; -esac - -for dir in . -do - echo processing $dir - (cd $dir; \ - libtoolize --copy --force; \ - aclocalinclude="$ACLOCAL_FLAGS"; \ - aclocal $aclocalinclude; \ - autoheader; automake --add-missing --gnu $am_opt; autoconf) -done - -./configure "$@" -echo -echo "Now type 'make' to compile $PROJECT." +. $srcdir/macros/autogen.sh Index: photopc/eph_cmd.c =================================================================== RCS file: /cvs/gnome/gphoto/photopc/eph_cmd.c,v retrieving revision 1.2.2.1 diff -u -r1.2.2.1 eph_cmd.c --- photopc/eph_cmd.c 2000/07/05 11:07:49 1.2.2.1 +++ photopc/eph_cmd.c 2000/07/20 22:28:00 @@ -79,6 +79,7 @@ #include "config.h" #endif #include +#include #include "eph_io.h" #include "eph_priv.h" @@ -258,7 +259,7 @@ putpoint=buf; maywrite=sizeof(buf); pktsize=0; - (iob->runcb)(written); + (iob->runcb)(written,0); } if (length <= maywrite) { maywrite=length; @@ -295,6 +296,7 @@ char *ptr; char *tmpbuf=NULL; size_t tmpbufsize=0; + off_t total = *bufsize; if ((buffer == NULL) && (iob->storecb == NULL)) { eph_error(iob,ERR_BADARGS, @@ -361,7 +363,7 @@ if (pkt.seq == expect) { index+=readsize; expect++; - (iob->runcb)(index); + (iob->runcb)(index,total); if (buffer == NULL) { if (iob->debug) printf("storing %lu at %08lx\n", Index: photopc/eph_io.c =================================================================== RCS file: /cvs/gnome/gphoto/photopc/eph_io.c,v retrieving revision 1.2.2.2 diff -u -r1.2.2.2 eph_io.c --- photopc/eph_io.c 2000/07/09 21:40:14 1.2.2.2 +++ photopc/eph_io.c 2000/07/20 22:28:02 @@ -368,10 +368,10 @@ uint16 usb_read; unsigned char usbbuf[256]; unsigned char *buffer_ptr; + unsigned char *buffer_ext; uint16 buffer_remaining; uint16 buffer_read; - buffer_ptr=buffer; buffer_read=0; usb_read=olympus_usb_read (gpdev,usbbuf,usbbuf_size); if (usb_read<4) { @@ -396,16 +396,32 @@ (unsigned long)length,(unsigned long)*bufsize); return -1; } + length+=2; /* frame length + 2bytes crc */ + buffer_ext = (iob->realloccb)(NULL,(size_t)length); + buffer_ptr = buffer_ext; + if (buffer_ext==0) { + eph_error(iob,ERR_DATA_TOO_LONG, + "could not malloc() %lu bytes",(unsigned long)length); + return -1; + } buffer_read=MIN (length,usb_read-4); memcpy (buffer_ptr,usbbuf+4,buffer_read); + for (i=0; i= 2. + */ + crc2=(buffer_ext[length-1]<<8)|buffer_ext[length-2]; + crc1-=buffer_ext[length-1]; + crc1-=buffer_ext[length-2]; + if (iob->debug) { + printf ("crc1=0x%04x\n",crc1); + printf ("crc2=0x%04x\n\n",crc2); + } + if (crc1 != crc2) { + if (iob->debug) + printf("crc %04x != %04x\n",crc1,crc2); + eph_error(iob,ERR_BADCRC, + "crc received=0x%04x counted=0x%04x", + crc2,crc1); + return -1; + } + /* + * copy the data to the buffer passed as argument, and + * exclude the final checksum + */ + memcpy (buffer,buffer_ext,length-2); + free (buffer_ext); + (*bufsize)=length-2; return 0; - } - - i=eph_readt(iob,buf,1,timeout_usec,&rc); - if (iob->debug > 1) - printf ("pktstart: i=%d rc=%d char=0x%02x\n",i,rc,*buf); - if (i < 0) { - eph_error(iob,ERRNO,"pkt start read error %s",strerror(ERRNO)); - return -1; - } else if ((i == 0) && (rc == 0)) { - eph_error(iob,ERR_TIMEOUT,"pkt start read timeout (%ld)", - timeout_usec); - return -2; - } else if (i != 1) { - eph_error(iob,ERR_BADREAD,"pkt start read %d, expected 1",i); - return -1; - } - pkthdr->typ=buf[0]; - if ((*buf != PKT_DATA) && (*buf != PKT_LAST)) { - if ((*buf != NAK) && (*buf != DC1)) - eph_error(iob,ERR_BADDATA,"pkt start got 0x%02x",*buf); - return *buf; - } - got=0; - while ((i=eph_readt(iob,buf+1+got,3-got,DATATIMEOUT,&rc)) > 0) { - got+=i; - } - if (got != 3) { - if (i < 0) { - eph_error(iob,ERRNO,"pkt hdr read error %s (got %d)", - strerror(ERRNO),got); - return -1; - } else if ((i == 0) && (rc == 0)) { - eph_error(iob,ERR_TIMEOUT,"pkt hdr read timeout (%ld)", - DATATIMEOUT); - return -2; - } else { - eph_error(iob,ERR_BADREAD,"pkt hdr read return %d rc %d", - i,rc); - return -1; - } - } - if (iob->debug > 1) printf("header: %02x %02x %02x %02x\n", - buf[0],buf[1],buf[2],buf[3]); - pkthdr->seq=buf[1]; - length=(buf[3]<<8)|buf[2]; - if (length > *bufsize) { - eph_error(iob,ERR_DATA_TOO_LONG, - "length in pkt header %lu bigger than buffer size %lu", - (unsigned long)length,(unsigned long)*bufsize); - return -1; - } - - got=0; - while ((i=eph_readt(iob,buffer+got,length-got,iob->timeout,&rc)) > 0) { - got+=i; - } - if (got != length) { + } else { + i=eph_readt(iob,buf,1,timeout_usec,&rc); + if (iob->debug > 1) + printf ("pktstart: i=%d rc=%d char=0x%02x\n",i,rc,*buf); if (i < 0) { - eph_error(iob,ERRNO,"pkt data read error %s",strerror(ERRNO)); + eph_error(iob,ERRNO, + "pkt start read error %s",strerror(ERRNO)); return -1; } else if ((i == 0) && (rc == 0)) { - eph_error(iob,ERR_TIMEOUT,"pkt data read timeout (%ld)", - iob->timeout); + eph_error(iob,ERR_TIMEOUT, + "pkt start read timeout (%ld)",timeout_usec); return -2; - } else { + } else if (i != 1) { eph_error(iob,ERR_BADREAD, - "pkt read return %d, rc %d",i,rc); + "pkt start read %d, expected 1",i); return -1; } - } - - for (i=0;i 0) { - got+=i; - } - if (iob->debug > 1) - printf ("crc: %02x %02x i=%d rc=%d\n",buf[0],buf[1],i,rc); - if (got != 2) { - if (i < 0) { - eph_error(iob,ERRNO,"pkt crc read error %s",strerror(ERRNO)); - return -1; - } else if ((i == 0) && (rc == 0)) { - eph_error(iob,ERR_TIMEOUT,"pkt crc read timeout (%ld)", - DATATIMEOUT); - return -2; - } else { - eph_error(iob,ERR_BADREAD,"pkt crc read return %d rc %d", - i,rc); - return -1; - } - } - - crc2=(buf[1]<<8)|buf[0]; - if (crc1 != crc2) { - if (iob->debug) printf("crc %04x != %04x\n",crc1,crc2); - eph_error(iob,ERR_BADCRC, - "crc received=0x%04x counted=0x%04x",crc2,crc1); - return -1; - } - if (iob->debug > 1) { - int j; - - printf("< %d,%d (%d)",pkthdr->typ,pkthdr->seq,length); - if (iob->debug > 2) for (j=0;jtyp,pkthdr->seq,length); - if (iob->debug > 2) for (j=0;j= ' ' && buffer[j] < 127) + pkthdr->typ=buf[0]; + if ((*buf != PKT_DATA) && (*buf != PKT_LAST)) { + if ((*buf != NAK) && (*buf != DC1)) + eph_error(iob,ERR_BADDATA, + "pkt start got 0x%02x",*buf); + return *buf; + } + got=0; + while ((i=eph_readt(iob,buf+1+got,3-got,DATATIMEOUT,&rc)) > 0) + got+=i; + if (got != 3) { + if (i < 0) { + eph_error(iob,ERRNO, + "pkt hdr read error %s (got %d)", + strerror(ERRNO),got); + return -1; + } else if ((i == 0) && (rc == 0)) { + eph_error(iob,ERR_TIMEOUT, + "pkt hdr read timeout (%ld)", + DATATIMEOUT); + return -2; + } else { + eph_error(iob,ERR_BADREAD, + "pkt hdr read return %d rc %d", + i,rc); + return -1; + } + } + if (iob->debug > 1) + printf("header: %02x %02x %02x %02x\n", + buf[0],buf[1],buf[2],buf[3]); + pkthdr->seq=buf[1]; + length=(buf[3]<<8)|buf[2]; + if (length > *bufsize) { + eph_error(iob,ERR_DATA_TOO_LONG, + "length in pkt header %lu " + "bigger than buffer size %lu", + (unsigned long)length, + (unsigned long)*bufsize); + return -1; + } + + got=0; + while ((i=eph_readt(iob,buffer+got, + length-got,iob->timeout,&rc)) > 0) + got+=i; + if (got != length) { + if (i < 0) { + eph_error(iob,ERRNO, + "pkt data read error %s", + strerror(ERRNO)); + return -1; + } else if ((i == 0) && (rc == 0)) { + eph_error(iob,ERR_TIMEOUT, + "pkt data read timeout (%ld)", + iob->timeout); + return -2; + } else { + eph_error(iob,ERR_BADREAD, + "pkt read return %d, rc %d",i,rc); + return -1; + } + } + + for (i=0;i 0) + got+=i; + if (iob->debug > 1) + printf ("crc: %02x %02x i=%d rc=%d\n", + buf[0],buf[1],i,rc); + if (got != 2) { + if (i < 0) { + eph_error(iob,ERRNO, + "pkt crc read error %s", + strerror(ERRNO)); + return -1; + } else if ((i == 0) && (rc == 0)) { + eph_error(iob,ERR_TIMEOUT, + "pkt crc read timeout (%ld)", + DATATIMEOUT); + return -2; + } else { + eph_error(iob,ERR_BADREAD, + "pkt crc read return %d rc %d", + i,rc); + return -1; + } + } + + crc2=(buf[1]<<8)|buf[0]; + if (crc1 != crc2) { + if (iob->debug) + printf("crc %04x != %04x\n",crc1,crc2); + eph_error(iob,ERR_BADCRC, + "crc received=0x%04x counted=0x%04x", + crc2,crc1); + return -1; + } + if (iob->debug > 1) { + int j; + + printf("< %d,%d (%d)",pkthdr->typ,pkthdr->seq,length); + if (iob->debug > 2) + for (j=0;jtyp,pkthdr->seq,length); + if (iob->debug > 2) + for (j=0;j= ' ' + && buffer[j] < 127) ? buffer[j] : '.'); - } else printf(" ..."); - printf("\n"); + } else + printf(" ..."); + printf("\n"); + } + (*bufsize)=length; + return 0; } - (*bufsize)=length; - return 0; } int Index: photopc/eph_io.h =================================================================== RCS file: /cvs/gnome/gphoto/photopc/eph_io.h,v retrieving revision 1.1.1.1.2.1 diff -u -r1.1.1.1.2.1 eph_io.h --- photopc/eph_io.h 2000/07/05 11:07:49 1.1.1.1.2.1 +++ photopc/eph_io.h 2000/07/20 22:28:02 @@ -95,7 +95,7 @@ typedef struct _eph_iob { void (*errorcb)(int errcode,char *errstr); void *(*realloccb)(void *old,size_t length); - void (*runcb)(off_t count); + void (*runcb)(off_t count, off_t total); int (*storecb)(char *data,size_t size); int debug; #if defined(UNIX) @@ -119,7 +119,7 @@ eph_iob *eph_new(void (*errorcb)(int errcode,char *errstr), void *(*realloccb)(void *old,size_t length), - void (*runcb)(off_t count), + void (*runcb)(off_t count, off_t total), int (*storecb)(char *data,size_t size), int debug); int eph_open(eph_iob *iob,char *device_name,long speed, Index: photopc/eph_iob.c =================================================================== RCS file: /cvs/gnome/gphoto/photopc/eph_iob.c,v retrieving revision 1.1.1.1.2.1 diff -u -r1.1.1.1.2.1 eph_iob.c --- photopc/eph_iob.c 2000/07/05 11:07:49 1.1.1.1.2.1 +++ photopc/eph_iob.c 2000/07/20 22:28:02 @@ -78,7 +78,7 @@ } static void -defruncb(off_t count) +defruncb(off_t count, off_t total) { return; } @@ -86,7 +86,7 @@ eph_iob * eph_new(void (*errorcb)(int errcode,char *errstr), void *(*realloccb)(void *old,size_t length), - void (*runcb)(off_t count), + void (*runcb)(off_t count, off_t total), int (*storecb)(char *data,size_t size), int debug) { Index: photopc/olympus.c =================================================================== RCS file: /cvs/gnome/gphoto/photopc/olympus.c,v retrieving revision 1.5.2.1 diff -u -r1.5.2.1 olympus.c --- photopc/olympus.c 2000/07/05 11:07:49 1.5.2.1 +++ photopc/olympus.c 2000/07/20 22:28:02 @@ -19,9 +19,21 @@ eph_iob *iob; /* Olympus/photoPC io-buffer */ struct olympus_device *gpdev; -int oly_initialize () { +extern float progress_min; +extern float progress_max; + +static void +oly_update_progress (off_t count, off_t total) +{ + float percent = (float)count/(float)total; + if (total) + update_progress (progress_min+percent*(progress_max-progress_min)); +} - iob = eph_new(NULL, NULL, NULL, NULL, 0); +int +oly_initialize () { + + iob = eph_new(NULL, NULL, oly_update_progress, NULL, 0); return 1; } @@ -32,7 +44,8 @@ * for the context. Cameras not supporting folders should not * reach this code, but should still work if they do. -mid */ -static int xchdir(eph_iob *iob,char *where, int have_folders) +static int +xchdir(eph_iob *iob,char *where, int have_folders) { char path[MAXPATH],*p; @@ -57,7 +70,8 @@ return 0; } -static int descend(eph_iob *iob,int depth,char *root,int(*each)(eph_iob *iob,char *path), int have_folders) +static int +descend(eph_iob *iob,int depth,char *root,int(*each)(eph_iob *iob,char *path), int have_folders) { long nfolders=0L,i; off_t f_size; @@ -125,7 +139,8 @@ } else return 0; } -int oly_init2(eph_iob *iob) +int +oly_init2(eph_iob *iob) { long ret; int rc; @@ -142,7 +157,9 @@ return 0; } -int oly_open_camera () { +int +oly_open_camera () +{ /* Open the camera for reading/writing */ @@ -154,19 +171,21 @@ gpdev = olympus_usb_open(); if (!gpdev) - return (0); + return 0; info_size=16; info=malloc(info_size); } else { if (eph_open(iob, serial_port, 115200, 0, 0) == -1) - return (0); + return 0; } oly_init2(iob); - return (1); + return 1; } -void oly_close_camera() { +void +oly_close_camera() +{ /* Close the camera */ @@ -176,7 +195,9 @@ eph_close(iob, 0); } -int oly_number_of_pictures () { +int +oly_number_of_pictures () +{ long num_pictures_taken = 0; @@ -190,7 +211,9 @@ return ((int)num_pictures_taken); } -int oly_take_picture () { +int +oly_take_picture () +{ char zero = 0; @@ -203,7 +226,9 @@ return (oly_number_of_pictures()); } -struct Image *oly_get_picture (int picNum, int thumbnail) { +struct Image * +oly_get_picture (int picNum, int thumbnail) +{ /* Reads image #picNum the Olympus camera. @@ -255,20 +280,26 @@ strcpy(im->image_type, "jpg"); oly_close_camera(); - update_progress(0); return (im); } -struct Image *oly_get_preview () { +struct Image * +oly_get_preview () +{ - char zero = '0'; + char zero = 0; - oly_open_camera(); + if (oly_open_camera() == 0) { + error_dialog("Could not open camera."); + return NULL; + } eph_action(iob,5,&zero,1); return (oly_get_picture(0, 0)); } -int oly_configure () { +int +oly_configure () +{ /* Shows the Olympus config dialog @@ -277,6 +308,8 @@ char *info, *camID; off_t info_size = 2048; time_t camtime; + time_t gmttime; + struct tm *loctime; char *atime; long value; @@ -526,8 +559,8 @@ eph_getint(iob,2,&camtime); update_progress(1.0); - atime = ctime(&camtime); - label = gtk_label_new(atime); + atime = asctime(gmtime(&camtime)); + label = gtk_label_new(atime); gtk_widget_show(label); gtk_table_attach_defaults(GTK_TABLE(table),label,3,5,11,12); @@ -639,9 +672,17 @@ /* Set the clock... */ if (GTK_WIDGET_STATE(Config.clk_comp) == GTK_STATE_ACTIVE) { - camtime = time(&camtime); - eph_setint(iob,2,camtime); - sleep(1); + gmttime = time(NULL); + loctime = localtime(&gmttime); + + /* + * Let's get the Seconds east of UTC + */ +#ifdef __USE_BSD + eph_setint(iob,2,gmttime+loctime->tm_gmtoff); +#else + eph_setint(iob,2,gmttime+loctime->__tm_gmtoff); +#endif } update_progress(1.00); oly_close_camera(); @@ -651,7 +692,9 @@ return 1; } -int oly_delete_image (int picNum) { +int +oly_delete_image (int picNum) +{ /* deletes image #picNum from the Olympus camera. @@ -672,7 +715,9 @@ char oly_summary_text[1024]; -char *oly_summary() { +char * +oly_summary() +{ unsigned long l; char *s; Index: photopc/photopc-usb.c =================================================================== RCS file: /cvs/gnome/gphoto/photopc/Attic/photopc-usb.c,v retrieving revision 1.1.2.2 diff -u -r1.1.2.2 photopc-usb.c --- photopc/photopc-usb.c 2000/07/09 21:40:14 1.1.2.2 +++ photopc/photopc-usb.c 2000/07/20 22:28:02 @@ -20,7 +20,10 @@ int olympus_usb_read(struct olympus_device *dev, void *buffer, int len) { #ifdef GPIO_USB - return gpio_read(dev->gpdev, buffer, len); + if (dev) + return gpio_read(dev->gpdev, buffer, len); + else + return GPIO_ERROR; #else return GPIO_ERROR; #endif @@ -29,7 +32,10 @@ int olympus_usb_send(struct olympus_device *dev, void *buffer, int len) { #ifdef GPIO_USB - return gpio_write(dev->gpdev, buffer, len); + if (dev) + return gpio_write(dev->gpdev, buffer, len); + else + return GPIO_ERROR; #else return GPIO_ERROR; #endif @@ -80,7 +86,7 @@ settings.usb.altsetting = 0; gpio_set_settings(dev->gpdev, settings); - gpio_set_timeout(dev->gpdev, 50000); + gpio_set_timeout(dev->gpdev, 5000); if (gpio_open(dev->gpdev) < 0) { fprintf(stderr, "error opening device\n"); return NULL; @@ -95,15 +101,20 @@ void olympus_usb_close (struct olympus_device *dev) { #ifdef GPIO_USB - gpio_close (dev->gpdev); - gpio_free (dev->gpdev); - free (dev); + if (dev) { + gpio_close (dev->gpdev); + gpio_free (dev->gpdev); + free (dev); + } #endif } void olympus_usb_reset (struct olympus_device *dev) { #ifdef GPIO_USB - gpio_usb_clear_halt (dev->gpdev); + if (dev) + gpio_clear_halt (dev->gpdev, GPIO_USB_IN_ENDPOINT); + else + return GPIO_ERROR; #endif } Index: sony/dscf55/Makefile.am =================================================================== RCS file: /cvs/gnome/gphoto/sony/dscf55/Makefile.am,v retrieving revision 1.1.2.2 diff -u -r1.1.2.2 Makefile.am --- sony/dscf55/Makefile.am 2000/06/08 12:25:43 1.1.2.2 +++ sony/dscf55/Makefile.am 2000/07/20 22:28:02 @@ -7,8 +7,8 @@ rsony_SOURCES = rsony_LDADD = srsony.o config.o serio.o -srsony.o : rsony.c serio.o config.o serio.h - $(COMPILE) -DSTAND_ALONE -o srsony.o -c rsony.c +srsony.o : ${srcdir}/rsony.c serio.o config.o serio.h + $(COMPILE) -DSTAND_ALONE -o srsony.o -c ${srcdir}/rsony.c ## rsony_SOURCES = rmain.c rsony.c config.c serio.c serio.h @@ -18,4 +18,4 @@ libgphoto_sony_dscf55_la_LDFLAGS = -version-info 0:0:0 -EXTRA_DIST = serio.h rsony.c serio.c config.c config.h \ No newline at end of file +EXTRA_DIST = serio.h rsony.c serio.c config.c config.h Index: src/callbacks.c =================================================================== RCS file: /cvs/gnome/gphoto/src/callbacks.c,v retrieving revision 1.51.2.23 diff -u -r1.51.2.23 callbacks.c --- src/callbacks.c 2000/07/06 18:08:15 1.51.2.23 +++ src/callbacks.c 2000/07/20 22:28:02 @@ -57,6 +57,10 @@ extern char *filesel_cwd; +extern float progress_min; +extern float progress_max; +extern int cam_busy; + /* Search the image_info tags for "name", return its value (string) */ char *find_tag(struct Image *im, char *name) { @@ -90,6 +94,7 @@ void set_camera(char *model) { int i; + int ret; for (i = 0; cameras[i].name; i++) { if (strcmp(model, cameras[i].name)) @@ -103,14 +108,29 @@ Camera = &cameras[i]; - if (Camera->ops->initialize() != 0) + if (cam_busy) { + error_dialog("Camera is already busy"); return; + } + cam_busy=1; + ret=Camera->ops->initialize(); + cam_busy=0; + if (ret) return; } } void configure_call(void) { - if (Camera->ops->configure() == 0) + int ret; + + if (cam_busy) { + error_dialog("Camera is already busy"); + return; + } + cam_busy=1; + ret=Camera->ops->configure(); + cam_busy=0; + if (ret == 0) error_dialog("No configuration options."); } @@ -126,14 +146,20 @@ update_status("Taking picture..."); + if (cam_busy) { + error_dialog("Camera is already busy"); + return; + } + cam_busy=1; picNum = Camera->ops->take_picture(); + cam_busy=0; if (!picNum) { error_dialog("Could not take a picture."); return; } - appendpic(picNum, 0, TRUE, NULL); + appendpic(picNum, 0, TRUE, NULL, 100); sprintf(status, "New picture is #%03i", picNum); gtk_notebook_set_page(GTK_NOTEBOOK(notebook), picNum); update_status(status); @@ -144,6 +170,11 @@ gint current, no_pics, i; char error[32]; + if (cam_busy) { + error_dialog("Camera is already busy"); + return; + } + cam_busy=1; no_pics = Camera->ops->number_of_pictures(); i = no_pics; @@ -166,6 +197,7 @@ update_status("Deleted all images."); update_progress(0); gtk_widget_destroy(dialog); + cam_busy=0; } void del_pics(GtkWidget *dialog, GtkObject *button) @@ -174,6 +206,11 @@ char error[32]; struct ImageMembers *node = &Thumbnails; + if (cam_busy) { + error_dialog("Camera is already busy"); + return; + } + cam_busy=1; gtk_widget_hide(dialog); update_status("Deleting selected pictures..."); @@ -196,6 +233,7 @@ } gtk_widget_destroy(dialog); update_status("Done."); + cam_busy=0; } void del_dialog(int type) @@ -282,7 +320,14 @@ } } - if ((im = Camera->ops->get_picture(picNum, thumbnail)) == 0) { + if (cam_busy) { + error_dialog("Camera is already busy"); + return; + } + cam_busy=1; + im = Camera->ops->get_picture(picNum, thumbnail); + cam_busy=0; + if (im == 0) { sprintf(error, "Could not save #%i", picNum); error_dialog(error); return; @@ -383,13 +428,14 @@ update_status(fname); } -void appendpic(gint picNum, gint thumbnail, gint fromCamera, char *fileName) +void appendpic(gint picNum, gint thumbnail, gint fromCamera, char *fileName, int factor) { int w, h; char fname[15], error[32], process[1024], imagename[1024],*openName; GtkWidget *scrwin, *label; + GdkImlibImage *scaledImage; GdkPixmap *pixmap; struct Image *im; @@ -410,7 +456,14 @@ node->next = NULL; if (fromCamera) { - if ((im = Camera->ops->get_picture(picNum, thumbnail))==0) { + if (cam_busy) { + error_dialog("Camera is already busy"); + return; + } + cam_busy=1; + im = Camera->ops->get_picture(picNum, thumbnail); + cam_busy=0; + if (im == 0) { sprintf(error, "Could not retrieve #%i", picNum); error_dialog(error); return; @@ -432,8 +485,29 @@ } else node->imlibimage = gdk_imlib_load_image(fileName); + if (node->imlibimage==0) { + sprintf(error, "Could not load image #%i to memory", picNum); + error_dialog(error); + return; + } w = node->imlibimage->rgb_width; h = node->imlibimage->rgb_height; + + w = (w * factor)/100; + h = (h * factor)/100; + + scaledImage = gdk_imlib_clone_scaled_image(node->imlibimage,w,h); + gdk_imlib_kill_image(node->imlibimage); + + if (scaledImage==0) { + sprintf(error, "Could not load image #%i to memory", picNum); + error_dialog(error); + return; + } + node->imlibimage = scaledImage; + w = node->imlibimage->rgb_width; + h = node->imlibimage->rgb_height; + gdk_imlib_render(node->imlibimage, w, h); pixmap = gdk_imlib_move_image(node->imlibimage); node->image = gtk_pixmap_new(pixmap, NULL); @@ -1097,14 +1171,21 @@ /* If the thumbnail is already there, then just load the image */ if (node->image && node->imlibimage) { - appendpic(i, 0, TRUE, NULL); + appendpic(i, 0, TRUE, NULL, 100); return; } sprintf(status, "Getting thumbnail %i...", i); update_status(status); - if ((im = Camera->ops->get_picture(i, 1))==0) { + if (cam_busy) { + error_dialog("Camera is already busy"); + return; + } + cam_busy=1; + im = Camera->ops->get_picture(i, 1); + cam_busy=0; + if (im==0) { sprintf(error, "Could not retrieve #%i", i); error_dialog(error); return; @@ -1123,6 +1204,11 @@ node->imlibimage = gdk_imlib_load_image_mem(im->image, im->image_size); free_image (im); + if (node->imlibimage==0) { + sprintf(error, "Could not load image #%i to memory", i); + error_dialog(error); + return; + } w = node->imlibimage->rgb_width; h = node->imlibimage->rgb_height; @@ -1203,8 +1289,14 @@ gtk_widget_show(index_table); gtk_container_add(GTK_CONTAINER(index_vp), index_table); + if (cam_busy) { + error_dialog("Camera is already busy"); + return; + } + cam_busy=1; num_pictures_taken = Camera->ops->number_of_pictures(); -fprintf(stderr, "num_pictures_taken is %d\n", num_pictures_taken); + cam_busy=0; + fprintf(stderr, "num_pictures_taken is %d\n", num_pictures_taken); if (num_pictures_taken == -1) { error_dialog("Could not get the number of pictures"); return; @@ -1259,6 +1351,8 @@ node->image=NULL; node->imlibimage=NULL; + progress_min=(float)i/(float)num_pictures_taken; + progress_max=(float)(i+1)/(float)num_pictures_taken; if (getthumbs) insert_thumbnail(node); @@ -1271,7 +1365,7 @@ node->button, i%6,i%6+1,i/6,i/6+1, GTK_FILL,GTK_FILL,5,5); - update_progress((float)i/(float)(num_pictures_taken - 1)); + update_progress(progress_max); } deactivate_button(stop_button); update_progress(0); @@ -1298,6 +1392,12 @@ /* get selected pictures */ void getpics(char *pictype) { + getpics_with_scale (pictype, 100); +} + +/* get selected pictures at a given scale */ +void getpics_with_scale(char *pictype, int factor) +{ char status[256]; gint i=0; gint x=0, y=0; @@ -1322,23 +1422,25 @@ node = node->next; i++; if (GTK_TOGGLE_BUTTON(node->button)->active) { + progress_min=(float)y/(float)x; + progress_max=(float)(y+1)/(float)x; y++; if ((strcmp("i", pictype) == 0) || (strcmp("ti", pictype) == 0)) { sprintf(status, "Getting Image #%03i...", i); update_status(status); - appendpic(i, 0, TRUE, NULL); + appendpic(i, 0, TRUE, NULL, factor); } if ((strcmp("t", pictype) == 0) || (strcmp("ti", pictype) == 0)) { - appendpic(i, 1, TRUE, NULL); + appendpic(i, 1, TRUE, NULL, factor); sprintf(status, "Getting Thumbnail #%03i...", i); update_status(status); } gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(node->button), FALSE); - update_progress((float)y/(float)x); + update_progress(progress_max); } } @@ -1484,7 +1586,7 @@ return; appendpic(0, 0, FALSE, gtk_file_selection_get_filename( - GTK_FILE_SELECTION(filew))); + GTK_FILE_SELECTION(filew)), 100); gtk_widget_destroy(filew); } @@ -1826,7 +1928,14 @@ void summary_dialog(void) { - message_window("Camera Summary", Camera->ops->summary(), GTK_JUSTIFY_FILL); + if (cam_busy) { + error_dialog("Camera is already busy"); + return; + } + cam_busy=1; + message_window("Camera Summary", + Camera->ops->summary(), GTK_JUSTIFY_FILL); + cam_busy=0; } /* Decreases image size by factor n % */ @@ -1903,8 +2012,18 @@ } void open_images(gpointer data, guint action, GtkWidget *widget) +{ + getpics_with_scale("i",100); +} + +void open_images_and_scale50(gpointer data, guint action, GtkWidget *widget) +{ + getpics_with_scale("i",50); +} + +void open_images_and_scale25(gpointer data, guint action, GtkWidget *widget) { - getpics("i"); + getpics_with_scale("i",25); } void save_thumbs(gpointer data, guint action, GtkWidget *widget) @@ -1914,7 +2033,7 @@ void open_thumbs(gpointer data, guint action, GtkWidget *widget) { - getpics("t"); + getpics_with_scale("t",100); } void save_both (gpointer data, guint action, GtkWidget *widget) @@ -1925,7 +2044,7 @@ void open_both(gpointer data, guint action, GtkWidget *widget) { - getpics("ti"); + getpics_with_scale("ti",100); } Index: src/callbacks.h =================================================================== RCS file: /cvs/gnome/gphoto/src/callbacks.h,v retrieving revision 1.12.2.6 diff -u -r1.12.2.6 callbacks.h --- src/callbacks.h 1999/11/21 16:33:39 1.12.2.6 +++ src/callbacks.h 2000/07/20 22:28:02 @@ -16,7 +16,7 @@ void del_dialog (int type); void savepictodisk (int picNum, int thumbnail, char *prefix); void saveselectedtodisk (GtkWidget *widget, char *type); -void appendpic (int picNum, int thumbnail, int fromCamera, char *fileName); +void appendpic (int picNum, int thumbnail, int fromCamera, char *fileName, int factor); void destroy (GtkWidget *widget, gpointer data); void port_dialog(); void version_dialog(); @@ -32,6 +32,7 @@ void getindex_empty (); void halt_action (); void getpics (char *type); +void getpics_with_scale (char *type, int factor); void remove_image(int i); void closepic (); void print_pic (); @@ -47,6 +48,8 @@ void scale_double (); void save_images (gpointer data, guint action, GtkWidget *widget); void open_images (gpointer data, guint action, GtkWidget *widget); +void open_images_and_scale25 (gpointer data, guint action, GtkWidget *widget); +void open_images_and_scale50 (gpointer data, guint action, GtkWidget *widget); void save_thumbs (gpointer data, guint action, GtkWidget *widget); void open_thumbs (gpointer data, guint action, GtkWidget *widget); void save_both (gpointer data, guint action, GtkWidget *widget); Index: src/commandline.c =================================================================== RCS file: /cvs/gnome/gphoto/src/commandline.c,v retrieving revision 1.8.2.4 diff -u -r1.8.2.4 commandline.c --- src/commandline.c 2000/02/24 19:50:24 1.8.2.4 +++ src/commandline.c 2000/07/20 22:28:02 @@ -1,4 +1,5 @@ +#include #include #include Index: src/gallery.c =================================================================== RCS file: /cvs/gnome/gphoto/src/gallery.c,v retrieving revision 1.18.2.7 diff -u -r1.18.2.7 gallery.c --- src/gallery.c 2000/07/06 18:08:15 1.18.2.7 +++ src/gallery.c 2000/07/20 22:28:03 @@ -211,6 +211,8 @@ extern struct Model *Camera; extern char *filesel_cwd; +extern int cam_busy; + /* initialize some tags */ char gallery_name[256]; char gallery_index[128]; @@ -675,7 +677,16 @@ /* Get the current thumbnail */ sprintf(cp, "Getting Thumbnail #%i...", j+1); update_status(cp); - if ((im = Camera->ops->get_picture(j+1, 1))==0) { + if (cam_busy) { + error_dialog("Camera is already busy"); + if (GTK_IS_OBJECT(dialog)) + gtk_widget_destroy(dialog); + return; + } + cam_busy=1; + im = Camera->ops->get_picture(j+1, 1); + cam_busy=0; + if (im==0) { sprintf(error, "Could not retrieve #%i", j+1); error_dialog(error); @@ -706,7 +717,16 @@ sprintf(cp, "Getting Image #%i...", j+1); update_status(cp); - if ((im = Camera->ops->get_picture(j+1, 0))==0) { + if (cam_busy) { + error_dialog("Camera is already busy"); + if (GTK_IS_OBJECT(dialog)) + gtk_widget_destroy(dialog); + return; + } + cam_busy=1; + im = Camera->ops->get_picture(j+1, 0); + cam_busy=0; + if (im==0) { sprintf(error, "Could not retrieve #%i", j+1); error_dialog(error); sprintf(picture, "Not Available"); Index: src/live.c =================================================================== RCS file: /cvs/gnome/gphoto/src/live.c,v retrieving revision 1.4.2.2 diff -u -r1.4.2.2 live.c --- src/live.c 2000/07/06 18:08:15 1.4.2.2 +++ src/live.c 2000/07/20 22:28:04 @@ -10,6 +10,7 @@ */ extern struct Model *Camera; +extern int cam_busy; int live_video_mode = 0; @@ -22,22 +23,32 @@ struct Image *im; GList *child = gtk_container_children( - GTK_CONTAINER(GTK_DIALOG(dialog)->vbox)); + GTK_CONTAINER(GTK_DIALOG(dialog)->vbox)); GtkWidget *gpixmap = GTK_WIDGET(child->data); + if (cam_busy) { + error_dialog("Camera is already busy"); + return; + } update_status("Getting live image..."); + cam_busy=1; if ((im = Camera->ops->get_preview()) == 0) { error_dialog("Could not get preview"); return; } - imlibimage = gdk_imlib_load_image_mem(im->image, im->image_size); - free_image(im); - w = imlibimage->rgb_width; - h = imlibimage->rgb_height; - gdk_imlib_render(imlibimage, w, h); - pixmap = gdk_imlib_move_image(imlibimage); - gtk_pixmap_set(GTK_PIXMAP(gpixmap), pixmap, NULL); - update_status("Done."); + cam_busy=0; + if (im) { + imlibimage = gdk_imlib_load_image_mem(im->image, im->image_size); + free_image(im); + if (imlibimage) { + w = imlibimage->rgb_width; + h = imlibimage->rgb_height; + gdk_imlib_render(imlibimage, w, h); + pixmap = gdk_imlib_move_image(imlibimage); + gtk_pixmap_set(GTK_PIXMAP(gpixmap), pixmap, NULL); + update_status("Done."); + } + } } void live_video (GtkWidget *button, GtkWidget *dialog) { @@ -50,10 +61,16 @@ while (live_video_mode) { while (gtk_events_pending()) gtk_main_iteration(); - live_snapshot(dialog); + if (live_video_mode) + live_snapshot(dialog); } } +void live_close (GtkWidget *dialog) { + live_video_mode = 0; + gtk_widget_destroy (dialog); +} + void live_main () { int w, h; @@ -65,6 +82,10 @@ GdkImlibImage *imlibimage; struct Image *im; + if (cam_busy) { + error_dialog("Camera is already busy"); + return; + } update_status("Getting live image..."); dialog = gtk_dialog_new(); gtk_window_set_title(GTK_WINDOW(dialog), "Live Camera!"); @@ -103,12 +124,14 @@ cbutton); gtk_signal_connect_object(GTK_OBJECT(cbutton), "clicked", - GTK_SIGNAL_FUNC(gtk_widget_destroy), + GTK_SIGNAL_FUNC(live_close), GTK_OBJECT(dialog)); + cam_busy=1; if ((im = Camera->ops->get_preview()) == 0) { error_dialog("Could not get preview"); return; } + cam_busy=0; imlibimage = gdk_imlib_load_image_mem(im->image, im->image_size); free(im->image); free(im); Index: src/main.c =================================================================== RCS file: /cvs/gnome/gphoto/src/main.c,v retrieving revision 1.22.2.11 diff -u -r1.22.2.11 main.c --- src/main.c 2000/07/09 21:40:15 1.22.2.11 +++ src/main.c 2000/07/20 22:28:04 @@ -37,6 +37,10 @@ GtkWidget *index_vp; /* Viewport for above */ GtkWidget *index_window; /* Index Scrolled Window */ GtkWidget *progress; /* Progress bar */ + float progress_min; /* min and max values for */ + float progress_max; /* Progress Bar during download */ + int cam_busy; /* TRUE/FALSE to lock operation */ + /* with the camera */ int post_process; /* TRUE/FALSE to post-process */ char post_process_script[1024]; /* Full path/filename */ Index: src/menu.c =================================================================== RCS file: /cvs/gnome/gphoto/src/menu.c,v retrieving revision 1.12.2.8 diff -u -r1.12.2.8 menu.c --- src/menu.c 2000/02/24 19:50:24 1.12.2.8 +++ src/menu.c 2000/07/20 22:28:04 @@ -211,6 +211,8 @@ {"/Camera/Download _Selected", NULL, 0, 0, ""}, {"/Camera/Download Selected/_Images", NULL, 0, 0, ""}, {"/Camera/Download Selected/Images/_Open in window", NULL, open_images, 18}, + {"/Camera/Download Selected/Images/_Open in window (scale 50%)",NULL, open_images_and_scale50,18}, + {"/Camera/Download Selected/Images/_Open in window (scale 25%)",NULL, open_images_and_scale25,18}, {"/Camera/Download Selected/Images/_Save to disk...","g", save_images, 19}, {"/Camera/Download Selected/_Thumbnails", NULL, 0, 0, ""}, {"/Camera/Download Selected/Thumbnails/_Open in window", NULL, open_thumbs, 0},