MCPcopy Create free account
hub / github.com/MailCore/mailcore2 / identity

Method identity

src/core/imap/MCIMAPSession.cpp:3669–3726  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3667}
3668
3669IMAPIdentity * IMAPSession::identity(IMAPIdentity * clientIdentity, ErrorCode * pError)
3670{
3671 connectIfNeeded(pError);
3672 if (* pError != ErrorNone)
3673 return NULL;
3674
3675 struct mailimap_id_params_list * client_identification;
3676
3677 client_identification = mailimap_id_params_list_new_empty();
3678
3679 mc_foreacharray(String, key, clientIdentity->allInfoKeys()) {
3680 MMAPString * mmap_str_name = mmap_string_new(key->UTF8Characters());
3681 MMAPString * mmap_str_value = mmap_string_new(clientIdentity->infoForKey(key)->UTF8Characters());
3682 mmap_string_ref(mmap_str_name);
3683 mmap_string_ref(mmap_str_value);
3684 mailimap_id_params_list_add_name_value(client_identification, mmap_str_name->str, mmap_str_value->str);
3685 }
3686
3687 int r;
3688 struct mailimap_id_params_list * server_identification;
3689 r = mailimap_id(mImap, client_identification, &server_identification);
3690 mailimap_id_params_list_free(client_identification);
3691 if (r == MAILIMAP_ERROR_STREAM) {
3692 mShouldDisconnect = true;
3693 * pError = ErrorConnection;
3694 return NULL;
3695 }
3696 else if (r == MAILIMAP_ERROR_PARSE) {
3697 mShouldDisconnect = true;
3698 * pError = ErrorParse;
3699 return NULL;
3700 }
3701 else if (hasError(r)) {
3702 * pError = ErrorIdentity;
3703 return NULL;
3704 }
3705
3706 IMAPIdentity * result = new IMAPIdentity();
3707
3708 clistiter * cur;
3709 for(cur = clist_begin(server_identification->idpa_list) ; cur != NULL ; cur = clist_next(cur)) {
3710 struct mailimap_id_param * param;
3711
3712 param = (struct mailimap_id_param *) clist_content(cur);
3713
3714 String * responseKey;
3715 String * responseValue;
3716 responseKey = String::stringWithUTF8Characters(param->idpa_name);
3717 responseValue = String::stringWithUTF8Characters(param->idpa_value);
3718 result->setInfoForKey(responseKey, responseValue);
3719 }
3720
3721 mailimap_id_params_list_free(server_identification);
3722 * pError = ErrorNone;
3723
3724 result->autorelease();
3725 return result;
3726}

Callers 1

mainMethod · 0.80

Calls 7

hasErrorFunction · 0.85
UTF8CharactersMethod · 0.80
mc_foreacharrayFunction · 0.70
allInfoKeysMethod · 0.45
infoForKeyMethod · 0.45
setInfoForKeyMethod · 0.45
autoreleaseMethod · 0.45

Tested by

no test coverage detected