2001-04-02 Jeffrey Stedfast <fejj@ximian.com>
+ * camel-pgp-context.c (camel_pgp_sign): mutex lock & unlock the context.
+ (camel_pgp_clearsign): Same.
+ (camel_pgp_verify): Same.
+ (camel_pgp_encrypt): Same.
+ (camel_pgp_decrypt): And finally here...
+
* camel-pgp-context.h: Update the function prototypes to match
those found in camel-pgp-context.c.
#include <iconv.h>
+#ifdef ENABLE_THREADS
+#include <pthread.h>
+#define PGP_LOCK(ctx) g_mutex_lock (((CamelPgpContext *) ctx)->priv->lock)
+#define PGP_UNLOCK(ctx) g_mutex_unlock (((CamelPgpContext *) ctx)->priv->lock);
+#else
+#define PGP_LOCK(ctx)
+#define PGP_UNLOCK(ctx)
+#endif
+
#define d(x)
struct _CamelPgpContextPrivate {
CamelSession *session;
CamelPgpType type;
char *path;
+
+#ifdef ENABLE_THREADS
+ GMutex *lock;
+#endif
};
static CamelObjectClass *parent_class;
char passwd_fd[32];
int retval, i;
+ PGP_LOCK(context);
+
/* get the plaintext in a form we can use */
plaintext = g_byte_array_new ();
stream = camel_stream_mem_new ();
g_free (ciphertext);
pgp_forget_passphrase (context->priv->session, context->priv->type, userid);
+ PGP_UNLOCK(context);
+
return -1;
}
camel_stream_write (ostream, ciphertext, strlen (ciphertext));
g_free (ciphertext);
+ PGP_UNLOCK(context);
+
return 0;
exception:
g_free (passphrase);
}
+ PGP_UNLOCK(context);
+
return -1;
}
char passwd_fd[32];
int retval, i;
+ PGP_LOCK(context);
+
/* get the plaintext in a form we can use */
plaintext = g_byte_array_new ();
stream = camel_stream_mem_new ();
camel_stream_write (ostream, ciphertext, strlen (ciphertext));
g_free (ciphertext);
+ PGP_UNLOCK(context);
+
return 0;
exception:
g_free (passphrase);
}
+ PGP_UNLOCK(context);
+
return -1;
}
char *sigfile = NULL;
int retval, i, clearlen;
+ PGP_LOCK(context);
+
/* get the plaintext in a form we can use */
plaintext = g_byte_array_new ();
stream = camel_stream_mem_new ();
g_free (diagnostics);
g_free (cleartext);
+ PGP_UNLOCK(context);
+
return valid;
exception:
g_byte_array_free (plaintext, TRUE);
+ PGP_UNLOCK(context);
+
return NULL;
}
char passwd_fd[32];
char *passphrase = NULL;
+ PGP_LOCK(context);
+
/* get the plaintext in a form we can use */
plaintext = g_byte_array_new ();
stream = camel_stream_mem_new ();
if (sign)
pgp_forget_passphrase (context->priv->session, context->priv->type, userid);
+ PGP_UNLOCK(context);
+
return -1;
}
camel_stream_write (ostream, ciphertext, strlen (ciphertext));
g_free (ciphertext);
+ PGP_UNLOCK(context);
+
return 0;
exception:
pgp_forget_passphrase (context->priv->session, context->priv->type, userid);
}
+ PGP_UNLOCK(context);
+
return -1;
}
char passwd_fd[32];
int retval, i;
+ PGP_LOCK(context);
+
/* get the ciphertext in a form we can use */
ciphertext = g_byte_array_new ();
stream = camel_stream_mem_new ();
pgp_forget_passphrase (context->priv->session, context->priv->type, NULL);
+ PGP_UNLOCK(context);
+
return -1;
}
camel_stream_write (ostream, plaintext, plainlen);
g_free (plaintext);
+ PGP_UNLOCK(context);
+
return 0;
exception:
g_free (passphrase);
}
+ PGP_UNLOCK(context);
+
return -1;
}