-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index dd8a365..09a44e6 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -77,94 +77,89 @@ Wellenreiter::Wellenreiter( QWidget* parent ) | |||
77 | manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" ); | 77 | manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" ); |
78 | #endif | 78 | #endif |
79 | manufacturerdb = new ManufacturerDB( manufile ); | 79 | manufacturerdb = new ManufacturerDB( manufile ); |
80 | 80 | ||
81 | logwindow->log( "(i) Wellenreiter has been started." ); | 81 | logwindow->log( "(i) Wellenreiter has been started." ); |
82 | 82 | ||
83 | // | 83 | // |
84 | // detect operating system | 84 | // detect operating system |
85 | // | 85 | // |
86 | 86 | ||
87 | #ifdef QWS | 87 | #ifdef QWS |
88 | QString sys; | 88 | QString sys; |
89 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); | 89 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); |
90 | _system = ODevice::inst()->system(); | 90 | _system = ODevice::inst()->system(); |
91 | logwindow->log( sys ); | 91 | logwindow->log( sys ); |
92 | #endif | 92 | #endif |
93 | 93 | ||
94 | // | 94 | // |
95 | // setup socket for daemon communication, register socket notifier | 95 | // setup socket for daemon communication, register socket notifier |
96 | // | 96 | // |
97 | 97 | ||
98 | // struct sockaddr_in sockaddr; | 98 | // struct sockaddr_in sockaddr; |
99 | daemon_fd = wl_setupsock( GUIADDR, GUIPORT, sockaddr ); | 99 | daemon_fd = wl_setupsock( GUIADDR, GUIPORT, sockaddr ); |
100 | if ( daemon_fd == -1 ) | 100 | if ( daemon_fd == -1 ) |
101 | { | 101 | { |
102 | logwindow->log( "(E) Couldn't get file descriptor for commsocket." ); | 102 | logwindow->log( "(E) Couldn't get file descriptor for commsocket." ); |
103 | } | 103 | } |
104 | else | 104 | else |
105 | { | 105 | { |
106 | int flags; | 106 | int flags; |
107 | flags = fcntl( daemon_fd, F_GETFL, 0 ); | 107 | flags = fcntl( daemon_fd, F_GETFL, 0 ); |
108 | fcntl( daemon_fd, F_SETFL, flags | O_NONBLOCK ); | 108 | fcntl( daemon_fd, F_SETFL, flags | O_NONBLOCK ); |
109 | QSocketNotifier *sn = new QSocketNotifier( daemon_fd, QSocketNotifier::Read, parent ); | 109 | QSocketNotifier *sn = new QSocketNotifier( daemon_fd, QSocketNotifier::Read, this ); |
110 | connect( sn, SIGNAL( activated( int ) ), this, SLOT( dataReceived() ) ); | 110 | connect( sn, SIGNAL( activated( int ) ), this, SLOT( dataReceived() ) ); |
111 | } | 111 | } |
112 | 112 | ||
113 | // setup GUI | 113 | // setup GUI |
114 | netview->setColumnWidthMode( 1, QListView::Manual ); | 114 | netview->setColumnWidthMode( 1, QListView::Manual ); |
115 | 115 | ||
116 | if ( manufacturerdb ) | 116 | if ( manufacturerdb ) |
117 | netview->setManufacturerDB( manufacturerdb ); | 117 | netview->setManufacturerDB( manufacturerdb ); |
118 | 118 | ||
119 | } | 119 | } |
120 | 120 | ||
121 | Wellenreiter::~Wellenreiter() | 121 | Wellenreiter::~Wellenreiter() |
122 | { | 122 | { |
123 | // no need to delete child widgets, Qt does it all for us | 123 | // no need to delete child widgets, Qt does it all for us |
124 | 124 | ||
125 | delete manufacturerdb; | 125 | delete manufacturerdb; |
126 | 126 | ||
127 | // X11-only - Hmm... Closing the socket here segfaults on exit, | ||
128 | // Maybe because the notifier still has a handle to it!? Seems not to | ||
129 | // occur on Qt/Embedded | ||
130 | |||
131 | #ifdef QWS | ||
132 | if ( daemon_fd != -1 ) | 127 | if ( daemon_fd != -1 ) |
133 | { | 128 | { |
134 | qDebug( "closing comm socket" ); | 129 | qDebug( "closing comm socket" ); |
135 | close( daemon_fd ); | 130 | ::shutdown( daemon_fd, 0 ); |
131 | ::close( daemon_fd ); | ||
132 | qDebug( "comm socket closed." ); | ||
136 | } | 133 | } |
137 | #endif | ||
138 | |||
139 | } | 134 | } |
140 | 135 | ||
141 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) | 136 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) |
142 | { | 137 | { |
143 | configwindow = cw; | 138 | configwindow = cw; |
144 | } | 139 | } |
145 | 140 | ||
146 | void Wellenreiter::handleMessage() | 141 | void Wellenreiter::handleMessage() |
147 | { | 142 | { |
148 | // FIXME: receive message and handle it | 143 | // FIXME: receive message and handle it |
149 | 144 | ||
150 | qDebug( "received message from daemon." ); | 145 | qDebug( "received message from daemon." ); |
151 | 146 | ||
152 | /*char buffer[10000]; | 147 | /*char buffer[10000]; |
153 | memset( &buffer, 0, sizeof( buffer ) );*/ | 148 | memset( &buffer, 0, sizeof( buffer ) );*/ |
154 | 149 | ||
155 | char buffer[WL_SOCKBUF]; | 150 | char buffer[WL_SOCKBUF]; |
156 | 151 | ||
157 | // int result = #wl_recv( &daemon_fd, (char*) &buffer, sizeof(buffer) ); | 152 | // int result = #wl_recv( &daemon_fd, (char*) &buffer, sizeof(buffer) ); |
158 | 153 | ||
159 | /* | 154 | /* |
160 | 155 | ||
161 | struct sockaddr from; | 156 | struct sockaddr from; |
162 | socklen_t len; | 157 | socklen_t len; |
163 | 158 | ||
164 | int result = recvfrom( daemon_fd, &buffer, 8192, MSG_WAITALL, &from, &len ); | 159 | int result = recvfrom( daemon_fd, &buffer, 8192, MSG_WAITALL, &from, &len ); |
165 | qDebug( "received %d from recv [%d bytes]", result, len ); | 160 | qDebug( "received %d from recv [%d bytes]", result, len ); |
166 | 161 | ||
167 | */ | 162 | */ |
168 | 163 | ||
169 | int result = wl_recv( &daemon_fd, sockaddr, (char*) &buffer, WL_SOCKBUF ); | 164 | int result = wl_recv( &daemon_fd, sockaddr, (char*) &buffer, WL_SOCKBUF ); |
170 | 165 | ||