summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authoraunsane <aunsane@gmail.com>2018-03-07 23:51:51 +0300
committeraunsane <aunsane@gmail.com>2018-03-07 23:52:18 +0300
commit7487e46fa72959aa95b86657774ec8608858427b (patch)
tree839f74d627c25334ae8652d6a4980254ceba3281 /plugins
parent777dc2174f34c2a4d4499c3d63ef8914ed9ecb81 (diff)
Import: some fixes for dbrw loader
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Import/src/dbrw/dbcontacts.cpp16
-rw-r--r--plugins/Import/src/dbrw/dbintf.cpp2
-rw-r--r--plugins/Import/src/dbrw/dbintf.h2
-rw-r--r--plugins/Import/src/dbrw/dbrw.cpp2
4 files changed, 20 insertions, 2 deletions
diff --git a/plugins/Import/src/dbrw/dbcontacts.cpp b/plugins/Import/src/dbrw/dbcontacts.cpp
index c3aac4b1bc..66ffcb61b9 100644
--- a/plugins/Import/src/dbrw/dbcontacts.cpp
+++ b/plugins/Import/src/dbrw/dbcontacts.cpp
@@ -22,6 +22,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../stdafx.h"
+void CDbxSQLite::FillContacts()
+{
+ sqlite3_stmt *st = nullptr;
+ if (sql_prepare(m_sqlite, "SELECT c.id, s.val FROM dbrw_contacts as c INNER JOIN dbrw_settings as s on s.id = c.id WHERE s.module = 'Protocol' and s.setting = 'p';", &st) != SQLITE_OK)
+ return;
+
+ while (sql_step(st) == SQLITE_ROW) {
+ MCONTACT contactID = sqlite3_column_int(st, 0);
+ const char *proto = (const char*)sqlite3_column_text(st, 1);
+ DBCachedContact *cc = m_cache->AddContactToCache(contactID);
+ cc->szProto = mir_strdup(proto);
+ }
+ sql_finalize(st);
+}
+
STDMETHODIMP_(BOOL) CDbxSQLite::IsDbContact(MCONTACT contactID)
{
DBCachedContact *cc = m_cache->GetCachedContact(contactID);
@@ -31,7 +46,6 @@ STDMETHODIMP_(BOOL) CDbxSQLite::IsDbContact(MCONTACT contactID)
STDMETHODIMP_(LONG) CDbxSQLite::GetContactCount(void)
{
int res = 0;
- sqlite3_bind_int(ctc_stmts_prep[SQL_CTC_STMT_COUNT], 1, res);
if (sql_step(ctc_stmts_prep[SQL_CTC_STMT_COUNT]) == SQLITE_ROW)
res = sqlite3_column_int(ctc_stmts_prep[SQL_CTC_STMT_COUNT], 0);
sql_reset(ctc_stmts_prep[SQL_CTC_STMT_COUNT]);
diff --git a/plugins/Import/src/dbrw/dbintf.cpp b/plugins/Import/src/dbrw/dbintf.cpp
index 73c48676d4..04e7734d42 100644
--- a/plugins/Import/src/dbrw/dbintf.cpp
+++ b/plugins/Import/src/dbrw/dbintf.cpp
@@ -61,6 +61,8 @@ int CDbxSQLite::Open(const wchar_t *profile)
sql_prepare_statements();
+ FillContacts();
+
return 0;
}
diff --git a/plugins/Import/src/dbrw/dbintf.h b/plugins/Import/src/dbrw/dbintf.h
index 801377fdde..a9a33f9f93 100644
--- a/plugins/Import/src/dbrw/dbintf.h
+++ b/plugins/Import/src/dbrw/dbintf.h
@@ -115,6 +115,8 @@ private:
int sql_prepare(sqlite3 *sql, const char *query, sqlite3_stmt **stmt);
int sql_finalize(sqlite3_stmt *stmt);
+ void FillContacts();
+
public:
CDbxSQLite();
~CDbxSQLite();
diff --git a/plugins/Import/src/dbrw/dbrw.cpp b/plugins/Import/src/dbrw/dbrw.cpp
index 0e43f23d8b..728fafe9ff 100644
--- a/plugins/Import/src/dbrw/dbrw.cpp
+++ b/plugins/Import/src/dbrw/dbrw.cpp
@@ -46,7 +46,7 @@ static int dbrw_grokHeader(const wchar_t *profile)
char *szPath = mir_utf8encodeW(profile);
rc = sqlite3_open(szPath, &sqlcheck);
- free(szPath);
+ mir_free(szPath);
if (rc == SQLITE_OK) {
sqlite3_stmt *stmt;
err = EGROKPRF_UNKHEADER;