Annotation of sbbs/src/sbbs3/gtkmonitor/events.c, revision 1.1

1.1     ! root        1: #include <sys/types.h>
        !             2: #include <sys/uio.h>
        !             3: #include <fcntl.h>
        !             4: #include <string.h>
        !             5: #include <utime.h>
        !             6: #include <unistd.h>
        !             7: 
        !             8: #include "gtkmonitor.h"
        !             9: #include "util_funcs.h"
        !            10: #include "datewrap.h"
        !            11: 
        !            12: int got_date=0;
        !            13: 
        !            14: void destroy_calendar_window(GtkWidget *t, gpointer data)
        !            15: {
        !            16:        if(!got_date)
        !            17:                gtk_main_quit();
        !            18: }
        !            19: 
        !            20: void changed_day(GtkWidget *t, gpointer data)
        !            21: {
        !            22:        got_date=1;
        !            23:        gtk_main_quit();
        !            24: }
        !            25: 
        !            26: int get_date(GtkWidget *t, isoDate_t *date)
        !            27: {
        !            28:        GladeXML        *cxml;
        !            29:        GtkWidget       *w;
        !            30:        GtkWidget       *win;
        !            31:        GtkWidget       *thiswin;
        !            32:        gint            x,x_off;
        !            33:        gint            y,y_off;
        !            34:        guint           year;
        !            35:        guint           month;
        !            36:        guint           day;
        !            37:        isoDate_t       odate=*date;
        !            38: 
        !            39:        got_date=0;
        !            40:     cxml = glade_xml_new(glade_path, "CalendarWindow", NULL);
        !            41:        if(cxml==NULL) {
        !            42:                fprintf(stderr,"Could not locate Calendar Window XML\n");
        !            43:                return(-1);
        !            44:        }
        !            45:     /* connect the signals in the interface */
        !            46:     glade_xml_signal_autoconnect(cxml);
        !            47:        win=glade_xml_get_widget(cxml, "CalendarWindow");
        !            48:        if(win==NULL) {
        !            49:                fprintf(stderr,"Could not locate Calendar window\n");
        !            50:                return(-1);
        !            51:        }
        !            52: 
        !            53:        thiswin = gtk_widget_get_toplevel(t);
        !            54:        if(thiswin==NULL) {
        !            55:                fprintf(stderr,"Could not locate main window\n");
        !            56:                return(-1);
        !            57:        }
        !            58:        if(!(gtk_widget_translate_coordinates(GTK_WIDGET(t)
        !            59:                        ,GTK_WIDGET(thiswin), 0, 0, &x_off, &y_off))) {
        !            60:                fprintf(stderr,"Could not get position of button in window");
        !            61:        }
        !            62:        gtk_window_get_position(GTK_WINDOW(thiswin), &x, &y);
        !            63: 
        !            64:        gtk_window_move(GTK_WINDOW(win), x+x_off, y+y_off);
        !            65: 
        !            66:        w=glade_xml_get_widget(cxml, "Calendar");
        !            67:        if(w==NULL) {
        !            68:                fprintf(stderr,"Could not locate Calendar widget\n");
        !            69:                return(-1);
        !            70:        }
        !            71:        gtk_calendar_select_month(GTK_CALENDAR(w), isoDate_month(*date)-1, isoDate_year(*date));
        !            72:        gtk_calendar_select_day(GTK_CALENDAR(w), isoDate_day(*date));
        !            73:        gtk_window_present(GTK_WINDOW(win));
        !            74:        /* Wait for window to close... */
        !            75:        gtk_main();
        !            76:        w=glade_xml_get_widget(cxml, "Calendar");
        !            77:        if(w==NULL)
        !            78:                return(-1);
        !            79:        gtk_calendar_get_date(GTK_CALENDAR(w), &year, &month, &day);
        !            80:        gtk_widget_destroy(GTK_WIDGET(gtk_widget_get_toplevel(GTK_WIDGET(w))));
        !            81:        *date=isoDate_create(year, month+1, day);
        !            82:        return(odate!=*date);
        !            83: }
        !            84: 
        !            85: void update_stats_callback(GtkWidget *wiggy, gpointer data)
        !            86: {
        !            87:        refresh_data(NULL);
        !            88: }
        !            89: 
        !            90: void on_guru_brain1_activate(GtkWidget *wiggy, gpointer data) {
        !            91:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"guru.dat");
        !            92: }
        !            93: 
        !            94: void on_text_strings1_activate(GtkWidget *wiggy, gpointer data) {
        !            95:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"text.dat");
        !            96: }
        !            97: 
        !            98: void on_default_colours1_activate(GtkWidget *wiggy, gpointer data) {
        !            99:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"attr.cfg");
        !           100: }
        !           101: 
        !           102: void on_nodes_full_message1_activate(GtkWidget *wiggy, gpointer data) {
        !           103:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"nonodes.txt");
        !           104: }
        !           105: 
        !           106: void on_answer_screen1_activate(GtkWidget *wiggy, gpointer data) {
        !           107:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"answer.asc");
        !           108: }
        !           109: 
        !           110: void on_logon_message1_activate(GtkWidget *wiggy, gpointer data) {
        !           111:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"menu/logon.asc");
        !           112: }
        !           113: 
        !           114: void on_auto_message1_activate(GtkWidget *wiggy, gpointer data) {
        !           115:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"menu/auto.msg");
        !           116: }
        !           117: 
        !           118: void on_zip_file_comment1_activate(GtkWidget *wiggy, gpointer data) {
        !           119:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"zipmsg.txt");
        !           120: }
        !           121: 
        !           122: void on_system_information1_activate(GtkWidget *wiggy, gpointer data) {
        !           123:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"system.msg");
        !           124: }
        !           125: 
        !           126: void on_new_user_message1_activate(GtkWidget *wiggy, gpointer data) {
        !           127:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"newuser.msg");
        !           128: }
        !           129: 
        !           130: void on_new_user_welcome_email1_activate(GtkWidget *wiggy, gpointer data) {
        !           131:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"welcome.msg");
        !           132: }
        !           133: 
        !           134: void on_new_user_password_failure1_activate(GtkWidget *wiggy, gpointer data) {
        !           135:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"nupguess.msg");
        !           136: }
        !           137: 
        !           138: void on_new_user_feedbakc_instructions1_activate(GtkWidget *wiggy, gpointer data)
        !           139: {
        !           140:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"feedback.msg");
        !           141: }
        !           142: 
        !           143: void on_allowed_rlogin_list1_activate(GtkWidget *wiggy, gpointer data)
        !           144: {
        !           145:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"rlogin.cfg");
        !           146: }
        !           147: 
        !           148: void on_alias_list1_activate(GtkWidget *wiggy, gpointer data)
        !           149: {
        !           150:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"alias.cfg");
        !           151: }
        !           152: 
        !           153: void on_domain_list1_activate(GtkWidget *wiggy, gpointer data)
        !           154: {
        !           155:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"domains.cfg");
        !           156: }
        !           157: 
        !           158: void on_spam_bait_list1_activate(GtkWidget *wiggy, gpointer data)
        !           159: {
        !           160:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"spambait.cfg");
        !           161: }
        !           162: 
        !           163: void on_spam_block_list1_activate(GtkWidget *wiggy, gpointer data)
        !           164: {
        !           165:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"spamblock.cfg");
        !           166: }
        !           167: 
        !           168: void on_allowed_relay_list1_activate(GtkWidget *wiggy, gpointer data)
        !           169: {
        !           170:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"relay.cfg");
        !           171: }
        !           172: 
        !           173: void on_dnsbased_blacklists1_activate(GtkWidget *wiggy, gpointer data)
        !           174: {
        !           175:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"dns_blacklist.cfg");
        !           176: }
        !           177: 
        !           178: void on_dnsblacklist_exempt_ips1_activate(GtkWidget *wiggy, gpointer data)
        !           179: {
        !           180:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"dnsbl_exempt.cfg.cfg");
        !           181: }
        !           182: 
        !           183: void on_external_mail_processing1_activate(GtkWidget *wiggy, gpointer data)
        !           184: {
        !           185:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"mailproc.ini");
        !           186: }
        !           187: 
        !           188: void on_login_message1_activate(GtkWidget *wiggy, gpointer data)
        !           189: {
        !           190:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"ftplogin.txt");
        !           191: }
        !           192: 
        !           193: void on_failed_login_mesage1_activate(GtkWidget *wiggy, gpointer data)
        !           194: {
        !           195:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"ftpbadlogin.txt");
        !           196: }
        !           197: 
        !           198: void on_hello_message1_activate(GtkWidget *wiggy, gpointer data)
        !           199: {
        !           200:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"ftphello.txt");
        !           201: }
        !           202: 
        !           203: void on_goodbye_message1_activate(GtkWidget *wiggy, gpointer data)
        !           204: {
        !           205:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"ftpbye.txt");
        !           206: }
        !           207: 
        !           208: void on_filename_aliases1_activate(GtkWidget *wiggy, gpointer data)
        !           209: {
        !           210:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"ftpalias.cfg");
        !           211: }
        !           212: 
        !           213: void on_mime_types1_activate(GtkWidget *wiggy, gpointer data)
        !           214: {
        !           215:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"mime_types.ini");
        !           216: }
        !           217: 
        !           218: void on_cgi_environment_variables1_activate(GtkWidget *wiggy, gpointer data)
        !           219: {
        !           220:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"cgi_env.ini");
        !           221: }
        !           222: 
        !           223: void on_external_content_handlers1_activate(GtkWidget *wiggy, gpointer data)
        !           224: {
        !           225:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"web_handler.ini");
        !           226: }
        !           227: 
        !           228: void on_servicesini1_activate(GtkWidget *wiggy, gpointer data)
        !           229: {
        !           230:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"services.ini");
        !           231: }
        !           232: 
        !           233: void on_error_log1_activate(GtkWidget *wiggy, gpointer data)
        !           234: {
        !           235:        exec_cmdstr(gtkm_conf.view_text_file ,cfg.logs_dir,"error.log");
        !           236: }
        !           237: 
        !           238: void on_statistics_log1_activate(GtkWidget *wiggy, gpointer data)
        !           239: {
        !           240:        exec_cmdstr(gtkm_conf.view_stdout ,cfg.exec_dir,"slog");
        !           241: }
        !           242: 
        !           243: void on_todays_log1_activate(GtkWidget *wiggy, gpointer data)
        !           244: {
        !           245:        time_t  t;
        !           246:        struct tm *tm;
        !           247:        char    fn[20];
        !           248: 
        !           249:        t=time(NULL);
        !           250:        tm=localtime(&t);
        !           251:        sprintf(fn,"logs/%02d%02d%02d.log",tm->tm_mon+1,tm->tm_mday,tm->tm_year%100);
        !           252:        exec_cmdstr(gtkm_conf.view_text_file, cfg.logs_dir,fn);
        !           253: }
        !           254: 
        !           255: void on_yesterdays_log1_activate(GtkWidget *wiggy, gpointer data)
        !           256: {
        !           257:        time_t  t;
        !           258:        struct tm *tm;
        !           259:        char    fn[20];
        !           260: 
        !           261:        t=time(NULL);
        !           262:        t-=24*60*60;
        !           263:        tm=localtime(&t);
        !           264:        sprintf(fn,"logs/%02d%02d%02d.log",tm->tm_mon+1,tm->tm_mday,tm->tm_year%100);
        !           265:        exec_cmdstr(gtkm_conf.view_text_file, cfg.logs_dir,fn);
        !           266: }
        !           267: 
        !           268: void on_another_days_log1_activate(GtkWidget *wiggy, gpointer data) {
        !           269:        isoDate_t       date;
        !           270:        char    fn[20];
        !           271:        GtkWidget       *w;
        !           272: 
        !           273:        date=time_to_isoDate(time(NULL));
        !           274:        get_date(wiggy, &date);
        !           275:        sprintf(fn,"logs/%02d%02d%02d.log",isoDate_month(date),isoDate_day(date),isoDate_year(date)%100);
        !           276:        exec_cmdstr(gtkm_conf.view_text_file, cfg.logs_dir, fn);
        !           277: }
        !           278: 
        !           279: void on_spam_log1_activate(GtkWidget *wiggy, gpointer data)
        !           280: {
        !           281:        exec_cmdstr(gtkm_conf.view_text_file, cfg.logs_dir,"spam.log");
        !           282: }
        !           283: 
        !           284: void on_ip_address_filter1_activate(GtkWidget *wiggy, gpointer data)
        !           285: {
        !           286:        exec_cmdstr(gtkm_conf.edit_text_file, cfg.text_dir,"ip.can");
        !           287: }
        !           288: 
        !           289: void on_ip_address_filter_silent1_activate(GtkWidget *wiggy, gpointer data)
        !           290: {
        !           291:        exec_cmdstr(gtkm_conf.edit_text_file, cfg.text_dir,"ip-silent.can");
        !           292: }
        !           293: 
        !           294: void on_ip_address_filter_message1_activate(GtkWidget *wiggy, gpointer data)
        !           295: {
        !           296:        exec_cmdstr(gtkm_conf.edit_text_file, cfg.text_dir,"badip.msg");
        !           297: }
        !           298: 
        !           299: void on_host_name_filter1_activate(GtkWidget *wiggy, gpointer data)
        !           300: {
        !           301:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"host.can");
        !           302: }
        !           303: 
        !           304: void on_host_name_filter_message1_activate(GtkWidget *wiggy, gpointer data)
        !           305: {
        !           306:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"badhost.msg");
        !           307: }
        !           308: 
        !           309: void on_user_name_filter1_activate(GtkWidget *wiggy, gpointer data)
        !           310: {
        !           311:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"name.can");
        !           312: }
        !           313: 
        !           314: void on_user_name_filter_message1_activate(GtkWidget *wiggy, gpointer data)
        !           315: {
        !           316:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"badname.msg");
        !           317: }
        !           318: 
        !           319: void on_email_address_filter1_activate(GtkWidget *wiggy, gpointer data)
        !           320: {
        !           321:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"email.can");
        !           322: }
        !           323: 
        !           324: void on_email_address_filter_message1_activate(GtkWidget *wiggy, gpointer data)
        !           325: {
        !           326:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"bademail.msg");
        !           327: }
        !           328: 
        !           329: void on_email_subject_filter1_activate(GtkWidget *wiggy, gpointer data)
        !           330: {
        !           331:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"subject.can");
        !           332: }
        !           333: 
        !           334: void on_file_name_filter1_activate(GtkWidget *wiggy, gpointer data)
        !           335: {
        !           336:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"file.can");
        !           337: }
        !           338: 
        !           339: void on_file_name_filter_message1_activate(GtkWidget *wiggy, gpointer data)
        !           340: {
        !           341:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"badfile.msg");
        !           342: }
        !           343: 
        !           344: void on_phone_number_filter1_activate(GtkWidget *wiggy, gpointer data)
        !           345: {
        !           346:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"phone.can");
        !           347: }
        !           348: 
        !           349: void on_phone_number_filter_message1_activate(GtkWidget *wiggy, gpointer data)
        !           350: {
        !           351:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"badphone.msg");
        !           352: }
        !           353: 
        !           354: void on_twit_list1_activate(GtkWidget *wiggy, gpointer data)
        !           355: {
        !           356:        exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"twitlist.cfg");
        !           357: }
        !           358: 
        !           359: void on_hack_attempt_log1_activate(GtkWidget *wiggy, gpointer data)
        !           360: {
        !           361:        exec_cmdstr(gtkm_conf.view_text_file,cfg.logs_dir,"hack.log");
        !           362: }
        !           363: 
        !           364: void on_configure1_activate(GtkWidget *wiggy, gpointer data)
        !           365: {
        !           366:        run_external(cfg.exec_dir,"scfg");
        !           367: }
        !           368: 
        !           369: void on_edit3_activate(GtkWidget *wiggy, gpointer data)
        !           370: {
        !           371:        run_external(cfg.exec_dir,"gtkuseredit");
        !           372: }
        !           373: 
        !           374: void on_truncate_deleted_users1_activate(GtkWidget *wiggy, gpointer data)
        !           375: {
        !           376:     int usernumber;
        !           377:     int deleted=0;
        !           378:     user_t user;
        !           379:     char str[128];
        !           380: 
        !           381:     while((user.number=lastuser(&cfg))!=0) {
        !           382:         if(getuserdat(&cfg,&user)!=0)
        !           383:             break;
        !           384:         if(!(user.misc&DELETED))
        !           385:             break;
        !           386:         if(!del_lastuser(&cfg))
        !           387:             break;
        !           388:         deleted++;
        !           389:     }
        !           390:     sprintf(str,"%u Deleted User Records Removed",deleted);
        !           391:        display_message("Users Truncated", str, NULL);
        !           392: }
        !           393: 
        !           394: void on_stop6_activate(GtkWidget *wiggy, gpointer data)
        !           395: {
        !           396:        touch_sem(cfg.ctrl_dir, "shutdown");
        !           397: }
        !           398: 
        !           399: void on_recycle6_activate(GtkWidget *wiggy, gpointer data)
        !           400: {
        !           401:        touch_sem(cfg.ctrl_dir, "recycle");
        !           402: }
        !           403: 
        !           404: void on_stop1_activate(GtkWidget *wiggy, gpointer data)
        !           405: {
        !           406:        touch_sem(cfg.ctrl_dir, "shutdown.telnet");
        !           407: }
        !           408: 
        !           409: void on_recycle5_activate(GtkWidget *wiggy, gpointer data)
        !           410: {
        !           411:        touch_sem(cfg.ctrl_dir, "recycle.telnet");
        !           412: }
        !           413: 
        !           414: void on_stop2_activate(GtkWidget *wiggy, gpointer data)
        !           415: {
        !           416:        touch_sem(cfg.ctrl_dir, "shutdown.mail");
        !           417: }
        !           418: 
        !           419: void on_recycle1_activate(GtkWidget *wiggy, gpointer data)
        !           420: {
        !           421:        touch_sem(cfg.ctrl_dir, "recycle.mail");
        !           422: }
        !           423: 
        !           424: void on_stop3_activate(GtkWidget *wiggy, gpointer data)
        !           425: {
        !           426:        touch_sem(cfg.ctrl_dir, "shutdown.ftp");
        !           427: }
        !           428: 
        !           429: void on_recycle2_activate(GtkWidget *wiggy, gpointer data)
        !           430: {
        !           431:        touch_sem(cfg.ctrl_dir, "recycle.ftp");
        !           432: }
        !           433: 
        !           434: void on_stop4_activate(GtkWidget *wiggy, gpointer data)
        !           435: {
        !           436:        touch_sem(cfg.ctrl_dir, "shutdown.web");
        !           437: }
        !           438: 
        !           439: void on_recycle3_activate(GtkWidget *wiggy, gpointer data)
        !           440: {
        !           441:        touch_sem(cfg.ctrl_dir, "recycle.web");
        !           442: }
        !           443: 
        !           444: void on_stop5_activate(GtkWidget *wiggy, gpointer data)
        !           445: {
        !           446:        touch_sem(cfg.ctrl_dir, "shutdown.services");
        !           447: }
        !           448: 
        !           449: void on_recycle4_activate(GtkWidget *wiggy, gpointer data)
        !           450: {
        !           451:        touch_sem(cfg.ctrl_dir, "recycle.services");
        !           452: }
        !           453: 
        !           454: void on_statistics_pane1_activate(GtkWidget *wiggy, gpointer data)
        !           455: {
        !           456:        GtkWidget *w;
        !           457: 
        !           458:        w=glade_xml_get_widget(xml, "StatisticsPane");
        !           459:        if(w==NULL)
        !           460:                fprintf(stderr,"Cannot get the statistics pane.\n");
        !           461:        else {
        !           462:                switch(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(wiggy))) {
        !           463:                        case 0:
        !           464:                                gtk_widget_hide(w);
        !           465:                                break;
        !           466:                        default:
        !           467:                                gtk_widget_show(w);
        !           468:                }
        !           469:        }
        !           470: }
        !           471: 
        !           472: void create_force_sem(GtkWidget *wiggy, gpointer data)
        !           473: {
        !           474:        gchar   *label;
        !           475:        char    fn[MAX_PATH+1];
        !           476: 
        !           477:        label=(gchar *)gtk_label_get_text(GTK_LABEL(wiggy));
        !           478:        if(label != NULL) {
        !           479:                sprintf(fn,"%s%s.now",(gchar *)data, label);
        !           480:                touch_sem(cfg.data_dir, fn);
        !           481:        }
        !           482: }
        !           483: 
        !           484: void on_force_event(GtkWidget *wiggy, gpointer data)
        !           485: {
        !           486:        /* There's only one child... so this is a bit of a cheat */
        !           487:        gtk_container_foreach(GTK_CONTAINER(wiggy), create_force_sem, "");
        !           488: }
        !           489: 
        !           490: void on_force_qnet(GtkWidget *wiggy, gpointer data)
        !           491: {
        !           492:        /* There's only one child... so this is a bit of a cheat */
        !           493:        gtk_container_foreach(GTK_CONTAINER(wiggy), create_force_sem, "qnet/");
        !           494: }
        !           495: 
        !           496: void on_reload_configuration1_activate(GtkWidget *wiggy, gpointer data)
        !           497: {
        !           498:        refresh_events();
        !           499: }
        !           500: 
        !           501: void toggle_node_bits(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
        !           502: {
        !           503:        int     *bit=data;
        !           504:        int     fd;
        !           505:        char    *node_str;
        !           506:        int             n,i;
        !           507:        node_t  node;
        !           508:        char    str[128];
        !           509: 
        !           510:        gtk_tree_model_get(model, iter, 0, &node_str, -1);
        !           511:        n=atoi(node_str);
        !           512: 
        !           513:        if((i=getnodedat(&cfg,n,&node,&fd))) {
        !           514:                sprintf(str,"Error reading node %d data (%d)!",n,i);
        !           515:                display_message("Read Error", str, "gtk-dialog-error");
        !           516:        }
        !           517:        else {
        !           518:                node.misc ^= *bit;
        !           519:                putnodedat(&cfg, n, &node, fd);
        !           520:        }
        !           521: }
        !           522: 
        !           523: void lock_nodes(GtkWidget *wiggy, gpointer data)
        !           524: {
        !           525:        int             bit=NODE_LOCK;
        !           526: 
        !           527:        gtk_tree_selection_selected_foreach(sel
        !           528:                        ,toggle_node_bits
        !           529:                        ,&bit);
        !           530:        refresh_data(NULL);
        !           531: }
        !           532: 
        !           533: void down_nodes(GtkWidget *wiggy, gpointer data)
        !           534: {
        !           535:        int             bit=NODE_DOWN;
        !           536: 
        !           537:        gtk_tree_selection_selected_foreach(sel
        !           538:                        ,toggle_node_bits
        !           539:                        ,&bit);
        !           540:        refresh_data(NULL);
        !           541: }
        !           542: 
        !           543: void interrupt_nodes(GtkWidget *wiggy, gpointer data)
        !           544: {
        !           545:        int             bit=NODE_INTR;
        !           546: 
        !           547:        gtk_tree_selection_selected_foreach(sel
        !           548:                        ,toggle_node_bits
        !           549:                        ,&bit);
        !           550:        refresh_data(NULL);
        !           551: }
        !           552: 
        !           553: void rerun_nodes(GtkWidget *wiggy, gpointer data)
        !           554: {
        !           555:        int             bit=NODE_RRUN;
        !           556: 
        !           557:        gtk_tree_selection_selected_foreach(sel
        !           558:                        ,toggle_node_bits
        !           559:                        ,&bit);
        !           560:        refresh_data(NULL);
        !           561: }
        !           562: 
        !           563: void do_clear_errors(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
        !           564: {
        !           565:        int     *bit=data;
        !           566:        int     fd;
        !           567:        char    *node_str;
        !           568:        int             n,i;
        !           569:        node_t  node;
        !           570:        char    str[128];
        !           571: 
        !           572:        gtk_tree_model_get(model, iter, 0, &node_str, -1);
        !           573:        n=atoi(node_str);
        !           574: 
        !           575:        if((i=getnodedat(&cfg,n,&node,&fd))) {
        !           576:                sprintf(str,"Error reading node %d data (%d)!",n,i);
        !           577:                display_message("Read Error",str,"gtk-dialog-error");
        !           578:        }
        !           579:        else {
        !           580:                node.errors = 0;
        !           581:                putnodedat(&cfg, n, &node, fd);
        !           582:        }
        !           583: }
        !           584: 
        !           585: void clear_errors(GtkWidget *wiggy, gpointer data)
        !           586: {
        !           587:        gtk_tree_selection_selected_foreach(sel
        !           588:                        ,do_clear_errors
        !           589:                        ,NULL);
        !           590:        refresh_data(NULL);
        !           591: }
        !           592: 
        !           593: void on_about1_activate(GtkWidget *wiggy, gpointer data)
        !           594: {
        !           595:        GladeXML        *axml;
        !           596: 
        !           597:     axml = glade_xml_new(glade_path, "AboutWindow", NULL);
        !           598:        if(axml==NULL) {
        !           599:                fprintf(stderr,"Could not locate AboutWindow widget\n");
        !           600:                return;
        !           601:        }
        !           602:     /* connect the signals in the interface */
        !           603:     glade_xml_signal_autoconnect(axml);
        !           604:        gtk_window_present(GTK_WINDOW(glade_xml_get_widget(axml, "AboutWindow")));
        !           605: }
        !           606: 
        !           607: void get_lastselected_node(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
        !           608: {
        !           609:        int     *i=data;
        !           610:        gchar   *node;
        !           611: 
        !           612:        gtk_tree_model_get(model, iter, 0, &node, -1);
        !           613:        *i=atoi(node);
        !           614: }
        !           615: 
        !           616: void chatwith_node(GtkWidget *wiggy, gpointer data)
        !           617: {
        !           618:        char    str[MAX_PATH+1];
        !           619:        int             i;
        !           620: 
        !           621:        gtk_tree_selection_selected_foreach(sel
        !           622:                        ,get_lastselected_node
        !           623:                        ,&i);
        !           624:        sprintf(str,"gtkchat %d",i);
        !           625:        run_external(cfg.exec_dir,str);
        !           626: }
        !           627: 
        !           628: void edituseron_node(GtkWidget *wiggy, gpointer data)
        !           629: {
        !           630:        char    str[MAX_PATH+1];
        !           631:        int             i;
        !           632:        node_t  node;
        !           633: 
        !           634:        gtk_tree_selection_selected_foreach(sel
        !           635:                        ,get_lastselected_node
        !           636:                        ,&i);
        !           637: 
        !           638:        if((i=getnodedat(&cfg,i,&node,NULL))) {
        !           639:                sprintf(str,"Error reading node data (%d)!",i);
        !           640:                display_message("Read Error",str,"gtk-dialog-error");
        !           641:        }
        !           642:        else {
        !           643:                sprintf(str,"gtkuseredit %d",node.useron);
        !           644:                run_external(cfg.exec_dir,str);
        !           645:        }
        !           646: }
        !           647: 
        !           648: void close_this_window(GtkWidget *wiggy, gpointer data)
        !           649: {
        !           650:        gtk_widget_destroy(GTK_WIDGET(gtk_widget_get_toplevel(wiggy)));
        !           651: }
        !           652: 
        !           653: void quick_validate(int usernum, int set)
        !           654: {
        !           655:        user_t          user;
        !           656:        int                     res;
        !           657:        char            str[1024];
        !           658: 
        !           659:        user.number=usernum;
        !           660:        if((res=getuserdat(&cfg,&user))) {
        !           661:                sprintf(str,"Error loading user %d.\n",usernum);
        !           662:                display_message("Load Error",str,"gtk-dialog-error");
        !           663:                return;
        !           664:        }
        !           665:        user.flags1=cfg.val_flags1[set];
        !           666:        user.flags2=cfg.val_flags2[set];
        !           667:        user.flags3=cfg.val_flags3[set];
        !           668:        user.flags4=cfg.val_flags4[set];
        !           669:        user.exempt=cfg.val_exempt[set];
        !           670:        user.rest=cfg.val_rest[set];
        !           671:        if(cfg.val_expire[set]) {
        !           672:                user.expire=time(NULL)
        !           673:                        +(cfg.val_expire[set]*24*60*60);
        !           674:        }
        !           675:        else
        !           676:                user.expire=0;
        !           677:        user.level=cfg.val_level[set];
        !           678:        if((res=putuserdat(&cfg,&user))) {
        !           679:                sprintf(str,"Error saving user %d.\n",usernum);
        !           680:                display_message("Save Error",str,"gtk=dialog-error");
        !           681:        }
        !           682: }
        !           683: 
        !           684: /* Show user list */
        !           685: on_list1_activate(GtkWidget *wiggy, gpointer data)
        !           686: {
        !           687:        run_external(cfg.exec_dir,"gtkuserlist");
        !           688: }
        !           689: 
        !           690: void quickvalidate_useron_node(GtkWidget *wiggy, gpointer data)
        !           691: {
        !           692:        char    str[MAX_PATH+1];
        !           693:        int             i;
        !           694:        int             set;
        !           695:        node_t  node;
        !           696:        GtkWidget       *w;
        !           697: 
        !           698:        set=gtk_combo_box_get_active(GTK_COMBO_BOX(wiggy))-1;
        !           699:        if(set>=0) {
        !           700:                gtk_tree_selection_selected_foreach(sel
        !           701:                                ,get_lastselected_node
        !           702:                                ,&i);
        !           703: 
        !           704:                if((i=getnodedat(&cfg,i,&node,NULL))) {
        !           705:                        sprintf(str,"Error reading node data (%d)!",i);
        !           706:                        display_message("Read Error",str,"gtk-dialog-error");
        !           707:                }
        !           708:                else {
        !           709:                        quick_validate(node.useron, set);
        !           710:                }
        !           711:                gtk_combo_box_set_active(GTK_COMBO_BOX(wiggy), 0);
        !           712:        }
        !           713: }
        !           714: 
        !           715: char *select_filename(GtkWidget *wiggy, char *title, char *name, char *in_pattern, char *dir, char *fn)
        !           716: {
        !           717:        GtkWidget               *chooser;
        !           718:        GtkFileFilter   *filter;
        !           719:        char                    *search;
        !           720:        char                    *next;
        !           721:        char                    *p1,*p2;
        !           722:        char                    *pattern;
        !           723:        char                    pat[MAX_PATH+1];
        !           724: 
        !           725:        chooser=gtk_file_chooser_dialog_new(title
        !           726:                        ,GTK_WINDOW(gtk_widget_get_toplevel(wiggy))
        !           727:                        ,GTK_FILE_CHOOSER_ACTION_OPEN
        !           728:                        ,GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL
        !           729:                        ,GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT
        !           730:                        ,NULL);
        !           731:        gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(chooser), TRUE);
        !           732:        gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(chooser) ,dir);
        !           733:        filter=gtk_file_filter_new();
        !           734:        gtk_file_filter_set_name(filter, name);
        !           735:        pattern=strdup(in_pattern);
        !           736:        search=pattern;
        !           737:        while((next=strtok(search, ";"))!=NULL) {
        !           738:                search=NULL;
        !           739:                pat[0]=0;
        !           740:                p2=pat;
        !           741:                for(p1=next;*p1;p1++) {
        !           742:                        if(toupper(*p1)!=tolower(*p1)) {
        !           743:                                *(p2++)='[';
        !           744:                                *(p2++)=toupper(*p1);
        !           745:                                *(p2++)=tolower(*p1);
        !           746:                                *(p2++)=']';
        !           747:                        }
        !           748:                        else
        !           749:                                *(p2++)=*p1;
        !           750:                        *p2=0;
        !           751:                }
        !           752:                gtk_file_filter_add_pattern(filter, pat);
        !           753:        }
        !           754:        free(pattern);
        !           755:        gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(chooser), filter);
        !           756:        filter=gtk_file_filter_new();
        !           757:        gtk_file_filter_set_name(filter, "All Files");
        !           758:        gtk_file_filter_add_pattern(filter, "*");
        !           759:        gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(chooser), filter);
        !           760:        
        !           761:        switch(gtk_dialog_run(GTK_DIALOG(chooser))) {
        !           762:                case GTK_RESPONSE_ACCEPT:
        !           763:                        strcpy(fn, gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser)));
        !           764:                        break;
        !           765:                default:
        !           766:                        fn[0]=0;
        !           767:        }
        !           768:        gtk_widget_destroy(chooser);
        !           769:        return(fn);
        !           770: }
        !           771: 
        !           772: void on_text_file1_activate(GtkWidget *wiggy, gpointer data)
        !           773: {
        !           774:        char    fn[MAX_PATH+1];
        !           775:        select_filename(wiggy, "Edit Text File", "Text Files", "*.txt", cfg.text_dir, fn);
        !           776:        if(fn[0])
        !           777:                exec_cmdstr(gtkm_conf.edit_text_file, NULL, fn);
        !           778: }
        !           779: 
        !           780: void on_javascript_file1_activate(GtkWidget *wiggy, gpointer data)
        !           781: {
        !           782:        char    fn[MAX_PATH+1];
        !           783:        select_filename(wiggy, "Edit Javascript File", "Javascript Files", "*.js", cfg.exec_dir, fn);
        !           784:        if(fn[0])
        !           785:                exec_cmdstr(gtkm_conf.edit_text_file, NULL, fn);
        !           786: }
        !           787: 
        !           788: void on_configuration_file1_activate(GtkWidget *wiggy, gpointer data)
        !           789: {
        !           790:        char    fn[MAX_PATH+1];
        !           791: 
        !           792:        select_filename(wiggy, "Edit Configuration File", "Configuration Files", "*.cfg;*.ini;*.conf", cfg.ctrl_dir, fn);
        !           793:        if(fn[0])
        !           794:                exec_cmdstr(gtkm_conf.edit_text_file, NULL, fn);
        !           795: }
        !           796: 
        !           797: void on_edit_and_compile_baja_script1_activate(GtkWidget *wiggy, gpointer data)
        !           798: {
        !           799:        char    fn[MAX_PATH+1];
        !           800:        char    compile[MAX_PATH*2+1];
        !           801: 
        !           802:        select_filename(wiggy, "Edit/Compile Baja Script", "BAJA Files", "*.src", cfg.exec_dir, fn);
        !           803:        if(!run_cmd_mutex_initalized) {
        !           804:                pthread_mutex_init(&run_cmd_mutex, NULL);
        !           805:                run_cmd_mutex_initalized=1;
        !           806:        }
        !           807:        if(fn[0]) {
        !           808:                exec_cmdstr(gtkm_conf.edit_text_file, NULL, fn);
        !           809:                /* Spin on the lock waiting for the edit command to start */
        !           810:                while(!pthread_mutex_trylock(&run_cmd_mutex))
        !           811:                        pthread_mutex_unlock(&run_cmd_mutex);
        !           812:                sprintf(compile, "baja %s", fn);
        !           813:                exec_cmdstr(gtkm_conf.view_stdout,cfg.exec_dir,compile);
        !           814:        }
        !           815: }
        !           816: 
        !           817: void on_index1_activate(GtkWidget *wiggy, gpointer data)
        !           818: {
        !           819:        exec_cmdstr(gtkm_conf.view_html_file,cfg.ctrl_dir,"../docs/index.htm");
        !           820: }
        !           821: 
        !           822: void on_sysop_manual1_activate(GtkWidget *wiggy, gpointer data)
        !           823: {
        !           824:        exec_cmdstr(gtkm_conf.view_html_file,cfg.ctrl_dir,"../docs/sysop.html");
        !           825: }
        !           826: 
        !           827: void on_frequently_asked_questions_faq1_activate(GtkWidget *wiggy, gpointer data)
        !           828: {
        !           829:        exec_cmdstr(gtkm_conf.view_text_file,cfg.ctrl_dir,"../docs/v3cfgfaq.txt");
        !           830: }
        !           831: 
        !           832: void on_preview_file1_activate(GtkWidget *wiggy, gpointer data)
        !           833: {
        !           834:        char    fn[MAX_PATH+1];
        !           835: 
        !           836:        select_filename(wiggy, "Preview File", "ANSI/Ctrl-A Files", "*.ans;*.asc;*.msg", cfg.text_dir, fn);
        !           837:        if(fn[0])
        !           838:                exec_cmdstr(gtkm_conf.view_ctrla_file,NULL, fn);
        !           839: }
        !           840: 
        !           841: void on_edit_and_preview_file1_activate(GtkWidget *wiggy, gpointer data)
        !           842: {
        !           843:        char    fn[MAX_PATH+1];
        !           844: 
        !           845:        select_filename(wiggy, "Edit and Preview File", "ANSI/Ctrl-A Files", "*.ans;*.asc;*.msg", cfg.text_dir, fn);
        !           846:        if(!run_cmd_mutex_initalized) {
        !           847:                pthread_mutex_init(&run_cmd_mutex, NULL);
        !           848:                run_cmd_mutex_initalized=1;
        !           849:        }
        !           850:        if(fn[0]) {
        !           851:                exec_cmdstr(gtkm_conf.edit_text_file, NULL, fn);
        !           852:                /* Spin on the lock waiting for the edit command to start */
        !           853:                while(!pthread_mutex_trylock(&run_cmd_mutex))
        !           854:                        pthread_mutex_unlock(&run_cmd_mutex);
        !           855:                exec_cmdstr(gtkm_conf.view_ctrla_file, NULL, fn);
        !           856:        }
        !           857: }
        !           858: 
        !           859: void sendmessageto_node(GtkWidget *wiggy, gpointer data)
        !           860: {
        !           861:        char    fn[MAX_PATH+1];
        !           862:        char    str[MAX_PATH+1];
        !           863:        int             i;
        !           864:        int             tmp;
        !           865:        node_t  node;
        !           866:        time_t  edited;
        !           867:        struct utimbuf tb;
        !           868:        char    *msg;
        !           869: 
        !           870:        gtk_tree_selection_selected_foreach(sel
        !           871:                        ,get_lastselected_node
        !           872:                        ,&i);
        !           873: 
        !           874:        if((i=getnodedat(&cfg,i,&node,NULL))) {
        !           875:                sprintf(str,"Error reading node data (%d)!",i);
        !           876:                display_message("Read Error",str,"gtk-dialog-error");
        !           877:        }
        !           878:        else {
        !           879:                strcpy(fn,"/tmp/gtkmonitor-msg-XXXXXXXX");
        !           880:                tmp=mkstemp(fn);
        !           881:                if(tmp!=-1) {
        !           882:                        write(tmp,"\1n\1y\1hMessage From Sysop:\1w \n\n",30);
        !           883:                        close(tmp);
        !           884:                        /* Set modified time back one second so we can tell if the sysop
        !           885:                           saved the file or not */
        !           886:                        edited=fdate(fn);
        !           887:                        edited--;
        !           888:                        tb.actime=edited;
        !           889:                        tb.modtime=edited;
        !           890:                        utime(fn, &tb);
        !           891:                        /* If utime() failed for some reason, sleep for a second */
        !           892:                        if(fdate(fn)!=edited)
        !           893:                                SLEEP(1000);
        !           894:                        if(!run_cmd_mutex_initalized) {
        !           895:                                pthread_mutex_init(&run_cmd_mutex, NULL);
        !           896:                                run_cmd_mutex_initalized=1;
        !           897:                        }
        !           898:                        exec_cmdstr(gtkm_conf.edit_text_file, NULL, fn);
        !           899:                        /* Spin on the lock waiting for the edit command to start */
        !           900:                        while(!pthread_mutex_trylock(&run_cmd_mutex))
        !           901:                                pthread_mutex_unlock(&run_cmd_mutex);
        !           902:                        /* Now, spin on the lock waiting for it to *exit* */
        !           903:                        while(pthread_mutex_trylock(&run_cmd_mutex)) {
        !           904:                                /* Allow events to happen as normal */
        !           905:                                while(gtk_events_pending()) {
        !           906:                                        if(gtk_main_iteration())
        !           907:                                                gtk_main_quit();
        !           908:                                }
        !           909:                                SLEEP(1);
        !           910:                        }
        !           911:                        pthread_mutex_unlock(&run_cmd_mutex);
        !           912:                        /* Now, read the message back in and send to the user */
        !           913:                        if(fdate(fn)!=edited) {
        !           914:                                i=flength(fn);
        !           915:                                if((msg=(char *)malloc(i))==NULL)
        !           916:                                        display_message("malloc() Error", "Cannot allocate enough memory for the message", "gtk-dialog-error");
        !           917:                                else {
        !           918:                                        tmp=open(fn, O_RDONLY);
        !           919:                                        if(tmp==-1)
        !           920:                                                display_message("open() Error", "Cannot open temp message file", "gtk-dialog-error");
        !           921:                                        else {
        !           922:                                                if(read(tmp, msg, i)!=i)
        !           923:                                                        display_message("read() Error", "Problem reading message file", "gtk-dialog-error");
        !           924:                                                else {
        !           925:                                                        putsmsg(&cfg, node.useron, msg);
        !           926:                                                }
        !           927:                                        }
        !           928:                                        free(msg);
        !           929:                                }
        !           930:                        }
        !           931:                }
        !           932:        }
        !           933: }
        !           934: 
        !           935: void on_properties1_activate(GtkWidget *wiggy, gpointer data)
        !           936: {
        !           937:        GladeXML        *pxml;
        !           938:        GtkWidget       *dialog;
        !           939:        GtkWidget       *w;
        !           940: 
        !           941:     pxml = glade_xml_new(glade_path, "PreferencesDialog", NULL);
        !           942:        if(pxml==NULL) {
        !           943:                fprintf(stderr,"Could not locate PreferencesDialog widget\n");
        !           944:                return;
        !           945:        }
        !           946:        /* connect the signals in the interface */
        !           947:        glade_xml_signal_autoconnect(pxml);
        !           948:        dialog=glade_xml_get_widget(pxml, "PreferencesDialog");
        !           949: 
        !           950:        /* Put in the current values */
        !           951:        w=glade_xml_get_widget(pxml,"eEditTextFile");
        !           952:        gtk_entry_set_text(GTK_ENTRY(w),gtkm_conf.edit_text_file);
        !           953:        w=glade_xml_get_widget(pxml,"eViewTextFile");
        !           954:        gtk_entry_set_text(GTK_ENTRY(w),gtkm_conf.view_text_file);
        !           955:        w=glade_xml_get_widget(pxml,"eViewStdout");
        !           956:        gtk_entry_set_text(GTK_ENTRY(w),gtkm_conf.view_stdout);
        !           957:        w=glade_xml_get_widget(pxml,"eViewCtrlAFile");
        !           958:        gtk_entry_set_text(GTK_ENTRY(w),gtkm_conf.view_ctrla_file);
        !           959:        w=glade_xml_get_widget(pxml,"eViewHTMLFile");
        !           960:        gtk_entry_set_text(GTK_ENTRY(w),gtkm_conf.view_html_file);
        !           961: 
        !           962:        switch(gtk_dialog_run(GTK_DIALOG(dialog))) {
        !           963:                case GTK_RESPONSE_OK:
        !           964:                        /* Read out the new values */
        !           965:                        w=glade_xml_get_widget(pxml,"eEditTextFile");
        !           966:                        strcpy(gtkm_conf.edit_text_file,gtk_entry_get_text(GTK_ENTRY(w)));
        !           967:                        w=glade_xml_get_widget(pxml,"eViewTextFile");
        !           968:                        strcpy(gtkm_conf.view_text_file,gtk_entry_get_text(GTK_ENTRY(w)));
        !           969:                        w=glade_xml_get_widget(pxml,"eViewStdout");
        !           970:                        strcpy(gtkm_conf.view_stdout,gtk_entry_get_text(GTK_ENTRY(w)));
        !           971:                        w=glade_xml_get_widget(pxml,"eViewCtrlAFile");
        !           972:                        strcpy(gtkm_conf.view_ctrla_file,gtk_entry_get_text(GTK_ENTRY(w)));
        !           973:                        w=glade_xml_get_widget(pxml,"eViewHTMLFile");
        !           974:                        strcpy(gtkm_conf.view_html_file,gtk_entry_get_text(GTK_ENTRY(w)));
        !           975:                        write_ini();
        !           976:        }
        !           977:        gtk_widget_destroy(dialog);
        !           978: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.