bool HostPool::addNewHost( QString hostname, QString port, QString login, QString pass ) { QMutexLocker locker(&mPoolLock); // make sure this is really a new host if( mHostPool.find( hostname ) != mHostPool.end() ) { return false; } if( hostname.size() < 1 ) return false; int portnumber = 23; if( port.size() >= 1 ) { portnumber = port.toInt(); } int id = createNewHostID(); Host * pNewHost = new Host( portnumber, hostname, login, pass, id ); if( pNewHost == 0 ) //enough memory? { return false; } mHostPool[hostname] = pNewHost; return true; }
bool HostPool::addNewHost( QString hostname, QString port, QString login, QString pass ) { QMutexLocker locker(&mPoolLock); // make sure this is really a new host if( mHostPool.find( hostname ) != mHostPool.end() ) { return false; } if( hostname.size() < 1 ) return false; int portnumber = 23; if( port.size() >= 1 ) { portnumber = port.toInt(); } int id = createNewHostID(); QSharedPointer<Host> pNewHost( new Host( portnumber, hostname, login, pass, id ) ); mHostPool.insert( hostname, pNewHost ); return true; }