Permalink
Browse files

Converts MythSocket from Qt3 based MSocketDevice to Qt4 QTcpSocket.

  • Loading branch information...
daniel-kristjansson committed Oct 11, 2012
1 parent 4587563 commit 0b106b10692ed7efd5eae81b498f591ad39b6222
Showing with 1,100 additions and 1,597 deletions.
  1. +19 −19 mythplugins/mythzoneminder/mythzoneminder/zmclient.cpp
  2. +0 −2 mythtv/libs/libmyth/mythcontext.cpp
  3. +4 −5 mythtv/libs/libmythbase/libmythbase.pro
  4. +76 −93 mythtv/libs/libmythbase/mythcorecontext.cpp
  5. +1 −1 mythtv/libs/libmythbase/mythmiscutil.cpp
  6. +605 −635 mythtv/libs/libmythbase/mythsocket.cpp
  7. +99 −94 mythtv/libs/libmythbase/mythsocket.h
  8. +1 −0 mythtv/libs/libmythbase/mythsocket_cb.h
  9. +0 −389 mythtv/libs/libmythbase/mythsocketthread.cpp
  10. +0 −49 mythtv/libs/libmythbase/mythsocketthread.h
  11. +66 −94 mythtv/libs/libmythbase/remotefile.cpp
  12. +0 −5 mythtv/libs/libmythbase/remotefile.h
  13. +35 −33 mythtv/libs/libmythprotoserver/mythsocketmanager.cpp
  14. +7 −3 mythtv/libs/libmythprotoserver/mythsocketmanager.h
  15. +7 −8 mythtv/libs/libmythprotoserver/requesthandler/basehandler.cpp
  16. +35 −32 mythtv/libs/libmythprotoserver/requesthandler/fileserverhandler.cpp
  17. +2 −2 mythtv/libs/libmythprotoserver/requesthandler/messagehandler.cpp
  18. +2 −14 mythtv/libs/libmythprotoserver/requesthandler/outboundhandler.cpp
  19. +2 −8 mythtv/libs/libmythprotoserver/sockethandler.cpp
  20. +1 −1 mythtv/libs/libmythprotoserver/sockethandler.h
  21. +4 −4 mythtv/libs/libmythprotoserver/sockethandler/filetransfer.cpp
  22. +2 −2 mythtv/libs/libmythtv/remoteencoder.cpp
  23. +4 −0 mythtv/libs/libmythupnp/libmythupnp.pro
  24. 0 mythtv/libs/{libmythbase → libmythupnp}/msocketdevice.cpp
  25. 0 mythtv/libs/{libmythbase → libmythupnp}/msocketdevice.h
  26. 0 mythtv/libs/{libmythbase → libmythupnp}/msocketdevice_unix.cpp
  27. 0 mythtv/libs/{libmythbase → libmythupnp}/msocketdevice_win.cpp
  28. +1 −0 mythtv/programs/mythbackend/encoderlink.cpp
  29. +3 −3 mythtv/programs/mythbackend/filetransfer.cpp
  30. +4 −7 mythtv/programs/mythbackend/main_helpers.cpp
  31. +113 −68 mythtv/programs/mythbackend/mainserver.cpp
  32. +3 −1 mythtv/programs/mythbackend/mainserver.h
  33. +1 −21 mythtv/programs/mythbackend/playbacksock.cpp
  34. +2 −3 mythtv/programs/mythbackend/server.cpp
  35. +1 −1 mythtv/programs/mythbackend/server.h
@@ -97,7 +97,7 @@ bool ZMClient::connectToHost(const QString &lhostname, unsigned int lport)
m_socket = new MythSocket();
//m_socket->setCallbacks(this);
if (!m_socket->connect(m_hostname, m_port))
if (!m_socket->ConnectToHost(m_hostname, m_port))
{
m_socket->DecrRef();
m_socket = NULL;
@@ -133,33 +133,35 @@ bool ZMClient::connectToHost(const QString &lhostname, unsigned int lport)
bool ZMClient::sendReceiveStringList(QStringList &strList)
{
QStringList origStrList = strList;
bool ok = false;
if (m_bConnected)
{
m_socket->writeStringList(strList);
ok = m_socket->readStringList(strList, false);
}
ok = m_socket->SendReceiveStringList(strList);
if (!ok)
{
LOG(VB_GENERAL, LOG_NOTICE, "Connection to mythzmserver lost");
if (!connectToHost(m_hostname, m_port))
{
LOG(VB_GENERAL, LOG_ERR, "Re connection to mythzmserver failed");
LOG(VB_GENERAL, LOG_ERR, "Re-connection to mythzmserver failed");
return false;
}
// try to resend
m_socket->writeStringList(strList);
ok = m_socket->readStringList(strList, false);
// try to resend
strList = origStrList;
ok = m_socket->SendReceiveStringList(strList);
if (!ok)
{
m_bConnected = false;
return false;
}
}
if (strList.empty())
return false;
// the server sends "UNKNOWN_COMMAND" if it did not recognise the command
if (strList[0] == "UNKNOWN_COMMAND")
{
@@ -231,7 +233,7 @@ void ZMClient::shutdown()
QMutexLocker locker(&m_socketLock);
if (m_socket)
m_socket->close();
m_socket->DisconnectFromHost();
m_zmclientReady = false;
m_bConnected = false;
@@ -456,7 +458,8 @@ bool ZMClient::readData(unsigned char *data, int dataSize)
while (dataSize > 0)
{
qint64 sret = m_socket->readBlock((char*) data + read, dataSize);
qint64 sret = m_socket->Read(
(char*) data + read, dataSize, 100 /*ms*/);
if (sret > 0)
{
read += sret;
@@ -466,18 +469,17 @@ bool ZMClient::readData(unsigned char *data, int dataSize)
timer.start();
}
}
else if (sret < 0 && m_socket->error() != MSocketDevice::NoError)
else if (sret < 0)
{
LOG(VB_GENERAL, LOG_ERR, QString("readData: Error, readBlock %1")
.arg(m_socket->errorToString()));
m_socket->close();
LOG(VB_GENERAL, LOG_ERR, "readData: Error, readBlock");
m_socket->DisconnectFromHost();
return false;
}
else if (!m_socket->isValid())
else if (!m_socket->IsConnected())
{
LOG(VB_GENERAL, LOG_ERR,
"readData: Error, socket went unconnected");
m_socket->close();
m_socket->DisconnectFromHost();
return false;
}
else
@@ -499,8 +501,6 @@ bool ZMClient::readData(unsigned char *data, int dataSize)
LOG(VB_GENERAL, LOG_ERR, "Error, readData timeout (readBlock)");
return false;
}
usleep(500);
}
}
@@ -26,7 +26,6 @@ using namespace std;
#include "dbutil.h"
#include "DisplayRes.h"
#include "mythmediamonitor.h"
#include "mythsocketthread.h"
#include "mythdb.h"
#include "mythdirs.h"
@@ -1168,7 +1167,6 @@ MythContext::~MythContext()
if (MThreadPool::globalInstance()->activeThreadCount())
LOG(VB_GENERAL, LOG_INFO, "Waiting for threads to exit.");
ShutdownRRT();
MThreadPool::globalInstance()->waitForDone();
logStop();
@@ -11,7 +11,7 @@ QMAKE_CLEAN += $(TARGET) $(TARGETA) $(TARGETD) $(TARGET0) $(TARGET1) $(TARGET2)
# Input
HEADERS += mthread.h mthreadpool.h
HEADERS += mythsocket.h mythsocket_cb.h mythsocketthread.h msocketdevice.h
HEADERS += mythsocket.h mythsocket_cb.h
HEADERS += mythbaseexp.h mythdbcon.h mythdb.h mythdbparams.h oldsettings.h
HEADERS += verbosedefs.h mythversion.h compat.h mythconfig.h
HEADERS += mythobservable.h mythevent.h httpcomms.h mcodecs.h
@@ -28,7 +28,7 @@ HEADERS += plist.h bswap.h signalhandling.h mythtimezone.h mythdate.h
HEADERS += ffmpeg-mmx.h
SOURCES += mthread.cpp mthreadpool.cpp
SOURCES += mythsocket.cpp mythsocketthread.cpp msocketdevice.cpp
SOURCES += mythsocket.cpp
SOURCES += mythdbcon.cpp mythdb.cpp mythdbparams.cpp oldsettings.cpp
SOURCES += mythobservable.cpp mythevent.cpp httpcomms.cpp mcodecs.cpp
SOURCES += mythdirs.cpp mythsignalingtimer.cpp
@@ -42,9 +42,8 @@ SOURCES += referencecounter.cpp mythcommandlineparser.cpp
SOURCES += filesysteminfo.cpp hardwareprofile.cpp serverpool.cpp
SOURCES += plist.cpp signalhandling.cpp mythtimezone.cpp mythdate.cpp
win32:SOURCES += msocketdevice_win.cpp
unix {
SOURCES += msocketdevice_unix.cpp system-unix.cpp
SOURCES += system-unix.cpp
HEADERS += system-unix.h
QMAKE_CXXFLAGS += -fno-strict-aliasing
}
@@ -60,7 +59,7 @@ inc.files = mythdbcon.h mythdbparams.h mythbaseexp.h mythdb.h
inc.files += compat.h mythversion.h mythconfig.h mythconfig.mak version.h
inc.files += mythobservable.h mythevent.h httpcomms.h mcodecs.h verbosedefs.h
inc.files += mythtimer.h lcddevice.h exitcodes.h mythdirs.h mythstorage.h
inc.files += mythsocket.h mythsocket_cb.h msocketdevice.h mythlogging.h
inc.files += mythsocket.h mythsocket_cb.h mythlogging.h
inc.files += mythcorecontext.h mythsystem.h storagegroup.h loggingserver.h
inc.files += mythcoreutil.h mythlocale.h mythdownloadmanager.h
inc.files += mythtranslation.h iso639.h iso3166.h mythmedia.h mythmiscutil.h
Oops, something went wrong.

0 comments on commit 0b106b1

Please sign in to comment.