@@ -47,8 +47,7 @@ bool WSServer::isControlCommand(USB2SnesWS::opcode opcode)
4747
4848#define CMD_TAKE_ONE_ARG (cmd ) if (req->arguments.size() != 1 ) \
4949{ \
50- setError (ErrorType::CommandError, QString (" %1 command take one argument" ).arg (cmd)); \
51- clientError (client); \
50+ client->sendError (ErrorType::CommandError, QString (" %1 command take one argument" ).arg (cmd)); \
5251 return ; \
5352}
5453
@@ -169,8 +168,7 @@ void WSServer::executeRequest(MRequest *req)
169168 case USB2SnesWS::PutFile : {
170169 if (req->arguments .size () != 2 )
171170 {
172- setError (ErrorType::CommandError, " PutFile command take 2 arguments (file1, SizeInHex)" );
173- clientError (client);
171+ client->sendError (ErrorType::CommandError, " PutFile command take 2 arguments (file1, SizeInHex)" );
174172 return ;
175173 }
176174 bool ok;
@@ -183,8 +181,7 @@ void WSServer::executeRequest(MRequest *req)
183181 case USB2SnesWS::Rename : {
184182 if (req->arguments .size () != 2 )
185183 {
186- setError (ErrorType::CommandError, " Rename command take 2 arguments (file1, file2)" );
187- clientError (client);
184+ client->sendError (ErrorType::CommandError, " Rename command take 2 arguments (file1, file2)" );
188185 return ;
189186 }
190187 device->fileCommand (SD2Snes::opcode::MV, QVector<QByteArray>() << req->arguments .at (0 ).toLatin1 ()
@@ -211,8 +208,7 @@ void WSServer::executeRequest(MRequest *req)
211208 case USB2SnesWS::GetAddress : {
212209 if (req->arguments .size () < 2 )
213210 {
214- setError (ErrorType::CommandError, " GetAddress commands take at least 2 arguments (AddressInHex, SizeInHex)" );
215- clientError (client);
211+ client->sendError (ErrorType::CommandError, " GetAddress commands take at least 2 arguments (AddressInHex, SizeInHex)" );
216212 return ;
217213 }
218214 connect (device, &ADevice::getDataReceived, this , &WSServer::onDeviceGetDataReceived, Qt::UniqueConnection);
@@ -222,8 +218,7 @@ void WSServer::executeRequest(MRequest *req)
222218 {
223219 if (req->arguments .at (1 ).toUInt (&ok, 16 ) == 0 )
224220 {
225- setError (ErrorType::CommandError, " GetAddress - trying to read 0 byte" );
226- clientError (client);
221+ client->sendError (ErrorType::CommandError, " GetAddress - trying to read 0 byte" );
227222 return ;
228223 }
229224 device->getAddrCommand (req->space , req->arguments .at (0 ).toUInt (&ok, 16 ), req->arguments .at (1 ).toUInt (&ok, 16 ));
@@ -239,8 +234,7 @@ void WSServer::executeRequest(MRequest *req)
239234 unsigned usize = req->arguments .at (i + 1 ).toUInt (&ok, 16 );
240235 if (usize == 0 )
241236 {
242- setError (ErrorType::CommandError, " GetAddress - trying to read 0 byte" );
243- clientError (client);
237+ client->sendError (ErrorType::CommandError, " GetAddress - trying to read 0 byte" );
244238 return ;
245239 }
246240 if (usize > 255 )
@@ -249,8 +243,7 @@ void WSServer::executeRequest(MRequest *req)
249243 {
250244 split = true ;
251245 } else {
252- setError (ErrorType::CommandError, " GetAddress - VGet with a size > 255" );
253- clientError (client);
246+ client->sendError (ErrorType::CommandError, " GetAddress - VGet with a size > 255" );
254247 return ;
255248 }
256249 }
@@ -288,8 +281,7 @@ void WSServer::executeRequest(MRequest *req)
288281 case USB2SnesWS::PutAddress : {
289282 if (req->arguments .size () < 2 )
290283 {
291- setError (ErrorType::CommandError, " PutAddress command take at least 2 arguments (AddressInHex, SizeInHex)" );
292- clientError (client);
284+ client->sendError (ErrorType::CommandError, " PutAddress command take at least 2 arguments (AddressInHex, SizeInHex)" );
293285 return ;
294286 }
295287 bool ok;
@@ -302,8 +294,7 @@ void WSServer::executeRequest(MRequest *req)
302294 putSize = req->arguments .at (1 ).toUInt (&ok, 16 );
303295 if (putSize == 0 )
304296 {
305- setError (ErrorType::CommandError, " PutAddress - trying to write 0 byte" );
306- clientError (client);
297+ client->sendError (ErrorType::CommandError, " PutAddress - trying to write 0 byte" );
307298 return ;
308299 }
309300 if (req->flags .isEmpty ())
@@ -322,8 +313,7 @@ void WSServer::executeRequest(MRequest *req)
322313 {
323314 if (req->arguments .at (i + 1 ).toUInt (&ok, 16 ) == 0 )
324315 {
325- setError (ErrorType::CommandError, " PutAddress - trying to write 0 byte" );
326- clientError (client);
316+ client->sendError (ErrorType::CommandError, " PutAddress - trying to write 0 byte" );
327317 return ;
328318 }
329319 vputArgs.append (QPair<unsigned int , quint8>(req->arguments .at (i).toUInt (&ok, 16 ), req->arguments .at (i + 1 ).toUShort (&ok, 16 )));
@@ -379,8 +369,7 @@ void WSServer::executeRequest(MRequest *req)
379369 case USB2SnesWS::PutIPS : {
380370 if (req->arguments .size () < 2 )
381371 {
382- setError (ErrorType::CommandError, " PutIPS command take at least 2 arguments (Name, SizeInHex)" );
383- clientError (client);
372+ client->sendError (ErrorType::CommandError, " PutIPS command take at least 2 arguments (Name, SizeInHex)" );
384373 return ;
385374 }
386375 bool ok;
@@ -391,8 +380,8 @@ void WSServer::executeRequest(MRequest *req)
391380 }
392381 default :
393382 {
394- setError (ErrorType::ProtocolError, " Invalid command or non implemented" );
395- clientError (client) ;
383+ client-> sendError (ErrorType::ProtocolError, " Invalid command or non implemented" );
384+ return ;
396385 }
397386 }
398387
@@ -607,8 +596,7 @@ void WSServer::cmdAttach(MRequest *req)
607596 }
608597 if (devFact->attachError ().isEmpty () == false )
609598 {
610- setError (ErrorType::CommandError, " Attach Error with " + deviceToAttach + " - " + devFact->attachError ());
611- clientError (req->owner );
599+ req->owner ->sendError (ErrorType::CommandError, " Attach Error with " + deviceToAttach + " - " + devFact->attachError ());
612600 return ;
613601 }
614602 }
@@ -621,8 +609,7 @@ void WSServer::cmdAttach(MRequest *req)
621609 sDebug () << " Trying to open device" ;
622610 if (devGet->open () == false )
623611 {
624- setError (ErrorType::CommandError, " Attach: Can't open the device on " + deviceToAttach);
625- clientError (req->owner );
612+ req->owner ->sendError (ErrorType::CommandError, " Attach: Can't open the device on " + deviceToAttach);
626613 return ;
627614 }
628615 }
@@ -636,8 +623,7 @@ void WSServer::cmdAttach(MRequest *req)
636623 processCommandQueue (devGet);
637624 return ;
638625 } else {
639- setError (ErrorType::CommandError, " Trying to Attach to an unknow device" );
640- clientError (req->owner );
626+ req->owner ->sendError (ErrorType::CommandError, " Trying to Attach to an unknow device" );
641627 return ;
642628 }
643629}
0 commit comments