diff options
author | George Hazan <george.hazan@gmail.com> | 2023-06-14 15:43:15 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-06-14 15:43:15 +0300 |
commit | dfb6bcc66e9755df814c45bba7fc0295f5d681b8 (patch) | |
tree | 391366445b12f342bc995de7742b5a61a2738b8a | |
parent | 6ef86b18b0e29e142868bc6a86621c50390e3b79 (diff) |
Steam: we don't need http polling queue either
-rw-r--r-- | protocols/Steam/Steam.vcxproj | 1 | ||||
-rw-r--r-- | protocols/Steam/Steam.vcxproj.filters | 3 | ||||
-rw-r--r-- | protocols/Steam/src/steam_avatars.cpp | 2 | ||||
-rw-r--r-- | protocols/Steam/src/steam_contacts.cpp | 8 | ||||
-rw-r--r-- | protocols/Steam/src/steam_history.cpp | 2 | ||||
-rw-r--r-- | protocols/Steam/src/steam_login.cpp | 24 | ||||
-rw-r--r-- | protocols/Steam/src/steam_menus.cpp | 8 | ||||
-rw-r--r-- | protocols/Steam/src/steam_messages.cpp | 4 | ||||
-rw-r--r-- | protocols/Steam/src/steam_proto.cpp | 26 | ||||
-rw-r--r-- | protocols/Steam/src/steam_proto.h | 115 | ||||
-rw-r--r-- | protocols/Steam/src/steam_request.cpp | 84 | ||||
-rw-r--r-- | protocols/Steam/src/steam_server.cpp | 23 |
12 files changed, 116 insertions, 184 deletions
diff --git a/protocols/Steam/Steam.vcxproj b/protocols/Steam/Steam.vcxproj index 97d32325c8..434fbe7c43 100644 --- a/protocols/Steam/Steam.vcxproj +++ b/protocols/Steam/Steam.vcxproj @@ -42,6 +42,7 @@ <ClCompile Include="src\steam_options.cpp" />
<ClCompile Include="src\steam_proto.cpp" />
<ClCompile Include="src\steam_request.cpp" />
+ <ClCompile Include="src\steam_server.cpp" />
<ClCompile Include="src\steam_utils.cpp" />
<ClCompile Include="src\steam_xstatus.cpp" />
<ClInclude Include="src\api\app_info.h" />
diff --git a/protocols/Steam/Steam.vcxproj.filters b/protocols/Steam/Steam.vcxproj.filters index d10e3f1b94..4e6664795d 100644 --- a/protocols/Steam/Steam.vcxproj.filters +++ b/protocols/Steam/Steam.vcxproj.filters @@ -54,6 +54,9 @@ <ClCompile Include="src\steam_xstatus.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="src\steam_server.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\http_request.h">
diff --git a/protocols/Steam/src/steam_avatars.cpp b/protocols/Steam/src/steam_avatars.cpp index cee909ed30..5a895b6a0c 100644 --- a/protocols/Steam/src/steam_avatars.cpp +++ b/protocols/Steam/src/steam_avatars.cpp @@ -67,7 +67,7 @@ INT_PTR CSteamProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam) needLoad = (wParam & GAIF_FORCE) || !fileExist;
if (needLoad) {
- PushRequest(new GetAvatarRequest(avatarUrl), &CSteamProto::OnGotAvatar, (void *)pai->hContact);
+ SendRequest(new GetAvatarRequest(avatarUrl), &CSteamProto::OnGotAvatar, (void *)pai->hContact);
return GAIR_WAITFOR;
}
if (fileExist)
diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp index aad1284484..d4bc14bcc2 100644 --- a/protocols/Steam/src/steam_contacts.cpp +++ b/protocols/Steam/src/steam_contacts.cpp @@ -209,7 +209,7 @@ void CSteamProto::UpdateContactDetails(MCONTACT hContact, const JSONNode &data) CMStringW message(gameInfo); if (gameId && message.IsEmpty()) { ptrA token(getStringA("TokenSecret")); - PushRequest(new GetAppInfoRequest(token, appId.c_str()), &CSteamProto::OnGotAppInfo, (void*)hContact); + SendRequest(new GetAppInfoRequest(token, appId.c_str()), &CSteamProto::OnGotAppInfo, (void*)hContact); } else { if (!gameId) @@ -442,10 +442,10 @@ void CSteamProto::OnGotFriendList(const JSONNode &root, void *) friendsMap.clear(); if (!steamIds.empty()) - PushRequest(new GetUserSummariesRequest(this, steamIds.c_str()), &CSteamProto::OnGotUserSummaries); + SendRequest(new GetUserSummariesRequest(this, steamIds.c_str()), &CSteamProto::OnGotUserSummaries); // Load last conversations - PushRequest(new GetConversationsRequest(this), &CSteamProto::OnGotConversations); + SendRequest(new GetConversationsRequest(this), &CSteamProto::OnGotConversations); } void CSteamProto::OnGotBlockList(const JSONNode &root, void *) @@ -732,5 +732,5 @@ void CSteamProto::OnSearchByNameStarted(const HttpResponse &response, void *arg) // remove trailing "," steamIds.pop_back(); - PushRequest(new GetUserSummariesRequest(this, steamIds.c_str()), &CSteamProto::OnSearchResults, (HANDLE)arg); + SendRequest(new GetUserSummariesRequest(this, steamIds.c_str()), &CSteamProto::OnSearchResults, (HANDLE)arg); } diff --git a/protocols/Steam/src/steam_history.cpp b/protocols/Steam/src/steam_history.cpp index 50b70b562c..cb2725f31a 100644 --- a/protocols/Steam/src/steam_history.cpp +++ b/protocols/Steam/src/steam_history.cpp @@ -23,7 +23,7 @@ void CSteamProto::OnGotConversations(const JSONNode &root, void *) if (lastMessageTS > storedMessageTS) { ptrA token(getStringA("TokenSecret")); ptrA steamId(getStringA("SteamID")); - PushRequest(new GetHistoryMessagesRequest(token, steamId, who, storedMessageTS), &CSteamProto::OnGotHistoryMessages, (void*)hContact); + SendRequest(new GetHistoryMessagesRequest(token, steamId, who, storedMessageTS), &CSteamProto::OnGotHistoryMessages, (void*)hContact); } } } diff --git a/protocols/Steam/src/steam_login.cpp b/protocols/Steam/src/steam_login.cpp index bd6e738e54..0363f16930 100644 --- a/protocols/Steam/src/steam_login.cpp +++ b/protocols/Steam/src/steam_login.cpp @@ -2,7 +2,7 @@ bool CSteamProto::IsOnline() { - return m_iStatus > ID_STATUS_OFFLINE; + return m_iStatus > ID_STATUS_OFFLINE && m_hServerThread != nullptr; } bool CSteamProto::IsMe(const char *steamId) @@ -16,7 +16,7 @@ void CSteamProto::Login() ptrA token(getStringA("TokenSecret")); ptrA sessionId(getStringA("SessionID")); if (mir_strlen(token) > 0 && mir_strlen(sessionId) > 0) { - PushRequest(new LogonRequest(token), &CSteamProto::OnLoggedOn); + SendRequest(new LogonRequest(token), &CSteamProto::OnLoggedOn); return; } @@ -24,15 +24,11 @@ void CSteamProto::Login() if (username == NULL) SetStatus(ID_STATUS_OFFLINE); else - PushRequest(new GetRsaKeyRequest(username), &CSteamProto::OnGotRsaKey); + SendRequest(new GetRsaKeyRequest(username), &CSteamProto::OnGotRsaKey); } void CSteamProto::Logout() { - m_isTerminated = true; - if (m_hRequestQueueThread) - SetEvent(m_hRequestsQueueEvent); - ptrA token(getStringA("TokenSecret")); if (mir_strlen(token) > 0) { ptrA umqid(getStringA("UMQID")); @@ -104,7 +100,7 @@ void CSteamProto::OnGotRsaKey(const JSONNode &root, void *) if (!captchaText) captchaText = mir_strdup(""); - PushRequest( + SendRequest( new AuthorizationRequest(username, base64RsaEncryptedPassword, timestamp.c_str(), twoFactorCode, guardCode, guardId, captchaId, captchaText), &CSteamProto::OnAuthorization); } @@ -129,7 +125,7 @@ void CSteamProto::OnGotCaptcha(const HttpResponse &response, void *arg) setString("CaptchaText", captchaDialog.GetCaptchaText()); T2Utf username(getWStringA("Username")); - PushRequest(new GetRsaKeyRequest(username), &CSteamProto::OnGotRsaKey); + SendRequest(new GetRsaKeyRequest(username), &CSteamProto::OnGotRsaKey); } void CSteamProto::OnAuthorization(const HttpResponse &response, void *) @@ -181,7 +177,6 @@ void CSteamProto::OnAuthorizationError(const JSONNode &root) delSetting("TwoFactorCode"); SetStatus(ID_STATUS_OFFLINE); ShowNotification(message); - return; } T2Utf username(getWStringA("Username")); @@ -199,8 +194,7 @@ void CSteamProto::OnAuthorizationError(const JSONNode &root) setString("TwoFactorCode", twoFactorDialog.GetTwoFactorCode()); - PushRequest(new GetRsaKeyRequest(username), &CSteamProto::OnGotRsaKey); - return; + SendRequest(new GetRsaKeyRequest(username), &CSteamProto::OnGotRsaKey); } if (root["emailauth_needed"].as_bool()) { @@ -232,7 +226,7 @@ void CSteamProto::OnAuthorizationError(const JSONNode &root) setString("GuardId", guardId.c_str()); setString("GuardCode", guardDialog.GetGuardCode()); - PushRequest(new GetRsaKeyRequest(username), &CSteamProto::OnGotRsaKey); + SendRequest(new GetRsaKeyRequest(username), &CSteamProto::OnGotRsaKey); return; } @@ -241,7 +235,7 @@ void CSteamProto::OnAuthorizationError(const JSONNode &root) delSetting("CaptchaId"); delSetting("CaptchaText"); json_string captchaId = root["captcha_gid"].as_string(); - PushRequest(new GetCaptchaRequest(captchaId.c_str()), &CSteamProto::OnGotCaptcha, mir_strdup(captchaId.c_str())); + SendRequest(new GetCaptchaRequest(captchaId.c_str()), &CSteamProto::OnGotCaptcha, mir_strdup(captchaId.c_str())); return; } @@ -275,7 +269,7 @@ void CSteamProto::OnAuthorizationSuccess(const JSONNode &root) SendRequest(new GetSessionRequest2(token.c_str(), steamId.c_str()), &CSteamProto::OnGotSession); - PushRequest(new LogonRequest(token.c_str()), &CSteamProto::OnLoggedOn); + SendRequest(new LogonRequest(token.c_str()), &CSteamProto::OnLoggedOn); } void CSteamProto::OnGotSession(const HttpResponse &response, void *) diff --git a/protocols/Steam/src/steam_menus.cpp b/protocols/Steam/src/steam_menus.cpp index 42b169a312..b1be43879c 100644 --- a/protocols/Steam/src/steam_menus.cpp +++ b/protocols/Steam/src/steam_menus.cpp @@ -22,7 +22,7 @@ INT_PTR CSteamProto::AuthRevokeCommand(WPARAM hContact, LPARAM) ptrA sessionId(getStringA("SessionID"));
ptrA steamId(getStringA("SteamID"));
char *who = getStringA(hContact, "SteamID");
- PushRequest(new RemoveFriendRequest(token, sessionId, steamId, who), &CSteamProto::OnFriendRemoved, who);
+ SendRequest(new RemoveFriendRequest(token, sessionId, steamId, who), &CSteamProto::OnFriendRemoved, who);
return 0;
}
@@ -32,7 +32,7 @@ int CSteamProto::BlockCommand(WPARAM hContact, LPARAM) ptrA sessionId(getStringA("SessionID"));
ptrA steamId(getStringA("SteamID"));
char *who = getStringA(hContact, "SteamID");
- PushRequest(new BlockFriendRequest(token, sessionId, steamId, who), &CSteamProto::OnFriendBlocked, who);
+ SendRequest(new BlockFriendRequest(token, sessionId, steamId, who), &CSteamProto::OnFriendBlocked, who);
return 0;
}
@@ -42,7 +42,7 @@ int CSteamProto::UnblockCommand(WPARAM hContact, LPARAM) ptrA sessionId(getStringA("SessionID"));
ptrA steamId(getStringA("SteamID"));
char *who = getStringA(hContact, "SteamID");
- PushRequest(new UnblockFriendRequest(token, sessionId, steamId, who), &CSteamProto::OnFriendUnblocked, who);
+ SendRequest(new UnblockFriendRequest(token, sessionId, steamId, who), &CSteamProto::OnFriendUnblocked, who);
return 0;
}
@@ -59,7 +59,7 @@ INT_PTR CSteamProto::OpenBlockListCommand(WPARAM, LPARAM) {
ptrA token(getStringA("TokenSecret"));
ptrA steamId(getStringA("SteamID"));
- PushRequest(new GetFriendListRequest(token, steamId, "ignoredfriend"), &CSteamProto::OnGotBlockList);
+ SendRequest(new GetFriendListRequest(token, steamId, "ignoredfriend"), &CSteamProto::OnGotBlockList);
return 0;
}
diff --git a/protocols/Steam/src/steam_messages.cpp b/protocols/Steam/src/steam_messages.cpp index deeb610a4b..f90bba865c 100644 --- a/protocols/Steam/src/steam_messages.cpp +++ b/protocols/Steam/src/steam_messages.cpp @@ -17,7 +17,7 @@ int CSteamProto::OnSendMessage(MCONTACT hContact, const char *message) ptrA token(getStringA("TokenSecret"));
ptrA umqid(getStringA("UMQID"));
ptrA steamId(getStringA(hContact, "SteamID"));
- PushRequest(new SendMessageRequest(token, umqid, steamId, message), &CSteamProto::OnMessageSent, param);
+ SendRequest(new SendMessageRequest(token, umqid, steamId, message), &CSteamProto::OnMessageSent, param);
return hMessage;
}
@@ -80,6 +80,6 @@ int CSteamProto::UserIsTyping(MCONTACT hContact, int type) ptrA token(getStringA("TokenSecret"));
ptrA umqid(getStringA("UMQID"));
ptrA steamId(getStringA(hContact, "SteamID"));
- PushRequest(new SendTypingRequest(token, umqid, steamId));
+ SendRequest(new SendTypingRequest(token, umqid, steamId));
return 0;
}
diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp index f64600bfa0..ce380c54eb 100644 --- a/protocols/Steam/src/steam_proto.cpp +++ b/protocols/Steam/src/steam_proto.cpp @@ -1,11 +1,8 @@ #include "stdafx.h"
CSteamProto::CSteamProto(const char *protoName, const wchar_t *userName) :
- PROTO<CSteamProto>(protoName, userName),
- m_requestQueue(1), hAuthProcess(1), hMessageProcess(1)
+ PROTO<CSteamProto>(protoName, userName)
{
- m_hRequestsQueueEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
-
// default group
m_defaultGroup = getWStringA("DefaultGroup");
if (m_defaultGroup == nullptr)
@@ -86,10 +83,6 @@ CSteamProto::CSteamProto(const char *protoName, const wchar_t *userName) : CSteamProto::~CSteamProto()
{
- if (m_hRequestsQueueEvent) {
- CloseHandle(m_hRequestsQueueEvent);
- m_hRequestsQueueEvent = nullptr;
- }
}
MCONTACT CSteamProto::AddToList(int, PROTOSEARCHRESULT *psr)
@@ -130,7 +123,7 @@ int CSteamProto::Authorize(MEVENT hDbEvent) ptrA steamId(getStringA("SteamID"));
char *who = getStringA(hContact, "SteamID");
- PushRequest(
+ SendRequest(
new ApprovePendingRequest(token, sessionId, steamId, who),
&CSteamProto::OnPendingApproved,
who);
@@ -160,7 +153,7 @@ int CSteamProto::AuthDeny(MEVENT hDbEvent, const wchar_t*) ptrA steamId(getStringA("SteamID"));
char *who = getStringA(hContact, "SteamID");
- PushRequest(
+ SendRequest(
new IgnorePendingRequest(token, sessionId, steamId, who),
&CSteamProto::OnPendingIgnoreded,
who);
@@ -185,7 +178,7 @@ int CSteamProto::AuthRequest(MCONTACT hContact, const wchar_t*) ptrA steamId(getStringA("SteamID"));
ptrA who(getStringA(hContact, "SteamID"));
- PushRequest(
+ SendRequest(
new AddFriendRequest(token, sessionId, steamId, who),
&CSteamProto::OnFriendAdded,
param);
@@ -220,7 +213,7 @@ HANDLE CSteamProto::SearchBasic(const wchar_t* id) return nullptr;
ptrA steamId(mir_u2a(id));
- PushRequest(new GetUserSummariesRequest(this, steamId), &CSteamProto::OnSearchResults, (HANDLE)STEAM_SEARCH_BYID);
+ SendRequest(new GetUserSummariesRequest(this, steamId), &CSteamProto::OnSearchResults, (HANDLE)STEAM_SEARCH_BYID);
return (HANDLE)STEAM_SEARCH_BYID;
}
@@ -237,7 +230,7 @@ HANDLE CSteamProto::SearchByName(const wchar_t *nick, const wchar_t *firstName, ptrA token(getStringA("TokenSecret"));
ptrA keywords(mir_utf8encodeW(rtrimw(keywordsT)));
- PushRequest(
+ SendRequest(
new SearchRequest(token, keywords),
&CSteamProto::OnSearchByNameStarted,
(HANDLE)STEAM_SEARCH_BYNAME);
@@ -297,10 +290,9 @@ int CSteamProto::SetStatus(int new_status) Logout();
}
- else if (m_hRequestQueueThread == nullptr && !IsStatusConnecting(m_iStatus)) {
+ else if (m_hServerThread == nullptr && !IsStatusConnecting(m_iStatus)) {
m_iStatus = ID_STATUS_CONNECTING;
- m_isTerminated = false;
- ForkThread(&CSteamProto::RequestQueueThread);
+ ForkThread(&CSteamProto::ServerThread);
Login();
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);
@@ -348,6 +340,6 @@ void CSteamProto::OnContactDeleted(MCONTACT hContact) ptrA sessionId(getStringA("SessionID"));
ptrA steamId(getStringA("SteamID"));
char *who = getStringA(hContact, "SteamID");
- PushRequest(new RemoveFriendRequest(token, sessionId, steamId, who), &CSteamProto::OnFriendRemoved, (void*)who);
+ SendRequest(new RemoveFriendRequest(token, sessionId, steamId, who), &CSteamProto::OnFriendRemoved, (void*)who);
}
}
diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h index 8d90fef211..d72caba56f 100644 --- a/protocols/Steam/src/steam_proto.h +++ b/protocols/Steam/src/steam_proto.h @@ -63,65 +63,21 @@ class CSteamProto : public PROTO<CSteamProto> time_t m_idleTS;
HWND m_hwndGuard;
- // requests
- bool m_isTerminated;
- mir_cs m_requestQueueLock;
- HANDLE m_hRequestsQueueEvent;
- HANDLE m_hRequestQueueThread;
- LIST<RequestQueueItem> m_requestQueue;
-
// polling
- ULONG hAuthProcess;
- ULONG hMessageProcess;
+ ULONG hAuthProcess = 1;
+ ULONG hMessageProcess = 1;
mir_cs m_addContactLock;
mir_cs m_setStatusLock;
std::map<HANDLE, time_t> m_mpOutMessages;
-public:
- // PROTO_INTERFACE
- CSteamProto(const char *protoName, const wchar_t *userName);
- ~CSteamProto();
-
- // PROTO_INTERFACE
- MCONTACT AddToList(int flags, PROTOSEARCHRESULT *psr) override;
- MCONTACT AddToListByEvent(int flags, int iContact, MEVENT hDbEvent) override;
-
- int Authorize(MEVENT hDbEvent) override;
- int AuthRecv(MCONTACT, PROTORECVEVENT*) override;
- int AuthDeny(MEVENT hDbEvent, const wchar_t *szReason) override;
- int AuthRequest(MCONTACT hContact, const wchar_t *szMessage) override;
-
- INT_PTR GetCaps(int type, MCONTACT hContact = NULL) override;
- HANDLE GetAwayMsg(MCONTACT hContact) override;
-
- HANDLE SearchBasic(const wchar_t *id) override;
- HANDLE SearchByName(const wchar_t *nick, const wchar_t *firstName, const wchar_t *lastName) override;
-
- int SendMsg(MCONTACT hContact, int flags, const char *msg) override;
-
- int SetStatus(int iNewStatus) override;
-
- int UserIsTyping(MCONTACT hContact, int type) override;
-
- void OnContactDeleted(MCONTACT) override;
- MWindow OnCreateAccMgrUI(MWindow) override;
- void OnModulesLoaded() override;
-
- // menus
- static void InitMenus();
+ // connection
+ HANDLE m_hServerThread;
+ void __cdecl ServerThread(void *);
-protected:
// requests
- void SendRequest(HttpRequest *request);
- void SendRequest(HttpRequest *request, HttpCallback callback, void *param = nullptr);
- void SendRequest(HttpRequest *request, JsonCallback callback, void *param = nullptr);
- void PushRequest(HttpRequest *request);
- void PushRequest(HttpRequest *request, HttpCallback callback, void *param = nullptr);
- void PushRequest(HttpRequest *request, JsonCallback callback, void *param = nullptr);
- void PushToRequestQueue(RequestQueueItem *item);
- RequestQueueItem *PopFromRequestQueue();
- void ProcessRequestQueue();
- void __cdecl RequestQueueThread(void*);
+ bool SendRequest(HttpRequest *request);
+ bool SendRequest(HttpRequest *request, HttpCallback callback, void *param = nullptr);
+ bool SendRequest(HttpRequest *request, JsonCallback callback, void *param = nullptr);
// login
bool IsOnline();
@@ -130,17 +86,17 @@ protected: void Login();
void Logout();
- void OnGotRsaKey(const JSONNode &root, void*);
+ void OnGotRsaKey(const JSONNode &root, void *);
void OnGotCaptcha(const HttpResponse &response, void *arg);
-
- void OnAuthorization(const HttpResponse &response, void*);
+
+ void OnAuthorization(const HttpResponse &response, void *);
void OnAuthorizationError(const JSONNode &root);
void OnAuthorizationSuccess(const JSONNode &root);
- void OnGotSession(const HttpResponse &response, void*);
+ void OnGotSession(const HttpResponse &response, void *);
- void OnLoggedOn(const HttpResponse &response, void*);
- void OnReLogin(const JSONNode &root, void*);
+ void OnLoggedOn(const HttpResponse &response, void *);
+ void OnReLogin(const JSONNode &root, void *);
void HandleTokenExpired();
void DeleteAuthSettings();
@@ -164,9 +120,9 @@ protected: MCONTACT GetContact(const char *steamId);
MCONTACT AddContact(const char *steamId, const wchar_t *nick = nullptr, bool isTemporary = false);
- void OnGotFriendList(const JSONNode &root, void*);
- void OnGotBlockList(const JSONNode &root, void*);
- void OnGotUserSummaries(const JSONNode &root, void*);
+ void OnGotFriendList(const JSONNode &root, void *);
+ void OnGotBlockList(const JSONNode &root, void *);
+ void OnGotUserSummaries(const JSONNode &root, void *);
void OnGotAvatar(const HttpResponse &response, void *arg);
void OnFriendAdded(const HttpResponse &response, void *arg);
@@ -189,7 +145,7 @@ protected: // history
void OnGotConversations(const JSONNode &root, void *arg);
- void OnGotHistoryMessages(const JSONNode &root, void*);
+ void OnGotHistoryMessages(const JSONNode &root, void *);
// menus
static int hChooserMenu;
@@ -210,7 +166,7 @@ protected: void OnInitStatusMenu();
// avatars
- wchar_t* GetAvatarFilePath(MCONTACT hContact);
+ wchar_t *GetAvatarFilePath(MCONTACT hContact);
bool GetDbAvatarInfo(PROTO_AVATAR_INFORMATION &pai);
void CheckAvatarChange(MCONTACT hContact, std::string avatarUrl);
@@ -272,6 +228,39 @@ protected: mir_snprintf(accountId, "%llu", steamId - 76561197960265728ll);
return accountId;
}
+
+public:
+ // PROTO_INTERFACE
+ CSteamProto(const char *protoName, const wchar_t *userName);
+ ~CSteamProto();
+
+ // PROTO_INTERFACE
+ MCONTACT AddToList(int flags, PROTOSEARCHRESULT *psr) override;
+ MCONTACT AddToListByEvent(int flags, int iContact, MEVENT hDbEvent) override;
+
+ int Authorize(MEVENT hDbEvent) override;
+ int AuthRecv(MCONTACT, PROTORECVEVENT*) override;
+ int AuthDeny(MEVENT hDbEvent, const wchar_t *szReason) override;
+ int AuthRequest(MCONTACT hContact, const wchar_t *szMessage) override;
+
+ INT_PTR GetCaps(int type, MCONTACT hContact = NULL) override;
+ HANDLE GetAwayMsg(MCONTACT hContact) override;
+
+ HANDLE SearchBasic(const wchar_t *id) override;
+ HANDLE SearchByName(const wchar_t *nick, const wchar_t *firstName, const wchar_t *lastName) override;
+
+ int SendMsg(MCONTACT hContact, int flags, const char *msg) override;
+
+ int SetStatus(int iNewStatus) override;
+
+ int UserIsTyping(MCONTACT hContact, int type) override;
+
+ void OnContactDeleted(MCONTACT) override;
+ MWindow OnCreateAccMgrUI(MWindow) override;
+ void OnModulesLoaded() override;
+
+ // menus
+ static void InitMenus();
};
struct CMPlugin : public ACCPROTOPLUGIN<CSteamProto>
diff --git a/protocols/Steam/src/steam_request.cpp b/protocols/Steam/src/steam_request.cpp index 9c31d78409..b4ddec0a65 100644 --- a/protocols/Steam/src/steam_request.cpp +++ b/protocols/Steam/src/steam_request.cpp @@ -1,22 +1,24 @@ #include "stdafx.h"
-void CSteamProto::SendRequest(HttpRequest *request)
+bool CSteamProto::SendRequest(HttpRequest *request)
{
- NETLIBHTTPREQUEST *pResp = Netlib_HttpTransaction(m_hNetlibUser, (NETLIBHTTPREQUEST*)request);
+ NETLIBHTTPREQUEST *pResp = Netlib_HttpTransaction(m_hNetlibUser, request);
HttpResponse response(request, pResp);
delete request;
+ return response.IsSuccess();
}
-void CSteamProto::SendRequest(HttpRequest *request, HttpCallback callback, void *param)
+bool CSteamProto::SendRequest(HttpRequest *request, HttpCallback callback, void *param)
{
NETLIBHTTPREQUEST *pResp = Netlib_HttpTransaction(m_hNetlibUser, (NETLIBHTTPREQUEST*)request);
HttpResponse response(request, pResp);
if (callback)
(this->*callback)(response, param);
delete request;
+ return response.IsSuccess();
}
-void CSteamProto::SendRequest(HttpRequest *request, JsonCallback callback, void *param)
+bool CSteamProto::SendRequest(HttpRequest *request, JsonCallback callback, void *param)
{
NETLIBHTTPREQUEST *pResp = Netlib_HttpTransaction(m_hNetlibUser, (NETLIBHTTPREQUEST*)request);
HttpResponse response(request, pResp);
@@ -25,77 +27,5 @@ void CSteamProto::SendRequest(HttpRequest *request, JsonCallback callback, void (this->*callback)(root, param);
}
delete request;
-}
-
-void CSteamProto::PushRequest(HttpRequest *request)
-{
- RequestQueueItem *item = new RequestQueueItem(request);
- PushToRequestQueue(item);
-}
-
-void CSteamProto::PushRequest(HttpRequest *request, HttpCallback callback, void *param)
-{
- RequestQueueItem *item = new RequestQueueItem(request, callback, param);
- PushToRequestQueue(item);
-}
-
-void CSteamProto::PushRequest(HttpRequest *request, JsonCallback callback, void *param)
-{
- RequestQueueItem *item = new RequestQueueItem(request, callback, param);
- PushToRequestQueue(item);
-}
-
-/////////////////////////////////////////////////////////////////////////////////
-
-void CSteamProto::PushToRequestQueue(RequestQueueItem *item)
-{
- if (m_isTerminated)
- return;
- {
- mir_cslock lock(m_requestQueueLock);
- m_requestQueue.insert(item);
- }
- SetEvent(m_hRequestsQueueEvent);
-}
-
-RequestQueueItem *CSteamProto::PopFromRequestQueue()
-{
- mir_cslock lock(m_requestQueueLock);
- if (!m_requestQueue.getCount())
- return nullptr;
-
- RequestQueueItem *item = m_requestQueue[0];
- m_requestQueue.remove(0);
- return item;
-}
-
-void CSteamProto::ProcessRequestQueue()
-{
- while (true) {
- RequestQueueItem *item = PopFromRequestQueue();
- if (item == nullptr)
- break;
- if (item->httpCallback)
- SendRequest(item->request, item->httpCallback, item->param);
- else if (item->jsonCallback)
- SendRequest(item->request, item->jsonCallback, item->param);
- else
- SendRequest(item->request);
- delete item;
- }
-}
-
-void CSteamProto::RequestQueueThread(void*)
-{
- do {
- ProcessRequestQueue();
- WaitForSingleObject(m_hRequestsQueueEvent, 1000);
- } while (!m_isTerminated);
-
- m_hRequestQueueThread = nullptr;
-
- mir_cslock lock(m_requestQueueLock);
- for (auto &it : m_requestQueue)
- delete it;
- m_requestQueue.destroy();
+ return response.IsSuccess();
}
diff --git a/protocols/Steam/src/steam_server.cpp b/protocols/Steam/src/steam_server.cpp new file mode 100644 index 0000000000..56df3f0cc3 --- /dev/null +++ b/protocols/Steam/src/steam_server.cpp @@ -0,0 +1,23 @@ +/* +Copyright (C) 2012-23 Miranda NG team (https://miranda-ng.org) + +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 version 2 +of the License. + +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" + +void __cdecl CSteamProto::ServerThread(void *) +{ + +} |