author | paule <paule> | 2007-01-28 04:04:14 (UTC) |
---|---|---|
committer | paule <paule> | 2007-01-28 04:04:14 (UTC) |
commit | ec2309cb69365847762db542c41951629cd06cbe (patch) (side-by-side diff) | |
tree | 2f0101c1f0d6268207dbd15eb21f40c812a4fff5 | |
parent | 3cd37427b5c5f26f62cff583fbde914467ddafe3 (diff) | |
download | opie-ec2309cb69365847762db542c41951629cd06cbe.zip opie-ec2309cb69365847762db542c41951629cd06cbe.tar.gz opie-ec2309cb69365847762db542c41951629cd06cbe.tar.bz2 |
Refactored out all communication with LIRC into new LircHandler class
-rw-r--r-- | noncore/tools/remote/buttondialog.cpp | 216 | ||||
-rw-r--r-- | noncore/tools/remote/buttondialog.h | 12 | ||||
-rw-r--r-- | noncore/tools/remote/learntab.cpp | 132 | ||||
-rw-r--r-- | noncore/tools/remote/learntab.h | 9 | ||||
-rw-r--r-- | noncore/tools/remote/lirchandler.cpp | 270 | ||||
-rw-r--r-- | noncore/tools/remote/lirchandler.h | 38 | ||||
-rw-r--r-- | noncore/tools/remote/mainview.cpp | 13 | ||||
-rw-r--r-- | noncore/tools/remote/mainview.h | 3 | ||||
-rw-r--r-- | noncore/tools/remote/packetread.h | 200 | ||||
-rw-r--r-- | noncore/tools/remote/remote.cpp | 73 | ||||
-rw-r--r-- | noncore/tools/remote/remote.pro | 4 | ||||
-rw-r--r-- | noncore/tools/remote/remotetab.cpp | 122 | ||||
-rw-r--r-- | noncore/tools/remote/remotetab.h | 7 |
13 files changed, 344 insertions, 755 deletions
diff --git a/noncore/tools/remote/buttondialog.cpp b/noncore/tools/remote/buttondialog.cpp index 580f101..56738d1 100644 --- a/noncore/tools/remote/buttondialog.cpp +++ b/noncore/tools/remote/buttondialog.cpp @@ -1,293 +1,95 @@ /* Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. Copyright (C) 2002 Thomas Stephens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "buttondialog.h" ButtonDialog::ButtonDialog(QString buttonName, QWidget *parent, const char*name, bool modal, WFlags f):QDialog(parent, name, modal, f) { setCaption(tr(buttonName)); QVBoxLayout *layout = new QVBoxLayout(this); QHBoxLayout *hlayout1 = new QHBoxLayout(this); QHBoxLayout *hlayout2 = new QHBoxLayout(this); QHBoxLayout *hlayout3 = new QHBoxLayout(this); layout->addSpacing(5); layout->addLayout(hlayout1); layout->addSpacing(5); layout->addLayout(hlayout2); layout->addSpacing(5); layout->addLayout(hlayout3); layout->addSpacing(5); + + lh = new LircHandler(); remote = new QComboBox(false, this, "remote"); QLabel *remoteLabel = new QLabel(remote, "Remote: ", this, "remoteLabel"); hlayout1->addSpacing(5); hlayout1->addWidget(remoteLabel); hlayout1->addSpacing(5); hlayout1->addWidget(remote); hlayout1->addSpacing(5); remote->insertItem("Remote "); - remote->insertStringList(getRemotes()); + remote->insertStringList(lh->getRemotes()); connect(remote, SIGNAL(activated(const QString&)), this, SLOT(remoteSelected(const QString&)) ); button = new QComboBox(false, this, "button"); QLabel *buttonLabel = new QLabel(remote, "Button: ", this, "buttonLabel"); hlayout2->addSpacing(5); hlayout2->addWidget(buttonLabel); hlayout2->addSpacing(5); hlayout2->addWidget(button); hlayout2->addSpacing(5); button->insertItem("Button "); connect(button, SIGNAL(activated(const QString&)), this, SLOT(buttonSelected(const QString&)) ); label = new QLineEdit(this, "label"); label->setText(buttonName); QLabel *labelLabel = new QLabel(label, "Label: ", this, "labelLabel"); hlayout3->addSpacing(5); hlayout3->addWidget(labelLabel); hlayout3->addSpacing(5); hlayout3->addWidget(label); hlayout3->addSpacing(5); } +ButtonDialog::~ButtonDialog() +{ + delete lh; +} + void ButtonDialog::remoteSelected(const QString &string) { - button->insertStringList(getButtons(string.latin1()) ); + button->insertStringList(lh->getButtons(string.latin1()) ); list="SEND_ONCE"; list+=string; } void ButtonDialog::buttonSelected(const QString &string) { list+=string; } QStringList ButtonDialog::getList() { return list; } QString ButtonDialog::getLabel() { return label->text(); } - -QStringList ButtonDialog::getRemotes() -{ - const char write_buffer[] = "LIST\n"; - const char *readbuffer; - int i, numlines; - QStringList list; - - addr.sun_family=AF_UNIX; - strcpy(addr.sun_path,"/dev/lircd"); - - fd = socket(AF_UNIX, SOCK_STREAM, 0); - if(fd == -1) - { - QMessageBox *mb = new QMessageBox("Error!", - "couldnt connect to socket", - QMessageBox::NoIcon, - QMessageBox::Ok, - QMessageBox::NoButton, - QMessageBox::NoButton); - mb->exec(); - perror("ButtonDialog::GetRemotes"); - return NULL; - } - - if(::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) - { - QMessageBox *mb = new QMessageBox("Error!", - "couldnt connect to socket", - QMessageBox::NoIcon, - QMessageBox::Ok, - QMessageBox::NoButton, - QMessageBox::NoButton); - mb->exec(); - perror("ButtonDialog::GetRemotes"); - return NULL; - } - - write(fd, write_buffer, strlen(write_buffer)); - - for(i=0; i<5; i++) - { - printf("%d\n", i); - readbuffer = readPacket(); - printf("%s", readbuffer); - printf("%d\n", i); - } - - numlines = atoi(readbuffer); - - for(i=0; i<numlines; i++) - { - list+=readPacket(); - } - - if(strcasecmp(readPacket(), "END") != 0) - { - QMessageBox *mb = new QMessageBox("Error!", - "bad packet", - QMessageBox::NoIcon, - QMessageBox::Ok, - QMessageBox::NoButton, - QMessageBox::NoButton); - mb->exec(); - perror("ButtonDialog::GetRemotes"); - return NULL; - } - - ::close(fd); - return list; -} - -QStringList ButtonDialog::getButtons(const char *remoteName) -{ - QString write_buffer = "LIST "; - const char *readbuffer; - int i, j, numlines; - QStringList list; - QString string; - - write_buffer += remoteName; - write_buffer += '\n'; - - fd = socket(AF_UNIX, SOCK_STREAM, 0); - if(fd == -1) - { - QMessageBox *mb = new QMessageBox("Error!", - "couldnt connect to socket", - QMessageBox::NoIcon, - QMessageBox::Ok, - QMessageBox::NoButton, - QMessageBox::NoButton); - mb->exec(); - perror("ButtonDialog::GetButtons"); - return NULL; - } - - - if(::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) - { - QMessageBox *mb = new QMessageBox("Error!", - "couldnt connect to socket", - QMessageBox::NoIcon, - QMessageBox::Ok, - QMessageBox::NoButton, - QMessageBox::NoButton); - mb->exec(); - perror("ButtonDialog::GetButtons"); - return NULL; - } - - write(fd, write_buffer.latin1(), strlen(write_buffer) ); - - for(i=0; i<5; i++) - { - readbuffer = readPacket(); - } - - numlines = atoi(readbuffer); - - for(i=0; i<numlines; i++) - { - list+=readPacket(); - for(j=0; j<list[i].length(); j++) - { - if(list[i][j] == ' ') - break; - } - list[i].remove(0, j+1); - } - - if(strcasecmp(readPacket(), "END") != 0) - { - QMessageBox *mb = new QMessageBox("Error!", - "bad packet", - QMessageBox::NoIcon, - QMessageBox::Ok, - QMessageBox::NoButton, - QMessageBox::NoButton); - mb->exec(); - perror("ButtonDialog::GetButtons"); - return NULL; - } - - ::close(fd); - return list; -} - - -//this function was ripped for rc.c in xrc, it is available here: http://www.lirc.org/software.html -const char *ButtonDialog::readPacket() -{ - static char buffer[PACKET_SIZE+1]=""; - char *end; - static int ptr=0,end_len=0; - ssize_t ret; - timeout = 0; - - if(ptr>0) - { - memmove(buffer,buffer+ptr,strlen(buffer+ptr)+1); - ptr=strlen(buffer); - end=strchr(buffer,'\n'); - } - else - { - end=NULL; - } - alarm(TIMEOUT); - while(end==NULL) - { - if(PACKET_SIZE<=ptr) - { - fprintf(stderr,"bad packet\n"); - ptr=0; - return(NULL); - } - ret=read(fd,buffer+ptr,PACKET_SIZE-ptr); - - if(ret<=0 || timeout) - { - if(timeout) - { - fprintf(stderr,"timeout\n"); - } - else - { - alarm(0); - } - ptr=0; - return(NULL); - } - buffer[ptr+ret]=0; - ptr=strlen(buffer); - end=strchr(buffer,'\n'); - } - alarm(0);timeout=0; - - end[0]=0; - ptr=strlen(buffer)+1; -//# ifdef DEBUG -// printf("buffer: -%s-\n",buffer); -//# endif - return(buffer); -} diff --git a/noncore/tools/remote/buttondialog.h b/noncore/tools/remote/buttondialog.h index 33dc4ef..cc697b5 100644 --- a/noncore/tools/remote/buttondialog.h +++ b/noncore/tools/remote/buttondialog.h @@ -1,59 +1,53 @@ /* Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. Copyright (C) 2002 Thomas Stephens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <qdialog.h> #include <qstring.h> #include <qstringlist.h> #include <qcombobox.h> #include <qlayout.h> #include <qlabel.h> #include <qlineedit.h> #include <qmessagebox.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/socket.h> #include <sys/types.h> #include <sys/un.h> #include <unistd.h> #include <errno.h> -#define PACKET_SIZE 256 -#define TIMEOUT 3 +#include "lirchandler.h" class ButtonDialog : public QDialog { Q_OBJECT public: ButtonDialog(QString buttonName, QWidget *parent=0, const char*name=0, bool modal=FALSE, WFlags f=0); - void setIRSocket(int newfd); - const char *readPacket(); - QStringList getRemotes(); - QStringList getButtons(const char *remoteName); + ~ButtonDialog(); QStringList getList(); QString getLabel(); public slots: void remoteSelected(const QString &string); void buttonSelected(const QString &string); private: QComboBox *remote; QComboBox *button; QStringList list; QLineEdit *label; - int fd; - int timeout; - struct sockaddr_un addr; + LircHandler *lh; }; diff --git a/noncore/tools/remote/learntab.cpp b/noncore/tools/remote/learntab.cpp index 335a3e9..69d2e7f 100644 --- a/noncore/tools/remote/learntab.cpp +++ b/noncore/tools/remote/learntab.cpp @@ -1,192 +1,66 @@ /* Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. Copyright (C) 2002 Thomas Stephens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "learntab.h" /* OPIE */ #include <qpe/qpeapplication.h> LearnTab::LearnTab(QWidget *parent, const char *name):QWidget(parent,name) { + LircHandler lh; + QVBoxLayout *layout = new QVBoxLayout(this); QHBoxLayout *bottomLayout = new QHBoxLayout(this); layout->insertSpacing(0,5); remotesBox = new QListBox(this, "remotesBox"); layout->insertWidget(0, remotesBox, 1); - remotesBox->insertStringList(getRemotes()); + remotesBox->insertStringList(lh.getRemotes()); layout->insertSpacing(-1,5); layout->insertLayout(-1, bottomLayout); layout->insertSpacing(-1,5); QPushButton *add = new QPushButton("Add", this, "add"); bottomLayout->insertSpacing(-1, 5); bottomLayout->insertWidget(-1, add); bottomLayout->insertSpacing(-1, 5); QPushButton *edit = new QPushButton("Edit", this, "edit"); bottomLayout->insertWidget(-1, edit); bottomLayout->insertSpacing(-1, 5); QPushButton *del = new QPushButton("Delete", this, "delete"); bottomLayout->insertWidget(-1, del); bottomLayout->insertSpacing(-1, 5); connect(add, SIGNAL(clicked()), this, SLOT(add()) ); connect(edit, SIGNAL(clicked()), this, SLOT(edit()) ); connect(del, SIGNAL(clicked()), this, SLOT(del()) ); } void LearnTab::add() { printf("LearnTab::add: add pressed\n"); RecordDialog *dialog = new RecordDialog(this); QPEApplication::showDialog( dialog ); } void LearnTab::edit() {} void LearnTab::del() {} -QStringList LearnTab::getRemotes() -{ - const char write_buffer[] = "LIST\n"; - const char *readbuffer; - int i, numlines; - QStringList list; - - addr.sun_family=AF_UNIX; - strcpy(addr.sun_path,"/dev/lircd"); - - fd = socket(AF_UNIX, SOCK_STREAM, 0); - if(fd == -1) - { - QMessageBox *mb = new QMessageBox("Error!", - "couldnt connect to socket", - QMessageBox::NoIcon, - QMessageBox::Ok, - QMessageBox::NoButton, - QMessageBox::NoButton); - mb->exec(); - perror("LearnTab::GetRemotes"); - return NULL; - } - - if(::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) - { - QMessageBox *mb = new QMessageBox("Error!", - "couldnt connect to socket", - QMessageBox::NoIcon, - QMessageBox::Ok, - QMessageBox::NoButton, - QMessageBox::NoButton); - mb->exec(); - perror("LearnTab::GetRemotes"); - return NULL; - } - - write(fd, write_buffer, strlen(write_buffer)); - - for(i=0; i<5; i++) - { - printf("%d\n", i); - readbuffer = readPacket(); - printf("%s", readbuffer); - printf("%d\n", i); - } - - numlines = atoi(readbuffer); - - for(i=0; i<numlines; i++) - { - list+=readPacket(); - } - - if(strcasecmp(readPacket(), "END") != 0) - { - QMessageBox *mb = new QMessageBox("Error!", - "bad packet", - QMessageBox::NoIcon, - QMessageBox::Ok, - QMessageBox::NoButton, - QMessageBox::NoButton); - mb->exec(); - perror("LearnTab::GetRemotes"); - return NULL; - } - - ::close(fd); - return list; -} - -//this function was ripped for rc.c in xrc, it is available here: http://www.lirc.org/software.html -const char *LearnTab::readPacket() -{ - static char buffer[PACKET_SIZE+1]=""; - char *end; - static int ptr=0,end_len=0; - ssize_t ret; - timeout = 0; - - if(ptr>0) - { - memmove(buffer,buffer+ptr,strlen(buffer+ptr)+1); - ptr=strlen(buffer); - end=strchr(buffer,'\n'); - } - else - { - end=NULL; - } - alarm(TIMEOUT); - while(end==NULL) - { - if(PACKET_SIZE<=ptr) - { - fprintf(stderr,"bad packet\n"); - ptr=0; - return(NULL); - } - ret=read(fd,buffer+ptr,PACKET_SIZE-ptr); - - if(ret<=0 || timeout) - { - if(timeout) - { - fprintf(stderr,"timeout\n"); - } - else - { - alarm(0); - } - ptr=0; - return(NULL); - } - buffer[ptr+ret]=0; - ptr=strlen(buffer); - end=strchr(buffer,'\n'); - } - alarm(0);timeout=0; - - end[0]=0; - ptr=strlen(buffer)+1; - //# ifdef DEBUG - // printf("buffer: -%s-\n",buffer); - //# endif - return(buffer); -} - diff --git a/noncore/tools/remote/learntab.h b/noncore/tools/remote/learntab.h index cb84600..c9d8e41 100644 --- a/noncore/tools/remote/learntab.h +++ b/noncore/tools/remote/learntab.h @@ -1,55 +1,48 @@ /* Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. Copyright (C) 2002 Thomas Stephens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <qwidget.h> #include <qlistbox.h> #include <qstring.h> #include <qstringlist.h> #include <qlayout.h> #include <qpushbutton.h> #include <qmessagebox.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/socket.h> #include <sys/types.h> #include <sys/un.h> #include <unistd.h> #include <errno.h> #include "recorddialog.h" - -#define PACKET_SIZE 256 -#define TIMEOUT 3 +#include "lirchandler.h" class LearnTab : public QWidget { Q_OBJECT public: LearnTab(QWidget *parent=0, const char *name=0); - const char *readPacket(); - QStringList getRemotes(); public slots: void add(); void edit(); void del(); private: QListBox *remotesBox; - int fd; - int timeout; - struct sockaddr_un addr; }; diff --git a/noncore/tools/remote/lirchandler.cpp b/noncore/tools/remote/lirchandler.cpp new file mode 100644 index 0000000..f44806e --- a/dev/null +++ b/noncore/tools/remote/lirchandler.cpp @@ -0,0 +1,270 @@ +/* +Opie-Remote. emulates remote controls on an iPaq (and maybe a Zaurus) in Opie. +Copyright (C) 2007 Paul Eggleton & Thomas Stephens + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public +License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the +implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free +Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/socket.h> +#include <sys/types.h> +#include <sys/un.h> +#include <unistd.h> +#include <errno.h> + +#include <qstring.h> +#include <qmessagebox.h> +#include <qobject.h> +#include <opie2/oprocess.h> + +#include "lirchandler.h" + +#define PACKET_SIZE 256 +#define TIMEOUT 3 +#define LIRCD_SOCKET "/dev/lircd" +#define LIRCD_SERVICECMD "/etc/init.d/lircd" + +using namespace Opie::Core; + +LircHandler::LircHandler(void) +{ + fd = 0; + addr.sun_family=AF_UNIX; + strcpy(addr.sun_path, LIRCD_SOCKET); +} + +bool LircHandler::connectLirc(void) +{ + fd = socket(AF_UNIX, SOCK_STREAM, 0); + if(fd == -1) + { + QMessageBox *mb = new QMessageBox(QObject::tr("Error"), + QObject::tr("Unable to create socket"), + QMessageBox::Critical, + QMessageBox::Ok, + QMessageBox::NoButton, + QMessageBox::NoButton); + mb->exec(); + perror("LircHandler::connectLirc"); + return false; + } + + if(::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) + { + QMessageBox *mb = new QMessageBox(QObject::tr("Error"), + QObject::tr("Could not connect to lircd"), + QMessageBox::Critical, + QMessageBox::Ok, + QMessageBox::NoButton, + QMessageBox::NoButton); + mb->exec(); + perror("LircHandler::connectLirc"); + return false; + } + + return true; +} + +//this function was ripped for rc.c in xrc, it is available here: http://www.lirc.org/software.html +const char *LircHandler::readPacket() +{ + static char buffer[PACKET_SIZE+1]=""; + char *end; + static int ptr=0; + ssize_t ret; + int timeout = 0; + + if(ptr>0) + { + memmove(buffer,buffer+ptr,strlen(buffer+ptr)+1); + ptr=strlen(buffer); + end=strchr(buffer,'\n'); + } + else + { + end=NULL; + } + alarm(TIMEOUT); + while(end==NULL) + { + if(PACKET_SIZE<=ptr) + { + fprintf(stderr,"readPacket: bad packet\n"); + ptr=0; + return(NULL); + } + ret=read(fd,buffer+ptr,PACKET_SIZE-ptr); + + if(ret<=0 || timeout) + { + if(timeout) + { + fprintf(stderr,"readPacket: timeout\n"); + } + else + { + alarm(0); + } + ptr=0; + return(NULL); + } + buffer[ptr+ret]=0; + ptr=strlen(buffer); + end=strchr(buffer,'\n'); + } + alarm(0); + + end[0]=0; + ptr=strlen(buffer)+1; +//# ifdef DEBUG +// printf("buffer: -%s-\n",buffer); +//# endif + return(buffer); +} + +QStringList LircHandler::getRemotes(void) +{ + const char write_buffer[] = "LIST\n"; + const char *readbuffer; + int i, numlines; + QStringList list; + + if(connectLirc()) { + write(fd, write_buffer, strlen(write_buffer) ); + + for(i=0; i<5; i++) + { + readbuffer = readPacket(); + } + + numlines = atoi(readbuffer); + + for(i=0; i<numlines; i++) + { + list+=readPacket(); + } + + if(strcasecmp(readPacket(), "END") != 0) + { + QMessageBox *mb = new QMessageBox(QObject::tr("Error"), + QObject::tr("Bad packet while communicating with lircd"), + QMessageBox::Critical, + QMessageBox::Ok, + QMessageBox::NoButton, + QMessageBox::NoButton); + mb->exec(); + perror("LircHandler::getRemotes"); + return NULL; + } + + ::close(fd); + } + + return list; +} + +QStringList LircHandler::getButtons(const char *remoteName) +{ + QString write_buffer = "LIST "; + const char *readbuffer; + int i, j, numlines; + QStringList list; + QString string; + + write_buffer += remoteName; + write_buffer += '\n'; + + if(connectLirc()) { + write(fd, write_buffer.latin1(), strlen(write_buffer) ); + + for(i=0; i<5; i++) + { + readbuffer = readPacket(); + } + + numlines = atoi(readbuffer); + + for(i=0; i<numlines; i++) + { + list+=readPacket(); + for(j=0; j<list[i].length(); j++) + { + if(list[i][j] == ' ') + break; + } + list[i].remove(0, j+1); + } + + if(strcasecmp(readPacket(), "END") != 0) + { + QMessageBox *mb = new QMessageBox(QObject::tr("Error"), + QObject::tr("Bad packet while communicating with lircd"), + QMessageBox::Critical, + QMessageBox::Ok, + QMessageBox::NoButton, + QMessageBox::NoButton); + mb->exec(); + perror("LircHandler::getRemotes"); + return NULL; + } + + ::close(fd); + } + + return list; +} + +int LircHandler::sendIR(const char *irbutton) +{ + const char *read_buffer; + bool done=false; + + if(connectLirc()) { + printf("fd2: %d\n", fd); + printf("%s", irbutton); + + printf("1\n"); + printf("%d\n", write(fd, irbutton, strlen(irbutton) ) ); + printf("2\n"); + while(!done) + { + read_buffer=readPacket(); + printf("%s\n", read_buffer); + if(strcasecmp(read_buffer, "END") == 0) + { + printf("done reading packet\n"); + done=true; + } + } + ::close(fd); + return 1; + } + else + return 0; +} + +bool LircHandler::startLircd(void) +{ + return (system(LIRCD_SERVICECMD " start") == 0); +} + +bool LircHandler::stopLircd(void) +{ + return (system(LIRCD_SERVICECMD " stop") == 0); +} + +bool LircHandler::isLircdRunning(void) +{ + return (OProcess::processPID("lircd") != 0); +} diff --git a/noncore/tools/remote/lirchandler.h b/noncore/tools/remote/lirchandler.h new file mode 100644 index 0000000..29894b4 --- a/dev/null +++ b/noncore/tools/remote/lirchandler.h @@ -0,0 +1,38 @@ +/* +Opie-Remote. emulates remote controls on an iPaq (and maybe a Zaurus) in Opie. +Copyright (C) 2007 Paul Eggleton & Thomas Stephens + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public +License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the +implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free +Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef LIRCHANDLER_H +#define LIRCHANDLER_H + +class LircHandler +{ +private: + bool connectLirc(void); + const char *readPacket(); + + struct sockaddr_un addr; + int fd; +public: + LircHandler(void); + QStringList getRemotes(void); + QStringList getButtons(const char *remoteName); + int sendIR(const char *irbutton); + bool startLircd(void); + bool stopLircd(void); + bool isLircdRunning(void); +}; + +#endif diff --git a/noncore/tools/remote/mainview.cpp b/noncore/tools/remote/mainview.cpp index 724eba9..8c87785 100644 --- a/noncore/tools/remote/mainview.cpp +++ b/noncore/tools/remote/mainview.cpp @@ -1,67 +1,54 @@ /* Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. Copyright (C) 2002 Thomas Stephens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "mainview.h" #include <opie2/oresource.h> MainView::MainView(QWidget *parent, const char *name) : QWidget(parent, name) { setIcon( Opie::Core::OResource::loadPixmap( "remote", Opie::Core::OResource::SmallIcon ) ); setCaption(tr("Remote") ); QVBoxLayout *layout = new QVBoxLayout(this); QTabWidget *tabs = new QTabWidget(this); layout->addWidget(tabs); remote = new RemoteTab(tabs); learn = new LearnTab(tabs); config = new ConfigTab(tabs); help = new HelpTab(tabs); connect(config, SIGNAL(remotesChanged()), this, SLOT(updateRemotesList()) ); - remote->setIRSocket(fd); - tabs->addTab(remote, tr("Remote") ); tabs->addTab(learn,tr("Learn") ); tabs->addTab(config,tr("Config") ); tabs->addTab(help, tr("Help") ); printf("1\n"); cfg = new Config("Remote"); printf("2\n"); remote->setConfig(cfg); config->setConfig(cfg); } -int MainView::getIRSocket() -{ - return fd; -} - -void MainView::setIRSocket(int newfd) -{ - fd = newfd; - remote->setIRSocket(fd); -} - void MainView::updateRemotesList() { remote->updateRemotesList(); printf("MainView: got remotes changed signal\n"); } diff --git a/noncore/tools/remote/mainview.h b/noncore/tools/remote/mainview.h index 7ea82a6..b1ddde4 100644 --- a/noncore/tools/remote/mainview.h +++ b/noncore/tools/remote/mainview.h @@ -1,55 +1,52 @@ /* Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. Copyright (C) 2002 Thomas Stephens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <qpe/qpeapplication.h> #include <qpe/config.h> #include <qpushbutton.h> #include <qtabwidget.h> #include <qlayout.h> #include <qmessagebox.h> #include <qpaintdevice.h> #include <qobject.h> #include <sys/socket.h> #include <sys/types.h> #include <sys/un.h> #include <unistd.h> #include <stdio.h> #include <signal.h> #include "remotetab.h" #include "learntab.h" #include "configtab.h" #include "helptab.h" #define BUFFERSIZE 256 class MainView : public QWidget { Q_OBJECT public: MainView(QWidget *parent=0, const char *name=0); - int getIRSocket(); - void setIRSocket(int newfd); public slots: void updateRemotesList(); private: - int fd; RemoteTab *remote; ConfigTab *config; LearnTab *learn; HelpTab *help; Config *cfg; }; diff --git a/noncore/tools/remote/packetread.h b/noncore/tools/remote/packetread.h deleted file mode 100644 index 5dc1ad4..0000000 --- a/noncore/tools/remote/packetread.h +++ b/dev/null @@ -1,200 +0,0 @@ -/* -Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. -Copyright (C) 2002 Thomas Stephens - -This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public -License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -Public License for more details. - -You should have received a copy of the GNU General Public License along with this program; if not, write to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -file not used -*/ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/socket.h> -#include <sys/types.h> -#include <sys/un.h> -#include <unistd.h> -#include <errno.h> - -#define PACKET_SIZE 256 -#define TIMEOUT 3 - -//this function was ripped for rc.c in xrc, it is available here: http://www.lirc.org/software.html -const char *readPacket(int fd) -{ - static char buffer[PACKET_SIZE+1]=""; - char *end; - static int ptr=0,end_len=0; - ssize_t ret; - - if(ptr>0) - { - memmove(buffer,buffer+ptr,strlen(buffer+ptr)+1); - ptr=strlen(buffer); - end=strchr(buffer,'\n'); - } - else - { - end=NULL; - } - alarm(TIMEOUT); - while(end==NULL) - { - if(PACKET_SIZE<=ptr) - { -// fprintf(stderr,"%s: bad packet\n",progname); - ptr=0; - return(NULL); - } - ret=read(fd,buffer+ptr,PACKET_SIZE-ptr); - - if(ret<=0 || timeout) - { - if(timeout) - { -// fprintf(stderr,"%s: timeout\n",progname); - } - else - { - alarm(0); - } - ptr=0; - return(NULL); - } - buffer[ptr+ret]=0; - ptr=strlen(buffer); - end=strchr(buffer,'\n'); - } - alarm(0);timeout=0; - - end[0]=0; - ptr=strlen(buffer)+1; -//# ifdef DEBUG -// printf("buffer: -%s-\n",buffer); -//# endif - return(buffer); -} -QStringList getRemotes(int fd) -{ - const char write_buffer[] = "LIST\n"; - const char *readbuffer; - int i, numlines; - QStringList list; - - fd = socket(AF_UNIX, SOCK_STREAM, 0); - - if(std::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) - { - QMessageBox *mb = new QMessageBox("Error!", - "couldnt connect to socket", - QMessageBox::NoIcon, - QMessageBox::Ok, - QMessageBox::NoButton, - QMessageBox::NoButton); - mb->exec(); - perror("ConfigTab::GetRemotes"); - return NULL; - } - - write(fd, write_buffer, strlen(write_buffer) ); - - for(i=0; i<5; i++) - { - readbuffer = readPacket(int fd); - } - - numlines = atoi(readbuffer); - - for(i=0; i<numlines; i++) - { - list+=readPacket(); - } - - if(strcasecmp(readPacket(), "END") != 0) - { - QMessageBox *mb = new QMessageBox("Error!", - "bad packet", - QMessageBox::NoIcon, - QMessageBox::Ok, - QMessageBox::NoButton, - QMessageBox::NoButton); - mb->exec(); - perror("ConfigTab::GetRemotes"); - return NULL; - } - - std::close(fd); - return list; -} - -QStringList getButtons(int fd, const char *remoteName) -{ - QString write_buffer = "LIST "; - const char *readbuffer; - int i, j, numlines; - QStringList list; - QString string; - - write_buffer += remoteName; - write_buffer += '\n'; - - fd = socket(AF_UNIX, SOCK_STREAM, 0); - - if(std::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) - { - QMessageBox *mb = new QMessageBox("Error!", - "couldnt connect to socket", - QMessageBox::NoIcon, - QMessageBox::Ok, - QMessageBox::NoButton, - QMessageBox::NoButton); - mb->exec(); - perror("ConfigTab::GetRemotes"); - return NULL; - } - - write(fd, write_buffer.latin1(), strlen(write_buffer) ); - - for(i=0; i<5; i++) - { - readbuffer = readPacket(); - } - - numlines = atoi(readbuffer); - - for(i=0; i<numlines; i++) - { - list+=readPacket(); - for(j=0; j<list[i].length(); j++) - { - if(list[i][j] == ' ') - break; - } - list[i].remove(0, j+1); - } - - if(strcasecmp(readPacket(), "END") != 0) - { - QMessageBox *mb = new QMessageBox("Error!", - "bad packet", - QMessageBox::NoIcon, - QMessageBox::Ok, - QMessageBox::NoButton, - QMessageBox::NoButton); - mb->exec(); - perror("ConfigTab::GetRemotes"); - return NULL; - } - - std::close(fd); - return list; -} diff --git a/noncore/tools/remote/remote.cpp b/noncore/tools/remote/remote.cpp index 35d06bc..67fc57d 100644 --- a/noncore/tools/remote/remote.cpp +++ b/noncore/tools/remote/remote.cpp @@ -1,105 +1,60 @@ /* Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. Copyright (C) 2002 Thomas Stephens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "mainview.h" /* OPIE */ #include <qpe/qpeapplication.h> #include <qpe/config.h> /* QT */ #include <qpushbutton.h> #include <qtabwidget.h> #include <qlayout.h> #include <qmessagebox.h> #include <qpaintdevice.h> #include <qobject.h> /* STD */ #include <sys/socket.h> #include <sys/types.h> #include <sys/un.h> #include <unistd.h> #include <stdio.h> #include <signal.h> -/*void reconnect(int &fd) -{ -// struct sockaddr_un addr; - - addr.sun_family=AF_UNIX; - strcpy(addr.sun_path,"/dev/lircd"); - fd = socket(AF_UNIX, SOCK_STREAM, 0); - - if(connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) - { - QMessageBox *mb = new QMessageBox("error", - "couldnt connect to socket", - QMessageBox::NoIcon, - QMessageBox::Ok, - QMessageBox::NoButton, - QMessageBox::NoButton); - mb->exec(); - } -} -*/ - int main( int argc, char **argv ) { QPEApplication a( argc, argv ); MainView w; - - int fd; - // struct sockaddr_un addr; - // char read_buffer[BUFFERSIZE+1]; - // char write_buffer[] = "LIST\n"; - - // addr.sun_family=AF_UNIX; - // strcpy(addr.sun_path,"/dev/lircd"); - // fd = socket(AF_UNIX, SOCK_STREAM, 0); - - // printf("fd1: %d\n", fd); - /* - if(connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) - { - QMessageBox *mb = new QMessageBox("error", - "couldnt connect to socket", - QMessageBox::NoIcon, - QMessageBox::Ok, - QMessageBox::NoButton, - QMessageBox::NoButton); - mb->exec(); - } - */ - - // printf("%d\n", write(fd, write_buffer, sizeof(write_buffer) ) ); - - // printf("%d\n", read(fd, read_buffer, BUFFERSIZE ) ); - - // QMessageBox *mbtest = new QMessageBox("lirc test", - // *new QString((const char *) read_buffer), - // QMessageBox::NoIcon, - // QMessageBox::Ok, - // QMessageBox::NoButton, - // QMessageBox::NoButton); - // mbtest->exec(); - a.setMainWidget( &w ); - w.setIRSocket(fd); QPEApplication::showWidget( &w ); - return a.exec(); + + LircHandler lh; + if(!lh.isLircdRunning()) { + QMessageBox mb("Error!", + "Lircd is not running", + QMessageBox::NoIcon, + QMessageBox::Ok, + QMessageBox::NoButton, + QMessageBox::NoButton); + mb.exec(); + + } + + return a.exec(); } diff --git a/noncore/tools/remote/remote.pro b/noncore/tools/remote/remote.pro index 880856c..59ea81b 100644 --- a/noncore/tools/remote/remote.pro +++ b/noncore/tools/remote/remote.pro @@ -1,11 +1,11 @@ TEMPLATE =app CONFIG +=qt warn_on DESTDIR =$(OPIEDIR)/bin -HEADERS = remotetab.h learntab.h configtab.h topgroup.h dvdgroup.h channelgroup.h vcrgroup.h buttondialog.h topgroupconf.h dvdgroupconf.h channelgroupconf.h vcrgroupconf.h mainview.h recorddialog.h helptab.h -SOURCES =remote.cpp remotetab.cpp learntab.cpp configtab.cpp topgroup.cpp dvdgroup.cpp channelgroup.cpp vcrgroup.cpp buttondialog.cpp topgroupconf.cpp dvdgroupconf.cpp channelgroupconf.cpp vcrgroupconf.cpp mainview.cpp recorddialog.cpp helptab.cpp +HEADERS = remotetab.h learntab.h configtab.h topgroup.h dvdgroup.h channelgroup.h vcrgroup.h buttondialog.h topgroupconf.h dvdgroupconf.h channelgroupconf.h vcrgroupconf.h mainview.h recorddialog.h helptab.h lirchandler.h +SOURCES =remote.cpp remotetab.cpp learntab.cpp configtab.cpp topgroup.cpp dvdgroup.cpp channelgroup.cpp vcrgroup.cpp buttondialog.cpp topgroupconf.cpp dvdgroupconf.cpp channelgroupconf.cpp vcrgroupconf.cpp mainview.cpp recorddialog.cpp helptab.cpp lirchandler.cpp INCLUDEPATH +=$(OPIEDIR)/include DEPENDPATH +=$(OPIEDIR)/include LIBS +=-lqpe -lopiecore2 TARGET = remote include( $(OPIEDIR)/include.pro ) diff --git a/noncore/tools/remote/remotetab.cpp b/noncore/tools/remote/remotetab.cpp index 5b02e94..84038ca 100644 --- a/noncore/tools/remote/remotetab.cpp +++ b/noncore/tools/remote/remotetab.cpp @@ -1,219 +1,105 @@ /* Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. Copyright (C) 2002 Thomas Stephens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "remotetab.h" +#include "lirchandler.h" RemoteTab::RemoteTab(QWidget *parent, const char *name):QWidget(parent,name) { QVBoxLayout *layout = new QVBoxLayout(this); topGroup = new TopGroup(this); // topGroup->setMaximumHeight(22); layout->addWidget(topGroup, 0, 0); printf("%d %d", topGroup->width(), topGroup->height()); layout->addSpacing(1); dvdGroup = new DVDGroup(this); // dvdGroup->setMaximumHeight(68); layout->addWidget(dvdGroup, 0, 0); layout->addSpacing(1); vcrGroup = new VCRGroup(this); layout->addWidget(vcrGroup, 0, 0); // vcrGroup->setMaximumHeight(45); layout->addSpacing(1); channelGroup = new ChannelGroup(this); // channelGroup->setMaximumHeight(91); layout->addWidget(channelGroup, 0, 0); this->setMaximumWidth(240); - - timeout = 0; - - addr.sun_family=AF_UNIX; - strcpy(addr.sun_path,"/dev/lircd"); } int RemoteTab::sendIR() { const QObject *button = sender(); QString string = cfg->readEntry(button->name()); string+='\n'; - const char *write_buffer = string.latin1(); - const char *read_buffer; - bool done=false; - - fd = socket(AF_UNIX, SOCK_STREAM, 0); - if(fd == -1) - { - QMessageBox *mb = new QMessageBox("Error!", - "couldnt connect to socket", - QMessageBox::NoIcon, - QMessageBox::Ok, - QMessageBox::NoButton, - QMessageBox::NoButton); - mb->exec(); - perror("RemoteTab::SendIR"); - return 0; - } - - - if(::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) - { - QMessageBox *mb = new QMessageBox("Error!", - "couldnt connect to socket", - QMessageBox::NoIcon, - QMessageBox::Ok, - QMessageBox::NoButton, - QMessageBox::NoButton); - mb->exec(); - perror("RemoteTab::SendIR"); - } - - printf("fd2: %d\n", fd); - printf("%s", write_buffer); - - printf("1\n"); - printf("%d\n", write(fd, write_buffer, strlen(write_buffer) ) ); - printf("2\n"); - while(!done) - { - read_buffer=readPacket(); - printf("%s\n", read_buffer); - if(strcasecmp(read_buffer, "END") == 0) - { - printf("done reading packet\n"); - done=true; - } - } - ::close(fd); -} - -// printf("%s\n", readPacket()); -// printf("%d\n", read(fd, read_buffer,sizeof(read_buffer)) ); -// printf("%s", read_buffer); - -//this function was ripped for rc.c in xrc, it is available here: http://www.lirc.org/software.html -const char *RemoteTab::readPacket() -{ - static char buffer[PACKET_SIZE+1]=""; - char *end; - static int ptr=0,end_len=0; - ssize_t ret; - - if(ptr>0) - { - memmove(buffer,buffer+ptr,strlen(buffer+ptr)+1); - ptr=strlen(buffer); - end=strchr(buffer,'\n'); - } - else - { - end=NULL; - } - alarm(TIMEOUT); - while(end==NULL) - { - if(PACKET_SIZE<=ptr) - { -// fprintf(stderr,"%s: bad packet\n",progname); - ptr=0; - return(NULL); - } - ret=read(fd,buffer+ptr,PACKET_SIZE-ptr); - - if(ret<=0 || timeout) - { - if(timeout) - { -// fprintf(stderr,"%s: timeout\n",progname); - } - else - { - alarm(0); - } - ptr=0; - return(NULL); - } - buffer[ptr+ret]=0; - ptr=strlen(buffer); - end=strchr(buffer,'\n'); - } - alarm(0);timeout=0; - - end[0]=0; - ptr=strlen(buffer)+1; -//# ifdef DEBUG -// printf("buffer: -%s-\n",buffer); -//# endif - return(buffer); -} - -void RemoteTab::setIRSocket(int newfd) -{ - fd = newfd; + + LircHandler lh; + return lh.sendIR(string.latin1()); } void RemoteTab::setConfig(Config *newCfg) { cfg = newCfg; cfg->setGroup("Remotes"); topGroup->updateRemotes(cfg); } void RemoteTab::remoteSelected(const QString &string) { printf("1%s\n", string.latin1() ); cfg->setGroup(string); const QObject *obj; const QObjectList *objList = topGroup->children(); for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) { if(obj->inherits("QPushButton")) { if(cfg->hasKey((QString)obj->name()+"Label")) { ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); } else { cfg->setGroup("Default"); ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); cfg->setGroup(string); } } } objList = dvdGroup->children(); for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) { if(obj->inherits("QPushButton")) { if(cfg->hasKey((QString)obj->name()+"Label")) { ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); } else { cfg->setGroup("Default"); ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); cfg->setGroup(string); } diff --git a/noncore/tools/remote/remotetab.h b/noncore/tools/remote/remotetab.h index 38b58e9..da0a543 100644 --- a/noncore/tools/remote/remotetab.h +++ b/noncore/tools/remote/remotetab.h @@ -1,64 +1,57 @@ /* Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. Copyright (C) 2002 Thomas Stephens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <qpe/config.h> #include <qwidget.h> #include <qlayout.h> #include <qvbox.h> #include <qmessagebox.h> #include <qstring.h> #include <qsize.h> #include <qobjectlist.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/socket.h> #include <sys/types.h> #include <sys/un.h> #include <unistd.h> #include <errno.h> #include "topgroup.h" #include "dvdgroup.h" #include "channelgroup.h" #include "vcrgroup.h" -#define PACKET_SIZE 256 -#define TIMEOUT 3 - class RemoteTab : public QWidget { Q_OBJECT public: RemoteTab(QWidget *parent=0, const char *name=0); - void setIRSocket(int newfd); const char *readPacket(); void setConfig(Config *newCfg); void updateRemotesList(); public slots: int sendIR(); void remoteSelected(const QString &string); private: - int fd; - int timeout; - struct sockaddr_un addr; Config *cfg; TopGroup *topGroup; DVDGroup *dvdGroup; VCRGroup *vcrGroup; ChannelGroup *channelGroup; }; |