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/Gadu-Gadu/src/core.cpp | 73 +++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 43 deletions(-) (limited to 'protocols/Gadu-Gadu/src/core.cpp') diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp index 26a0f6d477..938e1dead2 100644 --- a/protocols/Gadu-Gadu/src/core.cpp +++ b/protocols/Gadu-Gadu/src/core.cpp @@ -826,21 +826,19 @@ retry: if (chat) { TCHAR id[32]; - GCDEST gcdest = {0}; - gcdest.pszModule = m_szModuleName; - gcdest.ptszID = chat; - gcdest.iType = GC_EVENT_MESSAGE; - GCEVENT gcevent = {sizeof(GCEVENT), &gcdest}; - time_t t = time(NULL); UIN2IDT(e->event.msg.sender, id); - gcevent.ptszUID = id; + + GCDEST gcd = { m_szModuleName, chat, GC_EVENT_MESSAGE }; + GCEVENT gce = { sizeof(gce), &gcd }; + time_t t = time(NULL); + gce.ptszUID = id; TCHAR* messageT = mir_utf8decodeT(e->event.msg.message); - gcevent.ptszText = messageT; - gcevent.ptszNick = (TCHAR*) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) getcontact(e->event.msg.sender, 1, 0, NULL), GCDNF_TCHAR); - gcevent.time = (!(e->event.msg.msgclass & GG_CLASS_OFFLINE) || e->event.msg.time > (t - timeDeviation)) ? t : e->event.msg.time; - gcevent.dwFlags = GC_TCHAR | GCEF_ADDTOLOG; + gce.ptszText = messageT; + gce.ptszNick = (TCHAR*) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) getcontact(e->event.msg.sender, 1, 0, NULL), GCDNF_TCHAR); + gce.time = (!(e->event.msg.msgclass & GG_CLASS_OFFLINE) || e->event.msg.time > (t - timeDeviation)) ? t : e->event.msg.time; + gce.dwFlags = GCEF_ADDTOLOG; debugLog(_T("mainthread() (%x): Conference message to room %s & id %s."), this, chat, id); - CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent); + CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); mir_free(messageT); } } @@ -893,29 +891,26 @@ retry: if (chat) { TCHAR id[32]; - DBVARIANT dbv; - GCDEST gcdest = {0}; - gcdest.pszModule = m_szModuleName; - gcdest.ptszID = chat; - gcdest.iType = GC_EVENT_MESSAGE; - GCEVENT gcevent = {sizeof(GCEVENT), &gcdest}; UIN2IDT(getDword(GG_KEY_UIN, 0), id); - gcevent.ptszUID = id; + + DBVARIANT dbv; + GCDEST gcd = { m_szModuleName, chat, GC_EVENT_MESSAGE }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.ptszUID = id; TCHAR* messageT = mir_utf8decodeT(e->event.multilogon_msg.message); - gcevent.ptszText = messageT; + gce.ptszText = messageT; TCHAR* nickT; if (!getTString(GG_KEY_NICK, &dbv)){ nickT = mir_tstrdup(dbv.ptszVal); db_free(&dbv); - } else { - nickT = mir_tstrdup(TranslateT("Me")); } - gcevent.ptszNick = nickT; - gcevent.time = e->event.multilogon_msg.time; - gcevent.bIsMe = 1; - gcevent.dwFlags = GC_TCHAR | GCEF_ADDTOLOG; + else nickT = mir_tstrdup(TranslateT("Me")); + gce.ptszNick = nickT; + gce.time = e->event.multilogon_msg.time; + gce.bIsMe = 1; + gce.dwFlags = GCEF_ADDTOLOG; debugLog(_T("mainthread() (%x): Sent conference message to room %s."), this, chat); - CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent); + CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); mir_free(messageT); mir_free(nickT); } @@ -1284,12 +1279,8 @@ int GGPROTO::contactdeleted(WPARAM wParam, LPARAM lParam) DBVARIANT dbv; if ( isChatRoom(hContact) && !getTString(hContact, "ChatRoomID", &dbv) && gc_enabled) { - GCDEST gcdest = {0}; - gcdest.pszModule = m_szModuleName; - gcdest.ptszID = dbv.ptszVal; - gcdest.iType = GC_EVENT_CONTROL; - GCEVENT gcevent = {sizeof(GCEVENT), &gcdest}; - gcevent.dwFlags = GC_TCHAR; + GCDEST gcd = { m_szModuleName, dbv.ptszVal, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; GGGC *chat = gc_lookup(dbv.ptszVal); debugLogA("contactdeleted(): Terminating chat %x, id %s from contact list...", chat, dbv.pszVal); @@ -1299,8 +1290,8 @@ int GGPROTO::contactdeleted(WPARAM wParam, LPARAM lParam) free(chat->recipients); list_remove(&chats, chat, 1); // Terminate chat window / shouldn't cascade entry is deleted - CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, (LPARAM)&gcevent); - CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gcevent); + CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, (LPARAM)&gce); + CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce); } db_free(&dbv); @@ -1366,17 +1357,13 @@ int GGPROTO::dbsettingchanged(WPARAM wParam, LPARAM lParam) static int cascade = 0; if (!cascade && dbv.ptszVal) { - GCDEST gcdest = {0}; - gcdest.pszModule = m_szModuleName; - gcdest.ptszID = dbv.ptszVal; - gcdest.iType = GC_EVENT_CHANGESESSIONAME; - GCEVENT gcevent = {sizeof(GCEVENT), &gcdest}; - gcevent.dwFlags = GC_TCHAR; - gcevent.ptszText = ptszVal; + GCDEST gcd = { m_szModuleName, dbv.ptszVal, GC_EVENT_CHANGESESSIONAME }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.ptszText = ptszVal; debugLogA("dbsettingchanged(): Conference %s was renamed.", dbv.pszVal); // Mark cascading /* FIXME */ cascade = 1; - CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent); + CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); /* FIXME */ cascade = 0; } db_free(&dbv); -- cgit v1.2.3