Commit 3a5017a5 3a5017a550a95d903e6bdbad5099860b76e53df9 by Sergey Poznyakoff

(guess_level,list_copy): Fixed

(imap_parse): Handle NO case explicitely.
1 parent f9386077
...@@ -797,12 +797,17 @@ folder_imap_delete (mu_folder_t folder, const char *name) ...@@ -797,12 +797,17 @@ folder_imap_delete (mu_folder_t folder, const char *name)
797 void 797 void
798 guess_level (struct mu_list_response *resp, size_t prefix_len) 798 guess_level (struct mu_list_response *resp, size_t prefix_len)
799 { 799 {
800 char *p;
801 size_t lev = 0; 800 size_t lev = 0;
802 801
803 for (p = strchr (resp->name + prefix_len, resp->separator); p; 802 if (!resp->separator)
804 p = strchr (p + 1, resp->separator)) 803 lev = 0;
805 lev++; 804 else
805 {
806 char *p = resp->name + prefix_len;
807 if (p[0] == resp->separator)
808 for ( ; p; p = strchr (p + 1, resp->separator))
809 lev++;
810 }
806 resp->level = lev; 811 resp->level = lev;
807 } 812 }
808 813
...@@ -828,11 +833,15 @@ list_copy (mu_list_t dst, mu_list_t src, ...@@ -828,11 +833,15 @@ list_copy (mu_list_t dst, mu_list_t src,
828 for (mu_iterator_first (itr); !mu_iterator_is_done (itr); 833 for (mu_iterator_first (itr); !mu_iterator_is_done (itr);
829 mu_iterator_next (itr)) 834 mu_iterator_next (itr))
830 { 835 {
836 char *name;
831 struct mu_list_response *p; 837 struct mu_list_response *p;
832 mu_iterator_current (itr, (void **)&p); 838 mu_iterator_current (itr, (void **)&p);
833 guess_level (p, prefix_len); 839 guess_level (p, prefix_len);
834 if ((max_level == 0 || p->level < max_level) 840 name = p->name + prefix_len;
835 && (!namecmp || namecmp (pattern, p->name) == 0)) 841 if (name[0] == p->separator && pattern[0] != p->separator)
842 name++;
843 if ((max_level == 0 || p->level <= max_level)
844 && (!namecmp || namecmp (pattern, name) == 0))
836 mu_list_append (dst, p); 845 mu_list_append (dst, p);
837 else 846 else
838 free (p); 847 free (p);
...@@ -915,7 +924,7 @@ folder_imap_list (mu_folder_t folder, const char *ref, const char *name, ...@@ -915,7 +924,7 @@ folder_imap_list (mu_folder_t folder, const char *ref, const char *name,
915 f_imap_t f_imap = folder->data; 924 f_imap_t f_imap = folder->data;
916 int status = 0; 925 int status = 0;
917 char *path = NULL; 926 char *path = NULL;
918 927
919 status = mu_folder_open (folder, folder->flags); 928 status = mu_folder_open (folder, folder->flags);
920 if (status != 0) 929 if (status != 0)
921 return status; 930 return status;
...@@ -2437,7 +2446,7 @@ imap_parse (f_imap_t f_imap) ...@@ -2437,7 +2446,7 @@ imap_parse (f_imap_t f_imap)
2437 { 2446 {
2438 /* Cool we are doing ok. */ 2447 /* Cool we are doing ok. */
2439 } 2448 }
2440 else /* NO and BAD */ 2449 else if (strcasecmp (response, "NO") == 0)
2441 { 2450 {
2442 if (strncasecmp (remainder, "LOGIN", 5) == 0) 2451 if (strncasecmp (remainder, "LOGIN", 5) == 0)
2443 { 2452 {
...@@ -2446,11 +2455,15 @@ imap_parse (f_imap_t f_imap) ...@@ -2446,11 +2455,15 @@ imap_parse (f_imap_t f_imap)
2446 mu_observable_notify (observable, MU_EVT_AUTHORITY_FAILED); 2455 mu_observable_notify (observable, MU_EVT_AUTHORITY_FAILED);
2447 status = MU_ERR_AUTH_FAILURE; 2456 status = MU_ERR_AUTH_FAILURE;
2448 } 2457 }
2458 else if (strncasecmp (remainder, "LIST", 4) == 0)
2459 status = MU_ERR_NOENT;
2449 else 2460 else
2450 { 2461 status = MU_ERR_FAILURE;
2451 status = EINVAL; 2462 }
2452 mu_error ("NO/Bad Tagged: %s %s\n", response, remainder); 2463 else /* NO and BAD */
2453 } 2464 {
2465 status = EINVAL;
2466 mu_error ("NO/Bad Tagged: %s %s\n", response, remainder);
2454 } 2467 }
2455 } 2468 }
2456 f_imap->ptr = f_imap->buffer; 2469 f_imap->ptr = f_imap->buffer;
......