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); } }