summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src/jabber_util.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-12-23 18:52:25 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-12-23 18:52:25 +0000
commit4b283b1cf3004aebbb1f4807456a2cd0fdb5f30c (patch)
tree00ee44be29c5ac306109eb2cd9d1fc7047644b3f /protocols/JabberG/src/jabber_util.cpp
parentaf8c5b336e9609ed9c53b877dd7f57fb3d7194b9 (diff)
- XEP-0136 support (server-side message history);
- code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@2816 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG/src/jabber_util.cpp')
-rw-r--r--protocols/JabberG/src/jabber_util.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp
index 3c9dbc4b71..924270fc27 100644
--- a/protocols/JabberG/src/jabber_util.cpp
+++ b/protocols/JabberG/src/jabber_util.cpp
@@ -197,6 +197,17 @@ JABBER_RESOURCE_STATUS* CJabberProto::ResourceInfoFromJID(const TCHAR *jid)
return r;
}
+JABBER_LIST_ITEM* CJabberProto::GetItemFromContact(HANDLE hContact)
+{
+ DBVARIANT dbv;
+ if (JGetStringT(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;
@@ -1254,6 +1265,31 @@ void CJabberProto::RebuildInfoFrame()
}
////////////////////////////////////////////////////////////////////////
+// time2str & str2time
+
+TCHAR* time2str(time_t _time, TCHAR *buf, size_t bufLen)
+{
+ struct tm* T = localtime(&_time);
+ mir_sntprintf(buf, bufLen, _T("%04d-%02d-%02dT%02d:%02d:%02dZ"),
+ T->tm_year+1900, T->tm_mon+1, T->tm_mday, T->tm_hour, T->tm_min, T->tm_sec);
+ return buf;
+}
+
+time_t str2time(const TCHAR *buf)
+{
+ struct tm T = { 0 };
+ if ( _stscanf(buf, _T("%04d-%02d-%02dT%02d:%02d:%02dZ"), &T.tm_year, &T.tm_mon, &T.tm_mday, &T.tm_hour, &T.tm_min, &T.tm_sec) != 6) {
+ int boo;
+ if ( _stscanf(buf, _T("%04d-%02d-%02dT%02d:%02d:%02d.%dZ"), &T.tm_year, &T.tm_mon, &T.tm_mday, &T.tm_hour, &T.tm_min, &T.tm_sec, &boo) != 7)
+ return 0;
+ }
+
+ T.tm_year -= 1900;
+ T.tm_mon--;
+ return mktime(&T);
+}
+
+////////////////////////////////////////////////////////////////////////
// case-insensitive _tcsstr
const TCHAR *JabberStrIStr(const TCHAR *str, const TCHAR *substr)
{