示例#1
0
TaskManager::TaskManager(MainWindow *window, ContentLoader *loader, QObject *parent) :
    QObject(parent)
{
    QSettings settings;
    QString work_dir = settings.value("work_dir", "/tmp/").toString();
    this->current_directory = new QDir(work_dir);

    this->updatePlaylist();
    this->current_played_time = QTime::currentTime();
    this->current_text_index = this->current_video_index = 0;
    this->main_window = window;
    this->content_loader = loader;

    this->image_finish_timer = new QTimer();
    connect(this->image_finish_timer, SIGNAL(timeout()), this, SLOT(video_finished()));
    this->text_finish_timer = new QTimer();
    connect(this->text_finish_timer, SIGNAL(timeout()), this, SLOT(text_finished()));

    connect(this->main_window, SIGNAL(video_finished()), this, SLOT(video_finished()));

    this->update_timer = new QTimer();
    connect(this->update_timer, SIGNAL(timeout()), this, SLOT(update()));
    this->update_timer->start(1000);

    this->load_bus_timer = new QTimer();
    connect(this->load_bus_timer, SIGNAL(timeout()), this, SLOT(load_bus()));
    this->load_bus_timer->start(5 * 1000);
    this->load_bus();

    this->load_news_timer = new QTimer();
    connect(this->load_news_timer, SIGNAL(timeout()), this, SLOT(load_news()));
    this->load_news_timer->start(60 * 1000);
    this->news_index = -1;
    this->load_news();

    QTimer::singleShot(1000, this, SLOT(getCurrentTasks()));
}
示例#2
0
void do_news( CHAR_DATA *ch, char *argument )
{
    char                    arg1[MAX_NEWS_LENGTH],
                            buf[MIL],
                            arg2[MAX_NEWS_LENGTH];

    if ( IS_NPC( ch ) )
        return;

    if ( argument && argument[0] == '\0' ) {
        send_to_char( "\r\nuso: noticias [<opción>]\r\n", ch );
        send_to_char( "Opción puede ser: version, todas, ultima [<#>], primera [<#>], [#]\r\n", ch );
        if ( IS_IMMORTAL( ch ) ) {
            send_to_char( "\r\nUso: noticias [<campo>]\r\n", ch );
            send_to_char( "Campo puede ser: agregar, cargar, editar, eliminar\r\n", ch );
            send_to_char( "  <fecha>, lista\r\n", ch );
            return;
        }
        return;
    }

    if ( argument && argument[0] != '\0' ) {
        argument = one_argument( argument, arg1 );
        if ( !str_cmp( arg1, "version" ) ) {
            ch_printf_color( ch, "&cT&Che &cE&Clder &cC&Chronicles &cV&Cersion&c: &W%s&c.\r\n",
                             NEWS_VERSION );
            return;
        }
        else if ( is_number( arg1 ) ) {
            show_news( ch, TYPE_SHOW_ONE, atoi( arg1 ) );
            return;
        }
        else if ( !str_cmp( arg1, "todas" ) ) {
            show_news( ch, TYPE_ALL, -1 );
            send_to_char( "\r\nPara más detalles teclea 'ayuda noticias'\r\n", ch );
            return;
        }
        else if ( !str_cmp( arg1, "primera" ) ) {
            int                     show_count = -1;

            argument = one_argument( argument, arg2 );
            if ( !arg2 || arg2[0] == '\0' ) {
                show_count = -1;
            }
            else {
                if ( is_number( arg2 ) )
                    show_count = atoi( arg2 );
                else
                    show_count = -1;
            }
            show_news( ch, TYPE_LIST_FIRST, show_count );
        }
        else if ( !str_cmp( arg1, "ultima" ) ) {
            int                     show_count = -1;

            argument = one_argument( argument, arg2 );
            if ( !arg2 || arg2[0] == '\0' ) {
                show_count = 5;
            }
            else {
                if ( is_number( arg2 ) )
                    show_count = atoi( arg2 );
                else
                    show_count = -1;
            }

            show_news( ch, TYPE_LIST_LAST, show_count );
            send_to_char( "\r\nPara más detalles teclea 'ayuda noticias'\r\n", ch );
            return;
        }
        else if ( !IS_IMMORTAL( ch ) ) {
            show_news( ch, TYPE_NORMAL, -1 );
            return;
        }
        else if ( !str_cmp( arg1, "html" ) ) {
            if ( !argument || argument[0] == '\0' ) {
                ch_printf_color( ch, "&C&Gel sistema de noticias en HTML está &C&W%s&C&G.\r\n",
                                 USE_HTML_NEWS == TRUE ? "activado" : "desactivado" );
                return;
            }
            else if ( !str_cmp( argument, "cambiar" ) || !str_cmp( argument, "activar" )
                      || !str_cmp( argument, "desactivar" ) ) {
                if ( !str_cmp( argument, "cambiar" ) )
                    USE_HTML_NEWS = !USE_HTML_NEWS;
                else if ( !str_cmp( argument, "activar" ) )
                    USE_HTML_NEWS = TRUE;
                else
                    USE_HTML_NEWS = FALSE;

                do_news( ch, ( char * ) "html" );
                write_news(  );
                if ( USE_HTML_NEWS == TRUE )
                    generate_html_news(  );
                return;
            }
            else {
                do_news( ch, ( char * ) "html" );
                do_help( ch, ( char * ) "noticias" );
                return;
            }
        }
        else if ( !str_cmp( arg1, "agregar" ) && ( argument && argument[0] != '\0' ) ) {
            add_news( argument );
            send_to_char_color( "&C&GNoticia añadida.\r\n", ch );
            /*
             * Send the message about a note being posted to the mud 
             */
            snprintf( buf, MIL, "¡Hay una nueva noticia por %s!", ch->name );
            announce( buf );

        }
        else if ( !str_cmp( arg1, "cargar" ) ) {
            clear_news( FALSE, 0 );
            load_news(  );
            if ( USE_HTML_NEWS == TRUE )
                generate_html_news(  );
            send_to_char_color( "&C&GNoticias cargadas.\r\n", ch );
        }
        else if ( !str_cmp( arg1, "lista" ) ) {
            show_news( ch, TYPE_IMM_LIST, -1 );
        }
        else if ( !str_cmp( arg1, "eliminar" ) && ( argument && argument[0] != '\0' ) ) {
            bool                    clearAll = FALSE;

            if ( !str_cmp( argument, "todas" ) ) {
                clearAll = TRUE;
            }
            if ( !clearAll && !is_number( argument ) ) {
                send_to_char_color( "El argumento debe ser un número de noticia o todas.\r\n", ch );
                return;
            }
            if ( clearAll != TRUE )
                clear_news( TRUE, atoi( argument ) );
            else
                clear_news( FALSE, 0 );
            write_news(  );
            if ( USE_HTML_NEWS == TRUE )
                generate_html_news(  );
            send_to_char_color( "&C&GNoticias eliminadas.\r\n", ch );
        }
        else {
            do_help( ch, ( char * ) "noticias" );
            return;
        }
    }
    else {
        show_news( ch, TYPE_NORMAL, -1 );
    }
}
示例#3
0
int init(int ac, char **av)
{
    int i;
    int openlog_failed = 0, openlog_errno = 0;
    int started_from_term = isatty(0) && isatty(1) && isatty(2);

    /* Imported from main.c */
    extern void sighandler(int signum);


    /* Set file creation mask and group ID. */
#if defined(DEFUMASK) && HAVE_UMASK
    umask(DEFUMASK);
#endif
    if (set_group() < 0)
	return -1;
    
    /* Parse command line for -dir option. */
    parse_dir_options(ac, av);

    /* Chdir to Services data directory. */
    if (chdir(services_dir) < 0) {
	fprintf(stderr, "chdir(%s): %s\n", services_dir, strerror(errno));
	return -1;
    }

    /* Open logfile, and complain if we didn't. */
    if (open_log() < 0) {
	openlog_errno = errno;
	if (started_from_term) {
	    fprintf(stderr, "ATENCION: No puedo abrir el archivo de log %s: %s\n",
			log_filename, strerror(errno));
	} else {
	    openlog_failed = 1;
	}
    }

    /* Read configuration file; exit if there are problems. */
    if (!read_config())
	return -1;

    /* Parse all remaining command-line options. */
    parse_options(ac, av);

    /* Detach ourselves if requested. */
    if (!nofork) {
	if ((i = fork()) < 0) {
	    perror("fork()");
	    return -1;
	} else if (i != 0) {
	    exit(0);
	}
	if (started_from_term) {
	    close(0);
	    close(1);
	    close(2);
	}
	if (setpgid(0, 0) < 0) {
	    perror("setpgid()");
	    return -1;
	}
    }

    /* Write our PID to the PID file. */
    write_pidfile();

    /* Announce ourselves to the logfile. */
    if (debug || readonly || skeleton) {
	log("euskalirc-services-bdd %s (compilados para %s) iniciados (opciones:%s%s%s)",
		version_number, version_protocol,
		debug ? " debug" : "", readonly ? " readonly" : "",
		skeleton ? " skeleton" : "");
    } else {
	log("euskalirc-services-bdd %s (compilados para %s) iniciados.",
		version_number, version_protocol);
    }
    start_time = time(NULL);

    /* If in read-only mode, close the logfile again. */
    if (readonly)
	close_log();

    /* Set signal handlers.  Catch certain signals to let us do things or
     * panic as necessary, and ignore all others.
     */
#ifdef NSIG
    for (i = 1; i <= NSIG; i++)
#else
    for (i = 1; i <= 32; i++)
#endif
	signal(i, SIG_IGN);

    signal(SIGINT, sighandler);
    signal(SIGTERM, sighandler);
    signal(SIGQUIT, sighandler);
    signal(SIGSEGV, sighandler);
    signal(SIGBUS, sighandler);
    signal(SIGQUIT, sighandler);
    signal(SIGHUP, sighandler);
    signal(SIGILL, sighandler);
    signal(SIGTRAP, sighandler);
#ifdef SIGIOT
    signal(SIGIOT, sighandler);
#endif
    signal(SIGFPE, sighandler);

    signal(SIGUSR1, sighandler);  /* This is our "out-of-memory" panic switch */

    /* Initialize multi-language support */
    lang_init();
    if (debug)
	log("debug: Cargando lenguajes");

    /* Initialiize subservices */
    ns_init();
    cs_init();
#ifdef CREGSERV
    cr_init();
#endif    
    ms_init();
    os_init();
    load_spam();
    load_ipv();   /*leyendo datos de frases*/
    /* Load up databases */
    if (!skeleton) {
	load_ns_dbase();
	if (debug)
	    log("debug: Cargando la DB de %s (1/7)", s_NickServ);
	load_cs_dbase();
	if (debug)
	    log("debug: Cargando la DB de %s (2/7)", s_ChanServ);
	    load_cr_dbase();
	if (debug)
	    log("debug: Cargando la DB de %s (3/7)", s_CregServ);
    }
	
    load_os_dbase();
    if (debug)
	log("debug: Cargando la DB de %s (4/7)", s_OperServ);
    load_akill();
    if (debug)
	log("debug: Cargando la DB de GLINES (5/7)");
    load_news();
    if (debug)
	log("debug: Cargando la DB de NOTICIAS (6/7)");
   
    if (debug)
	log("debug: Cargando la DB de SPAM (7/7)");
    load_cr_dbase();
    load_ipv();
    log("Cargadas las bases de datos");

    /* Connect to the remote server */
    servsock = conn(RemoteServer, RemotePort, LocalHost, LocalPort);
    if (servsock < 0)
	fatal_perror("No puedo conectar al servidor");
    send_cmd(NULL, "PASS :%s", RemotePassword);
#ifdef IRC_UNDERNET_P09
    send_cmd(NULL, "SERVER %s 1 %lu %lu P09 :%s",
             ServerName, start_time, start_time, ServerDesc);
#else /* IRC_UNDERNET_P10 */
    send_cmd(NULL, "SERVER %s %d 0 %ld J10 %cD] :%s",
             ServerName, 2, start_time, convert2y[ServerNumerico], ServerDesc); 
#endif
    sgets2(inbuf, sizeof(inbuf), servsock);
    if (strnicmp(inbuf, "ERROR", 5) == 0) {
	/* Close server socket first to stop wallops, since the other
	 * server doesn't want to listen to us anyway */
	disconn(servsock);
	servsock = -1;
	fatal("El servidor ha devuelto: %s", inbuf);
    }


    /* Announce a logfile error if there was one */
    if (openlog_failed) {
	canalopers(NULL, "4ATENCION: No puedo abrir el fichero de log: 12%s",
		strerror(openlog_errno));
    }

    /* Bring in our pseudo-clients */
    introduce_user(NULL);

    send_cmd(ServerName, "SETTIME %lu", time(NULL));
#if HAVE_ALLWILD_NOTICE
    send_cmd(s_OperServ, "NOTICE $*.%s :Establecidos los servicios de la RED.", NETWORK_DOMAIN);
    
#else
# ifdef NETWORK_DOMAIN
    send_cmd(s_OperServ, "NOTICE $*.%s :Establecidos los servicios de la RED.", NETWORK_DOMAIN);
# else
     Go through all common top-level domains.  If you have others,
     * add them here.
     
    send_cmd(s_OperServ, "NOTICE $*.es :Establecidos los servicios de la RED.");
    send_cmd(s_OperServ, "NOTICE $*.com :Establecidos los servicios de la RED.");
    send_cmd(s_OperServ, "NOTICE $*.net :Establecidos los servicios de la RED.");
    send_cmd(s_OperServ, "NOTICE $*.org :Establecidos los servicios de la RED.");    
    send_cmd(s_OperServ, "NOTICE $*.edu :Establecidos los servicios de la RED.");
    send_cmd(s_OperServ, "NOTICE $*.tk :Establecidos los servicios de la RED.");
# endif
#endif
        
    join_chanserv();
      

    /* Success! */
    return 0;
}