Esempio n. 1
0
	void OnSubmit(CCtrlButton*)
	{
		HXML queryNode, xNode;
		const TCHAR *from;

		if (m_agentRegIqNode == NULL) return;
		if ((from = XmlGetAttrValue(m_agentRegIqNode, _T("from"))) == NULL) return;
		if ((queryNode = XmlGetChild(m_agentRegIqNode ,  "query")) == NULL) return;
		HWND hFrame = GetDlgItem(m_hwnd, IDC_FRAME);

		TCHAR *str2 = (TCHAR*)alloca(sizeof(TCHAR) * 128);
		int id = 0;

		XmlNodeIq iq( m_proto->AddIQ(&CJabberProto::OnIqResultSetRegister, JABBER_IQ_TYPE_SET, from));
		HXML query = iq << XQUERY(JABBER_FEAT_REGISTER);

		if ((xNode = XmlGetChild(queryNode , "x")) != NULL) {
			// use new jabber:x:data form
			HXML n = JabberFormGetData(hFrame, xNode);
			XmlAddChild(query, n);
			xmlDestroyNode(n);
		}
		else {
			// use old registration information form
			for (int i=0; ; i++) {
				HXML n = XmlGetChild(queryNode ,i);
				if (!n)
					break;

				if (XmlGetName(n)) {
					if (!mir_tstrcmp(XmlGetName(n), _T("key"))) {
						// field that must be passed along with the registration
						if (XmlGetText(n))
							XmlAddChild(query, XmlGetName(n), XmlGetText(n));
						else
							XmlAddChild(query, XmlGetName(n));
					}
					else if (!mir_tstrcmp(XmlGetName(n), _T("registered")) || !mir_tstrcmp(XmlGetName(n), _T("instructions"))) {
						// do nothing, we will skip these
					}
					else {
						GetDlgItemText(hFrame, id, str2, 128);
						XmlAddChild(query, XmlGetName(n), str2);
						id++;
		}	}	}	}

		m_proto->m_ThreadInfo->send(iq);

		CAgentRegProgressDlg(m_proto, m_hwnd).DoModal();

		Close();
	}
Esempio n. 2
0
HXML __fastcall operator<<(HXML node, const XQUERY& child)
{
	HXML n = XmlAddChild(node, _T("query"));
	if (n)
		XmlAddAttr(n, _T("xmlns"), child.ns);
	return n;
}
Esempio n. 3
0
BOOL CJabberProto::OnIqRequestOOB(HXML, CJabberIqInfo *pInfo)
{
	if (!pInfo->GetFrom() || !pInfo->GetHContact())
		return TRUE;

	HXML n = XmlGetChild(pInfo->GetChildNode(), "url");
	if (!n || !XmlGetText(n))
		return TRUE;

	if (m_options.BsOnlyIBB) {
		// reject
		XmlNodeIq iq(_T("error"), pInfo);
		HXML e = XmlAddChild(iq, _T("error"), _T("File transfer refused")); XmlAddAttr(e, _T("code"), 406);
		m_ThreadInfo->send(iq);
		return TRUE;
	}

	filetransfer *ft = new filetransfer(this);
	ft->std.totalFiles = 1;
	ft->jid = mir_tstrdup(pInfo->GetFrom());
	ft->std.hContact = pInfo->GetHContact();
	ft->type = FT_OOB;
	ft->httpHostName = NULL;
	ft->httpPort = 80;
	ft->httpPath = NULL;

	// Parse the URL
	TCHAR *str = (TCHAR*)XmlGetText(n);	// URL of the file to get
	if (!_tcsnicmp(str, _T("http://"), 7)) {
		TCHAR *p = str + 7, *q;
		if ((q = _tcschr(p, '/')) != NULL) {
			TCHAR text[1024];
			if (q - p < _countof(text)) {
				_tcsncpy_s(text, p, q - p);
				text[q - p] = '\0';
				if ((p = _tcschr(text, ':')) != NULL) {
					ft->httpPort = (WORD)_ttoi(p + 1);
					*p = '\0';
				}
				ft->httpHostName = mir_t2a(text);
			}
		}
	}

	if (pInfo->GetIdStr())
		ft->szId = JabberId2string(pInfo->GetIqId());

	if (ft->httpHostName && ft->httpPath) {
		TCHAR *desc = NULL;

		debugLogA("Host=%s Port=%d Path=%s", ft->httpHostName, ft->httpPort, ft->httpPath);
		if ((n = XmlGetChild(pInfo->GetChildNode(), "desc")) != NULL)
			desc = (TCHAR*)XmlGetText(n);

		TCHAR *str2;
		debugLog(_T("description = %s"), desc);
		if ((str2 = _tcsrchr(ft->httpPath, '/')) != NULL)
			str2++;
		else
			str2 = ft->httpPath;
		str2 = mir_tstrdup(str2);
		JabberHttpUrlDecode(str2);

		PROTORECVFILET pre;
		pre.dwFlags = PRFF_TCHAR;
		pre.timestamp = time(NULL);
		pre.descr.t = desc;
		pre.files.t = &str2;
		pre.fileCount = 1;
		pre.lParam = (LPARAM)ft;
		ProtoChainRecvFile(ft->std.hContact, &pre);
		mir_free(str2);
	}
	else {
		// reject
		XmlNodeIq iq(_T("error"), pInfo);
		HXML e = XmlAddChild(iq, _T("error"), _T("File transfer refused")); XmlAddAttr(e, _T("code"), 406);
		m_ThreadInfo->send(iq);
		delete ft;
	}
	return TRUE;
}
Esempio n. 4
0
HXML __fastcall operator<<(HXML node, const XCHILDNS& child)
{
	HXML res = XmlAddChild(node, child.name);
	XmlAddAttr(res, _T("xmlns"), child.ns);
	return res;
}