Source: klineakconfig/lineakparser.h


Annotated List
Files
Globals
Hierarchy
Index
/***************************************************************************
                          lineakparser.h  -  description
                             -------------------
    begin                : Sat May 25 2002
    copyright            : (C) 2002 by Sheldon Lee Wen
    email                : leewsb@hotmail.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program 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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef LINEAKPARSER_H
#define LINEAKPARSER_H

using namespace std;

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#ifdef HAVE_CONFIG_H
#include 
#endif

extern "C" {
#include "dcfp.h"
#include 
#include 
#include 
#include 
#include 
}

#define CONF_HEADER \
"# LinEAK - Linux support for Easy Access and Internet Keyboards\n" \
"#  Copyright (c) 2001,2002 Mark Smulders \n" \
"#  http://lineak.sourceforge.net\n" \
"#\n" \
"# lineakd configuration file\n" \
"#\n" \
"# example key configuration:\n" \
"# \tplay\t= \"xmms --play-pause\"\n" \
"# \teject\t= EAK_EJECT\n" \
"#\n" \
"# available special actions:\n" \
"# \tEAK_EJECT\n" \
"# \tEAK_VOLUP\n" \
"# \tEAK_VOLDOWN\n" \
"# \tEAK_MUTE\n" \
"# \tEAK_SLEEP\n" \
"#\n" \
"\n"

/* special actions in .conf file */
#define NR_SPECIALS 5
/* link them to strings */
#define EAK_EJECT "EAK_EJECT"
#define EAK_VOLUP "EAK_VOLUP"
#define EAK_VOLDOWN "EAK_VOLDOWN"
#define EAK_MUTE "EAK_MUTE"
#define EAK_SLEEP "EAK_SLEEP"

/* the conf and def filenames */
#define LINEAKDIR "/.lineak/"
#define PICSDIR "/.lineak/Pics/"
#define CONFFILE "/.lineak/lineakd.conf" /* (relative from $HOME dir) */
#define BAKFILE "/.lineak/.lineakd.conf.backup"
#define PIDFILE "/.lineak/lineakd.pid"
#define DEFFILE  "lineakkb.def"

/* for volume settings using the mixer device */
#define MIXERDEV "/dev/mixer"
#define VOLUP_VALUE 5
#define VOLDOWN_VALUE -5
#define VOLMUTE_VALUE 0
#define MAX_VOLUME 100

class specialact {
public:
  specialact(QString act="", QString lname="") : action(act), longname(lname) {}
  QString action;
  QString longname;
};

class EAkey {
public:
  EAkey() { next=NULL;
  		EAkeyname="";
       EAkeycode=0;
       EAcommand=""; }
  EAkey *next;
  QString EAkeyname;
  int EAkeycode;
  KeySym EAkeysym;
  QString EAcommand;
};

/* the EAK we will use.. */
class EAKeyboard {
public:
  EAKeyboard() : EAKnr(0), EAKtype(""), EAKbrand(""),
  		EAKmodel(""), EAKeylist(NULL)  { }
  int EAKnr;
  QString EAKtype;
  QString EAKbrand;
  QString EAKmodel;
  EAkey *EAKeylist;
};

/**Encapsulates the C functions required to parse the config file.
  *@author Sheldon Lee Wen
  */

class LineakParser {
public:
	LineakParser();
	~LineakParser();
    //int lineakdRunning(void);
  	void remove_pid_file(void);
  /** Strip the quotes out of a command. */
  QString stripEscapedQuotes(QString command);
  /** Strip the quotes out of a command. */
  QString escapeQuotes(QString command);

private:
   /* function prototypes */
	QString parseconffile(const QString &inFile=QString::null);
   bool parsedeffile(const QString &inFile=QString::null);
	bool initEAK (const QString &inKBType=QString::null);
	void cleanKeylist (void);
	void cleanConfdata(void);
	void cleanDefdata(void);
	void cleanexit(int status);
	QString backup_conffile (void);
	bool restore_conffile (void);
	bool save_conffile (void);

	QString kbtype;
 	QString cdromdev;
  	QString mixdev;
	QFile conffilename;
 	QFile deffilename;
  	QFile backupfile;
	int nrkeyboards;
	const dcfp_data_struct *confdata;
	const dcfp_data_struct *defdata;
 	const dcfp_data_struct *userdefdata;
 	specialact specialacts[NR_SPECIALS];
    /** Linked list structure containing my present keyboard selection data */
	EAKeyboard myEAK;
    /** map for the brand to models */
 	map< QString, vector > bmmap;
    /** map for the kbtype to the full name */
    map longkbname;
 	 /** Print basic structure */
    void print();
 friend class KlineakConfig;
 friend class KLineakDef;


};

#endif

Generated by: sheldonl on shugaru on Thu Oct 10 23:58:14 2002, using kdoc 2.0a53.