mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-19 01:52:35 -05:00
rbutil: introduce a util function to get the systemproxy, for better reuse.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16150 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
9759c035f4
commit
df6c5f414f
4 changed files with 52 additions and 60 deletions
|
|
@ -21,6 +21,14 @@
|
|||
|
||||
#include <QDir>
|
||||
|
||||
#if defined(Q_OS_WIN32)
|
||||
#if defined(UNICODE)
|
||||
#define _UNICODE
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#endif
|
||||
|
||||
// recursive function to delete a dir with files
|
||||
bool recRmdir( const QString &dirName )
|
||||
{
|
||||
|
|
@ -42,3 +50,39 @@ bool recRmdir( const QString &dirName )
|
|||
dir.cdUp();
|
||||
return dir.rmdir(dirN); // delete empty dir and return if (now empty) dir-removing was successfull
|
||||
}
|
||||
|
||||
|
||||
//Function to get the system proxy
|
||||
QUrl systemProxy(void)
|
||||
{
|
||||
#if defined(Q_OS_LINUX)
|
||||
return QUrl(getenv("http_proxy"));
|
||||
#endif
|
||||
#if defined(Q_OS_WIN32)
|
||||
HKEY hk;
|
||||
wchar_t proxyval[80];
|
||||
DWORD buflen = 80;
|
||||
long ret;
|
||||
DWORD enable;
|
||||
DWORD enalen = sizeof(DWORD);
|
||||
|
||||
ret = RegOpenKeyEx(HKEY_CURRENT_USER,
|
||||
_TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"),
|
||||
0, KEY_QUERY_VALUE, &hk);
|
||||
if(ret != ERROR_SUCCESS) return QUrl("");
|
||||
|
||||
ret = RegQueryValueEx(hk, _TEXT("ProxyServer"), NULL, NULL, (LPBYTE)proxyval, &buflen);
|
||||
if(ret != ERROR_SUCCESS) return QUrl("");
|
||||
|
||||
ret = RegQueryValueEx(hk, _TEXT("ProxyEnable"), NULL, NULL, (LPBYTE)&enable, &enalen);
|
||||
if(ret != ERROR_SUCCESS) return QUrl("");
|
||||
|
||||
RegCloseKey(hk);
|
||||
|
||||
//qDebug() << QString::fromWCharArray(proxyval) << QString("%1").arg(enable);
|
||||
if(enable != 0)
|
||||
return QUrl("http://" + QString::fromWCharArray(proxyval));
|
||||
else
|
||||
return QUrl("");
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue