Ejemplo n.º 1
0
int __cdecl CMsnProto::SetAwayMsg(int status, const TCHAR* msg)
{
	char** msgptr = GetStatusMsgLoc(status);

	if (msgptr == NULL)
		return 1;

	mir_free(*msgptr);
	char* buf = *msgptr = mir_utf8encodeT(msg);
	if (buf && strlen(buf) > 1859)
	{
		buf[1859] = 0;
		const int i = 1858;
		if (buf[i] & 128)
		{
			if (buf[i] & 64)
				buf[i] = '\0';
			else if ((buf[i-1] & 224) == 224)
				buf[i-1] = '\0';
			else if ((buf[i - 2] & 240) == 240)
				buf[i-2] = '\0';
		}
	}

	if (status == m_iDesiredStatus)
		MSN_SendStatusMessage(*msgptr);

	return 0;
}
Ejemplo n.º 2
0
INT_PTR CMsnProto::GetMyAwayMsg(WPARAM wParam, LPARAM lParam)
{
	char** msgptr = GetStatusMsgLoc(wParam ? wParam : m_iStatus);
	if (msgptr == NULL)	return 0;

	return (lParam & SGMA_UNICODE) ? (INT_PTR)mir_utf8decodeW(*msgptr) : (INT_PTR)mir_utf8decodeA(*msgptr);
}
Ejemplo n.º 3
0
INT_PTR CMsnProto::SetCurrentMedia(WPARAM, LPARAM lParam)
{
	// Clear old info
	mir_free(msnCurrentMedia.ptszArtist);
	mir_free(msnCurrentMedia.ptszAlbum);
	mir_free(msnCurrentMedia.ptszTitle);
	mir_free(msnCurrentMedia.ptszTrack);
	mir_free(msnCurrentMedia.ptszYear);
	mir_free(msnCurrentMedia.ptszGenre);
	mir_free(msnCurrentMedia.ptszLength);
	mir_free(msnCurrentMedia.ptszPlayer);
	mir_free(msnCurrentMedia.ptszType);
	memset(&msnCurrentMedia, 0, sizeof(msnCurrentMedia));

	// Copy new info
	LISTENINGTOINFO *cm = (LISTENINGTOINFO *)lParam;
	if (cm != NULL && cm->cbSize == sizeof(LISTENINGTOINFO) && (cm->ptszArtist != NULL || cm->ptszTitle != NULL)) {
		bool unicode = (cm->dwFlags & LTI_UNICODE) != 0;

		msnCurrentMedia.cbSize = sizeof(msnCurrentMedia);	// Marks that there is info set
		msnCurrentMedia.dwFlags = LTI_TCHAR;

		overrideStr(msnCurrentMedia.ptszType, cm->ptszType, unicode, _T("Music"));
		overrideStr(msnCurrentMedia.ptszArtist, cm->ptszArtist, unicode);
		overrideStr(msnCurrentMedia.ptszAlbum, cm->ptszAlbum, unicode);
		overrideStr(msnCurrentMedia.ptszTitle, cm->ptszTitle, unicode, _T("No Title"));
		overrideStr(msnCurrentMedia.ptszTrack, cm->ptszTrack, unicode);
		overrideStr(msnCurrentMedia.ptszYear, cm->ptszYear, unicode);
		overrideStr(msnCurrentMedia.ptszGenre, cm->ptszGenre, unicode);
		overrideStr(msnCurrentMedia.ptszLength, cm->ptszLength, unicode);
		overrideStr(msnCurrentMedia.ptszPlayer, cm->ptszPlayer, unicode);
	}

	// Set user text
	if (msnCurrentMedia.cbSize == 0)
		delSetting("ListeningTo");
	else {
		TCHAR *text;
		if (ServiceExists(MS_LISTENINGTO_GETPARSEDTEXT))
			text = (TCHAR *)CallService(MS_LISTENINGTO_GETPARSEDTEXT, (WPARAM)_T("%title% - %artist%"), (LPARAM)&msnCurrentMedia);
		else {
			text = (TCHAR *)mir_alloc(128 * sizeof(TCHAR));
			mir_sntprintf(text, 128, _T("%s - %s"), (msnCurrentMedia.ptszTitle ? msnCurrentMedia.ptszTitle : _T("")),
				(msnCurrentMedia.ptszArtist ? msnCurrentMedia.ptszArtist : _T("")));
		}
		setTString("ListeningTo", text);
		mir_free(text);
	}

	// Send it
	char** msgptr = GetStatusMsgLoc(m_iDesiredStatus);
	MSN_SendStatusMessage(msgptr ? *msgptr : NULL);

	return 0;
}
Ejemplo n.º 4
0
void CMsnProto::MSN_SetServerStatus(int newStatus)
{
	debugLogA("Setting MSN server status %d, logged in = %d", newStatus, msnLoggedIn);

	if (!msnLoggedIn)
		return;

	if (isIdle)
		newStatus = ID_STATUS_IDLE;

	const char* szStatusName = MirandaStatusToMSN(newStatus);

	if (newStatus != ID_STATUS_OFFLINE) {
		DBVARIANT msnObject = {0};
		if (ServiceExists(MS_AV_SETMYAVATAR))
			getString("PictObject", &msnObject);

		// Capabilties: WLM 2009, Chunking, UUN Bootstrap
		myFlags = 0xA0000000 | cap_SupportsChunking | cap_SupportsP2PBootstrap | cap_SupportsSipInvite;
		if (getByte("MobileEnabled", 0) && getByte("MobileAllowed", 0))
			myFlags |= cap_MobileEnabled;

		unsigned myFlagsEx = capex_SupportsPeerToPeerV2;

		char szMsg[256];
		if (m_iStatus < ID_STATUS_ONLINE) {
			int sz = mir_snprintf(szMsg, sizeof(szMsg),
				"<EndpointData><Capabilities>%u:%u</Capabilities></EndpointData>", myFlags, myFlagsEx);
			msnNsThread->sendPacket( "UUX", "%d\r\n%s", sz, szMsg );

			msnNsThread->sendPacket("BLP", msnOtherContactsBlocked ? "BL" : "AL");

			DBVARIANT dbv;
			if (!getStringUtf("Nick", &dbv)) {
				if (dbv.pszVal[0])
					MSN_SetNicknameUtf(dbv.pszVal);
				db_free(&dbv);
			}
		}

		char *szPlace;
		DBVARIANT dbv;
		if	(!getStringUtf("Place", &dbv))
			szPlace = dbv.pszVal;
		else {
			TCHAR buf[128] = _T("Miranda");
			DWORD buflen = SIZEOF(buf);
			GetComputerName(buf, &buflen);
			szPlace =  mir_utf8encodeT(buf);
		}

		int sz = mir_snprintf(szMsg, sizeof(szMsg),
			"<PrivateEndpointData>"
			"<EpName>%s</EpName>"
			"<Idle>%s</Idle>"
			"<ClientType>1</ClientType>"
			"<State>%s</State>"
			"</PrivateEndpointData>",
			szPlace, newStatus == ID_STATUS_IDLE ? "true" : "false", szStatusName);
		msnNsThread->sendPacket("UUX", "%d\r\n%s", sz, szMsg);
		mir_free(szPlace);

		if (newStatus != ID_STATUS_IDLE) {
			char** msgptr = GetStatusMsgLoc(newStatus);
			if (msgptr != NULL)
				MSN_SendStatusMessage(*msgptr);
		}

		msnNsThread->sendPacket("CHG", "%s %u:%u %s", szStatusName, myFlags, myFlagsEx, msnObject.pszVal ? msnObject.pszVal : "0");
		db_free(&msnObject);
	}
	else msnNsThread->sendPacket("CHG", szStatusName);
}