Пример #1
0
void FindSubDirs(std::vector<plFileName> &dirnames, const plFileName &path)
{
    std::vector<plFileName> subdirs = plFileSystem::ListSubdirs(path);
    for (auto iter = subdirs.begin(); iter != subdirs.end(); ++iter) {
        ST::string name = iter->GetFileName();
        if (name.compare_i("system") != 0 && name.compare_i("plasma") != 0)
            dirnames.push_back(name);
    }
}
Пример #2
0
ST::string pfFilePasswordStore::GetPassword(const ST::string& username)
{
    plFileName loginDat = plFileName::Join(plFileSystem::GetInitPath(), "login.dat");
    ST::string password = ST::null;

#ifndef PLASMA_EXTERNAL_RELEASE
    // internal builds can use the local init directory
    plFileName local("init\\login.dat");
    if (plFileInfo(local).Exists())
        loginDat = local;
#endif

    hsStream* stream = plEncryptedStream::OpenEncryptedFile(loginDat, fCryptKey);
    if (stream && !stream->AtEnd())
    {
        uint32_t savedKey[4];
        stream->Read(sizeof(savedKey), savedKey);

        if (memcmp(fCryptKey, savedKey, sizeof(savedKey)) == 0 && !stream->AtEnd())
        {
            ST::string uname = stream->ReadSafeString();
            if (username.compare_i(uname) == 0) {
                password = stream->ReadSafeString();
            }
        }

        stream->Close();
        delete stream;
    }

    return password;
}
Пример #3
0
void plAgeDescInterface::INewPage()
{
    ST::string name = ST_LITERAL("New Page Name");

    // Get the name of the new age from the user
    int ret = DialogBoxParam(hInstance,
                            MAKEINTRESOURCE(IDD_AGE_NAME),
                            GetCOREInterface()->GetMAXHWnd(),
                            NewAgeDlgProc,
                            (LPARAM)&name);
    if (ret != 1)
        return;

    HWND hPages = GetDlgItem(fhDlg, IDC_PAGE_LIST);

    // Make sure this page doesn't already exist
    int count = ListBox_GetCount(hPages);
    for (int i = 0; i < count; i++)
    {
        char pageName[256];
        ListBox_GetText(hPages, i, pageName);
        if (!name.compare_i(pageName))
            return;
    }

    // Add the new page and select it
    int idx = ListBox_AddString(hPages, name.c_str());

    // Choose a new sequence suffix for it
    plAgePage *newPage = new plAgePage( name, IGetFreePageSeqSuffix( hPages ), 0 );
    ListBox_SetItemData( hPages, idx, (LPARAM)newPage );
   
    fDirty = true;
}
Пример #4
0
plLocation plPluginResManager::ICreateLocation(const ST::string& age, const ST::string& page, int32_t seqNum, bool itinerant)
{
    bool willBeReserved = age.compare_i("global") == 0;

    int32_t oldNum = seqNum;
    seqNum = VerifySeqNumber(seqNum, age, page);
    if (seqNum != oldNum)
    {
        hsAssert(false, "Conflicting page sequence number. Somebody called NameToLoc without verifying their seq# first!"); 
    }

    if (seqNum < 0)
    {
        willBeReserved = true;
        seqNum = -seqNum;
    }

    plLocation newLoc;
    if (willBeReserved)
        newLoc = plLocation::MakeReserved(seqNum);
    else
        newLoc = plLocation::MakeNormal(seqNum);

    // Flag common pages
    for (int i = 0; i < plAgeDescription::kNumCommonPages; i++)
    {
        if (page.compare(plAgeDescription::GetCommonPage(i)) == 0)
        {
            newLoc.SetFlags(plLocation::kBuiltIn);
            break;
        }
    }

    // If we have an age description file for the age we're creating a location
    // for, grab some extra flags from it
    plAgeDescription* ageDesc = plPageInfoUtils::GetAgeDesc(age.c_str());
    plAgePage* agePage = ageDesc ? ageDesc->FindPage(page.c_str()) : nil;
    if (agePage)
    {
        if (agePage->GetFlags() & plAgePage::kIsLocalOnly)
            newLoc.SetFlags(plLocation::kLocalOnly);

        if (agePage->GetFlags() & plAgePage::kIsVolatile)
            newLoc.SetFlags(plLocation::kVolatile);
    }
    if (itinerant)
        newLoc.SetFlags(plLocation::kItinerant);

    delete ageDesc;
    return newLoc;
}
Пример #5
0
// Verifies that the given sequence number belongs to the given string combo and ONLY that combo. Returns a new, unique sequenceNumber if not
int32_t plPluginResManager::VerifySeqNumber(int32_t sequenceNumber, const ST::string& age, const ST::string& page)
{
    bool negated = false, willBeReserved = age.compare_i("global") == 0;
    if (sequenceNumber < 0)
    {
        sequenceNumber = -sequenceNumber;
        willBeReserved = negated = true;
    }

    fLastVerifyError = kNoVerifyError;
    fLastVerifyPage = nil;

    plLocation toCompareTo;
    if (willBeReserved)
        plLocation::MakeReserved(sequenceNumber);
    else
        plLocation::MakeNormal(sequenceNumber);

    // Does the page already exist?
    plRegistryPageNode* pageNode = FindPage(age, page);
    if (pageNode != nil)
    {
        if (pageNode->GetPageInfo().GetLocation() == toCompareTo)
            // Right page, right sequence #. Assume we're smart enough to already have it right
            return negated ? -sequenceNumber : sequenceNumber;

        // Right page, wrong seq #...tag our last error field so we can know this later on
        fLastVerifyError = kErrRightPageWrongSeq;
    }

    // Page doesn't yet exist, check to make sure the seq # isn't used yet
    if (sequenceNumber > 0)
    {
        pageNode = FindPage(toCompareTo);
        if (pageNode == nil)
            // Safe to use
            return negated ? -sequenceNumber : sequenceNumber;
        else
        {
            // If there is no error yet, set the error to "already taken"
            if (fLastVerifyError == kNoVerifyError)
                fLastVerifyError = kErrSeqAlreadyTaken;

            fLastVerifyPage = &pageNode->GetPageInfo();
        }
    }

    // Gotta find a good sequence number to use, so keep searching until we find one
    // (but start at a good high number so we won't hopefully ever run into anybody else)
    const int kTemporarySequenceStartPrefix = 100; // can't be larger then 0xFE, so well start out at 100 for kicks
    sequenceNumber = plPageInfoUtils::CombineSeqNum(kTemporarySequenceStartPrefix, 0);

    int32_t upperLimit = 0xFEFFFF; // largest legal sequence number is a prefix of FE and a suffix of FFFF
    for(; sequenceNumber < upperLimit; sequenceNumber++)
    {
        if (willBeReserved)
            toCompareTo = plLocation::MakeReserved(sequenceNumber);
        else
            toCompareTo = plLocation::MakeNormal(sequenceNumber);

        pageNode = FindPage(toCompareTo);
        if (pageNode == nil)
            return negated ? -sequenceNumber : sequenceNumber;
    }

    hsAssert(false, "Unable to find a valid sequence number to use");
    fLastVerifyError = kErrCantFindValid;
    return 0;
}