summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Pamment <apamment@yandex.com>2018-12-24 11:42:09 +1000
committerAndrew Pamment <apamment@yandex.com>2018-12-24 11:42:09 +1000
commit16689e094cfc7ac68431e261f3d5b78bf00925fd (patch)
tree282b94bcdaa986aa161969fd17b07191f85f4605
parent3a184193baba843345d808121e01d608a2950c28 (diff)
fix personal scan with sq3 bases
-rw-r--r--src/msglib/msglib_sq3.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/msglib/msglib_sq3.c b/src/msglib/msglib_sq3.c
index 4e07500..be2177e 100644
--- a/src/msglib/msglib_sq3.c
+++ b/src/msglib/msglib_sq3.c
@@ -59,9 +59,9 @@ struct msg_headers *sq3_read_message_headers(int msgconf, int msgarea, struct us
int z;
int j;
int k;
-
+ char buffer[256];
const char *sql = "SELECT id, sender, recipient, subject, date, mattribs, daddress, oaddress, msgid, replyid FROM msgs";
-
+ const char *sql2 = "SELECT id, sender, recipient, subject, date, mattribs, daddress, oaddress, msgid, replyid FROM msgs WHERE recipient = ? or recipient = ? COLLATE NOCASE";
sqlite3 *dbase;
sqlite3_stmt *res;
@@ -76,10 +76,21 @@ struct msg_headers *sq3_read_message_headers(int msgconf, int msgarea, struct us
return NULL;
}
- if (sqlite3_prepare_v2(dbase, sql, strlen(sql), &res, NULL) != SQLITE_OK) {
- dolog("Error prepareing sql line 75");
- sqlite3_close(dbase);
- return NULL;
+ if (!personal) {
+ if (sqlite3_prepare_v2(dbase, sql, strlen(sql), &res, NULL) != SQLITE_OK) {
+ dolog("Error prepareing sql line 81");
+ sqlite3_close(dbase);
+ return NULL;
+ }
+ } else {
+ snprintf(buffer, sizeof buffer, "%s %s", user->firstname, user->lastname);
+ if (sqlite3_prepare_v2(dbase, sql2, strlen(sql2), &res, NULL) != SQLITE_OK) {
+ dolog("Error prepareing sql line 88");
+ sqlite3_close(dbase);
+ return NULL;
+ }
+ sqlite3_bind_text(res, 1, user->loginname, -1, 0);
+ sqlite3_bind_text(res, 2, buffer, -1, 0);
}
init_ptr_vector(&vec);
@@ -130,7 +141,7 @@ int sq3_message_lastread(const char *db, int uid) {
}
if (sqlite3_prepare_v2(dbase, sql, strlen(sql), &res, NULL) != SQLITE_OK) {
- dolog("Error prepareing sql line 127");
+ dolog("Error prepareing sql line 144");
sqlite3_close(dbase);
return -1;
}
@@ -166,7 +177,7 @@ void sq3_write_lasthighread(const char *db, struct user_record *user, int lastre
if (lr == -1) {
if (sqlite3_prepare_v2(dbase, sql2, strlen(sql2), &res, NULL) != SQLITE_OK) {
- dolog("Error prepareing sql line 163");
+ dolog("Error prepareing sql line 180");
sqlite3_close(dbase);
return;
}
@@ -174,7 +185,7 @@ void sq3_write_lasthighread(const char *db, struct user_record *user, int lastre
sqlite3_bind_int(res, 2, highread);
} else {
if (sqlite3_prepare_v2(dbase, sql1, strlen(sql2), &res, NULL) != SQLITE_OK) {
- dolog("Error prepareing sql line 171");
+ dolog("Error prepareing sql line 188");
sqlite3_close(dbase);
return;
}
@@ -300,7 +311,7 @@ int sq3_write_message(struct msg_base_t *mb, const char *to, const char *from, c
}
if (sqlite3_prepare_v2(dbase, sql, strlen(sql), &res, NULL) != SQLITE_OK) {
- dolog("Error prepareing sql line 293");
+ dolog("Error prepareing sql line 314");
sqlite3_close(dbase);
free(oaddress);
free(daddress);
@@ -359,7 +370,7 @@ struct msg_t *sq3_message_header(const char *db, int id) {
}
if (sqlite3_prepare_v2(dbase, sql, strlen(sql), &res, NULL) != SQLITE_OK) {
- dolog("Error prepareing sql line 352");
+ dolog("Error prepareing sql line 373");
sqlite3_close(dbase);
return NULL;
}
@@ -399,7 +410,7 @@ char *sq3_fetch_body(const char *db, int mid) {
}
if (sqlite3_prepare_v2(dbase, sql, strlen(sql), &res, NULL) != SQLITE_OK) {
- dolog("Error prepareing sql line 391");
+ dolog("Error prepareing sql line 413");
sqlite3_close(dbase);
return NULL;
}