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

Method copyMessages

src/core/imap/MCIMAPSession.cpp:1805–1888  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1803}
1804
1805void IMAPSession::copyMessages(String * folder, IndexSet * uidSet, String * destFolder,
1806 HashMap ** pUidMapping, ErrorCode * pError)
1807{
1808 int r;
1809 struct mailimap_set * set;
1810 struct mailimap_set * src_uid;
1811 struct mailimap_set * dest_uid;
1812 uint32_t uidvalidity;
1813 clist * setList;
1814 IndexSet * uidSetResult;
1815 HashMap * uidMapping = NULL;
1816
1817 selectIfNeeded(folder, pError);
1818 if (* pError != ErrorNone)
1819 return;
1820
1821 set = setFromIndexSet(uidSet);
1822 if (clist_count(set->set_list) == 0) {
1823 mailimap_set_free(set);
1824 return;
1825 }
1826
1827 setList = splitSet(set, 10);
1828 uidSetResult = NULL;
1829
1830 for(clistiter * iter = clist_begin(setList) ; iter != NULL ; iter = clist_next(iter)) {
1831 struct mailimap_set * current_set;
1832
1833 current_set = (struct mailimap_set *) clist_content(iter);
1834
1835 r = mailimap_uidplus_uid_copy(mImap, current_set, MCUTF8(destFolder),
1836 &uidvalidity, &src_uid, &dest_uid);
1837 if (r == MAILIMAP_ERROR_STREAM) {
1838 mShouldDisconnect = true;
1839 * pError = ErrorConnection;
1840 goto release;
1841 }
1842 else if (r == MAILIMAP_ERROR_PARSE) {
1843 mShouldDisconnect = true;
1844 * pError = ErrorParse;
1845 goto release;
1846 }
1847 else if (hasError(r)) {
1848 * pError = ErrorCopy;
1849 goto release;
1850 }
1851
1852 if ((src_uid != NULL) && (dest_uid != NULL)) {
1853 if (uidMapping == NULL) {
1854 uidMapping = HashMap::hashMap();
1855 }
1856
1857 Array * srcUidsArray = arrayFromSet(src_uid);
1858 Array * destUidsArray = arrayFromSet(dest_uid);
1859
1860 for(int i = 0 ; i < srcUidsArray->count() && i < destUidsArray->count() ; i ++) {
1861 uidMapping->setObjectForKey(srcUidsArray->objectAtIndex(i), destUidsArray->objectAtIndex(i));
1862 }

Callers 1

mainMethod · 0.80

Calls 7

setFromIndexSetFunction · 0.85
splitSetFunction · 0.85
hasErrorFunction · 0.85
arrayFromSetFunction · 0.85
setObjectForKeyMethod · 0.80
objectAtIndexMethod · 0.80
countMethod · 0.45

Tested by

no test coverage detected