Recover work after repo corruption, experimental icons for channels, merge http.c keepalive changes from PR
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#include "chatwnd.h"
|
#include "chatwnd.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <string.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "snoctrl.h"
|
#include "snoctrl.h"
|
||||||
#include "../discordtypes.h"
|
#include "../discordtypes.h"
|
||||||
@@ -22,6 +23,7 @@ ChatWnd *GetChatControlDetails(HWND hwnd) {
|
|||||||
return &chatwnds[i];
|
return &chatwnds[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
void ChatView_SetUserPfp(char *path, char *user) {
|
void ChatView_SetUserPfp(char *path, char *user) {
|
||||||
HANDLE f = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, NULL,
|
HANDLE f = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, NULL,
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ GuildWnd *GetGuildControlDetails(HWND hwnd) {
|
|||||||
return &guildwnds[i];
|
return &guildwnds[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
void GuildView_InsertGuild(HWND hwnd, GUIGuild gld) {
|
void GuildView_InsertGuild(HWND hwnd, GUIGuild gld) {
|
||||||
GuildWnd *guildwnd = GetGuildControlDetails(hwnd);
|
GuildWnd *guildwnd = GetGuildControlDetails(hwnd);
|
||||||
|
|||||||
+1
-1
@@ -335,8 +335,8 @@ void HandleREADY(cJSON *json) {
|
|||||||
: 0) {
|
: 0) {
|
||||||
if (che->GuildID) {
|
if (che->GuildID) {
|
||||||
DiscordGuild *gld = GetGuild(che->GuildID);
|
DiscordGuild *gld = GetGuild(che->GuildID);
|
||||||
MessageBoxA(NULL, gld->name, "AAAAAAAAAA", 0);
|
|
||||||
if (gld) {
|
if (gld) {
|
||||||
|
MessageBoxA(NULL, gld->name, "AAAAAAAAAA", 0);
|
||||||
gld->MentionCount += che->ReadState.MentionCount;
|
gld->MentionCount += che->ReadState.MentionCount;
|
||||||
onDiscordUpdatedGuildReadState(*gld);
|
onDiscordUpdatedGuildReadState(*gld);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ int DiscordListGuildChannels(char* guildID, DiscordChannel** out);
|
|||||||
#define GUILD_VOICE 2
|
#define GUILD_VOICE 2
|
||||||
#define GROUPCHAT 3
|
#define GROUPCHAT 3
|
||||||
#define GUILD_CATEGORY 4
|
#define GUILD_CATEGORY 4
|
||||||
|
#define GUILD_ANNOUNCEMENT 5
|
||||||
int DiscordGetChannelHistory(const char* channelID, unsigned int amount, DiscordMessage** msgs);
|
int DiscordGetChannelHistory(const char* channelID, unsigned int amount, DiscordMessage** msgs);
|
||||||
char *DiscordFetchTmpPfp(char *userID, char *hash);
|
char *DiscordFetchTmpPfp(char *userID, char *hash);
|
||||||
char *DiscordFetchTmpGuildIcon(char *guildID, char *hash);
|
char *DiscordFetchTmpGuildIcon(char *guildID, char *hash);
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
#include <libloaderapi.h>
|
|
||||||
#include <minwindef.h>
|
|
||||||
#include <windef.h>
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <wingdi.h>
|
#include <wingdi.h>
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
@@ -64,7 +61,7 @@ char *PromptToken() {
|
|||||||
wc.hCursor = LoadCursorA(NULL, IDC_ARROW);
|
wc.hCursor = LoadCursorA(NULL, IDC_ARROW);
|
||||||
wc.lpfnWndProc = loginwndproc;
|
wc.lpfnWndProc = loginwndproc;
|
||||||
RegisterClassA(&wc);
|
RegisterClassA(&wc);
|
||||||
HWND hwnd = CreateWindowExA(0, clsname, "Backcord - Login", WS_OVERLAPPED,
|
HWND hwnd = CreateWindowExA(0, clsname, "Backcord - Login", WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU,
|
||||||
CW_USEDEFAULT, CW_USEDEFAULT, 320, 480, NULL,
|
CW_USEDEFAULT, CW_USEDEFAULT, 320, 480, NULL,
|
||||||
NULL, GetModuleHandleA(NULL), NULL);
|
NULL, GetModuleHandleA(NULL), NULL);
|
||||||
RECT clientrect;
|
RECT clientrect;
|
||||||
|
|||||||
@@ -34,9 +34,11 @@ static HWND hPfpAreaPfp;
|
|||||||
static HWND hPfpAreaDispName;
|
static HWND hPfpAreaDispName;
|
||||||
static HWND hPfpAreaUserName;
|
static HWND hPfpAreaUserName;
|
||||||
static HIMAGELIST hSidePfps;
|
static HIMAGELIST hSidePfps;
|
||||||
|
static HIMAGELIST hChannelImgList;
|
||||||
HINSTANCE hInstance;
|
HINSTANCE hInstance;
|
||||||
SSL *GatewaySSL;
|
SSL *GatewaySSL;
|
||||||
char *token;
|
char *token;
|
||||||
|
HWND hDMsProfileSide;
|
||||||
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, PSTR pCmdLine,
|
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, PSTR pCmdLine,
|
||||||
int nCmdShow) {
|
int nCmdShow) {
|
||||||
#ifdef test_token
|
#ifdef test_token
|
||||||
@@ -69,6 +71,9 @@ int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, PSTR pCmdLine,
|
|||||||
InitCommonControls();
|
InitCommonControls();
|
||||||
InitSnowsControls();
|
InitSnowsControls();
|
||||||
hSidePfps = ImageList_Create(32, 32, ILC_COLOR32 | ILC_MASK, 12, 1);
|
hSidePfps = ImageList_Create(32, 32, ILC_COLOR32 | ILC_MASK, 12, 1);
|
||||||
|
hChannelImgList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 8, 1);
|
||||||
|
ImageList_AddMasked(hChannelImgList,LoadBitmap(hinstance,MAKEINTRESOURCE(IDI_CHANNEL_VC)),RGB(255,0,255));
|
||||||
|
ImageList_AddMasked(hChannelImgList,LoadBitmap(hinstance,MAKEINTRESOURCE(IDI_CHANNEL_ANC)),RGB(255,0,255));
|
||||||
hInstance = hinstance;
|
hInstance = hinstance;
|
||||||
// register the window claws
|
// register the window claws
|
||||||
const char CLASS_NAME[] = "BackcordMain";
|
const char CLASS_NAME[] = "BackcordMain";
|
||||||
@@ -124,7 +129,7 @@ void onDiscordGuildLoad(DiscordGuild *guild, char *id) {
|
|||||||
char *path = malloc(MAX_PATH + strlen(guild->id) + 1);
|
char *path = malloc(MAX_PATH + strlen(guild->id) + 1);
|
||||||
wsprintfA(path, "%s%s.png", tempPath, guild->IconHash);
|
wsprintfA(path, "%s%s.png", tempPath, guild->IconHash);
|
||||||
if (GetFileAttributesA(path) == INVALID_FILE_ATTRIBUTES) {
|
if (GetFileAttributesA(path) == INVALID_FILE_ATTRIBUTES) {
|
||||||
char *path = DiscordFetchTmpGuildIcon(guild->id,
|
path = DiscordFetchTmpGuildIcon(guild->id,
|
||||||
guild->IconHash); // testing
|
guild->IconHash); // testing
|
||||||
}
|
}
|
||||||
GuildView_SetIcon(hGSel, LoadPNGImage(path), id);
|
GuildView_SetIcon(hGSel, LoadPNGImage(path), id);
|
||||||
@@ -244,7 +249,6 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
|
|||||||
HFONT BoldSysFont = CreateFontIndirect(&ncm.lfMessageFont);
|
HFONT BoldSysFont = CreateFontIndirect(&ncm.lfMessageFont);
|
||||||
|
|
||||||
InitHTTP();
|
InitHTTP();
|
||||||
OpenWebSocket("gateway.discord.gg", "/?encoding=json&v=9", &GatewaySSL);
|
|
||||||
|
|
||||||
RECT rc;
|
RECT rc;
|
||||||
GetClientRect(hwnd, &rc);
|
GetClientRect(hwnd, &rc);
|
||||||
@@ -345,6 +349,7 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
|
|||||||
NULL // Additional application data
|
NULL // Additional application data
|
||||||
);
|
);
|
||||||
SendMessage(hSend, WM_SETFONT, (WPARAM)regfont, 0);
|
SendMessage(hSend, WM_SETFONT, (WPARAM)regfont, 0);
|
||||||
|
OpenWebSocket("gateway.discord.gg", "/?encoding=json&v=9", &GatewaySSL);
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
case WM_SIZE: {
|
case WM_SIZE: {
|
||||||
@@ -417,8 +422,7 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
|
|||||||
|
|
||||||
tvInsert.hParent = hParent; // Parent is the root item
|
tvInsert.hParent = hParent; // Parent is the root item
|
||||||
tvInsert.hInsertAfter = TVI_LAST;
|
tvInsert.hInsertAfter = TVI_LAST;
|
||||||
tvInsert.item.mask = TVIF_TEXT | TVIF_PARAM |
|
tvInsert.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_STATE |
|
||||||
TVIS_EXPANDED | TVIF_STATE |
|
|
||||||
TVIF_IMAGE;
|
TVIF_IMAGE;
|
||||||
tvInsert.item.pszText =
|
tvInsert.item.pszText =
|
||||||
dms[i].receipents[0].DisplayName
|
dms[i].receipents[0].DisplayName
|
||||||
@@ -447,7 +451,7 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
|
|||||||
int ChannelCount =
|
int ChannelCount =
|
||||||
DiscordListGuildChannels(guild->id, &Channels);
|
DiscordListGuildChannels(guild->id, &Channels);
|
||||||
TreeView_DeleteAllItems(hChTree);
|
TreeView_DeleteAllItems(hChTree);
|
||||||
TreeView_SetImageList(hChTree, NULL, TVSIL_NORMAL);
|
//TreeView_SetImageList(hChTree, hChannelImgList, TVSIL_NORMAL);
|
||||||
struct hashmap *ChannelUITable =
|
struct hashmap *ChannelUITable =
|
||||||
hashmap_new(sizeof(ChannelUIEntry), 0, 0, 0, channel_hash,
|
hashmap_new(sizeof(ChannelUIEntry), 0, 0, 0, channel_hash,
|
||||||
channel_compare, NULL, NULL);
|
channel_compare, NULL, NULL);
|
||||||
@@ -476,11 +480,12 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
|
|||||||
tvInsert.hParent = hParent; // Parent is the root item
|
tvInsert.hParent = hParent; // Parent is the root item
|
||||||
tvInsert.hInsertAfter = TVI_LAST;
|
tvInsert.hInsertAfter = TVI_LAST;
|
||||||
tvInsert.item.mask =
|
tvInsert.item.mask =
|
||||||
TVIF_TEXT | TVIF_PARAM | TVIS_EXPANDED | TVIF_STATE;
|
TVIF_TEXT | TVIF_PARAM | TVIF_STATE;
|
||||||
tvInsert.item.pszText = (VisualName);
|
tvInsert.item.pszText = (VisualName);
|
||||||
tvInsert.item.lParam = (LPARAM) & (Channels[i]);
|
tvInsert.item.lParam = (LPARAM) & (Channels[i]);
|
||||||
tvInsert.item.state = TVIS_EXPANDED;
|
tvInsert.item.state = TVIS_EXPANDED;
|
||||||
tvInsert.item.stateMask = TVIS_EXPANDED;
|
tvInsert.item.stateMask = TVIS_EXPANDED;
|
||||||
|
|
||||||
HTREEITEM lres = (HTREEITEM)SendMessage(
|
HTREEITEM lres = (HTREEITEM)SendMessage(
|
||||||
hChTree, TVM_INSERTITEM, 0, (LPARAM)&tvInsert);
|
hChTree, TVM_INSERTITEM, 0, (LPARAM)&tvInsert);
|
||||||
if (Channels[i].type == GUILD_CATEGORY) {
|
if (Channels[i].type == GUILD_CATEGORY) {
|
||||||
@@ -494,6 +499,35 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
|
|||||||
}
|
}
|
||||||
} else if (pNMHDR.hwndFrom == hChTree) {
|
} else if (pNMHDR.hwndFrom == hChTree) {
|
||||||
LPNMTREEVIEW pnmv = (LPNMTREEVIEW)lParam;
|
LPNMTREEVIEW pnmv = (LPNMTREEVIEW)lParam;
|
||||||
|
if (pNMHDR.code == NM_CUSTOMDRAW) {
|
||||||
|
LPNMTVCUSTOMDRAW pcd = (LPNMTVCUSTOMDRAW)lParam;
|
||||||
|
switch (pcd->nmcd.dwDrawStage) {
|
||||||
|
case CDDS_PREPAINT:
|
||||||
|
SetWindowLongPtr(hwnd, DWLP_MSGRESULT, CDRF_NOTIFYITEMDRAW);
|
||||||
|
return CDRF_NOTIFYITEMDRAW;
|
||||||
|
case CDDS_ITEMPREPAINT:
|
||||||
|
return CDRF_NOTIFYPOSTPAINT;
|
||||||
|
case CDDS_ITEMPOSTPAINT: {
|
||||||
|
DiscordChannel *chnl = (DiscordChannel *)pcd->nmcd.lItemlParam;
|
||||||
|
if (chnl && chnl->type == GUILD_VOICE) {
|
||||||
|
RECT rc;
|
||||||
|
TreeView_GetItemRect(hChTree, (HTREEITEM)pcd->nmcd.dwItemSpec, &rc, TRUE);
|
||||||
|
// draw icon to the left of the label rect
|
||||||
|
ImageList_Draw(hChannelImgList, 0, pcd->nmcd.hdc,
|
||||||
|
rc.left - 18, rc.top + (rc.bottom - rc.top - 16) / 2,
|
||||||
|
ILD_TRANSPARENT);
|
||||||
|
} else if (chnl && chnl->type == GUILD_ANNOUNCEMENT) {
|
||||||
|
RECT rc;
|
||||||
|
TreeView_GetItemRect(hChTree, (HTREEITEM)pcd->nmcd.dwItemSpec, &rc, TRUE);
|
||||||
|
// draw icon to the left of the label rect
|
||||||
|
ImageList_Draw(hChannelImgList, 1, pcd->nmcd.hdc,
|
||||||
|
rc.left - 18, rc.top + (rc.bottom - rc.top - 16) / 2,
|
||||||
|
ILD_TRANSPARENT);
|
||||||
|
}
|
||||||
|
return CDRF_DODEFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (pNMHDR.code == TVN_SELCHANGED &&
|
if (pNMHDR.code == TVN_SELCHANGED &&
|
||||||
pnmv->itemNew.state & TVIS_SELECTED) {
|
pnmv->itemNew.state & TVIS_SELECTED) {
|
||||||
DiscordChannel *chnl = ((DiscordChannel *)pnmv->itemNew.lParam);
|
DiscordChannel *chnl = ((DiscordChannel *)pnmv->itemNew.lParam);
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ RES = rc/res.o
|
|||||||
Backcord: $(RES)
|
Backcord: $(RES)
|
||||||
$(WINDRES) rc/res.rc -o rc/res.o
|
$(WINDRES) rc/res.rc -o rc/res.o
|
||||||
$(CC) $(SRCS) $(RES) \
|
$(CC) $(SRCS) $(RES) \
|
||||||
-Wl,-Bstatic -lpng -lz \
|
-D _WIN32_WINNT=0x401 -D WINVER=0x401 -Wl,-Bstatic -lpng -lz \
|
||||||
-Wl,-Bdynamic -lgdi32 -lssl -lcrypto -lcrypt32 -lws2_32 \
|
-Wl,-Bdynamic -lgdi32 -lssl -lcrypto -lcrypt32 -lws2_32 \
|
||||||
-luser32 -lcomctl32 -lcomdlg32 -lcjson -lntdll \
|
-luser32 -lcomctl32 -lmsvcrt -lcomdlg32 -lcjson -lntdll \
|
||||||
-o Backcord.exe
|
-o Backcord.exe
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 338 B |
@@ -1,2 +1,4 @@
|
|||||||
#define IDI_BACKCORDIC 101
|
#define IDI_BACKCORDIC 101
|
||||||
#define IDI_BACKCORDBANNERIC 102
|
#define IDI_BACKCORDBANNERIC 102
|
||||||
|
#define IDI_CHANNEL_VC 111
|
||||||
|
#define IDI_CHANNEL_ANC 112
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
#include "res.h"
|
#include "res.h"
|
||||||
|
|
||||||
IDI_BACKCORDIC RCDATA "backcord_icon.png"
|
IDI_BACKCORDIC RCDATA "backcord_icon.png"
|
||||||
IDI_BACKCORDBANNERIC BITMAP "backcordbanner.bmp"
|
IDI_BACKCORDBANNERIC BITMAP "backcordbanner.bmp"
|
||||||
|
IDI_CHANNEL_VC BITMAP "vc.bmp"
|
||||||
|
IDI_CHANNEL_ANC BITMAP "anc.bmp"
|
||||||
@@ -201,7 +201,7 @@ int ReadWebSocket(SSL *ssl, char **out_buffer, size_t *out_length) {
|
|||||||
unsigned char tlen = (plHeaders << 1) >> 1;
|
unsigned char tlen = (plHeaders << 1) >> 1;
|
||||||
if (tlen == 127) {
|
if (tlen == 127) {
|
||||||
SSL_read(ssl, &curPayloadLen, 8);
|
SSL_read(ssl, &curPayloadLen, 8);
|
||||||
curPayloadLen = ntohll(curPayloadLen);
|
curPayloadLen = ntohl(curPayloadLen);
|
||||||
payloadLen += curPayloadLen;
|
payloadLen += curPayloadLen;
|
||||||
} else if (tlen == 126) {
|
} else if (tlen == 126) {
|
||||||
unsigned short templen;
|
unsigned short templen;
|
||||||
|
|||||||
Reference in New Issue
Block a user