summaryrefslogtreecommitdiff
path: root/protocols/JabberG
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-12-22 14:05:14 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-12-22 14:05:14 +0300
commitaf65a46c9d706c396d1e67ec5840b2fbd3d0e70d (patch)
tree774ea0268f234354158087230840ab0c20f58cf2 /protocols/JabberG
parent4ea8606ff81de70d598499c4ef0d89783e244bd2 (diff)
Jabber: "ver" & "softver" are different entities in caps
Diffstat (limited to 'protocols/JabberG')
-rw-r--r--protocols/JabberG/src/jabber_caps.cpp21
-rw-r--r--protocols/JabberG/src/jabber_caps.h8
-rw-r--r--protocols/JabberG/src/jabber_userinfo.cpp81
3 files changed, 51 insertions, 59 deletions
diff --git a/protocols/JabberG/src/jabber_caps.cpp b/protocols/JabberG/src/jabber_caps.cpp
index 5a71713436..dbd3133f29 100644
--- a/protocols/JabberG/src/jabber_caps.cpp
+++ b/protocols/JabberG/src/jabber_caps.cpp
@@ -419,7 +419,7 @@ void CJabberProto::UpdateFeatHash()
CJabberClientPartialCaps::CJabberClientPartialCaps(CJabberClientCaps *pParent, const char *szHash, const char *szVer) :
m_parent(pParent),
m_szHash(mir_strdup(szHash)),
- m_szSoftVer(mir_strdup(szVer))
+ m_szVer(mir_strdup(szVer))
{
m_iTime = time(0);
}
@@ -599,7 +599,7 @@ void CJabberClientCapsManager::Load()
}
for (auto &ver : node["versions"]) {
- std::string szVer = ver["softver"].as_string();
+ std::string szVer = ver["ver"].as_string();
std::string szHash = ver["hash"].as_string();
JabberCapsBits jcbCaps = _atoi64(ver["caps"].as_string().c_str());
@@ -608,6 +608,7 @@ void CJabberClientCapsManager::Load()
res->SetOs(str2buf(ver["os"].as_string()));
res->SetOsVer(str2buf(ver["osver"].as_string()));
res->SetSoft(str2buf(ver["soft"].as_string()));
+ res->SetSoftVer(str2buf(ver["softver"].as_string()));
res->SetSoftMir(str2buf(ver["softmir"].as_string()));
}
}
@@ -625,9 +626,19 @@ void CJabberClientCapsManager::Save()
continue;
JSONNode ver;
- ver << CHAR_PARAM("hash", p->GetHash()) << INT64_PARAM("caps", p->GetCaps()) << INT_PARAM("time", p->GetTime())
- << CHAR_PARAM("os", p->GetOs()) << CHAR_PARAM("osver", p->GetOsVer())
- << CHAR_PARAM("soft", p->GetSoft()) << CHAR_PARAM("softver", p->GetSoftVer()) << CHAR_PARAM("softmir", p->GetSoftMir());
+ ver << CHAR_PARAM("hash", p->GetHash()) << INT64_PARAM("caps", p->GetCaps()) << INT_PARAM("time", p->GetTime());
+ if (p->GetVer())
+ ver << CHAR_PARAM("ver", p->GetVer());
+ if(p->GetOs())
+ ver << CHAR_PARAM("os", p->GetOs());
+ if(p->GetOsVer())
+ ver << CHAR_PARAM("osver", p->GetOsVer());
+ if(p->GetSoft())
+ ver << CHAR_PARAM("soft", p->GetSoft());
+ if(p->GetSoftVer())
+ ver << CHAR_PARAM("softver", p->GetSoftVer());
+ if(p->GetSoftMir())
+ ver << CHAR_PARAM("softmir", p->GetSoftMir());
versions.push_back(ver);
}
diff --git a/protocols/JabberG/src/jabber_caps.h b/protocols/JabberG/src/jabber_caps.h
index 8ed6a24996..0e6bcc5f89 100644
--- a/protocols/JabberG/src/jabber_caps.h
+++ b/protocols/JabberG/src/jabber_caps.h
@@ -265,7 +265,7 @@ typedef unsigned __int64 JabberCapsBits;
class CJabberClientPartialCaps
{
- ptrA m_szHash, m_szOs, m_szOsVer, m_szSoft, m_szSoftVer, m_szSoftMir;
+ ptrA m_szHash, m_szVer, m_szOs, m_szOsVer, m_szSoft, m_szSoftVer, m_szSoftMir;
JabberCapsBits m_jcbCaps = JABBER_RESOURCE_CAPS_UNINIT;
int m_nIqId = -1, m_iTime;
uint32_t m_dwRequestTime = 0;
@@ -304,10 +304,8 @@ public:
__inline int GetIqId() const { return m_nIqId; }
- __inline void SetVer(const char *szVer)
- {
- m_szSoft = mir_strdup(szVer);
- }
+ __inline void SetVer(const char *szVer) { m_szVer = mir_strdup(szVer); }
+ __inline const char* GetVer() const { return m_szVer.get(); }
};
class CJabberClientCaps
diff --git a/protocols/JabberG/src/jabber_userinfo.cpp b/protocols/JabberG/src/jabber_userinfo.cpp
index d606c55d4b..5b991fa908 100644
--- a/protocols/JabberG/src/jabber_userinfo.cpp
+++ b/protocols/JabberG/src/jabber_userinfo.cpp
@@ -234,32 +234,26 @@ class JabberUserInfoDlg : public JabberBaseUserInfoDlg
if (r->m_szResourceName && *r->m_szResourceName)
htiResource = FillInfoLine(htiRoot, Skin_LoadProtoIcon(ppro->m_szModuleName, r->m_iStatus),
- TranslateT("Resource"), r->m_szResourceName, sttInfoLineId(resource, INFOLINE_NAME), true);
+ nullptr, r->m_szResourceName, sttInfoLineId(resource, INFOLINE_NAME), true);
// StatusMsg
- FillInfoLine(htiResource, nullptr /*Skin_LoadIcon(SKINICON_EVENT_MESSAGE)*/,
- TranslateT("Message"), r->m_szStatusMessage,
- sttInfoLineId(resource, INFOLINE_MESSAGE));
+ if (r->m_szStatusMessage)
+ FillInfoLine(htiResource, nullptr, TranslateT("Message"), r->m_szStatusMessage, sttInfoLineId(resource, INFOLINE_MESSAGE));
// Software
if (CJabberClientPartialCaps *pCaps = r->m_pCaps) {
HICON hIcon = nullptr;
if (Finger_IsPresent()) {
- if (pCaps->GetSoft()) {
+ if (pCaps->GetVer()) {
wchar_t buf[256];
- mir_snwprintf(buf, L"%s %s", pCaps->GetSoft(), pCaps->GetSoftVer());
+ mir_snwprintf(buf, L"%S %S", pCaps->GetVer(), pCaps->GetSoftVer());
hIcon = Finger_GetClientIcon(buf, 0);
}
}
- FillInfoLine(htiResource, hIcon, TranslateT("Software"), pCaps->GetSoft(), sttInfoLineId(resource, INFOLINE_SOFTWARE));
-
- // Version
- FillInfoLine(htiResource, nullptr, TranslateT("Version"), pCaps->GetSoftMir() ? pCaps->GetSoftMir() : pCaps->GetSoftVer(), sttInfoLineId(resource, INFOLINE_VERSION));
-
- // System
- FillInfoLine(htiResource, nullptr, TranslateT("System"), pCaps->GetOsVer() ? pCaps->GetOsVer() : pCaps->GetOs(), sttInfoLineId(resource, INFOLINE_SYSTEM));
+ if (pCaps->GetVer())
+ FillInfoLine(htiResource, hIcon, TranslateT("Software"), pCaps->GetVer(), sttInfoLineId(resource, INFOLINE_SOFTWARE));
if (hIcon)
DestroyIcon(hIcon);
@@ -268,17 +262,12 @@ class JabberUserInfoDlg : public JabberBaseUserInfoDlg
// Resource priority
char buf[256];
itoa(r->m_iPriority, buf, 10);
- FillInfoLine(htiResource, nullptr, TranslateT("Resource priority"), buf, sttInfoLineId(resource, INFOLINE_PRIORITY));
+ FillInfoLine(htiResource, nullptr, TranslateT("Priority"), buf, sttInfoLineId(resource, INFOLINE_PRIORITY));
// Idle
- if (r->m_dwIdleStartTime != -1) {
- if (r->m_dwIdleStartTime != 0) {
- mir_strncpy(buf, ctime(&r->m_dwIdleStartTime), _countof(buf));
- size_t len = mir_strlen(buf);
- if (len > 0)
- buf[len - 1] = 0;
- }
- else mir_strncpy(buf, TranslateU("<currently online>"), _countof(buf));
+ if (r->m_dwIdleStartTime > 0) {
+ struct tm *lt = localtime(&r->m_dwIdleStartTime);
+ mir_snprintf(buf, "%d.%d.%d %d:%d", lt->tm_mday, lt->tm_mon, 1900 + lt->tm_year, lt->tm_hour, lt->tm_min);
FillInfoLine(htiResource, nullptr, TranslateT("Last activity"), buf, sttInfoLineId(resource, INFOLINE_IDLE));
}
@@ -286,7 +275,7 @@ class JabberUserInfoDlg : public JabberBaseUserInfoDlg
// caps
JabberCapsBits jcb = ppro->GetResourceCapabilities(MakeJid(item->jid, r->m_szResourceName), r);
if (!(jcb & JABBER_RESOURCE_CAPS_ERROR)) {
- HTREEITEM htiCaps = FillInfoLine(htiResource, IcoLib_GetIconByHandle(ppro->m_hProtoIcon), nullptr, TranslateU("Client capabilities"), sttInfoLineId(resource, INFOLINE_CAPS));
+ HTREEITEM htiCaps = FillInfoLine(htiResource, IcoLib_GetIconByHandle(ppro->m_hProtoIcon), nullptr, TranslateU("Client capabilities (only ones known to Miranda)"), sttInfoLineId(resource, INFOLINE_CAPS));
int i;
for (i = 0; i < g_cJabberFeatCapPairs; i++)
if (jcb & g_JabberFeatCapPairs[i].jcbCap) {
@@ -310,20 +299,22 @@ class JabberUserInfoDlg : public JabberBaseUserInfoDlg
}
}
- // Software info
- HTREEITEM htiSoftwareInfo = FillInfoLine(htiResource, IcoLib_GetIconByHandle(ppro->m_hProtoIcon), nullptr, TranslateU("Software information"), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION));
- int nLineId = 0;
+ // Software info if extended one available
if (CJabberClientPartialCaps *pCaps = r->m_pCaps) {
- if (pCaps->GetOs())
- FillInfoLine(htiSoftwareInfo, nullptr, TranslateT("Operating system"), pCaps->GetOs(), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++));
- if (pCaps->GetOsVer())
- FillInfoLine(htiSoftwareInfo, nullptr, TranslateT("Operating system version"), pCaps->GetOsVer(), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++));
- if (pCaps->GetSoft())
- FillInfoLine(htiSoftwareInfo, nullptr, TranslateT("Software"), pCaps->GetSoft(), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++));
- if (pCaps->GetSoftVer())
- FillInfoLine(htiSoftwareInfo, nullptr, TranslateT("Software version"), pCaps->GetSoftVer(), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++));
- if (pCaps->GetSoftMir())
- FillInfoLine(htiSoftwareInfo, nullptr, TranslateT("Miranda core version"), pCaps->GetSoftMir(), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++));
+ if (pCaps->GetSoft() || pCaps->GetSoftVer() || pCaps->GetOs() || pCaps->GetOsVer() || pCaps->GetSoftMir()) {
+ HTREEITEM htiSoftwareInfo = FillInfoLine(htiResource, IcoLib_GetIconByHandle(ppro->m_hProtoIcon), nullptr, TranslateU("Software information"), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION));
+ int nLineId = 0;
+ if (pCaps->GetOs())
+ FillInfoLine(htiSoftwareInfo, nullptr, TranslateT("Operating system"), pCaps->GetOs(), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++));
+ if (pCaps->GetOsVer())
+ FillInfoLine(htiSoftwareInfo, nullptr, TranslateT("Operating system version"), pCaps->GetOsVer(), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++));
+ if (pCaps->GetSoft())
+ FillInfoLine(htiSoftwareInfo, nullptr, TranslateT("Software"), pCaps->GetSoft(), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++));
+ if (pCaps->GetSoftVer())
+ FillInfoLine(htiSoftwareInfo, nullptr, TranslateT("Software version"), pCaps->GetSoftVer(), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++));
+ if (pCaps->GetSoftMir())
+ FillInfoLine(htiSoftwareInfo, nullptr, TranslateT("Miranda core version"), pCaps->GetSoftMir(), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++));
+ }
}
}
@@ -333,7 +324,7 @@ class JabberUserInfoDlg : public JabberBaseUserInfoDlg
CleanupInfo(0);
- HTREEITEM htiRoot = FillInfoLine(nullptr, IcoLib_GetIconByHandle(ppro->m_hProtoIcon), L"JID", item->jid, sttInfoLineId(0, INFOLINE_NAME), true);
+ HTREEITEM htiRoot = FillInfoLine(nullptr, IcoLib_GetIconByHandle(ppro->m_hProtoIcon), nullptr, item->jid, sttInfoLineId(0, INFOLINE_NAME), true);
if (MCONTACT hContact = ppro->HContactFromJID(item->jid)) {
FillAdvStatusInfo(htiRoot, sttInfoLineId(0, INFOLINE_MOOD), hContact, TranslateT("Mood"), ADVSTATUS_MOOD);
@@ -360,14 +351,9 @@ class JabberUserInfoDlg : public JabberBaseUserInfoDlg
// logoff
char buf[256];
JABBER_RESOURCE_STATUS *r = item->getTemp();
- if (r->m_dwIdleStartTime != -1) {
- if (r->m_dwIdleStartTime > 0) {
- mir_strncpy(buf, ctime(&r->m_dwIdleStartTime), _countof(buf));
- size_t len = mir_strlen(buf);
- if (len > 0)
- buf[len - 1] = 0;
- }
- else mir_strncpy(buf, TranslateU("<currently online>"), _countof(buf));
+ if (r->m_dwIdleStartTime > 0) {
+ struct tm *lt = localtime(&r->m_dwIdleStartTime);
+ mir_snprintf(buf, "%d.%d.%d %d:%d", lt->tm_mday, lt->tm_mon, 1900 + lt->tm_year, lt->tm_hour, lt->tm_min);
FillInfoLine(htiRoot, nullptr,
(item->jid && strchr(item->jid, '@')) ? TranslateT("Last logoff time") : TranslateT("Uptime"), buf,
@@ -379,10 +365,7 @@ class JabberUserInfoDlg : public JabberBaseUserInfoDlg
// activity
if (item->m_pLastSeenResource)
- mir_strncpy(buf, item->m_pLastSeenResource->m_szResourceName, _countof(buf));
- else
- mir_strncpy(buf, TranslateU("<no information available>"), _countof(buf));
- FillInfoLine(htiRoot, nullptr, TranslateT("Last active resource"), buf, sttInfoLineId(0, INFOLINE_LASTACTIVE));
+ FillInfoLine(htiRoot, nullptr, TranslateT("Last active resource"), item->m_pLastSeenResource->m_szResourceName, sttInfoLineId(0, INFOLINE_LASTACTIVE));
// resources
if (item->arResources.getCount()) {