From 05cd7934d4bdb097e112efdda356946868f3f5d6 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 8 Jan 2014 19:39:48 +0000 Subject: - end of ANSI support in chats; - manual crit section control removed from chat engine; - bunch of memory-related clutches either removed or replaced with smart pointers git-svn-id: http://svn.miranda-ng.org/main/trunk@7549 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Omegle/src/chat.cpp | 120 ++++++++++++----------------------------- protocols/Omegle/src/proto.cpp | 2 +- 2 files changed, 36 insertions(+), 86 deletions(-) (limited to 'protocols/Omegle') diff --git a/protocols/Omegle/src/chat.cpp b/protocols/Omegle/src/chat.cpp index 39ad7925e5..88f6874c71 100644 --- a/protocols/Omegle/src/chat.cpp +++ b/protocols/Omegle/src/chat.cpp @@ -23,30 +23,23 @@ along with this program. If not, see . void OmegleProto::UpdateChat(const TCHAR *name, const TCHAR *message, bool addtolog) { - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = const_cast(m_tszUserName); - - GCEVENT gce = {sizeof(gce)}; - gce.pDest = &gcd; + GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_MESSAGE }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.time = ::time(NULL); gce.ptszText = message; - gce.time = ::time(NULL); - gce.dwFlags = GC_TCHAR; - gcd.iType = GC_EVENT_MESSAGE; if (name == NULL) { gcd.iType = GC_EVENT_INFORMATION; name = TranslateT("Server"); gce.bIsMe = false; - } else { - gce.bIsMe = !_tcscmp(name, this->facy.nick_); } + else gce.bIsMe = !_tcscmp(name, this->facy.nick_); if (addtolog) gce.dwFlags |= GCEF_ADDTOLOG; gce.ptszNick = name; gce.ptszUID = gce.ptszNick; - CallServiceSync(MS_GC_EVENT,0,reinterpret_cast(&gce)); } @@ -214,29 +207,19 @@ int OmegleProto::OnChatEvent(WPARAM wParam,LPARAM lParam) /*void OmegleProto::SendChatEvent(int type) { - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = const_cast(m_tszUserName); - gcd.iType = GC_EVENT_CONTROL; - - GCEVENT gce = {sizeof(gce)}; - gce.dwFlags = GC_TCHAR; - gce.pDest = &gcd; - + GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; CallServiceSync(MS_GC_EVENT,WINDOW_CLEARLOG,reinterpret_cast(&gce)); }*/ void OmegleProto::AddChatContact(const TCHAR *name) { - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = const_cast(m_tszUserName); - gcd.iType = GC_EVENT_JOIN; - - GCEVENT gce = {sizeof(gce)}; - gce.pDest = &gcd; - gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG; - gce.ptszNick = name; - gce.ptszUID = gce.ptszNick; - gce.time = static_cast(time(0)); + GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_JOIN }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.time = DWORD(time(0)); + gce.dwFlags = GCEF_ADDTOLOG; + gce.ptszNick = name; + gce.ptszUID = gce.ptszNick; if (name == NULL) gce.bIsMe = false; @@ -253,16 +236,12 @@ void OmegleProto::AddChatContact(const TCHAR *name) void OmegleProto::DeleteChatContact(const TCHAR *name) { - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = const_cast(m_tszUserName); - gcd.iType = GC_EVENT_PART; - - GCEVENT gce = {sizeof(gce)}; - gce.pDest = &gcd; - gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG; - gce.ptszNick = name; - gce.ptszUID = gce.ptszNick; - gce.time = static_cast(time(0)); + GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_PART }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.dwFlags = GCEF_ADDTOLOG; + gce.ptszNick = name; + gce.ptszUID = gce.ptszNick; + gce.time = DWORD(time(0)); if (name == NULL) gce.bIsMe = false; else @@ -273,29 +252,21 @@ void OmegleProto::DeleteChatContact(const TCHAR *name) INT_PTR OmegleProto::OnJoinChat(WPARAM,LPARAM suppress) { - GCSESSION gcw = {sizeof(gcw)}; - // Create the group chat session - gcw.dwFlags = GC_TCHAR; - gcw.iType = GCW_CHATROOM; + GCSESSION gcw = {sizeof(gcw)}; + gcw.iType = GCW_CHATROOM; + gcw.ptszID = m_tszUserName; + gcw.ptszName = m_tszUserName; gcw.pszModule = m_szModuleName; - gcw.ptszName = m_tszUserName; - gcw.ptszID = m_tszUserName; CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw); if(m_iStatus == ID_STATUS_OFFLINE) return 0; // Create a group - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = const_cast(m_tszUserName); - - GCEVENT gce = {sizeof(gce)}; - gce.pDest = &gcd; - gce.dwFlags = GC_TCHAR; - - gcd.iType = GC_EVENT_ADDGROUP; - + GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_ADDGROUP }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.ptszStatus = _T("Admin"); CallServiceSync( MS_GC_EVENT, NULL, reinterpret_cast(&gce)); @@ -313,15 +284,10 @@ INT_PTR OmegleProto::OnJoinChat(WPARAM,LPARAM suppress) void OmegleProto::SetTopic(const TCHAR *topic) { - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = const_cast(m_tszUserName); - gcd.iType = GC_EVENT_TOPIC; - - GCEVENT gce = {sizeof(gce)}; - gce.pDest = &gcd; - gce.dwFlags = GC_TCHAR; + GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_TOPIC }; + GCEVENT gce = { sizeof(gce), &gcd }; gce.time = ::time(NULL); - + if (topic == NULL) gce.ptszText = TranslateT("Omegle is a great way of meeting new friends!"); else @@ -332,14 +298,9 @@ void OmegleProto::SetTopic(const TCHAR *topic) INT_PTR OmegleProto::OnLeaveChat(WPARAM,LPARAM) { - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = const_cast(m_tszUserName); - gcd.iType = GC_EVENT_CONTROL; - - GCEVENT gce = {sizeof(gce)}; - gce.dwFlags = GC_TCHAR; + GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; gce.time = ::time(NULL); - gce.pDest = &gcd; CallServiceSync(MS_GC_EVENT,SESSION_OFFLINE, reinterpret_cast(&gce)); CallServiceSync(MS_GC_EVENT,SESSION_TERMINATE,reinterpret_cast(&gce)); @@ -349,14 +310,9 @@ INT_PTR OmegleProto::OnLeaveChat(WPARAM,LPARAM) void OmegleProto::SetChatStatus(int status) { - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = const_cast(m_tszUserName); - gcd.iType = GC_EVENT_CONTROL; - - GCEVENT gce = {sizeof(gce)}; - gce.dwFlags = GC_TCHAR; + GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; gce.time = ::time(NULL); - gce.pDest = &gcd; if(status == ID_STATUS_ONLINE) { @@ -391,15 +347,9 @@ void OmegleProto::ClearChat() if (getByte(OMEGLE_KEY_NO_CLEAR, 0)) return; - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = const_cast(m_tszUserName); - gcd.iType = GC_EVENT_CONTROL; - - GCEVENT gce = {sizeof(gce)}; - gce.dwFlags = GC_TCHAR; - gce.pDest = &gcd; - - CallServiceSync(MS_GC_EVENT,WINDOW_CLEARLOG,reinterpret_cast(&gce)); + GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; + CallServiceSync(MS_GC_EVENT, WINDOW_CLEARLOG, reinterpret_cast(&gce)); } // TODO: Could this be done better? diff --git a/protocols/Omegle/src/proto.cpp b/protocols/Omegle/src/proto.cpp index f0ebd14717..245fa749ea 100644 --- a/protocols/Omegle/src/proto.cpp +++ b/protocols/Omegle/src/proto.cpp @@ -176,7 +176,7 @@ int OmegleProto::OnModulesLoaded(WPARAM wParam,LPARAM lParam) GCREGISTER gcr = {sizeof(gcr)}; gcr.dwFlags = GC_TYPNOTIF; //GC_ACKMSG; gcr.pszModule = m_szModuleName; - gcr.pszModuleDispName = m_szModuleName; + gcr.ptszDispName = m_tszUserName; gcr.iMaxText = OMEGLE_MESSAGE_LIMIT; gcr.nColors = 0; gcr.pColors = NULL; -- cgit v1.2.3