예제 #1
0
Location * LocationsFactory::setNewPath(const QString& uPath, const QString& authUser, const QString& passwd, bool savePassword)
{
    storeValidFileInfo(0);
    CleanUrl url(uPath);
    m_lastUrlNeedsAuthentication = false;
    NetAuthenticationData authData(authUser, passwd);
    if (authData.isEmpty() && url.hasAuthenticationData())
    {
        authData.user      = url.user();
        authData.password  = url.password();
    }
    Location *location = parse(url.cleanUrl());
    if (location)
    {
        DirItemInfo *item = validateCurrentUrl(location,authData);
        if (item)
        {
            //now if there is Authentication Data
            //at this point item is ready and authentication if necessary worked
            if (item && !authData.isEmpty())
            {
                m_authDataStore->store(item->authenticationPath(),
                                       authData.user,
                                       authData.password,
                                       savePassword);
            }
            //isContentReadable() must already carry execution permission
            if (item->isValid() && item->isBrowsable() && item->isContentReadable())
            {
                location->setInfoItem(item);
                if (location != m_curLoc)
                {
                    if (m_curLoc)
                    {
                        m_curLoc->stopWorking();
                    }
                    emit locationChanged(m_curLoc, location);
                    location->startWorking();
                    m_curLoc = location;
                }
            }
            else
            {
                storeValidFileInfo(item);
                location = 0;
            }
        }
        else
        {   // not valid
            location = 0;
        }
    }
#if DEBUG_MESSAGES
    qDebug() << Q_FUNC_INFO << "input path:" << uPath  << "location result:" << location;
#endif
    return location;
}
예제 #2
0
bool DiskLocation::becomeParent()
{
    bool ret = false;
    if (m_info && !m_info->isRoot())
    {
        DirItemInfo *other = new DirItemInfo(m_info->absolutePath());
        if (other->isValid())
        {
            delete m_info;
            m_info = other;
            ret = true;
        }
        else
        {
            delete other;
        }
    }
    return ret;
}
예제 #3
0
DirItemInfo * DiskLocation::validateUrlPath(const QString& uPath)
{
    QString myPath(uPath);
    QFileInfo tmpUrl(uPath);
    if (tmpUrl.isRelative() && m_info)
    {
        tmpUrl.setFile(m_info->absoluteFilePath(), uPath);
        myPath  =  tmpUrl.absoluteFilePath();
    }
#if DEBUG_MESSAGES
    qDebug() << Q_FUNC_INFO << "path:" << myPath;
#endif
    DirItemInfo * item = new DirItemInfo(myPath);
    if (!item->isValid() || !item->exists() || !item->isContentReadable())
    {
        delete item;
        item = 0;
    }
    return item;
}