/** * public method to get the summary information for the camara. * * takes a string buffer to put the information in and returns the length writen. */ int tc_get_summary(char * content, const int size_of) { CameraText text; int content_length = 0; int ret; initCamaraAndContext(); if( initFailed ) { content_length = snprintf(content, size_of, "No camera detected"); } else { ret = gp_camera_get_summary (camera, &text, context); if (ret < GP_OK) { // here we will try and reset the camara so next time some one tries to use it hopefully it will re init. tc_reset(); content_length = snprintf(content, size_of, "Camera failed retrieving summary."); } else { content_length = snprintf(content, size_of, "Summary info from camara:\n %s",text.text); } } return content_length; }
int main(int argc, char **argv) { Camera *camera = NULL; int ret; GPContext *context; CameraWidget *rootwidget; char buf[200]; CameraText summary; gp_log_add_func(GP_LOG_DEBUG, errordumper, NULL); context = sample_create_context (); /* see context.c */ strcpy(buf,"usb:"); if (argc > 1) strcat (buf, argv[1]); fprintf(stderr,"setting path %s.\n", buf); ret = sample_open_camera (&camera, "USB PTP Class Camera", buf, context); if (ret < GP_OK) { fprintf(stderr,"camera %s not found.\n", buf); goto out; } ret = gp_camera_init (camera, context); if (ret < GP_OK) { fprintf(stderr,"No camera auto detected.\n"); goto out; } /* AFL PART STARTS HERE */ ret = gp_camera_get_summary (camera, &summary, context); if (ret < GP_OK) { printf ("Could not get summary.\n"); goto out; } #if 1 ret = gp_camera_get_config (camera, &rootwidget, context); if (ret < GP_OK) { fprintf (stderr,"Could not get config.\n"); goto out; } #endif printf ("OK, %s\n", summary.text); /* AFL PART ENDS HERE */ out: gp_camera_exit (camera, context); gp_camera_free (camera); return 0; }
bool GPCamera::cameraSummary(QString& summary) { #ifdef HAVE_GPHOTO2 int errorCode; CameraText sum; d->status->cancel = false; errorCode = gp_camera_get_summary(d->camera, &sum, d->status->context); if (errorCode != GP_OK) { qCDebug(DIGIKAM_IMPORTUI_LOG) << "Failed to get camera summary!"; printGphotoErrorDescription(errorCode); return false; } // we do not expect titel/model/etc. to contain newlines, // so we just escape HTML characters summary = i18nc("@info List of device properties", "Title: <b>%1</b><br/>" "Model: <b>%2</b><br/>" "Port: <b>%3</b><br/>" "Path: <b>%4</b><br/><br/>", title().toHtmlEscaped(), model().toHtmlEscaped(), port().toHtmlEscaped(), path().toHtmlEscaped()); summary += i18nc("@info List of supported device operations", "Thumbnails: <b>%1</b><br/>" "Capture image: <b>%2</b><br/>" "Delete items: <b>%3</b><br/>" "Upload items: <b>%4</b><br/>" "Create directories: <b>%5</b><br/>" "Delete Directories: <b>%6</b><br/><br/>", thumbnailSupport() ? i18n("yes") : i18n("no"), captureImageSupport() ? i18n("yes") : i18n("no"), deleteSupport() ? i18n("yes") : i18n("no"), uploadSupport() ? i18n("yes") : i18n("no"), mkDirSupport() ? i18n("yes") : i18n("no"), delDirSupport() ? i18n("yes") : i18n("no")); // here we need to make sure whitespace and newlines // are converted to HTML properly summary.append(Qt::convertFromPlainText(QString::fromLocal8Bit(sum.text), Qt::WhiteSpacePre)); return true; #else Q_UNUSED(summary); return false; #endif /* HAVE_GPHOTO2 */ }
int main(int argc, char **argv) { CameraList *list; Camera **cams; int ret, i, count; const char *name, *value; GPContext *context; context = sample_create_context (); /* see context.c */ /* Detect all the cameras that can be autodetected... */ ret = gp_list_new (&list); if (ret < GP_OK) return 1; count = sample_autodetect (list, context); /* Now open all cameras we autodected for usage */ printf("Number of cameras: %d\n", count); cams = calloc (sizeof (Camera*),count); for (i = 0; i < count; i++) { gp_list_get_name (list, i, &name); gp_list_get_value (list, i, &value); ret = sample_open_camera (&cams[i], name, value, context); if (ret < GP_OK) fprintf(stderr,"Camera %s on port %s failed to open\n", name, value); } /* Now call a simple function in each of those cameras. */ for (i = 0; i < count; i++) { CameraText text; char *owner; ret = gp_camera_get_summary (cams[i], &text, context); if (ret < GP_OK) { fprintf (stderr, "Failed to get summary.\n"); continue; } gp_list_get_name (list, i, &name); gp_list_get_value (list, i, &value); printf("%-30s %-16s\n", name, value); printf("Summary:\n%s\n", text.text); /* Query a simple string configuration variable. */ ret = get_config_value_string (cams[i], "owner", &owner, context); if (ret >= GP_OK) { printf("Owner: %s\n", owner); free (owner); } else { printf("Owner: No owner found.\n"); } } return 0; }
int main(int argc, char **argv) { Camera *camera; int ret; char *owner; GPContext *context; CameraText text; context = sample_create_context (); /* see context.c */ gp_camera_new (&camera); /* This call will autodetect cameras, take the * first one from the list and use it. It will ignore * any others... See the *multi* examples on how to * detect and use more than the first one. */ ret = gp_camera_init (camera, context); if (ret < GP_OK) { printf("No camera auto detected.\n"); gp_camera_free (camera); return 0; } /* Simple query the camera summary text */ ret = gp_camera_get_summary (camera, &text, context); if (ret < GP_OK) { printf("Camera failed retrieving summary.\n"); gp_camera_free (camera); return 0; } printf("Summary:\n%s\n", text.text); /* Simple query of a string configuration variable. */ ret = get_config_value_string (camera, "owner", &owner, context); if (ret >= GP_OK) { printf("Owner: %s\n", owner); free (owner); } gp_camera_exit (camera, context); gp_camera_free (camera); gp_context_unref (context); return 0; }
int main(int argc, char **argv) { Camera *camera = NULL; int ret; GPContext *context; CameraWidget *rootwidget; char buf[200]; CameraText summary; gp_log_add_func(GP_LOG_DEBUG, errordumper, NULL); context = sample_create_context (); /* see context.c */ strcpy(buf,"usb:"); if (argc > 1) strcat (buf, argv[1]); fprintf(stderr,"setting path %s.\n", buf); ret = sample_open_camera (&camera, "USB PTP Class Camera", buf, context); if (ret < GP_OK) { fprintf(stderr,"camera %s not found.\n", buf); goto out; } ret = gp_camera_init (camera, context); if (ret < GP_OK) { fprintf(stderr,"No camera auto detected.\n"); goto out; } /* AFL PART STARTS HERE */ ret = recursive_directory(camera, "/", context, NULL); if (ret < GP_OK) { printf ("Could not recursive list files.\n"); goto out; } ret = gp_camera_get_summary (camera, &summary, context); if (ret < GP_OK) { printf ("Could not get summary.\n"); goto out; } #if 1 ret = gp_camera_get_config (camera, &rootwidget, context); if (ret < GP_OK) { fprintf (stderr,"Could not get config.\n"); goto out; } #endif printf ("OK, %s\n", summary.text); while (1) { CameraEventType evttype; void *data = NULL; ret = gp_camera_wait_for_event(camera, 1, &evttype, &data, context); if (ret < GP_OK) break; if (data) free (data); if (evttype == GP_EVENT_TIMEOUT) break; } /* AFL PART ENDS HERE */ out: gp_camera_exit (camera, context); gp_camera_free (camera); return 0; }
void dt_camctl_detect_cameras(const dt_camctl_t *c) { dt_camctl_t *camctl=(dt_camctl_t *)c; dt_pthread_mutex_lock(&camctl->lock); /* reload portdrivers */ if (camctl->gpports) gp_port_info_list_free (camctl->gpports); gp_port_info_list_new( &camctl->gpports ); gp_port_info_list_load( camctl->gpports ); dt_print(DT_DEBUG_CAMCTL,"[camera_control] loaded %d port drivers.\n", gp_port_info_list_count( camctl->gpports ) ); CameraList *available_cameras=NULL; gp_list_new( &available_cameras ); gp_abilities_list_detect (c->gpcams,c->gpports, available_cameras, c->gpcontext ); dt_print(DT_DEBUG_CAMCTL,"[camera_control] %d cameras connected\n",gp_list_count( available_cameras )>0?gp_list_count( available_cameras ):0); for(int i=0; i<gp_list_count( available_cameras ); i++) { dt_camera_t *camera=g_malloc(sizeof(dt_camera_t)); memset( camera,0,sizeof(dt_camera_t)); gp_list_get_name (available_cameras, i, &camera->model); gp_list_get_value (available_cameras, i, &camera->port); dt_pthread_mutex_init(&camera->config_lock, NULL); dt_pthread_mutex_init(&camera->live_view_pixbuf_mutex, NULL); dt_pthread_mutex_init(&camera->live_view_synch, NULL); // if(strcmp(camera->port,"usb:")==0) { g_free(camera); continue; } GList *citem; if( (citem=g_list_find_custom(c->cameras,camera,_compare_camera_by_port)) == NULL || strcmp(((dt_camera_t *)citem->data)->model,camera->model)!=0 ) { if(citem==NULL) { // Newly connected camera if(_camera_initialize(c,camera)==FALSE) { dt_print(DT_DEBUG_CAMCTL,"[camera_control] failed to initialize device %s on port %s, probably causes are: locked by another application, no access to udev etc.\n", camera->model,camera->port); g_free(camera); continue; } // Check if camera has capabililties for being presented to darktable if( camera->can_import==FALSE && camera->can_tether==FALSE ) { dt_print(DT_DEBUG_CAMCTL,"[camera_control] device %s on port %s doesn't support import or tether, skipping device.\n", camera->model,camera->port); g_free(camera); continue; } // Fetch some summary of camera if( gp_camera_get_summary(camera->gpcam, &camera->summary, c->gpcontext) == GP_OK ) { // Remove device property summary: char *eos=strstr(camera->summary.text,"Device Property Summary:\n"); if (eos) eos[0]='\0'; } // Add to camera list camctl->cameras = g_list_append(camctl->cameras,camera); // Notify listeners of connected camera _dispatch_camera_connected(camctl,camera); } } else g_free(camera); } /* check c->cameras in available_cameras */ if( c->cameras && g_list_length(c->cameras)>0) { GList *citem = c->cameras; do { int index=0; dt_camera_t *cam=(dt_camera_t *)citem->data; if (gp_list_find_by_name(available_cameras,&index,cam->model)!= GP_OK) { /* remove camera from cached list.. */ dt_camctl_t *camctl=(dt_camctl_t *)c; dt_camera_t *oldcam = (dt_camera_t *)citem->data; camctl->cameras=citem= g_list_delete_link (c->cameras,citem); g_free(oldcam); } } while ( citem && (citem=g_list_next(citem))!=NULL); } dt_pthread_mutex_unlock(&camctl->lock); }