예제 #1
0
XmlNode& XmlNode::operator =(const XmlNode& n)
{
	if (m_hXml)
		xmlDestroyNode(m_hXml);
	m_hXml = xmlCopyNode(n);
	return *this;
}
예제 #2
0
	virtual void OnDestroy()
	{
		xmlDestroyNode(m_agentRegIqNode);
		JabberFormDestroyUI(GetDlgItem(m_hwnd, IDC_FRAME));
		m_proto->m_hwndAgentRegInput = NULL;
		EnableWindow(GetParent(m_hwnd), TRUE);
		SetActiveWindow(GetParent(m_hwnd));
	}
예제 #3
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();
	}
예제 #4
0
XmlNode::~XmlNode()
{
	if (m_hXml) {
		xmlDestroyNode(m_hXml);
		m_hXml = NULL;
}	}
예제 #5
0
void CSkypeProto::OnChatEvent(const JSONNode &node)
{
	//std::string clientMsgId = node["clientmessageid"].as_string();
	//std::string skypeEditedId = node["skypeeditedid"].as_string();

	std::string fromLink = node["from"].as_string();
	CMStringA from(ContactUrlToName(fromLink.c_str()));

	time_t timestamp = IsoToUnixTime(node["composetime"].as_string().c_str());

	std::string content = node["content"].as_string();
	int emoteOffset = node["skypeemoteoffset"].as_int();

	std::string conversationLink = node["conversationLink"].as_string();
	CMStringA chatname(ChatUrlToName(conversationLink.c_str()));

	CMString topic(node["threadtopic"].as_mstring());
	if (FindChatRoom(chatname) == NULL)
		SendRequest(new GetChatInfoRequest(m_szRegToken, chatname, m_szServer), &CSkypeProto::OnGetChatInfo, topic.Detach());

	std::string messageType = node["messagetype"].as_string();
	if (!mir_strcmpi(messageType.c_str(), "Text") || !mir_strcmpi(messageType.c_str(), "RichText"))
	{
		AddMessageToChat(_A2T(chatname), _A2T(from), content.c_str(), emoteOffset != NULL, emoteOffset, timestamp);
	}
	else if (!mir_strcmpi(messageType.c_str(), "ThreadActivity/AddMember"))
	{
		ptrA xinitiator, xtarget, initiator;
		//content = <addmember><eventtime>1429186229164</eventtime><initiator>8:initiator</initiator><target>8:user</target></addmember>

		HXML xml = xmlParseString(ptrT(mir_a2t(content.c_str())), 0, _T("addmember"));
		if (xml == NULL)
			return;

		for (int i = 0; i < xmlGetChildCount(xml); i++)
		{
			HXML xmlNode = xmlGetNthChild(xml, L"target", i);
			if (xmlNode == NULL)
				break;

			xtarget = mir_t2a(xmlGetText(xmlNode));

			CMStringA target = ParseUrl(xtarget, "8:");
			AddChatContact(_A2T(chatname), target, target, L"User");
		}
		xmlDestroyNode(xml);
	}
	else if (!mir_strcmpi(messageType.c_str(), "ThreadActivity/DeleteMember"))
	{
		ptrA xinitiator, xtarget;
		//content = <addmember><eventtime>1429186229164</eventtime><initiator>8:initiator</initiator><target>8:user</target></addmember>

		HXML xml = xmlParseString(ptrT(mir_a2t(content.c_str())), 0, _T("deletemember"));
		if (xml != NULL) {
			HXML xmlNode = xmlGetChildByPath(xml, _T("initiator"), 0);
			xinitiator = node != NULL ? mir_t2a(xmlGetText(xmlNode)) : NULL;

			xmlNode = xmlGetChildByPath(xml, _T("target"), 0);
			xtarget = xmlNode != NULL ? mir_t2a(xmlGetText(xmlNode)) : NULL;

			xmlDestroyNode(xml);
		}
		if (xtarget == NULL)
			return;

		CMStringA target = ParseUrl(xtarget, "8:");
		CMStringA initiator = ParseUrl(xinitiator, "8:");
		RemoveChatContact(_A2T(chatname), target, target, true, initiator);

	}
	else if (!mir_strcmpi(messageType.c_str(), "ThreadActivity/TopicUpdate"))
	{
		//content=<topicupdate><eventtime>1429532702130</eventtime><initiator>8:user</initiator><value>test topic</value></topicupdate>
		ptrA xinitiator, value;
		HXML xml = xmlParseString(ptrT(mir_a2t(content.c_str())), 0, _T("topicupdate"));
		if (xml != NULL) {
			HXML xmlNode = xmlGetChildByPath(xml, _T("initiator"), 0);
			xinitiator = xmlNode != NULL ? mir_t2a(xmlGetText(xmlNode)) : NULL;

			xmlNode = xmlGetChildByPath(xml, _T("value"), 0);
			value = xmlNode != NULL ? mir_t2a(xmlGetText(xmlNode)) : NULL;

			xmlDestroyNode(xml);
		}

		CMStringA initiator = ParseUrl(xinitiator, "8:");
		RenameChat(chatname, value);
		ChangeChatTopic(chatname, value, initiator);
	}
	else if (!mir_strcmpi(messageType.c_str(), "ThreadActivity/RoleUpdate"))
	{
		//content=<roleupdate><eventtime>1429551258363</eventtime><initiator>8:user</initiator><target><id>8:user1</id><role>admin</role></target></roleupdate>
		ptrA xinitiator, xId, xRole;
		HXML xml = xmlParseString(ptrT(mir_a2t(content.c_str())), 0, _T("roleupdate"));
		if (xml != NULL) {
			HXML xmlNode = xmlGetChildByPath(xml, _T("initiator"), 0);
			xinitiator = xmlNode != NULL ? mir_t2a(xmlGetText(xmlNode)) : NULL;

			xmlNode = xmlGetChildByPath(xml, _T("target"), 0);
			if (xmlNode != NULL)
			{
				HXML xmlId = xmlGetChildByPath(xmlNode, _T("id"), 0);
				HXML xmlRole = xmlGetChildByPath(xmlNode, _T("role"), 0);
				xId = xmlId != NULL ? mir_t2a(xmlGetText(xmlId)) : NULL;
				xRole = xmlRole != NULL ? mir_t2a(xmlGetText(xmlRole)) : NULL;
			}
			xmlDestroyNode(xml);
			
			CMStringA initiator = ParseUrl(xinitiator, "8:");
			CMStringA id = ParseUrl(xId, "8:");

			GCDEST gcd = { m_szModuleName, _A2T(chatname), !mir_strcmpi(xRole, "Admin") ? GC_EVENT_ADDSTATUS : GC_EVENT_REMOVESTATUS };
			GCEVENT gce = { sizeof(gce), &gcd };
			ptrT tszId(mir_a2t(id));
			ptrT tszRole(mir_a2t(xRole));
			ptrT tszInitiator(mir_a2t(initiator));
			gce.pDest = &gcd;
			gce.dwFlags = GCEF_ADDTOLOG;
			gce.ptszNick = tszId;
			gce.ptszUID = tszId;
			gce.ptszText = tszInitiator;
			gce.time = time(NULL);
			gce.bIsMe = IsMe(id);
			gce.ptszStatus = TranslateT("Admin");
			CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
		}
	}
}
예제 #6
0
INT_PTR CSkypeProto::GetEventText(WPARAM, LPARAM lParam)
{
	DBEVENTGETTEXT *pEvent = (DBEVENTGETTEXT *)lParam;

	CMStringA szText; 
	BOOL bUseBB = db_get_b(NULL, pEvent->dbei->szModule, "UseBBCodes", 1);
	switch (pEvent->dbei->eventType)
	{
	case SKYPE_DB_EVENT_TYPE_EDITED_MESSAGE:
		{
			
			JSONNode jMsg = JSONNode::parse((char*)pEvent->dbei->pBlob);
			if (jMsg)
			{
				JSONNode &jOriginalMsg = jMsg["original_message"];
				szText.AppendFormat(bUseBB ? Translate("[b]Original message:[/b]\n%s\n") : Translate("Original message:\n%s\n"), mir_utf8decodeA(jOriginalMsg["text"].as_string().c_str()));
				JSONNode &jEdits = jMsg["edits"];
				for (auto it = jEdits.begin(); it != jEdits.end(); ++it)
				{
					const JSONNode &jEdit = *it;

					time_t time = jEdit["time"].as_int();
					char szTime[MAX_PATH];
					strftime(szTime, sizeof(szTime), "%X %x", localtime(&time));

					szText.AppendFormat(bUseBB ? Translate("[b]Edited at %s:[/b]\n%s\n") : Translate("Edited at %s:\n%s\n"), szTime, mir_utf8decodeA(jEdit["text"].as_string().c_str()));
				}
				
			}
			else 
			{
				szText = INVALID_DATA;
			}
			break;
		}

	case SKYPE_DB_EVENT_TYPE_CALL_INFO:
		{
			HXML xml = xmlParseString(ptrT(mir_utf8decodeT((char*)pEvent->dbei->pBlob)), 0, _T("partlist"));
			if (xml != NULL)
			{
				ptrA type(mir_t2a(xmlGetAttrValue(xml, _T("type"))));
				bool bType = (!mir_strcmpi(type, "started")) ? 1 : 0;
				time_t callDuration = 0;

				for (int i = 0; i < xmlGetChildCount(xml); i++)
				{
					HXML xmlPart = xmlGetNthChild(xml, _T("part"), i);		
					if (xmlPart != NULL)
					{
						HXML xmlDuration = xmlGetChildByPath(xmlPart, _T("duration"), 0);
						
						if (xmlDuration != NULL)
						{
							callDuration = _ttol(xmlGetText(xmlDuration));
							xmlDestroyNode(xmlDuration);
							xmlDestroyNode(xmlPart);
							break;
						}
						xmlDestroyNode(xmlPart);
					}
				}

				if (bType)
				{
					szText = Translate("Call");
				}
				else 
				{
					if (callDuration == 0)
					{
						szText = Translate("Call missed");
					}
					else
					{
						char szTime[100];
						strftime(szTime, sizeof(szTime), "%X", gmtime(&callDuration));
						szText.Format(Translate("Call ended (%s)"), szTime);
					}
				}
				xmlDestroyNode(xml);
			}
			else
			{
				szText = INVALID_DATA;
			}
			break;
		}
	case SKYPE_DB_EVENT_TYPE_FILETRANSFER_INFO:
		{
			HXML xml = xmlParseString(ptrT(mir_utf8decodeT((char*)pEvent->dbei->pBlob)), 0, _T("files"));
			if (xml != NULL)
			{
				for (int i = 0; i < xmlGetChildCount(xml); i++)
				{
					LONGLONG fileSize = 0;
					HXML xmlNode = xmlGetNthChild(xml, _T("file"), i);
					if (xmlNode != NULL)
					{
						fileSize = _ttol(xmlGetAttrValue(xmlNode, _T("size")));
						char *fileName = _T2A(xmlGetText(xmlNode));
						if (fileName != NULL)
						{
							szText.AppendFormat(Translate("File transfer:\n\tFile name: %s \n\tSize: %lld bytes \n"), fileName, fileSize);
						}

						xmlDestroyNode(xmlNode);
					}
				}
				xmlDestroyNode(xml);
			}
			else
			{
				szText = INVALID_DATA;
			}
			break;
		}
	case SKYPE_DB_EVENT_TYPE_MOJI:
	case SKYPE_DB_EVENT_TYPE_URIOBJ:
		{
			HXML xml = xmlParseString(ptrT(mir_utf8decodeT((char*)pEvent->dbei->pBlob)), 0, _T("URIObject"));
			if (xml != NULL)
			{
				szText.Append(_T2A(xmlGetText(xml)));
				HXML xmlA = xmlGetChildByPath(xml, _T("a"), 0);
				if (xmlA != NULL)
				{
					szText += _T2A(xmlGetAttrValue(xmlA, _T("href")));
					xmlDestroyNode(xmlA);
				}
				xmlDestroyNode(xml);
			}
			else 
			{
				szText = INVALID_DATA;
			}
			break;

		}

	case SKYPE_DB_EVENT_TYPE_INCOMING_CALL:
		{
			szText = Translate("Incoming call");
			break;
		}
	case SKYPE_DB_EVENT_TYPE_UNKNOWN:
		{
			szText.Format(Translate("Unknown event, please send this text for developer: \"%s\""), mir_utf8decodeA((char*)pEvent->dbei->pBlob));
			break;
		}
	default:
		{
			szText = ptrA(mir_utf8decodeA((char*)pEvent->dbei->pBlob));
		}
	}

	switch(pEvent->datatype)
	{
	case DBVT_TCHAR:
		{
			return (INT_PTR)mir_a2t(szText);
		}
	case DBVT_ASCIIZ:
		{
			return (INT_PTR)szText.Detach();
		}
	case DBVT_UTF8:
		{
			return (INT_PTR)mir_utf8encode(szText);
		}
	default:
		{
			return NULL;
		}
	}
}
예제 #7
0
INT_PTR CSkypeProto::GetCallEventText(WPARAM, LPARAM lParam)
{
	DBEVENTGETTEXT *pEvent = (DBEVENTGETTEXT *)lParam;

	INT_PTR nRetVal = 0;

	ptrA pszText;
	
	switch (pEvent->dbei->eventType)
	{
	case SKYPE_DB_EVENT_TYPE_CALL_INFO:
		{
			CMStringA text;
			HXML xml = xmlParseString(ptrT(mir_utf8decodeT((char*)pEvent->dbei->pBlob)), 0, _T("partlist"));
			if (xml != NULL)
			{
				ptrA type(mir_t2a(xmlGetAttrValue(xml, _T("type"))));
				bool bType = (!mir_strcmpi(type, "started")) ? 1 : 0;

				for (int i = 0; i < xmlGetChildCount(xml); i++)
				{
					HXML xmlPart = xmlGetNthChild(xml, _T("part"), i);
					if (xmlPart != NULL)
					{
						HXML xmlName = xmlGetChildByPath(xmlPart, _T("name"), 0);
						if (xmlName != NULL)
						{
							text.AppendFormat(Translate("%s %s this call.\n"), _T2A(xmlGetText(xmlName)), bType ? Translate("enters") : Translate("leaves"));
							xmlDestroyNode(xmlName);
						}
						xmlDestroyNode(xmlPart);
					}
				}
				xmlDestroyNode(xml);
			}
			pszText = mir_strdup(text.GetBuffer());
			break;
		}
	case SKYPE_DB_EVENT_TYPE_FILETRANSFER_INFO:
		{
			CMStringA text;
			HXML xml = xmlParseString(ptrT(mir_utf8decodeT((char*)pEvent->dbei->pBlob)), 0, _T("files"));
			if (xml != NULL)
			{
				for (int i = 0; i < xmlGetChildCount(xml); i++)
				{
					size_t fileSize = 0;
					HXML xmlNode = xmlGetNthChild(xml, _T("file"), i);
					if (xmlNode != NULL)
					{
						fileSize = _ttoi(ptrT((TCHAR*)xmlGetAttrValue(xmlNode, _T("size"))));
						ptrA fileName(mir_utf8encodeT(ptrT((TCHAR*)xmlGetText(xmlNode))));
						if (fileName != NULL)
						{
							CMStringA msg(FORMAT, Translate("File transfer:\n\tFile name: %s\n\tSize: %d bytes"), fileName, fileSize);
							text.AppendFormat("%s\n", msg);
						}

						xmlDestroyNode(xmlNode);
					}
				}
				xmlDestroyNode(xml);
			}
			pszText = mir_strdup(text.GetBuffer());
			break;
		}
	case SKYPE_DB_EVENT_TYPE_URIOBJ:
		{
			CMStringA text;
			HXML xml = xmlParseString(ptrT(mir_utf8decodeT((char*)pEvent->dbei->pBlob)), 0, _T("URIObject"));
			if (xml != NULL)
			{
				text.Append(_T2A(xmlGetText(xml)));
				xmlDestroyNode(xml);
			}
			pszText = mir_strdup(text.GetBuffer());
			break;

		}
	case SKYPE_DB_EVENT_TYPE_INCOMING_CALL:
		{
			pszText = Translate("Incoming call.");
			break;
		}
	default:
		{
			pszText = mir_strdup((char*)pEvent->dbei->pBlob);
		}
	}


	if (pEvent->datatype == DBVT_TCHAR)
	{
		TCHAR *pwszText = _A2T(pszText);
		nRetVal = (INT_PTR)mir_tstrdup(pwszText);
	}
	else if (pEvent->datatype == DBVT_ASCIIZ)
		nRetVal = (INT_PTR)mir_strdup(pszText);

	return nRetVal;
}