Пример #1
0
void AuthYahooCommand::WriteCommand()
{
	MojLogTrace(m_log);
	if (m_state == State_SendingYCookie) {
		MojLogInfo(m_log, "Sending AUTH XYMCOOKIE command with YCookie");
	
		std::string command = COMMAND_STRING;
	
		std::string cookie = m_yCookie.data();
		cookie.erase(0,2); // erase 'Y='

		command += ' ';

		MojLogInfo(m_log, "Pre-encoded command: {%s}", cookie.c_str());
		
		gchar * encodedPayload = g_base64_encode((unsigned guchar*)cookie.c_str(), cookie.length());
		try {
			command += encodedPayload;
		} catch (...) {
			g_free(encodedPayload);
			throw;
		}
		g_free(encodedPayload);


		MojLogInfo(m_log, "Post-encoded command: {%s}", command.c_str());
	
		SendCommand(command);
		
	} else if (m_state == State_SendingTCookie) {
		MojLogInfo(m_log, "Sending TCookie");
	
		std::string cookie = m_tCookie.data();
		cookie.erase(0,2); // erase 'T='
		
		cookie += " ts=";
		cookie += boost::lexical_cast<std::string>(timeMillis() / 1000);
		
		cookie += " src=";
		cookie += m_partnerId.data();
		cookie += " GUID=";
		cookie += m_deviceId.data();
		
		MojLogInfo(m_log, "Pre-encoded cookie: {%s}", cookie.c_str());

		gchar * encodedPayload = g_base64_encode((unsigned guchar*)cookie.c_str(), cookie.length());
		try {
			cookie = encodedPayload;
		} catch (...) {
			g_free(encodedPayload);
			throw;
		}
		g_free(encodedPayload);

		MojLogInfo(m_log, "Post-encoded cookie: {%s}", cookie.c_str());
		
		SendCommand(cookie);
	}
}
Пример #2
0
void AuthYahooCommand::RunImpl()
{
	MojLogTrace(m_log);
	// HACK: Hard-code partner ID and fetch of NDUID
	m_partnerId.assign("mblclt11");
	
	char id[256];
	memset(id, '\0', 256);
	
	// Read nduid, if available, otherwise make a fake one and try to record it.
	FILE * nduid = fopen("/proc/nduid", "r");
	if (!nduid) {
		nduid = fopen("yahooCachedFakeDeviceId", "r");
		if (!nduid) {
			snprintf(id, 255, "FEED0BEEF479121481533145%016llX", timeMillis());
			nduid = fopen("yahooCachedFakeDeviceId", "w");
			if (nduid) {
				fputs(id, nduid);
				fclose(nduid);
				nduid = NULL;
			}
		}
	}
	
	if (nduid) {
		if (fgets(id, 255, nduid) == NULL)
			id[0] = '\0';
		
		fclose(nduid);
		nduid = NULL;

		if (strlen(id) > 0 && id[strlen(id)-1] == '\n')
			id[strlen(id)-1] = '\0';
	}
	
	m_deviceId.assign(id);

	MojLogInfo(m_log, "Temp: partnerId=%s deviceId=%s", m_partnerId.data(), m_deviceId.data());

	MojObject accountId = m_session.GetAccount()->GetAccountId();

	MojObject params;
	MojErr err = params.put("accountId", accountId);
	ErrorToException(err);

	MojString token;
	token.assign(m_session.GetAccount()->GetYahooToken().c_str());
	err = params.put("securityToken", token);
	ErrorToException(err);

	MojLogInfo(m_log, "Looking up yahoo cookies for account %s", AsJsonString(accountId).c_str());
	// TODO: Should send the request with SmtpClient instead.
	err = m_session.CreateRequest()->send(m_getYahooCookiesSlot, "com.palm.yahoo","fetchcookies", params);
	ErrorToException(err);
}
Пример #3
0
void callbackRet(int use) {
	if (use_act) {
		static long time_end = 0;
		static bool active = false;
		long now = timeMillis();
		if (use == ACTIVATE) { //Set timer
			time_end = now + DELAY_RET;
			servoRet.write(ANGLE_RET);
			active = true;
		} else if (active) { //update regulier
			if (now >= time_end && use_act) {
				servoRet.write(180);
				setLastId();
				active = false;
			}
		}
	}
}