Mercurial > pidgin.yaz
view doc/PERL-HOWTO.dox @ 7652:ac6b2b3a9a1f
[gaim-migrate @ 8296]
Bj?rn Voigt (bjoernv) writes:
" I found a small problem in Gaim's proxy settings. There
is an option "Use Environmental Settings". This option
does not work as expected.
Gaim reads the environment variables http_proxy (or
HTTP_PROXY or HTTPPROXY) and http_proxy_port (or
HTTP_PROXY_PORT or HTTPPROXYPORT) and variables for
proxy user and proxy password. Gaim expects the
following format:
export http_proxy=your.proxy.server
export http_proxy_port=8080
As far as I know this is a unusual format. Probably
there is no
standard document, which describes the correct format
of proxy
variables, but browsers like Konqueror, Amaya, Lynx and
others use a pseudo standard format:
export http_proxy="http://your.proxy.server:8080/"
The port number defaults to 80. The variable
http_proxy_port is
unknown. The proxy variable format is described in some
W3C pages, for instance:
http://www.w3.org/Daemon/User/Proxies/ProxyClients.html
http://www.w3.org/Library/User/Using/Proxy.html
http://www.w3.org/Amaya/User/Proxy.html
Solution
--------
My patch fixes the proxy environment variable parsing
in src/proxy.c:1626: gaim_proxy_connect(). The patch
removes
http_proxy_port and uses gaim_url_parse() from
src/util.c to parse the http_proxy variable.
Remaining problems
------------------
If a user has adjusted his proxy settings to Gaim's old
proxy variable format, he gets an error. I don't think,
that this is a big problem, as not much users set their
proxy variables only for one program (old proxy
variables where incompatible with browsers like Lynx,
Konqueror,
...).
Gaim still doesn't look at the no_proxy variable. This
variables
defines hosts and domains, which should be connected
directly:
export
no_proxy="cern.ch,ncsa.uiuc.edu,some.host:8080"
For example, one user may want to connect to Yahoo!
over a proxy and to an internal Jabber server without a
proxy. But the user can define individual proxy
variables for each account."
he continues:
"Nathan Walp <faceprint@faceprint.com> wrote:
> Why not have your patch check to see if the http_proxy var
starts with
> "http://", and if so, parse it, otherwise fall
back on the
old behavior.
Ok, the function gaim_url_parse() automatically detects
hostnames and port numbers, if the http_proxy URL does not
start with http://.
My new patch also checks for http_proxy_port. Now my patch
(file proxy2.patch) is fully backward compatible and tested."
given how rarely the current proxy code works, i don't see how this could
possibly make things worse, so i'm taking a chance since it compiles.
someone please test this.
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Sat, 29 Nov 2003 03:46:24 +0000 |
parents | 3c3039aa7259 |
children | 90ed8fcca27c |
line wrap: on
line source
/** @page perl-howto Perl Scripting HOWTO @section Introduction Perl is the first scripting language compatible with Gaim, and has been a valuable aid to developers wishing to write scripts to modify the behavior of their favorite instant messenger. A perl script acts like a normal plugin, and appears in the list of plugins in Gaim's preferences pane. Until now, they have been very basic, and consisted of only a few functions. However, with the latest changes to Gaim's perl API, a much larger part of Gaim is now open. In time, even such things as Gtk+ preference panes for perl scripts will be possible. @section first-script Writing your first perl script Enough of that. You want to know how to write a perl script, right? First off, we're going to assume here that you are familiar with perl. Perl scripts in Gaim are just normal perl scripts, which happen to use Gaim's loadable perl module. Now, you're going to want to place your script in $HOME/.gaim/plugins/. That's the place where all plugins and scripts go, regardless of language. The first thing you're going to write in your script is the necessary code to actually register and initialize your script, which looks something like this: @code use Gaim; %PLUGIN_INFO = ( perl_api_version => 2, name => "Your Plugin's Name", version => "0.1", summary => "Brief summary of your plugin.", description => "Detailed description of what your plugin does.", author => "Your Name <email@address>", url => "http://yoursite.com/", load => "plugin_load", unload => "plugin_unload" ); sub plugin_init { return %PLUGIN_INFO; } sub plugin_load { my $plugin = shift; } sub plugin_unload { my $plugin = shift; } @endcode The first thing you see is a hash called @c @%PLUGIN_INFO. It contains the basic information on your plugin. In the future, additional fields may be allowed, such as ones to setup a Gtk+ preferences pane. The @c plugin_init function is required in all perl scripts. Its job is to return the @c @%PLUGIN_INFO hash, which Gaim will use to register and initialize your plugin. The @c plugin_load function is called when the user loads your plugin from the preferences, or on startup. It is passed one variable, which is a handle to the plugin. This must be used when registering signal handlers or timers. The @c plugin_unload function is called when the user is unloading your plugin. Its job is to clean up anything that must be dealt with before unloading, such as removing temporary files or saving configuration information. It does @em not have to unregister signal handlers or timers, as Gaim will do that for you. @warning Do @b NOT put any executable code outside of these functions or your own user-defined functions. Variable declarations are okay, as long as they're set to be local. Bad Things (TM) can happen if you don't follow this simple instruction. @section Timeouts One feature useful to many perl plugin writers are timeouts. Timeouts allow code to be ran after a specified number of seconds, and are rather simple to setup. Here's one way of registering a timeout. @code sub timeout_cb { my $data = shift; Gaim::debug_info("my perl plugin", "Timeout callback called! data says: $data\n"); } sub plugin_load { my $plugin = shift; # Start a timeout for 5 seconds. Gaim::timeout_add($plugin, 5, \&timeout_cb, "Hello!"); } @endcode Here's another way of calling a timeout: @code sub plugin_load { my $plugin = shift; # Start a timeout for 5 seconds. Gaim::timeout_add($plugin, 5, sub { my $data = shift; Gaim::debug_info("my perl plugin", "Timeout callback called! data says: $data\n"); }, "Hello!"); } @endcode A timeout automatically unregisters when it reaches 0 (which is also when the callback is called). If you want a timeout to call a function every specified number of seconds, just re-register the timeout at the end of the callback. The data parameter is optional. If you don't have data to pass to the callback, simply omit the parameter. @section Signals Signals are how gaim plugins get events. There are a number of @ref Signals signals available. A signal is registered by connecting a signal name owned by an instance handle to a callback on the plugin handle. This is best illustrated with an example. @code sub connection_signed_on_cb { my ($gc, $data) = @_; my $account = $gc->get_account(); Gaim::debug_info("my perl plugin", "Account " . $account->get_username() . " signed on.\n"); } sub plugin_load { my $plugin = shift; my $data = ""; Gaim::signal_connect(Gaim::Connections::handle, "signed-on", $plugin, \&signed_on_cb, $data); } @endcode Like timeouts, the callback can be an embedded subroutine, and also like timeouts, the data parameter can be omitted. @section Notes The API in perl is very similar to Gaim's C API. The functions have been gathered into packages, but most are the same, and the documentation can be a big help at times. @section Resources @see Signals @see Perl API Reference */ // vim: syntax=c tw=75 et