diff options
author | David Ostrovsky <david@ostrovsky.org> | 2012-11-20 22:19:51 +0100 |
---|---|---|
committer | David Ostrovsky <david@ostrovsky.org> | 2012-11-20 22:40:40 +0100 |
commit | 4b9c10e298a5285edbeb87c47303c151209abded (patch) | |
tree | 5667f56c2049b12378268ae8c07256c96a235e7d /connectivity | |
parent | d23764182ccb5d1e96774cc958a7afaaa659e114 (diff) |
fdo#57285 restore acceptsURL logic
Change-Id: Ib03c7e4a78510eb0300d78a0ae3e83ec6a17f72f
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/qa/connectivity/mork/DriverTest.cxx | 22 | ||||
-rw-r--r-- | connectivity/source/drivers/mork/MDriver.cxx | 38 |
2 files changed, 57 insertions, 3 deletions
diff --git a/connectivity/qa/connectivity/mork/DriverTest.cxx b/connectivity/qa/connectivity/mork/DriverTest.cxx index 1db1d9f7c1e0..33720ac4b2d8 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 c5998921e324..9e96464b178e 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( |