diff options
Diffstat (limited to 'protocols/MSN')
| -rw-r--r-- | protocols/MSN/src/msn_commands.cpp | 1539 | ||||
| -rw-r--r-- | protocols/MSN/src/msn_contact.cpp | 9 | ||||
| -rw-r--r-- | protocols/MSN/src/msn_ftold.cpp | 2 | ||||
| -rw-r--r-- | protocols/MSN/src/msn_global.h | 1 | ||||
| -rw-r--r-- | protocols/MSN/src/msn_lists.cpp | 2 | ||||
| -rw-r--r-- | protocols/MSN/src/msn_menu.cpp | 24 | ||||
| -rw-r--r-- | protocols/MSN/src/msn_misc.cpp | 51 | ||||
| -rw-r--r-- | protocols/MSN/src/msn_msgqueue.cpp | 2 | ||||
| -rw-r--r-- | protocols/MSN/src/msn_natdetect.cpp | 2 | ||||
| -rw-r--r-- | protocols/MSN/src/msn_opts.cpp | 2 | ||||
| -rw-r--r-- | protocols/MSN/src/msn_p2p.cpp | 2 | ||||
| -rw-r--r-- | protocols/MSN/src/msn_p2ps.cpp | 2 | ||||
| -rw-r--r-- | protocols/MSN/src/msn_proto.cpp | 38 | ||||
| -rw-r--r-- | protocols/MSN/src/msn_proto.h | 10 | ||||
| -rw-r--r-- | protocols/MSN/src/msn_svcs.cpp | 6 | ||||
| -rw-r--r-- | protocols/MSN/src/msn_switchboard.cpp | 3 | ||||
| -rw-r--r-- | protocols/MSN/src/msn_threads.cpp | 28 | ||||
| -rw-r--r-- | protocols/MSN/src/msn_ws.cpp | 4 | 
18 files changed, 963 insertions, 764 deletions
| diff --git a/protocols/MSN/src/msn_commands.cpp b/protocols/MSN/src/msn_commands.cpp index e04d768ccc..6e12f8838a 100644 --- a/protocols/MSN/src/msn_commands.cpp +++ b/protocols/MSN/src/msn_commands.cpp @@ -23,29 +23,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #include "msn_global.h"
  #include "msn_proto.h"
 -/////////////////////////////////////////////////////////////////////////////////////////
 -// Starts a file sending thread
 -
 -void MSN_ConnectionProc(HANDLE hNewConnection, DWORD /* dwRemoteIP */, void* extra)
 -{
 -	CMsnProto *proto = (CMsnProto*)extra;
 -
 -	proto->debugLogA("File transfer connection accepted");
 -
 -	NETLIBCONNINFO connInfo = { sizeof(connInfo) };
 -	CallService(MS_NETLIB_GETCONNECTIONINFO, (WPARAM)hNewConnection, (LPARAM)&connInfo);
 -
 -	ThreadData* T = proto->MSN_GetThreadByPort(connInfo.wPort);
 -	if (T != NULL && T->s == NULL) {
 -		T->s = hNewConnection;
 -		ReleaseSemaphore(T->hWaitEvent, 1, NULL);
 -	}
 -	else {
 -		proto->debugLogA("There's no registered file transfers for incoming port #%u, connection closed", connInfo.wPort);
 -		Netlib_CloseHandle(hNewConnection);
 -	}
 -}
 -
  void CMsnProto::MSN_SetMirVer(MCONTACT hContact, DWORD dwValue, bool always)
  {
  	static const char* MirVerStr[] =
 @@ -93,215 +70,6 @@ void CMsnProto::MSN_SetMirVer(MCONTACT hContact, DWORD dwValue, bool always)  	setByte(hContact, "StdMirVer", 1);
  }
 -/////////////////////////////////////////////////////////////////////////////////////////
 -// Processes various invitations
 -
 -void CMsnProto::MSN_InviteMessage(ThreadData* info, char* msgBody, char* email, char* nick)
 -{
 -	MimeHeaders tFileInfo;
 -	tFileInfo.readFromBuffer(msgBody);
 -
 -	const char* Appname = tFileInfo["Application-Name"];
 -	const char* AppGUID = tFileInfo["Application-GUID"];
 -	const char* Invcommand = tFileInfo["Invitation-Command"];
 -	const char* Invcookie = tFileInfo["Invitation-Cookie"];
 -	const char* Appfile = tFileInfo["Application-File"];
 -	const char* Appfilesize = tFileInfo["Application-FileSize"];
 -	const char* IPAddress = tFileInfo["IP-Address"];
 -	const char* IPAddressInt = tFileInfo["IP-Address-Internal"];
 -	const char* Port = tFileInfo["Port"];
 -	const char* PortXInt = tFileInfo["PortX-Internal"];
 -	const char* AuthCookie = tFileInfo["AuthCookie"];
 -	const char* SessionID = tFileInfo["Session-ID"];
 -	const char* SessionProtocol = tFileInfo["Session-Protocol"];
 -	//	const char* Connectivity = tFileInfo["Connectivity"];
 -
 -	if (AppGUID != NULL) {
 -		if (!strcmp(AppGUID, "{02D3C01F-BF30-4825-A83A-DE7AF41648AA}")) {
 -			MSN_ShowPopup(info->getContactHandle(),
 -				TranslateT("Contact tried to open an audio conference (not currently supported)"), MSN_ALLOW_MSGBOX);
 -			return;
 -		}
 -	}
 -
 -	if (Invcommand && (strcmp(Invcommand, "CANCEL") == 0)) {
 -		delete info->mMsnFtp;
 -		info->mMsnFtp = NULL;
 -	}
 -
 -	if (Appname != NULL && Appfile != NULL && Appfilesize != NULL)  // receive first
 -	{
 -		filetransfer* ft = info->mMsnFtp = new filetransfer(this);
 -
 -		ft->std.hContact = MSN_HContactFromEmail(email, nick, true, true);
 -		mir_free(ft->std.tszCurrentFile);
 -		ft->std.tszCurrentFile = mir_utf8decodeT(Appfile);
 -		ft->std.totalBytes = ft->std.currentFileSize = _atoi64(Appfilesize);
 -		ft->std.totalFiles = 1;
 -		ft->szInvcookie = mir_strdup(Invcookie);
 -		ft->p2p_dest = mir_strdup(email);
 -
 -		TCHAR tComment[40];
 -		mir_sntprintf(tComment, SIZEOF(tComment), TranslateT("%I64u bytes"), ft->std.currentFileSize);
 -
 -		PROTORECVFILET pre = { 0 };
 -		pre.flags = PREF_TCHAR;
 -		pre.fileCount = 1;
 -		pre.timestamp = time(NULL);
 -		pre.tszDescription = tComment;
 -		pre.ptszFiles = &ft->std.tszCurrentFile;
 -		pre.lParam = (LPARAM)ft;
 -		ProtoChainRecvFile(ft->std.hContact, &pre);
 -		return;
 -	}
 -
 -	// receive Second
 -	if (IPAddress != NULL && Port != NULL && AuthCookie != NULL) {
 -		ThreadData* newThread = new ThreadData;
 -
 -		if (inet_addr(IPAddress) != MyConnection.extIP || !IPAddressInt)
 -			mir_snprintf(newThread->mServer, SIZEOF(newThread->mServer), "%s:%s", IPAddress, Port);
 -		else
 -			mir_snprintf(newThread->mServer, SIZEOF(newThread->mServer), "%s:%u", IPAddressInt, atol(PortXInt) ^ 0x3141);
 -
 -		newThread->mType = SERVER_FILETRANS;
 -
 -		if (info->mMsnFtp == NULL) {
 -			ThreadData* otherThread = MSN_GetOtherContactThread(info);
 -			if (otherThread) {
 -				info->mMsnFtp = otherThread->mMsnFtp;
 -				otherThread->mMsnFtp = NULL;
 -			}
 -		}
 -
 -		newThread->mMsnFtp = info->mMsnFtp; info->mMsnFtp = NULL;
 -		strcpy(newThread->mCookie, AuthCookie);
 -
 -		newThread->startThread(&CMsnProto::MSNServerThread, this);
 -		return;
 -	}
 -
 -	// send 1
 -	if (Invcommand != NULL && Invcookie != NULL && Port == NULL && AuthCookie == NULL && SessionID == NULL) { 
 -		msnftp_startFileSend(info, Invcommand, Invcookie);
 -		return;
 -	}
 -
 -	// netmeeting send 1
 -	if (Appname == NULL && SessionID != NULL && SessionProtocol != NULL) {
 -		if (!_stricmp(Invcommand, "ACCEPT")) {
 -			ShellExecuteA(NULL, "open", "conf.exe", NULL, NULL, SW_SHOW);
 -			Sleep(3000);
 -
 -			info->sendPacketPayload("MSG", "N",
 - 				"MIME-Version: 1.0\r\n"
 -				"Content-Type: text/x-msmsgsinvite; charset=UTF-8\r\n\r\n"
 -				"Invitation-Command: ACCEPT\r\n"
 -				"Invitation-Cookie: %s\r\n"
 -				"Session-ID: {1A879604-D1B8-11D7-9066-0003FF431510}\r\n"
 -				"Launch-Application: TRUE\r\n"
 -				"IP-Address: %s\r\n\r\n",
 -				Invcookie, MyConnection.GetMyExtIPStr());
 -		}
 -		return;
 -	}
 -
 -	// netmeeting receive 1
 -	if (Appname != NULL && !_stricmp(Appname, "NetMeeting")) {
 -		TCHAR text[512], *tszEmail = mir_a2t(email);
 -		mir_sntprintf(text, SIZEOF(text), TranslateT("Accept NetMeeting request from %s?"), tszEmail);
 -		mir_free(tszEmail);
 -
 -		if (MessageBox(NULL, text, TranslateT("MSN Protocol"), MB_YESNO | MB_ICONQUESTION) == IDYES) {
 -			info->sendPacketPayload("MSG", "N",
 -				"MIME-Version: 1.0\r\n"
 -				"Content-Type: text/x-msmsgsinvite; charset=UTF-8\r\n\r\n"
 -				"Invitation-Command: ACCEPT\r\n"
 -				"Invitation-Cookie: %s\r\n"
 -				"Session-ID: {A2ED5ACF-F784-4B47-A7D4-997CD8F643CC}\r\n"
 -				"Session-Protocol: SM1\r\n"
 -				"Launch-Application: TRUE\r\n"
 -				"Request-Data: IP-Address:\r\n"
 -				"IP-Address: %s\r\n\r\n",
 -				Invcookie, MyConnection.GetMyExtIPStr());
 -		}
 -		else {
 -			info->sendPacketPayload("MSG", "N",
 -				"MIME-Version: 1.0\r\n"
 -				"Content-Type: text/x-msmsgsinvite; charset=UTF-8\r\n\r\n"
 -				"Invitation-Command: CANCEL\r\n"
 -				"Invitation-Cookie: %s\r\n"
 -				"Cancel-Code: REJECT\r\n\r\n",
 -				Invcookie);
 -		}
 -		return;
 -	}
 -
 -	if (IPAddress != NULL && Port == NULL && SessionID != NULL && SessionProtocol == NULL) { // netmeeting receive 2
 -		char ipaddr[256];
 -		mir_snprintf(ipaddr, SIZEOF(ipaddr), "callto://%s", IPAddress);
 -		ShellExecuteA(NULL, "open", ipaddr, NULL, NULL, SW_SHOW);
 -	}
 -}
 -
 -/////////////////////////////////////////////////////////////////////////////////////////
 -// Processes custom smiley messages
 -
 -void CMsnProto::MSN_CustomSmiley(const char* msgBody, char* email, char* nick, int iSmileyType)
 -{
 -	MCONTACT hContact = MSN_HContactFromEmail(email, nick, true, true);
 -
 -	char smileyList[500] = "";
 -
 -	const char *tok1 = msgBody, *tok2;
 -	char *smlp = smileyList;
 -	char lastsml[50];
 -
 -	unsigned iCount = 0;
 -	bool parseSmiley = true;
 -
 -	for (;;) {
 -		tok2 = strchr(tok1, '\t');
 -		if (tok2 == NULL) break;
 -
 -		size_t sz = tok2 - tok1;
 -		if (parseSmiley) {
 -			sz = min(sz, sizeof(lastsml)-1);
 -			memcpy(lastsml, tok1, sz);
 -			lastsml[sz] = 0;
 -
 -			memcpy(smlp, tok1, sz); smlp += sz;
 -			*(smlp++) = '\n'; *smlp = 0;
 -			++iCount;
 -		}
 -		else {
 -			filetransfer* ft = new filetransfer(this);
 -			ft->std.hContact = hContact;
 -
 -			ft->p2p_object = (char*)mir_alloc(sz + 1);
 -			memcpy(ft->p2p_object, tok1, sz);
 -			ft->p2p_object[sz] = 0;
 -
 -			size_t slen = strlen(lastsml);
 -			ptrA buf(mir_base64_encode((PBYTE)lastsml, (unsigned)slen));
 -			ptrA smileyName(mir_urlEncode(buf));
 -
 -			TCHAR path[MAX_PATH];
 -			MSN_GetCustomSmileyFileName(hContact, path, SIZEOF(path), smileyName, iSmileyType);
 -			ft->std.tszCurrentFile = mir_tstrdup(path);
 -
 -			if (p2p_IsDlFileOk(ft))
 -				delete ft;
 -			else {
 -				debugLogA("Custom Smiley p2p invite for object : %s", ft->p2p_object);
 -				p2p_invite(iSmileyType, ft, email);
 -				Sleep(3000);
 -			}
 -		}
 -		parseSmiley = !parseSmiley;
 -		tok1 = tok2 + 1;
 -	}
 -}
  /////////////////////////////////////////////////////////////////////////////////////////
  //	MSN_ReceiveMessage - receives message or a file from the server
 @@ -620,6 +388,7 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para  		sttNotificationMessage(msgBody, true);
  	else if (!_strnicmp(tContentType, "text/x-msmsgsoimnotification", 28))
  		sttNotificationMessage(msgBody, false);
 +#ifdef OBSOLETE
  	else if (!_strnicmp(tContentType, "text/x-msmsgsinvite", 19))
  		MSN_InviteMessage(info, msgBody, email, nick);
  	else if (!_strnicmp(tContentType, "application/x-msnmsgrp2p", 24)) {
 @@ -643,6 +412,7 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para  		MSN_CustomSmiley(msgBody, email, nick, MSN_APPID_CUSTOMSMILEY);
  	else if (!_strnicmp(tContentType, "text/x-mms-animemoticon", 23))
  		MSN_CustomSmiley(msgBody, email, nick, MSN_APPID_CUSTOMANIMATEDSMILEY);
 +#endif
  	mir_free(mChatID);
  	mir_free(newbody);
 @@ -701,90 +471,6 @@ void CMsnProto::MSN_ProcessYFind(char* buf, size_t len)  }
  /////////////////////////////////////////////////////////////////////////////////////////
 -// Process user addition
 -
 -void CMsnProto::MSN_ProcessAdd(char* buf, size_t len)
 -{
 -	if (buf == NULL) return;
 -
 -	ezxml_t xmli = ezxml_parse_str(buf, len);
 -	ezxml_t dom  = ezxml_child(xmli, "d");
 -	while (dom != NULL) {
 -		const char* szDom = ezxml_attr(dom, "n");
 -		ezxml_t cont = ezxml_child(dom, "c");
 -		while (cont != NULL) {
 -			const char* szCont = ezxml_attr(cont, "n");
 -			const char* szNick = ezxml_attr(cont, "f");
 -			int listId = atol(ezxml_attr(cont, "l"));
 -			int netId = atol(ezxml_attr(cont, "t"));
 -
 -			char szEmail[128];
 -			mir_snprintf(szEmail, SIZEOF(szEmail), "%s@%s", szCont, szDom);
 -
 -			UrlDecode((char*)szNick);
 -
 -			if (listId == LIST_FL) {
 -				MCONTACT hContact = MSN_HContactFromEmail(szEmail, szNick, true, false);
 -				MSN_SetContactDb(hContact, szEmail);
 -			}
 -
 -			if (listId == LIST_RL)
 -				MSN_SharingFindMembership(true);
 -			else
 -				MSN_AddUser(NULL, szEmail, netId, listId);
 -
 -			MsnContact* msc = Lists_Get(szEmail);
 -			if (msc == NULL) {
 -				Lists_Add(listId, netId, szEmail);
 -				msc = Lists_Get(szEmail);
 -			}
 -
 -			if (listId == LIST_RL) {
 -				if ((msc->list & (LIST_AL | LIST_BL)) == 0) {
 -					MSN_AddAuthRequest(szEmail, szNick, msc->invite);
 -					msc->netId = netId;
 -				}
 -				else MSN_AddUser(NULL, szEmail, netId, LIST_PL + LIST_REMOVE);
 -			}
 -
 -			cont = ezxml_next(cont);
 -		}
 -		dom = ezxml_next(dom);
 -	}
 -	ezxml_free(xmli);
 -}
 -
 -void CMsnProto::MSN_ProcessRemove(char* buf, size_t len)
 -{
 -	ezxml_t xmli = ezxml_parse_str(buf, len);
 -	ezxml_t dom  = ezxml_child(xmli, "d");
 -	while (dom != NULL) {
 -		const char* szDom = ezxml_attr(dom, "n");
 -		ezxml_t cont = ezxml_child(dom, "c");
 -		while (cont != NULL) {
 -			const char* szCont = ezxml_attr(cont, "n");
 -			int listId = atol(ezxml_attr(cont, "l"));
 -
 -			char szEmail[128];
 -			mir_snprintf(szEmail, SIZEOF(szEmail), "%s@%s", szCont, szDom);
 -			Lists_Remove(listId, szEmail);
 -
 -			MsnContact* msc = Lists_Get(szEmail);
 -			if (msc == NULL || (msc->list & (LIST_RL | LIST_FL | LIST_LL)) == 0) {
 -				if (msc->hContact && _stricmp(szEmail, MyOptions.szEmail)) {
 -					CallService(MS_DB_CONTACT_DELETE, (WPARAM)msc->hContact, 0);
 -					msc->hContact = NULL;
 -				}
 -			}
 -
 -			cont = ezxml_next(cont);
 -		}
 -		dom = ezxml_next(dom);
 -	}
 -	ezxml_free(xmli);
 -}
 -
 -/////////////////////////////////////////////////////////////////////////////////////////
  //	MSN_HandleCommands - process commands from the server
  /////////////////////////////////////////////////////////////////////////////////////////
 @@ -934,6 +620,7 @@ void CMsnProto::MSN_ProcessStatusMessage(ezxml_t xmli, const char* wlid)  		ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, NULL, tszStatus);
  	}
 +#ifdef OBSOLETE
  	// Process current media info
  	const char* szCrntMda = ezxml_txt(ezxml_child(xmli, "CurrentMedia"));
  	if (!*szCrntMda) {
 @@ -1038,25 +725,7 @@ void CMsnProto::MSN_ProcessStatusMessage(ezxml_t xmli, const char* wlid)  		mir_free(lti.ptszPlayer);
  		mir_free(lti.ptszType);
  	}
 -}
 -
 -void CMsnProto::MSN_ProcessPage(char* buf, unsigned len)
 -{
 -	if (buf == NULL) return;
 -	ezxml_t xmlnot = ezxml_parse_str(buf, len);
 -
 -	ezxml_t xmlbdy = ezxml_get(xmlnot, "MSG", 0, "BODY", -1);
 -	const char* szMsg = ezxml_txt(ezxml_child(xmlbdy, "TEXT"));
 -	const char* szTel = ezxml_attr(ezxml_child(xmlnot, "FROM"), "name");
 -
 -	if (szTel && *szMsg) {
 -		PROTORECVEVENT pre = { 0 };
 -		pre.szMessage = (char*)szMsg;
 -		pre.flags = PREF_UTF /*+ ((isRtl) ? PREF_RTL : 0)*/;
 -		pre.timestamp = time(NULL);
 -		ProtoChainRecvMsg(MSN_HContactFromEmail(szTel, szTel, true, true), &pre);
 -	}
 -	ezxml_free(xmlnot);
 +#endif
  }
  void CMsnProto::MSN_ProcessNotificationMessage(char* buf, unsigned len)
 @@ -1106,60 +775,6 @@ void CMsnProto::MSN_ProcessNotificationMessage(char* buf, unsigned len)  	ezxml_free(xmlnot);
  }
 -void CMsnProto::MSN_InitSB(ThreadData* info, const char* szEmail)
 -{
 -/* MSNP21: No more switchboard, bye, bye ... 
 -	MsnContact *cont = Lists_Get(szEmail);
 -
 -	if (cont->netId == NETID_MSN)
 -		info->sendCaps();
 -
 -	bool typing = false;
 -
 -	for (int i = 3; --i;) {
 -		MsgQueueEntry E;
 -		while (MsgQueue_GetNext(szEmail, E)) {
 -			if (E.msgType == 'X') ;
 -			else if (E.msgType == 2571)
 -				typing = E.flags != 0;
 -			else if (E.msgSize == 0) {
 -				info->sendMessage(E.msgType, NULL, 1, E.message, E.flags);
 -				ProtoBroadcastAck(cont->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)E.seq, 0);
 -			}
 -			else {
 -				if (E.msgType == 'D' && !info->mBridgeInit) { //&& strchr(data.flags, ':'))  {
 -					info->mBridgeInit = true;
 -
 -//					P2PV2_Header hdrdata(E.message);
 -//					P2PV2_Header tHdr;
 -//					tHdr.mID = hdrdata.mID;
 -//					p2p_sendMsg(info, E.wlid, 0, tHdr, NULL, 0);
 -				}
 -				info->sendRawMessage(E.msgType, E.message, E.msgSize);
 -			}
 -
 -			mir_free(E.message);
 -			mir_free(E.wlid);
 -
 -			if (E.ft != NULL)
 -				info->mMsnFtp = E.ft;
 -		}
 -		mir_free(info->mInitialContactWLID); info->mInitialContactWLID = NULL;
 -	}
 -
 -	if (typing)
 -		MSN_StartStopTyping(info, true);
 -
 -	if (getByte("EnableDeliveryPopup", 0))
 -		MSN_ShowPopup(cont->hContact, info->mCaller ?
 -			TranslateT("Chat session established by my request") :
 -			TranslateT("Chat session established by contact request"), 0);
 -
 -	PROTO_AVATAR_INFORMATIONT ai = { sizeof(ai), cont->hContact };
 -	GetAvatarInfo(GAIF_FORCE, (LPARAM)&ai);
 -	*/
 -}
 -
  int CMsnProto::MSN_HandleCommands(ThreadData* info, char* cmdString)
  {
  	char* params = "";
 @@ -1182,45 +797,10 @@ int CMsnProto::MSN_HandleCommands(ThreadData* info, char* cmdString)  	}
  	switch((*(PDWORD)cmdString & 0x00FFFFFF) | 0x20000000) {
 -	case ' KCA':    //********* ACK: section 8.7 Instant Messages
 -		ReleaseSemaphore(info->hWaitEvent, 1, NULL);
 -
 -		if (info->mJoinedContactsWLID.getCount() > 0 && MyOptions.SlowSend)
 -			ProtoBroadcastAck(info->getContactHandle(), ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)trid, 0);
 -		break;
 -
 -	case ' YQF':	//********* FQY: Find Yahoo User
 -		char* tWords[1];
 -		if (sttDivideWords(params, 1, tWords) != 1)
 -			debugLogA("Invalid %.3s command, ignoring", cmdString);
 -		else {
 -			size_t len = atol(tWords[0]);
 -			MSN_ProcessYFind((char*)HReadBuffer(info, 0).surelyRead(len), len);
 -		}
 -		break;
 -
 -	case ' LDA':	//********* ADL: Add to the list
 -		{
 -			char* tWords[1];
 -			if (sttDivideWords(params, 1, tWords) != 1) {
 -LBL_InvalidCommand:
 -				debugLogA("Invalid %.3s command, ignoring", cmdString);
 -				break;
 -			}
 -
 -			if (strcmp(tWords[0], "OK") != 0) {
 -				size_t len = atol(tWords[0]);
 -				MSN_ProcessAdd((char*)HReadBuffer(info, 0).surelyRead(len), len);
 -			}
 -		}
 -		break;
  	case ' SBS':
  		break;
 -	case ' SNA':    //********* ANS: section 8.4 Getting Invited to a Switchboard Session
 -		break;
 -
  	case ' HTA':	//********* ATH: MSNP21+ Authentication
  		{
  			union {
 @@ -1228,8 +808,11 @@ LBL_InvalidCommand:  				struct { char *typeId, *strMsgBytes; } data;
  			};
 -			if (sttDivideWords(params, SIZEOF(tWords), tWords) < 2)
 -				goto LBL_InvalidCommand;
 +			if (sttDivideWords(params, SIZEOF(tWords), tWords) < 2) {
 +LBL_InvalidCommand:
 +				debugLogA("Invalid %.3s command, ignoring", cmdString);
 +				break;
 +			}
  			HReadBuffer buf(info, 0);
  			char* msgBody = (char*)buf.surelyRead(atol(data.strMsgBytes));
 @@ -1257,12 +840,6 @@ LBL_InvalidCommand:  		}
  		break;
 -	case ' PRP':
 -		break;
 -
 -	case ' PLB':    //********* BLP: section 7.6 List Retrieval And Property Management
 -		break;
 -
  	case ' DNB':	//********* BND: MSNP21+ bind request answer?
  		{
  			union {
 @@ -1294,120 +871,6 @@ LBL_InvalidCommand:  		}
  		break;
 -	case ' EYB':   //********* BYE: section 8.5 Session Participant Changes
 -		{
 -			union {
 -				char* tWords[2];
 -				// modified for chat, orginally param2 = junk
 -				// param 2: quit due to idle = "1", normal quit = nothing
 -				struct { char *userEmail, *isIdle; } data;
 -			};
 -
 -			sttDivideWords(params, 2, tWords);
 -			UrlDecode(data.userEmail);
 -
 -			if (strchr(data.userEmail, ';')) {
 -				if (info->mJoinedContactsWLID.getCount() == 1)
 -					p2p_clearThreadSessions((MCONTACT)info->mJoinedContactsWLID[0], info->mType);
 -				info->contactLeft(data.userEmail);
 -				break;
 -			}
 -
 -			MCONTACT hContact = MSN_HContactFromEmail(data.userEmail);
 -
 -			if (getByte("EnableSessionPopup", 0))
 -				MSN_ShowPopup(hContact, TranslateT("Contact left channel"), 0);
 -
 -			// modified for chat
 -			{
 -				GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_QUIT };
 -				GCEVENT gce = { sizeof(gce), &gcd };
 -				gce.dwFlags = GCEF_ADDTOLOG;
 -				gce.ptszNick = GetContactNameT(hContact);
 -				gce.ptszUID = mir_a2t(data.userEmail);
 -				gce.time = time(NULL);
 -				gce.bIsMe = FALSE;
 -				CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
 -				mir_free((void*)gce.ptszUID);
 -			}
 -
 -			int personleft = info->contactLeft(data.userEmail);
 -
 -			int temp_status = getWord(hContact, "Status", ID_STATUS_OFFLINE);
 -			if (temp_status == ID_STATUS_INVISIBLE && MSN_GetThreadByContact(data.userEmail) == NULL)
 -				setWord(hContact, "Status", ID_STATUS_OFFLINE);
 -
 -			// see if the session is quit due to idleness
 -			if (info->mChatID[0] && personleft == 1) {
 -				if (!strcmp(data.isIdle, "1")) {
 -					GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_INFORMATION };
 -					GCEVENT gce = { sizeof(gce), &gcd };
 -					gce.dwFlags = GCEF_ADDTOLOG;
 -					gce.bIsMe = FALSE;
 -					gce.time = time(NULL);
 -					gce.ptszText = TranslateT("This conversation has been inactive, participants will be removed.");
 -					CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
 -					gce.ptszText = TranslateT("To resume the conversation, please quit this session and start a new chat session.");
 -					CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
 -				}
 -				else {
 -					if (!Miranda_Terminated() && MessageBox(NULL,
 -						TranslateT("There is only 1 person left in the chat, do you want to switch back to standard message window?"),
 -						TranslateT("MSN Chat"), MB_YESNO | MB_ICONQUESTION) == IDYES) {
 -						// kill chat dlg and open srmm dialog
 -						MSN_KillChatSession(info->mChatID);
 -
 -						// open up srmm dialog when quit while 1 person left
 -						MCONTACT hContact = info->getContactHandle();
 -						if (hContact) CallServiceSync(MS_MSG_SENDMESSAGE, hContact, 0);
 -					}
 -				}
 -			}
 -			// this is not in chat session, quit the session when everyone left
 -			else if (info->mJoinedContactsWLID.getCount() < 1)
 -				return 1;
 -
 -		}
 -		break;
 -
 -	case ' LAC':    //********* CAL: section 8.3 Inviting Users to a Switchboard Session
 -		break;
 -
 -	case ' GHC':    //********* CHG: section 7.7 Client States
 -		{
 -			int oldStatus = m_iStatus;
 -			int newStatus = MSNStatusToMiranda(params);
 -			if (oldStatus <= ID_STATUS_OFFLINE) {
 -				isConnectSuccess = true;
 -				int count = -1;
 -				for (;;) {
 -					MsnContact *msc = Lists_GetNext(count);
 -					if (msc == NULL) break;
 -
 -					if (msc->netId == NETID_MOB)
 -						setWord(msc->hContact, "Status", ID_STATUS_ONTHEPHONE);
 -				}
 -			}
 -			if (newStatus != ID_STATUS_IDLE) {
 -				m_iStatus = newStatus;
 -				ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, newStatus);
 -				debugLogA("Status change acknowledged: %s", params);
 -				MSN_RemoveEmptyGroups();
 -			}
 -			if (newStatus == ID_STATUS_OFFLINE) return 1;
 -		}
 -		break;
 -	case ' LHC':    //********* CHL: Query from Server on MSNP7
 -		{
 -			char* authChallengeInfo;
 -			if (sttDivideWords(params, 1, &authChallengeInfo) != 1)
 -				goto LBL_InvalidCommand;
 -
 -			char dgst[64];
 -			MSN_MakeDigest(authChallengeInfo, dgst);
 -			info->sendPacket("QRY", "%s 32\r\n%s", msnProductID, dgst);
 -		}
 -		break;
  	case ' TNC':	//********* CNT: Connect, MSNP21+ Authentication
  		{
  			union {
 @@ -1469,30 +932,10 @@ LBL_InvalidCommand:  			bSentBND = false;
  			ForkThread(&CMsnProto::msn_keepAliveThread, NULL);
 -			/* FIXME: Currently disables, as P2P maybe not working anymore in MSNP24? */
 -			//ForkThread(&CMsnProto::MSNConnDetectThread, NULL);
 -		}
 -		break;
 -	case ' RVC':    //********* CVR: MSNP8
 -		break;
 -
 -	case ' NLF':    //********* FLN: section 7.9 Notification Messages
 -		{
 -			union {
 -				char* tWords[2];
 -				struct { char *userEmail, *netId; } data;
 -			};
 -
 -			int tArgs = sttDivideWords(params, 2, tWords);
 -			if (tArgs < 2)
 -				goto LBL_InvalidCommand;
 -
 -			MCONTACT hContact = MSN_HContactFromEmail(data.userEmail);
 -			if (hContact != NULL) {
 -				setWord(hContact, "Status", MSN_GetThreadByContact(data.userEmail) ? ID_STATUS_INVISIBLE : ID_STATUS_OFFLINE);
 -				setDword(hContact, "IdleTS", 0);
 -				ForkThread(&CMsnProto::MsgQueue_AllClearThread, mir_strdup(data.userEmail));
 -			}
 +#ifdef OBSOLETE
 +			/* FIXME: Currently disabled, as P2P maybe not working anymore in MSNP24? */
 +			ForkThread(&CMsnProto::MSNConnDetectThread, NULL);
 +#endif
  		}
  		break;
 @@ -1656,6 +1099,771 @@ LBL_InvalidCommand:  		}
  		break;
 +	case ' YFN':   //********* NFY: MSNP21+ Notifications
 +		{
 +			union {
 +				char* tWords[2];
 +				struct { char *typeId, *strMsgBytes; } data;
 +			};
 +
 +			if (sttDivideWords(params, SIZEOF(tWords), tWords) < 2)
 +				goto LBL_InvalidCommand;
 +
 +			HReadBuffer buf(info, 0);
 +			char* msgBody = (char*)buf.surelyRead(atol(data.strMsgBytes));
 +			if (msgBody == NULL) break;
 +			if (!strcmp(data.typeId, "MSGR\\HOTMAIL")) {
 +				char szParam[128];
 +				mir_snprintf(szParam, sizeof(szParam), "%s %s", data.typeId, data.strMsgBytes);
 +				MSN_ReceiveMessage(info, cmdString, szParam);
 +				break;
 +			} else if (!strcmp(data.typeId, "MSGR\\ABCH")) {
 +				MimeHeaders tHeader;
 +				msgBody = tHeader.readFromBuffer(msgBody);
 +				MSN_ProcessNotificationMessage(msgBody, strlen(msgBody));
 +				break;
 +			}
 +
 +			if (!strcmp(data.typeId, "MSGR\\PUT") || !strcmp(data.typeId, "MSGR\\DEL")) {
 +				MimeHeaders tHeader;
 +
 +				int i;
 +				for (i=0; i<2; i++) msgBody = tHeader.readFromBuffer(msgBody);
 +				char *pszTo = NULL, *pszToNet;
 +				if (tHeader["To"]) parseWLID(NEWSTR_ALLOCA(tHeader["To"]), &pszToNet, &pszTo, NULL);
 +				const char *pszFrom =  tHeader["From"];
 +				for (i=0; i<2; i++) msgBody = tHeader.readFromBuffer(msgBody);
 +
 +				if (pszFrom)
 +				{
 +					ezxml_t xmli;
 +					if (xmli = ezxml_parse_str(msgBody, strlen(msgBody)))
 +					{
 +						if (!strcmp(xmli->name, "user"))
 +						{
 +							ezxml_t xmlstatus = ezxml_get(xmli, "s", 0, "Status", -1);
 +							/* FIXME: MSGR\DEL: Instance of user with given EPID disconnected, not 
 +							 * sure if this implies that contact is offline now... */
 +							if (xmlstatus || !strcmp(data.typeId, "MSGR\\DEL"))
 +							{
 +								// These capabilities seem to be something different than in previous MSNP versions?
 +								//ezxml_t xmlcaps = ezxml_get(xmli, "sep", 0, "Capabilities", -1);
 +								ezxml_t usertile = ezxml_get(xmli, "s", 1, "UserTileLocation", -1);
 +								MSN_ProcessNLN(ezxml_txt(xmlstatus), pszFrom, NULL, NULL, usertile?usertile->txt:NULL);
 +							}
 +							MSN_ProcessStatusMessage(xmli, pszFrom);
 +						}
 +						ezxml_free(xmli);
 +					}				
 +				}
 +			}
 +			else if (!strcmp(data.typeId, "MSGR\\THREAD")) {
 +				MimeHeaders tHeader;
 +				char *msgBody = tHeader.readFromBuffer(info->mData);
 +				ezxml_t xmli;
 +
 +				if (xmli = ezxml_parse_str(msgBody, strlen(msgBody)))
 +				{
 +					MSN_ChatStart(xmli);
 +					ezxml_free(xmli);
 +				}				
 +			}
 +		}
 +		break;
 +
 +	case ' TUP':	//******** MSNP21+: PUT notifications
 +	case ' GNP':	//******** MSNP21+: PNG reply
 +		{
 +			union {
 +				char* tWords[2];
 +				struct { char *typeId, *strMsgBytes; } data;
 +			};
 +
 +			if (sttDivideWords(params, SIZEOF(tWords), tWords) < 2)
 +				goto LBL_InvalidCommand;
 +
 +			MimeHeaders tHeader;
 +			HReadBuffer buf(info, 0);
 +			char* msgBody = tHeader.readFromBuffer((char*)buf.surelyRead(atol(data.strMsgBytes)));
 +
 +			if (tHeader["Set-Registration"]) replaceStr(msnRegistration,tHeader["Set-Registration"]);
 +			if (cmdString[1]=='N') { // PNG
 +				if (ezxml_t xmli = ezxml_parse_str(msgBody, strlen(msgBody))) {
 +					if (ezxml_t wait = ezxml_child(xmli, "wait")) {
 +						msnPingTimeout = atoi(ezxml_txt(wait));
 +						if (msnPingTimeout && hKeepAliveThreadEvt != NULL)
 +							SetEvent(hKeepAliveThreadEvt);
 +					}
 +					ezxml_free(xmli);
 +				}				
 +			} else { // PUT
 +				ezxml_t xmli;
 +				if (*msgBody && (xmli = ezxml_parse_str(msgBody, strlen(msgBody)))) {
 +					if (!strcmp(xmli->name, "presence-response")) {
 +						ezxml_t user, from;
 +						if ((user = ezxml_child(xmli, "user")) && (from = ezxml_child(xmli, "from"))) {
 +							if (ezxml_t xmlstatus = ezxml_get(user, "s", 0, "Status", -1)) {
 +								ezxml_t usertile = ezxml_get(user, "s", 1, "UserTileLocation", -1);
 +								MSN_ProcessNLN(ezxml_txt(xmlstatus), from->txt, NULL, NULL, usertile?usertile->txt:NULL);
 +							} else {
 +								int oldMode = m_iStatus;
 +								m_iStatus = m_iDesiredStatus;
 +								ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldMode, m_iStatus);
 +							}
 +							MSN_ProcessStatusMessage(user, from->txt);
 +						}
 +					}
 +					ezxml_free(xmli);
 +				}				
 +			}
 +		}
 +		break;
 +
 +	case ' GDS':   // SDG:  MSNP21+ Messaging
 +		MSN_ReceiveMessage(info, cmdString, params);
 +		break;
 +
 +	case ' RFX':    //******** XFR: sections 7.4 Referral, 8.1 Referral to Switchboard
 +		{
 +			union {
 +				char* tWords[2];
 +				struct { char *typeId, *strMsgBytes; } data;
 +			};
 +
 +			if (sttDivideWords(params, SIZEOF(tWords), tWords) < 2)
 +				goto LBL_InvalidCommand;
 +
 +			MimeHeaders tHeader;
 +			HReadBuffer buf(info, 0);
 +			char* msgBody = tHeader.readFromBuffer((char*)buf.surelyRead(atol(data.strMsgBytes)));
 +			if (!strcmp(data.typeId, "CON")) {
 +				ezxml_t xmlxfr = ezxml_parse_str(msgBody, strlen(msgBody));
 +				ezxml_t xmltgt = ezxml_child(xmlxfr, "target");
 +				if (xmltgt)
 +				{
 +					ThreadData* newThread = new ThreadData;
 +					strcpy(newThread->mServer, xmltgt->txt);
 +					strcpy(newThread->mState, ezxml_txt(ezxml_child(xmlxfr, "state")));
 +					newThread->mType = SERVER_NOTIFICATION;
 +					newThread->mTrid = info->mTrid;
 +					newThread->mIsMainThread = true;
 +					info->mIsMainThread = false;
 +
 +					debugLogA("Switching to notification server '%s'...", xmltgt->txt);
 +					newThread->startThread(&CMsnProto::MSNServerThread, this);
 +					ezxml_free(xmlxfr);
 +					return 1;  //kill the old thread
 +				}
 +				ezxml_free(xmlxfr);
 +			}
 +		}
 +		break;
 +
 +	default:
 +		debugLogA("Unrecognised message: %s", cmdString);
 +		break;
 +	}
 +
 +	return 0;
 +}
 +
 +
 +#ifdef OBSOLETE
 +
 +/////////////////////////////////////////////////////////////////////////////////////////
 +// Starts a file sending thread
 +
 +void MSN_ConnectionProc(HANDLE hNewConnection, DWORD /* dwRemoteIP */, void* extra)
 +{
 +	CMsnProto *proto = (CMsnProto*)extra;
 +
 +	proto->debugLogA("File transfer connection accepted");
 +
 +	NETLIBCONNINFO connInfo = { sizeof(connInfo) };
 +	CallService(MS_NETLIB_GETCONNECTIONINFO, (WPARAM)hNewConnection, (LPARAM)&connInfo);
 +
 +	ThreadData* T = proto->MSN_GetThreadByPort(connInfo.wPort);
 +	if (T != NULL && T->s == NULL) {
 +		T->s = hNewConnection;
 +		ReleaseSemaphore(T->hWaitEvent, 1, NULL);
 +	}
 +	else {
 +		proto->debugLogA("There's no registered file transfers for incoming port #%u, connection closed", connInfo.wPort);
 +		Netlib_CloseHandle(hNewConnection);
 +	}
 +}
 +
 +/////////////////////////////////////////////////////////////////////////////////////////
 +// Processes various invitations
 +
 +void CMsnProto::MSN_InviteMessage(ThreadData* info, char* msgBody, char* email, char* nick)
 +{
 +	MimeHeaders tFileInfo;
 +	tFileInfo.readFromBuffer(msgBody);
 +
 +	const char* Appname = tFileInfo["Application-Name"];
 +	const char* AppGUID = tFileInfo["Application-GUID"];
 +	const char* Invcommand = tFileInfo["Invitation-Command"];
 +	const char* Invcookie = tFileInfo["Invitation-Cookie"];
 +	const char* Appfile = tFileInfo["Application-File"];
 +	const char* Appfilesize = tFileInfo["Application-FileSize"];
 +	const char* IPAddress = tFileInfo["IP-Address"];
 +	const char* IPAddressInt = tFileInfo["IP-Address-Internal"];
 +	const char* Port = tFileInfo["Port"];
 +	const char* PortXInt = tFileInfo["PortX-Internal"];
 +	const char* AuthCookie = tFileInfo["AuthCookie"];
 +	const char* SessionID = tFileInfo["Session-ID"];
 +	const char* SessionProtocol = tFileInfo["Session-Protocol"];
 +	//	const char* Connectivity = tFileInfo["Connectivity"];
 +
 +	if (AppGUID != NULL) {
 +		if (!strcmp(AppGUID, "{02D3C01F-BF30-4825-A83A-DE7AF41648AA}")) {
 +			MSN_ShowPopup(info->getContactHandle(),
 +				TranslateT("Contact tried to open an audio conference (not currently supported)"), MSN_ALLOW_MSGBOX);
 +			return;
 +		}
 +	}
 +
 +	if (Invcommand && (strcmp(Invcommand, "CANCEL") == 0)) {
 +		delete info->mMsnFtp;
 +		info->mMsnFtp = NULL;
 +	}
 +
 +	if (Appname != NULL && Appfile != NULL && Appfilesize != NULL)  // receive first
 +	{
 +		filetransfer* ft = info->mMsnFtp = new filetransfer(this);
 +
 +		ft->std.hContact = MSN_HContactFromEmail(email, nick, true, true);
 +		mir_free(ft->std.tszCurrentFile);
 +		ft->std.tszCurrentFile = mir_utf8decodeT(Appfile);
 +		ft->std.totalBytes = ft->std.currentFileSize = _atoi64(Appfilesize);
 +		ft->std.totalFiles = 1;
 +		ft->szInvcookie = mir_strdup(Invcookie);
 +		ft->p2p_dest = mir_strdup(email);
 +
 +		TCHAR tComment[40];
 +		mir_sntprintf(tComment, SIZEOF(tComment), TranslateT("%I64u bytes"), ft->std.currentFileSize);
 +
 +		PROTORECVFILET pre = { 0 };
 +		pre.flags = PREF_TCHAR;
 +		pre.fileCount = 1;
 +		pre.timestamp = time(NULL);
 +		pre.tszDescription = tComment;
 +		pre.ptszFiles = &ft->std.tszCurrentFile;
 +		pre.lParam = (LPARAM)ft;
 +		ProtoChainRecvFile(ft->std.hContact, &pre);
 +		return;
 +	}
 +
 +	// receive Second
 +	if (IPAddress != NULL && Port != NULL && AuthCookie != NULL) {
 +		ThreadData* newThread = new ThreadData;
 +
 +		if (inet_addr(IPAddress) != MyConnection.extIP || !IPAddressInt)
 +			mir_snprintf(newThread->mServer, SIZEOF(newThread->mServer), "%s:%s", IPAddress, Port);
 +		else
 +			mir_snprintf(newThread->mServer, SIZEOF(newThread->mServer), "%s:%u", IPAddressInt, atol(PortXInt) ^ 0x3141);
 +
 +		newThread->mType = SERVER_FILETRANS;
 +
 +		if (info->mMsnFtp == NULL) {
 +			ThreadData* otherThread = MSN_GetOtherContactThread(info);
 +			if (otherThread) {
 +				info->mMsnFtp = otherThread->mMsnFtp;
 +				otherThread->mMsnFtp = NULL;
 +			}
 +		}
 +
 +		newThread->mMsnFtp = info->mMsnFtp; info->mMsnFtp = NULL;
 +		strcpy(newThread->mCookie, AuthCookie);
 +
 +		newThread->startThread(&CMsnProto::MSNServerThread, this);
 +		return;
 +	}
 +
 +	// send 1
 +	if (Invcommand != NULL && Invcookie != NULL && Port == NULL && AuthCookie == NULL && SessionID == NULL) { 
 +		msnftp_startFileSend(info, Invcommand, Invcookie);
 +		return;
 +	}
 +
 +	// netmeeting send 1
 +	if (Appname == NULL && SessionID != NULL && SessionProtocol != NULL) {
 +		if (!_stricmp(Invcommand, "ACCEPT")) {
 +			ShellExecuteA(NULL, "open", "conf.exe", NULL, NULL, SW_SHOW);
 +			Sleep(3000);
 +
 +			info->sendPacketPayload("MSG", "N",
 + 				"MIME-Version: 1.0\r\n"
 +				"Content-Type: text/x-msmsgsinvite; charset=UTF-8\r\n\r\n"
 +				"Invitation-Command: ACCEPT\r\n"
 +				"Invitation-Cookie: %s\r\n"
 +				"Session-ID: {1A879604-D1B8-11D7-9066-0003FF431510}\r\n"
 +				"Launch-Application: TRUE\r\n"
 +				"IP-Address: %s\r\n\r\n",
 +				Invcookie, MyConnection.GetMyExtIPStr());
 +		}
 +		return;
 +	}
 +
 +	// netmeeting receive 1
 +	if (Appname != NULL && !_stricmp(Appname, "NetMeeting")) {
 +		TCHAR text[512], *tszEmail = mir_a2t(email);
 +		mir_sntprintf(text, SIZEOF(text), TranslateT("Accept NetMeeting request from %s?"), tszEmail);
 +		mir_free(tszEmail);
 +
 +		if (MessageBox(NULL, text, TranslateT("MSN Protocol"), MB_YESNO | MB_ICONQUESTION) == IDYES) {
 +			info->sendPacketPayload("MSG", "N",
 +				"MIME-Version: 1.0\r\n"
 +				"Content-Type: text/x-msmsgsinvite; charset=UTF-8\r\n\r\n"
 +				"Invitation-Command: ACCEPT\r\n"
 +				"Invitation-Cookie: %s\r\n"
 +				"Session-ID: {A2ED5ACF-F784-4B47-A7D4-997CD8F643CC}\r\n"
 +				"Session-Protocol: SM1\r\n"
 +				"Launch-Application: TRUE\r\n"
 +				"Request-Data: IP-Address:\r\n"
 +				"IP-Address: %s\r\n\r\n",
 +				Invcookie, MyConnection.GetMyExtIPStr());
 +		}
 +		else {
 +			info->sendPacketPayload("MSG", "N",
 +				"MIME-Version: 1.0\r\n"
 +				"Content-Type: text/x-msmsgsinvite; charset=UTF-8\r\n\r\n"
 +				"Invitation-Command: CANCEL\r\n"
 +				"Invitation-Cookie: %s\r\n"
 +				"Cancel-Code: REJECT\r\n\r\n",
 +				Invcookie);
 +		}
 +		return;
 +	}
 +
 +	if (IPAddress != NULL && Port == NULL && SessionID != NULL && SessionProtocol == NULL) { // netmeeting receive 2
 +		char ipaddr[256];
 +		mir_snprintf(ipaddr, SIZEOF(ipaddr), "callto://%s", IPAddress);
 +		ShellExecuteA(NULL, "open", ipaddr, NULL, NULL, SW_SHOW);
 +	}
 +}
 +
 +void CMsnProto::MSN_ProcessRemove(char* buf, size_t len)
 +{
 +	ezxml_t xmli = ezxml_parse_str(buf, len);
 +	ezxml_t dom  = ezxml_child(xmli, "d");
 +	while (dom != NULL) {
 +		const char* szDom = ezxml_attr(dom, "n");
 +		ezxml_t cont = ezxml_child(dom, "c");
 +		while (cont != NULL) {
 +			const char* szCont = ezxml_attr(cont, "n");
 +			int listId = atol(ezxml_attr(cont, "l"));
 +
 +			char szEmail[128];
 +			mir_snprintf(szEmail, SIZEOF(szEmail), "%s@%s", szCont, szDom);
 +			Lists_Remove(listId, szEmail);
 +
 +			MsnContact* msc = Lists_Get(szEmail);
 +			if (msc == NULL || (msc->list & (LIST_RL | LIST_FL | LIST_LL)) == 0) {
 +				if (msc->hContact && _stricmp(szEmail, MyOptions.szEmail)) {
 +					CallService(MS_DB_CONTACT_DELETE, (WPARAM)msc->hContact, 0);
 +					msc->hContact = NULL;
 +				}
 +			}
 +
 +			cont = ezxml_next(cont);
 +		}
 +		dom = ezxml_next(dom);
 +	}
 +	ezxml_free(xmli);
 +}
 +
 +/////////////////////////////////////////////////////////////////////////////////////////
 +// Processes custom smiley messages
 +
 +void CMsnProto::MSN_CustomSmiley(const char* msgBody, char* email, char* nick, int iSmileyType)
 +{
 +	MCONTACT hContact = MSN_HContactFromEmail(email, nick, true, true);
 +
 +	char smileyList[500] = "";
 +
 +	const char *tok1 = msgBody, *tok2;
 +	char *smlp = smileyList;
 +	char lastsml[50];
 +
 +	unsigned iCount = 0;
 +	bool parseSmiley = true;
 +
 +	for (;;) {
 +		tok2 = strchr(tok1, '\t');
 +		if (tok2 == NULL) break;
 +
 +		size_t sz = tok2 - tok1;
 +		if (parseSmiley) {
 +			sz = min(sz, sizeof(lastsml)-1);
 +			memcpy(lastsml, tok1, sz);
 +			lastsml[sz] = 0;
 +
 +			memcpy(smlp, tok1, sz); smlp += sz;
 +			*(smlp++) = '\n'; *smlp = 0;
 +			++iCount;
 +		}
 +		else {
 +			filetransfer* ft = new filetransfer(this);
 +			ft->std.hContact = hContact;
 +
 +			ft->p2p_object = (char*)mir_alloc(sz + 1);
 +			memcpy(ft->p2p_object, tok1, sz);
 +			ft->p2p_object[sz] = 0;
 +
 +			size_t slen = strlen(lastsml);
 +			ptrA buf(mir_base64_encode((PBYTE)lastsml, (unsigned)slen));
 +			ptrA smileyName(mir_urlEncode(buf));
 +
 +			TCHAR path[MAX_PATH];
 +			MSN_GetCustomSmileyFileName(hContact, path, SIZEOF(path), smileyName, iSmileyType);
 +			ft->std.tszCurrentFile = mir_tstrdup(path);
 +
 +			if (p2p_IsDlFileOk(ft))
 +				delete ft;
 +			else {
 +				debugLogA("Custom Smiley p2p invite for object : %s", ft->p2p_object);
 +				p2p_invite(iSmileyType, ft, email);
 +				Sleep(3000);
 +			}
 +		}
 +		parseSmiley = !parseSmiley;
 +		tok1 = tok2 + 1;
 +	}
 +}
 +
 +/////////////////////////////////////////////////////////////////////////////////////////
 +// Process user addition
 +
 +void CMsnProto::MSN_ProcessAdd(char* buf, size_t len)
 +{
 +	if (buf == NULL) return;
 +
 +	ezxml_t xmli = ezxml_parse_str(buf, len);
 +	ezxml_t dom  = ezxml_child(xmli, "d");
 +	while (dom != NULL) {
 +		const char* szDom = ezxml_attr(dom, "n");
 +		ezxml_t cont = ezxml_child(dom, "c");
 +		while (cont != NULL) {
 +			const char* szCont = ezxml_attr(cont, "n");
 +			const char* szNick = ezxml_attr(cont, "f");
 +			int listId = atol(ezxml_attr(cont, "l"));
 +			int netId = atol(ezxml_attr(cont, "t"));
 +
 +			char szEmail[128];
 +			mir_snprintf(szEmail, SIZEOF(szEmail), "%s@%s", szCont, szDom);
 +
 +			UrlDecode((char*)szNick);
 +
 +			if (listId == LIST_FL) {
 +				MCONTACT hContact = MSN_HContactFromEmail(szEmail, szNick, true, false);
 +				MSN_SetContactDb(hContact, szEmail);
 +			}
 +
 +			if (listId == LIST_RL)
 +				MSN_SharingFindMembership(true);
 +			else
 +				MSN_AddUser(NULL, szEmail, netId, listId);
 +
 +			MsnContact* msc = Lists_Get(szEmail);
 +			if (msc == NULL) {
 +				Lists_Add(listId, netId, szEmail);
 +				msc = Lists_Get(szEmail);
 +			}
 +
 +			if (listId == LIST_RL) {
 +				if ((msc->list & (LIST_AL | LIST_BL)) == 0) {
 +					MSN_AddAuthRequest(szEmail, szNick, msc->invite);
 +					msc->netId = netId;
 +				}
 +				else MSN_AddUser(NULL, szEmail, netId, LIST_PL + LIST_REMOVE);
 +			}
 +
 +			cont = ezxml_next(cont);
 +		}
 +		dom = ezxml_next(dom);
 +	}
 +	ezxml_free(xmli);
 +}
 +
 +void CMsnProto::MSN_ProcessPage(char* buf, unsigned len)
 +{
 +	if (buf == NULL) return;
 +	ezxml_t xmlnot = ezxml_parse_str(buf, len);
 +
 +	ezxml_t xmlbdy = ezxml_get(xmlnot, "MSG", 0, "BODY", -1);
 +	const char* szMsg = ezxml_txt(ezxml_child(xmlbdy, "TEXT"));
 +	const char* szTel = ezxml_attr(ezxml_child(xmlnot, "FROM"), "name");
 +
 +	if (szTel && *szMsg) {
 +		PROTORECVEVENT pre = { 0 };
 +		pre.szMessage = (char*)szMsg;
 +		pre.flags = PREF_UTF /*+ ((isRtl) ? PREF_RTL : 0)*/;
 +		pre.timestamp = time(NULL);
 +		ProtoChainRecvMsg(MSN_HContactFromEmail(szTel, szTel, true, true), &pre);
 +	}
 +	ezxml_free(xmlnot);
 +}
 +
 +
 +void CMsnProto::MSN_InitSB(ThreadData* info, const char* szEmail)
 +{
 +	MsnContact *cont = Lists_Get(szEmail);
 +
 +	if (cont->netId == NETID_MSN)
 +		info->sendCaps();
 +
 +	bool typing = false;
 +
 +	for (int i = 3; --i;) {
 +		MsgQueueEntry E;
 +		while (MsgQueue_GetNext(szEmail, E)) {
 +			if (E.msgType == 'X') ;
 +			else if (E.msgType == 2571)
 +				typing = E.flags != 0;
 +			else if (E.msgSize == 0) {
 +				info->sendMessage(E.msgType, NULL, 1, E.message, E.flags);
 +				ProtoBroadcastAck(cont->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)E.seq, 0);
 +			}
 +			else {
 +				if (E.msgType == 'D' && !info->mBridgeInit) { //&& strchr(data.flags, ':'))  {
 +					info->mBridgeInit = true;
 +
 +//					P2PV2_Header hdrdata(E.message);
 +//					P2PV2_Header tHdr;
 +//					tHdr.mID = hdrdata.mID;
 +//					p2p_sendMsg(info, E.wlid, 0, tHdr, NULL, 0);
 +				}
 +				info->sendRawMessage(E.msgType, E.message, E.msgSize);
 +			}
 +
 +			mir_free(E.message);
 +			mir_free(E.wlid);
 +
 +			if (E.ft != NULL)
 +				info->mMsnFtp = E.ft;
 +		}
 +		mir_free(info->mInitialContactWLID); info->mInitialContactWLID = NULL;
 +	}
 +
 +	if (typing)
 +		MSN_StartStopTyping(info, true);
 +
 +	if (getByte("EnableDeliveryPopup", 0))
 +		MSN_ShowPopup(cont->hContact, info->mCaller ?
 +			TranslateT("Chat session established by my request") :
 +			TranslateT("Chat session established by contact request"), 0);
 +
 +	PROTO_AVATAR_INFORMATIONT ai = { sizeof(ai), cont->hContact };
 +	GetAvatarInfo(GAIF_FORCE, (LPARAM)&ai);
 +}
 +
 +int CMsnProto::MSN_HandleCommands(ThreadData* info, char* cmdString)
 +{
 +	char* params = "";
 +	int trid = -1;
 +
 +	if (cmdString[3]) {
 +		if (isdigit((BYTE)cmdString[4])) {
 +			trid = strtol(cmdString + 4, ¶ms, 10);
 +			switch (*params) {
 +			case ' ':	case '\0':	case '\t':	case '\n':
 +				while (*params == ' ' || *params == '\t')
 +					params++;
 +				break;
 +
 +			default:
 +				params = cmdString + 4;
 +			}
 +		}
 +		else params = cmdString + 4;
 +	}
 +
 +	switch((*(PDWORD)cmdString & 0x00FFFFFF) | 0x20000000) {
 +	case ' KCA':    //********* ACK: section 8.7 Instant Messages
 +		ReleaseSemaphore(info->hWaitEvent, 1, NULL);
 +
 +		if (info->mJoinedContactsWLID.getCount() > 0 && MyOptions.SlowSend)
 +			ProtoBroadcastAck(info->getContactHandle(), ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)trid, 0);
 +		break;
 +
 +	case ' YQF':	//********* FQY: Find Yahoo User
 +		char* tWords[1];
 +		if (sttDivideWords(params, 1, tWords) != 1)
 +			debugLogA("Invalid %.3s command, ignoring", cmdString);
 +		else {
 +			size_t len = atol(tWords[0]);
 +			MSN_ProcessYFind((char*)HReadBuffer(info, 0).surelyRead(len), len);
 +		}
 +		break;
 +
 +	case ' LDA':	//********* ADL: Add to the list
 +		{
 +			char* tWords[1];
 +			if (sttDivideWords(params, 1, tWords) != 1) {
 +LBL_InvalidCommand:
 +				debugLogA("Invalid %.3s command, ignoring", cmdString);
 +				break;
 +			}
 +
 +			if (strcmp(tWords[0], "OK") != 0) {
 +				size_t len = atol(tWords[0]);
 +				MSN_ProcessAdd((char*)HReadBuffer(info, 0).surelyRead(len), len);
 +			}
 +		}
 +		break;
 +
 +	case ' SBS':
 +		break;
 +
 +	case ' SNA':    //********* ANS: section 8.4 Getting Invited to a Switchboard Session
 +		break;
 +
 +	case ' PRP':
 +		break;
 +
 +	case ' PLB':    //********* BLP: section 7.6 List Retrieval And Property Management
 +		break;
 +
 +	case ' EYB':   //********* BYE: section 8.5 Session Participant Changes
 +		{
 +			union {
 +				char* tWords[2];
 +				// modified for chat, orginally param2 = junk
 +				// param 2: quit due to idle = "1", normal quit = nothing
 +				struct { char *userEmail, *isIdle; } data;
 +			};
 +
 +			sttDivideWords(params, 2, tWords);
 +			UrlDecode(data.userEmail);
 +
 +			if (strchr(data.userEmail, ';')) {
 +				if (info->mJoinedContactsWLID.getCount() == 1)
 +					p2p_clearThreadSessions((MCONTACT)info->mJoinedContactsWLID[0], info->mType);
 +				info->contactLeft(data.userEmail);
 +				break;
 +			}
 +
 +			MCONTACT hContact = MSN_HContactFromEmail(data.userEmail);
 +
 +			if (getByte("EnableSessionPopup", 0))
 +				MSN_ShowPopup(hContact, TranslateT("Contact left channel"), 0);
 +
 +			// modified for chat
 +			{
 +				GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_QUIT };
 +				GCEVENT gce = { sizeof(gce), &gcd };
 +				gce.dwFlags = GCEF_ADDTOLOG;
 +				gce.ptszNick = GetContactNameT(hContact);
 +				gce.ptszUID = mir_a2t(data.userEmail);
 +				gce.time = time(NULL);
 +				gce.bIsMe = FALSE;
 +				CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
 +				mir_free((void*)gce.ptszUID);
 +			}
 +
 +			int personleft = info->contactLeft(data.userEmail);
 +
 +			int temp_status = getWord(hContact, "Status", ID_STATUS_OFFLINE);
 +			if (temp_status == ID_STATUS_INVISIBLE && MSN_GetThreadByContact(data.userEmail) == NULL)
 +				setWord(hContact, "Status", ID_STATUS_OFFLINE);
 +
 +			// see if the session is quit due to idleness
 +			if (info->mChatID[0] && personleft == 1) {
 +				if (!strcmp(data.isIdle, "1")) {
 +					GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_INFORMATION };
 +					GCEVENT gce = { sizeof(gce), &gcd };
 +					gce.dwFlags = GCEF_ADDTOLOG;
 +					gce.bIsMe = FALSE;
 +					gce.time = time(NULL);
 +					gce.ptszText = TranslateT("This conversation has been inactive, participants will be removed.");
 +					CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
 +					gce.ptszText = TranslateT("To resume the conversation, please quit this session and start a new chat session.");
 +					CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
 +				}
 +				else {
 +					if (!Miranda_Terminated() && MessageBox(NULL,
 +						TranslateT("There is only 1 person left in the chat, do you want to switch back to standard message window?"),
 +						TranslateT("MSN Chat"), MB_YESNO | MB_ICONQUESTION) == IDYES) {
 +						// kill chat dlg and open srmm dialog
 +						MSN_KillChatSession(info->mChatID);
 +
 +						// open up srmm dialog when quit while 1 person left
 +						MCONTACT hContact = info->getContactHandle();
 +						if (hContact) CallServiceSync(MS_MSG_SENDMESSAGE, hContact, 0);
 +					}
 +				}
 +			}
 +			// this is not in chat session, quit the session when everyone left
 +			else if (info->mJoinedContactsWLID.getCount() < 1)
 +				return 1;
 +
 +		}
 +		break;
 +
 +	case ' LAC':    //********* CAL: section 8.3 Inviting Users to a Switchboard Session
 +		break;
 +
 +	case ' GHC':    //********* CHG: section 7.7 Client States
 +		{
 +			int oldStatus = m_iStatus;
 +			int newStatus = MSNStatusToMiranda(params);
 +			if (oldStatus <= ID_STATUS_OFFLINE) {
 +				isConnectSuccess = true;
 +				int count = -1;
 +				for (;;) {
 +					MsnContact *msc = Lists_GetNext(count);
 +					if (msc == NULL) break;
 +
 +					if (msc->netId == NETID_MOB)
 +						setWord(msc->hContact, "Status", ID_STATUS_ONTHEPHONE);
 +				}
 +			}
 +			if (newStatus != ID_STATUS_IDLE) {
 +				m_iStatus = newStatus;
 +				ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, newStatus);
 +				debugLogA("Status change acknowledged: %s", params);
 +				MSN_RemoveEmptyGroups();
 +			}
 +			if (newStatus == ID_STATUS_OFFLINE) return 1;
 +		}
 +		break;
 +	case ' LHC':    //********* CHL: Query from Server on MSNP7
 +		{
 +			char* authChallengeInfo;
 +			if (sttDivideWords(params, 1, &authChallengeInfo) != 1)
 +				goto LBL_InvalidCommand;
 +
 +			char dgst[64];
 +			MSN_MakeDigest(authChallengeInfo, dgst);
 +			info->sendPacket("QRY", "%s 32\r\n%s", msnProductID, dgst);
 +		}
 +		break;
 +
 +	case ' RVC':    //********* CVR: MSNP8
 +		break;
 +
 +	case ' NLF':    //********* FLN: section 7.9 Notification Messages
 +		{
 +			union {
 +				char* tWords[2];
 +				struct { char *userEmail, *netId; } data;
 +			};
 +
 +			int tArgs = sttDivideWords(params, 2, tWords);
 +			if (tArgs < 2)
 +				goto LBL_InvalidCommand;
 +
 +			MCONTACT hContact = MSN_HContactFromEmail(data.userEmail);
 +			if (hContact != NULL) {
 +				setWord(hContact, "Status", MSN_GetThreadByContact(data.userEmail) ? ID_STATUS_INVISIBLE : ID_STATUS_OFFLINE);
 +				setDword(hContact, "IdleTS", 0);
 +				ForkThread(&CMsnProto::MsgQueue_AllClearThread, mir_strdup(data.userEmail));
 +			}
 +		}
 +		break;
 +
  	case ' NLI':
  	case ' NLN':    //********* ILN/NLN: section 7.9 Notification Messages
  		{
 @@ -1672,7 +1880,7 @@ LBL_InvalidCommand:  			MSN_ProcessNLN(data.userStatus, data.wlid, data.userNick, data.objid, data.cmdstring);
  		}
  		break;
 -	case ' ORI':    /********* IRO: section 8.4 Getting Invited to a Switchboard Session
 +	case ' ORI':    //******** IRO: section 8.4 Getting Invited to a Switchboard Session
  		{
  			union {
  				char* tWords[5];
 @@ -1709,7 +1917,7 @@ LBL_InvalidCommand:  		}
  		break;*/
 -	case ' IOJ':    /********* JOI: section 8.5 Session Participant Changes
 +	case ' IOJ':    //******** JOI: section 8.5 Session Participant Changes
  		{
  			union {
  				char* tWords[3];
 @@ -1832,78 +2040,6 @@ LBL_InvalidCommand:  		debugLogA("Message send failed (trid=%d)", trid);
  		break;
 -	case ' YFN':   //********* NFY: MSNP21+ Notifications
 -		{
 -			union {
 -				char* tWords[2];
 -				struct { char *typeId, *strMsgBytes; } data;
 -			};
 -
 -			if (sttDivideWords(params, SIZEOF(tWords), tWords) < 2)
 -				goto LBL_InvalidCommand;
 -
 -			HReadBuffer buf(info, 0);
 -			char* msgBody = (char*)buf.surelyRead(atol(data.strMsgBytes));
 -			if (msgBody == NULL) break;
 -			if (!strcmp(data.typeId, "MSGR\\HOTMAIL")) {
 -				char szParam[128];
 -				mir_snprintf(szParam, sizeof(szParam), "%s %s", data.typeId, data.strMsgBytes);
 -				MSN_ReceiveMessage(info, cmdString, szParam);
 -				break;
 -			} else if (!strcmp(data.typeId, "MSGR\\ABCH")) {
 -				MimeHeaders tHeader;
 -				msgBody = tHeader.readFromBuffer(msgBody);
 -				MSN_ProcessNotificationMessage(msgBody, strlen(msgBody));
 -				break;
 -			}
 -
 -			if (!strcmp(data.typeId, "MSGR\\PUT") || !strcmp(data.typeId, "MSGR\\DEL")) {
 -				MimeHeaders tHeader;
 -
 -				int i;
 -				for (i=0; i<2; i++) msgBody = tHeader.readFromBuffer(msgBody);
 -				char *pszTo = NULL, *pszToNet;
 -				if (tHeader["To"]) parseWLID(NEWSTR_ALLOCA(tHeader["To"]), &pszToNet, &pszTo, NULL);
 -				const char *pszFrom =  tHeader["From"];
 -				for (i=0; i<2; i++) msgBody = tHeader.readFromBuffer(msgBody);
 -
 -				if (pszFrom)
 -				{
 -					ezxml_t xmli;
 -					if (xmli = ezxml_parse_str(msgBody, strlen(msgBody)))
 -					{
 -						if (!strcmp(xmli->name, "user"))
 -						{
 -							ezxml_t xmlstatus = ezxml_get(xmli, "s", 0, "Status", -1);
 -							/* FIXME: MSGR\DEL: Instance of user with given EPID disconnected, not 
 -							 * sure if this implies that contact is offline now... */
 -							if (xmlstatus || !strcmp(data.typeId, "MSGR\\DEL"))
 -							{
 -								// These capabilities seem to be something different than in previous MSNP versions?
 -								//ezxml_t xmlcaps = ezxml_get(xmli, "sep", 0, "Capabilities", -1);
 -								ezxml_t usertile = ezxml_get(xmli, "s", 1, "UserTileLocation", -1);
 -								MSN_ProcessNLN(ezxml_txt(xmlstatus), pszFrom, NULL, NULL, usertile?usertile->txt:NULL);
 -							}
 -							MSN_ProcessStatusMessage(xmli, pszFrom);
 -						}
 -						ezxml_free(xmli);
 -					}				
 -				}
 -			}
 -			else if (!strcmp(data.typeId, "MSGR\\THREAD")) {
 -				MimeHeaders tHeader;
 -				char *msgBody = tHeader.readFromBuffer(info->mData);
 -				ezxml_t xmli;
 -
 -				if (xmli = ezxml_parse_str(msgBody, strlen(msgBody)))
 -				{
 -					MSN_ChatStart(xmli);
 -					ezxml_free(xmli);
 -				}				
 -			}
 -		}
 -		break;
 -
  	case ' TON':   //********* NOT: notification message
  		MSN_ProcessNotificationMessage((char*)HReadBuffer(info, 0).surelyRead(trid), trid);
  		break;
 @@ -1927,54 +2063,6 @@ LBL_InvalidCommand:  		return 1;
 -	case ' TUP':	//******** MSNP21+: PUT notifications
 -	case ' GNP':	//******** MSNP21+: PNG reply
 -		{
 -			union {
 -				char* tWords[2];
 -				struct { char *typeId, *strMsgBytes; } data;
 -			};
 -
 -			if (sttDivideWords(params, SIZEOF(tWords), tWords) < 2)
 -				goto LBL_InvalidCommand;
 -
 -			MimeHeaders tHeader;
 -			HReadBuffer buf(info, 0);
 -			char* msgBody = tHeader.readFromBuffer((char*)buf.surelyRead(atol(data.strMsgBytes)));
 -
 -			if (tHeader["Set-Registration"]) replaceStr(msnRegistration,tHeader["Set-Registration"]);
 -			if (cmdString[1]=='N') { // PNG
 -				if (ezxml_t xmli = ezxml_parse_str(msgBody, strlen(msgBody))) {
 -					if (ezxml_t wait = ezxml_child(xmli, "wait")) {
 -						msnPingTimeout = atoi(ezxml_txt(wait));
 -						if (msnPingTimeout && hKeepAliveThreadEvt != NULL)
 -							SetEvent(hKeepAliveThreadEvt);
 -					}
 -					ezxml_free(xmli);
 -				}				
 -			} else { // PUT
 -				ezxml_t xmli;
 -				if (*msgBody && (xmli = ezxml_parse_str(msgBody, strlen(msgBody)))) {
 -					if (!strcmp(xmli->name, "presence-response")) {
 -						ezxml_t user, from;
 -						if ((user = ezxml_child(xmli, "user")) && (from = ezxml_child(xmli, "from"))) {
 -							if (ezxml_t xmlstatus = ezxml_get(user, "s", 0, "Status", -1)) {
 -								ezxml_t usertile = ezxml_get(user, "s", 1, "UserTileLocation", -1);
 -								MSN_ProcessNLN(ezxml_txt(xmlstatus), from->txt, NULL, NULL, usertile?usertile->txt:NULL);
 -							} else {
 -								int oldMode = m_iStatus;
 -								m_iStatus = m_iDesiredStatus;
 -								ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldMode, m_iStatus);
 -							}
 -							MSN_ProcessStatusMessage(user, from->txt);
 -						}
 -					}
 -					ezxml_free(xmli);
 -				}				
 -			}
 -		}
 -		break;
 -
  	case ' YRQ':   //********* QRY:
  		break;
 @@ -2034,10 +2122,6 @@ LBL_InvalidCommand:  		}
  		break;
 -	case ' GDS':   // SDG:  MSNP21+ Messaging
 -		MSN_ReceiveMessage(info, cmdString, params);
 -		break;
 -
  	case ' XBU':   // UBX : MSNP11+ User Status Message
  		{
  			union {
 @@ -2214,36 +2298,52 @@ LBL_InvalidCommand:  	case ' RFX':    //******** XFR: sections 7.4 Referral, 8.1 Referral to Switchboard
  		{
  			union {
 -				char* tWords[2];
 -				struct { char *typeId, *strMsgBytes; } data;
 +				char* tWords[7];
 +				struct { char *type, *newServer, *security, *authChallengeInfo,
 +								*type2, *srcUrl, *genGateway; } data;
  			};
 -			if (sttDivideWords(params, SIZEOF(tWords), tWords) < 2)
 +			int numWords = sttDivideWords(params, 7, tWords);
 +			if (numWords < 3)
  				goto LBL_InvalidCommand;
 -			MimeHeaders tHeader;
 -			HReadBuffer buf(info, 0);
 -			char* msgBody = tHeader.readFromBuffer((char*)buf.surelyRead(atol(data.strMsgBytes)));
 -			if (!strcmp(data.typeId, "CON")) {
 -				ezxml_t xmlxfr = ezxml_parse_str(msgBody, strlen(msgBody));
 -				ezxml_t xmltgt = ezxml_child(xmlxfr, "target");
 -				if (xmltgt)
 -				{
 -					ThreadData* newThread = new ThreadData;
 -					strcpy(newThread->mServer, xmltgt->txt);
 -					strcpy(newThread->mState, ezxml_txt(ezxml_child(xmlxfr, "state")));
 -					newThread->mType = SERVER_NOTIFICATION;
 -					newThread->mTrid = info->mTrid;
 -					newThread->mIsMainThread = true;
 -					info->mIsMainThread = false;
 +			if (!strcmp(data.type, "NS")) {  //notification server
 +				UrlDecode(data.newServer);
 +				ThreadData* newThread = new ThreadData;
 +				strcpy(newThread->mServer, data.newServer);
 +				newThread->mType = SERVER_NOTIFICATION;
 +				newThread->mTrid = info->mTrid;
 +				newThread->mIsMainThread = true;
 +				usingGateway |= (*data.security == 'G');
 +				info->mIsMainThread = false;
 +
 +				debugLogA("Switching to notification server '%s'...", data.newServer);
 +				newThread->startThread(&CMsnProto::MSNServerThread, this);
 +				return 1;  //kill the old thread
 +			}
 -					debugLogA("Switching to notification server '%s'...", xmltgt->txt);
 -					newThread->startThread(&CMsnProto::MSNServerThread, this);
 -					ezxml_free(xmlxfr);
 -					return 1;  //kill the old thread
 +			if (!strcmp(data.type, "SB")) {  //switchboard server
 +				UrlDecode(data.newServer);
 +
 +				if (numWords < 4)
 +					goto LBL_InvalidCommand;
 +
 +				if (strcmp(data.security, "CKI")) {
 +					debugLogA("Unknown XFR SB security package '%s'", data.security);
 +					break;
  				}
 -				ezxml_free(xmlxfr);
 +
 +				ThreadData* newThread = new ThreadData;
 +				strcpy(newThread->mServer, data.newServer);
 +				newThread->gatewayType = data.genGateway && atol(data.genGateway) != 0;
 +				newThread->mType = SERVER_SWITCHBOARD;
 +				newThread->mCaller = 1;
 +				strcpy(newThread->mCookie, data.authChallengeInfo);
 +
 +				debugLogA("Opening switchboard server '%s'...", data.newServer);
 +				newThread->startThread(&CMsnProto::MSNServerThread, this);
  			}
 +			else debugLogA("Unknown referral server: %s", data.type);
  		}
  		break;
 @@ -2254,3 +2354,4 @@ LBL_InvalidCommand:  	return 0;
  }
 +#endif
\ No newline at end of file diff --git a/protocols/MSN/src/msn_contact.cpp b/protocols/MSN/src/msn_contact.cpp index 4e58396710..6087c99a8b 100644 --- a/protocols/MSN/src/msn_contact.cpp +++ b/protocols/MSN/src/msn_contact.cpp @@ -106,7 +106,7 @@ void CMsnProto::MSN_SetContactDb(MCONTACT hContact, const char *szEmail)  void CMsnProto::AddDelUserContList(const char* email, const int list, const int netId, const bool del)
  {
 -/*
 +#ifdef OBSOLETE
  	char buf[512];
  	size_t sz;
 @@ -126,7 +126,7 @@ void CMsnProto::AddDelUserContList(const char* email, const int list, const int  		}
  		msnNsThread->sendPacket(del ? "RML" : "ADL", "%d\r\n%s", sz, buf);
  	}
 -*/
 +#endif
  	if (del)
  		Lists_Remove(list, email);
 @@ -204,8 +204,10 @@ bool CMsnProto::MSN_AddUser(MCONTACT hContact, const char* email, int netId, int  				MSN_SharingFindMembership(true);
  				AddDelUserContList(email, flags, netId, false);
  			}
 +#ifdef OBSOLETE
  			else if (netId == 1 && strstr(email, "@yahoo.com") != 0)
  				MSN_FindYahooUser(email);
 +#endif
  			db_free(&dbv);
  		}
 @@ -232,7 +234,7 @@ bool CMsnProto::MSN_AddUser(MCONTACT hContact, const char* email, int netId, int  	return res;
  }
 -
 +#ifdef OBSOLETE
  void CMsnProto::MSN_FindYahooUser(const char* email)
  {
  	const char *dom = strchr(email, '@');
 @@ -246,6 +248,7 @@ void CMsnProto::MSN_FindYahooUser(const char* email)  		msnNsThread->sendPacket("FQY", "%d\r\n%s", sz, buf);
  	}
  }
 +#endif
  bool CMsnProto::MSN_RefreshContactList(void)
  {
 diff --git a/protocols/MSN/src/msn_ftold.cpp b/protocols/MSN/src/msn_ftold.cpp index c921ae3e11..dfd2e296c7 100644 --- a/protocols/MSN/src/msn_ftold.cpp +++ b/protocols/MSN/src/msn_ftold.cpp @@ -22,6 +22,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #include "msn_global.h"
  #include "msn_proto.h"
 +#ifdef OBSOLETE
  void CMsnProto::msnftp_sendAcceptReject(filetransfer *ft, bool acc)
  {
 @@ -365,3 +366,4 @@ void CMsnProto::msnftp_startFileSend(ThreadData* info, const char* Invcommand, c  	}
  	else delete ft;
  }
 +#endif
 diff --git a/protocols/MSN/src/msn_global.h b/protocols/MSN/src/msn_global.h index c67555d59e..d60f62a1f3 100644 --- a/protocols/MSN/src/msn_global.h +++ b/protocols/MSN/src/msn_global.h @@ -378,6 +378,7 @@ enum TInfoType  };
 +
  struct filetransfer
  {
  	filetransfer(CMsnProto* prt);
 diff --git a/protocols/MSN/src/msn_lists.cpp b/protocols/MSN/src/msn_lists.cpp index 6f7b6384fd..b8419abf25 100644 --- a/protocols/MSN/src/msn_lists.cpp +++ b/protocols/MSN/src/msn_lists.cpp @@ -133,6 +133,7 @@ int CMsnProto::Lists_GetNetId(const char* email)  	return p ? p->netId : NETID_UNKNOWN;
  }
 +#ifdef OBSOLETE
  unsigned CMsnProto::p2p_getMsgId(const char* wlid, int inc)
  {
  	mir_cslock lck(m_csLists);
 @@ -152,6 +153,7 @@ unsigned CMsnProto::p2p_getPktNum(const char* wlid)  	MsnPlace *p = Lists_GetPlace(wlid);
  	return p ? p->p2pPktNum++ : 0;
  }
 +#endif
  int CMsnProto::Lists_Add(int list, int netId, const char* email, MCONTACT hContact, const char* nick, const char* invite)
  {
 diff --git a/protocols/MSN/src/msn_menu.cpp b/protocols/MSN/src/msn_menu.cpp index 8675781a19..fc1eb5441d 100644 --- a/protocols/MSN/src/msn_menu.cpp +++ b/protocols/MSN/src/msn_menu.cpp @@ -141,7 +141,9 @@ int CMsnProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM)  		Menu_ModifyItem(hOpenInboxMenuItem, &mi);
  		Menu_ShowItem(hOpenInboxMenuItem, emailEnabled);
 +#ifdef OBSOLETE
  		Menu_ShowItem(hNetmeetingMenuItem, !noChat);
 +#endif
  		Menu_ShowItem(hChatInviteMenuItem, !noChat);
  	}
 @@ -157,6 +159,7 @@ int CMsnProto::OnContactDoubleClicked(WPARAM hContact, LPARAM)  	return 0;
  }
 +#ifdef OBSOLETE
  /////////////////////////////////////////////////////////////////////////////////////////
  // MsnSendNetMeeting - Netmeeting callback function
 @@ -192,6 +195,13 @@ INT_PTR CMsnProto::MsnSendNetMeeting(WPARAM wParam, LPARAM)  	return 0;
  }
 +static INT_PTR MsnMenuSendNetMeeting(WPARAM wParam, LPARAM lParam)
 +{
 +	CMsnProto* ppro = GetProtoInstanceByHContact(wParam);
 +	return (ppro) ? ppro->MsnSendNetMeeting(wParam, lParam) : 0;
 +}
 +#endif
 +
  /////////////////////////////////////////////////////////////////////////////////////////
  //	SetNicknameCommand - sets nick name
 @@ -372,12 +382,6 @@ static INT_PTR MsnMenuViewProfile(WPARAM wParam, LPARAM lParam)  	return (ppro) ? ppro->MsnViewProfile(wParam, lParam) : 0;
  }
 -static INT_PTR MsnMenuSendNetMeeting(WPARAM wParam, LPARAM lParam)
 -{
 -	CMsnProto* ppro = GetProtoInstanceByHContact(wParam);
 -	return (ppro) ? ppro->MsnSendNetMeeting(wParam, lParam) : 0;
 -}
 -
  static INT_PTR MsnMenuSendHotmail(WPARAM wParam, LPARAM lParam)
  {
  	CMsnProto* ppro = GetProtoInstanceByHContact(wParam);
 @@ -392,7 +396,9 @@ static int MSN_OnPrebuildContactMenu(WPARAM wParam, LPARAM lParam)  	else {
  		Menu_ShowItem(hBlockMenuItem, false);
  		Menu_ShowItem(hLiveSpaceMenuItem, false);
 +#ifdef OBSOLETE
  		Menu_ShowItem(hNetmeetingMenuItem, false);
 +#endif
  		Menu_ShowItem(hChatInviteMenuItem, false);
  		Menu_ShowItem(hOpenInboxMenuItem, false);
  	}
 @@ -423,6 +429,7 @@ void MSN_InitContactMenu(void)  	mi.pszName = LPGEN("View &Profile");
  	hLiveSpaceMenuItem = Menu_AddContactMenuItem(&mi);
 +#ifdef OBSOLETE
  	strcpy(tDest, MSN_NETMEETING);
  	hNetMeeting = CreateServiceFunction(servicefunction, MsnMenuSendNetMeeting);
  	mi.flags = CMIF_NOTOFFLINE;
 @@ -430,6 +437,7 @@ void MSN_InitContactMenu(void)  	mi.icolibItem = GetIconHandle(IDI_NETMEETING);
  	mi.pszName = LPGEN("&Start Netmeeting");
  	hNetmeetingMenuItem = Menu_AddContactMenuItem(&mi);
 +#endif
  	strcpy(tDest, "/SendHotmail");
  	hSendHotMail = CreateServiceFunction(servicefunction, MsnMenuSendHotmail);
 @@ -446,11 +454,13 @@ void MSN_RemoveContactMenus(void)  {
  	CallService(MO_REMOVEMENUITEM, (WPARAM)hBlockMenuItem, 0);
  	CallService(MO_REMOVEMENUITEM, (WPARAM)hLiveSpaceMenuItem, 0);
 +#ifdef OBSOLETE
  	CallService(MO_REMOVEMENUITEM, (WPARAM)hNetmeetingMenuItem, 0);
 +	DestroyServiceFunction(hNetMeeting);
 +#endif
  	CallService(MO_REMOVEMENUITEM, (WPARAM)hChatInviteMenuItem, 0);
  	CallService(MO_REMOVEMENUITEM, (WPARAM)hOpenInboxMenuItem, 0);
 -	DestroyServiceFunction(hNetMeeting);
  	DestroyServiceFunction(hBlockCom);
  	DestroyServiceFunction(hSendHotMail);
  	DestroyServiceFunction(hInviteChat);
 diff --git a/protocols/MSN/src/msn_misc.cpp b/protocols/MSN/src/msn_misc.cpp index 1c877b2488..b34350ded7 100644 --- a/protocols/MSN/src/msn_misc.cpp +++ b/protocols/MSN/src/msn_misc.cpp @@ -391,7 +391,9 @@ void CMsnProto::MSN_GoOffline(void)  		MSN_EnableMenuItems(false);
  	MSN_FreeGroups();
 +#ifdef OBSOLETE
  	MsgQueue_Clear();
 +#endif
  	clearCachedMsg();
  	if (!Miranda_Terminated()) {
 @@ -431,7 +433,7 @@ int ThreadData::sendMessage(int msgType, const char* email, int netId, const cha  	CMStringA buf;
  	if ((parFlags & MSG_DISABLE_HDR) == 0) {
 -		/*
 +
  		char  tFontName[100], tFontStyle[3];
  		DWORD tFontColor;
 @@ -465,12 +467,11 @@ int ThreadData::sendMessage(int msgType, const char* email, int netId, const cha  			tFontStyle[0] = 0;
  		}
 +#ifdef OBSOLETE
  		if (parFlags & MSG_OFFLINE)
 -			off += mir_snprintf((buf + off), (SIZEOF(buf) - off), "Dest-Agent: client\r\n");
 +			off += mir_snprintf((buf + off), (SIZEOF(buf) - off), "Dest-Agent: client\r\n"); 
 +#endif
 -		buf.AppendFormat("X-MMS-IM-Format: FN=%s; EF=%s; CO=%x; CS=0; PF=31%s\r\n\r\n",
 -			tFontName, tFontStyle, tFontColor, (parFlags & MSG_RTL) ? ";RL=1" : "");
 -		*/
  		char *pszNick=proto->MyOptions.szEmail;
  		DBVARIANT dbv;
  		time_t cur_time;
 @@ -489,12 +490,15 @@ int ThreadData::sendMessage(int msgType, const char* email, int netId, const cha  		"Message-Type: %s\r\n"
  		"IM-Display-Name: %s\r\n"
  		"Content-Type: %s\r\n"
 -		"Content-Length: %d\r\n\r\n%s",
 +		"Content-Length: %d\r\n"
 +		"X-MMS-IM-Format: FN=%s; EF=%s; CO=%x; CS=0; PF=31%s\r\n\r\n%s",
  		msgid,
  		(parFlags & MSG_CONTACT)?"RichText/Contacts":"Text",
  		pszNick,
  		(parFlags & MSG_CONTACT)?"application/user+xml\r\nSkype-Age: 18":"Text/plain; charset=UTF-8",
 -		strlen(parMsg), parMsg);
 +		strlen(parMsg), 
 +		tFontName, tFontStyle, tFontColor, (parFlags & MSG_RTL) ? ";RL=1" : "",
 +		parMsg);
  		if (pszNick!=proto->MyOptions.szEmail) db_free(&dbv);
  		parMsg = buf;
 @@ -511,18 +515,19 @@ int ThreadData::sendMessage(int msgType, const char* email, int netId, const cha  		netId == NETID_SKYPE?netId:proto->MyOptions.netId, proto->GetMyUsername(netId), proto->MyOptions.szMachineGuid,
  		parMsg);
 -	/*
 +#ifdef OBSOLETE
  	if (netId == NETID_YAHOO || netId == NETID_MOB || (parFlags & MSG_OFFLINE))
  		seq = sendPacket("UUM", "%s %d %c %d\r\n%s%s", email, netId, msgType,
  		strlen(parMsg) + off, buf, parMsg);
  	else
  		seq = sendPacket("MSG", "%c %d\r\n%s%s", msgType,
  		strlen(parMsg) + off, buf, parMsg);
 -	*/
 +#endif
  	return seq;
  }
 +#ifdef OBSOLETE
  void ThreadData::sendCaps(void)
  {
  	char mversion[100], capMsg[1000];
 @@ -535,6 +540,7 @@ void ThreadData::sendCaps(void)  	sendMessage('U', NULL, 1, capMsg, MSG_DISABLE_HDR);
  }
 +#endif
  void ThreadData::sendTerminate(void)
  {
 @@ -606,8 +612,9 @@ void CMsnProto::MSN_SendStatusMessage(const char* msg)  		return;
  	MSN_SetServerStatus(m_iDesiredStatus);
 -	/* FIXME: Currently not implemented, shuold be set on status change anyway 
 +	/* FIXME: Currently not implemented, should be set on status change anyway  */
 +#ifdef OBSOLETE
  	char* msgEnc = HtmlEncode(msg ? msg : "");
  	size_t sz;
 @@ -675,7 +682,8 @@ void CMsnProto::MSN_SendStatusMessage(const char* msg)  		replaceStr(msnPreviousUUX, szMsg);
  		msnNsThread->sendPacket("UUX", "%d\r\n%s", sz, szMsg);
  		mStatusMsgTS = clock();
 -	} */
 +	}
 +#endif
  }
  /////////////////////////////////////////////////////////////////////////////////////////
 @@ -777,7 +785,7 @@ void CMsnProto::MSN_SetServerStatus(int newStatus)  		unsigned myFlagsExEx = capexex_SupportsMissedConversations | capexex_SupportsShortCircuit;
  		char szMsg[2048];
 -		/*
 +#ifdef OBSOLETE
  		if (m_iStatus < ID_STATUS_ONLINE) {
  			int sz = mir_snprintf(szMsg, SIZEOF(szMsg),
  				"<EndpointData><Capabilities>%u:%u</Capabilities></EndpointData>", myFlags, myFlagsEx);
 @@ -792,7 +800,7 @@ void CMsnProto::MSN_SetServerStatus(int newStatus)  				db_free(&dbv);
  			}
  		}
 -		*/
 +#endif
  		char *szPlace;
  		DBVARIANT dbv;
 @@ -838,7 +846,7 @@ void CMsnProto::MSN_SetServerStatus(int newStatus)  		// TODO: Send, MSN_SendStatusMessage anpassen.
 -		/*
 +#ifdef OBSOLETE
  		int sz = mir_snprintf(szMsg, SIZEOF(szMsg),
  			"<PrivateEndpointData>"
  			"<EpName>%s</EpName>"
 @@ -848,10 +856,10 @@ void CMsnProto::MSN_SetServerStatus(int newStatus)  			"</PrivateEndpointData>",
  			szPlace, newStatus == ID_STATUS_IDLE ? "true" : "false", szStatusName);
  		msnNsThread->sendPacket("UUX", "%d\r\n%s", sz, szMsg);
 -		*/
 +#endif
  		mir_free(szPlace);
 -		/*
 +#ifdef OBSOLETE
  		if (newStatus != ID_STATUS_IDLE) {
  			char** msgptr = GetStatusMsgLoc(newStatus);
  			if (msgptr != NULL)
 @@ -859,10 +867,12 @@ void CMsnProto::MSN_SetServerStatus(int newStatus)  		}
  		msnNsThread->sendPacket("CHG", "%s %u:%u %s", szStatusName, myFlags, myFlagsEx, msnObject.pszVal ? msnObject.pszVal : "0");
 -		*/
 +#endif
  		db_free(&msnObject);
  	}
 -	//else msnNsThread->sendPacket("CHG", szStatusName);
 +#ifdef OBSOLETE
 +	else msnNsThread->sendPacket("CHG", szStatusName);
 +#endif
  }
  /////////////////////////////////////////////////////////////////////////////////////////
 @@ -1091,7 +1101,7 @@ void CMsnProto::MSN_ShowPopup(const MCONTACT hContact, const TCHAR* msg, int fla  /////////////////////////////////////////////////////////////////////////////////////////
  // filetransfer class members
 -
 +#ifdef OBSOLETE
  filetransfer::filetransfer(CMsnProto* prt)
  {
  	memset(this, 0, sizeof(filetransfer));
 @@ -1266,6 +1276,9 @@ void directconnection::xNonceToBin(UUID* nonce)  	p[len - 2] = 0;
  	UuidFromStringA((BYTE*)p, nonce);
  }
 +#else
 +filetransfer::~filetransfer(void) { }
 +#endif
  /////////////////////////////////////////////////////////////////////////////////////////
  // TWinErrorCode class
 diff --git a/protocols/MSN/src/msn_msgqueue.cpp b/protocols/MSN/src/msn_msgqueue.cpp index 3edfa0cbbf..a8f3ebab2c 100644 --- a/protocols/MSN/src/msn_msgqueue.cpp +++ b/protocols/MSN/src/msn_msgqueue.cpp @@ -23,6 +23,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #include "msn_global.h"
  #include "msn_proto.h"
 +#ifdef OBSOLETE
  //a few little functions to manage queuing send message requests until the
  //connection is established
 @@ -179,3 +180,4 @@ void __cdecl CMsnProto::MsgQueue_AllClearThread(void* arg)  	MsgQueue_Clear((char*)arg);
  	mir_free(arg);
  }
 +#endif
 diff --git a/protocols/MSN/src/msn_natdetect.cpp b/protocols/MSN/src/msn_natdetect.cpp index c5e0d782db..00709b25bd 100644 --- a/protocols/MSN/src/msn_natdetect.cpp +++ b/protocols/MSN/src/msn_natdetect.cpp @@ -21,6 +21,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #include "msn_global.h"
  #include "msn_proto.h"
  #include <netfw.h>
 +#ifdef OBSOLETE
  #ifndef CLSID_NetFwMgr
  #define MDEF_CLSID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
 @@ -467,3 +468,4 @@ void MyConnectionType::CalculateWeight(void)  	else if (udpConType == conFirewall) weight = 2;
  	else if (udpConType == conISALike) weight = 3;
  }
 +#endif
 diff --git a/protocols/MSN/src/msn_opts.cpp b/protocols/MSN/src/msn_opts.cpp index 6b992dcb2f..e512463499 100644 --- a/protocols/MSN/src/msn_opts.cpp +++ b/protocols/MSN/src/msn_opts.cpp @@ -413,8 +413,10 @@ static INT_PTR CALLBACK DlgProcMsnConnOpts(HWND hwndDlg, UINT msg, WPARAM wParam  			}
  			else proto->delSetting("YourHost");
 +#ifdef OBSOLETE
  			if (gethst != gethst2)
  				proto->ForkThread(&CMsnProto::MSNConnDetectThread, NULL);
 +#endif
  			if (reconnectRequired && proto->msnLoggedIn)
  				MessageBox(hwndDlg, TranslateT("The changes you have made require you to reconnect to the MSN Messenger network before they take effect"),
 diff --git a/protocols/MSN/src/msn_p2p.cpp b/protocols/MSN/src/msn_p2p.cpp index 505facbd68..8d97c5fa79 100644 --- a/protocols/MSN/src/msn_p2p.cpp +++ b/protocols/MSN/src/msn_p2p.cpp @@ -34,6 +34,7 @@ static const char sttP2PheaderV2[] =  	"P2P-Src: %s;%s\r\n\r\n";
  const char sttVoidUid[] = "{00000000-0000-0000-0000-000000000000}";
 +#ifdef OBSOLETE
  static const char szUbnCall[] = "{F13B5C79-0126-458F-A29D-747C79C56530}";
  static const char p2pV2Caps[] = { 0x01, 0x0C, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x0F, 0x01, 0x00, 0x00 };
 @@ -2329,3 +2330,4 @@ char* P2P_Header::createMsg(char *buf, const char* wlid, CMsnProto *ppro)  	memcpy(buf, &mSessionID, 48);
  	return buf + 48;
  }
 +#endif
\ No newline at end of file diff --git a/protocols/MSN/src/msn_p2ps.cpp b/protocols/MSN/src/msn_p2ps.cpp index f7840374c8..4b0ded416d 100644 --- a/protocols/MSN/src/msn_p2ps.cpp +++ b/protocols/MSN/src/msn_p2ps.cpp @@ -22,6 +22,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #include "msn_global.h"
  #include "msn_proto.h"
 +#ifdef OBSOLETE
  /////////////////////////////////////////////////////////////////////////////////////////
  // add file session to a list
 @@ -271,3 +272,4 @@ void CMsnProto::P2pSessions_Uninit(void)  	m_arSessions.destroy();
  	m_arDirect.destroy();
  }
 +#endif
 diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp index 4a0279b398..8f63189efd 100644 --- a/protocols/MSN/src/msn_proto.cpp +++ b/protocols/MSN/src/msn_proto.cpp @@ -39,8 +39,10 @@ CMsnProto::CMsnProto(const char* aProtoName, const TCHAR* aUserName) :  	m_arGroups(10, CompareId),
  	m_arThreads(10, PtrKeySortT),
  	m_arGCThreads(10, PtrKeySortT),
 +#ifdef OBSOLETE
  	m_arSessions(10, PtrKeySortT),
  	m_arDirect(10, PtrKeySortT),
 +#endif
  	lsMessageQueue(1),
  	lsAvatarQueue(1),
  	msgCache(5, CompareId)
 @@ -52,7 +54,6 @@ CMsnProto::CMsnProto(const char* aProtoName, const TCHAR* aUserName) :  	db_set_resident(m_szModuleName, "MobileAllowed");
  	// Protocol services and events...
 -	hMSNNudge = CreateProtoEvent("/Nudge");
  	CreateProtoService(PS_CREATEACCMGRUI, &CMsnProto::SvcCreateAccMgrUI);
 @@ -65,12 +66,17 @@ CMsnProto::CMsnProto(const char* aProtoName, const TCHAR* aUserName) :  	CreateProtoService(PS_SETMYAVATART, &CMsnProto::SetAvatar);
  	CreateProtoService(PS_GETAVATARCAPS, &CMsnProto::GetAvatarCaps);
 +	CreateProtoService(PS_SETMYNICKNAME, &CMsnProto::SetNickName);
 +#ifdef OBSOLETE
  	CreateProtoService(PS_GET_LISTENINGTO, &CMsnProto::GetCurrentMedia);
  	CreateProtoService(PS_SET_LISTENINGTO, &CMsnProto::SetCurrentMedia);
 -	CreateProtoService(PS_SETMYNICKNAME, &CMsnProto::SetNickName);
 +	hMSNNudge = CreateProtoEvent("/Nudge");
  	CreateProtoService(PS_SEND_NUDGE, &CMsnProto::SendNudge);
 +	MsgQueue_Init();
 +#endif
 +
  	CreateProtoService(PS_GETUNREADEMAILCOUNT, &CMsnProto::GetUnreadEmailCount);
  	// event hooks
 @@ -111,7 +117,6 @@ CMsnProto::CMsnProto(const char* aProtoName, const TCHAR* aUserName) :  	mir_snprintf(alertsoundname, 64, "%s:Alerts", m_szModuleName);
  	SkinAddNewSoundExT(alertsoundname, m_tszUserName, LPGENT("Live Alert"));
 -	MsgQueue_Init();
  	AvatarQueue_Init();
  	InitCustomFolders();
 @@ -149,14 +154,15 @@ CMsnProto::~CMsnProto()  {
  	MsnRemoveMainMenus();
 -	DestroyHookableEvent(hMSNNudge);
 -
  	MSN_FreeGroups();
  	Threads_Uninit();
 -	MsgQueue_Uninit();
  	AvatarQueue_Uninit();
  	Lists_Uninit();
 +#ifdef OBSOLETE
 +	DestroyHookableEvent(hMSNNudge);
  	P2pSessions_Uninit();
 +	MsgQueue_Uninit();
 +#endif
  	CachedMsg_Uninit();
  	Netlib_CloseHandle(m_hNetlibUser);
 @@ -424,10 +430,12 @@ void __cdecl CMsnProto::MsnSearchAckThread(void* arg)  	case 1:
  		if (strstr(email, "@yahoo.com") == NULL)
  			ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, arg, 0);
 +#ifdef OBSOLETE
  		else {
  			msnSearchId = arg;
  			MSN_FindYahooUser(email);
  		}
 +#endif
  		break;
  	default:
 @@ -454,6 +462,7 @@ HANDLE __cdecl CMsnProto::SearchByEmail(const PROTOCHAR* email)  	return SearchBasic(email);
  }
 +#ifdef OBSOLETE
  /////////////////////////////////////////////////////////////////////////////////////////
  // MsnFileAllow - starts the file transfer
 @@ -596,6 +605,7 @@ int __cdecl CMsnProto::FileResume(HANDLE hTransfer, int* action, const PROTOCHAR  	return 0;
  }
 +#endif
  /////////////////////////////////////////////////////////////////////////////////////////
  // MsnGetAwayMsg - reads the current status message for a user
 @@ -715,6 +725,7 @@ int CMsnProto::RecvContacts(MCONTACT hContact, PROTORECVEVENT* pre)  }
 +#ifdef OBSOLETE
  /////////////////////////////////////////////////////////////////////////////////////////
  // MsnSendFile - initiates a file transfer
 @@ -761,6 +772,7 @@ HANDLE __cdecl CMsnProto::SendFile(MCONTACT hContact, const PROTOCHAR*, PROTOCHA  	ProtoBroadcastAck(hContact, ACKTYPE_FILE, ACKRESULT_SENTREQUEST, sft, 0);
  	return sft;
  }
 +#endif
  /////////////////////////////////////////////////////////////////////////////////////////
  // MsnSendMessage - sends the message to a server
 @@ -865,9 +877,13 @@ int __cdecl CMsnProto::SendMsg(MCONTACT hContact, int flags, const char* pszSrc)  		else {
  			const char msgType = MyOptions.SlowSend ? 'A' : 'N';
  			bool isOffline;
 -			ThreadData* thread; // = MSN_StartSB(tEmail, isOffline);
 +			ThreadData* thread;
 +#ifdef OBSOLETE
 +			thread = MSN_StartSB(tEmail, isOffline);
 +#else
  			/* MSNP24 doesn't have a switchboard anymore */
  			thread = NULL; isOffline = true;
 +#endif
  			if (thread == NULL) {
  				if (isOffline) {
 @@ -881,6 +897,7 @@ int __cdecl CMsnProto::SendMsg(MCONTACT hContact, int flags, const char* pszSrc)  						ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, errMsg, this));
  					}
  				}
 +#ifdef OBSOLETE
  				else
  					seq = MsgQueue_Add(tEmail, msgType, msg, 0, 0, rtlFlag);
  			}
 @@ -888,6 +905,7 @@ int __cdecl CMsnProto::SendMsg(MCONTACT hContact, int flags, const char* pszSrc)  				seq = thread->sendMessage(msgType, tEmail, netId, msg, rtlFlag);
  				if (!MyOptions.SlowSend)
  					ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, NULL, this));
 +#endif
  			}
  		}
  		break;
 @@ -983,8 +1001,10 @@ int __cdecl CMsnProto::SetStatus(int iNewStatus)  			return 0;
  		}
 +#ifdef OBSOLETE
  		m_arSessions.destroy();
  		m_arDirect.destroy();
 +#endif
  		usingGateway = false;
 @@ -1018,7 +1038,7 @@ int __cdecl CMsnProto::UserIsTyping(MCONTACT hContact, int type)  	bool typing = type == PROTOTYPE_SELFTYPING_ON;
  	int netId = Lists_GetNetId(tEmail);
 -	/*
 +#ifdef OBSOLETE
  	switch (netId) {
  	case NETID_UNKNOWN:
  	case NETID_MSN:
 @@ -1042,7 +1062,7 @@ int __cdecl CMsnProto::UserIsTyping(MCONTACT hContact, int type)  	default:
  		break;
  	}
 -	*/
 +#endif
  	if (getWord(hContact, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
  		MSN_SendTyping(msnNsThread, tEmail, netId, typing);
 diff --git a/protocols/MSN/src/msn_proto.h b/protocols/MSN/src/msn_proto.h index dc139a6451..75ef888607 100644 --- a/protocols/MSN/src/msn_proto.h +++ b/protocols/MSN/src/msn_proto.h @@ -40,10 +40,12 @@ struct CMsnProto : public PROTO<CMsnProto>  	virtual	int       __cdecl AuthRecv(MCONTACT hContact, PROTORECVEVENT*);
  	virtual	int       __cdecl AuthRequest(MCONTACT hContact, const TCHAR* szMessage);
 +#ifdef OBSOLETE
  	virtual	HANDLE    __cdecl FileAllow(MCONTACT hContact, HANDLE hTransfer, const PROTOCHAR* szPath);
  	virtual	int       __cdecl FileCancel(MCONTACT hContact, HANDLE hTransfer);
  	virtual	int       __cdecl FileDeny(MCONTACT hContact, HANDLE hTransfer, const PROTOCHAR* szReason);
  	virtual	int       __cdecl FileResume(HANDLE hTransfer, int* action, const PROTOCHAR** szFilename);
 +#endif
  	virtual	DWORD_PTR __cdecl GetCaps(int type, MCONTACT hContact = NULL);
 @@ -53,7 +55,9 @@ struct CMsnProto : public PROTO<CMsnProto>  	virtual	int       __cdecl RecvMsg(MCONTACT hContact, PROTORECVEVENT*);
  	virtual	int       __cdecl RecvContacts(MCONTACT hContact, PROTORECVEVENT*);
 +#ifdef OBSOLETE
  	virtual	HANDLE    __cdecl SendFile(MCONTACT hContact, const PROTOCHAR* szDescription, PROTOCHAR** ppszFiles);
 +#endif
  	virtual	int       __cdecl SendMsg(MCONTACT hContact, int flags, const char* msg);
  	virtual	int       __cdecl SendContacts(MCONTACT hContact, int flags, int nContacts, MCONTACT *hContactsList);
 @@ -100,7 +104,9 @@ struct CMsnProto : public PROTO<CMsnProto>  	int  __cdecl OnContactDoubleClicked(WPARAM wParam,LPARAM lParam);
  	int  __cdecl OnDbSettingChanged(WPARAM wParam,LPARAM lParam);
  	int  __cdecl OnUserInfoInit(WPARAM wParam,LPARAM lParam);
 +#ifdef OBSOLETE
  	int  __cdecl OnWindowEvent(WPARAM wParam, LPARAM lParam);
 +#endif
  	int  __cdecl OnWindowPopup(WPARAM wParam, LPARAM lParam);
  	//====| Data |========================================================================
 @@ -129,8 +135,10 @@ struct CMsnProto : public PROTO<CMsnProto>  	LIST<GCThreadData> m_arGCThreads;
  	mir_cs m_csSessions;
 +#ifdef OBSOLETE
  	OBJLIST<filetransfer> m_arSessions;
  	OBJLIST<directconnection> m_arDirect;
 +#endif
  	mir_cs csMsgQueue;
  	int msgQueueSeq;
 @@ -330,6 +338,7 @@ struct CMsnProto : public PROTO<CMsnProto>  	/////////////////////////////////////////////////////////////////////////////////////////
  	// MSN P2P session support
 +#ifdef OBSOLETE
  	void  p2p_clearDormantSessions(void);
  	void  p2p_cancelAllSessions(void);
  	void  p2p_redirectSessions(const char* wlid);
 @@ -401,6 +410,7 @@ struct CMsnProto : public PROTO<CMsnProto>  	int  MSN_HandleMSNFTP(ThreadData *info, char *cmdString);
  	void __cdecl msnftp_sendFileThread(void* arg);
 +#endif
  	/////////////////////////////////////////////////////////////////////////////////////////
  	//	MSN Chat support
 diff --git a/protocols/MSN/src/msn_svcs.cpp b/protocols/MSN/src/msn_svcs.cpp index 864a3770d1..46cd62754a 100644 --- a/protocols/MSN/src/msn_svcs.cpp +++ b/protocols/MSN/src/msn_svcs.cpp @@ -133,6 +133,7 @@ INT_PTR CMsnProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam)  			pushAvatarRequest(AI->hContact, dbv.pszVal);
  			db_free(&dbv);
  		}
 +#ifdef OBSOLETE
  		else if (p2p_getAvatarSession(AI->hContact) == NULL) {
  			filetransfer* ft = new filetransfer(this);
  			ft->std.hContact = AI->hContact;
 @@ -143,6 +144,7 @@ INT_PTR CMsnProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam)  			p2p_invite(MSN_APPID_AVATAR, ft, NULL);
  		}
 +#endif
  		return GAIR_WAITFOR;
  	}
 @@ -238,6 +240,7 @@ INT_PTR CMsnProto::SetNickName(WPARAM wParam, LPARAM lParam)  	return 0;
  }
 +#ifdef OBSOLETE
  /////////////////////////////////////////////////////////////////////////////////////////
  // MsnSendNudge - Sending a nudge
 @@ -366,6 +369,7 @@ INT_PTR CMsnProto::SetCurrentMedia(WPARAM, LPARAM lParam)  	return 0;
  }
 +#endif
  /////////////////////////////////////////////////////////////////////////////////////////
  // MsnContactDeleted - called when a contact is deleted from list
 @@ -515,6 +519,7 @@ int CMsnProto::OnIdleChanged(WPARAM, LPARAM lParam)  	return 0;
  }
 +#ifdef OBSOLETE
  /////////////////////////////////////////////////////////////////////////////////////////
  // OnWindowEvent - creates session on window open
 @@ -544,6 +549,7 @@ int CMsnProto::OnWindowEvent(WPARAM, LPARAM lParam)  	}
  	return 0;
  }
 +#endif
  /////////////////////////////////////////////////////////////////////////////////////////
  // OnWindowEvent - creates session on window open
 diff --git a/protocols/MSN/src/msn_switchboard.cpp b/protocols/MSN/src/msn_switchboard.cpp index d8967f66c0..8bb2ab2c1a 100644 --- a/protocols/MSN/src/msn_switchboard.cpp +++ b/protocols/MSN/src/msn_switchboard.cpp @@ -22,6 +22,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #include "msn_global.h"
  #include "msn_proto.h"
 +#ifdef OBSOLETE
  int ThreadData::contactJoined(const char* email)
  {
 @@ -46,8 +47,10 @@ int ThreadData::contactLeft(const char* email)  	return mJoinedContactsWLID.getCount();
  }
 +#endif
  MCONTACT ThreadData::getContactHandle(void)
  {
  	return mJoinedContactsWLID.getCount() ? proto->MSN_HContactFromEmail(mJoinedContactsWLID[0]) : NULL;
  }
 +
 diff --git a/protocols/MSN/src/msn_threads.cpp b/protocols/MSN/src/msn_threads.cpp index ed78b91f50..3fffb806a4 100644 --- a/protocols/MSN/src/msn_threads.cpp +++ b/protocols/MSN/src/msn_threads.cpp @@ -44,7 +44,9 @@ void __cdecl CMsnProto::msn_keepAliveThread(void*)  				msnPingTimeout = 20;
  				keepFlag = keepFlag && msnNsThread->sendPacket("PNG", "CON 0");
  			}
 +#ifdef OBSOLETE
  			p2p_clearDormantSessions();
 +#endif
  			if (hHttpsConnection && (clock() - mHttpsTS) > 60 * CLOCKS_PER_SEC) {
  				HANDLE hConn = hHttpsConnection;
  				hHttpsConnection = NULL;
 @@ -198,11 +200,14 @@ void __cdecl CMsnProto::MSNServerThread(void* arg)  		info->mBytesInData += recvResult;
 +#ifdef OBSOLETE
  		if (info->mCaller == 1 && info->mType == SERVER_FILETRANS) {
  			if (MSN_HandleMSNFTP(info, info->mData))
  				break;
  		}
 -		else {
 +		else 
 +#endif
 +		{
  			for (;;) {
  				char* peol = strchr(info->mData, '\r');
  				if (peol == NULL)
 @@ -241,9 +246,11 @@ void __cdecl CMsnProto::MSNServerThread(void* arg)  						info->sendTerminate();
  					}
  				}
 +#ifdef OBSOLETE
  				else
  					if (MSN_HandleMSNFTP(info, msg))
  						goto LBL_Exit;
 +#endif
  			}
  		}
 @@ -276,7 +283,9 @@ LBL_Exit:  			if (info->s == NULL)
  				ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_NONETWORK);
  			else {
 +#ifdef OBSOLETE
  				p2p_cancelAllSessions();
 +#endif
  				MSN_CloseConnections();
  			}
 @@ -377,6 +386,7 @@ GCThreadData* CMsnProto::MSN_GetThreadByChatId(const TCHAR* chatId)  	return NULL;
  }
 +#ifdef OBSOLETE
  ThreadData* CMsnProto::MSN_GetP2PThreadByContact(const char *wlid)
  {
  	mir_cslock lck(m_csThreads);
 @@ -425,7 +435,6 @@ void CMsnProto::MSN_StartP2PTransferByContact(const char* wlid)  	}
  }
 -
  ThreadData* CMsnProto::MSN_GetOtherContactThread(ThreadData* thread)
  {
  	mir_cslock lck(m_csThreads);
 @@ -478,7 +487,6 @@ ThreadData* CMsnProto::MSN_StartSB(const char* wlid, bool& isOffline)  }
 -
  int CMsnProto::MSN_GetActiveThreads(ThreadData** parResult)
  {
  	int tCount = 0;
 @@ -492,6 +500,7 @@ int CMsnProto::MSN_GetActiveThreads(ThreadData** parResult)  	return tCount;
  }
 +#endif
  ThreadData* CMsnProto::MSN_GetThreadByConnection(HANDLE s)
  {
 @@ -506,6 +515,7 @@ ThreadData* CMsnProto::MSN_GetThreadByConnection(HANDLE s)  	return NULL;
  }
 +#ifdef OBSOLETE
  ThreadData* CMsnProto::MSN_GetThreadByPort(WORD wPort)
  {
  	mir_cslock lck(m_csThreads);
 @@ -518,6 +528,7 @@ ThreadData* CMsnProto::MSN_GetThreadByPort(WORD wPort)  	return NULL;
  }
 +#endif
  /////////////////////////////////////////////////////////////////////////////////////////
  // class ThreadData members
 @@ -533,8 +544,6 @@ ThreadData::ThreadData()  ThreadData::~ThreadData()
  {
 -	int i;
 -
  	if (s != NULL) {
  		proto->debugLogA("Closing connection handle %08X", s);
  		Netlib_CloseHandle(s);
 @@ -555,8 +564,9 @@ ThreadData::~ThreadData()  	if (mTimerId != 0)
  		KillTimer(NULL, mTimerId);
 +#ifdef OBSOLETE
  	if (mType == SERVER_SWITCHBOARD) {
 -		for (i = 0; i < mJoinedContactsWLID.getCount(); ++i) {
 +		for (int i = 0; i < mJoinedContactsWLID.getCount(); ++i) {
  			const char* wlid = mJoinedContactsWLID[i];
  			MCONTACT hContact = proto->MSN_HContactFromEmail(wlid);
  			int temp_status = proto->getWord(hContact, "Status", ID_STATUS_OFFLINE);
 @@ -564,13 +574,16 @@ ThreadData::~ThreadData()  				proto->setWord(hContact, "Status", ID_STATUS_OFFLINE);
  		}
  	}
 +#endif
  	mJoinedContactsWLID.destroy();
  	mJoinedIdentContactsWLID.destroy();
 -	const char* wlid = NEWSTR_ALLOCA(mInitialContactWLID);
  	mir_free(mInitialContactWLID); mInitialContactWLID = NULL;
 +#ifdef OBSOLETE
 +	const char* wlid = NEWSTR_ALLOCA(mInitialContactWLID);
 +
  	if (proto && mType == SERVER_P2P_DIRECT)
  		proto->p2p_clearDormantSessions();
 @@ -579,6 +592,7 @@ ThreadData::~ThreadData()  		proto->MSN_GetUnconnectedThread(wlid) == NULL) {
  		proto->MsgQueue_Clear(wlid, true);
  	}
 +#endif
  	mir_free(mData);
  }
 diff --git a/protocols/MSN/src/msn_ws.cpp b/protocols/MSN/src/msn_ws.cpp index 3bea4b60eb..79c35ed56d 100644 --- a/protocols/MSN/src/msn_ws.cpp +++ b/protocols/MSN/src/msn_ws.cpp @@ -66,6 +66,7 @@ bool ThreadData::isTimeout(void)  		if (mJoinedContactsWLID.getCount() == 0 || termPending)
  			res = true;
 +#ifdef OBSOLETE
  		else if (proto->p2p_getThreadSession(hContact, mType) != NULL)
  			res = false;
  		else if (mType == SERVER_SWITCHBOARD) {
 @@ -76,6 +77,7 @@ bool ThreadData::isTimeout(void)  					res = false;
  			}
  		}
 +#endif
  		else
  			res = true;
  	}
 @@ -86,6 +88,7 @@ bool ThreadData::isTimeout(void)  		proto->debugLogA("Dropping the idle %s due to inactivity", sbsess ? "switchboard" : "p2p");
  		if (!sbsess || termPending) return true;
 +#ifdef OBSOLETE
  		if (proto->getByte("EnableSessionPopup", 0)) {
  			MCONTACT hContact = NULL;
  			if (mJoinedContactsWLID.getCount())
 @@ -99,6 +102,7 @@ bool ThreadData::isTimeout(void)  		sendTerminate();
  		resetTimeout(true);
 +#endif
  	}
  	else
  		resetTimeout();
 | 
