コード例 #1
0
void CJabberProto::CheckAllContactsAreTransported()
{
	for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
		ptrT jid( getTStringA(hContact, "jid"));
		if (jid)
			DBCheckIsTransportedContact(jid, hContact);
	}
}
コード例 #2
0
ファイル: jabber_misc.cpp プロジェクト: 0xmono/miranda-ng
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, *p;
	// strip resource if present
	if ((p = _tcschr(s, '@')) != NULL)
		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 = _tcslen(s);
	for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
		ptrT jid( getTStringA(hContact, "jid"));
		if (jid == NULL)
			continue;

		TCHAR *p = jid;
		if (p && _tcslen(p) >= len && (p[len]=='\0'||p[len]=='/') && !_tcsnicmp(p, s, len))
			return hContact;
	}

	MCONTACT hNewContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
	CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hNewContact, (LPARAM)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;
}