~ubuntu-branches/ubuntu/raring/klineakconfig/raring

« back to all changes in this revision

Viewing changes to klineakconfig-api/klineakconfig___lineakparser_h.html

  • Committer: Bazaar Package Importer
  • Author(s): Aurelien Jarno
  • Date: 2006-05-27 02:45:41 UTC
  • mto: (2.1.2 edgy)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20060527024541-4fxlqc8639le61c7
Tags: upstream-0.9
ImportĀ upstreamĀ versionĀ 0.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<HTML>
2
 
<HEAD>
3
 
<TITLE>Source: klineakconfig/lineakparser.h</TITLE>
4
 
 
5
 
<META NAME="Generator" CONTENT="KDOC ">
6
 
</HEAD>
7
 
<BODY bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000099" alink= "#ffffff">
8
 
<TABLE WIDTH="100%" BORDER="0">
9
 
<TR>
10
 
<TD>
11
 
        <TABLE BORDER="0">
12
 
                <TR><TD valign="top" align="left" cellspacing="10">
13
 
                <h1>Source: klineakconfig/lineakparser.h</h1>
14
 
                </TD>
15
 
                <TD valign="top" align="right" colspan="1"></TD></TR>
16
 
        </TABLE>
17
 
        <HR>
18
 
        <TABLE BORDER="0">
19
 
                
20
 
        </TABLE>
21
 
        </TD>
22
 
<TD align="right"><TABLE BORDER="0"><TR><TD><small><A HREF="index-long.html">Annotated List</A></small></TD></TR>
23
 
<TR><TD><small><A HREF="header-list.html">Files</A></small></TD></TR>
24
 
<TR><TD><small><A HREF="all-globals.html">Globals</A></small></TD></TR>
25
 
<TR><TD><small><A HREF="hier.html">Hierarchy</A></small></TD></TR>
26
 
<TR><TD><small><A HREF="index.html">Index</A></small></TD></TR>
27
 
</TABLE></TD></TR></TABLE>
28
 
<pre>
29
 
/***************************************************************************
30
 
                          lineakparser.h  -  description
31
 
                             -------------------
32
 
    begin                : Sat May 25 2002
33
 
    copyright            : (C) 2002 by Sheldon Lee Wen
34
 
    email                : leewsb@hotmail.com
35
 
 ***************************************************************************/
36
 
 
37
 
/***************************************************************************
38
 
 *                                                                         *
39
 
 *   This program is free software; you can redistribute it and/or modify  *
40
 
 *   it under the terms of the GNU General Public License as published by  *
41
 
 *   the Free Software Foundation; either version 2 of the License, or     *
42
 
 *   (at your option) any later version.                                   *
43
 
 *                                                                         *
44
 
 ***************************************************************************/
45
 
 
46
 
#ifndef LINEAKPARSER_H
47
 
#define LINEAKPARSER_H
48
 
 
49
 
using namespace std;
50
 
 
51
 
#include <qstring.h>
52
 
#include <qfile.h>
53
 
#include <qfileinfo.h>
54
 
#include <qdir.h>
55
 
#include <qtextstream.h>
56
 
#include <iostream>
57
 
#include <map>
58
 
#include <vector>
59
 
#include <cstdlib>
60
 
#include <kurl.h>
61
 
#include <kio/job.h>
62
 
 
63
 
#ifdef HAVE_CONFIG_H
64
 
#include <config.h>
65
 
#endif
66
 
 
67
 
extern "C" {
68
 
#include "dcfp.h"
69
 
#include <X11/Xlib.h>
70
 
#include <X11/XKBlib.h>
71
 
#include <X11/extensions/XKBfile.h>
72
 
#include <sys/types.h>
73
 
#include <unistd.h>
74
 
}
75
 
 
76
 
#define CONF_HEADER \
77
 
"# LinEAK - Linux support for Easy Access and Internet Keyboards\n" \
78
 
"#  Copyright (c) 2001,2002 Mark Smulders <Mark@PIRnet.nl>\n" \
79
 
"#  http://lineak.sourceforge.net\n" \
80
 
"#\n" \
81
 
"# lineakd configuration file\n" \
82
 
"#\n" \
83
 
"# example key configuration:\n" \
84
 
"# \tplay\t= \"xmms --play-pause\"\n" \
85
 
"# \teject\t= EAK_EJECT\n" \
86
 
"#\n" \
87
 
"# available special actions:\n" \
88
 
"# \tEAK_EJECT\n" \
89
 
"# \tEAK_VOLUP\n" \
90
 
"# \tEAK_VOLDOWN\n" \
91
 
"# \tEAK_MUTE\n" \
92
 
"# \tEAK_SLEEP\n" \
93
 
"#\n" \
94
 
"\n"
95
 
 
96
 
/* special actions in .conf file */
97
 
#define NR_SPECIALS 5
98
 
/* link them to strings */
99
 
#define EAK_EJECT "EAK_EJECT"
100
 
#define EAK_VOLUP "EAK_VOLUP"
101
 
#define EAK_VOLDOWN "EAK_VOLDOWN"
102
 
#define EAK_MUTE "EAK_MUTE"
103
 
#define EAK_SLEEP "EAK_SLEEP"
104
 
 
105
 
/* the conf and def filenames */
106
 
#define LINEAKDIR "/.lineak/"
107
 
#define PICSDIR "/.lineak/Pics/"
108
 
#define CONFFILE "/.lineak/lineakd.conf" /* (relative from $HOME dir) */
109
 
#define BAKFILE "/.lineak/.lineakd.conf.backup"
110
 
#define PIDFILE "/.lineak/lineakd.pid"
111
 
#define DEFFILE  "lineakkb.def"
112
 
 
113
 
/* for volume settings using the mixer device */
114
 
#define MIXERDEV "/dev/mixer"
115
 
#define VOLUP_VALUE 5
116
 
#define VOLDOWN_VALUE -5
117
 
#define VOLMUTE_VALUE 0
118
 
#define MAX_VOLUME 100
119
 
 
120
 
class specialact {
121
 
public:
122
 
  specialact(QString act="", QString lname="") : action(act), longname(lname) {}
123
 
  QString action;
124
 
  QString longname;
125
 
};
126
 
 
127
 
class EAkey {
128
 
public:
129
 
  EAkey() { next=NULL;
130
 
                EAkeyname="";
131
 
       EAkeycode=0;
132
 
       EAcommand=""; }
133
 
  EAkey *next;
134
 
  QString EAkeyname;
135
 
  int EAkeycode;
136
 
  KeySym EAkeysym;
137
 
  QString EAcommand;
138
 
};
139
 
 
140
 
/* the EAK we will use.. */
141
 
class EAKeyboard {
142
 
public:
143
 
  EAKeyboard() : EAKnr(0), EAKtype(""), EAKbrand(""),
144
 
                EAKmodel(""), EAKeylist(NULL)  { }
145
 
  int EAKnr;
146
 
  QString EAKtype;
147
 
  QString EAKbrand;
148
 
  QString EAKmodel;
149
 
  EAkey *EAKeylist;
150
 
};
151
 
 
152
 
/**Encapsulates the C functions required to parse the config file.
153
 
  *@author Sheldon Lee Wen
154
 
  */
155
 
 
156
 
class LineakParser {
157
 
public:
158
 
        LineakParser();
159
 
        ~LineakParser();
160
 
    //int lineakdRunning(void);
161
 
        void remove_pid_file(void);
162
 
  /** Strip the quotes out of a command. */
163
 
  QString stripEscapedQuotes(QString command);
164
 
  /** Strip the quotes out of a command. */
165
 
  QString escapeQuotes(QString command);
166
 
 
167
 
private:
168
 
   /* function prototypes */
169
 
        QString parseconffile(const QString &inFile=QString::null);
170
 
   bool parsedeffile(const QString &inFile=QString::null);
171
 
        bool initEAK (const QString &inKBType=QString::null);
172
 
        void cleanKeylist (void);
173
 
        void cleanConfdata(void);
174
 
        void cleanDefdata(void);
175
 
        void cleanexit(int status);
176
 
        QString backup_conffile (void);
177
 
        bool restore_conffile (void);
178
 
        bool save_conffile (void);
179
 
 
180
 
        QString kbtype;
181
 
        QString cdromdev;
182
 
        QString mixdev;
183
 
        QFile conffilename;
184
 
        QFile deffilename;
185
 
        QFile backupfile;
186
 
        int nrkeyboards;
187
 
        const dcfp_data_struct *confdata;
188
 
        const dcfp_data_struct *defdata;
189
 
        const dcfp_data_struct *userdefdata;
190
 
        specialact specialacts[NR_SPECIALS];
191
 
    /** Linked list structure containing my present keyboard selection data */
192
 
        EAKeyboard myEAK;
193
 
    /** map for the brand to models */
194
 
        map< QString, vector<QString> > bmmap;
195
 
    /** map for the kbtype to the full name */
196
 
    map<QString,QString> longkbname;
197
 
         /** Print basic structure */
198
 
    void print();
199
 
 friend class KlineakConfig;
200
 
 friend class KLineakDef;
201
 
 
202
 
 
203
 
};
204
 
 
205
 
#endif
206
 
</pre>
207
 
<HR>
208
 
        <table>
209
 
        <tr><td><small>Generated by: sheldonl on shugaru on Thu Oct 10 23:58:14 2002, using kdoc 2.0a53.</small></td></tr>
210
 
        </table>
211
 
</BODY>
212
 
</HTML>