diff options
114 files changed, 1696 insertions, 1165 deletions
diff --git a/bin10/lib/mir_app.lib b/bin10/lib/mir_app.lib Binary files differindex d3189234bb..ce0d8b07db 100644 --- a/bin10/lib/mir_app.lib +++ b/bin10/lib/mir_app.lib diff --git a/bin10/lib/mir_app64.lib b/bin10/lib/mir_app64.lib Binary files differindex 7bb2057b6e..03c4754582 100644 --- a/bin10/lib/mir_app64.lib +++ b/bin10/lib/mir_app64.lib diff --git a/bin12/lib/mir_app.lib b/bin12/lib/mir_app.lib Binary files differindex d3189234bb..ce0d8b07db 100644 --- a/bin12/lib/mir_app.lib +++ b/bin12/lib/mir_app.lib diff --git a/bin12/lib/mir_app64.lib b/bin12/lib/mir_app64.lib Binary files differindex 7bb2057b6e..03c4754582 100644 --- a/bin12/lib/mir_app64.lib +++ b/bin12/lib/mir_app64.lib diff --git a/bin14/lib/mir_app.lib b/bin14/lib/mir_app.lib Binary files differindex d3189234bb..ce0d8b07db 100644 --- a/bin14/lib/mir_app.lib +++ b/bin14/lib/mir_app.lib diff --git a/bin14/lib/mir_app64.lib b/bin14/lib/mir_app64.lib Binary files differindex 7bb2057b6e..03c4754582 100644 --- a/bin14/lib/mir_app64.lib +++ b/bin14/lib/mir_app64.lib diff --git a/include/delphi/m_avatars.inc b/include/delphi/m_avatars.inc index 64494e64c8..9f7b820ee0 100644 --- a/include/delphi/m_avatars.inc +++ b/include/delphi/m_avatars.inc @@ -169,7 +169,7 @@ const lParam = either a full picture filename or NIL. If lParam = NIL, the service
will open a file selection dialog.
}
- MS_AV_SETAVATAR:PAnsiChar = 'SV_Avatars/SetAvatar';
+ MS_AV_SETAVATARW:PAnsiChar = 'SV_Avatars/SetAvatarW';
{
set a local picture for the given protocol
@@ -178,7 +178,7 @@ const lParam = either a full picture filename or NULL. If lParam == NULL, the service
will open a file selection dialog.
}
- MS_AV_SETMYAVATAR:PAnsiChar = 'SV_Avatars/SetMyAvatar';
+ MS_AV_SETMYAVATARW:PAnsiChar = 'SV_Avatars/SetMyAvatarW';
{
see if is possible to set the avatar for the expecified protocol
diff --git a/include/delphi/m_helpers.inc b/include/delphi/m_helpers.inc index 3e9d70b32f..0c98ecd947 100644 --- a/include/delphi/m_helpers.inc +++ b/include/delphi/m_helpers.inc @@ -16,11 +16,6 @@ function CreateVersionStringPlugin(pluginInfo:PPluginInfoEx;buf:PAnsiChar):PAnsi function PLUGIN_MAKE_VERSION(a,b,c,d: Cardinal): int;
function PLUGIN_CMP_VERSION(verA: LongInt; verB: LongInt): int;
-function Netlib_CloseHandle(Handle: THANDLE): int;
-function Netlib_GetBase64DecodedBufferSize(const cchEncoded: int): int;
-function Netlib_GetBase64EncodedBufferSize(const cbDecoded: int): int;
-function Netlib_Send(hConn: THANDLE; const buf: PAnsiChar; len: int; flags: int): int_ptr;
-function Netlib_Recv(hConn: THANDLE; const buf: PAnsiChar; len: int; flags: int): int_ptr;
procedure Netlib_Log(hNetLib: THANDLE; const sz: PAnsiChar);
function mir_hashstr (const key:PAnsiChar):uint; {inline;}
@@ -178,44 +173,6 @@ begin Inc(Result, (verA and $FF000000) - (verB and $FF000000));
end;
-function Netlib_CloseHandle(Handle: THANDLE): int;
- {$IFDEF AllowInline}inline;{$ENDIF}
-begin
- Result := CallService(MS_NETLIB_CLOSEHANDLE, Handle, 0);
-end;
-
-function Netlib_GetBase64DecodedBufferSize(const cchEncoded: int): int;
- {$IFDEF AllowInline}inline;{$ENDIF}
-begin
- Result := (cchEncoded shr 2) * 3;
-end;
-
-function Netlib_GetBase64EncodedBufferSize(const cbDecoded: int): int;
- {$IFDEF AllowInline}inline;{$ENDIF}
-begin
- Result := (cbDecoded * 4+11) div 12*4+1;
-end;
-
-function Netlib_Send(hConn: THANDLE; const buf: PAnsiChar; len: int; flags: int): int_ptr;
-var
- nlb: TNETLIBBUFFER;
-begin
- nlb.buf := buf;
- nlb.len := len;
- nlb.flags := flags;
- Result := CallService(MS_NETLIB_SEND, wParam(hConn), lParam(@nlb));
-end;
-
-function Netlib_Recv(hConn: THANDLE; const buf: PAnsiChar; len: int; flags: int): int_ptr;
-var
- nlb: TNETLIBBUFFER;
-begin
- nlb.buf := buf;
- nlb.len := len;
- nlb.flags := flags;
- Result := CallService(MS_NETLIB_RECV, wParam(hConn), lParam(@nlb));
-end;
-
procedure Netlib_Log(hNetLib: THANDLE; const sz: PAnsiChar);
{$IFDEF AllowInline}inline;{$ENDIF}
begin
diff --git a/include/delphi/m_netlib.inc b/include/delphi/m_netlib.inc index edbf277804..3a9512cb49 100644 --- a/include/delphi/m_netlib.inc +++ b/include/delphi/m_netlib.inc @@ -313,27 +313,6 @@ const }
MS_NETLIB_REGISTERUSER:PAnsiChar = 'Netlib/RegisterUser';
-{
- Assign a Netlib user handle a set of dynamic HTTP headers to be used with all
-
- HTTP connections that enable the HTTP-use-sticky headers flag.
- The headers persist until cleared with lParam=NULL.
-
- All memory should be allocated by the caller using malloc() from MS_SYSTEM_GET_MMI
- Once it has passed to Netlib, Netlib is the owner of it, the caller should not refer to the memory
- In any way after this point.
-
- wParam=(WPARAM)hNetLibUser
- lParam=(LPARAM)(AnsiChar*)szHeaders
-
- NOTE: The szHeaders parameter should be a NULL terminated string following the HTTP header syntax.
- This string will be injected verbatim, thus the user should be aware of setting strings that are not
- headers. This service is NOT THREAD SAFE, only a single thread is expected to set the headers and a single
- thread reading the pointer internally, stopping race conditions and mutual exclusion don't happen.
-
- Version 0.3.2a+ (2003/10/27)
-}
- MS_NETLIB_SETSTICKYHEADERS:PAnsiChar = 'Netlib/SetStickyHeaders';
{
wParam : HANDLE
@@ -348,20 +327,6 @@ const Errors : ERROR_INVALID_PARAMETER
}
MS_NETLIB_GETUSERSETTINGS:PAnsiChar = 'Netlib/GetUserSettings';
-
- {
- wParam : HANDLE
- lParam : Pointer to a initalised NETLIBUSERSETTINGS structure
- Affect : Changes the configurable settings for a Netlib user -- see notes
- Returns: [non zero] on success, NULL(0) on failure
- Notes : This service is only really useful for people that specify NUF_NOOPTIONS
- when registering and want to create their own options.
- Settings will be stored even if the option to enable it, is it not enabled,
- e.g. useProxyAuth is 0, szProxyAuthPassword will still be saved
- Errors : ERROR_INVALID_PARAMETER
- }
- MS_NETLIB_SETUSERSETTINGS:PAnsiChar = 'Netlib/SetUserSettings';
-
{
wParam : HANDLE / SOCKET
lParam : 0
@@ -371,7 +336,8 @@ const If a SOCKET type is passed instead of netlib handle type, it is closed
Errors : ERROR_INVALID_PARAMETER
}
- MS_NETLIB_CLOSEHANDLE:PAnsiChar = 'Netlib/CloseHandle';
+
+function Netlib_CloseHandle(pHandle:THANDLE) : int; stdcall; external AppDll;
{
wParam : HANDLE
@@ -390,6 +356,8 @@ const Errors : ERROR_INVALID_PARAMETER, any returned by socket(), bind(), listen()
getsockname()
}
+
+const
MS_NETLIB_BINDPORT:PAnsiChar = 'Netlib/BindPort';
{
@@ -602,8 +570,6 @@ const MS_NETLIB_HTTPTRANSACTION:PAnsiChar = 'Netlib/HttpTransaction';
{
- wParam : HANDLE
- lParam : Pointer to an initialised TNETLIBBUFFER structure
Affect : Send data over an open connection see notes
Returns: The number of bytes sent on success, SOCKET_ERROR on failure
Notes : see Netlib_Send() helper function
@@ -613,11 +579,10 @@ const (HTTP proxy): ERROR_GEN_FAILURE (http result code wasn't 2xx)
MS_NETLIB_SENDHTTPREQUEST, MS_NETLIB_RECVHTTPHEADERS
}
- MS_NETLIB_SEND:PAnsiChar = 'Netlib/Send';
+
+function Netlib_Send(hConn:THANDLE; pBuf:Pointer; len,flags:int) : int; stdcall; external AppDll;
{
- wParam : HANDLE
- lParam : Pointer to an initialised TNETLIBBUFFER structure
Affect : Receive data over a connection, see notes
Returns: The number of bytes read on success, SOCKET_ERROR on failure
Notes :
@@ -646,7 +611,8 @@ const connect(), MS_NETLIB_SENDHTTPREQUEST
}
- MS_NETLIB_RECV:PAnsiChar = 'Netlib/Recv';
+
+function Netlib_Recv(hConn:THANDLE; pBuf:Pointer; len,flags:int) : int; stdcall; external AppDll;
{
wParam : 0
@@ -659,6 +625,7 @@ const or INVALID_HANDLE_VALUE.
Errors : ERROR_INVALID_HANDLE, ERROR_INVALID_DATA, anything from select()
}
+const
MS_NETLIB_SELECT :PAnsiChar = 'Netlib/Select';
MS_NETLIB_SELECTEX:PAnsiChar = 'Netlib/SelectEx'; // added in v0.3.3
diff --git a/include/m_avatars.h b/include/m_avatars.h index 213cc7ff7e..60f44fcd96 100644 --- a/include/m_avatars.h +++ b/include/m_avatars.h @@ -70,7 +70,7 @@ unless AF_FETCHIFPROTONOTVISIBLE is set. #define AVS_OWNAVATAR 128 // is own avatar entry
#define AVS_NOTREADY 4096
-typedef struct avatarCacheEntry
+struct AVATARCACHEENTRY
{
DWORD cbSize; // set to sizeof(struct)
MCONTACT hContact; // contacts handle, 0, if it is a protocol avatar
@@ -82,8 +82,7 @@ typedef struct avatarCacheEntry // to implement cache expiration
LPVOID lpDIBSection; // unused field
wchar_t szFilename[MAX_PATH]; // filename of the avatar (absolute path)
-}
- AVATARCACHEENTRY;
+};
#define AVDRQ_FALLBACKPROTO 0x0001 // use the protocol picture as fallback (currently not used)
#define AVDRQ_FAILIFNOTCACHED 0x0002 // don't create a cache entry if it doesn't already exist. (currently not working)
@@ -157,19 +156,15 @@ typedef struct _avatarDrawRequest // lParam = either a full picture filename or NULL. If lParam == NULL, the service
// will open a file selection dialog.
-#define MS_AV_SETAVATAR "SV_Avatars/SetAvatar"
#define MS_AV_SETAVATARW "SV_Avatars/SetAvatarW"
-#define MS_AV_SETAVATART MS_AV_SETAVATARW
// set a local picture for the given protocol
//
-// wParam = (char *) protocol name or NULL for all protocols
+// wParam = (char*) protocol name or NULL for all protocols
// lParam = either a full picture filename or NULL. If lParam == NULL, the service
// will open a file selection dialog. If lParam == "" the avatar will be removed
-#define MS_AV_SETMYAVATAR "SV_Avatars/SetMyAvatar"
#define MS_AV_SETMYAVATARW "SV_Avatars/SetMyAvatarW"
-#define MS_AV_SETMYAVATART MS_AV_SETMYAVATARW
// see if is possible to set the avatar for the expecified protocol
//
@@ -213,17 +208,18 @@ typedef struct _avatarDrawRequest #define ME_AV_AVATARCHANGED "SV_Avatars/AvatarChanged"
-typedef struct _contactAvatarChangedNotification {
+struct CONTACTAVATARCHANGEDNOTIFICATION
+{
int cbSize; // sizeof()
MCONTACT hContact; // this might have to be set by the caller too
int format; // PA_FORMAT_*
wchar_t filename[MAX_PATH]; // full path to filename which contains the avatar
wchar_t hash[128]; // avatar hash
-} CONTACTAVATARCHANGEDNOTIFICATION;
+};
// fired when the contacts avatar is changed by the contact
// wParam = hContact
-// lParam = struct CONTACTAVATARCHANGEDNOTIFICATION *cacn
+// lParam = CONTACTAVATARCHANGEDNOTIFICATION *cacn
// the event CAN pass a NULL pointer in lParam which means that the contact deleted its avatar
#define ME_AV_CONTACTAVATARCHANGED "SV_Avatars/ContactAvatarChanged"
@@ -255,14 +251,14 @@ typedef struct _contactAvatarChangedNotification { /*
wParam=0
lParam=(const wchar_t*)Avatar file name or NULL to remove the avatar
-return=0 for sucess
+return=0 for success
*/
#define PS_SETMYAVATAR "/SetMyAvatar"
/*
wParam=(wchar_t*)Buffer to file name
lParam=(int)Buffer size
-return=0 for sucess
+return=0 for success
*/
#define PS_GETMYAVATAR "/GetMyAvatar"
diff --git a/include/m_gui.h b/include/m_gui.h index 60f315c32a..b784ad95f1 100644 --- a/include/m_gui.h +++ b/include/m_gui.h @@ -32,7 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_protoint.h>
#include <m_clc.h>
-#pragma warning(disable:4355 4251)
+#pragma warning(disable:4355 4251 4481)
/////////////////////////////////////////////////////////////////////////////////////////
// helpers for the option's visualization
diff --git a/include/m_netlib.h b/include/m_netlib.h index 1daf530be5..51b18adc48 100644 --- a/include/m_netlib.h +++ b/include/m_netlib.h @@ -61,7 +61,7 @@ struct NETLIBOPENCONNECTION; typedef int (*NETLIBHTTPGATEWAYINITPROC)(HANDLE hConn, NETLIBOPENCONNECTION *nloc, NETLIBHTTPREQUEST *nlhr);
typedef int (*NETLIBHTTPGATEWAYBEGINPROC)(HANDLE hConn, NETLIBOPENCONNECTION *nloc);
-typedef int (*NETLIBHTTPGATEWAYWRAPSENDPROC)(HANDLE hConn, PBYTE buf, int len, int flags, MIRANDASERVICE pfnNetlibSend);
+typedef int (*NETLIBHTTPGATEWAYWRAPSENDPROC)(HANDLE hConn, PBYTE buf, int len, int flags);
typedef PBYTE (*NETLIBHTTPGATEWAYUNWRAPRECVPROC)(NETLIBHTTPREQUEST *nlhr, PBYTE buf, int len, int *outBufLen, void *(*NetlibRealloc)(void*, size_t));
struct NETLIBUSER
@@ -223,18 +223,13 @@ struct NETLIBUSERSETTINGS #define MS_NETLIB_SETUSERSETTINGS "Netlib/SetUserSettings"
// Closes a netlib handle
-// wParam = (WPARAM)(HANDLE)hNetlibHandle
-// lParam = 0
// Returns nonzero on success, 0 on failure (!! this is different to most of the rest of Miranda, but consistent with netlib)
// This function should be called on all handles returned by netlib functions
// once you are done with them. If it's called on a socket-type handle, the
// socket will be closed.
// Errors: ERROR_INVALID_PARAMETER
-#define MS_NETLIB_CLOSEHANDLE "Netlib/CloseHandle"
-__forceinline INT_PTR Netlib_CloseHandle(HANDLE h)
-{ return CallService(MS_NETLIB_CLOSEHANDLE, (WPARAM)h, 0);
-}
+EXTERN_C MIR_APP_DLL(int) Netlib_CloseHandle(HANDLE h);
/////////////////////////////////////////////////////////////////////////////////////////
// Open a port and wait for connections on it
@@ -599,8 +594,7 @@ public: /////////////////////////////////////////////////////////////////////////////////////////
// Send data over a connection
-// wParam = (WPARAM)(HANDLE)hConnection
-// lParam = (LPARAM)(NETLIBBUFFER*)&nlb
+//
// Returns the number of bytes sent on success, SOCKET_ERROR on failure
// Errors: ERROR_INVALID_PARAMETER
// anything from send(), nlu.pfnHttpGatewayWrapSend()
@@ -610,31 +604,18 @@ public: // flags:
#define MSG_NOHTTPGATEWAYWRAP 0x010000 // don't wrap the outgoing packet using nlu.pfnHttpGatewayWrapSend
-#define MSG_NODUMP 0x020000 // don't dump this packet to the log
+#define MSG_NODUMP 0x020000 // don't dump this packet to the log
#define MSG_DUMPPROXY 0x040000 // this is proxy communiciation. For dump filtering only.
-#define MSG_DUMPASTEXT 0x080000 // this is textual data, don't dump as hex
+#define MSG_DUMPASTEXT 0x080000 // this is textual data, don't dump as hex
#define MSG_RAW 0x100000 // send as raw data, bypass any HTTP proxy stuff
#define MSG_DUMPSSL 0x200000 // this is SSL traffic. For dump filtering only.
+#define MSG_NOTITLE 0x400000 // skip date, time & protocol from dump
-struct NETLIBBUFFER
-{
- char *buf;
- int len;
- int flags;
-};
-
-#define MS_NETLIB_SEND "Netlib/Send"
-
-__inline INT_PTR Netlib_Send(HANDLE hConn, const char *buf, int len, int flags)
-{
- NETLIBBUFFER nlb = {(char*)buf, len, flags};
- return CallService(MS_NETLIB_SEND, (WPARAM)hConn, (LPARAM)&nlb);
-}
+EXTERN_C MIR_APP_DLL(int) Netlib_Send(HANDLE hConn, const char *buf, int len, int flags = 0);
/////////////////////////////////////////////////////////////////////////////////////////
// Receive data over a connection
-// wParam = (WPARAM)(HANDLE)hConnection
-// lParam = (LPARAM)(NETLIBBUFFER*)&nlb
+//
// Returns the number of bytes read on success, SOCKET_ERROR on failure,
// 0 if the connection has been closed
// Flags supported: MSG_PEEK, MSG_NODUMP, MSG_DUMPPROXY, MSG_NOHTTPGATEWAYWRAP,
@@ -654,13 +635,7 @@ __inline INT_PTR Netlib_Send(HANDLE hConn, const char *buf, int len, int flags) // nlu.pfnHttpGatewayUnwrapRecv, socket(), connect(),
// MS_NETLIB_SENDHTTPREQUEST
-#define MS_NETLIB_RECV "Netlib/Recv"
-
-__inline INT_PTR Netlib_Recv(HANDLE hConn, char *buf, int len, int flags)
-{
- NETLIBBUFFER nlb = {buf, len, flags};
- return CallService(MS_NETLIB_RECV, (WPARAM)hConn, (LPARAM)&nlb);
-}
+EXTERN_C MIR_APP_DLL(int) Netlib_Recv(HANDLE hConn, char *buf, int len, int flags = 0);
/////////////////////////////////////////////////////////////////////////////////////////
// Determine the status of one or more connections
@@ -924,7 +899,9 @@ static __inline char* Netlib_NtlmCreateResponse2(HANDLE hProvider, char* szChall struct NETLIBNOTIFY
{
- NETLIBBUFFER* nlb; // pointer to the request buffer
+ const char *buf;
+ int len;
+ int flags;
int result; // amount of bytes really sent/received
};
diff --git a/plugins/AVS/src/acc.cpp b/plugins/AVS/src/acc.cpp index f24d1e6680..30dcc47720 100644 --- a/plugins/AVS/src/acc.cpp +++ b/plugins/AVS/src/acc.cpp @@ -496,11 +496,11 @@ static LRESULT CALLBACK ACCWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP int *height = (int*)lParam;
// Get avatar
- avatarCacheEntry *ace;
+ AVATARCACHEENTRY *ace;
if (data->hContact == NULL)
- ace = (avatarCacheEntry *)CallService(MS_AV_GETMYAVATAR, 0, (LPARAM)data->proto);
+ ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETMYAVATAR, 0, (LPARAM)data->proto);
else
- ace = (avatarCacheEntry *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)data->hContact, 0);
+ ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)data->hContact, 0);
if (ace == NULL || ace->bmHeight == 0 || ace->bmWidth == 0 || (data->respectHidden && (ace->dwFlags & AVS_HIDEONCLIST))) {
*width = 0;
diff --git a/plugins/AVS/src/acc.h b/plugins/AVS/src/acc.h index 9917156385..94a8f1253a 100644 --- a/plugins/AVS/src/acc.h +++ b/plugins/AVS/src/acc.h @@ -21,10 +21,9 @@ Boston, MA 02111-1307, USA. #ifndef __ACC_H__
# define __ACC_H__
-static INT_PTR avSetAvatar(MCONTACT hContact, wchar_t *tszPath);
-INT_PTR avSetMyAvatar(char *szProto, wchar_t *tszPath);
+INT_PTR SetAvatar(WPARAM wParam, LPARAM lParam);
+INT_PTR SetMyAvatar(WPARAM wParam, LPARAM lParam);
int LoadACC();
-
#endif // __ACC_H__
diff --git a/plugins/AVS/src/cache.cpp b/plugins/AVS/src/cache.cpp index 6bd8f97177..18250bddd7 100644 --- a/plugins/AVS/src/cache.cpp +++ b/plugins/AVS/src/cache.cpp @@ -75,7 +75,7 @@ CacheNode* FindAvatarInCache(MCONTACT hContact, bool add, bool findAny) if (szProto == NULL || !db_get_b(NULL, AVS_MODULE, szProto, 1))
return NULL;
- avatarCacheEntry tmp;
+ AVATARCACHEENTRY tmp;
tmp.hContact = hContact;
mir_cslock lck(cachecs);
@@ -167,7 +167,7 @@ void DeleteAvatarFromCache(MCONTACT hContact, bool bForever) if (g_shutDown)
return;
- avatarCacheEntry tmp;
+ AVATARCACHEENTRY tmp;
tmp.hContact = GetContactThatHaveTheAvatar(hContact);
mir_cslock lck(cachecs);
@@ -193,7 +193,7 @@ int SetAvatarAttribute(MCONTACT hContact, DWORD attrib, int mode) if (g_shutDown)
return 0;
- avatarCacheEntry tmp;
+ AVATARCACHEENTRY tmp;
tmp.hContact = hContact;
mir_cslock lck(cachecs);
diff --git a/plugins/AVS/src/options.cpp b/plugins/AVS/src/options.cpp index e83ceb28e1..b7304c11f5 100644 --- a/plugins/AVS/src/options.cpp +++ b/plugins/AVS/src/options.cpp @@ -30,7 +30,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define DM_PROTOCOLCHANGED (WM_USER + 13) extern int _DebugPopup(MCONTACT hContact, const char *fmt, ...); -extern INT_PTR SetAvatar(WPARAM wParam, LPARAM lParam); extern OBJLIST<protoPicCacheEntry> g_ProtoPictures; extern HANDLE hEventChanged; extern HINSTANCE g_hInst; @@ -164,7 +163,7 @@ static void SetProtoPic(char *szProto) if (!mir_strcmp(p.szProtoname, szProto) && mir_strlen(p.szProtoname) == mir_strlen(szProto)) { if (p.hbmPic != 0) DeleteObject(p.hbmPic); - memset(&p, 0, sizeof(avatarCacheEntry)); + memset(&p, 0, sizeof(AVATARCACHEENTRY)); CreateAvatarInCache(0, &p, szProto); NotifyEventHooks(hEventChanged, 0, (LPARAM)&p); break; @@ -1062,18 +1061,18 @@ static INT_PTR CALLBACK DlgProcAvatarProtoInfo(HWND hwndDlg, UINT msg, WPARAM wP switch (LOWORD(wParam)) { case IDC_CHANGE: if (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_PER_PROTO)) - avSetMyAvatar(NULL, NULL); + SetMyAvatar(NULL, NULL); else { char *proto = GetSelectedProtocol(hwndDlg); if (proto != NULL) - avSetMyAvatar(proto, NULL); + SetMyAvatar((WPARAM)proto, NULL); } break; case IDC_DELETE: if (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_PER_PROTO)) { if (MessageBox(hwndDlg, TranslateT("Are you sure you want to remove your avatar?"), TranslateT("Global avatar"), MB_YESNO) == IDYES) - avSetMyAvatar(NULL, L""); + SetMyAvatar(NULL, (LPARAM)L""); } else { char *proto = GetSelectedProtocol(hwndDlg); @@ -1084,7 +1083,7 @@ static INT_PTR CALLBACK DlgProcAvatarProtoInfo(HWND hwndDlg, UINT msg, WPARAM wP CallProtoService(proto, PS_GETNAME, _countof(description), (LPARAM)description); wchar_t *descr = mir_a2u(description); if (MessageBox(hwndDlg, TranslateT("Are you sure you want to remove your avatar?"), descr, MB_YESNO) == IDYES) - avSetMyAvatar(proto, L""); + SetMyAvatar((WPARAM)proto, (LPARAM)L""); mir_free(descr); } break; diff --git a/plugins/AVS/src/services.cpp b/plugins/AVS/src/services.cpp index aba7818492..754fa54dc7 100644 --- a/plugins/AVS/src/services.cpp +++ b/plugins/AVS/src/services.cpp @@ -115,7 +115,7 @@ UINT_PTR CALLBACK OpenFileSubclass(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP return FALSE;
}
-static INT_PTR avSetAvatar(MCONTACT hContact, wchar_t *tszPath)
+INT_PTR SetAvatar(WPARAM hContact, LPARAM lParam)
{
wchar_t FileName[MAX_PATH];
wchar_t *szFinalName;
@@ -126,6 +126,7 @@ static INT_PTR avSetAvatar(MCONTACT hContact, wchar_t *tszPath) int is_locked = db_get_b(hContact, "ContactPhoto", "Locked", 0);
+ wchar_t *tszPath = (wchar_t*)lParam;
if (tszPath == NULL) {
wchar_t filter[256];
Bitmap_GetFilter(filter, _countof(filter));
@@ -172,16 +173,6 @@ static INT_PTR avSetAvatar(MCONTACT hContact, wchar_t *tszPath) return 0;
}
-INT_PTR SetAvatar(WPARAM wParam, LPARAM lParam)
-{
- return avSetAvatar(wParam, _A2T((const char*)lParam));
-}
-
-INT_PTR SetAvatarW(WPARAM wParam, LPARAM lParam)
-{
- return avSetAvatar(wParam, (wchar_t*)lParam);
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
// see if is possible to set the avatar for the expecified protocol
@@ -608,7 +599,7 @@ static int InternalSetMyAvatar(char *protocol, wchar_t *szFinalName, SetMyAvatar return ret;
}
-INT_PTR avSetMyAvatar(char* protocol, wchar_t* tszPath)
+INT_PTR SetMyAvatar(WPARAM wParam, LPARAM lParam)
{
wchar_t FileName[MAX_PATH];
wchar_t *szFinalName = NULL;
@@ -616,9 +607,11 @@ INT_PTR avSetMyAvatar(char* protocol, wchar_t* tszPath) BOOL allAcceptSWF;
// Protocol allow seting of avatar?
+ char* protocol = (char*)wParam;
if (protocol != NULL && !CanSetMyAvatar((WPARAM)protocol, 0))
return -1;
+ wchar_t* tszPath = (wchar_t*)lParam;
if (tszPath == NULL && hwndSetMyAvatar != 0) {
SetForegroundWindow(hwndSetMyAvatar);
SetFocus(hwndSetMyAvatar);
@@ -707,16 +700,6 @@ INT_PTR avSetMyAvatar(char* protocol, wchar_t* tszPath) return InternalSetMyAvatar(protocol, szFinalName, data, allAcceptXML, allAcceptSWF);
}
-static INT_PTR SetMyAvatar(WPARAM wParam, LPARAM lParam)
-{
- return avSetMyAvatar((char*)wParam, _A2T((const char*)lParam));
-}
-
-static INT_PTR SetMyAvatarW(WPARAM wParam, LPARAM lParam)
-{
- return avSetMyAvatar((char*)wParam, (wchar_t*)lParam);
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
INT_PTR CALLBACK DlgProcAvatarOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
@@ -859,10 +842,8 @@ void InitServices() {
CreateServiceFunction(MS_AV_GETAVATARBITMAP, GetAvatarBitmap);
CreateServiceFunction(MS_AV_PROTECTAVATAR, ProtectAvatar);
- CreateServiceFunction(MS_AV_SETAVATAR, SetAvatar);
- CreateServiceFunction(MS_AV_SETAVATARW, SetAvatarW);
- CreateServiceFunction(MS_AV_SETMYAVATAR, SetMyAvatar);
- CreateServiceFunction(MS_AV_SETMYAVATARW, SetMyAvatarW);
+ CreateServiceFunction(MS_AV_SETAVATARW, SetAvatar);
+ CreateServiceFunction(MS_AV_SETMYAVATARW, SetMyAvatar);
CreateServiceFunction(MS_AV_CANSETMYAVATAR, CanSetMyAvatar);
CreateServiceFunction(MS_AV_CONTACTOPTIONS, ContactOptions);
CreateServiceFunction(MS_AV_DRAWAVATAR, DrawAvatarPicture);
diff --git a/plugins/AVS/src/stdafx.h b/plugins/AVS/src/stdafx.h index a28ea994c6..4eb907d41e 100644 --- a/plugins/AVS/src/stdafx.h +++ b/plugins/AVS/src/stdafx.h @@ -64,7 +64,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-struct CacheNode : public avatarCacheEntry, public MZeroedObject
+struct CacheNode : public AVATARCACHEENTRY, public MZeroedObject
{
CacheNode();
~CacheNode();
@@ -76,8 +76,8 @@ struct CacheNode : public avatarCacheEntry, public MZeroedObject void wipeInfo();
};
-// The same fields as avatarCacheEntry + proto name
-struct protoPicCacheEntry : public avatarCacheEntry, public MZeroedObject
+// The same fields as AVATARCACHEENTRY + proto name
+struct protoPicCacheEntry : public AVATARCACHEENTRY, public MZeroedObject
{
protoPicCacheEntry() { memset(this, 0, sizeof(*this)); };
~protoPicCacheEntry();
@@ -126,10 +126,10 @@ void MakePathRelative(MCONTACT hContact); void MakePathRelative(MCONTACT hContact, wchar_t *dest);
void MyPathToAbsolute(const wchar_t *ptszPath, wchar_t *ptszDest);
-HBITMAP LoadPNG(struct avatarCacheEntry *ace, char *szFilename);
+HBITMAP LoadPNG(struct AVATARCACHEENTRY *ace, char *szFilename);
void UnloadCache(void);
-int CreateAvatarInCache(MCONTACT hContact, avatarCacheEntry *ace, char *szProto);
+int CreateAvatarInCache(MCONTACT hContact, AVATARCACHEENTRY *ace, char *szProto);
void DeleteAvatarFromCache(MCONTACT hContact, bool bForever);
void PicLoader(LPVOID param);
void NotifyMetaAware(MCONTACT hContact, CacheNode *node = NULL, AVATARCACHEENTRY *ace = (AVATARCACHEENTRY*)-1);
diff --git a/plugins/AVS/src/utils.cpp b/plugins/AVS/src/utils.cpp index a47b3f15c1..a20372b9dc 100644 --- a/plugins/AVS/src/utils.cpp +++ b/plugins/AVS/src/utils.cpp @@ -65,7 +65,7 @@ void MakePathRelative(MCONTACT hContact) // create the avatar in cache
// returns 0 if not created (no avatar), iIndex otherwise, -2 if has to request avatar, -3 if avatar too big
-int CreateAvatarInCache(MCONTACT hContact, avatarCacheEntry *ace, char *szProto)
+int CreateAvatarInCache(MCONTACT hContact, AVATARCACHEENTRY *ace, char *szProto)
{
ptrW tszValue;
wchar_t tszFilename[MAX_PATH]; tszFilename[0] = 0;
@@ -157,7 +157,7 @@ int CreateAvatarInCache(MCONTACT hContact, avatarCacheEntry *ace, char *szProto) BITMAP bminfo;
GetObject(ace->hbmPic, sizeof(bminfo), &bminfo);
- ace->cbSize = sizeof(avatarCacheEntry);
+ ace->cbSize = sizeof(AVATARCACHEENTRY);
ace->dwFlags = AVS_BITMAP_VALID;
if (hContact != NULL && db_get_b(hContact, "ContactPhoto", "Hidden", 0))
ace->dwFlags |= AVS_HIDEONCLIST;
@@ -280,7 +280,7 @@ void protoPicCacheEntry::clear() if (hbmPic != 0)
DeleteObject(hbmPic);
- memset(this, 0, sizeof(avatarCacheEntry));
+ memset(this, 0, sizeof(AVATARCACHEENTRY));
}
///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/Clist_modern/src/modern_cachefuncs.cpp b/plugins/Clist_modern/src/modern_cachefuncs.cpp index e5f0f68040..e4fcfe208e 100644 --- a/plugins/Clist_modern/src/modern_cachefuncs.cpp +++ b/plugins/Clist_modern/src/modern_cachefuncs.cpp @@ -645,7 +645,7 @@ BOOL ReduceAvatarPosition(ClcContact *contact, BOOL, void *param) void Cache_ProceedAvatarInList(ClcData *dat, ClcContact *contact) { - avatarCacheEntry *ace = contact->avatar_data; + AVATARCACHEENTRY *ace = contact->avatar_data; int old_pos = contact->avatar_pos; if (ace == NULL || ace->dwFlags == AVS_BITMAP_EXPIRED || ace->hbmPic == NULL) { @@ -718,8 +718,8 @@ void Cache_GetAvatar(ClcData *dat, ClcContact *contact) } if (dat->avatars_show && !db_get_b(contact->hContact, "CList", "HideContactAvatar", 0)) { - contact->avatar_data = (avatarCacheEntry*)CallService(MS_AV_GETAVATARBITMAP, contact->hContact, 0); - if (contact->avatar_data == NULL || contact->avatar_data->cbSize != sizeof(avatarCacheEntry) || contact->avatar_data->dwFlags == AVS_BITMAP_EXPIRED) + contact->avatar_data = (AVATARCACHEENTRY*)CallService(MS_AV_GETAVATARBITMAP, contact->hContact, 0); + if (contact->avatar_data == NULL || contact->avatar_data->cbSize != sizeof(AVATARCACHEENTRY) || contact->avatar_data->dwFlags == AVS_BITMAP_EXPIRED) contact->avatar_data = NULL; if (contact->avatar_data != NULL) diff --git a/plugins/Clist_modern/src/modern_clc.h b/plugins/Clist_modern/src/modern_clc.h index 76ce6f3479..64deabf5f6 100644 --- a/plugins/Clist_modern/src/modern_clc.h +++ b/plugins/Clist_modern/src/modern_clc.h @@ -180,7 +180,7 @@ struct ClcContact : public ClcContactBase bool bSubExpanded, bImageIsSpecial;
int avatar_pos;
- avatarCacheEntry *avatar_data;
+ AVATARCACHEENTRY *avatar_data;
SIZE avatar_size;
CSmileyString ssText;
diff --git a/plugins/Clist_nicer/src/clc.cpp b/plugins/Clist_nicer/src/clc.cpp index 2f15c72d6d..fafadeb568 100644 --- a/plugins/Clist_nicer/src/clc.cpp +++ b/plugins/Clist_nicer/src/clc.cpp @@ -423,7 +423,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L case INTM_AVATARCHANGED:
contact = NULL;
{
- avatarCacheEntry *cEntry = (struct avatarCacheEntry *)lParam;
+ AVATARCACHEENTRY *cEntry = (struct AVATARCACHEENTRY *)lParam;
if (wParam == 0) {
//RemoveFromImgCache(0, cEntry);
diff --git a/plugins/Clist_nicer/src/clc.h b/plugins/Clist_nicer/src/clc.h index 56b8fe301f..f5303f506d 100644 --- a/plugins/Clist_nicer/src/clc.h +++ b/plugins/Clist_nicer/src/clc.h @@ -117,20 +117,20 @@ struct TExtraCache struct ClcContact : public ClcContactBase
{
- BOOL bIsMeta;
- BYTE xStatus;
- int xStatusIcon;
+ BOOL bIsMeta;
+ BYTE xStatus;
+ int xStatusIcon;
MCONTACT hSubContact;
- char *metaProto;
- DWORD codePage;
- WORD wStatus;
- int avatarLeft, extraIconRightBegin;
- int isRtl;
- DWORD cFlags;
- BYTE bSecondLine;
-
- avatarCacheEntry *ace;
- TExtraCache* pExtra;
+ char *metaProto;
+ DWORD codePage;
+ WORD wStatus;
+ int avatarLeft, extraIconRightBegin;
+ int isRtl;
+ DWORD cFlags;
+ BYTE bSecondLine;
+
+ AVATARCACHEENTRY *ace;
+ TExtraCache *pExtra;
};
#define DRAGSTAGE_NOTMOVED 0
diff --git a/plugins/Clist_nicer/src/clcitems.cpp b/plugins/Clist_nicer/src/clcitems.cpp index 0ab9137e9d..ebfdcd6cc8 100644 --- a/plugins/Clist_nicer/src/clcitems.cpp +++ b/plugins/Clist_nicer/src/clcitems.cpp @@ -84,8 +84,8 @@ void LoadAvatarForContact(ClcContact *p) p->ace = NULL;
if (cfg::dat.bAvatarServiceAvail && (p->cFlags & ECF_AVATAR) && (!cfg::dat.bNoOfflineAvatars || p->wStatus != ID_STATUS_OFFLINE)) {
- p->ace = (struct avatarCacheEntry *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)p->hContact, 0);
- if (p->ace != NULL && p->ace->cbSize != sizeof(struct avatarCacheEntry))
+ p->ace = (struct AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)p->hContact, 0);
+ if (p->ace != NULL && p->ace->cbSize != sizeof(struct AVATARCACHEENTRY))
p->ace = NULL;
if (p->ace != NULL)
p->ace->t_lastAccess = cfg::dat.t_now;
diff --git a/plugins/Clist_nicer/src/clcpaint.cpp b/plugins/Clist_nicer/src/clcpaint.cpp index 4436f60553..f4b72bb304 100644 --- a/plugins/Clist_nicer/src/clcpaint.cpp +++ b/plugins/Clist_nicer/src/clcpaint.cpp @@ -262,7 +262,7 @@ static int __fastcall DrawAvatar(HDC hdcMem, RECT *rc, ClcContact *contact, int if (!cfg::dat.bAvatarServiceAvail || dat->bisEmbedded)
return 0;
- if (contact->ace != NULL && contact->ace->cbSize == sizeof(struct avatarCacheEntry)) {
+ if (contact->ace != NULL && contact->ace->cbSize == sizeof(struct AVATARCACHEENTRY)) {
if (contact->ace->dwFlags & AVS_HIDEONCLIST)
return (cfg::dat.dwFlags & CLUI_FRAME_ALWAYSALIGNNICK) ? avatar_size + 2 : 0;
@@ -1458,11 +1458,11 @@ bgdone: line_num++;
ClcContact *cc = group->cl[group->scanIndex];
if (cfg::dat.bForceRefetchOnPaint)
- cc->ace = (struct avatarCacheEntry*) - 1;
+ cc->ace = (struct AVATARCACHEENTRY*) - 1;
if (y > rcPaint->top - dat->row_heights[line_num] && y <= rcPaint->bottom) {
- if (cc->ace == (struct avatarCacheEntry*) - 1)
- cc->ace = (struct avatarCacheEntry *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)cc->hContact, 0);
+ if (cc->ace == (struct AVATARCACHEENTRY*) - 1)
+ cc->ace = (struct AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)cc->hContact, 0);
RowHeight::getRowHeight(dat, cc, line_num, style);
PaintItem(hdcMem, group, cc, indent, y, dat, index, hwnd, style, &clRect, &bFirstNGdrawn, groupCountsFontTopShift, dat->row_heights[line_num]);
}
diff --git a/plugins/CryptoPP/src/main.cpp b/plugins/CryptoPP/src/main.cpp index 22be7cadba..62a75b02b3 100644 --- a/plugins/CryptoPP/src/main.cpp +++ b/plugins/CryptoPP/src/main.cpp @@ -130,8 +130,7 @@ void InitNetlib() void DeinitNetlib()
{
- if (hNetlibUser)
- CallService(MS_NETLIB_CLOSEHANDLE, (WPARAM)hNetlibUser, 0);
+ Netlib_CloseHandle(hNetlibUser);
}
int Sent_NetLog(const char *fmt, ...)
diff --git a/plugins/IEView/src/TemplateHTMLBuilder.cpp b/plugins/IEView/src/TemplateHTMLBuilder.cpp index a1a7a3e565..2910730b1c 100644 --- a/plugins/IEView/src/TemplateHTMLBuilder.cpp +++ b/plugins/IEView/src/TemplateHTMLBuilder.cpp @@ -39,14 +39,14 @@ char* TemplateHTMLBuilder::getAvatar(MCONTACT hContact, const char *szProto) wchar_t *result = NULL;
if (Options::getAvatarServiceFlags() == Options::AVATARSERVICE_PRESENT) {
- avatarCacheEntry *ace;
+ AVATARCACHEENTRY *ace;
if (hContact == NULL)
- ace = (avatarCacheEntry *)CallService(MS_AV_GETMYAVATAR, 0, (LPARAM)szProto);
+ ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETMYAVATAR, 0, (LPARAM)szProto);
else
- ace = (avatarCacheEntry *)CallService(MS_AV_GETAVATARBITMAP, hContact, 0);
+ ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, hContact, 0);
if (ace != NULL) {
- if (ace->cbSize == sizeof(avatarCacheEntry))
+ if (ace->cbSize == sizeof(AVATARCACHEENTRY))
result = ace->szFilename;
else // compatibility: in M0.9 it will always be char*
MultiByteToWideChar(CP_ACP, 0, (char*)ace->szFilename, -1, tmpPath, _countof(tmpPath));
diff --git a/plugins/MyDetails/src/data.cpp b/plugins/MyDetails/src/data.cpp index 6005135cd8..79a2cf47bd 100644 --- a/plugins/MyDetails/src/data.cpp +++ b/plugins/MyDetails/src/data.cpp @@ -265,7 +265,7 @@ void Protocol::GetAvatar() ace = NULL;
// Get HBITMAP from cache
- ace = (avatarCacheEntry *)CallService(MS_AV_GETMYAVATAR, 0, (LPARAM)name);
+ ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETMYAVATAR, 0, (LPARAM)name);
if (ace != NULL)
avatar_bmp = ace->hbmPic;
@@ -317,7 +317,7 @@ bool Protocol::CanSetAvatar() void Protocol::SetAvatar(const wchar_t *file_name)
{
if (CanSetAvatar())
- CallService(MS_AV_SETMYAVATART, (WPARAM)name, (LPARAM)file_name);
+ CallService(MS_AV_SETMYAVATARW, (WPARAM)name, (LPARAM)file_name);
}
bool Protocol::CanGetListeningTo()
@@ -450,7 +450,7 @@ void ProtocolArray::SetAvatars(const wchar_t *file_name) if (!CanSetAvatars())
return;
- CallService(MS_AV_SETMYAVATART, NULL, (WPARAM)file_name);
+ CallService(MS_AV_SETMYAVATARW, NULL, (WPARAM)file_name);
}
void ProtocolArray::SetNicks(const wchar_t *nick)
diff --git a/plugins/Popup/src/avatars.cpp b/plugins/Popup/src/avatars.cpp index 73bd43ede4..d099ddbd73 100644 --- a/plugins/Popup/src/avatars.cpp +++ b/plugins/Popup/src/avatars.cpp @@ -27,7 +27,7 @@ PopupAvatar *PopupAvatar::create(MCONTACT hContact) {
if (hContact) {
if (ServiceExists(MS_AV_GETAVATARBITMAP)) {
- avatarCacheEntry *av = (avatarCacheEntry *)CallService(MS_AV_GETAVATARBITMAP, hContact, 0);
+ AVATARCACHEENTRY *av = (AVATARCACHEENTRY*)CallService(MS_AV_GETAVATARBITMAP, hContact, 0);
if (av && (mir_wstrlen(av->szFilename) > 4))
if (!mir_wstrcmpi(av->szFilename + mir_wstrlen(av->szFilename) - 4, L".gif"))
if (db_get_b(NULL, MODULNAME, "EnableGifAnimation", 1) && GDIPlus_IsAnimatedGIF(av->szFilename))
diff --git a/plugins/Popup/src/avatars_gif.cpp b/plugins/Popup/src/avatars_gif.cpp index c0eba9f628..5b8cbac17c 100644 --- a/plugins/Popup/src/avatars_gif.cpp +++ b/plugins/Popup/src/avatars_gif.cpp @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. GifAvatar::GifAvatar(MCONTACT hContact) : PopupAvatar()
{
- av = (avatarCacheEntry *)CallService(MS_AV_GETAVATARBITMAP, hContact, 0);
+ av = (AVATARCACHEENTRY*)CallService(MS_AV_GETAVATARBITMAP, hContact, 0);
bIsAnimated = true;
bIsValid = true;
GDIPlus_GetGIFSize(av->szFilename, &this->width, &this->height);
diff --git a/plugins/Popup/src/avatars_gif.h b/plugins/Popup/src/avatars_gif.h index eca4c186c8..07cf5e1a49 100644 --- a/plugins/Popup/src/avatars_gif.h +++ b/plugins/Popup/src/avatars_gif.h @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. class GifAvatar : public PopupAvatar
{
protected:
- avatarCacheEntry *av;
+ AVATARCACHEENTRY *av;
int cachedWidth, cachedHeight;
int activeFrame;
diff --git a/plugins/Popup/src/avatars_simple.cpp b/plugins/Popup/src/avatars_simple.cpp index 5b55467b7f..b887bb27fd 100644 --- a/plugins/Popup/src/avatars_simple.cpp +++ b/plugins/Popup/src/avatars_simple.cpp @@ -36,7 +36,7 @@ SimpleAvatar::SimpleAvatar(HANDLE h, bool bUseBitmap) height = abs(bmp.bmHeight);
avNeedFree = true;
- av = new avatarCacheEntry;
+ av = new AVATARCACHEENTRY;
av->bmHeight = abs(bmp.bmHeight);
av->bmWidth = abs(bmp.bmWidth);
av->hbmPic = (HBITMAP)h;
@@ -46,7 +46,7 @@ SimpleAvatar::SimpleAvatar(HANDLE h, bool bUseBitmap) if (h && ServiceExists(MS_AV_GETAVATARBITMAP)) {
avNeedFree = false;
- av = (avatarCacheEntry *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)h, 0);
+ av = (AVATARCACHEENTRY*)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)h, 0);
if (av) {
if (av->hbmPic && (av->dwFlags&AVS_BITMAP_VALID) && !(av->dwFlags&AVS_HIDEONCLIST) && !(av->dwFlags&AVS_NOTREADY)) {
width = av->bmWidth;
diff --git a/plugins/Popup/src/avatars_simple.h b/plugins/Popup/src/avatars_simple.h index 0479674cd4..490e1f403b 100644 --- a/plugins/Popup/src/avatars_simple.h +++ b/plugins/Popup/src/avatars_simple.h @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. class SimpleAvatar : public PopupAvatar
{
private:
- avatarCacheEntry *av;
+ AVATARCACHEENTRY *av;
bool avNeedFree;
public:
diff --git a/plugins/Scriver/src/msgs.h b/plugins/Scriver/src/msgs.h index 2a2ba4411c..e3620340f7 100644 --- a/plugins/Scriver/src/msgs.h +++ b/plugins/Scriver/src/msgs.h @@ -134,7 +134,7 @@ struct SrmmWindowData : public CommonWindowData int lastEventType;
DWORD flags;
int messagesInProgress;
- struct avatarCacheEntry *ace;
+ struct AVATARCACHEENTRY *ace;
int isMixed;
int sendAllConfirm;
HICON statusIcon;
diff --git a/plugins/SecureIM/src/commonheaders.cpp b/plugins/SecureIM/src/commonheaders.cpp index eca5257814..0ac3f749e3 100644 --- a/plugins/SecureIM/src/commonheaders.cpp +++ b/plugins/SecureIM/src/commonheaders.cpp @@ -107,8 +107,7 @@ void InitNetlib() void DeinitNetlib()
{
- if (hNetlibUser)
- CallService(MS_NETLIB_CLOSEHANDLE, (WPARAM)hNetlibUser, 0);
+ Netlib_CloseHandle(hNetlibUser);
}
int Sent_NetLog(const char *fmt, ...)
diff --git a/plugins/SimpleStatusMsg/src/options.cpp b/plugins/SimpleStatusMsg/src/options.cpp index 9eedcc3e5f..fb3c1d931e 100644 --- a/plugins/SimpleStatusMsg/src/options.cpp +++ b/plugins/SimpleStatusMsg/src/options.cpp @@ -1654,7 +1654,8 @@ int InitOptions(WPARAM wParam, LPARAM) odp.flags = ODPF_BOLDGROUPS;
if (!ServiceExists(MS_SS_GETPROFILECOUNT)) {
- odp.szTitle.a = LPGEN("Status");
+ odp.szTitle.a = LPGEN("Startup status");
+ odp.szGroup.a = LPGEN("Status");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_STATUS);
odp.pfnDlgProc = DlgStatusOptionsProc;
Options_AddPage(wParam, &odp);
diff --git a/plugins/SimpleStatusMsg/src/version.h b/plugins/SimpleStatusMsg/src/version.h index a888247a47..9ead42738d 100644 --- a/plugins/SimpleStatusMsg/src/version.h +++ b/plugins/SimpleStatusMsg/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 1 #define __MINOR_VERSION 9 #define __RELEASE_NUM 0 -#define __BUILD_NUM 5 +#define __BUILD_NUM 6 #include <stdver.h> diff --git a/plugins/StatusManager/StatusManager.vcxproj b/plugins/StatusManager/StatusManager.vcxproj index 8fb9c5748d..f194247e9c 100644 --- a/plugins/StatusManager/StatusManager.vcxproj +++ b/plugins/StatusManager/StatusManager.vcxproj @@ -26,6 +26,18 @@ <Import Project="$(ProjectDir)..\..\build\vc.common\plugin.props" /> </ImportGroup> <ItemGroup> + <ClInclude Include="src\KeepStatus\*.h" /> + <ClCompile Include="src\KeepStatus\*.cpp"> + <PrecompiledHeaderFile>..\stdafx.h</PrecompiledHeaderFile> + </ClCompile> + <ClInclude Include="src\StartupStatus\*.h" /> + <ClCompile Include="src\StartupStatus\*.cpp"> + <PrecompiledHeaderFile>..\stdafx.h</PrecompiledHeaderFile> + </ClCompile> + <ClInclude Include="src\AdvancedAutoAway\*.h" /> + <ClCompile Include="src\AdvancedAutoAway\*.cpp"> + <PrecompiledHeaderFile>..\stdafx.h</PrecompiledHeaderFile> + </ClCompile> <ClCompile Include="..\helpers\gen_helpers.cpp"> <PrecompiledHeader>NotUsing</PrecompiledHeader> </ClCompile> @@ -39,4 +51,4 @@ <ExceptionHandling>Sync</ExceptionHandling> </ClCompile> </ItemDefinitionGroup> -</Project>
\ No newline at end of file +</Project> diff --git a/plugins/StatusManager/StatusManager.vcxproj.filters b/plugins/StatusManager/StatusManager.vcxproj.filters index 3361c3477f..8f90aeb3d5 100644 --- a/plugins/StatusManager/StatusManager.vcxproj.filters +++ b/plugins/StatusManager/StatusManager.vcxproj.filters @@ -1,374 +1,4 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$(ProjectDir)..\..\build\vc.common\common.filters" /> - <ItemGroup> - <ClCompile Include="src\stdafx.cxx"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="src\commonstatus.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="src\keepstatus.cpp" /> - <ClCompile Include="src\main.cpp" /> - <ClCompile Include="src\options.cpp" /> - <ClCompile Include="src\commonstatus.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="src\keepstatus.cpp" /> - <ClCompile Include="src\main.cpp" /> - <ClCompile Include="src\options.cpp" /> - <ClCompile Include="src\commonstatus.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="src\keepstatus.cpp" /> - <ClCompile Include="src\main.cpp" /> - <ClCompile Include="src\options.cpp" /> - <ClCompile Include="src\commonstatus.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="src\keepstatus.cpp" /> - <ClCompile Include="src\main.cpp" /> - <ClCompile Include="src\options.cpp" /> - <ClCompile Include="src\commonstatus.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="src\keepstatus.cpp" /> - <ClCompile Include="src\main.cpp" /> - <ClCompile Include="src\options.cpp" /> - <ClCompile Include="src\commonstatus.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="src\keepstatus.cpp" /> - <ClCompile Include="src\main.cpp" /> - <ClCompile Include="src\options.cpp" /> - <ClCompile Include="src\aaa_msgoptions.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="src\aaa_options.cpp" /> - <ClCompile Include="src\advancedautoaway.cpp" /> - <ClCompile Include="src\commonstatus.cpp" /> - <ClCompile Include="src\confirmdialog.cpp" /> - <ClCompile Include="src\keepstatus.cpp" /> - <ClCompile Include="src\ks_options.cpp" /> - <ClCompile Include="src\main.cpp" /> - <ClCompile Include="src\ss_options.cpp" /> - <ClCompile Include="src\ss_profiles.cpp" /> - <ClCompile Include="src\ss_toolbars.cpp" /> - <ClCompile Include="src\startupstatus.cpp" /> - <ClCompile Include="src\aaa_msgoptions.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="src\aaa_options.cpp" /> - <ClCompile Include="src\advancedautoaway.cpp" /> - <ClCompile Include="src\commonstatus.cpp" /> - <ClCompile Include="src\confirmdialog.cpp" /> - <ClCompile Include="src\keepstatus.cpp" /> - <ClCompile Include="src\ks_options.cpp" /> - <ClCompile Include="src\main.cpp" /> - <ClCompile Include="src\ss_options.cpp" /> - <ClCompile Include="src\ss_profiles.cpp" /> - <ClCompile Include="src\ss_toolbars.cpp" /> - <ClCompile Include="src\startupstatus.cpp" /> - <ClCompile Include="src\aaa_msgoptions.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="src\aaa_options.cpp" /> - <ClCompile Include="src\advancedautoaway.cpp" /> - <ClCompile Include="src\commonstatus.cpp" /> - <ClCompile Include="src\confirmdialog.cpp" /> - <ClCompile Include="src\keepstatus.cpp" /> - <ClCompile Include="src\ks_options.cpp" /> - <ClCompile Include="src\main.cpp" /> - <ClCompile Include="src\ss_options.cpp" /> - <ClCompile Include="src\ss_profiles.cpp" /> - <ClCompile Include="src\ss_toolbars.cpp" /> - <ClCompile Include="src\startupstatus.cpp" /> - <ClCompile Include="src\aaa_msgoptions.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="src\aaa_options.cpp" /> - <ClCompile Include="src\advancedautoaway.cpp" /> - <ClCompile Include="src\commonstatus.cpp" /> - <ClCompile Include="src\confirmdialog.cpp" /> - <ClCompile Include="src\keepstatus.cpp" /> - <ClCompile Include="src\ks_options.cpp" /> - <ClCompile Include="src\main.cpp" /> - <ClCompile Include="src\ss_options.cpp" /> - <ClCompile Include="src\ss_profiles.cpp" /> - <ClCompile Include="src\ss_toolbars.cpp" /> - <ClCompile Include="src\startupstatus.cpp" /> - <ClCompile Include="src\aaa_msgoptions.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="src\aaa_options.cpp" /> - <ClCompile Include="src\advancedautoaway.cpp" /> - <ClCompile Include="src\commonstatus.cpp" /> - <ClCompile Include="src\confirmdialog.cpp" /> - <ClCompile Include="src\keepstatus.cpp" /> - <ClCompile Include="src\ks_options.cpp" /> - <ClCompile Include="src\main.cpp" /> - <ClCompile Include="src\ss_options.cpp" /> - <ClCompile Include="src\ss_profiles.cpp" /> - <ClCompile Include="src\ss_toolbars.cpp" /> - <ClCompile Include="src\startupstatus.cpp" /> - <ClCompile Include="src\aaa_msgoptions.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="src\aaa_options.cpp" /> - <ClCompile Include="src\advancedautoaway.cpp" /> - <ClCompile Include="src\commonstatus.cpp" /> - <ClCompile Include="src\confirmdialog.cpp" /> - <ClCompile Include="src\keepstatus.cpp" /> - <ClCompile Include="src\ks_options.cpp" /> - <ClCompile Include="src\main.cpp" /> - <ClCompile Include="src\ss_options.cpp" /> - <ClCompile Include="src\ss_profiles.cpp" /> - <ClCompile Include="src\ss_toolbars.cpp" /> - <ClCompile Include="src\startupstatus.cpp" /> - <ClCompile Include="src\aaa_msgoptions.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="src\aaa_options.cpp" /> - <ClCompile Include="src\advancedautoaway.cpp" /> - <ClCompile Include="src\commonstatus.cpp" /> - <ClCompile Include="src\confirmdialog.cpp" /> - <ClCompile Include="src\keepstatus.cpp" /> - <ClCompile Include="src\ks_options.cpp" /> - <ClCompile Include="src\main.cpp" /> - <ClCompile Include="src\ss_options.cpp" /> - <ClCompile Include="src\ss_profiles.cpp" /> - <ClCompile Include="src\ss_toolbars.cpp" /> - <ClCompile Include="src\startupstatus.cpp" /> - <ClCompile Include="src\aaa_msgoptions.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="src\aaa_options.cpp" /> - <ClCompile Include="src\advancedautoaway.cpp" /> - <ClCompile Include="src\commonstatus.cpp" /> - <ClCompile Include="src\confirmdialog.cpp" /> - <ClCompile Include="src\keepstatus.cpp" /> - <ClCompile Include="src\ks_options.cpp" /> - <ClCompile Include="src\main.cpp" /> - <ClCompile Include="src\ss_options.cpp" /> - <ClCompile Include="src\ss_profiles.cpp" /> - <ClCompile Include="src\ss_toolbars.cpp" /> - <ClCompile Include="src\startupstatus.cpp" /> - <ClCompile Include="src\aaa_msgoptions.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="src\aaa_options.cpp" /> - <ClCompile Include="src\advancedautoaway.cpp" /> - <ClCompile Include="src\commonstatus.cpp" /> - <ClCompile Include="src\confirmdialog.cpp" /> - <ClCompile Include="src\keepstatus.cpp" /> - <ClCompile Include="src\ks_options.cpp" /> - <ClCompile Include="src\main.cpp" /> - <ClCompile Include="src\ss_options.cpp" /> - <ClCompile Include="src\ss_profiles.cpp" /> - <ClCompile Include="src\ss_toolbars.cpp" /> - <ClCompile Include="src\startupstatus.cpp" /> - <ClCompile Include="src\aaa_msgoptions.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="src\aaa_options.cpp" /> - <ClCompile Include="src\advancedautoaway.cpp" /> - <ClCompile Include="src\commonstatus.cpp" /> - <ClCompile Include="src\confirmdialog.cpp" /> - <ClCompile Include="src\keepstatus.cpp" /> - <ClCompile Include="src\ks_options.cpp" /> - <ClCompile Include="src\main.cpp" /> - <ClCompile Include="src\ss_options.cpp" /> - <ClCompile Include="src\ss_profiles.cpp" /> - <ClCompile Include="src\ss_toolbars.cpp" /> - <ClCompile Include="src\startupstatus.cpp" /> - <ClCompile Include="src\aaa_msgoptions.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="src\aaa_options.cpp" /> - <ClCompile Include="src\advancedautoaway.cpp" /> - <ClCompile Include="src\commonstatus.cpp" /> - <ClCompile Include="src\confirmdialog.cpp" /> - <ClCompile Include="src\keepstatus.cpp" /> - <ClCompile Include="src\ks_options.cpp" /> - <ClCompile Include="src\main.cpp" /> - <ClCompile Include="src\ss_options.cpp" /> - <ClCompile Include="src\ss_profiles.cpp" /> - <ClCompile Include="src\ss_toolbars.cpp" /> - <ClCompile Include="src\startupstatus.cpp" /> - <ClCompile Include="src\aaa_msgoptions.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="src\aaa_options.cpp" /> - <ClCompile Include="src\advancedautoaway.cpp" /> - <ClCompile Include="src\commonstatus.cpp" /> - <ClCompile Include="src\confirmdialog.cpp" /> - <ClCompile Include="src\keepstatus.cpp" /> - <ClCompile Include="src\ks_options.cpp" /> - <ClCompile Include="src\main.cpp" /> - <ClCompile Include="src\ss_options.cpp" /> - <ClCompile Include="src\ss_profiles.cpp" /> - <ClCompile Include="src\ss_toolbars.cpp" /> - <ClCompile Include="src\startupstatus.cpp" /> - <ClCompile Include="..\helpers\gen_helpers.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - </ItemGroup> - <ItemGroup> - <ClInclude Include="src\commonstatus.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="src\keepstatus.h" /> - <ClInclude Include="src\resource.h" /> - <ClInclude Include="src\stdafx.h" /> - <ClInclude Include="src\version.h" /> - <ClInclude Include="src\commonstatus.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="src\keepstatus.h" /> - <ClInclude Include="src\resource.h" /> - <ClInclude Include="src\stdafx.h" /> - <ClInclude Include="src\version.h" /> - <ClInclude Include="src\commonstatus.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="src\keepstatus.h" /> - <ClInclude Include="src\resource.h" /> - <ClInclude Include="src\stdafx.h" /> - <ClInclude Include="src\version.h" /> - <ClInclude Include="src\commonstatus.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="src\keepstatus.h" /> - <ClInclude Include="src\resource.h" /> - <ClInclude Include="src\stdafx.h" /> - <ClInclude Include="src\version.h" /> - <ClInclude Include="src\commonstatus.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="src\keepstatus.h" /> - <ClInclude Include="src\resource.h" /> - <ClInclude Include="src\stdafx.h" /> - <ClInclude Include="src\version.h" /> - <ClInclude Include="src\commonstatus.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="src\keepstatus.h" /> - <ClInclude Include="src\resource.h" /> - <ClInclude Include="src\stdafx.h" /> - <ClInclude Include="src\version.h" /> - <ClInclude Include="src\commonstatus.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="src\keepstatus.h" /> - <ClInclude Include="src\resource.h" /> - <ClInclude Include="src\stdafx.h" /> - <ClInclude Include="src\version.h" /> - <ClInclude Include="src\commonstatus.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="src\keepstatus.h" /> - <ClInclude Include="src\resource.h" /> - <ClInclude Include="src\stdafx.h" /> - <ClInclude Include="src\version.h" /> - <ClInclude Include="src\advancedautoaway.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="src\commonstatus.h" /> - <ClInclude Include="src\keepstatus.h" /> - <ClInclude Include="src\resource.h" /> - <ClInclude Include="src\startupstatus.h" /> - <ClInclude Include="src\stdafx.h" /> - <ClInclude Include="src\version.h" /> - <ClInclude Include="src\advancedautoaway.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="src\commonstatus.h" /> - <ClInclude Include="src\keepstatus.h" /> - <ClInclude Include="src\resource.h" /> - <ClInclude Include="src\startupstatus.h" /> - <ClInclude Include="src\stdafx.h" /> - <ClInclude Include="src\version.h" /> - <ClInclude Include="src\advancedautoaway.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="src\commonstatus.h" /> - <ClInclude Include="src\keepstatus.h" /> - <ClInclude Include="src\resource.h" /> - <ClInclude Include="src\startupstatus.h" /> - <ClInclude Include="src\stdafx.h" /> - <ClInclude Include="src\version.h" /> - <ClInclude Include="src\advancedautoaway.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="src\commonstatus.h" /> - <ClInclude Include="src\keepstatus.h" /> - <ClInclude Include="src\resource.h" /> - <ClInclude Include="src\startupstatus.h" /> - <ClInclude Include="src\stdafx.h" /> - <ClInclude Include="src\version.h" /> - <ClInclude Include="src\advancedautoaway.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="src\commonstatus.h" /> - <ClInclude Include="src\keepstatus.h" /> - <ClInclude Include="src\resource.h" /> - <ClInclude Include="src\startupstatus.h" /> - <ClInclude Include="src\stdafx.h" /> - <ClInclude Include="src\version.h" /> - <ClInclude Include="src\advancedautoaway.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="src\commonstatus.h" /> - <ClInclude Include="src\keepstatus.h" /> - <ClInclude Include="src\resource.h" /> - <ClInclude Include="src\startupstatus.h" /> - <ClInclude Include="src\stdafx.h" /> - <ClInclude Include="src\version.h" /> - <ClInclude Include="src\advancedautoaway.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="src\commonstatus.h" /> - <ClInclude Include="src\keepstatus.h" /> - <ClInclude Include="src\resource.h" /> - <ClInclude Include="src\startupstatus.h" /> - <ClInclude Include="src\stdafx.h" /> - <ClInclude Include="src\version.h" /> - </ItemGroup> - <ItemGroup> - <ResourceCompile Include="res\resource.rc"> - <Filter>Resource Files</Filter> - </ResourceCompile> - <ResourceCompile Include="res\StartupStatus.rc" /> - <ResourceCompile Include="res\version.rc" /> - <ResourceCompile Include="res\resource.rc"> - <Filter>Resource Files</Filter> - </ResourceCompile> - <ResourceCompile Include="res\StartupStatus.rc" /> - <ResourceCompile Include="res\version.rc" /> - <ResourceCompile Include="res\resource.rc"> - <Filter>Resource Files</Filter> - </ResourceCompile> - <ResourceCompile Include="res\StartupStatus.rc" /> - <ResourceCompile Include="res\version.rc" /> - <ResourceCompile Include="res\resource.rc"> - <Filter>Resource Files</Filter> - </ResourceCompile> - <ResourceCompile Include="res\StartupStatus.rc" /> - <ResourceCompile Include="res\version.rc" /> - <ResourceCompile Include="res\resource.rc"> - <Filter>Resource Files</Filter> - </ResourceCompile> - <ResourceCompile Include="res\StartupStatus.rc" /> - <ResourceCompile Include="res\version.rc" /> - <ResourceCompile Include="res\resource.rc"> - <Filter>Resource Files</Filter> - </ResourceCompile> - <ResourceCompile Include="res\StartupStatus.rc" /> - <ResourceCompile Include="res\version.rc" /> - <ResourceCompile Include="res\resource.rc"> - <Filter>Resource Files</Filter> - </ResourceCompile> - <ResourceCompile Include="res\StartupStatus.rc" /> - <ResourceCompile Include="res\version.rc" /> - </ItemGroup> -</Project>
\ No newline at end of file +</Project> diff --git a/plugins/StatusManager/res/notick.ico b/plugins/StatusManager/res/notick.ico Binary files differdeleted file mode 100644 index 7f93490642..0000000000 --- a/plugins/StatusManager/res/notick.ico +++ /dev/null diff --git a/plugins/StatusManager/res/notick1.ico b/plugins/StatusManager/res/notick1.ico Binary files differdeleted file mode 100644 index 609504d614..0000000000 --- a/plugins/StatusManager/res/notick1.ico +++ /dev/null diff --git a/plugins/StatusManager/res/resource.rc b/plugins/StatusManager/res/resource.rc index 5497def240..3edc4bc950 100644 --- a/plugins/StatusManager/res/resource.rc +++ b/plugins/StatusManager/res/resource.rc @@ -13,49 +13,73 @@ #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// -// German (Germany) resources +// English resources -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) -LANGUAGE LANG_GERMAN, SUBLANG_GERMAN +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL #pragma code_page(1252) -#ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // -// TEXTINCLUDE +// Dialog // -1 TEXTINCLUDE +IDD_OPT_SUBPLUGINS DIALOGEX 0, 0, 302, 181 +STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - "..\\src\\resource.h\0" + GROUPBOX "Enable modules",IDC_STATIC,9,8,282,156 + CONTROL "Keep status",IDC_ENABLE_KEEPSTATUS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,24,262,10 + LTEXT "A connection checker. Automatically reconnects your accounts after protocol error or internet drop.",IDC_STATIC,40,36,241,24 + CONTROL "Startup status",IDC_ENABLE_STARTUPSTATUS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,64,262,10 + LTEXT "Allows you to define the status Miranda should set on startup, configurable per account.",IDC_STATIC,40,76,241,24 + CONTROL "Advanced auto away",IDC_ENABLE_ADVANCEDAUTOAWAY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,105,262,10 + LTEXT "Improved Auto Away module with some more options than the built in, configurable per account.",IDC_STATIC,40,117,241,24 + LTEXT "Note: Miranda NG will have to be restarted for changes to take effect.",IDC_STATIC,19,148,270,9 END -2 TEXTINCLUDE -BEGIN - "#include ""winres.h""\r\n" - "\0" -END -3 TEXTINCLUDE +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO BEGIN - "\r\n" - "\0" + IDD_OPT_SUBPLUGINS, DIALOG + BEGIN + RIGHTMARGIN, 298 + VERTGUIDE, 19 + VERTGUIDE, 40 + VERTGUIDE, 281 + BOTTOMMARGIN, 176 + END END - #endif // APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // -// Icon +// AFX_DIALOG_LAYOUT // -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_TTBDOWN ICON "ttbDown.ico" +IDD_OPT_SUBPLUGINS AFX_DIALOG_LAYOUT +BEGIN + 0x0000 +END -IDI_TTBUP ICON "ttbUp.ico" +#endif // English resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// German (Germany) resources +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) +LANGUAGE LANG_GERMAN, SUBLANG_GERMAN +#pragma code_page(1252) ///////////////////////////////////////////////////////////////////////////// // @@ -360,7 +384,7 @@ BEGIN END IDD_TRG_AAASTATECHANGE DIALOGEX 0, 0, 212, 144 -STYLE DS_SETFONT | DS_3DLOOK | WS_CHILD +STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_CHILD EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN @@ -368,12 +392,12 @@ BEGIN CONTROL "Entering second auto-away status",IDC_ENTERSECOND, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,37,123,10 CONTROL "Leaving first auto-away status",IDC_LEAVEFIRST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,50,109,10 - CONTROL "Leaving second auto-away status",IDC_LEAVESECOND,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,63,122,10 - CONTROL "Becoming active without status change",IDC_BECOMEACTIVE, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,76,140,10 GROUPBOX "Pre-conditions",IDC_STATIC,7,7,198,89 - GROUPBOX "TriggerData",IDC_STATIC,7,97,198,40 LTEXT "Status: The status the account will change to\r\nAccount: The account changing state",IDC_STATIC,19,111,177,18 + GROUPBOX "TriggerData",IDC_STATIC,7,97,198,40 + CONTROL "Becoming active without status change",IDC_BECOMEACTIVE, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,76,140,10 + CONTROL "Leaving second auto-away status",IDC_LEAVESECOND,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,63,122,10 END @@ -445,6 +469,10 @@ BEGIN VERTGUIDE, 11 VERTGUIDE, 283 END + + IDD_TRG_AAASTATECHANGE, DIALOG + BEGIN + END END #endif // APSTUDIO_INVOKED @@ -454,32 +482,73 @@ END // AFX_DIALOG_LAYOUT // -IDD_OPT_KS_ADV AFX_DIALOG_LAYOUT +IDD_OPT_KS_ADV AFX_DIALOG_LAYOUT +BEGIN + 0x0000 +END + +IDD_OPT_AUTOAWAY AFX_DIALOG_LAYOUT +BEGIN + 0x0000 +END + +IDD_OPT_GENAUTOAWAY AFX_DIALOG_LAYOUT BEGIN - 0 + 0x0000 END -IDD_OPT_AUTOAWAY AFX_DIALOG_LAYOUT +IDD_OPT_KS_BASIC AFX_DIALOG_LAYOUT BEGIN - 0 + 0x0000 END -IDD_OPT_GENAUTOAWAY AFX_DIALOG_LAYOUT +IDD_PUOPT_KEEPSTATUS AFX_DIALOG_LAYOUT BEGIN - 0 + 0x0000 END -IDD_OPT_KS_BASIC AFX_DIALOG_LAYOUT +IDD_TRG_AAASTATECHANGE AFX_DIALOG_LAYOUT BEGIN - 0 + 0x0000 END -IDD_PUOPT_KEEPSTATUS AFX_DIALOG_LAYOUT + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE BEGIN - 0 + "..\\src\\resource.h\0" END -#endif // Deutsch (Deutschland) resources +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_TTBDOWN ICON "ttbDown.ico" +IDI_TTBUP ICON "ttbUp.ico" +#endif // German (Germany) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/plugins/StatusManager/res/useronli.ico b/plugins/StatusManager/res/useronli.ico Binary files differdeleted file mode 100644 index 2760c47d5c..0000000000 --- a/plugins/StatusManager/res/useronli.ico +++ /dev/null diff --git a/plugins/StatusManager/src/aaa_msgoptions.cpp b/plugins/StatusManager/src/AdvancedAutoAway/aaa_msgoptions.cpp index 5647199a43..2484440b2a 100644 --- a/plugins/StatusManager/src/aaa_msgoptions.cpp +++ b/plugins/StatusManager/src/AdvancedAutoAway/aaa_msgoptions.cpp @@ -17,7 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "stdafx.h" +#include "..\stdafx.h" extern char *StatusModeToDbSetting(int status,const char *suffix); diff --git a/plugins/StatusManager/src/aaa_options.cpp b/plugins/StatusManager/src/AdvancedAutoAway/aaa_options.cpp index d26678c1ce..63971adcdf 100644 --- a/plugins/StatusManager/src/aaa_options.cpp +++ b/plugins/StatusManager/src/AdvancedAutoAway/aaa_options.cpp @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "stdafx.h" +#include "..\stdafx.h" int LoadAutoAwaySetting(TAAAProtoSetting &autoAwaySetting, char* protoName); @@ -119,7 +119,7 @@ static void SetDialogStatus(HWND hwndDlg, TAAAProtoSetting *sameSetting) ///////////////////////////////////////////////////////////////////////////////////////// // Rules dialog window procedure -static TAAAProtoSettingList optionSettings(10, CompareSettings); +static TAAAProtoSettingList optionSettings(10, AAACompareSettings); static INT_PTR CALLBACK DlgProcAutoAwayRulesOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -337,7 +337,7 @@ static INT_PTR CALLBACK DlgProcAutoAwayRulesOpts(HWND hwndDlg, UINT msg, WPARAM for (int i = 0; i < optionSettings.getCount(); i++) WriteAutoAwaySetting(optionSettings[i], optionSettings[i].szName); } - LoadOptions(autoAwaySettings, FALSE); + AAALoadOptions(autoAwaySettings, FALSE); } break; @@ -402,7 +402,7 @@ static INT_PTR CALLBACK DlgProcAutoAwayGeneralOpts(HWND hwndDlg, UINT msg, WPARA db_set_w(NULL, AAAMODULENAME, SETTING_CONFIRMDELAY, (WORD)GetDlgItemInt(hwndDlg, IDC_CONFIRMDELAY, NULL, FALSE)); db_set_b(NULL, AAAMODULENAME, SETTING_MONITORMOUSE, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_MONITORMOUSE)); db_set_b(NULL, AAAMODULENAME, SETTING_MONITORKEYBOARD, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_MONITORKEYBOARD)); - LoadOptions(autoAwaySettings, FALSE); + AAALoadOptions(autoAwaySettings, FALSE); } break; } @@ -513,6 +513,7 @@ int AutoAwayOptInitialise(WPARAM wParam, LPARAM) OPTIONSDIALOGPAGE odp = { 0 }; odp.position = 1000000000; odp.hInstance = hInst; + odp.hLangpack = hAAALangpack; odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_TABS); odp.szTitle.a = LPGEN("Auto away"); odp.szGroup.a = LPGEN("Status"); diff --git a/plugins/StatusManager/src/advancedautoaway.cpp b/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp index 7f09466bd2..b9647816f2 100644 --- a/plugins/StatusManager/src/advancedautoaway.cpp +++ b/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp @@ -20,7 +20,9 @@ Some code is copied from Miranda's AutoAway module */ -#include "stdafx.h" +#include "..\stdafx.h" + +int hAAALangpack = 0; #ifdef _DEBUG #define SECS_PER_MINUTE 20 /* speedup */ @@ -30,12 +32,7 @@ ///////////////////////////////////////////////////////////////////////////////////////// -int CompareSettings(const TAAAProtoSetting *p1, const TAAAProtoSetting *p2) -{ - return mir_strcmp(p1->szName, p2->szName); -} - -TAAAProtoSettingList autoAwaySettings(10, CompareSettings); +TAAAProtoSettingList autoAwaySettings(10, AAACompareSettings); TAAAProtoSetting::TAAAProtoSetting(PROTOACCOUNT *pa) { @@ -55,7 +52,8 @@ TAAAProtoSetting::~TAAAProtoSetting() ///////////////////////////////////////////////////////////////////////////////////////// -extern HANDLE hStateChangedEvent; +HANDLE hAAAModuleLoadedHook = NULL, + hStateChangedEvent = NULL; static BOOL ignoreLockKeys = FALSE; static BOOL ignoreSysKeys = FALSE; @@ -95,7 +93,7 @@ extern char *StatusModeToDbSetting(int status,const char *suffix); ///////////////////////////////////////////////////////////////////////////////////////// // Load from DB -void LoadOptions(TAAAProtoSettingList &loadSettings, BOOL override) +void AAALoadOptions(TAAAProtoSettingList &loadSettings, BOOL override) { // if override is enabled, samesettings will be ignored (for options loading) int monitorMiranda = FALSE; // use windows hooks? @@ -562,7 +560,7 @@ static int AutoAwayShutdown(WPARAM, LPARAM) return 0; } -int AAACSModuleLoaded(WPARAM, LPARAM) +int AAAModuleLoaded(WPARAM, LPARAM) { HookEvent(ME_PROTO_ACCLISTCHANGED, OnAAAAccChanged); HookEvent(ME_OPT_INITIALISE, AutoAwayOptInitialise); @@ -585,6 +583,21 @@ int AAACSModuleLoaded(WPARAM, LPARAM) //////////////////////////////////////////////////////////////////////////////////////// - LoadOptions(autoAwaySettings, FALSE); + AAALoadOptions(autoAwaySettings, FALSE); return 0; } + +void AdvancedAutoAwayLoad() +{ + MUUID muidLast = MIID_LAST; + hAAALangpack = GetPluginLangId(muidLast, 0); + + hAAAModuleLoadedHook = HookEvent(ME_SYSTEM_MODULESLOADED, AAAModuleLoaded); + hStateChangedEvent = CreateHookableEvent(ME_AAA_STATECHANGED); +} + +void AdvancedAutoAwayUnload() +{ + UnhookEvent(hAAAModuleLoadedHook); + DestroyHookableEvent(hStateChangedEvent); +}
\ No newline at end of file diff --git a/plugins/StatusManager/src/advancedautoaway.h b/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.h index a8177c2a77..3f3a0b3c02 100644 --- a/plugins/StatusManager/src/advancedautoaway.h +++ b/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.h @@ -19,6 +19,8 @@ #ifndef __ADVANCED_AUTOAWAY_HEADER #define __ADVANCED_AUTOAWAY_HEADER +extern int hAAALangpack; + #define AAAMODULENAME "AdvancedAutoAway" #define SETTING_IGNLOCK "IgnoreLockKeys" #define SETTING_IGNSYSKEYS "IgnoreSysKeys" @@ -70,6 +72,11 @@ struct TAAAProtoSetting : public PROTOCOLSETTINGEX, public MZeroedObject unsigned int sts1setTimer; }; +static int AAACompareSettings(const TAAAProtoSetting *p1, const TAAAProtoSetting *p2) +{ + return mir_strcmp(p1->szName, p2->szName); +} + struct AAMSGSETTING { short useCustom; @@ -77,14 +84,13 @@ struct AAMSGSETTING char* msg; }; -extern HINSTANCE hInst; - -int CompareSettings( const TAAAProtoSetting *p1, const TAAAProtoSetting *p2 ); +void AdvancedAutoAwayLoad(); +void AdvancedAutoAwayUnload(); typedef OBJLIST<TAAAProtoSetting> TAAAProtoSettingList; extern TAAAProtoSettingList autoAwaySettings; int LoadAutoAwaySetting(TAAAProtoSetting &autoAwaySetting, char *protoName); -void LoadOptions(TAAAProtoSettingList &settings, BOOL override); +void AAALoadOptions(TAAAProtoSettingList &settings, BOOL override); #endif diff --git a/plugins/StatusManager/src/keepstatus.cpp b/plugins/StatusManager/src/KeepStatus/keepstatus.cpp index 41c244cde4..1cc209f0c7 100644 --- a/plugins/StatusManager/src/keepstatus.cpp +++ b/plugins/StatusManager/src/KeepStatus/keepstatus.cpp @@ -17,7 +17,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "stdafx.h" +#include "..\stdafx.h" + +int hKSLangpack = 0; struct TimerInfo { int timer; @@ -27,6 +29,16 @@ struct TimerInfo { HANDLE hEvent; }; +HANDLE hMainThread = 0; +unsigned long mainThreadId = 0; + +HANDLE hKSModuleLoadedHook = NULL, + hConnectionEvent = NULL, + hStopRecon = NULL, + hEnableProto = NULL, + hIsProtoEnabled = NULL, + hAnnounceStat = NULL; + static mir_cs GenTimerCS, GenStatusCS, CheckContinueslyCS; static HANDLE hProtoAckHook = NULL; @@ -34,9 +46,6 @@ static HANDLE hStatusChangeHook = NULL; static HANDLE hCSStatusChangeHook = NULL; static HANDLE hCSStatusChangeExHook = NULL; -extern HANDLE hConnectionEvent; -extern PLUGININFOEX pluginInfoEx; - static HWND hMessageWindow = NULL; static int CompareConnections(const TConnectionSettings *p1, const TConnectionSettings *p2) @@ -64,7 +73,6 @@ static int showConnectionPopups = 0; // prototypes static int StartTimer(int timer, int timeout, BOOL restart); static int StopTimer(int timer); -int KSLoadMainOptions(); static void GetCurrentConnectionSettings(); static int AssignStatus(TConnectionSettings* connSetting, int status, int lastStatus, wchar_t *szMsg); static int ProcessProtoAck(WPARAM wParam, LPARAM lParam); @@ -83,7 +91,7 @@ INT_PTR IsProtocolEnabledService(WPARAM wParam, LPARAM lParam); static int ProcessPopup(int reason, LPARAM lParam); static INT_PTR ShowPopup(wchar_t *msg, HICON hIcon); -LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); +LRESULT CALLBACK KSPopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); static DWORD CALLBACK MessageWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); // options.c @@ -106,7 +114,7 @@ TConnectionSettings::~TConnectionSettings() free(szMsg); } -int KSLoadMainOptions() +int KSLoadOptions() { UnhookEvent(hProtoAckHook); UnhookEvent(hStatusChangeHook); @@ -991,7 +999,7 @@ static INT_PTR ShowPopup(wchar_t *msg, HICON hIcon) ppd.colorBack = db_get_dw(NULL, KSMODULENAME, SETTING_POPUP_BACKCOLOR, 0xAAAAAA); ppd.colorText = db_get_dw(NULL, KSMODULENAME, SETTING_POPUP_TEXTCOLOR, 0x0000CC); } - ppd.PluginWindowProc = PopupDlgProc; + ppd.PluginWindowProc = KSPopupDlgProc; switch (db_get_b(NULL, KSMODULENAME, SETTING_POPUP_DELAYTYPE, POPUP_DELAYFROMPU)) { case POPUP_DELAYCUSTOM: @@ -1012,7 +1020,7 @@ static INT_PTR ShowPopup(wchar_t *msg, HICON hIcon) return PUAddPopupT(&ppd); } -LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK KSPopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_CONTEXTMENU: // right @@ -1193,15 +1201,48 @@ static int onShutdown(WPARAM, LPARAM) return 0; } -int KSCSModuleLoaded(WPARAM, LPARAM) +int KSModuleLoaded(WPARAM, LPARAM) { protoList = (OBJLIST<PROTOCOLSETTINGEX>*)&connectionSettings; hMessageWindow = NULL; - KSLoadMainOptions(); + KSLoadOptions(); HookEvent(ME_OPT_INITIALISE, KeepStatusOptionsInit); HookEvent(ME_SYSTEM_PRESHUTDOWN, onShutdown); HookEvent(ME_PROTO_ACCLISTCHANGED, OnKSAccChanged); return 0; } + +void KeepStatusLoad() +{ + MUUID muidLast = MIID_LAST; + hKSLangpack = GetPluginLangId(muidLast, 0); + + hKSModuleLoadedHook = HookEvent(ME_SYSTEM_MODULESLOADED, KSModuleLoaded); + + CreateHookableEvent(ME_KS_CONNECTIONEVENT); + + hStopRecon = CreateServiceFunction(MS_KS_STOPRECONNECTING, StopReconnectingService); + hEnableProto = CreateServiceFunction(MS_KS_ENABLEPROTOCOL, EnableProtocolService); + hIsProtoEnabled = CreateServiceFunction(MS_KS_ISPROTOCOLENABLED, IsProtocolEnabledService); + hAnnounceStat = CreateServiceFunction(MS_KS_ANNOUNCESTATUSCHANGE, AnnounceStatusChangeService); + + DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &hMainThread, THREAD_SET_CONTEXT, FALSE, 0); + mainThreadId = GetCurrentThreadId(); +} + +void KeepStatusUnload() +{ + if (hMainThread) + CloseHandle(hMainThread); + + DestroyServiceFunction(hStopRecon); + DestroyServiceFunction(hEnableProto); + DestroyServiceFunction(hIsProtoEnabled); + DestroyServiceFunction(hAnnounceStat); + + DestroyHookableEvent(hConnectionEvent); + + UnhookEvent(hKSModuleLoadedHook); +} diff --git a/plugins/StatusManager/src/keepstatus.h b/plugins/StatusManager/src/KeepStatus/keepstatus.h index d44b312e80..167bb1a051 100644 --- a/plugins/StatusManager/src/keepstatus.h +++ b/plugins/StatusManager/src/KeepStatus/keepstatus.h @@ -20,6 +20,7 @@ #ifndef __KEEPSTATUS_HEADER #define __KEEPSTATUS_HEADER +extern int hKSLangpack; #define KSMODULENAME "KeepStatus" #define SETTING_CHECKCONNECTION "CheckConnection" @@ -113,16 +114,12 @@ typedef struct { #define ME_CS_STATUSCHANGE "CommonStatus/StatusChange" ///////////////////////////////////////////////////////////////////////////////////////// -// main.cpp - -extern HINSTANCE hInst; -extern HANDLE hMainThread; -extern unsigned long mainThreadId; - -///////////////////////////////////////////////////////////////////////////////////////// // keepstatus.cpp -int KSLoadMainOptions(); -LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); +void KeepStatusLoad(); +void KeepStatusUnload(); +int KSLoadOptions(); + +LRESULT CALLBACK KSPopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); #endif //__KEEPSTATUS_HEADER diff --git a/plugins/StatusManager/src/ks_options.cpp b/plugins/StatusManager/src/KeepStatus/ks_options.cpp index 890981a8c1..1a4d6075b8 100644 --- a/plugins/StatusManager/src/ks_options.cpp +++ b/plugins/StatusManager/src/KeepStatus/ks_options.cpp @@ -17,7 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "stdafx.h" +#include "..\stdafx.h" // prototypes INT_PTR CALLBACK OptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); @@ -341,7 +341,7 @@ static INT_PTR CALLBACK DlgProcKsTabs(HWND hwndDlg, UINT msg, WPARAM wParam, LPA SendMessage((HWND)tci.lParam, WM_NOTIFY, 0, lParam); } // let main reload options - KSLoadMainOptions(); + KSLoadOptions(); } break; } @@ -497,7 +497,7 @@ INT_PTR CALLBACK PopupOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l ppd.colorBack = SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0); ppd.colorText = SendDlgItemMessage(hwndDlg, IDC_TEXTCOLOR, CPM_GETCOLOUR, 0, 0); } - ppd.PluginWindowProc = PopupDlgProc; + ppd.PluginWindowProc = KSPopupDlgProc; ppd.PluginData = NULL; if (IsDlgButtonChecked(hwndDlg, IDC_DELAYFROMPU)) { @@ -567,6 +567,7 @@ int KeepStatusOptionsInit(WPARAM wparam, LPARAM) { OPTIONSDIALOGPAGE odp = { 0 }; odp.hInstance = hInst; + odp.hLangpack = hKSLangpack; odp.szGroup.w = LPGENW("Status"); odp.szTitle.w = LPGENW("Keep status"); odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE; diff --git a/plugins/StatusManager/src/ss_options.cpp b/plugins/StatusManager/src/StartupStatus/ss_options.cpp index 2acf61483f..eaa5566820 100644 --- a/plugins/StatusManager/src/ss_options.cpp +++ b/plugins/StatusManager/src/StartupStatus/ss_options.cpp @@ -17,7 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "stdafx.h" +#include "..\stdafx.h" ///////////////////////////////////////////////////////////////////////////////////////// @@ -27,7 +27,7 @@ TSettingsList* GetCurrentProtoSettings() PROTOACCOUNT **protos; Proto_EnumAccounts(&count, &protos); - TSettingsList *result = new TSettingsList(count, CompareSettings); + TSettingsList *result = new TSettingsList(count, SSCompareSettings); if (result == NULL) return NULL; @@ -905,6 +905,7 @@ int StartupStatusOptionsInit(WPARAM wparam,LPARAM) { OPTIONSDIALOGPAGE odp = { 0 }; odp.hInstance = hInst; + odp.hLangpack = hSSLangpack; odp.szGroup.a = LPGEN("Status"); odp.szTitle.a = LPGEN("Startup status"); odp.flags = ODPF_BOLDGROUPS; diff --git a/plugins/StatusManager/src/ss_profiles.cpp b/plugins/StatusManager/src/StartupStatus/ss_profiles.cpp index 521d498fe9..5cb311b605 100644 --- a/plugins/StatusManager/src/ss_profiles.cpp +++ b/plugins/StatusManager/src/StartupStatus/ss_profiles.cpp @@ -17,7 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "stdafx.h" +#include "..\stdafx.h" #define MAX_MMITEMS 6 @@ -57,6 +57,7 @@ static int CreateMainMenuItems(WPARAM, LPARAM) CMenuItem mi; mi.position = 2000100000; mi.flags = CMIF_UNICODE; + mi.hLangpack = hSSLangpack; mcount = 0; int count = GetProfileCount(0, 0); for (int i = 0; i < count && mcount < MAX_MMITEMS; i++) { @@ -65,7 +66,7 @@ static int CreateMainMenuItems(WPARAM, LPARAM) continue; if (db_get_b(NULL, SSMODULENAME, OptName(i, SETTING_INSUBMENU), 1) && !mi.root) { - mi.root = Menu_CreateRoot(MO_STATUS, LPGENW("Status profiles"), 2000100000); + mi.root = Menu_CreateRoot(MO_STATUS, LPGENW("Status profiles"), 2000100000, 0, hSSLangpack); Menu_ConfigureItem(mi.root, MCI_OPT_UID, "1AB30D51-BABA-4B27-9288-1A12278BAD8D"); } @@ -199,7 +200,7 @@ INT_PTR LoadAndSetProfile(WPARAM iProfileNo, LPARAM) { // wParam == profile no. int profile = (int)iProfileNo; - TSettingsList profileSettings(10, CompareSettings); + TSettingsList profileSettings(10, SSCompareSettings); if (!GetProfile(profile, profileSettings)) { profile = (profile >= 0) ? profile : db_get_w(NULL, SSMODULENAME, SETTING_DEFAULTPROFILE, 0); @@ -313,6 +314,12 @@ int LoadProfileModule() return 0; } +int UnloadProfileModule() +{ + DestroyServiceFunction(hLoadAndSetProfileService); + return 0; +} + int InitProfileModule() { hTTBModuleLoadedHook = HookEvent(ME_TTB_MODULELOADED, CreateTopToolbarButtons); @@ -337,7 +344,5 @@ int DeinitProfilesModule() UnregisterHotKeys(); RemoveTopToolbarButtons(); - - DestroyServiceFunction(hLoadAndSetProfileService); return 0; } diff --git a/plugins/StatusManager/src/ss_toolbars.cpp b/plugins/StatusManager/src/StartupStatus/ss_toolbars.cpp index 2ecf0a6b95..db8f6aeb61 100644 --- a/plugins/StatusManager/src/ss_toolbars.cpp +++ b/plugins/StatusManager/src/StartupStatus/ss_toolbars.cpp @@ -17,7 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "stdafx.h" +#include "..\stdafx.h" #define MAX_MMITEMS 6 @@ -41,7 +41,7 @@ void RemoveTopToolbarButtons() int CreateTopToolbarButtons(WPARAM, LPARAM) { if (iconList[0].hIcolib == NULL) - Icon_Register(hInst, "Toolbar/StartupStatus", iconList, _countof(iconList)); + Icon_Register(hInst, "Toolbar/StartupStatus", iconList, _countof(iconList), NULL, hSSLangpack); int profileCount = CallService(MS_SS_GETPROFILECOUNT, 0, 0); diff --git a/plugins/StatusManager/src/startupstatus.cpp b/plugins/StatusManager/src/StartupStatus/startupstatus.cpp index 995aa68934..b9de70b28c 100644 --- a/plugins/StatusManager/src/startupstatus.cpp +++ b/plugins/StatusManager/src/StartupStatus/startupstatus.cpp @@ -17,16 +17,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "stdafx.h" +#include "..\stdafx.h" -static UINT_PTR setStatusTimerId = 0; +int hSSLangpack = 0; -int CompareSettings(const TSSSetting *p1, const TSSSetting *p2) -{ - return mir_strcmp(p1->szName, p2->szName); -} +static UINT_PTR setStatusTimerId = 0; -static TSettingsList startupSettings(10, CompareSettings); +static TSettingsList startupSettings(10, SSCompareSettings); TSSSetting::TSSSetting(PROTOACCOUNT *pa) { @@ -342,8 +339,6 @@ static int OnOkToExit(WPARAM, LPARAM) static int OnShutdown(WPARAM, LPARAM) { - DeinitProfilesModule(); - // set windowstate and docked for next startup if (db_get_b(NULL, SSMODULENAME, SETTING_SETWINSTATE, 0)) { int state = db_get_b(NULL, SSMODULENAME, SETTING_WINSTATE, SETTING_STATE_NORMAL); @@ -402,7 +397,7 @@ static DWORD CALLBACK MessageWndProc(HWND, UINT msg, WPARAM wParam, LPARAM) return TRUE; } -int SSCSModuleLoaded(WPARAM, LPARAM) +int SSModuleLoaded(WPARAM, LPARAM) { protoList = (OBJLIST<PROTOCOLSETTINGEX>*)&startupSettings; @@ -484,3 +479,51 @@ int SSCSModuleLoaded(WPARAM, LPARAM) return 0; } + +HANDLE hSSModuleLoadedHook = NULL, + hGetProfileService, + hGetProfileCountService, + hGetProfileNameService; + +void StartupStatusLoad() +{ + MUUID muidLast = MIID_LAST; + hSSLangpack = GetPluginLangId(muidLast, 0); + + hSSModuleLoadedHook = HookEvent(ME_SYSTEM_MODULESLOADED, SSModuleLoaded); + + if (db_get_b(NULL, SSMODULENAME, SETTING_SETPROFILE, 1) || + db_get_b(NULL, SSMODULENAME, SETTING_OFFLINECLOSE, 0)) + db_set_w(NULL, "CList", "Status", (WORD)ID_STATUS_OFFLINE); + + // docking + if (db_get_b(NULL, SSMODULENAME, SETTING_SETDOCKED, 0)) { + int docked = db_get_b(NULL, SSMODULENAME, SETTING_DOCKED, DOCKED_NONE); + if (docked == DOCKED_LEFT || docked == DOCKED_RIGHT) + docked = -docked; + + db_set_b(NULL, MODULE_CLIST, SETTING_DOCKED, (BYTE)docked); + } + + // Create service functions; the get functions are created here; they don't rely on commonstatus + hGetProfileService = CreateServiceFunction(MS_SS_GETPROFILE, SrvGetProfile); + hGetProfileCountService = CreateServiceFunction(MS_SS_GETPROFILECOUNT, GetProfileCount); + hGetProfileNameService = CreateServiceFunction(MS_SS_GETPROFILENAME, GetProfileName); + + LoadProfileModule(); +} + +void StartupStatusUnload() +{ + KillModuleIcons(hSSLangpack); + KillModuleMenus(hSSLangpack); + + DeinitProfilesModule(); + UnloadProfileModule(); + + DestroyServiceFunction(hGetProfileService); + DestroyServiceFunction(hGetProfileCountService); + DestroyServiceFunction(hGetProfileNameService); + + UnhookEvent(hSSModuleLoadedHook); +} diff --git a/plugins/StatusManager/src/startupstatus.h b/plugins/StatusManager/src/StartupStatus/startupstatus.h index f106a141d9..e1ad779103 100644 --- a/plugins/StatusManager/src/startupstatus.h +++ b/plugins/StatusManager/src/StartupStatus/startupstatus.h @@ -19,6 +19,8 @@ #ifndef __STARTUPSTATUSHEADER #define __STARTUPSTATUSHEADER +extern int hSSLangpack; + #define SSMODULENAME "StartupStatus" struct TSSSetting : public PROTOCOLSETTINGEX, public MZeroedObject @@ -28,6 +30,11 @@ struct TSSSetting : public PROTOCOLSETTINGEX, public MZeroedObject ~TSSSetting(); }; +static int SSCompareSettings(const TSSSetting *p1, const TSSSetting *p2) +{ + return mir_strcmp(p1->szName, p2->szName); +} + typedef OBJLIST<TSSSetting> TSettingsList; struct PROFILECE @@ -130,9 +137,10 @@ int StartupStatusOptionsInit(WPARAM wparam,LPARAM lparam); char* OptName(int i, const char* setting); // startupstatus -int SSLoadMainOptions(); +void StartupStatusLoad(); +void StartupStatusUnload(); -int CompareSettings( const TSSSetting* p1, const TSSSetting* p2 ); +int SSLoadMainOptions(); TSettingsList* GetCurrentProtoSettings(); @@ -140,6 +148,11 @@ TSettingsList* GetCurrentProtoSettings(); int GetProfile(int profileID, TSettingsList& arSettings ); wchar_t *GetStatusMessage(int profile, char *szProto); +static INT_PTR SrvGetProfile(WPARAM wParam, LPARAM lParam) +{ + return GetProfile((int)wParam, *(TSettingsList*)lParam); +} + INT_PTR LoadAndSetProfile(WPARAM wParam, LPARAM lParam); INT_PTR GetProfileCount(WPARAM wParam, LPARAM lParam); INT_PTR GetProfileName(WPARAM wParam, LPARAM lParam); @@ -149,6 +162,7 @@ void RemoveTopToolbarButtons(); int CreateTopToolbarButtons(WPARAM wParam, LPARAM lParam); int LoadProfileModule(); +int UnloadProfileModule(); int InitProfileModule(); int DeinitProfilesModule(); diff --git a/plugins/StatusManager/src/main.cpp b/plugins/StatusManager/src/main.cpp index 41455e029a..e1cdb19222 100644 --- a/plugins/StatusManager/src/main.cpp +++ b/plugins/StatusManager/src/main.cpp @@ -19,21 +19,6 @@ #include "stdafx.h" -unsigned long mainThreadId = 0; - -HANDLE hMainThread = 0, - hCSModuleLoadedHook, - hGetProfileService, - hGetProfileCountService, - hGetProfileNameService, - hStateChangedEvent; - -HANDLE hConnectionEvent = NULL, - hStopRecon = NULL, - hEnableProto = NULL, - hIsProtoEnabled = NULL, - hAnnounceStat = NULL; - HINSTANCE hInst; int hLangpack = 0; CLIST_INTERFACE *pcli; @@ -74,19 +59,26 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) ///////////////////////////////////////////////////////////////////////////////////////// // interfaces -extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_AUTOAWAY, MIID_LAST }; +MUUID Interfaces[2] = {0}; +MUUID miidAutoAway = MIID_AUTOAWAY; + + +MUUID* GetInterfaces(void) +{ + if (IsSubPluginEnabled(AAAMODULENAME)) + Interfaces[0] = miidAutoAway; + return Interfaces; +}; + +extern "C" __declspec(dllexport) MUUID* MirandaInterfaces = GetInterfaces(); ///////////////////////////////////////////////////////////////////////////////////////// // plugin's entry point -INT_PTR StopReconnectingService(WPARAM wParam, LPARAM lParam); -INT_PTR EnableProtocolService(WPARAM wParam, LPARAM lParam); -INT_PTR IsProtocolEnabledService(WPARAM wParam, LPARAM lParam); -INT_PTR AnnounceStatusChangeService(WPARAM wParam, LPARAM lParam); - -static INT_PTR SrvGetProfile(WPARAM wParam, LPARAM lParam) +int OnModulesLoaded(WPARAM, LPARAM) { - return GetProfile((int)wParam, *(TSettingsList*)lParam); + HookEvent(ME_OPT_INITIALISE, CSubPluginsOptionsDlg::OnOptionsInit); + return 0; } extern "C" int __declspec(dllexport) Load(void) @@ -94,48 +86,16 @@ extern "C" int __declspec(dllexport) Load(void) mir_getLP(&pluginInfoEx); pcli = Clist_GetInterface(); - //common - InitCommonStatus(); + HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); - /* KeepStatus */ - hCSModuleLoadedHook = HookEvent(ME_SYSTEM_MODULESLOADED, KSCSModuleLoaded); - - hConnectionEvent = CreateHookableEvent(ME_KS_CONNECTIONEVENT); - - hStopRecon = CreateServiceFunction(MS_KS_STOPRECONNECTING, StopReconnectingService); - hEnableProto = CreateServiceFunction(MS_KS_ENABLEPROTOCOL, EnableProtocolService); - hIsProtoEnabled = CreateServiceFunction(MS_KS_ISPROTOCOLENABLED, IsProtocolEnabledService); - hAnnounceStat = CreateServiceFunction(MS_KS_ANNOUNCESTATUSCHANGE, AnnounceStatusChangeService); - - DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &hMainThread, THREAD_SET_CONTEXT, FALSE, 0); - mainThreadId = GetCurrentThreadId(); - - /* StartupStatus */ - hCSModuleLoadedHook = HookEvent(ME_SYSTEM_MODULESLOADED, SSCSModuleLoaded); - - if (db_get_b(NULL, SSMODULENAME, SETTING_SETPROFILE, 1) || - db_get_b(NULL, SSMODULENAME, SETTING_OFFLINECLOSE, 0)) - db_set_w(NULL, "CList", "Status", (WORD)ID_STATUS_OFFLINE); - - // docking - if (db_get_b(NULL, SSMODULENAME, SETTING_SETDOCKED, 0)) { - int docked = db_get_b(NULL, SSMODULENAME, SETTING_DOCKED, DOCKED_NONE); - if (docked == DOCKED_LEFT || docked == DOCKED_RIGHT) - docked = -docked; - - db_set_b(NULL, MODULE_CLIST, SETTING_DOCKED, (BYTE)docked); - } - - // Create service functions; the get functions are created here; they don't rely on commonstatus - hGetProfileService = CreateServiceFunction(MS_SS_GETPROFILE, SrvGetProfile); - hGetProfileCountService = CreateServiceFunction(MS_SS_GETPROFILECOUNT, GetProfileCount); - hGetProfileNameService = CreateServiceFunction(MS_SS_GETPROFILENAME, GetProfileName); - - LoadProfileModule(); + InitCommonStatus(); - /* AdvancedAutoAway */ - hCSModuleLoadedHook = HookEvent(ME_SYSTEM_MODULESLOADED, AAACSModuleLoaded); - hStateChangedEvent = CreateHookableEvent(ME_AAA_STATECHANGED); + if (IsSubPluginEnabled(KSMODULENAME)) + KeepStatusLoad(); + if (IsSubPluginEnabled(SSMODULENAME)) + StartupStatusLoad(); + if (IsSubPluginEnabled(AAAMODULENAME)) + AdvancedAutoAwayLoad(); return 0; } @@ -145,22 +105,9 @@ extern "C" int __declspec(dllexport) Load(void) extern "C" int __declspec(dllexport) Unload(void) { - UnhookEvent(hCSModuleLoadedHook); - - // StartupStatus - DestroyHookableEvent(hConnectionEvent); - - if (hMainThread) - CloseHandle(hMainThread); - DestroyServiceFunction(hStopRecon); - DestroyServiceFunction(hEnableProto); - DestroyServiceFunction(hIsProtoEnabled); - DestroyServiceFunction(hAnnounceStat); - - // StartupStatus - DestroyServiceFunction(hGetProfileService); - DestroyServiceFunction(hGetProfileCountService); - DestroyServiceFunction(hGetProfileNameService); + KeepStatusUnload(); + StartupStatusUnload(); + AdvancedAutoAwayUnload(); return 0; } diff --git a/plugins/StatusManager/src/options.cpp b/plugins/StatusManager/src/options.cpp new file mode 100644 index 0000000000..c6fe45bda4 --- /dev/null +++ b/plugins/StatusManager/src/options.cpp @@ -0,0 +1,42 @@ +#include "stdafx.h" + +CSubPluginsOptionsDlg::CSubPluginsOptionsDlg() + : CPluginDlgBase(hInst, IDD_OPT_SUBPLUGINS, MODULENAME), + m_enableKeepStatus(this, IDC_ENABLE_KEEPSTATUS), + m_enableStartupStatus(this, IDC_ENABLE_STARTUPSTATUS), + m_enableAdvancedAutoAway(this, IDC_ENABLE_ADVANCEDAUTOAWAY) +{ +} + +void CSubPluginsOptionsDlg::OnInitDialog() +{ + CDlgBase::OnInitDialog(); + + m_enableKeepStatus.SetState(IsSubPluginEnabled(KSMODULENAME)); + m_enableStartupStatus.SetState(IsSubPluginEnabled(SSMODULENAME)); + m_enableAdvancedAutoAway.SetState(IsSubPluginEnabled(AAAMODULENAME)); +} + +void CSubPluginsOptionsDlg::OnApply() +{ + char setting[128]; + mir_snprintf(setting, "%s_enabled", KSMODULENAME); + db_set_b(NULL, MODULENAME, setting, m_enableKeepStatus.GetState()); + mir_snprintf(setting, "%s_enabled", SSMODULENAME); + db_set_b(NULL, MODULENAME, setting, m_enableStartupStatus.GetState()); + mir_snprintf(setting, "%s_enabled", AAAMODULENAME); + db_set_b(NULL, MODULENAME, setting, m_enableAdvancedAutoAway.GetState()); +} + +int CSubPluginsOptionsDlg::OnOptionsInit(WPARAM wParam, LPARAM) +{ + OPTIONSDIALOGPAGE odp = { 0 }; + odp.hInstance = hInst; + odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE; + odp.szGroup.w = LPGENW("Status"); + odp.szTitle.w = LPGENW("Status manager"); + odp.pDialog = CSubPluginsOptionsDlg::CreateOptionsPage(); + Options_AddPage(wParam, &odp); + + return 0; +}
\ No newline at end of file diff --git a/plugins/StatusManager/src/resource.h b/plugins/StatusManager/src/resource.h index f49d2abbd5..fe80e01f93 100644 --- a/plugins/StatusManager/src/resource.h +++ b/plugins/StatusManager/src/resource.h @@ -1,8 +1,7 @@ //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. -// Used by resource.rc +// Used by E:\Projects\C++\miranda-ng\plugins\StatusManager\res\resource.rc // -#define IDD_OPT_KEEPSTATUS 101 #define IDD_OPT_KS_BASIC 101 #define IDD_CONFIRMDIALOG 102 #define IDD_OPT_AUTOAWAY 104 @@ -11,28 +10,23 @@ #define IDD_OPT_STARTUPSTATUS 110 #define IDD_PUOPT_KEEPSTATUS 113 #define IDD_OPT_AUTOAWAYMSG 114 -#define IDI_TICK 117 -#define IDI_NOTICK 118 #define IDD_OPT_GENAUTOAWAY 119 #define IDD_OPT_KS_ACTION 120 #define IDD_SETSTSMSGDIALOG 121 #define IDD_OPT_STATUSPROFILES 123 -#define IDD_OPT_AAATABS 126 #define IDD_OPT_TABS 126 #define IDD_OPT_KS_ADV 127 #define IDD_TRG_AAASTATECHANGE 128 #define IDI_TTBDOWN 129 +#define IDD_OPT_SUBPLUGINS 129 #define IDI_TTBUP 130 #define IDC_PROTOCOL 1000 #define IDC_STATUS 1001 #define IDC_PROFILE 1002 #define IDC_STARTUPLIST 1008 #define IDC_STATUSMSG 1008 -#define IDC_SETSTATUSONSTARTUP 1010 #define IDC_SETPROFILE 1010 -#define IDC_SETWINDOW 1011 #define IDC_SETWINSTATE 1011 -#define IDC_WINDOW 1012 #define IDC_WINSTATE 1012 #define IDC_CLOSE 1013 #define IDC_SHOWDIALOG 1014 @@ -46,7 +40,6 @@ #define IDC_CHECKCONNECTION 1025 #define IDC_MAXRETRIES 1026 #define IDC_INITDELAY 1027 -#define IDC_SETSTATUSDELAY 1027 #define IDC_SETPROFILEDELAY 1027 #define IDC_DOCKED 1028 #define IDC_SETDOCKED 1029 @@ -63,12 +56,10 @@ #define IDC_DELPROFILE 1042 #define IDC_PROFILENAME 1043 #define IDC_CANCEL 1044 -#define IDC_DEFAULTPROFILE 1045 #define IDC_MONITORMIRANDA 1045 #define IDC_WINCOLORS 1045 #define IDC_CHKINET 1045 #define IDC_IGNLOCK 1045 -#define IDC_CREATETTBBUTTONS 1046 #define IDC_CREATETTB 1046 #define IDC_PERPROTOCOLSETTINGS 1050 #define IDC_SAMESETTINGS 1051 @@ -145,12 +136,14 @@ #define IDC_LEAVEFIRST 1136 #define IDC_LEAVESECOND 1137 #define IDC_BECOMEACTIVE 1138 +#define IDC_ENABLE_KEEPSTATUS 1141 +#define IDC_ENABLE_STARTUPSTATUS 1142 +#define IDC_ENABLE_ADVANCEDAUTOAWAY 1143 #define IDC_SCREENSAVE 1145 #define IDC_TIMED 1146 #define IDC_AWAYTIME 1147 #define IDC_SETNA 1148 #define IDC_NATIME 1149 -#define IDC_SCREENSAVE2 1150 #define IDC_FULLSCREEN 1150 #define IDC_RADUSEMIRANDA 1210 #define IDC_RADUSECUSTOM 1212 @@ -160,9 +153,9 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 129 +#define _APS_NEXT_RESOURCE_VALUE 131 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1141 +#define _APS_NEXT_CONTROL_VALUE 1144 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/plugins/StatusManager/src/stdafx.h b/plugins/StatusManager/src/stdafx.h index a8fd9051a7..f82e4ae86a 100644 --- a/plugins/StatusManager/src/stdafx.h +++ b/plugins/StatusManager/src/stdafx.h @@ -21,17 +21,48 @@ #include <m_protocols.h> #include <m_toptoolbar.h> #include <m_statusplugins.h> +#include <m_gui.h> #include "version.h" #include "resource.h" +#define MODULENAME "StatusManager" + #include "commonstatus.h" -#include "keepstatus.h" -#include "startupstatus.h" -#include "advancedautoaway.h" +#include "KeepStatus\keepstatus.h" +#include "StartupStatus\startupstatus.h" +#include "AdvancedAutoAway\advancedautoaway.h" + +extern HINSTANCE hInst; + +static BYTE IsSubPluginEnabled(const char* name) +{ + // Check if this plugin was disabled as separate dll + CMStringA dllName(FORMAT, "%s.dll", name); + dllName.MakeLower(); + bool dllEnabled = !db_get_b(NULL, "PluginDisable", dllName); + + char setting[128]; + mir_snprintf(setting, "%s_enabled", name); + return db_get_b(NULL, MODULENAME, setting, dllEnabled ? 1 : 0); +} + +class CSubPluginsOptionsDlg : CPluginDlgBase +{ +private: + CCtrlCheck m_enableKeepStatus; + CCtrlCheck m_enableStartupStatus; + CCtrlCheck m_enableAdvancedAutoAway; + +protected: + void OnInitDialog(); + void OnApply(); + +public: + CSubPluginsOptionsDlg(); -int KSCSModuleLoaded(WPARAM, LPARAM); -int SSCSModuleLoaded(WPARAM, LPARAM); -int AAACSModuleLoaded(WPARAM, LPARAM); + static int OnOptionsInit(WPARAM wParam, LPARAM); + static CDlgBase *CreateOptionsPage() { return new CSubPluginsOptionsDlg(); } +}; #endif //_COMMON_H_ diff --git a/plugins/StatusManager/src/version.h b/plugins/StatusManager/src/version.h index afc5ef5d5f..d4e2982f74 100644 --- a/plugins/StatusManager/src/version.h +++ b/plugins/StatusManager/src/version.h @@ -1,7 +1,7 @@ // plugin version part #define __MAJOR_VERSION 0 #define __MINOR_VERSION 11 -#define __RELEASE_NUM 0 +#define __RELEASE_NUM 2 #define __BUILD_NUM 0 // other stuff for Version resource @@ -14,4 +14,4 @@ #define __AUTHOR "P Boon" #define __AUTHOREMAIL "unregistered@users.sourceforge.net" #define __AUTHORWEB "http://miranda-ng.org/p/StatusManager/" -#define __COPYRIGHT "© 2003-08 P. Boon, 2008-17 George Hazan" +#define __COPYRIGHT "� 2003-08 P. Boon, 2008-17 George Hazan" diff --git a/plugins/TabSRMM/src/buttonsbar.cpp b/plugins/TabSRMM/src/buttonsbar.cpp index b6457fcdaa..0c9c79ba8f 100644 --- a/plugins/TabSRMM/src/buttonsbar.cpp +++ b/plugins/TabSRMM/src/buttonsbar.cpp @@ -164,8 +164,8 @@ void BB_InitDlgButtons(TWindowData *dat) CustomButtonData *cbd; for (int i = 0; cbd = Srmm_GetNthButton(i); i++) { - HWND hwndBtn = GetDlgItem(hdlg, cbd->m_dwButtonCID); - if (hwndBtn == NULL) + HWND hwndButton = GetDlgItem(hdlg, cbd->m_dwButtonCID); + if (hwndButton == NULL) continue; if (!cbd->m_bHidden) { @@ -180,11 +180,14 @@ void BB_InitDlgButtons(TWindowData *dat) if (cbd->m_bSeparator) continue; - CustomizeButton(hwndBtn); + CustomizeButton(hwndButton); - SendMessage(hwndBtn, BUTTONSETASTHEMEDBTN, CSkin::IsThemed(), 0); - SendMessage(hwndBtn, BUTTONSETCONTAINER, (LPARAM)dat->pContainer, 0); - SendMessage(hwndBtn, BUTTONSETASTOOLBARBUTTON, TRUE, 0); + if (cbd->m_dwArrowCID) + SendMessage(hwndButton, BUTTONSETARROW, (cbd->m_dwButtonCID == IDOK) ? IDC_SENDMENU : cbd->m_dwArrowCID, 0); + + SendMessage(hwndButton, BUTTONSETASTHEMEDBTN, CSkin::IsThemed(), 0); + SendMessage(hwndButton, BUTTONSETCONTAINER, (LPARAM)dat->pContainer, 0); + SendMessage(hwndButton, BUTTONSETASTOOLBARBUTTON, TRUE, 0); } } @@ -211,7 +214,7 @@ BOOL BB_SetButtonsPos(TWindowData *dat) HWND hwnd = dat->hwnd; RECT rect; - HWND hwndBtn = 0; + HWND hwndButton = 0; BYTE gap = DPISCALEX_S(db_get_b(NULL, SRMSGMOD, "ButtonsBarGap", 1)); bool showToolbar = !(dat->pContainer->dwFlags & CNT_HIDETOOLBAR); @@ -252,40 +255,40 @@ BOOL BB_SetButtonsPos(TWindowData *dat) continue; if (((dat->bType == SESSIONTYPE_IM) && cbd->m_bIMButton) || ((dat->bType == SESSIONTYPE_CHAT) && cbd->m_bChatButton)) { - hwndBtn = GetDlgItem(hwnd, cbd->m_dwButtonCID); + hwndButton = GetDlgItem(hwnd, cbd->m_dwButtonCID); if (!showToolbar) { - ShowWindow(hwndBtn, SW_HIDE); - if (NULL != hwndBtn) /* Wine fix. */ - hdwp = DeferWindowPos(hdwp, hwndBtn, NULL, lwidth, splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE); - if (IsWindowVisible(hwndBtn) || (cbd->m_bSeparator && !(cbd->m_bAutoHidden || cbd->m_bHidden))) + ShowWindow(hwndButton, SW_HIDE); + if (NULL != hwndButton) /* Wine fix. */ + hdwp = DeferWindowPos(hdwp, hwndButton, NULL, lwidth, splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE); + if (IsWindowVisible(hwndButton) || (cbd->m_bSeparator && !(cbd->m_bAutoHidden || cbd->m_bHidden))) lwidth += cbd->m_iButtonWidth + gap; - if (!IsWindowEnabled(hwndBtn) && !IsWindowVisible(hwndBtn) && !cbd->m_bAutoHidden) + if (!IsWindowEnabled(hwndButton) && !IsWindowVisible(hwndButton) && !cbd->m_bAutoHidden) cbd->m_bAutoHidden = 1; continue; } - if (!cbd->m_bCanBeHidden && !cbd->m_bHidden && !(!IsWindowEnabled(hwndBtn) && !IsWindowVisible(hwndBtn) && !cbd->m_bAutoHidden)) { - ShowWindow(hwndBtn, SW_SHOW); + if (!cbd->m_bCanBeHidden && !cbd->m_bHidden && !(!IsWindowEnabled(hwndButton) && !IsWindowVisible(hwndButton) && !cbd->m_bAutoHidden)) { + ShowWindow(hwndButton, SW_SHOW); cbd->m_bAutoHidden = 0; } - if (!cbd->m_bSeparator && !IsWindowVisible(hwndBtn) && !IsWindowEnabled(hwndBtn) && !cbd->m_bAutoHidden) + if (!cbd->m_bSeparator && !IsWindowVisible(hwndButton) && !IsWindowEnabled(hwndButton) && !cbd->m_bAutoHidden) tempL -= cbd->m_iButtonWidth + gap; - if (cbd->m_bCanBeHidden && !cbd->m_bHidden && (cbd->m_bSeparator || !((!IsWindowEnabled(hwndBtn) && !IsWindowVisible(hwndBtn)) && !cbd->m_bAutoHidden))) { + if (cbd->m_bCanBeHidden && !cbd->m_bHidden && (cbd->m_bSeparator || !((!IsWindowEnabled(hwndButton) && !IsWindowVisible(hwndButton)) && !cbd->m_bAutoHidden))) { if (tempL + tempR > (rect.right - foravatar)) { - ShowWindow(hwndBtn, SW_HIDE); + ShowWindow(hwndButton, SW_HIDE); cbd->m_bAutoHidden = 1; tempL -= cbd->m_iButtonWidth + gap; } else if (cbd->m_bAutoHidden) { - ShowWindow(hwndBtn, SW_SHOW); + ShowWindow(hwndButton, SW_SHOW); cbd->m_bAutoHidden = 0; } } - if (NULL != hwndBtn) /* Wine fix. */ - hdwp = DeferWindowPos(hdwp, hwndBtn, NULL, lwidth, splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);// SWP_NOCOPYBITS); - if (IsWindowVisible(hwndBtn) || (cbd->m_bSeparator && !(cbd->m_bAutoHidden || cbd->m_bHidden))) + if (NULL != hwndButton) /* Wine fix. */ + hdwp = DeferWindowPos(hdwp, hwndButton, NULL, lwidth, splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);// SWP_NOCOPYBITS); + if (IsWindowVisible(hwndButton) || (cbd->m_bSeparator && !(cbd->m_bAutoHidden || cbd->m_bHidden))) lwidth += cbd->m_iButtonWidth + gap; } } @@ -302,42 +305,42 @@ BOOL BB_SetButtonsPos(TWindowData *dat) continue; if (((dat->bType == SESSIONTYPE_IM) && cbd->m_bIMButton) || ((dat->bType == SESSIONTYPE_CHAT) && cbd->m_bChatButton)) { - hwndBtn = GetDlgItem(hwnd, cbd->m_dwButtonCID); + hwndButton = GetDlgItem(hwnd, cbd->m_dwButtonCID); if (!showToolbar) { - ShowWindow(hwndBtn, SW_HIDE); - if (IsWindowVisible(hwndBtn) || (cbd->m_bSeparator && !(cbd->m_bAutoHidden || cbd->m_bHidden))) + ShowWindow(hwndButton, SW_HIDE); + if (IsWindowVisible(hwndButton) || (cbd->m_bSeparator && !(cbd->m_bAutoHidden || cbd->m_bHidden))) rwidth += cbd->m_iButtonWidth + gap; - if (NULL != hwndBtn) /* Wine fix. */ - hdwp = DeferWindowPos(hdwp, hwndBtn, NULL, rect.right - foravatar - rwidth + gap, splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE); - if (!IsWindowEnabled(hwndBtn) && !IsWindowVisible(hwndBtn) && !cbd->m_bAutoHidden) + if (NULL != hwndButton) /* Wine fix. */ + hdwp = DeferWindowPos(hdwp, hwndButton, NULL, rect.right - foravatar - rwidth + gap, splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE); + if (!IsWindowEnabled(hwndButton) && !IsWindowVisible(hwndButton) && !cbd->m_bAutoHidden) cbd->m_bAutoHidden = 1; continue; } - if (!cbd->m_bCanBeHidden && !cbd->m_bHidden && !((!IsWindowEnabled(hwndBtn) && !IsWindowVisible(hwndBtn)) && !cbd->m_bAutoHidden)) { - ShowWindow(hwndBtn, SW_SHOW); + if (!cbd->m_bCanBeHidden && !cbd->m_bHidden && !((!IsWindowEnabled(hwndButton) && !IsWindowVisible(hwndButton)) && !cbd->m_bAutoHidden)) { + ShowWindow(hwndButton, SW_SHOW); cbd->m_bAutoHidden = 0; } - if (!cbd->m_bSeparator && !IsWindowVisible(hwndBtn) && !IsWindowEnabled(hwndBtn) && !cbd->m_bAutoHidden) + if (!cbd->m_bSeparator && !IsWindowVisible(hwndButton) && !IsWindowEnabled(hwndButton) && !cbd->m_bAutoHidden) tempR -= cbd->m_iButtonWidth + gap; - if (cbd->m_bCanBeHidden && !cbd->m_bHidden && (cbd->m_bSeparator || !((!IsWindowEnabled(hwndBtn) && !IsWindowVisible(hwndBtn)) && !cbd->m_bAutoHidden))) { + if (cbd->m_bCanBeHidden && !cbd->m_bHidden && (cbd->m_bSeparator || !((!IsWindowEnabled(hwndButton) && !IsWindowVisible(hwndButton)) && !cbd->m_bAutoHidden))) { if (tempL + tempR > (rect.right - foravatar)) { - ShowWindow(hwndBtn, SW_HIDE); + ShowWindow(hwndButton, SW_HIDE); cbd->m_bAutoHidden = 1; tempR -= cbd->m_iButtonWidth + gap; } else if (cbd->m_bAutoHidden) { - ShowWindow(hwndBtn, SW_SHOW); + ShowWindow(hwndButton, SW_SHOW); cbd->m_bAutoHidden = 0; } } - if (IsWindowVisible(hwndBtn) || (cbd->m_bSeparator && !(cbd->m_bAutoHidden || cbd->m_bHidden))) + if (IsWindowVisible(hwndButton) || (cbd->m_bSeparator && !(cbd->m_bAutoHidden || cbd->m_bHidden))) rwidth += cbd->m_iButtonWidth + gap; - if (NULL != hwndBtn) /* Wine fix. */ - hdwp = DeferWindowPos(hdwp, hwndBtn, NULL, rect.right - foravatar - rwidth + gap, splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE); + if (NULL != hwndButton) /* Wine fix. */ + hdwp = DeferWindowPos(hdwp, hwndButton, NULL, rect.right - foravatar - rwidth + gap, splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE); } } return EndDeferWindowPos(hdwp); @@ -347,41 +350,41 @@ void CB_DestroyAllButtons(HWND hwndDlg) { CustomButtonData *cbd; for (int i = 0; cbd = Srmm_GetNthButton(i); i++) { - HWND hwndBtn = GetDlgItem(hwndDlg, cbd->m_dwButtonCID); - if (hwndBtn) - DestroyWindow(hwndBtn); + HWND hwndButton = GetDlgItem(hwndDlg, cbd->m_dwButtonCID); + if (hwndButton) + DestroyWindow(hwndButton); } } void CB_DestroyButton(HWND hwndDlg, TWindowData *dat, DWORD dwButtonCID, DWORD dwFlags) { - HWND hwndBtn = GetDlgItem(hwndDlg, dwButtonCID); - if (hwndBtn == NULL) + HWND hwndButton = GetDlgItem(hwndDlg, dwButtonCID); + if (hwndButton == NULL) return; RECT rc = { 0 }; - GetClientRect(hwndBtn, &rc); + GetClientRect(hwndButton, &rc); if (dwFlags & BBBF_ISRSIDEBUTTON) dat->bbRSideWidth -= rc.right; else dat->bbLSideWidth -= rc.right; - DestroyWindow(hwndBtn); + DestroyWindow(hwndButton); BB_SetButtonsPos(dat); } void CB_ChangeButton(HWND hwndDlg, TWindowData *dat, CustomButtonData *cbd) { - HWND hwndBtn = GetDlgItem(hwndDlg, cbd->m_dwButtonCID); - if (hwndBtn == NULL) + HWND hwndButton = GetDlgItem(hwndDlg, cbd->m_dwButtonCID); + if (hwndButton == NULL) return; if (cbd->m_hIcon) - SendMessage(hwndBtn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIconByHandle(cbd->m_hIcon)); + SendMessage(hwndButton, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIconByHandle(cbd->m_hIcon)); if (cbd->m_pwszTooltip) - SendMessage(hwndBtn, BUTTONADDTOOLTIP, (WPARAM)cbd->m_pwszTooltip, BATF_UNICODE); - SendMessage(hwndBtn, BUTTONSETCONTAINER, (LPARAM)dat->pContainer, 0); - SetWindowTextA(hwndBtn, cbd->m_pszModuleName); + SendMessage(hwndButton, BUTTONADDTOOLTIP, (WPARAM)cbd->m_pwszTooltip, BATF_UNICODE); + SendMessage(hwndButton, BUTTONSETCONTAINER, (LPARAM)dat->pContainer, 0); + SetWindowTextA(hwndButton, cbd->m_pszModuleName); } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp index 1f30d68496..d655767595 100644 --- a/plugins/TabSRMM/src/msgdlgutils.cpp +++ b/plugins/TabSRMM/src/msgdlgutils.cpp @@ -282,7 +282,7 @@ int TSAPI MsgWindowUpdateMenu(TWindowData *dat, HMENU submenu, int menuID) }
else {
EnableMenuItem(submenu, 0, MF_BYPOSITION | MF_GRAYED);
- EnableMenuItem(submenu, ID_PICMENU_SETTINGS, MF_BYCOMMAND | ((ServiceExists(MS_AV_SETMYAVATAR) && CallService(MS_AV_CANSETMYAVATAR, (WPARAM)(dat->cache->getActiveProto()), 0)) ? MF_ENABLED : MF_GRAYED));
+ EnableMenuItem(submenu, ID_PICMENU_SETTINGS, MF_BYCOMMAND | ((ServiceExists(MS_AV_SETMYAVATARW) && CallService(MS_AV_CANSETMYAVATAR, (WPARAM)(dat->cache->getActiveProto()), 0)) ? MF_ENABLED : MF_GRAYED));
szText = TranslateT("Set your avatar...");
}
mii.dwTypeData = szText;
@@ -388,8 +388,8 @@ int TSAPI MsgWindowMenuHandler(TWindowData *dat, int selection, int menuId) CallService(MS_AV_CONTACTOPTIONS, dat->hContact, 0);
else if (menuId == MENU_PICMENU) {
if (dat->Panel->isActive()) {
- if (ServiceExists(MS_AV_SETMYAVATAR) && CallService(MS_AV_CANSETMYAVATAR, (WPARAM)(dat->cache->getActiveProto()), 0))
- CallService(MS_AV_SETMYAVATAR, (WPARAM)(dat->cache->getActiveProto()), 0);
+ if (ServiceExists(MS_AV_SETMYAVATARW) && CallService(MS_AV_CANSETMYAVATAR, (WPARAM)(dat->cache->getActiveProto()), 0))
+ CallService(MS_AV_SETMYAVATARW, (WPARAM)(dat->cache->getActiveProto()), 0);
}
else
CallService(MS_AV_CONTACTOPTIONS, dat->hContact, 0);
diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h index 29f5e8aa3b..d00fcfb84e 100644 --- a/plugins/TabSRMM/src/msgs.h +++ b/plugins/TabSRMM/src/msgs.h @@ -302,7 +302,7 @@ struct TWindowData HANDLE hTimeZone;
DWORD panelStatusCX;
COLORREF inputbg;
- avatarCacheEntry *ace, *ownAce;
+ AVATARCACHEENTRY *ace, *ownAce;
MEVENT *hHistoryEvents;
int maxHistory, curHistory;
HANDLE hTheme, hThemeIP, hThemeToolbar;
diff --git a/plugins/UserInfoEx/src/svc_avatar.cpp b/plugins/UserInfoEx/src/svc_avatar.cpp index bf510a731b..48a619d79d 100644 --- a/plugins/UserInfoEx/src/svc_avatar.cpp +++ b/plugins/UserInfoEx/src/svc_avatar.cpp @@ -27,16 +27,13 @@ namespace NServices {
static HANDLE ghChangedHook = NULL;
- static int GetContactAvatarFileName(LPCTSTR zodiac, LPSTR szFileName, int cchFileName)
+ static int GetContactAvatarFileName(LPCWSTR zodiac, LPWSTR szFileName, int cchFileName)
{
- if (!Profile_GetPathA(cchFileName, szFileName)) {
- size_t len = mir_strlen(szFileName);
+ if (!Profile_GetPathW(cchFileName, szFileName)) {
+ size_t len = mir_wstrlen(szFileName);
+ mir_snwprintf(szFileName + len, cchFileName - len, L"\\avatars\\%s.png", zodiac);
- CHAR tmp[64];
- if (WideCharToMultiByte(CP_ACP, 0, zodiac, 64, tmp, _countof(tmp), 0, 0) > 0)
- mir_snprintf(szFileName + len, cchFileName - len, "\\avatars\\%s.png", tmp);
-
- return !PathFileExistsA(szFileName);
+ return !PathFileExistsW(szFileName);
}
return 1;
}
@@ -49,7 +46,7 @@ namespace NServices if (!mtb.DBGetBirthDate(hContact)) {
MZodiac zodiac;
//ICONINFO iinfo;
- CHAR szFileName[MAX_PATH];
+ WCHAR szFileName[MAX_PATH];
// get zodiac for birthday
zodiac = mtb.Zodiac();
@@ -59,7 +56,7 @@ namespace NServices //GetIconInfo(zodiac.hIcon, &iinfo);
// save the bitmap to a file used as avatar later
- if (!CallService(MS_AV_SETAVATAR, hContact, (LPARAM)szFileName))
+ if (!CallService(MS_AV_SETAVATARW, hContact, (LPARAM)szFileName))
db_set_b(hContact, "ContactPhoto", "IsZodiac", 1);
}
}
diff --git a/plugins/UserInfoEx/src/svc_constants.cpp b/plugins/UserInfoEx/src/svc_constants.cpp index 4deefca9b4..b345b25f26 100644 --- a/plugins/UserInfoEx/src/svc_constants.cpp +++ b/plugins/UserInfoEx/src/svc_constants.cpp @@ -231,7 +231,8 @@ static IDSTRLIST TmplMarital[]={ {40, LPGEN("Widowed"), 0},
{50, LPGEN("Actively searching"), 0 },
{60, LPGEN("In love"), 0 },
- {70, LPGEN("It\'s complicated"), 0 }
+ {70, LPGEN("It\'s complicated"), 0 },
+ {80, LPGEN("In a civil union"), 0 }
};
static IDSTRLIST TmplPrefixes[]={
diff --git a/plugins/Utils.pas/mirutils.pas b/plugins/Utils.pas/mirutils.pas index 10f2ea2578..4ede3640a2 100644 --- a/plugins/Utils.pas/mirutils.pas +++ b/plugins/Utils.pas/mirutils.pas @@ -458,7 +458,7 @@ begin end;
if (hNetLib=0) and (nlu.cbSize<>0) then
- CallService(MS_NETLIB_CLOSEHANDLE,hTmpNetLib,0);
+ Netlib_CloseHandle(hTmpNetLib);
end;
(*
@@ -537,7 +537,7 @@ begin CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,lparam(resp));
if nlu.cbSize<>0 then
- CallService(MS_NETLIB_CLOSEHANDLE,hNetLib,0);
+ Netlib_CloseHandle(hNetLib);
end;
end;
@@ -640,7 +640,7 @@ begin end;
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,lparam(resp));
end;
- CallService(MS_NETLIB_CLOSEHANDLE,hNetLib,0);
+ Netlib_CloseHandle(hNetLib);
end;
function RegisterSingleIcon(resname,ilname,descr,group:PAnsiChar):int;
diff --git a/plugins/Watrack/myshows/i_cookies.inc b/plugins/Watrack/myshows/i_cookies.inc index 1258490199..3241134cf3 100644 --- a/plugins/Watrack/myshows/i_cookies.inc +++ b/plugins/Watrack/myshows/i_cookies.inc @@ -87,5 +87,5 @@ begin CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,lparam(resp));
end;
- CallService(MS_NETLIB_CLOSEHANDLE,hTmpNetLib,0);
+ Netlib_CloseHandle(hTmpNetLib);
end;
diff --git a/plugins/YAMN/src/proto/netlib.cpp b/plugins/YAMN/src/proto/netlib.cpp index 0d8df55ab1..cc8f73a602 100644 --- a/plugins/YAMN/src/proto/netlib.cpp +++ b/plugins/YAMN/src/proto/netlib.cpp @@ -119,14 +119,7 @@ void CNLClient::Connect(const char* servername, const int port) throw(DWORD) // query- command to send
int CNLClient::LocalNetlib_Send(HANDLE hConn, const char *buf, int len, int flags)
{
- if (isTLSed) {
- #ifdef DEBUG_COMM
- SSL_DebugLog("SSL send: %s", buf);
- #endif
- }
-
- NETLIBBUFFER nlb = { (char*)buf,len,flags };
- return CallService(MS_NETLIB_SEND, (WPARAM)hConn, (LPARAM)&nlb);
+ return Netlib_Send(hConn, buf, len, flags);
}
void CNLClient::Send(const char *query) throw(DWORD)
@@ -166,8 +159,7 @@ void CNLClient::Send(const char *query) throw(DWORD) int CNLClient::LocalNetlib_Recv(HANDLE hConn, char *buf, int len, int flags)
{
- NETLIBBUFFER nlb = { buf,len,flags };
- int iReturn = CallService(MS_NETLIB_RECV, (WPARAM)hConn, (LPARAM)&nlb);
+ int iReturn = Netlib_Recv(hConn, buf, len, flags);
if (isTLSed) {
#ifdef DEBUG_COMM
SSL_DebugLog("SSL recv: %s", buf);
diff --git a/plugins/mRadio/mradio.dpr b/plugins/mRadio/mradio.dpr index 3843cf56cd..3c3a5c3050 100644 --- a/plugins/mRadio/mradio.dpr +++ b/plugins/mRadio/mradio.dpr @@ -130,7 +130,7 @@ begin DestroyHookableEvent(hhRadioStatus);
- CallService(MS_NETLIB_CLOSEHANDLE,hNetLib,0);
+ Netlib_CloseHandle(hNetLib);
mFreeMem(storage);
mFreeMem(storagep);
diff --git a/protocols/Discord/discord.vcxproj b/protocols/Discord/discord.vcxproj index a360422c31..1a76deed6c 100644 --- a/protocols/Discord/discord.vcxproj +++ b/protocols/Discord/discord.vcxproj @@ -30,4 +30,10 @@ <ExceptionHandling>Sync</ExceptionHandling> </ClCompile> </ItemDefinitionGroup> + <ItemGroup> + <ProjectReference Include="..\..\libs\zlib\zlib.vcxproj"> + <Project>{e2a369cd-eda3-414f-8ad0-e732cd7ee68c}</Project> + <ReferenceOutputAssembly>false</ReferenceOutputAssembly> + </ProjectReference> + </ItemGroup> </Project>
\ No newline at end of file diff --git a/protocols/Discord/proto_discord/res/Idle.ico b/protocols/Discord/proto_discord/res/Away.ico Binary files differindex c2830ed132..2a43c57cd8 100644 --- a/protocols/Discord/proto_discord/res/Idle.ico +++ b/protocols/Discord/proto_discord/res/Away.ico diff --git a/protocols/Discord/proto_discord/res/Proto_Discord.rc b/protocols/Discord/proto_discord/res/Proto_Discord.rc index eed49abaf1..36290c99f3 100644 --- a/protocols/Discord/proto_discord/res/Proto_Discord.rc +++ b/protocols/Discord/proto_discord/res/Proto_Discord.rc @@ -54,6 +54,7 @@ END IDI_ICON1 ICON "Offline.ico" IDI_ICON2 ICON "Online.ico" IDI_ICON4 ICON "Invisible.ico" +IDI_ICON5 ICON "Away.ico" IDI_ICON6 ICON "DND.ico" #endif // Russian (Russia) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/protocols/Discord/res/discord.rc b/protocols/Discord/res/discord.rc index fc31363075..b8b5e4ae5a 100644 --- a/protocols/Discord/res/discord.rc +++ b/protocols/Discord/res/discord.rc @@ -7,7 +7,7 @@ // // Generated from the TEXTINCLUDE 2 resource. // -#include "afxres.h" +#include "winres.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS @@ -32,7 +32,7 @@ END 2 TEXTINCLUDE BEGIN - "#include ""afxres.h""\r\n" + "#include ""winres.h""\r\n" "\0" END @@ -44,6 +44,7 @@ END #endif // APSTUDIO_INVOKED + ///////////////////////////////////////////////////////////////////////////// // // Icon @@ -51,9 +52,8 @@ END // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. - -IDI_MAIN ICON "discord.ico" -IDI_OFFLINE ICON "offline.ico" +IDI_MAIN ICON "discord.ico" +IDI_OFFLINE ICON "offline.ico" ///////////////////////////////////////////////////////////////////////////// // @@ -70,12 +70,26 @@ BEGIN EDITTEXT IDC_USERNAME,84,18,123,13,ES_AUTOHSCROLL LTEXT "Password:",IDC_STATIC,17,36,61,8,0,WS_EX_RIGHT EDITTEXT IDC_PASSWORD,84,34,123,13,ES_PASSWORD | ES_AUTOHSCROLL - GROUPBOX "Contacts",IDC_STATIC,7,77,291,88 LTEXT "Default group:",IDC_STATIC,17,91,61,8,0,WS_EX_RIGHT EDITTEXT IDC_GROUP,84,89,123,13,ES_AUTOHSCROLL END +IDD_OPTIONS_ACCMGR DIALOGEX 0, 0, 200, 88 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + GROUPBOX "User details",IDC_STATIC,7,7,178,46 + LTEXT "E-mail:",IDC_STATIC,17,20,69,8,0,WS_EX_RIGHT + EDITTEXT IDC_USERNAME,92,18,86,13,ES_AUTOHSCROLL + LTEXT "Password:",IDC_STATIC,17,36,69,8,0,WS_EX_RIGHT + EDITTEXT IDC_PASSWORD,92,34,86,13,ES_PASSWORD | ES_AUTOHSCROLL + GROUPBOX "Contacts",IDC_STATIC,7,56,178,28 + LTEXT "Default group:",IDC_STATIC,17,67,69,8,0,WS_EX_RIGHT + EDITTEXT IDC_GROUP,92,65,86,13,ES_AUTOHSCROLL +END + IDD_EXTSEARCH DIALOGEX 0, 0, 114, 55 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_SYSMENU EXSTYLE WS_EX_TRANSPARENT | WS_EX_CONTROLPARENT diff --git a/protocols/Discord/src/avatars.cpp b/protocols/Discord/src/avatars.cpp new file mode 100644 index 0000000000..1e0f41a565 --- /dev/null +++ b/protocols/Discord/src/avatars.cpp @@ -0,0 +1,210 @@ +/* +Copyright © 2016-17 Miranda NG team + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "stdafx.h" + +CMStringW CDiscordProto::GetAvatarFilename(MCONTACT hContact) +{ + CMStringW wszResult(FORMAT, L"%s\\%S", VARSW(L"%miranda_avatarcache%"), m_szModuleName); + + DWORD dwAttributes = GetFileAttributes(wszResult); + if (dwAttributes == 0xffffffff || (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) + CreateDirectoryTreeW(wszResult); + + wszResult.AppendChar('\\'); + + const wchar_t* szFileType = ProtoGetAvatarExtension(getByte(hContact, "AvatarType", PA_FORMAT_PNG)); + wszResult.AppendFormat(L"%lld%s", getId(hContact, DB_KEY_ID), szFileType); + return wszResult; +} + +INT_PTR CDiscordProto::GetAvatarCaps(WPARAM wParam, LPARAM lParam) +{ + int res = 0; + + switch (wParam) { + case AF_MAXSIZE: + ((POINT*)lParam)->x = ((POINT*)lParam)->y = 128; + break; + + case AF_PROPORTION: + res = PIP_NONE; + break; + + case AF_FORMATSUPPORTED: + res = lParam == PA_FORMAT_PNG || lParam == PA_FORMAT_GIF || lParam == PA_FORMAT_JPEG; + break; + + case AF_ENABLED: + res = 1; + break; + } + + return res; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +void CDiscordProto::OnReceiveAvatar(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) +{ + PROTO_AVATAR_INFORMATION ai = { 0 }; + ai.format = PA_FORMAT_UNKNOWN; + ai.hContact = (MCONTACT)pReq->pUserInfo; + + if (reply->resultCode != 200) { +LBL_Error: + ProtoBroadcastAck(ai.hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, (HANDLE)&ai); + return; + } + + const char *pszMimeType = NULL; + for (int i = 0; i < reply->headersCount; i++) + if (!mir_strcmp(reply->headers[i].szName, "Content-Type")) { + pszMimeType = reply->headers[i].szValue; + break; + } + + if (!mir_strcmp(pszMimeType, "image/jpeg")) + ai.format = PA_FORMAT_JPEG; + else if (!mir_strcmp(pszMimeType, "image/png")) + ai.format = PA_FORMAT_PNG; + else if (!mir_strcmp(pszMimeType, "image/gif")) + ai.format = PA_FORMAT_GIF; + else if (!mir_strcmp(pszMimeType, "image/bmp")) + ai.format = PA_FORMAT_BMP; + else { + debugLogA("unknown avatar mime type: %s", pszMimeType); + goto LBL_Error; + } + + mir_wstrncpy(ai.filename, GetAvatarFilename(ai.hContact), _countof(ai.filename)); + + FILE *out = _wfopen(ai.filename, L"wb"); + if (out == NULL) { + debugLogA("cannot open avatar file %S for writing", ai.filename); + goto LBL_Error; + } + + fwrite(reply->pData, 1, reply->dataLength, out); + fclose(out); + + if (ai.hContact) + ProtoBroadcastAck(ai.hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&ai); + else + CallService(MS_AV_REPORTMYAVATARCHANGED, (WPARAM)m_szModuleName, 0); +} + +bool CDiscordProto::RetrieveAvatar(MCONTACT hContact) +{ + ptrA szAvatarHash(getStringA(hContact, DB_KEY_AVHASH)); + SnowFlake id = getId(hContact, DB_KEY_ID); + if (id == 0 || szAvatarHash == NULL) + return false; + + CMStringA szUrl(FORMAT, "https://cdn.discordapp.com/avatars/%lld/%s.jpg", id, szAvatarHash); + AsyncHttpRequest *pReq = new AsyncHttpRequest(this, REQUEST_GET, szUrl, &CDiscordProto::OnReceiveAvatar); + pReq->pUserInfo = (void*)hContact; + Push(pReq); + return true; +} + +INT_PTR CDiscordProto::GetAvatarInfo(WPARAM flags, LPARAM lParam) +{ + PROTO_AVATAR_INFORMATION *pai = (PROTO_AVATAR_INFORMATION *)lParam; + + CMStringW wszFileName(GetAvatarFilename(pai->hContact)); + if (!wszFileName.IsEmpty()) { + mir_wstrncpy(pai->filename, wszFileName, _countof(pai->filename)); + + bool bFileExist = _waccess(wszFileName, 0) == 0; + + // if we still need to load an avatar + if ((flags & GAIF_FORCE) || !bFileExist) { + if (RetrieveAvatar(pai->hContact)) + return GAIR_WAITFOR; + } + else if (bFileExist) + return GAIR_SUCCESS; + } + + return GAIR_NOAVATAR; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +INT_PTR CDiscordProto::GetMyAvatar(WPARAM wParam, LPARAM lParam) +{ + if (!wParam || !lParam) + return -3; + + wchar_t* buf = (wchar_t*)wParam; + int size = (int)lParam; + + PROTO_AVATAR_INFORMATION ai = {}; + switch (GetAvatarInfo(0, (LPARAM)&ai)) { + case GAIR_SUCCESS: + wcsncpy_s(buf, size, ai.filename, _TRUNCATE); + return 0; + + case GAIR_WAITFOR: + return -1; + } + + return -2; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +INT_PTR CDiscordProto::SetMyAvatar(WPARAM, LPARAM lParam) +{ + CMStringW wszFileName(GetAvatarFilename(NULL)); + + const wchar_t *pwszFilename = (const wchar_t*)lParam; + if (pwszFilename == NULL) { // remove my avatar file + delSetting(DB_KEY_AVHASH); + DeleteFile(wszFileName); + } + + CMStringA szPayload("data:"); + + int iFormat = ProtoGetAvatarFileFormat(pwszFilename); + switch (iFormat) { + case PA_FORMAT_BMP: szPayload.Append("image/bmp"); break; + case PA_FORMAT_GIF: szPayload.Append("image/gif"); break; + case PA_FORMAT_PNG: szPayload.Append("image/png"); break; + case PA_FORMAT_JPEG: szPayload.Append("image/jpeg"); break; + default: + debugLogA("invalid file format for avatar %S: %d", pwszFilename, iFormat); + return 1; + } + szPayload.Append(";base64,"); + FILE *in = _wfopen(pwszFilename, L"rb"); + if (in == NULL) { + debugLogA("cannot open avatar file %S for reading", pwszFilename); + return 2; + } + + int iFileLength = _filelength(_fileno(in)); + ptrA szFileContents((char*)mir_alloc(iFileLength)); + fread(szFileContents, 1, iFileLength, in); + fclose(in); + szPayload.Append(ptrA(mir_base64_encode((BYTE*)szFileContents.get(), iFileLength))); + + JSONNode root; root << CHAR_PARAM("avatar", szPayload); + Push(new AsyncHttpRequest(this, REQUEST_PATCH, "/users/@me", NULL, &root)); + return 0; +} diff --git a/protocols/Discord/src/connection.cpp b/protocols/Discord/src/connection.cpp index bc48d402e4..969e85fb05 100644 --- a/protocols/Discord/src/connection.cpp +++ b/protocols/Discord/src/connection.cpp @@ -33,8 +33,10 @@ void CDiscordProto::ExecuteRequest(AsyncHttpRequest *pReq) } } - pReq->flags |= NLHRF_PERSISTENT; - pReq->nlc = m_hAPIConnection; + if (pReq->m_bMainSite) { + pReq->flags |= NLHRF_PERSISTENT; + pReq->nlc = m_hAPIConnection; + } debugLogA("Executing request #%d:\n%s", pReq->m_iReqNum, pReq->szUrl); NETLIBHTTPREQUEST *reply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)pReq); @@ -49,11 +51,11 @@ void CDiscordProto::ExecuteRequest(AsyncHttpRequest *pReq) else { debugLogA("Request %d failed", pReq->m_iReqNum); - if (IsStatusConnecting(m_iStatus)) - ConnectionFailed(LOGINERR_NONETWORK); - else - ShutdownSession(); - m_hAPIConnection = NULL; + if (pReq->m_bMainSite) { + if (IsStatusConnecting(m_iStatus)) + ConnectionFailed(LOGINERR_NONETWORK); + m_hAPIConnection = NULL; + } } delete pReq; } @@ -64,10 +66,6 @@ void CDiscordProto::OnLoggedIn() m_bOnline = true; SetServerStatus(m_iDesiredStatus); - Push(new AsyncHttpRequest(this, REQUEST_GET, "/users/@me/guilds", &CDiscordProto::OnReceiveGuilds)); - Push(new AsyncHttpRequest(this, REQUEST_GET, "/users/@me/channels", &CDiscordProto::OnReceiveChannels)); - Push(new AsyncHttpRequest(this, REQUEST_GET, "/users/@me/relationships", &CDiscordProto::OnReceiveFriends)); - if (m_szGateway.IsEmpty()) Push(new AsyncHttpRequest(this, REQUEST_GET, "/gateway", &CDiscordProto::OnReceiveGateway)); else @@ -78,10 +76,10 @@ void CDiscordProto::OnLoggedOut() { debugLogA("CDiscordProto::OnLoggedOut"); m_bOnline = false; - m_hWorkerThread = NULL; + m_bTerminated = true; + m_iGatewaySeq = 0; - if (m_hAPIConnection) - Netlib_CloseHandle(m_hAPIConnection); + KillTimer(g_hwndHeartbeat, (UINT_PTR)this); ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)m_iStatus, ID_STATUS_OFFLINE); m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; @@ -89,10 +87,19 @@ void CDiscordProto::OnLoggedOut() void CDiscordProto::ShutdownSession() { + if (m_bTerminated) + return; + debugLogA("CDiscordProto::ShutdownSession"); - m_bTerminated = true; + + // shutdown all resources if (m_hWorkerThread) SetEvent(m_evRequestsQueue); + if (m_hGatewayConnection) + Netlib_Shutdown(m_hGatewayConnection); + if (m_hAPIConnection) + Netlib_Shutdown(m_hAPIConnection); + OnLoggedOut(); } diff --git a/protocols/Discord/src/dispatch.cpp b/protocols/Discord/src/dispatch.cpp new file mode 100644 index 0000000000..8d314e0836 --- /dev/null +++ b/protocols/Discord/src/dispatch.cpp @@ -0,0 +1,221 @@ +/* +Copyright © 2016-17 Miranda NG team + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "stdafx.h" + +#pragma pack(4) + +struct CDiscordCommand +{ + const wchar_t *szCommandId; + GatewayHandlerFunc pFunc; +} +static handlers[] = // these structures must me sorted alphabetically +{ + { L"MESSAGE_CREATE", &CDiscordProto::OnCommandMessage }, + { L"MESSAGE_UPDATE", &CDiscordProto::OnCommandMessage }, + + { L"PRESENCE_UPDATE", &CDiscordProto::OnCommandPresence }, + + { L"READY", &CDiscordProto::OnCommandReady }, + + { L"TYPING_START", &CDiscordProto::OnCommandTyping }, + + { L"USER_UPDATE", &CDiscordProto::OnCommandUserUpdate }, +}; + +static int __cdecl pSearchFunc(const void *p1, const void *p2) +{ + return wcscmp(((CDiscordCommand*)p1)->szCommandId, ((CDiscordCommand*)p2)->szCommandId); +} + +GatewayHandlerFunc CDiscordProto::GetHandler(const wchar_t *pwszCommand) +{ + CDiscordCommand tmp = { pwszCommand, NULL }; + CDiscordCommand *p = (CDiscordCommand*)bsearch(&tmp, handlers, _countof(handlers), sizeof(handlers[0]), pSearchFunc); + return (p != NULL) ? p->pFunc : NULL; +} + +////////////////////////////////////////////////////////////////////////////////////// +// reading a new message + +void CDiscordProto::OnCommandMessage(const JSONNode &pRoot) +{ + PROTORECVEVENT recv = {}; + + CDiscordUser *pUser = PrepareUser(pRoot["author"]); + SnowFlake channelId = _wtoi64(pRoot["channel_id"].as_mstring()); + CMStringW msgId = pRoot["id"].as_mstring(); + CMStringW wszText = pRoot["content"].as_mstring(); + + // if a message has myself as an author, mark it as sent + if (pUser->id == 0) + return; + + const JSONNode &edited = pRoot["edited_timestamp"]; + if (!edited.isnull()) + wszText.AppendFormat(L" (%s %s)", TranslateT("edited at"), edited.as_mstring().c_str()); + + if (pUser->channelId != channelId) { + debugLogA("failed to process a groupchat message, exiting"); + return; + } + + ptrA buf(mir_utf8encodeW(wszText)); + recv.timestamp = (DWORD)StringToDate(pRoot["timestamp"].as_mstring()); + recv.szMessage = buf; + recv.lParam = (LPARAM)msgId.c_str(); + ProtoChainRecvMsg(pUser->hContact, &recv); + + SnowFlake lastId = getId(pUser->hContact, DB_KEY_LASTMSGID); // as stored in a database + if (lastId < _wtoi64(msgId)) + setId(pUser->hContact, DB_KEY_LASTMSGID, _wtoi64(msgId)); +} + +////////////////////////////////////////////////////////////////////////////////////// +// someone changed its status + +void CDiscordProto::OnCommandPresence(const JSONNode &pRoot) +{ + CDiscordUser *pUser = PrepareUser(pRoot["user"]); + if (pUser == NULL) + return; + + int iStatus; + CMStringW wszStatus = pRoot["status"].as_mstring(); + if (wszStatus == L"idle") + iStatus = ID_STATUS_IDLE; + else if (wszStatus == L"online") + iStatus = ID_STATUS_ONLINE; + else if (wszStatus == L"offline") + iStatus = ID_STATUS_OFFLINE; + else + iStatus = 0; + + if (iStatus != 0) + setWord(pUser->hContact, "Status", iStatus); + + CMStringW wszGame = pRoot["game"]["name"].as_mstring(); + if (!wszGame.IsEmpty()) + setWString(pUser->hContact, "XStatusMsg", wszGame); + else + delSetting(pUser->hContact, "XStatusMsg"); +} + +////////////////////////////////////////////////////////////////////////////////////// +// gateway session start + +void CALLBACK CDiscordProto::HeartbeatTimerProc(HWND, UINT, UINT_PTR id, DWORD) +{ + ((CDiscordProto*)id)->GatewaySendHeartbeat(); +} + +static void __stdcall sttStartTimer(void *param) +{ + CDiscordProto *ppro = (CDiscordProto*)param; + SetTimer(g_hwndHeartbeat, (UINT_PTR)param, ppro->getHeartbeatInterval(), &CDiscordProto::HeartbeatTimerProc); +} + +void CDiscordProto::OnCommandReady(const JSONNode &pRoot) +{ + GatewaySendHeartbeat(); + CallFunctionAsync(sttStartTimer, this); + + m_szGatewaySessionId = pRoot["session_id"].as_mstring(); + + const JSONNode &relations = pRoot["relationships"]; + for (auto it = relations.begin(); it != relations.end(); ++it) { + const JSONNode &p = *it; + + const JSONNode &user = p["user"]; + if (user) + PrepareUser(user); + } + + const JSONNode &channels = pRoot["private_channels"]; + for (auto it = channels.begin(); it != channels.end(); ++it) { + const JSONNode &p = *it; + + CDiscordUser *pUser = NULL; + const JSONNode &recipients = p["recipients"]; + for (auto it2 = recipients.begin(); it2 != recipients.end(); ++it2) + pUser = PrepareUser(*it2); + + if (pUser == NULL) + continue; + + pUser->channelId = _wtoi64(p["id"].as_mstring()); + pUser->lastMessageId = _wtoi64(p["last_message_id"].as_mstring()); + pUser->bIsPrivate = true; + + setId(pUser->hContact, DB_KEY_CHANNELID, pUser->channelId); + + SnowFlake oldMsgId = getId(pUser->hContact, DB_KEY_LASTMSGID); + if (pUser->lastMessageId > oldMsgId) + RetrieveHistory(pUser->hContact, MSG_AFTER, oldMsgId, 99); + } +} + +////////////////////////////////////////////////////////////////////////////////////// +// UTN support + +void CDiscordProto::OnCommandTyping(const JSONNode &pRoot) +{ + SnowFlake userId = _wtoi64(pRoot["user_id"].as_mstring()); + SnowFlake channelId = _wtoi64(pRoot["channel_id"].as_mstring()); + debugLogA("user typing notification: userid=%lld, channelid=%lld", userId, channelId); + + CDiscordUser *pUser = FindUser(userId); + if (pUser == NULL) { + debugLogA("user with id=%lld is not found", userId); + return; + } + + if (pUser->channelId == channelId) { + debugLogA("user is typing in his private channel"); + CallService(MS_PROTO_CONTACTISTYPING, pUser->hContact, 20); + } + else { + debugLogA("user is typing in a group channel, skipped"); + } +} + +////////////////////////////////////////////////////////////////////////////////////// +// UTN support + +void CDiscordProto::OnCommandUserUpdate(const JSONNode &pRoot) +{ + SnowFlake id = _wtoi64(pRoot["id"].as_mstring()); + + MCONTACT hContact; + if (id != m_ownId) { + CDiscordUser *pUser = FindUser(id); + if (pUser == NULL) + return; + + hContact = pUser->hContact; + } + else hContact = 0; + + // force rereading avatar + ptrW wszOldHash(getWStringA(hContact, DB_KEY_AVHASH)); + CMStringW wszNewHash(pRoot["avatar"].as_mstring()); + if (mir_wstrcmp(wszOldHash, wszNewHash)) { + setWString(hContact, DB_KEY_AVHASH, wszNewHash); + RetrieveAvatar(hContact); + } +} diff --git a/protocols/Discord/src/gateway.cpp b/protocols/Discord/src/gateway.cpp index a7352d4120..7454383878 100644 --- a/protocols/Discord/src/gateway.cpp +++ b/protocols/Discord/src/gateway.cpp @@ -17,30 +17,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "stdafx.h" -void CDiscordProto::OnReceiveGateway(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest*) -{ - if (pReply->resultCode != 200) { - ShutdownSession(); - return; - } - - JSONNode root = JSONNode::parse(pReply->pData); - if (!root) { - ShutdownSession(); - return; - } +////////////////////////////////////////////////////////////////////////////////////// +// sends a piece of JSON to a server via a websocket, masked - m_szGateway = root["url"].as_mstring(); - ForkThread(&CDiscordProto::GatewayThread, NULL); -} - -void CDiscordProto::GatewaySend(int opCode, const char *szBuf) +void CDiscordProto::GatewaySend(const JSONNode &pRoot, int opCode) { if (m_hGatewayConnection == NULL) return; + json_string szText = pRoot.write(); + BYTE header[20]; - size_t datalen, strLen = mir_strlen(szBuf); + size_t datalen; + uint64_t strLen = szText.length(); + header[0] = 0x80 + (opCode & 0x7F); if (strLen < 126) { header[1] = (strLen & 0xFF); @@ -65,15 +55,36 @@ void CDiscordProto::GatewaySend(int opCode, const char *szBuf) datalen = 10; } + union { + uLong dwMask; + Bytef arMask[4]; + }; + dwMask = crc32(rand(), (Bytef*)szText.c_str(), (uInt)szText.length()); + memcpy(header + datalen, arMask, _countof(arMask)); + datalen += _countof(arMask); + header[1] |= 0x80; + ptrA sendBuf((char*)mir_alloc(strLen + datalen)); memcpy(sendBuf, header, datalen); - if (strLen) - memcpy(sendBuf.get() + datalen, szBuf, strLen); + if (strLen) { + memcpy(sendBuf.get() + datalen, szText.c_str(), strLen); + for (size_t i = 0; i < strLen; i++) + sendBuf[i + datalen] ^= arMask[i & 3]; + } Netlib_Send(m_hGatewayConnection, sendBuf, int(strLen + datalen), 0); } +////////////////////////////////////////////////////////////////////////////////////// +// gateway worker thread + void CDiscordProto::GatewayThread(void*) { + GatewayThreadWorker(); + ShutdownSession(); +} + +void CDiscordProto::GatewayThreadWorker() +{ // connect to the gateway server if (!mir_strncmp(m_szGateway, "wss://", 6)) m_szGateway.Delete(0, 6); @@ -94,13 +105,11 @@ void CDiscordProto::GatewayThread(void*) m_hGatewayConnection = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_hGatewayNetlibUser, (LPARAM)&conn); if (m_hGatewayConnection == NULL) { debugLogA("Gateway connection failed to connect to %s:%d, exiting", m_szGateway.c_str(), conn.wPort); - LBL_Fatal: - ShutdownSession(); return; } { CMStringA szBuf; - szBuf.AppendFormat("GET https://%s/?encoding=etf&v=6 HTTP/1.1\r\n", m_szGateway.c_str()); + szBuf.AppendFormat("GET https://%s/?encoding=json&v=6 HTTP/1.1\r\n", m_szGateway.c_str()); szBuf.AppendFormat("Host: %s\r\n", m_szGateway.c_str()); szBuf.AppendFormat("Upgrade: websocket\r\n"); szBuf.AppendFormat("Pragma: no-cache\r\n"); @@ -112,7 +121,7 @@ void CDiscordProto::GatewayThread(void*) szBuf.AppendFormat("\r\n"); if (Netlib_Send(m_hGatewayConnection, szBuf, szBuf.GetLength(), MSG_DUMPASTEXT) == SOCKET_ERROR) { debugLogA("Error establishing gateway connection to %s:%d, send failed", m_szGateway.c_str(), conn.wPort); - goto LBL_Fatal; + return; } } { @@ -120,13 +129,13 @@ void CDiscordProto::GatewayThread(void*) int bufSize = Netlib_Recv(m_hGatewayConnection, buf, _countof(buf), MSG_DUMPASTEXT); if (bufSize <= 0) { debugLogA("Error establishing gateway connection to %s:%d, read failed", m_szGateway.c_str(), conn.wPort); - goto LBL_Fatal; + return; } int status = 0; if (sscanf(buf, "HTTP/1.1 %d", &status) != 1 || status != 101) { debugLogA("Error establishing gateway connection to %s:%d, status %d", m_szGateway.c_str(), conn.wPort, status); - goto LBL_Fatal; + return; } } @@ -134,22 +143,16 @@ void CDiscordProto::GatewayThread(void*) bool bExit = false; int offset = 0; - unsigned char *dataBuf = NULL; + char *dataBuf = NULL; size_t dataBufSize = 0; + bool bDataBufAllocated = false; while (!bExit) { if (m_bTerminated) break; - NETLIBSELECT sel = {}; - sel.cbSize = sizeof(sel); - sel.dwTimeout = 1000; - sel.hReadConns[0] = m_hGatewayConnection; - if (CallService(MS_NETLIB_SELECT, 0, (LPARAM)&sel) == 0) // timeout, send a hartbeat packet - GatewaySend(3, "{ \"op\":1, \"d\":(null) }"); - unsigned char buf[2048]; - int bufSize = Netlib_Recv(m_hGatewayConnection, (char*)buf+offset, _countof(buf) - offset, 0); + int bufSize = Netlib_Recv(m_hGatewayConnection, (char*)buf + offset, _countof(buf) - offset, 0); if (bufSize == 0) { debugLogA("Gateway connection gracefully closed"); break; @@ -201,16 +204,37 @@ void CDiscordProto::GatewayThread(void*) debugLogA("Got packet: buffer = %d, opcode = %d, headerSize = %d, final = %d, masked = %d", bufSize, opCode, headerSize, bIsFinal, bIsMasked); + // we have some additional data, not only opcode if (bufSize > headerSize) { - size_t newSize = dataBufSize + bufSize - headerSize; - dataBuf = (unsigned char*)mir_realloc(dataBuf, newSize); - memcpy(dataBuf + dataBufSize, buf + headerSize, bufSize - headerSize); - dataBufSize = newSize; - debugLogA("data buffer reallocated to %d bytes", dataBufSize); - } + if (bIsFinal && payloadSize < _countof(buf)) { // it fits, no need to reallocate a buffer + bDataBufAllocated = false; + dataBuf = (char*)buf + headerSize; + dataBufSize = bufSize - headerSize; + } + else { + bDataBufAllocated = true; + size_t newSize = dataBufSize + payloadSize; + size_t currPacketSize = bufSize - headerSize; + dataBuf = (char*)mir_realloc(dataBuf, newSize+1); + memcpy(dataBuf + dataBufSize, buf + headerSize, currPacketSize); + while (currPacketSize < payloadSize) { + int result = Netlib_Recv(m_hGatewayConnection, dataBuf + dataBufSize + currPacketSize, int(payloadSize - currPacketSize), 0); + if (result == 0) { + debugLogA("Gateway connection gracefully closed"); + break; + } + if (result < 0) { + debugLogA("Gateway connection error, exiting"); + break; + } + currPacketSize += result; + } - if (dataBufSize < payloadSize) - continue; + dataBufSize = newSize; + debugLogA("data buffer reallocated to %d bytes", dataBufSize); + } + dataBuf[dataBufSize] = 0; + } switch (opCode){ case 0: // text packet @@ -218,8 +242,9 @@ void CDiscordProto::GatewayThread(void*) case 2: // continuation if (bIsFinal) { // process a packet here - mir_free(dataBuf); dataBuf = NULL; - dataBufSize = 0; + JSONNode root = JSONNode::parse(dataBuf); + if (root) + GatewayProcess(root); } break; @@ -233,9 +258,85 @@ void CDiscordProto::GatewayThread(void*) Netlib_Send(m_hGatewayConnection, (char*)buf + headerSize, bufSize - headerSize, 0); break; } + + if (bIsFinal) { + if (bDataBufAllocated) + mir_free(dataBuf); + dataBuf = NULL; + dataBufSize = 0; + } } Netlib_CloseHandle(m_hGatewayConnection); m_hGatewayConnection = NULL; - ShutdownSession(); +} + +////////////////////////////////////////////////////////////////////////////////////// +// handles server commands + +void CDiscordProto::GatewayProcess(const JSONNode &pRoot) +{ + int opCode = pRoot["op"].as_int(); + switch (opCode) { + case 0: // process incoming command + { + int iSeq = pRoot["s"].as_int(); + if (iSeq != 0) + m_iGatewaySeq = iSeq; + + CMStringW wszCommand = pRoot["t"].as_mstring(); + debugLogA("got a server command to dispatch: %S", wszCommand.c_str()); + + GatewayHandlerFunc pFunc = GetHandler(wszCommand); + if (pFunc) + (this->*pFunc)(pRoot["d"]); + } + break; + + case 10: // hello + m_iHartbeatInterval = pRoot["d"]["heartbeat_interval"].as_int(); + + GatewaySendIdentify(); + break; + + case 11: // heartbeat ack + break; + + default: + debugLogA("ACHTUNG! Unknown opcode: %d, report it to developer", opCode); + } +} + +////////////////////////////////////////////////////////////////////////////////////// +// requests to be sent to a gateway + +void CDiscordProto::GatewaySendHeartbeat() +{ + // we don't send heartbeat packets until we get logged in + if (!m_iHartbeatInterval || !m_iGatewaySeq) + return; + + JSONNode root; + root << INT_PARAM("op", 1) << INT_PARAM("d", m_iGatewaySeq); + GatewaySend(root); +} + +void CDiscordProto::GatewaySendIdentify() +{ + wchar_t wszOs[256]; + GetOSDisplayString(wszOs, _countof(wszOs)); + + char szVersion[256]; + Miranda_GetVersionText(szVersion, _countof(szVersion)); + + JSONNode props; props.set_name("properties"); + props << WCHAR_PARAM("os", wszOs) << CHAR_PARAM("browser", "Chrome") << CHAR_PARAM("device", szVersion) + << CHAR_PARAM("referrer", "http://miranda-ng.org") << CHAR_PARAM("referring_domain", "miranda-ng.org"); + + JSONNode payload; payload.set_name("d"); + payload << CHAR_PARAM("token", m_szAccessToken) << props << BOOL_PARAM("compress", false) << INT_PARAM("large_threshold", 250); + + JSONNode root; + root << INT_PARAM("op", 2) << payload; + GatewaySend(root); } diff --git a/protocols/Discord/src/http.cpp b/protocols/Discord/src/http.cpp index e5941a71a4..a9136c5552 100644 --- a/protocols/Discord/src/http.cpp +++ b/protocols/Discord/src/http.cpp @@ -43,10 +43,14 @@ AsyncHttpRequest::AsyncHttpRequest(CDiscordProto *ppro, int iRequestType, LPCSTR cbSize = sizeof(NETLIBHTTPREQUEST); if (*_url == '/') { // relative url leads to a site - m_szUrl = "https://discordapp.com/api"; + m_szUrl = "https://discordapp.com/api/v6"; m_szUrl += _url; + m_bMainSite = true; + } + else { + m_szUrl = _url; + m_bMainSite = false; } - else m_szUrl = _url; flags = NLHRF_HTTP11 | NLHRF_REDIRECT | NLHRF_SSL; if (ppro->m_szAccessToken != NULL) { @@ -98,6 +102,15 @@ AsyncHttpRequest* operator<<(AsyncHttpRequest *pReq, const INT_PARAM ¶m) return pReq; } +AsyncHttpRequest* operator<<(AsyncHttpRequest *pReq, const INT64_PARAM ¶m) +{ + CMStringA &s = pReq->m_szParam; + if (!s.IsEmpty()) + s.AppendChar('&'); + s.AppendFormat("%s=%lld", param.szName, param.iValue); + return pReq; +} + AsyncHttpRequest* operator<<(AsyncHttpRequest *pReq, const CHAR_PARAM ¶m) { CMStringA &s = pReq->m_szParam; diff --git a/protocols/Discord/src/main.cpp b/protocols/Discord/src/main.cpp index edfac36d0c..850d4a044e 100644 --- a/protocols/Discord/src/main.cpp +++ b/protocols/Discord/src/main.cpp @@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. HINSTANCE g_hInstance; int hLangpack = 0; +HWND g_hwndHeartbeat; PLUGININFOEX pluginInfo = { sizeof(PLUGININFOEX), @@ -68,6 +69,8 @@ extern "C" int __declspec(dllexport) Load(void) { mir_getLP(&pluginInfo); + g_hwndHeartbeat = CreateWindowEx(0, L"STATIC", NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL); + PROTOCOLDESCRIPTOR pd = { 0 }; pd.cbSize = sizeof(pd); pd.szName = "Discord"; @@ -83,5 +86,6 @@ extern "C" int __declspec(dllexport) Load(void) extern "C" int __declspec(dllexport) Unload(void) { + DestroyWindow(g_hwndHeartbeat); return 0; } diff --git a/protocols/Discord/src/options.cpp b/protocols/Discord/src/options.cpp index 2114e47af9..c52424ce6f 100644 --- a/protocols/Discord/src/options.cpp +++ b/protocols/Discord/src/options.cpp @@ -25,8 +25,8 @@ class CDiscardAccountOptions : public CProtoDlgBase<CDiscordProto> ptrW m_wszOldGroup; public: - CDiscardAccountOptions(CDiscordProto *ppro) : - CProtoDlgBase<CDiscordProto>(ppro, IDD_OPTIONS_ACCOUNT), + CDiscardAccountOptions(CDiscordProto *ppro, int iDlgID) : + CProtoDlgBase<CDiscordProto>(ppro, iDlgID, false), m_edGroup(this, IDC_GROUP), m_edUserName(this, IDC_USERNAME), m_edPassword(this, IDC_PASSWORD), @@ -55,6 +55,14 @@ public: ///////////////////////////////////////////////////////////////////////////////////////// +INT_PTR CDiscordProto::SvcCreateAccMgrUI(WPARAM, LPARAM hwndParent) +{ + CDiscardAccountOptions *pDlg = new CDiscardAccountOptions(this, IDD_OPTIONS_ACCMGR); + pDlg->SetParent((HWND)hwndParent); + pDlg->Create(); + return (INT_PTR)pDlg->GetHwnd(); +} + int CDiscordProto::OnOptionsInit(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = { 0 }; @@ -65,7 +73,7 @@ int CDiscordProto::OnOptionsInit(WPARAM wParam, LPARAM) odp.position = 1; odp.szTab.w = LPGENW("Account"); - odp.pDialog = new CDiscardAccountOptions(this); + odp.pDialog = new CDiscardAccountOptions(this, IDD_OPTIONS_ACCOUNT); Options_AddPage(wParam, &odp); return 0; } diff --git a/protocols/Discord/src/proto.cpp b/protocols/Discord/src/proto.cpp index f85df56fe3..ea3975a983 100644 --- a/protocols/Discord/src/proto.cpp +++ b/protocols/Discord/src/proto.cpp @@ -33,14 +33,24 @@ CDiscordProto::CDiscordProto(const char *proto_name, const wchar_t *username) : m_evRequestsQueue(CreateEvent(NULL, FALSE, FALSE, NULL)), m_wszDefaultGroup(this, DB_KEY_GROUP, DB_KEYVAL_GROUP), m_wszEmail(this, DB_KEY_EMAIL, L""), + arMarkReadQueue(1, compareUsers), arUsers(50, compareUsers) { // Services CreateProtoService(PS_GETSTATUS, &CDiscordProto::GetStatus); + CreateProtoService(PS_CREATEACCMGRUI, &CDiscordProto::SvcCreateAccMgrUI); + + CreateProtoService(PS_GETAVATARINFO, &CDiscordProto::GetAvatarInfo); + CreateProtoService(PS_GETAVATARCAPS, &CDiscordProto::GetAvatarCaps); + CreateProtoService(PS_GETMYAVATAR, &CDiscordProto::GetMyAvatar); + CreateProtoService(PS_SETMYAVATAR, &CDiscordProto::SetMyAvatar); // Events HookProtoEvent(ME_OPT_INITIALISE, &CDiscordProto::OnOptionsInit); - HookProtoEvent(ME_MSG_WINDOWEVENT, &CDiscordProto::OnSrmmEvent); + HookProtoEvent(ME_DB_EVENT_MARKED_READ, &CDiscordProto::OnDbEventRead); + + // database + db_set_resident(m_szModuleName, "XStatusMsg"); // Clist Clist_GroupCreate(NULL, m_wszDefaultGroup); @@ -91,7 +101,7 @@ DWORD_PTR CDiscordProto::GetCaps(int type, MCONTACT) return PF1_IM | PF1_MODEMSGRECV | PF1_SERVERCLIST | PF1_BASICSEARCH | PF1_EXTSEARCH | PF1_ADDSEARCHRES; case PFLAGNUM_2: case PFLAGNUM_3: - return PF2_ONLINE | PF2_HEAVYDND | PF2_INVISIBLE | PF2_IDLE; + return PF2_ONLINE | PF2_LONGAWAY | PF2_HEAVYDND | PF2_INVISIBLE; case PFLAGNUM_4: return PF4_FORCEADDED | PF4_FORCEAUTH | PF4_NOCUSTOMAUTH | PF4_NOAUTHDENYREASON | PF4_SUPPORTTYPING | PF4_SUPPORTIDLE | PF4_AVATARS | PF4_IMSENDOFFLINE; case PFLAG_UNIQUEIDTEXT: @@ -109,33 +119,34 @@ INT_PTR CDiscordProto::GetStatus(WPARAM, LPARAM) int CDiscordProto::SetStatus(int iNewStatus) { + debugLogA("CDiscordProto::SetStatus iNewStatus = %d, m_iStatus = %d, m_iDesiredStatus = %d m_hWorkerThread = %p", iNewStatus, m_iStatus, m_iDesiredStatus, m_hWorkerThread); + if (iNewStatus == m_iStatus) return 0; m_iDesiredStatus = iNewStatus; int iOldStatus = m_iStatus; - // all statuses but offline are treated as online - if (iNewStatus >= ID_STATUS_ONLINE && iNewStatus <= ID_STATUS_OUTTOLUNCH) { - m_iDesiredStatus = ID_STATUS_ONLINE; - - // if we're already connecting and they want to go online - if (IsStatusConnecting(m_iStatus)) - return 0; - - // if we're already connected, don't try to reconnect - if (m_iStatus >= ID_STATUS_ONLINE && m_iStatus <= ID_STATUS_OUTTOLUNCH) - return 0; + // go offline + if (iNewStatus == ID_STATUS_OFFLINE) { + if (m_bOnline) { + SetServerStatus(ID_STATUS_OFFLINE); + ShutdownSession(); + } + m_iStatus = m_iDesiredStatus; + SetAllContactStatuses(ID_STATUS_OFFLINE); + ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)iOldStatus, m_iStatus); + } + // not logged in? come on + else if (m_hWorkerThread == NULL && !IsStatusConnecting(m_iStatus)) { m_iStatus = ID_STATUS_CONNECTING; ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)iOldStatus, m_iStatus); m_hWorkerThread = ForkThreadEx(&CDiscordProto::ServerThread, NULL, NULL); } - else if (iNewStatus == ID_STATUS_OFFLINE) { - m_iStatus = m_iDesiredStatus; - SetAllContactStatuses(ID_STATUS_OFFLINE); - - ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)iOldStatus, m_iStatus); + else if (m_bOnline) { + debugLogA("setting server online status to %d", iNewStatus); + SetServerStatus(iNewStatus); } return 0; @@ -258,6 +269,92 @@ MCONTACT CDiscordProto::AddToList(int flags, PROTOSEARCHRESULT *psr) return hContact; } +//////////////////////////////////////////////////////////////////////////////////////// +// RecvMsg + +int CDiscordProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT *evt) +{ + T2Utf szResUtf((const wchar_t*)evt->lParam); + evt->pCustomData = (char*)szResUtf; + evt->cbCustomDataSize = (DWORD)mir_strlen(szResUtf); + Proto_RecvMessage(hContact, evt); + return 0; +} + +//////////////////////////////////////////////////////////////////////////////////////// +// SendMsg + +void __cdecl CDiscordProto::SendMessageAckThread(void *param) +{ + Sleep(100); + ProtoBroadcastAck((MCONTACT)param, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)1, (LPARAM)Translate("Protocol is offline or no JID")); +} + +int CDiscordProto::SendMsg(MCONTACT hContact, int /*flags*/, const char *pszSrc) +{ + if (!m_bOnline) { + ForkThread(&CDiscordProto::SendMessageAckThread, (void*)hContact); + return 1; + } + + ptrW wszText(mir_utf8decodeW(pszSrc)); + if (wszText == NULL) + return 0; + + CDiscordUser *pUser = FindUser(getId(hContact, DB_KEY_ID)); + if (pUser == NULL || pUser->channelId == NULL) + return 0; + + CMStringA szUrl(FORMAT, "/channels/%lld/messages", pUser->channelId); + JSONNode body; body << WCHAR_PARAM("content", wszText); + AsyncHttpRequest *pReq = new AsyncHttpRequest(this, REQUEST_POST, szUrl, &CDiscordProto::OnReceiveMessage, &body); + pReq->pUserInfo = (void*)hContact; + Push(pReq); + return pReq->m_iReqNum; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +void CDiscordProto::MarkReadTimerProc(HWND hwnd, UINT, UINT_PTR id, DWORD) +{ + CDiscordProto *ppro = (CDiscordProto*)(id - 1); + + JSONNode root; root.push_back(JSONNode("token", NULL)); + + mir_cslock lck(ppro->csMarkReadQueue); + while (ppro->arMarkReadQueue.getCount()) { + CDiscordUser *pUser = ppro->arMarkReadQueue[0]; + CMStringA szUrl(FORMAT, "/channels/%lld/messages/%lld/ack", pUser->channelId, pUser->lastMessageId); + ppro->Push(new AsyncHttpRequest(ppro, REQUEST_POST, szUrl, &CDiscordProto::OnReceiveMessageAck)); + ppro->arMarkReadQueue.remove(0); + } + KillTimer(hwnd, id); +} + +int CDiscordProto::OnDbEventRead(WPARAM, LPARAM hDbEvent) +{ + MCONTACT hContact = db_event_getContact(hDbEvent); + if (!hContact) + return 0; + + // filter out only events of my protocol + const char *szProto = GetContactProto(hContact); + if (mir_strcmp(szProto, m_szModuleName)) + return 0; + + if (m_bOnline) { + SetTimer(g_hwndHeartbeat, UINT_PTR(this) + 1, 200, &CDiscordProto::MarkReadTimerProc); + + CDiscordUser *pUser = FindUser(getId(hContact, DB_KEY_ID)); + if (pUser != NULL) { + mir_cslock lck(csMarkReadQueue); + if (arMarkReadQueue.indexOf(pUser) == -1) + arMarkReadQueue.insert(pUser); + } + } + return 0; +} + ///////////////////////////////////////////////////////////////////////////////////////// int CDiscordProto::OnModulesLoaded(WPARAM, LPARAM) @@ -279,23 +376,6 @@ int CDiscordProto::OnPreShutdown(WPARAM, LPARAM) ///////////////////////////////////////////////////////////////////////////////////////// -int CDiscordProto::OnSrmmEvent(WPARAM, LPARAM lParam) -{ - MessageWindowEventData *MWeventdata = (MessageWindowEventData*)lParam; - - if (MWeventdata->uType == MSG_WINDOW_EVT_OPENING && MWeventdata->hContact) { - SnowFlake oldid = getId(MWeventdata->hContact, DB_KEY_LASTMSGID); - if (oldid > 0) - RetrieveHistory(MWeventdata->hContact, MSG_AFTER, oldid, 99); - else - RetrieveHistory(MWeventdata->hContact, MSG_NOFILTER, 0, 99); - } - - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// - int CDiscordProto::OnEvent(PROTOEVENTTYPE event, WPARAM wParam, LPARAM lParam) { switch (event) { diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h index b822bbf323..15a6a9eeeb 100644 --- a/protocols/Discord/src/proto.h +++ b/protocols/Discord/src/proto.h @@ -3,6 +3,7 @@ typedef __int64 SnowFlake; class CDiscordProto; typedef void (CDiscordProto::*HttpCallback)(NETLIBHTTPREQUEST*, struct AsyncHttpRequest*); +typedef void (CDiscordProto::*GatewayHandlerFunc)(const JSONNode&); struct AsyncHttpRequest : public NETLIBHTTPREQUEST, public MZeroedObject { @@ -16,6 +17,7 @@ struct AsyncHttpRequest : public NETLIBHTTPREQUEST, public MZeroedObject CMStringA m_szParam; HttpCallback m_pCallback; int m_iErrorCode, m_iReqNum; + bool m_bMainSite; void *pUserInfo; }; @@ -26,6 +28,15 @@ struct PARAM {} }; +struct BOOL_PARAM : public PARAM +{ + bool bValue; + __forceinline BOOL_PARAM(LPCSTR _name, bool _value) : + PARAM(_name), bValue(_value) + {} +}; +AsyncHttpRequest* operator<<(AsyncHttpRequest*, const BOOL_PARAM&); + struct INT_PARAM : public PARAM { int iValue; @@ -35,6 +46,15 @@ struct INT_PARAM : public PARAM }; AsyncHttpRequest* operator<<(AsyncHttpRequest*, const INT_PARAM&); +struct INT64_PARAM : public PARAM +{ + SnowFlake iValue; + __forceinline INT64_PARAM(LPCSTR _name, SnowFlake _value) : + PARAM(_name), iValue(_value) + {} +}; +AsyncHttpRequest* operator<<(AsyncHttpRequest*, const INT64_PARAM&); + struct CHAR_PARAM : public PARAM { LPCSTR szValue; @@ -54,6 +74,7 @@ struct WCHAR_PARAM : public PARAM AsyncHttpRequest* operator<<(AsyncHttpRequest*, const WCHAR_PARAM&); JSONNode& operator<<(JSONNode &json, const INT_PARAM ¶m); +JSONNode& operator<<(JSONNode &json, const BOOL_PARAM ¶m); JSONNode& operator<<(JSONNode &json, const CHAR_PARAM ¶m); JSONNode& operator<<(JSONNode &json, const WCHAR_PARAM ¶m); @@ -91,6 +112,7 @@ class CDiscordProto : public PROTO<CDiscordProto> void __cdecl ServerThread(void*); void __cdecl SearchThread(void *param); + void __cdecl SendMessageAckThread(void* param); ////////////////////////////////////////////////////////////////////////////////////// // session control @@ -119,14 +141,27 @@ class CDiscordProto : public PROTO<CDiscordProto> ////////////////////////////////////////////////////////////////////////////////////// // gateway - CMStringA m_szGateway; + CMStringA + m_szGateway, // gateway url + m_szGatewaySessionId; // current session id + HANDLE m_hGatewayNetlibUser, // the separate netlib user handle for gateways m_hGatewayConnection; // gateway connection + void __cdecl GatewayThread(void*); - void GatewaySend(int opCode, const char*); + void CDiscordProto::GatewayThreadWorker(void); + + void GatewaySend(const JSONNode&, int opCode = 1); + void GatewayProcess(const JSONNode&); - void OnReceiveGateway(NETLIBHTTPREQUEST*, AsyncHttpRequest*); + void GatewaySendHeartbeat(void); + void GatewaySendIdentify(void); + + GatewayHandlerFunc GetHandler(const wchar_t*); + + int m_iHartbeatInterval; // in milliseconds + int m_iGatewaySeq; // gateway sequence number ////////////////////////////////////////////////////////////////////////////////////// // options @@ -139,9 +174,13 @@ class CDiscordProto : public PROTO<CDiscordProto> SnowFlake m_ownId; + mir_cs csMarkReadQueue; + LIST<CDiscordUser> arMarkReadQueue; + OBJLIST<CDiscordUser> arUsers; CDiscordUser* FindUser(SnowFlake id); CDiscordUser* FindUser(const wchar_t *pwszUsername, int iDiscriminator); + CDiscordUser* FindUserByChannel(SnowFlake channelId); CDiscordUser* PrepareUser(const JSONNode&); ////////////////////////////////////////////////////////////////////////////////////// @@ -168,26 +207,45 @@ public: virtual int __cdecl AuthRequest(MCONTACT hContact, const wchar_t*) override; + virtual int __cdecl RecvMsg(MCONTACT hContact, PROTORECVEVENT *evt) override; + virtual int __cdecl SendMsg(MCONTACT hContact, int flags, const char* pszSrc) override; + virtual int __cdecl SetStatus(int iNewStatus) override; virtual int __cdecl OnEvent(PROTOEVENTTYPE, WPARAM, LPARAM) override; // Services + INT_PTR __cdecl SvcCreateAccMgrUI(WPARAM, LPARAM); INT_PTR __cdecl GetStatus(WPARAM, LPARAM); + INT_PTR __cdecl GetAvatarCaps(WPARAM, LPARAM); + INT_PTR __cdecl GetAvatarInfo(WPARAM, LPARAM); + INT_PTR __cdecl GetMyAvatar(WPARAM, LPARAM); + INT_PTR __cdecl SetMyAvatar(WPARAM, LPARAM); + // Events int __cdecl OnModulesLoaded(WPARAM, LPARAM); int __cdecl OnPreShutdown(WPARAM, LPARAM); int __cdecl OnOptionsInit(WPARAM, LPARAM); - int __cdecl OnSrmmEvent(WPARAM, LPARAM); + int __cdecl OnDbEventRead(WPARAM, LPARAM); + + // dispatch commands + void OnCommandMessage(const JSONNode&); + void OnCommandPresence(const JSONNode&); + void OnCommandReady(const JSONNode&); + void OnCommandTyping(const JSONNode&); + void OnCommandUserUpdate(const JSONNode&); void OnLoggedIn(); void OnLoggedOut(); void OnReceiveAuth(NETLIBHTTPREQUEST*, AsyncHttpRequest*); - void OnReceiveToken(NETLIBHTTPREQUEST*, AsyncHttpRequest*); - void OnReceiveGuilds(NETLIBHTTPREQUEST*, AsyncHttpRequest*); void OnReceiveChannels(NETLIBHTTPREQUEST*, AsyncHttpRequest*); void OnReceiveFriends(NETLIBHTTPREQUEST*, AsyncHttpRequest*); + void OnReceiveGateway(NETLIBHTTPREQUEST*, AsyncHttpRequest*); + void OnReceiveGuilds(NETLIBHTTPREQUEST*, AsyncHttpRequest*); + void OnReceiveMessage(NETLIBHTTPREQUEST*, AsyncHttpRequest*); + void OnReceiveMessageAck(NETLIBHTTPREQUEST*, AsyncHttpRequest*); + void OnReceiveToken(NETLIBHTTPREQUEST*, AsyncHttpRequest*); void RetrieveUserInfo(MCONTACT hContact); void OnReceiveUserInfo(NETLIBHTTPREQUEST*, AsyncHttpRequest*); @@ -195,6 +253,16 @@ public: void RetrieveHistory(MCONTACT hContact, CDiscordHitoryOp iOp = MSG_NOFILTER, SnowFlake msgid = 0, int iLimit = 50); void OnReceiveHistory(NETLIBHTTPREQUEST*, AsyncHttpRequest*); + bool RetrieveAvatar(MCONTACT hContact); + void OnReceiveAvatar(NETLIBHTTPREQUEST*, AsyncHttpRequest*); + // Misc void SetServerStatus(int iStatus); + + CMStringW GetAvatarFilename(MCONTACT hContact); + + __forceinline int getHeartbeatInterval() const { return m_iHartbeatInterval; } + + static void CALLBACK HeartbeatTimerProc(HWND hwnd, UINT msg, UINT_PTR id, DWORD); + static void CALLBACK MarkReadTimerProc(HWND hwnd, UINT msg, UINT_PTR id, DWORD); }; diff --git a/protocols/Discord/src/resource.h b/protocols/Discord/src/resource.h index 840b444d17..20a3000f8c 100644 --- a/protocols/Discord/src/resource.h +++ b/protocols/Discord/src/resource.h @@ -1,17 +1,16 @@ //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. -// Used by twitter.rc +// Used by w:\miranda-ng\protocols\Discord\res\discord.rc // - #define IDI_MAIN 101 #define IDI_OFFLINE 102 #define IDD_OPTIONS_ACCOUNT 103 #define IDD_EXTSEARCH 104 - -#define IDC_PASSWORD 1001 -#define IDC_USERNAME 1002 -#define IDC_GROUP 1003 -#define IDC_NICK 1004 +#define IDD_OPTIONS_ACCMGR 105 +#define IDC_PASSWORD 1001 +#define IDC_USERNAME 1002 +#define IDC_GROUP 1003 +#define IDC_NICK 1004 // Next default values for new objects // diff --git a/protocols/Discord/src/server.cpp b/protocols/Discord/src/server.cpp index a5ac8e215a..858be58c55 100644 --- a/protocols/Discord/src/server.cpp +++ b/protocols/Discord/src/server.cpp @@ -31,9 +31,9 @@ void CDiscordProto::RetrieveHistory(MCONTACT hContact, CDiscordHitoryOp iOp, Sno pReq << INT_PARAM("limit", iLimit); switch (iOp) { case MSG_AFTER: - pReq << CHAR_PARAM("after", CMStringA(FORMAT, "%lld", msgid)); break; + pReq << INT64_PARAM("after", msgid); break; case MSG_BEFORE: - pReq << CHAR_PARAM("before", CMStringA(FORMAT, "%lld", msgid)); break; + pReq << INT64_PARAM("before", msgid); break; } pReq->pUserInfo = pUser; Push(pReq); @@ -110,17 +110,46 @@ void CDiscordProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *pReply, AsyncHttpReques return; } + ptrW wszOldAvatar(getWStringA(hContact, DB_KEY_AVHASH)); + m_ownId = _wtoi64(root["id"].as_mstring()); setId(hContact, DB_KEY_ID, m_ownId); setByte(hContact, DB_KEY_MFA, root["mfa_enabled"].as_bool()); setDword(hContact, DB_KEY_DISCR, root["discriminator"].as_int()); setWString(hContact, DB_KEY_NICK, root["username"].as_mstring()); - setWString(hContact, DB_KEY_AVHASH, root["avatar"].as_mstring()); setWString(hContact, DB_KEY_EMAIL, root["email"].as_mstring()); - if (hContact == NULL) + CMStringW wszNewAvatar(root["avatar"].as_mstring()); + setWString(hContact, DB_KEY_AVHASH, wszNewAvatar); + + if (hContact == NULL) { + // if avatar's hash changed, we need to request a new one + if (mir_wstrcmp(wszNewAvatar, wszOldAvatar)) + RetrieveAvatar(NULL); + OnLoggedIn(); + } +} + +///////////////////////////////////////////////////////////////////////////////////////// +// finds a gateway address + +void CDiscordProto::OnReceiveGateway(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest*) +{ + if (pReply->resultCode != 200) { + ShutdownSession(); + return; + } + + JSONNode root = JSONNode::parse(pReply->pData); + if (!root) { + ShutdownSession(); + return; + } + + m_szGateway = root["url"].as_mstring(); + ForkThread(&CDiscordProto::GatewayThread, NULL); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -132,6 +161,17 @@ void CDiscordProto::SetServerStatus(int iStatus) if (iStatus == ID_STATUS_OFFLINE) Push(new AsyncHttpRequest(this, REQUEST_POST, "/auth/logout", NULL)); + else { + const char *pszStatus; + switch (iStatus) { + case ID_STATUS_NA: pszStatus = "idle"; break; + case ID_STATUS_DND: pszStatus = "dnd"; break; + case ID_STATUS_INVISIBLE: pszStatus = "invisible"; break; + default: pszStatus = "online"; break; + } + JSONNode root; root << CHAR_PARAM("status", pszStatus); + Push(new AsyncHttpRequest(this, REQUEST_PATCH, "/users/@me/settings", NULL, &root)); + } int iOldStatus = m_iStatus; m_iStatus = iStatus; ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)iOldStatus, m_iStatus); @@ -201,6 +241,47 @@ void CDiscordProto::OnReceiveGuilds(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest* ///////////////////////////////////////////////////////////////////////////////////////// +void CDiscordProto::OnReceiveMessage(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq) +{ + MCONTACT hContact = (MCONTACT)pReq->pUserInfo; + + bool bSucceeded = true; + if (pReply->resultCode != 200 && pReply->resultCode != 204) + bSucceeded = false; + + JSONNode root = JSONNode::parse(pReply->pData); + if (root) { + SnowFlake newLastId = _wtoi64(root["id"].as_mstring()); + SnowFlake oldLastId = getId(hContact, DB_KEY_LASTMSGID); // as stored in a database + if (oldLastId < newLastId) + setId(hContact, DB_KEY_LASTMSGID, newLastId); + } + + ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, bSucceeded ? ACKRESULT_SUCCESS : ACKRESULT_FAILED, (HANDLE)pReq->m_iReqNum, 0); +} + +///////////////////////////////////////////////////////////////////////////////////////// + +void CDiscordProto::OnReceiveMessageAck(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest*) +{ + if (pReply->resultCode != 200) + return; + + JSONNode root = JSONNode::parse(pReply->pData); + if (!root) + return; + + CMStringW wszToken(root["token"].as_mstring()); + if (!wszToken.IsEmpty()) { + JSONNode props; props.set_name("properties"); + JSONNode reply; reply << props; + reply << CHAR_PARAM("event", "ack_messages") << WCHAR_PARAM("token", root["token"].as_mstring()); + Push(new AsyncHttpRequest(this, REQUEST_POST, "/track", NULL, &reply)); + } +} + +///////////////////////////////////////////////////////////////////////////////////////// + void CDiscordProto::OnReceiveToken(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest*) { if (pReply->resultCode != 200) { @@ -224,5 +305,3 @@ LBL_Error: RetrieveUserInfo(NULL); } - -///////////////////////////////////////////////////////////////////////////////////////// diff --git a/protocols/Discord/src/stdafx.h b/protocols/Discord/src/stdafx.h index 43d0077d7c..9bf1ba7cc1 100644 --- a/protocols/Discord/src/stdafx.h +++ b/protocols/Discord/src/stdafx.h @@ -9,6 +9,7 @@ #include <Shlwapi.h> #include <Wincrypt.h> #include <stdio.h> +#include <io.h> #include <direct.h> #include <time.h> @@ -37,9 +38,13 @@ #include <m_utils.h> #include <m_hotkeys.h> #include <m_json.h> +#include <m_avatars.h> #include <win2k.h> +#include "../../libs/zlib/src/zlib.h" + extern HINSTANCE g_hInstance; +extern HWND g_hwndHeartbeat; #include "version.h" #include "proto.h" @@ -58,3 +63,4 @@ extern HINSTANCE g_hInstance; #define DB_KEYVAL_GROUP L"Discord" time_t StringToDate(const CMStringW &str); +int SerialNext(void);
\ No newline at end of file diff --git a/protocols/Discord/src/utils.cpp b/protocols/Discord/src/utils.cpp index 0513e49aac..ac9eb85c11 100644 --- a/protocols/Discord/src/utils.cpp +++ b/protocols/Discord/src/utils.cpp @@ -32,6 +32,12 @@ JSONNode& operator<<(JSONNode &json, const INT_PARAM ¶m) return json; } +JSONNode& operator<<(JSONNode &json, const BOOL_PARAM ¶m) +{ + json.push_back(JSONNode(param.szName, param.bValue)); + return json; +} + JSONNode& operator<<(JSONNode &json, const CHAR_PARAM ¶m) { json.push_back(JSONNode(param.szName, param.szValue)); @@ -64,6 +70,15 @@ time_t StringToDate(const CMStringW &str) ///////////////////////////////////////////////////////////////////////////////////////// +static LONG volatile g_counter = 1; + +int SerialNext() +{ + return InterlockedIncrement(&g_counter); +} + +///////////////////////////////////////////////////////////////////////////////////////// + SnowFlake CDiscordProto::getId(const char *szSetting) { DBVARIANT dbv; @@ -100,6 +115,8 @@ void CDiscordProto::setId(MCONTACT hContact, const char *szSetting, SnowFlake iV ///////////////////////////////////////////////////////////////////////////////////////// +static CDiscordUser *g_myUser = new CDiscordUser(0); + CDiscordUser* CDiscordProto::FindUser(SnowFlake id) { return arUsers.find((CDiscordUser*)&id); @@ -116,9 +133,23 @@ CDiscordUser* CDiscordProto::FindUser(const wchar_t *pwszUsername, int iDiscrimi return NULL; } +CDiscordUser* CDiscordProto::FindUserByChannel(SnowFlake channelId) +{ + for (int i = 0; i < arUsers.getCount(); i++) { + CDiscordUser &p = arUsers[i]; + if (p.channelId == channelId) + return &p; + } + + return NULL; +} + CDiscordUser* CDiscordProto::PrepareUser(const JSONNode &user) { SnowFlake id = _wtoi64(user["id"].as_mstring()); + if (id == m_ownId) + return g_myUser; + int iDiscriminator = _wtoi(user["discriminator"].as_mstring()); CMStringW avatar = user["avatar"].as_mstring(); CMStringW username = user["username"].as_mstring(); @@ -137,6 +168,7 @@ CDiscordUser* CDiscordProto::PrepareUser(const JSONNode &user) MCONTACT hContact = db_add_contact(); Proto_AddToContact(hContact, m_szModuleName); + db_set_ws(hContact, "CList", "Group", m_wszDefaultGroup); setId(hContact, DB_KEY_ID, id); setWString(hContact, DB_KEY_NICK, username); setDword(hContact, DB_KEY_DISCR, iDiscriminator); diff --git a/protocols/Discord/src/version.h b/protocols/Discord/src/version.h index c4be71667a..283aed187b 100644 --- a/protocols/Discord/src/version.h +++ b/protocols/Discord/src/version.h @@ -1,5 +1,5 @@ #define __MAJOR_VERSION 0 -#define __MINOR_VERSION 0 +#define __MINOR_VERSION 1 #define __RELEASE_NUM 0 #define __BUILD_NUM 3 diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index 764ae69c5a..d577fb882c 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -403,7 +403,7 @@ void parseAttachments(FacebookProto *proto, std::string *message_text, const JSO } else { *message_text += T2Utf(TranslateT("User sent an unsupported attachment. Open your browser to see it.")); - proto->debugLogA("json::parseAttachments (%s) - Unsupported attachment:\n%s", legacy ? "legacy" : "not legacy", attachments_.as_string()); + proto->debugLogA("json::parseAttachments (%s) - Unsupported attachment:\n%s", legacy ? "legacy" : "not legacy", attachments_.as_string().c_str()); } } @@ -1089,7 +1089,7 @@ int facebook_json_parser::parse_unread_threads(std::string *data, std::vector< s return EXIT_FAILURE; for (auto it = unread_threads.begin(); it != unread_threads.end(); ++it) { - const JSONNode &thread_ids = (*it)["thread_ids"]; + const JSONNode &thread_ids = (*it)["thread_fbids"]; for (auto jt = thread_ids.begin(); jt != thread_ids.end(); ++jt) threads->push_back((*jt).as_string()); diff --git a/protocols/GTalkExt/src/avatar.cpp b/protocols/GTalkExt/src/avatar.cpp index 36c6f4ff6a..621df70a90 100644 --- a/protocols/GTalkExt/src/avatar.cpp +++ b/protocols/GTalkExt/src/avatar.cpp @@ -138,7 +138,7 @@ void SetAvatar(MCONTACT hContact) {
mir_cslock lck(g_csSetAvatar);
- avatarCacheEntry *ava = (avatarCacheEntry*)CallService(MS_AV_GETAVATARBITMAP, hContact, 0);
+ AVATARCACHEENTRY *ava = (AVATARCACHEENTRY*)CallService(MS_AV_GETAVATARBITMAP, hContact, 0);
if (ava && GetFileAttributes(&ava->szFilename[0]) != INVALID_FILE_ATTRIBUTES)
return;
@@ -153,7 +153,7 @@ void SetAvatar(MCONTACT hContact) return;
if (ava)
- CallService(MS_AV_SETAVATART, hContact, (LPARAM)L"");
- CallService(MS_AV_SETAVATART, hContact, (LPARAM)avaFile);
+ CallService(MS_AV_SETAVATARW, hContact, (LPARAM)L"");
+ CallService(MS_AV_SETAVATARW, hContact, (LPARAM)avaFile);
db_set_ws(hContact, SRMM_MODULE_NAME, SRMM_AVATAR_SETTING_NAME, avaFile);
}
diff --git a/protocols/IcqOscarJ/src/icq_http.cpp b/protocols/IcqOscarJ/src/icq_http.cpp index 5c5492cbc3..d9a8e5378a 100644 --- a/protocols/IcqOscarJ/src/icq_http.cpp +++ b/protocols/IcqOscarJ/src/icq_http.cpp @@ -101,7 +101,7 @@ int icq_httpGatewayBegin(HANDLE hConn, NETLIBOPENCONNECTION* nloc) -int icq_httpGatewayWrapSend(HANDLE hConn, PBYTE buf, int len, int flags, MIRANDASERVICE pfnNetlibSend)
+int icq_httpGatewayWrapSend(HANDLE hConn, PBYTE buf, int len, int flags)
{
PBYTE sendBuf = buf;
int sendLen = len;
@@ -119,8 +119,7 @@ int icq_httpGatewayWrapSend(HANDLE hConn, PBYTE buf, int len, int flags, MIRANDA write_httphdr(&packet, HTTP_PACKETTYPE_FLAP, GetGatewayIndex(hConn));
packBuffer(&packet, sendBuf, curLen);
- NETLIBBUFFER nlb={ (char*)packet.pData, packet.wLen, flags };
- curResult = pfnNetlibSend((WPARAM)hConn, (LPARAM)&nlb);
+ curResult = Netlib_Send(hConn, (char*)packet.pData, packet.wLen, flags);
SAFE_FREE((void**)&packet.pData);
diff --git a/protocols/IcqOscarJ/src/icq_http.h b/protocols/IcqOscarJ/src/icq_http.h index fb4b948770..0f2eb6a394 100644 --- a/protocols/IcqOscarJ/src/icq_http.h +++ b/protocols/IcqOscarJ/src/icq_http.h @@ -37,7 +37,7 @@ int icq_httpGatewayInit(HANDLE hConn, NETLIBOPENCONNECTION *nloc, NETLIBHTTPREQUEST *nlhr);
int icq_httpGatewayBegin(HANDLE hConn, NETLIBOPENCONNECTION *nloc);
-int icq_httpGatewayWrapSend(HANDLE hConn, PBYTE buf, int len, int flags, MIRANDASERVICE pfnNetlibSend);
+int icq_httpGatewayWrapSend(HANDLE hConn, PBYTE buf, int len, int flags);
PBYTE icq_httpGatewayUnwrapRecv(NETLIBHTTPREQUEST *nlhr, PBYTE buf, int bufLen, int *outBufLen, void *(*NetlibRealloc)(void *, size_t));
int icq_httpGatewayWalkTo(HANDLE hConn, NETLIBOPENCONNECTION* nloc);
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp index a72bbf3eeb..a91cd1d3d4 100644 --- a/protocols/JabberG/src/jabber_iqid.cpp +++ b/protocols/JabberG/src/jabber_iqid.cpp @@ -608,7 +608,7 @@ void CJabberProto::OnIqResultGetVcardPhoto(HXML n, MCONTACT hContact, bool &hasP debugLogA("%d bytes written", nWritten);
if (hContact == NULL) {
hasPhoto = true;
- CallService(MS_AV_SETMYAVATART, (WPARAM)m_szModuleName, (LPARAM)szAvatarFileName);
+ CallService(MS_AV_SETMYAVATARW, (WPARAM)m_szModuleName, (LPARAM)szAvatarFileName);
debugLogW(L"My picture saved to %s", szAvatarFileName);
}
diff --git a/protocols/MSN/src/msn.cpp b/protocols/MSN/src/msn.cpp index 30f52a74f2..6be1bed1dd 100644 --- a/protocols/MSN/src/msn.cpp +++ b/protocols/MSN/src/msn.cpp @@ -79,7 +79,7 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID) // OnModulesLoaded - finalizes plugin's configuration on load
static int OnModulesLoaded(WPARAM, LPARAM)
{
- avsPresent = ServiceExists(MS_AV_SETMYAVATART) != 0;
+ avsPresent = ServiceExists(MS_AV_SETMYAVATARW) != 0;
MsnLinks_Init();
diff --git a/protocols/MSN/src/msn_http.cpp b/protocols/MSN/src/msn_http.cpp index 7ea45b5a8a..74a0f66fb7 100644 --- a/protocols/MSN/src/msn_http.cpp +++ b/protocols/MSN/src/msn_http.cpp @@ -52,7 +52,7 @@ int msn_httpGatewayInit(HANDLE hConn, NETLIBOPENCONNECTION*, NETLIBHTTPREQUEST*) // function generates the initial URL depending on a thread type
//=======================================================================================
-int msn_httpGatewayWrapSend(HANDLE hConn, PBYTE buf, int len, int flags, MIRANDASERVICE pfnNetlibSend)
+int msn_httpGatewayWrapSend(HANDLE hConn, PBYTE buf, int len, int flags)
{
ThreadData *T = FindThreadConn(hConn);
if (T != NULL) {
@@ -62,8 +62,7 @@ int msn_httpGatewayWrapSend(HANDLE hConn, PBYTE buf, int len, int flags, MIRANDA T->applyGatewayData(hConn, len == 0);
}
- NETLIBBUFFER tBuf = { (char*)buf, len, flags };
- return pfnNetlibSend((LPARAM)hConn, WPARAM(&tBuf));
+ return Netlib_Send(hConn, (char*)buf, len, flags);
}
//=======================================================================================
diff --git a/protocols/MSN/src/msn_misc.cpp b/protocols/MSN/src/msn_misc.cpp index 868fa66ba4..2f89d21fbe 100644 --- a/protocols/MSN/src/msn_misc.cpp +++ b/protocols/MSN/src/msn_misc.cpp @@ -753,7 +753,7 @@ void CMsnProto::MSN_SetServerStatus(int newStatus) if (newStatus != ID_STATUS_OFFLINE) {
DBVARIANT msnObject = { 0 };
- if (ServiceExists(MS_AV_SETMYAVATAR))
+ if (ServiceExists(MS_AV_SETMYAVATARW))
getString("PictObject", &msnObject);
// Capabilties: WLM 2009, Chunking, UUN Bootstrap
diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp index ce4d563de3..1efe0b33d9 100644 --- a/protocols/MSN/src/msn_proto.cpp +++ b/protocols/MSN/src/msn_proto.cpp @@ -25,7 +25,7 @@ static const COLORREF crCols[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; int msn_httpGatewayInit(HANDLE hConn,NETLIBOPENCONNECTION *nloc,NETLIBHTTPREQUEST *nlhr);
int msn_httpGatewayBegin(HANDLE hConn,NETLIBOPENCONNECTION *nloc);
-int msn_httpGatewayWrapSend(HANDLE hConn,PBYTE buf,int len,int flags,MIRANDASERVICE pfnNetlibSend);
+int msn_httpGatewayWrapSend(HANDLE hConn,PBYTE buf,int len,int flags);
PBYTE msn_httpGatewayUnwrapRecv(NETLIBHTTPREQUEST *nlhr,PBYTE buf,int len,int *outBufLen,void *(*NetlibRealloc)(void*,size_t));
static int CompareLists(const MsnContact *p1, const MsnContact *p2)
diff --git a/protocols/MSN/src/msn_svcs.cpp b/protocols/MSN/src/msn_svcs.cpp index d4410c4967..a5138006b9 100644 --- a/protocols/MSN/src/msn_svcs.cpp +++ b/protocols/MSN/src/msn_svcs.cpp @@ -118,7 +118,7 @@ INT_PTR CMsnProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam) }
if ((wParam & GAIF_FORCE) != 0 && pai->hContact != NULL) {
- if (avsPresent < 0) avsPresent = ServiceExists(MS_AV_SETMYAVATAR) != 0;
+ if (avsPresent < 0) avsPresent = ServiceExists(MS_AV_SETMYAVATARW) != 0;
if (!avsPresent)
return GAIR_NOAVATAR;
diff --git a/protocols/MSN/src/msn_ws.cpp b/protocols/MSN/src/msn_ws.cpp index d087f579c0..1c7dcd07e9 100644 --- a/protocols/MSN/src/msn_ws.cpp +++ b/protocols/MSN/src/msn_ws.cpp @@ -27,8 +27,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. int ThreadData::send(const char data[], size_t datalen)
{
- NETLIBBUFFER nlb = { (char*)data, (int)datalen, 0 };
-
resetTimeout();
if (proto->usingGateway && !(mType == SERVER_FILETRANS || mType == SERVER_P2P_DIRECT)) {
@@ -36,7 +34,7 @@ int ThreadData::send(const char data[], size_t datalen) CallService(MS_NETLIB_SETPOLLINGTIMEOUT, WPARAM(s), mGatewayTimeout);
}
- int rlen = CallService(MS_NETLIB_SEND, (WPARAM)s, (LPARAM)&nlb);
+ int rlen = Netlib_Send(s, data, (int)datalen);
if (rlen == SOCKET_ERROR) {
// should really also check if sendlen is the same as datalen
proto->debugLogA("Send failed: %d", WSAGetLastError());
@@ -113,8 +111,6 @@ bool ThreadData::isTimeout(void) int ThreadData::recv(char* data, size_t datalen)
{
- NETLIBBUFFER nlb = { data, (int)datalen, 0 };
-
if (!proto->usingGateway) {
resetTimeout();
NETLIBSELECT nls = { 0 };
@@ -137,7 +133,7 @@ int ThreadData::recv(char* data, size_t datalen) }
LBL_RecvAgain:
- int ret = CallService(MS_NETLIB_RECV, (WPARAM)s, (LPARAM)&nlb);
+ int ret = Netlib_Recv(s, data, (int)datalen);
if (ret == 0) {
proto->debugLogA("Connection closed gracefully");
return 0;
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index b71271e598..7348f04c1f 100644 --- a/protocols/VKontakte/src/version.h +++ b/protocols/VKontakte/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
#define __RELEASE_NUM 2
-#define __BUILD_NUM 9
+#define __BUILD_NUM 10
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk.h b/protocols/VKontakte/src/vk.h index 01e92919c2..9c8b4ed64a 100644 --- a/protocols/VKontakte/src/vk.h +++ b/protocols/VKontakte/src/vk.h @@ -82,7 +82,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define VK_USER_DEACTIVATE_ACTION 9321
-#define VK_API_VER "5.60"
+#define VK_API_VER "5.62"
#define VER_API CHAR_PARAM("v", VK_API_VER)
#define VK_FEED_USER 2147483647L
diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp index d770180521..84b8075d3f 100644 --- a/protocols/VKontakte/src/vk_messages.cpp +++ b/protocols/VKontakte/src/vk_messages.cpp @@ -142,8 +142,8 @@ int CVkProto::OnDbEventRead(WPARAM, LPARAM hDbEvent) MCONTACT hContact = db_event_getContact(hDbEvent);
if (!hContact)
return 0;
-
- CMStringA szProto(ptrA(db_get_sa(hContact, "Protocol", "p")));
+
+ CMStringA szProto(GetContactProto(hContact));
if (szProto.IsEmpty() || szProto != m_szModuleName)
return 0;
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index 8de06350ac..e47ca75430 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -347,8 +347,7 @@ MCONTACT CVkProto::SetContactInfo(const JSONNode &jnItem, bool flag, bool self) }
int iNewStatus = (jnItem["online"].as_int() == 0) ? ID_STATUS_OFFLINE : ID_STATUS_ONLINE;
- if (getWord(hContact, "Status", ID_STATUS_OFFLINE) != iNewStatus)
- setWord(hContact, "Status", iNewStatus);
+ setWord(hContact, "Status", iNewStatus);
if (iNewStatus == ID_STATUS_ONLINE) {
db_set_dw(hContact, "BuddyExpectator", "LastSeen", (DWORD)time(NULL));
@@ -379,9 +378,7 @@ MCONTACT CVkProto::SetContactInfo(const JSONNode &jnItem, bool flag, bool self) setWString(hContact, "Phone", wszValue);
wszValue = jnItem["status"].as_mstring();
- CMStringW wszOldStatus(ptrW(db_get_wsa(hContact, hContact ? "CList" : m_szModuleName, "StatusMsg")));
- if (wszValue != wszOldStatus)
- db_set_ws(hContact, hContact ? "CList" : m_szModuleName, "StatusMsg", wszValue);
+ db_set_ws(hContact, hContact ? "CList" : m_szModuleName, "StatusMsg", wszValue);
CMStringW wszOldListeningTo(ptrW(db_get_wsa(hContact, m_szModuleName, "ListeningTo")));
const JSONNode &jnAudio = jnItem["status_audio"];
@@ -416,7 +413,7 @@ MCONTACT CVkProto::SetContactInfo(const JSONNode &jnItem, bool flag, bool self) }
// MaritalStatus
- BYTE cMaritalStatus[] = {0, 10, 11, 12, 20, 70, 50, 60};
+ BYTE cMaritalStatus[] = {0, 10, 11, 12, 20, 70, 50, 60, 80};
if (jnItem["relation"] && jnItem["relation"].as_int() < _countof(cMaritalStatus))
setByte(hContact, "MaritalStatus", cMaritalStatus[jnItem["relation"].as_int()]);
@@ -675,8 +672,7 @@ void CVkProto::OnReceiveGroupInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pR if (!wszValue.IsEmpty())
setWString(hContact, "Nick", wszValue);
- if (getWord(hContact, "Status", ID_STATUS_OFFLINE) != ID_STATUS_ONLINE)
- setWord(hContact, "Status", ID_STATUS_ONLINE);
+ setWord(hContact, "Status", ID_STATUS_ONLINE);
setByte(hContact, "Auth", !bIsMember);
setByte(hContact, "friend", bIsMember);
@@ -700,9 +696,7 @@ void CVkProto::OnReceiveGroupInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pR }
wszValue = jnItem["status"].as_mstring();
- CMStringW wszOldStatus(ptrW(db_get_wsa(hContact, "CList", "StatusMsg")));
- if (wszValue != wszOldStatus)
- db_set_ws(hContact, "CList", "StatusMsg", wszValue);
+ db_set_ws(hContact, "CList", "StatusMsg", wszValue);
CMStringW wszOldListeningTo(ptrW(db_get_wsa(hContact, m_szModuleName, "ListeningTo")));
const JSONNode &jnAudio = jnItem["status_audio"];
diff --git a/protocols/WhatsApp/src/WASocketConnection.cpp b/protocols/WhatsApp/src/WASocketConnection.cpp index b6ec0c0998..03ebf84ea7 100644 --- a/protocols/WhatsApp/src/WASocketConnection.cpp +++ b/protocols/WhatsApp/src/WASocketConnection.cpp @@ -30,12 +30,7 @@ void WASocketConnection::write(int i) char buffer;
buffer = (char)i;
- NETLIBBUFFER nlb;
- nlb.buf = &buffer;
- nlb.len = 1;
- nlb.flags = MSG_NOHTTPGATEWAYWRAP | MSG_NODUMP;
-
- int result = CallService(MS_NETLIB_SEND, WPARAM(this->hConn), LPARAM(&nlb));
+ int result = Netlib_Send(this->hConn, &buffer, 1, MSG_NOHTTPGATEWAYWRAP | MSG_NODUMP);
if (result < 1)
throw WAException(getLastErrorMsg(), WAException::SOCKET_EX, WAException::SOCKET_EX_SEND);
}
@@ -49,13 +44,8 @@ void WASocketConnection::flush() {} void WASocketConnection::write(const std::vector<unsigned char> &bytes, int length)
{
- NETLIBBUFFER nlb;
std::string tmpBuf = std::string(bytes.begin(), bytes.end());
- nlb.buf = (char*)&(tmpBuf.c_str()[0]);
- nlb.len = length;
- nlb.flags = MSG_NODUMP;
-
- int result = CallService(MS_NETLIB_SEND, WPARAM(hConn), LPARAM(&nlb));
+ int result = Netlib_Send(hConn, tmpBuf.c_str(), length, MSG_NODUMP);
if (result < length)
throw WAException(getLastErrorMsg(), WAException::SOCKET_EX, WAException::SOCKET_EX_SEND);
}
diff --git a/src/core/stduserinfo/src/stdinfo.cpp b/src/core/stduserinfo/src/stdinfo.cpp index 83e21d7200..fc076abd8b 100644 --- a/src/core/stduserinfo/src/stdinfo.cpp +++ b/src/core/stduserinfo/src/stdinfo.cpp @@ -132,6 +132,9 @@ static void SetValue(HWND hwndDlg, int idCtrl, MCONTACT hContact, char *szModule case 70:
ptstr = TranslateT("It\'s complicated");
break;
+ case 80:
+ ptstr = TranslateT("In a civil union");
+ break;
default:
unspecified = 1;
}
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 7ad0d3650d..5c5bd98036 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -345,3 +345,6 @@ Miranda_GetVersion @345 Miranda_GetFileVersion @346
Miranda_GetVersionText @347
Srmm_CreateToolbarIcons @348
+Netlib_CloseHandle @349
+Netlib_Recv @350
+Netlib_Send @351
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 68a6b11090..f0a887610b 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -345,3 +345,6 @@ Miranda_GetVersion @345 Miranda_GetFileVersion @346
Miranda_GetVersionText @347
Srmm_CreateToolbarIcons @348
+Netlib_CloseHandle @349
+Netlib_Recv @350
+Netlib_Send @351
diff --git a/src/mir_app/src/netlib.cpp b/src/mir_app/src/netlib.cpp index a8f731000d..269c4ca5bf 100644 --- a/src/mir_app/src/netlib.cpp +++ b/src/mir_app/src/netlib.cpp @@ -244,15 +244,15 @@ void NetlibDoClose(NetlibConnection *nlc, bool noShutdown) nlc->s = INVALID_SOCKET;
}
-INT_PTR NetlibCloseHandle(WPARAM wParam, LPARAM)
+MIR_APP_DLL(int) Netlib_CloseHandle(HANDLE hNetlib)
{
- if (wParam == NULL)
+ if (hNetlib == NULL)
return 0;
- switch(GetNetlibHandleType((void*)wParam)) {
+ switch (GetNetlibHandleType(hNetlib)) {
case NLH_USER:
{
- NetlibUser *nlu = (NetlibUser*)wParam;
+ NetlibUser *nlu = (NetlibUser*)hNetlib;
{
mir_cslock lck(csNetlibUser);
int i = netlibUser.getIndex(nlu);
@@ -272,7 +272,7 @@ INT_PTR NetlibCloseHandle(WPARAM wParam, LPARAM) case NLH_CONNECTION:
WaitForSingleObject(hConnectionHeaderMutex, INFINITE);
{
- NetlibConnection *nlc = (NetlibConnection*)wParam;
+ NetlibConnection *nlc = (NetlibConnection*)hNetlib;
if (GetNetlibHandleType(nlc) == NLH_CONNECTION) {
if (nlc->usingHttpGateway)
HttpGatewayRemovePacket(nlc, -1);
@@ -301,11 +301,11 @@ INT_PTR NetlibCloseHandle(WPARAM wParam, LPARAM) return 1;
case NLH_BOUNDPORT:
- return NetlibFreeBoundPort((struct NetlibBoundPort*)wParam);
+ return NetlibFreeBoundPort((NetlibBoundPort*)hNetlib);
case NLH_PACKETRECVER:
{
- struct NetlibPacketRecver *nlpr = (struct NetlibPacketRecver*)wParam;
+ struct NetlibPacketRecver *nlpr = (NetlibPacketRecver*)hNetlib;
mir_free(nlpr->packetRecver.buffer);
}
break;
@@ -314,7 +314,7 @@ INT_PTR NetlibCloseHandle(WPARAM wParam, LPARAM) SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
- mir_free((void*)wParam);
+ mir_free(hNetlib);
return 1;
}
@@ -411,7 +411,7 @@ void UnloadNetlibModule(void) DestroyHookableEvent(hSendEvent); hSendEvent = NULL;
for (int i = netlibUser.getCount(); i > 0; i--)
- NetlibCloseHandle((WPARAM)netlibUser[i-1], 0);
+ Netlib_CloseHandle(netlibUser[i-1]);
CloseHandle(hConnectionHeaderMutex);
if (hConnectionOpenMutex)
@@ -482,7 +482,6 @@ int LoadNetlibModule(void) CreateServiceFunction(MS_NETLIB_REGISTERUSER, NetlibRegisterUser);
CreateServiceFunction(MS_NETLIB_GETUSERSETTINGS, NetlibGetUserSettings);
CreateServiceFunction(MS_NETLIB_SETUSERSETTINGS, NetlibSetUserSettings);
- CreateServiceFunction(MS_NETLIB_CLOSEHANDLE, NetlibCloseHandle);
CreateServiceFunction(MS_NETLIB_BINDPORT, NetlibBindPort);
CreateServiceFunction(MS_NETLIB_OPENCONNECTION, NetlibOpenConnection);
CreateServiceFunction(MS_NETLIB_SETHTTPPROXYINFO, NetlibHttpGatewaySetInfo);
@@ -492,8 +491,6 @@ int LoadNetlibModule(void) CreateServiceFunction(MS_NETLIB_RECVHTTPHEADERS, NetlibHttpRecvHeaders);
CreateServiceFunction(MS_NETLIB_FREEHTTPREQUESTSTRUCT, NetlibHttpFreeRequestStruct);
CreateServiceFunction(MS_NETLIB_HTTPTRANSACTION, NetlibHttpTransaction);
- CreateServiceFunction(MS_NETLIB_SEND, NetlibSend);
- CreateServiceFunction(MS_NETLIB_RECV, NetlibRecv);
CreateServiceFunction(MS_NETLIB_SELECT, NetlibSelect);
CreateServiceFunction(MS_NETLIB_SELECTEX, NetlibSelectEx);
CreateServiceFunction(MS_NETLIB_SHUTDOWN, NetlibShutdown);
diff --git a/src/mir_app/src/netlib.h b/src/mir_app/src/netlib.h index 7eb961fc7a..dddb69c7ed 100644 --- a/src/mir_app/src/netlib.h +++ b/src/mir_app/src/netlib.h @@ -38,7 +38,7 @@ struct NetlibUser int handleType;
NETLIBUSER user;
NETLIBUSERSETTINGS settings;
- char * szStickyHeaders;
+ char *szStickyHeaders;
int toLog;
int inportnum;
int outportnum;
@@ -188,7 +188,6 @@ struct NetlibPacketRecver { //netlib.c
void NetlibFreeUserSettingsStruct(NETLIBUSERSETTINGS *settings);
void NetlibDoClose(NetlibConnection *nlc, bool noShutdown = false);
-INT_PTR NetlibCloseHandle(WPARAM wParam, LPARAM lParam);
void NetlibInitializeNestedCS(NetlibNestedCriticalSection *nlncs);
void NetlibDeleteNestedCS(NetlibNestedCriticalSection *nlncs);
#define NLNCS_SEND 0
@@ -261,8 +260,6 @@ INT_PTR NetlibPacketRecverGetMore(WPARAM wParam, LPARAM lParam); #define NL_SELECT_WRITE 0x0002
#define NL_SELECT_ALL (NL_SELECT_READ+NL_SELECT_WRITE)
-INT_PTR NetlibSend(WPARAM wParam, LPARAM lParam);
-INT_PTR NetlibRecv(WPARAM wParam, LPARAM lParam);
INT_PTR NetlibSelect(WPARAM wParam, LPARAM lParam);
INT_PTR NetlibSelectEx(WPARAM wParam, LPARAM lParam);
INT_PTR NetlibShutdown(WPARAM wParam, LPARAM lParam);
@@ -287,13 +284,3 @@ HANDLE NetlibInitSecurityProvider(const wchar_t* szProvider, const wchar_t* szPr HANDLE NetlibInitSecurityProvider(const char* szProvider, const char* szPrincipal);
char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge, const wchar_t* login, const wchar_t* psw,
bool http, unsigned& complete);
-
-static __inline INT_PTR NLSend(NetlibConnection *nlc, const char *buf, int len, int flags) {
- NETLIBBUFFER nlb = {(char*)buf, len, flags};
- return NetlibSend((WPARAM)nlc, (LPARAM)&nlb);
-}
-
-static __inline INT_PTR NLRecv(NetlibConnection *nlc, char *buf, int len, int flags) {
- NETLIBBUFFER nlb = {buf, len, flags};
- return NetlibRecv((WPARAM)nlc, (LPARAM)&nlb);
-}
diff --git a/src/mir_app/src/netlibhttp.cpp b/src/mir_app/src/netlibhttp.cpp index ce92b6c361..4eaeb33475 100644 --- a/src/mir_app/src/netlibhttp.cpp +++ b/src/mir_app/src/netlibhttp.cpp @@ -94,7 +94,7 @@ static int RecvWithTimeoutTime(NetlibConnection *nlc, unsigned dwTimeoutTime, ch return SOCKET_ERROR;
case 1:
- return NLRecv(nlc, buf, len, flags);
+ return Netlib_Recv(nlc, buf, len, flags);
}
if (nlc->termRequested || Miranda_IsTerminated())
@@ -103,7 +103,7 @@ static int RecvWithTimeoutTime(NetlibConnection *nlc, unsigned dwTimeoutTime, ch SetLastError(ERROR_TIMEOUT);
return SOCKET_ERROR;
}
- return NLRecv(nlc, buf, len, flags);
+ return Netlib_Recv(nlc, buf, len, flags);
}
static char* NetlibHttpFindHeader(NETLIBHTTPREQUEST *nlhrReply, const char *hdr)
@@ -340,7 +340,7 @@ static int HttpPeekFirstResponseLine(NetlibConnection *nlc, DWORD dwTimeoutTime, static int SendHttpRequestAndData(NetlibConnection *nlc, CMStringA &httpRequest, NETLIBHTTPREQUEST *nlhr, int sendContentLengthHeader)
{
- bool sendData = (nlhr->requestType == REQUEST_POST || nlhr->requestType == REQUEST_PUT);
+ bool sendData = (nlhr->requestType == REQUEST_POST || nlhr->requestType == REQUEST_PUT || nlhr->requestType == REQUEST_PATCH);
if (sendContentLengthHeader && sendData)
httpRequest.AppendFormat("Content-Length: %d\r\n\r\n", nlhr->dataLength);
@@ -352,14 +352,14 @@ static int SendHttpRequestAndData(NetlibConnection *nlc, CMStringA &httpRequest, MSG_NODUMP : (nlhr->flags & NLHRF_DUMPPROXY ? MSG_DUMPPROXY : 0)) |
(nlhr->flags & NLHRF_NOPROXY ? MSG_RAW : 0);
- int bytesSent = NLSend(nlc, httpRequest, httpRequest.GetLength(), hflags);
+ int bytesSent = Netlib_Send(nlc, httpRequest, httpRequest.GetLength(), hflags);
if (bytesSent != SOCKET_ERROR && sendData && nlhr->dataLength) {
- DWORD sflags = (nlhr->flags & NLHRF_DUMPASTEXT ? MSG_DUMPASTEXT : 0) |
+ DWORD sflags = MSG_NOTITLE | (nlhr->flags & NLHRF_DUMPASTEXT ? MSG_DUMPASTEXT : 0) |
(nlhr->flags & (NLHRF_NODUMP | NLHRF_NODUMPSEND) ?
MSG_NODUMP : (nlhr->flags & NLHRF_DUMPPROXY ? MSG_DUMPPROXY : 0)) |
(nlhr->flags & NLHRF_NOPROXY ? MSG_RAW : 0);
- int sendResult = NLSend(nlc, nlhr->pData, nlhr->dataLength, sflags);
+ int sendResult = Netlib_Send(nlc, nlhr->pData, nlhr->dataLength, sflags);
bytesSent = sendResult != SOCKET_ERROR ? bytesSent + sendResult : SOCKET_ERROR;
}
@@ -739,7 +739,7 @@ INT_PTR NetlibHttpRecvHeaders(WPARAM wParam, LPARAM lParam) }
char *buffer = (char*)_alloca(NHRV_BUF_SIZE + 1);
- int bytesPeeked = NLRecv(nlc, buffer, min(firstLineLength, NHRV_BUF_SIZE), lParam | MSG_DUMPASTEXT);
+ int bytesPeeked = Netlib_Recv(nlc, buffer, min(firstLineLength, NHRV_BUF_SIZE), lParam | MSG_DUMPASTEXT);
if (bytesPeeked != firstLineLength) {
NetlibLeaveNestedCS(&nlc->ncsRecv);
NetlibHttpFreeRequestStruct(0, (LPARAM)nlhr);
@@ -753,7 +753,7 @@ INT_PTR NetlibHttpRecvHeaders(WPARAM wParam, LPARAM lParam) int headersCount = 0;
bytesPeeked = 0;
for (bool headersCompleted = false; !headersCompleted;) {
- bytesPeeked = RecvWithTimeoutTime(nlc, dwRequestTimeoutTime, buffer, NHRV_BUF_SIZE, lParam | MSG_DUMPASTEXT);
+ bytesPeeked = RecvWithTimeoutTime(nlc, dwRequestTimeoutTime, buffer, NHRV_BUF_SIZE, lParam | MSG_DUMPASTEXT | MSG_NOTITLE);
if (bytesPeeked == 0)
break;
@@ -874,7 +874,7 @@ INT_PTR NetlibHttpTransaction(WPARAM wParam, LPARAM lParam) if (NetlibHttpSendRequest((WPARAM)nlc, (LPARAM)&nlhrSend) == SOCKET_ERROR) {
if (!doneUserAgentHeader || !doneAcceptEncoding) mir_free(nlhrSend.headers);
nlhr->resultCode = nlhrSend.resultCode;
- NetlibCloseHandle((WPARAM)nlc, 0);
+ Netlib_CloseHandle(nlc);
return 0;
}
if (!doneUserAgentHeader || !doneAcceptEncoding)
@@ -899,7 +899,7 @@ INT_PTR NetlibHttpTransaction(WPARAM wParam, LPARAM lParam) }
if ((nlhr->flags & NLHRF_PERSISTENT) == 0 || nlhrReply == NULL) {
- NetlibCloseHandle((WPARAM)nlc, 0);
+ Netlib_CloseHandle(nlc);
if (nlhrReply)
nlhrReply->nlc = NULL;
}
@@ -975,7 +975,7 @@ static int NetlibHttpRecvChunkHeader(NetlibConnection *nlc, bool first, DWORD fl while (true) {
char data[1000];
- int recvResult = NLRecv(nlc, data, _countof(data) - 1, MSG_RAW | flags);
+ int recvResult = Netlib_Recv(nlc, data, _countof(data) - 1, MSG_RAW | flags);
if (recvResult <= 0 || recvResult >= _countof(data))
return SOCKET_ERROR;
@@ -1048,7 +1048,7 @@ next: int dataBufferAlloced;
if (chunked) {
- chunksz = NetlibHttpRecvChunkHeader(nlc, true, dflags);
+ chunksz = NetlibHttpRecvChunkHeader(nlc, true, dflags | (cenctype ? MSG_NODUMP : 0));
if (chunksz == SOCKET_ERROR) {
NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply);
return NULL;
@@ -1091,7 +1091,7 @@ next: if (!chunked)
break;
- chunksz = NetlibHttpRecvChunkHeader(nlc, false, dflags);
+ chunksz = NetlibHttpRecvChunkHeader(nlc, false, dflags | MSG_NODUMP);
if (chunksz == SOCKET_ERROR) {
NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply);
return NULL;
@@ -1132,7 +1132,7 @@ next: }
if (bufsz > 0) {
- NetlibDumpData(nlc, (PBYTE)szData, bufsz, 0, dflags);
+ NetlibDumpData(nlc, (PBYTE)szData, bufsz, 0, dflags | MSG_NOTITLE);
mir_free(nlhrReply->pData);
nlhrReply->pData = szData;
nlhrReply->dataLength = bufsz;
diff --git a/src/mir_app/src/netlibhttpproxy.cpp b/src/mir_app/src/netlibhttpproxy.cpp index 806e08d7ee..6caa8631bf 100644 --- a/src/mir_app/src/netlibhttpproxy.cpp +++ b/src/mir_app/src/netlibhttpproxy.cpp @@ -272,7 +272,7 @@ int NetlibHttpGatewayRecv(NetlibConnection *nlc, char *buf, int len, int flags) nlc->lastPost = GetTickCount();
if (nlc->pHttpProxyPacketQueue == NULL && nlu->user.pfnHttpGatewayWrapSend != NULL)
- if (nlu->user.pfnHttpGatewayWrapSend(nlc, (PBYTE)"", 0, MSG_NOHTTPGATEWAYWRAP, NetlibSend) == SOCKET_ERROR)
+ if (nlu->user.pfnHttpGatewayWrapSend(nlc, (PBYTE)"", 0, MSG_NOHTTPGATEWAYWRAP) == SOCKET_ERROR)
return SOCKET_ERROR;
}
diff --git a/src/mir_app/src/netliblog.cpp b/src/mir_app/src/netliblog.cpp index 5219a98994..d73c075a8a 100644 --- a/src/mir_app/src/netliblog.cpp +++ b/src/mir_app/src/netliblog.cpp @@ -278,15 +278,13 @@ static INT_PTR ShowOptions(WPARAM, LPARAM) return 0;
}
-static INT_PTR NetlibLog(WPARAM wParam, LPARAM lParam)
+int NetlibLog_Worker(NetlibUser *nlu, const char *pszMsg, int flags)
{
if (!bIsActive)
return 0;
DWORD dwOriginalLastError = GetLastError();
- NetlibUser *nlu = (NetlibUser*)wParam;
- const char *pszMsg = (const char*)lParam;
if ((nlu != NULL && GetNetlibHandleType(nlu) != NLH_USER) || pszMsg == NULL) {
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
@@ -323,11 +321,15 @@ static INT_PTR NetlibLog(WPARAM wParam, LPARAM lParam) break;
}
- char *szUser = (logOptions.showUser) ? (nlu == NULL ? NULL : nlu->user.szSettingsModule) : NULL;
- if (szUser)
- mir_snprintf(szHead, "[%s%04X] [%s] ", szTime, GetCurrentThreadId(), szUser);
- else
- mir_snprintf(szHead, "[%s%04X] ", szTime, GetCurrentThreadId());
+ if (flags & MSG_NOTITLE)
+ szHead[0] = 0;
+ else {
+ char *szUser = (logOptions.showUser) ? (nlu == NULL ? NULL : nlu->user.szSettingsModule) : NULL;
+ if (szUser)
+ mir_snprintf(szHead, "[%s%04X] [%s] ", szTime, GetCurrentThreadId(), szUser);
+ else
+ mir_snprintf(szHead, "[%s%04X] ", szTime, GetCurrentThreadId());
+ }
if (logOptions.toOutputDebugString) {
if (szHead[0])
@@ -348,13 +350,18 @@ static INT_PTR NetlibLog(WPARAM wParam, LPARAM lParam) return 1;
}
+static INT_PTR NetlibLog(WPARAM wParam, LPARAM lParam)
+{
+ NetlibUser *nlu = (NetlibUser*)wParam;
+ const char *pszMsg = (const char*)lParam;
+ return NetlibLog_Worker(nlu, pszMsg, 0);
+}
+
static INT_PTR NetlibLogW(WPARAM wParam, LPARAM lParam)
{
- const wchar_t *pszMsg = (const wchar_t*)lParam;
- char* szMsg = Utf8EncodeW(pszMsg);
- INT_PTR res = NetlibLog(wParam, (LPARAM)szMsg);
- mir_free(szMsg);
- return res;
+ NetlibUser *nlu = (NetlibUser*)wParam;
+ const wchar_t *pwszMsg = (const wchar_t*)lParam;
+ return NetlibLog_Worker(nlu, ptrA(Utf8EncodeW(pwszMsg)), 0);
}
void NetlibLogf(NetlibUser* nlu, const char *fmt, ...)
@@ -373,7 +380,7 @@ void NetlibLogf(NetlibUser* nlu, const char *fmt, ...) mir_vsnprintf(szText, sizeof(szText), fmt, va);
va_end(va);
- NetlibLog((WPARAM)nlu, (LPARAM)szText);
+ NetlibLog_Worker(nlu, szText, 0);
}
void NetlibDumpData(NetlibConnection *nlc, PBYTE buf, int len, int sent, int flags)
@@ -401,8 +408,11 @@ void NetlibDumpData(NetlibConnection *nlc, PBYTE buf, int len, int sent, int fla WaitForSingleObject(hConnectionHeaderMutex, INFINITE);
NetlibUser *nlu = nlc ? nlc->nlu : NULL;
- int titleLineLen = mir_snprintf(szTitleLine, "(%p:%u) Data %s%s\r\n",
- nlc, nlc ? nlc->s : 0, sent ? "sent" : "received", flags & MSG_DUMPPROXY ? " (proxy)" : "");
+ int titleLineLen;
+ if (flags & MSG_NOTITLE)
+ titleLineLen = 0;
+ else
+ titleLineLen = mir_snprintf(szTitleLine, "(%p:%u) Data %s%s\r\n", nlc, nlc ? nlc->s : 0, sent ? "sent" : "received", flags & MSG_DUMPPROXY ? " (proxy)" : "");
ReleaseMutex(hConnectionHeaderMutex);
// check filter settings
@@ -480,7 +490,7 @@ void NetlibDumpData(NetlibConnection *nlc, PBYTE buf, int len, int sent, int fla *pszBuf = '\0';
}
- NetlibLog((WPARAM)nlu, (LPARAM)szBuf);
+ NetlibLog_Worker(nlu, szBuf, flags);
if (!useStack)
mir_free(szBuf);
}
diff --git a/src/mir_app/src/netlibopenconn.cpp b/src/mir_app/src/netlibopenconn.cpp index 069da71d74..65482350ea 100644 --- a/src/mir_app/src/netlibopenconn.cpp +++ b/src/mir_app/src/netlibopenconn.cpp @@ -99,7 +99,7 @@ bool RecvUntilTimeout(NetlibConnection *nlc, char *buf, int len, int flags, DWOR while ((dwTimeNow = GetTickCount()) < dwCompleteTime) { if (WaitUntilReadable(nlc->s, dwCompleteTime - dwTimeNow) <= 0) return false; - nReceived = NLRecv(nlc, buf, len, flags); + nReceived = Netlib_Recv(nlc, buf, len, flags); if (nReceived <= 0) return false; buf += nReceived; @@ -135,8 +135,8 @@ static int NetlibInitSocks4Connection(NetlibConnection *nlc, NetlibUser *nlu, NE len += nHostLen; } - if (NLSend(nlc, pInit, (int)len, MSG_DUMPPROXY) == SOCKET_ERROR) { - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "NLSend", GetLastError()); + if (Netlib_Send(nlc, pInit, (int)len, MSG_DUMPPROXY) == SOCKET_ERROR) { + NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "Netlib_Send", GetLastError()); return 0; } @@ -165,8 +165,8 @@ static int NetlibInitSocks5Connection(NetlibConnection *nlc, NetlibUser *nlu, NE buf[0] = 5; //yep, socks5 buf[1] = 1; //one auth method buf[2] = nlu->settings.useProxyAuth?2:0; - if (NLSend(nlc, (char*)buf, 3, MSG_DUMPPROXY) == SOCKET_ERROR) { - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "NLSend", GetLastError()); + if (Netlib_Send(nlc, (char*)buf, 3, MSG_DUMPPROXY) == SOCKET_ERROR) { + NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "Netlib_Send", GetLastError()); return 0; } @@ -177,7 +177,7 @@ static int NetlibInitSocks5Connection(NetlibConnection *nlc, NetlibUser *nlu, NE } if ((buf[1] != 0 && buf[1] != 2)) { SetLastError(ERROR_INVALID_ID_AUTHORITY); - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "NLRecv", GetLastError()); + NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "Netlib_Recv", GetLastError()); return 0; } @@ -190,8 +190,8 @@ static int NetlibInitSocks5Connection(NetlibConnection *nlc, NetlibUser *nlu, NE memcpy(pAuthBuf + 2, nlu->settings.szProxyAuthUser, nUserLen); pAuthBuf[2 + nUserLen] = (BYTE)nPassLen; memcpy(pAuthBuf + 3 + nUserLen, nlu->settings.szProxyAuthPassword, nPassLen); - if (NLSend(nlc, (char*)pAuthBuf, int(3 + nUserLen + nPassLen), MSG_DUMPPROXY) == SOCKET_ERROR) { - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "NLSend", GetLastError()); + if (Netlib_Send(nlc, (char*)pAuthBuf, int(3 + nUserLen + nPassLen), MSG_DUMPPROXY) == SOCKET_ERROR) { + NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "Netlib_Send", GetLastError()); mir_free(pAuthBuf); return 0; } @@ -235,8 +235,8 @@ static int NetlibInitSocks5Connection(NetlibConnection *nlc, NetlibUser *nlu, NE *(PDWORD)(pInit + 4) = hostIP; } *(PWORD)(pInit + 4 + nHostLen) = htons(nloc->wPort); - if (NLSend(nlc, (char*)pInit, int(6 + nHostLen), MSG_DUMPPROXY) == SOCKET_ERROR) { - NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "NLSend", GetLastError()); + if (Netlib_Send(nlc, (char*)pInit, int(6 + nHostLen), MSG_DUMPPROXY) == SOCKET_ERROR) { + NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "Netlib_Send", GetLastError()); mir_free(pInit); return 0; } diff --git a/src/mir_app/src/netlibpktrecver.cpp b/src/mir_app/src/netlibpktrecver.cpp index b0449867aa..5281cc5dab 100644 --- a/src/mir_app/src/netlibpktrecver.cpp +++ b/src/mir_app/src/netlibpktrecver.cpp @@ -81,7 +81,7 @@ INT_PTR NetlibPacketRecverGetMore(WPARAM wParam, LPARAM lParam) }
}
- INT_PTR recvResult = NLRecv(nlpr->nlc, (char*)nlpr->packetRecver.buffer + nlpr->packetRecver.bytesAvailable, nlpr->packetRecver.bufferSize - nlpr->packetRecver.bytesAvailable, 0);
+ INT_PTR recvResult = Netlib_Recv(nlpr->nlc, (char*)nlpr->packetRecver.buffer + nlpr->packetRecver.bytesAvailable, nlpr->packetRecver.bufferSize - nlpr->packetRecver.bytesAvailable, 0);
if (recvResult > 0)
nlpr->packetRecver.bytesAvailable += recvResult;
*nlprParam = nlpr->packetRecver;
diff --git a/src/mir_app/src/netlibsock.cpp b/src/mir_app/src/netlibsock.cpp index e11049cf44..34d1739103 100644 --- a/src/mir_app/src/netlibsock.cpp +++ b/src/mir_app/src/netlibsock.cpp @@ -27,76 +27,63 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern HANDLE hConnectionHeaderMutex, hSendEvent, hRecvEvent;
-INT_PTR NetlibSend(WPARAM wParam, LPARAM lParam)
+MIR_APP_DLL(int) Netlib_Send(HANDLE hConn, const char *buf, int len, int flags)
{
- NetlibConnection *nlc = (NetlibConnection*)wParam;
- NETLIBBUFFER *nlb = (NETLIBBUFFER*)lParam;
- if (nlb == NULL) {
- SetLastError(ERROR_INVALID_PARAMETER);
- return SOCKET_ERROR;
- }
-
+ NetlibConnection *nlc = (NetlibConnection*)hConn;
if (!NetlibEnterNestedCS(nlc, NLNCS_SEND))
return SOCKET_ERROR;
int result;
- if (nlc->usingHttpGateway && !(nlb->flags & MSG_RAW)) {
- if (!(nlb->flags & MSG_NOHTTPGATEWAYWRAP) && nlc->nlu->user.pfnHttpGatewayWrapSend) {
- NetlibDumpData(nlc, (PBYTE)nlb->buf, nlb->len, 1, nlb->flags);
- result = nlc->nlu->user.pfnHttpGatewayWrapSend((HANDLE)nlc, (PBYTE)nlb->buf, nlb->len, nlb->flags | MSG_NOHTTPGATEWAYWRAP, NetlibSend);
+ if (nlc->usingHttpGateway && !(flags & MSG_RAW)) {
+ if (!(flags & MSG_NOHTTPGATEWAYWRAP) && nlc->nlu->user.pfnHttpGatewayWrapSend) {
+ NetlibDumpData(nlc, (PBYTE)buf, len, 1, flags);
+ result = nlc->nlu->user.pfnHttpGatewayWrapSend((HANDLE)nlc, (PBYTE)buf, len, flags | MSG_NOHTTPGATEWAYWRAP);
}
- else result = NetlibHttpGatewayPost(nlc, nlb->buf, nlb->len, nlb->flags);
+ else result = NetlibHttpGatewayPost(nlc, buf, len, flags);
}
else {
- NetlibDumpData(nlc, (PBYTE)nlb->buf, nlb->len, 1, nlb->flags);
+ NetlibDumpData(nlc, (PBYTE)buf, len, 1, flags);
if (nlc->hSsl)
- result = sslApi.write(nlc->hSsl, nlb->buf, nlb->len);
+ result = sslApi.write(nlc->hSsl, buf, len);
else
- result = send(nlc->s, nlb->buf, nlb->len, nlb->flags & 0xFFFF);
+ result = send(nlc->s, buf, len, flags & 0xFFFF);
}
NetlibLeaveNestedCS(&nlc->ncsSend);
- NETLIBNOTIFY nln = { nlb, result };
+ NETLIBNOTIFY nln = { buf, len, flags, result };
NotifyFastHook(hSendEvent, (WPARAM)&nln, (LPARAM)&nlc->nlu->user);
return result;
}
-INT_PTR NetlibRecv(WPARAM wParam, LPARAM lParam)
+MIR_APP_DLL(int) Netlib_Recv(HANDLE hConn, char *buf, int len, int flags)
{
- NetlibConnection *nlc = (NetlibConnection*)wParam;
- NETLIBBUFFER* nlb = (NETLIBBUFFER*)lParam;
- int recvResult;
-
- if (nlb == NULL) {
- SetLastError(ERROR_INVALID_PARAMETER);
- return SOCKET_ERROR;
- }
-
+ NetlibConnection *nlc = (NetlibConnection*)hConn;
if (!NetlibEnterNestedCS(nlc, NLNCS_RECV))
return SOCKET_ERROR;
- if (nlc->usingHttpGateway && !(nlb->flags & MSG_RAW))
- recvResult = NetlibHttpGatewayRecv(nlc, nlb->buf, nlb->len, nlb->flags);
+ int recvResult;
+ if (nlc->usingHttpGateway && !(flags & MSG_RAW))
+ recvResult = NetlibHttpGatewayRecv(nlc, buf, len, flags);
else {
if (!nlc->foreBuf.isEmpty()) {
- recvResult = min(nlb->len, nlc->foreBuf.length());
- memcpy(nlb->buf, nlc->foreBuf.data(), recvResult);
+ recvResult = min(len, nlc->foreBuf.length());
+ memcpy(buf, nlc->foreBuf.data(), recvResult);
nlc->foreBuf.remove(recvResult);
}
else if (nlc->hSsl)
- recvResult = sslApi.read(nlc->hSsl, nlb->buf, nlb->len, (nlb->flags & MSG_PEEK) != 0);
+ recvResult = sslApi.read(nlc->hSsl, buf, len, (flags & MSG_PEEK) != 0);
else
- recvResult = recv(nlc->s, nlb->buf, nlb->len, nlb->flags & 0xFFFF);
+ recvResult = recv(nlc->s, buf, len, flags & 0xFFFF);
}
NetlibLeaveNestedCS(&nlc->ncsRecv);
if (recvResult <= 0)
return recvResult;
- NetlibDumpData(nlc, (PBYTE)nlb->buf, recvResult, 0, nlb->flags);
+ NetlibDumpData(nlc, (PBYTE)buf, recvResult, 0, flags);
- if ((nlb->flags & MSG_PEEK) == 0) {
- NETLIBNOTIFY nln = { nlb, recvResult };
+ if ((flags & MSG_PEEK) == 0) {
+ NETLIBNOTIFY nln = { buf, len, flags, recvResult };
NotifyFastHook(hRecvEvent, (WPARAM)&nln, (LPARAM)&nlc->nlu->user);
}
return recvResult;
|