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

Method storeLabels

src/core/imap/MCIMAPSession.cpp:4008–4083  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4006}
4007
4008void IMAPSession::storeLabels(String * folder, bool identifier_is_uid, IndexSet * identifiers, IMAPStoreFlagsRequestKind kind, Array * labels, ErrorCode * pError)
4009{
4010 struct mailimap_set * imap_set;
4011 struct mailimap_msg_att_xgmlabels * xgmlabels;
4012 int r;
4013 clist * setList;
4014
4015 selectIfNeeded(folder, pError);
4016 if (* pError != ErrorNone)
4017 return;
4018
4019 imap_set = setFromIndexSet(identifiers);
4020 if (clist_count(imap_set->set_list) == 0) {
4021 mailimap_set_free(imap_set);
4022 return;
4023 }
4024
4025 setList = splitSet(imap_set, 10);
4026
4027 xgmlabels = mailimap_msg_att_xgmlabels_new_empty();
4028 for(unsigned int i = 0 ; i < labels->count() ; i ++) {
4029 String * label = (String *) labels->objectAtIndex(i);
4030 mailimap_msg_att_xgmlabels_add(xgmlabels, strdup(label->UTF8Characters()));
4031 }
4032
4033 for(clistiter * iter = clist_begin(setList) ; iter != NULL ; iter = clist_next(iter)) {
4034 struct mailimap_set * current_set;
4035 int fl_sign;
4036
4037 current_set = (struct mailimap_set *) clist_content(iter);
4038
4039 switch (kind) {
4040 case IMAPStoreFlagsRequestKindRemove:
4041 fl_sign = -1;
4042 break;
4043 case IMAPStoreFlagsRequestKindAdd:
4044 fl_sign = 1;
4045 break;
4046 case IMAPStoreFlagsRequestKindSet:
4047 fl_sign = 0;
4048 break;
4049 }
4050 if (identifier_is_uid) {
4051 r = mailimap_uid_store_xgmlabels(mImap, current_set, fl_sign, 1, xgmlabels);
4052 }
4053 else {
4054 r = mailimap_store_xgmlabels(mImap, current_set, fl_sign, 1, xgmlabels);
4055 }
4056 if (r == MAILIMAP_ERROR_STREAM) {
4057 mShouldDisconnect = true;
4058 * pError = ErrorConnection;
4059 goto release;
4060 }
4061 else if (r == MAILIMAP_ERROR_PARSE) {
4062 mShouldDisconnect = true;
4063 * pError = ErrorParse;
4064 goto release;
4065 }

Callers

nothing calls this directly

Calls 6

setFromIndexSetFunction · 0.85
splitSetFunction · 0.85
hasErrorFunction · 0.85
objectAtIndexMethod · 0.80
UTF8CharactersMethod · 0.80
countMethod · 0.45

Tested by

no test coverage detected