diff options
author | Lutz Mueller <lutz@users.sourceforge.net> | 2002-01-15 12:29:46 +0000 |
---|---|---|
committer | Lutz Mueller <lutz@users.sourceforge.net> | 2002-01-15 12:29:46 +0000 |
commit | 603159e7428b1f7bbdab398e7efff531c40e45e3 (patch) | |
tree | f5b615838e55daf8413d8ffe517e86e1d29f71a3 /libgphoto2 | |
parent | d7e780db499e9a362d99d8079055e3e155b53458 (diff) | |
download | libgphoto2-603159e7428b1f7bbdab398e7efff531c40e45e3.tar.gz |
2002-01-15 Lutz M�ller <urc8@rz.uni-karlsruhe.de>
More GPContext changes:
* libgphoto2/gphoto2-context.[c,h]: Add message functionality
* camlibs: Use it.
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@3886 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'libgphoto2')
-rw-r--r-- | libgphoto2/gphoto2-camera.c | 70 | ||||
-rw-r--r-- | libgphoto2/gphoto2-camera.h | 7 | ||||
-rw-r--r-- | libgphoto2/gphoto2-context.c | 30 | ||||
-rw-r--r-- | libgphoto2/gphoto2-context.h | 5 | ||||
-rw-r--r-- | libgphoto2/gphoto2-widget.c | 4 | ||||
-rw-r--r-- | libgphoto2/gphoto2-widget.h | 4 |
6 files changed, 49 insertions, 71 deletions
diff --git a/libgphoto2/gphoto2-camera.c b/libgphoto2/gphoto2-camera.c index 455a2e2f8..cbb734eec 100644 --- a/libgphoto2/gphoto2-camera.c +++ b/libgphoto2/gphoto2-camera.c @@ -224,9 +224,6 @@ struct _CameraPrivateCore { CameraStatusFunc status_func; void *status_data; - CameraMessageFunc message_func; - void *message_data; - /* The abilities of this camera */ CameraAbilities a; @@ -530,32 +527,6 @@ gp_camera_set_status_func (Camera *camera, CameraStatusFunc func, } /** - * gp_camera_set_message_func: - * @camera: a #Camera - * @func: a #CameraMessageFunc - * @data: - * - * Sets the message function that will be used for displaying messages. - * This mechanism is used by camera drivers in order to display information - * that cannot be passed through gphoto2 using standard mechanisms. As gphoto2 - * allows camera specific error codes, the message mechanism should never be - * used. It is here for historical reasons. - * - * Return value: a gphoto2 error code - **/ -int -gp_camera_set_message_func (Camera *camera, CameraMessageFunc func, - void *data) -{ - CHECK_NULL (camera); - - camera->pc->message_func = func; - camera->pc->message_data = data; - - return (GP_OK); -} - -/** * gp_camera_status: * @camera: a #Camera * @format: @@ -595,39 +566,6 @@ gp_camera_status (Camera *camera, const char *format, ...) } /** - * gp_camera_message: - * @camera: a #Camera - * @format: - * @...: - * - * This function is here for historical reasons. Please do not use. - * - * Return value: a gphoto2 error code - **/ -int -gp_camera_message (Camera *camera, const char *format, ...) -{ - char buffer[2048]; - va_list arg; - - CHECK_NULL (camera && format); - - va_start (arg, format); -#if HAVE_VSNPRINTF - vsnprintf (buffer, sizeof (buffer), format, arg); -#else - vsprintf (buffer, format, arg); -#endif - va_end (arg); - - if (camera->pc->message_func) - camera->pc->message_func (camera, buffer, - camera->pc->message_data); - - return (GP_OK); -} - -/** * gp_camera_ref: * @camera: a #Camera * @@ -1444,3 +1382,11 @@ gp_camera_progress (Camera *camera, float percentage) "Please use gp_context_progress_update. Thank you!"); return (GP_OK); } +int gp_camera_message (Camera *camera, const char *format, ...); +int +gp_camera_message (Camera *camera, const char *format, ...) +{ + gp_log (GP_LOG_DEBUG, "camera", "gp_camera_message is deprecated. " + "Please use gp_context_message. Thank you!"); + return (GP_OK); +} diff --git a/libgphoto2/gphoto2-camera.h b/libgphoto2/gphoto2-camera.h index c444b8ad6..12352e76d 100644 --- a/libgphoto2/gphoto2-camera.h +++ b/libgphoto2/gphoto2-camera.h @@ -191,15 +191,10 @@ int gp_camera_file_get (Camera *camera, const char *folder, int gp_camera_file_delete (Camera *camera, const char *folder, const char *file, GPContext *context); -/* Informing frontends */ -typedef void (* CameraMessageFunc) (Camera *, const char *msg, void *data); +/* Informing frontends - DON'T USE! THOSE ARE DEPRECATED!!! */ typedef void (* CameraStatusFunc) (Camera *, const char *status, void *data); int gp_camera_set_status_func (Camera *camera, CameraStatusFunc func, void *data); -int gp_camera_set_message_func (Camera *camera, CameraMessageFunc func, - void *data); - -int gp_camera_message (Camera *camera, const char *format, ...); int gp_camera_status (Camera *camera, const char *format, ...); #endif /* __GPHOTO2_CAMERA_H__ */ diff --git a/libgphoto2/gphoto2-context.c b/libgphoto2/gphoto2-context.c index 4bd3fea05..4939c3be9 100644 --- a/libgphoto2/gphoto2-context.c +++ b/libgphoto2/gphoto2-context.c @@ -45,6 +45,9 @@ struct _GPContext GPContextStatusFunc status_func; void *status_func_data; + GPContextMessageFunc message_func; + void *message_func_data; + unsigned int ref_count; }; @@ -204,6 +207,22 @@ gp_context_status (GPContext *context, const char *format, ...) } } +void +gp_context_message (GPContext *context, const char *format, ...) +{ + va_list args; + + if (!context) + return; + + if (context->message_func) { + va_start (args, format); + context->message_func (context, format, args, + context->message_func_data); + va_end (args); + } +} + /** * gp_context_question: * @context: a #GPContext @@ -325,3 +344,14 @@ gp_context_set_cancel_func (GPContext *context, GPContextCancelFunc func, context->cancel_func = func; context->cancel_func_data = data; } + +void +gp_context_set_message_func (GPContext *context, GPContextMessageFunc func, + void *data) +{ + if (!context) + return; + + context->message_func = func; + context->message_func_data = data; +} diff --git a/libgphoto2/gphoto2-context.h b/libgphoto2/gphoto2-context.h index 69423b791..8353268bd 100644 --- a/libgphoto2/gphoto2-context.h +++ b/libgphoto2/gphoto2-context.h @@ -42,6 +42,8 @@ typedef void (* GPContextErrorFunc) (GPContext *context, const char *format, va_list args, void *data); typedef void (* GPContextStatusFunc) (GPContext *context, const char *format, va_list args, void *data); +typedef void (* GPContextMessageFunc) (GPContext *context, const char *format, + va_list args, void *data); typedef GPContextFeedback (* GPContextQuestionFunc) (GPContext *context, const char *format, va_list args, void *data); @@ -75,11 +77,14 @@ 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); /* Calling those functions (backends) */ void gp_context_idle (GPContext *context); 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, ...); GPContextFeedback gp_context_question (GPContext *context, const char *format, ...); GPContextFeedback gp_context_cancel (GPContext *context); diff --git a/libgphoto2/gphoto2-widget.c b/libgphoto2/gphoto2-widget.c index 01eacaf3e..753511e67 100644 --- a/libgphoto2/gphoto2-widget.c +++ b/libgphoto2/gphoto2-widget.c @@ -70,7 +70,7 @@ struct _CameraWidget { int id; /* Callback */ - int (* callback) (Camera *, CameraWidget *); + CameraWidgetCallback callback; }; /** @@ -345,7 +345,7 @@ gp_widget_set_value (CameraWidget *widget, void *value) switch (widget->type) { case GP_WIDGET_BUTTON: - widget->callback = (CameraWidgetCallback)value; + widget->callback = (CameraWidgetCallback) value; return (GP_OK); case GP_WIDGET_MENU: case GP_WIDGET_RADIO: diff --git a/libgphoto2/gphoto2-widget.h b/libgphoto2/gphoto2-widget.h index 8e1b0071a..e5733621d 100644 --- a/libgphoto2/gphoto2-widget.h +++ b/libgphoto2/gphoto2-widget.h @@ -21,6 +21,8 @@ #ifndef __GPHOTO2_WIDGET_H__ #define __GPHOTO2_WIDGET_H__ +#include <gphoto2-context.h> + /* You don't really want to know what's inside, do you? */ typedef struct _CameraWidget CameraWidget; @@ -38,7 +40,7 @@ typedef enum { /* Value (get/set): */ GP_WIDGET_DATE /* int */ } CameraWidgetType; -typedef int (* CameraWidgetCallback) (Camera *, CameraWidget *); +typedef int (* CameraWidgetCallback) (Camera *, CameraWidget *, GPContext *); int gp_widget_new (CameraWidgetType type, const char *label, CameraWidget **widget); |