From c69a9c892f52056d452ad8520e6c09b6956f30e3 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 21 Sep 2013 13:40:52 +0000 Subject: smart pointers for Jabber resources git-svn-id: http://svn.miranda-ng.org/main/trunk@6155 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/JabberG/src/jabber_caps.cpp | 6 +-- protocols/JabberG/src/jabber_chat.cpp | 11 ++--- protocols/JabberG/src/jabber_groupchat.cpp | 12 ++--- protocols/JabberG/src/jabber_iqid.cpp | 2 +- protocols/JabberG/src/jabber_list.cpp | 74 +++++++++++++++++++----------- protocols/JabberG/src/jabber_list.h | 48 +++++++++++++++++-- protocols/JabberG/src/jabber_menu.cpp | 4 +- protocols/JabberG/src/jabber_misc.cpp | 6 +-- protocols/JabberG/src/jabber_proto.cpp | 4 +- protocols/JabberG/src/jabber_proto.h | 13 +++--- protocols/JabberG/src/jabber_svc.cpp | 2 +- protocols/JabberG/src/jabber_thread.cpp | 18 ++++---- protocols/JabberG/src/jabber_util.cpp | 4 +- 13 files changed, 132 insertions(+), 72 deletions(-) diff --git a/protocols/JabberG/src/jabber_caps.cpp b/protocols/JabberG/src/jabber_caps.cpp index 4ab1b65fda..4a9c6507a1 100644 --- a/protocols/JabberG/src/jabber_caps.cpp +++ b/protocols/JabberG/src/jabber_caps.cpp @@ -96,7 +96,7 @@ const JabberFeatCapPair g_JabberFeatCapPairsExt[] = { void CJabberProto::OnIqResultCapsDiscoInfoSI(HXML, CJabberIqInfo* pInfo) { - JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID(pInfo->GetFrom()); + pResourceStatus r( ResourceInfoFromJID(pInfo->GetFrom())); if (r == NULL) return; @@ -138,7 +138,7 @@ void CJabberProto::OnIqResultCapsDiscoInfoSI(HXML, CJabberIqInfo* pInfo) void CJabberProto::OnIqResultCapsDiscoInfo(HXML, CJabberIqInfo* pInfo) { - JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID(pInfo->GetFrom()); + pResourceStatus r( ResourceInfoFromJID(pInfo->GetFrom())); HXML query = pInfo->GetChildNode(); if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT && query) { @@ -222,7 +222,7 @@ JabberCapsBits CJabberProto::GetResourceCapabilites(const TCHAR *jid, BOOL appen else _tcsncpy(fullJid, jid, SIZEOF(fullJid)); - JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID(fullJid); + pResourceStatus r( ResourceInfoFromJID(fullJid)); if (r == NULL) return JABBER_RESOURCE_CAPS_ERROR; diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp index b1d4fe97d2..a7e5e42de8 100644 --- a/protocols/JabberG/src/jabber_chat.cpp +++ b/protocols/JabberG/src/jabber_chat.cpp @@ -194,7 +194,7 @@ void CJabberProto::GcLogCreate(JABBER_LIST_ITEM *item) GcInit(item); } -void CJabberProto::GcLogShowInformation(JABBER_LIST_ITEM *item, JABBER_RESOURCE_STATUS *user, TJabberGcLogInfoType type) +void CJabberProto::GcLogShowInformation(JABBER_LIST_ITEM *item, pResourceStatus &user, TJabberGcLogInfoType type) { if ( !item || !user || (item->bChatActive != 2)) return; @@ -309,6 +309,7 @@ void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const TCHAR * gce.ptszStatus = TranslateT("Moderator"); break; default: + mir_cslock lck(m_csLists); for (int i=0; i < item->arResources.getCount(); i++) { JABBER_RESOURCE_STATUS *JS = item->arResources[i]; if ( !lstrcmp(resource, JS->resourceName)) { @@ -539,7 +540,7 @@ int CJabberProto::JabberGcMenuHook(WPARAM, LPARAM lParam) if (item == NULL) return 0; - JABBER_RESOURCE_STATUS *me = NULL, *him = NULL; + pResourceStatus me(NULL), him(NULL); for (int i=0; i < item->arResources.getCount(); i++) { JABBER_RESOURCE_STATUS *p = item->arResources[i]; if ( !lstrcmp(p->resourceName, item->nick)) me = p; @@ -1027,9 +1028,7 @@ static INT_PTR CALLBACK sttUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam static void sttNickListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* gch) { - JABBER_RESOURCE_STATUS - *me = item->findResource(item->nick), - *him = item->findResource(gch->ptszUID); + pResourceStatus me( item->findResource(item->nick)), him( item->findResource(gch->ptszUID)); if (him == NULL || me == NULL) return; @@ -1446,7 +1445,7 @@ static void sttSendPrivateMessage(CJabberProto *ppro, JABBER_LIST_ITEM *item, co mir_sntprintf(szFullJid, SIZEOF(szFullJid), _T("%s/%s"), item->jid, nick); HANDLE hContact = ppro->DBCreateContact(szFullJid, NULL, TRUE, FALSE); if (hContact != NULL) { - JABBER_RESOURCE_STATUS *r = item->findResource(nick); + pResourceStatus r( item->findResource(nick)); if (r) ppro->setWord(hContact, "Status", r->status); diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp index 8ad5307200..7597c9bdd8 100644 --- a/protocols/JabberG/src/jabber_groupchat.cpp +++ b/protocols/JabberG/src/jabber_groupchat.cpp @@ -864,7 +864,7 @@ void CJabberProto::RenameParticipantNick(JABBER_LIST_ITEM *item, const TCHAR *ol if (newNick == NULL) return; - JABBER_RESOURCE_STATUS *r = item->findResource(oldNick); + pResourceStatus r( item->findResource(oldNick)); if (r == NULL) return; @@ -914,7 +914,7 @@ void CJabberProto::GroupchatProcessPresence(HXML node) if (item == NULL) return; - JABBER_RESOURCE_STATUS *r = item->findResource(resource); + pResourceStatus r( item->findResource(resource)); HXML nNode = xmlGetChildByTag(node, "nick", "xmlns", JABBER_FEAT_NICK); if (nNode == NULL) @@ -959,9 +959,9 @@ void CJabberProto::GroupchatProcessPresence(HXML node) priority = (char)_ttoi(ptszPriority); bool bStatusChanged = false, bRoomCreated = false, bAffiliationChanged = false, bRoleChanged = false; - int newRes = (ListAddResource(LIST_CHATROOM, from, status, str, priority, cnick) == 0) ? 0 : GC_EVENT_JOIN; + int newRes = ListAddResource(LIST_CHATROOM, from, status, str, priority, cnick) ? GC_EVENT_JOIN : 0; - if (JABBER_RESOURCE_STATUS *oldRes = ListFindResource(LIST_CHATROOM, from)) + if (pResourceStatus oldRes = ListFindResource(LIST_CHATROOM, from)) if ((oldRes->status != status) || lstrcmp_null(oldRes->statusMessage, str)) bStatusChanged = true; @@ -1013,7 +1013,7 @@ void CJabberProto::GroupchatProcessPresence(HXML node) // show status change if needed if (bStatusChanged) - if (JABBER_RESOURCE_STATUS *res = ListFindResource(LIST_CHATROOM, from)) + if (pResourceStatus res = ListFindResource(LIST_CHATROOM, from)) GcLogShowInformation(item, res, INFO_STATUS); // Update groupchat log window @@ -1198,7 +1198,7 @@ void CJabberProto::GroupchatProcessMessage(HXML node) msgTime = now; if (resource != NULL) { - JABBER_RESOURCE_STATUS *r = item->findResource(resource); + pResourceStatus r( item->findResource(resource)); nick = (r && r->nick) ? r->nick : resource; } else nick = NULL; diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp index 8bf30efaa6..7c1d9a9709 100644 --- a/protocols/JabberG/src/jabber_iqid.cpp +++ b/protocols/JabberG/src/jabber_iqid.cpp @@ -1612,7 +1612,7 @@ void CJabberProto::OnIqResultSetBookmarks(HXML iqNode) // last activity (XEP-0012) support void CJabberProto::OnIqResultLastActivity(HXML iqNode, CJabberIqInfo* pInfo) { - JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID(pInfo->m_szFrom); + pResourceStatus r( ResourceInfoFromJID(pInfo->m_szFrom)); if (r == NULL) return; diff --git a/protocols/JabberG/src/jabber_list.cpp b/protocols/JabberG/src/jabber_list.cpp index d97d758055..1533733ca1 100644 --- a/protocols/JabberG/src/jabber_list.cpp +++ b/protocols/JabberG/src/jabber_list.cpp @@ -35,25 +35,6 @@ JABBER_LIST_ITEM::JABBER_LIST_ITEM() : { } -///////////////////////////////////////////////////////////////////////////////////////// - -JABBER_RESOURCE_STATUS::~JABBER_RESOURCE_STATUS() -{ - mir_free(resourceName); - mir_free(nick); - mir_free(statusMessage); - mir_free(software); - mir_free(version); - mir_free(system); - mir_free(szCapsNode); - mir_free(szCapsVer); - mir_free(szCapsExt); - mir_free(szRealJid); - - if (pSoftwareInfo) - delete pSoftwareInfo; -} - JABBER_LIST_ITEM::~JABBER_LIST_ITEM() { for (int i=0; i < arResources.getCount(); i++) @@ -81,6 +62,43 @@ JABBER_LIST_ITEM::~JABBER_LIST_ITEM() delete ft; } +///////////////////////////////////////////////////////////////////////////////////////// + +JABBER_RESOURCE_STATUS::JABBER_RESOURCE_STATUS() : + m_refCount(1) +{ +} + +JABBER_RESOURCE_STATUS::~JABBER_RESOURCE_STATUS() +{ + mir_free(resourceName); + mir_free(nick); + mir_free(statusMessage); + mir_free(software); + mir_free(version); + mir_free(system); + mir_free(szCapsNode); + mir_free(szCapsVer); + mir_free(szCapsExt); + mir_free(szRealJid); + + if (pSoftwareInfo) + delete pSoftwareInfo; +} + +void JABBER_RESOURCE_STATUS::AddRef() +{ + if (this != NULL) + ::InterlockedIncrement(&m_refCount); +} + +void JABBER_RESOURCE_STATUS::Release() +{ + if (this != NULL) + if (::InterlockedDecrement(&m_refCount) == 0) + delete this; +} + void CJabberProto::ListWipe(void) { mir_cslock lck(m_csLists); @@ -212,7 +230,7 @@ int CJabberProto::ListFindNext(JABBER_LIST list, int fromOffset) ///////////////////////////////////////////////////////////////////////////////////////// // Resource related code -JABBER_RESOURCE_STATUS* JABBER_LIST_ITEM::findResource(const TCHAR *resourceName) const +pResourceStatus JABBER_LIST_ITEM::findResource(const TCHAR *resourceName) const { if (arResources.getCount() == 0 || resourceName == NULL || *resourceName == 0) return NULL; @@ -226,7 +244,7 @@ JABBER_RESOURCE_STATUS* JABBER_LIST_ITEM::findResource(const TCHAR *resourceName return NULL; } -JABBER_RESOURCE_STATUS* CJabberProto::ListFindResource(JABBER_LIST list, const TCHAR *jid) +pResourceStatus CJabberProto::ListFindResource(JABBER_LIST list, const TCHAR *jid) { mir_cslock lck(m_csLists); JABBER_LIST_ITEM *LI = ListGetItemPtr(list, jid); @@ -238,12 +256,12 @@ JABBER_RESOURCE_STATUS* CJabberProto::ListFindResource(JABBER_LIST list, const T return (q == NULL) ? NULL : LI->findResource(q+1); } -int CJabberProto::ListAddResource(JABBER_LIST list, const TCHAR *jid, int status, const TCHAR *statusMessage, char priority, const TCHAR *nick) +bool CJabberProto::ListAddResource(JABBER_LIST list, const TCHAR *jid, int status, const TCHAR *statusMessage, char priority, const TCHAR *nick) { mir_cslockfull lck(m_csLists); JABBER_LIST_ITEM *LI = ListGetItemPtr(list, jid); if (LI == NULL) - return NULL; + return false; bool bIsNewResource = false; @@ -252,7 +270,7 @@ int CJabberProto::ListAddResource(JABBER_LIST list, const TCHAR *jid, int status if (q) { const TCHAR *resource = q+1; if (resource[0]) { - JABBER_RESOURCE_STATUS *r = LI->findResource(resource); + pResourceStatus r( LI->findResource(resource)); if (r != NULL) { // Already exists, update status and statusMessage r->status = status; replaceStrT(r->statusMessage, statusMessage); @@ -297,7 +315,7 @@ void CJabberProto::ListRemoveResource(JABBER_LIST list, const TCHAR *jid) if (q == NULL) return; - JABBER_RESOURCE_STATUS *r = LI->findResource(q+1); + pResourceStatus r( LI->findResource(q+1)); if (r == NULL) return; @@ -315,13 +333,13 @@ void CJabberProto::ListRemoveResource(JABBER_LIST list, const TCHAR *jid) UpdateMirVer(LI); LI->arResources.remove(r); - delete r; + r->Release(); lck.unlock(); MenuUpdateSrmmIcon(LI); } -JABBER_RESOURCE_STATUS* JABBER_LIST_ITEM::getBestResource() const +pResourceStatus JABBER_LIST_ITEM::getBestResource() const { if (!arResources.getCount()) return NULL; @@ -354,7 +372,7 @@ TCHAR* CJabberProto::ListGetBestClientResourceNamePtr(const TCHAR *jid) if (LI == NULL) return NULL; - JABBER_RESOURCE_STATUS *r = LI->getBestResource(); + pResourceStatus r( LI->getBestResource()); if (r != NULL) return r->resourceName; diff --git a/protocols/JabberG/src/jabber_list.h b/protocols/JabberG/src/jabber_list.h index 16f1c8aad3..88b646c1c0 100644 --- a/protocols/JabberG/src/jabber_list.h +++ b/protocols/JabberG/src/jabber_list.h @@ -73,10 +73,17 @@ struct JABBER_XEP0232_SOFTWARE_INFO : public MZeroedObject ptrT tszOs, tszOsVersion, tszSoftware, tszSoftwareVersion, tszXMirandaCoreVersion; }; -struct JABBER_RESOURCE_STATUS : public MZeroedObject +class JABBER_RESOURCE_STATUS : public MZeroedObject { + LONG m_refCount; + +public: + JABBER_RESOURCE_STATUS(); ~JABBER_RESOURCE_STATUS(); + void AddRef(); + void Release(); + int status; TCHAR* resourceName; TCHAR* nick; @@ -105,6 +112,37 @@ struct JABBER_RESOURCE_STATUS : public MZeroedObject JABBER_XEP0232_SOFTWARE_INFO* pSoftwareInfo; }; +class pResourceStatus +{ + JABBER_RESOURCE_STATUS *m_pStatus; + +public: + __forceinline pResourceStatus(JABBER_RESOURCE_STATUS *pStatus) : + m_pStatus(pStatus) + { pStatus->AddRef(); + } + + __forceinline pResourceStatus(const pResourceStatus &r) + { m_pStatus = r.m_pStatus; + m_pStatus->AddRef(); + } + + __forceinline ~pResourceStatus() + { m_pStatus->Release(); + } + + __forceinline operator JABBER_RESOURCE_STATUS*() const { return m_pStatus; } + __forceinline JABBER_RESOURCE_STATUS* operator->() const { return m_pStatus; } + + __forceinline void operator=(const pResourceStatus &r) { + m_pStatus->Release(); + m_pStatus = r.m_pStatus; + m_pStatus->AddRef(); + } +}; + +///////////////////////////////////////////////////////////////////////////////////////////// + struct JABBER_LIST_ITEM : public MZeroedObject { JABBER_LIST_ITEM(); @@ -117,14 +155,14 @@ struct JABBER_LIST_ITEM : public MZeroedObject // jid = jid of the contact TCHAR* nick; - JABBER_RESOURCE_STATUS* findResource(const TCHAR *resourceName) const; - JABBER_RESOURCE_STATUS* getBestResource() const; + pResourceStatus findResource(const TCHAR *resourceName) const; + pResourceStatus getBestResource() const; JABBER_RESOURCE_MODE resourceMode; LIST arResources; // array of resources JABBER_RESOURCE_STATUS *pLastSeenResource, // resource which was last seen active *pManualResource, // manually set resource - *m_pItemResource; // resource for jids without /resource node + *m_pItemResource; // resource for jids without /resource node JABBER_SUBSCRIPTION subscription; TCHAR* group; @@ -172,6 +210,8 @@ struct JABBER_LIST_ITEM : public MZeroedObject BOOL bHistoryRead; }; +///////////////////////////////////////////////////////////////////////////////////////////// + struct JABBER_HTTP_AVATARS { char * Url; diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp index 7b47dcf4a3..9cfba1f4d2 100644 --- a/protocols/JabberG/src/jabber_menu.cpp +++ b/protocols/JabberG/src/jabber_menu.cpp @@ -448,7 +448,7 @@ int CJabberProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM) m_phMenuResourceItems[i] = Menu_AddContactMenuItem(&mi); } if (i < item->arResources.getCount()) { - JABBER_RESOURCE_STATUS *r = item->arResources[i]; + pResourceStatus r(item->arResources[i]); CLISTMENUITEM clmi = { sizeof(clmi) }; clmi.flags = CMIM_NAME|CMIM_FLAGS | CMIF_CHILDPOPUP|CMIF_TCHAR; if ((item->resourceMode == RSMODE_MANUAL) && (item->pManualResource == r)) @@ -1057,7 +1057,7 @@ int CJabberProto::OnProcessSrmmEvent(WPARAM, LPARAM lParam) TCHAR jid[JABBER_MAX_JID_LEN]; if ( GetClientJID(event->hContact, jid, SIZEOF(jid))) { - JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID(jid); + pResourceStatus r( ResourceInfoFromJID(jid)); if (r && r->bMessageSessionActive) { r->bMessageSessionActive = FALSE; diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp index d5f38fb6e7..f3e9bc35af 100644 --- a/protocols/JabberG/src/jabber_misc.cpp +++ b/protocols/JabberG/src/jabber_misc.cpp @@ -384,7 +384,7 @@ void CJabberProto::UpdateMirVer(JABBER_LIST_ITEM *item) Log("JabberUpdateMirVer: for jid %S", item->jid); - JABBER_RESOURCE_STATUS *p = NULL; + pResourceStatus p(NULL); if (item->resourceMode == RSMODE_LASTSEEN) p = item->pLastSeenResource; else if (item->resourceMode == RSMODE_MANUAL) @@ -394,7 +394,7 @@ void CJabberProto::UpdateMirVer(JABBER_LIST_ITEM *item) UpdateMirVer(hContact, p); } -void CJabberProto::FormatMirVer(JABBER_RESOURCE_STATUS *resource, TCHAR *buf, int bufSize) +void CJabberProto::FormatMirVer(pResourceStatus &resource, TCHAR *buf, int bufSize) { if ( !buf || !bufSize) return; buf[ 0 ] = _T('\0'); @@ -475,7 +475,7 @@ void CJabberProto::FormatMirVer(JABBER_RESOURCE_STATUS *resource, TCHAR *buf, in } -void CJabberProto::UpdateMirVer(HANDLE hContact, JABBER_RESOURCE_STATUS *resource) +void CJabberProto::UpdateMirVer(HANDLE hContact, pResourceStatus &resource) { TCHAR szMirVer[ 512 ]; FormatMirVer(resource, szMirVer, SIZEOF(szMirVer)); diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 784ce86e82..5ce0f096ad 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -728,7 +728,7 @@ int __cdecl CJabberProto::GetInfo(HANDLE hContact, int /*infoType*/) } JABBER_LIST_ITEM *tmpItem = NULL; if (pDelimiter && (tmpItem = ListGetItemPtr(LIST_CHATROOM, szBareJid))) { - JABBER_RESOURCE_STATUS *him = tmpItem->findResource(pDelimiter); + pResourceStatus him( tmpItem->findResource(pDelimiter)); if (him) { item = ListAdd(LIST_VCARD_TEMP, jid); ListAddResource(LIST_VCARD_TEMP, jid, him->status, him->statusMessage, him->priority); @@ -1150,7 +1150,7 @@ int __cdecl CJabberProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc } mir_free(msg); - JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID(szClientJid); + pResourceStatus r( ResourceInfoFromJID(szClientJid)); if (r) r->bMessageSessionActive = TRUE; diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index b8f864c5e6..300f00f8ee 100644 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -445,7 +445,7 @@ struct CJabberProto : public PROTO int GcInit(JABBER_LIST_ITEM *item); void GcLogCreate(JABBER_LIST_ITEM *item); void GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const TCHAR *resource, const TCHAR *nick, const TCHAR *jid, int action, HXML reason, int nStatusCode = -1); - void GcLogShowInformation(JABBER_LIST_ITEM *item, JABBER_RESOURCE_STATUS *user, TJabberGcLogInfoType type); + void GcLogShowInformation(JABBER_LIST_ITEM *item, pResourceStatus &user, TJabberGcLogInfoType type); void GcQuit(JABBER_LIST_ITEM* jid, int code, HXML reason); void FilterList(HWND hwndList); @@ -650,8 +650,9 @@ struct CJabberProto : public PROTO void ListRemoveByIndex(int index); int ListFindNext(JABBER_LIST list, int fromOffset); - JABBER_RESOURCE_STATUS *CJabberProto::ListFindResource(JABBER_LIST list, const TCHAR *jid); - int ListAddResource(JABBER_LIST list, const TCHAR *jid, int status, const TCHAR *statusMessage, char priority = 0, const TCHAR *nick = NULL); + pResourceStatus ListFindResource(JABBER_LIST list, const TCHAR *jid); + + bool ListAddResource(JABBER_LIST list, const TCHAR *jid, int status, const TCHAR *statusMessage, char priority = 0, const TCHAR *nick = NULL); void ListRemoveResource(JABBER_LIST list, const TCHAR *jid); TCHAR* ListGetBestClientResourceNamePtr(const TCHAR *jid); @@ -703,9 +704,9 @@ struct CJabberProto : public PROTO void GetAvatarFileName(HANDLE hContact, TCHAR* pszDest, size_t cbLen); void ResolveTransportNicks(const TCHAR *jid); void SetServerStatus(int iNewStatus); - void FormatMirVer(JABBER_RESOURCE_STATUS *resource, TCHAR *buf, int bufSize); + void FormatMirVer(pResourceStatus &resource, TCHAR *buf, int bufSize); void UpdateMirVer(JABBER_LIST_ITEM *item); - void UpdateMirVer(HANDLE hContact, JABBER_RESOURCE_STATUS *resource); + void UpdateMirVer(HANDLE hContact, pResourceStatus &resource); void UpdateSubscriptionInfo(HANDLE hContact, JABBER_LIST_ITEM *item); void SetContactOfflineStatus(HANDLE hContact); void InitCustomFolders(void); @@ -859,7 +860,7 @@ struct CJabberProto : public PROTO bool ProcessCaptcha(HXML node, HXML parentNode, ThreadData *info); //---- jabber_util.c ----------------------------------------------------------------- - JABBER_RESOURCE_STATUS* ResourceInfoFromJID(const TCHAR *jid); + pResourceStatus ResourceInfoFromJID(const TCHAR *jid); void SerialInit(void); void SerialUninit(void); diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp index 5a507af5f0..de10ebd483 100644 --- a/protocols/JabberG/src/jabber_svc.cpp +++ b/protocols/JabberG/src/jabber_svc.cpp @@ -396,7 +396,7 @@ INT_PTR __cdecl CJabberProto::JabberGCGetToolTipText(WPARAM wParam, LPARAM lPara if (item == NULL) return 0; //no room found - JABBER_RESOURCE_STATUS *info = item->findResource((TCHAR*)lParam); + pResourceStatus info( item->findResource((TCHAR*)lParam)); if (info == NULL) return 0; //no info found diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index 840b05bf59..f392327dfd 100644 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -1098,7 +1098,7 @@ HANDLE CJabberProto::CreateTemporaryContact(const TCHAR *szJid, JABBER_LIST_ITEM p = szJid; hContact = DBCreateContact(szJid, p, TRUE, FALSE); - JABBER_RESOURCE_STATUS *r = chatItem->findResource(p); + pResourceStatus r( chatItem->findResource(p)); if (r) setWord(hContact, "Status", r->status); } @@ -1122,7 +1122,7 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData* info) return; LPCTSTR idStr = xmlGetAttrValue(node, _T("id")); - JABBER_RESOURCE_STATUS *pFromResource = ResourceInfoFromJID(from); + pResourceStatus pFromResource( ResourceInfoFromJID(from)); // Message receipts delivery request. Reply here, before a call to HandleMessagePermanent() to make sure message receipts are handled for external plugins too. if ((!type || _tcsicmp(type, _T("error"))) && xmlGetChildByTag(node, "request", "xmlns", JABBER_FEAT_MESSAGE_RECEIPTS)) { @@ -1494,8 +1494,9 @@ void CJabberProto::OnProcessPresenceCapabilites(HXML node) Log("presence: for jid %S", from); - JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID(from); - if (r == NULL) return; + pResourceStatus r( ResourceInfoFromJID(from)); + if (r == NULL) + return; HXML n; @@ -1544,7 +1545,7 @@ void CJabberProto::UpdateJidDbSettings(const TCHAR *jid) int nSelectedResource = -1, i = 0; int nMaxPriority = -999; // -128...+127 valid range for (i = 0; i < item->arResources.getCount(); i++) { - JABBER_RESOURCE_STATUS *r = item->arResources[i]; + pResourceStatus r(item->arResources[i]); if (r->priority > nMaxPriority) { nMaxPriority = r->priority; status = r->status; @@ -1557,7 +1558,7 @@ void CJabberProto::UpdateJidDbSettings(const TCHAR *jid) } item->m_pItemResource->status = status; if (nSelectedResource != -1) { - JABBER_RESOURCE_STATUS *r = item->arResources[nSelectedResource]; + pResourceStatus r(item->arResources[nSelectedResource]); Log("JabberUpdateJidDbSettings: updating jid %S to rc %S", item->jid, r->resourceName); if (r->statusMessage) db_set_ts(hContact, "CList", "StatusMsg", r->statusMessage); @@ -1805,8 +1806,9 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData* info) void CJabberProto::OnIqResultVersion(HXML /*node*/, CJabberIqInfo *pInfo) { - JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID(pInfo->GetFrom()); - if (r == NULL) return; + pResourceStatus r( ResourceInfoFromJID(pInfo->GetFrom())); + if (r == NULL) + return; r->dwVersionRequestTime = -1; diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index 2d2102e6ba..2f4229dba2 100644 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.cpp @@ -148,7 +148,7 @@ TCHAR* __stdcall JabberNickFromJID(const TCHAR *jid) return nick; } -JABBER_RESOURCE_STATUS* CJabberProto::ResourceInfoFromJID(const TCHAR *jid) +pResourceStatus CJabberProto::ResourceInfoFromJID(const TCHAR *jid) { if ( !jid) return NULL; @@ -908,7 +908,7 @@ TCHAR* CJabberProto::GetClientJID(const TCHAR *jid, TCHAR *dest, size_t destLen) } if (p == NULL) { - JABBER_RESOURCE_STATUS *r = LI->getBestResource(); + pResourceStatus r( LI->getBestResource()); if (r != NULL) mir_sntprintf(dest, destLen, _T("%s/%s"), jid, r->resourceName); } -- cgit v1.2.3