kandy

commandscheduler.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 TQt, and distribute the resulting executable,
00022     without including the source code for TQt in the source distribution.
00023 */
00024 #ifndef COMMANDSCHEDULER_H
00025 #define COMMANDSCHEDULER_H
00026 
00027 #include <tqobject.h>
00028 #include <tqptrlist.h>
00029 
00030 #include "atcommand.h"
00031 #include "commandset.h"
00032 
00033 class Modem;
00034 
00035 class CommandScheduler : public TQObject {
00036     Q_OBJECT
00037   
00038   public:
00039     CommandScheduler (Modem *modem,TQObject *parent = 0, const char *name = 0);
00040 
00041     void execute(const TQString &command);
00042     void execute(ATCommand *command);
00043     void executeId(const TQString &id);
00044 
00045     Modem *modem() { return mModem; }
00046     CommandSet *commandSet() { return &mCommandSet; }
00047 
00048     bool loadProfile(const TQString& filename);
00049     bool saveProfile(const TQString& filename);
00050 
00051   signals:
00052     void result(const TQString &);
00053     void commandProcessed(ATCommand *);
00054 
00055   private slots:
00056     void processOutput(const char *line);
00057 
00058   private:
00059     void sendCommand(const TQString &command);
00060     void nextCommand();
00061 
00062   private:
00063     Modem *mModem;
00064     
00065     CommandSet mCommandSet;
00066 
00067     ATCommand *mLastCommand;
00068 
00069     TQPtrList<ATCommand> mCommandQueue;
00070 
00071     enum State { WAITING, PROCESSING };
00072     State mState;
00073     
00074     TQString mResult;
00075 };
00076 
00077 #endif