Exemplo n.º 1
0
/**
 * \internal Funkcja zwrotna połączenia bezpośredniego.
 *
 * Pole \c callback struktury \c gg_dcc zawiera wskaźnik do tej funkcji.
 * Wywołuje ona \c gg_dcc_watch_fd() i zachowuje wynik w polu \c event.
 *
 * \note Funkcjonalność funkcji zwrotnej nie jest już wspierana.
 *
 * \param d Struktura połączenia
 *
 * \return 0 jeśli się powiodło, -1 w przypadku błędu
 */
static int gg_dcc_callback(struct gg_dcc *d)
{
	struct gg_event *e = gg_dcc_watch_fd(d);

	d->event = e;

	return (e != NULL) ? 0 : -1;
}
Exemplo n.º 2
0
void
GaduDCCServer::watcher() {

	gg_event* dccEvent;
	bool handled = false;

	disableNotifiers();

	dccEvent = gg_dcc_watch_fd( dccSock );
	if ( ! dccEvent ) {
		// connection is f****d
		// we should try to reenable it
//		closeDCC();
		return;
	}
	switch ( dccEvent->type ) {
		case GG_EVENT_NONE:
			break;
		case GG_EVENT_DCC_ERROR:
			kdDebug( 14100 ) << " dcc error occured " << endl;
			break;
		case GG_EVENT_DCC_NEW:
			// I do expect reciver to set this boolean to true if he handled signal
			// if so, no other reciver should be bothered with it, and I shall not close it
			// otherwise connection is closed as not handled
			emit incoming( dccEvent->event.dcc_new, handled );
			if ( !handled ) {
				if ( dccEvent->event.dcc_new->file_fd > 0) {
					close( dccEvent->event.dcc_new->file_fd );
				}
				gg_dcc_free( dccEvent->event.dcc_new );
			}
			break;
		default:
			kdDebug(14100) << "unknown/unhandled DCC EVENT: " << dccEvent->type << endl;
			break;
	}

	if ( dccEvent ) {
		gg_free_event( dccEvent );
	}

	enableNotifiers( dccSock->check );
}