[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4. Architecture

PGG introduces the notion of a "scheme of PGP implementation" (used interchangeably with "scheme" in this document). This term refers to a singleton object wrapped with the luna object system.

Since PGG was designed for accessing and developing PGP functionality, the architecture had to be designed not just for interoperability but also for extensiblity. In this chapter we explore the architecture while finding out how to write the PGG backend.

4.1 Initializing  
4.2 Backend methods  
4.3 Getting output  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1 Initializing

A scheme must be initialized before it is used. It had better guarantee to keep only one instance of a scheme.

The following code is snipped out of `pgg-gpg.el'. Once an instance of pgg-gpg scheme is initialized, it's stored to the variable pgg-scheme-gpg-instance and will be reused from now on.

 
(defvar pgg-scheme-gpg-instance nil)

(defun pgg-make-scheme-gpg ()
  (or pgg-scheme-gpg-instance
      (setq pgg-scheme-gpg-instance
	    (luna-make-entity 'pgg-scheme-gpg))))

The name of the function must follow the regulation---pgg-make-scheme- follows the backend name.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.2 Backend methods

In each backend, these methods must be present. The output of these methods is stored in special buffers (4.3 Getting output), so that these methods must tell the status of the execution.

Method: pgg-scheme-lookup-key scheme string &optional type
Return keys associated with string. If the optional third argument type is non-nil, it searches from the secret keyrings.

Method: pgg-scheme-encrypt-region scheme start end recipients &optional sign
Encrypt the current region between start and end for recipients. If sign is non-nil, do a combined sign and encrypt. If encryption is successful, it returns t, otherwise nil.

Method: pgg-scheme-decrypt-region scheme start end
Decrypt the current region between start and end. If decryption is successful, it returns t, otherwise nil.

Method: pgg-scheme-sign-region scheme start end &optional cleartext
Make the signature from text between start and end. If the optional third argument cleartext is non-nil, it does not create a detached signature. If signing is successful, it returns t, otherwise nil.

Method: pgg-scheme-verify-region scheme start end &optional signature
Verify the current region between start and end. If the optional third argument signature is non-nil, it is treated as the detached signature of the current region. If the signature is successfully verified, it returns t, otherwise nil.

Method: pgg-scheme-insert-key scheme
Retrieve the user's public key and insert it as ASCII-armored format. On success, it returns t, otherwise nil.

Method: pgg-scheme-snarf-keys-region scheme start end
Collect public keys in the current region between start and end, and add them into the user's keyring. On success, it returns t, otherwise nil.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.3 Getting output

The output of the backend methods (4.2 Backend methods) is stored in special buffers, so that these methods must tell the status of the execution.

Variable: pgg-errors-buffer
The standard error output of the execution of the PGP command is stored here.

Variable: pgg-output-buffer
The standard output of the execution of the PGP command is stored here.

Variable: pgg-status-buffer
The rest of status information of the execution of the PGP command is stored here.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by XEmacs shared group account on December, 19 2009 using texi2html 1.65.