-rw-r--r-- | noncore/tools/remote/buttondialog.cpp | 25 | ||||
-rw-r--r-- | noncore/tools/remote/remotetab.cpp | 15 | ||||
-rw-r--r-- | noncore/tools/remote/remotetab.h | 2 |
3 files changed, 40 insertions, 2 deletions
diff --git a/noncore/tools/remote/buttondialog.cpp b/noncore/tools/remote/buttondialog.cpp index e7ff4b4..7479e85 100644 --- a/noncore/tools/remote/buttondialog.cpp +++ b/noncore/tools/remote/buttondialog.cpp | |||
@@ -85,32 +85,44 @@ QStringList ButtonDialog::getList() | |||
85 | QString ButtonDialog::getLabel() | 85 | QString ButtonDialog::getLabel() |
86 | { | 86 | { |
87 | return label->text(); | 87 | return label->text(); |
88 | } | 88 | } |
89 | 89 | ||
90 | QStringList ButtonDialog::getRemotes() | 90 | QStringList ButtonDialog::getRemotes() |
91 | { | 91 | { |
92 | const char write_buffer[] = "LIST\n"; | 92 | const char write_buffer[] = "LIST\n"; |
93 | const char *readbuffer; | 93 | const char *readbuffer; |
94 | int i, numlines; | 94 | int i, numlines; |
95 | QStringList list; | 95 | QStringList list; |
96 | 96 | ||
97 | addr.sun_family=AF_UNIX; | 97 | addr.sun_family=AF_UNIX; |
98 | strcpy(addr.sun_path,"/dev/lircd"); | 98 | strcpy(addr.sun_path,"/dev/lircd"); |
99 | 99 | ||
100 | fd = socket(AF_UNIX, SOCK_STREAM, 0); | 100 | fd = socket(AF_UNIX, SOCK_STREAM, 0); |
101 | if(fd == -1) | ||
102 | { | ||
103 | QMessageBox *mb = new QMessageBox("Error!", | ||
104 | "couldnt connect to socket", | ||
105 | QMessageBox::NoIcon, | ||
106 | QMessageBox::Ok, | ||
107 | QMessageBox::NoButton, | ||
108 | QMessageBox::NoButton); | ||
109 | mb->exec(); | ||
110 | perror("ButtonDialog::GetRemotes"); | ||
111 | return NULL; | ||
112 | } | ||
101 | 113 | ||
102 | if(std::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) | 114 | if(std::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) |
103 | { | 115 | { |
104 | QMessageBox *mb = new QMessageBox("Error!", | 116 | QMessageBox *mb = new QMessageBox("Error!", |
105 | "couldnt connect to socket", | 117 | "couldnt connect to socket", |
106 | QMessageBox::NoIcon, | 118 | QMessageBox::NoIcon, |
107 | QMessageBox::Ok, | 119 | QMessageBox::Ok, |
108 | QMessageBox::NoButton, | 120 | QMessageBox::NoButton, |
109 | QMessageBox::NoButton); | 121 | QMessageBox::NoButton); |
110 | mb->exec(); | 122 | mb->exec(); |
111 | perror("ButtonDialog::GetRemotes"); | 123 | perror("ButtonDialog::GetRemotes"); |
112 | return NULL; | 124 | return NULL; |
113 | } | 125 | } |
114 | 126 | ||
115 | write(fd, write_buffer, strlen(write_buffer)); | 127 | write(fd, write_buffer, strlen(write_buffer)); |
116 | 128 | ||
@@ -145,32 +157,45 @@ QStringList ButtonDialog::getRemotes() | |||
145 | std::close(fd); | 157 | std::close(fd); |
146 | return list; | 158 | return list; |
147 | } | 159 | } |
148 | 160 | ||
149 | QStringList ButtonDialog::getButtons(const char *remoteName) | 161 | QStringList ButtonDialog::getButtons(const char *remoteName) |
150 | { | 162 | { |
151 | QString write_buffer = "LIST "; | 163 | QString write_buffer = "LIST "; |
152 | const char *readbuffer; | 164 | const char *readbuffer; |
153 | int i, j, numlines; | 165 | int i, j, numlines; |
154 | QStringList list; | 166 | QStringList list; |
155 | QString string; | 167 | QString string; |
156 | 168 | ||
157 | write_buffer += remoteName; | 169 | write_buffer += remoteName; |
158 | write_buffer += '\n'; | 170 | write_buffer += '\n'; |
159 | 171 | ||
160 | fd = socket(AF_UNIX, SOCK_STREAM, 0); | 172 | fd = socket(AF_UNIX, SOCK_STREAM, 0); |
173 | if(fd == -1) | ||
174 | { | ||
175 | QMessageBox *mb = new QMessageBox("Error!", | ||
176 | "couldnt connect to socket", | ||
177 | QMessageBox::NoIcon, | ||
178 | QMessageBox::Ok, | ||
179 | QMessageBox::NoButton, | ||
180 | QMessageBox::NoButton); | ||
181 | mb->exec(); | ||
182 | perror("ButtonDialog::GetButtons"); | ||
183 | return NULL; | ||
184 | } | ||
185 | |||
161 | 186 | ||
162 | if(std::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) | 187 | if(std::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) |
163 | { | 188 | { |
164 | QMessageBox *mb = new QMessageBox("Error!", | 189 | QMessageBox *mb = new QMessageBox("Error!", |
165 | "couldnt connect to socket", | 190 | "couldnt connect to socket", |
166 | QMessageBox::NoIcon, | 191 | QMessageBox::NoIcon, |
167 | QMessageBox::Ok, | 192 | QMessageBox::Ok, |
168 | QMessageBox::NoButton, | 193 | QMessageBox::NoButton, |
169 | QMessageBox::NoButton); | 194 | QMessageBox::NoButton); |
170 | mb->exec(); | 195 | mb->exec(); |
171 | perror("ButtonDialog::GetButtons"); | 196 | perror("ButtonDialog::GetButtons"); |
172 | return NULL; | 197 | return NULL; |
173 | } | 198 | } |
174 | 199 | ||
175 | write(fd, write_buffer.latin1(), strlen(write_buffer) ); | 200 | write(fd, write_buffer.latin1(), strlen(write_buffer) ); |
176 | 201 | ||
diff --git a/noncore/tools/remote/remotetab.cpp b/noncore/tools/remote/remotetab.cpp index f3a8945..64b8ee4 100644 --- a/noncore/tools/remote/remotetab.cpp +++ b/noncore/tools/remote/remotetab.cpp | |||
@@ -38,42 +38,55 @@ RemoteTab::RemoteTab(QWidget *parent=0, const char *name=0):QWidget(parent,name) | |||
38 | //vcrGroup->setMaximumHeight(45); | 38 | //vcrGroup->setMaximumHeight(45); |
39 | 39 | ||
40 | layout->addSpacing(1); | 40 | layout->addSpacing(1); |
41 | 41 | ||
42 | channelGroup = new ChannelGroup(this); | 42 | channelGroup = new ChannelGroup(this); |
43 | //channelGroup->setMaximumHeight(91); | 43 | //channelGroup->setMaximumHeight(91); |
44 | layout->addWidget(channelGroup, 0, 0); | 44 | layout->addWidget(channelGroup, 0, 0); |
45 | 45 | ||
46 | this->setMaximumWidth(240); | 46 | this->setMaximumWidth(240); |
47 | 47 | ||
48 | timeout = 0; | 48 | timeout = 0; |
49 | 49 | ||
50 | addr.sun_family=AF_UNIX; | 50 | addr.sun_family=AF_UNIX; |
51 | strcpy(addr.sun_path,"/dev/lircd"); | 51 | strcpy(addr.sun_path,"/dev/lircd"); |
52 | } | 52 | } |
53 | 53 | ||
54 | void RemoteTab::sendIR() | 54 | int RemoteTab::sendIR() |
55 | { | 55 | { |
56 | const QObject *button = sender(); | 56 | const QObject *button = sender(); |
57 | QString string = cfg->readEntry(button->name()); | 57 | QString string = cfg->readEntry(button->name()); |
58 | string+='\n'; | 58 | string+='\n'; |
59 | const char *write_buffer = string.latin1(); | 59 | const char *write_buffer = string.latin1(); |
60 | const char *read_buffer; | 60 | const char *read_buffer; |
61 | bool done=false; | 61 | bool done=false; |
62 | 62 | ||
63 | fd = socket(AF_UNIX, SOCK_STREAM, 0); | 63 | fd = socket(AF_UNIX, SOCK_STREAM, 0); |
64 | if(fd == -1) | ||
65 | { | ||
66 | QMessageBox *mb = new QMessageBox("Error!", | ||
67 | "couldnt connect to socket", | ||
68 | QMessageBox::NoIcon, | ||
69 | QMessageBox::Ok, | ||
70 | QMessageBox::NoButton, | ||
71 | QMessageBox::NoButton); | ||
72 | mb->exec(); | ||
73 | perror("RemoteTab::SendIR"); | ||
74 | return NULL; | ||
75 | } | ||
76 | |||
64 | 77 | ||
65 | if(std::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) | 78 | if(std::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) |
66 | { | 79 | { |
67 | QMessageBox *mb = new QMessageBox("Error!", | 80 | QMessageBox *mb = new QMessageBox("Error!", |
68 | "couldnt connect to socket", | 81 | "couldnt connect to socket", |
69 | QMessageBox::NoIcon, | 82 | QMessageBox::NoIcon, |
70 | QMessageBox::Ok, | 83 | QMessageBox::Ok, |
71 | QMessageBox::NoButton, | 84 | QMessageBox::NoButton, |
72 | QMessageBox::NoButton); | 85 | QMessageBox::NoButton); |
73 | mb->exec(); | 86 | mb->exec(); |
74 | perror("RemoteTab::SendIR"); | 87 | perror("RemoteTab::SendIR"); |
75 | } | 88 | } |
76 | 89 | ||
77 | printf("fd2: %d\n", fd); | 90 | printf("fd2: %d\n", fd); |
78 | printf("%s", write_buffer); | 91 | printf("%s", write_buffer); |
79 | 92 | ||
diff --git a/noncore/tools/remote/remotetab.h b/noncore/tools/remote/remotetab.h index 77a7318..38b58e9 100644 --- a/noncore/tools/remote/remotetab.h +++ b/noncore/tools/remote/remotetab.h | |||
@@ -37,28 +37,28 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
37 | #include "channelgroup.h" | 37 | #include "channelgroup.h" |
38 | #include "vcrgroup.h" | 38 | #include "vcrgroup.h" |
39 | 39 | ||
40 | #define PACKET_SIZE 256 | 40 | #define PACKET_SIZE 256 |
41 | #define TIMEOUT 3 | 41 | #define TIMEOUT 3 |
42 | 42 | ||
43 | class RemoteTab : public QWidget | 43 | class RemoteTab : public QWidget |
44 | { | 44 | { |
45 | Q_OBJECT | 45 | Q_OBJECT |
46 | public: | 46 | public: |
47 | RemoteTab(QWidget *parent=0, const char *name=0); | 47 | RemoteTab(QWidget *parent=0, const char *name=0); |
48 | void setIRSocket(int newfd); | 48 | void setIRSocket(int newfd); |
49 | const char *readPacket(); | 49 | const char *readPacket(); |
50 | void setConfig(Config *newCfg); | 50 | void setConfig(Config *newCfg); |
51 | void updateRemotesList(); | 51 | void updateRemotesList(); |
52 | public slots: | 52 | public slots: |
53 | void sendIR(); | 53 | int sendIR(); |
54 | void remoteSelected(const QString &string); | 54 | void remoteSelected(const QString &string); |
55 | private: | 55 | private: |
56 | int fd; | 56 | int fd; |
57 | int timeout; | 57 | int timeout; |
58 | struct sockaddr_un addr; | 58 | struct sockaddr_un addr; |
59 | Config *cfg; | 59 | Config *cfg; |
60 | TopGroup *topGroup; | 60 | TopGroup *topGroup; |
61 | DVDGroup *dvdGroup; | 61 | DVDGroup *dvdGroup; |
62 | VCRGroup *vcrGroup; | 62 | VCRGroup *vcrGroup; |
63 | ChannelGroup *channelGroup; | 63 | ChannelGroup *channelGroup; |
64 | }; | 64 | }; |