/*
 * camera-info.c: A plugin for the Video Disk Recorder
 *
 * See the README file for copyright information and how to reach the author.
 *   
 * This code is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This code 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
 * $Id: camera-info.c,v 1.8 2004/11/26 21:18:53 peter Exp $
 */

 
/*

File	: camera-info.c
Autor	: Peter Juszack

Description
-----------------------------------------------------------------
OSD output of libgphoto2 camera summary

Camera summary is a multi line String which
is directly printed into th OSD
*/


#include <vdr/status.h>
#include <vdr/menuitems.h>

// wrapper for libgphoto2
#include "digitalcamera.h"
#include "camera-info.h"
#include "digicam-logger.h"
// globals
#include "digicam.h"
#include "i18n.h"

#if VDRVERSNUM < 10307
cCameraInfoMenu::cCameraInfoMenu():cOsdMenu( tr("Camera info") ) {
#else
cCameraInfoMenu::cCameraInfoMenu():cMenuText( tr("Camera info"), "") {
#endif
    // libgphoto2 struct for camera info
    CameraText summary;

    if (digitalCamera.isAvailable() ) {
	// get camera info
	digitalCamera.getSummary(&summary);

	if (digitalCamera.getErrNo() == DIGICAM_NO_ERROR) {
	    // display camera info in scrollable box			
#if VDRVERSNUM < 10307
	    Add( new cMenuTextItem(summary.text, 1, 1, Setup.OSDwidth ));
#else	
	    SetText(summary.text);
#endif	    
	} else // camera error
	    cDigicamLogger::reportCameraError( digitalCamera.getErrNo() );
    } 
    
    SetButtons();   
}

void cCameraInfoMenu::SetButtons() {
    SetHelp( 0,0,0, tr("Back") );
    Display();
}

eOSState cCameraInfoMenu::ProcessKey(eKeys Key) {

#if VDRVERSNUM < 10307
    eOSState state = cOsdMenu::ProcessKey(Key);
#else
    eOSState state = cMenuText::ProcessKey(Key);
#endif
    
    if (state != osUnknown && state != osContinue)
	return state;

    switch(Key) {
	case kBlue: 
	    state = osBack;
	    break;
	default:
	    state = osContinue;
	    break;
    }
    
    return state;
}
