gphoto2-context.h File Reference

Context callback operation functions. More...

`#include <stdarg.h>`
Include dependency graph for gphoto2-context.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Typedefs

typedef struct _GPContext | GPContext
| The gphoto context structure. More...
typedef enum _GPContextFeedback | GPContextFeedback
| Return codes that can be returned by progress handling. More...
typedef void(* | GPContextIdleFunc) (GPContext *context, void *data)
typedef void(* | GPContextErrorFunc) (GPContext *context, const char *text, void *data)
typedef void(* | GPContextStatusFunc) (GPContext *context, const char *text, void *data)
typedef void(* | GPContextMessageFunc) (GPContext *context, const char *text, void *data)
typedef GPContextFeedback(* | GPContextQuestionFunc) (GPContext *context, const char *text, void *data)
typedef GPContextFeedback(* | GPContextCancelFunc) (GPContext *context, void *data)
typedef unsigned int(* | GPContextProgressStartFunc) (GPContext *context, float target, const char *text, void *data)
typedef void(* | GPContextProgressUpdateFunc) (GPContext *context, unsigned int id, float current, void *data)
typedef void(* | GPContextProgressStopFunc) (GPContext *context, unsigned int id, void *data)

## Enumerations

enum | _GPContextFeedback { GP_CONTEXT_FEEDBACK_OK , GP_CONTEXT_FEEDBACK_CANCEL }
| Return codes that can be returned by progress handling. More...

## Functions

GPContext * | gp_context_new (void)
| Creates a new context. More...
void | gp_context_ref (GPContext *context)
void | gp_context_unref (GPContext *context)
| Decrements reference count of a context. More...
void | gp_context_set_idle_func (GPContext *context, GPContextIdleFunc func, void *data)
void | gp_context_set_progress_funcs (GPContext *context, GPContextProgressStartFunc start_func, GPContextProgressUpdateFunc update_func, GPContextProgressStopFunc stop_func, void *data)
void | gp_context_set_error_func (GPContext *context, GPContextErrorFunc func, void *data)
void | gp_context_set_status_func (GPContext *context, GPContextStatusFunc func, void *data)
void | gp_context_set_question_func (GPContext *context, GPContextQuestionFunc func, void *data)
void | gp_context_set_cancel_func (GPContext *context, GPContextCancelFunc func, void *data)
void | gp_context_set_message_func (GPContext *context, GPContextMessageFunc func, void *data)
void | gp_context_idle (GPContext *context)
| Notify frontend of a brief idle time. More...
void | gp_context_error (GPContext *context, const char *format,...)
void | gp_context_status (GPContext *context, const char *format,...)
void | gp_context_message (GPContext *context, const char *format,...)
| Print a message to the context. More...
GPContextFeedback | gp_context_question (GPContext *context, const char *format,...)
| Ask frontend user a question. More...
GPContextFeedback | gp_context_cancel (GPContext *context)
unsigned int | gp_context_progress_start (GPContext *context, float target, const char *format,...)
| Start progress tracking. More...
void | gp_context_progress_update (GPContext *context, unsigned int id, float current)
void | gp_context_progress_stop (GPContext *context, unsigned int id)

## Detailed Description

Context callback operation functions.

Author
  Copyright 2001 Lutz Mueller lutz@.nosp@m.user.nosp@m.s.sou.nosp@m.rcef.nosp@m.orge..nosp@m.net

Note
  This library 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 2 of the License, or (at your option) any later version.
  This library 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 Lesser General Public License for more details.
  You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

## Typedef Documentation

## GPContext

typedef struct _GPContext GPContext

The gphoto context structure.

This structure allows callback handling, passing error contexts back, progress handling and download cancellation and similar things. It is usually passed around the functions.

## GPContextFeedback

typedef enum _GPContextFeedback GPContextFeedback

Return codes that can be returned by progress handling.

An application can return special values back to the libgphoto2 progress callback handling functions. If "Cancel" is selected, libgphoto2 and the camera driver will try to cancel transfer.

## Enumeration Type Documentation

## _GPContextFeedback

enum _GPContextFeedback

Return codes that can be returned by progress handling.

An application can return special values back to the libgphoto2 progress callback handling functions. If "Cancel" is selected, libgphoto2 and the camera driver will try to cancel transfer.

Enumerator
GP_CONTEXT_FEEDBACK_OK | Everything ok... proceed.
GP_CONTEXT_FEEDBACK_CANCEL | Please cancel the current transfer if possible.

## Function Documentation

## gp_context_cancel()

GPContextFeedback gp_context_cancel | ( | GPContext * | context | ) |

gp_context_cancel: @context: a GPContext

Gives the frontend the possibility to cancel the current operation that is executed in this @context.

Return value: a GPContextFeedback.

References GP_CONTEXT_FEEDBACK_OK.

## gp_context_idle()

void gp_context_idle | ( | GPContext * | context | ) |

Notify frontend of a brief idle time.

Tells the frontend that it can do other processing at this moment, like refresh the UI. Backends should call this function every time when an interruption of the transfer is possible.

Parameters

  context | a GPContext

## gp_context_message()

void gp_context_message | ( | GPContext * | context,
|  | const char * | format,
|  |  | ...
| ) |  |

Print a message to the context.

This sends a message to the passed context, to be printed by it in some kind of way, but do no other action.

To be used by camera drivers.

Parameters

  context | A GPContext
  format | A sprintf style format string
  ... | variable argument list depending on format string

## gp_context_new()

GPContext * gp_context_new | ( | void |  | ) |

Creates a new context.

To be used by the frontend.

Returns
  a GPContext.

## gp_context_progress_start()

unsigned int gp_context_progress_start | ( | GPContext * | context,
|  | float | target,
|  | const char * | format,
|  |  | ...
| ) |  |

Start progress tracking.

This function starts up a new progress tracking for a specified context. Several nested progress reports can happen at once, depending on the backend.

Parameters

  context | The context in which to start the progress.
  target | The 100% value.
  format | A sprintf style string to print out, including the following variable arguments.

## gp_context_question()

GPContextFeedback gp_context_question | ( | GPContext * | context,
|  | const char * | format,
|  |  | ...
| ) |  |

Ask frontend user a question.

Asks the user a question that he must answer either with "Ok" or "Cancel".

To be used by a camera driver. (So far no camera driver is using it, but this might change later.)

Parameters

  context | a GPContext
  format | a sprintf format string
  ... | variable arguments for format string

Returns
  The user's answer in form of a GPContextFeedback.

## gp_context_ref()

void gp_context_ref | ( | GPContext * | context | ) |

Increments the reference count of the context.

Parameters

  context | The context to bump the reference

## gp_context_unref()

void gp_context_unref | ( | GPContext * | context | ) |

Decrements reference count of a context.

Decrement the reference count of a context and free if it goes to 0.

Parameters

  context | The context to drop the reference count.