Esempio n. 1
0
DWORD CMraProto::MraSetXStatusInternal(DWORD dwXStatus)
{
	if (IsXStatusValid(dwXStatus)) {
		CMStringW szBuff;

		// obsolete (TODO: remove in next version)
		char szValueName[MAX_PATH];
		mir_snprintf(szValueName, SIZEOF(szValueName), "XStatus%ldName", dwXStatus);
		if (!mraGetStringW(NULL, szValueName, szBuff))
			szBuff = lpcszXStatusNameDef[dwXStatus];
		mraSetStringExW(NULL, DBSETTING_XSTATUSNAME, szBuff);

		// obsolete (TODO: remove in next version)
		mir_snprintf(szValueName, SIZEOF(szValueName), "XStatus%ldMsg", dwXStatus);
		if (mraGetStringW(NULL, szValueName, szBuff))
			mraSetStringExW(NULL, DBSETTING_XSTATUSMSG, szBuff);
		else
			delSetting(DBSETTING_XSTATUSMSG);
	}
	else {
		delSetting(DBSETTING_XSTATUSNAME);
		delSetting(DBSETTING_XSTATUSMSG);
		dwXStatus = MRA_MIR_XSTATUS_NONE;
	}

	DWORD dwOldStatusMode = InterlockedExchange((volatile LONG*)&m_iXStatus, dwXStatus);
	setByte(DBSETTING_XSTATUSID, (BYTE)dwXStatus);

	MraSendNewStatus(m_iStatus, dwXStatus, _T(""), _T(""));

	return dwOldStatusMode;
}
Esempio n. 2
0
void FacebookProto::SaveName(HANDLE hContact, const facebook_user *fbu)
{
    if (fbu->real_name.empty()) {
        delSetting(hContact, FACEBOOK_KEY_NICK);
        delSetting(hContact, FACEBOOK_KEY_FIRST_NAME);
        delSetting(hContact, FACEBOOK_KEY_SECOND_NAME);
        delSetting(hContact, FACEBOOK_KEY_LAST_NAME);
        return;
    }

    setStringUtf(hContact, FACEBOOK_KEY_NICK, fbu->real_name.c_str());

    // Explode whole name into first, second and last name
    std::vector<std::string> names;
    utils::text::explode(fbu->real_name, " ", &names);

    setStringUtf(hContact, FACEBOOK_KEY_FIRST_NAME, names.front().c_str());
    setStringUtf(hContact, FACEBOOK_KEY_LAST_NAME, names.back().c_str());

    if (names.size() > 2) {
        std::string middle = "";
        for (std::string::size_type i = 1; i < names.size() - 1; i++) {
            if (!middle.empty())
                middle += " ";

            middle += names.at(i);
        }
        setStringUtf(hContact, FACEBOOK_KEY_SECOND_NAME, middle.c_str());
    } else {
        delSetting(hContact, FACEBOOK_KEY_SECOND_NAME);
    }
}
Esempio n. 3
0
void CJabberProto::ConvertPasswords()
{
	ptrT passw(JSetStringCrypt(m_szModuleName, NULL, "LoginPassword"));
	if (passw == NULL)
		return;

	setTString("Password", passw);
	delSetting("LoginPassword");

	for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
		if ((passw = JSetStringCrypt(m_szModuleName, hContact, "LoginPassword")) == NULL)
			continue;

		setTString(hContact, "Password", passw);
		delSetting(hContact, "LoginPassword");
	}

	for (int i = 0;; i++) {
		char varName[100];
		mir_snprintf(varName, sizeof(varName), "rcMuc_%d_server", i);
		ptrA str(getStringA(NULL, varName));
		if (str == NULL)
			break;

		mir_snprintf(varName, sizeof(varName), "rcMuc_%d", i);
		if ((passw = JSetStringCrypt(m_szModuleName, NULL, varName)) != NULL) {
			delSetting(varName);

			mir_snprintf(varName, sizeof(varName), "password_rcMuc_%d", i);
			setTString(varName, passw);
		}
	}
}
Esempio n. 4
0
void CSteamProto::DeleteAuthSettings()
{
	delSetting("TwoFactorCode");
	delSetting("GuardId");
	delSetting("GuardCode");
	delSetting("CaptchaId");
	delSetting("CaptchaText");
}
Esempio n. 5
0
void CYahooProto::logoff_buddies()
{
	//set all contacts to 'offline'
	for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
		setWord(hContact, "Status", ID_STATUS_OFFLINE);
		setDword(hContact, "IdleTS", 0);
		setDword(hContact, "PictLastCheck", 0);
		setDword(hContact, "PictLoading", 0);
		db_unset(hContact, "CList", "StatusMsg");
		delSetting(hContact, "YMsg");
		delSetting(hContact, "YGMsg");
	}
}
Esempio n. 6
0
void CJabberProto::SetContactOfflineStatus(MCONTACT hContact)
{
	if (getWord(hContact, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
		setWord(hContact, "Status", ID_STATUS_OFFLINE);

	delSetting(hContact, DBSETTING_XSTATUSID);
	delSetting(hContact, DBSETTING_XSTATUSNAME);
	delSetting(hContact, DBSETTING_XSTATUSMSG);
	delSetting(hContact, DBSETTING_DISPLAY_UID);

	ResetAdvStatus(hContact, ADVSTATUS_MOOD);
	ResetAdvStatus(hContact, ADVSTATUS_TUNE);
}
Esempio n. 7
0
void CSteamProto::HandleTokenExpired()
{
	// Delete expired token
	delSetting("TokenSecret");

	// Try to relogin automatically (but only once)
	if (isLoginAgain) {
		// Notify error to user
		ShowNotification(_T("Steam"), TranslateT("Cannot obtain connection token."));

		// Just go offline; it also resets the isLoginAgain to false
		SetStatus(ID_STATUS_OFFLINE);
	}
	else
	{
		// Remember we are trying to relogin
		isLoginAgain = true;

		// Remember status user wanted
		int desiredStatus = m_iDesiredStatus;

		// Set status to offline
		SetStatus(ID_STATUS_OFFLINE);

		// Try to login again automatically
		SetStatus(desiredStatus);
	}
}
Esempio n. 8
0
void MinecraftDynmapProto::SignOffWorker(void*)
{
	ScopedLock s(signon_lock_);

	SetEvent(events_loop_event_);

	m_cookie.clear();
	m_title.clear();
	m_server.clear();
	m_timestamp.clear();

	int old_status = m_iStatus;
	m_iStatus = ID_STATUS_OFFLINE;

	Netlib_Shutdown(hEventsConnection);

	OnLeaveChat(NULL, NULL);

	delSetting("LogonTS");

	ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);

	//SetAllContactStatuses(ID_STATUS_OFFLINE);
	//ToggleStatusMenuItems(false);

	if (hConnection)
		Netlib_CloseHandle(hConnection);
	hConnection = NULL;

	if (hEventsConnection)
		Netlib_CloseHandle(hEventsConnection);
	hEventsConnection = NULL;
}
Esempio n. 9
0
void CJabberProto::DBAddAuthRequest(const TCHAR *jid, const TCHAR *nick)
{
	MCONTACT hContact = DBCreateContact(jid, nick, TRUE, TRUE);
	delSetting(hContact, "Hidden");

	char* szJid = mir_utf8encodeT(jid);
	char* szNick = mir_utf8encodeT(nick);

	//blob is: uin(DWORD), hContact(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ)
	//blob is: 0(DWORD), hContact(DWORD), nick(ASCIIZ), ""(ASCIIZ), ""(ASCIIZ), email(ASCIIZ), ""(ASCIIZ)
	DBEVENTINFO dbei = { sizeof(DBEVENTINFO) };
	dbei.szModule = m_szModuleName;
	dbei.timestamp = (DWORD)time(NULL);
	dbei.flags = DBEF_UTF;
	dbei.eventType = EVENTTYPE_AUTHREQUEST;
	dbei.cbBlob = (DWORD)(sizeof(DWORD)*2 + strlen(szNick) + strlen(szJid) + 5);
	PBYTE pCurBlob = dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob);
	*((PDWORD)pCurBlob) = 0; pCurBlob += sizeof(DWORD);
	*((PDWORD)pCurBlob) = (DWORD)hContact; pCurBlob += sizeof(DWORD);
	strcpy((char*)pCurBlob, szNick); pCurBlob += strlen(szNick)+1;
	*pCurBlob = '\0'; pCurBlob++;		//firstName
	*pCurBlob = '\0'; pCurBlob++;		//lastName
	strcpy((char*)pCurBlob, szJid); pCurBlob += strlen(szJid)+1;
	*pCurBlob = '\0';					//reason

	db_event_add(NULL, &dbei);
	debugLogA("Setup DBAUTHREQUEST with nick='%s' jid='%s'", szNick, szJid);

	mir_free(szJid);
	mir_free(szNick);
}
Esempio n. 10
0
void CJabberProto::SearchDeleteFromRecent(const TCHAR *szAddr, BOOL deleteLastFromDB)
{
	//search in recent
	for (int i=0; i<10; i++) {
		char key[30];
		mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", i);
		ptrT szValue( getTStringA(key));
		if (szValue == NULL || _tcsicmp(szAddr, szValue))
			continue;

		for (int j=i; j < 10; j++) {
			mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", j + 1);
			szValue = getTStringA(key);
			if (szValue != NULL) {
				mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", j);
				setTString(NULL, key, szValue);
			}
			else {
				if (deleteLastFromDB) {
					mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", j);
					delSetting(NULL,key);
				}
				break;
		}	}
		break;
}	}
Esempio n. 11
0
void CToxProto::OnGotFriendAvatarInfo(AvatarTransferParam *transfer)
{
	if (transfer->pfts.totalBytes == 0)
	{
		MCONTACT hConact = transfer->pfts.hContact;
		std::tstring path = GetAvatarFilePath(hConact);
		if (IsFileExists(path))
			DeleteFile(path.c_str());

		transfers.Remove(transfer);
		delSetting(hConact, TOX_SETTINGS_AVATAR_HASH);
		ProtoBroadcastAck(hConact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, 0, 0);
		return;
	}

	DBVARIANT dbv;
	if (!db_get(transfer->pfts.hContact, m_szModuleName, TOX_SETTINGS_AVATAR_HASH, &dbv))
	{
		if (memcmp(transfer->hash, dbv.pbVal, TOX_HASH_LENGTH) == 0)
		{
			db_free(&dbv);
			OnFileCancel(transfer->pfts.hContact, transfer);
			return;
		}
		db_free(&dbv);
	}

	TCHAR path[MAX_PATH];
	mir_sntprintf(path, _countof(path), _T("%s\\%S"), VARST(_T("%miranda_avatarcache%")), m_szModuleName);
	OnFileAllow(transfer->pfts.hContact, transfer, path);
}
Esempio n. 12
0
void CSkypeProto::UpdateProfileLastName(const JSONNode &root, MCONTACT hContact)
{
	CMString lastname = root["lastname"].as_mstring();
	if (!lastname.IsEmpty() && lastname != "null")
		setTString(hContact, "LastName", lastname);
	else
		delSetting(hContact, "LastName");
}
Esempio n. 13
0
void CSkypeProto::UpdateProfilePhoneOffice(const JSONNode &root, MCONTACT hContact)
{
	CMString province = root["phoneOffice"].as_mstring();
	if (!province.IsEmpty() && province != "null")
		setTString(hContact, "CompanyPhone", province);
	else
		delSetting(hContact, "CompanyPhone");
}
Esempio n. 14
0
void CSkypeProto::UpdateProfileAbout(const JSONNode &root, MCONTACT hContact)
{
	CMString about = root["about"].as_mstring();
	if (!about.IsEmpty() && about != "null")
		setTString(hContact, "About", about);
	else
		delSetting(hContact, "About");
}
Esempio n. 15
0
void CSkypeProto::UpdateProfileHomepage(const JSONNode &root, MCONTACT hContact)
{
	CMString homepage = root["homepage"].as_mstring();
	if (!homepage.IsEmpty() && homepage != "null")
		setTString(hContact, "Homepage", homepage);
	else
		delSetting(hContact, "Homepage");
}
Esempio n. 16
0
void CSkypeProto::UpdateProfileLanguage(const JSONNode &root, MCONTACT hContact)
{
	CMString isocode = root["language"].as_mstring();
	if (!isocode.IsEmpty() && isocode != "null")
		setTString(hContact, "Language0", languages[isocode.GetBuffer()].c_str());
	else
		delSetting(hContact, "Language0");
}
Esempio n. 17
0
void CSkypeProto::UpdateProfileCity(const JSONNode &root, MCONTACT hContact)
{
	CMString city = root["city"].as_mstring();
	if (!city.IsEmpty() && city != "null")
		setTString(hContact, "City", city);
	else
		delSetting(hContact, "City");
}
Esempio n. 18
0
void CSkypeProto::UpdateProfileGender(const JSONNode &root, MCONTACT hContact)
{
	CMString gender = root["gender"].as_mstring();
	if (!gender.IsEmpty() && gender != "null")
		setByte(hContact, "Gender", (BYTE)(_ttoi(gender) == 1 ? 'M' : 'F'));
	else
		delSetting(hContact, "Gender");
}
Esempio n. 19
0
void CSkypeProto::UpdateProfileXStatusMessage(const JSONNode &root, MCONTACT hContact)
{
	CMString province = root["richMood"].as_mstring();
	if (!province.IsEmpty() && province != "null")
		setTString(hContact, "XStatusMsg", province);
	else
		delSetting(hContact, "XStatusMsg");
}
Esempio n. 20
0
void CVkProto::ConnectionFailed(int iReason)
{
	delSetting("AccessToken");

	ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, iReason);
	debugLogA("CVkProto::ConnectionFailed ShutdownSession");
	ShutdownSession();
}
Esempio n. 21
0
void CSkypeProto::UpdateProfileBirthday(const JSONNode &root, MCONTACT hContact)
{
	CMString birthday = root["birthday"].as_mstring();
	if (!birthday.IsEmpty() && birthday != "null")
	{
		int d, m, y;
		_stscanf(birthday.GetBuffer(), _T("%d-%d-%d"), &y, &m, &d);
		setWord(hContact, "BirthYear", y);
		setByte(hContact, "BirthDay", d);
		setByte(hContact, "BirthMonth", m);
	}
	else
	{
		delSetting(hContact, "BirthYear");
		delSetting(hContact, "BirthDay");
		delSetting(hContact, "BirthMonth");
	}
}
Esempio n. 22
0
void CMsnProto::MSN_GetAvatarFileName(MCONTACT hContact, TCHAR* pszDest, size_t cbLen, const TCHAR *ext)
{
	size_t tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\%S"), VARST(_T("%miranda_avatarcache%")), m_szModuleName);

	if (_taccess(pszDest, 0))
		CreateDirectoryTreeT(pszDest);

	size_t tPathLen2 = tPathLen;
	if (hContact != NULL) {
		DBVARIANT dbv;
		if (getString(hContact, "PictContext", &dbv) == 0) {
			char* szAvatarHash = MSN_GetAvatarHash(dbv.pszVal);
			if (szAvatarHash != NULL) {
				TCHAR *sztAvatarHash = mir_a2t(szAvatarHash);
				tPathLen += mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\%s."), sztAvatarHash);
				mir_free(sztAvatarHash);
				mir_free(szAvatarHash);
			}
			else {
				delSetting(hContact, "PictContext");
				if (cbLen) pszDest[0] = 0;
			}
			db_free(&dbv);
		}
		else if (cbLen)
			pszDest[0] = 0;
	}
	else {
		TCHAR *sztModuleName = mir_a2t(m_szModuleName);
		tPathLen += mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\%s avatar."), sztModuleName);
		mir_free(sztModuleName);
	}

	if (ext == NULL) {
		mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("*"));

		bool found = false;
		_tfinddata_t c_file;
		long hFile = _tfindfirst(pszDest, &c_file);
		if (hFile > -1L) {
			do {
				if (_tcsrchr(c_file.name, '.')) {
					mir_sntprintf(pszDest + tPathLen2, cbLen - tPathLen2, _T("\\%s"), c_file.name);
					found = true;
				}
			}
				while(_tfindnext(hFile, &c_file) == 0);
			_findclose( hFile );
		}

		if (!found) pszDest[0] = 0;
	}
	else {
		tPathLen--;
		mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, ext);
	}
}
Esempio n. 23
0
INT_PTR CMsnProto::SetAvatar(WPARAM, LPARAM lParam)
{
	TCHAR* szFileName = (TCHAR*)lParam;

	TCHAR tFileName[MAX_PATH];
	MSN_GetAvatarFileName(NULL, tFileName, _countof(tFileName), NULL);
	_tremove(tFileName);

	if (szFileName == NULL) {
		delSetting("PictObject");
		delSetting("AvatarHash");
		ForkThread(&CMsnProto::msn_storeAvatarThread, NULL);
	}
	else {
		int fileId = _topen(szFileName, _O_RDONLY | _O_BINARY, _S_IREAD);
		if (fileId < 0) return 1;

		size_t dwPngSize = _filelengthi64(fileId);
		unsigned char* pData = (unsigned char*)mir_alloc(dwPngSize);
		if (pData == NULL) {
			_close(fileId);
			return 2;
		}

		_read(fileId, pData, (unsigned)dwPngSize);
		_close(fileId);

		TCHAR drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT];
		_tsplitpath(szFileName, drive, dir, fname, ext);

		MSN_SetMyAvatar(fname, pData, dwPngSize);

		StoreAvatarData* par = (StoreAvatarData*)mir_alloc(sizeof(StoreAvatarData));
		par->szName = mir_tstrdup(fname);
		par->data = pData;
		par->dataSize = dwPngSize;
		par->szMimeType = "image/png";

		ForkThread(&CMsnProto::msn_storeAvatarThread, par);
	}

	MSN_SetServerStatus(m_iStatus);
	return 0;
}
Esempio n. 24
0
void CYahooProto::ext_got_picture_upload(const char *me, const char *url, unsigned int ts)
{
	int cksum = 0;
	DBVARIANT dbv;

	LOG(("[ext_yahoo_got_picture_upload] url: %s timestamp: %d", url, ts));

	if (!url) {
		LOG(("[ext_yahoo_got_picture_upload] Problem with upload?"));
		return;
	}


	cksum = getDword("TMPAvatarHash", 0);
	if (cksum != 0) {
		LOG(("[ext_yahoo_got_picture_upload] Updating Checksum to: %d", cksum));
		setDword("AvatarHash", cksum);
		delSetting("TMPAvatarHash");

		// This is only meant for message sessions, but we don't got those in miranda yet
		//YAHOO_bcast_picture_checksum(cksum);
		yahoo_send_picture_checksum(m_id, NULL, cksum);

		// need to tell the stupid Yahoo that our icon updated
		//YAHOO_bcast_picture_update(2);
	}
	else
		cksum = getDword("AvatarHash", 0);

	setString("AvatarURL", url);
	//YAHOO_SetDword("AvatarExpires", ts);

	if (!getString("AvatarInv", &dbv)) {
		LOG(("[ext_yahoo_got_picture_upload] Buddy: %s told us this is bad??", dbv.pszVal));

		LOG(("[ext_yahoo_got_picture] Sending url: %s checksum: %d to '%s'!", url, cksum, dbv.pszVal));
		//void yahoo_send_picture_info(int id, const char *me, const char *who, const char *pic_url, int cksum)
		yahoo_send_picture_info(m_id, dbv.pszVal, 2, url, cksum);

		delSetting("AvatarInv");
		db_free(&dbv);
	}
}
Esempio n. 25
0
void CSkypeProto::UpdateProfileCountry(const JSONNode &root, MCONTACT hContact)
{
	std::string isocode = root["country"].as_string();
	if (!isocode.empty() && isocode != "null")
	{
		char *country = (char *)CallService(MS_UTILS_GETCOUNTRYBYISOCODE, (WPARAM)isocode.c_str(), 0);
		setString(hContact, "Country", country);
	}
	else delSetting(hContact, "Country");
}
Esempio n. 26
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;
}
Esempio n. 27
0
void CSteamProto::OnAuthorizationSuccess(const JSONNode &node)
{
	delSetting("GuardId");
	delSetting("GuardCode");
	delSetting("CaptchaId");
	delSetting("CaptchaText");

	if (!node["login_complete"].as_bool())
	{
		SetStatus(ID_STATUS_OFFLINE);
		return;
	}

	std::string oauth = node["oauth"].as_string();
	JSONNode root = JSONNode::parse(oauth.c_str());
	if (!root)
	{
		SetStatus(ID_STATUS_OFFLINE);
		return;
	}

	std::string steamId = root["steamid"].as_string();
	setString("SteamID", steamId.c_str());

	std::string token = root["oauth_token"].as_string();
	setString("TokenSecret", token.c_str());

	std::string cookie = root["webcookie"].as_string();

	PushRequest(
		new GetSessionRequest(token.c_str(), steamId.c_str(), cookie.c_str()),
		&CSteamProto::OnGotSession);

	// We need to load homepage to get sessionid cookie
	PushRequest(
		new GetSessionRequest2(),
		&CSteamProto::OnGotSession);

	PushRequest(
		new LogonRequest(token.c_str()),
		&CSteamProto::OnLoggedOn);
}
Esempio n. 28
0
int CSteamProto::OnIdleChanged(WPARAM, LPARAM lParam)
{
	bool idle = (lParam & IDF_ISIDLE) != 0;
	bool privacy = (lParam & IDF_PRIVACY) != 0;

	// Respect user choice about (not) notifying idle to protocols
	if (privacy)
	{
		// Reset it to 0 if there is some time already
		if (m_idleTS)
		{
			m_idleTS = 0;
			delSetting("IdleTS");
		}

		return 0;
	}

	// We don't want to reset idle time when we're already in idle state
	if (idle && m_idleTS > 0)
		return 0;

	if (idle)
	{
		// User started being idle
		MIRANDA_IDLE_INFO mii = { sizeof(mii) };
		CallService(MS_IDLE_GETIDLEINFO, 0, (LPARAM)&mii);

		// Compute time when user really became idle
		m_idleTS = time(0) - mii.idleTime * 60;
		setDword("IdleTS", m_idleTS);
	}
	else
	{
		// User stopped being idle
		m_idleTS = 0;
		delSetting("IdleTS");
	}

	return 0;
}
Esempio n. 29
0
INT_PTR __cdecl CJabberProto::OnMenuConvertChatContact(WPARAM hContact, LPARAM)
{
    BYTE bIsChatRoom = isChatRoom(hContact);
    const char *szSetting = (bIsChatRoom) ? "ChatRoomID" : "jid";

    ptrT jid(getTStringA(hContact, szSetting));
    if (jid != NULL) {
        delSetting(hContact, szSetting);
        setTString(hContact, szSetting, jid);
        setByte(hContact, "ChatRoom", !bIsChatRoom);
    }
    return 0;
}
Esempio n. 30
0
void FacebookProto::SaveName(MCONTACT hContact, const facebook_user *fbu)
{
    if (fbu->type == CONTACT_PAGE) {
        // Page has only nickname and no first/last names
        std::string nick = m_pagePrefix + " " + fbu->real_name;

        updateStringUtf(this, hContact, FACEBOOK_KEY_NICK, nick);
        delSetting(hContact, FACEBOOK_KEY_FIRST_NAME);
        delSetting(hContact, FACEBOOK_KEY_SECOND_NAME);
        delSetting(hContact, FACEBOOK_KEY_LAST_NAME);
        return;
    }

    // Save nick
    std::string nick = fbu->real_name;
    if (!getBool(FACEBOOK_KEY_NAME_AS_NICK, 1) && !fbu->nick.empty())
        nick = fbu->nick;

    updateStringUtf(this, hContact, FACEBOOK_KEY_NICK, nick);

    // Explode whole name into first, second and last name
    std::vector<std::string> names;
    utils::text::explode(fbu->real_name, " ", &names);

    updateStringUtf(this, hContact, FACEBOOK_KEY_FIRST_NAME, names.size() > 0 ? names.front().c_str() : "");
    updateStringUtf(this, hContact, FACEBOOK_KEY_LAST_NAME, names.size() > 1 ? names.back().c_str() : "");

    std::string middle;
    if (names.size() > 2) {
        for (std::string::size_type i = 1; i < names.size() - 1; i++) {
            if (!middle.empty())
                middle += " ";

            middle += names.at(i);
        }
    }
    updateStringUtf(this, hContact, FACEBOOK_KEY_SECOND_NAME, middle);
}