-
- if (imap_cmd_envelope(SESSION(session)->sock, num, num)
- != IMAP_SUCCESS) {
- log_warning(_("can't get envelope\n"));
- return NULL;
- }
-
- str = g_string_new(NULL);
-
- if ((tmp = sock_getline(SESSION(session)->sock)) == NULL) {
- log_warning(_("error occurred while getting envelope.\n"));
- g_string_free(str, TRUE);
- return NULL;
- }
- strretchomp(tmp);
- log_print("IMAP4< %s\n", tmp);
- g_string_assign(str, tmp);
- g_free(tmp);
-
- /* if the server did not return a envelope */
- if (str->str[0] != '*') {
- g_string_free(str, TRUE);
- return NULL;
- }
-
- msginfo = imap_parse_envelope(SESSION(session)->sock,
- item, str);
-
- /* Read all data on the socket until the server is read for a new command */
- tmp = NULL;
- do {
- g_free(tmp);
- tmp = sock_getline(SESSION(session)->sock);
- } while (!(tmp == NULL || tmp[0] != '*' || tmp[1] != ' '));
- g_free(tmp);
-
- /* if message header could not be parsed */
- if (!msginfo) {
- log_warning(_("can't parse envelope: %s\n"), str->str);
- return NULL;
- }
-
- g_string_free(str, TRUE);
-
- msginfo->folder = item;