Ejemplo n.º 1
0
int CJabberProto::AddFeatures(LPCTSTR szFeatures)
{
	if (!szFeatures)
		return false;

	mir_cslockfull lck(m_csLists);
	BOOL ret = true;
	LPCTSTR szFeat = szFeatures;
	while (szFeat[0]) {
		JabberFeatCapPairDynamic *fcp = FindFeature(szFeat);
		// if someone is trying to add one of core features, RegisterFeature() will return false, so we don't have to perform this check here
		if (!fcp) { // if the feature is not registered yet
			if (!RegisterFeature(szFeat, NULL))
				ret = false;
			else
				fcp = FindFeature(szFeat); // update fcp after RegisterFeature()
		}
		if (fcp)
			m_uEnabledFeatCapsDynamic |= fcp->jcbCap;
		else
			ret = false;
		szFeat += lstrlen(szFeat) + 1;
	}
	lck.unlock();

	if (m_bJabberOnline)
		SendPresence(m_iStatus, true);

	return ret;
}
Ejemplo n.º 2
0
void CJabberProto::SetServerStatus(int iNewStatus)
{
	if (!m_bJabberOnline)
		return;

	// change status
	int oldStatus = m_iStatus;
	switch (iNewStatus) {
	case ID_STATUS_ONLINE:
	case ID_STATUS_NA:
	case ID_STATUS_FREECHAT:
	case ID_STATUS_INVISIBLE:
		m_iStatus = iNewStatus;
		break;
	case ID_STATUS_AWAY:
	case ID_STATUS_ONTHEPHONE:
	case ID_STATUS_OUTTOLUNCH:
		m_iStatus = ID_STATUS_AWAY;
		break;
	case ID_STATUS_DND:
	case ID_STATUS_OCCUPIED:
		m_iStatus = ID_STATUS_DND;
		break;
	default:
		return;
	}

	if (m_iStatus == oldStatus)
		return;

	// send presence update
	SendPresence(m_iStatus, true);
	ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
}
Ejemplo n.º 3
0
void CSkypeProto::ProcessTimer()
{
    if (IsOnline())
    {
        PushRequest(new GetContactListRequest(li, NULL), &CSkypeProto::LoadContactList);
        SendPresence(false);
        //if (!m_hTrouterThread)
        //	SendRequest(new CreateTrouterRequest(), &CSkypeProto::OnCreateTrouter);
    }
}
Ejemplo n.º 4
0
void CSkypeProto::ProcessTimer()
{
	if (IsOnline())
	{
		PushRequest(new GetContactListRequest(m_szTokenSecret), &CSkypeProto::LoadContactList);
		SendPresence(false);
		if (!m_hTrouterThread)
			SendRequest(new CreateTrouterRequest(), &CSkypeProto::OnCreateTrouter);
	}
}
Ejemplo n.º 5
0
INT_PTR CJabberProto::OnMenuSetPriority(WPARAM, LPARAM, LPARAM dwDelta)
{
    int iDelta = (int)dwDelta;
    int priority = getWord("Priority", 0) + iDelta;
    if (priority > 127)
        priority = 127;
    else if (priority < -128)
        priority = -128;
    setWord("Priority", priority);
    SendPresence(m_iStatus, true);
    return 0;
}
Ejemplo n.º 6
0
void CSkypeProto::OnSubscriptionsCreated(const NETLIBHTTPREQUEST *response)
{
	if (!IsStatusConnecting(m_iStatus)) return;

	if (response == NULL)
	{
		debugLogA(__FUNCTION__ ": failed to create subscription");
		ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
		SetStatus(ID_STATUS_OFFLINE);
		return;
	}

	SendPresence(true);
}
Ejemplo n.º 7
0
int CJabberProto::RemoveFeatures(LPCTSTR szFeatures)
{
	if (!szFeatures)
		return false;

	mir_cslockfull lck(m_csLists);
	BOOL ret = true;
	LPCTSTR szFeat = szFeatures;
	while (szFeat[0]) {
		JabberFeatCapPairDynamic *fcp = FindFeature(szFeat);
		if (fcp)
			m_uEnabledFeatCapsDynamic &= ~fcp->jcbCap;
		else
			ret = false; // indicate that there was an error removing at least one of the specified features

		szFeat += lstrlen(szFeat) + 1;
	}
	lck.unlock();

	if (m_bJabberOnline)
		SendPresence(m_iStatus, true);

	return ret;
}
Ejemplo n.º 8
0
INT_PTR __cdecl CJabberProto::JabberSetAvatar(WPARAM, LPARAM lParam)
{
	TCHAR *tszFileName = (TCHAR*)lParam;

	if (m_bJabberOnline) {
		SetServerVcard(TRUE, tszFileName);
		SendPresence(m_iDesiredStatus, false);
	}
	else if (tszFileName == NULL || tszFileName[0] == 0) {
		// Remove avatar
		TCHAR tFileName[ MAX_PATH ];
		GetAvatarFileName(NULL, tFileName, MAX_PATH);
		DeleteFile(tFileName);

		delSetting("AvatarSaved");
		delSetting("AvatarHash");
	}
	else {
		int fileIn = _topen(tszFileName, O_RDWR | O_BINARY, S_IREAD | S_IWRITE);
		if (fileIn == -1) {
			mir_free(tszFileName);
			return 1;
		}

		long dwPngSize = _filelength(fileIn);
		char *pResult = new char[ dwPngSize ];
		if (pResult == NULL) {
			_close(fileIn);
			mir_free(tszFileName);
			return 2;
		}

		_read(fileIn, pResult, dwPngSize);
		_close(fileIn);

		BYTE digest[MIR_SHA1_HASH_SIZE];
		mir_sha1_ctx sha1ctx;
		mir_sha1_init(&sha1ctx);
		mir_sha1_append(&sha1ctx, (BYTE*)pResult, dwPngSize);
		mir_sha1_finish(&sha1ctx, digest);

		TCHAR tFileName[MAX_PATH];
		GetAvatarFileName(NULL, tFileName, MAX_PATH);
		DeleteFile(tFileName);

		char buf[MIR_SHA1_HASH_SIZE*2+1];
		bin2hex(digest, sizeof(digest), buf);

		m_options.AvatarType = ProtoGetBufferFormat(pResult);

		GetAvatarFileName(NULL, tFileName, MAX_PATH);
		FILE *out = _tfopen(tFileName, _T("wb"));
		if (out != NULL) {
			fwrite(pResult, dwPngSize, 1, out);
			fclose(out);
		}
		delete[] pResult;

		setString("AvatarSaved", buf);
	}

	return 0;
}
Ejemplo n.º 9
0
int			main(int argc, char* argv[])
{
	WORD	wVersionRequested;
	WSADATA wsaData;
	int		err, account;
	char	*User, *Pass;

	account = 0;

	if (account == 0)
	{
		User = "******"; 
		Pass = "******";
	}
	else if (account == 1)
	{
		User = "******"; 
		Pass = "******";
	}
	else if (account == 2)
	{
		User = "******"; 
		Pass = "******";
	}
	else if (account == 3)
	{
		User = "******";
		Pass = "******";
	}
	else if (account == 4)
	{
		User = "******"; 
		Pass = "******";
	}
	else if (account == 5)
	{
		User = "******"; 
		Pass = "******";
	}
	else if (account == 6)
	{
		User = "******"; 
		Pass = "******";
	}
	else if (account == 7)
	{
		User = "******"; 
		Pass = "******";
	}
	else if (account == 8)
	{
		User = "******"; 
		Pass = "******";
	}
	else if (account == 9)
	{
		User = "******"; 
		Pass = "******";
	}
	else if (account == 10)
	{
		User = "******"; 
		Pass = "******";
	}

	wVersionRequested = MAKEWORD(2, 2);
	err = WSAStartup(wVersionRequested, &wsaData);
	if (err != 0)
	{
		printf("Unable to start WSA Lib\n");
		return (0xBADF00D);
	}

	//FIXED NODEID

	InitLocalNode();

	InitKeyServer();

	HostScan(&Session_SN);

	PerformLogin(User, Pass);	

	SendPresence(Session_SN, User);

	EventContacts(User, Pass);	
	
	SearchContactList(Session_SN, User);

	InitialPingOnLine(Session_SN, User);

	Listen2SN(Session_SN);

	EndKeyServer();	

	WSACleanup();

	return 0;
}