Kaydet (Commit) ece4466e authored tarafından Stephan Bergmann's avatar Stephan Bergmann

loplugin:staticmethods

Change-Id: Ic93e560641f1ec1c5fc316ed126617c6d99ab5b5
üst 1394e454
......@@ -368,6 +368,18 @@ OString OEvoabVersionHelper::getUserName( EBook *pBook )
return aName;
}
namespace {
bool isBookBackend( EBookClient *pBook, const char *backendname)
{
if (!pBook)
return false;
ESource *pSource = e_client_get_source ((EClient *) pBook);
return isSourceBackend(pSource, backendname);
}
}
class OEvoabVersion36Helper : public OEvoabVersionHelper
{
private:
......@@ -416,14 +428,6 @@ public:
return pBook;
}
bool isBookBackend( EBookClient *pBook, const char *backendname)
{
if (!pBook)
return false;
ESource *pSource = e_client_get_source ((EClient *) pBook);
return isSourceBackend(pSource, backendname);
}
virtual bool isLDAP( EBook *pBook ) SAL_OVERRIDE
{
return isBookBackend(pBook, "ldap");
......@@ -490,37 +494,41 @@ protected:
}
};
class OEvoabVersion35Helper : public OEvoabVersionHelper
{
private:
GList *m_pContacts;
namespace {
ESource * findSource( const char *id )
{
ESourceList *pSourceList = NULL;
ESource * findSource( const char *id )
{
ESourceList *pSourceList = NULL;
g_return_val_if_fail (id != NULL, NULL);
g_return_val_if_fail (id != NULL, NULL);
if (!e_book_get_addressbooks (&pSourceList, NULL))
pSourceList = NULL;
if (!e_book_get_addressbooks (&pSourceList, NULL))
pSourceList = NULL;
for ( GSList *g = e_source_list_peek_groups (pSourceList); g; g = g->next)
for ( GSList *g = e_source_list_peek_groups (pSourceList); g; g = g->next)
{
for (GSList *s = e_source_group_peek_sources (E_SOURCE_GROUP (g->data)); s; s = s->next)
{
for (GSList *s = e_source_group_peek_sources (E_SOURCE_GROUP (g->data)); s; s = s->next)
{
ESource *pSource = E_SOURCE (s->data);
if (!strcmp (e_source_peek_name (pSource), id))
return pSource;
}
ESource *pSource = E_SOURCE (s->data);
if (!strcmp (e_source_peek_name (pSource), id))
return pSource;
}
return NULL;
}
return NULL;
}
bool isAuthRequired( EBook *pBook )
{
return e_source_get_property( e_book_get_source( pBook ),
"auth" ) != NULL;
}
bool isAuthRequired( EBook *pBook )
{
return e_source_get_property( e_book_get_source( pBook ),
"auth" ) != NULL;
}
}
class OEvoabVersion35Helper : public OEvoabVersionHelper
{
private:
GList *m_pContacts;
public:
OEvoabVersion35Helper()
......
......@@ -49,6 +49,26 @@ using namespace com::sun::star::container;
using namespace com::sun::star::io;
using namespace com::sun::star::util;
namespace {
EBookQuery * createTrue()
{ // Not the world's most efficient unconditional true but ...
return e_book_query_from_string("(exists \"full_name\")");
}
EBookQuery * createTest( const OUString &aColumnName,
EBookQueryTest eTest,
const OUString &aMatch )
{
OString sMatch = OUStringToOString( aMatch, RTL_TEXTENCODING_UTF8 );
OString sColumnName = OUStringToOString( aColumnName, RTL_TEXTENCODING_UTF8 );
return e_book_query_field_test( e_contact_field_id( sColumnName.getStr() ),
eTest, sMatch.getStr() );
}
}
OCommonStatement::OCommonStatement(OEvoabConnection* _pConnection)
: OCommonStatement_IBase(m_aMutex)
, ::comphelper::OPropertyContainer(OCommonStatement_IBase::rBHelper)
......@@ -152,27 +172,6 @@ void SAL_CALL OCommonStatement::close( ) throw(SQLException, RuntimeException,
dispose();
}
EBookQuery *
OCommonStatement::createTrue()
{ // Not the world's most efficient unconditional true but ...
return e_book_query_from_string("(exists \"full_name\")");
}
EBookQuery *
OCommonStatement::createTest( const OUString &aColumnName,
EBookQueryTest eTest,
const OUString &aMatch )
{
OString sMatch = OUStringToOString( aMatch, RTL_TEXTENCODING_UTF8 );
OString sColumnName = OUStringToOString( aColumnName, RTL_TEXTENCODING_UTF8 );
return e_book_query_field_test( e_contact_field_id( sColumnName.getStr() ),
eTest, sMatch.getStr() );
}
OUString OCommonStatement::impl_getColumnRefColumnName_throw( const OSQLParseNode& _rColumnRef )
{
ENSURE_OR_THROW( SQL_ISRULE( &_rColumnRef, column_ref ), "internal error: only column_refs supported as LHS" );
......
......@@ -180,10 +180,6 @@ namespace connectivity
EBookQuery *whereAnalysis( const OSQLParseNode* parseTree );
void orderByAnalysis( const OSQLParseNode* _pOrderByClause, SortDescriptor& _out_rSort );
OUString getTableName();
EBookQuery *createTrue();
EBookQuery *createTest( const OUString &aColumnName,
EBookQueryTest eTest,
const OUString &aMatch );
public:
......
......@@ -56,6 +56,82 @@ using namespace com::sun::star::sdb;
using namespace com::sun::star::frame;
using namespace connectivity::kab;
namespace {
/** throws a generic SQL exception with SQLState S1000 and error code 0
*/
void throwGenericSQLException( const OUString& _rMessage )
{
SQLException aError;
aError.Message = _rMessage;
aError.SQLState = "S1000";
aError.ErrorCode = 0;
throw aError;
}
/** throws an SQLException saying than no KDE installation was found
*/
void throwNoKdeException()
{
::connectivity::SharedResources aResources;
const OUString sError( aResources.getResourceString(
STR_NO_KDE_INST
) );
throwGenericSQLException( sError );
}
/** throws an SQLException saying that the found KDE version is too old
*/
void throwKdeTooOldException()
{
::connectivity::SharedResources aResources;
const OUString sError( aResources.getResourceStringWithSubstitution(
STR_KDE_VERSION_TOO_OLD,
"$major$",OUString::number(MIN_KDE_VERSION_MAJOR),
"$minor$",OUString::number(MIN_KDE_VERSION_MINOR)
) );
throwGenericSQLException( sError );
}
/** throws an SQLException saying that the found KDE version is too new
*/
void throwKdeTooNewException()
{
::connectivity::SharedResources aResources;
SQLException aError;
aError.Message = aResources.getResourceStringWithSubstitution(
STR_KDE_VERSION_TOO_NEW,
"$major$",OUString::number(MIN_KDE_VERSION_MAJOR),
"$minor$",OUString::number(MIN_KDE_VERSION_MINOR)
);
aError.SQLState = "S1000";
aError.ErrorCode = 0;
SQLContext aDetails;
OUStringBuffer aMessage;
aMessage.append( aResources.getResourceString(STR_KDE_VERSION_TOO_NEW_WORK_AROUND) );
aMessage.appendAscii( "Sub disableKDEMaxVersionCheck\n" );
aMessage.appendAscii( " BasicLibraries.LoadLibrary( \"Tools\" )\n" );
aMessage.appendAscii( " Dim configNode as Object\n" );
aMessage.appendAscii( " configNode = GetRegistryKeyContent( \"" );
aMessage.append( KabDriver::impl_getConfigurationSettingsPath() );
aMessage.appendAscii( "\", true )\n" );
aMessage.appendAscii( " configNode.DisableKDEMaximumVersionCheck = TRUE\n" );
aMessage.appendAscii( " configNode.commitChanges\n" );
aMessage.appendAscii( "End Sub\n" );
aDetails.Message = aMessage.makeStringAndClear();
aError.NextException <<= aDetails;
throw aError;
}
}
// = KabImplModule
......@@ -172,16 +248,16 @@ void KabImplModule::impl_unloadModule()
void KabImplModule::init()
{
if ( !impl_loadModule() )
impl_throwNoKdeException();
throwNoKdeException();
// if we're not running on a supported version, throw
KabImplModule::KDEVersionType eKDEVersion = matchKDEVersion();
if ( eKDEVersion == eTooOld )
impl_throwKdeTooOldException();
throwKdeTooOldException();
if ( ( eKDEVersion == eToNew ) && !impl_doAllowNewKDEVersion() )
impl_throwKdeTooNewException();
throwKdeTooNewException();
if ( !m_bAttemptedInitialize )
{
......@@ -221,75 +297,6 @@ bool KabImplModule::impl_doAllowNewKDEVersion()
}
void KabImplModule::impl_throwNoKdeException()
{
::connectivity::SharedResources aResources;
const OUString sError( aResources.getResourceString(
STR_NO_KDE_INST
) );
impl_throwGenericSQLException( sError );
}
void KabImplModule::impl_throwKdeTooOldException()
{
::connectivity::SharedResources aResources;
const OUString sError( aResources.getResourceStringWithSubstitution(
STR_KDE_VERSION_TOO_OLD,
"$major$",OUString::number(MIN_KDE_VERSION_MAJOR),
"$minor$",OUString::number(MIN_KDE_VERSION_MINOR)
) );
impl_throwGenericSQLException( sError );
}
void KabImplModule::impl_throwGenericSQLException( const OUString& _rMessage )
{
SQLException aError;
aError.Message = _rMessage;
aError.SQLState = "S1000";
aError.ErrorCode = 0;
throw aError;
}
void KabImplModule::impl_throwKdeTooNewException()
{
::connectivity::SharedResources aResources;
SQLException aError;
aError.Message = aResources.getResourceStringWithSubstitution(
STR_KDE_VERSION_TOO_NEW,
"$major$",OUString::number(MIN_KDE_VERSION_MAJOR),
"$minor$",OUString::number(MIN_KDE_VERSION_MINOR)
);
aError.SQLState = "S1000";
aError.ErrorCode = 0;
SQLContext aDetails;
OUStringBuffer aMessage;
aMessage.append( aResources.getResourceString(STR_KDE_VERSION_TOO_NEW_WORK_AROUND) );
aMessage.appendAscii( "Sub disableKDEMaxVersionCheck\n" );
aMessage.appendAscii( " BasicLibraries.LoadLibrary( \"Tools\" )\n" );
aMessage.appendAscii( " Dim configNode as Object\n" );
aMessage.appendAscii( " configNode = GetRegistryKeyContent( \"" );
aMessage.append( KabDriver::impl_getConfigurationSettingsPath() );
aMessage.appendAscii( "\", true )\n" );
aMessage.appendAscii( " configNode.DisableKDEMaximumVersionCheck = TRUE\n" );
aMessage.appendAscii( " configNode.commitChanges\n" );
aMessage.appendAscii( "End Sub\n" );
aDetails.Message = aMessage.makeStringAndClear();
aError.NextException <<= aDetails;
throw aError;
}
css::uno::Reference<css::sdbc::XConnection> KabImplModule::createConnection(
KabDriver * driver) const
{
......
......@@ -122,22 +122,6 @@ namespace connectivity
*/
void impl_unloadModule();
/** throws an SQLException saying than no KDE installation was found
*/
void impl_throwNoKdeException();
/** throws an SQLException saying that the found KDE version is too old
*/
void impl_throwKdeTooOldException();
/** throws an SQLException saying that the found KDE version is too new
*/
void impl_throwKdeTooNewException();
/** throws a generic SQL exception with SQLState S1000 and error code 0
*/
void impl_throwGenericSQLException( const OUString& _rMessage );
/** determines whether it's allowed to run on a too-new (not confirmed to work) version
*/
bool impl_doAllowNewKDEVersion();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment