summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2015-04-04 14:19:11 +0300
committerTor Lillqvist <tml@collabora.com>2015-04-04 14:52:20 +0300
commit372f9bce4e28ffcc89f92dc9982ab9a5c4922994 (patch)
tree3acad0fe2d3137451a0c0dd499134f35b9b293f3 /desktop
parent648655994e8d839d9ab645f5084c906ae2cc1e75 (diff)
Presumably at least the #ifndef DISABLE_BDB2PMAP thing can be killed
Not sure if the comment in desktop/source/deployment/inc/dp_persmap.h: "should be removed for LibreOffice 4.0" refers to just the DISABLE_BDB2PMAP parts or the class and functionality as a whole. Change-Id: Ie701576efc4076ab8be02a89145b5ecfcaaebc53
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/deployment/dp_persmap.cxx104
-rw-r--r--desktop/source/deployment/inc/dp_persmap.h5
2 files changed, 0 insertions, 109 deletions
diff --git a/desktop/source/deployment/dp_persmap.cxx b/desktop/source/deployment/dp_persmap.cxx
index a8acf90d8391..7606da6d6952 100644
--- a/desktop/source/deployment/dp_persmap.cxx
+++ b/desktop/source/deployment/dp_persmap.cxx
@@ -46,9 +46,6 @@ PersistentMap::PersistentMap( OUString const & url_, bool readOnly )
, m_bToBeCreated( !readOnly )
, m_bIsDirty( false )
{
-#ifndef DISABLE_BDB2PMAP
- m_MapFileName = expandUnoRcUrl( url_ );
-#endif
open();
}
@@ -158,11 +155,6 @@ bool PersistentMap::open()
// or create later if needed
m_bToBeCreated &= (rcOpen == osl::File::E_NOENT) && !m_bIsOpen;
-#ifndef DISABLE_BDB2PMAP
- if( m_bToBeCreated )
- importFromBDB();
-#endif
-
if( !m_bIsOpen)
return m_bToBeCreated;
@@ -316,102 +308,6 @@ bool PersistentMap::erase( OString const & key, bool flush_immediately )
return true;
}
-#ifndef DISABLE_BDB2PMAP
-bool PersistentMap::importFromBDB()
-{
- if( m_bReadOnly)
- return false;
-
- // get the name of its BDB counterpart
- OUString aDBName = m_MapFileName;
- if( !aDBName.endsWith( ".pmap" ))
- return false;
- aDBName = aDBName.replaceAt( aDBName.getLength()-5, 5, ".db");
-
- // open the corresponding BDB file for reading
- osl::File aDBFile( aDBName);
- osl::File::RC rc = aDBFile.open( osl_File_OpenFlag_Read);
- if( rc != osl::File::E_None)
- return false;
- sal_uInt64 nFileSize = 0;
- if( aDBFile.getSize( nFileSize) != osl::File::E_None)
- return false;
-
- // read the BDB file
- std::vector<sal_uInt8> aRawBDB( nFileSize);
- for( sal_uInt64 nOfs = 0; nOfs < nFileSize;) {
- sal_uInt64 nBytesRead = 0;
- rc = aDBFile.read( (void*)&aRawBDB[nOfs], nFileSize - nOfs, nBytesRead);
- if( (rc != osl::File::E_None) || !nBytesRead)
- return false;
- nOfs += nBytesRead;
- }
-
- // check BDB file header for non_encrypted Hash format v4..9
- if( nFileSize < 0x0100)
- return false;
- if( aRawBDB[24] != 0) // only not-encrypted migration
- return false;
- if( aRawBDB[25] != 8) // we expect a P_HASHMETA page
- return false;
- const bool bLE = (aRawBDB[12]==0x61 && aRawBDB[13]==0x15 && aRawBDB[14]==0x06);
- const bool bBE = (aRawBDB[15]==0x61 && aRawBDB[14]==0x15 && aRawBDB[13]==0x06);
- if( bBE == bLE)
- return false;
- if( (aRawBDB[16] < 4) || (9 < aRawBDB[16])) // version
- return false;
- const sal_uInt64 nPgSize = bLE
- ? (aRawBDB[20] + (aRawBDB[21]<<8) + (aRawBDB[22]<<16) + (aRawBDB[23]<<24))
- : (aRawBDB[23] + (aRawBDB[22]<<8) + (aRawBDB[21]<<16) + (aRawBDB[20]<<24));
- const int nPgCount = nFileSize / nPgSize;
- if( nPgCount * nPgSize != nFileSize)
- return false;
-
- // find PackageManager's new_style entries
- // using a simple heuristic for BDB_Hash pages
- int nEntryCount = 0;
- for( int nPgNo = 1; nPgNo < nPgCount; ++nPgNo) {
- // parse the next _db_page
- const sal_uInt8* const pPage = &aRawBDB[ nPgNo * nPgSize];
- const sal_uInt8* const pEnd = pPage + nPgSize;
- const int nHfOffset = bLE ? (pPage[22] + (pPage[23]<<8)) : (pPage[23] + (pPage[22]<<8));
- if( nHfOffset <= 0)
- continue;
- const sal_uInt8* pCur = pPage + nHfOffset;
- // iterate through the entries
- for(; pCur < pEnd; ++pCur) {
- if( pCur[0] != 0x01)
- continue;
- // get the value-candidate
- const sal_uInt8* pVal = pCur + 1;
- while( ++pCur < pEnd)
- if( (*pCur < ' ') || ((*pCur > 0x7F) && (*pCur != 0xFF)))
- break;
- if( pCur >= pEnd)
- break;
- if( (pCur[0] != 0x01) || (pCur[1] != 0xFF))
- continue;
- const OString aVal( reinterpret_cast<char const *>(pVal), pCur - pVal);
- // get the key-candidate
- const sal_uInt8* pKey = pCur + 1;
- while( ++pCur < pEnd)
- if( (*pCur < ' ') || ((*pCur > 0x7F) && (*pCur != 0xFF)))
- break;
- if( (pCur < pEnd) && (*pCur > 0x01))
- continue;
- const OString aKey( reinterpret_cast<char const *>(pKey), pCur - pKey);
- --pCur; // prepare for next round by rewinding to end of key-string
-
- // add the key/value pair
- add( aKey, aVal);
- ++nEntryCount;
- }
- }
-
- return (nEntryCount > 0);
-}
-#endif // DISABLE_BDB2PMAP
-
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/source/deployment/inc/dp_persmap.h b/desktop/source/deployment/inc/dp_persmap.h
index 9a86fffcffc9..4f97994c8275 100644
--- a/desktop/source/deployment/inc/dp_persmap.h
+++ b/desktop/source/deployment/inc/dp_persmap.h
@@ -58,11 +58,6 @@ protected:
bool readAll();
void add( OString const & key, OString const & value );
void flush();
-
-#ifndef DISABLE_BDB2PMAP
- bool importFromBDB( void);
- OUString m_MapFileName;
-#endif
};
}