26 #include <tdelocale.h>
30 #include "commandscheduler.h"
31 #include "commandscheduler.moc"
33 CommandScheduler::CommandScheduler(Modem *modem,TQObject *parent,
35 TQObject(parent,name),
38 connect(mModem,TQ_SIGNAL(gotLine(
const char *)),
39 TQ_SLOT(processOutput(
const char *)));
42 void 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());
55 void CommandScheduler::execute(
const TQString &command)
58 cmd->setAutoDelete(
true);
63 void 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;
76 void 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());
90 void 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) {
117 void CommandScheduler::nextCommand()
119 if (mCommandQueue.first()->autoDelete())
delete mCommandQueue.first();
120 mCommandQueue.removeFirst();
121 if (mCommandQueue.count() > 0) {
122 sendCommand(mCommandQueue.first()->cmd());
126 bool CommandScheduler::loadProfile(
const TQString& filename)
130 if (!mCommandSet.loadFile(filename))
return false;
135 bool CommandScheduler::saveProfile(
const TQString& filename)
137 if (!mCommandSet.saveFile(filename))
return false;
This class provides an abstraction of an AT command.