+2003-09-11 [paul] 0.9.5claws2
+
+ * sync with 0.9.5cvs2
+ see ChangeLog 2003-09-05
+
2003-09-11 [paul] 0.9.5claws1
* sync with 0.9.5cvs3
MICRO_VERSION=5
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=1
+EXTRA_VERSION=2
if test $EXTRA_VERSION -eq 0; then
VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws
else
return ret;
}
+/*
+ * Create a new boundary in a way that it is very unlikely that this
+ * will occur in the following text. It would be easy to ensure
+ * uniqueness if everything is either quoted-printable or base64
+ * encoded (note that conversion is allowed), but because MIME bodies
+ * may be nested, it may happen that the same boundary has already
+ * been used. We avoid scanning the message for conflicts and hope the
+ * best.
+ *
+ * boundary := 0*69<bchars> bcharsnospace
+ * bchars := bcharsnospace / " "
+ * bcharsnospace := DIGIT / ALPHA / "'" / "(" / ")" /
+ * "+" / "_" / "," / "-" / "." /
+ * "/" / ":" / "=" / "?"
+ *
+ * some special characters removed because of buggy MTAs
+ */
+
+gchar *generate_mime_boundary(const gchar *prefix)
+{
+ static gchar tbl[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz"
+ "1234567890+_./=";
+ gchar buf_uniq[17];
+ gchar buf_date[64];
+ gint i;
+ gint pid;
+
+ pid = getpid();
+
+ /* We make the boundary depend on the pid, so that all running
+ * processes generate different values even when they have been
+ * started within the same second and srandom(time(NULL)) has been
+ * used. I can't see whether this is really an advantage but it
+ * doesn't do any harm.
+ */
+ for (i = 0; i < sizeof(buf_uniq) - 1; i++)
+ buf_uniq[i] = tbl[(random() ^ pid) % (sizeof(tbl) - 1)];
+ buf_uniq[i] = '\0';
+
+ get_rfc822_date(buf_date, sizeof(buf_date));
+ subst_char(buf_date, ' ', '_');
+ subst_char(buf_date, ',', '_');
+ subst_char(buf_date, ':', '_');
+
+ return g_strdup_printf("%s=_%s_%s", prefix ? prefix : "Multipart",
+ buf_date, buf_uniq);
+}
+
gint change_file_mode_rw(FILE *fp, const gchar *file)
{
#if HAVE_FCHMOD
g_free(addr);
return buf;
}
-
-/**
- * Create a new boundary in a way that it is very unlikely that this
- * will occur in the following text. It would be easy to ensure
- * uniqueness if everything is either quoted-printable or base64
- * encoded (note that conversion is allowed), but because MIME bodies
- * may be nested, it may happen that the same boundary has already
- * been used. We avoid scanning the message for conflicts and hope the
- * best.
- *
- * boundary := 0*69<bchars> bcharsnospace
- * bchars := bcharsnospace / " "
- * bcharsnospace := DIGIT / ALPHA / "'" / "(" / ")" /
- * "+" / "_" / "," / "-" / "." /
- * "/" / ":" / "=" / "?"
- *
- * ":" and "," removed because of buggy MTAs
- */
-
-gchar *generate_mime_boundary(void)
-{
- static gchar tbl[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz"
- "1234567890'()+_./=?";
- gchar bufuniq[17];
- gchar bufdate[BUFFSIZE];
- int i, equal;
- int pid;
-
- pid = getpid();
-
- /* We make the boundary depend on the pid, so that all running
- * processed generate different values even when they have been
- * started within the same second and srand48(time(NULL)) has been
- * used. I can't see whether this is really an advantage but it
- * doesn't do any harm.
- */
- equal = -1;
- for (i = 0; i < sizeof(bufuniq) - 1; i++) {
- bufuniq[i] = tbl[(lrand48() ^ pid) % (sizeof(tbl) - 1)]; /* fill with random */
- if (bufuniq[i] == '=' && equal == -1)
- equal = i;
- }
- bufuniq[i] = 0;
-
- /* now make sure that we do have the sequence "=." in it which cannot
- * be matched by quoted-printable or base64 encoding */
- if (equal != -1 && (equal + 1) < i)
- bufuniq[equal + 1] = '.';
- else {
- bufuniq[0] = '=';
- bufuniq[1] = '.';
- }
-
- get_rfc822_date(bufdate, sizeof(bufdate));
- subst_char(bufdate, ' ', '_');
- subst_char(bufdate, ',', '_');
- subst_char(bufdate, ':', '_');
-
- return g_strdup_printf("Multipart_%s_%s",
- bufdate, bufuniq);
-}
Folder *(*new_folder) (const gchar *name,
const gchar *path);
void (*destroy_folder) (Folder *folder);
- void (*scan_tree) (Folder *folder);
+ gint (*scan_tree) (Folder *folder);
gint (*create_tree) (Folder *folder);
static gint imap_close(Folder * folder, FolderItem * item);
-static void imap_scan_tree(Folder * folder);
+static gint imap_scan_tree(Folder * folder);
static gint imap_create_tree(Folder * folder);
if (!session) return -1;
if (session->mbox) {
- if (strcmp(item->path, session->mbox))
- return -1;
+ if (strcmp2(session->mbox, item->path) != 0) return -1;
ok = imap_cmd_close(session);
if (ok != IMAP_SUCCESS)
return 0;
}
-void imap_scan_tree(Folder *folder)
+gint imap_scan_tree(Folder *folder)
{
FolderItem *item = NULL;
IMAPSession *session;
gchar *root_folder = NULL;
- g_return_if_fail(folder != NULL);
- g_return_if_fail(folder->account != NULL);
+ g_return_val_if_fail(folder != NULL, -1);
+ g_return_val_if_fail(folder->account != NULL, -1);
session = imap_session_get(folder);
if (!session) {
item->folder = folder;
folder->node = item->node = g_node_new(item);
}
- return;
+ return -1;
}
if (folder->account->imap_dir && *folder->account->imap_dir) {
- Xstrdup_a(root_folder, folder->account->imap_dir, return);
+ gchar *real_path;
+
+ Xstrdup_a(root_folder, folder->account->imap_dir, return -1);
strtailchomp(root_folder, '/');
- debug_print("IMAP root directory: %s\n", root_folder);
+ extract_quote(root_folder, '"');
+ real_path = imap_get_real_path
+ (IMAP_FOLDER(folder), root_folder);
+ debug_print("IMAP root directory: %s\n", real_path);
+ if (imap_status(session, IMAP_FOLDER(folder), root_folder,
+ NULL, NULL, NULL, NULL, NULL)
+ != IMAP_SUCCESS) {
+ if (imap_cmd_create(session, real_path)
+ != IMAP_SUCCESS) {
+ log_warning(_("can't create root folder %s\n"),
+ real_path);
+ g_free(real_path);
+ return -1;
+ }
+ }
+ g_free(real_path);
}
if (folder->node)
imap_scan_tree_recursive(session, FOLDER_ITEM(folder->node->data));
imap_create_missing_folders(folder);
+
+ return 0;
}
static gint imap_scan_tree_recursive(IMAPSession *session, FolderItem *item)
strretchomp(buf);
if (buf[0] != '*' || buf[1] != ' ') {
log_print("IMAP4< %s\n", buf);
+ if (sscanf(buf, "%*d %16s", buf) < 1 ||
+ strcmp(buf, "OK") != 0)
+ log_warning(_("error occurred while getting LIST.\n"));
+
break;
}
debug_print("IMAP4< %s\n", buf);
if (!path) path = "";
- Xstrcat_a(tmp_path, path, "/", return NULL);
-
for (; ns_list != NULL; ns_list = ns_list->next) {
IMAPNameSpace *tmp_ns = ns_list->data;
+ Xstrcat_a(tmp_path, path, "/", return namespace);
Xstrdup_a(name, tmp_ns->name, return namespace);
- if (tmp_ns->separator && tmp_ns->separator != '/')
+ if (tmp_ns->separator && tmp_ns->separator != '/') {
+ subst_char(tmp_path, tmp_ns->separator, '/');
subst_char(name, tmp_ns->separator, '/');
+ }
if (strncmp(tmp_path, name, strlen(name)) == 0)
namespace = tmp_ns;
}
gchar *real_path;
gchar *real_path_;
gint ok;
- GPtrArray *argbuf;
+ GPtrArray *argbuf = NULL;
gchar *str;
- *messages = *recent = *uid_next = *uid_validity = *unseen = 0;
-
- if (path == NULL)
- return -1;
-
- argbuf = g_ptr_array_new();
+ if (messages && recent && uid_next && uid_validity && unseen) {
+ *messages = *recent = *uid_next = *uid_validity = *unseen = 0;
+ argbuf = g_ptr_array_new();
+ }
real_path = imap_get_real_path(folder, path);
QUOTE_IF_REQUIRED(real_path_, real_path);
real_path_);
ok = imap_cmd_ok(session, argbuf);
- if (ok != IMAP_SUCCESS) THROW(ok);
+ if (ok != IMAP_SUCCESS || !argbuf) THROW(ok);
str = search_array_str(argbuf, "STATUS");
if (!str) THROW(IMAP_ERROR);
catch:
g_free(real_path);
- ptr_array_free_strings(argbuf);
- g_ptr_array_free(argbuf, TRUE);
+ if (argbuf) {
+ ptr_array_free_strings(argbuf);
+ g_ptr_array_free(argbuf, TRUE);
+ }
return ok;
}
typedef enum
{
IMAP_AUTH_LOGIN = 1 << 0,
- IMAP_AUTH_CRAM_MD5 = 1 << 1,
+ IMAP_AUTH_CRAM_MD5 = 1 << 1
} IMAPAuthType;
FolderClass *imap_get_class (void);
static gint mh_get_num_list(Folder * folder,
FolderItem * item, GSList ** list, gboolean *old_uids_valid);
-static void mh_scan_tree(Folder * folder);
+static gint mh_scan_tree(Folder * folder);
static gint mh_create_tree(Folder * folder);
static FolderItem *mh_create_folder(Folder * folder,
return FALSE;
}
-void mh_scan_tree(Folder *folder)
+gint mh_scan_tree(Folder *folder)
{
FolderItem *item;
gchar *rootpath;
- g_return_if_fail(folder != NULL);
+ g_return_val_if_fail(folder != NULL, -1);
if (!folder->node) {
item = folder_item_new(folder, folder->name, NULL);
rootpath = folder_item_get_path(item);
if (change_dir(rootpath) < 0) {
g_free(rootpath);
- return;
+ return -1;
}
g_free(rootpath);
mh_create_tree(folder);
mh_remove_missing_folder_items(folder);
mh_scan_tree_recursive(item);
+
+ return 0;
}
#define MAKE_DIR_IF_NOT_EXIST(dir) \
summary_clear_list(summaryview);
summary_set_column_titles(summaryview);
- if (!is_refresh)
- messageview_clear(summaryview->messageview);
buf = NULL;
if (!item || !item->path || !item->parent || item->no_select) {
g_free(buf);
debug_print("empty folder\n\n");
summary_set_hide_read_msgs_menu(summaryview, FALSE);
- if (is_refresh)
- messageview_clear(summaryview->messageview);
summary_clear_all(summaryview);
summaryview->folder_item = item;
gtk_clist_thaw(GTK_CLIST(ctree));
}
g_free(buf);
+ if (!is_refresh)
+ messageview_clear(summaryview->messageview);
+
summaryview->folder_item = item;
item->opened = TRUE;
void summary_clear_all(SummaryView *summaryview)
{
+ messageview_clear(summaryview->messageview);
summary_clear_list(summaryview);
summary_set_menu_sensitive(summaryview);
toolbar_main_set_sensitive(summaryview->mainwin);