20 changes: 19 additions & 1 deletion mythtv/libs/libmythui/platforms/mythdisplaywindows.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "windows.h"

// MythTV
#include "mythdisplaywindows.h"
#include "mythmainwindow.h"

MythDisplayWindows::MythDisplayWindows()
: MythDisplay()
Expand All @@ -13,7 +16,22 @@ MythDisplayWindows::~MythDisplayWindows()

void MythDisplayWindows::UpdateCurrentMode(void)
{
HDC hdc = GetDC((HWND)GetWindowID());
QWidget* widget = m_widget;

if (!widget)
{
if (!HasMythMainWindow())
{
MythDisplay::UpdateCurrentMode();
return;
}
widget = qobject_cast<QWidget*>(MythMainWindow::getMainWindow());
}
WId win = 0;
if (widget)
win = widget->winId();

HDC hdc = GetDC((HWND)win);
if (!hdc)
{
MythDisplay::UpdateCurrentMode();
Expand Down
11 changes: 5 additions & 6 deletions mythtv/libs/libmythupnp/msocketdevice_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -910,8 +910,7 @@ qint64 MSocketDevice::bytesAvailable() const
return nbytes;
}


qint64 MSocketDevice::waitForMore(int msecs, bool *timeout) const
qint64 MSocketDevice::waitForMore(std::chrono::milliseconds msecs, bool *timeout) const
{
if (!isValid())
return -1;
Expand All @@ -924,13 +923,13 @@ qint64 MSocketDevice::waitForMore(int msecs, bool *timeout) const

fds.fd_array[0] = m_fd;

struct timeval tv;
struct timeval tv {};

tv.tv_sec = msecs / 1000;
tv.tv_sec = msecs.count() / 1000;

tv.tv_usec = (msecs % 1000) * 1000;
tv.tv_usec = (msecs.count() % 1000) * 1000;

int rv = select(m_fd + 1, &fds, nullptr, nullptr, msecs < 0 ? nullptr : &tv);
int rv = select(m_fd + 1, &fds, nullptr, nullptr, msecs < 0ms ? nullptr : &tv);

if (rv < 0)
return -1;
Expand Down
1 change: 0 additions & 1 deletion mythtv/programs/mythbackend/encoderlink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ bool EncoderLink::CheckFile(ProgramInfo *pginfo)
ReferenceLocker rlocker(m_sock);
return m_sock->CheckFile(pginfo);
}

pginfo->SetPathname(GetPlaybackURL(pginfo));
return pginfo->IsLocal();
}
Expand Down
7 changes: 7 additions & 0 deletions mythtv/programs/mythbackend/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,11 @@ int main(int argc, char **argv)
return retval;
}

#ifdef _WIN32 // TODO Needs fixing for Windows
QString GetPlaybackURL(ProgramInfo *pginfo, bool storePath)
{
return "";
}
#endif

/* vim: set expandtab tabstop=4 shiftwidth=4: */
19 changes: 14 additions & 5 deletions mythtv/programs/mythbackend/services/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,11 @@ bool Channel::UpdateDBChannel( uint MplexID,
channel.m_atscMinorChan = ATSCMinorChannel;
if (HAS_PARAM("useeit"))
channel.m_useOnAirGuide = UseEIT;
if (HAS_PARAM("extendedvisible"))
channel.m_visible = channelVisibleTypeFromString(ExtendedVisible);

#ifndef _WIN32 // TODO Does not compile on Windows
if (HAS_PARAM("extendedvisible"))
channel.m_visible = channelVisibleTypeFromString(ExtendedVisible);
#endif
else if (HAS_PARAM("visible"))
{
if (channel.m_visible == kChannelVisible ||
Expand Down Expand Up @@ -249,10 +252,16 @@ bool Channel::AddDBChannel( uint MplexID,
uint ServiceType )
{
ChannelVisibleType chan_visible = kChannelVisible;
if (HAS_PARAM("extendedvisible"))
chan_visible = channelVisibleTypeFromString(ExtendedVisible);
else if (HAS_PARAM("visible"))

#ifdef _WIN32 // TODO Needs fixing for Windows
chan_visible = (Visible ? kChannelVisible : kChannelNotVisible);
#else
if (HAS_PARAM("extendedvisible"))
chan_visible = channelVisibleTypeFromString(ExtendedVisible);
else if (HAS_PARAM("visible"))
chan_visible = (Visible ? kChannelVisible : kChannelNotVisible);
#endif


bool bResult = ChannelUtil::CreateChannel( MplexID, SourceID, ChannelID,
CallSign, ChannelName, ChannelNumber,
Expand Down
4 changes: 3 additions & 1 deletion mythtv/programs/mythbackend/services/serviceUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ bool FillChannelInfo( DTC::ChannelInfo *pChannel,
}
pChannel->setChannelName(channelInfo.m_name);
pChannel->setVisible(channelInfo.m_visible > kChannelNotVisible);
pChannel->setExtendedVisible(toRawString(channelInfo.m_visible));
#ifndef _WIN32 // Needs fixing for Windows
pChannel->setExtendedVisible(toRawString(channelInfo.m_visible));
#endif

pChannel->setSerializeDetails( bDetails );

Expand Down
2 changes: 1 addition & 1 deletion mythtv/programs/programs-libs.pro
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ win32 {
CONFIG += console
}

!win32-msvc* {
!mingw || win32-msvc* {
POST_TARGETDEPS += ../../libs/libmythui/libmythui-$${MYTH_SHLIB_EXT}
POST_TARGETDEPS += ../../libs/libmyth/libmyth-$${MYTH_SHLIB_EXT}
POST_TARGETDEPS += ../../libs/libmythtv/libmythtv-$${MYTH_SHLIB_EXT}
Expand Down
3 changes: 2 additions & 1 deletion mythtv/programs/programs.pro
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ TEMPLATE = subdirs
using_frontend {
SUBDIRS += mythavtest mythfrontend mythcommflag
SUBDIRS += mythjobqueue mythlcdserver
SUBDIRS += mythwelcome mythshutdown mythutil
SUBDIRS += mythshutdown mythutil
!win32-*: SUBDIRS += mythwelcome
SUBDIRS += mythpreviewgen mythmediaserver mythccextractor
SUBDIRS += mythscreenwizard
!mingw:!win32-msvc*: SUBDIRS += mythtranscode/external/replex
Expand Down
5 changes: 5 additions & 0 deletions mythtv/settings.pro
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ win32 {
# This corrects the moc tool path from a DOS-style to a unix style:
QMAKE_MOC = $$[QT_INSTALL_BINS]/moc
QMAKE_EXTENSION_SHLIB = dll

isEmpty(QMAKE_EXTENSION_LIB) {
QMAKE_EXTENSION_LIB=a
}
MYTH_LIB_EXT =$${LIBVERSION}.$${QMAKE_EXTENSION_LIB}
}

# if CYGWIN compile, set up flag in CONFIG
Expand Down
47 changes: 47 additions & 0 deletions platform/win32/w64-mingw32/Installer/1 Install Mythtv.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
echo off

echo "1. Run Install Mythtv.cmd"
echo "2. Go to General->'Host Address and Network setup' (should be 127.0.0.1) and then exit and save."
echo "When exiting click do not fix"
echo "3. Run MythFrontend & Backend"
echo "config.xml is stored in C:\Users\%username%\AppData\Local\mythtv". Please enter your backend ip address/password if required.
echo "You may need to tweak the frontend video profiles under Setup->Video->playback and select opengl normal"

echo "Press ctrl-x to quit the command prompt if mythtv gets stuck closing"

echo "Ok?"
pause


robocopy share C:\ProgramData\ /E

if not exist xampp-portable-windows.zip (
curl -L "https://sourceforge.net/projects/xampp/files/XAMPP%%20Windows/8.0.9/xampp-portable-windows-x64-8.0.9-0-VS16.zip/download" > xampp-portable-windows.zip
)

if not exist timezone_2021a_leaps.zip (
curl -L https://downloads.mysql.com/general/timezone_2021a_leaps.zip > timezone_2021a_leaps.zip
)

echo "copying files.."
tar -xf xampp-portable-windows.zip
tar -xf timezone_2021a_leaps.zip

robocopy timezone_2021a_leaps\ xampp\mysql\data\mysql\

rmdir -r timezone_2021a_leaps /s /q

cd xampp
start /min cmd /k "setup_xampp.bat"
TIMEOUT 5 /nobreak
start /min cmd /k "mysql\bin\mysqld --defaults-file=mysql\bin\my.ini --standalone"
TIMEOUT 7 /nobreak
echo "creating user"
"mysql\bin\mysql.exe" -u root -e "CREATE USER 'mythtv'@'localhost' IDENTIFIED BY 'mythtv';CREATE DATABASE mythconverg;GRANT ALL PRIVILEGES ON *.* TO 'mythtv'@'localhost';"

cd ..
TIMEOUT 1 /nobreak
"bin/mythbackend.exe"
TIMEOUT 2 /nobreak
"bin/mythtv-setup.exe"
"bin/mythtv-setup.exe"
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cd xampp
start /min cmd /k "mysql\bin\mysqld --defaults-file=mysql\bin\my.ini --standalone"
cd ..
TIMEOUT 1 /nobreak
start cmd /k "bin\mythbackend.exe"
TIMEOUT 16 /nobreak
"bin\mythfrontend.exe" --disable-autodiscovery --noupnp
pause
1 change: 1 addition & 0 deletions platform/win32/w64-mingw32/Installer/Run MythFrontend.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"bin/mythfrontend.exe" --disable-autodiscovery --noupnp
5 changes: 5 additions & 0 deletions platform/win32/w64-mingw32/Installer/Run MythTv Setup.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cd xampp
start /min cmd /k "mysql\bin\mysqld --defaults-file=mysql\bin\my.ini --standalone"
cd ..
"bin/mythtv-setup.exe"
pause
175 changes: 175 additions & 0 deletions platform/win32/w64-mingw32/MythBuild_MXE.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
echo "Tested on ubuntu 2004. Run this file to build mythtv for Windows"

sudo apt-get --assume-yes install git
sudo apt-get --assume-yes install gcc
sudo apt-get --assume-yes install g++
sudo apt-get --assume-yes install wget
sudo apt-get --assume-yes install python3
sudo apt-get --assume-yes install perl
sudo apt-get --assume-yes install bzip2
sudo apt-get --assume-yes install xy-utils
sudo apt-get --assume-yes install lzip
sudo apt-get --assume-yes install unzip
sudo apt-get --assume-yes install libssl-dev
sudo apt-get --assume-yes install p7zip
sudo apt-get --assume-yes install make
sudo apt-get --assume-yes install autoconf
sudo apt-get --assume-yes install automake
sudo apt-get --assume-yes install bison
sudo apt-get --assume-yes install flex
sudo apt-get --assume-yes install autopoint
sudo apt-get --assume-yes install gperf
sudo apt-get --assume-yes install libtool
sudo apt-get --assume-yes install libtool-bin
sudo apt-get --assume-yes install ruby
sudo apt-get --assume-yes install intltool
sudo apt-get --assume-yes install p7zip-full
sudo apt-get --assume-yes install python

export buildPath=$PWD"/build"
mkdir -p $buildPath
cd $buildPath
mkdir -p install
mkdir -p install/bin
mkdir -p install/bin/plugins
mkdir -p themes

cd $buildPath/themes
git clone https://github.com/paul-h/MythCenterXMAS-wide.git
git clone https://github.com/wesnewell/Functionality
git clone https://github.com/MythTV-Themes/TintedGlass
git clone https://github.com/MythTV-Themes/Readability
git clone https://github.com/MythTV-Themes/Steppes
git clone https://github.com/MythTV-Themes/Retro-wide
git clone https://github.com/MythTV-Themes/LCARS
git clone https://github.com/MythTV-Themes/Childish
git clone https://github.com/MythTV-Themes/Arclight
git clone https://github.com/MythTV-Themes/Mythbuntu
git clone https://github.com/MythTV-Themes/blue-abstract-wide
git clone https://github.com/MythTV-Themes/Mythbuntu-classic
cd ..

git clone https://github.com/MythTV/mythtv.git

git clone https://github.com/mxe/mxe.git

echo "Add SQL to QT"
sed -i 's/-no-sql-mysql /\//g' $buildPath/mxe/src/qt.mk

sudo apt-get --assume-yes install pkg-config

cd mxe
sudo make cc MXE_PLUGIN_DIRS=plugins/gcc8 MXE_TARGETS='i686-w64-mingw32.shared' vulkan-loader vulkan-headers qt5 nasm yasm libsamplerate taglib zlib gnutls mman-win32 pthreads libxml2 libdvdcss x264 x265 lame libass qtwebkit xvidcore libvpx vorbis flac
cd ..

find . -name \*.dll -exec cp {} \install/bin \;

export PATH=$buildPath"/mxe/usr/bin":$PATH
export qt5=$buildPath"/mxe/usr/i686-w64-mingw32.shared/qt5"
export in1=$buildPath"/mxe/usr/i686-w64-mingw32.shared"
sudo chmod -R 777 $buildPath/mxe

echo -e "#define RTLD_LAZY 0 \n#define HAVE_DVDCSS_DVDCSS_H" | sudo -E tee $buildPath/mxe/usr/i686-w64-mingw32.shared/include/dlfcn.h

sudo -E sed -i 's/#define GetUserName __MINGW_NAME_AW(GetUserName)//g' $buildPath/mxe/usr/i686-w64-mingw32.shared/include/winbase.h
sudo -E sed -i 's/#define CopyFile __MINGW_NAME_AW(CopyFile)//g' $buildPath/mxe/usr/i686-w64-mingw32.shared/include/winbase.h
sudo -E sed -i 's/#define MoveFile __MINGW_NAME_AW(MoveFile)//g' $buildPath/mxe/usr/i686-w64-mingw32.shared/include/winbase.h

sudo apt-get --assume-yes remove yasm

sudo cp $buildPath/mxe/usr/x86_64-pc-linux-gnu/bin/yasm $buildPath//mxe/usr/bin/yasm
sudo cp $buildPath/mxe/usr/bin/i686-w64-mingw32.shared-pkg-config $buildPath//mxe/usr/bin/pkg-config
sudo cp -R $buildPath/mxe/usr/lib/gcc/i686-w64-mingw32.shared/8.4.0/include/c++ $buildPath/mxe/usr/lib/gcc/i686-w64-mingw32.shared/8.4.0/include

cp $buildPath/mythtv/platform/win32/w64-mingw32/Patches/libexiv2.patch $buildPath/mythtv/libexiv2.patch
cd mythtv
git apply libexiv2.patch -v
rm libexiv2.patch
cd ..

echo "Compiling libudfread"
git clone https://code.videolan.org/videolan/libudfread.git
cd libudfread
./bootstrap
./configure --prefix=$buildPath/mxe/usr/i686-w64-mingw32.shared --host=i686-w64-mingw32.shared
make -j$(nproc)
sudo make install
cd ..

git clone https://code.videolan.org/videolan/libbluray.git
cd $buildPath/libbluray
git submodule update --init

sudo -E chmod -R 777 $buildPath/libbluray

echo "Compiling libbluray"
./bootstrap
./configure --prefix=$buildPath/mxe/usr/i686-w64-mingw32.shared --disable-examples --with-freetype --with-libxml2 --disable-bdjava-jar --host=i686-w64-mingw32.shared
make -j$(nproc)
make install
cd ..

echo "Compiling libzip"
git clone https://github.com/nih-at/libzip.git
sudo -E chmod -R 777 $buildPath/libzip
cd libzip
$buildPath/mxe/usr/bin/i686-w64-mingw32.shared-cmake $buildPath/libzip
make -j$(nproc)
make install
cd ..

echo "Install endian.h"
git clone https://gist.github.com/PkmX/63dd23f28ba885be53a5
sudo -E cp $buildPath/63dd23f28ba885be53a5/portable_endian.h $buildPath/mxe/usr/i686-w64-mingw32.shared/include/endian.h


sudo apt-get --assume-yes remove pkg-config

echo "Compiling mythtv"
cd $buildPath/mythtv/mythtv
./configure --prefix="$buildPath/install" --enable-cross-compile --cross-prefix=i686-w64-mingw32.shared- --target_os=mingw32 --arch=x86 --cpu=pentium3 --qmake=$qt5/bin/qmake --extra-cflags=-I$in1/include-I/home/ubuntu/Desktop/build/mxe/usr/lib/gcc/i686-w64-mingw32.shared/8.4.0/include/c++/i686-w64-mingw32.shared --extra-ldflags=-L$in1/lib --disable-lirc --disable-hdhomerun --disable-firewire --disable-ivtv --disable-vdpau --disable-nvdec --disable-dxva2 --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libxvid --enable-libvpx --disable-w32threads

make -j$(nproc)

sudo -E cp $buildPath/mythtv/mythtv/external/FFmpeg/ffmpeg_g.exe $buildPath/mythtv/mythtv/external/FFmpeg/mythffmpeg.exe
sudo -E cp $buildPath/mythtv/mythtv/external/FFmpeg/ffprobe_g.exe $buildPath/mythtv/mythtv/external/FFmpeg/mythffprobe.exe
sudo -E make install
cd ..

sudo chmod -R 777 $buildPath/install
cd mythplugins

./configure --prefix="$buildPath/install" -cross-prefix=i686-w64-mingw32.shared- --disable-mytharchive
make -j$(nproc) install
cd ..

cp -R $buildPath/mythtv/platform/win32/w64-mingw32/Installer/. $buildPath/install/
cp -R $buildPath/mythtv/mythtv/src/COPYING $buildPath/install/COPYING
cp -R $buildPath/themes/ $buildPath/install/share/mythtv/

cd $buildPath"/install/bin"

mv opengl32.dll SOFTWARE_opengl32.dll
rm opengl32.dll

mv libmythgame.dll plugins/libmythgame.dll
mv libmythnews.dll plugins/libmythnews.dll
mv libmythmusic.dll plugins/libmythmusic.dll
mv libmythbrowser.dll plugins/libmythbrowser.dll
mv libmythzoneminder.dll plugins/libmythzoneminder.dll


mkdir -p platforms
mkdir -p sqldrivers
cp qwindows.dll $buildPath"/install/bin/platforms/windowplugin.dll"
cp qwindowsvistastyle.dll $buildPath"/install/bin/platforms/qwindowsvistastyle.dll"
cp qwindowsvistastyle.dll $buildPath"/install/bin/platforms/libtasn1-6.dll"
cp qsqlmysql.dll $buildPath"/install/bin/sqldrivers/qsqlmysql.dll"
cd ..

find . -name \*.a -exec cp {} \lib \;
find . -name \*.lib -exec cp {} \lib \;

zip -r MythTv_Windows.zip *

echo "Done"
285 changes: 285 additions & 0 deletions platform/win32/w64-mingw32/Patches/libexiv2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
diff --git a/mythtv/external/libexiv2/include/exiv2/exv_conf.h b/mythtv/external/libexiv2/include/exiv2/exv_conf.h
index 99622ed5b7..ac0a9dfe20 100644
--- a/mythtv/external/libexiv2/include/exiv2/exv_conf.h
+++ b/mythtv/external/libexiv2/include/exiv2/exv_conf.h
@@ -13,7 +13,9 @@
/* #undef EXV_ENABLE_WEBREADY */

// Define if you have the `gmtime_r' function.
-#define EXV_HAVE_GMTIME_R
+#ifndef _WIN32
+ #define EXV_HAVE_GMTIME_R
+#endif

// Define if you have the <libintl.h> header file.
/* #undef EXV_HAVE_LIBINTL_H */
@@ -61,10 +63,14 @@
#define EXV_HAVE_STRINGS_H

// Define if you have the mmap function.
-#define EXV_HAVE_MMAP
+#ifndef _WIN32
+ #define EXV_HAVE_MMAP
+#endif

// Define if you have the munmap function.
-#define EXV_HAVE_MUNMAP
+#ifndef _WIN32
+ #define EXV_HAVE_MUNMAP
+#endif

// Define if you have <sys/stat.h> header file.
#define EXV_HAVE_SYS_STAT_H
diff --git a/mythtv/external/libexiv2/libexiv2.pro b/mythtv/external/libexiv2/libexiv2.pro
index 1ccb983477..04819c0cb3 100644
--- a/mythtv/external/libexiv2/libexiv2.pro
+++ b/mythtv/external/libexiv2/libexiv2.pro
@@ -5,6 +5,8 @@ TARGET = mythexiv2-0.28
target.path = $${LIBDIR}
INSTALLS = target

+mingw:LIBS += -lz -liconv
+
darwin {
QMAKE_CXXFLAGS = "-I. -I./include -I./include/exiv2 -I./src -I./xmpsdk/include" $${QMAKE_CXXFLAGS}
LIBS += -lexpat -liconv -lz
diff --git a/mythtv/external/libexiv2/src/crwimage_int.cpp b/mythtv/external/libexiv2/src/crwimage_int.cpp
index 9959f2310a..00bf2d333e 100644
--- a/mythtv/external/libexiv2/src/crwimage_int.cpp
+++ b/mythtv/external/libexiv2/src/crwimage_int.cpp
@@ -1141,7 +1141,7 @@ namespace Exiv2 {
struct tm tm;
std::memset(&tm, 0x0, sizeof(tm));
int rc = exifTime(ed->toString().c_str(), &tm);
- if (rc == 0) t = timegm(&tm);
+ //if (rc == 0) t = timegm(&tm);
}
if (t != 0) {
DataBuf buf(12);
diff --git a/mythtv/external/libexiv2/src/futils.cpp b/mythtv/external/libexiv2/src/futils.cpp
index 884fb5ff68..9948ff18e1 100644
--- a/mythtv/external/libexiv2/src/futils.cpp
+++ b/mythtv/external/libexiv2/src/futils.cpp
@@ -479,9 +479,9 @@ namespace Exiv2 {
processHandle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, GetCurrentProcessId());
if (processHandle != nullptr) {
TCHAR filename[MAX_PATH];
- if (GetModuleFileNameEx(processHandle, nullptr, filename, MAX_PATH) != 0) {
+ //if (GetModuleFileNameEx(processHandle, nullptr, filename, MAX_PATH) != 0) {
ret = filename;
- }
+ //}
CloseHandle(processHandle);
}
#elif defined(__APPLE__)
@@ -526,14 +526,14 @@ namespace Exiv2 {
// enumerate loaded libraries and determine path to executable
HMODULE handles[200];
DWORD cbNeeded;
- if ( EnumProcessModules(GetCurrentProcess(),handles,lengthof(handles),&cbNeeded)) {
- char szFilename[_MAX_PATH];
- for ( DWORD h = 0 ; h < cbNeeded/sizeof(handles[0]) ; h++ ) {
- GetModuleFileNameA(handles[h],szFilename,lengthof(szFilename)) ;
- std::string path(szFilename);
- pushPath(path,libs,paths);
- }
- }
+ //if ( EnumProcessModules(GetCurrentProcess(),handles,lengthof(handles),&cbNeeded)) {
+ //char szFilename[_MAX_PATH];
+ //for ( DWORD h = 0 ; h < cbNeeded/sizeof(handles[0]) ; h++ ) {
+ //GetModuleFileNameA(handles[h],szFilename,lengthof(szFilename)) ;
+ //std::string path(szFilename);
+ //pushPath(path,libs,paths);
+ //}
+ //}
#elif defined(__APPLE__)
// man 3 dyld
uint32_t count = _dyld_image_count();
diff --git a/mythtv/external/libexiv2/src/http.cpp b/mythtv/external/libexiv2/src/http.cpp
index dc5f0ac97c..9d073fa823 100644
--- a/mythtv/external/libexiv2/src/http.cpp
+++ b/mythtv/external/libexiv2/src/http.cpp
@@ -132,7 +132,7 @@ int sleep_ = SLEEP;

static int forgive(int n, int& err)
{
- err = WSAGetLastError();
+ err = 0;//WSAGetLastError();
if (!n && !err)
return FINISH;
#ifndef WIN32
@@ -140,7 +140,7 @@ static int forgive(int n, int& err)
return FINISH; // server hungup
#endif
bool bForgive = err == WSAEWOULDBLOCK || err == WSAENOTCONN;
- bool bError = n == SOCKET_ERROR;
+ bool bError = true;//n == SOCKET_ERROR;
if (bError && bForgive)
return 0;
return n;
@@ -192,7 +192,8 @@ static int makeNonBlocking(int sockfd)
{
#ifdef WIN32
ULONG ioctl_opt = 1;
- return ioctlsocket(sockfd, FIONBIO, &ioctl_opt);
+ //return ioctlsocket(sockfd, FIONBIO, &ioctl_opt);
+ return 0;
#else
int result = fcntl(sockfd, F_SETFL, O_NONBLOCK);
return result >= 0 ? result : SOCKET_ERROR;
@@ -217,8 +218,8 @@ int Exiv2::http(Exiv2::Dictionary& request, Exiv2::Dictionary& response, std::st
////////////////////////////////////
// Windows specific code
#ifdef WIN32
- WSADATA wsaData;
- WSAStartup(MAKEWORD(2, 2), &wsaData);
+ //WSADATA wsaData;
+ //WSAStartup(MAKEWORD(2, 2), &wsaData);
#endif

const char* servername = request["server"].c_str();
@@ -268,41 +269,41 @@ int Exiv2::http(Exiv2::Dictionary& request, Exiv2::Dictionary& response, std::st

////////////////////////////////////
// open the socket
- int sockfd = (int)socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ int sockfd = 0; //(int)socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (sockfd < 0)
return error(errors, "unable to create socket\n", nullptr, nullptr, 0);

// fill in the address
- struct sockaddr_in serv_addr;
- int serv_len = sizeof(serv_addr);
- memset((char*)&serv_addr, 0, serv_len);
+ //struct sockaddr_in serv_addr;
+ int serv_len = 0; //sizeof(serv_addr);
+ //memset((char*)&serv_addr, 0, serv_len);

- serv_addr.sin_addr.s_addr = inet_addr(servername_p);
- serv_addr.sin_family = AF_INET;
- serv_addr.sin_port = htons(atoi(port_p));
+ //serv_addr.sin_addr.s_addr = inet_addr(servername_p);
+ //serv_addr.sin_family = AF_INET;
+ //serv_addr.sin_port = htons(atoi(port_p));

// convert unknown servername into IP address
// http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/rzab6/rzab6uafinet.htm
- if (serv_addr.sin_addr.s_addr == (unsigned long)INADDR_NONE) {
- struct hostent* host = gethostbyname(servername_p);
- if (!host) {
- closesocket(sockfd);
- return error(errors, "no such host", servername_p);
- }
- memcpy(&serv_addr.sin_addr, host->h_addr, sizeof(serv_addr.sin_addr));
- }
+ //if (serv_addr.sin_addr.s_addr == (unsigned long)INADDR_NONE) {
+ //struct hostent* host = gethostbyname(servername_p);
+ //if (!host) {
+ ////closesocket(sockfd);
+ //return error(errors, "no such host", servername_p);
+ //}
+ //memcpy(&serv_addr.sin_addr, host->h_addr, sizeof(serv_addr.sin_addr));
+ //}

makeNonBlocking(sockfd);

////////////////////////////////////
// connect the socket to the server
- auto server = connect(sockfd, (const struct sockaddr*)&serv_addr, serv_len);
- if (server == SOCKET_ERROR && WSAGetLastError() != WSAEWOULDBLOCK) {
- auto errorCode = WSAGetLastError();
- closesocket(sockfd);
- return error(errors, "error - unable to connect to server = %s port = %s wsa_error = %d", servername_p, port_p,
- errorCode);
- }
+ //auto server = connect(sockfd, (const struct sockaddr*)&serv_addr, serv_len);
+ //if (server == SOCKET_ERROR && WSAGetLastError() != WSAEWOULDBLOCK) {
+ //auto errorCode = WSAGetLastError();
+ //closesocket(sockfd);
+ //return error(errors, "error - unable to connect to server = %s port = %s wsa_error = %d", servername_p, port_p,
+ // errorCode);
+ //}

char buffer[32 * 1024 + 1];
size_t buff_l = sizeof buffer - 1;
@@ -315,17 +316,17 @@ int Exiv2::http(Exiv2::Dictionary& request, Exiv2::Dictionary& response, std::st

////////////////////////////////////
// send the header (we'll have to wait for the connection by the non-blocking socket)
- while (sleep_ >= 0 && send(sockfd, buffer, n, 0) == SOCKET_ERROR /* && WSAGetLastError() == WSAENOTCONN */) {
- Sleep(snooze);
- sleep_ -= snooze;
- }
+ //while (sleep_ >= 0 && send(sockfd, buffer, n, 0) == SOCKET_ERROR /* && WSAGetLastError() == WSAENOTCONN */) {
+ //Sleep(snooze);
+ //sleep_ -= snooze;
+ //}

if (sleep_ < 0) {
- auto errorCode = WSAGetLastError();
- closesocket(server);
- closesocket(sockfd);
- return error(errors, "error - timeout connecting to server = %s port = %s wsa_error = %d", servername, port,
- errorCode);
+ //auto errorCode = WSAGetLastError();
+ //closesocket(server);
+ //closesocket(sockfd);
+ //return error(errors, "error - timeout connecting to server = %s port = %s wsa_error = %d", servername, port,
+ // errorCode);
}

int end = 0; // write position in buffer
@@ -335,7 +336,7 @@ int Exiv2::http(Exiv2::Dictionary& request, Exiv2::Dictionary& response, std::st
////////////////////////////////////
// read and process the response
int err;
- n = forgive(recv(sockfd, buffer, (int)buff_l, 0), err);
+ n = false; //forgive(recv(sockfd, buffer, (int)buff_l, 0), err);
while (n >= 0 && OK(status)) {
if (n) {
end += n;
@@ -400,7 +401,7 @@ int Exiv2::http(Exiv2::Dictionary& request, Exiv2::Dictionary& response, std::st
flushBuffer(buffer, body, end, file);
}
}
- n = forgive(recv(sockfd, buffer + end, (int)(buff_l - end), 0), err);
+ n = false;//forgive(recv(sockfd, buffer + end, (int)(buff_l - end), 0), err);
if (!n) {
Sleep(snooze);
sleep_ -= snooze;
@@ -410,26 +411,26 @@ int Exiv2::http(Exiv2::Dictionary& request, Exiv2::Dictionary& response, std::st
}

if (n != FINISH || !OK(status)) {
- snprintf(buffer, sizeof buffer, "wsa_error = %d,n = %d,sleep_ = %d status = %d", WSAGetLastError(), n, sleep_,
- status);
+ // snprintf(buffer, sizeof buffer, "wsa_error = %d,n = %d,sleep_ = %d status = %d", WSAGetLastError(), n, sleep_,
+ // status);
error(errors, buffer, nullptr, nullptr, 0);
} else if (bSearching && OK(status)) {
if (end) {
// we finished OK without finding headers, flush the buffer
flushBuffer(buffer, 0, end, file);
} else {
- auto errorCode = WSAGetLastError();
- closesocket(server);
- closesocket(sockfd);
- return error(errors, "error - no response from server = %s port = %s wsa_error = %d", servername, port,
- errorCode);
+ //auto errorCode = WSAGetLastError();
+ //closesocket(server);
+ //closesocket(sockfd);
+ //return error(errors, "error - no response from server = %s port = %s wsa_error = %d", servername, port,
+ // errorCode);
}
}

////////////////////////////////////
// close sockets
- closesocket(server);
- closesocket(sockfd);
+ //closesocket(server);
+ //closesocket(sockfd);
response["body"] = file;
return result;
}