| 157 |
157 |
static gint imap_rename_folder (Folder *folder,
|
| 158 |
158 |
FolderItem *item,
|
| 159 |
159 |
const gchar *name);
|
|
160 |
static gint imap_move_folder (Folder *folder,
|
|
161 |
FolderItem *item,
|
|
162 |
FolderItem *new_parent);
|
| 160 |
163 |
static gint imap_remove_folder (Folder *folder,
|
| 161 |
164 |
FolderItem *item);
|
| 162 |
165 |
|
| ... | ... | |
| 391 |
394 |
|
| 392 |
395 |
imap_create_folder,
|
| 393 |
396 |
imap_rename_folder,
|
| 394 |
|
NULL,
|
|
397 |
imap_move_folder,
|
| 395 |
398 |
imap_remove_folder
|
| 396 |
399 |
};
|
| 397 |
400 |
|
| ... | ... | |
| 2045 |
2048 |
return new_item;
|
| 2046 |
2049 |
}
|
| 2047 |
2050 |
|
| 2048 |
|
static gint imap_rename_folder(Folder *folder, FolderItem *item,
|
| 2049 |
|
const gchar *name)
|
|
2051 |
static gint imap_rename_folder_real(Folder *folder, FolderItem *item,
|
|
2052 |
FolderItem *new_parent, const gchar *name)
|
| 2050 |
2053 |
{
|
| 2051 |
|
gchar *dirpath;
|
| 2052 |
2054 |
gchar *newpath;
|
| 2053 |
2055 |
gchar *real_oldpath;
|
| 2054 |
2056 |
gchar *real_newpath;
|
| ... | ... | |
| 2063 |
2065 |
|
| 2064 |
2066 |
g_return_val_if_fail(folder != NULL, -1);
|
| 2065 |
2067 |
g_return_val_if_fail(item != NULL, -1);
|
|
2068 |
g_return_val_if_fail(folder == item->folder, -1);
|
| 2066 |
2069 |
g_return_val_if_fail(item->path != NULL, -1);
|
| 2067 |
|
g_return_val_if_fail(name != NULL, -1);
|
|
2070 |
g_return_val_if_fail(new_parent != NULL || name != NULL, -1);
|
|
2071 |
if (new_parent) {
|
|
2072 |
g_return_val_if_fail(item != new_parent, -1);
|
|
2073 |
g_return_val_if_fail(item->parent != new_parent, -1);
|
|
2074 |
g_return_val_if_fail(item->folder == new_parent->folder, -1);
|
|
2075 |
if (g_node_is_ancestor(item->node, new_parent->node)) {
|
|
2076 |
g_warning("folder to be moved is ancestor of new parent\n");
|
|
2077 |
return -1;
|
|
2078 |
}
|
|
2079 |
}
|
| 2068 |
2080 |
|
| 2069 |
2081 |
session = imap_session_get(folder);
|
| 2070 |
2082 |
if (!session) return -1;
|
| ... | ... | |
| 2081 |
2093 |
}
|
| 2082 |
2094 |
|
| 2083 |
2095 |
separator = imap_get_path_separator(IMAP_FOLDER(folder), item->path);
|
| 2084 |
|
if (strchr(item->path, G_DIR_SEPARATOR)) {
|
| 2085 |
|
dirpath = g_dirname(item->path);
|
| 2086 |
|
newpath = g_strconcat(dirpath, G_DIR_SEPARATOR_S, name, NULL);
|
| 2087 |
|
g_free(dirpath);
|
| 2088 |
|
} else
|
| 2089 |
|
newpath = g_strdup(name);
|
|
2096 |
if (new_parent) {
|
|
2097 |
if (name) {
|
|
2098 |
newpath = g_strconcat(new_parent->path,
|
|
2099 |
G_DIR_SEPARATOR_S, name, NULL);
|
|
2100 |
} else {
|
|
2101 |
gchar *name_;
|
| 2090 |
2102 |
|
|
2103 |
name_ = g_path_get_basename(item->path);
|
|
2104 |
newpath = g_strconcat(new_parent->path,
|
|
2105 |
G_DIR_SEPARATOR_S, name_, NULL);
|
|
2106 |
AUTORELEASE_STR(name_, );
|
|
2107 |
name = name_;
|
|
2108 |
}
|
|
2109 |
} else {
|
|
2110 |
if (strchr(item->path, G_DIR_SEPARATOR)) {
|
|
2111 |
gchar *dirpath;
|
|
2112 |
|
|
2113 |
dirpath = g_dirname(item->path);
|
|
2114 |
newpath = g_strconcat(dirpath, G_DIR_SEPARATOR_S, name,
|
|
2115 |
NULL);
|
|
2116 |
g_free(dirpath);
|
|
2117 |
} else
|
|
2118 |
newpath = g_strdup(name);
|
|
2119 |
}
|
|
2120 |
g_print("oldpath = %s, newpath = %s\n", item->path, newpath);
|
|
2121 |
|
| 2091 |
2122 |
real_newpath = imap_utf8_to_modified_utf7(newpath);
|
| 2092 |
2123 |
imap_path_separator_subst(real_newpath, separator);
|
| 2093 |
2124 |
|
| ... | ... | |
| 2101 |
2132 |
return -1;
|
| 2102 |
2133 |
}
|
| 2103 |
2134 |
|
|
2135 |
if (new_parent) {
|
|
2136 |
g_node_unlink(item->node);
|
|
2137 |
g_node_append(new_parent->node, item->node);
|
|
2138 |
item->parent = new_parent;
|
|
2139 |
}
|
|
2140 |
|
| 2104 |
2141 |
g_free(item->name);
|
| 2105 |
2142 |
item->name = g_strdup(name);
|
| 2106 |
2143 |
|
| ... | ... | |
| 2128 |
2165 |
return 0;
|
| 2129 |
2166 |
}
|
| 2130 |
2167 |
|
|
2168 |
static gint imap_rename_folder(Folder *folder, FolderItem *item,
|
|
2169 |
const gchar *name)
|
|
2170 |
{
|
|
2171 |
return imap_rename_folder_real(folder, item, NULL, name);
|
|
2172 |
}
|
|
2173 |
|
|
2174 |
static gint imap_move_folder(Folder *folder, FolderItem *item,
|
|
2175 |
FolderItem *new_parent)
|
|
2176 |
{
|
|
2177 |
return imap_rename_folder_real(folder, item, new_parent, NULL);
|
|
2178 |
}
|
|
2179 |
|
| 2131 |
2180 |
static gint imap_remove_folder(Folder *folder, FolderItem *item)
|
| 2132 |
2181 |
{
|
| 2133 |
2182 |
gint ok;
|