summaryrefslogtreecommitdiff
path: root/noncore/tools/remote
authorspiralman <spiralman>2002-05-16 21:14:13 (UTC)
committer spiralman <spiralman>2002-05-16 21:14:13 (UTC)
commitd8d70e07a09a7c50021f6c85690b79b422d43df5 (patch) (unidiff)
tree56e4655aca1eac9b46f44e78e2cc378e7f7033de /noncore/tools/remote
parentdaeba256e5a7442dde237f39a6272485e01b7ccd (diff)
downloadopie-d8d70e07a09a7c50021f6c85690b79b422d43df5.zip
opie-d8d70e07a09a7c50021f6c85690b79b422d43df5.tar.gz
opie-d8d70e07a09a7c50021f6c85690b79b422d43df5.tar.bz2
fixed segfault when socket() returns -1 (hopefully)
Diffstat (limited to 'noncore/tools/remote') (more/less context) (show 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
@@ -97,8 +97,20 @@ QStringList ButtonDialog::getRemotes()
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!",
@@ -157,8 +169,21 @@ QStringList ButtonDialog::getButtons(const char *remoteName)
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!",
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
@@ -50,9 +50,9 @@ RemoteTab::RemoteTab(QWidget *parent=0, const char *name=0):QWidget(parent,name)
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';
@@ -60,8 +60,21 @@ void RemoteTab::sendIR()
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!",
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
@@ -49,9 +49,9 @@ public:
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;