Skip to content

Commit

Permalink
Get rid of qt3support in libmythdb.
Browse files Browse the repository at this point in the history
Pulled in Q3SocketDevice, and renamed it as MSocketDevice.  No direct 
equivalent exists in Qt4.  Need to take a look at using Qt4's network code, now
that it's less tied to their event loop.  Eventually.

Updated the kmdcodec to current kcodecs.

Slightly changed the LCD api to use QLists instead of Q3PtrList.

Otherwise, this was pretty straightforward.



git-svn-id: http://svn.mythtv.org/svn/trunk@17665 7dbf422c-18fa-0310-86e9-fd20926502f2
  • Loading branch information
Isaac Richards committed Jun 30, 2008
1 parent 4d31b32 commit 06602aa
Show file tree
Hide file tree
Showing 23 changed files with 3,366 additions and 653 deletions.
8 changes: 3 additions & 5 deletions mythtv/libs/libmyth/mythdialogs.cpp
Expand Up @@ -889,12 +889,10 @@ MythProgressDialog::MythProgressDialog(const QString &message, int totalSteps,

if (class LCD * lcddev = LCD::Get())
{
textItems = new Q3PtrList<LCDTextItem>;
textItems->setAutoDelete(true);
QList<LCDTextItem> textItems;

textItems->clear();
textItems->append(new LCDTextItem(1, ALIGN_CENTERED, message, "Generic",
false));
textItems.append(LCDTextItem(1, ALIGN_CENTERED, message, "Generic",
false));
lcddev->switchToGeneric(textItems);
}
else
Expand Down
7 changes: 3 additions & 4 deletions mythtv/libs/libmyth/uilistbtntype.cpp
Expand Up @@ -1631,8 +1631,7 @@ void UIListBtnType::Draw(QPainter *p, int order, int context, bool active_on)
// add max of lcd height menu items either side of the selected item
// let the lcdserver figure out which ones to display

Q3PtrList<LCDMenuItem> menuItems;
menuItems.setAutoDelete(true);
QList<LCDMenuItem> menuItems;

Q3PtrListIterator<UIListBtnTypeItem> it = (*m_selIterator);
uint count = 0;
Expand Down Expand Up @@ -1667,7 +1666,7 @@ void UIListBtnType::Draw(QPainter *p, int order, int context, bool active_on)
else
selected = false;

menuItems.append(new LCDMenuItem(selected, checkState, msg));
menuItems.append(LCDMenuItem(selected, checkState, msg));
++it;
++count;
}
Expand All @@ -1686,7 +1685,7 @@ void UIListBtnType::Draw(QPainter *p, int order, int context, bool active_on)

if (!menuItems.isEmpty())
{
lcddev->switchToMenu(&menuItems, title);
lcddev->switchToMenu(menuItems, title);
}
}
}
Expand Down
9 changes: 4 additions & 5 deletions mythtv/libs/libmyth/uitypes.cpp
Expand Up @@ -3507,8 +3507,7 @@ void UIManagedTreeListType::Draw(QPainter *p, int drawlayer, int context)
bool selected;

Q3PtrList<GenericTree> *nodes = parent->getAllChildren(visual_order);
Q3PtrList<LCDMenuItem> menuItems;
menuItems.setAutoDelete(true);
QList<LCDMenuItem> menuItems;

if (pos > (int)lcddev->getLCDHeight())
nodes->at(pos - lcddev->getLCDHeight());
Expand All @@ -3525,8 +3524,8 @@ void UIManagedTreeListType::Draw(QPainter *p, int drawlayer, int context)
else
selected = false;

menuItems.append(new LCDMenuItem(selected, NOTCHECKABLE,
lnode->getString()));
menuItems.append(LCDMenuItem(selected, NOTCHECKABLE,
lnode->getString()));
nodes->next();
++count;
}
Expand All @@ -3536,7 +3535,7 @@ void UIManagedTreeListType::Draw(QPainter *p, int drawlayer, int context)
title += (current_node->childCount () > 0) ? " >> " : " ";
if (!menuItems.isEmpty())
{
lcddev->switchToMenu(&menuItems, title);
lcddev->switchToMenu(menuItems, title);
}
}
}
Expand Down
81 changes: 42 additions & 39 deletions mythtv/libs/libmythdb/httpcomms.cpp
Expand Up @@ -10,7 +10,7 @@

using namespace std;

#include "qmdcodec.h"
#include "qcodecs.h"
#include "httpcomms.h"

HttpComms::HttpComms()
Expand Down Expand Up @@ -84,9 +84,9 @@ void HttpComms::request(QUrl &url,
int timeoutms,
QIODevice *pData /* = NULL*/ )
{
Q_UINT16 port = 80;
quint16 port = 80;

if (url.hasPort())
if (url.port() != -1)
port = url.port();

http->setHost(url.host(), port);
Expand All @@ -105,7 +105,8 @@ void HttpComms::request(QUrl &url,
connect(m_timer, SIGNAL(timeout()), SLOT(timeout()));
}
m_timeoutInterval = timeoutms;
m_timer->start(timeoutms, TRUE);
m_timer->setSingleShot(true);
m_timer->start(timeoutms);
}

if (!m_cookie.isEmpty())
Expand Down Expand Up @@ -133,7 +134,7 @@ void HttpComms::done(bool error)
"%1 (%2): url: '%3'")
.arg(http->errorString())
.arg(error)
.arg(m_url.toString().latin1()));
.arg(m_url.toString()));
}
else if (m_authNeeded)
{
Expand Down Expand Up @@ -186,8 +187,8 @@ void HttpComms::headerReceived(const QHttpResponseHeader &resp)
{
QRegExp rx("PHPSESSID=(.+);");
rx.setMinimal(true);
rx.setCaseSensitive(false);
if (rx.search(resp.value(sidkey)) >= 0)
rx.setCaseSensitivity(Qt::CaseInsensitive);
if (rx.indexIn(resp.value(sidkey)) >= 0)
{
m_cookie = "PHPSESSID=" + rx.cap(1);
VERBOSE(VB_NETWORK, QString("HttpComms found cookie: %1").arg(m_cookie));
Expand Down Expand Up @@ -239,7 +240,8 @@ void HttpComms::headerReceived(const QHttpResponseHeader &resp)
if (m_timer)
{
m_timer->stop();
m_timer->start(m_timeoutInterval, TRUE);
m_timer->setSingleShot(true);
m_timer->start(m_timeoutInterval);
}

// Not sure if it's possible to receive a session ID or other cookie
Expand All @@ -261,7 +263,7 @@ void HttpComms::headerReceived(const QHttpResponseHeader &resp)
void HttpComms::timeout()
{
VERBOSE(VB_IMPORTANT, QString("HttpComms::Timeout for url: %1")
.arg(m_url.toString().latin1()));
.arg(m_url.toString()));
m_timeout = true;
m_done = true;
}
Expand Down Expand Up @@ -294,7 +296,7 @@ QString HttpComms::getHttp(QString &url,
QUrl qurl(url);
if (hostname == "")
hostname = qurl.host(); // hold onto original host
if (!qurl.hasHost()) // can occur on redirects to partial paths
if (qurl.host().isEmpty()) // can occur on redirects to partial paths
qurl.setHost(hostname);

VERBOSE(VB_NETWORK, QString("getHttp: grabbing: %1").arg(qurl.toString()));
Expand All @@ -320,20 +322,20 @@ QString HttpComms::getHttp(QString &url,
// Handle timeout
if (httpGrabber->isTimedout())
{
VERBOSE(VB_NETWORK, QString("timeout for url: %1").arg(url.latin1()));
VERBOSE(VB_NETWORK, QString("timeout for url: %1").arg(url));

// Increment the counter and check were not over the limit
if (timeoutCount++ >= maxRetries)
{
VERBOSE(VB_IMPORTANT, QString("Failed to contact server for url: %1").arg(url.latin1()));
VERBOSE(VB_IMPORTANT, QString("Failed to contact server for url: %1").arg(url));
break;
}

// Try again
VERBOSE(VB_NETWORK, QString("Attempt # %1/%2 for url: %3")
.arg(timeoutCount + 1)
.arg(maxRetries)
.arg(url.latin1()));
.arg(url));

continue;
}
Expand All @@ -342,7 +344,7 @@ QString HttpComms::getHttp(QString &url,
if (!httpGrabber->getRedirectedURL().isEmpty())
{
VERBOSE(VB_NETWORK, QString("Redirection: %1, count: %2, max: %3")
.arg(httpGrabber->getRedirectedURL().latin1())
.arg(httpGrabber->getRedirectedURL())
.arg(redirectCount)
.arg(maxRedirects));
if (redirectCount++ < maxRedirects)
Expand All @@ -362,7 +364,7 @@ QString HttpComms::getHttp(QString &url,

VERBOSE(VB_NETWORK, QString("Got %1 bytes from url: '%2'")
.arg(res.length())
.arg(url.latin1()));
.arg(url));
VERBOSE(VB_NETWORK, res);

return res;
Expand All @@ -387,7 +389,7 @@ bool HttpComms::getHttpFile(const QString& filename, QString& url, int timeoutMS
if (hostname == "")
hostname = qurl.host(); // hold onto original host

if (!qurl.hasHost()) // can occur on redirects to partial paths
if (qurl.host().isEmpty()) // can occur on redirects to partial paths
qurl.setHost(hostname);

VERBOSE(VB_NETWORK, QString("getHttp: grabbing: '%1'")
Expand All @@ -414,29 +416,29 @@ bool HttpComms::getHttpFile(const QString& filename, QString& url, int timeoutMS
{
VERBOSE(VB_IMPORTANT, QString("Server returned an error status code %1 for url: %2")
.arg(statusCode)
.arg(url.latin1()));
.arg(url));
break;
}

// Handle timeout
if (httpGrabber->isTimedout())
{
VERBOSE(VB_NETWORK, QString("Timeout for url: '%1'")
.arg(url.latin1()));
.arg(url));

// Increment the counter and check were not over the limit
if (timeoutCount++ >= maxRetries)
{
VERBOSE(VB_IMPORTANT, QString("Failed to contact server for url: '%1'")
.arg(url.latin1()));
.arg(url));
break;
}

// Try again
VERBOSE(VB_NETWORK, QString("Attempt # %1/%2 for url: %3")
.arg(timeoutCount + 1)
.arg(maxRetries)
.arg(url.latin1()));
.arg(url));

continue;
}
Expand All @@ -445,7 +447,7 @@ bool HttpComms::getHttpFile(const QString& filename, QString& url, int timeoutMS
if (!httpGrabber->getRedirectedURL().isEmpty())
{
VERBOSE(VB_NETWORK, QString("redirection: '%1', count: %2, max: %3")
.arg(httpGrabber->getRedirectedURL().latin1())
.arg(httpGrabber->getRedirectedURL())
.arg(redirectCount)
.arg(maxRedirects));

Expand All @@ -468,7 +470,7 @@ bool HttpComms::getHttpFile(const QString& filename, QString& url, int timeoutMS
if (file.open( QIODevice::WriteOnly ))
{
QDataStream stream(& file);
stream.writeRawBytes( (const char*) (data), data.size() );
stream.writeRawData((const char*)(data), data.size() );
file.close();
res = true;
VERBOSE(VB_NETWORK, QString("getHttpFile: File saved OK"));
Expand All @@ -484,7 +486,7 @@ bool HttpComms::getHttpFile(const QString& filename, QString& url, int timeoutMS

VERBOSE(VB_NETWORK, QString("Got %1 bytes from url: '%2'")
.arg(data.size())
.arg(url.latin1()));
.arg(url));

delete httpGrabber;

Expand Down Expand Up @@ -539,7 +541,7 @@ QString HttpComms::postHttp(QUrl &url ,
{
if (hostname == "")
hostname = url.host(); // hold onto original host
if (!url.hasHost()) // can occur on redirects to partial paths
if (url.host().isEmpty()) // can occur on redirects to partial paths
url.setHost(hostname);

VERBOSE(VB_NETWORK, QString("postHttp: grabbing: %1").arg(url.toString()));
Expand Down Expand Up @@ -586,7 +588,7 @@ QString HttpComms::postHttp(QUrl &url ,
if (!httpGrabber->getRedirectedURL().isEmpty())
{
VERBOSE(VB_NETWORK, QString("Redirection: %1, count: %2, max: %3")
.arg(httpGrabber->getRedirectedURL().latin1())
.arg(httpGrabber->getRedirectedURL())
.arg(redirectCount)
.arg(maxRedirects));
if (redirectCount++ < maxRedirects)
Expand Down Expand Up @@ -629,17 +631,17 @@ bool HttpComms::createDigestAuth ( bool isForProxy, const QString& authStr, QHtt
{
header = "Proxy-Authorization";
auth = "Digest ";
info.username = m_proxyCredentials.user.latin1();
info.password = m_proxyCredentials.pass.latin1();
p = authStr.latin1();
info.username = qPrintable(m_proxyCredentials.user);
info.password = qPrintable(m_proxyCredentials.pass);
p = qPrintable(authStr);
}
else
{
header = "Authorization";
auth = "Digest ";
info.username = m_webCredentials.user.latin1();
info.password = m_webCredentials.pass.latin1();
p = authStr.latin1();
info.username = qPrintable(m_webCredentials.user);
info.password = qPrintable(m_webCredentials.pass);
p = qPrintable(authStr);
}

if (!p || !*p)
Expand All @@ -664,7 +666,8 @@ bool HttpComms::createDigestAuth ( bool isForProxy, const QString& authStr, QHtt
info.nc = "00000001";

// Set the method used...
info.method = request->method();
info.method.clear();
info.method += request->method();

// Parse the Digest response....
while (*p)
Expand Down Expand Up @@ -703,21 +706,21 @@ bool HttpComms::createDigestAuth ( bool isForProxy, const QString& authStr, QHtt
QByteArray uri = QByteArray(p,i+1);
do
{
pos = uri.find( ' ', idx );
pos = uri.indexOf( ' ', idx );

if ( pos != -1 )
{
QString sUrl = m_url + "//" + uri.mid(idx, pos-idx);
QString sUrl = m_url.toString() + "//" + uri.mid(idx, pos-idx);
QUrl u(sUrl);
if (u.isValid ())
info.digestURI.append( u.toString().latin1() );
info.digestURI.append(qPrintable(u.toString()));
}
else
{
QString sUrl = m_url + "//" + uri.mid(idx, uri.length()-idx);
QString sUrl = m_url.toString() + "//" + uri.mid(idx, uri.length()-idx);
QUrl u(sUrl);
if (u.isValid ())
info.digestURI.append( u.toString().latin1() );
info.digestURI.append(qPrintable(u.toString()));
}
idx = pos+1;
} while ( pos != -1 );
Expand Down Expand Up @@ -826,7 +829,7 @@ void HttpComms::calculateDigestResponse( DigestAuthInfo& info, QByteArray& Respo
authStr += info.password;
md.update( authStr );

if ( info.algorithm.lower() == "md5-sess" )
if (info.algorithm.toLower() == "md5-sess" )
{
authStr = md.hexDigest();
authStr += ':';
Expand All @@ -846,7 +849,7 @@ void HttpComms::calculateDigestResponse( DigestAuthInfo& info, QByteArray& Respo
// Calculate H(A2)
authStr = info.method;
authStr += ':';
authStr += sEncodedPathAndQuery.latin1();
authStr += qPrintable(sEncodedPathAndQuery);

if ( info.qop == "auth-int" )
{
Expand Down

0 comments on commit 06602aa

Please sign in to comment.