From 0ea1ce46b586e93ecd78a57e8d30e492d67691f1 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 12 Nov 2023 19:03:36 +0300 Subject: fixes #3917 (Omegle is dead) --- protocols/Omegle/src/chat.cpp | 316 -------------- protocols/Omegle/src/client.h | 126 ------ protocols/Omegle/src/communication.cpp | 737 --------------------------------- protocols/Omegle/src/connection.cpp | 178 -------- protocols/Omegle/src/constants.h | 47 --- protocols/Omegle/src/db.h | 45 -- protocols/Omegle/src/dialogs.cpp | 335 --------------- protocols/Omegle/src/dialogs.h | 26 -- protocols/Omegle/src/http.h | 36 -- protocols/Omegle/src/main.cpp | 64 --- protocols/Omegle/src/messages.cpp | 74 ---- protocols/Omegle/src/proto.cpp | 174 -------- protocols/Omegle/src/proto.h | 109 ----- protocols/Omegle/src/resource.h | 35 -- protocols/Omegle/src/stdafx.cxx | 18 - protocols/Omegle/src/stdafx.h | 97 ----- protocols/Omegle/src/theme.cpp | 35 -- protocols/Omegle/src/theme.h | 25 -- protocols/Omegle/src/version.h | 13 - 19 files changed, 2490 deletions(-) delete mode 100644 protocols/Omegle/src/chat.cpp delete mode 100644 protocols/Omegle/src/client.h delete mode 100644 protocols/Omegle/src/communication.cpp delete mode 100644 protocols/Omegle/src/connection.cpp delete mode 100644 protocols/Omegle/src/constants.h delete mode 100644 protocols/Omegle/src/db.h delete mode 100644 protocols/Omegle/src/dialogs.cpp delete mode 100644 protocols/Omegle/src/dialogs.h delete mode 100644 protocols/Omegle/src/http.h delete mode 100644 protocols/Omegle/src/main.cpp delete mode 100644 protocols/Omegle/src/messages.cpp delete mode 100644 protocols/Omegle/src/proto.cpp delete mode 100644 protocols/Omegle/src/proto.h delete mode 100644 protocols/Omegle/src/resource.h delete mode 100644 protocols/Omegle/src/stdafx.cxx delete mode 100644 protocols/Omegle/src/stdafx.h delete mode 100644 protocols/Omegle/src/theme.cpp delete mode 100644 protocols/Omegle/src/theme.h delete mode 100644 protocols/Omegle/src/version.h (limited to 'protocols/Omegle/src') diff --git a/protocols/Omegle/src/chat.cpp b/protocols/Omegle/src/chat.cpp deleted file mode 100644 index 0cec37e307..0000000000 --- a/protocols/Omegle/src/chat.cpp +++ /dev/null @@ -1,316 +0,0 @@ -/* - -Omegle plugin for Miranda Instant Messenger -_____________________________________________ - -Copyright © 2011-17 Robert Pösel, 2017-23 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 . -*/ - -#include "stdafx.h" - -const wchar_t msgChatModes[] = -LPGENW("There are three different modes of chatting:\ -\n1) Standard mode\t - You chat with random stranger privately\ -\n2) Question mode\t - You ask two strangers a question and see how they discuss it (you can't join their conversation, only watch)\ -\n3) Spy mode\t - You and stranger got a question to discuss from third stranger (he can't join your conversation, only watch)\ -\n\nSend '/commands' for available commands."); - -const wchar_t msgChatCommands[] = -LPGENW("You can use different commands:\ -\n/help\t - show info about chat modes\ -\n/new\t - start standard mode\ -\n/ask - start question mode with your question\ -\n/ask\t - start question mode with your last asked question\ -\n/spy\t - start spy mode\ -\n/quit\t - disconnect from stranger or stop connecting\ -\n/asl\t - send your predefined ASL message\ -\n\nNote: You can reconnect to different stranger without disconnecting from current one."); - -void OmegleProto::UpdateChat(const wchar_t *name, const wchar_t *message, bool addtolog) -{ - if (message == nullptr) - return; - - // replace % to %% to not interfere with chat color codes - CMStringW smessage(message); - smessage.Replace(L"%", L"%%"); - - GCEVENT gce = { m_si, GC_EVENT_MESSAGE }; - gce.time = ::time(0); - gce.pszText.w = smessage.c_str(); - - if (name == nullptr) { - gce.iType = GC_EVENT_INFORMATION; - name = TranslateT("Server"); - gce.bIsMe = false; - } - else gce.bIsMe = !mir_wstrcmp(name, this->facy.nick_); - - if (addtolog) - gce.dwFlags |= GCEF_ADDTOLOG; - - gce.pszNick.w = name; - gce.pszUID.w = gce.pszNick.w; - Chat_Event(&gce); -} - -int OmegleProto::OnChatEvent(WPARAM, LPARAM lParam) -{ - GCHOOK *hook = reinterpret_cast(lParam); - if (mir_strcmp(hook->si->pszModule, m_szModuleName)) - return 0; - - switch (hook->iType) { - case GC_USER_MESSAGE: - { - std::string text = mir_u2a_cp(hook->ptszText, CP_UTF8); - - // replace %% back to %, because chat automatically does this to sent messages - utils::text::replace_all(&text, "%%", "%"); - - if (text.empty()) - break; - - if (text.substr(0, 1) == "/") { // Process commands - - std::string command = ""; - std::string params = ""; - - std::string::size_type pos = 0; - if ((pos = text.find(" ")) != std::string::npos) { - command = text.substr(1, pos - 1); - params = text.substr(pos + 1); - } - else command = text.substr(1); - - if (!mir_strcmpi(command.c_str(), "new")) { - facy.spy_mode_ = false; - facy.question_.clear(); - - ForkThread(&OmegleProto::NewChatWorker, nullptr); - break; - } - else if (!mir_strcmpi(command.c_str(), "quit")) { - ForkThread(&OmegleProto::StopChatWorker, nullptr); - break; - } - else if (!mir_strcmpi(command.c_str(), "spy")) { - facy.spy_mode_ = true; - facy.question_.clear(); - - ForkThread(&OmegleProto::NewChatWorker, nullptr); - break; - } - else if (!mir_strcmpi(command.c_str(), "ask")) { - if (params.empty()) { - // Load last question - DBVARIANT dbv; - if (!getU8String(OMEGLE_KEY_LAST_QUESTION, &dbv)) { - params = dbv.pszVal; - db_free(&dbv); - } - - if (params.empty()) { - UpdateChat(nullptr, TranslateT("Last question is empty."), false); - break; - } - } - else { - // Save actual question as last question - if (params.length() >= OMEGLE_QUESTION_MIN_LENGTH) - setU8String(OMEGLE_KEY_LAST_QUESTION, params.c_str()); - } - - if (params.length() < OMEGLE_QUESTION_MIN_LENGTH) { - UpdateChat(nullptr, TranslateT("Your question is too short."), false); - break; - } - - facy.spy_mode_ = true; - facy.question_ = params; - ForkThread(&OmegleProto::NewChatWorker, nullptr); - break; - } - else if (!mir_strcmpi(command.c_str(), "asl")) { - DBVARIANT dbv; - if (!getU8String(OMEGLE_KEY_ASL, &dbv)) { - text = dbv.pszVal; - db_free(&dbv); - - SendChatMessage(text); - } - else { - UpdateChat(nullptr, TranslateT("Your '/asl' setting is empty."), false); - break; - } - } - else if (!mir_strcmpi(command.c_str(), "help")) { - UpdateChat(nullptr, TranslateW(msgChatModes), false); - } - else if (!mir_strcmpi(command.c_str(), "commands")) { - UpdateChat(nullptr, TranslateW(msgChatCommands), false); - break; - } - else { - UpdateChat(nullptr, TranslateT("Unknown command. Send '/commands' for list."), false); - break; - } - } - else // Outgoing message - SendChatMessage(text); - } - break; - - case GC_SESSION_TERMINATE: - facy.nick_ = nullptr; - ForkThread(&OmegleProto::StopChatWorker, nullptr); - break; - } - - return 1; -} - -void OmegleProto::SendChatMessage(std::string text) -{ - switch (facy.state_) { - case STATE_ACTIVE: - debugLogA("**Chat - Outgoing message: %s", text.c_str()); - ForkThread(&OmegleProto::SendMsgWorker, new std::string(text)); - break; - - case STATE_INACTIVE: - UpdateChat(nullptr, TranslateT("You aren't connected to any stranger. Send '/help' or '/commands' for help."), false); - break; - - case STATE_SPY: - UpdateChat(nullptr, TranslateT("You can't send messages in question mode."), false); - break; - } -} - -void OmegleProto::AddChatContact(const wchar_t *name) -{ - GCEVENT gce = { m_si, GC_EVENT_JOIN }; - gce.time = uint32_t(time(0)); - gce.dwFlags = GCEF_ADDTOLOG; - gce.pszNick.w = name; - gce.pszUID.w = gce.pszNick.w; - - if (name == nullptr) - gce.bIsMe = false; - else - gce.bIsMe = mir_wstrcmp(name, this->facy.nick_); - - if (gce.bIsMe) - gce.pszStatus.w = L"Admin"; - else - gce.pszStatus.w = L"Normal"; - - Chat_Event(&gce); -} - -void OmegleProto::DeleteChatContact(const wchar_t *name) -{ - GCEVENT gce = { m_si, GC_EVENT_PART }; - gce.dwFlags = GCEF_ADDTOLOG; - gce.pszNick.w = name; - gce.pszUID.w = gce.pszNick.w; - gce.time = uint32_t(time(0)); - if (name == nullptr) - gce.bIsMe = false; - else - gce.bIsMe = mir_wstrcmp(name, this->facy.nick_); - - Chat_Event(&gce); -} - -INT_PTR OmegleProto::OnJoinChat(WPARAM, LPARAM suppress) -{ - // Create the group chat session - m_si = Chat_NewSession(GCW_PRIVMESS, m_szModuleName, m_tszUserName, m_tszUserName); - if (!m_si || m_iStatus == ID_STATUS_OFFLINE) - return 0; - - // Create a group - Chat_AddGroup(m_si, TranslateT("Admin")); - Chat_AddGroup(m_si, TranslateT("Normal")); - - SetTopic(); - - // Note: Initialization will finish up in SetChatStatus, called separately - if (!suppress) - SetChatStatus(m_iStatus); - - return 0; -} - -void OmegleProto::SetTopic(const wchar_t *topic) -{ - GCEVENT gce = { m_si, GC_EVENT_TOPIC }; - gce.time = ::time(0); - - if (topic == nullptr) - gce.pszText.w = TranslateT("Omegle is a great way of meeting new friends!"); - else - gce.pszText.w = topic; - - Chat_Event(&gce); -} - -INT_PTR OmegleProto::OnLeaveChat(WPARAM, LPARAM) -{ - Chat_Control(m_si, SESSION_OFFLINE); - Chat_Terminate(m_si); - m_si = nullptr; - return 0; -} - -void OmegleProto::SetChatStatus(int status) -{ - if (status == ID_STATUS_ONLINE) { - // Load actual name from database - facy.nick_ = db_get_wsa(0, m_szModuleName, OMEGLE_KEY_NAME); - if (facy.nick_ == NULL) { - facy.nick_ = mir_wstrdup(TranslateT("You")); - db_set_ws(0, m_szModuleName, OMEGLE_KEY_NAME, facy.nick_); - } - - // Add self contact - AddChatContact(facy.nick_); - - Chat_Control(m_si, SESSION_INITDONE); - Chat_Control(m_si, SESSION_ONLINE); - } - else Chat_Control(m_si, SESSION_OFFLINE); -} - -void OmegleProto::ClearChat() -{ - if (!getByte(OMEGLE_KEY_NO_CLEAR, 0)) - Chat_Control(m_si, WINDOW_CLEARLOG); -} - -// TODO: Could this be done better? -MCONTACT OmegleProto::GetChatHandle() -{ - GC_INFO gci = {}; - gci.Flags = GCF_HCONTACT; - gci.pszModule = m_szModuleName; - gci.pszID = m_tszUserName; - Chat_GetInfo(&gci); - - return gci.hContact; -} diff --git a/protocols/Omegle/src/client.h b/protocols/Omegle/src/client.h deleted file mode 100644 index 1a34b20629..0000000000 --- a/protocols/Omegle/src/client.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - -Omegle plugin for Miranda Instant Messenger -_____________________________________________ - -Copyright © 2011-17 Robert Pösel, 2017-23 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 . - -*/ - -#pragma once - -#define FORCE_DISCONNECT true - -#define STATE_INACTIVE 0 // not connected to any stranger -#define STATE_WAITING 1 // connecting to stranger -#define STATE_ACTIVE 2 // active discussion -#define STATE_DISCONNECTING 3 // disconnecting from stranger -#define STATE_SPY 4 // spy mode (read-only) - -#define HANDLE_ENTRY handle_entry(__FUNCTION__) -#define HANDLE_SUCCESS handle_success(__FUNCTION__) -#define HANDLE_ERROR(force_disconnect) handle_error(__FUNCTION__, force_disconnect) - -class Omegle_client -{ -public: - - // Client definition - Omegle_client() - { - nick_ = nullptr; - //msgid_ = 0; - state_ = STATE_INACTIVE; - - typing_ = spy_mode_ = false; - - error_count_ = 0; - - parent = nullptr; - handle_ = nullptr; - hConnection = nullptr; - hEventsConnection = nullptr; - connection_lock_ = nullptr; - chatHandle_ = nullptr; - } - - HNETLIBCONN hConnection; - HNETLIBCONN hEventsConnection; - HANDLE connection_lock_; - HANDLE chatHandle_; - - // Parent handle - OmegleProto* parent; - - // Chat data - std::string chat_id_; - std::string server_; - std::string question_; - ptrW nick_; - - //int msgid_; - - // State of client - int state_; - bool typing_; - bool spy_mode_; - - // Data storage - void store_headers(http::response *resp, NETLIBHTTPHEADER *headers, int headers_count); - - std::string get_server(bool not_last = false); - std::string get_language(); - - // Connection handling - unsigned int error_count_; - - bool handle_entry(const std::string &method); - bool handle_success(const std::string &method); - bool handle_error(const std::string &method, bool force_disconnect = false); - - void __inline increment_error() { error_count_++; } - void __inline decrement_error() { if (error_count_ > 0) error_count_--; } - void __inline reset_error() { error_count_ = 0; } - - bool start(); - bool stop(); - bool events(); - - bool typing_start(); - bool typing_stop(); - bool recaptcha(); - - std::string get_page(int); - - bool send_message(const std::string &message_text); - - // HTTP communication - http::response flap(const int request_type, std::string *post_data = nullptr, std::string *get_data = nullptr); - - std::string choose_server(int); - std::string choose_action(int, std::string *get_data = nullptr); - - NETLIBHTTPHEADER *get_request_headers(int request_type, int *headers_count); - - // Netlib handle - - HNETLIBUSER handle_; - - void set_handle(HNETLIBUSER h) - { - handle_ = h; - } -}; diff --git a/protocols/Omegle/src/communication.cpp b/protocols/Omegle/src/communication.cpp deleted file mode 100644 index 060430a9ec..0000000000 --- a/protocols/Omegle/src/communication.cpp +++ /dev/null @@ -1,737 +0,0 @@ -/* - -Omegle plugin for Miranda Instant Messenger -_____________________________________________ - -Copyright © 2011-17 Robert Pösel, 2017-23 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 . -*/ - -#include "stdafx.h" - -http::response Omegle_client::flap(const int request_type, std::string *post_data, std::string *get_data) -{ - http::response resp; - - // Prepare the request - NETLIBHTTPREQUEST nlhr = { sizeof(NETLIBHTTPREQUEST) }; - - // Set request URL - std::string url = choose_server(request_type) + choose_action(request_type, get_data); - nlhr.szUrl = (char*)url.c_str(); - - // Set timeout (bigger for channel request) - nlhr.timeout = 1000 * ((request_type == OMEGLE_REQUEST_EVENTS) ? 65 : 20); - - // Set request type (GET/POST) and eventually also POST data - if (post_data != nullptr) { - nlhr.requestType = REQUEST_POST; - nlhr.pData = (char*)(*post_data).c_str(); - nlhr.dataLength = (int)post_data->length(); - } - else { - nlhr.requestType = REQUEST_GET; - } - - // Set headers - it depends on requestType so it must be after setting that - nlhr.headers = get_request_headers(nlhr.requestType, &nlhr.headersCount); - - // Set flags - nlhr.flags = NLHRF_HTTP11; - -#ifdef _DEBUG - nlhr.flags |= NLHRF_DUMPASTEXT; -#else - nlhr.flags |= NLHRF_NODUMP; -#endif - - // Set persistent connection (or not) - switch (request_type) - { - case OMEGLE_REQUEST_HOME: - nlhr.nlc = nullptr; - break; - - case OMEGLE_REQUEST_EVENTS: - nlhr.nlc = hEventsConnection; - nlhr.flags |= NLHRF_PERSISTENT; - break; - - default: - WaitForSingleObject(connection_lock_, INFINITE); - nlhr.nlc = hConnection; - nlhr.flags |= NLHRF_PERSISTENT; - break; - } - - parent->debugLogA("@@@@@ Sending request to '%s'", nlhr.szUrl); - - // Send the request - NLHR_PTR pnlhr(Netlib_HttpTransaction(handle_, &nlhr)); - - mir_free(nlhr.headers); - - // Remember the persistent connection handle (or not) - switch (request_type) - { - case OMEGLE_REQUEST_HOME: - break; - - case OMEGLE_REQUEST_EVENTS: - hEventsConnection = pnlhr ? pnlhr->nlc : nullptr; - break; - - default: - ReleaseMutex(connection_lock_); - hConnection = pnlhr ? pnlhr->nlc : nullptr; - break; - } - - // Check and copy response data - if (pnlhr != nullptr) - { - parent->debugLogA("@@@@@ Got response with code %d", pnlhr->resultCode); - store_headers(&resp, pnlhr->headers, pnlhr->headersCount); - resp.code = pnlhr->resultCode; - resp.data = pnlhr->pData ? pnlhr->pData : ""; - - // This error code gives us some error page, but we don't need that, so clear the response - if (pnlhr->resultCode == HTTP_CODE_WEB_SERVER_IS_DOWN) { - resp.data = ""; - } - - parent->debugLogA("&&&&& Got response: %s", resp.data.c_str()); - } - else { - parent->debugLogA("!!!!! No response from server (time-out)"); - resp.code = HTTP_CODE_FAKE_DISCONNECTED; - // Better to have something set explicitely as this value is compaired in all communication requests - } - - return resp; -} - -bool Omegle_client::handle_entry(const std::string &method) -{ - parent->debugLogA(" >> Entering %s()", method.c_str()); - return true; -} - -bool Omegle_client::handle_success(const std::string &method) -{ - parent->debugLogA(" << Quitting %s()", method.c_str()); - reset_error(); - return true; -} - -bool Omegle_client::handle_error(const std::string &method, bool force_disconnect) -{ - bool result; - increment_error(); - parent->debugLogA("!!!!! %s(): Something with Omegle went wrong", method.c_str()); - - if (force_disconnect) - result = false; - else if (error_count_ <= (UINT)db_get_b(0, parent->m_szModuleName, OMEGLE_KEY_TIMEOUTS_LIMIT, OMEGLE_TIMEOUTS_LIMIT)) - result = true; - else - result = false; - - if (result == false) - { - reset_error(); - parent->UpdateChat(nullptr, TranslateT("Connection error.")); - parent->StopChat(false); - } - - return result; -} - -////////////////////////////////////////////////////////////////////////////// - -std::string Omegle_client::choose_server(int request_type) -{ - switch (request_type) - { - case OMEGLE_REQUEST_HOME: - return OMEGLE_SERVER_REGULAR; - - /* case OMEGLE_REQUEST_START: - case OMEGLE_REQUEST_STOP: - case OMEGLE_REQUEST_SEND: - case OMEGLE_REQUEST_EVENTS: - case OMEGLE_REQUEST_TYPING_START: - case OMEGLE_REQUEST_TYPING_STOP: - case OMEGLE_REQUEST_RECAPTCHA: - case OMEGLE_REQUEST_COUNT: - */ default: - std::string server = OMEGLE_SERVER_CHAT; - utils::text::replace_first(&server, "%s", this->server_); - return server; - } -} - -std::string Omegle_client::choose_action(int request_type, std::string* get_data) -{ - switch (request_type) - { - case OMEGLE_REQUEST_START: - { - std::string action = "/start?caps=recaptcha2,t&rcs=1&spid=&lang="; - action += get_language(); - if (get_data != nullptr) - action += (*get_data); - - return action; - } - - case OMEGLE_REQUEST_STOP: - return "/disconnect"; - - case OMEGLE_REQUEST_SEND: - return "/send"; - - case OMEGLE_REQUEST_EVENTS: - return "/events"; - - case OMEGLE_REQUEST_TYPING_START: - return "/typing"; - - case OMEGLE_REQUEST_TYPING_STOP: - return "/stoppedtyping"; - - case OMEGLE_REQUEST_RECAPTCHA: - return "/recaptcha"; - - case OMEGLE_REQUEST_COUNT: - return "/count"; - - // "/stoplookingforcommonlikes" - - /* case OMEGLE_REQUEST_HOME: - */ default: - return "/"; - } -} - - -NETLIBHTTPHEADER* Omegle_client::get_request_headers(int request_type, int* headers_count) -{ - if (request_type == REQUEST_POST) - *headers_count = 4; - else - *headers_count = 3; - - NETLIBHTTPHEADER *headers = (NETLIBHTTPHEADER*)mir_calloc(sizeof(NETLIBHTTPHEADER)*(*headers_count)); - - if (request_type == REQUEST_POST) { - headers[3].szName = "Content-Type"; - headers[3].szValue = "application/x-www-form-urlencoded; charset=utf-8"; - } - - headers[2].szName = "User-Agent"; - headers[2].szValue = Netlib_GetUserAgent(); - headers[1].szName = "Accept"; - headers[1].szValue = "*/*"; - headers[0].szName = "Accept-Language"; - headers[0].szValue = "en,en-US;q=0.9"; - - return headers; -} - -void Omegle_client::store_headers(http::response* resp, NETLIBHTTPHEADER* headers, int headersCount) -{ - for (size_t i = 0; i < (size_t)headersCount; i++) - { - std::string header_name = headers[i].szName; - std::string header_value = headers[i].szValue; - - // TODO RM: (un)comment - //parent->debugLogA("----- Got header '%s': %s", header_name.c_str(), header_value.c_str()); - resp->headers[header_name] = header_value; - } -} - -////////////////////////////////////////////////////////////////////////////// - -bool Omegle_client::start() -{ - HANDLE_ENTRY; - - this->server_ = get_server(); - //parent->debugLogA("Chosing server %s", this->server_.c_str()); - //std::string log = Translate("Chosing server: ") + this->server_; - //parent->UpdateChat(NULL, log.c_str()); - - std::string data; - - if (this->spy_mode_) { - //// get last server from list, which is for spy mode - //this->server_ = servers[_countof(servers)-1]; - - if (this->question_.empty()) { - data = "&wantsspy=1"; - } - else { - data = "&ask=" + utils::url::encode(this->question_); - data += "&cansavequestion="; - data += db_get_b(0, parent->m_szModuleName, OMEGLE_KEY_REUSE_QUESTION, 0) ? "1" : "0"; - } - } - else if (db_get_b(0, parent->m_szModuleName, OMEGLE_KEY_MEET_COMMON, 0)) - { - DBVARIANT dbv; - if (!db_get_utf(NULL, parent->m_szModuleName, OMEGLE_KEY_INTERESTS, &dbv)) - { - std::string topics = dbv.pszVal; - std::string topic; - - db_free(&dbv); - - std::string::size_type pos = 0; - std::string::size_type pos2 = 0; - while ((pos2 = topics.find(",", pos)) != std::string::npos) { - topic = topics.substr(pos, pos2 - pos); - topic = utils::text::trim(topic); - - if (!topic.empty()) { - if (pos > 0) - data += ","; - - data += "\"" + topic + "\""; - } - - pos = pos2 + 1; - } - - topic = topics.substr(pos); - topic = utils::text::trim(topic); - if (!topic.empty()) { - if (pos > 0) - data += ","; - data += "\"" + topic + "\""; - } - - parent->debugLogA("TOPICS: %s", data.c_str()); - - if (!data.empty()) { - data = "[" + data + "]"; - data = "&topics=" + utils::url::encode(data); - } - - //// get any server but last, which is for spy mode - //this->server_ = get_server(true); - } - } - - if (db_get_b(0, parent->m_szModuleName, OMEGLE_KEY_SERVER_INFO, 0)) - { - std::string count = get_page(OMEGLE_REQUEST_COUNT); - if (!count.empty()) { - char str[255]; - mir_snprintf(str, Translate("Connected to server %s. There are %s users online now."), server_.c_str(), count.c_str()); - - wchar_t *msg = mir_a2u(str); - parent->UpdateChat(nullptr, msg); - mir_free(msg); - } - } - else { - char str[255]; - mir_snprintf(str, Translate("Connected to server %s."), server_.c_str()); - - wchar_t *msg = mir_a2u(str); - parent->UpdateChat(nullptr, msg); - mir_free(msg); - } - - // Send validation - http::response resp = flap(OMEGLE_REQUEST_START, nullptr, &data); - - switch (resp.code) - { - case HTTP_CODE_FAKE_DISCONNECTED: - { - // If is is only timeout error, try login once more - if (HANDLE_ERROR(false)) - return start(); - else - return false; - } - - case HTTP_CODE_OK: - { - if (!resp.data.empty()) { - this->chat_id_ = resp.data.substr(1, resp.data.length() - 2); - this->state_ = STATE_WAITING; - - return HANDLE_SUCCESS; - } - else { - return HANDLE_ERROR(FORCE_DISCONNECT); - } - } - - default: - return HANDLE_ERROR(FORCE_DISCONNECT); - } -} - -bool Omegle_client::stop() -{ - if (parent->isOffline()) - return true; - - HANDLE_ENTRY; - - std::string data = "id=" + this->chat_id_; - - http::response resp = flap(OMEGLE_REQUEST_STOP, &data); - - Netlib_Shutdown(hConnection); - Netlib_Shutdown(hEventsConnection); - - return (resp.data == "win") ? HANDLE_SUCCESS : HANDLE_ERROR(false); -} - -bool Omegle_client::events() -{ - HANDLE_ENTRY; - - std::string post_data = "id=" + this->chat_id_; - - // Get update - http::response resp = flap(OMEGLE_REQUEST_EVENTS, &post_data); - - // Return - switch (resp.code) - { - case HTTP_CODE_OK: - { - if (resp.data == "null") { - // Everything is OK, no new message received -- OR it is a problem - // TODO: if we are waiting for Stranger with common likes, then we should try standard Stranger if this takes too long - return HANDLE_ERROR(false); - } - else if (resp.data == "fail") { - // Something went wrong - return HANDLE_ERROR(false); - } - - JSONROOT root(resp.data.c_str()); - if (root == nullptr) - return HANDLE_ERROR(false); - - bool newStranger = false; - bool waiting = false; - - for (size_t i = 0; i < json_size(root); i++) { - JSONNode *item = json_at(root, i); - if (item == nullptr) - continue; - - std::string name = _T2A(json_as_string(json_at(item, 0))); - - if (name == "waiting") { - // We are just waiting for new Stranger - waiting = true; - } - else if (name == "identDigests") { - // We get some comma separated hashes, I'm not sure what for - } - else if (name == "statusInfo") { - JSONNode *data = json_at(item, 1); - - // We got some object as second parameter - //data["antinudepercent"]; // probably 1 by default - //data["antinudeservers"]; // array of server names, like "waw3.omegle.com" - //data["rtmfp"]; // some rtmfp protocol address - //data["servers"]; // array of server names, like "front5.omegle.com" - //data["spyeeQueueTime"]; // some float number, e.g. 0.0701999903 - //data["spyQueueTime"]; // some float number, e.g. 4.7505000114 - //data["timestamp"]; // e.g. 1445336566.0196209 - - // We got info about count of connected people there - ptrW count(json_as_string(json_get(data, "count"))); - wchar_t strT[255]; - mir_snwprintf(strT, TranslateT("On whole Omegle are %s strangers online now."), count.get()); - - parent->UpdateChat(nullptr, strT); - } - else if (name == "serverMessage") { - ptrW message(json_as_string(json_at(item, 1))); - parent->UpdateChat(nullptr, TranslateW(message)); - } - else if (name == "connected") { - // Stranger connected - if (this->spy_mode_ && !this->question_.empty()) { - parent->AddChatContact(TranslateT("Stranger 1")); - parent->AddChatContact(TranslateT("Stranger 2")); - this->state_ = STATE_SPY; - } - else { - parent->AddChatContact(TranslateT("Stranger")); - this->state_ = STATE_ACTIVE; - } - - newStranger = true; - waiting = false; - } - else if (name == "commonLikes") { - std::wstring likes = TranslateT("You and the Stranger both like: "); - - JSONNode *items = json_at(item, 1); - size_t size = json_size(items); - for (size_t j = 0; j < size; j++) { - likes += ptrW(json_as_string(json_at(items, j))); - if (j < size - 1) - likes += L", "; - } - - parent->debugLogW(L"Got common likes: '%s'", likes.c_str()); - parent->SetTopic(likes.c_str()); - } - else if (name == "question") { - ptrW question(json_as_string(json_at(item, 1))); - parent->SetTopic(question); - } - else if (name == "typing" || name == "spyTyping") { - // Stranger is typing, not supported by chat module yet - Skin_PlaySound("StrangerTyp"); - - ptrW who(name == "spyTyping" ? json_as_string(json_at(item, 1)) : mir_wstrdup(L"Stranger")); - Srmm_SetStatusText(parent->GetChatHandle(), CMStringW(FORMAT, TranslateT("%s is typing."), TranslateW(who)), g_plugin.getIcon(IDI_TYPING_ON)); - } - else if (name == "stoppedTyping" || name == "spyStoppedTyping") { - // Stranger stopped typing, not supported by chat module yet - Skin_PlaySound("StrangerTypStop"); - - ptrW who(name == "spyTyping" ? json_as_string(json_at(item, 1)) : mir_wstrdup(L"Stranger")); - Srmm_SetStatusText(parent->GetChatHandle(), CMStringW(FORMAT, TranslateT("%s stopped typing."), TranslateW(who)), g_plugin.getIcon(IDI_TYPING_OFF)); - } - else if (name == "gotMessage") { - Srmm_SetStatusText(parent->GetChatHandle(), nullptr); - - // Play sound as we received message - Skin_PlaySound("StrangerMessage"); - - if (state_ == STATE_ACTIVE) { - ptrW msg(json_as_string(json_at(item, 1))); - parent->UpdateChat(TranslateT("Stranger"), msg); - } - } - else if (name == "spyMessage") { - Srmm_SetStatusText(parent->GetChatHandle(), nullptr); - - // Play sound as we received message - Skin_PlaySound("StrangerMessage"); - - if (state_ == STATE_SPY) { - ptrW stranger(json_as_string(json_at(item, 1))); - ptrW msg(json_as_string(json_at(item, 2))); - parent->UpdateChat(stranger, msg); - } - } - else if (name == "strangerDisconnected") { - Srmm_SetStatusText(parent->GetChatHandle(), nullptr); - - // Stranger disconnected - if (db_get_b(0, parent->m_szModuleName, OMEGLE_KEY_DONT_STOP, 0)) - { - Skin_PlaySound("StrangerChange"); - parent->NewChat(); - } - else - parent->StopChat(false); - } - else if (name == "spyDisconnected") { - Srmm_SetStatusText(parent->GetChatHandle(), nullptr); - - ptrW stranger(json_as_string(json_at(item, 1))); - - wchar_t strT[255]; - mir_snwprintf(strT, TranslateT("%s disconnected."), TranslateW(stranger)); - parent->UpdateChat(nullptr, strT); - - // Stranger disconnected - if (db_get_b(0, parent->m_szModuleName, OMEGLE_KEY_DONT_STOP, 0)) - { - Skin_PlaySound("StrangerChange"); - parent->NewChat(); - } - else - parent->StopChat(false); - } - else if (name == "recaptchaRequired") { - // Nothing to do with recaptcha - parent->UpdateChat(nullptr, TranslateT("Recaptcha is required.\nOpen http://omegle.com , solve Recaptcha and try again.")); - parent->StopChat(false); - } - else if (name == "recaptchaRejected") { - // Nothing to do with recaptcha - parent->StopChat(false); - } - else if (name == "error") { - ptrW error(json_as_string(json_at(item, 1))); - - wchar_t strT[255]; - mir_snwprintf(strT, TranslateT("Error: %s"), TranslateW(error)); - parent->UpdateChat(nullptr, strT); - } - } - - if (newStranger && !spy_mode_) { - // We got new stranger in this event, lets say him "Hi message" if enabled - if (db_get_b(0, parent->m_szModuleName, OMEGLE_KEY_HI_ENABLED, 0)) { - DBVARIANT dbv; - if (!db_get_utf(NULL, parent->m_szModuleName, OMEGLE_KEY_HI, &dbv)) { - std::vector messages; - utils::text::explode(std::string(dbv.pszVal), "\r\n", &messages); - db_free(&dbv); - - int pos = rand() % messages.size(); - std::string *message = new std::string(messages.at(pos)); - - parent->debugLogA("**Chat - saying Hi! message"); - parent->ForkThread(&OmegleProto::SendMsgWorker, message); - } - else parent->debugLogA("**Chat - Hi message is enabled but not used"); - } - } - - if (waiting) { - // If we are only waiting in this event... - parent->UpdateChat(nullptr, TranslateT("We are still waiting...")); - } - - return HANDLE_SUCCESS; - } - - case HTTP_CODE_FAKE_DISCONNECTED: - // timeout - return HANDLE_SUCCESS; - - default: - return HANDLE_ERROR(false); - } -} - -bool Omegle_client::send_message(const std::string &message_text) -{ - HANDLE_ENTRY; - - std::string data = "msg=" + utils::url::encode(message_text); - data += "&id=" + this->chat_id_; - - http::response resp = flap(OMEGLE_REQUEST_SEND, &data); - - switch (resp.code) - { - case HTTP_CODE_OK: - if (resp.data == "win") { - return HANDLE_SUCCESS; - } - - case HTTP_CODE_FAKE_DISCONNECTED: - default: - return HANDLE_ERROR(false); - } -} - -bool Omegle_client::typing_start() -{ - HANDLE_ENTRY; - - std::string data = "id=" + this->chat_id_; - - http::response resp = flap(OMEGLE_REQUEST_TYPING_START, &data); - - switch (resp.code) - { - case HTTP_CODE_OK: - if (resp.data == "win") { - return HANDLE_SUCCESS; - } - - case HTTP_CODE_FAKE_DISCONNECTED: - default: - return HANDLE_ERROR(false); - } -} - -bool Omegle_client::typing_stop() -{ - HANDLE_ENTRY; - - std::string data = "id=" + this->chat_id_; - - http::response resp = flap(OMEGLE_REQUEST_TYPING_STOP, &data); - - switch (resp.code) - { - case HTTP_CODE_OK: - if (resp.data == "win") { - return HANDLE_SUCCESS; - } - - case HTTP_CODE_FAKE_DISCONNECTED: - default: - return HANDLE_ERROR(false); - } -} - -bool Omegle_client::recaptcha() -{ - // TODO: Implement! - - HANDLE_ENTRY; - - // data:{id:this.clientID,challenge:b,response:a}} - //std::string data = "?id=...&challenge= ..., &response= ..."; - - http::response resp = flap(OMEGLE_REQUEST_RECAPTCHA); - - switch (resp.code) - { - case HTTP_CODE_OK: - /* if (resp.data == "win") { - return handle_success( "typing_start" ); - }*/ - - case HTTP_CODE_FAKE_DISCONNECTED: - default: - return HANDLE_ERROR(false); - } -} - -std::string Omegle_client::get_page(const int request_type) -{ - HANDLE_ENTRY; - - http::response resp = flap(request_type); - - switch (resp.code) - { - case HTTP_CODE_OK: - HANDLE_SUCCESS; - break; - - case HTTP_CODE_FAKE_DISCONNECTED: - default: - HANDLE_ERROR(false); - } - - return resp.data; -} diff --git a/protocols/Omegle/src/connection.cpp b/protocols/Omegle/src/connection.cpp deleted file mode 100644 index f0f40221f1..0000000000 --- a/protocols/Omegle/src/connection.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/* - -Omegle plugin for Miranda Instant Messenger -_____________________________________________ - -Copyright © 2011-17 Robert Pösel, 2017-23 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 . - -*/ - -#include "stdafx.h" - -// Known server messages, only to inform lpgen -const char *server_messages[] = { - LPGEN("Stranger is using Omegle's mobile Web site (omegle.com on a phone or tablet)"), - LPGEN("You both speak the same language.") -}; - -void OmegleProto::SignOn(void*) -{ - SYSTEMTIME t; - GetLocalTime(&t); - debugLogA("[%d.%d.%d] Using Omegle Protocol %s", t.wDay, t.wMonth, t.wYear, __VERSION_STRING_DOTS); - - ScopedLock s(signon_lock_); - - int old_status = m_iStatus; - m_iStatus = m_iDesiredStatus; - ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus); - - setDword("LogonTS", (uint32_t)time(0)); - ClearChat(); - OnJoinChat(0, false); - - if (getByte(OMEGLE_KEY_AUTO_CONNECT, 0)) - NewChat(); -} - -void OmegleProto::SignOff(void*) -{ - ScopedLock s(signon_lock_); - - int old_status = m_iStatus; - m_iStatus = ID_STATUS_OFFLINE; - - Netlib_Shutdown(facy.hEventsConnection); - - OnLeaveChat(NULL, NULL); - - delSetting("LogonTS"); - - ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus); -} - -void OmegleProto::StopChat(bool disconnect) -{ - if (facy.state_ == STATE_WAITING) - UpdateChat(nullptr, TranslateT("Connecting canceled."), false); - - else if (facy.state_ == STATE_ACTIVE || facy.state_ == STATE_SPY) { - bool spy = facy.state_ == STATE_SPY; - - if (disconnect) { - facy.state_ = STATE_DISCONNECTING; - UpdateChat(nullptr, TranslateT("Disconnecting..."), true); - - if (facy.stop()) - debugLogA("***** Disconnected from stranger %s", facy.chat_id_.c_str()); - else - debugLogA("***** Error in disconnecting from stranger %s", facy.chat_id_.c_str()); - } - - if (spy) { - DeleteChatContact(TranslateT("Stranger 1")); - DeleteChatContact(TranslateT("Stranger 2")); - } - else DeleteChatContact(TranslateT("Stranger")); - - SetTopic(); // reset topic content - - Srmm_SetStatusText(GetChatHandle(), nullptr); - } - else return; // disconnecting or inactive - - facy.state_ = STATE_INACTIVE; - facy.chat_id_.clear(); -} - -void OmegleProto::NewChat() -{ - if (facy.state_ == STATE_WAITING) { - UpdateChat(nullptr, TranslateT("We are already waiting for new stranger..."), false); - return; - } - - if (facy.state_ == STATE_ACTIVE || facy.state_ == STATE_SPY) { - UpdateChat(nullptr, TranslateT("Disconnecting..."), true); - - if (facy.stop()) - debugLogA("***** Disconnected from stranger %s", facy.chat_id_.c_str()); - else - debugLogA("***** Error in disconnecting from stranger %s", facy.chat_id_.c_str()); - - if (facy.state_ == STATE_SPY) { - DeleteChatContact(TranslateT("Stranger 1")); - DeleteChatContact(TranslateT("Stranger 2")); - } - else { - DeleteChatContact(TranslateT("Stranger")); - } - - SetTopic(); // reset topic content - - ClearChat(); - - UpdateChat(nullptr, TranslateT("Connecting..."), true); - - facy.state_ = STATE_WAITING; - - if (facy.start()) { - UpdateChat(nullptr, TranslateT("Waiting for Stranger..."), true); - debugLogA("***** Waiting for stranger %s", facy.chat_id_.c_str()); - } - } - else if (facy.state_ == STATE_DISCONNECTING) { - //UpdateChat(NULL, TranslateT("We are disconnecting now, wait..."), false); - return; - } - else { - ClearChat(); - UpdateChat(nullptr, TranslateT("Connecting..."), true); - - facy.state_ = STATE_WAITING; - - if (facy.start()) { - UpdateChat(nullptr, TranslateT("Waiting for Stranger..."), true); - debugLogA("***** Waiting for stranger %s", facy.chat_id_.c_str()); - - ForkThread(&OmegleProto::EventsLoop, this); - } - } -} - -void OmegleProto::EventsLoop(void *) -{ - ScopedLock s(events_loop_lock_); - - time_t tim = ::time(0); - debugLogA(">>>>> Entering Omegle::EventsLoop[%d]", tim); - - while (facy.events()) { - if (facy.state_ == STATE_INACTIVE || facy.state_ == STATE_DISCONNECTING || !isOnline()) - break; - debugLogA("***** OmegleProto::EventsLoop[%d] refreshing...", tim); - } - - ResetEvent(events_loop_lock_); - - Netlib_CloseHandle(facy.hConnection); - facy.hConnection = nullptr; - - Netlib_CloseHandle(facy.hEventsConnection); - facy.hEventsConnection = nullptr; - - debugLogA("<<<<< Exiting OmegleProto::EventsLoop[%d]", tim); -} diff --git a/protocols/Omegle/src/constants.h b/protocols/Omegle/src/constants.h deleted file mode 100644 index 960a07e980..0000000000 --- a/protocols/Omegle/src/constants.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - -Omegle plugin for Miranda Instant Messenger -_____________________________________________ - -Copyright © 2011-17 Robert Pösel, 2017-23 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 . - -*/ - -#pragma once - -// Product management -#define OMEGLE_NAME "Omegle" -#define OMEGLE_SERVER_REGULAR "https://www.omegle.com" -#define OMEGLE_SERVER_CHAT "https://%s.omegle.com" - -// Limits -#define OMEGLE_TIMEOUTS_LIMIT 6 -// There is "no limit" on Omegle, but we should set some wise limit -#define OMEGLE_MESSAGE_LIMIT 4096 -#define OMEGLE_MESSAGE_LIMIT_TEXT "4096" - -#define OMEGLE_QUESTION_MIN_LENGTH 10 - -// Omegle request types -#define OMEGLE_REQUEST_HOME 100 // getting server name -#define OMEGLE_REQUEST_COUNT 105 // get count of connected users -#define OMEGLE_REQUEST_START 110 // starting conversation -#define OMEGLE_REQUEST_STOP 120 // ending conversation -#define OMEGLE_REQUEST_SEND 300 // sending message -#define OMEGLE_REQUEST_EVENTS 301 // receiving events -#define OMEGLE_REQUEST_TYPING_START 310 // started typing -#define OMEGLE_REQUEST_TYPING_STOP 311 // stoped typing -#define OMEGLE_REQUEST_RECAPTCHA 400 // recaptcha handling diff --git a/protocols/Omegle/src/db.h b/protocols/Omegle/src/db.h deleted file mode 100644 index 45d3478828..0000000000 --- a/protocols/Omegle/src/db.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - -Omegle plugin for Miranda Instant Messenger -_____________________________________________ - -Copyright © 2011-17 Robert Pösel, 2017-23 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 . - -*/ - -#pragma once - -// DB macros -#define getU8String( setting, dest ) db_get_utf( NULL, m_szModuleName, setting, dest ) -#define setU8String( setting, value ) db_set_utf( NULL, m_szModuleName, setting, value ) - -// DB settings -#define OMEGLE_KEY_TIMEOUTS_LIMIT "TimeoutsLimit" // [HIDDEN] - -#define OMEGLE_KEY_ASL "MessageAsl" -#define OMEGLE_KEY_HI "MessageHi" -#define OMEGLE_KEY_HI_ENABLED "MessageHiEnabled" -#define OMEGLE_KEY_NAME "Nick" -#define OMEGLE_KEY_DONT_STOP "DontStop" -#define OMEGLE_KEY_NO_CLEAR "NoClear" -#define OMEGLE_KEY_MEET_COMMON "MeetCommon" -#define OMEGLE_KEY_INTERESTS "Interests" -#define OMEGLE_KEY_REUSE_QUESTION "ReuseQuestion" -#define OMEGLE_KEY_SERVER "Server" -#define OMEGLE_KEY_LANGUAGE "Language" -#define OMEGLE_KEY_SERVER_INFO "GetServerInfo" -#define OMEGLE_KEY_LAST_QUESTION "LastQuestion" -#define OMEGLE_KEY_AUTO_CONNECT "AutoConnect" diff --git a/protocols/Omegle/src/dialogs.cpp b/protocols/Omegle/src/dialogs.cpp deleted file mode 100644 index 82708bf836..0000000000 --- a/protocols/Omegle/src/dialogs.cpp +++ /dev/null @@ -1,335 +0,0 @@ -/* - -Omegle plugin for Miranda Instant Messenger -_____________________________________________ - -Copyright © 2011-17 Robert Pösel, 2017-23 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 . - -*/ - -#include "stdafx.h" - -struct -{ - const char *id; - const wchar_t *lang; -} -static languages[] = { - { "en", LPGENW("English") }, - { "af", LPGENW("Afrikaans") }, - { "sq", LPGENW("Albanian") }, - { "ar", LPGENW("Arabic") }, - { "hy", LPGENW("Armenian") }, - { "az", LPGENW("Azerbaijani") }, - { "eu", LPGENW("Basque") }, - { "be", LPGENW("Belarusian") }, - { "bn", LPGENW("Bengali") }, - { "bs", LPGENW("Bosnian") }, - { "bg", LPGENW("Bulgarian") }, - { "ceb", LPGENW("Cebuano") }, - { "cs", LPGENW("Czech") }, - { "zh-CN", LPGENW("Chinese (simplified)") }, - { "zh-TW", LPGENW("Chinese (traditional)") }, - { "da", LPGENW("Danish") }, - { "eo", LPGENW("Esperanto") }, - { "et", LPGENW("Estonian") }, - { "tl", LPGENW("Filipino") }, - { "fi", LPGENW("Finnish") }, - { "fr", LPGENW("French") }, - { "gl", LPGENW("Galician") }, - { "ka", LPGENW("Georgian") }, - { "gu", LPGENW("Gujarati") }, - { "ht", LPGENW("Haitian Creole") }, - { "iw", LPGENW("Hebrew") }, - { "hi", LPGENW("Hindi") }, - { "hmn", LPGENW("Hmong") }, - { "nl", LPGENW("Dutch") }, - { "hr", LPGENW("Croat") }, - { "id", LPGENW("Indonesian") }, - { "ga", LPGENW("Irish") }, - { "is", LPGENW("Icelandic") }, - { "it", LPGENW("Italian") }, - { "ja", LPGENW("Japanese") }, - { "jw", LPGENW("Javanese") }, - { "yi", LPGENW("Yiddish") }, - { "kn", LPGENW("Kannada") }, - { "ca", LPGENW("Catalan") }, - { "km", LPGENW("Khmer") }, - { "ko", LPGENW("Korean") }, - { "lo", LPGENW("Lao") }, - { "la", LPGENW("Latina") }, - { "lt", LPGENW("Lithuanian") }, - { "lv", LPGENW("Latvian") }, - { "hu", LPGENW("Hungarian") }, - { "mk", LPGENW("Macedonian") }, - { "ms", LPGENW("Malay") }, - { "mt", LPGENW("Maltese") }, - { "mr", LPGENW("Marathi") }, - { "de", LPGENW("German") }, - { "no", LPGENW("Norwegian") }, - { "fa", LPGENW("Persian") }, - { "pl", LPGENW("Polish") }, - { "pt", LPGENW("Portuguese") }, - { "ro", LPGENW("Romanian") }, - { "ru", LPGENW("Russian") }, - { "el", LPGENW("Greek") }, - { "sk", LPGENW("Slovak") }, - { "sl", LPGENW("Slovenian") }, - { "sr", LPGENW("Serbian") }, - { "sw", LPGENW("Swahili") }, - { "es", LPGENW("Spanish") }, - { "sv", LPGENW("Swedish") }, - { "ta", LPGENW("Tamil") }, - { "te", LPGENW("Telugu") }, - { "th", LPGENW("Thai") }, - { "tr", LPGENW("Turkish") }, - { "uk", LPGENW("Ukrainian") }, - { "ur", LPGENW("Urdu") }, - { "cy", LPGENW("Welsh") }, - { "vi", LPGENW("Vietnamese") } -}; - -std::string Omegle_client::get_language() -{ - int language = db_get_b(0, parent->m_szModuleName, OMEGLE_KEY_LANGUAGE, 0); - if (language < 0 || language >= (_countof(languages))) - language = 0; - - return language > 0 ? languages[language].id : "en"; -} - -///////////////////////////////////////////////////////////////////////////////////////// -// Servers list - -static const char *servers[] = { LPGEN("Random"), "front1", "front2", "front3", "front4", "front5", "front6", "front7", "front8", "front9", "front10", "front11", "front12", "front13", "front14", "front15", "front16", "front17", "front18", "front19", "front20", "front21", "front22", "front23", "front24", "front25", "front26", "front27", "front28", "front29", "front30", "front31", "front32" }; - -std::string Omegle_client::get_server(bool not_last) -{ - int q = not_last ? 1 : 0; - - int server = db_get_b(0, parent->m_szModuleName, OMEGLE_KEY_SERVER, 0); - if (server < 0 || server >= (int)(_countof(servers) - q)) - server = 0; - - if (server == 0) { - srand(::time(0)); - server = (rand() % (_countof(servers) - 1 - q)) + 1; - } - - return servers[server]; -} - -///////////////////////////////////////////////////////////////////////////////////////// -// Options - -static BOOL LoadDBCheckState(OmegleProto* ppro, HWND hwnd, int idCtrl, const char* szSetting, uint8_t bDef = 0) -{ - BOOL state = db_get_b(0, ppro->m_szModuleName, szSetting, bDef); - CheckDlgButton(hwnd, idCtrl, state ? BST_CHECKED : BST_UNCHECKED); - return state; -} - -static BOOL StoreDBCheckState(OmegleProto* ppro, HWND hwnd, int idCtrl, const char* szSetting) -{ - BOOL state = IsDlgButtonChecked(hwnd, idCtrl); - db_set_b(0, ppro->m_szModuleName, szSetting, (uint8_t)state); - return state; -} - -static void LoadDBText(OmegleProto* ppro, HWND hwnd, int idCtrl, const char* szSetting) -{ - ptrW tstr(db_get_wsa(0, ppro->m_szModuleName, szSetting)); - if (tstr) - SetDlgItemText(hwnd, idCtrl, tstr); -} - -static void StoreDBText(OmegleProto* ppro, HWND hwnd, int idCtrl, const char* szSetting) -{ - wchar_t tstr[250 + 1]; - - GetDlgItemText(hwnd, idCtrl, tstr, _countof(tstr)); - if (tstr[0] != '\0') - db_set_ws(0, ppro->m_szModuleName, szSetting, tstr); - else - db_unset(0, ppro->m_szModuleName, szSetting); -} - -INT_PTR CALLBACK OmegleAccountProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) -{ - OmegleProto *proto; - - switch (message) { - case WM_INITDIALOG: - TranslateDialogDefault(hwnd); - - proto = reinterpret_cast(lparam); - SetWindowLongPtr(hwnd, GWLP_USERDATA, lparam); - - SendDlgItemMessage(hwnd, IDC_INTERESTS, EM_LIMITTEXT, 512, 0); - - // Server - SendDlgItemMessageA(hwnd, IDC_SERVER, CB_INSERTSTRING, 0, reinterpret_cast(Translate(servers[0]))); - for (size_t i = 1; i < _countof(servers); i++) - SendDlgItemMessageA(hwnd, IDC_SERVER, CB_INSERTSTRING, i, reinterpret_cast(servers[i])); - SendDlgItemMessage(hwnd, IDC_SERVER, CB_SETCURSEL, db_get_b(0, proto->m_szModuleName, OMEGLE_KEY_SERVER, 0), 0); - - // Language - for (size_t i = 0; i < _countof(languages); i++) - SendDlgItemMessageW(hwnd, IDC_LANGUAGE, CB_INSERTSTRING, i, reinterpret_cast(TranslateW(languages[i].lang))); - SendDlgItemMessage(hwnd, IDC_LANGUAGE, CB_SETCURSEL, db_get_b(0, proto->m_szModuleName, OMEGLE_KEY_LANGUAGE, 0), 0); - - LoadDBText(proto, hwnd, IDC_NAME, OMEGLE_KEY_NAME); - LoadDBText(proto, hwnd, IDC_INTERESTS, OMEGLE_KEY_INTERESTS); - LoadDBCheckState(proto, hwnd, IDC_MEET_COMMON, OMEGLE_KEY_MEET_COMMON); - return TRUE; - - case WM_COMMAND: - switch (LOWORD(wparam)) { - case IDC_LANGUAGE: - case IDC_SERVER: - if (HIWORD(wparam) == CBN_SELCHANGE) - SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); - break; - - case IDC_NAME: - case IDC_INTERESTS: - if (HIWORD(wparam) != EN_CHANGE || (HWND)lparam != GetFocus()) - return TRUE; - - SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); - break; - - case IDC_MEET_COMMON: - if (HIWORD(wparam) == BN_CLICKED) - SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); - break; - } - break; - - case WM_NOTIFY: - if (reinterpret_cast(lparam)->code == PSN_APPLY) { - proto = reinterpret_cast(GetWindowLongPtr(hwnd, GWLP_USERDATA)); - - db_set_b(0, proto->m_szModuleName, OMEGLE_KEY_SERVER, SendDlgItemMessage(hwnd, IDC_SERVER, CB_GETCURSEL, 0, 0)); - db_set_b(0, proto->m_szModuleName, OMEGLE_KEY_LANGUAGE, SendDlgItemMessage(hwnd, IDC_LANGUAGE, CB_GETCURSEL, 0, 0)); - - StoreDBText(proto, hwnd, IDC_NAME, OMEGLE_KEY_NAME); - StoreDBText(proto, hwnd, IDC_INTERESTS, OMEGLE_KEY_INTERESTS); - StoreDBCheckState(proto, hwnd, IDC_MEET_COMMON, OMEGLE_KEY_MEET_COMMON); - return TRUE; - } - break; - } - return FALSE; -} - -INT_PTR CALLBACK OmegleOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) -{ - OmegleProto *proto = reinterpret_cast(GetWindowLongPtr(hwnd, GWLP_USERDATA)); - - switch (message) { - case WM_INITDIALOG: - TranslateDialogDefault(hwnd); - - proto = reinterpret_cast(lparam); - SetWindowLongPtr(hwnd, GWLP_USERDATA, lparam); - - SendDlgItemMessage(hwnd, IDC_INTERESTS, EM_LIMITTEXT, 250, 0); - SendDlgItemMessage(hwnd, IDC_HI_MESSAGE, EM_LIMITTEXT, 250, 0); - SendDlgItemMessage(hwnd, IDC_ASL_MESSAGE, EM_LIMITTEXT, 250, 0); - - // Server - SendDlgItemMessageA(hwnd, IDC_SERVER, CB_INSERTSTRING, 0, reinterpret_cast(Translate(servers[0]))); - for (size_t i = 1; i < _countof(servers); i++) - SendDlgItemMessageA(hwnd, IDC_SERVER, CB_INSERTSTRING, i, reinterpret_cast(servers[i])); - SendDlgItemMessage(hwnd, IDC_SERVER, CB_SETCURSEL, db_get_b(0, proto->m_szModuleName, OMEGLE_KEY_SERVER, 0), 0); - - // Language - for (size_t i = 0; i < _countof(languages); i++) - SendDlgItemMessageW(hwnd, IDC_LANGUAGE, CB_INSERTSTRING, i, reinterpret_cast(TranslateW(languages[i].lang))); - SendDlgItemMessage(hwnd, IDC_LANGUAGE, CB_SETCURSEL, db_get_b(0, proto->m_szModuleName, OMEGLE_KEY_LANGUAGE, 0), 0); - - LoadDBText(proto, hwnd, IDC_NAME, OMEGLE_KEY_NAME); - LoadDBText(proto, hwnd, IDC_INTERESTS, OMEGLE_KEY_INTERESTS); - LoadDBText(proto, hwnd, IDC_HI_MESSAGE, OMEGLE_KEY_HI); - LoadDBText(proto, hwnd, IDC_ASL_MESSAGE, OMEGLE_KEY_ASL); - LoadDBText(proto, hwnd, IDC_LAST_QUESTION, OMEGLE_KEY_LAST_QUESTION); - - LoadDBCheckState(proto, hwnd, IDC_MEET_COMMON, OMEGLE_KEY_MEET_COMMON); - LoadDBCheckState(proto, hwnd, IDC_HI_ENABLED, OMEGLE_KEY_HI_ENABLED); - LoadDBCheckState(proto, hwnd, IDC_NOCLEAR, OMEGLE_KEY_NO_CLEAR); - LoadDBCheckState(proto, hwnd, IDC_DONTSTOP, OMEGLE_KEY_DONT_STOP); - LoadDBCheckState(proto, hwnd, IDC_REUSE_QUESTIONS, OMEGLE_KEY_REUSE_QUESTION); - LoadDBCheckState(proto, hwnd, IDC_SERVER_INFO, OMEGLE_KEY_SERVER_INFO); - LoadDBCheckState(proto, hwnd, IDC_AUTO_CONNECT, OMEGLE_KEY_AUTO_CONNECT); - return TRUE; - - case WM_COMMAND: - switch (LOWORD(wparam)) { - case IDC_SERVER: - case IDC_LANGUAGE: - if (HIWORD(wparam) == CBN_SELCHANGE) - SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); - break; - - case IDC_NAME: - case IDC_INTERESTS: - case IDC_HI_MESSAGE: - case IDC_ASL_MESSAGE: - if (HIWORD(wparam) != EN_CHANGE || (HWND)lparam != GetFocus()) - return TRUE; - - SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); - break; - case IDC_MEET_COMMON: - case IDC_HI_ENABLED: - case IDC_NOCLEAR: - case IDC_DONTSTOP: - case IDC_REUSE_QUESTIONS: - case IDC_SERVER_INFO: - case IDC_AUTO_CONNECT: - if (HIWORD(wparam) == BN_CLICKED) - SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); - break; - } - break; - - case WM_NOTIFY: - if (reinterpret_cast(lparam)->code == PSN_APPLY) { - proto = reinterpret_cast(GetWindowLongPtr(hwnd, GWLP_USERDATA)); - - db_set_b(0, proto->m_szModuleName, OMEGLE_KEY_SERVER, SendDlgItemMessage(hwnd, IDC_SERVER, CB_GETCURSEL, 0, 0)); - db_set_b(0, proto->m_szModuleName, OMEGLE_KEY_LANGUAGE, SendDlgItemMessage(hwnd, IDC_LANGUAGE, CB_GETCURSEL, 0, 0)); - - StoreDBText(proto, hwnd, IDC_NAME, OMEGLE_KEY_NAME); - StoreDBText(proto, hwnd, IDC_INTERESTS, OMEGLE_KEY_INTERESTS); - StoreDBText(proto, hwnd, IDC_HI_MESSAGE, OMEGLE_KEY_HI); - StoreDBText(proto, hwnd, IDC_ASL_MESSAGE, OMEGLE_KEY_ASL); - - StoreDBCheckState(proto, hwnd, IDC_MEET_COMMON, OMEGLE_KEY_MEET_COMMON); - StoreDBCheckState(proto, hwnd, IDC_HI_ENABLED, OMEGLE_KEY_HI_ENABLED); - StoreDBCheckState(proto, hwnd, IDC_NOCLEAR, OMEGLE_KEY_NO_CLEAR); - StoreDBCheckState(proto, hwnd, IDC_DONTSTOP, OMEGLE_KEY_DONT_STOP); - StoreDBCheckState(proto, hwnd, IDC_REUSE_QUESTIONS, OMEGLE_KEY_REUSE_QUESTION); - StoreDBCheckState(proto, hwnd, IDC_SERVER_INFO, OMEGLE_KEY_SERVER_INFO); - StoreDBCheckState(proto, hwnd, IDC_AUTO_CONNECT, OMEGLE_KEY_AUTO_CONNECT); - return TRUE; - } - break; - } - - return FALSE; -} diff --git a/protocols/Omegle/src/dialogs.h b/protocols/Omegle/src/dialogs.h deleted file mode 100644 index 080b36c07a..0000000000 --- a/protocols/Omegle/src/dialogs.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - -Omegle plugin for Miranda Instant Messenger -_____________________________________________ - -Copyright © 2011-17 Robert Pösel, 2017-23 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 . - -*/ - -#pragma once - -INT_PTR CALLBACK OmegleAccountProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); -INT_PTR CALLBACK OmegleOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); diff --git a/protocols/Omegle/src/http.h b/protocols/Omegle/src/http.h deleted file mode 100644 index b107aaf3a0..0000000000 --- a/protocols/Omegle/src/http.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - -Omegle plugin for Miranda Instant Messenger -_____________________________________________ - -Copyright © 2011-17 Robert Pösel, 2017-23 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 . - -*/ - -#pragma once - -#define HTTP_CODE_FAKE_DISCONNECTED 0 - -namespace http -{ - struct response - { - response() : code(0) {} - int code; - std::map< std::string, std::string > headers; - std::string data; - }; -} diff --git a/protocols/Omegle/src/main.cpp b/protocols/Omegle/src/main.cpp deleted file mode 100644 index 72b1edc3cd..0000000000 --- a/protocols/Omegle/src/main.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - -Omegle plugin for Miranda Instant Messenger -_____________________________________________ - -Copyright © 2011-17 Robert Pösel, 2017-23 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 . - -*/ - -#include "stdafx.h" - -// TODO: Make following as "globals" structure? - -CMPlugin g_plugin; - -uint32_t g_mirandaVersion; - -///////////////////////////////////////////////////////////////////////////////////////// - -PLUGININFOEX pluginInfoEx = { - sizeof(PLUGININFOEX), - __PLUGIN_NAME, - PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), - __DESCRIPTION, - __AUTHOR, - __COPYRIGHT, - __AUTHORWEB, - UNICODE_AWARE, - // {9E1D9244-606C-4ef4-99A0-1D7D23CB7601} - { 0x9e1d9244, 0x606c, 0x4ef4, { 0x99, 0xa0, 0x1d, 0x7d, 0x23, 0xcb, 0x76, 0x1 } } -}; - -CMPlugin::CMPlugin() : - ACCPROTOPLUGIN("Omegle", pluginInfoEx) -{ - SetUniqueId("Nick"); -} - -///////////////////////////////////////////////////////////////////////////////////////// -// Interface information - -extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST }; - -///////////////////////////////////////////////////////////////////////////////////////// -// Load - -int CMPlugin::Load() -{ - InitIcons(); - return 0; -} diff --git a/protocols/Omegle/src/messages.cpp b/protocols/Omegle/src/messages.cpp deleted file mode 100644 index fd7a79e4ae..0000000000 --- a/protocols/Omegle/src/messages.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - -Omegle plugin for Miranda Instant Messenger -_____________________________________________ - -Copyright © 2011-17 Robert Pösel, 2017-23 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 . - -*/ - -#include "stdafx.h" - -void OmegleProto::SendMsgWorker(void *p) -{ - if (p == nullptr) - return; - - std::string data = *(std::string*)p; - delete (std::string*)p; - - data = utils::text::trim(data); - - if (facy.state_ == STATE_ACTIVE && data.length() && facy.send_message(data)) { - wchar_t *msg = mir_a2u_cp(data.c_str(), CP_UTF8); - UpdateChat(facy.nick_, msg); - mir_free(msg); - } -} - -void OmegleProto::SendTypingWorker(void *p) -{ - if (p == nullptr) - return; - - // Save typing info - bool typ = (*static_cast(p) == PROTOTYPE_SELFTYPING_ON); - delete (int*)p; - - // Ignore same typing info - if (facy.typing_ == typ) - return; - - if (facy.state_ != STATE_ACTIVE) - return; - - facy.typing_ = typ; - - if (typ) - facy.typing_start(); - else - facy.typing_stop(); -} - -void OmegleProto::NewChatWorker(void*) -{ - NewChat(); -} - -void OmegleProto::StopChatWorker(void*) -{ - StopChat(); -} diff --git a/protocols/Omegle/src/proto.cpp b/protocols/Omegle/src/proto.cpp deleted file mode 100644 index 36b85b01dd..0000000000 --- a/protocols/Omegle/src/proto.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/* - -Omegle plugin for Miranda Instant Messenger -_____________________________________________ - -Copyright © 2011-17 Robert Pösel, 2017-23 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 . - -*/ - -#include "stdafx.h" - -OmegleProto::OmegleProto(const char* proto_name, const wchar_t* username) : - PROTO(proto_name, username) -{ - this->facy.parent = this; - - this->signon_lock_ = CreateMutex(nullptr, FALSE, nullptr); - this->log_lock_ = CreateMutex(nullptr, FALSE, nullptr); - this->facy.connection_lock_ = CreateMutex(nullptr, FALSE, nullptr); - this->events_loop_lock_ = CreateMutex(nullptr, FALSE, nullptr); - - // Group chats - CreateProtoService(PS_JOINCHAT, &OmegleProto::OnJoinChat); - CreateProtoService(PS_LEAVECHAT, &OmegleProto::OnLeaveChat); - - HookProtoEvent(ME_OPT_INITIALISE, &OmegleProto::OnOptionsInit); - HookProtoEvent(ME_GC_EVENT, &OmegleProto::OnChatEvent); - - // Create standard network connection - NETLIBUSER nlu = {}; - nlu.flags = NUF_INCOMING | NUF_OUTGOING | NUF_HTTPCONNS | NUF_UNICODE; - nlu.szSettingsModule = m_szModuleName; - nlu.szDescriptiveName.w = m_tszUserName; - m_hNetlibUser = Netlib_RegisterUser(&nlu); - if (m_hNetlibUser == nullptr) { - wchar_t error[200]; - mir_snwprintf(error, TranslateT("Unable to initialize Netlib for %s."), m_tszUserName); - MessageBox(nullptr, error, L"Miranda NG", MB_OK | MB_ICONERROR); - } - - facy.set_handle(m_hNetlibUser); - - g_plugin.addSound("StrangerTyp", m_tszUserName, LPGENW("Stranger is typing")); - g_plugin.addSound("StrangerTypStop", m_tszUserName, LPGENW("Stranger stopped typing")); - g_plugin.addSound("StrangerChange", m_tszUserName, LPGENW("Changing stranger")); - g_plugin.addSound("StrangerMessage", m_tszUserName, LPGENW("Receive message")); - - // Register group chat - GCREGISTER gcr = {}; - gcr.dwFlags = 0; //GC_TYPNOTIF; //GC_ACKMSG; - gcr.pszModule = m_szModuleName; - gcr.ptszDispName = m_tszUserName; - gcr.iMaxText = OMEGLE_MESSAGE_LIMIT; - Chat_Register(&gcr); -} - -OmegleProto::~OmegleProto() -{ - Netlib_CloseHandle(m_hNetlibUser); - - WaitForSingleObject(this->signon_lock_, IGNORE); - WaitForSingleObject(this->log_lock_, IGNORE); - WaitForSingleObject(this->events_loop_lock_, IGNORE); - - CloseHandle(this->signon_lock_); - CloseHandle(this->log_lock_); - CloseHandle(this->events_loop_lock_); - CloseHandle(this->facy.connection_lock_); -} - -////////////////////////////////////////////////////////////////////////////// - -INT_PTR OmegleProto::GetCaps(int type, MCONTACT) -{ - switch (type) { - case PFLAGNUM_1: - return PF1_CHAT; - case PFLAGNUM_2: - return PF2_ONLINE; - case PFLAGNUM_4: - return PF4_SUPPORTTYPING; - case PFLAG_MAXLENOFMESSAGE: - return OMEGLE_MESSAGE_LIMIT; - case PFLAG_UNIQUEIDTEXT: - return (INT_PTR)TranslateT("Visible name"); - } - return 0; -} - -////////////////////////////////////////////////////////////////////////////// - -int OmegleProto::SetStatus(int new_status) -{ - // Routing statuses not supported by Omegle - switch (new_status) { - case ID_STATUS_OFFLINE: - case ID_STATUS_CONNECTING: - new_status = ID_STATUS_OFFLINE; - break; - default: - new_status = ID_STATUS_ONLINE; - break; - } - - m_iDesiredStatus = new_status; - - if (new_status == m_iStatus) - return 0; - - if (m_iStatus == ID_STATUS_CONNECTING && new_status != ID_STATUS_OFFLINE) - return 0; - - if (new_status == ID_STATUS_OFFLINE) - ForkThread(&OmegleProto::SignOff, this); - else - ForkThread(&OmegleProto::SignOn, this); - - return 0; -} - -////////////////////////////////////////////////////////////////////////////// -// EVENTS - -MWindow OmegleProto::OnCreateAccMgrUI(MWindow hwndParent) -{ - return CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_OmegleACCOUNT), hwndParent, OmegleAccountProc, (LPARAM)this); -} - -void OmegleProto::OnShutdown() -{ - SetStatus(ID_STATUS_OFFLINE); -} - -int OmegleProto::OnOptionsInit(WPARAM wParam, LPARAM) -{ - OPTIONSDIALOGPAGE odp = {}; - odp.szTitle.w = m_tszUserName; - odp.dwInitParam = LPARAM(this); - odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE | ODPF_DONTTRANSLATE; - - odp.position = 271828; - odp.szGroup.w = LPGENW("Network"); - odp.szTab.w = LPGENW("Account"); - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS); - odp.pfnDlgProc = OmegleOptionsProc; - g_plugin.addOptions(wParam, &odp); - return 0; -} - -void OmegleProto::OnContactDeleted(MCONTACT) -{ - OnLeaveChat(NULL, NULL); -} - -int OmegleProto::UserIsTyping(MCONTACT hContact, int type) -{ - if (hContact && facy.state_ == STATE_ACTIVE) - ForkThread(&OmegleProto::SendTypingWorker, new int(type)); - - return 0; -} diff --git a/protocols/Omegle/src/proto.h b/protocols/Omegle/src/proto.h deleted file mode 100644 index da10733393..0000000000 --- a/protocols/Omegle/src/proto.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - -Omegle plugin for Miranda Instant Messenger -_____________________________________________ - -Copyright © 2011-17 Robert Pösel, 2017-23 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 . - -*/ - -#pragma once - -class OmegleProto : public PROTO -{ - SESSION_INFO *m_si; - -public: - OmegleProto(const char *proto_name, const wchar_t *username); - ~OmegleProto(); - - inline const char* ModuleName() const - { - return m_szModuleName; - } - - inline bool isOnline() - { - return (m_iStatus != ID_STATUS_OFFLINE && m_iStatus != ID_STATUS_CONNECTING); - } - - inline bool isOffline() - { - return (m_iStatus == ID_STATUS_OFFLINE); - } - - // PROTO_INTERFACE - - INT_PTR GetCaps(int type, MCONTACT hContact = NULL) override; - - int SetStatus(int iNewStatus) override; - - int UserIsTyping(MCONTACT hContact, int type) override; - - void OnContactDeleted(MCONTACT) override; - MWindow OnCreateAccMgrUI(MWindow) override; - void OnShutdown() override; - - // Events - int __cdecl OnOptionsInit(WPARAM, LPARAM); - - // Chat handling - int __cdecl OnChatEvent(WPARAM, LPARAM); - INT_PTR __cdecl OnJoinChat(WPARAM, LPARAM); - INT_PTR __cdecl OnLeaveChat(WPARAM, LPARAM); - - // Loops - void __cdecl EventsLoop(void*); - - // Worker threads - void __cdecl SignOn(void*); - void __cdecl SignOff(void*); - - void __cdecl SendMsgWorker(void*); - void __cdecl SendTypingWorker(void*); - - void __cdecl NewChatWorker(void*); - void __cdecl StopChatWorker(void*); - - void StopChat(bool disconnect = true); - void NewChat(); - - // Chat handling - void UpdateChat(const wchar_t *name, const wchar_t *message, bool addtochat = true); - void SendChatMessage(std::string message); - void AddChatContact(const wchar_t *nick); - void DeleteChatContact(const wchar_t *name); - void SetChatStatus(int); - void ClearChat(); - void SetTopic(const wchar_t *topic = nullptr); - MCONTACT GetChatHandle(); - - // Connection client - Omegle_client facy; - - HANDLE signon_lock_; - HANDLE log_lock_; - HANDLE events_loop_lock_; - - static void CALLBACK APC_callback(ULONG_PTR p); -}; - -struct CMPlugin : public ACCPROTOPLUGIN -{ - CMPlugin(); - - int Load() override; -}; diff --git a/protocols/Omegle/src/resource.h b/protocols/Omegle/src/resource.h deleted file mode 100644 index 6d48095934..0000000000 --- a/protocols/Omegle/src/resource.h +++ /dev/null @@ -1,35 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by ..\res\omegle.rc -// -#define IDI_OMEGLE 101 -#define IDI_TYPING_ON 105 -#define IDI_TYPING_OFF 106 -#define IDD_OmegleACCOUNT 111 -#define IDD_OPTIONS 122 -#define IDC_SERVER 1204 -#define IDC_NAME 1205 -#define IDC_MEET_COMMON 1206 -#define IDC_INTERESTS 1207 -#define IDC_HI_ENABLED 1208 -#define IDC_SERVER2 1208 -#define IDC_HI_MESSAGE 1209 -#define IDC_ASL_MESSAGE 1210 -#define IDC_LAST_QUESTION 1211 -#define IDC_LANGUAGE 1212 -#define IDC_NOCLEAR 1213 -#define IDC_DONTSTOP 1214 -#define IDC_REUSE_QUESTIONS 1215 -#define IDC_SERVER_INFO 1217 -#define IDC_AUTO_CONNECT 1219 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 124 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1208 -#define _APS_NEXT_SYMED_VALUE 131 -#endif -#endif diff --git a/protocols/Omegle/src/stdafx.cxx b/protocols/Omegle/src/stdafx.cxx deleted file mode 100644 index ebbde0ade1..0000000000 --- a/protocols/Omegle/src/stdafx.cxx +++ /dev/null @@ -1,18 +0,0 @@ -/* -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 . -*/ - -#include "stdafx.h" \ No newline at end of file diff --git a/protocols/Omegle/src/stdafx.h b/protocols/Omegle/src/stdafx.h deleted file mode 100644 index 81425082c5..0000000000 --- a/protocols/Omegle/src/stdafx.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - -Omegle plugin for Miranda Instant Messenger -_____________________________________________ - -Copyright © 2011-17 Robert Pösel, 2017-23 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 . - -*/ - -#pragma once - -#pragma warning(disable:4996) - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "version.h" - -class OmegleProto; - -#include "../../utils/std_string_utils.h" - -#include "http.h" -#include "client.h" -#include "proto.h" -#include "db.h" -#include "constants.h" -#include "dialogs.h" -#include "theme.h" -#include "resource.h" - -extern uint32_t g_mirandaVersion; - -class ScopedLock -{ -public: - ScopedLock(HANDLE h) : handle_(h) - { - WaitForSingleObject(handle_, INFINITE); - } - ~ScopedLock() - { - if (handle_) - ReleaseMutex(handle_); - } - void Unlock() - { - ReleaseMutex(handle_); - handle_ = nullptr; - } -private: - HANDLE handle_; -}; diff --git a/protocols/Omegle/src/theme.cpp b/protocols/Omegle/src/theme.cpp deleted file mode 100644 index f9899adbe9..0000000000 --- a/protocols/Omegle/src/theme.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - -Omegle plugin for Miranda Instant Messenger -_____________________________________________ - -Copyright © 2011-17 Robert Pösel, 2017-23 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 . - -*/ - -#include "stdafx.h" - -static IconItem iconList[] = -{ - { LPGEN("Omegle Icon"), "omegle", IDI_OMEGLE }, - { LPGEN("Stranger is typing"), "typing_on", IDI_TYPING_ON }, - { LPGEN("Stranger stopped typing"), "typing_off", IDI_TYPING_OFF }, -}; - -void InitIcons(void) -{ - g_plugin.registerIcon("Protocols/Omegle", iconList, "Omegle"); -} diff --git a/protocols/Omegle/src/theme.h b/protocols/Omegle/src/theme.h deleted file mode 100644 index 0418ca4268..0000000000 --- a/protocols/Omegle/src/theme.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - -Omegle plugin for Miranda Instant Messenger -_____________________________________________ - -Copyright © 2011-17 Robert Pösel, 2017-23 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 . - -*/ - -#pragma once - -void InitIcons(void); diff --git a/protocols/Omegle/src/version.h b/protocols/Omegle/src/version.h deleted file mode 100644 index 3780281020..0000000000 --- a/protocols/Omegle/src/version.h +++ /dev/null @@ -1,13 +0,0 @@ -#define __MAJOR_VERSION 0 -#define __MINOR_VERSION 1 -#define __RELEASE_NUM 3 -#define __BUILD_NUM 4 - -#include - -#define __PLUGIN_NAME "Omegle protocol" -#define __FILENAME "Omegle.dll" -#define __DESCRIPTION "Omegle protocol support for Miranda NG." -#define __AUTHOR "Robert Pösel" -#define __AUTHORWEB "https://miranda-ng.org/p/Omegle" -#define __COPYRIGHT "© 2011-17 Robert Pösel, 2017-23 Miranda NG team" -- cgit v1.2.3