Esempio n. 1
0
KviSharedFile * KviSharedFilesManager::addSharedFile(const QString & szName, const QString & szAbsPath, const QString & szMask, int timeoutInSecs)
{
	QFileInfo inf(szAbsPath);
	if(inf.exists() && inf.isFile() && inf.isReadable() && (inf.size() > 0))
	{
		// First find the list
		KviSharedFileList * l = m_pSharedListDict->find(szName);
		if(!l)
		{
			l = new KviSharedFileList;
			l->setAutoDelete(true);
			m_pSharedListDict->replace(szName, l);
		}

		// Now insert
		KviSharedFile * o = new KviSharedFile(szName, szAbsPath, szMask, timeoutInSecs > 0 ? (((int)(time(nullptr))) + timeoutInSecs) : 0, inf.size());

		doInsert(l, o);

		if(((int)o->expireTime()) > 0)
		{
			if(!m_pCleanupTimer->isActive())
				m_pCleanupTimer->start(60000);
		}

		emit sharedFileAdded(o);

		return o;
	}
	else
	{
		qDebug("File %s unreadable: can't add offer", szAbsPath.toUtf8().data());
		return nullptr;
	}
}
Esempio n. 2
0
void KviSharedFilesManager::addSharedFile(KviSharedFile * f)
{
	// First find the list
	KviSharedFileList * l = m_pSharedListDict->find(f->name());
	if(!l)
	{
		l = new KviSharedFileList;
		l->setAutoDelete(true);
		m_pSharedListDict->replace(f->name(),l);
	}

	doInsert(l,f);

	if(((int)f->expireTime()) > 0)
	{
		if(!m_pCleanupTimer->isActive())m_pCleanupTimer->start(60000);
	}

	emit sharedFileAdded(f);
}