~arky/ubuntu/lucid/aptdaemon/fix-523759

« back to all changes in this revision

Viewing changes to debian/patches/aptd_http_proxy.patch

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2009-10-09 10:16:49 UTC
  • mfrom: (1.1.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20091009101649-6sy3jeo30b3zg4gm
Tags: 0.10+bzr259-0ubuntu1
* debian/patches/aptd_http_proxy.patch:
  - add basic http proxy proxy support (LP: #446069)
* dropped patches:
  - debian/patches/aptd_locking_fixes.patch
  - debian/patches/fix_syslog_crash.patch
  Both got accepted upstream (no other changes in r259)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
=== modified file 'aptdaemon/client.py'
 
2
--- aptdaemon/client.py 2009-10-04 11:51:44 +0000
 
3
+++ aptdaemon/client.py 2009-10-09 08:13:12 +0000
 
4
@@ -302,6 +302,15 @@
 
5
         self._iface.Cancel(reply_handler=reply_handler,
 
6
                            error_handler=error_handler)
 
7
 
 
8
+    def set_http_proxy(self, proxy, 
 
9
+                       reply_handler=None, error_handler=None):
 
10
+        """Set the http_proxy property"""
 
11
+        self._proxy.Set("org.debian.apt.transaction", 
 
12
+                        "HttpProxy", proxy,
 
13
+                        dbus_interface=dbus.PROPERTIES_IFACE,
 
14
+                        reply_handler=reply_handler,
 
15
+                        error_handler=error_handler)
 
16
+
 
17
     def set_allow_unauthenticated(self, allow_unauthenticated, 
 
18
                             reply_handler=None, error_handler=None):
 
19
         """Set the allow_unauthenticated property"""
 
20
 
 
21
=== modified file 'aptdaemon/core.py'
 
22
--- aptdaemon/core.py   2009-10-06 07:09:22 +0000
 
23
+++ aptdaemon/core.py   2009-10-09 08:13:12 +0000
 
24
@@ -149,6 +149,7 @@
 
25
         self.uid = uid
 
26
         self.locale = None
 
27
         self.allow_unauthenticated = False
 
28
+        self.http_proxy = ""
 
29
         self.terminal = None
 
30
         self.debconf = None
 
31
         self.kwargs = None
 
32
@@ -678,6 +679,21 @@
 
33
         else:
 
34
             self.locale = "%s.%s" % (lang, encoding)
 
35
 
 
36
+    def _set_http_proxy(self, proxy):
 
37
+        """Set a http network proxy 
 
38
+           
 
39
+           Keyword arguments:
 
40
+           host - the proxy server
 
41
+           port - the proxy port
 
42
+        """
 
43
+        if  proxy != "":
 
44
+            if (not proxy.startswith("http://") or 
 
45
+                not ":" in proxy):
 
46
+                raise errors.InvalidProxyError(proxy)
 
47
+        logging.debug("http proxy set to '%s'" % proxy)
 
48
+        self.http_proxy = proxy
 
49
+        apt_pkg.Config.Set("Acquire::http::Proxy", self.http_proxy)
 
50
+
 
51
     def _set_allow_unauthenticated(self, allow_unauthenticated):
 
52
         """Set the handling of unauthenticated packages 
 
53
 
 
54
@@ -879,6 +895,8 @@
 
55
                 deferred.add_callback(lambda x: self._set_locale(value))
 
56
             elif property == "AllowUnauthenticated":
 
57
                 deferred.add_callback(lambda x: self._set_allow_unauthenticated(value))
 
58
+            elif property == "HttpProxy":
 
59
+                deferred.add_callback(lambda x: self._set_http_proxy(value))
 
60
             else:
 
61
                 raise dbus.exceptions.DBusException("Unknown or read only "
 
62
                                                     "property: %s" % property)
 
63
@@ -915,6 +933,7 @@
 
64
                     "DebconfSocket": self.debconf,
 
65
                     "Paused": self.paused,
 
66
                     "AllowUnauthenticated": self.allow_unauthenticated,
 
67
+                    "HttpProxy": self.http_proxy,
 
68
                     }
 
69
         else:
 
70
             return {}
 
71
 
 
72
=== modified file 'aptdaemon/errors.py'
 
73
--- aptdaemon/errors.py 2009-10-04 12:17:51 +0000
 
74
+++ aptdaemon/errors.py 2009-10-09 08:13:12 +0000
 
75
@@ -45,6 +45,12 @@
 
76
         self.enum = enum
 
77
         self.message = msg
 
78
 
 
79
+class InvalidProxyError(APTDError):
 
80
+    """Invalid proxy given"""
 
81
+    _dbus_error_name = "org.debian.apt.InvalidProxy"
 
82
+    def __init__(self, proxy):
 
83
+        APTDError.__init__(self, "InvalidProxyError: %s" % proxy)
 
84
+
 
85
 class TransactionCancelled(APTDError):
 
86
     """Internal error if a transaction was cancelled."""
 
87
     _dbus_error_name = "org.debian.apt.TransactionCancelled"
 
88
 
 
89
=== modified file 'aptdaemon/gtkwidgets.py'
 
90
--- aptdaemon/gtkwidgets.py     2009-10-04 09:27:44 +0000
 
91
+++ aptdaemon/gtkwidgets.py     2009-10-09 08:13:12 +0000
 
92
@@ -477,6 +477,17 @@
 
93
         self.set_title(role)
 
94
         self.label_role.set_markup("<big><b>%s</b></big>" % role)
 
95
 
 
96
+    def _setup_http_proxy(self, transaction):
 
97
+        try:
 
98
+            import gconf
 
99
+        except ImportError:
 
100
+            return
 
101
+        client = gconf.client_get_default()
 
102
+        if client.get_bool("/system/http_proxy/use_http_proxy"):
 
103
+            host = client.get_string("/system/http_proxy/host")
 
104
+            port = client.get_int("/system/http_proxy/port")
 
105
+            transaction.set_http_proxy("http://%s:%s/" % (host, port))
 
106
+
 
107
     def set_transaction(self, transaction):
 
108
         """Connect the dialog to the given aptdaemon transaction"""
 
109
         for sig in self._signals:
 
110
@@ -498,6 +509,7 @@
 
111
         self._transaction = transaction
 
112
         if self.debconf:
 
113
             self._transaction.set_debconf_frontend("gnome")
 
114
+        self._setup_http_proxy(transaction)
 
115
 
 
116
     def _on_medium_required(self, transaction, medium, drive):
 
117
         dialog = AptMediumRequiredDialog(medium, drive, self)
 
118
 
 
119
=== modified file 'data/org.debian.apt.policy.in'
 
120
--- data/org.debian.apt.policy.in       2009-08-27 09:26:26 +0000
 
121
+++ data/org.debian.apt.policy.in       2009-10-09 08:13:12 +0000
 
122
@@ -84,7 +84,7 @@
 
123
     <defaults>
 
124
       <allow_any>auth_admin</allow_any>
 
125
       <allow_inactive>auth_admin</allow_inactive>
 
126
-      <allow_active>yes</allow_active>
 
127
+      <allow_active>auth_admin_keep</allow_active>
 
128
     </defaults>
 
129
   </action>
 
130
 
 
131