diff options
author | George Hazan <george.hazan@gmail.com> | 2016-02-25 13:36:37 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2016-02-25 13:36:37 +0000 |
commit | 42095fb5cb7228f9dfb94965988029fd7f47b793 (patch) | |
tree | 6185ec5d7450fb474ed80b0ce95d0d1c0e0b26a8 /plugins/Quotes/src/QuotesProviders.cpp | |
parent | 8e891173c74ceaa0964f32be247f380fd5f8bcd1 (diff) |
Quotes: major code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@16335 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Quotes/src/QuotesProviders.cpp')
-rw-r--r-- | plugins/Quotes/src/QuotesProviders.cpp | 47 |
1 files changed, 14 insertions, 33 deletions
diff --git a/plugins/Quotes/src/QuotesProviders.cpp b/plugins/Quotes/src/QuotesProviders.cpp index 1c61395d55..1edbfc7825 100644 --- a/plugins/Quotes/src/QuotesProviders.cpp +++ b/plugins/Quotes/src/QuotesProviders.cpp @@ -17,17 +17,12 @@ const CQuotesProviders::TQuotesProviders& CQuotesProviders::GetProviders()const return m_apProviders;
}
-namespace
+template<class T>void create_provider(CQuotesProviders::TQuotesProviders& apProviders)
{
- template<class T>void create_provider(CQuotesProviders::TQuotesProviders& apProviders)
- {
- CQuotesProviders::TQuotesProviderPtr pProvider(new T);
- if (pProvider->Init())
- {
- apProviders.push_back(pProvider);
- }
- }
-}
+ CQuotesProviders::TQuotesProviderPtr pProvider(new T);
+ if (pProvider->Init())
+ apProviders.push_back(pProvider);
+};
void CQuotesProviders::CreateProviders()
{
@@ -42,17 +37,13 @@ void CQuotesProviders::ClearProviders() m_apProviders.clear();
}
-namespace
+void convert_contact_settings(MCONTACT hContact)
{
- void convert_contact_settings(MCONTACT hContact)
- {
- WORD dwLogMode = db_get_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_LOG, static_cast<WORD>(lmDisabled));
- if ((dwLogMode&lmInternalHistory) || (dwLogMode&lmExternalFile))
- {
- db_set_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_CONTACT_SPEC_SETTINGS, 1);
- }
- }
+ WORD dwLogMode = db_get_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_LOG, static_cast<WORD>(lmDisabled));
+ if ((dwLogMode&lmInternalHistory) || (dwLogMode&lmExternalFile))
+ db_set_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_CONTACT_SPEC_SETTINGS, 1);
}
+
void CQuotesProviders::InitProviders()
{
CreateProviders();
@@ -60,16 +51,12 @@ void CQuotesProviders::InitProviders() const WORD nCurrentVersion = 17;
WORD nVersion = db_get_w(NULL, QUOTES_MODULE_NAME, LAST_RUN_VERSION, 1);
- for (MCONTACT hContact = db_find_first(QUOTES_MODULE_NAME); hContact; hContact = db_find_next(hContact, QUOTES_MODULE_NAME))
- {
+ for (MCONTACT hContact = db_find_first(QUOTES_MODULE_NAME); hContact; hContact = db_find_next(hContact, QUOTES_MODULE_NAME)) {
TQuotesProviderPtr pProvider = GetContactProviderPtr(hContact);
- if (pProvider)
- {
+ if (pProvider) {
pProvider->AddContact(hContact);
if (nVersion < nCurrentVersion)
- {
convert_contact_settings(hContact);
- }
}
}
@@ -80,15 +67,11 @@ CQuotesProviders::TQuotesProviderPtr CQuotesProviders::GetContactProviderPtr(MCO {
char* szProto = GetContactProto(hContact);
if (NULL == szProto || 0 != ::_stricmp(szProto, QUOTES_PROTOCOL_NAME))
- {
return TQuotesProviderPtr();
- }
tstring sProvider = Quotes_DBGetStringT(hContact, QUOTES_MODULE_NAME, DB_STR_QUOTE_PROVIDER);
if (true == sProvider.empty())
- {
return TQuotesProviderPtr();
- }
return FindProvider(sProvider);
}
@@ -96,12 +79,10 @@ CQuotesProviders::TQuotesProviderPtr CQuotesProviders::GetContactProviderPtr(MCO CQuotesProviders::TQuotesProviderPtr CQuotesProviders::FindProvider(const tstring& rsName)const
{
TQuotesProviderPtr pResult;
- for (TQuotesProviders::const_iterator i = m_apProviders.begin(); i != m_apProviders.end(); ++i)
- {
+ for (TQuotesProviders::const_iterator i = m_apProviders.begin(); i != m_apProviders.end(); ++i) {
const TQuotesProviderPtr& pProvider = *i;
const IQuotesProvider::CProviderInfo& rInfo = pProvider->GetInfo();
- if (0 == ::quotes_stricmp(rsName.c_str(), rInfo.m_sName.c_str()))
- {
+ if (0 == ::quotes_stricmp(rsName.c_str(), rInfo.m_sName.c_str())) {
pResult = pProvider;
break;
}
|