BOOL CJabberProto::OnIqProcessIqOldTime(HXML, CJabberIqInfo *pInfo) { struct tm *gmt; time_t ltime; TCHAR stime[100], *dtime; _tzset(); time(<ime); gmt = gmtime(<ime); mir_sntprintf(stime, _countof(stime), _T("%.4i%.2i%.2iT%.2i:%.2i:%.2i"), gmt->tm_year + 1900, gmt->tm_mon + 1, gmt->tm_mday, gmt->tm_hour, gmt->tm_min, gmt->tm_sec); dtime = _tctime(<ime); dtime[24] = 0; XmlNodeIq iq(_T("result"), pInfo); HXML queryNode = iq << XQUERY(JABBER_FEAT_ENTITY_TIME_OLD); queryNode << XCHILD(_T("utc"), stime); LPCTSTR szTZName = TimeZone_GetName(NULL); if (szTZName) queryNode << XCHILD(_T("tz"), szTZName); queryNode << XCHILD(_T("display"), dtime); m_ThreadInfo->send(iq); return TRUE; }
// entity time (XEP-0202) support BOOL CJabberProto::OnIqRequestTime(HXML, CJabberIqInfo *pInfo) { TCHAR stime[100]; TCHAR szTZ[10]; TimeZone_PrintDateTime(UTC_TIME_HANDLE, _T("I"), stime, _countof(stime), 0); int nGmtOffset = GetGMTOffset(); mir_sntprintf(szTZ, _countof(szTZ), _T("%+03d:%02d"), nGmtOffset / 60, nGmtOffset % 60); XmlNodeIq iq(_T("result"), pInfo); HXML timeNode = iq << XCHILDNS(_T("time"), JABBER_FEAT_ENTITY_TIME); timeNode << XCHILD(_T("utc"), stime); timeNode << XCHILD(_T("tzo"), szTZ); LPCTSTR szTZName = TimeZone_GetName(NULL); if (szTZName) timeNode << XCHILD(_T("tz"), szTZName); m_ThreadInfo->send(iq); return TRUE; }
char* ChangeInfoData::GetItemSettingText(int i, char *buf, size_t bufsize) { char *text = buf; int alloced = 0; buf[0] = '\0'; const SettingItem &si = setting[i]; SettingItemData &sid = settingData[i]; if (sid.value == 0 && !(si.displayType & LIF_ZEROISVALID)) { if (si.displayType & LIF_CHANGEONLY) text = ICQTranslateUtfStatic(LPGEN("<unremovable once applied>"), buf, bufsize); else text = ICQTranslateUtfStatic(LPGEN("<empty>"), buf, bufsize); } else { switch (si.displayType & LIM_TYPE) { case LI_STRING: case LI_LONGSTRING: text = BinaryToEscapes((char*)sid.value); alloced = 1; break; case LI_NUMBER: _itoa(sid.value, text, 10); break; case LI_LIST: if (si.dbType == DBVT_ASCIIZ) text = ICQTranslateUtfStatic((char*)sid.value, buf, bufsize); else { text = ICQTranslateUtfStatic(LPGEN("Unknown value"), buf, bufsize); FieldNamesItem *list = (FieldNamesItem*)si.pList; if (list == timezonesField) { HANDLE tz = TimeZone_CreateByContact(NULL, ppro->m_szModuleName, 0); text = make_utf8_string_static(TimeZone_GetDescription(TimeZone_GetName(tz)), buf, bufsize); break; } for (int j = 0;; j++) { if (list[j].code == sid.value) { text = ICQTranslateUtfStatic(list[j].text, buf, bufsize); break; } else if (!list[j].text) { if (list[j].code == sid.value) text = ICQTranslateUtfStatic("Unspecified", buf, bufsize); break; } } } break; } } if (si.displayType & LIF_PASSWORD) { if (sid.changed) { for (int j = 0; text[j]; j++) text[j] = '*'; } else { if (alloced) { SAFE_FREE(&text); alloced = 0; } text = "********"; } } if (text != buf) { char *tmp = text; text = null_strcpy(buf, text, bufsize - 1); if (alloced) SAFE_FREE(&tmp); } return text; }