void taddon_connect::post_show(twindow& window)
{
	if(get_retval() == twindow::OK || get_retval() == 3) {
		ttext_box& host_widget =
				find_widget<ttext_box>(&window, "host_name", false);

		host_widget.save_to_history();
	}
}
Example #2
0
void unit_advance::post_show(window& window)
{
	if(get_retval() == retval::OK) {
		selected_index_ = find_widget<listbox>(&window, "advance_choice", false)
			.get_selected_row();
	}
}
Example #3
0
void unit_recruit::post_show(window& window)
{
	if(get_retval() == window::OK) {
		selected_index_ = find_widget<listbox>(&window, "recruit_list", false)
			.get_selected_row();
	}
}
Example #4
0
void tmp_login::post_show(twindow& window)
{
	if(get_retval() == twindow::OK) {
		preferences::set_password(find_widget<tpassword_box>(
				&window, "password", false).get_real_value());
	}
}
void tunit_recall::post_show(twindow& window)
{
	if(get_retval() == twindow::OK) {
		selected_unit_ = find_widget<tlistbox>(&window, "unit_list", false)
			.get_selected_row();
	}
}
Example #6
0
void tunit_attack::post_show(twindow& window)
{
	if(get_retval() == twindow::OK) {
		selected_weapon_ = find_widget<tlistbox>(&window, "weapon_list", false)
								   .get_selected_row();
	}
}
Example #7
0
void tunit_create::post_show(twindow& window)
{
	ttoggle_button& female_toggle = find_widget<ttoggle_button>(
			&window, "female_toggle", false);
	ttoggle_button& namegen_toggle = find_widget<ttoggle_button>(
			&window, "namegen_toggle", false);
	tlistbox& list = find_widget<tlistbox>(&window, "unit_type_list", false);

	choice_ = "";

	if(get_retval() != twindow::OK) {
		return;
	}

	const int selected_row = list.get_selected_row();
	if(selected_row < 0) {
		return;
	}
	else if(static_cast<size_t>(selected_row) >= type_ids_.size()) {
		// FIXME: maybe assert?
		ERR_GUI_G << "unit create dialog has more list items than known unit types; not good\n";
		return;
	}

	last_chosen_type_id = choice_ =
		type_ids_[static_cast<size_t>(selected_row)];
	last_gender = gender_ =
		female_toggle.get_value() ? unit_race::FEMALE : unit_race::MALE;
	last_generate_names_value = generate_name_ =
		namegen_toggle.get_value();
}
Example #8
0
void custom_tod::post_show(window& window)
{
	update_tod_display(window);
	
	if(get_retval() == window::OK) {
		// TODO: save ToD
	}
}
Example #9
0
void unit_recall::post_show(window& window)
{
	listbox& list = find_widget<listbox>(&window, "recall_list", false);
	sort_last = list.get_active_sorting_option();

	if(get_retval() == retval::OK) {
		selected_index_ = list.get_selected_row();
	}
}
void tadvanced_graphics_options::post_show(twindow& /*window*/)
{
    if(get_retval() == twindow::OK) {
        for(const std::string & i : scale_cases) {
            update_scale_case(i);
        }
        image::update_from_preferences();
    }
}
void teditor_set_starting_position::post_show(twindow& window)
{
	if(get_retval() != twindow::OK) {
		return;
	}

	tlistbox& list = find_widget<tlistbox>(&window, "listbox", false);
	selection_ = list.get_selected_row();
}
Example #12
0
void simple_item_selector::post_show(window& window)
{
	if(get_retval() != window::OK) {
		return;
	}

	listbox& list = find_widget<listbox>(&window, "listbox", false);
	index_ = list.get_selected_row();
}
Example #13
0
void ttheme_list::post_show(twindow& window)
{
	if(get_retval() != twindow::OK) {
		return;
	}

	tlistbox& list = find_widget<tlistbox>(&window, "themes", false);
	index_ = list.get_selected_row();
}
Example #14
0
void game_stats::post_show(window& window)
{
	if(get_retval() == retval::OK) {
		const int selected_tab = find_widget<listbox>(&window, "tab_bar", false).get_selected_row();

		const std::string list_id = selected_tab == 0 ? "game_stats_list" : "scenario_settings_list";
		selected_index_ = find_widget<listbox>(&window, list_id, false).get_selected_row();
	}
}
void tcampaign_difficulty::post_show(twindow& window)
{
	if(get_retval() != twindow::OK) {
		selected_difficulty_ = "CANCEL";
		return;
	}

	tlistbox& list = find_widget<tlistbox>(&window, "listbox", false);
	selected_difficulty_ = difficulties_.child("difficulty", list.get_selected_row())["define"].str();
}
Example #16
0
void taddon_connect::post_show(twindow& window)
{
	if(get_retval() == twindow::OK) {
		ttext_box* host_widget = dynamic_cast<ttext_box*>(window.find_widget("host_name", false));
		assert(host_widget);

		host_widget->save_to_history();
		host_name_= host_widget->get_value();
	}
}
Example #17
0
twidget* tbuilder_button::build() const
{
	tbutton* widget = new tbutton();

	init_control(widget);

	widget->set_retval(get_retval(retval_id_, retval_, id));

	DBG_GUI_G << "Window builder: placed button '" << id
			  << "' with definition '" << definition << "'.\n";

	return widget;
}
Example #18
0
void tmp_server_list::post_show(twindow& window)
{
	if(get_retval() == twindow::OK) {

		const tlistbox& list
				= find_widget<const tlistbox>(&window, "server_list", false);

		const tgrid* row = list.get_row_grid(list.get_selected_row());
		assert(row);

		host_name_ = find_widget<const tcontrol>(row, "address", false).label();
	}
}
Example #19
0
void tlanguage_selection::post_show(twindow& window)
{
	if(get_retval() == twindow::OK) {
		const int res = find_widget<tlistbox>(&window, "language_list", false)
								.get_selected_row();

		assert(res != -1);

		const std::vector<language_def>& languages = get_languages();
		::set_language(languages[res]);
		preferences::set_language(languages[res].localename);
	}
}
Example #20
0
twidget* tbuilder_button::build() const
{
	tbutton* button = new tbutton();

	init_control(button);

	button->set_retval(get_retval(retval_id_, retval_, id));

	DBG_GUI << "Window builder: placed button '" << id << "' with defintion '"
		<< definition << "'.\n";

	return button;
}
Example #21
0
widget* builder_menu_button::build() const
{
	menu_button* widget = new menu_button(*this);

	widget->set_retval(get_retval(retval_id_, retval_, id));
	if(!options_.empty()) {
		widget->set_values(options_);
	}

	DBG_GUI_G << "Window builder: placed menu_button '" << id
	          << "' with definition '" << definition << "'.\n";

	return widget;
}
Example #22
0
twidget* tbuilder_toggle_panel::build() const
{
	ttoggle_panel* widget = new ttoggle_panel();

	init_control(widget);

	widget->set_retval(get_retval(retval_id_, retval_, id));

	DBG_GUI_G << "Window builder: placed toggle panel '" << id
			  << "' with definition '" << definition << "'.\n";

	widget->init_grid(grid);
	return widget;
}
void tmp_method_selection::post_show(twindow& window)
{
	if(get_retval() == twindow::OK) {
		ttext_box& user_widget = find_widget<ttext_box>(
				&window, "user_name", false);
		tlistbox& list = find_widget<tlistbox>(&window, "method_list", false);

		choice_ = list.get_selected_row();

		user_widget.save_to_history();
		user_name_ = user_widget.get_value();
		preferences::set_login(user_name_);
	}
}
Example #24
0
void taddon_uninstall_list::post_show(twindow& window)
{
    const tlistbox& list = find_widget<tlistbox>(&window, "addons_list", false);
    const unsigned rows = list.get_item_count();

    assert(rows == this->ids_.size() && rows == this->titles_map_.size());

    if(!rows || get_retval() != twindow::OK) {
        return;
    }

    for(unsigned k = 0; k < rows; ++k) {
        tgrid const* g = list.get_row_grid(k);
        const ttoggle_button& checkbox
            = find_widget<const ttoggle_button>(g, "checkbox", false);
        this->selections_[this->ids_[k]] = checkbox.get_value_bool();
    }
}
Example #25
0
void tunit_create::post_show(twindow& window)
{
	tlistbox& list = find_widget<tlistbox>(&window, "unit_type_list", false);

	choice_ = "";

	if(get_retval() != twindow::OK) {
		return;
	}

	const int selected_row = list.get_selected_row();
	if(selected_row < 0) {
		return;
	} else if(static_cast<size_t>(selected_row) >= units_.size()) {
		// FIXME: maybe assert?
		ERR_GUI_G << "unit create dialog has more list items than known unit "
					 "types; not good\n";
		return;
	}

	last_chosen_type_id = choice_ = units_[selected_row]->id();
	last_gender = gender_;
}
void tformation_attack::post_show(twindow& window)
{
	if (get_retval() == twindow::OK) {
		selected_ = find_widget<tlistbox>(&window, "tactic_list", false).get_selected_row();
	}
}
Example #27
0
void tmp_change_control::post_show(twindow& /*window*/)
{
	view_->post_show(get_retval(), menu_handler_);
}
Example #28
0
void tmp_create_game::post_show(twindow& window)
{
    if(get_retval() == twindow::OK) {
        find_widget<tlistbox>(&window, "map_list", false);
    }
}
Example #29
0
/*
 * Send a command to the service 
 */
int rpc_send_command(char *path, int cmd, int forfd, void *data, int len)
{
  pthread_mutex_lock(&lock);
  char c, padding[] = {PADDING};
  char cmdbuf[BUF_SZ], CANARY[CANARY_SZ+PADDING_SZ], metabuf[BUF_SZ];
  memcpy(CANARY+CANARY_SZ, padding, sizeof(padding));
  uint64_t canary_num;
  // ephemeral RPC socket used only for this command
  int rpc_sock = rpc_join(path);
  // Generate token
  int fdrand = open("/dev/urandom", O_RDONLY);

  if(read(fdrand, &CANARY, CANARY_SZ) < 0) {
     fprintf(stderr,"unable to read from /dev/urandom for RPC canary data\n");
     return -1;  
  }
  memcpy(&canary_num, CANARY, CANARY_SZ);  
  cmdbuf[CMD_ID_IDX] = cmd;
  memcpy(&cmdbuf[CANARY_IDX], &canary_num, CANARY_SZ);
  memcpy(&cmdbuf[STRUCT_IDX], data, len);

#ifdef VERBOSE
  memset(metabuf, 0, BUF_SZ);
  pid_t pid = syscall(SYS_getpid);
  pid_t tid = syscall(SYS_gettid);
  rpc_count++;
  char timestring[20];
  time_t timestamp;
  timestamp = time(NULL);
  strftime(timestring, sizeof(timestring), "%H:%M:%S", localtime(&timestamp));
  memcpy(metabuf, RPC_PHRASE, RPC_PHRASE_SZ); // Write signal phrase
  
  memcpy(&metabuf[IDX_PID],     &pid,         sizeof(pid_t)      ); /* pid       */
  memcpy(&metabuf[IDX_TID],     &tid,         sizeof(pid_t)      ); /* tid       */
  memcpy(&metabuf[IDX_COUNT],   &rpc_count,   sizeof(rpc_count)  ); /* rpc_count */
  memcpy(&metabuf[IDX_TIME],    &timestring,   20                ); /* timestamp */
#endif
  /* Combine command flag+payload with RPC metadata */
  memcpy(&metabuf[IDX_PAYLOAD], cmdbuf, len + 1 + CANARY_SZ);
  
  // Write RPC
  int n_write = write(rpc_sock, &metabuf, BUF_SZ);
  if(n_write < 0) {
    fprintf(stderr, "Error writing command to service (CMD = %d)\n", cmdbuf[CMD_ID_IDX]);
    errno = 0;
  }
  // Write token to corresponding data stream
  if(read(rpc_sock, &c, 1) < 0) {
    fprintf(stderr, "unable to read RPC ACK byte from service.\n");
    return -1;
  }
  if(c == 'z' && n_write > 0 && forfd > -1){
    if(send(forfd, &CANARY, CANARY_SZ+PADDING_SZ, 0) < 0) {
      fprintf(stderr,"unable to write canary to stream\n");
      return -1;
    }
  }
  // Process response from service
  int ret = ERR_OK;
  if(n_write > 0) {
    if(cmdbuf[CMD_ID_IDX]==RPC_SOCKET) {
      pthread_mutex_unlock(&lock);
      return rpc_sock; // Used as new socket
    }
    if(cmdbuf[CMD_ID_IDX]==RPC_CONNECT
      || cmdbuf[CMD_ID_IDX]==RPC_BIND
      || cmdbuf[CMD_ID_IDX]==RPC_LISTEN) {
    	ret = get_retval(rpc_sock);
    }
    if(cmdbuf[CMD_ID_IDX]==RPC_GETSOCKNAME) {
      pthread_mutex_unlock(&lock);
      return rpc_sock; // Don't close rpc here, we'll use it to read getsockopt_st
    }
  }
  else
    ret = -1;
  close(rpc_sock); // We're done with this RPC socket, close it (if type-R)
  pthread_mutex_unlock(&lock);
  return ret;
}
Example #30
0
int main(int argc, char **argv) {
  std::cout << "C++ seems to be working." << std::endl;
  return get_retval();
}