diff options
author | George Hazan <ghazan@miranda.im> | 2019-08-13 11:39:01 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-08-13 11:39:01 +0300 |
commit | 985c61c624c7304783266c9f79e602f26f2887fd (patch) | |
tree | d564daacf70417f2756137b6b86a3ee33025090e /protocols | |
parent | 23f1148da6fd87d759b69d6f3865384672f78974 (diff) |
useless checks removed
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp | 23 | ||||
-rw-r--r-- | protocols/Dummy/src/dummy_proto.cpp | 25 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/core.cpp | 12 | ||||
-rw-r--r-- | protocols/MSN/src/msn_contact.cpp | 3 | ||||
-rw-r--r-- | protocols/Sametime/src/userlist.cpp | 10 |
5 files changed, 22 insertions, 51 deletions
diff --git a/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp b/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp index c35877dc4c..3c8bdbfed6 100644 --- a/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp +++ b/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp @@ -609,22 +609,15 @@ void CCurrencyRatesProviderBase::WriteContactRate(MCONTACT hContact, double dRat MCONTACT CCurrencyRatesProviderBase::CreateNewContact(const tstring& rsName) { MCONTACT hContact = db_add_contact(); - if (hContact) { - if (0 == Proto_AddToContact(hContact, CURRENCYRATES_PROTOCOL_NAME)) { - tstring sProvName = GetInfo().m_sName; - db_set_ws(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_PROVIDER, sProvName.c_str()); - db_set_ws(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_SYMBOL, rsName.c_str()); - db_set_ws(hContact, LIST_MODULE_NAME, CONTACT_LIST_NAME, rsName.c_str()); - - mir_cslock lck(m_cs); - m_aContacts.push_back(hContact); - } - else { - db_delete_contact(hContact); - hContact = NULL; - } - } + Proto_AddToContact(hContact, CURRENCYRATES_PROTOCOL_NAME); + tstring sProvName = GetInfo().m_sName; + db_set_ws(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_PROVIDER, sProvName.c_str()); + db_set_ws(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_SYMBOL, rsName.c_str()); + db_set_ws(hContact, LIST_MODULE_NAME, CONTACT_LIST_NAME, rsName.c_str()); + + mir_cslock lck(m_cs); + m_aContacts.push_back(hContact); return hContact; } diff --git a/protocols/Dummy/src/dummy_proto.cpp b/protocols/Dummy/src/dummy_proto.cpp index 0911ce15a5..3c32087d23 100644 --- a/protocols/Dummy/src/dummy_proto.cpp +++ b/protocols/Dummy/src/dummy_proto.cpp @@ -151,23 +151,18 @@ MCONTACT CDummyProto::AddToList(int flags, PROTOSEARCHRESULT* psr) return NULL; MCONTACT hContact = db_add_contact(); - if (hContact && Proto_AddToContact(hContact, m_szModuleName) != 0) { - db_delete_contact(hContact); - hContact = NULL; - } + Proto_AddToContact(hContact, m_szModuleName); - if (hContact) { - if (flags & PALF_TEMPORARY) { - db_set_b(hContact, "CList", "Hidden", 1); - db_set_b(hContact, "CList", "NotOnList", 1); - } - else if (db_get_b(hContact, "CList", "NotOnList", 0)) { - db_unset(hContact, "CList", "Hidden"); - db_unset(hContact, "CList", "NotOnList"); - } - setWString(hContact, uniqueIdSetting, psr->id.w); - setWString(hContact, "Nick", psr->id.w); + if (flags & PALF_TEMPORARY) { + db_set_b(hContact, "CList", "Hidden", 1); + db_set_b(hContact, "CList", "NotOnList", 1); + } + else if (db_get_b(hContact, "CList", "NotOnList", 0)) { + db_unset(hContact, "CList", "Hidden"); + db_unset(hContact, "CList", "NotOnList"); } + setWString(hContact, uniqueIdSetting, psr->id.w); + setWString(hContact, "Nick", psr->id.w); return hContact; } diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp index d1d74dbc57..d6a16a9493 100644 --- a/protocols/Gadu-Gadu/src/core.cpp +++ b/protocols/Gadu-Gadu/src/core.cpp @@ -1469,17 +1469,7 @@ MCONTACT GaduProto::getcontact(uin_t uin, int create, int inlist, wchar_t *szNic return NULL;
MCONTACT hContact = db_add_contact();
- if (!hContact) {
- debugLogW(L"getcontact(): Failed to create Gadu-Gadu contact %s", szNick);
- return NULL;
- }
-
- if (Proto_AddToContact(hContact, m_szModuleName) != 0) {
- // For some reason we failed to register the protocol for this contact
- db_delete_contact(hContact);
- debugLogA("getcontact(): Failed to register GG contact %d", uin);
- return NULL;
- }
+ Proto_AddToContact(hContact, m_szModuleName);
debugLogA("getcontact(): Added buddy: %d", uin);
if (!inlist)
diff --git a/protocols/MSN/src/msn_contact.cpp b/protocols/MSN/src/msn_contact.cpp index 39bdbd1ac2..61e1cbb5fb 100644 --- a/protocols/MSN/src/msn_contact.cpp +++ b/protocols/MSN/src/msn_contact.cpp @@ -38,7 +38,8 @@ MCONTACT CMsnProto::MSN_HContactFromEmail(const char* wlid, const char* msnNick, int netId = (msc && msc->netId)?msc->netId:(szNet?atoi(szNet):NETID_MSN);
hContact = db_add_contact();
Proto_AddToContact(hContact, m_szModuleName);
- if (netId != NETID_SKYPE) setString(hContact, "e-mail", szEmail);
+ if (netId != NETID_SKYPE)
+ setString(hContact, "e-mail", szEmail);
setStringUtf(hContact, "Nick", msnNick ? msnNick : szEmail);
setWord(hContact, "netId", netId);
setString(hContact, "wlid", szEmail);
diff --git a/protocols/Sametime/src/userlist.cpp b/protocols/Sametime/src/userlist.cpp index a16ed8d103..8b892d85d5 100644 --- a/protocols/Sametime/src/userlist.cpp +++ b/protocols/Sametime/src/userlist.cpp @@ -65,15 +65,7 @@ MCONTACT CSametimeProto::AddContact(mwSametimeUser* user, bool temporary) bool new_contact = false;
if (!hContact) {
hContact = db_add_contact();
- if (!hContact) {
- debugLogW(L"AddContact(): Failed to create Sametime contact");
- return NULL; ///TODO error handling
- }
- if (Proto_AddToContact(hContact, m_szModuleName) != 0) {
- db_delete_contact(hContact);
- debugLogW(L"AddContact(): Failed to register Sametime contact");
- return NULL; ///TODO error handling
- }
+ Proto_AddToContact(hContact, m_szModuleName);
new_contact = true;
}
else if (!temporary) {
|