Hacking Gmail

(Grace) #1

148 Part II — Getting Inside Gmail


$aim->im_permit_all();

$aim -> sign_on();

while (1)
{
last unless defined($foo->ui_dataget(undef));
}

sub reply
{

my $params = $_[ARG1];

my $aim_event_type = $params->[0];

if($aim_event_type eq ‘IM_IN’) {

my $aimdestuser = $params->[1];

my $gmail = Mail::Webmail::Gmail->new(
username => $gmail_user,
password => $gmail_password,
);

my $messages =
$gmail->get_messages( label =>
$Mail::Webmail::Gmail::FOLDERS{‘INBOX’} );

my $new_msgs = 0;

if ( defined($messages) ) {
foreach ( @{$messages} ) {
if ( $_->{‘new’} ) {
$new_msgs++;
}
}
}

my $message = “$gmail_user has a new message count of
$new_msg”;
$aim->toc_send_im($aim_destuser, $message);

}
}
s
Free download pdf