| 780 | } |
| 781 | |
| 782 | void IMAPSession::login(ErrorCode * pError) |
| 783 | { |
| 784 | int r; |
| 785 | |
| 786 | MCLog("login"); |
| 787 | |
| 788 | MCAssert(mState == STATE_CONNECTED); |
| 789 | |
| 790 | MC_SAFE_RELEASE(mLoginResponse); |
| 791 | MC_SAFE_RELEASE(mUnparsedResponseData); |
| 792 | |
| 793 | if (mImap->imap_connection_info != NULL) { |
| 794 | if (mImap->imap_connection_info->imap_capability != NULL) { |
| 795 | mailimap_capability_data_free(mImap->imap_connection_info->imap_capability); |
| 796 | mImap->imap_connection_info->imap_capability = NULL; |
| 797 | } |
| 798 | } |
| 799 | |
| 800 | const char * utf8username; |
| 801 | const char * utf8password; |
| 802 | utf8username = MCUTF8(mUsername); |
| 803 | utf8password = MCUTF8(mPassword); |
| 804 | if (utf8username == NULL) { |
| 805 | utf8username = ""; |
| 806 | } |
| 807 | if (utf8password == NULL) { |
| 808 | utf8password = ""; |
| 809 | } |
| 810 | |
| 811 | switch (mAuthType) { |
| 812 | case 0: |
| 813 | default: |
| 814 | r = mailimap_login(mImap, utf8username, utf8password); |
| 815 | break; |
| 816 | |
| 817 | case AuthTypeSASLCRAMMD5: |
| 818 | r = mailimap_authenticate(mImap, "CRAM-MD5", |
| 819 | MCUTF8(mHostname), |
| 820 | NULL, |
| 821 | NULL, |
| 822 | utf8username, utf8username, |
| 823 | utf8password, NULL); |
| 824 | break; |
| 825 | |
| 826 | case AuthTypeSASLPlain: |
| 827 | r = mailimap_authenticate(mImap, "PLAIN", |
| 828 | MCUTF8(mHostname), |
| 829 | NULL, |
| 830 | NULL, |
| 831 | utf8username, utf8username, |
| 832 | utf8password, NULL); |
| 833 | break; |
| 834 | |
| 835 | case AuthTypeSASLGSSAPI: |
| 836 | // needs to be tested |
| 837 | r = mailimap_authenticate(mImap, "GSSAPI", |
| 838 | MCUTF8(mHostname), |
| 839 | NULL, |
nothing calls this directly
no test coverage detected