aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@helixcode.com>2001-01-02 07:19:54 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-01-02 07:19:54 +0800
commit161d88eee643a9aa9c5d6aa52cce7d4e4d894c72 (patch)
tree3d142a0cdf04ed1c3cee0806f24669fad8222ba9
parentf561a84cdea45210b991faeddf908d7529d1592b (diff)
downloadgsoc2013-evolution-161d88eee643a9aa9c5d6aa52cce7d4e4d894c72.tar
gsoc2013-evolution-161d88eee643a9aa9c5d6aa52cce7d4e4d894c72.tar.gz
gsoc2013-evolution-161d88eee643a9aa9c5d6aa52cce7d4e4d894c72.tar.bz2
gsoc2013-evolution-161d88eee643a9aa9c5d6aa52cce7d4e4d894c72.tar.lz
gsoc2013-evolution-161d88eee643a9aa9c5d6aa52cce7d4e4d894c72.tar.xz
gsoc2013-evolution-161d88eee643a9aa9c5d6aa52cce7d4e4d894c72.tar.zst
gsoc2013-evolution-161d88eee643a9aa9c5d6aa52cce7d4e4d894c72.zip
Implemented.
2000-12-26 Jeffrey Stedfast <fejj@helixcode.com> * mail-crypto.c (mail_crypto_openpgp_verify): Implemented. 2000-12-23 Jeffrey Stedfast <fejj@helixcode.com> * mail-ops.c (mail_do_setup_trash): New function similar to mail_do_setup_folder() except that this creates the Trash VFolder (special-case). 2000-12-21 Jeffrey Stedfast <fejj@helixcode.com> * mail-ops.c (do_send_mail): Don't free info inside the last if-statement, if sent_folder doesn't exist we'll have a memory leak. Instead free it afterward. svn path=/trunk/; revision=7205
-rw-r--r--mail/ChangeLog17
-rw-r--r--mail/mail-crypto.c89
-rw-r--r--mail/mail-ops.c178
-rw-r--r--mail/mail-ops.h1
4 files changed, 250 insertions, 35 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 0795a42940..926733dbf2 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,19 @@
+2000-12-26 Jeffrey Stedfast <fejj@helixcode.com>
+
+ * mail-crypto.c (mail_crypto_openpgp_verify): Implemented.
+
+2000-12-23 Jeffrey Stedfast <fejj@helixcode.com>
+
+ * mail-ops.c (mail_do_setup_trash): New function similar to
+ mail_do_setup_folder() except that this creates the Trash VFolder
+ (special-case).
+
+2000-12-21 Jeffrey Stedfast <fejj@helixcode.com>
+
+ * mail-ops.c (do_send_mail): Don't free info inside the last
+ if-statement, if sent_folder doesn't exist we'll have a memory
+ leak. Instead free it afterward.
+
2000-12-29 Dan Winship <danw@helixcode.com>
* mail-crypto.c: Oops. Update this for CamelContentType stuff too.
@@ -77,6 +93,7 @@
* component-factory.c (factory_destroy): Wait till all views have
gone and then destroy both factories.
+>>>>>>> 1.805
2000-12-21 Dan Winship <danw@helixcode.com>
* mail-display.c (pixbuf_for_mime_type): Deal with the possibility
diff --git a/mail/mail-crypto.c b/mail/mail-crypto.c
index dd2ee1fe45..95042da6b0 100644
--- a/mail/mail-crypto.c
+++ b/mail/mail-crypto.c
@@ -898,6 +898,25 @@ mail_crypto_openpgp_sign (const char *in, int inlen, const char *userid,
return cyphertext;
}
+static char *
+swrite (const char *data, int len)
+{
+ char *template;
+ int fd;
+
+ template = g_strdup ("/tmp/mail-crypto-XXXXXX");
+ fd = mkstemp (template);
+ if (fd == -1) {
+ g_free (template);
+ return NULL;
+ }
+
+ write (fd, data, len);
+ close (fd);
+
+ return template;
+}
+
gboolean
mail_crypto_openpgp_verify (const char *in, int inlen, const char *sigin, int siglen, CamelException *ex)
{
@@ -907,7 +926,7 @@ mail_crypto_openpgp_verify (const char *in, int inlen, const char *sigin, int si
char *path;
int passwd_fds[2];
char passwd_fd[32];
- char *tmp = "/tmp/mail-crypto-XXXXXX";
+ char *sigfile;
int retval, i, clearlen;
gboolean valid = TRUE;
@@ -925,52 +944,56 @@ mail_crypto_openpgp_verify (const char *in, int inlen, const char *sigin, int si
return FALSE;
}
- i = 0;
-#if defined(GPG_PATH)
- path = GPG_PATH;
-
- argv[i++] = "gpg";
-
- argv[i++] = "--verify";
-
if (sigin != NULL && siglen) {
/* We are going to verify a detached signature so save
- the signature to a temp file and write the data to
- verify to stdin */
- int fd;
-
- fd = mkstemp (tmp);
- if (fd == -1) {
+ the signature to a temp file. */
+ sigfile = swrite (sigin, siglen);
+ if (!sigfile) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Couldn't create temp file: %s"),
g_strerror (errno));
return FALSE;
}
-
- write (fd, sigin, siglen);
- close (fd);
-
- argv[i++] = tmp;
- argv[i++] = "-";
- } else {
- /* We are going to verify using stdin */
- argv[i++] = "-";
}
- argv[i++] = "--verbose";
- argv[i++] = "--yes";
- argv[i++] = "--batch";
+ i = 0;
+#if defined(GPG_PATH)
+ path = GPG_PATH;
- argv[i++] = "--output";
- argv[i++] = "-"; /* output to stdout */
+ argv[i++] = "gpg";
+
+ argv[i++] = "--verify";
+
+ if (sigin != NULL && siglen)
+ argv[i++] = sigfile;
+
+ /* We are going to verify using stdin */
+ argv[i++] = "-";
+
+ /*argv[i++] = "--verbose";
+ argv[i++] = "--yes";
+ argv[i++] = "--batch";*/
#elif defined (PGP5_PATH)
path = PGP5_PATH;
argv[i++] = "pgpv";
+
+ argv[i++] = "-z";
+
+ if (sigin != NULL && siglen)
+ argv[i++] = sigfile;
+
+ argv[i++] = "-f";
+
#else
path = PGP_PATH;
argv[i++] = "pgp";
+
+ if (sigin != NULL && siglen)
+ argv[i++] = sigfile;
+
+ argv[i++] = "-f";
#endif
argv[i++] = NULL;
@@ -982,8 +1005,14 @@ mail_crypto_openpgp_verify (const char *in, int inlen, const char *sigin, int si
&cleartext, &clearlen,
&diagnostics);
+ /* cleanup */
+ if (sigfile) {
+ unlink (sigfile);
+ g_free (sigfile);
+ }
+
/* FIXME: maybe we should always set an exception? */
- if (retval != 0 || clearlen == 0) {
+ if (retval != 0) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
"%s", diagnostics);
valid = FALSE;
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index bea8e335f2..aa574b53b4 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -640,12 +640,11 @@ do_send_mail (gpointer in_data, gpointer op_data, CamelException *ex)
/* now to save the message in Sent */
if (sent_folder) {
mail_tool_camel_lock_up ();
-
camel_folder_append_message (sent_folder, input->message, info, ex);
- g_free (info);
-
mail_tool_camel_lock_down ();
}
+
+ g_free (info);
}
static void
@@ -1939,6 +1938,7 @@ mail_do_create_folder (const GNOME_Evolution_ShellComponentListener listener,
mail_operation_queue (&op_create_folder, input, FALSE);
}
+
/* ** SYNC FOLDER ********************************************************* */
static gchar *
@@ -1954,8 +1954,7 @@ describe_sync_folder (gpointer in_data, gboolean gerund)
}
static void
-setup_sync_folder (gpointer in_data, gpointer op_data, CamelException *ex)
-{
+setup_sync_folder (gpointer in_data, gpointer op_data, CamelException *ex) {
camel_object_ref (CAMEL_OBJECT (in_data));
}
@@ -2368,6 +2367,175 @@ mail_do_setup_folder (const char *name, CamelFolder **folder)
mail_operation_queue (&op_setup_folder, input, TRUE);
}
+/* ** SETUP TRASH VFOLDER ************************************************* */
+
+typedef struct setup_trash_input_s {
+ gchar *name;
+ gchar *store_uri;
+ CamelFolder **folder;
+} setup_trash_input_t;
+
+static gchar *
+describe_setup_trash (gpointer in_data, gboolean gerund)
+{
+ setup_trash_input_t *input = (setup_trash_input_t *) in_data;
+
+ if (gerund)
+ return g_strdup_printf (_("Loading %s Folder for %s"), input->name, input->store_uri);
+ else
+ return g_strdup_printf (_("Load %s Folder for %s"), input->name, input->store_uri);
+}
+
+/* maps the shell's uri to the real vfolder uri and open the folder */
+static CamelFolder *
+create_trash_vfolder (const char *name, GPtrArray *urls, CamelException *ex)
+{
+ void camel_vee_folder_add_folder (CamelFolder *, CamelFolder *);
+
+ char *storeuri, *foldername;
+ CamelFolder *folder = NULL, *sourcefolder;
+ const char *sourceuri;
+ int source = 0;
+
+ d(fprintf (stderr, "Creating Trash vfolder\n"));
+
+ storeuri = g_strdup_printf ("vfolder:%s/vfolder/%s", evolution_dir, name);
+ foldername = g_strdup ("mbox?(match-all (system-flag Deleted))");
+
+ /* we dont have indexing on vfolders */
+ folder = mail_tool_get_folder_from_urlname (storeuri, foldername, CAMEL_STORE_FOLDER_CREATE, ex);
+
+ sourceuri = NULL;
+ while (source < urls->len) {
+ sourceuri = urls->pdata[source];
+ fprintf (stderr, "adding vfolder source: %s\n", sourceuri);
+
+ sourcefolder = mail_tool_uri_to_folder (sourceuri, ex);
+ d(fprintf (stderr, "source folder = %p\n", sourcefolder));
+
+ if (sourcefolder) {
+ mail_tool_camel_lock_up ();
+ camel_vee_folder_add_folder (folder, sourcefolder);
+ mail_tool_camel_lock_down ();
+ } else {
+ /* we'll just silently ignore now-missing sources */
+ camel_exception_clear (ex);
+ }
+
+ g_free (urls->pdata[source]);
+ source++;
+ }
+
+ g_ptr_array_free (urls, TRUE);
+
+ g_free (foldername);
+ g_free (storeuri);
+
+ return folder;
+}
+
+static void
+populate_folder_urls (CamelFolderInfo *info, GPtrArray *urls)
+{
+ if (!info)
+ return;
+
+ g_ptr_array_add (urls, info->url);
+
+ if (info->child)
+ populate_folder_urls (info->child, urls);
+
+ if (info->sibling)
+ populate_folder_urls (info->sibling, urls);
+}
+
+static void
+local_folder_urls (gpointer key, gpointer value, gpointer user_data)
+{
+ GPtrArray *urls = user_data;
+ CamelFolder *folder = value;
+
+ g_ptr_array_add (urls, g_strdup_printf ("file://%s/local/%s",
+ evolution_dir,
+ folder->full_name));
+}
+
+static void
+do_setup_trash (gpointer in_data, gpointer op_data, CamelException *ex)
+{
+ setup_trash_input_t *input = (setup_trash_input_t *) in_data;
+ EvolutionStorage *storage;
+ CamelFolderInfo *info;
+ CamelStore *store;
+ GPtrArray *urls;
+
+ urls = g_ptr_array_new ();
+
+ /* we don't want to connect */
+ store = (CamelStore *) camel_session_get_service (session, input->store_uri,
+ CAMEL_PROVIDER_STORE, ex);
+ if (store == NULL) {
+ g_warning ("Couldn't get service %s: %s\n", input->store_uri,
+ camel_exception_get_description (ex));
+ camel_exception_clear (ex);
+ } else {
+ char *path, *uri;
+
+ if (!strcmp (input->store_uri, "file:/")) {
+ /* Yeah - this is a hack but then again so are local folders */
+ g_hash_table_foreach (store->folders, local_folder_urls, urls);
+ } else {
+ info = camel_store_get_folder_info (store, "/", TRUE, TRUE, TRUE, ex);
+ populate_folder_urls (info, urls);
+ camel_store_free_folder_info (store, info);
+ }
+
+ *(input->folder) = create_trash_vfolder (input->name, urls, ex);
+
+ uri = g_strdup_printf ("vfolder:%s", input->name);
+ path = g_strdup_printf ("/%s", input->name);
+ storage = mail_lookup_storage (store);
+ evolution_storage_new_folder (storage, path, g_basename (path),
+ "mail", uri, input->name, FALSE);
+ gtk_object_unref (GTK_OBJECT (storage));
+ g_free (path);
+ g_free (uri);
+ }
+}
+
+static void
+cleanup_setup_trash (gpointer in_data, gpointer op_data, CamelException *ex)
+{
+ setup_trash_input_t *input = (setup_trash_input_t *) in_data;
+
+ g_free (input->name);
+ g_free (input->store_uri);
+}
+
+static const mail_operation_spec op_setup_trash = {
+ describe_setup_trash,
+ 0,
+ NULL,
+ do_setup_trash,
+ cleanup_setup_trash
+};
+
+void
+mail_do_setup_trash (const char *name, const char *store_uri, CamelFolder **folder)
+{
+ setup_trash_input_t *input;
+
+ g_return_if_fail (name != NULL);
+ g_return_if_fail (folder != NULL);
+
+ input = g_new (setup_trash_input_t, 1);
+ input->name = g_strdup (name);
+ input->store_uri = g_strdup (store_uri);
+ input->folder = folder;
+ mail_operation_queue (&op_setup_trash, input, TRUE);
+}
+
+
/* ** VIEW MESSAGES ******************************************************* */
typedef struct view_messages_input_s {
diff --git a/mail/mail-ops.h b/mail/mail-ops.h
index 1144810592..17ed16c9c5 100644
--- a/mail/mail-ops.h
+++ b/mail/mail-ops.h
@@ -69,6 +69,7 @@ void mail_do_display_message (MessageList *ml, MailDisplay *md, const char *uid,
void mail_do_edit_messages (CamelFolder *folder, GPtrArray *uids,
GtkSignalFunc signal);
void mail_do_setup_folder (const char *name, CamelFolder **folder);
+void mail_do_setup_trash (const char *name, const char *store_uri, CamelFolder **folder);
void mail_do_view_messages (CamelFolder *folder, GPtrArray *uids,
FolderBrowser *fb);
void mail_do_save_messages (CamelFolder *folder, GPtrArray *uids, gchar *path);