Пример #1
0
void ServerDB::open(Fl_Preferences &prefs){
    AutoLocker<const ServerDB * const> locker(this);

    clear();

    char *uid_list;
    if(!prefs.get("sys.server_uids", uid_list, "")){
        prefs.set("sys.server_uids", "");
        free(uid_list);
        return;
    }

    const char **server_uids = FJ::CSV::ParseString(uid_list);
    free(uid_list);

    char *groups;
    GetAndExist(prefs, "sys.group_uids", groups, "");
    const char **group_uids = FJ::CSV::ParseString(groups);
    free(groups);

    for(int i = 0; group_uids[i]!=nullptr; i++){
        guts->groups.push_back(group_uids[i]);
    }

    FJ::CSV::FreeParse(group_uids);

    for(int i = 0; server_uids[i]!=nullptr; i++){
        struct ServerData *server = new ServerData();
        server->UID = server_uids[i];
        server->owner = this;
        LoadServer(server, prefs);

        for(std::vector<std::string>::const_iterator iter = server->group_UIDs.cbegin();
              iter != server->group_UIDs.cend(); iter++){
start:
            if(std::find(guts->groups.cbegin(), guts->groups.cend(), *iter)==guts->groups.cend()){
                guts->groups.push_back(*iter);
                goto start;
            }
        }

        push_back(ServerDataP(server));
    }

    // The individual items are now owned by the ServerData.
    free(server_uids);

    GetAndExist(prefs, "sys.global.nickname", guts->global.nick, "KashyyykUser");
    GetAndExist(prefs, "sys.global.username", guts->global.user, "KashyyykUser");
    GetAndExist(prefs, "sys.global.realname", guts->global.real, "KashyyykUser");

}
Пример #2
0
void BlockWindow::setup() {
	reset();
	help_button_ = new Fl_Button(0, 0, 20, 20, "?");
	help_button_->callback((Fl_Callback *)help_cb, this);
	help_button_->shortcut('?');

	play_button_ = new Fl_Button(80, (h() - 80) / 2, 80, 80, "@>");
	play_button_->callback((Fl_Callback *)play_cb, this);
	play_button_->labelsize(44);
	play_button_->shortcut(' ');

	sound_ = new BlockSound();
	prefs_.get("high_score", high_score_, 0);
	Fl::add_timeout(0.1, (Fl_Timeout_Handler)timeout_cb, (void *)this);
}
Пример #3
0
/*
============================================================================
Routine to create the PeripheralSetup Window and tabs
============================================================================
*/
void cb_SocketSetup (Fl_Widget* w, void*)
{
	Fl_Box* b;
	int		port_num, enabled, telnet;

	// Get socket interface preferences
	virtualt_prefs.get("SocketPort", port_num, get_remote_port());
	telnet = get_remote_telnet();
	enabled = get_remote_enabled();

	// Create Peripheral Setup window
	gsdw = new Fl_Window(300, 260, "Socket Configuration");
	gsdw->callback(cb_sockdlg_win);

	/* Create enable checkbox */
	sockdlg_ctrl.pEnable = new Fl_Check_Button(20, 20, 190, 20, "Enable Socket Interface");
	sockdlg_ctrl.pEnable->callback(cb_sockdlg_enable);
	sockdlg_ctrl.pEnable->value(enabled);

	/* Create input field for for port number */
	b = new Fl_Box(50, 50, 70, 20, "Port Number");
	b->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
	sockdlg_ctrl.pPortNumber = new Fl_Input(160, 50, 60, 20, "");
	sockdlg_ctrl.pPortNumber->align(FL_ALIGN_LEFT);
	sprintf(sockdlg_ctrl.sPortNumber, "%d", port_num);
	sockdlg_ctrl.pPortNumber->value(sockdlg_ctrl.sPortNumber);

	// Create checkbox for telnet mode
	sockdlg_ctrl.pTelnet = new Fl_Check_Button(50, 80, 200, 20, "Telnet Mode (std port is 23)");
	sockdlg_ctrl.pTelnet->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
	sockdlg_ctrl.pTelnet->value(telnet);

	// Deactivate port number and telnet mode if socket interface inactive
	if (!enabled)
	{
		sockdlg_ctrl.pPortNumber->deactivate();
		sockdlg_ctrl.pTelnet->deactivate();
	}

	b = new Fl_Box(20, 130, 120, 20, "Socket Port Status");
	b->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
	sockdlg_ctrl.pStatus = new Fl_Box(50, 160, 200, 20, "");
	sockdlg_ctrl.pStatus->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
	update_port_status();


	// Cancel button
    { Fl_Button* o = new Fl_Button(40, 200, 60, 30, "Cancel");
      o->callback((Fl_Callback*) cb_sockdlg_cancel);
    }

	// Apply button
	sockdlg_ctrl.pApply = new Fl_Button(120, 200, 60, 30, "Apply");
    sockdlg_ctrl.pApply->callback((Fl_Callback*) cb_sockdlg_apply);
 
	// OK button
    { Fl_Return_Button* o = new Fl_Return_Button(200, 200, 60, 30, "OK");
      o->callback((Fl_Callback*)cb_sockdlg_OK);
    }

	gsdw->show();
}