ZipArchiveImpl::~ZipArchiveImpl() { int r = ZIP_OK; if (m_File) r = zipClose(m_File, ":)"); m_File = nullptr; m_Info = ArchiveInfo(); }
/** * Populate the user list through one AB container. * When this method completes, the userlist will be available for all users * from the passed container that should have one or more archives attached to * their primary store. * @param[in] lpContainer The addressbook container to process. */ HRESULT ArchiveStateCollector::PopulateFromContainer(LPABCONT lpContainer) { HRESULT hr = hrSuccess; SPropValue sPropObjType; SPropValue sPropDispType; SRestrictionPtr ptrRestriction; MAPITablePtr ptrTable; SRowSetPtr ptrRows; SizedSPropTagArray(4, sptaUserProps) = {4, {PR_ENTRYID, PR_ACCOUNT, PR_EC_ARCHIVE_SERVERS, PR_EC_ARCHIVE_COUPLINGS}}; enum {IDX_ENTRYID, IDX_ACCOUNT, IDX_EC_ARCHIVE_SERVERS, IDX_EC_ARCHIVE_COUPLINGS}; ECAndRestriction resFilter( ECPropertyRestriction(RELOP_EQ, PR_OBJECT_TYPE, &sPropObjType, ECRestriction::Cheap) + ECPropertyRestriction(RELOP_EQ, PR_DISPLAY_TYPE, &sPropDispType, ECRestriction::Cheap) + ECOrRestriction( ECExistRestriction(PR_EC_ARCHIVE_SERVERS) + ECExistRestriction(PR_EC_ARCHIVE_COUPLINGS) ) ); sPropObjType.ulPropTag = PR_OBJECT_TYPE; sPropObjType.Value.ul = MAPI_MAILUSER; sPropDispType.ulPropTag = PR_DISPLAY_TYPE; sPropDispType.Value.ul = DT_MAILUSER;; hr = resFilter.CreateMAPIRestriction(&ptrRestriction, ECRestriction::Cheap); if (hr != hrSuccess) goto exit; hr = lpContainer->GetContentsTable(0, &ptrTable); if (hr != hrSuccess) goto exit; hr = ptrTable->SetColumns((LPSPropTagArray)&sptaUserProps, TBL_BATCH); if (hr != hrSuccess) goto exit; hr = ptrTable->Restrict(ptrRestriction, TBL_BATCH); if (hr != hrSuccess) goto exit; while (true) { hr = ptrTable->QueryRows(50, 0, &ptrRows); if (hr != hrSuccess) goto exit; if (ptrRows.size() == 0) break; for (SRowSetPtr::size_type i = 0; i < ptrRows.size(); ++i) { ArchiveInfoMap::iterator iterator; if (ptrRows[i].lpProps[IDX_ENTRYID].ulPropTag != PR_ENTRYID) { m_lpLogger->Log(EC_LOGLEVEL_ERROR, "Unable to get entryid from address list. hr=0x%08x", ptrRows[i].lpProps[IDX_ACCOUNT].Value.err); continue; } if (ptrRows[i].lpProps[IDX_ACCOUNT].ulPropTag != PR_ACCOUNT) { m_lpLogger->Log(EC_LOGLEVEL_ERROR, "Unable to get username from address list. hr=0x%08x", ptrRows[i].lpProps[IDX_ACCOUNT].Value.err); continue; } m_lpLogger->Log(EC_LOGLEVEL_DEBUG, "Inserting row for user '" TSTRING_PRINTF "'", ptrRows[i].lpProps[IDX_ACCOUNT].Value.LPSZ); iterator = m_mapArchiveInfo.insert(std::make_pair(abentryid_t(ptrRows[i].lpProps[IDX_ENTRYID].Value.bin), ArchiveInfo())).first; iterator->second.userName.assign(ptrRows[i].lpProps[IDX_ACCOUNT].Value.LPSZ); if (ptrRows[i].lpProps[IDX_EC_ARCHIVE_SERVERS].ulPropTag == PR_EC_ARCHIVE_SERVERS) { m_lpLogger->Log(EC_LOGLEVEL_DEBUG, "Adding %u archive server(s)", ptrRows[i].lpProps[IDX_EC_ARCHIVE_SERVERS].Value.MVSZ.cValues); for (ULONG j = 0; j < ptrRows[i].lpProps[IDX_EC_ARCHIVE_SERVERS].Value.MVSZ.cValues; ++j) iterator->second.lstServers.push_back(ptrRows[i].lpProps[IDX_EC_ARCHIVE_SERVERS].Value.MVSZ.LPPSZ[j]); } if (ptrRows[i].lpProps[IDX_EC_ARCHIVE_COUPLINGS].ulPropTag == PR_EC_ARCHIVE_COUPLINGS) { m_lpLogger->Log(EC_LOGLEVEL_DEBUG, "Adding %u archive coupling(s)", ptrRows[i].lpProps[IDX_EC_ARCHIVE_COUPLINGS].Value.MVSZ.cValues); for (ULONG j = 0; j < ptrRows[i].lpProps[IDX_EC_ARCHIVE_COUPLINGS].Value.MVSZ.cValues; ++j) iterator->second.lstCouplings.push_back(ptrRows[i].lpProps[IDX_EC_ARCHIVE_COUPLINGS].Value.MVSZ.LPPSZ[j]); } } } exit: return hr; }