# $Id: Crypt.pm,v 1.4 2002/05/16 04:32:07 muhri Exp $
# -*- perl -*-
package Pronto::Crypt;

use strict;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);

require Exporter;

@ISA = qw(Exporter AutoLoader);
# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.
@EXPORT = qw(
	
);
$VERSION = '0.01';

sub get_addresses_from_string {
	my $self = shift;
        my $string = shift;
        my @raw_addresses;
        my @addresses;


        @raw_addresses = split(/[<>\s,\")(]+/, $string);

        foreach my $frag (@raw_addresses) {
                if ($frag =~ /\@/) {
                        push(@addresses, $frag);
                } 
        }

         return(@addresses);

}


sub obtain_passphrase {
	my $self = shift;
        my $passwindow = new Gtk::Window(-toplevel);
	$passwindow->set_modal(1);
	$passwindow->position(-mouse);
        $passwindow->set_title(_("Please enter your passphrase"));	#" Dont ask.
        my $hbox = new Gtk::HBox(0,0);
        my $label = new Gtk::Label(_("Passphrase"));
        my $entry = new Gtk::Entry();
        $entry->set_visibility(0);
        my $button = new Gtk::Button(_("Submit"));
        $button->signal_connect('clicked', \&set_passphrase, $entry, $passwindow, $self);
	$entry->signal_connect("activate", \&set_passphrase, $entry, $passwindow, $self);
        $hbox->pack_start($label,0,0,0);
        $hbox->pack_start($entry,0,0,0);
        $hbox->pack_start($button,0,0,0);

        $passwindow->add($hbox);
        $button->show;
        $hbox->show;
        $label->show;
        $entry->show;
        $passwindow->show;
	$entry->grab_focus();
	Gtk->main();
        return 1;
}

sub set_passphrase {
        my $button = shift;
        my $entry = shift;
        my $passwin = shift;
        my $self = shift;

        $self->{passphrase} = $entry->get_text;
#	$self->wr_debug("Got passphrase: $self->{passphrase}");
        $passwin->destroy;
	Gtk->main_quit();
        return 1;
}

sub keyserver_search_window {
	my $self = shift;
        $self->wr_debug("Opening keyserver search window");
        return 1;
}

sub wr_debug {
	print(STDERR "@_\n");
}


# Preloaded methods go here.

# Autoload methods go after =cut, and are processed by the autosplit program.

1;
__END__
# Below is the stub of documentation for your module. You better edit it!

=head1 NAME

Pronto::Crypt - Perl extension for blah blah blah

=head1 SYNOPSIS

  use Pronto::Crypt;
  blah blah blah

=head1 DESCRIPTION

Stub documentation for Pronto::Crypt was created by h2xs. It looks like the
author of the extension was negligent enough to leave the stub
unedited.

Blah blah blah.

=head1 AUTHOR

A. U. Thor, a.u.thor@a.galaxy.far.far.away

=head1 SEE ALSO

perl(1).

=cut


syntax highlighted by Code2HTML, v. 0.9.1