Changeset 2081
- Timestamp:
- 06/06/07 12:58:10
- Files:
-
- trunk/ChangeLog (modified) (1 diff)
- trunk/README (modified) (1 diff)
- trunk/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.c (modified) (39 diffs)
- trunk/libtinymail-camel/camel-lite/camel/providers/pop3/camel-pop3-store.c (modified) (11 diffs)
- trunk/libtinymail-camel/camel-lite/configure.ac (modified) (1 diff)
- trunk/libtinymail-camel/tny-camel-account.c (modified) (1 diff)
- trunk/libtinymail/tny-account.c (modified) (1 diff)
- trunk/tests/shared/account-store.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ChangeLog
r2077 r2081 6 6 * Added the option --with-ssl=nss,openssl,none to the build to assist 7 7 the SSL library availability detection 8 * Changed the use_ssl options to "wrapped", "tls", "when-possible" and 9 "never" for both POP3 and IMAP 10 * Some connection fixes in the IMAP and POP3 connection procedures 8 11 9 12 2007-06-05 Philip Van Hoof <pvanhoof@gnome.org> trunk/README
r1724 r2081 108 108 To use SSL (other values are "never" and "when-possible"): 109 109 110 gconftool-2 -s /apps/tinymail/accounts/0/options -t list --list-type=string '[use_ssl= always]'110 gconftool-2 -s /apps/tinymail/accounts/0/options -t list --list-type=string '[use_ssl=wrapped]' 111 111 112 112 Distribution specific: also check out requirements.txt trunk/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.c
r2076 r2081 671 671 672 672 static gboolean 673 connect_to_server (CamelService *service, struct addrinfo *ai, int ssl_mode, CamelException *ex)673 connect_to_server (CamelService *service, struct addrinfo *ai, int ssl_mode, int must_tls, CamelException *ex) 674 674 { 675 675 CamelImapStore *store = (CamelImapStore *) service; … … 682 682 gboolean not_ssl = TRUE; 683 683 684 if (ssl_mode != MODE_CLEAR) { 684 if (ssl_mode != MODE_CLEAR) 685 { 685 686 not_ssl = FALSE; 687 686 688 #ifdef HAVE_SSL 687 if (ssl_mode == MODE_TLS) {689 if (ssl_mode == MODE_TLS) 688 690 tcp_stream = camel_tcp_stream_ssl_new_raw (service->session, service->url->host, STARTTLS_FLAGS); 689 } else {691 else 690 692 tcp_stream = camel_tcp_stream_ssl_new (service->session, service->url->host, SSL_PORT_FLAGS); 691 }692 693 #else 694 693 695 camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, 694 _("Could not connect to %s: %s"),695 service->url->host, _("SSL unavailable"));696 696 _("Could not connect to %s: %s"), 697 service->url->host, _("SSL unavailable in this build")); 698 697 699 return FALSE; 700 698 701 #endif /* HAVE_SSL */ 699 } else {702 } else 700 703 tcp_stream = camel_tcp_stream_raw_new (); 701 } 702 703 if (camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai) == -1){704 705 if (camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai) == -1) 706 { 704 707 if (errno == EINTR) 705 708 camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, … … 710 713 service->url->host, 711 714 g_strerror (errno)); 712 713 715 camel_object_unref (tcp_stream); 714 715 716 return FALSE; 716 717 } … … 738 739 if (camel_imap_store_readline (store, &buf, ex) < 0) 739 740 { 740 741 g_mutex_lock (store->stream_lock); 742 if (store->istream) { 743 camel_object_unref (store->istream); 744 store->istream = NULL; 745 } 746 747 if (store->ostream) { 748 camel_object_unref (store->ostream); 749 store->ostream = NULL; 750 } 751 g_mutex_unlock (store->stream_lock); 752 753 store->connected = FALSE; 754 755 return FALSE; 756 } 757 741 camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, 742 _("Failed to connect to IMAP server %s"), 743 service->url->host, _("Reading IMAP greeting failed")); 744 goto exception; 745 } 746 758 747 if (!strncmp(buf, "* PREAUTH", 9)) 759 748 store->preauthed = TRUE; 760 761 if (strstr (buf, "Courier-IMAP") || getenv("CAMEL_IMAP_BRAINDAMAGED")) { 749 750 if (strstr (buf, "Courier-IMAP") || getenv("CAMEL_IMAP_BRAINDAMAGED")) 751 { 762 752 /* Courier-IMAP is braindamaged. So far this flag only 763 753 * works around the fact that Courier-IMAP is known to … … 767 757 * rather than getting individual parts. */ 768 758 store->braindamaged = TRUE; 769 } else if (strstr (buf, "WEB.DE") || strstr (buf, "Mail2World")) { 759 } else if (strstr (buf, "WEB.DE") || strstr (buf, "Mail2World")) 760 { 770 761 /* This is a workaround for servers which advertise 771 762 * IMAP4rev1 but which can sometimes subtly break in … … 786 777 force_imap4 = TRUE; 787 778 } 788 789 779 790 780 /* Tinymail hack: always use IMAP4, not IMAP4rev1 (sorry) */ 791 792 781 /* force_imap4 = TRUE; */ 793 782 store->braindamaged = TRUE; 794 795 783 /* end of hack :) */ 796 784 797 785 g_free (buf); 798 786 799 787 /* get the imap server capabilities */ 800 788 if (!imap_get_capability (service, ex)) 801 789 { 802 g_mutex_lock (store->stream_lock); 803 if (store->istream) { 804 camel_object_unref (store->istream); 805 store->istream = NULL; 806 } 807 808 if (store->ostream) { 809 camel_object_unref (store->ostream); 810 store->ostream = NULL; 811 } 812 g_mutex_unlock (store->stream_lock); 813 814 store->connected = FALSE; 815 return FALSE; 816 } 817 818 if (force_imap4) { 790 camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, 791 _("Failed to connect to IMAP server %s"), 792 service->url->host, _("Reading first CAPABILITY failed")); 793 goto exception; 794 } 795 796 if (must_tls && !(store->capabilities & IMAP_CAPABILITY_STARTTLS)) 797 { 798 camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, 799 _("Failed to connect to IMAP server %s"), 800 service->url->host, _("STARTTLS not announced as supported on this server")); 801 goto exception; 802 } 803 804 if (force_imap4) 805 { 819 806 store->capabilities &= ~IMAP_CAPABILITY_IMAP4REV1; 820 807 store->server_level = IMAP_LEVEL_IMAP4; 821 808 } 822 823 if ( not_ssl || ssl_mode != MODE_TLS) {824 809 810 if (!must_tls && (not_ssl || ssl_mode != MODE_TLS)) 811 { 825 812 /* we're done */ 826 827 813 return TRUE; 828 829 } 830 814 } 815 816 831 817 #ifdef HAVE_SSL 832 if (!(store->capabilities & IMAP_CAPABILITY_STARTTLS)) { 818 819 if (!(store->capabilities & IMAP_CAPABILITY_STARTTLS)) 820 { 833 821 camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, 834 822 _("Failed to connect to IMAP server %s in secure mode: %s"), 835 823 service->url->host, _("STARTTLS not supported")); 836 837 824 goto exception; 838 825 } 839 826 840 827 /* as soon as we send a STARTTLS command, all hope is lost of a clean QUIT if problems arise */ 841 828 clean_quit = FALSE; 842 829 843 830 response = camel_imap_command (store, NULL, ex, "STARTTLS"); 844 831 if (!response) … … 850 837 store->ostream = NULL; 851 838 g_mutex_unlock (store->stream_lock); 852 853 return FALSE; 854 } 855 839 clean_quit = FALSE; 840 camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, 841 _("Failed to connect to IMAP server %s in secure mode: %s"), 842 service->url->host, _("STARTTLS not supported")); 843 goto exception; 844 } 845 856 846 camel_imap_response_free_without_processing (store, response); 857 847 858 848 /* Okay, now toggle SSL/TLS mode */ 859 if (camel_tcp_stream_ssl_enable_ssl (CAMEL_TCP_STREAM_SSL (tcp_stream)) == -1) { 849 if (camel_tcp_stream_ssl_enable_ssl (CAMEL_TCP_STREAM_SSL (tcp_stream)) == -1) 850 { 860 851 camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, 861 _("Failed to connect to IMAP server %s in secure mode: %s"),862 service->url->host, _("SSL negotiations failed"));852 _("Failed to connect to IMAP server %s in secure mode: %s"), 853 service->url->host, _("SSL negotiations failed")); 863 854 goto exception; 864 855 } 856 865 857 #else 866 858 camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, … … 869 861 goto exception; 870 862 #endif /* HAVE_SSL */ 871 863 864 872 865 /* rfc2595, section 4 states that after a successful STLS 873 command, the client MUST discard prior CAPA responses */ 866 command, the client MUST discard prior CAPA responses */ 867 874 868 if (!imap_get_capability (service, ex)) 875 869 { 876 877 g_mutex_lock (store->stream_lock); 878 if (store->istream) { 879 camel_object_unref (store->istream); 880 store->istream = NULL; 881 } 882 883 if (store->ostream) { 884 camel_object_unref (store->ostream); 885 store->ostream = NULL; 886 } 887 g_mutex_unlock (store->stream_lock); 888 889 store->connected = FALSE; 890 891 return FALSE; 870 camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, 871 _("Failed to connect to IMAP server %s"), 872 service->url->host, _("Reading second CAPABILITY failed")); 873 goto exception; 892 874 } 893 875 894 876 if (store->capabilities & IMAP_CAPABILITY_LOGINDISABLED ) { 895 clean_quit = TRUE;896 877 camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, 897 _("Failed to connect to IMAP server %s in secure mode: %s"), service->url->host, _("Unknown error")); 878 _("Failed to connect to IMAP server %s in secure mode: %s"), 879 service->url->host, _("Unknown error, LOGINDISABLED with SSL")); 898 880 goto exception; 899 881 } 900 882 901 883 return TRUE; 902 903 exception: 904 905 if (clean_quit && store->connected) { 884 885 exception: 886 887 if (clean_quit && store->connected) 888 { 906 889 /* try to disconnect cleanly */ 907 890 response = camel_imap_command (store, NULL, ex, "LOGOUT"); … … 915 898 store->istream = NULL; 916 899 } 917 918 900 if (store->ostream) { 919 901 camel_object_unref (store->ostream); … … 921 903 } 922 904 g_mutex_unlock (store->stream_lock); 923 924 905 store->connected = FALSE; 925 906 926 907 return FALSE; 927 908 } … … 1012 993 while (i) 1013 994 g_free(child_env[--i]); 1014 995 1015 996 if (ret == -1) { 1016 997 if (errno == EINTR) … … 1036 1017 store->preauthed = FALSE; 1037 1018 store->command = 0; 1038 1019 1039 1020 /* Read the greeting, if any, and deal with PREAUTH */ 1040 1021 if (camel_imap_store_readline (store, &buf, ex) < 0) … … 1055 1036 return FALSE; 1056 1037 } 1038 1057 1039 if (!strncmp(buf, "* PREAUTH", 9)) 1058 1040 store->preauthed = TRUE; 1059 1041 g_free (buf); 1060 1042 1061 1043 /* get the imap server capabilities */ 1062 1044 if (!imap_get_capability (service, ex)) … … 1067 1049 store->istream = NULL; 1068 1050 } 1069 1070 1051 if (store->ostream) { 1071 1052 camel_object_unref (store->ostream); … … 1077 1058 return FALSE; 1078 1059 } 1079 1060 1080 1061 return TRUE; 1081 1062 … … 1089 1070 char *port; 1090 1071 int mode; 1072 int must_tls; 1091 1073 } ssl_options[] = { 1092 { "", "imaps", IMAPS_PORT, MODE_SSL }, /* really old (1.x) */ 1093 { "always", "imaps", IMAPS_PORT, MODE_SSL }, 1094 { "when-possible", "imap", IMAP_PORT, MODE_TLS }, 1095 { "never", "imap", IMAP_PORT, MODE_CLEAR }, 1096 { NULL, "imap", IMAP_PORT, MODE_CLEAR }, 1074 { "", "imaps", IMAPS_PORT, MODE_SSL, 0 }, /* really old (1.x) */ 1075 { "wrapped", "imaps", IMAPS_PORT, MODE_SSL, 0 }, 1076 { "tls", "imap", IMAPS_PORT, MODE_TLS, 1 }, 1077 { "when-possible", "imap", IMAP_PORT, MODE_TLS, 0 }, 1078 { "never", "imap", IMAP_PORT, MODE_CLEAR, 0 }, 1079 { NULL, "imap", IMAP_PORT, MODE_CLEAR, 0 }, 1097 1080 }; 1098 1081 … … 1103 1086 const char *ssl_mode; 1104 1087 struct addrinfo hints, *ai; 1105 int mode = -1, ret, i ;1088 int mode = -1, ret, i, must_tls = 0; 1106 1089 char *serv; 1107 1090 const char *port; … … 1113 1096 && (command = camel_url_get_param(service->url, "command"))) 1114 1097 return connect_to_server_process(service, command, ex); 1115 #endif 1116 if ((ssl_mode = camel_url_get_param (service->url, "use_ssl"))) { 1098 #endif 1099 1100 if ((ssl_mode = camel_url_get_param (service->url, "use_ssl"))) 1101 { 1117 1102 for (i = 0; ssl_options[i].value; i++) 1118 1103 if (!strcmp (ssl_options[i].value, ssl_mode)) … … 1121 1106 serv = ssl_options[i].serv; 1122 1107 port = ssl_options[i].port; 1123 } else { 1108 must_tls = ssl_options[i].must_tls; 1109 } else 1110 { 1124 1111 mode = MODE_CLEAR; 1125 1112 serv = "imap"; 1126 1113 port = IMAP_PORT; 1127 } 1128 1129 if (service->url->port) { 1114 must_tls = 0; 1115 } 1116 1117 if (service->url->port) 1118 { 1130 1119 serv = g_alloca (16); 1131 1120 sprintf (serv, "%d", service->url->port); 1132 1121 port = NULL; 1133 1122 } 1134 1123 1135 1124 memset (&hints, 0, sizeof (hints)); 1136 1125 hints.ai_socktype = SOCK_STREAM; 1137 1126 hints.ai_family = PF_UNSPEC; 1127 1138 1128 ai = camel_getaddrinfo(service->url->host, serv, &hints, ex); 1139 if (ai == NULL && port != NULL && camel_exception_get_id(ex) != CAMEL_EXCEPTION_USER_CANCEL) { 1129 1130 if (ai == NULL && port != NULL && camel_exception_get_id(ex) != CAMEL_EXCEPTION_USER_CANCEL) 1131 { 1140 1132 camel_exception_clear (ex); 1141 1133 ai = camel_getaddrinfo(service->url->host, port, &hints, ex); 1142 1134 } 1143 1135 1144 1136 if (ai == NULL) 1145 1137 return FALSE; 1146 1147 ret = connect_to_server (service, ai, mode, ex); 1148 1138 1139 ret = connect_to_server (service, ai, mode, must_tls, ex); 1149 1140 camel_freeaddrinfo (ai); 1150 1141 1151 1142 return ret; 1152 1143 } … … 1469 1460 1470 1461 auth_domain = camel_url_get_param (service->url, "auth-domain"); 1471 1472 if (store->preauthed) { 1462 1463 if (store->preauthed) 1464 { 1473 1465 if (camel_verbose_debug) 1474 1466 fprintf(stderr, "Server %s has preauthenticated us.\n", … … 1477 1469 } 1478 1470 1479 if (service->url->authmech) { 1471 if (service->url->authmech) 1472 { 1480 1473 if (!g_hash_table_lookup (store->authtypes, service->url->authmech)) { 1481 1474 camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, 1482 _("IMAP server %s does not support requested "1483 "authentication type %s"),1484 service->url->host,1485 service->url->authmech);1475 _("IMAP server %s does not support requested " 1476 "authentication type %s"), 1477 service->url->host, 1478 service->url->authmech); 1486 1479 return FALSE; 1487 1480 } 1488 1481 1489 1482 authtype = camel_sasl_authtype (service->url->authmech); 1490 1483 if (!authtype) { … … 1494 1487 return FALSE; 1495 1488 } 1496 1497 if (!authtype->need_password) { 1489 1490 if (!authtype->need_password) 1491 { 1498 1492 authenticated = try_auth (store, authtype->authproto, ex); 1499 1493 if (!authenticated) … … 1501 1495 } 1502 1496 } 1503 1504 while (!authenticated) { 1505 if (errbuf) { 1497 1498 while (!authenticated) 1499 { 1500 if (errbuf) 1501 { 1506 1502 /* We need to un-cache the password before prompting again */ 1507 1503 camel_session_forget_password (session, service, auth_domain, "password", ex); … … 1509 1505 service->url->passwd = NULL; 1510 1506 } 1511 1512 if (!service->url->passwd) { 1507 1508 if (!service->url->passwd) 1509 { 1513 1510 char *prompt; 1514 1511 1515 1512 prompt = g_strdup_printf (_("%sPlease enter the IMAP " 1516 "password for %s@%s"),1517 errbuf ? errbuf : "",1518 service->url->user,1519 service->url->host);1513 "password for %s@%s"), 1514 errbuf ? errbuf : "", 1515 service->url->user, 1516 service->url->host); 1520 1517 service->url->passwd = 1521 1518 camel_session_get_password (session, service, auth_domain, 1522 prompt, "password", CAMEL_SESSION_PASSWORD_SECRET, ex);1519 prompt, "password", CAMEL_SESSION_PASSWORD_SECRET, ex); 1523 1520 g_free (prompt); 1524 1521 g_free (errbuf); 1525 1522 errbuf = NULL; 1526 1523 1527 1524 if (!service->url->passwd) { 1528 1525 camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, 1529 _("You did not enter a password."));1526 _("You did not enter a password.")); 1530 1527 return FALSE; 1531 1528 } 1532 1529 } 1533 1530 1534 if (!store->connected) { 1531 if (!store->connected) 1532 { 1535 1533 /* Some servers (eg, courier) will disconnect on 1536 * a bad password. So reconnect here. 1537 */ 1534 * a bad password. So reconnect here. */ 1538 1535 if (!connect_to_server_wrapper (service, ex)) 1539 1536 return FALSE; 1540 1537 } 1541 1538 1542 1539 if (authtype) 1543 1540 authenticated = try_auth (store, authtype->authproto, ex); … … 1572 1569 { 1573 1570 errbuf = g_strdup_printf (_("Unable to authenticate " 1574 "to IMAP server.\n%s\n\n"),1575 camel_exception_get_description (ex));1571 "to IMAP server.\n%s\n\n"), 1572 camel_exception_get_description (ex)); 1576 1573 camel_exception_clear (ex); 1577 1574 return FALSE; … … 1586 1583 { 1587 1584 CamelImapStore *store = CAMEL_IMAP_STORE (disco_store); 1588 1585 1589 1586 return camel_store_summary_count((CamelStoreSummary *)store->summary) != 0; 1590 1587 } … … 1604 1601 CAMEL_SERVICE_REC_LOCK (store, connect_lock); 1605 1602 1606 if (!connect_to_server_wrapper (service, ex) || 1607 !imap_auth_loop (service, ex)){1603 if (!connect_to_server_wrapper (service, ex) || !imap_auth_loop (service, ex)) 1604 { 1608 1605 CAMEL_DISCO_STORE (store)->status = CAMEL_DISCO_STORE_OFFLINE; 1609 1606 CAMEL_SERVICE_REC_UNLOCK (store, connect_lock); … … 1614 1611 /* Get namespace and hierarchy separator */ 1615 1612 if ((store->capabilities & IMAP_CAPABILITY_NAMESPACE) && 1616 !(store->parameters & IMAP_PARAM_OVERRIDE_NAMESPACE)) { 1613 !(store->parameters & IMAP_PARAM_OVERRIDE_NAMESPACE)) 1614 { 1617 1615 response = camel_imap_command (store, NULL, ex, "NAMESPACE"); 1618 1616 if (!response) 1619 1617 goto done; 1620 1618 1621 1619 result = camel_imap_response_extract (store, response, "NAMESPACE", ex); 1622 1620 if (!result) 1623 1621 goto done; 1624 1622 1625 1623 #if 0 1626 1624 /* new code... */ … … 1629 1627 /* end new code */ 1630 1628 #endif 1631 1629 1632 1630 name = camel_strstrcase (result, "NAMESPACE (("); 1633 if (name) { 1631 if (name) 1632 { 1634 1633 char *sep; 1635 1636 1634 name += 12; 1637 1635 store->namespace = imap_parse_string ((const char **) &name, &len); … … 1646 1644 g_free (result); 1647 1645 } 1648 1646 1649 1647 if (!store->namespace) 1650 1648 store->namespace = g_strdup (""); 1651 1649 1652 1650 if (!store->dir_sep) { 1653 if (store->server_level >= IMAP_LEVEL_IMAP4REV1) { 1651 if (store->server_level >= IMAP_LEVEL_IMAP4REV1) 1652 { 1654 1653 /* This idiom means "tell me the hierarchy separator 1655 1654 * for the given path, even if that path doesn't exist. … … 1667 1666 store->namespace); 1668 1667 } 1668 1669 1669 if (!response) 1670 1670 goto done; 1671 1671 1672 1672 result = camel_imap_response_extract (store, response, "LIST", NULL); 1673 if (result) { 1673 if (result) 1674 { 1674 1675 imap_parse_list_response (store, result, NULL, &store->dir_sep, NULL); 1675 1676 g_free (result); 1676 1677 } 1677 if (!store->dir_sep) {1678 if (!store->dir_sep) 1678 1679 store->dir_sep = '/'; /* Guess */ 1679 } 1680 } 1681 1680 } 1681 1682 1682 /* canonicalize the namespace to end with dir_sep */ 1683 1683 len = strlen (store->namespace); 1684 if (len && store->namespace[len - 1] != store->dir_sep) { 1685 gchar *tmp; 1686 1687 tmp = g_strdup_printf ("%s%c", store->namespace, store->dir_sep); 1684 if (len && store->namespace[len - 1] != store->dir_sep) 1685 { 1686 gchar *tmp = g_strdup_printf ("%s%c", store->namespace, store->dir_sep); 1688 1687 g_free (store->namespace); 1689 1688 store->namespace = tmp; 1690 1689 } 1691 1690 1692 1691 ns = camel_imap_store_summary_namespace_new(store->summary, store->namespace, store->dir_sep); 1693 1692 camel_imap_store_summary_namespace_set(store->summary, ns); 1694 1693 1695 1694 if ((store->parameters & IMAP_PARAM_SUBSCRIPTIONS) 1696 && camel_store_summary_count((CamelStoreSummary *)store->summary) == 0) { 1695 && camel_store_summary_count((CamelStoreSummary *)store->summary) == 0) 1696 { 1697 1697 CamelStoreInfo *si; 1698 1698 char *pattern; 1699 1699 1700 1700 get_folders_sync(store, store->namespace, ex); 1701 1701 if (camel_exception_is_set(ex)) … … 1709 1709 /* Make sure INBOX is present/subscribed */ 1710 1710 si = camel_store_summary_path((CamelStoreSummary *)store->summary, "INBOX"); 1711 if (si == NULL || (si->flags & CAMEL_FOLDER_SUBSCRIBED) == 0) { 1711 1712 if (si == NULL || (si->flags & CAMEL_FOLDER_SUBSCRIBED) == 0) 1713 { 1712 1714 response = camel_imap_command (store, NULL, ex, "SUBSCRIBE INBOX"); 1713 1715 if (response != NULL) { … … 1720 1722 get_folders_sync(store, "INBOX", ex); 1721 1723 } 1724 1722 1725 store->refresh_stamp = time(0); 1723 1726 } 1724 1725 1727 1726 1728 done: 1727 1729 … … 1730 1732 1731 1733 CAMEL_SERVICE_REC_UNLOCK (store, connect_lock); 1732 1733 1734 if (camel_exception_is_set (ex)) 1734 1735 camel_service_disconnect (service, TRUE, NULL); … … 1767 1768 store->istream = NULL; 1768 1769 } 1769 1770 1770 1771 if (store->ostream) { 1771 1772 camel_stream_close(store->ostream); … … 1786 1787 store->authtypes = NULL; 1787 1788 } 1788 1789 1789 1790 if (store->namespace && !(store->parameters & IMAP_PARAM_OVERRIDE_NAMESPACE)) { 1790 1791 g_free (store->namespace); 1791 1792 store->namespace = NULL; 1792 1793 } 1793 1794 1794 1795 return TRUE; 1795 1796 } … … 1807 1808 camel_imap_response_free (store, response); 1808 1809 } 1809 1810 1810 1811 imap_disconnect_offline (service, clean, ex); 1811 1812 1812 1813 return TRUE; 1813 1814 } … … 1829 1830 } 1830 1831 } 1831 1832 1832 1833 return FALSE; 1833 1834 } … … 1839 1840 CamelImapResponse *response; 1840 1841 CamelFolder *current_folder; 1841 1842 1842 1843 CAMEL_SERVICE_REC_LOCK (imap_store, connect_lock); 1843 1844 trunk/libtinymail-camel/camel-lite/camel/providers/pop3/camel-pop3-store.c
r2076 r2081 251 251 252 252 static gboolean 253 connect_to_server (CamelService *service, struct addrinfo *ai, int ssl_mode, CamelException *ex)253 connect_to_server (CamelService *service, struct addrinfo *ai, int ssl_mode, int must_tls, CamelException *ex) 254 254 { 255 255 CamelPOP3Store *store = CAMEL_POP3_STORE (service); … … 263 263 store->connected = FALSE; 264 264 265 if (ssl_mode != MODE_CLEAR) { 265 if (ssl_mode != MODE_CLEAR) 266 { 267 266 268 #ifdef HAVE_SSL 267 if (ssl_mode == MODE_TLS) {269 if (ssl_mode == MODE_TLS) 268 270 tcp_stream = camel_tcp_stream_ssl_new_raw (service->session, service->url->host, STARTTLS_FLAGS); 269 } else {271 else 270 272 tcp_stream = camel_tcp_stream_ssl_new (service->session, service->url->host, SSL_PORT_FLAGS); 271 }272 273 #else 274 273 275 camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, 274 _("Could not connect to %s: %s"),275 service->url->host, _("SSL unavailable"));276 276 _("Could not connect to %s: %s"), 277 service->url->host, _("SSL unavailable")); 278 277 279 return FALSE; 280 278 281 #endif /* HAVE_SSL */ 279 } else {282 } else 280 283 tcp_stream = camel_tcp_stream_raw_new (); 281 } 282 283 if ((ret = camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai)) == -1){284 285 if ((ret = camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai)) == -1) 286 { 284 287 if (errno == EINTR) 285 288 camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, 286 _("Connection canceled"));289 _("Connection canceled")); 287 290 else 288 291 camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, 289 _("Could not connect to %s: %s"),290 service->url->host,291 g_strerror (errno));292 _("Could not connect to %s: %s"), 293 service->url->host, 294 g_strerror (errno)); 292 295 293 296 camel_object_unref (tcp_stream); … … 295 298 return FALSE; 296 299 } 297 300 298 301 /* parent class connect initialization */ 299 302 /*if (CAMEL_SERVICE_CLASS (parent_class)->connect (service, ex) == FALSE) { … … 301 304 return FALSE; 302 305 }*/ 303 306 304 307 if (camel_url_get_param (service->url, "disable_extensions")) 305 308 flags |= CAMEL_POP3_ENGINE_DISABLE_EXTENSIONS; 306 309 307 310 if ((delete_days = (gchar *) camel_url_get_param(service->url,"delete_after"))) 308 311 store->delete_after = atoi(delete_days); 309 312 310 313 if (!(store->engine = camel_pop3_engine_new (tcp_stream, flags))) { 311 314 camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, 312 _("Failed to read a valid greeting from POP server %s"),313 service->url->host);315 _("Failed to read a valid greeting from POP server %s"), 316 service->url->host); 314 317 camel_object_unref (tcp_stream); 315 318 return FALSE; … … 319 322 store->engine->partial_happening = FALSE; 320 323 321 if (ssl_mode != MODE_TLS) { 324 if (!must_tls && (ssl_mode != MODE_TLS)) 325 { 322 326
