|
aMessa Messaging Program |
|
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.
@return = auth_methods( { CLID => $ClassID } );
$handle = open( { AUTH_METHOD => $auth_method,
AUTH_PARAMETERS => %auth_parameters,
CLID => $ClassID } );
where,
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
$handle->close();and ends the relationship with the storage class specified by $handle
$ref_data = $handle->read( { LOCATOR => %aQL } )
where,
%return = $handle->read_next( { DATA => $ref_data } );
$handle->insert( { DATA => %Data } );
$handle->update( { DATA => %Data } );
where,
#!/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();
|
aMessa Messaging program |