[aMess - a Messaging Program]

aMess

a Messaging Program

SourceForge Logo

Implementation details

The class attributed to the storage objects is aMail::Storage.

As explained, each object has methods (open, close, read, write, etc.) to manipulate data in the data storage, whose interface (and usage) is defined in the following paragraphs.

A note, before starting with the methods, is that all methods return a value, which indicates an error when this values is undefinde (undef). The error number and text are stored in the variables $Error and $ErrorText. The text message is not language dependent, because it's intended for internal use.

auth_methods()

@return = auth_methods( { CLID => $ClassID } );
(1) The authentication method supported are:

open()

Opens a connection to the desired storage class.
$handle = open( { AUTH_METHOD => $auth_method,
                  AUTH_PARAMETERS => %auth_parameters,
                  CLID => $ClassID       } );
where, It returns a handle to the created object that links the actual program to the indicated storage class.

In this implementation the class ID will be the name of the clase that implements the corresponding storage class as follows:

CLass ID    --->   Implemented in class

EMail       --->   aMail::Storage::EMail
Profile     --->   aMail::Storage::Profile
Config      --->   aMail::Storage::Config

close()

The usage is simply:
$handle->close();
and ends the relationship with the storage class specified by $handle

read()

Inits the data retrieval.
$ref_data = $handle->read( { LOCATOR => %aQL } )
where,

read_next()

Returns the next element that satisfies the criteria stated in read through the LOCATOR clause (in aQL).
%return = $handle->read_next( { DATA => $ref_data } );

insert() or update()

$handle->insert( { DATA => %Data } );
$handle->update( { DATA => %Data } );
where,

Example of usage

#!/usr/bin/perl
#
# This example is for use when the e-mail storage mechanism uses
# user/password athentication schema (such as many RDBMS do it).

use aMail::Storage;

######
## Queries about the accepted authentication methods
######

@auth_method = auth_methods( { CLID => 'EMail' } );

print "auth_methods failed :-(\nError: $ErrorText\n" 
    if ( ! defined @auth_method  );

######
## Look for User/password authentication method
######

foreach ( @auth_method ) {
    $ok = 1     if ( $_ eq 'USER_PWD' );
}

die "No User/Password authentication :-(\n"  
    if ( ! $ok );

######
## Create a connection
######

%auth_parameters = ( 'USER' => 'MyUser',
                     'PASSWDORD' => 'MyPassword'  );

$handle = open( { AUTH_METHOD => 'USER_PWD',
                  AUTH_PARAMETERS => %auth_parameters,
                  CLID => 'EMail'       } );

print "open failed :-(\nError: $ErrorText\n" 
    if ( ! defined $handle  );

######
## Queries the e-mail storage area
######

%aQL = ( 'FOLDER' => 'Sent',
         'SUBJECT' => 'aMail-devel');

$ref_data = $handle->read( { LOCATOR => %aQL } )

print "read failed :-(\nError: $ErrorText\n" 
    if ( ! defined $ref_data  );

######
## Read each record (??)
######

while ( %return = $handle->read_next( { DATA => $ref_data } ) ) {
    foreach ( keys %return ) {
        print "$_: " . $return{$_} . "\n";
    }
    print "-" x 50 . "\n";
}

######
## Bye, bye storage !!!
######

$handle->close();


[aMess documentation]

aMess

a Messaging program