The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Slackware::Slackget::Network - A class for network communication

VERSION

Version 1.0.0 (this version number is absolutly irrelevant and should be considered as an error, real version number is 0.8.2 and is accessible through the $VERSION_REAL variable)

SYNOPSIS

WARNING WARNING : this module's API and behaviour changed a lot since the 0.12 release ! Please take good care of this : WARNING WARNING

This class' purpose is to make all network dialog transparent. You give to this class the raw (XML) network message sent to (or from) a slack-get daemon (sg_daemon) and Slackware::Slackget::Network decode and wrap it for you. The "plus" of this system is that sg_daemon (or any slack-get client) developpers are safe if something change in the network protocol : it will never change the API.

    use Slackware::Slackget::Network;

    my $net = Slackware::Slackget::Network->new();
    my $message_object = new Slackware::Slackget::Network::Message ;
    $message_object->action('get_connection_id');
    my $xml_msg = $net->encode($message_object);
    my $response_object = $net->decode($xml_msg);
    # $message_object and $response_object are equals in term of values

All methods from this module return a Slackware::Slackget::Network::Message (Slackware::Slackget::Network::Message) object.

Since the 0.12 release of this module this module is nothing more than a encoder/decoder for slack-get's network messages. So no more network handling nor automatic response sent directly through the socket passed as argument.

CONSTRUCTOR

new

You can pass the following arguments to the constructor :

* backends => <ARRAYREF> my $net = Slackware::Slackget::Network->new(backends => [ 'ZIP' , 'XML' ]); # **ATTENTION ** : the order you give to the backends determine the way it will encode/decode messages ! # in this exemple, decode() will call : # |_ ZIP->backend_decode() # |_ XML->backend_decode() # And encode() will call : # |_ XML->backend_encode() # |_ ZIP->backend_encode()

The only included backend is the XML one for the moment. If the backend could not be loaded the constructor fall back to the XML backend.

FUNCTIONS

All methods return a Slackware::Slackget::Network::Message (Slackware::Slackget::Network::Message) object, and if the remote slack-getd return some data they are accessibles via the data() accessor of the Slackware::Slackget::Network::Message object.

decode

Decode a Slackware::Slackget::Network::Message by going through the backend decoding stack.

encode

Encode a Slackware::Slackget::Network::Message by going through the backend encoding stack.

interpret

Interpret a Slackware::Slackget::Network::Message. "Interpret" means "execute actions".

So the interpretable Slackware::Slackget::Network::Message are those supported by this module.

Currently supported actions are : get_connection_id

generate

Generate a new Slackware::Slackget::Network::Message formatted for a specific action. Like interpret() it works only with a subset of available actions.

Only the major actions are hardcoded to be automatically generated.

You can generate messages for the following actions : search, build_medias_list, build_update_list, build_installed_list, notification, upgradepkg, installpkg, removepkg, get_patches_list.

backends_list

Return the list of supported backends.

backends_list() returned list contains only backends that can be loaded an instanciated.

scan_backends

Return a list of available backends on the system. Some of those backends can be completly broken.

At this point you have absolutly no garanties that all the backends will works.

cache_data

This method allow you to cache data (incredible isn't it ?). It's use by slack-get to fill network buffer until the complete network message is received.

        $net->cache_data('some kind of stupid data');

cached_data

Return previously cached data.

        my $data = $net->cached_data() ;

clear_cache

Unconditionnally delete cached data from memory.

        $net->clear_cache();

__get_connection_id

Set the id of the connection. The id is generate by the constructor and must not be modified. This method is automatically called by the constructor and is mostly private.

        $net->__get_connection_id ;

connection_id

Get or set the connection ID.

        $net->connection_id(1234);
        print "Connection ID : ", $net->connection_id , "\n";

PKGTOOLS BINDINGS

Methods in this section are the remote call procedure for pkgtools interactions. The slack-getd daemon use another class for direct call to the pkgtools (Slackware::Slackget::PkgTools).

The 3 methods have the same operating mode :

1) Take a single Slackware::Slackget::PackageList as argument

2) Do the job

3) If their is more than one choice for the package you try to install, the daemon ask for a choice of you.

3bis) Re-do the job

4) For each package in the Slackware::Slackget::PackageList set a 'status' field which contain the status of the (install|upgrade|remove) process.

__installpkg

        $net->installpkg($packagelist) ;

__upgradepkg

        $net->upgradepkg($packagelist) ;

__removepkg

Send network commands to a slack-get daemon. This method (like other pkgtools network call), do nothing by herself, but sending a "removepkg:pkg1;pkg2;..;pkgN" to the slack-getd.

        $net->removepkg($packagelist) ;

DEFAULT HANDLERS

Since the 0.12 release there is no more default handlers.

AUTHOR

DUPUIS Arnaud, <a.dupuis@infinityperl.org>

BUGS

Please report any bugs or feature requests to bug-Slackware-Slackget@rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Slackware-Slackget. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Slackware::Slackget

You can also look for information at:

ACKNOWLEDGEMENTS

Thanks to Bertrand Dupuis (yes my brother) for his contribution to the documentation.

SEE ALSO

Slackware::Slackget::Network::Message, Slackware::Slackget::Status, Slackware::Slackget::Network::Connection

COPYRIGHT & LICENSE

Copyright 2005 DUPUIS Arnaud, All Rights Reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.