kandy

atcommand.h

00001 /*
00002     This file is part of Kandy.
00003 
00004     Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019 
00020     As a special exception, permission is given to link this program
00021     with any edition of Qt, and distribute the resulting executable,
00022     without including the source code for Qt in the source distribution.
00023 */
00024 #ifndef ATCOMMAND_H
00025 #define ATCOMMAND_H
00026 
00027 #include <qstring.h>
00028 #include <qstringlist.h>
00029 #include <qptrlist.h>
00030 
00031 class ATParameter {
00032   public:
00033     ATParameter();
00034     ATParameter(const QString &value,const QString &name="",
00035                 bool userInput=false);
00036 
00037     void setName(const QString &name) { mName = name; }
00038     QString name() const { return mName; }
00039     void setValue(const QString &value) { mValue = value; }
00040     QString value() const { return mValue; }
00041     void setUserInput(bool userInput) { mUserInput = userInput; }
00042     bool userInput() const { return mUserInput; }
00043 
00044   private:
00045     QString mName;
00046     QString mValue;
00047     bool mUserInput;
00048 };
00049 
00053 // TODO: emit a signal, when the command was executed.
00054 class ATCommand {
00055   public:
00056     ATCommand();
00057     ATCommand(const QString &cmdString);
00058     ATCommand(const QString &cmdName,const QString &cmdString,
00059               bool hexOutput=false);
00060     virtual ~ATCommand();
00061 
00062     void setCmdName(const QString &);
00063     QString cmdName();
00064 
00065     void setCmdString(const QString &);
00066     QString cmdString();
00067 
00068     QString cmd();
00069 
00070     QString id();
00071 
00072     void setHexOutput(bool);
00073     bool hexOutput();
00074 
00075     QString processOutput(const QString &);
00076     QString processOutput();
00077 
00078     void setResultString(const QString &);
00079     QString resultString();
00080     QString resultField(int index);
00081     QPtrList<QStringList> *resultFields();
00082 
00083     void addParameter(ATParameter *);
00084     void clearParameters();
00085     QPtrList<ATParameter> parameters();
00086 
00087     void setParameter(int index,const QString &value);
00088     void setParameter(int index,int value);
00089 
00090     void setAutoDelete(bool autoDelete) { mAutoDelete = autoDelete; }
00091     bool autoDelete() { return mAutoDelete; }
00092 
00093   private:
00094     void construct();
00095     void setResultFields(QString fieldsString);
00096     void extractParameters();
00097 
00098     QString mCmdName;
00099     QString mCmdString;
00100     QString mId;
00101     bool mHexOutput;
00102 
00103     QString mResultString;
00104     QPtrList<QStringList> mResultFieldsList;
00105 
00106     QPtrList<ATParameter> mParameters;
00107 
00108     bool mAutoDelete;
00109 };
00110 
00111 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys