#include <vdr/tools.h>

#include "digicam.h"
#include "digitalcamera.h"
#include "digicam-logger.h"

void cDigicamLogger::reportCameraError( int errCode ) {
    const char* message = NULL;

    // validate camera error and set message for user
    switch (errCode) {
        case GP_ERROR_MODEL_NOT_FOUND:
	    message = tr("No supported camera connected"); break;
        case GP_ERROR:
	    message = tr("Camera communication error"); break;
        case DIGICAM_CLASS_ERROR: // digitalcamera internal error (not gphoto2)
	    message = tr("Camera initialisation error"); break;
	    
	default: // report error code
	    char buf[CAMERA_PATH_MAXLENGTH];
	
	    snprintf(buf, CAMERA_PATH_MAXLENGTH, "%s: %d", 
		tr("gphoto camera error occured"), errCode);
    
	    message = buf;
    }	

    if (message != NULL) {
	isyslog("Digicam: Camera error %d: %s", errCode, message);
	OSD_ErrorMsg( message );
    } else {
    	isyslog("Digicam: Camera error %d", errCode);
    }
}
