[Kde-pim] [patch] make gpgme++ portable to msvc

Marc Mutz marc at klaralvdalens-datakonsult.se
Sat Dec 8 10:20:25 GMT 2007


Hi Jaroslaw,

Thanks for the patch, I have only minor comments, inlined:

On Friday 07 December 2007 23:18, Jarosław Staniek wrote:
<snip>
> Index: result_p.h
> ===================================================================
> --- result_p.h  (revision 746016)
> +++ result_p.h  (working copy)
> @@ -33,7 +33,7 @@
>  
>  #define make_error_ctor(x) \
>  GpgME::x::x( const Error & error ) \
> -  : GpgME::Result( error ), d( 0 ) \
> +  : GpgME::Result( error.toErrorCode() ), d( 0 ) \

GpgME::Result should probably take an GpgME::Error as ctor arg right away, 
here, don't you think? :)

>  { \
>   \
>  }
> Index: gpgsetownertrusteditinteractor.cpp
> ===================================================================
> --- gpgsetownertrusteditinteractor.cpp  (revision 746016)
> +++ gpgsetownertrusteditinteractor.cpp  (working copy)
> @@ -25,6 +25,8 @@
>  
>  #include <gpgme.h>
>  
> +#undef ERROR
> +

#ifdef ERROR
# undef ERROR
#endif

>  using namespace GpgME;
>  
>  GpgSetOwnerTrustEditInteractor::GpgSetOwnerTrustEditInteractor(
> Key::OwnerTrust ot ) Index: context.cpp
> ===================================================================
> --- context.cpp (revision 746016)
> +++ context.cpp (working copy)
> @@ -553,7 +553,9 @@
>      return Error( d->lasterr = gpgme_op_getauditlog_start( d->ctx, odp ?
> odp->data : 0, to_auditlog_flags( flags ) ) ); #else
>      (void)output; (void)flags;
> -    return Error( d->lasterr = makeError( GPG_ERR_NOT_IMPLEMENTED ) );
> +    Error error( makeError( GPG_ERR_NOT_IMPLEMENTED ) );
> +    d->lasterr = error.toErrorCode();
> +    return error;
>  #endif
>    }
>  
> @@ -564,7 +566,9 @@
>      return Error( d->lasterr = gpgme_op_getauditlog( d->ctx, odp ?
> odp->data : 0, to_auditlog_flags( flags ) ) ); #else
>      (void)output; (void)flags;
> -    return Error( d->lasterr = makeError( GPG_ERR_NOT_IMPLEMENTED ) );
> +    Error error( makeError( GPG_ERR_NOT_IMPLEMENTED ) );
> +    d->lasterr = error.toErrorCode();
> +    return error;

Unless there's a problem with making makeError() return a gpg(me)_error_t, or 
turning d->lasterr into a GpgME::Error, I'd prefer you kept the single-line 
version, thanks.

>  #endif
>    }
>  
> Index: error.h
> ===================================================================
> --- error.h     (revision 746016)
> +++ error.h     (working copy)
> @@ -41,7 +41,7 @@
>  
>      bool isCanceled() const;
>  
> -    operator unsigned int() const { return mErr; }
> +    int toErrorCode() const { return mErr; }

First of all, there's already a code() method, and it returns the error code 
sans source ID. So toErrorCode() is misnamed. I don't have a good name, 
either, but
  unsigned int encodedError() const;
or
  unsigned int codeAndSource() const;
come to mind. Note the return type and function naming convention.

>    private:
>      struct __safe_bool_dummy__ { void nonnull() {} };
> Index: editinteractor.cpp
> ===================================================================
> --- editinteractor.cpp  (revision 746016)
> +++ editinteractor.cpp  (working copy)
> @@ -59,7 +59,7 @@
>              
>              if ( ei->state != oldState &&
>                   // if there was an error from before, we stop here (###
> this looks weird, can this happen at all?) -                 gpg_err_code(
> ei->error ) == GPG_ERR_NO_ERROR ) { +                 gpg_err_code(
> ei->error.toErrorCode() ) == GPG_ERR_NO_ERROR ) { 

This one should actually be
  ei->error.code() == GPG_ERR_NO_ERROR
Not your patch's problem, though.

Thanks,
Marc


-- 
Marc Mutz -- marc at klaralvdalens-datakonsult.se, mutz at kde.org
Klarälvdalens Datakonsult AB, Platform-independent software solutions
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/


More information about the kde-pim mailing list