예제 #1
0
파일: RenoCommand.cpp 프로젝트: m1h4/Reno
BOOL CRenoCommandFrame::ReplyPart(const CString& prefix,const CString& command,const CStringPtrArray& parameters)
{
	CString nick;

	if(prefix.GetLength())
	{
		LONG seperator = prefix.Find(TEXT('!'));
		if(seperator == -1)
			nick = prefix;
		else
			nick = prefix.Left(seperator);
	}

	if(!nick.GetLength())
		nick = TEXT("????");

	if(parameters.GetCount() == 2 && parameters[1].GetLength())
		PrintFormat(TEXT("[Reno|Info] User %s is leaving %s (%s)\r\n"),nick,parameters[0],parameters[1]);
	else if(parameters.GetCount() == 1)
		PrintFormat(TEXT("[Reno|Info] User %s is leaving %s\r\n"),nick,parameters[0]);
	else
		PrintFormat(TEXT("[Reno|Info] Error: Reply in invalid format ('%s' '%s' '%d')\r\n"),prefix,command,parameters.GetCount());

	return TRUE;
}
예제 #2
0
파일: RenoCommand.cpp 프로젝트: m1h4/Reno
BOOL CRenoCommandFrame::CmdPrivate(const CStringPtrArray& commandElements)
{
	// Maybe we are not connected
	if(m_State < RENO_NETWORK_CONNECTED)
	{
		PrintFormat(TEXT("* Error: Not connected\r\n"));
		return FALSE;
	}

	if(commandElements.GetCount() < 3)
	{
		PrintFormat(TEXT("* Usage: %s <message_target> <text>\r\n"),commandElements[0]);
		return FALSE;
	}

	CString cmd = TEXT("PRIVMSG ");

	cmd += commandElements[1] + TEXT(" :");

	for(LONG i = 2; i < commandElements.GetCount(); ++i)
		cmd += commandElements[i] + ((i < commandElements.GetCount() - 1) ? TEXT(" ") : TEXT(""));

	cmd += TEXT("\r\n");

	if(theApp.GetNickList().GetCount())
		PrintFormat(TEXT("[%s] %s\r\n"),theApp.GetNickList()[0],commandElements[2]);
	else
		PrintFormat(TEXT("[????] %s\r\n"),commandElements[2]);

	return Send(cmd,cmd.GetLength());
}
예제 #3
0
파일: RenoCommand.cpp 프로젝트: m1h4/Reno
BOOL CRenoCommandFrame::CmdDisconnect(const CStringPtrArray& commandElements)
{
	// Maybe we are not connected
	if(m_State < RENO_NETWORK_CONNECTED)
	{
		PrintFormat(TEXT("* Error: Not connected\r\n"));
		return FALSE;
	}

	// Tell the server we are quitting
	CString cmd = TEXT("QUIT ");

	if(commandElements.GetCount() > 1)
		cmd += TEXT(":");

	for(LONG i = 1; i < commandElements.GetCount(); ++i)
		cmd += commandElements[i] + ((i < commandElements.GetCount() - 1) ? TEXT(" ") : TEXT(""));

	cmd += TEXT("\r\n");

	Send(cmd,cmd.GetLength());

	// Close the connection
	Close();

	PrintFormat(TEXT("* Disconnected\r\n"));

	return TRUE;
}
예제 #4
0
파일: RenoCommand.cpp 프로젝트: m1h4/Reno
BOOL CRenoCommandFrame::CmdTopic(const CStringPtrArray& commandElements)
{
	// Maybe we are not connected
	if(m_State < RENO_NETWORK_CONNECTED)
	{
		PrintFormat(TEXT("* Error: Not connected\r\n"));
		return FALSE;
	}

	if(commandElements.GetCount() < 2)
	{
		PrintFormat(TEXT("* Usage: %s <channel> [new_topic]\r\n"),commandElements[0]);
		return FALSE;
	}

	CString cmd = TEXT("TOPIC ");

	cmd += commandElements[1];

	if(commandElements.GetCount() > 2)
		cmd += TEXT(" :");

	for(LONG i = 2; i < commandElements.GetCount(); ++i)
		cmd += commandElements[i] + ((i < commandElements.GetCount() - 1) ? TEXT(" ") : TEXT(""));

	cmd += TEXT("\r\n");

	return Send(cmd,cmd.GetLength());
}
예제 #5
0
파일: RenoCommand.cpp 프로젝트: m1h4/Reno
BOOL CRenoCommandFrame::CmdLogin(const CStringPtrArray& commandElements)
{
	// Maybe we are not connected
	if(m_State < RENO_NETWORK_CONNECTED)
	{
		PrintFormat(TEXT("* Error: Not connected\r\n"));
		return FALSE;
	}

	if(!theApp.GetNickList().GetCount())
	{
		PrintFormat(TEXT("* No nicks entered in configuration\r\n"));
		return FALSE;
	}

	if(!theApp.GetRealName().GetLength())
	{
		PrintFormat(TEXT("* No real name entered in configuration\r\n"));
		return FALSE;
	}

	if(!theApp.GetUserName().GetLength())
	{
		PrintFormat(TEXT("* No user name entered in configuration\r\n"));
		return FALSE;
	}

	return SendFormat(TEXT("PASS ghjfhjfgjgfh\r\nUSER %s 0 * :%s\r\nNICK %s\r\n"),theApp.GetUserName(),theApp.GetRealName(),theApp.GetNickList()[0]);
}
예제 #6
0
VOID CRenoCommandFrame::OnConnect(INT nErrorCode)
{
	switch(nErrorCode)
	{
	case NULL:
		PrintFormat(TEXT("* Connection established\r\n"));
		break;

	case WSAECONNREFUSED:
		PrintFormat(TEXT("* Failed to connect. No connection could be made because the target computer actively refused it\r\n"));
		break;

	case WSAENETUNREACH:
		PrintFormat(TEXT("* Failed to connect. The network cannot be reached from this host at this time\r\n"));
		break;

	case WSAETIMEDOUT:
		PrintFormat(TEXT("* Failed to connect. The connected party did not properly respond after a period of time\r\n"));
		break;

	default:
		PrintFormat(TEXT("* Failed to connect. Connection error %d\r\n"),nErrorCode);
		break;
	}

	CRenoSocketWnd::OnConnect(nErrorCode);
}
예제 #7
0
static inline bool LatestVersion(int *major, int *minor, int *current_line) {
	u32 http_status = 0;
	u8* outbuf = NULL;
	u32 filesize;
	int line = *current_line;

	PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X, MENU_POS_Y + 20*line, Downloads[DOWNLOAD_VERSION].text);
	UpdateScreen();
	line++;
	if(!http_request(Downloads[DOWNLOAD_VERSION].url, Downloads[DOWNLOAD_VERSION].max_size)) {
		PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X, MENU_POS_Y + 20*line, "Failed to retrieve version");
		UpdateScreen();
		*current_line = line;
		return false;
	}
	

	http_get_result(&http_status, &outbuf, &filesize);
	
	if (((int)*outbuf & 0xF0000000) == 0xF0000000) 
	{
		if (outbuf != NULL) free(outbuf);
		*current_line = line;
		return false;
	}
	sscanf((char*)outbuf, " #ifndef %*s #define %*s #define NIN_MAJOR_VERSION %i #define NIN_MINOR_VERSION %i", major, minor);
	gprintf("major = %i, minor = %i\r\n", *major, *minor);
	if (outbuf != NULL) free(outbuf);
	if ((*major <= NIN_MAJOR_VERSION) && (*minor <= NIN_MINOR_VERSION)) {
		bool still_download = true;
		PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X, MENU_POS_Y + 20*line, "You already have the latest version");
		line++;
		PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X, MENU_POS_Y + 20*line, "Download anyway? (A: Yes, B: No)");
		line++;
		UpdateScreen();
		while(true) {
			DrawBuffer();
			FPAD_Update();
			if (FPAD_Cancel(0)) {
				gprintf("Cancelling download\n");
				still_download = false;
				break;
			}
			if (FPAD_OK(0)) {
				gprintf("okay\n");
				break;
			}
			GRRLIB_Render();
		}
		if(!still_download) {
			*current_line = line;
			return false;
		}
	}
	*current_line = line;
	return (*major + *minor) > 0;

}
예제 #8
0
파일: RenoCommand.cpp 프로젝트: m1h4/Reno
BOOL CRenoCommandFrame::ReplyError(const CString& prefix,const CString& command,const CStringPtrArray& parameters)
{
	if(parameters.GetCount() == 1)
		PrintFormat(TEXT("[Reno|Error] %s\r\n"),parameters[0]);
	else
		PrintFormat(TEXT("[Reno|Error] Error: Reply in invalid format ('%s' '%s' '%d')\r\n"),prefix,command,parameters.GetCount());

	return TRUE;
}
예제 #9
0
파일: RenoCommand.cpp 프로젝트: m1h4/Reno
BOOL CRenoCommandFrame::CmdSave(const CStringPtrArray& commandElements)
{
	if(theApp.SaveSettings())
		PrintFormat(TEXT("* Configuration saved\r\n"));
	else
		PrintFormat(TEXT("* Error: Failed to save configuration\r\n"));

	return TRUE;
}
예제 #10
0
파일: RenoCommand.cpp 프로젝트: m1h4/Reno
BOOL CRenoCommandFrame::CmdHelp(const CStringPtrArray& commandElements)
{
	PrintFormat(TEXT("* Supported commands:\r\n"));

	const RENO_COMMAND* commandMap = GetCommandMap();
	ASSERT(commandMap);

	ULONG i;

	for(i = 0; commandMap[i].name && commandMap[i].function; ++i)
		PrintFormat(TEXT("*   %12s - %s\r\n"),commandMap[i].name + 1,commandMap[i].description);

	PrintFormat(TEXT("* %d total command(s)\r\n"),i);

	return TRUE;
}
예제 #11
0
BOOL CRenoCommandFrame::ExecuteCommand(const CString& command)
{
	CStringPtrArray commandElements;

	// Split the command into arguments
	SplitCommand(command,commandElements);

	// Check if null command passed in
	if(!commandElements.GetCount())
		return FALSE;

	// Get our command map
	const RENO_COMMAND* commandMap = GetCommandMap();
	ASSERT(commandMap);

	// Find the command that was called
	for(ULONG i = 0; commandMap[i].name && commandMap[i].function; ++i)
		if(!lstrcmpi(commandMap[i].name,commandElements[0]))
			return (this->*commandMap[i].function)(commandElements);	// TODO Maybe just always return TRUE since the passed in command name was valid

	// Unknown command
	PrintFormat(TEXT("* Unknown command: %s\r\n"),commandElements[0]);

	return FALSE;
}
예제 #12
0
파일: RenoCommand.cpp 프로젝트: m1h4/Reno
BOOL CRenoCommandFrame::CmdTime(const CStringPtrArray& commandElements)
{
	// Maybe we are not connected
	if(m_State < RENO_NETWORK_CONNECTED)
	{
		PrintFormat(TEXT("* Error: Not connected\r\n"));
		return FALSE;
	}

	if(commandElements.GetCount() != 1)
	{
		PrintFormat(TEXT("* Usage: %s\r\n"),commandElements[0]);
		return FALSE;
	}

	return SendFormat(TEXT("TIME\r\n"));
}
예제 #13
0
파일: RenoCommand.cpp 프로젝트: m1h4/Reno
BOOL CRenoCommandFrame::CmdUser(const CStringPtrArray& commandElements)
{
	// Maybe we are not connected
	if(m_State < RENO_NETWORK_CONNECTED)
	{
		PrintFormat(TEXT("* Error: Not connected\r\n"));
		return FALSE;
	}

	if(commandElements.GetCount() != 4)
	{
		PrintFormat(TEXT("* Usage: %s <user> <mode> <realname>\r\n"),commandElements[0]);
		return FALSE;
	}

	return SendFormat(TEXT("USER %s %s * :%s\r\n"),commandElements[1],commandElements[2],commandElements[3]);
}
예제 #14
0
파일: RenoCommand.cpp 프로젝트: m1h4/Reno
BOOL CRenoCommandFrame::CmdHosts(const CStringPtrArray& commandElements)
{
	PrintFormat(TEXT("* Host list:\r\n"));

	for(LONG i = 0; i < theApp.GetServerList().GetCount(); ++i)
	{
		LONG index = theApp.GetServerList()[i].Find(TEXT('|'));
		if(index != -1)
			PrintFormat(TEXT("*   %s [%s]\r\n"),theApp.GetServerList()[i].Left(index),theApp.GetServerList()[i].GetBuffer() + index + 1);
		else
			PrintFormat(TEXT("*   %s\r\n"),theApp.GetServerList()[i]);
	}

	PrintFormat(TEXT("* %d host(s)\r\n"),theApp.GetServerList().GetCount());

	return TRUE;
}
예제 #15
0
파일: RenoCommand.cpp 프로젝트: m1h4/Reno
BOOL CRenoCommandFrame::ReplyMode(const CString& prefix,const CString& command,const CStringPtrArray& parameters)
{
	// http://webtoman.com/opera/panel/ircdmodes.html

	PrintFormat(TEXT("[Reno|Info] Mode set to %s for user %s\r\n"),parameters[1],parameters[0]);

	return TRUE;
}
예제 #16
0
/* Open the mixer with a certain desired audio format */
int Mix_OpenAudio(int frequency, Uint16 format, int nchannels, int chunksize)
{
	int i;
	SDL_AudioSpec desired;

	/* If the mixer is already opened, increment open count */
	if ( audio_opened ) {
	    ++audio_opened;
	    return(0);
	}

	/* Set the desired format and frequency */
	desired.freq = frequency;
	desired.format = format;
	desired.channels = nchannels;
	desired.samples = chunksize;
	desired.callback = mix_channels;
	desired.userdata = NULL;

	/* Accept nearly any audio format */
	if ( SDL_OpenAudio(&desired, &mixer) < 0 ) {
		return(-1);
	}
#if 0
	PrintFormat("Audio device", &mixer);
#endif

	/* Initialize the music players */
	if ( open_music(&mixer) < 0 ) {
		SDL_CloseAudio();
		return(-1);
	}

	num_channels = MIX_CHANNELS;
	mix_channel = (struct _Mix_Channel *) malloc(num_channels * sizeof(struct _Mix_Channel));

	/* Clear out the audio channels */
	for ( i=0; i<num_channels; ++i ) {
		mix_channel[i].chunk = NULL;
		mix_channel[i].playing = 0;
		mix_channel[i].looping = 0;
		mix_channel[i].volume = SDL_MIX_MAXVOLUME;
		mix_channel[i].fade_volume = SDL_MIX_MAXVOLUME;
		mix_channel[i].fading = MIX_NO_FADING;
		mix_channel[i].tag = -1;
		mix_channel[i].expire = 0;
		mix_channel[i].effects = NULL;
		mix_channel[i].paused = 0;
	}
	Mix_VolumeMusic(SDL_MIX_MAXVOLUME);

	_Mix_InitEffects();

	audio_opened = 1;
	SDL_PauseAudio(0);
	return(0);
}
예제 #17
0
파일: RenoCommand.cpp 프로젝트: m1h4/Reno
BOOL CRenoCommandFrame::ReplyTime(const CString& prefix,const CString& command,const CStringPtrArray& parameters)
{
	switch(parameters.GetCount())
	{
	case 3:
		PrintFormat(TEXT("[%s|Time] %s\r\n"),parameters[1],parameters[2]);
		break;

	case 2:
		PrintFormat(TEXT("[Reno|Time] %s\r\n"),parameters[1]);
		break;

	default:
		PrintFormat(TEXT("[Reno|Time] Error: Reply in invalid format ('%s' '%s' '%d')\r\n"),prefix,command,parameters.GetCount());
		break;
	}

	return TRUE;
}
예제 #18
0
파일: RenoCommand.cpp 프로젝트: m1h4/Reno
BOOL CRenoCommandFrame::CmdNames(const CStringPtrArray& commandElements)
{
	// Maybe we are not connected
	if(m_State < RENO_NETWORK_CONNECTED)
	{
		PrintFormat(TEXT("* Error: Not connected\r\n"));
		return FALSE;
	}

	if(commandElements.GetCount() != 1 && commandElements.GetCount() != 2)
	{
		PrintFormat(TEXT("* Usage: %s [channel]\r\n"),commandElements[0]);
		return FALSE;
	}

	if(commandElements.GetCount() == 1)
		return SendFormat(TEXT("NAMES\r\n"));

	return SendFormat(TEXT("NAMES %s\r\n"),commandElements[1]);
}
예제 #19
0
파일: RenoCommand.cpp 프로젝트: m1h4/Reno
BOOL CRenoCommandFrame::ReplyPing(const CString& prefix,const CString& command,const CStringPtrArray& parameters)
{
	if(parameters.GetCount())
		SendFormat(TEXT("PONG :%s\r\n"),parameters[0]);
	else
		SendFormat(TEXT("PONG\r\n"));

	PrintFormat(TEXT("* Pong!\r\n"));

	return TRUE;
}
예제 #20
0
파일: RenoCommand.cpp 프로젝트: m1h4/Reno
BOOL CRenoCommandFrame::ReplyNull(const CString& prefix,const CString& command,const CStringPtrArray& parameters)
{
	CString message = TEXT("'") + prefix + TEXT("' '") + command + TEXT("'");

	for(LONG i = 0; i < parameters.GetCount(); ++i)
		message += TEXT(" '") + parameters[i] + TEXT("'");

	PrintFormat(TEXT("%s\r\n"),message);

	return TRUE;
}
예제 #21
0
파일: RenoCommand.cpp 프로젝트: m1h4/Reno
BOOL CRenoCommandFrame::CmdExit(const CStringPtrArray& commandElements)
{
	if(commandElements.GetCount() != 1)
	{
		PrintFormat(TEXT("* Usage: %s\r\n"),commandElements[0]);
		return FALSE;
	}

	AfxGetMainWnd()->PostMessage(WM_CLOSE);

	return TRUE;
}
예제 #22
0
파일: RenoCommand.cpp 프로젝트: m1h4/Reno
BOOL CRenoCommandFrame::CmdClear(const CStringPtrArray& commandElements)
{
	if(commandElements.GetCount() != 1)
	{
		PrintFormat(TEXT("* Usage: %s\r\n"),commandElements[0]);
		return FALSE;
	}

	Clear();

	return TRUE;
}
예제 #23
0
파일: RenoCommand.cpp 프로젝트: m1h4/Reno
BOOL CRenoCommandFrame::CmdStatus(const CStringPtrArray& commandElements)
{
	switch(m_State)
	{
	case RENO_NETWORK_DISCONNECTED:
		PrintFormat(TEXT("* Not connected\r\n"));
		break;

	case RENO_NETWORK_CONNECTING:
		PrintFormat(TEXT("* Connecting\r\n"));
		break;

	case RENO_NETWORK_CONNECTED:
		PrintFormat(TEXT("* Connected\r\n"));
		break;

	case RENO_NETWORK_RESOLVING:
		PrintFormat(TEXT("* Resolving host address\r\n"));
		break;

	case RENO_NETWORK_DISCONNECTING:
		PrintFormat(TEXT("* Disconnecting\r\n"));
		break;

	default:
		PrintFormat(TEXT("* Unknown state\r\n"));
		AfxDebugBreak();
		break;
	}

	return TRUE;
}
예제 #24
0
void UpdateNintendont(void) {
	int selected = 0;
	u64 delay = ticks_to_millisecs(gettime()) + 500;
	while(true) {
		ClearScreen();
		PrintInfo();
		PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X + 50, MENU_POS_Y + 20*5, "Download Nintendont");
		PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X + 50, MENU_POS_Y + 20*6, "Download titles.txt");
		PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X + 50, MENU_POS_Y + 20*7, "Download controllers.zip");
		PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X + 50, MENU_POS_Y + 20*8, "Return to Settings");
		PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X + 35, MENU_POS_Y + 20*(5+selected), ARROW_RIGHT);
		GRRLIB_Render();
		FPAD_Update();
		if (delay > ticks_to_millisecs(gettime())) continue;
		if (FPAD_Start(1)) {
			ShowMessageScreenAndExit("Returning to loader...", 0);
		}
		if (FPAD_OK(1)) {
			if (selected <= DOWNLOAD_CONTROLLERS)
				Download(selected);
			else
				break;
		}
		if (FPAD_Down(1)) {
			delay = ticks_to_millisecs(gettime()) + 150;
			selected++;
			if (selected > 3) selected = 0;
		}
		if (FPAD_Up(1)) {
			delay = ticks_to_millisecs(gettime()) + 150;
			selected--;
			if (selected < 0) selected = 3;
		}
		if (FPAD_Cancel(1)) {
			break;
		}
	}
	ClearScreen();
	return;
}
예제 #25
0
파일: RenoCommand.cpp 프로젝트: m1h4/Reno
BOOL CRenoCommandFrame::CmdRemove(const CStringPtrArray& commandElements)
{
	if(commandElements.GetCount() != 3)
	{
		PrintFormat(TEXT("* Usage: %s <'nick'|'host'> <address|host_label|nick>\r\n"),commandElements[0]);
		return FALSE;
	}

	if(!_wcsicmp(commandElements[1],TEXT("nick")))
	{
		for(LONG i = 0; i < theApp.GetNickList().GetCount(); ++i)
		{
			if(!_wcsicmp(commandElements[2],theApp.GetNickList()[i]))
			{
				theApp.GetNickList().RemoveAt(i);
				PrintFormat(TEXT("* Removed nick\r\n"));
				return TRUE;
			}
		}

		PrintFormat(TEXT("* Nick with the specified name does not exist\r\n"));
		return FALSE;
	}
	else if(!_wcsicmp(commandElements[1],TEXT("host")))
	{
		for(LONG i = 0; i < theApp.GetServerList().GetCount(); ++i)
		{
			LONG index = theApp.GetServerList()[i].Find(TEXT('|'));
			if(index != -1)
			{
				if(!_wcsicmp(commandElements[2],theApp.GetServerList()[i].Left(index)) || !_wcsicmp(commandElements[2],theApp.GetServerList()[i].GetBuffer() + index + 1))
				{
					theApp.GetServerList().RemoveAt(i);
					PrintFormat(TEXT("* Removed host\r\n"));
					return TRUE;
				}
			}
			else
			{
				if(!_wcsicmp(commandElements[2],theApp.GetServerList()[i]))
				{
					theApp.GetServerList().RemoveAt(i);
					PrintFormat(TEXT("* Removed host\r\n"));
					return TRUE;
				}
			}
		}

		PrintFormat(TEXT("* Host with the specified name/label does not exist\r\n"));
		return FALSE;
	}
	
	PrintFormat(TEXT("* Error: Unknown type: %s\r\n"),commandElements[1]);
	return FALSE;
}
예제 #26
0
파일: RenoCommand.cpp 프로젝트: m1h4/Reno
BOOL CRenoCommandFrame::ReplyPrivate(const CString& prefix,const CString& command,const CStringPtrArray& parameters)
{
	CString nick;

	if(prefix.GetLength())
	{
		LONG seperator = prefix.Find(TEXT('!'));
		if(seperator == -1)
			nick = prefix;
		else
			nick = prefix.Left(seperator);
	}

	if(!nick.GetLength())
		nick = TEXT("????");

	LPCTSTR ctcpAction = TEXT("\001ACTION ");
	LPCTSTR ctcpVersion = TEXT("\001VERSION\001");
	LPCTSTR ctcpPing = TEXT("\001PING\001");

	if(!_wcsnicmp(parameters[1],ctcpAction,wcslen(ctcpAction)))
	{
		PrintFormat(TEXT("* %s %s\r\n"),nick,parameters[1].Mid(wcslen(ctcpAction),parameters[1].Find(TEXT("\001"),wcslen(ctcpAction)) - wcslen(ctcpAction)));
	}
	else if(!_wcsnicmp(parameters[1],ctcpVersion,wcslen(ctcpVersion)))
	{
		SendFormat(TEXT("NOTICE %s :\001VERSION Reno:0.1:Marko Mihovilic\001\r\n"),nick);
		PrintFormat(TEXT("* Sent version CTCP reply\r\n"));
	}
	else if(!_wcsnicmp(parameters[1],ctcpPing,wcslen(ctcpPing)))
	{
		SendFormat(TEXT("NOTICE %s :\001PONG\001\r\n"),nick);
		PrintFormat(TEXT("* Sent pong CTCP reply\r\n"));
	}
	else
		PrintFormat(TEXT("[%s|%s] %s\r\n"),parameters[0],nick,parameters[1]);

	return TRUE;
}
예제 #27
0
파일: RenoCommand.cpp 프로젝트: m1h4/Reno
BOOL CRenoCommandFrame::ReplyTopicChange(const CString& prefix,const CString& command,const CStringPtrArray& parameters)
{
	CString nick;

	if(prefix.GetLength())
	{
		LONG seperator = prefix.Find(TEXT('!'));
		if(seperator == -1)
			nick = prefix;
		else
			nick = prefix.Left(seperator);
	}

	if(!nick.GetLength())
		nick = TEXT("????");
	
	if(parameters.GetCount() == 2)
		PrintFormat(TEXT("[%s|Info] User %s changed topic to '%s'\r\n"),parameters[0],nick,parameters[1]);
	else
		PrintFormat(TEXT("[Reno|Topic] Error: Reply in invalid format ('%s' '%s' '%d')\r\n"),prefix,command,parameters.GetCount());

	return TRUE;
}
예제 #28
0
파일: RenoCommand.cpp 프로젝트: m1h4/Reno
BOOL CRenoCommandFrame::ReplyQuit(const CString& prefix,const CString& command,const CStringPtrArray& parameters)
{
	CString nick;

	if(prefix.GetLength())
	{
		LONG seperator = prefix.Find(TEXT('!'));
		if(seperator == -1)
			nick = prefix;
		else
			nick = prefix.Left(seperator);
	}

	if(!nick.GetLength())
		nick = TEXT("????");
	
	if(parameters.GetCount() == 1 && parameters[0].GetLength())
		PrintFormat(TEXT("[Reno|Info] User %s has quit IRC (%s)\r\n"),nick,parameters[0]);
	else
		PrintFormat(TEXT("[Reno|Info] User %s has quit IRC\r\n"),nick);

	return TRUE;
}
예제 #29
0
파일: RenoCommand.cpp 프로젝트: m1h4/Reno
BOOL CRenoCommandFrame::CmdMsg(const CStringPtrArray& commandElements)
{
	// Maybe we are not connected
	if(m_State < RENO_NETWORK_CONNECTED)
	{
		PrintFormat(TEXT("* Error: Not connected\r\n"));
		return FALSE;
	}

	if(commandElements.GetCount() < 2)
	{
		PrintFormat(TEXT("* Usage: %s <command> [parameters]...\r\n"),commandElements[0]);
		return FALSE;
	}

	CString cmd;

	for(LONG i = 1; i < commandElements.GetCount(); ++i)
		cmd += commandElements[i] + ((i < commandElements.GetCount() - 1) ? TEXT(" ") : TEXT(""));

	cmd += TEXT("\r\n");

	return Send(cmd,cmd.GetLength());
}
예제 #30
0
VOID CRenoCommandFrame::OnResolved(INT nErrorCode,LPADDRINFO info)
{
	if(nErrorCode || !info)
	{
		switch(nErrorCode)
		{
		case NULL:
			PrintFormat(TEXT("* Failed to resolve name\r\n"));
			break;

		case WSATRY_AGAIN:
			PrintFormat(TEXT("* Failed to resolve name. Temporary error occurred during host name resolution\r\n"));
			break;

		case WSANO_RECOVERY:
			PrintFormat(TEXT("* Failed to resolve name. Non-recoverable error occurred during database lookup\r\n"));
			break;

		case WSAHOST_NOT_FOUND:
			PrintFormat(TEXT("* Failed to resolve name. The specified name could not be found in the database\r\n"));
			break;

		case WSATYPE_NOT_FOUND:
			PrintFormat(TEXT("* Failed to resolve name. The specified class could not be found in the database\r\n"));
			break;

		default:
			PrintFormat(TEXT("* Failed to resolve name. Resolution error %d\r\n"),nErrorCode);
			break;
		}

		CRenoSocketWnd::OnResolved(nErrorCode,NULL);
	}
	else
	{
		// Tell the user the resolved address that we are connecting to
		TCHAR address[NI_MAXHOST];
		AddressToString(info->ai_addr,info->ai_addrlen,address,sizeof(address)/sizeof(TCHAR));
		PrintFormat(TEXT("* Connecting to %s\r\n"),address);

		// This will actualy call connect
		CRenoSocketWnd::OnResolved(nErrorCode,info);
	}
}