diff options
author | George Hazan <ghazan@miranda.im> | 2017-12-29 17:27:00 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-12-29 17:27:08 +0300 |
commit | f16cf071e51f4768f20692c99414cb39521fa413 (patch) | |
tree | 7dd3cc512fe65fdd546f7753937261c518e5008c /src | |
parent | 939048b7ebce6a70c8e243fec36983de7d931e8b (diff) |
PROTO_INTERFACE::setAllContactStatuses - common code moved to the core
Diffstat (limited to 'src')
-rw-r--r-- | src/mir_app/src/mir_app.def | 3 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 3 | ||||
-rw-r--r-- | src/mir_app/src/netliblog.cpp | 16 | ||||
-rw-r--r-- | src/mir_app/src/netlibsecurity.cpp | 4 | ||||
-rw-r--r-- | src/mir_app/src/proto_utils.cpp | 30 |
5 files changed, 46 insertions, 10 deletions
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 73fd746295..304f189b4f 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -122,8 +122,6 @@ ProtoGetAvatarFileFormat @120 ProtoGetAvatarFormat @121
ProtoGetBufferFormat @122
ProtoHookEvent @123
-ProtoLogA @124
-ProtoLogW @125
ProtoWindowAdd @126
ProtoWindowRemove @127
Proto_IsProtocolLoaded @128
@@ -492,3 +490,4 @@ Srmm_GetColorTable @496 Contact_Add @497
Contact_AddByEvent @498
Contact_AddBySearch @499
+?setAllContactStatuses@PROTO_INTERFACE@@QAEXH_N@Z @500 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index defbe2c365..93bdf48d98 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -122,8 +122,6 @@ ProtoGetAvatarFileFormat @120 ProtoGetAvatarFormat @121
ProtoGetBufferFormat @122
ProtoHookEvent @123
-ProtoLogA @124
-ProtoLogW @125
ProtoWindowAdd @126
ProtoWindowRemove @127
Proto_IsProtocolLoaded @128
@@ -492,3 +490,4 @@ Srmm_GetColorTable @496 Contact_Add @497
Contact_AddByEvent @498
Contact_AddBySearch @499
+?setAllContactStatuses@PROTO_INTERFACE@@QEAAXH_N@Z @500 NONAME
diff --git a/src/mir_app/src/netliblog.cpp b/src/mir_app/src/netliblog.cpp index 09c08b9f67..0e34498d99 100644 --- a/src/mir_app/src/netliblog.cpp +++ b/src/mir_app/src/netliblog.cpp @@ -352,18 +352,26 @@ int NetlibLog_Worker(NetlibUser *nlu, const char *pszMsg, int flags) /////////////////////////////////////////////////////////////////////////////////////////
-MIR_APP_DLL(void) ProtoLogA(PROTO_INTERFACE *pThis, LPCSTR szFormat, va_list args)
+void PROTO_INTERFACE::debugLogA(const char *szFormat, ...)
{
char buf[4096];
+ va_list args;
+ va_start(args, szFormat);
int res = _vsnprintf(buf, _countof(buf), szFormat, args);
- NetlibLog_Worker(pThis ? pThis->m_hNetlibUser : nullptr, (res != -1) ? buf : CMStringA().FormatV(szFormat, args), 0);
+ va_end(args);
+
+ NetlibLog_Worker(m_hNetlibUser, (res != -1) ? buf : CMStringA().FormatV(szFormat, args), 0);
}
-MIR_APP_DLL(void) ProtoLogW(PROTO_INTERFACE *pThis, LPCWSTR wszFormat, va_list args)
+void PROTO_INTERFACE::debugLogW(const wchar_t *wszFormat, ...)
{
WCHAR buf[4096];
+ va_list args;
+ va_start(args, wszFormat);
int res = _vsnwprintf(buf, _countof(buf), wszFormat, args);
- NetlibLog_Worker(pThis ? pThis->m_hNetlibUser : nullptr, ptrA(Utf8EncodeW((res != -1) ? buf : CMStringW().FormatV(wszFormat, args))), 0);
+ va_end(args);
+
+ NetlibLog_Worker(m_hNetlibUser, ptrA(Utf8EncodeW((res != -1) ? buf : CMStringW().FormatV(wszFormat, args))), 0);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/mir_app/src/netlibsecurity.cpp b/src/mir_app/src/netlibsecurity.cpp index 0c678ea6b7..de31d4e74f 100644 --- a/src/mir_app/src/netlibsecurity.cpp +++ b/src/mir_app/src/netlibsecurity.cpp @@ -224,13 +224,13 @@ char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge, return nullptr;
if (isGSSAPI && complete)
- return CompleteGssapi(hSecurity, token, tokenLen);
+ return CompleteGssapi(hSecurity, token, (unsigned)tokenLen);
inputBufferDescriptor.cBuffers = 1;
inputBufferDescriptor.pBuffers = &inputSecurityToken;
inputBufferDescriptor.ulVersion = SECBUFFER_VERSION;
inputSecurityToken.BufferType = SECBUFFER_TOKEN;
- inputSecurityToken.cbBuffer = tokenLen;
+ inputSecurityToken.cbBuffer = (unsigned)tokenLen;
inputSecurityToken.pvBuffer = token;
// try to decode the domain name from the NTLM challenge
diff --git a/src/mir_app/src/proto_utils.cpp b/src/mir_app/src/proto_utils.cpp index b68942c8ea..13b4a14e52 100644 --- a/src/mir_app/src/proto_utils.cpp +++ b/src/mir_app/src/proto_utils.cpp @@ -62,6 +62,23 @@ MIR_APP_DLL(INT_PTR) ProtoBroadcastAck(const char *szModule, MCONTACT hContact, /////////////////////////////////////////////////////////////////////////////////////////
+void PROTO_INTERFACE::setAllContactStatuses(int iStatus, bool bSkipChats)
+{
+ for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ if (isChatRoom(hContact)) {
+ if (!bSkipChats && iStatus == ID_STATUS_OFFLINE) {
+ ptrW wszRoom(getWStringA(hContact, "ChatRoomID"));
+ if (wszRoom != nullptr)
+ Chat_Control(m_szModuleName, wszRoom, SESSION_OFFLINE);
+ }
+ }
+ else setWord(hContact, "Status", iStatus);
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// protocol constructor & destructor
+
MIR_APP_DLL(void) ProtoConstructor(PROTO_INTERFACE *pThis, LPCSTR pszModuleName, LPCTSTR ptszUserName)
{
pThis->m_iVersion = 2;
@@ -80,6 +97,9 @@ MIR_APP_DLL(void) ProtoDestructor(PROTO_INTERFACE *pThis) WindowList_Destroy(pThis->m_hWindowList);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// protocol services
+
MIR_APP_DLL(void) ProtoCreateService(PROTO_INTERFACE *pThis, const char* szService, ProtoServiceFunc serviceProc)
{
char str[MAXMODULELABELLENGTH * 2];
@@ -96,6 +116,9 @@ MIR_APP_DLL(void) ProtoCreateServiceParam(PROTO_INTERFACE *pThis, const char* sz ::CreateServiceFunctionObjParam(str, (MIRANDASERVICEOBJPARAM)*(void**)&serviceProc, pThis, lParam);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// protocol events
+
MIR_APP_DLL(void) ProtoHookEvent(PROTO_INTERFACE *pThis, const char* szEvent, ProtoEventFunc handler)
{
::HookEventObj(szEvent, (MIRANDAHOOKOBJ)*(void**)&handler, pThis);
@@ -109,6 +132,9 @@ MIR_APP_DLL(HANDLE) ProtoCreateHookableEvent(PROTO_INTERFACE *pThis, const char* return CreateHookableEvent(str);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// protocol threads
+
MIR_APP_DLL(void) ProtoForkThread(PROTO_INTERFACE *pThis, ProtoThreadFunc pFunc, void *param)
{
UINT threadID;
@@ -121,6 +147,9 @@ MIR_APP_DLL(HANDLE) ProtoForkThreadEx(PROTO_INTERFACE *pThis, ProtoThreadFunc pF return (HANDLE)::mir_forkthreadowner((pThreadFuncOwner)*(void**)&pFunc, pThis, param, threadID ? threadID : <hreadID);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// protocol windows
+
MIR_APP_DLL(void) ProtoWindowAdd(PROTO_INTERFACE *pThis, HWND hwnd)
{
if (pThis->m_hWindowList == nullptr)
@@ -135,6 +164,7 @@ MIR_APP_DLL(void) ProtoWindowRemove(PROTO_INTERFACE *pThis, HWND hwnd) }
/////////////////////////////////////////////////////////////////////////////////////////
+// avatar support
MIR_APP_DLL(LPCTSTR) ProtoGetAvatarExtension(int format)
{
|