diff options
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 23 | ||||
-rw-r--r-- | mail/em-folder-selector.c | 11 | ||||
-rw-r--r-- | mail/em-folder-tree-model.c | 77 | ||||
-rw-r--r-- | mail/em-folder-tree-model.h | 4 | ||||
-rw-r--r-- | mail/em-folder-tree.c | 141 | ||||
-rw-r--r-- | mail/importers/evolution-mbox-importer.c | 5 | ||||
-rw-r--r-- | mail/importers/evolution-outlook-importer.c | 31 | ||||
-rw-r--r-- | mail/mail-component.c | 18 | ||||
-rw-r--r-- | mail/mail-folder-cache.c | 28 |
9 files changed, 170 insertions, 168 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index e03c70bb72..96c941fb12 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,12 @@ +2004-05-26 Not Zed <NotZed@Ximian.com> + + * importers/evolution-mbox-importer.c (create_control_fn): set the + default selection to inbox. + + * importers/evolution-outlook-importer.c (folder_selected) + (create_control_fn): copied from mbox importer. fixes a crash & + lets you choose the target folder. + 2004-05-25 Jeffrey Stedfast <fejj@novell.com> * mail-errors.xml: a few fixes. @@ -9,6 +18,20 @@ 2004-05-25 Not Zed <NotZed@Ximian.com> + * mail-component.c (mc_add_local_store_done): removed, now + redundant. + + * em-folder-tree.c (em_folder_tree_set_selected): fix for path changes. + + * em-folder-tree-model.c (em_folder_tree_model_set_unread_count): + change to use full name rather than path name. + + * em-folder-tree-model.h: renamed path_hash to full_hash. + + * em-folder-tree-model.c (folder_subscribed): dont use + g_path_get_dirname here, it is os dependent, we want / always. + (full_hash_free): rename from path_hash free. + * em-folder-view.c (emfv_popup_menu[]): disable add sender to addressbook bar if it is also disabled. #58955. diff --git a/mail/em-folder-selector.c b/mail/em-folder-selector.c index d317635ee1..4d2c771f86 100644 --- a/mail/em-folder-selector.c +++ b/mail/em-folder-selector.c @@ -357,8 +357,15 @@ em_folder_selector_get_selected_uri (EMFolderSelector *emfs) camel_url_set_fragment (url, newpath); } else { - newpath = g_strdup_printf("%s/%s", (url->path == NULL || strcmp(url->path, "/") == 0) ? "":url->path, name); + char *path; + + path = g_strdup_printf("%s/%s", (url->path == NULL || strcmp(url->path, "/") == 0) ? "":url->path, name); camel_url_set_path(url, newpath); + if (path[0] == '/') { + newpath = g_strdup(path+1); + g_free(path); + } else + newpath = path; } g_free (emfs->selected_path); @@ -406,7 +413,7 @@ em_folder_selector_get_selected_path (EMFolderSelector *emfs) char *newpath; name = gtk_entry_get_text (emfs->name_entry); - if (strcmp (path, "/") != 0) + if (strcmp (path, "") != 0) newpath = g_strdup_printf ("%s/%s", path, name); else newpath = g_strdup_printf ("/%s", name); diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c index 571ac3042b..fe0f902234 100644 --- a/mail/em-folder-tree-model.c +++ b/mail/em-folder-tree-model.c @@ -238,7 +238,7 @@ em_folder_tree_model_init (EMFolderTreeModel *model) } static void -path_hash_free (gpointer key, gpointer value, gpointer user_data) +full_hash_free (gpointer key, gpointer value, gpointer user_data) { g_free (key); gtk_tree_row_reference_free (value); @@ -256,7 +256,7 @@ store_info_free (struct _EMFolderTreeModelStoreInfo *si) g_free (si->display_name); camel_object_unref (si->store); gtk_tree_row_reference_free (si->row); - g_hash_table_foreach (si->path_hash, path_hash_free, NULL); + g_hash_table_foreach (si->full_hash, full_hash_free, NULL); g_free (si); } @@ -430,7 +430,7 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model, GtkTreeIter *ite gtk_tree_path_free (path); g_hash_table_insert (model->uri_hash, g_strdup (fi->uri), uri_row); - g_hash_table_insert (si->path_hash, g_strdup (fi->path), path_row); + g_hash_table_insert (si->full_hash, g_strdup (fi->full_name), path_row); /* HACK: if we have the folder, and its the outbox folder, we need the total count, not unread */ /* This is duplicated in mail-folder-cache too, should perhaps be functionised */ @@ -454,7 +454,7 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model, GtkTreeIter *ite gtk_tree_store_set ((GtkTreeStore *) model, iter, COL_STRING_DISPLAY_NAME, fi->name, COL_POINTER_CAMEL_STORE, si->store, - COL_STRING_FOLDER_PATH, fi->path, + COL_STRING_FULL_NAME, fi->full_name, COL_STRING_URI, fi->uri, COL_UINT_UNREAD, unread, COL_UINT_FLAGS, fi->flags, @@ -468,7 +468,7 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model, GtkTreeIter *ite gtk_tree_store_set ((GtkTreeStore *) model, &sub, COL_STRING_DISPLAY_NAME, _("Loading..."), COL_POINTER_CAMEL_STORE, NULL, - COL_STRING_FOLDER_PATH, NULL, + COL_STRING_FULL_NAME, NULL, COL_BOOL_LOAD_SUBDIRS, FALSE, COL_BOOL_IS_STORE, FALSE, COL_STRING_URI, NULL, @@ -515,26 +515,25 @@ folder_subscribed (CamelStore *store, CamelFolderInfo *fi, EMFolderTreeModel *mo GtkTreeIter parent, iter; GtkTreePath *path; gboolean load; - char *dirname; - + char *dirname, *p; + if (!(si = g_hash_table_lookup (model->store_hash, store))) goto done; /* make sure we don't already know about it? */ - if (g_hash_table_lookup (si->path_hash, fi->path)) + if (g_hash_table_lookup (si->full_hash, fi->full_name)) goto done; /* get our parent folder's path */ - if (!(dirname = g_path_get_dirname (fi->path))) - goto done; - - if (!strcmp (dirname, "/")) { + dirname = alloca(strlen(fi->full_name)+1); + strcpy(dirname, fi->full_name); + p = strrchr(dirname, '/'); + if (p == NULL) { /* user subscribed to a toplevel folder */ row = si->row; - g_free (dirname); } else { - row = g_hash_table_lookup (si->path_hash, dirname); - g_free (dirname); + *p = 0; + row = g_hash_table_lookup (si->full_hash, dirname); /* if row is NULL, don't bother adding to the tree, * when the user expands enough nodes - it will be @@ -560,8 +559,8 @@ folder_subscribed (CamelStore *store, CamelFolderInfo *fi, EMFolderTreeModel *mo gtk_tree_store_append ((GtkTreeStore *) model, &iter, &parent); em_folder_tree_model_set_folder_info (model, &iter, si, fi, TRUE); - - g_signal_emit (model, signals[FOLDER_ADDED], 0, fi->path, fi->uri); + + g_signal_emit (model, signals[FOLDER_ADDED], 0, fi->full_name, fi->uri); done: @@ -590,7 +589,7 @@ folder_unsubscribed (CamelStore *store, CamelFolderInfo *fi, EMFolderTreeModel * if (!(si = g_hash_table_lookup (model->store_hash, store))) goto done; - if (!(row = g_hash_table_lookup (si->path_hash, fi->path))) + if (!(row = g_hash_table_lookup (si->full_hash, fi->full_name))) goto done; path = gtk_tree_row_reference_get_path (row); @@ -621,7 +620,7 @@ static void folder_created_cb (CamelStore *store, void *event_data, EMFolderTreeModel *model) { CamelFolderInfo *fi; - + /* we only want created events to do more work if we don't support subscriptions */ if (camel_store_supports_subscriptions (store)) return; @@ -657,12 +656,8 @@ folder_renamed (CamelStore *store, CamelRenameInfo *info, EMFolderTreeModel *mod if (!(si = g_hash_table_lookup (model->store_hash, store))) goto done; - parent = g_strdup_printf ("/%s", info->old_base); - if (!(row = g_hash_table_lookup (si->path_hash, parent))) { - g_free (parent); + if (!(row = g_hash_table_lookup (si->full_hash, info->old_base))) goto done; - } - g_free (parent); path = gtk_tree_row_reference_get_path (row); if (!(gtk_tree_model_get_iter ((GtkTreeModel *) model, &iter, path))) { @@ -672,15 +667,15 @@ folder_renamed (CamelStore *store, CamelRenameInfo *info, EMFolderTreeModel *mod em_folder_tree_model_remove_folders (model, si, &iter); - parent = g_strdup (info->new->path); + parent = g_strdup(info->new->full_name); p = strrchr(parent, '/'); - g_assert(p); - *p = 0; - if (parent == p) { + if (p) + *p = 0; + if (p == NULL || parent == p) { /* renamed to a toplevel folder on the store */ path = gtk_tree_row_reference_get_path (si->row); } else { - if (!(row = g_hash_table_lookup (si->path_hash, parent))) { + if (!(row = g_hash_table_lookup (si->full_hash, parent))) { /* NOTE: this should never happen, but I * suppose if it does in reality, we can add * code here to add the missing nodes to the @@ -753,7 +748,7 @@ em_folder_tree_model_add_store (EMFolderTreeModel *model, CamelStore *store, con gtk_tree_store_set ((GtkTreeStore *) model, &iter, COL_STRING_DISPLAY_NAME, display_name, COL_POINTER_CAMEL_STORE, store, - COL_STRING_FOLDER_PATH, "/", + COL_STRING_FULL_NAME, "", COL_BOOL_LOAD_SUBDIRS, TRUE, COL_BOOL_IS_STORE, TRUE, COL_STRING_URI, uri, -1); @@ -767,7 +762,7 @@ em_folder_tree_model_add_store (EMFolderTreeModel *model, CamelStore *store, con si->store = store; si->account = account; si->row = row; - si->path_hash = g_hash_table_new (g_str_hash, g_str_equal); + si->full_hash = g_hash_table_new (g_str_hash, g_str_equal); g_hash_table_insert (model->store_hash, store, si); g_hash_table_insert (model->account_hash, account, si); @@ -777,7 +772,7 @@ em_folder_tree_model_add_store (EMFolderTreeModel *model, CamelStore *store, con gtk_tree_store_set ((GtkTreeStore *) model, &iter, COL_STRING_DISPLAY_NAME, _("Loading..."), COL_POINTER_CAMEL_STORE, NULL, - COL_STRING_FOLDER_PATH, NULL, + COL_STRING_FULL_NAME, NULL, COL_BOOL_LOAD_SUBDIRS, FALSE, COL_BOOL_IS_STORE, FALSE, COL_STRING_URI, NULL, @@ -850,11 +845,11 @@ em_folder_tree_model_remove_folders (EMFolderTreeModel *model, struct _EMFolderT } gtk_tree_model_get ((GtkTreeModel *) model, toplevel, COL_STRING_URI, &uri, - COL_STRING_FOLDER_PATH, &folder_path, + COL_STRING_FULL_NAME, &folder_path, COL_BOOL_IS_STORE, &is_store, -1); - if (folder_path && (row = g_hash_table_lookup (si->path_hash, folder_path))) { - g_hash_table_remove (si->path_hash, folder_path); + if (folder_path && (row = g_hash_table_lookup (si->full_hash, folder_path))) { + g_hash_table_remove (si->full_hash, folder_path); gtk_tree_row_reference_free (row); } @@ -929,7 +924,7 @@ em_folder_tree_model_get_expanded (EMFolderTreeModel *model, const char *key) if (p[-1] == '/') p[-1] = '\0'; p = NULL; - + do { if ((p = strchr (name, '/'))) *p = '\0'; @@ -947,7 +942,7 @@ em_folder_tree_model_get_expanded (EMFolderTreeModel *model, const char *key) name = p ? p + 1 : NULL; } while (name && node); - + return FALSE; } @@ -1061,7 +1056,7 @@ em_folder_tree_model_expand_foreach (EMFolderTreeModel *model, EMFTModelExpandFu } void -em_folder_tree_model_set_unread_count (EMFolderTreeModel *model, CamelStore *store, const char *path, int unread) +em_folder_tree_model_set_unread_count (EMFolderTreeModel *model, CamelStore *store, const char *full, int unread) { struct _EMFolderTreeModelStoreInfo *si; GtkTreeRowReference *row; @@ -1070,9 +1065,9 @@ em_folder_tree_model_set_unread_count (EMFolderTreeModel *model, CamelStore *sto g_return_if_fail (EM_IS_FOLDER_TREE_MODEL (model)); g_return_if_fail (CAMEL_IS_STORE (store)); - g_return_if_fail (path != NULL); + g_return_if_fail (full != NULL); - u(printf("set unread count %p '%s' %d\n", store, path, unread)); + u(printf("set unread count %p '%s' %d\n", store, full, unread)); if (unread < 0) unread = 0; @@ -1082,7 +1077,7 @@ em_folder_tree_model_set_unread_count (EMFolderTreeModel *model, CamelStore *sto return; } - if (!(row = g_hash_table_lookup (si->path_hash, path))) { + if (!(row = g_hash_table_lookup (si->full_hash, full))) { u(printf(" can't find row\n")); return; } diff --git a/mail/em-folder-tree-model.h b/mail/em-folder-tree-model.h index c6beb52ee1..83d2490c36 100644 --- a/mail/em-folder-tree-model.h +++ b/mail/em-folder-tree-model.h @@ -52,7 +52,7 @@ typedef struct _EMFolderTreeModelStoreInfo EMFolderTreeModelStoreInfo; enum { COL_STRING_DISPLAY_NAME, /* string that appears in the tree */ COL_POINTER_CAMEL_STORE, /* CamelStore object */ - COL_STRING_FOLDER_PATH, /* if node is a folder, the full path of the folder */ + COL_STRING_FULL_NAME, /* if node is a folder, the full path name of the folder, no leading / */ COL_STRING_URI, /* the uri to get the store or folder object */ COL_UINT_UNREAD, /* unread count */ COL_UINT_FLAGS, /* FolderInfo.flags */ @@ -68,7 +68,7 @@ enum { struct _EMFolderTreeModelStoreInfo { CamelStore *store; GtkTreeRowReference *row; - GHashTable *path_hash; /* maps CamelFolderInfo::path's to GtkTreeRowReferences */ + GHashTable *full_hash; /* maps CamelFolderInfo::full_name's to GtkTreeRowReferences */ EAccount *account; char *display_name; diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c index a424250707..b2b78418b2 100644 --- a/mail/em-folder-tree.c +++ b/mail/em-folder-tree.c @@ -272,17 +272,17 @@ render_pixbuf (GtkTreeViewColumn *column, GtkCellRenderer *renderer, initialised = TRUE; } - gtk_tree_model_get (model, iter, COL_STRING_FOLDER_PATH, &path, + gtk_tree_model_get (model, iter, COL_STRING_FULL_NAME, &path, COL_BOOL_IS_STORE, &is_store, -1); if (!is_store && path != NULL) { - if (!strcasecmp (path, "/Inbox")) + if (!g_ascii_strcasecmp (path, "Inbox")) pixbuf = folder_icons[FOLDER_ICON_INBOX]; - else if (!strcasecmp (path, "/Outbox")) + else if (!g_ascii_strcasecmp (path, "Outbox")) pixbuf = folder_icons[FOLDER_ICON_OUTBOX]; - else if (*path == '/' && !strcasecmp (path + 1, CAMEL_VTRASH_NAME)) + else if (!strcmp (path, CAMEL_VTRASH_NAME)) pixbuf = folder_icons[FOLDER_ICON_TRASH]; - else if (*path == '/' && !strcasecmp (path + 1, CAMEL_VJUNK_NAME)) + else if (!strcmp(path, CAMEL_VJUNK_NAME)) pixbuf = folder_icons[FOLDER_ICON_JUNK]; else pixbuf = folder_icons[FOLDER_ICON_NORMAL]; @@ -546,7 +546,7 @@ emft_expand_node (EMFolderTreeModel *model, const char *key, EMFolderTree *emft) camel_object_unref (store); if (p != NULL) { - if (!(row = g_hash_table_lookup (si->path_hash, p))) + if (!(row = g_hash_table_lookup (si->full_hash, p))) return; } else row = si->row; @@ -565,19 +565,19 @@ emft_maybe_expand_row (EMFolderTreeModel *model, GtkTreePath *tree_path, GtkTree char *path, *key; gtk_tree_model_get ((GtkTreeModel *) model, iter, - COL_STRING_FOLDER_PATH, &path, + COL_STRING_FULL_NAME, &path, COL_POINTER_CAMEL_STORE, &store, -1); si = g_hash_table_lookup (model->store_hash, store); if ((account = mail_config_get_account_by_name (si->display_name))) { - key = g_strdup_printf ("%s%s", account->uid, path); + key = g_strdup_printf ("%s/%s", account->uid, path); } else if (CAMEL_IS_VEE_STORE (store)) { /* vfolder store */ - key = g_strdup_printf ("vfolder%s", path); + key = g_strdup_printf ("vfolder/%s", path); } else { /* local store */ - key = g_strdup_printf ("local%s", path); + key = g_strdup_printf ("local/%s", path); } if (em_folder_tree_model_get_expanded (model, key)) { @@ -630,12 +630,11 @@ tree_drag_data_delete(GtkWidget *widget, GdkDragContext *context, EMFolderTree * { struct _EMFolderTreePrivate *priv = emft->priv; GtkTreePath *src_path; - const char *full_name; gboolean is_store; CamelStore *store; CamelException ex; GtkTreeIter iter; - char *path; + char *full_name; if (!priv->drag_row || (src_path = gtk_tree_row_reference_get_path (priv->drag_row))) return; @@ -645,14 +644,12 @@ tree_drag_data_delete(GtkWidget *widget, GdkDragContext *context, EMFolderTree * gtk_tree_model_get((GtkTreeModel *)priv->model, &iter, COL_POINTER_CAMEL_STORE, &store, - COL_STRING_FOLDER_PATH, &path, + COL_STRING_FULL_NAME, &full_name, COL_BOOL_IS_STORE, &is_store, -1); if (is_store) goto fail; - full_name = path[0] == '/' ? path + 1 : path; - camel_exception_init(&ex); camel_store_delete_folder(store, full_name, &ex); if (camel_exception_is_set(&ex)) @@ -666,12 +663,11 @@ tree_drag_data_get(GtkWidget *widget, GdkDragContext *context, GtkSelectionData { struct _EMFolderTreePrivate *priv = emft->priv; GtkTreePath *src_path; - const char *full_name; CamelFolder *folder; CamelStore *store; CamelException ex; GtkTreeIter iter; - char *path, *uri; + char *full_name, *uri; if (!priv->drag_row || !(src_path = gtk_tree_row_reference_get_path(priv->drag_row))) return; @@ -681,15 +677,13 @@ tree_drag_data_get(GtkWidget *widget, GdkDragContext *context, GtkSelectionData gtk_tree_model_get((GtkTreeModel *)priv->model, &iter, COL_POINTER_CAMEL_STORE, &store, - COL_STRING_FOLDER_PATH, &path, + COL_STRING_FULL_NAME, &full_name, COL_STRING_URI, &uri, -1); /* make sure user isn't trying to drag on a placeholder row */ - if (path == NULL) + if (full_name == NULL) goto fail; - full_name = path[0] == '/' ? path + 1 : path; - camel_exception_init(&ex); switch (info) { @@ -968,14 +962,11 @@ tree_drag_data_received(GtkWidget *widget, GdkDragContext *context, int x, int y GtkTreeViewDropPosition pos; GtkTreePath *dest_path; struct _DragDataReceivedAsync *m; - const char *full_name; CamelStore *store; GtkTreeIter iter; - char *path; + char *full_name; int i; - printf("drag data received, action %d\n", context->action); - if (!gtk_tree_view_get_dest_row_at_pos (priv->treeview, x, y, &dest_path, &pos)) return; @@ -992,16 +983,14 @@ tree_drag_data_received(GtkWidget *widget, GdkDragContext *context, int x, int y gtk_tree_model_get((GtkTreeModel *)priv->model, &iter, COL_POINTER_CAMEL_STORE, &store, - COL_STRING_FOLDER_PATH, &path, -1); + COL_STRING_FULL_NAME, &full_name, -1); /* make sure user isn't try to drop on a placeholder row */ - if (path == NULL) { + if (full_name == NULL) { gtk_drag_finish (context, FALSE, FALSE, GDK_CURRENT_TIME); return; } - full_name = path[0] == '/' ? path + 1 : path; - m = mail_msg_new (&emft_drop_async_op, NULL, sizeof (struct _DragDataReceivedAsync)); m->context = context; g_object_ref(context); @@ -1067,7 +1056,7 @@ emft_drop_target(EMFolderTree *emft, GdkDragContext *context, GtkTreePath *path) return GDK_NONE; gtk_tree_model_get((GtkTreeModel *)p->model, &iter, COL_BOOL_IS_STORE, &is_store, - COL_STRING_FOLDER_PATH, &folder_path, + COL_STRING_FULL_NAME, &folder_path, COL_POINTER_CAMEL_STORE, &dstore, COL_STRING_URI, &uri, -1); @@ -1077,8 +1066,6 @@ emft_drop_target(EMFolderTree *emft, GdkDragContext *context, GtkTreePath *path) /* Check for special destinations */ if (uri && folder_path) { - folder_path = folder_path[0] == '/' ? folder_path + 1 : folder_path; - #if 0 /* only allow copying/moving folders (not messages) into the local Outbox */ if (dstore == local && !strcmp (folder_path, "Outbox")) { @@ -1503,7 +1490,7 @@ get_selected_uris_path_iterate (GtkTreeModel *model, GtkTreePath *treepath, GtkT GList **list = (GList **) data; char *path; - gtk_tree_model_get (model, iter, COL_STRING_FOLDER_PATH, &path, -1); + gtk_tree_model_get (model, iter, COL_STRING_FULL_NAME, &path, -1); *list = g_list_append (*list, g_strdup (path)); } @@ -1692,19 +1679,19 @@ emft_update_model_expanded_state (struct _EMFolderTreePrivate *priv, GtkTreeIter char *path, *key; gtk_tree_model_get ((GtkTreeModel *) priv->model, iter, - COL_STRING_FOLDER_PATH, &path, + COL_STRING_FULL_NAME, &path, COL_POINTER_CAMEL_STORE, &store, -1); si = g_hash_table_lookup (priv->model->store_hash, store); if ((account = mail_config_get_account_by_name (si->display_name))) { - key = g_strdup_printf ("%s%s", account->uid, path); + key = g_strdup_printf ("%s/%s", account->uid, path); } else if (CAMEL_IS_VEE_STORE (store)) { /* vfolder store */ - key = g_strdup_printf ("vfolder%s", path); + key = g_strdup_printf ("vfolder/%s", path); } else { /* local store */ - key = g_strdup_printf ("local%s", path); + key = g_strdup_printf ("local/%s", path); } em_folder_tree_model_set_expanded (priv->model, key, expanded); @@ -1718,14 +1705,13 @@ emft_tree_row_expanded (GtkTreeView *treeview, GtkTreeIter *root, GtkTreePath *t struct _EMFolderTreeGetFolderInfo *m; GtkTreeModel *model; CamelStore *store; - const char *top; gboolean load; char *path; model = gtk_tree_view_get_model (treeview); gtk_tree_model_get (model, root, - COL_STRING_FOLDER_PATH, &path, + COL_STRING_FULL_NAME, &path, COL_POINTER_CAMEL_STORE, &store, COL_BOOL_LOAD_SUBDIRS, &load, -1); @@ -1737,18 +1723,13 @@ emft_tree_row_expanded (GtkTreeView *treeview, GtkTreeIter *root, GtkTreePath *t return; } - if (!path || !strcmp (path, "/")) - top = NULL; - else - top = path + 1; - m = mail_msg_new (&get_folder_info_op, NULL, sizeof (struct _EMFolderTreeGetFolderInfo)); m->root = gtk_tree_row_reference_new (model, tree_path); camel_object_ref (store); m->store = store; m->emft = emft; g_object_ref(emft); - m->top = g_strdup (top); + m->top = g_strdup (path); m->flags = CAMEL_STORE_FOLDER_INFO_RECURSIVE; m->select_uri = NULL; @@ -1779,7 +1760,7 @@ emft_tree_row_activated (GtkTreeView *treeview, GtkTreePath *tree_path, GtkTreeV if (!gtk_tree_model_get_iter (model, &iter, tree_path)) return; - gtk_tree_model_get (model, &iter, COL_STRING_FOLDER_PATH, &path, + gtk_tree_model_get (model, &iter, COL_STRING_FULL_NAME, &path, COL_STRING_URI, &uri, COL_UINT_FLAGS, &flags, -1); g_free (priv->selected_uri); @@ -2329,16 +2310,14 @@ emft_popup_delete_rec (CamelStore *store, CamelFolderInfo *fi, CamelException *e } static void -emft_popup_delete_folders (CamelStore *store, const char *path, CamelException *ex) +emft_popup_delete_folders (CamelStore *store, const char *full_name, CamelException *ex) { guint32 flags = CAMEL_STORE_FOLDER_INFO_RECURSIVE | CAMEL_STORE_FOLDER_INFO_FAST; - const char *full_name; CamelFolderInfo *fi; if (camel_store_supports_subscriptions (store)) flags |= CAMEL_STORE_FOLDER_INFO_SUBSCRIBED; - full_name = path[0] == '/' ? path + 1 : path; fi = camel_store_get_folder_info (store, full_name, flags, ex); if (camel_exception_is_set (ex)) return; @@ -2392,7 +2371,7 @@ emft_popup_delete_response (GtkWidget *dialog, guint response, EMFolderTree *emf if (!emft_selection_get_selected (selection, &model, &iter)) return; - gtk_tree_model_get (model, &iter, COL_STRING_FOLDER_PATH, &path, + gtk_tree_model_get (model, &iter, COL_STRING_FULL_NAME, &path, COL_POINTER_CAMEL_STORE, &store, -1); camel_exception_init (&ex); @@ -2413,18 +2392,16 @@ emft_popup_delete_folder (GtkWidget *item, EMFolderTree *emft) GtkTreeModel *model; GtkTreeIter iter; GtkWidget *dialog; - const char *full_name; - char *path; + char *full_name; selection = gtk_tree_view_get_selection (priv->treeview); if (!emft_selection_get_selected (selection, &model, &iter)) return; - gtk_tree_model_get (model, &iter, COL_POINTER_CAMEL_STORE, &store, COL_STRING_FOLDER_PATH, &path, -1); + gtk_tree_model_get (model, &iter, COL_POINTER_CAMEL_STORE, &store, COL_STRING_FULL_NAME, &full_name, -1); local = mail_component_peek_local_store (NULL); - full_name = path[0] == '/' ? path + 1 : path; if (store == local && is_special_local_folder (full_name)) { e_error_run(NULL, "mail:no-delete-spethal-folder", full_name, NULL); return; @@ -2440,9 +2417,9 @@ static void emft_popup_rename_folder (GtkWidget *item, EMFolderTree *emft) { struct _EMFolderTreePrivate *priv = emft->priv; - char *prompt, *folder_path, *name, *new_name, *uri; + char *prompt, *full_name, *name, *new_name, *uri; GtkTreeSelection *selection; - const char *full_name, *p; + const char *p; CamelStore *local, *store; gboolean done = FALSE; GtkTreeModel *model; @@ -2455,13 +2432,11 @@ emft_popup_rename_folder (GtkWidget *item, EMFolderTree *emft) if (!emft_selection_get_selected (selection, &model, &iter)) return; - gtk_tree_model_get (model, &iter, COL_STRING_FOLDER_PATH, &folder_path, + gtk_tree_model_get (model, &iter, COL_STRING_FULL_NAME, &full_name, COL_STRING_DISPLAY_NAME, &name, COL_POINTER_CAMEL_STORE, &store, COL_STRING_URI, &uri, -1); - full_name = folder_path[0] == '/' ? folder_path + 1 : folder_path; - /* don't allow user to rename one of the special local folders */ if (store == local && is_special_local_folder (full_name)) { e_error_run((GtkWindow *)gtk_widget_get_toplevel((GtkWidget *)emft), @@ -2571,7 +2546,6 @@ emft_tree_button_press (GtkTreeView *treeview, GdkEventButton *event, EMFolderTr { GtkTreeSelection *selection; CamelStore *local, *store; - const char *folder_name; EMPopupTarget *target; GtkTreePath *tree_path; GtkTreeModel *model; @@ -2580,7 +2554,7 @@ emft_tree_button_press (GtkTreeView *treeview, GdkEventButton *event, EMFolderTr guint32 info_flags = 0; guint32 flags = 0; gboolean isstore; - char *uri, *path; + char *uri, *full_name; GtkMenu *menu; EMPopup *emp; int i; @@ -2608,10 +2582,10 @@ emft_tree_button_press (GtkTreeView *treeview, GdkEventButton *event, EMFolderTr return FALSE; gtk_tree_model_get (model, &iter, COL_POINTER_CAMEL_STORE, &store, - COL_STRING_URI, &uri, COL_STRING_FOLDER_PATH, &path, + COL_STRING_URI, &uri, COL_STRING_FULL_NAME, &full_name, COL_BOOL_IS_STORE, &isstore, -1); - if (path == NULL) + if (full_name == NULL) return FALSE; if (isstore) @@ -2621,14 +2595,12 @@ emft_tree_button_press (GtkTreeView *treeview, GdkEventButton *event, EMFolderTr local = mail_component_peek_local_store (NULL); - folder_name = path[0] == '/' ? path + 1 : path; - /* don't allow deletion of special local folders */ - if (!(store == local && is_special_local_folder (folder_name))) + if (!(store == local && is_special_local_folder (full_name))) flags |= EM_POPUP_FOLDER_DELETE; /* hack for vTrash/vJunk */ - if (!strcmp (folder_name, CAMEL_VTRASH_NAME) || !strcmp (folder_name, CAMEL_VJUNK_NAME)) + if (!strcmp (full_name, CAMEL_VTRASH_NAME) || !strcmp (full_name, CAMEL_VJUNK_NAME)) info_flags |= CAMEL_FOLDER_VIRTUAL | CAMEL_FOLDER_NOINFERIORS; /* handle right-click by opening a context menu */ @@ -2671,7 +2643,7 @@ emft_tree_selection_changed (GtkTreeSelection *selection, EMFolderTree *emft) if (!emft_selection_get_selected (selection, &model, &iter)) return; - gtk_tree_model_get (model, &iter, COL_STRING_FOLDER_PATH, &path, + gtk_tree_model_get (model, &iter, COL_STRING_FULL_NAME, &path, COL_STRING_URI, &uri, COL_UINT_FLAGS, &flags, -1); g_free (priv->selected_uri); @@ -2695,7 +2667,6 @@ em_folder_tree_set_selected (EMFolderTree *emft, const char *uri) GtkTreePath *tree_path; CamelStore *store; CamelException ex; - const char *top; char *path, *p; CamelURL *url; @@ -2720,17 +2691,16 @@ em_folder_tree_set_selected (EMFolderTree *emft, const char *uri) } if (((CamelService *) store)->provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH) - path = g_strdup_printf ("/%s", url->fragment ? url->fragment : ""); + path = url->fragment; else - path = g_strdup (url->path ? url->path : "/"); - - top = path[0] == '/' ? path + 1 : path; + path = url->path && url->path[0]=='/' ? url->path+1:url->path; + path = g_strdup(path?path:""); camel_url_free (url); - if (!strcmp (path, "/")) + if (path[0] == 0) row = si->row; - if (row || (row = g_hash_table_lookup (si->path_hash, path))) { + if (row || (row = g_hash_table_lookup (si->full_hash, path))) { /* the folder-info node has already been loaded */ tree_path = gtk_tree_row_reference_get_path (row); gtk_tree_view_expand_to_path (priv->treeview, tree_path); @@ -2749,37 +2719,34 @@ em_folder_tree_set_selected (EMFolderTree *emft, const char *uri) if (*p == '/') { *p = '\0'; - if ((row = g_hash_table_lookup (si->path_hash, path))) + if ((row = g_hash_table_lookup (si->full_hash, path))) break; } p--; } - if (row == NULL) { - /* none of the folders of the desired store have been loaded yet */ - row = si->row; - top = NULL; - } - /* FIXME: this gets all the subfolders of our first loaded * parent folder - ideally we'd only get what we needed, but * it's probably not worth the effort */ m = mail_msg_new (&get_folder_info_op, NULL, sizeof (struct _EMFolderTreeGetFolderInfo)); - m->root = gtk_tree_row_reference_copy (row); m->store = store; m->emft = emft; g_object_ref(emft); - m->top = top ? g_strdup (top) : NULL; + if (row) { + m->top = path; + m->root = gtk_tree_row_reference_copy(row); + } else { + g_free(path); + m->root = gtk_tree_row_reference_copy(si->row); + } + m->flags = CAMEL_STORE_FOLDER_INFO_FAST | CAMEL_STORE_FOLDER_INFO_RECURSIVE; m->select_uri = g_strdup (uri); - g_free (path); - e_thread_put (mail_thread_new, (EMsg *) m); } - const char * em_folder_tree_get_selected_uri (EMFolderTree *emft) { diff --git a/mail/importers/evolution-mbox-importer.c b/mail/importers/evolution-mbox-importer.c index 9e08bf2087..94b8403e28 100644 --- a/mail/importers/evolution-mbox-importer.c +++ b/mail/importers/evolution-mbox-importer.c @@ -111,13 +111,14 @@ create_control_fn(EvolutionImporter *importer, Bonobo_Control *control, void *da { GtkWidget *hbox, *w; - hbox = gtk_hbox_new(FALSE, FALSE); + hbox = gtk_hbox_new(FALSE, 0); w = gtk_label_new(_("Destination folder:")); gtk_box_pack_start((GtkBox *)hbox, w, FALSE, TRUE, 6); w = em_folder_selection_button_new(_("Select folder"), _("Select folder to import into")); - /* set selection to Inbox? */ + em_folder_selection_button_set_selection((EMFolderSelectionButton *)w, + mail_component_get_folder_uri(NULL, MAIL_COMPONENT_FOLDER_INBOX)); g_signal_connect(w, "selected", G_CALLBACK(folder_selected), data); gtk_box_pack_start((GtkBox *)hbox, w, FALSE, TRUE, 6); diff --git a/mail/importers/evolution-outlook-importer.c b/mail/importers/evolution-outlook-importer.c index a2c6d035e6..83f5c241a2 100644 --- a/mail/importers/evolution-outlook-importer.c +++ b/mail/importers/evolution-outlook-importer.c @@ -113,6 +113,35 @@ process_item_fn(EvolutionImporter *eimporter, CORBA_Object listener, void *data, /* EvolutionImporterFactory methods */ +static void +folder_selected(EMFolderSelectionButton *button, OutlookImporter *importer) +{ + g_free(importer->uri); + importer->uri = g_strdup(em_folder_selection_button_get_selection(button)); +} + +static void +create_control_fn(EvolutionImporter *importer, Bonobo_Control *control, void *data) +{ + GtkWidget *hbox, *w; + + hbox = gtk_hbox_new(FALSE, 0); + + w = gtk_label_new(_("Destination folder:")); + gtk_box_pack_start((GtkBox *)hbox, w, FALSE, TRUE, 6); + + w = em_folder_selection_button_new(_("Select folder"), _("Select folder to import into")); + em_folder_selection_button_set_selection((EMFolderSelectionButton *)w, + mail_component_get_folder_uri(NULL, MAIL_COMPONENT_FOLDER_INBOX)); + g_signal_connect(w, "selected", G_CALLBACK(folder_selected), data); + gtk_box_pack_start((GtkBox *)hbox, w, FALSE, TRUE, 6); + + gtk_widget_show_all(hbox); + + /* Another weird-arsed shell api */ + *control = BONOBO_OBJREF(bonobo_control_new(hbox)); +} + static gboolean support_format_fn(EvolutionImporter *importer, const char *filename, void *data) { @@ -252,7 +281,7 @@ outlook_importer_new(void) oli = g_new0 (OutlookImporter, 1); oli->status_lock = g_mutex_new(); - importer = evolution_importer_new (NULL, support_format_fn, load_file_fn, process_item_fn, NULL, oli); + importer = evolution_importer_new (create_control_fn, support_format_fn, load_file_fn, process_item_fn, NULL, oli); g_object_weak_ref((GObject *)importer, importer_destroy_cb, oli); return BONOBO_OBJECT (importer); diff --git a/mail/mail-component.c b/mail/mail-component.c index 11ecbb9ca4..ebe949d5b5 100644 --- a/mail/mail-component.c +++ b/mail/mail-component.c @@ -182,23 +182,9 @@ mc_add_store(MailComponent *component, CamelStore *store, const char *name, void } static void -mc_add_local_store_done(CamelStore *store, CamelFolderInfo *info, void *data) -{ - /*MailComponent *mc = data;*/ - int i; - -#if 0 - for (i=0;i<sizeof(mc_default_folders)/sizeof(mc_default_folders[0]);i++) { - if (mc_default_folders[i].folder) - mail_note_folder(mc_default_folders[i].folder); - } -#endif -} - -static void mc_add_local_store(CamelStore *store, const char *name, MailComponent *mc) { - mc_add_store(mc, store, name, mc_add_local_store_done); + mc_add_store(mc, store, name, NULL); camel_object_unref(store); g_object_unref(mc); } @@ -331,7 +317,7 @@ mc_startup(MailComponent *mc) static void folder_selected_cb (EMFolderTree *emft, const char *path, const char *uri, guint32 flags, EMFolderView *view) { - if ((flags & CAMEL_FOLDER_NOSELECT) || !path || !strcmp (path, "/")) + if ((flags & CAMEL_FOLDER_NOSELECT) || !path || !strcmp (path, "")) em_folder_view_set_folder (view, NULL, NULL); else em_folder_view_set_folder_uri (view, uri); diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c index 4f2e3b20d2..43071e45f9 100644 --- a/mail/mail-folder-cache.c +++ b/mail/mail-folder-cache.c @@ -66,7 +66,6 @@ static pthread_mutex_t info_lock = PTHREAD_MUTEX_INITIALIZER; struct _folder_info { struct _store_info *store_info; /* 'parent' link */ - char *path; /* shell path */ char *full_name; /* full name of folder/folderinfo */ char *uri; /* uri of folder */ @@ -86,9 +85,9 @@ struct _folder_update { unsigned int unsub:1; /* unsubcribing? */ unsigned int new:1; /* new mail arrived? */ - char *path; + char *full_name; char *uri; - char *oldpath; + char *oldfull; char *olduri; int unread; @@ -134,11 +133,11 @@ static int count_trash = FALSE; static void free_update(struct _folder_update *up) { - g_free(up->path); + g_free(up->full_name); g_free(up->uri); if (up->store) camel_object_unref(up->store); - g_free(up->oldpath); + g_free(up->oldfull); g_free(up->olduri); g_free(up); } @@ -221,7 +220,7 @@ real_flush_updates(void *o, void *event_data, void *data) } /* update unread counts */ - em_folder_tree_model_set_unread_count (model, up->store, up->path, up->unread); + em_folder_tree_model_set_unread_count (model, up->store, up->full_name, up->unread); /* new mail notification */ if (notify_type == -1) { @@ -277,7 +276,7 @@ unset_folder_info(struct _folder_info *mfi, int delete, int unsub) up->delete = delete; up->unsub = unsub; up->store = mfi->store_info->store; - up->path = g_strdup (mfi->path); + up->full_name = g_strdup (mfi->full_name); camel_object_ref(up->store); up->uri = g_strdup(mfi->uri); @@ -289,7 +288,6 @@ unset_folder_info(struct _folder_info *mfi, int delete, int unsub) static void free_folder_info(struct _folder_info *mfi) { - g_free(mfi->path); g_free(mfi->full_name); g_free(mfi->uri); g_free(mfi); @@ -356,7 +354,7 @@ update_1folder(struct _folder_info *mfi, int new, CamelFolderInfo *info) return; up = g_malloc0(sizeof(*up)); - up->path = g_strdup(mfi->path); + up->full_name = g_strdup(mfi->full_name); up->unread = unread; up->new = new ? 1 : 0; up->store = mfi->store_info->store; @@ -377,7 +375,6 @@ setup_folder(CamelFolderInfo *fi, struct _store_info *si) } else { /*d(printf("Adding new folder: %s (%s) %d unread\n", fi->path, fi->url, fi->unread_message_count));*/ mfi = g_malloc0(sizeof(*mfi)); - mfi->path = g_strdup(fi->path); mfi->full_name = g_strdup(fi->full_name); mfi->uri = g_strdup(fi->uri); mfi->store_info = si; @@ -387,7 +384,7 @@ setup_folder(CamelFolderInfo *fi, struct _store_info *si) g_hash_table_insert(si->folders_uri, mfi->uri, mfi); up = g_malloc0(sizeof(*up)); - up->path = g_strdup(mfi->path); + up->full_name = g_strdup(mfi->full_name); up->uri = g_strdup(fi->uri); up->unread = (fi->unread==-1)?0:fi->unread; up->store = si->store; @@ -581,14 +578,12 @@ rename_folders(struct _store_info *si, const char *oldbase, const char *newbase, if (mfi) { d(printf("Found old folder '%s' renaming to '%s'\n", mfi->full_name, fi->full_name)); - up->oldpath = mfi->path; + up->oldfull = mfi->full_name; up->olduri = mfi->uri; /* Its a rename op */ g_hash_table_remove(si->folders, mfi->full_name); g_hash_table_remove(si->folders, mfi->uri); - g_free(mfi->full_name); - mfi->path = g_strdup(fi->path); mfi->full_name = g_strdup(fi->full_name); mfi->uri = g_strdup(fi->uri); mfi->flags = fi->flags; @@ -599,7 +594,6 @@ rename_folders(struct _store_info *si, const char *oldbase, const char *newbase, d(printf("Rename found a new folder? old '%s' new '%s'\n", old, fi->full_name)); /* Its a new op */ mfi = g_malloc0(sizeof(*mfi)); - mfi->path = g_strdup(fi->path); mfi->full_name = g_strdup(fi->full_name); mfi->uri = g_strdup(fi->uri); mfi->store_info = si; @@ -611,7 +605,7 @@ rename_folders(struct _store_info *si, const char *oldbase, const char *newbase, g_free(old); - up->path = g_strdup(mfi->path); + up->full_name = g_strdup(mfi->full_name); up->uri = g_strdup(mfi->uri); up->unread = fi->unread==-1?0:fi->unread; up->store = si->store; @@ -649,7 +643,7 @@ folder_cmp(const void *ap, const void *bp) const CamelFolderInfo *a = ((CamelFolderInfo **)ap)[0]; const CamelFolderInfo *b = ((CamelFolderInfo **)bp)[0]; - return strcmp(a->path, b->path); + return strcmp(a->full_name, b->full_name); } static void |