connectivity/qa/connectivity/mork/DriverTest.cxx | 22 +++++++++++++ connectivity/source/drivers/mork/MDriver.cxx | 38 +++++++++++++++++++++-- 2 files changed, 57 insertions(+), 3 deletions(-)
New commits: commit 4b9c10e298a5285edbeb87c47303c151209abded Author: David Ostrovsky <da...@ostrovsky.org> Date: Tue Nov 20 22:19:51 2012 +0100 fdo#57285 restore acceptsURL logic Change-Id: Ib03c7e4a78510eb0300d78a0ae3e83ec6a17f72f diff --git a/connectivity/qa/connectivity/mork/DriverTest.cxx b/connectivity/qa/connectivity/mork/DriverTest.cxx index 1db1d9f..33720ac 100644 --- a/connectivity/qa/connectivity/mork/DriverTest.cxx +++ b/connectivity/qa/connectivity/mork/DriverTest.cxx @@ -27,6 +27,7 @@ class MorkDriverTest: public test::BootstrapFixture public: MorkDriverTest() : test::BootstrapFixture(false, false) {}; + void checkAcceptsURL(Reference< XDriver> xDriver, const char* url, bool expected); void test_metadata(); void test_select_default_all(); void test_select_list_table_joe_doe_5(); @@ -46,6 +47,15 @@ private: Reference<XConnection> m_xConnection; }; +void MorkDriverTest::checkAcceptsURL(Reference< XDriver> xDriver, const char* url, bool expected) +{ + sal_Bool res = xDriver->acceptsURL(OUString::createFromAscii(url)); + if (res != expected) + { + CPPUNIT_ASSERT_MESSAGE("wrong URL outcome!", true); + } +} + void MorkDriverTest::setUp() { test::BootstrapFixture::setUp(); @@ -64,6 +74,18 @@ void MorkDriverTest::setUp() CPPUNIT_ASSERT_MESSAGE("cannot connect to mork driver!", xDriver.is()); } + // bad + checkAcceptsURL(xDriver, "sdbc:address:macab", false); + checkAcceptsURL(xDriver, "sdbc:mozab:ldap:", false); + checkAcceptsURL(xDriver, "sdbc:mozab:outlook:", false); + checkAcceptsURL(xDriver, "sdbc:mozab:outlookexp:", false); + + // good + checkAcceptsURL(xDriver, "sdbc:mozab:mozilla:", true); + checkAcceptsURL(xDriver, "sdbc:mozab:thunderbird:", true); + checkAcceptsURL(xDriver, "sdbc:address:mozilla:", true); + checkAcceptsURL(xDriver, "sdbc:address:thunderbird:", true); + m_xConnection = xDriver->connect(url, info); if (!m_xConnection.is()) { diff --git a/connectivity/source/drivers/mork/MDriver.cxx b/connectivity/source/drivers/mork/MDriver.cxx index c599892..9e96464 100644 --- a/connectivity/source/drivers/mork/MDriver.cxx +++ b/connectivity/source/drivers/mork/MDriver.cxx @@ -95,10 +95,42 @@ sal_Bool MorkDriver::acceptsURL(rtl::OUString const & url) throw (css::sdbc::SQLException, css::uno::RuntimeException) { SAL_INFO("connectivity.mork", "=> MorkDriver::acceptsURL()" ); + // Skip 'sdbc:mozab: part of URL + // + sal_Int32 nLen = url.indexOf(':'); + nLen = url.indexOf(':',nLen+1); + OUString aAddrbookURI(url.copy(nLen+1)); + // Get Scheme + nLen = aAddrbookURI.indexOf(':'); + OUString aAddrbookScheme; + if ( nLen == -1 ) + { + // There isn't any subschema: - but could be just subschema + if ( !aAddrbookURI.isEmpty() ) + { + aAddrbookScheme= aAddrbookURI; + } + else if(url == OUString("sdbc:address:") ) + { + return false; + } + else + { + return false; + } + } + else + { + aAddrbookScheme = aAddrbookURI.copy(0, nLen); + } - //... TODO - (void) url; // avoid warnings - return true; + if ((aAddrbookScheme.compareToAscii( "thunderbird" ) == 0) || + (aAddrbookScheme.compareToAscii( "mozilla" ) == 0)) + { + return true; + } + + return false; } css::uno::Sequence< css::sdbc::DriverPropertyInfo > MorkDriver::getPropertyInfo( _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits