summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/remote/buttondialog.cpp25
-rw-r--r--noncore/tools/remote/remotetab.cpp15
-rw-r--r--noncore/tools/remote/remotetab.h2
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
@@ -5,252 +5,277 @@ Copyright (C) 2002 Thomas Stephens
5This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public 5This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
6License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later 6License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
7version. 7version.
8 8
9This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 9This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
10implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 10implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11Public License for more details. 11Public License for more details.
12 12
13You should have received a copy of the GNU General Public License along with this program; if not, write to the Free 13You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
14Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 14Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15*/ 15*/
16 16
17#include "buttondialog.h" 17#include "buttondialog.h"
18 18
19ButtonDialog::ButtonDialog(QString buttonName, QWidget *parent=0, const char*name=0, bool modal=FALSE, WFlags f=0):QDialog(parent, name, modal, f) 19ButtonDialog::ButtonDialog(QString buttonName, QWidget *parent=0, const char*name=0, bool modal=FALSE, WFlags f=0):QDialog(parent, name, modal, f)
20{ 20{
21 setCaption(tr(buttonName)); 21 setCaption(tr(buttonName));
22 22
23 QVBoxLayout *layout = new QVBoxLayout(this); 23 QVBoxLayout *layout = new QVBoxLayout(this);
24 24
25 QHBoxLayout *hlayout1 = new QHBoxLayout(this); 25 QHBoxLayout *hlayout1 = new QHBoxLayout(this);
26 QHBoxLayout *hlayout2 = new QHBoxLayout(this); 26 QHBoxLayout *hlayout2 = new QHBoxLayout(this);
27 QHBoxLayout *hlayout3 = new QHBoxLayout(this); 27 QHBoxLayout *hlayout3 = new QHBoxLayout(this);
28 28
29 layout->addSpacing(5); 29 layout->addSpacing(5);
30 layout->addLayout(hlayout1); 30 layout->addLayout(hlayout1);
31 layout->addSpacing(5); 31 layout->addSpacing(5);
32 layout->addLayout(hlayout2); 32 layout->addLayout(hlayout2);
33 layout->addSpacing(5); 33 layout->addSpacing(5);
34 layout->addLayout(hlayout3); 34 layout->addLayout(hlayout3);
35 layout->addSpacing(5); 35 layout->addSpacing(5);
36 36
37 remote = new QComboBox(false, this, "remote"); 37 remote = new QComboBox(false, this, "remote");
38 QLabel *remoteLabel = new QLabel(remote, "Remote: ", this, "remoteLabel"); 38 QLabel *remoteLabel = new QLabel(remote, "Remote: ", this, "remoteLabel");
39 hlayout1->addSpacing(5); 39 hlayout1->addSpacing(5);
40 hlayout1->addWidget(remoteLabel); 40 hlayout1->addWidget(remoteLabel);
41 hlayout1->addSpacing(5); 41 hlayout1->addSpacing(5);
42 hlayout1->addWidget(remote); 42 hlayout1->addWidget(remote);
43 hlayout1->addSpacing(5); 43 hlayout1->addSpacing(5);
44 remote->insertItem("Remote "); 44 remote->insertItem("Remote ");
45 remote->insertStringList(getRemotes()); 45 remote->insertStringList(getRemotes());
46 connect(remote, SIGNAL(activated(const QString &)), this, SLOT(remoteSelected(const QString&)) ); 46 connect(remote, SIGNAL(activated(const QString &)), this, SLOT(remoteSelected(const QString&)) );
47 47
48 button = new QComboBox(false, this, "button"); 48 button = new QComboBox(false, this, "button");
49 QLabel *buttonLabel = new QLabel(remote, "Button: ", this, "buttonLabel"); 49 QLabel *buttonLabel = new QLabel(remote, "Button: ", this, "buttonLabel");
50 hlayout2->addSpacing(5); 50 hlayout2->addSpacing(5);
51 hlayout2->addWidget(buttonLabel); 51 hlayout2->addWidget(buttonLabel);
52 hlayout2->addSpacing(5); 52 hlayout2->addSpacing(5);
53 hlayout2->addWidget(button); 53 hlayout2->addWidget(button);
54 hlayout2->addSpacing(5); 54 hlayout2->addSpacing(5);
55 button->insertItem("Button "); 55 button->insertItem("Button ");
56 connect(button, SIGNAL(activated(const QString &)), this, SLOT(buttonSelected(const QString&)) ); 56 connect(button, SIGNAL(activated(const QString &)), this, SLOT(buttonSelected(const QString&)) );
57 57
58 label = new QLineEdit(this, "label"); 58 label = new QLineEdit(this, "label");
59 label->setText(buttonName); 59 label->setText(buttonName);
60 QLabel *labelLabel = new QLabel(label, "Label: ", this, "labelLabel"); 60 QLabel *labelLabel = new QLabel(label, "Label: ", this, "labelLabel");
61 hlayout3->addSpacing(5); 61 hlayout3->addSpacing(5);
62 hlayout3->addWidget(labelLabel); 62 hlayout3->addWidget(labelLabel);
63 hlayout3->addSpacing(5); 63 hlayout3->addSpacing(5);
64 hlayout3->addWidget(label); 64 hlayout3->addWidget(label);
65 hlayout3->addSpacing(5); 65 hlayout3->addSpacing(5);
66} 66}
67 67
68void ButtonDialog::remoteSelected(const QString &string) 68void ButtonDialog::remoteSelected(const QString &string)
69{ 69{
70 button->insertStringList(getButtons(string.latin1()) ); 70 button->insertStringList(getButtons(string.latin1()) );
71 list="SEND_ONCE"; 71 list="SEND_ONCE";
72 list+=string; 72 list+=string;
73} 73}
74 74
75void ButtonDialog::buttonSelected(const QString &string) 75void ButtonDialog::buttonSelected(const QString &string)
76{ 76{
77 list+=string; 77 list+=string;
78} 78}
79 79
80QStringList ButtonDialog::getList() 80QStringList ButtonDialog::getList()
81{ 81{
82 return list; 82 return list;
83} 83}
84 84
85QString ButtonDialog::getLabel() 85QString ButtonDialog::getLabel()
86{ 86{
87 return label->text(); 87 return label->text();
88} 88}
89 89
90QStringList ButtonDialog::getRemotes() 90QStringList 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
117 for(i=0; i<5; i++) 129 for(i=0; i<5; i++)
118 { 130 {
119 printf("%d\n", i); 131 printf("%d\n", i);
120 readbuffer = readPacket(); 132 readbuffer = readPacket();
121 printf("%s", readbuffer); 133 printf("%s", readbuffer);
122 printf("%d\n", i); 134 printf("%d\n", i);
123 } 135 }
124 136
125 numlines = atoi(readbuffer); 137 numlines = atoi(readbuffer);
126 138
127 for(i=0; i<numlines; i++) 139 for(i=0; i<numlines; i++)
128 { 140 {
129 list+=readPacket(); 141 list+=readPacket();
130 } 142 }
131 143
132 if(strcasecmp(readPacket(), "END") != 0) 144 if(strcasecmp(readPacket(), "END") != 0)
133 { 145 {
134 QMessageBox *mb = new QMessageBox("Error!", 146 QMessageBox *mb = new QMessageBox("Error!",
135 "bad packet", 147 "bad packet",
136 QMessageBox::NoIcon, 148 QMessageBox::NoIcon,
137 QMessageBox::Ok, 149 QMessageBox::Ok,
138 QMessageBox::NoButton, 150 QMessageBox::NoButton,
139 QMessageBox::NoButton); 151 QMessageBox::NoButton);
140 mb->exec(); 152 mb->exec();
141 perror("ButtonDialog::GetRemotes"); 153 perror("ButtonDialog::GetRemotes");
142 return NULL; 154 return NULL;
143 } 155 }
144 156
145 std::close(fd); 157 std::close(fd);
146 return list; 158 return list;
147} 159}
148 160
149QStringList ButtonDialog::getButtons(const char *remoteName) 161QStringList 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
177 for(i=0; i<5; i++) 202 for(i=0; i<5; i++)
178 { 203 {
179 readbuffer = readPacket(); 204 readbuffer = readPacket();
180 } 205 }
181 206
182 numlines = atoi(readbuffer); 207 numlines = atoi(readbuffer);
183 208
184 for(i=0; i<numlines; i++) 209 for(i=0; i<numlines; i++)
185 { 210 {
186 list+=readPacket(); 211 list+=readPacket();
187 for(j=0; j<list[i].length(); j++) 212 for(j=0; j<list[i].length(); j++)
188 { 213 {
189 if(list[i][j] == ' ') 214 if(list[i][j] == ' ')
190 break; 215 break;
191 } 216 }
192 list[i].remove(0, j+1); 217 list[i].remove(0, j+1);
193 } 218 }
194 219
195 if(strcasecmp(readPacket(), "END") != 0) 220 if(strcasecmp(readPacket(), "END") != 0)
196 { 221 {
197 QMessageBox *mb = new QMessageBox("Error!", 222 QMessageBox *mb = new QMessageBox("Error!",
198 "bad packet", 223 "bad packet",
199 QMessageBox::NoIcon, 224 QMessageBox::NoIcon,
200 QMessageBox::Ok, 225 QMessageBox::Ok,
201 QMessageBox::NoButton, 226 QMessageBox::NoButton,
202 QMessageBox::NoButton); 227 QMessageBox::NoButton);
203 mb->exec(); 228 mb->exec();
204 perror("ButtonDialog::GetButtons"); 229 perror("ButtonDialog::GetButtons");
205 return NULL; 230 return NULL;
206 } 231 }
207 232
208 std::close(fd); 233 std::close(fd);
209 return list; 234 return list;
210} 235}
211 236
212 237
213//this function was ripped for rc.c in xrc, it is available here: http://www.lirc.org/software.html 238//this function was ripped for rc.c in xrc, it is available here: http://www.lirc.org/software.html
214const char *ButtonDialog::readPacket() 239const char *ButtonDialog::readPacket()
215{ 240{
216 static char buffer[PACKET_SIZE+1]=""; 241 static char buffer[PACKET_SIZE+1]="";
217 char *end; 242 char *end;
218 static int ptr=0,end_len=0; 243 static int ptr=0,end_len=0;
219 ssize_t ret; 244 ssize_t ret;
220 timeout = 0; 245 timeout = 0;
221 246
222 if(ptr>0) 247 if(ptr>0)
223 { 248 {
224 memmove(buffer,buffer+ptr,strlen(buffer+ptr)+1); 249 memmove(buffer,buffer+ptr,strlen(buffer+ptr)+1);
225 ptr=strlen(buffer); 250 ptr=strlen(buffer);
226 end=strchr(buffer,'\n'); 251 end=strchr(buffer,'\n');
227 } 252 }
228 else 253 else
229 { 254 {
230 end=NULL; 255 end=NULL;
231 } 256 }
232 alarm(TIMEOUT); 257 alarm(TIMEOUT);
233 while(end==NULL) 258 while(end==NULL)
234 { 259 {
235 if(PACKET_SIZE<=ptr) 260 if(PACKET_SIZE<=ptr)
236 { 261 {
237 fprintf(stderr,"bad packet\n"); 262 fprintf(stderr,"bad packet\n");
238 ptr=0; 263 ptr=0;
239 return(NULL); 264 return(NULL);
240 } 265 }
241 ret=read(fd,buffer+ptr,PACKET_SIZE-ptr); 266 ret=read(fd,buffer+ptr,PACKET_SIZE-ptr);
242 267
243 if(ret<=0 || timeout) 268 if(ret<=0 || timeout)
244 { 269 {
245 if(timeout) 270 if(timeout)
246 { 271 {
247 fprintf(stderr,"timeout\n"); 272 fprintf(stderr,"timeout\n");
248 } 273 }
249 else 274 else
250 { 275 {
251 alarm(0); 276 alarm(0);
252 } 277 }
253 ptr=0; 278 ptr=0;
254 return(NULL); 279 return(NULL);
255 } 280 }
256 buffer[ptr+ret]=0; 281 buffer[ptr+ret]=0;
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
@@ -1,159 +1,172 @@
1/* 1/*
2Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. 2Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie.
3Copyright (C) 2002 Thomas Stephens 3Copyright (C) 2002 Thomas Stephens
4 4
5This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public 5This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
6License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later 6License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
7version. 7version.
8 8
9This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 9This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
10implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 10implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11Public License for more details. 11Public License for more details.
12 12
13You should have received a copy of the GNU General Public License along with this program; if not, write to the Free 13You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
14Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 14Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15*/ 15*/
16 16
17#include "remotetab.h" 17#include "remotetab.h"
18 18
19RemoteTab::RemoteTab(QWidget *parent=0, const char *name=0):QWidget(parent,name) 19RemoteTab::RemoteTab(QWidget *parent=0, const char *name=0):QWidget(parent,name)
20{ 20{
21 QVBoxLayout *layout = new QVBoxLayout(this); 21 QVBoxLayout *layout = new QVBoxLayout(this);
22 22
23 topGroup = new TopGroup(this); 23 topGroup = new TopGroup(this);
24 //topGroup->setMaximumHeight(22); 24 //topGroup->setMaximumHeight(22);
25 layout->addWidget(topGroup, 0, 0); 25 layout->addWidget(topGroup, 0, 0);
26 printf("%d %d", topGroup->width(), topGroup->height()); 26 printf("%d %d", topGroup->width(), topGroup->height());
27 27
28 layout->addSpacing(1); 28 layout->addSpacing(1);
29 29
30 dvdGroup = new DVDGroup(this); 30 dvdGroup = new DVDGroup(this);
31 //dvdGroup->setMaximumHeight(68); 31 //dvdGroup->setMaximumHeight(68);
32 layout->addWidget(dvdGroup, 0, 0); 32 layout->addWidget(dvdGroup, 0, 0);
33 33
34 layout->addSpacing(1); 34 layout->addSpacing(1);
35 35
36 vcrGroup = new VCRGroup(this); 36 vcrGroup = new VCRGroup(this);
37 layout->addWidget(vcrGroup, 0, 0); 37 layout->addWidget(vcrGroup, 0, 0);
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
54void RemoteTab::sendIR() 54int 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
80 printf("1\n"); 93 printf("1\n");
81 printf("%d\n", write(fd, write_buffer, strlen(write_buffer) ) ); 94 printf("%d\n", write(fd, write_buffer, strlen(write_buffer) ) );
82 printf("2\n"); 95 printf("2\n");
83 while(!done) 96 while(!done)
84 { 97 {
85 read_buffer=readPacket(); 98 read_buffer=readPacket();
86 printf("%s\n", read_buffer); 99 printf("%s\n", read_buffer);
87 if(strcasecmp(read_buffer, "END") == 0) 100 if(strcasecmp(read_buffer, "END") == 0)
88 { 101 {
89 printf("done reading packet\n"); 102 printf("done reading packet\n");
90 done=true; 103 done=true;
91 } 104 }
92 } 105 }
93 std::close(fd); 106 std::close(fd);
94} 107}
95 108
96 // printf("%s\n", readPacket()); 109 // printf("%s\n", readPacket());
97 // printf("%d\n", read(fd, read_buffer,sizeof(read_buffer)) ); 110 // printf("%d\n", read(fd, read_buffer,sizeof(read_buffer)) );
98 // printf("%s", read_buffer); 111 // printf("%s", read_buffer);
99 112
100//this function was ripped for rc.c in xrc, it is available here: http://www.lirc.org/software.html 113//this function was ripped for rc.c in xrc, it is available here: http://www.lirc.org/software.html
101const char *RemoteTab::readPacket() 114const char *RemoteTab::readPacket()
102{ 115{
103 static char buffer[PACKET_SIZE+1]=""; 116 static char buffer[PACKET_SIZE+1]="";
104 char *end; 117 char *end;
105 static int ptr=0,end_len=0; 118 static int ptr=0,end_len=0;
106 ssize_t ret; 119 ssize_t ret;
107 120
108 if(ptr>0) 121 if(ptr>0)
109 { 122 {
110 memmove(buffer,buffer+ptr,strlen(buffer+ptr)+1); 123 memmove(buffer,buffer+ptr,strlen(buffer+ptr)+1);
111 ptr=strlen(buffer); 124 ptr=strlen(buffer);
112 end=strchr(buffer,'\n'); 125 end=strchr(buffer,'\n');
113 } 126 }
114 else 127 else
115 { 128 {
116 end=NULL; 129 end=NULL;
117 } 130 }
118 alarm(TIMEOUT); 131 alarm(TIMEOUT);
119 while(end==NULL) 132 while(end==NULL)
120 { 133 {
121 if(PACKET_SIZE<=ptr) 134 if(PACKET_SIZE<=ptr)
122 { 135 {
123 // fprintf(stderr,"%s: bad packet\n",progname); 136 // fprintf(stderr,"%s: bad packet\n",progname);
124 ptr=0; 137 ptr=0;
125 return(NULL); 138 return(NULL);
126 } 139 }
127 ret=read(fd,buffer+ptr,PACKET_SIZE-ptr); 140 ret=read(fd,buffer+ptr,PACKET_SIZE-ptr);
128 141
129 if(ret<=0 || timeout) 142 if(ret<=0 || timeout)
130 { 143 {
131 if(timeout) 144 if(timeout)
132 { 145 {
133 // fprintf(stderr,"%s: timeout\n",progname); 146 // fprintf(stderr,"%s: timeout\n",progname);
134 } 147 }
135 else 148 else
136 { 149 {
137 alarm(0); 150 alarm(0);
138 } 151 }
139 ptr=0; 152 ptr=0;
140 return(NULL); 153 return(NULL);
141 } 154 }
142 buffer[ptr+ret]=0; 155 buffer[ptr+ret]=0;
143 ptr=strlen(buffer); 156 ptr=strlen(buffer);
144 end=strchr(buffer,'\n'); 157 end=strchr(buffer,'\n');
145 } 158 }
146 alarm(0);timeout=0; 159 alarm(0);timeout=0;
147 160
148 end[0]=0; 161 end[0]=0;
149 ptr=strlen(buffer)+1; 162 ptr=strlen(buffer)+1;
150//# ifdef DEBUG 163//# ifdef DEBUG
151 //printf("buffer: -%s-\n",buffer); 164 //printf("buffer: -%s-\n",buffer);
152//# endif 165//# endif
153 return(buffer); 166 return(buffer);
154} 167}
155 168
156void RemoteTab::setIRSocket(int newfd) 169void RemoteTab::setIRSocket(int newfd)
157{ 170{
158 fd = newfd; 171 fd = newfd;
159} 172}
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
@@ -1,64 +1,64 @@
1/* 1/*
2Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. 2Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie.
3Copyright (C) 2002 Thomas Stephens 3Copyright (C) 2002 Thomas Stephens
4 4
5This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public 5This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
6License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later 6License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
7version. 7version.
8 8
9This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 9This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
10implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 10implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11Public License for more details. 11Public License for more details.
12 12
13You should have received a copy of the GNU General Public License along with this program; if not, write to the Free 13You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
14Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 14Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15*/ 15*/
16 16
17#include <qpe/config.h> 17#include <qpe/config.h>
18#include <qwidget.h> 18#include <qwidget.h>
19#include <qlayout.h> 19#include <qlayout.h>
20#include <qvbox.h> 20#include <qvbox.h>
21#include <qmessagebox.h> 21#include <qmessagebox.h>
22#include <qstring.h> 22#include <qstring.h>
23#include <qsize.h> 23#include <qsize.h>
24#include <qobjectlist.h> 24#include <qobjectlist.h>
25 25
26#include <stdio.h> 26#include <stdio.h>
27#include <stdlib.h> 27#include <stdlib.h>
28#include <string.h> 28#include <string.h>
29#include <sys/socket.h> 29#include <sys/socket.h>
30#include <sys/types.h> 30#include <sys/types.h>
31#include <sys/un.h> 31#include <sys/un.h>
32#include <unistd.h> 32#include <unistd.h>
33#include <errno.h> 33#include <errno.h>
34 34
35#include "topgroup.h" 35#include "topgroup.h"
36#include "dvdgroup.h" 36#include "dvdgroup.h"
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
43class RemoteTab : public QWidget 43class RemoteTab : public QWidget
44{ 44{
45 Q_OBJECT 45 Q_OBJECT
46public: 46public:
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();
52public slots: 52public slots:
53 void sendIR(); 53 int sendIR();
54 void remoteSelected(const QString &string); 54 void remoteSelected(const QString &string);
55private: 55private:
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};