There is a system-wide proxy setup for os x, I'll look into how to get 
at it!

- Tom

Youness Alaoui wrote:
> Hi,
> Thanks for the patch and for giving a detailed explanation
> of your changes... 
> however, I see two problems :
> 1 - code duplication.. it would be better to have the code
> that checks for the system configs in config.tcl after we
> loadProfile... this way, the code will be there only one... 
> Also, make sure that the option for 'use system settings'
> would only be available when it is actually possible to
> check user settings (on mac, windows, do not show the
> option)..
> also note that it might be confusing if someone has old
> settings for gnome, and is using KDE, and amsn takes gnome
> settings instead of his new KDE settings... maybe check for
> the $::env(DESKTOP) variable too...
> 
> Thanks again for the contribution!
> 
> KaKaRoTo
> 
> 
> On Tue, Dec 23, 2008 at 04:43:11PM +0100, Pablo Castellano wrote:
>> Hello again!
>>
>> Here I attach a patch to use the system proxy settings like Firefox or
>> Pidgin does.
>>
>> Actually it supports the environment variable "http_proxy"
>> (ex: $ export http_proxy=http://myproxy.com:81)
>>
>> and the proxy set in the gnome preferences:
>> (System -> Preferences -> Proxy)
>>
>> It has a lot of checks about gconf that I didn't know if it would be
>> better to remove to make the code more readable but finally I have left
>> them there. Remove them if you think it's better.
>>
>> Finally I couldn't test authentication but it should work so if someone
>> can confirm it, please do it!
>>
>>
>> ToDo:
>> * Translate the key "systemconnection" "Use system proxy settings" to
>> all of the languages except spanish and english. You can look into the
>> network preferences of firefox and use the same phrase.
>> * KDE, Xfce support...
>> * Testing authentication
>> * Test...
>>
>>
>>
>> I have been using it for two weeks and everything seems to work fine.
>>
>> -- 
>> Regards, Pablo.
> 
>> Index: lang/langen
>> ===================================================================
>> --- lang/langen      (revisi??n: 10812)
>> +++ lang/langen      (copia de trabajo)
>> @@ -933,6 +933,7 @@
>>  subject Subject
>>  svnversion SVN Version
>>  syntaxerror Syntax Error
>> +systemconnection Use system proxy settings
>>  tabbedglobal A tabbed window for all users in the contact list
>>  tabbedgroups A tabbed window for users from the same group
>>  tabbed Tabbed Windows
>> Index: lang/langes
>> ===================================================================
>> --- lang/langes      (revisi??n: 10812)
>> +++ lang/langes      (copia de trabajo)
>> @@ -934,6 +934,7 @@
>>  subjectrequired Asunto requerido
>>  svnversion Versi??n SVN
>>  syntaxerror Error de sintaxis
>> +systemconnection Usar los datos de proxy del sistema
>>  tabbedglobal Una ventana con pesta??as para todos los usuarios
>>  tabbedgroups Una ventana con pesta??as para cada grupo
>>  tabbed Ventanas con pesta??as
>> Index: protocol.tcl
>> ===================================================================
>> --- protocol.tcl     (revisi??n: 10812)
>> +++ protocol.tcl     (copia de trabajo)
>> @@ -7257,6 +7257,104 @@
>>              $name configure -proxy_user [::config::getKey proxyuser]
>>              $name configure -proxy_password [::config::getKey proxypass]
>>  
>> +    } elseif { [::config::getKey connectiontype] == "system" } {
>> +
>> +            # System proxy settings by PabloCastellano
>> +            # !!!Only GNOME and $http_proxy support at the moment!!!
>> +            # Maybe the gconf keys use_same_proxy and autoconfig_url should 
>> be considered.
>> +            # system http proxy working
>> +            # I HAVE NOT TESTED authentication over http but it should work.
>> +
>> +            #First try to get environment var "http_proxy"
>> +            # env $http_proxy will only exist if amsn is launched from a 
>> terminal
>> +            #try to get use_http_proxy from gconf           
>> +            if { ! [info exists ::env(http_proxy) ] &&
>> +                    ! [catch { eval [concat [list "exec"] "gconftool -g 
>> /system/proxy/mode"]} proxymode ] } {
>> +
>> +                    set usehttp [eval [concat [list "exec"] "gconftool -g 
>> /system/http_proxy/use_http_proxy"]]
>> +                    status_log "systemproxy: Use system proxy: $usehttp\n" 
>> red
>> +
>> +                    if {$usehttp == "true" && $proxymode != "none"} {
>> +
>> +                            #Get host from gconf
>> +                            if { [catch { eval [concat [list "exec"] 
>> "gconftool -g /system/http_proxy/host"]} proxyhost ] } {
>> +                                    status_log "systemproxy: Error getting 
>> host from gconf\n" red
>> +                            } else {
>> +                                    status_log "systemproxy: proxy is: 
>> $proxyhost\n" red
>> +                                    $name configure -proxy_host $proxyhost
>> +                            }
>> +                            
>> +                            #Get port from gconf
>> +                            if { [catch { eval [concat [list "exec"] 
>> "gconftool -g /system/http_proxy/port"]} proxyport ] } {
>> +                                    status_log "systemproxy: Error getting 
>> port from gconf\n" red
>> +                            } else {
>> +                                    status_log "systemproxy: port is: 
>> $proxyport\n" red
>> +                                    $name configure -proxy_port $proxyport
>> +                            }
>> +
>> +                            #Get use_authentication from gconf
>> +                            if { [catch { eval [concat [list "exec"] 
>> "gconftool -g /system/http_proxy/use_authentication"]} proxyauth ] } {
>> +                                    status_log "systemproxy: Error getting 
>> use_authentication from gconf\n" red
>> +                            } else {
>> +                                    status_log "systemproxy: 
>> use_authentication is: $proxyauth\n" red
>> +
>> +                                    if {$proxyauth == "true"} {
>> +
>> +                                            $name configure 
>> -proxy_authenticate 1
>> +
>> +                                            #Get authentication_user from 
>> gconf
>> +                                            if { [catch { eval [concat 
>> [list "exec"] "gconftool -g /system/http_proxy/authentication_user"]} 
>> proxyuser ] } {
>> +                                                    status_log 
>> "systemproxy: Error getting authentication_user from gconf\n" red
>> +                                            } else {
>> +                                                    status_log 
>> "systemproxy: authentication_user is: $proxyuser\n" red
>> +                                                    $name configure 
>> -proxy_user $proxyuser
>> +                                            }
>> +
>> +                                            #Get authentication_password 
>> from gconf
>> +                                            if { [catch { eval [concat 
>> [list "exec"] "gconftool -g /system/http_proxy/authentication_password"]} 
>> proxypass ] } {
>> +                                                    status_log 
>> "systemproxy: Error getting authentication_password from gconf\n" red
>> +                                            } else {
>> +                                                    status_log 
>> "systemproxy: authentication_password is: $proxypass\n" red
>> +                                                    $name configure 
>> -proxy_password $proxypass
>> +                                            }
>> +
>> +                                    } else { # use_authentication == "false"
>> +                                            $name configure 
>> -proxy_authenticate 0 -proxy_user "" -proxy_password ""
>> +                                    } 
>> +                            }
>> +            
>> +
>> +                    } else { # use_http_proxy == "false" || mode == "none"
>> +                            #Configure as direct
>> +                            $name configure -proxy_host ""
>> +                            $name configure -proxy_port ""
>> +                    }
>> +            
>> +            } elseif { [info exists ::env(http_proxy) ] } {
>> +                    #regexp. http://%s:%...@%s:%d
>> +                    regsub 
>> {^(?:(?:[^:/?#]+):)?(?://(?:(?:(?:([^:@]*):?([^:@]*))?@)?([^:/?#]*)(?::(\d*))?))?}
>>  $::env(http_proxy) {"\1" "\2" "\3" "\4"} result
>> +
>> +                    set     user [lindex $result 0]
>> +                    set pass [lindex $result 1]
>> +                    set host [lindex $result 2]
>> +                    set port [lindex $result 3]
>> +
>> +                    $name configure -proxy_host $host -proxy_port $port
>> +
>> +                    if {[llength $user] == 0} { 
>> +                            $name configure -proxy_authenticate 0 
>> -proxy_user "" -proxy_password ""
>> +                    } else {
>> +                            $name configure -proxy_authenticate 1 
>> -proxy_user $user -proxy_password $pass
>> +                    }
>> +
>> +            } else { #it's not gnome and ENV $http_proxy is not set. => 
>> Don't use proxy
>> +                    status_log "systemproxy: use_http_proxy gconf key NOT 
>> FOUND\n" red
>> +                    
>> +                    #Configure as direct
>> +                    $name configure -proxy_host ""
>> +                    $name configure -proxy_port ""
>> +        } 
>> +
>>      } else {
>>              #$name configure -connection_wrapper DirectConnection
>>              ::config::setKey connectiontype "direct"
>> Index: preferences.tcl
>> ===================================================================
>> --- preferences.tcl  (revisi??n: 10812)
>> +++ preferences.tcl  (copia de trabajo)
>> @@ -2197,6 +2197,8 @@
>>      pack $lfname.1.direct -anchor w -side top -padx 10
>>      radiobutton $lfname.2.http -text "[trans httpconnection]" -value http 
>> -variable [::config::getVar connectiontype] -command UpdatePreferences
>>      pack $lfname.2.http -anchor w -side top -padx 10
>> +    radiobutton $lfname.3.system -text "[trans systemconnection]" -value 
>> system -variable [::config::getVar connectiontype] -command UpdatePreferences
>> +    pack $lfname.3.system -anchor w -side top -padx 10
>>      radiobutton $lfname.3.proxy -text "[trans proxyconnection]" -value 
>> proxy -variable [::config::getVar connectiontype] -command UpdatePreferences
>>      pack $lfname.3.proxy -anchor w -side top -padx 10
>>  
>> Index: soap.tcl
>> ===================================================================
>> --- soap.tcl (revisi??n: 10812)
>> +++ soap.tcl (copia de trabajo)
>> @@ -76,6 +76,51 @@
>>                              set headers [linsert $headers 0 
>> "Proxy-Authorization" "Basic $auth"]
>>                      }
>>                      http::register https 443 HTTPsecureSocket
>> +                    http::register http 80 ::socket
>> +            } elseif { [::config::getKey connectiontype] == "system" } {
>> +                    
>> +                    if { ! [info exists ::env(http_proxy) ] &&
>> +                            ! [catch { eval [concat [list "exec"] 
>> "gconftool -g /system/proxy/mode"]} proxymode ] } {
>> +                            set usehttp [eval [concat [list "exec"] 
>> "gconftool -g /system/http_proxy/use_http_proxy"]]
>> +
>> +                            if {$usehttp == "true" && $proxymode != "none"} 
>> {
>> +                                    set proxy_host [eval [concat [list 
>> "exec"] "gconftool -g /system/http_proxy/host"]]
>> +                                    set proxy_port [eval [concat [list 
>> "exec"] "gconftool -g /system/http_proxy/port"]]
>> +                                    ::http::config -proxyhost $proxy_host 
>> -proxyport $proxy_port
>> +
>> +                                    if { ! [catch { eval [concat [list 
>> "exec"] "gconftool -g /system/http_proxy/use_authentication"]} result ] } {
>> +                                            
>> +                                            if {$result == "true"} {        
>> +                                                    set proxy_user [eval 
>> [concat [list "exec"] "gconftool -g /system/http_proxy/authentication_user"]]
>> +                                                    set proxy_pass [eval 
>> [concat [list "exec"] "gconftool -g 
>> /system/http_proxy/authentication_password"]]
>> +                                                    set auth [string map 
>> {"\n" "" } [base64::encode ${proxy_user}:${proxy_pass}]]
>> +                                                    set headers [linsert 
>> $headers 0 "Proxy-Authorization" "Basic $auth"]
>> +                                            }
>> +                                    }
>> +
>> +                            }
>> +                    } elseif { [info exists ::env(http_proxy) ] } {
>> +                                    #regexp. http://%s:%...@%s:%d
>> +                                    regsub 
>> {^(?:(?:[^:/?#]+):)?(?://(?:(?:(?:([^:@]*):?([^:@]*))?@)?([^:/?#]*)(?::(\d*))?))?}
>>  $::env(http_proxy) {"\1" "\2" "\3" "\4"} result
>> +
>> +                                    set     proxy_user [lindex $result 0]
>> +                                    set proxy_pass [lindex $result 1]
>> +                                    set proxy_host [lindex $result 2]
>> +                                    set proxy_port [lindex $result 3]
>> +
>> +                                    ::http::config -proxyhost $proxy_host 
>> -proxyport $proxy_port
>> +
>> +                                    if {[llength $user] != 0} {
>> +                                            set auth [string map {"\n" "" } 
>> [base64::encode ${proxy_user}:${proxy_pass}]]
>> +                                            set headers [linsert $headers 0 
>> "Proxy-Authorization" "Basic $auth"]
>> +                                    }
>> +
>> +                    } else {
>> +                            status_log "systemproxy: in soap.tcl couldn't 
>> find use_http_proxy key in gnome" red
>> +                            ::http::config -proxyhost "" -proxyport ""
>> +                    }
>> +
>> +                    http::register https 443 HTTPsecureSocket
>>                      http::register http 80 ::socket
>>              } elseif { [::config::getKey connectiontype] == "proxy" && 
>> [::config::getKey proxytype] == "socks5" } {
>>                      if {$proxy_host == "" } {
>> Index: config.tcl
>> ===================================================================
>> --- config.tcl       (revisi??n: 10812)
>> +++ config.tcl       (copia de trabajo)
>> @@ -27,7 +27,7 @@
>>              ::config::setKey log_event_nick 0               ;#Log 
>> changement of status
>>              ::config::setKey log_event_psm 0                ;#Log 
>> changement of status
>>  
>> -            ::config::setKey connectiontype direct  ;# Connection type: 
>> direct|http|proxy
>> +            ::config::setKey connectiontype direct  ;# Connection type: 
>> direct|http|proxy|system
>>              ::config::setKey proxy ""                       ;# If using 
>> proxy, proxy host
>>              ::config::setKey proxytype "http"               ;# Proxy type: 
>> http|ssl|socks5
>>              ::config::setKey proxyauthenticate 0            ;# SOCKS5 use 
>> username/password
>> Index: proxy.tcl
>> ===================================================================
>> --- proxy.tcl        (revisi??n: 10812)
>> +++ proxy.tcl        (copia de trabajo)
>> @@ -172,6 +172,23 @@
>>                      install proxy using ProxyDirect %AUTO% -name $self
>>              } elseif { [::config::getKey connectiontype] == "proxy" && 
>> [::config::getKey proxytype] == "socks5" } {
>>                      install proxy using ProxyDirect %AUTO% -name $self
>> +            } elseif { [::config::getKey connectiontype] == "system" } {
>> +                    if { ! [info exists ::env(http_proxy) ] &&
>> +                            ! [catch { eval [concat [list "exec"] 
>> "gconftool -g /system/proxy/mode"]} proxymode ] } {
>> +                            set usehttp [eval [concat [list "exec"] 
>> "gconftool -g /system/http_proxy/use_http_proxy"]]
>> +
>> +                            if {$usehttp == "true" && $proxymode != "none"} 
>> {
>> +                                    install proxy using ProxyHTTP %AUTO% 
>> -name $self -direct 0
>> +                            } else { 
>> +                                    #if use_http_proxy is false then use 
>> directconnection
>> +                                    install proxy using ProxyDirect %AUTO% 
>> -name $self
>> +                            }
>> +                    } elseif { [info exists ::env(http_proxy) ] } {
>> +                            install proxy using ProxyHTTP %AUTO% -name 
>> $self -direct 0
>> +                    } else {
>> +                            status_log "systemproxy: in proxy.tcl couldn't 
>> find use_http_proxy key in gnome" red
>> +                            install proxy using ProxyDirect %AUTO% -name 
>> $self
>> +                    }
>>              } else {
>>                      ::config::setKey connectiontype "direct"
>>                      install proxy using ProxyDirect %AUTO% -name $self
> 
>> ------------------------------------------------------------------------------
> 
>> _______________________________________________
>> Amsn-devel mailing list
>> Amsn-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/amsn-devel
> 
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> Amsn-devel mailing list
> Amsn-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/amsn-devel
> 

------------------------------------------------------------------------------
_______________________________________________
Amsn-devel mailing list
Amsn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amsn-devel

Reply via email to