diff options
author | George Hazan <george.hazan@gmail.com> | 2023-07-13 14:04:40 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-07-13 14:04:40 +0300 |
commit | 211ddb4c49d1686760d6ce84b47121f4fa75b5df (patch) | |
tree | 9a6432fa93e909476035e733aef9a7e587cd8cd9 /src | |
parent | 4a83b52c0affc137b1eccfb6201737bf455394fb (diff) |
code simplification
Diffstat (limited to 'src')
-rw-r--r-- | src/mir_app/src/file.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/mir_app/src/file.cpp b/src/mir_app/src/file.cpp index bbc689bf3a..74e842b9a7 100644 --- a/src/mir_app/src/file.cpp +++ b/src/mir_app/src/file.cpp @@ -319,9 +319,12 @@ INT_PTR openRecDir(WPARAM, LPARAM) MEVENT Proto_RecvFile(MCONTACT hContact, PROTORECVFILE *pre) { - if (pre->fileCount == 0) + if (!pre || !pre->fileCount) return 0; + bool bSilent = (pre->dwFlags & PRFF_SILENT) != 0; + bool bSent = (pre->dwFlags & PRFF_SENT) != 0; + DB::EventInfo dbei; dbei.szModule = Proto_GetBaseAccountName(hContact); dbei.timestamp = pre->timestamp; @@ -329,27 +332,24 @@ MEVENT Proto_RecvFile(MCONTACT hContact, PROTORECVFILE *pre) dbei.szUserId = pre->szUserId; dbei.eventType = EVENTTYPE_FILE; dbei.flags = DBEF_UTF; - if (pre->dwFlags & PRFF_SENT) + if (bSent) dbei.flags |= DBEF_SENT; if (pre->dwFlags & PRFF_READ) dbei.flags |= DBEF_READ; - if ((pre->dwFlags & PRFF_UNICODE) == PRFF_UNICODE) { - CMStringW wszFiles; + CMStringW wszFiles, wszDescr; + if ((pre->dwFlags & PRFF_UNICODE) == PRFF_UNICODE) { for (int i = 0; i < pre->fileCount; i++) { if (i != 0) wszFiles.AppendChar(','); wszFiles.Append(pre->files.w[i]); } - DB::FILE_BLOB blob(wszFiles, pre->descr.w); - CallProtoService(dbei.szModule, PS_PRECREATE_OFFLINEFILE, WPARAM(&blob), pre->lParam); - blob.write(dbei); + wszDescr = pre->descr.w; } else { bool bUtf = (pre->dwFlags & PRFF_UTF) != 0; - CMStringW wszFiles; for (int i = 0; i < pre->fileCount; i++) { if (i != 0) @@ -361,13 +361,13 @@ MEVENT Proto_RecvFile(MCONTACT hContact, PROTORECVFILE *pre) wszFiles.Append(_A2T(pre->files.a[i])); } - DB::FILE_BLOB blob(wszFiles, bUtf ? Utf2T(pre->descr.a).get() : _A2T(pre->descr.a)); - CallProtoService(dbei.szModule, PS_PRECREATE_OFFLINEFILE, WPARAM(&blob), pre->lParam); - blob.write(dbei); + wszDescr = (bUtf) ? Utf2T(pre->descr.a).get() : _A2T(pre->descr.a); } - bool bSilent = (pre->dwFlags & PRFF_SILENT) != 0; - bool bSent = (pre->dwFlags & PRFF_SENT) != 0; + DB::FILE_BLOB blob(wszFiles, wszDescr); + CallProtoService(dbei.szModule, PS_PRECREATE_OFFLINEFILE, WPARAM(&blob), pre->lParam); + blob.write(dbei); + MEVENT hdbe = db_event_add(hContact, &dbei); CLISTEVENT cle = {}; |