30#include "commandscheduler.h"
31#include "commandscheduler.moc"
33CommandScheduler::CommandScheduler(Modem *modem,TQObject *parent,
35 TQObject(parent,name),
38 connect(mModem,TQ_SIGNAL(gotLine(
const char *)),
39 TQ_SLOT(processOutput(
const char *)));
42void CommandScheduler::execute(
ATCommand *command)
44 if (!mModem->isOpen()) {
45 kdDebug(5960) <<
"Warning! Modem not open." << endl;
49 mCommandQueue.append(command);
52 if (mCommandQueue.count() == 1) sendCommand(command->cmd());
55void CommandScheduler::execute(
const TQString &command)
58 cmd->setAutoDelete(
true);
63void CommandScheduler::executeId(
const TQString &
id)
65 TQPtrList<ATCommand> *cmds = mCommandSet.commandList();
67 for(uint i=0;i<cmds->count();++i) {
68 if (cmds->at(i)->id() ==
id) {
73 kdDebug(5960) <<
"CommandScheduler::executeId(): Id '" <<
id <<
"' not found" << endl;
76void CommandScheduler::sendCommand(
const TQString &command)
78 if (command.isEmpty()) {
79 kdDebug(5960) <<
"CommandScheduler::sendCommand(): Warning! Empty command."
84 kdDebug(5960) <<
"CommandScheduler:sendCommand(): " << command << endl;
86 mModem->writeLine(command.latin1());
90void CommandScheduler::processOutput(
const char *line)
97 cmd->setResultString(mResult);
98 emit commandProcessed(cmd);
100 }
else if (l ==
"ERROR") {
102 emit result(i18n(
"Error"));
105 if (mState == WAITING) {
108 }
else if (mState == PROCESSING) {
117void CommandScheduler::nextCommand()
119 if (mCommandQueue.first()->autoDelete())
delete mCommandQueue.first();
120 mCommandQueue.removeFirst();
121 if (mCommandQueue.count() > 0) {
122 sendCommand(mCommandQueue.first()->cmd());
126bool CommandScheduler::loadProfile(
const TQString& filename)
130 if (!mCommandSet.loadFile(filename))
return false;
135bool CommandScheduler::saveProfile(
const TQString& filename)
137 if (!mCommandSet.saveFile(filename))
return false;
This class provides an abstraction of an AT command.