summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-09-23 08:08:32 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-09-23 08:08:32 +0000
commit83181e39a7613a9ed00c6c7ddcbea59a340d491e (patch)
tree875f2c835adb77d2bd27d6a8566c005bc7507e2e /protocols
parent4d048a498cfaf2eff47167714d37e11f451135de (diff)
automatic allocator for a temp resource item
git-svn-id: http://svn.miranda-ng.org/main/trunk@6192 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/JabberG/src/jabber_chat.cpp49
-rw-r--r--protocols/JabberG/src/jabber_disco.cpp4
-rw-r--r--protocols/JabberG/src/jabber_groupchat.cpp2
-rw-r--r--protocols/JabberG/src/jabber_list.cpp63
-rw-r--r--protocols/JabberG/src/jabber_list.h3
-rw-r--r--protocols/JabberG/src/jabber_menu.cpp2
-rw-r--r--protocols/JabberG/src/jabber_opt.cpp4
-rw-r--r--protocols/JabberG/src/jabber_proto.cpp9
-rw-r--r--protocols/JabberG/src/jabber_thread.cpp12
-rw-r--r--protocols/JabberG/src/jabber_userinfo.cpp35
-rw-r--r--protocols/JabberG/src/jabber_util.cpp2
11 files changed, 93 insertions, 92 deletions
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp
index f5aa8f541d..ffec5dbc2f 100644
--- a/protocols/JabberG/src/jabber_chat.cpp
+++ b/protocols/JabberG/src/jabber_chat.cpp
@@ -560,9 +560,10 @@ int CJabberProto::JabberGcMenuHook(WPARAM, LPARAM lParam)
sttSetupGcMenuItem(gcmi, 0, FALSE);
int idx = IDM_LINK0;
- if (item->m_pItemResource && item->m_pItemResource->m_tszStatusMessage && *item->m_pItemResource->m_tszStatusMessage) {
+ TCHAR *ptszStatusMsg = item->getTemp()->m_tszStatusMessage;
+ if (ptszStatusMsg && *ptszStatusMsg) {
TCHAR *bufPtr = url_buf;
- for (TCHAR *p = _tcsstr(item->m_pItemResource->m_tszStatusMessage, _T("http://")); p && *p; p = _tcsstr(p+1, _T("http://"))) {
+ for (TCHAR *p = _tcsstr(ptszStatusMsg, _T("http://")); p && *p; p = _tcsstr(p+1, _T("http://"))) {
lstrcpyn(bufPtr, p, SIZEOF(url_buf) - (bufPtr - url_buf));
gc_item *pItem = sttFindGcMenuItem(gcmi, idx);
pItem->pszDesc = bufPtr;
@@ -570,7 +571,8 @@ int CJabberProto::JabberGcMenuHook(WPARAM, LPARAM lParam)
for (; *bufPtr && !_istspace(*bufPtr); ++bufPtr) ;
*bufPtr++ = 0;
- if (++idx > IDM_LINK9) break;
+ if (++idx > IDM_LINK9)
+ break;
}
}
for (; idx <= IDM_LINK9; ++idx)
@@ -1281,7 +1283,7 @@ static void sttNickListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK*
static void sttLogListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* gch)
{
TCHAR szCaption[1024], szBuffer[1024];
- szBuffer[ 0 ] = _T('\0');
+ szBuffer[0] = 0;
switch(gch->dwData) {
case IDM_LST_PARTICIPANT:
@@ -1311,23 +1313,22 @@ static void sttLogListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* g
case IDM_TOPIC:
mir_sntprintf(szCaption, SIZEOF(szCaption), TranslateT("Set topic for %s"), gch->pDest->ptszID);
{
- size_t cbLen = 2048 + lstrlen(item->m_pItemResource->m_tszStatusMessage)*2;
- ptrT ptszBuf((TCHAR*)mir_alloc( sizeof(TCHAR) * cbLen));
- if (item->m_pItemResource->m_tszStatusMessage) {
+ LPCTSTR s = item->getTemp()->m_tszStatusMessage;
+ size_t cbLen = 2048 + lstrlen(s)*2;
+ TCHAR *ptszBuf = (TCHAR*)_alloca(sizeof(TCHAR) * cbLen);
+ if (s) {
TCHAR *d = ptszBuf;
- for (int i = 0; i < (int)cbLen; i++) {
- if (item->m_pItemResource->m_tszStatusMessage[ i ] != _T('\n') || (i && item->m_pItemResource->m_tszStatusMessage[ i - 1 ] == _T('\r')))
- *d++ = item->m_pItemResource->m_tszStatusMessage[ i ];
+ for (size_t i = 0; i < cbLen && s[i] != 0; i++) {
+ if (s[i] != '\n' || (i && s[i-1] == '\r'))
+ *d++ = s[i];
else {
- *d++ = _T('\r');
- *d++ = _T('\n');
+ *d++ = '\r';
+ *d++ = '\n';
}
- if ( !item->m_pItemResource->m_tszStatusMessage[ i ])
- break;
}
*d = 0;
}
- else ptszBuf[0] = 0;
+ else *ptszBuf = 0;
if (ppro->EnterString(ptszBuf, cbLen, szCaption, JES_RICHEDIT, "gcTopic_"))
ppro->m_ThreadInfo->send(
@@ -1339,7 +1340,7 @@ static void sttLogListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* g
case IDM_NICK:
mir_sntprintf(szCaption, SIZEOF(szCaption), TranslateT("Change nickname in %s"), gch->pDest->ptszID);
if (item->nick)
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s"), item->nick);
+ _tcsncpy_s(szBuffer, SIZEOF(szBuffer), item->nick, _TRUNCATE);
if (ppro->EnterString(szBuffer, SIZEOF(szBuffer), szCaption, JES_COMBO, "gcNick_")) {
JABBER_LIST_ITEM *item = ppro->ListGetItemPtr(LIST_CHATROOM, gch->pDest->ptszID);
if (item != NULL) {
@@ -1350,11 +1351,8 @@ static void sttLogListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* g
break;
case IDM_INVITE:
- {
- CGroupchatInviteDlg *dlg = new CGroupchatInviteDlg(ppro, gch->pDest->ptszID);
- dlg->Show();
+ (new CGroupchatInviteDlg(ppro, gch->pDest->ptszID))->Show();
break;
- }
case IDM_CONFIG:
{
@@ -1398,21 +1396,16 @@ static void sttLogListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* g
case IDM_PRESENCE_NA:
case IDM_PRESENCE_DND:
case IDM_PRESENCE_FREE4CHAT:
- {
if (HANDLE h = ppro->HContactFromJID(item->jid))
ppro->OnMenuHandleDirectPresence((WPARAM)h, 0, gch->dwData);
break;
- }
-
case IDM_LINK0: case IDM_LINK1: case IDM_LINK2: case IDM_LINK3: case IDM_LINK4:
case IDM_LINK5: case IDM_LINK6: case IDM_LINK7: case IDM_LINK8: case IDM_LINK9:
{
unsigned idx = IDM_LINK0;
- for (TCHAR *p = _tcsstr(item->m_pItemResource->m_tszStatusMessage, _T("http://")); p && *p; p = _tcsstr(p+1, _T("http://")))
- {
- if (idx == gch->dwData)
- {
+ for (TCHAR *p = _tcsstr(item->getTemp()->m_tszStatusMessage, _T("http://")); p && *p; p = _tcsstr(p+1, _T("http://"))) {
+ if (idx == gch->dwData) {
char *bufPtr, *url = mir_t2a(p);
for (bufPtr = url; *bufPtr && !isspace(*bufPtr); ++bufPtr) ;
*bufPtr++ = 0;
@@ -1431,7 +1424,7 @@ static void sttLogListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* g
JabberCopyText((HWND)CallService(MS_CLUI_GETHWND, 0, 0), item->jid);
break;
case IDM_CPY_TOPIC:
- JabberCopyText((HWND)CallService(MS_CLUI_GETHWND, 0, 0), item->m_pItemResource->m_tszStatusMessage);
+ JabberCopyText((HWND)CallService(MS_CLUI_GETHWND, 0, 0), item->getTemp()->m_tszStatusMessage);
break;
}
}
diff --git a/protocols/JabberG/src/jabber_disco.cpp b/protocols/JabberG/src/jabber_disco.cpp
index dec2a9f62e..0f73122e4b 100644
--- a/protocols/JabberG/src/jabber_disco.cpp
+++ b/protocols/JabberG/src/jabber_disco.cpp
@@ -1229,9 +1229,9 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM
continue;
if ((items[i].flags & SD_FLG_NOTSUBSCRIBED) && (rosterItem && (rosterItem->subscription != SUB_NONE)))
continue;
- if ((items[i].flags & SD_FLG_ONLINE) && rosterItem && (rosterItem->m_pItemResource->m_iStatus != ID_STATUS_OFFLINE))
+ if ((items[i].flags & SD_FLG_ONLINE) && rosterItem && (rosterItem->getTemp()->m_iStatus != ID_STATUS_OFFLINE))
continue;
- if ((items[i].flags & SD_FLG_NOTONLINE) && rosterItem && (rosterItem->m_pItemResource->m_iStatus == ID_STATUS_OFFLINE))
+ if ((items[i].flags & SD_FLG_NOTONLINE) && rosterItem && (rosterItem->getTemp()->m_iStatus == ID_STATUS_OFFLINE))
continue;
if ((items[i].flags & SD_FLG_NORESOURCE) && _tcschr(pNode->GetJid(), _T('/')))
continue;
diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp
index 4bd9b689a1..2913bc6cb1 100644
--- a/protocols/JabberG/src/jabber_groupchat.cpp
+++ b/protocols/JabberG/src/jabber_groupchat.cpp
@@ -1164,7 +1164,7 @@ void CJabberProto::GroupchatProcessMessage(HXML node)
resource = tmpnick;
}
}
- item->m_pItemResource->m_tszStatusMessage = mir_tstrdup(msgText);
+ item->getTemp()->m_tszStatusMessage = mir_tstrdup(msgText);
}
else {
if ((n = xmlGetChildByTag(node , "body", "xml:lang", m_tszSelectedLang)) == NULL)
diff --git a/protocols/JabberG/src/jabber_list.cpp b/protocols/JabberG/src/jabber_list.cpp
index a6f8e6ffb1..d6930918f0 100644
--- a/protocols/JabberG/src/jabber_list.cpp
+++ b/protocols/JabberG/src/jabber_list.cpp
@@ -65,7 +65,8 @@ JABBER_LIST_ITEM::~JABBER_LIST_ITEM()
/////////////////////////////////////////////////////////////////////////////////////////
JABBER_RESOURCE_STATUS::JABBER_RESOURCE_STATUS() :
- m_refCount(1)
+ m_refCount(1),
+ m_iStatus(ID_STATUS_OFFLINE)
{
}
@@ -135,10 +136,6 @@ JABBER_LIST_ITEM *CJabberProto::ListAdd(JABBER_LIST list, const TCHAR *jid)
item->jid = s;
item->resourceMode = RSMODE_LASTSEEN;
item->bUseResource = bUseResource;
- if (!bUseResource) {
- item->m_pItemResource = new JABBER_RESOURCE_STATUS();
- item->m_pItemResource->m_iStatus = ID_STATUS_OFFLINE;
- }
m_lstRoster.insert(item);
lck.unlock();
@@ -177,7 +174,7 @@ void CJabberProto::ListRemoveByIndex(int index)
JABBER_LIST_ITEM* CJabberProto::ListGetItemPtr(JABBER_LIST list, const TCHAR *jid)
{
- JABBER_LIST_ITEM *tmp = (JABBER_LIST_ITEM*)alloca( sizeof(JABBER_LIST_ITEM));
+ JABBER_LIST_ITEM *tmp = (JABBER_LIST_ITEM*)_alloca( sizeof(JABBER_LIST_ITEM));
tmp->list = list;
tmp->jid = (TCHAR*)jid;
tmp->bUseResource = FALSE;
@@ -256,32 +253,34 @@ bool CJabberProto::ListAddResource(JABBER_LIST list, const TCHAR *jid, int statu
const TCHAR *q = _tcschr((p == NULL) ? jid : p, '/');
if (q) {
const TCHAR *resource = q+1;
- if (resource[0]) {
- pResourceStatus r( LI->findResource(resource));
- if (r != NULL) { // Already exists, update status and statusMessage
- r->m_iStatus = status;
+ if (*resource == 0)
+ return 0;
+
+ JABBER_RESOURCE_STATUS *r = LI->findResource(resource);
+ if (r != NULL) { // Already exists, update status and statusMessage
+ r->m_iStatus = status;
+ r->m_tszStatusMessage = mir_tstrdup(statusMessage);
+ r->m_iPriority = priority;
+ }
+ else { // Does not exist, add new resource
+ bIsNewResource = true;
+ r = new JABBER_RESOURCE_STATUS();
+ r->m_iStatus = status;
+ r->m_affiliation = AFFILIATION_NONE;
+ r->m_role = ROLE_NONE;
+ r->m_tszResourceName = mir_tstrdup(resource);
+ r->m_tszNick = mir_tstrdup(nick);
+ if (statusMessage)
r->m_tszStatusMessage = mir_tstrdup(statusMessage);
- r->m_iPriority = priority;
- }
- else { // Does not exist, add new resource
- bIsNewResource = true;
- r = new JABBER_RESOURCE_STATUS();
- r->m_iStatus = status;
- r->m_affiliation = AFFILIATION_NONE;
- r->m_role = ROLE_NONE;
- r->m_tszResourceName = mir_tstrdup(resource);
- r->m_tszNick = mir_tstrdup(nick);
- if (statusMessage)
- r->m_tszStatusMessage = mir_tstrdup(statusMessage);
- r->m_iPriority = priority;
- LI->arResources.insert(r);
- } }
+ r->m_iPriority = priority;
+ LI->arResources.insert(r);
+ }
}
// No resource, update the main statusMessage
else {
- LI->m_pItemResource = new JABBER_RESOURCE_STATUS();
- LI->m_pItemResource->m_iStatus = status;
- LI->m_pItemResource->m_tszStatusMessage = mir_tstrdup(statusMessage);
+ JABBER_RESOURCE_STATUS *r = LI->getTemp();
+ r->m_iStatus = status;
+ r->m_tszStatusMessage = mir_tstrdup(statusMessage);
}
lck.unlock();
@@ -352,6 +351,14 @@ pResourceStatus JABBER_LIST_ITEM::getBestResource() const
return (nBestPos != -1) ? arResources[nBestPos] : NULL;
}
+JABBER_RESOURCE_STATUS* JABBER_LIST_ITEM::getTemp()
+{
+ if (m_pItemResource == NULL)
+ m_pItemResource = new JABBER_RESOURCE_STATUS();
+
+ return m_pItemResource;
+}
+
TCHAR* CJabberProto::ListGetBestClientResourceNamePtr(const TCHAR *jid)
{
mir_cslock lck(m_csLists);
diff --git a/protocols/JabberG/src/jabber_list.h b/protocols/JabberG/src/jabber_list.h
index 08c82bbc1b..d7e9fe8f4d 100644
--- a/protocols/JabberG/src/jabber_list.h
+++ b/protocols/JabberG/src/jabber_list.h
@@ -157,7 +157,8 @@ struct JABBER_LIST_ITEM : public MZeroedObject
JABBER_RESOURCE_STATUS
*m_pLastSeenResource, // resource which was last seen active
*m_pManualResource, // manually set resource
- *m_pItemResource; // resource for jids without /resource node
+ *m_pItemResource, // resource for jids without /resource node
+ *getTemp(); // allocates m_pItemResource if needed
JABBER_SUBSCRIPTION subscription;
TCHAR* group;
diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp
index 7d2ae259a0..4e3f49443b 100644
--- a/protocols/JabberG/src/jabber_menu.cpp
+++ b/protocols/JabberG/src/jabber_menu.cpp
@@ -587,7 +587,7 @@ INT_PTR __cdecl CJabberProto::OnMenuTransportLogin(WPARAM wParam, LPARAM)
JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, jid.ptszVal);
if (item != NULL) {
XmlNode p(_T("presence")); xmlAddAttr(p, _T("to"), item->jid);
- if (item->m_pItemResource->m_iStatus == ID_STATUS_ONLINE)
+ if (item->getTemp()->m_iStatus == ID_STATUS_ONLINE)
xmlAddAttr(p, _T("type"), _T("unavailable"));
m_ThreadInfo->send(p);
}
diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp
index c00e7025d7..2062c06c12 100644
--- a/protocols/JabberG/src/jabber_opt.cpp
+++ b/protocols/JabberG/src/jabber_opt.cpp
@@ -872,8 +872,8 @@ public:
HANDLE hContact = m_proto->HContactFromJID(item->jid);
if (hContact != NULL) {
if (bChecked) {
- if (item->m_pItemResource->m_iStatus != m_proto->getWord(hContact, "Status", ID_STATUS_OFFLINE)) {
- m_proto->setWord(hContact, "Status", (WORD)item->m_pItemResource->m_iStatus);
+ if (item->getTemp()->m_iStatus != m_proto->getWord(hContact, "Status", ID_STATUS_OFFLINE)) {
+ m_proto->setWord(hContact, "Status", (WORD)item->getTemp()->m_iStatus);
} }
else if (m_proto->getWord(hContact, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
m_proto->setWord(hContact, "Status", ID_STATUS_OFFLINE);
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp
index 55fd4c8e7d..14aaaae002 100644
--- a/protocols/JabberG/src/jabber_proto.cpp
+++ b/protocols/JabberG/src/jabber_proto.cpp
@@ -753,14 +753,14 @@ int __cdecl CJabberProto::GetInfo(HANDLE hContact, int /*infoType*/)
m_ThreadInfo->send(iq5);
}
- if ( !r->m_dwVersionRequestTime) {
+ if (r->m_dwVersionRequestTime == 0) {
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);
}
}
}
- else if (item->m_pItemResource && item->m_pItemResource->m_dwVersionRequestTime == 0) {
+ else if (item->getTemp()->m_dwVersionRequestTime == 0) {
XmlNodeIq iq4(m_iqManager.AddHandler(&CJabberProto::OnIqResultVersion, JABBER_IQ_TYPE_GET, item->jid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_CHILD_TAG_NODE));
iq4 << XQUERY(JABBER_FEAT_VERSION);
m_ThreadInfo->send(iq4);
@@ -1337,8 +1337,9 @@ void __cdecl CJabberProto::GetAwayMsgThread(void* hContact)
return;
}
- if (item->m_pItemResource->m_tszStatusMessage != NULL) {
- ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)item->m_pItemResource->m_tszStatusMessage);
+ TCHAR *tszStatusMsg = item->getTemp()->m_tszStatusMessage;
+ if (tszStatusMsg != NULL) {
+ ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)tszStatusMsg);
return;
}
}
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp
index 420544d65c..d12bf6fcff 100644
--- a/protocols/JabberG/src/jabber_thread.cpp
+++ b/protocols/JabberG/src/jabber_thread.cpp
@@ -1517,9 +1517,9 @@ void CJabberProto::UpdateJidDbSettings(const TCHAR *jid)
if ( !item->arResources.getCount()) {
// set offline only if jid has resources
if (_tcschr(jid, '/') == NULL)
- status = item->m_pItemResource->m_iStatus;
- if (item->m_pItemResource->m_tszStatusMessage)
- db_set_ts(hContact, "CList", "StatusMsg", item->m_pItemResource->m_tszStatusMessage);
+ status = item->getTemp()->m_iStatus;
+ if (item->getTemp()->m_tszStatusMessage)
+ db_set_ts(hContact, "CList", "StatusMsg", item->getTemp()->m_tszStatusMessage);
else
db_unset(hContact, "CList", "StatusMsg");
}
@@ -1539,7 +1539,7 @@ void CJabberProto::UpdateJidDbSettings(const TCHAR *jid)
nSelectedResource = i;
}
}
- item->m_pItemResource->m_iStatus = status;
+ item->getTemp()->m_iStatus = status;
if (nSelectedResource != -1) {
pResourceStatus r(item->arResources[nSelectedResource]);
Log("JabberUpdateJidDbSettings: updating jid %S to rc %S", item->jid, r->m_tszResourceName);
@@ -1708,8 +1708,8 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData* info)
// set status only if no more available resources
if ( !item->arResources.getCount()) {
- item->m_pItemResource->m_iStatus = ID_STATUS_OFFLINE;
- item->m_pItemResource->m_tszStatusMessage = mir_tstrdup(xmlGetText( xmlGetChild(node , "status")));
+ item->getTemp()->m_iStatus = ID_STATUS_OFFLINE;
+ item->getTemp()->m_tszStatusMessage = mir_tstrdup(xmlGetText( xmlGetChild(node , "status")));
}
}
else Log("SKIP Receive presence offline from %S (who is not in my roster)", from);
diff --git a/protocols/JabberG/src/jabber_userinfo.cpp b/protocols/JabberG/src/jabber_userinfo.cpp
index 81b8a6d04d..1810d3ec73 100644
--- a/protocols/JabberG/src/jabber_userinfo.cpp
+++ b/protocols/JabberG/src/jabber_userinfo.cpp
@@ -212,7 +212,7 @@ static void sttFillResourceInfo(CJabberProto *ppro, HWND hwndTree, HTREEITEM hti
{
TCHAR buf[256];
HTREEITEM htiResource = htiRoot;
- pResourceStatus r = resource ? item->arResources[resource-1] : item->m_pItemResource;
+ pResourceStatus r = resource ? item->arResources[resource-1] : item->getTemp();
if (r->m_tszResourceName && *r->m_tszResourceName)
htiResource = sttFillInfoLine(hwndTree, htiRoot, LoadSkinnedProtoIcon(ppro->m_szModuleName, r->m_iStatus),
@@ -362,24 +362,23 @@ static void sttFillUserInfo(CJabberProto *ppro, HWND hwndTree, JABBER_LIST_ITEM
}
// logoff
- if (item->m_pItemResource) {
- if (item->m_pItemResource->m_dwIdleStartTime > 0) {
- lstrcpyn(buf, _tctime(&item->m_pItemResource->m_dwIdleStartTime), SIZEOF(buf));
- int len = lstrlen(buf);
- if (len > 0) buf[len-1] = 0;
- }
- else if ( !item->m_pItemResource->m_dwIdleStartTime)
- lstrcpyn(buf, TranslateT("unknown"), SIZEOF(buf));
- else
- lstrcpyn(buf, TranslateT("<not specified>"), SIZEOF(buf));
+ JABBER_RESOURCE_STATUS *r = item->getTemp();
+ if (r->m_dwIdleStartTime > 0) {
+ lstrcpyn(buf, _tctime(&r->m_dwIdleStartTime), SIZEOF(buf));
+ int len = lstrlen(buf);
+ if (len > 0) buf[len-1] = 0;
+ }
+ else if ( !r->m_dwIdleStartTime)
+ lstrcpyn(buf, TranslateT("unknown"), SIZEOF(buf));
+ else
+ lstrcpyn(buf, TranslateT("<not specified>"), SIZEOF(buf));
- sttFillInfoLine(hwndTree, htiRoot, NULL,
- (item->jid && _tcschr(item->jid, _T('@'))) ? TranslateT("Last logoff time") : TranslateT("Uptime"), buf,
- sttInfoLineId(0, INFOLINE_LOGOFF));
+ sttFillInfoLine(hwndTree, htiRoot, NULL,
+ (item->jid && _tcschr(item->jid, _T('@'))) ? TranslateT("Last logoff time") : TranslateT("Uptime"), buf,
+ sttInfoLineId(0, INFOLINE_LOGOFF));
- sttFillInfoLine(hwndTree, htiRoot, NULL, TranslateT("Logoff message"),
- item->m_pItemResource->m_tszStatusMessage ? item->m_pItemResource->m_tszStatusMessage : TranslateT("<not specified>"), sttInfoLineId(0, INFOLINE_LOGOFF_MSG));
- }
+ sttFillInfoLine(hwndTree, htiRoot, NULL, TranslateT("Logoff message"),
+ r->m_tszStatusMessage ? r->m_tszStatusMessage : TranslateT("<not specified>"), sttInfoLineId(0, INFOLINE_LOGOFF_MSG));
// activity
if (item->m_pLastSeenResource)
@@ -395,7 +394,7 @@ static void sttFillUserInfo(CJabberProto *ppro, HWND hwndTree, JABBER_LIST_ITEM
for (int i = 0; i < item->arResources.getCount(); i++)
sttFillResourceInfo(ppro, hwndTree, htiRoot, item, i+1);
}
- else if ( !_tcschr(item->jid, _T('@')) || (item->m_pItemResource->m_iStatus != ID_STATUS_OFFLINE))
+ else if ( !_tcschr(item->jid, _T('@')) || (r->m_iStatus != ID_STATUS_OFFLINE))
sttFillResourceInfo(ppro, hwndTree, htiRoot, item, 0);
sttCleanupInfo(hwndTree, 1);
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp
index 577a71198f..bf8c94a298 100644
--- a/protocols/JabberG/src/jabber_util.cpp
+++ b/protocols/JabberG/src/jabber_util.cpp
@@ -146,7 +146,7 @@ pResourceStatus CJabberProto::ResourceInfoFromJID(const TCHAR *jid)
const TCHAR *p = _tcschr(jid, '/');
if (p == NULL)
- return item->m_pItemResource;
+ return item->getTemp();
return item->findResource(p+1);
}