예제 #1
0
BOOL CNNTPConnection::Connect(LPCTSTR pszHostName, LPCTSTR pszUser, LPCTSTR pszPassword, int nPort)
{
	USES_CONVERSION;

	if (!m_nntp.Create())
	{
		m_strErrorMsg = FuncGetStringFromIDS("<%IDS_News_4%>");//<%IDS_News_4%>_T("ͨÐųõʼ»¯Ê§°Ü")
		return FALSE;
	}

	if (!m_nntp.Connect(pszHostName, nPort))
	{
		m_strErrorMsg = FuncGetStringFromIDS("<%IDS_News_5%>");//<%IDS_News_5%>_T("Ö÷»úÁ¬½Óʧ°Ü")
		return FALSE;
	}
	else
	{
		m_bConnected = TRUE;
		
		CString	strInfo = _T("");
		int nRes = CommandResponse(strInfo);
		if(nRes != 2)
		{
			m_strErrorMsg = strInfo;
			Disconnect();
			return FALSE;
		}

		if(*pszUser)
		{
			if(!LoginUser(pszUser))
			{
				m_strErrorMsg = FuncGetStringFromIDS("<%IDS_News_6%>");//<%IDS_News_6%>_T("µÇ¼ʧ°Ü")
				Disconnect();
				return FALSE;
			}

			if(!LoginUser(pszPassword))
			{
				m_strErrorMsg = FuncGetStringFromIDS("<%IDS_News_7%>");//<%IDS_News_7%>_T("µÇ¼ʧ°Ü")
				Disconnect();
				return FALSE;
			}
		}

		return TRUE;
	}
}
예제 #2
0
bool Login::ShowSignInMenu() {
	string username = "", password = "";
	bool valid = false;

	cout << "******* SIGN IN *******\n";
	while (valid == false) {
		cout << "Username: "******"Password: "******"\n" << endl;

		int id = LoginUser(username, password);

		if (id > 0) { // valid user
			valid = true;
			cout << "\n ** You're now logged in !! **\n" << endl;
			return true;
		}
		else {
			cout << "Invalid username or password, please try again !! \n" << endl;
		}
	}
	return false;
}