Skip to content

Commit

Permalink
- Added UPnP support (experimental) - taken from aMule CVS
Browse files Browse the repository at this point in the history
  • Loading branch information
Christophe Dumez committed Mar 19, 2007
1 parent f8e7687 commit fd2d2dd
Show file tree
Hide file tree
Showing 12 changed files with 2,602 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Changelog
@@ -1,3 +1,6 @@
* Unknown - Christophe Dumez <chris@qbittorrent.org> - v0.10.0
- FEATURE: Added UPnP port forwarding support

* Unknown - Christophe Dumez <chris@qbittorrent.org> - v0.9.0
- FEATURE: Based on libtorrent v0.12
- FEATURE: Based on Qt4.2
Expand Down
2 changes: 1 addition & 1 deletion TODO
Expand Up @@ -34,5 +34,5 @@
- Allow to edit the trackers for a torrent
- Improve torrent creation dialog (look & features)
- Add IPv6 support (at least start working on it)
- UPnP support?
- UPnP support? (debug, sync with aMule, option entry)
- Allow user to change application style (WinXP, MacOS, CleanLooks...) : app.setStyle(new QCleanlooksStyle());
89 changes: 89 additions & 0 deletions configure
Expand Up @@ -22,6 +22,9 @@ Dependency options:
--with-libtorrent-lib=[path] Path to libtorrent library files
--with-libcurl-inc=[path] Path to libcurl include files
--with-libcurl-lib=[path] Path to libcurl library files
--disable-libupnp Disable use of libupnp
--disable-upnp disable UPnP support
--with-libupnp-inc=[path] Path to libupnp include files
EOT
}
Expand Down Expand Up @@ -158,6 +161,21 @@ while [ $# -gt 0 ]; do
shift
;;

--disable-libupnp)
QC_DISABLE_libupnp="Y"
shift
;;

--disable-upnp)
QC_DISABLE_UPNP="Y"
shift
;;

--with-libupnp-inc=*)
QC_WITH_LIBUPNP_INC=$optarg
shift
;;

--verbose)
QC_DEBUG="Y"
shift
Expand All @@ -183,6 +201,9 @@ echo QC_WITH_LIBTORRENT_INC=$QC_WITH_LIBTORRENT_INC
echo QC_WITH_LIBTORRENT_LIB=$QC_WITH_LIBTORRENT_LIB
echo QC_WITH_LIBCURL_INC=$QC_WITH_LIBCURL_INC
echo QC_WITH_LIBCURL_LIB=$QC_WITH_LIBCURL_LIB
echo QC_DISABLE_libupnp=$QC_DISABLE_libupnp
echo QC_DISABLE_UPNP=$QC_DISABLE_UPNP
echo QC_WITH_LIBUPNP_INC=$QC_WITH_LIBUPNP_INC
echo
fi

Expand Down Expand Up @@ -447,6 +468,68 @@ public:
return false;
}
};
#line 1 "libupnp.qcm"
/*
-----BEGIN QCMOD-----
name: libupnp
arg: disable-upnp, disable UPnP support
arg: with-libupnp-inc=[path], Path to libupnp include files
-----END QCMOD-----
*/
class qc_libupnp : public ConfObj
{
public:
qc_libupnp(Conf *c) : ConfObj(c) {}
QString name() const { return "libupnp"; }
QString shortname() const { return "libupnp"; }
bool exec(){
QString s;
s = conf->getenv("QC_DISABLE_UPNP");
if(!s.isEmpty()){
conf->addDefine("NO_UPNP");
return false;
}
s = conf->getenv("QC_WITH_LIBUPNP_INC");
if(!s.isEmpty()) {
if(!conf->checkHeader(s, "upnp/upnp.h")) {
//qWarning("libupnp includes not found!");
conf->addDefine("NO_UPNP");
return false;
}
conf->addIncludePath(s);
}else{
QStringList sl;
sl += "/usr/include";
sl += "/usr/local/include";
if(!conf->findHeader("upnp/upnp.h", sl, &s)) {
//qWarning("libupnp includes not found!");
conf->addDefine("NO_UPNP");
return false;
}
conf->addIncludePath(s);
}
/*s = conf->getenv("QC_WITH_LIBUPNP_LIB");
if(!s.isEmpty()) {
if(!conf->checkLibrary(s, "upnp")) {
qWarning("libupnp library not found!");
return false;
}
conf->addLib(QString("-L") + s);
}else{
if(!conf->findLibrary("upnp", &s)) {
qWarning("libupnp library not found!");
return false;
}
if (!s.isEmpty())
conf->addLib(QString("-L") + s);
}
conf->addLib("-lupnp");*/
return true;
}
};
EOT
cat >$1/modules_new.cpp <<EOT
Expand All @@ -465,6 +548,9 @@ cat >$1/modules_new.cpp <<EOT
o = new qc_python(conf);
o->required = true;
o->disabled = false;
o = new qc_libupnp(conf);
o->required = false;
o->disabled = false;
EOT
cat >$1/conf4.h <<EOT
Expand Down Expand Up @@ -1395,6 +1481,9 @@ export QC_WITH_LIBTORRENT_INC
export QC_WITH_LIBTORRENT_LIB
export QC_WITH_LIBCURL_INC
export QC_WITH_LIBCURL_LIB
export QC_DISABLE_libupnp
export QC_DISABLE_UPNP
export QC_WITH_LIBUPNP_INC
export QC_DEBUG
rm -rf .qconftemp
(
Expand Down
3 changes: 3 additions & 0 deletions qbittorrent.qc
Expand Up @@ -17,4 +17,7 @@
<dep type='python'>
<required/>
</dep>
<dep type='libupnp'>
<optional/>
</dep>
</qconf>
61 changes: 61 additions & 0 deletions qcm/libupnp.qcm
@@ -0,0 +1,61 @@
/*
-----BEGIN QCMOD-----
name: libupnp
arg: disable-upnp, disable UPnP support
arg: with-libupnp-inc=[path], Path to libupnp include files
-----END QCMOD-----
*/
class qc_libupnp : public ConfObj
{
public:
qc_libupnp(Conf *c) : ConfObj(c) {}
QString name() const { return "libupnp"; }
QString shortname() const { return "libupnp"; }
bool exec(){
QString s;
s = conf->getenv("QC_DISABLE_UPNP");
if(!s.isEmpty()){
conf->addDefine("NO_UPNP");
return false;
}
s = conf->getenv("QC_WITH_LIBUPNP_INC");
if(!s.isEmpty()) {
if(!conf->checkHeader(s, "upnp/upnp.h")) {
//qWarning("libupnp includes not found!");
conf->addDefine("NO_UPNP");
return false;
}
conf->addIncludePath(s);
}else{
QStringList sl;
sl += "/usr/include";
sl += "/usr/local/include";
if(!conf->findHeader("upnp/upnp.h", sl, &s)) {
//qWarning("libupnp includes not found!");
conf->addDefine("NO_UPNP");
return false;
}
conf->addIncludePath(s);
}

/*s = conf->getenv("QC_WITH_LIBUPNP_LIB");
if(!s.isEmpty()) {
if(!conf->checkLibrary(s, "upnp")) {
qWarning("libupnp library not found!");
return false;
}
conf->addLib(QString("-L") + s);
}else{
if(!conf->findLibrary("upnp", &s)) {
qWarning("libupnp library not found!");
return false;
}
if (!s.isEmpty())
conf->addLib(QString("-L") + s);
}

conf->addLib("-lupnp");*/

return true;
}
};
5 changes: 5 additions & 0 deletions src/GUI.cpp
Expand Up @@ -1172,6 +1172,11 @@ void GUI::configureSession(bool deleteOptions){
}else{
BTSession.disableDHT();
}
#ifndef NO_UPNP
// Upnp
BTSession.enableUPnP();
#endif
// PeX
if(!options->isPeXDisabled()){
qDebug("Enabling Peer eXchange (PeX)");
BTSession.enablePeerExchange();
Expand Down
1 change: 0 additions & 1 deletion src/GUI.h
Expand Up @@ -45,7 +45,6 @@
#include "trackerLogin.h"
#include "bittorrent.h"


#define TIME_TRAY_BALLOON 5000

class createtorrent;
Expand Down

0 comments on commit fd2d2dd

Please sign in to comment.