Porting GPA to GPGME

Miguel Coca e970095@zipi.fi.upm.es
Sun Aug 11 20:59:02 2002


On Sun, Aug 11, 2002 at 15:16:07 +0200, Marcus Brinkmann wrote:
> > On a related note, that may be worth documenting, I would like to know if
> > after a call to gpgme_data_new_from_file returns a GPGME_File_Error, I can
> > trust that I can still retrieve the original error ("file not found", etc),
> > from errno.
> 
> If a file error occurs, it will do that.

Ok, so I can trust it not to attempt any other operation that may change
errno before I get to it.

> But there are other errors possible, too (like, out of memory, invalid
> arguments), so you need a two-staged error handling

Yes, that's what I was doing. Most GPGME errors are fatal errors, so if they
happen I just pop up an error dialog and terminate the application, but
before I check for any reasonable errors (no file found, etc).

> > Also, importing keys does not work. I think that is not my fault, since a
> > "make check" on gpgme fails with:
> 
> Please be more specific.

The code that fails is:

      if (filename)
        {
          /* Import keys from the user specified file.
           */
          GpgmeData data;
          GpgmeError err;
          err = gpgme_data_new_from_file (&data, filename, 1);
          if (err == GPGME_No_Error)
            {
              err = gpgme_op_import (ctx, data);
              /* FIXME: Check for non fatal errors */
              if (err != GPGME_No_Error)
                {
                  gpa_gpgme_error (err);
                }
              gpgme_data_release (data);
            }
          else if (err == GPGME_File_Error)
            {
              gchar message[256];
              g_snprintf (message, sizeof(message), "%s: %s",
                          filename, strerror(errno));
              gpa_window_error (message, editor->window);
              return;
            }
          else
            {
              gpa_gpgme_error (err);
            }
        }

I've verified that filename contains a valid file, and the error occurs in
the gpgme_op_import in any case.

> It should work, the test case is broken.

Since the error I get is the same as the one in the test case, my guess is
that my code is broken too :-) Could you tell me where exactly?

Bye,
-- 
Miguel Coca                                         e970095@zipi.fi.upm.es
PGP Key 0x27FC3CA8                         http://zipi.fi.upm.es/~e970095/