[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Yet Another AppleEvents Question (YAAEQ)



Hi, everyone,

Yet another AppleEvents question from a novice...

I'm trying to control WebStar from a CGI (I'm writing Mac::Apps::WebStar)
and I don't understand how to handle booleans (passing them or receiving
them).


Here's a snippet from 'aete.convert':

@EVENT "validate user", "Validate that a given password is correct for a
user in a specific realm", 'WWW½', 'Vusr'
@REPLY 'bool', "True: User is valid, False: user or password is invalid",
REQ, SINGLE, NOENUM
@DIRECT 'char', "user name", REQ, SINGLE, NOENUM, NOCHANGE
@PARAM  "password", 'AUpw', 'char', "password", REQ, SINGLE, NOENUM
@PARAM  "realm", 'AUrm', 'char', "realm", REQ, SINGLE, NOENUM

@EVENT "Refuse Connections", "Toggle incoming connections on or off",
'WWW½', 'fcon'
@REPLY 'null', "¹", REQ, SINGLE, NOENUM
@DIRECT 'bool', "True or False", REQ, SINGLE, NOENUM, NOCHANGE



Here's a framework for the two routines (I inserted '???'s in the areas
that I have no idea about):

use Mac::AppleEvents::Simple;
sub validate_user {
    my ($userid, $realm, $passwd) = @_;
    my $obj = "obj{obj{want:type(bool), " .                ???
        "from:null(), form:enum(name), seld:TEXT(\@)}}";   ???
    $event = do_event(qw/WWW½ VUsr WWW½/,
        "'----':$obj, AUpw:TEXT(@), AUrm:TEXT(@)",
        $userid, $passwd, $realm);
    return ??? ;
}

sub refuse_connections {
    my ($state) = shift;
    my $obj = "obj{   ???   }";
    $event = do_event(qw/WWW½ fcon WWW½/,
        "'----':$obj", $state);
}


So my questions are:
1) How do I pass a boolean?  Is it expecting a 0|1 or "TRUE|FALSE", etc?
2) How do I retrieve a boolean result?
3) Is the routine 'event_error()' an appropriate way to check for error
conditions?

# Ex: $err = event_error($evt)
sub event_error {
    $event = shift;
    return "" unless $event;
    my $err = $event->{REPLY};
    if ($err =~ /errn:/) {
        my ($val) = $err =~ /:(.*)}/;
        return $val;
    } else {
        return "";
    }
}


Thanks,
--Michael


Michael Leahy             Computer Systems Development Supervisor
michael.leahy@vt.edu      Educational Technologies, Mail Code 0232
540-231-3272              Old Security Building, Virginia Tech
540-231-5922 fax          Blacksburg, Virginia  24061

         Intellectual revolutions succeed when
         the old guard dies or retires. --Unknown



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch