dt_camctl_t *dt_camctl_new() { dt_camctl_t *camctl=g_malloc(sizeof(dt_camctl_t)); memset(camctl,0,sizeof(dt_camctl_t)); dt_print(DT_DEBUG_CAMCTL,"[camera_control] creating new context %lx\n",(unsigned long int)camctl); // Initialize gphoto2 context and setup dispatch callbacks camctl->gpcontext = gp_context_new(); gp_context_set_idle_func( camctl->gpcontext , (GPContextIdleFunc)_idle_func_dispatch, camctl ); gp_context_set_status_func( camctl->gpcontext , (GPContextStatusFunc)_status_func_dispatch, camctl ); gp_context_set_error_func( camctl->gpcontext , (GPContextErrorFunc)_error_func_dispatch, camctl ); gp_context_set_message_func( camctl->gpcontext , (GPContextMessageFunc)_message_func_dispatch, camctl ); // Load all camera drivers we know... gp_abilities_list_new( &camctl->gpcams ); gp_abilities_list_load( camctl->gpcams, camctl->gpcontext ); dt_print(DT_DEBUG_CAMCTL,"[camera_control] loaded %d camera drivers.\n", gp_abilities_list_count( camctl->gpcams ) ); dt_pthread_mutex_init(&camctl->lock, NULL); // Let's detect cameras connexted dt_camctl_detect_cameras(camctl); return camctl; }
void gp_glue_context_set_status_func (GPGlueContext *gluecontext, GPGlueContextStatusFunc status_func, void *data) { gluecontext->status_func = status_func; gluecontext->status_data = data; gp_context_set_status_func (gluecontext->context, gp_glue_status_func_wrapper, gluecontext); }
GPContext* photo_camera::photo_camera_create_context( void ) { context_ = gp_context_new(); // Optional debugging and status output gp_context_set_error_func( context_, photo_reporter::contextError, NULL ); gp_context_set_status_func( context_, photo_reporter::contextStatus, NULL ); return context_; }
// Create a constext. used in init. GPContext* create_context() { GPContext *context; context = gp_context_new(); // make sure we log errors. helps work out wtf is going on. gp_context_set_error_func (context, (GPContextErrorFunc) ctx_error_func, NULL); gp_context_set_status_func (context, (GPContextStatusFunc) ctx_status_func, NULL); return context; }
GPStatus() { #ifdef HAVE_GPHOTO2 context = gp_context_new(); cancel = false; gp_context_set_cancel_func(context, cancel_func, 0); #ifdef GPHOTO2_DEBUG gp_context_set_progress_funcs(context, start_func, update_func, stop_func, 0); gp_context_set_error_func(context, error_func, 0); gp_context_set_status_func(context, status_func, 0); #endif /* GPHOTO2_DEBUG */ #endif /* HAVE_GPHOTO2 */ }
void Context::init_messages() { gp_context_set_error_func(context, error_func, NULL); gp_context_set_message_func(context, msg_func, NULL); gp_context_set_status_func(context, status_func, NULL); // debug logging is massive const char *debug_enable = getenv("GPWRAP_LOG_DEBUG"); static bool debug_created; if (debug_enable && debug_enable[0] == '1' && !debug_created) { debug_created = true; // maybe should have a top-level class for this as it's not context specific // typecast because just enum vs int in header, should be safe gp_log_add_func(GP_LOG_DEBUG, reinterpret_cast<GPLogFunc>(log_func), NULL); } }
void gp_params_init (GPParams *p, char **envp) { if (!p) return; memset (p, 0, sizeof (GPParams)); p->folder = strdup ("/"); if (!p->folder) { fprintf (stderr, _("Not enough memory.")); fputc ('\n', stderr); exit (1); } gp_camera_new (&p->camera); p->cols = 79; p->flags = FLAGS_RECURSE; /* Create a context. Report progress only if users will see it. */ p->context = gp_context_new (); gp_context_set_cancel_func (p->context, ctx_cancel_func, p); gp_context_set_error_func (p->context, ctx_error_func, p); gp_context_set_status_func (p->context, ctx_status_func, p); gp_context_set_message_func (p->context, ctx_message_func, p); if (isatty (STDOUT_FILENO)) gp_context_set_progress_funcs (p->context, ctx_progress_start_func, ctx_progress_update_func, ctx_progress_stop_func, p); p->_abilities_list = NULL; p->debug_func_id = -1; p->envp = envp; }