diff options
author | George Hazan <ghazan@miranda.im> | 2023-04-11 22:03:29 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2023-04-11 22:03:29 +0300 |
commit | cd83b1c10bbe50f5aa43a8e8f7dffc5fee1d769a (patch) | |
tree | ffbe1ab12d4f89ecbf6b909efe1a1ac7669efc15 /include | |
parent | 805a76745801f9ac14a837e45ef50b9206ac54da (diff) |
DB::FILE_BLOB expansion for the offline file transfers, part I
Diffstat (limited to 'include')
-rw-r--r-- | include/m_database.h | 12 | ||||
-rw-r--r-- | include/m_db_int.h | 3 | ||||
-rw-r--r-- | include/m_protoint.h | 2 | ||||
-rw-r--r-- | include/m_protosvc.h | 17 |
4 files changed, 33 insertions, 1 deletions
diff --git a/include/m_database.h b/include/m_database.h index 59c0dacb82..c29f589495 100644 --- a/include/m_database.h +++ b/include/m_database.h @@ -369,6 +369,10 @@ EXTERN_C MIR_CORE_DLL(MEVENT) db_event_prev(MCONTACT hContact, MEVENT hDbEvent); EXTERN_C MIR_CORE_DLL(MEVENT) db_event_getById(const char *szModule, const char *szId);
+// Sets a value to the JSON field in the blob
+
+MIR_CORE_DLL(int) db_event_setJson(MEVENT hDbEvent, const char *szSetting, DBVARIANT *dbv);
+
// Updates the server ID associated with an event
// Returns 0 on success or a failure otherwise
@@ -702,6 +706,8 @@ namespace DB class MIR_APP_EXPORT FILE_BLOB : public MNonCopyable
{
ptrW m_wszFileName, m_wszDescription;
+ ptrA m_szProtoString;
+ uint32_t m_iFileSize = 0, m_iTransferred = 0;
public:
explicit FILE_BLOB(const wchar_t *pwszName, const wchar_t *pwszDescr = nullptr);
@@ -710,8 +716,14 @@ namespace DB void write(EventInfo &dbei);
+ __forceinline const char* getUrl() const { return m_szProtoString; }
__forceinline const wchar_t* getName() const { return m_wszFileName; }
__forceinline const wchar_t* getDescr() const { return m_wszDescription; }
+
+ __forceinline bool isCompleted() const { return m_iFileSize == 0 || m_iFileSize == m_iTransferred; }
+ __forceinline bool isOffline() const { return m_szProtoString != nullptr; }
+
+ __forceinline void setSize(uint32_t iSize) { m_iFileSize = m_iTransferred = iSize; }
};
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/include/m_db_int.h b/include/m_db_int.h index 7c1e5f2461..fa25ddcc26 100644 --- a/include/m_db_int.h +++ b/include/m_db_int.h @@ -132,6 +132,7 @@ interface MIR_APP_EXPORT MIDatabase STDMETHOD_(MEVENT, FindLastEvent)(MCONTACT contactID) PURE;
STDMETHOD_(MEVENT, FindNextEvent)(MCONTACT contactID, MEVENT hDbEvent) PURE;
STDMETHOD_(MEVENT, FindPrevEvent)(MCONTACT contactID, MEVENT hDbEvent) PURE;
+ STDMETHOD_(int, SetEventJson)(MEVENT hDbEvent, const char *szSetting, DBVARIANT *dbv) PURE;
STDMETHOD_(BOOL, DeleteModule)(MCONTACT contactID, LPCSTR szModule) PURE;
STDMETHOD_(BOOL, EnumModuleNames)(DBMODULEENUMPROC pFunc, void *pParam) PURE;
@@ -224,6 +225,8 @@ public: STDMETHODIMP_(BOOL) FreeVariant(DBVARIANT *dbv);
STDMETHODIMP_(BOOL) WriteContactSetting(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv) override;
+ STDMETHODIMP_(int) SetEventJson(MEVENT hDbEvent, const char *szSetting, DBVARIANT *dbv) override;
+
STDMETHODIMP_(BOOL) EnumResidentSettings(DBMODULEENUMPROC pFunc, void *pParam) override;
STDMETHODIMP_(BOOL) SetSettingResident(BOOL bIsResident, const char *pszSettingName) override;
diff --git a/include/m_protoint.h b/include/m_protoint.h index 609bbfbd92..07e461a118 100644 --- a/include/m_protoint.h +++ b/include/m_protoint.h @@ -235,7 +235,7 @@ public: virtual MWindow CreateExtendedSearchUI(MWindow owner);
virtual int RecvContacts(MCONTACT hContact, PROTORECVEVENT *);
- virtual int RecvFile(MCONTACT hContact, PROTORECVFILE *);
+ virtual MEVENT RecvFile(MCONTACT hContact, PROTORECVFILE *);
virtual MEVENT RecvMsg(MCONTACT hContact, PROTORECVEVENT *);
virtual int SendContacts(MCONTACT hContact, int flags, int nContacts, MCONTACT *hContactsList);
diff --git a/include/m_protosvc.h b/include/m_protosvc.h index 32fcc8bc7b..a49788f6e6 100644 --- a/include/m_protosvc.h +++ b/include/m_protosvc.h @@ -788,6 +788,23 @@ __forceinline INT_PTR ProtoChainRecvFile(MCONTACT hContact, PROTORECVFILE *pre) }
///////////////////////////////////////////////////////////////////////////////
+// Offline file processing
+
+#define PS_OFFLINEFILE "/OfflineFile"
+
+struct OFDTHREAD
+{
+ __forceinline OFDTHREAD(MEVENT _1, const CMStringW &_2) :
+ hDbEvent(_1),
+ wszPath(_2)
+ {}
+
+ MEVENT hDbEvent;
+ CMStringW wszPath;
+ bool bOpen = true;
+};
+
+///////////////////////////////////////////////////////////////////////////////
// Contacts have been received
// wParam = 0
// lParam = (LPARAM)(PROTORECVEVENT*)&pre
|