void CJabberProto::ResolveTransportNicks(const TCHAR *jid) { // Set all contacts to offline MCONTACT hContact = m_ThreadInfo->resolveContact; if (hContact == NULL) hContact = db_find_first(m_szModuleName); for (; hContact != NULL; hContact = db_find_next(hContact, m_szModuleName)) { if (!getByte(hContact, "IsTransported", 0)) continue; ptrT dbJid( getTStringA(hContact, "jid")); if (dbJid == NULL) continue; ptrT dbNick( getTStringA(hContact, "Nick")); if (dbNick == NULL) continue; TCHAR *p = _tcschr(dbJid, '@'); if (p == NULL) continue; *p = 0; if (!lstrcmp(jid, p+1) && !lstrcmp(dbJid, dbNick)) { *p = '@'; m_ThreadInfo->resolveID = SendGetVcard(dbJid); m_ThreadInfo->resolveContact = hContact; return; } } m_ThreadInfo->resolveID = -1; m_ThreadInfo->resolveContact = NULL; }
MCONTACT CJabberProto::DBCreateContact(const TCHAR *jid, const TCHAR *nick, BOOL temporary, BOOL stripResource) { if (jid == NULL || jid[0] == '\0') return NULL; TCHAR *s = NEWTSTR_ALLOCA(jid); TCHAR *q = NULL; // strip resource if present if (TCHAR *p = _tcschr(s, '@')) if ((q = _tcschr(p, '/')) != NULL) *q = '\0'; if (!stripResource && q != NULL) // so that resource is not stripped *q = '/'; // We can't use JabberHContactFromJID() here because of the stripResource option size_t len = mir_tstrlen(s); for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { ptrT dbJid(getTStringA(hContact, "jid")); if (dbJid == NULL) continue; TCHAR *p = dbJid; // not null if (_tcslen(p) >= len && (p[len] == '\0' || p[len] == '/') && !_tcsnicmp(p, s, len)) return hContact; } MCONTACT hNewContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0); Proto_AddToContact(hNewContact, m_szModuleName); setTString(hNewContact, "jid", s); if (nick != NULL && *nick != '\0') setTString(hNewContact, "Nick", nick); if (temporary) db_set_b(hNewContact, "CList", "NotOnList", 1); else SendGetVcard(s); debugLog(_T("Create Jabber contact jid=%s, nick=%s"), s, nick); DBCheckIsTransportedContact(s, hNewContact); return hNewContact; }