From bc0b5ed1e7f371820a08a9fdd275be68afe2fbe9 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 20 Sep 2013 13:26:16 +0000 Subject: code cleaning & simplification git-svn-id: http://svn.miranda-ng.org/main/trunk@6138 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/JabberG/src/jabber_menu.cpp | 3 ++- protocols/JabberG/src/jabber_proto.h | 2 -- protocols/JabberG/src/jabber_svc.cpp | 23 +++++++---------------- protocols/JabberG/src/jabber_thread.cpp | 2 +- protocols/JabberG/src/jabber_util.cpp | 11 ----------- 5 files changed, 10 insertions(+), 31 deletions(-) (limited to 'protocols/JabberG') diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp index 466f1aea62..174e571571 100644 --- a/protocols/JabberG/src/jabber_menu.cpp +++ b/protocols/JabberG/src/jabber_menu.cpp @@ -1031,7 +1031,8 @@ int CJabberProto::OnProcessSrmmEvent(WPARAM, LPARAM lParam) hDialogsList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0); WindowList_Add(hDialogsList, event->hwndWindow, event->hContact); - JABBER_LIST_ITEM *pItem = GetItemFromContact(event->hContact); + ptrT jid( getTStringA(event->hContact, "jid")); + JABBER_LIST_ITEM *pItem = (jid == NULL) ? NULL : ListGetItemPtr(LIST_ROSTER, jid); if (pItem && (m_ThreadInfo->jabberServerCaps & JABBER_CAPS_ARCHIVE_AUTO) && m_options.EnableMsgArchive) RetrieveMessageArchive(event->hContact, pItem); } diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index 829f096b97..b8f864c5e6 100644 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -859,8 +859,6 @@ struct CJabberProto : public PROTO bool ProcessCaptcha(HXML node, HXML parentNode, ThreadData *info); //---- jabber_util.c ----------------------------------------------------------------- - - JABBER_LIST_ITEM* GetItemFromContact(HANDLE hContact); JABBER_RESOURCE_STATUS* ResourceInfoFromJID(const TCHAR *jid); void SerialInit(void); diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp index ae1bf712f7..5a507af5f0 100644 --- a/protocols/JabberG/src/jabber_svc.cpp +++ b/protocols/JabberG/src/jabber_svc.cpp @@ -795,7 +795,7 @@ LPTSTR CJabberSysInterface::GetBestResourceName(LPCTSTR jid) LPTSTR CJabberSysInterface::GetResourceList(LPCTSTR jid) { - if ( !jid) + if (jid == NULL) return NULL; mir_cslock lck(m_psProto->m_csLists); @@ -808,23 +808,14 @@ LPTSTR CJabberSysInterface::GetResourceList(LPCTSTR jid) if (!item->arResources.getCount()) return NULL; - int i; - int iLen = 1; // 1 for extra zero terminator at the end of the string - // calculate total necessary string length - for (i=0; iarResources.getCount(); i++) - iLen += lstrlen(item->arResources[i]->resourceName) + 1; - - // allocate memory and fill it - LPTSTR str = (LPTSTR)mir_alloc(iLen * sizeof(TCHAR)); - LPTSTR p = str; - for (i=0; iarResources.getCount(); i++) { - JABBER_RESOURCE_STATUS *r = item->arResources[i]; - lstrcpy(p, r->resourceName); - p += lstrlen(r->resourceName) + 1; + CMString res; + for (int i=0; i < item->arResources.getCount(); i++) { + res.Append(item->arResources[i]->resourceName); + res.AppendChar(0); } - *p = 0; // extra zero terminator + res.AppendChar(0); - return str; + return mir_tstrndup(res, res.GetLength()); } char *CJabberSysInterface::GetModuleName() const diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index 0ded9a90c9..7df6e3fc41 100644 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -2041,7 +2041,7 @@ int ThreadData::send(char* buffer, int bufsize) return 0; if (bufsize == -1) - bufsize = strlen(buffer); + bufsize = (int)strlen(buffer); WaitForSingleObject(iomutex, 6000); diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index a3ec3000c6..53d7fc87f0 100644 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.cpp @@ -166,17 +166,6 @@ JABBER_RESOURCE_STATUS* CJabberProto::ResourceInfoFromJID(const TCHAR *jid) return item->findResource(p+1); } -JABBER_LIST_ITEM* CJabberProto::GetItemFromContact(HANDLE hContact) -{ - DBVARIANT dbv; - if (getTString(hContact, "jid", &dbv)) - return NULL; - - JABBER_LIST_ITEM *pItem = ListGetItemPtr(LIST_ROSTER, dbv.ptszVal); - db_free(&dbv); - return pItem; -} - TCHAR* JabberPrepareJid(LPCTSTR jid) { if ( !jid) return NULL; -- cgit v1.2.3