CallerAliasDB::CallerAliasDB( const UtlString& name ) : mDatabaseName( name ) , mTableLoaded ( true ) { // Access the shared table databse SIPDBManager* pSIPDBManager = SIPDBManager::getInstance(); mpFastDB = pSIPDBManager->getDatabase(name); // If we are the first process to attach // then we need to load the DB int users = pSIPDBManager->getNumDatabaseProcesses(name); OsSysLog::add(FAC_SUPERVISOR, PRI_DEBUG, "CallerAliasDB::_ users = %d, mTableLoaded = %d", users, mTableLoaded); if ( users == 1 || ( users > 1 && mTableLoaded == false ) ) { OsSysLog::add(FAC_DB, PRI_DEBUG, "CallerAliasDB::_ about to load"); mTableLoaded = false; // Load the file implicitly if (this->load() == OS_SUCCESS) { mTableLoaded = true; OsSysLog::add(FAC_DB, PRI_DEBUG, "CallerAliasDB::_ table successfully loaded"); } } OsSysLog::add(FAC_SUPERVISOR, PRI_DEBUG, "CallerAliasDB::_ rows in table = %d", getRowCount()); }
void DialByNameDB::getContacts ( const UtlString& digitString, ResultSet& rResultSet ) const { // This should erase the contents of the existing resultset rResultSet.destroyAll(); if ( !digitString.isNull() && (m_pFastDB != NULL) ) { // Check the TableInfo table to see whether we need to reload // the Tables from the Credential/Permission tables SIPDBManager* pSIPDBManager = SIPDBManager::getInstance(); if ( pSIPDBManager->getDatabaseChangedFlag( "credential" ) || pSIPDBManager->getDatabaseChangedFlag( "permission" ) ) { // Reload this IMDB and rese the changed flags // in the credential and permission tables this->load(); } // Thread Local Storage m_pFastDB->attach(); // Search to see if we have a Credential Row dbCursor< DialByNameRow > cursor; dbQuery query; UtlString queryString = "np_digits like '" + digitString + "%'"; query = queryString; if ( cursor.select(query) > 0 ) { do { UtlHashMap record; UtlString* np_identityValue = new UtlString ( cursor->np_identity ); UtlString* np_contactValue = new UtlString ( cursor->np_contact ); UtlString* np_digitsValue = new UtlString ( cursor->np_digits ); // Memory Leak fixes, make shallow copies of static keys UtlString* np_identityKey = new UtlString( gNp_identityKey ); UtlString* np_contactKey = new UtlString( gNp_contactKey ); UtlString* np_digitsKey = new UtlString( gNp_digitsKey ); record.insertKeyAndValue ( np_identityKey, np_identityValue ); record.insertKeyAndValue ( np_contactKey, np_contactValue ); record.insertKeyAndValue ( np_digitsKey, np_digitsValue ); rResultSet.addValue(record); } while ( cursor.next() ); } // Commit the rows to memory - multiprocess workaround m_pFastDB->detach(0); } }
void DialByNameDB::getAllRows(ResultSet& rResultSet) const { // Clear the results rResultSet.destroyAll(); // Check the TableInfo table to see whether we need to reload // the Tables from the Credential/Permission tables if ( m_pFastDB != NULL ) { SIPDBManager* pSIPDBManager = SIPDBManager::getInstance(); if ( pSIPDBManager->getDatabaseChangedFlag( "credential" ) || pSIPDBManager->getDatabaseChangedFlag( "permission" ) ) { // Reload this IMDB and reset the changed flags // in both the credential and permission tables this->load(); } // Thread Local Storage m_pFastDB->attach(); dbCursor< DialByNameRow > cursor; if ( cursor.select() > 0 ) { do { UtlHashMap record; UtlString* np_identityValue = new UtlString ( cursor->np_identity ); UtlString* np_contactValue = new UtlString ( cursor->np_contact ); UtlString* np_digitsValue = new UtlString ( cursor->np_digits ); // Memory Leak fixes, make shallow copies of static keys UtlString* np_identityKey = new UtlString( gNp_identityKey ); UtlString* np_contactKey = new UtlString( gNp_contactKey ); UtlString* np_digitsKey = new UtlString( gNp_digitsKey ); record.insertKeyAndValue ( np_identityKey, np_identityValue ); record.insertKeyAndValue ( np_contactKey, np_contactValue ); record.insertKeyAndValue ( np_digitsKey, np_digitsValue ); rResultSet.addValue(record); } while (cursor.next()); } // Commit rows to memory - multiprocess workaround m_pFastDB->detach(0); } }
DialByNameDB::DialByNameDB( const UtlString& name ) : mDatabaseName( name ) { // Access the shared table databse SIPDBManager* pSIPDBManager = SIPDBManager::getInstance(); m_pFastDB = pSIPDBManager->getDatabase(name); // If we are the first process to attach // then we need to load the DB int users = pSIPDBManager->getNumDatabaseProcesses(name); if ( users == 1 || ( users > 1 && mTableLoaded == false ) ) { mTableLoaded = false; // Load the file implicitly if (this->load() == OS_SUCCESS) { mTableLoaded = true; } } }
/* *Function Name: RegistrationDB Constructor * *Parameters: * *Description: This is a protected method as this is a singleton * *Returns: * */ RegistrationDB::RegistrationDB( const UtlString& name ) : mDatabaseName( name ) { // Access the shared table databse SIPDBManager* pSIPDBManager = SIPDBManager::getInstance(); m_pFastDB = pSIPDBManager->getDatabase(name); // If we are the first process to attach // then we need to load the DB int users = pSIPDBManager->getNumDatabaseProcesses(name); if ( users == 1 || ( users > 1 && mTableLoaded == false ) ) { OsSysLog::add(FAC_SUPERVISOR, PRI_DEBUG, "About to try to load registration db"); mTableLoaded = false; // Load the file implicitly this->load(); // the RegistrationDB is not replicated from sipXconfig, as // a result, make this table appear as being loaded regardless // of the load() result. mTableLoaded = true; } }
CredentialDB::CredentialDB ( const UtlString& name ) : mDatabaseName( name ) , mTableLoaded ( false ) { // Access the shared table database SIPDBManager* pSIPDBManager = SIPDBManager::getInstance(); m_pFastDB = pSIPDBManager->getDatabase( name ); // If we are the first process to attach // then we need to load the DB int numusers = pSIPDBManager->getNumDatabaseProcesses (name); if ( numusers == 1 || ( numusers > 1 && mTableLoaded == false ) ) { OsSysLog::add(FAC_DB, PRI_DEBUG, "CredentialDB::CredentialDB() about to load"); mTableLoaded = false; // Load the file implicitly if (this->load() == OS_SUCCESS) { mTableLoaded = true; OsSysLog::add(FAC_DB, PRI_DEBUG, "CredentialDB::CredentialDB() table successfully loaded"); } } }