KviSharedFile * KviSharedFilesManager::lookupSharedFile(const QString & szName, KviIrcMask * mask, unsigned int uFileSize) { KviSharedFileList * l = m_pSharedListDict->find(szName); if(!l) return nullptr; for(KviSharedFile * o = l->first(); o; o = l->next()) { bool bMatch; if(mask) { KviIrcMask umask(o->userMask()); bMatch = mask->matchedBy(umask); } else bMatch = KviQString::equalCS(o->userMask(), "*!*@*"); if(bMatch) { if(uFileSize > 0) { if(uFileSize == o->fileSize()) return o; } else return o; } } return nullptr; }
bool KviSharedFilesManager::removeSharedFile(const QString &szName,KviSharedFile * off) { KviSharedFileList * l = m_pSharedListDict->find(szName); if(!l)return false; for(KviSharedFile * o = l->first();o;o = l->next()) { if(off == o) { QString save = szName; // <-- szName MAY Be a pointer to o->name() l->removeRef(o); if(l->count() == 0)m_pSharedListDict->remove(save); emit sharedFileRemoved(off); return true; } } return false; }
bool KviSharedFilesManager::removeSharedFile(const QString &szName,const QString &szMask,unsigned int uFileSize) { KviSharedFileList * l = m_pSharedListDict->find(szName); if(!l)return false; for(KviSharedFile * o = l->first();o;o = l->next()) { if(KviQString::equalCI(szMask,o->userMask())) { bool bMatch = uFileSize > 0 ? uFileSize == o->fileSize() : true; if(bMatch) { QString save = szName; // <-- szName MAY Be a pointer to o->name() l->removeRef(o); if(l->count() == 0)m_pSharedListDict->remove(save); emit sharedFileRemoved(o); return true; } } } return false; }