From c7bb55b7586eeb85258759dd71c2a1012d772556 Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Sun, 4 Oct 2015 16:04:25 +0000 Subject: MirandaG15: - fixed group chat messages (broken in r14971) - minor cleanup, leaks fixed, etc... git-svn-id: http://svn.miranda-ng.org/main/trunk@15508 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirandaG15/src/CAppletManager.cpp | 29 +++++++++++------------- plugins/MirandaG15/src/CContactList.cpp | 31 ++++++++++++-------------- plugins/MirandaG15/src/LCDFramework/CLCDList.h | 3 ++- 3 files changed, 29 insertions(+), 34 deletions(-) (limited to 'plugins/MirandaG15/src') diff --git a/plugins/MirandaG15/src/CAppletManager.cpp b/plugins/MirandaG15/src/CAppletManager.cpp index 2ec2cb4f48..d7c9388caa 100644 --- a/plugins/MirandaG15/src/CAppletManager.cpp +++ b/plugins/MirandaG15/src/CAppletManager.cpp @@ -750,9 +750,6 @@ void CAppletManager::SendTypingNotification(MCONTACT hContact, bool bEnable) MEVENT CAppletManager::SendMessageToContact(MCONTACT hContact, tstring strMessage) { tstring strAscii = _A2T(toNarrowString(strMessage).c_str()); - SMessageJob *pJob = new SMessageJob(); - pJob->dwTimestamp = GetTickCount(); - pJob->hContact = hContact; char *szProto = GetContactProto(hContact); tstring strProto = toTstring(szProto); @@ -760,14 +757,13 @@ MEVENT CAppletManager::SendMessageToContact(MCONTACT hContact, tstring strMessag CIRCConnection *pIRCCon = CAppletManager::GetInstance()->GetIRCConnection(strProto); if (pIRCCon && db_get_b(hContact, szProto, "ChatRoom", 0) != 0) { - GCDEST gcd = { szProto, 0, GC_EVENT_SENDMESSAGE }; - DBVARIANT dbv; - if (!db_get_ts(hContact, szProto, "Nick", &dbv)) - gcd.ptszID = dbv.ptszVal; - else + if (db_get_ts(hContact, szProto, "Nick", &dbv)) return NULL; + GCDEST gcd = { szProto, 0, GC_EVENT_SENDMESSAGE }; + gcd.ptszID = dbv.ptszVal; + tstring strID = tstring(gcd.ptszID) + _T(" - ") + tstring(_A2T(toNarrowString(pIRCCon->strNetwork).c_str())); gcd.ptszID = (LPTSTR)strID.c_str(); @@ -778,9 +774,14 @@ MEVENT CAppletManager::SendMessageToContact(MCONTACT hContact, tstring strMessag gce.bIsMe = true; CallService(MS_GC_EVENT, NULL, (LPARAM)&gce); - pJob->hEvent = NULL; + db_free(&dbv); + return 0; } else { + SMessageJob *pJob = new SMessageJob(); + pJob->dwTimestamp = GetTickCount(); + pJob->hContact = hContact; + char* szMsgUtf = mir_utf8encodeW(strMessage.c_str()); pJob->iBufferSize = (int)mir_strlen(szMsgUtf) + 1; @@ -792,9 +793,8 @@ MEVENT CAppletManager::SendMessageToContact(MCONTACT hContact, tstring strMessag pJob->hEvent = (MEVENT)CallContactService(pJob->hContact, PSS_MESSAGE, 0, (LPARAM)pJob->pcBuffer); CAppletManager::GetInstance()->AddMessageJob(pJob); + return pJob->hEvent; } - - return pJob->hEvent; } //************************************************************************ @@ -1361,7 +1361,7 @@ int CAppletManager::HookChatInbound(WPARAM, LPARAM lParam) TRACE(_T("OK!\n")); return 0; } - if (gcd->ptszID != NULL) { + else if (gcd->ptszID != NULL) { TRACE(_T("OK!\n")); return 0; } @@ -1583,6 +1583,7 @@ int CAppletManager::HookProtoAck(WPARAM, LPARAM lParam) if (pProtoData == NULL) return 0; + // Skip connecting status if (iNewStatus == ID_STATUS_CONNECTING) return 0; @@ -1602,10 +1603,6 @@ int CAppletManager::HookProtoAck(WPARAM, LPARAM lParam) Event.eType = EVENT_PROTO_STATUS; } - // Skip connecting status - if (iNewStatus == ID_STATUS_CONNECTING) - return 0; - pProtoData->iStatus = iNewStatus; Event.iValue = iNewStatus; diff --git a/plugins/MirandaG15/src/CContactList.cpp b/plugins/MirandaG15/src/CContactList.cpp index 6964d74d59..7a61b0d39a 100644 --- a/plugins/MirandaG15/src/CContactList.cpp +++ b/plugins/MirandaG15/src/CContactList.cpp @@ -813,7 +813,7 @@ void CContactList::OnContactDeleted(MCONTACT hContact) if(!db_mc_isSub(hContact)) ChangeGroupObjectCounters(strGroup,-1); - if(pGroup->iMembers <= 0) + if(pGroup && pGroup->iMembers <= 0) DeleteGroupObjectByPath(pGroup->strPath); } } @@ -997,14 +997,11 @@ void CContactList::UninitializeGroupObjects() void CContactList::InitializeGroupObjects() { UninitializeGroupObjects(); - - CContactListGroup *pGroup = NULL; - char *szProto = NULL; for(MCONTACT hContact = db_find_first();hContact != NULL;hContact = db_find_next(hContact)) { tstring strGroup = GetContactGroupPath(hContact); - szProto = GetContactProto(hContact); + char *szProto = GetContactProto(hContact); if(szProto && db_get_b(NULL,META_PROTO,"Enabled",1) && !mir_strcmpi(szProto,META_PROTO)) { tstring strName = CAppletManager::GetContactDisplayname(hContact); @@ -1013,7 +1010,7 @@ void CContactList::InitializeGroupObjects() strPath += strGroup; strPath += (strPath.empty()?_T(""):_T("\\")) + strName; - pGroup = CreateGroupObjectByPath(strPath); + CContactListGroup *pGroup = CreateGroupObjectByPath(strPath); pGroup->hMetaContact = hContact; if(!strGroup.empty()) @@ -1022,11 +1019,11 @@ void CContactList::InitializeGroupObjects() // If the contact has no group, continue else if(!strGroup.empty() && CConfig::GetBoolSetting(CLIST_USEGROUPS)) { - pGroup = GetGroupObjectByPath(strGroup); + CContactListGroup *pGroup = GetGroupObjectByPath(strGroup); // create the group if(!pGroup) - pGroup = CreateGroupObjectByPath(strGroup); + CreateGroupObjectByPath(strGroup); // update it's counters if(!db_mc_isSub(hContact)) @@ -1104,9 +1101,7 @@ void CContactList::DeleteGroupObjectByPath(tstring strPath) { ASSERT(!strPath.empty()); - CContactListGroup *pParentGroup = NULL; - vector::iterator iter = m_Groups.begin(); - for(iter = m_Groups.begin();iter != m_Groups.end();iter++) + for(vector::iterator iter = iter = m_Groups.begin();iter != m_Groups.end();iter++) { if((*iter)->strPath == strPath) { @@ -1120,13 +1115,15 @@ void CContactList::DeleteGroupObjectByPath(tstring strPath) tstring strParse = strPath; tstring::size_type pos = strParse.rfind('\\'); - if(pos != tstring::npos ) + if (pos != tstring::npos) { - strParse = strParse.substr(0,pos); - pParentGroup = GetGroupObjectByPath(strParse); - pParentGroup->iGroups--; - if(pParentGroup->iMembers <= 0 && pParentGroup->iGroups <= 0) - DeleteGroupObjectByPath(strParse); + strParse = strParse.substr(0, pos); + CContactListGroup *pParentGroup = GetGroupObjectByPath(strParse); + if (pParentGroup) { + pParentGroup->iGroups--; + if (pParentGroup->iMembers <= 0 && pParentGroup->iGroups <= 0) + DeleteGroupObjectByPath(strParse); + } } return; } diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDList.h b/plugins/MirandaG15/src/LCDFramework/CLCDList.h index 0f7006d46d..93284ba71a 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDList.h +++ b/plugins/MirandaG15/src/LCDFramework/CLCDList.h @@ -400,7 +400,8 @@ public: delete *iter; m_Entrys.erase(iter); - m_pRoot->UpdateEntryCount(); + if (m_pRoot) + m_pRoot->UpdateEntryCount(); return; } } -- cgit v1.2.3