diff options
author | George Hazan <george.hazan@gmail.com> | 2013-08-02 22:24:11 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-08-02 22:24:11 +0000 |
commit | fe09f8b1b3e119ee88332a79bdfb143b907c2805 (patch) | |
tree | ef4c19d6156da0fa58c6427d24b6c0cb10f77ad8 /protocols | |
parent | c55fd3e3c7312d6a76bc8037df78c07cc269935f (diff) |
static array of resources replaced with LIST<>
git-svn-id: http://svn.miranda-ng.org/main/trunk@5559 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/JabberG/src/jabber_adhoc.cpp | 14 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_caps.cpp | 6 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_chat.cpp | 18 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_disco.cpp | 2 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_list.cpp | 126 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_list.h | 6 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_menu.cpp | 34 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_proto.cpp | 37 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_svc.cpp | 15 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_thread.cpp | 28 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_userinfo.cpp | 10 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_util.cpp | 2 |
12 files changed, 153 insertions, 145 deletions
diff --git a/protocols/JabberG/src/jabber_adhoc.cpp b/protocols/JabberG/src/jabber_adhoc.cpp index 222a34e044..3275897273 100644 --- a/protocols/JabberG/src/jabber_adhoc.cpp +++ b/protocols/JabberG/src/jabber_adhoc.cpp @@ -547,10 +547,10 @@ int __cdecl CJabberProto::ContactMenuRunCommands(WPARAM wParam, LPARAM lParam) mir_cslock lck(m_csLists);
item = ListGetItemPtr(LIST_ROSTER, jid);
if (item) {
- if (item->resourceCount > 1) {
+ if (item->arResources.getCount() > 1) {
HMENU hMenu = CreatePopupMenu();
- for (int i=0; i < item->resourceCount; i++)
- AppendMenu(hMenu,MF_STRING,i+1, item->pResources[i].resourceName);
+ for (int i=0; i < item->arResources.getCount(); i++)
+ AppendMenu(hMenu,MF_STRING,i+1, item->arResources[i]->resourceName);
HWND hwndTemp=CreateWindowEx(WS_EX_TOOLWINDOW,_T("button"),_T("PopupMenuHost"),0,0,0,10,10,NULL,NULL,hInst,NULL);
SetForegroundWindow(hwndTemp);
POINT pt;
@@ -563,10 +563,10 @@ int __cdecl CJabberProto::ContactMenuRunCommands(WPARAM wParam, LPARAM lParam) else selected = 1;
if (selected > 0) {
- selected--;
- if (item->pResources) {
- _tcsncat(jid,_T("/"),SIZEOF(jid));
- _tcsncat(jid,item->pResources[selected].resourceName,SIZEOF(jid));
+ JABBER_RESOURCE_STATUS *r = item->arResources[selected-1];
+ if (r) {
+ _tcsncat(jid, _T("/"),SIZEOF(jid));
+ _tcsncat(jid, r->resourceName, SIZEOF(jid));
}
selected = 1;
}
diff --git a/protocols/JabberG/src/jabber_caps.cpp b/protocols/JabberG/src/jabber_caps.cpp index 9a37025b92..524ece8816 100644 --- a/protocols/JabberG/src/jabber_caps.cpp +++ b/protocols/JabberG/src/jabber_caps.cpp @@ -195,16 +195,16 @@ JabberCapsBits CJabberProto::GetTotalJidCapabilites(const TCHAR *jid) JabberCapsBits jcbToReturn = JABBER_RESOURCE_CAPS_NONE;
// get bare jid info only if where is no resources
- if ( !item || (item && !item->resourceCount)) {
+ if ( !item || (item && !item->arResources.getCount())) {
jcbToReturn = GetResourceCapabilites(szBareJid, FALSE);
if (jcbToReturn & JABBER_RESOURCE_CAPS_ERROR)
jcbToReturn = JABBER_RESOURCE_CAPS_NONE;
}
if (item) {
- for (int i = 0; i < item->resourceCount; i++) {
+ for (int i = 0; i < item->arResources.getCount(); i++) {
TCHAR szFullJid[JABBER_MAX_JID_LEN];
- mir_sntprintf(szFullJid, JABBER_MAX_JID_LEN, _T("%s/%s"), szBareJid, item->pResources[i].resourceName);
+ mir_sntprintf(szFullJid, JABBER_MAX_JID_LEN, _T("%s/%s"), szBareJid, item->arResources[i]->resourceName);
JabberCapsBits jcb = GetResourceCapabilites(szFullJid, FALSE);
if ( !(jcb & JABBER_RESOURCE_CAPS_ERROR))
jcbToReturn |= jcb;
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp index 5018d5f3be..9b65682856 100644 --- a/protocols/JabberG/src/jabber_chat.cpp +++ b/protocols/JabberG/src/jabber_chat.cpp @@ -309,9 +309,9 @@ void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const TCHAR * gce.ptszStatus = TranslateT("Moderator");
break;
default:
- for (int i=0; i < item->resourceCount; i++) {
- JABBER_RESOURCE_STATUS& JS = item->pResources[i];
- if ( !lstrcmp(resource, JS.resourceName)) {
+ for (int i=0; i < item->arResources.getCount(); i++) {
+ JABBER_RESOURCE_STATUS *JS = item->arResources[i];
+ if ( !lstrcmp(resource, JS->resourceName)) {
if (action != GC_EVENT_JOIN) {
switch(action) {
case 0:
@@ -321,9 +321,9 @@ void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const TCHAR * }
gce.ptszText = TranslateT("Moderator");
}
- gce.ptszStatus = TranslateTS(sttStatuses[JabberGcGetStatus(&JS)]);
+ gce.ptszStatus = TranslateTS(sttStatuses[JabberGcGetStatus(JS)]);
gce.bIsMe = (lstrcmp(nick, myNick) == 0);
- statusToSet = JS.status;
+ statusToSet = JS->status;
break;
} } }
@@ -540,10 +540,10 @@ int CJabberProto::JabberGcMenuHook(WPARAM, LPARAM lParam) return 0;
JABBER_RESOURCE_STATUS *me = NULL, *him = NULL;
- for (int i=0; i < item->resourceCount; i++) {
- JABBER_RESOURCE_STATUS& p = item->pResources[i];
- if ( !lstrcmp(p.resourceName, item->nick )) me = &p;
- if ( !lstrcmp(p.resourceName, gcmi->pszUID)) him = &p;
+ for (int i=0; i < item->arResources.getCount(); i++) {
+ JABBER_RESOURCE_STATUS *p = item->arResources[i];
+ if ( !lstrcmp(p->resourceName, item->nick)) me = p;
+ if ( !lstrcmp(p->resourceName, gcmi->pszUID)) him = p;
}
if (gcmi->Type == MENU_ON_LOG) {
diff --git a/protocols/JabberG/src/jabber_disco.cpp b/protocols/JabberG/src/jabber_disco.cpp index ef850a1e73..41d4d20042 100644 --- a/protocols/JabberG/src/jabber_disco.cpp +++ b/protocols/JabberG/src/jabber_disco.cpp @@ -1442,7 +1442,7 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM if (ListGetItemPtr(LIST_VCARD_TEMP, pNode->GetJid()) == NULL) {
JABBER_LIST_ITEM *item = ListAdd(LIST_VCARD_TEMP, pNode->GetJid());
item->bUseResource = TRUE;
- if (item->pResources == NULL)
+ if (item->arResources.getCount() == 0)
ListAddResource(LIST_VCARD_TEMP, jid, ID_STATUS_OFFLINE, NULL, 0);
}
CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)hContact, 0);
diff --git a/protocols/JabberG/src/jabber_list.cpp b/protocols/JabberG/src/jabber_list.cpp index c33d83140c..548bfc7fa2 100644 --- a/protocols/JabberG/src/jabber_list.cpp +++ b/protocols/JabberG/src/jabber_list.cpp @@ -28,7 +28,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void MenuUpdateSrmmIcon(JABBER_LIST_ITEM *item);
/////////////////////////////////////////////////////////////////////////////////////////
-// List item freeing
+// List item constructor & destructor
+
+JABBER_LIST_ITEM::JABBER_LIST_ITEM() :
+ arResources(1, PtrKeySortT)
+{
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
static void JabberListFreeResourceInternal(JABBER_RESOURCE_STATUS *r)
{
@@ -47,41 +54,40 @@ static void JabberListFreeResourceInternal(JABBER_RESOURCE_STATUS *r) delete r->pSoftwareInfo;
}
-static void JabberListFreeItemInternal(JABBER_LIST_ITEM *item)
+JABBER_LIST_ITEM::~JABBER_LIST_ITEM()
{
- if (item == NULL)
- return;
-
- for (int i=0; i < item->resourceCount; i++)
- JabberListFreeResourceInternal(&item->pResources[i]);
+ for (int i=0; i < arResources.getCount(); i++) {
+ JABBER_RESOURCE_STATUS *r = arResources[i];
+ JabberListFreeResourceInternal(r);
+ mir_free(r);
+ }
+ arResources.destroy();
- JabberListFreeResourceInternal(&item->itemResource);
+ JabberListFreeResourceInternal(&itemResource);
- if (item->photoFileName) {
- if (item->list == LIST_VCARD_TEMP)
- DeleteFile(item->photoFileName);
- mir_free(item->photoFileName);
+ if (photoFileName) {
+ if (list == LIST_VCARD_TEMP)
+ DeleteFile(photoFileName);
+ mir_free(photoFileName);
}
- mir_free(item->jid);
- mir_free(item->nick);
- mir_free(item->pResources);
- mir_free(item->group);
- mir_free(item->messageEventIdStr);
- mir_free(item->name);
- mir_free(item->type);
- mir_free(item->service);
- mir_free(item->password);
- if (item->list == LIST_ROSTER && item->ft)
- delete item->ft;
- mir_free(item);
+ mir_free(jid);
+ mir_free(nick);
+ mir_free(group);
+ mir_free(messageEventIdStr);
+ mir_free(name);
+ mir_free(type);
+ mir_free(service);
+ mir_free(password);
+ if (list == LIST_ROSTER && ft)
+ delete ft;
}
void CJabberProto::ListWipe(void)
{
mir_cslock lck(m_csLists);
for (int i=0; i < m_lstRoster.getCount(); i++)
- JabberListFreeItemInternal(m_lstRoster[i]);
+ delete m_lstRoster[i];
m_lstRoster.destroy();
}
@@ -121,7 +127,7 @@ JABBER_LIST_ITEM *CJabberProto::ListAdd(JABBER_LIST list, const TCHAR *jid) }
}
- item = (JABBER_LIST_ITEM*)mir_calloc(sizeof(JABBER_LIST_ITEM));
+ item = new JABBER_LIST_ITEM();
item->list = list;
item->jid = s;
item->itemResource.status = ID_STATUS_OFFLINE;
@@ -140,7 +146,7 @@ void CJabberProto::ListRemove(JABBER_LIST list, const TCHAR *jid) JABBER_LIST_ITEM *LI = ListGetItemPtr(list, jid);
if (LI != NULL) {
m_lstRoster.remove(LI);
- JabberListFreeItemInternal(LI);
+ delete LI;
}
}
@@ -155,7 +161,7 @@ void CJabberProto::ListRemoveByIndex(int index) {
mir_cslock lck(m_csLists);
if (index >= 0 && index < m_lstRoster.getCount()) {
- JabberListFreeItemInternal(m_lstRoster[index]);
+ delete m_lstRoster[index];
m_lstRoster.remove(index);
}
}
@@ -165,21 +171,21 @@ void CJabberProto::ListRemoveByIndex(int index) JABBER_LIST_ITEM* CJabberProto::ListGetItemPtr(JABBER_LIST list, const TCHAR *jid)
{
- JABBER_LIST_ITEM tmp;
- tmp.list = list;
- tmp.jid = (TCHAR*)jid;
- tmp.bUseResource = FALSE;
+ JABBER_LIST_ITEM *tmp = (JABBER_LIST_ITEM*)alloca( sizeof(JABBER_LIST_ITEM));
+ tmp->list = list;
+ tmp->jid = (TCHAR*)jid;
+ tmp->bUseResource = FALSE;
mir_cslock lck(m_csLists);
if (list == LIST_ROSTER) {
- tmp.list = LIST_CHATROOM;
- int id = m_lstRoster.getIndex(&tmp);
+ tmp->list = LIST_CHATROOM;
+ int id = m_lstRoster.getIndex(tmp);
if (id != -1)
- tmp.bUseResource = TRUE;
- tmp.list = list;
+ tmp->bUseResource = TRUE;
+ tmp->list = list;
}
- return m_lstRoster.find(&tmp);
+ return m_lstRoster.find(tmp);
}
JABBER_LIST_ITEM* CJabberProto::ListGetItemPtrFromIndex(int index)
@@ -207,12 +213,14 @@ int CJabberProto::ListFindNext(JABBER_LIST list, int fromOffset) JABBER_RESOURCE_STATUS* JABBER_LIST_ITEM::findResource(const TCHAR *resourceName) const
{
- if (pResources == NULL || resourceName == NULL || *resourceName == 0)
+ if (arResources.getCount() == 0 || resourceName == NULL || *resourceName == 0)
return NULL;
- for (int i=0; i < resourceCount; i++)
- if ( !_tcscmp(pResources[i].resourceName, resourceName))
- return pResources + i;
+ for (int i=0; i < arResources.getCount(); i++) {
+ JABBER_RESOURCE_STATUS *r = arResources[i];
+ if ( !_tcscmp(r->resourceName, resourceName))
+ return r;
+ }
return NULL;
}
@@ -250,9 +258,8 @@ int CJabberProto::ListAddResource(JABBER_LIST list, const TCHAR *jid, int status r->priority = priority;
}
else { // Does not exist, add new resource
- LI->pResources = (JABBER_RESOURCE_STATUS *)mir_realloc(LI->pResources, (LI->resourceCount+1)*sizeof(JABBER_RESOURCE_STATUS));
bIsNewResource = true;
- r = LI->pResources + LI->resourceCount++;
+ r = (JABBER_RESOURCE_STATUS*)mir_calloc( sizeof(JABBER_RESOURCE_STATUS));
memset(r, 0, sizeof(JABBER_RESOURCE_STATUS));
r->status = status;
r->affiliation = AFFILIATION_NONE;
@@ -262,6 +269,7 @@ int CJabberProto::ListAddResource(JABBER_LIST list, const TCHAR *jid, int status if (statusMessage)
r->statusMessage = mir_tstrdup(statusMessage);
r->priority = priority;
+ LI->arResources.insert(r);
} }
}
// No resource, update the main statusMessage
@@ -307,17 +315,8 @@ void CJabberProto::ListRemoveResource(JABBER_LIST list, const TCHAR *jid) // Update MirVer due to possible resource changes
UpdateMirVer(LI);
+ LI->arResources.remove(r);
JabberListFreeResourceInternal(r);
-
- if (LI->resourceCount-- == 1) {
- mir_free(r);
- LI->pResources = NULL;
- }
- else {
- memmove(r, r+1, (LI->resourceCount - (r-LI->pResources))*sizeof(JABBER_RESOURCE_STATUS));
- LI->pResources = (JABBER_RESOURCE_STATUS*)mir_realloc(LI->pResources, LI->resourceCount*sizeof(JABBER_RESOURCE_STATUS));
- }
-
lck.unlock();
MenuUpdateSrmmIcon(LI);
@@ -325,11 +324,11 @@ void CJabberProto::ListRemoveResource(JABBER_LIST list, const TCHAR *jid) JABBER_RESOURCE_STATUS* JABBER_LIST_ITEM::getBestResource() const
{
- if (!resourceCount)
+ if (!arResources.getCount())
return NULL;
- if (resourceCount == 1)
- return pResources;
+ if (arResources.getCount() == 1)
+ return arResources[0];
if (resourceMode == RSMODE_LASTSEEN)
return pLastSeenResource;
@@ -338,14 +337,15 @@ JABBER_RESOURCE_STATUS* JABBER_LIST_ITEM::getBestResource() const return pManualResource;
int nBestPos = -1, nBestPri = -200;
- for (int j=0; j < resourceCount; j++) {
- if (pResources[j].priority > nBestPri) {
- nBestPri = pResources[j].priority;
- nBestPos = j;
+ for (int i=0; i < arResources.getCount(); i++) {
+ JABBER_RESOURCE_STATUS *r = arResources[i];
+ if (r->priority > nBestPri) {
+ nBestPri = r->priority;
+ nBestPos = i;
}
}
- return (nBestPos != -1) ? &pResources[nBestPos] : NULL;
+ return (nBestPos != -1) ? arResources[nBestPos] : NULL;
}
TCHAR* CJabberProto::ListGetBestClientResourceNamePtr(const TCHAR *jid)
@@ -361,8 +361,8 @@ TCHAR* CJabberProto::ListGetBestClientResourceNamePtr(const TCHAR *jid) int status = ID_STATUS_OFFLINE;
TCHAR *res = NULL;
- for (int i=0; i < LI->resourceCount; i++) {
- r = &LI->pResources[i];
+ for (int i=0; i < LI->arResources.getCount(); i++) {
+ r = LI->arResources[i];
bool foundBetter = false;
switch (r->status) {
case ID_STATUS_FREECHAT:
diff --git a/protocols/JabberG/src/jabber_list.h b/protocols/JabberG/src/jabber_list.h index 2f8f5c4edb..9df9b7b710 100644 --- a/protocols/JabberG/src/jabber_list.h +++ b/protocols/JabberG/src/jabber_list.h @@ -105,6 +105,9 @@ struct JABBER_RESOURCE_STATUS struct JABBER_LIST_ITEM : public MZeroedObject
{
+ JABBER_LIST_ITEM();
+ ~JABBER_LIST_ITEM();
+
JABBER_LIST list;
TCHAR* jid;
@@ -115,9 +118,8 @@ struct JABBER_LIST_ITEM : public MZeroedObject JABBER_RESOURCE_STATUS* findResource(const TCHAR *resourceName) const;
JABBER_RESOURCE_STATUS* getBestResource() const;
JABBER_RESOURCE_MODE resourceMode;
- int resourceCount;
+ LIST<JABBER_RESOURCE_STATUS> arResources; // array of resources
JABBER_RESOURCE_STATUS
- *pResources, // array of resources
*pLastSeenResource, // resource which was last seen active
*pManualResource, // manually set resource
itemResource; // resource for jids without /resource node
diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp index e70e94d14d..ed29d6ab75 100644 --- a/protocols/JabberG/src/jabber_menu.cpp +++ b/protocols/JabberG/src/jabber_menu.cpp @@ -406,7 +406,7 @@ int CJabberProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM) Menu_ShowItem(g_hMenuCommands, ((jcb & JABBER_CAPS_COMMANDS) != 0) || bCtrlPressed);
Menu_ShowItem(g_hMenuSendNote, TRUE);
- if (item->resourceCount >= 1) {
+ if (item->arResources.getCount() >= 1) {
Menu_ShowItem(g_hMenuResourcesRoot, TRUE);
CLISTMENUITEM mi = { sizeof(mi) };
@@ -421,9 +421,9 @@ int CJabberProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM) Menu_ModifyItem(g_hMenuResourcesServer, &mi);
int nMenuResourceItemsNew = m_nMenuResourceItems;
- if (m_nMenuResourceItems < item->resourceCount) {
- m_phMenuResourceItems = (HGENMENU*)mir_realloc(m_phMenuResourceItems, item->resourceCount * sizeof(HGENMENU));
- nMenuResourceItemsNew = item->resourceCount;
+ if (m_nMenuResourceItems < item->arResources.getCount()) {
+ m_phMenuResourceItems = (HGENMENU*)mir_realloc(m_phMenuResourceItems, item->arResources.getCount() * sizeof(HGENMENU));
+ nMenuResourceItemsNew = item->arResources.getCount();
}
char text[ 256 ];
@@ -447,18 +447,18 @@ int CJabberProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM) mi.hParentMenu = g_hMenuResourcesRoot;
m_phMenuResourceItems[i] = Menu_AddContactMenuItem(&mi);
}
- if (i < item->resourceCount) {
- JABBER_RESOURCE_STATUS &r = item->pResources[i];
+ if (i < item->arResources.getCount()) {
+ JABBER_RESOURCE_STATUS *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))
+ if ((item->resourceMode == RSMODE_MANUAL) && (item->pManualResource == r))
clmi.flags |= CMIF_CHECKED;
if (ServiceExists(MS_FP_GETCLIENTICONT)) {
clmi.flags |= CMIM_ICON;
- FormatMirVer(&r, szTmp, SIZEOF(szTmp));
+ FormatMirVer(r, szTmp, SIZEOF(szTmp));
clmi.hIcon = (HICON)CallService(MS_FP_GETCLIENTICONT, (WPARAM)szTmp, 0);
}
- mir_sntprintf(szTmp, SIZEOF(szTmp), _T("%s [%s, %d]"), r.resourceName, pcli->pfnGetStatusModeDescription(r.status, 0), r.priority);
+ mir_sntprintf(szTmp, SIZEOF(szTmp), _T("%s [%s, %d]"), r->resourceName, pcli->pfnGetStatusModeDescription(r->status, 0), r->priority);
clmi.ptszName = szTmp;
Menu_ModifyItem(m_phMenuResourceItems[i], &clmi);
DestroyIcon(clmi.hIcon);
@@ -515,7 +515,7 @@ INT_PTR __cdecl CJabberProto::OnMenuRosterAdd(WPARAM wParam, LPARAM) if (m_options.AddRoster2Bookmarks == TRUE) {
JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_BOOKMARK, roomID);
if (item == NULL) {
- item = (JABBER_LIST_ITEM*)mir_calloc(sizeof(JABBER_LIST_ITEM));
+ item = new JABBER_LIST_ITEM();
item->jid = mir_tstrdup(roomID);
item->name = mir_tstrdup(nick);
if ( !getTString((HANDLE)wParam, "MyNick", &dbv)) {
@@ -627,7 +627,7 @@ INT_PTR __cdecl CJabberProto::OnMenuBookmarkAdd(WPARAM wParam, LPARAM) db_free(&dbv);
}
- JABBER_LIST_ITEM *item = (JABBER_LIST_ITEM*)mir_calloc(sizeof(JABBER_LIST_ITEM));
+ JABBER_LIST_ITEM *item = new JABBER_LIST_ITEM();
item->jid = mir_tstrdup(roomID);
item->name = pcli->pfnGetContactDisplayName(hContact, 0);
item->type = _T("conference");
@@ -1018,7 +1018,7 @@ void CJabberProto::MenuUpdateSrmmIcon(JABBER_LIST_ITEM *item) StatusIconData sid = { sizeof(sid) };
sid.szModule = m_szModuleName;
- sid.flags = item->resourceCount ? 0 : MBF_DISABLED;
+ sid.flags = item->arResources.getCount() ? 0 : MBF_DISABLED;
Srmm_ModifyIcon(hContact, &sid);
}
@@ -1098,15 +1098,15 @@ int CJabberProto::OnProcessSrmmIconClick(WPARAM wParam, LPARAM lParam) AppendMenu(hMenu, MF_STRING, MENUITEM_SERVER, TranslateT("Highest priority (server's choice)"));
AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
- for (int i = 0; i < LI->resourceCount; i++)
- AppendMenu(hMenu, MF_STRING, MENUITEM_RESOURCES+i, LI->pResources[i].resourceName);
+ for (int i = 0; i < LI->arResources.getCount(); i++)
+ AppendMenu(hMenu, MF_STRING, MENUITEM_RESOURCES+i, LI->arResources[i]->resourceName);
if (LI->resourceMode == RSMODE_LASTSEEN)
CheckMenuItem(hMenu, MENUITEM_LASTSEEN, MF_BYCOMMAND|MF_CHECKED);
else if (LI->resourceMode == RSMODE_SERVER)
CheckMenuItem(hMenu, MENUITEM_SERVER, MF_BYCOMMAND|MF_CHECKED);
else if (LI->pManualResource)
- CheckMenuItem(hMenu, MENUITEM_RESOURCES + (LI->pManualResource - LI->pResources), MF_BYCOMMAND|MF_CHECKED);
+ CheckMenuItem(hMenu, MENUITEM_RESOURCES + LI->arResources.indexOf(LI->pManualResource), MF_BYCOMMAND|MF_CHECKED);
int res = TrackPopupMenu(hMenu, TPM_RETURNCMD, sicd->clickLocation.x, sicd->clickLocation.y, 0, WindowList_Find(hDialogsList, hContact), NULL);
@@ -1119,7 +1119,7 @@ int CJabberProto::OnProcessSrmmIconClick(WPARAM wParam, LPARAM lParam) LI->resourceMode = RSMODE_SERVER;
}
else if (res >= MENUITEM_RESOURCES) {
- LI->pManualResource = &LI->pResources[res - MENUITEM_RESOURCES];
+ LI->pManualResource = LI->arResources[res - MENUITEM_RESOURCES];
LI->resourceMode = RSMODE_MANUAL;
}
@@ -1155,7 +1155,7 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleResource(WPARAM wParam, LPARAM, LPARAM LI->resourceMode = RSMODE_SERVER;
}
else if (res >= MENUITEM_RESOURCES) {
- LI->pManualResource = &LI->pResources[res - MENUITEM_RESOURCES];
+ LI->pManualResource = LI->arResources[res - MENUITEM_RESOURCES];
LI->resourceMode = RSMODE_MANUAL;
}
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index a8f61f9fb3..047e8f3da6 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -737,23 +737,24 @@ int __cdecl CJabberProto::GetInfo(HANDLE hContact, int /*infoType*/) else item = ListAdd(LIST_VCARD_TEMP, jid);
}
- if (item && item->pResources) {
- for (int i = 0; i < item->resourceCount; i++) {
+ if (item && item->arResources.getCount()) {
+ for (int i = 0; i < item->arResources.getCount(); i++) {
+ JABBER_RESOURCE_STATUS *r = item->arResources[i];
TCHAR szp1[JABBER_MAX_JID_LEN], tmp[JABBER_MAX_JID_LEN];
JabberStripJid(jid, szp1, SIZEOF(szp1));
- mir_sntprintf(tmp, SIZEOF(tmp), _T("%s/%s"), szp1, item->pResources[i].resourceName);
+ mir_sntprintf(tmp, SIZEOF(tmp), _T("%s/%s"), szp1, r->resourceName);
XmlNodeIq iq3(m_iqManager.AddHandler(&CJabberProto::OnIqResultLastActivity, JABBER_IQ_TYPE_GET, tmp, JABBER_IQ_PARSE_FROM));
iq3 << XQUERY(JABBER_FEAT_LAST_ACTIVITY);
m_ThreadInfo->send(iq3);
- if ( !item->pResources[i].dwVersionRequestTime) {
+ if ( !r->dwVersionRequestTime) {
XmlNodeIq iq4(m_iqManager.AddHandler(&CJabberProto::OnIqResultVersion, JABBER_IQ_TYPE_GET, tmp, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_CHILD_TAG_NODE));
iq4 << XQUERY(JABBER_FEAT_VERSION);
m_ThreadInfo->send(iq4);
}
- if ( !item->pResources[i].pSoftwareInfo) {
+ if ( !r->pSoftwareInfo) {
XmlNodeIq iq5(m_iqManager.AddHandler(&CJabberProto::OnIqResultCapsDiscoInfoSI, JABBER_IQ_TYPE_GET, tmp, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE | JABBER_IQ_PARSE_HCONTACT));
iq5 << XQUERY(JABBER_FEAT_DISCO_INFO);
m_ThreadInfo->send(iq5);
@@ -1302,33 +1303,35 @@ void __cdecl CJabberProto::GetAwayMsgThread(void* hContact) DBVARIANT dbv;
JABBER_LIST_ITEM *item;
int i, msgCount;
- size_t len;
if ( !getTString(hContact, "jid", &dbv)) {
if ((item = ListGetItemPtr(LIST_ROSTER, dbv.ptszVal)) != NULL) {
db_free(&dbv);
- if (item->resourceCount > 0) {
- Log("resourceCount > 0");
- JABBER_RESOURCE_STATUS *r = item->pResources;
- len = msgCount = 0;
- for (i=0; i < item->resourceCount; i++)
- if (r[i].statusMessage) {
+ if (item->arResources.getCount() > 0) {
+ Log("arResources.getCount() > 0");
+ size_t len = msgCount = 0;
+ for (i=0; i < item->arResources.getCount(); i++) {
+ JABBER_RESOURCE_STATUS *r = item->arResources[i];
+ if (r->statusMessage) {
msgCount++;
- len += (_tcslen(r[i].resourceName) + _tcslen(r[i].statusMessage) + 8);
+ len += (_tcslen(r->resourceName) + _tcslen(r->statusMessage) + 8);
}
+ }
TCHAR *str = (TCHAR*)alloca(sizeof(TCHAR)*(len+1));
str[0] = str[len] = '\0';
- for (i=0; i < item->resourceCount; i++)
- if (r[i].statusMessage) {
+ for (i=0; i < item->arResources.getCount(); i++) {
+ JABBER_RESOURCE_STATUS *r = item->arResources[i];
+ if (r->statusMessage) {
if (str[0] != '\0') _tcscat(str, _T("\r\n"));
if (msgCount > 1) {
_tcscat(str, _T("("));
- _tcscat(str, r[i].resourceName);
+ _tcscat(str, r->resourceName);
_tcscat(str, _T("): "));
}
- _tcscat(str, r[i].statusMessage);
+ _tcscat(str, r->statusMessage);
}
+ }
ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)str);
return;
diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp index 6e24c20f52..c4fb05571e 100644 --- a/protocols/JabberG/src/jabber_svc.cpp +++ b/protocols/JabberG/src/jabber_svc.cpp @@ -156,7 +156,7 @@ INT_PTR __cdecl CJabberProto::JabberGetAvatarInfo(WPARAM wParam, LPARAM lParam) BOOL isXVcard = getByte(AI->hContact, "AvatarXVcard", 0);
TCHAR szJid[JABBER_MAX_JID_LEN];
- if (item->resourceCount != NULL && !isXVcard) {
+ if (item->arResources.getCount() != NULL && !isXVcard) {
TCHAR *bestResName = ListGetBestClientResourceNamePtr(dbv.ptszVal);
mir_sntprintf(szJid, SIZEOF(szJid), bestResName?_T("%s/%s"):_T("%s"), dbv.ptszVal, bestResName);
}
@@ -806,21 +806,22 @@ LPTSTR CJabberSysInterface::GetResourceList(LPCTSTR jid) if (item == NULL)
return NULL;
- if (item->pResources == NULL)
+ 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; i<item->resourceCount; i++)
- iLen += lstrlen(item->pResources[i].resourceName) + 1;
+ for (i=0; i<item->arResources.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; i<item->resourceCount; i++) {
- lstrcpy(p, item->pResources[i].resourceName);
- p += lstrlen(item->pResources[i].resourceName) + 1;
+ for (i=0; i<item->arResources.getCount(); i++) {
+ JABBER_RESOURCE_STATUS *r = item->arResources[i];
+ lstrcpy(p, r->resourceName);
+ p += lstrlen(r->resourceName) + 1;
}
*p = 0; // extra zero terminator
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index deb993b7a5..e7047594cc 100644 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -1528,7 +1528,7 @@ void CJabberProto::UpdateJidDbSettings(const TCHAR *jid) if ( !hContact) return;
int status = ID_STATUS_OFFLINE;
- if ( !item->resourceCount) {
+ if ( !item->arResources.getCount()) {
// set offline only if jid has resources
if (_tcschr(jid, '/') == NULL)
status = item->itemResource.status;
@@ -1541,25 +1541,27 @@ void CJabberProto::UpdateJidDbSettings(const TCHAR *jid) // Determine status to show for the contact based on the remaining resources
int nSelectedResource = -1, i = 0;
int nMaxPriority = -999; // -128...+127 valid range
- for (i = 0; i < item->resourceCount; i++) {
- if (item->pResources[i].priority > nMaxPriority) {
- nMaxPriority = item->pResources[i].priority;
- status = item->pResources[i].status;
+ for (i = 0; i < item->arResources.getCount(); i++) {
+ JABBER_RESOURCE_STATUS *r = item->arResources[i];
+ if (r->priority > nMaxPriority) {
+ nMaxPriority = r->priority;
+ status = r->status;
nSelectedResource = i;
}
- else if (item->pResources[i].priority == nMaxPriority) {
- if ((status = JabberCombineStatus(status, item->pResources[i].status)) == item->pResources[i].status)
+ else if (r->priority == nMaxPriority) {
+ if ((status = JabberCombineStatus(status, r->status)) == r->status)
nSelectedResource = i;
}
}
item->itemResource.status = status;
if (nSelectedResource != -1) {
- Log("JabberUpdateJidDbSettings: updating jid %S to rc %S", item->jid, item->pResources[nSelectedResource].resourceName);
- if (item->pResources[nSelectedResource].statusMessage)
- db_set_ts(hContact, "CList", "StatusMsg", item->pResources[nSelectedResource].statusMessage);
+ JABBER_RESOURCE_STATUS *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);
else
db_unset(hContact, "CList", "StatusMsg");
- UpdateMirVer(hContact, &item->pResources[nSelectedResource]);
+ UpdateMirVer(hContact, r);
}
else delSetting(hContact, DBSETTING_DISPLAY_UID);
@@ -1714,13 +1716,13 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData* info) hContact = HContactFromJID(from);
if (hContact && db_get_b(hContact, "CList", "NotOnList", 0) == 1) {
// remove selfcontact, if where is no more another resources
- if (item->resourceCount == 1 && ResourceInfoFromJID(info->fullJID))
+ if (item->arResources.getCount() == 1 && ResourceInfoFromJID(info->fullJID))
ListRemoveResource(LIST_ROSTER, info->fullJID);
}
// set status only if no more available resources
- if ( !item->resourceCount) {
+ if ( !item->arResources.getCount()) {
item->itemResource.status = ID_STATUS_OFFLINE;
replaceStrT(item->itemResource.statusMessage, xmlGetText( xmlGetChild(node , "status")));
}
diff --git a/protocols/JabberG/src/jabber_userinfo.cpp b/protocols/JabberG/src/jabber_userinfo.cpp index eddc3c11ed..f8a6852bb5 100644 --- a/protocols/JabberG/src/jabber_userinfo.cpp +++ b/protocols/JabberG/src/jabber_userinfo.cpp @@ -76,7 +76,7 @@ struct JabberUserInfoDlgData CJabberProto* ppro;
HANDLE hContact;
JABBER_LIST_ITEM *item;
- int resourceCount;
+ int resourcesCount;
};
enum
@@ -212,7 +212,7 @@ static void sttFillResourceInfo(CJabberProto *ppro, HWND hwndTree, HTREEITEM hti {
TCHAR buf[256];
HTREEITEM htiResource = htiRoot;
- JABBER_RESOURCE_STATUS *res = resource ? &item->pResources[resource-1] : &item->itemResource;
+ JABBER_RESOURCE_STATUS *res = resource ? item->arResources[resource-1] : &item->itemResource;
if (res->resourceName && *res->resourceName)
htiResource = sttFillInfoLine(hwndTree, htiRoot, LoadSkinnedProtoIcon(ppro->m_szModuleName, res->status),
@@ -392,8 +392,8 @@ static void sttFillUserInfo(CJabberProto *ppro, HWND hwndTree, JABBER_LIST_ITEM sttInfoLineId(0, INFOLINE_LASTACTIVE));
// resources
- if (item->resourceCount) {
- for (int i = 0; i < item->resourceCount; i++)
+ if (item->arResources.getCount()) {
+ for (int i = 0; i < item->arResources.getCount(); i++)
sttFillResourceInfo(ppro, hwndTree, htiRoot, item, i+1);
}
else if ( !_tcschr(item->jid, _T('@')) || (item->itemResource.status != ID_STATUS_OFFLINE))
@@ -443,7 +443,7 @@ static INT_PTR CALLBACK JabberUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa dat = (JabberUserInfoDlgData *)mir_alloc(sizeof(JabberUserInfoDlgData));
ZeroMemory(dat, sizeof(JabberUserInfoDlgData));
- dat->resourceCount = -1;
+ dat->resourcesCount = -1;
if (CallService(MS_DB_CONTACT_IS, (WPARAM)lParam, 0))
dat->hContact = (HANDLE)lParam;
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index 48e492df91..34f429c83b 100644 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.cpp @@ -933,7 +933,7 @@ TCHAR* CJabberProto::GetClientJID(const TCHAR *jid, TCHAR *dest, size_t destLen) mir_cslock lck(m_csLists);
JABBER_LIST_ITEM *LI = ListGetItemPtr(LIST_ROSTER, jid);
if (LI != NULL) {
- if (LI->resourceCount == 1 && !lstrcmp(LI->pResources->szCapsNode, _T("http://talk.google.com/xmpp/bot/caps"))) {
+ if (LI->arResources.getCount() == 1 && !lstrcmp(LI->arResources[0]->szCapsNode, _T("http://talk.google.com/xmpp/bot/caps"))) {
if (p) *p = 0;
return dest;
}
|