2006-06-15 [colin] 2.3.0cvs16
[claws.git] / src / privacy.c
index 2df36b9314e7e5480d21288904cf0f8cacaf632e..4d8ed9385ec57b4c428e9785a4fce978d9d75d6f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2003 Hiroyuki Yamamoto & the Sylpheed-Claws team
+ * Copyright (C) 1999-2006 Hiroyuki Yamamoto & the Sylpheed-Claws team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 #include "procmime.h"
 
 static GSList *systems = NULL;
+static gchar *privacy_last_error = NULL;
+
+void privacy_set_error(const gchar *format, ...)
+{
+       va_list args;
+       gchar buf[BUFSIZ];
+
+       va_start(args, format);
+       g_vsnprintf(buf, BUFSIZ, format, args);
+       va_end(args);
+       g_free(privacy_last_error);
+       privacy_last_error = g_strdup(buf);
+}
+
+static gchar tmp_privacy_error[BUFSIZ];
+
+const gchar *privacy_get_error (void)
+{
+       if (privacy_last_error) {
+               strncpy2(tmp_privacy_error, privacy_last_error, BUFSIZ-1);
+               g_free(privacy_last_error);
+               privacy_last_error = NULL;
+               return tmp_privacy_error;
+       } else {
+               return _("Unknown error");
+       }
+}
 
 PrivacySystem *privacy_data_get_system(PrivacyData *data)
 {
@@ -365,7 +392,10 @@ gboolean privacy_encrypt(const gchar *id, MimeInfo *mimeinfo, const gchar *encda
 
        g_return_val_if_fail(id != NULL, FALSE);
        g_return_val_if_fail(mimeinfo != NULL, FALSE);
-       g_return_val_if_fail(encdata != NULL, FALSE);
+       if (encdata == NULL) {
+               privacy_set_error(_("No recipient keys defined."));
+               return FALSE;
+       }
 
        system = privacy_get_system(id);
        if (system == NULL)