 +	                        port_str, port_str, addr, 0, "TCP");
 +	if(r==0)
 +		printf("AddPortMapping(%s, %s, %s) failed\n", port_str, port_str, addr);
++	fflush(stdout);
 +}
 +
 +/** Based on http://miniupnp.free.fr/files/download.php?file=xchat-upnp20061022.patch */
 +void
-+ServerSettings::upnp_rem_redir(int port)
++UPNPControl::upnp_rem_redir(int port)
 +{
 +	char port_str[16];
 +	int t;

   torcontrol
   util
 )
@@ -268,3 +276,4 @@
 endif(NOT WIN32 AND NOT APPLE)
 
 
+
Index: src/vidalia/config/serversettings.cpp
===================================================================
--- src/vidalia/config/serversettings.cpp	(revision 2465)
+++ src/vidalia/config/serversettings.cpp	(working copy)
@@ -130,6 +130,9 @@
   bool rc;
 
   if (isServerEnabled()) {

+	if(urls.controlURL[0] == '\0')
+	{
+		printf("TB : the init was not done !\n");
+		fflush(stdout);
+		return;
+	}
+	sprintf(port_str, "%d", port);
+	UPNP_DeletePortMapping(urls.controlURL, data.servicetype, port_str, "TCP");
+}
Index: config/upnpcontrol.h
===================================================================
--- config/upnpcontrol.h	(revision 0)
+++ config/upnpcontrol.h	(revision 0)
@@ -0,0 +1,48 @@
+/*
+**  This file is part of Vidalia, and is subject to the license terms in the
+**  LICENSE file, found in the top level directory of this distribution. If 
+**  you did not receive the LICENSE file with this file, you may obtain it
+**  from the Vidalia source package distributed by the Vidalia Project at
+**  http://www.vidalia-project.net/. No part of Vidalia, including this file,
+**  may be copied, modified, propagated, or distributed except according to
+**  the terms described in the LICENSE file.
+*/
+
+/* 
+** \file upnpcontrol.h
+** \version $Id: torcontrol.h 2362 2008-02-29 04:30:11Z edmanm $
+** \brief Singleton object for interacting with UPNP device
+*/
+
+#ifndef _UPNPCONTROL_H
+#define _UPNPCONTROL_H
+
+#include <QObject>
+
+#define STATICLIB
+#include <miniupnpc/miniwget.h>
+#include <miniupnpc/miniupnpc.h>
+#include <miniupnpc/upnpcommands.h>
+
+class UPNPControl : public QObject
+{
+  Q_OBJECT
+
+public:
+  static UPNPControl* Instance();
+  void forwardPort(int port);
+protected:
+  UPNPControl();
+private:
+  static UPNPControl* pInstance;
+
+  /** Used by miniupnpc library */
+  struct UPNPUrls urls;
+  struct IGDdatas data;
