コード例 #1
0
ファイル: liteweightstgdbrw.cpp プロジェクト: ArildF/masters
//*****************************************************************************
//*****************************************************************************
HRESULT CLiteWeightStgdbRW::SaveToStorage(
    TiggerStorage *pStorage)
{
    HRESULT     hr;                     // A result.
    LPCWSTR     szName;                 // Name of the tables stream.
    IStream     *pIStreamTbl = 0;
    ULONG       cb;

    // Must call GetSaveSize to cache the streams up front.
    if (!m_cbSaveSize)
        IfFailGo(GetSaveSize(cssAccurate, 0));

    // Save the header of the data file.
    IfFailGo(pStorage->WriteHeader(m_pStreamList, 0, NULL));

    // Create a stream and save the tables.
    szName = m_bSaveCompressed ? COMPRESSED_MODEL_STREAM : ENC_MODEL_STREAM;
    IfFailGo(pStorage->CreateStream(szName,
                                    STGM_DIRECT | STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
                                    0, 0, &pIStreamTbl));
    IfFailGo(m_MiniMd.SaveTablesToStream(pIStreamTbl));
    pIStreamTbl->Release();
    pIStreamTbl = 0;

    // Save the pools.
    IfFailGo(SavePool(STRING_POOL_STREAM, pStorage, MDPoolStrings));
    IfFailGo(SavePool(US_BLOB_POOL_STREAM, pStorage, MDPoolUSBlobs));
    IfFailGo(SavePool(GUID_POOL_STREAM, pStorage, MDPoolGuids));
    IfFailGo(SavePool(BLOB_POOL_STREAM, pStorage, MDPoolBlobs));

    // Write the header to disk.
    IfFailGo(pStorage->WriteFinished(m_pStreamList, &cb));

    _ASSERTE(m_cbSaveSize == cb);

    // Let the Storage release some memory.
    pStorage->ResetBackingStore();

    m_MiniMd.SaveDone();

ErrExit:
    if (pIStreamTbl)
        pIStreamTbl->Release();
    delete m_pStreamList;
    m_pStreamList = 0;
    m_cbSaveSize = 0;
    return hr;
} // HRESULT CLiteWeightStgdbRW::SaveToStorage()
コード例 #2
0
void ContactsManager::AddContact(ContactDescriptor &pContact)
{
    mContactsMutex.lock();
    mContacts.push_back(pContact);
    if (CONF.GetSipContactsProbing())
        MEETING.SendAvailabilityProbe(pContact.GetUserStdStr(), pContact.GetHostStdStr(), pContact.GetPortStdStr(), pContact.Transport);
    mContactsMutex.unlock();
    if (mContactsModel != NULL)
        mContactsModel->UpdateView();

    SavePool();
}
コード例 #3
0
bool ContactsManager::FavorizedContact(QString pUser, QString pHost, QString pPort)
{
    mContactsMutex.lock();

    bool tFound = false;
    ContactsVector::iterator tIt, tFoundIt, tItEnd = mContacts.end();

    for (tIt = mContacts.begin(); tIt != tItEnd; tIt++)
    {
        // have we found the contact within our internal contact pool?
        if ((tIt->User == pUser) && (tIt->Host == pHost) && (tIt-> Port == pPort))
        {
            tFoundIt = tIt;
            tFound = true;
            // search for the first occurrence
            break;
        }
    }

    if (tFound)
    {
        ContactsVector tContacts;

        unsigned int tNewIndex = 1;

        // rearrange the pool of contacts and adopt the id numbers
        tFoundIt->Id = tNewIndex;
        tContacts.push_back(*tFoundIt);
        for (tIt = mContacts.begin(); tIt != tItEnd; tIt++)
        {
            if (tIt != tFoundIt)
            {
                (*tIt).Id = ++tNewIndex;
                tContacts.push_back(*tIt);
            }
        }
        mContacts = tContacts;
    }

    mContactsMutex.unlock();

    if (mContactsModel != NULL)
        mContactsModel->UpdateView();

    // automatically save the new pool data
    SavePool();

    return tFound;
}
コード例 #4
0
void ContactsManager::RemoveContact(unsigned int pId)
{
    mContactsMutex.lock();
    ContactsVector::iterator tIt, tItEnd = mContacts.end();

    for (tIt = mContacts.begin(); tIt != tItEnd; tIt++)
    {
        if (tIt->Id == pId)
        {
            mContacts.erase(tIt);

            mContactsMutex.unlock();

            if (mContactsModel != NULL)
                mContactsModel->UpdateView();

            SavePool();

            return;
        }
    }
    mContactsMutex.unlock();
}
コード例 #5
0
//*****************************************************************************
//*****************************************************************************
__checkReturn 
HRESULT CLiteWeightStgdbRW::SaveToStorage(
    TiggerStorage            *pStorage,
    MetaDataReorderingOptions reorderingOptions,
    CorProfileData           *pProfileData)
{
    HRESULT  hr;                     // A result.
    LPCWSTR  szName;                 // Name of the tables stream.
    IStream *pIStreamTbl = 0;
    UINT32   cb;
    UINT32   cbSaveSize = m_cbSaveSize;
    
    // Must call GetSaveSize to cache the streams up front.
    // Don't trust cached values in the delta case... if there was a previous call to get 
    // a non-delta size, it will be incorrect.
    if ((m_cbSaveSize == 0) || IsENCDelta(m_MiniMd.m_OptionValue.m_UpdateMode))
    {
        IfFailGo(GetSaveSize(cssAccurate, &cbSaveSize));
    }
    
    // Save the header of the data file.
    IfFailGo(pStorage->WriteHeader(m_pStreamList, 0, NULL));
    
    // If this is a minimal delta, write a stream marker 
    if (IsENCDelta(m_MiniMd.m_OptionValue.m_UpdateMode))
    {
        IfFailGo(pStorage->CreateStream(MINIMAL_MD_STREAM, 
            STGM_DIRECT | STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 
            0, 0, &pIStreamTbl));
        pIStreamTbl->Release();
        pIStreamTbl = 0;
    }
    
    if (pProfileData != NULL)
    {
        DWORD bCompressed;
        UINT32 cbHotSize;
        // Will the stream be compressed data?
        
        // Only create this additional stream if it will be non-empty
        IfFailGo(m_MiniMd.GetSaveSize(cssAccurate, &cbHotSize, &bCompressed, reorderingOptions, pProfileData));
        
        if (cbHotSize > 0)
        {
            // Create a stream and save the hot tables.
            szName = HOT_MODEL_STREAM;
            IfFailGo(pStorage->CreateStream(szName, 
                    STGM_DIRECT | STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 
                    0, 0, &pIStreamTbl));
            IfFailGo(m_MiniMd.SaveTablesToStream(pIStreamTbl, reorderingOptions, pProfileData));
            pIStreamTbl->Release();
            pIStreamTbl = 0;
        }
    }
    
    if (reorderingOptions & ReArrangeStringPool)
    {
        // Save the string pool before the tables when we do not have the string pool cache
        IfFailGo(SavePool(STRING_POOL_STREAM, pStorage, MDPoolStrings));
    }
    
    // Create a stream and save the tables.
    szName = m_bSaveCompressed ? COMPRESSED_MODEL_STREAM : ENC_MODEL_STREAM;
    IfFailGo(pStorage->CreateStream(szName, 
            STGM_DIRECT | STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 
            0, 0, &pIStreamTbl));
    IfFailGo(m_MiniMd.SaveTablesToStream(pIStreamTbl, NoReordering, NULL));
    pIStreamTbl->Release();
    pIStreamTbl = 0;
    
    // Save the pools.
    if (!(reorderingOptions & ReArrangeStringPool))
    {
        // string pool must be saved after the tables when we have the string pool cache
        IfFailGo(SavePool(STRING_POOL_STREAM, pStorage, MDPoolStrings));
    }
    IfFailGo(SavePool(US_BLOB_POOL_STREAM, pStorage, MDPoolUSBlobs));
    IfFailGo(SavePool(GUID_POOL_STREAM, pStorage, MDPoolGuids));
    IfFailGo(SavePool(BLOB_POOL_STREAM, pStorage, MDPoolBlobs));
    
    // Write the header to disk.
    OptionValue ov;
    IfFailGo(m_MiniMd.GetOption(&ov));
    
    IfFailGo(pStorage->WriteFinished(m_pStreamList, (ULONG *)&cb, IsENCDelta(ov.m_UpdateMode)));
    
    _ASSERTE(cbSaveSize == cb);
    
    // Let the Storage release some memory.
    pStorage->ResetBackingStore();
    
    IfFailGo(m_MiniMd.SaveDone());
    
ErrExit:
    if (pIStreamTbl != NULL)
        pIStreamTbl->Release();
    delete m_pStreamList;
    m_pStreamList = 0;
    m_cbSaveSize = 0;
    return hr;
} // CLiteWeightStgdbRW::SaveToStorage