ar_parser.h

00001 /***************************************************************************
00002  *   Copyright (C) 2006 by M.Fedotov   *
00003  *   mo_fedotov@mail.ru   *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #ifndef AR_PARSER_H
00021 #define AR_PARSER_H
00022 
00027 #include <qstring.h>
00028 
00029 #include "kanyremote.h"
00030 
00031 #define CFGFILE         ".anyremote.cfg"
00032 
00033 // Key code can contains      ":"
00034 // Shell command can contains ";" "&" "|"
00035 // Comments starts with       "%"
00036 // So ... i choose separator as "!"
00037 #define SEPARATOR "!"
00038 
00039 #define KEYS_SECTION_STR    "Keys"
00040 #define ALARMS_SECTION_STR  "Alarms"
00041 
00042 #define RETRY_STR       "RetrySecs"
00043 #define DEVICE_STR      "Device"
00044 #define AUTOCONN_STR    "AutoConnect"
00045 #define CHARSET_STR     "CharSet"
00046 #define SCREEN_STR      "Screen"
00047 #define LOG_STR                 "Log"
00048 #define BAUD_STR        "Baudrate"
00049 #define TOMAIN_STR      "ToMainMenu"
00050 #define GREETING_STR    "Greeting"
00051 #define CMER_ON_STR     "CmerOn"
00052 #define CMER_OFF_STR    "CmerOff"
00053 #define EXIT_STR        "Exit"
00054 #define TMPDISC_STR             "TempDisconnect"
00055 
00056 #define MKEYS           30
00057 #define KEYLEN          3
00058 #define MTEXTLEN        30
00059 #define MAXARGLEN       100
00060 #define MAXNAMELEN      512
00061 #define MAXALARMS       30
00062 
00063 #define DEFAULT_DEVICE  "/dev/rfcomm0"
00064 #define DEF_AT_CMER_ON  "AT+CMER=3,1,0,0,0" // \r will be added before send
00065 #define DEF_AT_CMER_OFF "AT+CMER=0,0,0,0,0" 
00066 
00067 #define CMER_ON         1
00068 #define CMER_OFF        2
00069 
00070 #define SAME            99
00071 #define PAUSE_STR       "PAUSE"
00072 
00073 #define KEY_NOSPECIAL   0
00074 #define KEY_EXIT        1
00075 #define KEY_TMPDISCONN  2
00076 
00081 typedef struct
00082 {
00083         QString key;
00084         QString cmd;
00085         QString seq;
00086 } type_key;
00087 
00088 typedef struct
00089 {
00090     QString alarmFile;
00091     QString greeting;
00092 } type_alarm;
00093 
00094 class AR_Parser {
00095 public:
00096     AR_Parser();
00097     ~AR_Parser();
00098 
00099 public:
00100         void  truncate          (void);
00101         int   load              (QString file);
00102         void  printConf         (void);
00103         bool  getLog            (void);
00104         void  setLog            (bool);
00105         bool  getAutoConnect    (void);
00106         void  setAutoConnect    (bool);
00107         bool  getUseScreen      (void);
00108         QString getCharset      (void);
00109         QString getDevice       (void);
00110         void setDevice          (QString);
00111         int   getBaudrate       (void);
00112         int   getRetrySecs      (void);
00113         QString getToMainMenu   (void);
00114         QString getGreeting     (void);
00115         int   isSpecialKey              (char *key);
00116         QString getAT_CMER      (int what);
00117         QString getCommand              (int i);
00118         QString getBackSeq              (int i);
00119         int   findItem          (QString key);
00120         int   getNumAlarms      (void);
00121         QString getAlarmInfo    (int which, QString& greeting);
00122 
00123 private:
00124 
00125         int baudrate;
00126         int retrysecs;
00127         bool log;
00128         bool screen;
00129         bool autoConnect;
00130 
00131         QString charset;        // Charset
00132         QString device;         // Device
00133         QString toMain;         // AnyMenu  -> MainMenu
00134         QString greeting;       // Greeting
00135         QString exitKey;        // Exit
00136         QString tmpDisc;        // TempDisconnect
00137         QString cmerOn;
00138         QString cmerOff;
00139 
00140         type_key   Keys[MKEYS];
00141         type_alarm AlarmsData[MAXALARMS];
00142         int numAlarms;
00143 
00144         int     load_cfg                (QString s);
00145         int     setBaudrate     (int rate);
00146         void    printParams     (void);
00147         void    printKeys       (void);
00148         void    printAlarms     (void);
00149         int     loadKeys        (FILE *fp);
00150         int     loadAlarms      (FILE *fp);
00151 };
00152 
00153 #endif

Generated on Sat Apr 29 12:37:08 2006 for kanyremote.kdevelop by  doxygen 1.4.6