int PackageManager::doSearch(Common::ArchiveMemberList &list, const Common::String &filter, const Common::String &path, uint typeFilter) { Common::String normalizedFilter = normalizePath(filter, _currentDirectory); int num = 0; if (path.size() > 0) warning("STUB: PackageManager::doSearch(<%s>, <%s>, %d)", filter.c_str(), path.c_str(), typeFilter); // Loop through checking each archive Common::List<ArchiveEntry *>::iterator i; for (i = _archiveList.begin(); i != _archiveList.end(); ++i) { Common::ArchiveMemberList memberList; if (!normalizedFilter.hasPrefix((*i)->_mountPath)) { // The mount path is in different subtree. Skipping continue; } // Construct relative path Common::String resFilter(&normalizedFilter.c_str()[(*i)->_mountPath.size()]); if ((*i)->archive->listMatchingMembers(memberList, resFilter) == 0) continue; // Create a list of the matching names for (Common::ArchiveMemberList::iterator it = memberList.begin(); it != memberList.end(); ++it) { if (((typeFilter & PackageManager::FT_DIRECTORY) && (*it)->getName().hasSuffix("/")) || ((typeFilter & PackageManager::FT_FILE) && !(*it)->getName().hasSuffix("/"))) { // Do not add duplicate files bool found = false; for (Common::ArchiveMemberList::iterator it1 = list.begin(); it1 != list.end(); ++it1) { if ((*it1)->getName() == (*it)->getName()) { found = true; break; } } if (!found) list.push_back(*it); num++; } } } return num; }
/** * 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; }