Example #1
0
File: prog.c Project: goneri/burp
int main (int argc, char *argv[])
{
	int ret=0;
	int option=0;
	int daemon=1;
	int forking=1;
	int gotlock=0;
	int strip=0;
	struct config conf;
	int forceoverwrite=0;
	enum action act=ACTION_LIST;
	const char *backup=NULL;
	const char *restoreprefix=NULL;
	const char *regex=NULL;
	const char *browsefile=NULL;
	const char *browsedir=NULL;
	FILE *fp=NULL;
	const char *configfile=get_config_path();
	const char *orig_client=NULL;
	// The orig_client is the original client that the normal client
	// would like to restore from.
#ifndef HAVE_WIN32
	const char *sclient=NULL; // Status monitor client to view.
	int generate_ca_only=0;
#endif

	init_log(argv[0]);

	while((option=getopt(argc, argv, "a:b:c:C:d:ghfFil:nr:s:vz:?"))!=-1)
	{
		switch(option)
		{
			case 'a':
				if(!strncmp(optarg, "backup", 1))
					act=ACTION_BACKUP;
				else if(!strncmp(optarg, "timedbackup", 1))
					act=ACTION_BACKUP_TIMED;
				else if(!strncmp(optarg, "restore", 1))
					act=ACTION_RESTORE;
				else if(!strncmp(optarg, "verify", 1))
					act=ACTION_VERIFY;
				else if(!strncmp(optarg, "list", 1))
					act=ACTION_LIST;
				else if(!strncmp(optarg, "List", 1))
					act=ACTION_LONG_LIST;
				else if(!strncmp(optarg, "status", 1))
					act=ACTION_STATUS;
				else if(!strncmp(optarg, "Status", 1))
					act=ACTION_STATUS_SNAPSHOT;
				else if(!strncmp(optarg, "estimate", 1))
					act=ACTION_ESTIMATE;
				else
				{
					usage();
					return 1;
				}
				break;
			case 'b':
				backup=optarg;
				break;
			case 'c':
				configfile=optarg;
				break;
			case 'C':
				orig_client=optarg;
#ifndef HAVE_WIN32
				sclient=optarg;
#endif
				break;
			case 'd':
				restoreprefix=optarg; // for restores
				browsedir=optarg; // for lists
				break;
			case 'f':
				forceoverwrite=1;
				break;
			case 'F':
				daemon=0;
				break;
			case 'g':
#ifndef HAVE_WIN32
				generate_ca_only=1;
#endif
				break;
			case 'i':
				print_all_cmds();
				return 0;
			case 'l':
				logp("-l <logfile> option obsoleted\n");
				break;
			case 'n':
				forking=0;
				break;
			case 'r':
				regex=optarg;
				break;
			case 's':
				strip=atoi(optarg);
				break;
			case 'v':
				printf("%s-%s\n", progname(), VERSION);
				return 0;
			case 'z':
				browsefile=optarg;
				break;
			case 'h':
			case '?':
			default:
				usage();
				return 1;
				break;
		}
	}
	if(optind<argc)
	{
		usage();
		return 1;
	}

	if(reload(&conf, configfile,
	  1 /* first time */,
	  0 /* no oldmax_children setting */,
	  0 /* no oldmax_status_children setting */)) return 1;

	if((act==ACTION_RESTORE || act==ACTION_VERIFY) && !backup)
	{
		logp("No backup specified. Using the most recent.\n");
		backup="0";
	}

	if(conf.mode==MODE_CLIENT)
	{
		if(orig_client && *orig_client)
		{
			if(!(conf.orig_client=strdup(orig_client)))
			{
				logp("out of memory\n");
				return 1;
			}
		}
	}

	if(conf.mode==MODE_SERVER
	  && (act==ACTION_STATUS || act==ACTION_STATUS_SNAPSHOT))
	{
		// Server status mode needs to run without getting the lock.
	}
	else
	{
		if(get_lock(conf.lockfile))
		{
			logp("Could not get lockfile.\n");
			logp("Another process is probably running,\n");
			logp("or you do not have permissions to write to %s.\n",
				conf.lockfile);
			return 1;
		}
		gotlock++;
	}

	conf.overwrite=forceoverwrite;
	conf.strip=strip;
	conf.forking=forking;
	conf.daemon=daemon;
	if(replace_conf_str(backup, &(conf.backup))
	  || replace_conf_str(restoreprefix, &(conf.restoreprefix))
	  || replace_conf_str(regex, &(conf.regex))
	  || replace_conf_str(browsefile, &(conf.browsefile))
	  || replace_conf_str(browsedir, &(conf.browsedir)))
		return -1;
	if(conf.mode==MODE_SERVER)
	{
#ifdef HAVE_WIN32
		logp("Sorry, server mode is not implemented for Windows.\n");
#else
		if(act==ACTION_STATUS || act==ACTION_STATUS_SNAPSHOT)
		{
			// We are running on the server machine, being a client
			// of the burp server, getting status information.
			ret=status_client_ncurses(&conf, act, sclient);
		}
		else
			ret=server(&conf, configfile,
				generate_ca_only);
#endif
	}
	else
	{
		logp("before client\n");
		ret=client(&conf, act);
		logp("after client\n");
	}

	if(gotlock) unlink(conf.lockfile);
	free_config(&conf);

	// If there was no forking, logfp ends up getting closed before this
	// and will segfault if we try to do it again.
	if(fp && conf.forking) fclose(fp);
	return ret;
}
 void FontTexture::bind()
 {
     reload();
     glBindTexture(GL_TEXTURE_2D, id);
 }
void KreCategoriesListWidget::createCategory( const Element & category, int parent_id )
{
	reload( ForceReload );
}
Example #4
0
void PainterTerrain::setWaterAlgorithm(PathWaterAlgorithm *da){
    water_algorithm = da;
    render_tab = render_water;
    QObject::connect(water_algorithm, SIGNAL(reload()), this, SLOT(updateGL()));
    this->GLWidget::updateGL();
}
Example #5
0
void PainterTerrain::setFluvialTerraceAlgorithm(FluvialTerraceAlgorithm* alg){
    fluvial_terrace_algorithm = alg;
    render_tab = render_fluvial_terraces;
    QObject::connect(fluvial_terrace_algorithm, SIGNAL(reload()), this, SLOT(updateGL()));
    this->GLWidget::updateGL();
}
void KOEventEditor::modified()
{
  // Play dumb, just reload the event. This dialog has become so complicated
  // that there is no point in trying to be smart here...
  reload();
}
Example #7
0
void PainterTerrain::setDrainageAlgorithm(DrainageAlgorithms *da){
    drainage_algorithm = da;
    render_tab = render_drainage;
    QObject::connect(drainage_algorithm, SIGNAL(reload()), this, SLOT(updateGL()));
    this->GLWidget::updateGL();
}
Example #8
0
void gRuleEditorWidget::on_btnRemoveEvent_clicked()
{
    if(ui->listEvents->selectedItems().count() == 0)return;
    m_conn.removeSenderEvent(ui->listEvents->currentRow());
    reload();
}
Example #9
0
ShadingModel::ShadingModel(std::string const& name,
                           std::string const& file_name)
    : file_name_(file_name), shader_stages_(4), name_(name) {

  reload();
}
Example #10
0
void create()
{
  reload("tianzhu_huang_tang");
  set_name("╗к╠└", ({"huang tang", "huang", "tang"}));
void KonqSideBarWebModule::pageLoaded() {
    if( reloadTimeout > 0 ) {
        QTimer::singleShot( reloadTimeout, this, SLOT(reload()) );
    }
}
Example #12
0
ImageStatus ImageItem::render(const RenderSetting &setting, ImageModel *model)
{
    if (renderSetting() == setting && renderStatus() == IMAGE_STATUS_DONE)
    {
        qDebug("Image:%s is already ready\n", name().toStdString().c_str());
        return renderStatus();
    }

    // MUST NOT reload at this time
    setRenderStatus(IMAGE_STATUS_WAIT);
    qDebug("Render Image:%s!!! \n", name().toStdString().c_str());

    if (!(renderSetting() == setting) &&
        !model->getImagesMgr().makeEnoughMemory(tryCalcImageLength(
                                                setting.contentArea().width(),
                                                setting.contentArea().height(),
                                                QImage::Format_Indexed8),
                                                name(),
                                                model->renderPolicy()))
    {
        setRenderStatus(IMAGE_STATUS_ABORT);
        return renderStatus();
    }

    // if the data is null, reload the image
    if (needReload(setting) && !reload())
    {
        qWarning("Reload fails\n\n");
        setRenderStatus(IMAGE_STATUS_ABORT);
        return renderStatus();
    }

    if (data_ == 0)
    {
        setRenderStatus(IMAGE_STATUS_ABORT);
        return renderStatus();
    }

    int cur_area_size = data_->width() * data_->height();
    int scaled_area_size = setting.contentArea().width() * setting.contentArea().height();
    if (cur_area_size < scaled_area_size)
    {
        // pre-quantize
        quantize();
    }
    else if (cur_area_size > scaled_area_size)
    {
        dirty_ = true;
    }

    if (setting.rotation() != renderSetting().rotation())
    {
        rotate(setting.rotation());
    }

    if (setting.contentArea() != renderSetting().contentArea())
    {
        if (!scaled(setting.contentArea().size()))
        {
            setRenderStatus(IMAGE_STATUS_ABORT);
            return renderStatus();
        }
    }

    // post-quantize
    quantize();

    setRenderSetting(setting);
    setRenderStatus(IMAGE_STATUS_DONE);
    return renderStatus();
}
Example #13
0
ImageStatus ImageItem::renderThumbnail(const QRect &bounding_rect,
                                       QRect &display_area,
                                       shared_ptr<ImageThumbnail> thumbnail,
                                       ImageModel *model)
{
    // check the previous thumbnail image
    if (thumbnail->image() != 0)
    {
        if (thumbnail->size() != display_area.size())
        {
            thumbnail->clearPage();
        }
        else
        {
            return IMAGE_STATUS_DONE;
        }
    }

    // if there is no data being loaded, reload the image
    scoped_ptr<QImage> cur_data;
    if (data_ == 0)
    {
        reload();
    }
    cur_data.reset(new QImage(*data_));

    if (!display_area.isValid())
    {
        getThumbnailRectangle(bounding_rect, cur_data->size(), &display_area);
    }

    if (model->getThumbsMgr().makeEnoughMemory(tryCalcImageLength(
                                               display_area.width(),
                                               display_area.height(),
                                               QImage::Format_Indexed8),
                                               name(),
                                               model->renderPolicy()))
    {
        int width  = display_area.width();
        int height = display_area.height();

        int cur_area_size = cur_data->width() * cur_data->height();
        int scaled_area_size = width * height;
        bool dithered = false;
        if (cur_area_size < scaled_area_size)
        {
            // pre-dither
            dithering_strategy_->dither(cur_data.get());
            dithered = true;
        }

        if (cur_data->size() != display_area.size())
        {
            cur_data.reset(scaled(display_area.size(), cur_data.get()));
        }

        if (!dithered && ImageGlobalSettings::instance().needDither())
        {
            // post-dither
            dithering_strategy_->dither(cur_data.get());
        }

        thumbnail->setImage(cur_data.release());
        thumbnail->setOriginSize(actualSize());
        return IMAGE_STATUS_DONE;
    }
    return IMAGE_STATUS_FAIL;
}
Example #14
0
void AttributeManager::initialize()
{
    reload();
}
Example #15
0
EnvMap::EnvMap(QProcess *process)
 : QObject(0), _process(process)
{
    reload();
}
Example #16
0
void create()
{
  reload("wuji_xiaoer_er");
  set_name("店小二", ({"xiao er","xiaoer","xiao","waiter","er"}));
// Reload the configuration using the specified configuration loader
bool Configuration::reload(ConfigLoader* configLoader)
{
	this->configLoader = configLoader;

	return reload();
}
Example #18
0
void create()
{
  reload("zhuzi_wan_koufu");
  set_name("万口福", ({"wan koufu", "wan"}));
Example #19
0
/* Many execution paths may lead to this code so it needs to take appropriate
 * precausions to stuff like doc_view and doc_view->vs being NULL. */
enum frame_event_status
do_action(struct session *ses, enum main_action action_id, int verbose)
{
	enum frame_event_status status = FRAME_EVENT_OK;
	struct terminal *term = ses->tab->term;
	struct document_view *doc_view = current_frame(ses);
	struct link *link = NULL;

	if (action_id == -1) goto unknown_action;

	if (doc_view && doc_view->vs) {
		if (action_prefix_is_link_number(KEYMAP_MAIN, action_id)
		    && !try_jump_to_link_number(ses, doc_view))
			goto ignore_action;

		link = get_current_link(doc_view);

	} else if (action_requires_view_state(KEYMAP_MAIN, action_id)) {
		goto ignore_action;
	}

	if (action_requires_location(KEYMAP_MAIN, action_id)
	    && !have_location(ses))
		return FRAME_EVENT_OK;

	if (action_requires_link(KEYMAP_MAIN, action_id)
	    && !link)
		goto ignore_action;

	if (action_requires_form(KEYMAP_MAIN, action_id)
	    && (!link || !link_is_form(link)))
		goto ignore_action;

	if (!action_is_anonymous_safe(KEYMAP_MAIN, action_id)
	    && get_cmd_opt_bool("anonymous"))
		goto ignore_action;

	/* Please keep in alphabetical order for now. Later we can sort by most
	 * used or something. */
	switch (action_id) {
		case ACT_MAIN_ABORT_CONNECTION:
			abort_loading(ses, 1);
			print_screen_status(ses);
			break;

		case ACT_MAIN_ADD_BOOKMARK:
#ifdef CONFIG_BOOKMARKS
			launch_bm_add_doc_dialog(term, NULL, ses);
#endif
			break;
		case ACT_MAIN_ADD_BOOKMARK_LINK:
#ifdef CONFIG_BOOKMARKS
			launch_bm_add_link_dialog(term, NULL, ses);
#endif
			break;
		case ACT_MAIN_ADD_BOOKMARK_TABS:
#ifdef CONFIG_BOOKMARKS
			bookmark_terminal_tabs_dialog(term);
#endif
			break;

		case ACT_MAIN_AUTH_MANAGER:
			auth_manager(ses);
			break;

		case ACT_MAIN_BACKSPACE_PREFIX:

			if (!ses->kbdprefix.repeat_count) break;

			set_kbd_repeat_count(ses,
			                     ses->kbdprefix.repeat_count / 10);

			/* Keep send_event from resetting repeat_count. */
			status = FRAME_EVENT_SESSION_DESTROYED;

			break;

		case ACT_MAIN_BOOKMARK_MANAGER:
#ifdef CONFIG_BOOKMARKS
			bookmark_manager(ses);
#endif
			break;

		case ACT_MAIN_CACHE_MANAGER:
			cache_manager(ses);
			break;

		case ACT_MAIN_CACHE_MINIMIZE:
			shrink_memory(1);
			break;

		case ACT_MAIN_COOKIES_LOAD:
#ifdef CONFIG_COOKIES
			if (!get_opt_bool("cookies.save", NULL)) break;
			load_cookies();
#endif
			break;

		case ACT_MAIN_COOKIE_MANAGER:
#ifdef CONFIG_COOKIES
			cookie_manager(ses);
#endif
			break;

		case ACT_MAIN_COPY_CLIPBOARD:
			status = copy_current_link_to_clipboard(ses, doc_view, 0);
			break;

		case ACT_MAIN_DOCUMENT_INFO:
			document_info_dialog(ses);
			break;

		case ACT_MAIN_DOWNLOAD_MANAGER:
			download_manager(ses);
			break;

		case ACT_MAIN_EXMODE:
#ifdef CONFIG_EXMODE
			exmode_start(ses);
#endif
			break;

		case ACT_MAIN_FILE_MENU:
			activate_bfu_technology(ses, 0);
			break;

		case ACT_MAIN_FIND_NEXT:
			status = find_next(ses, doc_view, 1);
			break;

		case ACT_MAIN_FIND_NEXT_BACK:
			status = find_next(ses, doc_view, -1);
			break;

		case ACT_MAIN_FORGET_CREDENTIALS:
			free_auth();
			shrink_memory(1); /* flush caches */
			break;

		case ACT_MAIN_FORMHIST_MANAGER:
#ifdef CONFIG_FORMHIST
			formhist_manager(ses);
#endif
			break;

		case ACT_MAIN_FRAME_EXTERNAL_COMMAND:
			status = pass_uri_to_command(ses, doc_view,
			                             PASS_URI_FRAME);
			break;

		case ACT_MAIN_FRAME_NEXT:
			next_frame(ses, 1);
			draw_formatted(ses, 0);
			break;

		case ACT_MAIN_FRAME_MAXIMIZE:
			status = set_frame(ses, doc_view, 0);
			break;

		case ACT_MAIN_FRAME_PREV:
			next_frame(ses, -1);
			draw_formatted(ses, 0);
			break;

		case ACT_MAIN_GOTO_URL:
			goto_url_action(ses, NULL);
			break;

		case ACT_MAIN_GOTO_URL_CURRENT:
			goto_url_action(ses, get_current_url);
			break;

		case ACT_MAIN_GOTO_URL_CURRENT_LINK:
			goto_url_action(ses, get_current_link_url);
			break;

		case ACT_MAIN_GOTO_URL_HOME:
			goto_url_home(ses);
			break;

		case ACT_MAIN_HEADER_INFO:
			protocol_header_dialog(ses);
			break;

		case ACT_MAIN_HISTORY_MANAGER:
#ifdef CONFIG_GLOBHIST
			history_manager(ses);
#endif
			break;

		case ACT_MAIN_HISTORY_MOVE_BACK:
		{
			int count = int_max(1, eat_kbd_repeat_count(ses));

			go_history_by_n(ses, -count);
			break;
		}
		case ACT_MAIN_HISTORY_MOVE_FORWARD:
		{
			int count = int_max(1, eat_kbd_repeat_count(ses));

			go_history_by_n(ses, count);
			break;
		}
		case ACT_MAIN_JUMP_TO_LINK:
			break;

		case ACT_MAIN_KEYBINDING_MANAGER:
			keybinding_manager(ses);
			break;

		case ACT_MAIN_KILL_BACKGROUNDED_CONNECTIONS:
			abort_background_connections();
			break;

		case ACT_MAIN_LINK_DIALOG:
			open_link_dialog(ses);
			break;

		case ACT_MAIN_LINK_DOWNLOAD:
		case ACT_MAIN_LINK_DOWNLOAD_IMAGE:
		case ACT_MAIN_LINK_DOWNLOAD_RESUME:
			status = download_link(ses, doc_view, action_id);
			break;

		case ACT_MAIN_LINK_EXTERNAL_COMMAND:
			status = pass_uri_to_command(ses, doc_view,
			                             PASS_URI_LINK);
			break;

		case ACT_MAIN_LINK_FOLLOW:
			status = enter(ses, doc_view, 0);
			break;

		case ACT_MAIN_LINK_FOLLOW_RELOAD:
			status = enter(ses, doc_view, 1);
			break;

		case ACT_MAIN_LINK_INFO:
			link_info_dialog(ses);
			break;
			
		case ACT_MAIN_LINK_MENU:
			link_menu(term, NULL, ses);
			break;

		case ACT_MAIN_LINK_FORM_MENU:
			link_form_menu(ses);
			break;

		case ACT_MAIN_LUA_CONSOLE:
#ifdef CONFIG_SCRIPTING_LUA
			trigger_event_name("dialog-lua-console", ses);
#endif
			break;

		case ACT_MAIN_MARK_SET:
#ifdef CONFIG_MARKS
			ses->kbdprefix.mark = KP_MARK_SET;
			status = FRAME_EVENT_REFRESH;
#endif
			break;

		case ACT_MAIN_MARK_GOTO:
#ifdef CONFIG_MARKS
			/* TODO: Show promptly a menu (or even listbox?)
			 * with all the marks. But the next letter must
			 * still choose a mark directly! --pasky */
			ses->kbdprefix.mark = KP_MARK_GOTO;
			status = FRAME_EVENT_REFRESH;
#endif
			break;

		case ACT_MAIN_MENU:
			activate_bfu_technology(ses, -1);
			break;

		case ACT_MAIN_MOVE_CURRENT_TOP:
			status = move_current_top(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_CURSOR_UP:
			status = move_cursor_up(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_CURSOR_DOWN:
			status = move_cursor_down(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_CURSOR_LEFT:
			status = move_cursor_left(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_CURSOR_RIGHT:
			status = move_cursor_right(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_CURSOR_LINE_START:
			status = move_cursor_line_start(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_HALF_PAGE_DOWN:
			status = move_half_page_down(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_HALF_PAGE_UP:
			status = move_half_page_up(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_LINK_DOWN:
			status = move_link_down(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_LINK_DOWN_LINE:
			status = move_link_down_line(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_LINK_LEFT:
			status = move_link_left(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_LINK_LEFT_LINE:
			status = move_link_prev_line(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_LINK_NEXT:
			status = move_link_next(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_LINK_PREV:
			status = move_link_prev(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_LINK_RIGHT:
			status = move_link_right(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_LINK_RIGHT_LINE:
			status = move_link_next_line(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_LINK_UP:
			status = move_link_up(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_LINK_UP_LINE:
			status = move_link_up_line(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_PAGE_DOWN:
			status = move_page_down(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_PAGE_UP:
			status = move_page_up(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_DOCUMENT_START:
			status = move_document_start(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_DOCUMENT_END:
			status = move_document_end(ses, doc_view);
			break;

		case ACT_MAIN_OPEN_LINK_IN_NEW_TAB:
			open_current_link_in_new_tab(ses, 0);
			break;

		case ACT_MAIN_OPEN_LINK_IN_NEW_TAB_IN_BACKGROUND:
			open_current_link_in_new_tab(ses, 1);
			break;

		case ACT_MAIN_OPEN_LINK_IN_NEW_WINDOW:
			open_in_new_window(term, send_open_in_new_window, ses);
			break;

		case ACT_MAIN_OPEN_NEW_TAB:
			open_uri_in_new_tab(ses, NULL, 0, 1);
			break;

		case ACT_MAIN_OPEN_NEW_TAB_IN_BACKGROUND:
			open_uri_in_new_tab(ses, NULL, 1, 1);
			break;

		case ACT_MAIN_OPEN_NEW_WINDOW:
			open_in_new_window(term, send_open_new_window, ses);
			break;

		case ACT_MAIN_OPEN_OS_SHELL:
			exec_shell(term);
			break;

		case ACT_MAIN_OPTIONS_MANAGER:
			options_manager(ses);
			break;

		case ACT_MAIN_QUIT:
			exit_prog(ses, 1);
			break;

		case ACT_MAIN_REALLY_QUIT:
			exit_prog(ses, 0);
			break;

		case ACT_MAIN_REDRAW:
			redraw_terminal_cls(term);
			break;

		case ACT_MAIN_RELOAD:
			reload(ses, CACHE_MODE_INCREMENT);
			break;

		case ACT_MAIN_RERENDER:
			draw_formatted(ses, 2);
			break;

		case ACT_MAIN_RESET_FORM:
			status = reset_form(ses, doc_view, 0);
			break;

		case ACT_MAIN_RESOURCE_INFO:
			resource_info(term);
			break;

		case ACT_MAIN_SAVE_AS:
			status = save_as(ses, doc_view, 0);
			break;

		case ACT_MAIN_SAVE_FORMATTED:
			status = save_formatted_dlg(ses, doc_view, 0);
			break;

		case ACT_MAIN_SAVE_OPTIONS:
			write_config(term);
			break;

		case ACT_MAIN_SAVE_URL_AS:
			save_url_as(ses);
			break;

		case ACT_MAIN_SCROLL_DOWN:
			status = scroll_down(ses, doc_view);
			break;

		case ACT_MAIN_SCROLL_LEFT:
			status = scroll_left(ses, doc_view);
			break;

		case ACT_MAIN_SCROLL_RIGHT:
			status = scroll_right(ses, doc_view);
			break;

		case ACT_MAIN_SCROLL_UP:
			status = scroll_up(ses, doc_view);
			break;

		case ACT_MAIN_SEARCH:
			status = search_dlg(ses, doc_view, 1);
			break;

		case ACT_MAIN_SEARCH_BACK:
			status = search_dlg(ses, doc_view, -1);
			break;

		case ACT_MAIN_SEARCH_TYPEAHEAD:
		case ACT_MAIN_SEARCH_TYPEAHEAD_LINK:
		case ACT_MAIN_SEARCH_TYPEAHEAD_TEXT:
		case ACT_MAIN_SEARCH_TYPEAHEAD_TEXT_BACK:
			status = search_typeahead(ses, doc_view, action_id);
			break;

		case ACT_MAIN_SHOW_TERM_OPTIONS:
			terminal_options(term, NULL, ses);
			break;

		case ACT_MAIN_SUBMIT_FORM:
			status = submit_form(ses, doc_view, 0);
			break;

		case ACT_MAIN_SUBMIT_FORM_RELOAD:
			status = submit_form(ses, doc_view, 1);
			break;

		case ACT_MAIN_TAB_CLOSE:
			close_tab(term, ses);
			status = FRAME_EVENT_SESSION_DESTROYED;
			break;

		case ACT_MAIN_TAB_CLOSE_ALL_BUT_CURRENT:
			close_all_tabs_but_current(ses);
			break;

		case ACT_MAIN_TAB_EXTERNAL_COMMAND:
			status = pass_uri_to_command(ses, doc_view,
			                             PASS_URI_TAB);
			break;

		case ACT_MAIN_TAB_MOVE_LEFT:
			move_current_tab(ses, -1);
			break;

		case ACT_MAIN_TAB_MOVE_RIGHT:
			move_current_tab(ses, 1);
			break;

		case ACT_MAIN_TAB_MENU:
			assert(ses->tab == get_current_tab(term));

			if (ses->status.show_tabs_bar)
				tab_menu(ses, ses->tab->xpos,
					 term->height - 1
					  - ses->status.show_status_bar,
					 1);
			else
				tab_menu(ses, 0, 0, 0);

			break;

		case ACT_MAIN_TAB_NEXT:
			switch_current_tab(ses, 1);
			break;

		case ACT_MAIN_TAB_PREV:
			switch_current_tab(ses, -1);
			break;

		case ACT_MAIN_TERMINAL_RESIZE:
			resize_terminal_dialog(term);
			break;

		case ACT_MAIN_TOGGLE_CSS:
#ifdef CONFIG_CSS
			toggle_document_option(ses, "document.css.enable");
#endif
			break;

		case ACT_MAIN_TOGGLE_DISPLAY_IMAGES:
			toggle_document_option(ses, "document.browse.images.show_as_links");
			break;

		case ACT_MAIN_TOGGLE_DISPLAY_TABLES:
			toggle_document_option(ses, "document.html.display_tables");
			break;

		case ACT_MAIN_TOGGLE_DOCUMENT_COLORS:
			toggle_document_option(ses, "document.colors.use_document_colors");
			break;

		case ACT_MAIN_TOGGLE_HTML_PLAIN:
			toggle_plain_html(ses, ses->doc_view, 0);
			break;

		case ACT_MAIN_TOGGLE_MOUSE:
#ifdef CONFIG_MOUSE
			toggle_mouse();
#endif
			break;

		case ACT_MAIN_TOGGLE_NUMBERED_LINKS:
			toggle_document_option(ses, "document.browse.links.numbering");
			break;

		case ACT_MAIN_TOGGLE_PLAIN_COMPRESS_EMPTY_LINES:
			toggle_document_option(ses, "document.plain.compress_empty_lines");
			break;

		case ACT_MAIN_TOGGLE_WRAP_TEXT:
			toggle_wrap_text(ses, ses->doc_view, 0);
			break;

		case ACT_MAIN_VIEW_IMAGE:
			status = view_image(ses, doc_view, 0);
			break;

		case ACT_MAIN_SCRIPTING_FUNCTION:
		case ACT_MAIN_NONE:
		case MAIN_ACTIONS:
		default:
unknown_action:
			if (verbose) {
				INTERNAL("No action handling defined for '%s'.",
					 get_action_name(KEYMAP_MAIN, action_id));
			}

			status = FRAME_EVENT_IGNORED;
	}

ignore_action:
	/* XXX: At this point the session may have been destroyed */

	if (status != FRAME_EVENT_SESSION_DESTROYED
	    && ses->insert_mode == INSERT_MODE_ON
	    && link != get_current_link(doc_view))
		ses->insert_mode = INSERT_MODE_OFF;

	if (status == FRAME_EVENT_REFRESH && doc_view)
		refresh_view(ses, doc_view, 0);

	return status;
}
void Weapon::loadAmmo(std::string name, double mass) {
    m_bullet_type = name;
    m_bullet_mass = mass;
    m_capacity_current = capacityMax();
    reload();
}
Example #21
0
void PainterTerrain::setPatternAlgorithm(AlgorithmPatron *da){
    pattern_algorithm = da;
    render_tab = render_patterns;
    QObject::connect(pattern_algorithm, SIGNAL(reload()), this, SLOT(updateGL()));
    this->GLWidget::updateGL();
}
void PathWaterCallaghanAlgorithm::changeAttr(){
    this->run(coords_asked, ter);
    emit reload();
}
Example #23
0
void PainterTerrain::setNetworkAlgorithm(BuildNetwork* alg){
    build_network = alg;
    render_tab = render_network;
    QObject::connect(build_network, SIGNAL(reload()), this, SLOT(updateGL()));
    this->GLWidget::updateGL();
}
Example #24
0
/*!
 * \brief Applies the settings set with setDisplaySizes
 * \returns true is everything went fine and false if not
 */
bool iRandR::applyNewRandRSettings() {
   vPreviousConfig_eD = vCurrentConfig_eD;

   bool lRetrunValue_B = false;

   for ( iDisplays const &disp : vDisplaysToChange_eD ) {
      DEVMODEW lDevmodeToChange_win32 = disp.getSelectedDevmode();

      iLOG( "Change ",
            disp.getDisplayDevice().DeviceName,
            " to: ",
            (int32_t)lDevmodeToChange_win32.dmPelsWidth,
            "x",
            (int32_t)lDevmodeToChange_win32.dmPelsHeight );
      switch ( ChangeDisplaySettingsExW(
            disp.getDisplayDevice().DeviceName,
            &lDevmodeToChange_win32,
            NULL,
            ( CDS_UPDATEREGISTRY | CDS_NORESET ), // We will apply the settings later
            NULL ) ) {
         case DISP_CHANGE_SUCCESSFUL:
            iLOG( "Successfully changed display ", disp.getDisplayDevice().DeviceName, "  [set]" );
            lRetrunValue_B = true;
            break;

         case DISP_CHANGE_BADDUALVIEW:
            wLOG( "ChangeDisplaySettingsEx returned DISP_CHANGE_BADDUALVIEW [set]" );
            break;

         case DISP_CHANGE_BADFLAGS:
            wLOG( "ChangeDisplaySettingsEx returned DISP_CHANGE_BADFLAGS [set]" );
            break;

         case DISP_CHANGE_BADMODE:
            wLOG( "ChangeDisplaySettingsEx returned DISP_CHANGE_BADMODE [set]" );
            break;

         case DISP_CHANGE_BADPARAM:
            wLOG( "ChangeDisplaySettingsEx returned DISP_CHANGE_BADPARAM [set]" );
            break;

         case DISP_CHANGE_FAILED:
            wLOG( "ChangeDisplaySettingsEx returned DISP_CHANGE_FAILED [set]" );
            break;

         case DISP_CHANGE_NOTUPDATED:
            wLOG( "ChangeDisplaySettingsEx returned DISP_CHANGE_NOTUPDATED [set]" );
            break;

         case DISP_CHANGE_RESTART:
            wLOG( "ChangeDisplaySettingsEx returned DISP_CHANGE_FAILED [set] (You need to restart "
                  "yout PC because you have Windows)" );
            break;

         default: eLOG( "ChangeDisplaySettingsEx returned a unknown error [set]" ); break;
      }
   }

   // Now really apply the settings
   switch ( ChangeDisplaySettingsExW( NULL, NULL, NULL, 0, NULL ) ) {
      case DISP_CHANGE_SUCCESSFUL:
         iLOG( "Successfully applyed display changes [apply]" );
         lRetrunValue_B = true;
         break;

      case DISP_CHANGE_BADDUALVIEW:
         wLOG( "ChangeDisplaySettingsEx returned DISP_CHANGE_BADDUALVIEW [apply]" );
         break;

      case DISP_CHANGE_BADFLAGS:
         wLOG( "ChangeDisplaySettingsEx returned DISP_CHANGE_BADFLAGS [apply]" );
         break;

      case DISP_CHANGE_BADMODE:
         wLOG( "ChangeDisplaySettingsEx returned DISP_CHANGE_BADMODE [apply]" );
         break;

      case DISP_CHANGE_BADPARAM:
         wLOG( "ChangeDisplaySettingsEx returned DISP_CHANGE_BADPARAM [apply]" );
         break;

      case DISP_CHANGE_FAILED:
         wLOG( "ChangeDisplaySettingsEx returned DISP_CHANGE_FAILED [apply]" );
         break;

      case DISP_CHANGE_NOTUPDATED:
         wLOG( "ChangeDisplaySettingsEx returned DISP_CHANGE_NOTUPDATED [apply]" );
         break;

      case DISP_CHANGE_RESTART:
         wLOG( "ChangeDisplaySettingsEx returned DISP_CHANGE_FAILED [apply] (You need to restart "
               "yout PC because you have Windows)" );
         break;

      default: eLOG( "ChangeDisplaySettingsEx returned a unknown error [apply]" ); break;
   }

   vDisplaysToChange_eD.clear();

   reload();
   return lRetrunValue_B;
}
Example #25
0
Storage::Storage() :
	isChanged_(false)
{
	reload();
}
Example #26
0
iRandR::iRandR() {
   vDisplaysToChange_eD.clear();
   reload();
   vDefaultConfig_eD = vPreviousConfig_eD = vCurrentConfig_eD;
}
Example #27
0
void *MsgViewBase::processEvent(Event *e)
{
    if ((e->type() == EventRewriteMessage) || (e->type() == EventMessageRead)){
        Message *msg = (Message*)(e->param());
        if (msg->contact() != m_id)
            return NULL;
        unsigned i;
        for (i = 0; i < (unsigned)paragraphs(); i++){
            QString s = text(i);
            int n = s.find(MSG_ANCHOR);
            if (n < 0)
                continue;
            s = s.mid(n + strlen(MSG_ANCHOR));
            n = s.find("\"");
            if (n < 0)
                continue;
            string client;
            if ((messageId(s.left(n), client) == msg->id()) && (client == msg->client()))
                break;
        }
        if (i >= (unsigned)paragraphs())
            return NULL;
        Msg_Id id;
        id.id     = msg->id();
        id.client = msg->client();
        m_updated.push_back(id);
        QTimer::singleShot(0, this, SLOT(update()));
        return NULL;
    }
    if (e->type() == EventCutHistory){
        CutHistory *ch = (CutHistory*)(e->param());
        if (ch->contact != m_id)
            return NULL;

        bool bDelete = false;
        vector<unsigned> start_pos;
        vector<unsigned> end_pos;
        for (unsigned i = 0; i < (unsigned)paragraphs(); i++){
            QString s = text(i);
            int n = s.find(MSG_ANCHOR);
            if (n < 0)
                continue;
            s = s.mid(n + strlen(MSG_ANCHOR));
            n = s.find("\"");
            if (n < 0)
                continue;
            string client;
            unsigned id = messageId(s.left(n), client);
            if ((client == ch->client) && (id >= ch->from) && (id < ch->from + ch->size)){
                if (!bDelete){
                    bDelete = true;
                    start_pos.push_back(i);
                }
            }else{
                if (bDelete){
                    bDelete = false;
                    end_pos.push_back(i);
                }
            }
        }
        if (bDelete)
            end_pos.push_back(paragraphs());
        if (start_pos.size()){
            int paraFrom, indexFrom;
            int paraTo, indexTo;
            getSelection(&paraFrom, &indexFrom, &paraTo, &indexTo);
            QPoint p = QPoint(0, 0);
            p = mapToGlobal(p);
            p = viewport()->mapFromGlobal(p);
            int x, y;
            viewportToContents(p.x(), p.y(), x, y);
            int para;
            int pos = charAt(QPoint(x, y), &para);
            setReadOnly(false);
            for (unsigned i = 0; i < start_pos.size(); i++){
                setSelection(start_pos[i], 0, end_pos[i], 0);
                removeSelectedText();
                if ((unsigned)pos >= start_pos[i])
                    pos = end_pos[i] - start_pos[i];
            }
            if ((paraFrom == -1) && (paraTo == -1)){
                if (pos == -1){
                    scrollToBottom();
                }else{
                    setCursorPosition(para, pos);
                    ensureCursorVisible();
                }
            }else{
                setSelection(paraFrom, indexFrom, paraTo, indexTo);
            }
            setReadOnly(true);
            repaint();
        }
        m_cut.push_back(*ch);
        return NULL;
    }
    if (e->type() == EventMessageDeleted){
        Message *msg = (Message*)(e->param());
        if (msg->contact() != m_id)
            return NULL;
        for (unsigned i = 0; i < (unsigned)paragraphs(); i++){
            QString s = text(i);
            int n = s.find(MSG_ANCHOR);
            if (n < 0)
                continue;
            s = s.mid(n + strlen(MSG_ANCHOR));
            n = s.find("\"");
            if (n < 0)
                continue;
            string client;
            if ((messageId(s.left(n), client) != msg->id()) || (client != msg->client()))
                continue;
            string ss;
            ss = text(i).local8Bit();
            log(L_DEBUG, "?: %s", ss.c_str());

            unsigned j;
            for (j = i + 1; j < (unsigned)paragraphs(); j++){
                QString s = text(j);
                ss = text(j).local8Bit();
                log(L_DEBUG, ">: %s", ss.c_str());
                int n = s.find(MSG_ANCHOR);
                if (n < 0)
                    continue;
                s = s.mid(n + strlen(MSG_ANCHOR));
                n = s.find("\"");
                if (n < 0)
                    continue;
                string client;
                if ((messageId(s.left(n), client) != msg->id()) || (client != msg->client()))
                    break;
            }
            int paraFrom, indexFrom;
            int paraTo, indexTo;
            getSelection(&paraFrom, &indexFrom, &paraTo, &indexTo);
            unsigned pos = 0xFFFF;
            if (j == (unsigned)paragraphs()){
                j++;
                pos = 0;
            }
            setSelection(i, 0, j - 1, pos);
            setReadOnly(false);
            removeSelectedText();
            setReadOnly(true);
            if ((paraFrom == -1) && (paraTo == -1)){
                scrollToBottom();
            }else{
                setSelection(paraFrom, indexFrom, paraTo, indexTo);
            }
            break;
        }
        return NULL;
    }
    if (e->type() == EventHistoryConfig){
        unsigned id = (unsigned)(e->param());
        if (id && (id != m_id))
            return NULL;
        reload();
    }
    if (e->type() == EventHistoryColors)
        setColors();
    if (e->type() == EventCheckState){
        CommandDef *cmd = (CommandDef*)(e->param());
        if ((cmd->param != this) || (cmd->menu_id != MenuMsgView))
            return NULL;
        Message *msg;
        switch (cmd->id){
        case CmdCopy:
            cmd->flags &= ~(COMMAND_DISABLED | COMMAND_CHECKED);
            if (!hasSelectedText())
                cmd->flags |= COMMAND_DISABLED;
            return e->param();
        case CmdMsgOpen:
            msg = currentMessage();
            if (msg){
                unsigned type = msg->baseType();
                delete msg;
                CommandDef *def = CorePlugin::m_plugin->messageTypes.find(type);
                if (def == NULL)
                    return NULL;
                cmd->icon = def->icon;
                cmd->flags &= ~COMMAND_CHECKED;
                return e->param();
            }
            return NULL;
        case CmdMsgSpecial:
            msg = currentMessage();
            if (msg){
                Event eMenu(EventGetMenuDef, (void*)MenuMsgCommand);
                CommandsDef *cmdsMsg = (CommandsDef*)(eMenu.process());

                unsigned n = 0;
                MessageDef *mdef = NULL;
                unsigned type = msg->baseType();
                const CommandDef *cmdsSpecial = NULL;
                CommandDef *msgCmd = CorePlugin::m_plugin->messageTypes.find(type);
                if (msgCmd)
                    mdef = (MessageDef*)(msgCmd->param);

                if (mdef){
                    if (msg->getFlags() & MESSAGE_RECEIVED){
                        cmdsSpecial = mdef->cmdReceived;
                    }else{
                        cmdsSpecial = mdef->cmdSent;
                    }
                    if (cmdsSpecial)
                        for (const CommandDef *d = cmdsSpecial; d->text; d++)
                            n++;
                }

                {
                    CommandsList it(*cmdsMsg, true);
                    while (++it)
                        n++;
                }
                if (n == 0)
                    return NULL;

                n++;
                CommandDef *cmds = new CommandDef[n];
                memset(cmds, 0, sizeof(CommandDef) * n);
                n = 0;
                if (cmdsSpecial){
                    for (const CommandDef *d = cmdsSpecial; d->text; d++){
                        cmds[n] = *d;
                        cmds[n].id = CmdMsgSpecial + n;
                        n++;
                    }
                }
                CommandDef *c;
                CommandsList it(*cmdsMsg, true);
                while ((c = ++it) != NULL){
                    CommandDef cmd = *c;
                    cmd.menu_id = MenuMsgCommand;
                    cmd.param   = msg;
                    Event e(EventCheckState, &cmd);
                    if (!e.process())
                        continue;
                    cmd.flags &= ~COMMAND_CHECK_STATE;
                    cmds[n++] = cmd;
                }
                cmd->param = cmds;
                cmd->flags |= COMMAND_RECURSIVE;
                delete msg;
                return e->param();
            }
            return NULL;
        }
    }
    if (e->type() == EventCommandExec){
        CommandDef *cmd = (CommandDef*)(e->param());
        if ((cmd->param != this) || (cmd->menu_id != MenuMsgView))
            return NULL;
        Message *msg;
        switch (cmd->id){
        case CmdCutHistory:
            msg = currentMessage();
            if (msg){
                History::cut(msg, 0, 0);
                delete msg;
                return e->param();
            }
            return NULL;
        case CmdDeleteMessage:
            msg = currentMessage();
            if (msg){
                History::del(msg);
                delete msg;
                return e->param();
            }
            return NULL;
        case CmdCopy:
            copy();
            return e->param();
        case CmdMsgOpen:
            msg = currentMessage();
            if (msg){
                msg->setFlags(msg->getFlags() | MESSAGE_OPEN);
                Event eOpen(EventOpenMessage, &msg);
                eOpen.process();
                delete msg;
                return e->param();
            }
            return NULL;
        default:
            msg = currentMessage();
            if (msg){
                if (cmd->id >= CmdMsgSpecial){
                    MessageDef *mdef = NULL;
                    unsigned type = msg->baseType();
                    CommandDef *msgCmd = CorePlugin::m_plugin->messageTypes.find(type);
                    if (msgCmd)
                        mdef = (MessageDef*)(msgCmd->param);
                    const CommandDef *cmds = NULL;
                    if (mdef){
                        if (msg->getFlags() & MESSAGE_RECEIVED){
                            cmds = mdef->cmdReceived;
                        }else{
                            cmds = mdef->cmdSent;
                        }
                    }

                    if (cmds){
                        unsigned n = cmd->id - CmdMsgSpecial;
                        for (const CommandDef *d = cmds; d->text; d++){
                            if (n-- == 0){
                                CommandDef cmd = *d;
                                cmd.param = msg;
                                Event eCmd(EventCommandExec, &cmd);
                                eCmd.process();
                                return e->param();
                            }
                        }
                    }
                }
                Command c;
                c->id = cmd->id;
                c->menu_id = MenuMsgCommand;
                c->param = msg;
                Event e(EventCommandExec, c);
                void *res = e.process();
                delete msg;
                return res;
            }
            return NULL;
        }
    }
    return NULL;
}
Example #28
0
File: main.c Project: hannenz/busy
/* Read from TCP connection
 * A TCP connection on PORT 4000 on localhost can be used to issue commands
 * to the daemon, e.g. start manual backups etc.
 */
static gboolean network_read(GIOChannel *channel, GIOCondition condition, gpointer udata){
	GSocketConnection *connection = udata;
	gchar *str, **token;
	gsize len;
	gint ret, i;

	// Read the line
	ret = g_io_channel_read_line(channel, &str, &len, NULL, NULL);
	if (ret == G_IO_STATUS_ERROR){
		syslog(LOG_NOTICE, "Error reading from network\n");
		g_object_unref(connection);
		return (FALSE);
	}
	if (ret == G_IO_STATUS_EOF){
		return (FALSE);
	}


	// Trim trailing non-alphanumeric character in line
	for (i = len - 1; i > 0; i--){
		if (!isalnum(str[i])){
			str[i] = '\0';
		}
		else {
			break;
		}
	}

	// Split line into tokens
	token = g_strsplit(str, " ", 0);

	// Act upon command

	if (g_strcmp0(token[0], "reload") == 0){
		// Reload configuration
		syslog(LOG_NOTICE, "Reload has been requested");
		reload(0);
	}
	else if (g_strcmp0(token[0], "backup") == 0){
		Host *host;
		if (g_strcmp0(token[1], "full") == 0){
			syslog(LOG_NOTICE, "Requested full backup for \"%s\"\n", token[2]);
			if ((host = host_find_by_name(token[2], app_data_aux_ptr)) == NULL){
				syslog(LOG_WARNING, "No such host: %s\n", token[2]);
			}
			else {
				syslog(LOG_NOTICE, "Calling manual_backup() for %s\n", host_get_hostname(host));
				queue_backup(host, BUS_BACKUP_TYPE_FULL, app_data_aux_ptr);
			}
		}
		else if (g_strcmp0(token[1], "incr") == 0){
			syslog(LOG_NOTICE, "Requested incremental backup for \"%s\"\n", token[2]);
			if ((host = host_find_by_name(token[2], app_data_aux_ptr)) == NULL){
				syslog(LOG_WARNING, "No such host: \"%s\"\n", token[2]);
			}
			else {
				queue_backup(host, BUS_BACKUP_TYPE_INCREMENTAL, app_data_aux_ptr);
			}
		}
		else {
			syslog(LOG_WARNING, "Unknown backup type: %s\n", token[1]);
		}
	}
	else if (g_strcmp0(token[0], "remove") == 0){
		syslog(LOG_NOTICE, "Sorry, but this command is not implemented yet...\n");
		//(token[1], token[2]);
	}
	else if (g_strcmp0(token[0], "stop") == 0){
		exit(0);
	}
	else if (g_strcmp0(token[0], "cancel") == 0){
		Host *host;
		GList *p;
		host = host_find_by_name(token[1], app_data_aux_ptr);
		if (host){
			syslog(LOG_NOTICE, "Cancelling all backups for Host \"%s\"", host_get_name(host));
			for (p = app_data_aux_ptr->running_backups; p != NULL; p = p->next){
				Backup *backup;
				Host *host2;

				backup = p->data;
				host2 = backup_get_host(backup);
				if (g_strcmp0(host_get_name(host), host_get_name(host2)) == 0){
					backup_cancel(backup);
				}
			}
		}
	}
	else {
		syslog(LOG_WARNING, "Invalid message: %s\n", str);
	}
	return (TRUE);
}
void KreCategoriesListWidget::removeCategory( int id )
{
	reload( ForceReload );
}
Example #30
0
void create()
{
  reload("jinping_dian_zhu");
  set_name("µêÖ÷", ({"dian zhu", "zhu"}));