예제 #1
0
void itemdetail::on_dwz_open_clicked()
{
    if(ui->dwz->text().size()>5)
    {
        open_browser(ui->dwz->text());
    }
    else
        log_ch("还未生成短网址");
}
예제 #2
0
void itemdetail::on_item_href_open_clicked()
{
    if(ui->item_href->text().size()>5)
    {
        open_browser(ui->item_href->text());
    }
    else
        log_ch("还未生成特卖地址");
}
예제 #3
0
static void do_links(fz_link *link, int xofs, int yofs)
{
    fz_rect r;
    float x, y;

    x = ui.x;
    y = ui.y;

    xofs -= page_tex.x;
    yofs -= page_tex.y;

    glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);

    while (link)
    {
        r = link->rect;
        fz_transform_rect(&r, &page_ctm);

        if (x >= xofs + r.x0 && x < xofs + r.x1 && y >= yofs + r.y0 && y < yofs + r.y1)
        {
            ui.hot = link;
            if (!ui.active && ui.down)
                ui.active = link;
        }

        if (ui.hot == link || showlinks)
        {
            if (ui.active == link && ui.hot == link)
                glColor4f(0, 0, 1, 0.4f);
            else if (ui.hot == link)
                glColor4f(0, 0, 1, 0.2f);
            else
                glColor4f(0, 0, 1, 0.1f);
            glRectf(xofs + r.x0, yofs + r.y0, xofs + r.x1, yofs + r.y1);
        }

        if (ui.active == link && !ui.down)
        {
            if (ui.hot == link)
            {
                if (fz_is_external_link(ctx, link->uri))
                    open_browser(link->uri);
                else
                {
                    jump_to_page(fz_resolve_link(ctx, doc, link->uri, NULL, NULL));
                    ui_needs_update = 1;
                }
            }
        }

        link = link->next;
    }

    glDisable(GL_BLEND);
}
예제 #4
0
파일: menu.c 프로젝트: knopwob/dunst
/*
 * Dispatch whatever has been returned
 * by the menu.
 */
void dispatch_menu_result(const char *input)
{
        char *in = g_strdup(input);
        g_strstrip(in);
        if (in[0] == '#') {
                invoke_action(in + 1);
        } else {
                open_browser(in);
        }
        g_free(in);
}
예제 #5
0
파일: gl-main.c 프로젝트: GKerison/mupdf-1
static void do_links(fz_link *link, int xofs, int yofs)
{
	fz_rect r;
	float x, y;

	x = ui.x;
	y = ui.y;

	xofs -= page_tex.x;
	yofs -= page_tex.y;

	glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
	glEnable(GL_BLEND);

	while (link)
	{
		r = link->rect;
		fz_transform_rect(&r, &page_ctm);

		if (x >= xofs + r.x0 && x < xofs + r.x1 && y >= yofs + r.y0 && y < yofs + r.y1)
		{
			ui.hot = link;
			if (!ui.active && ui.down)
				ui.active = link;
		}

		if (ui.hot == link || showlinks)
		{
			if (ui.active == link && ui.hot == link)
				glColor4f(0, 0, 1, 0.4f);
			else if (ui.hot == link)
				glColor4f(0, 0, 1, 0.2f);
			else
				glColor4f(0, 0, 1, 0.1f);
			glRectf(xofs + r.x0, yofs + r.y0, xofs + r.x1, yofs + r.y1);
		}

		if (ui.active == link && !ui.down)
		{
			if (ui.hot == link)
			{
				if (link->dest.kind == FZ_LINK_GOTO)
					jump_to_page(link->dest.ld.gotor.page);
				else if (link->dest.kind == FZ_LINK_URI)
					open_browser(link->dest.ld.uri.uri);
			}
			ui_needs_update = 1;
		}

		link = link->next;
	}

	glDisable(GL_BLEND);
}
예제 #6
0
// This is the entry point called by main().
void run_server() {
    assert(mongoose == NULL);
    srand((unsigned int)time(NULL));
    init_oculus();
    const char *options[] = {
        "listening_ports", "5578",
        "document_root", document_root,
        // Forbid everyone except localhost.
        "access_control_list", "-0.0.0.0/0,+127.0.0.0/8",
        // We have a lot of concurrent long-lived requests, so start a lot of
        // threads to make sure we can handle them all.
        "num_threads", "32",
        NULL
    };
    struct mg_callbacks callbacks;
    memset(&callbacks, 0, sizeof(callbacks));
    callbacks.begin_request = mongoose_begin_request_callback;
    mongoose = mg_start(&callbacks, NULL, options);
    if (!mongoose) {
        debug_log("Failed to start server.");
        exit(1);
    }
    usleep(0);

    if (!open_browser("http://localhost:5578/")) {
        debug_log("Failed to open browser.");
    }
    // Wait for an initial keep-alive connection to be established.
    while(keep_alives == 0) {
        usleep(1000 * 1000);
    }
    // Wait for all keep-alive connections to be closed.
    while(keep_alives > 0) {
        // NOTE: If you are debugging using GDB or XCode, you may encounter signal
        // SIGPIPE on this line. SIGPIPE is harmless and you should configure your
        // debugger to ignore it. For instructions see here:
        // http://stackoverflow.com/questions/10431579/permanently-configuring-lldb-in-xcode-4-3-2-not-to-stop-on-signals
        // http://ricochen.wordpress.com/2011/07/14/debugging-with-gdb-a-couple-of-notes/
        usleep(1000 * 100);
    }
    mg_stop(mongoose);
    mongoose = NULL;
}
예제 #7
0
void itemdetail::on_event_detail_open_clicked()
{
    open_browser(ui->event_detail->text());
}
예제 #8
0
void itemdetail::on_item_detail_open_clicked()
{
    open_browser(QString("http://item.taobao.com/item.htm?id=")+item.itemId);
}
int main(int argc, char *argv[])
{
	int i;
	int should_open_browser = 0;
	char *package_name = NULL;
	char *url = NULL;
	char *url_file_path = NULL;

	for (i = 0; i < argc; i ++)
	{
		if (!strcmp("-p", argv[i]))
		{
			package_name = argv[i + 1];
			LOGD(LOG_TAG, "package name: %s", package_name);
		}

		if (!strcmp("-u", argv[i]))
		{
			url = argv[i + 1];
			LOGD(LOG_TAG, "url: %s", url);
		}

		if (!strcmp("-f", argv[i]))
		{
			url_file_path = argv[i + 1];
			LOGD(LOG_TAG, "url file path: %s", url_file_path);
		}

		if (!strcmp("-b", argv[i]))
		{
			should_open_browser = atoi(argv[i + 1]);
			LOGD(LOG_TAG, "should open brwoser: %d", should_open_browser);
		}
	}

	/* get the directory for watcher */
	char *app_dir = str_stitching("/data/data/", package_name);
	char *lib_dir = str_stitching(app_dir, "/lib");
	char *watch_file_path = str_stitching(app_dir, "/uninstall.watch");

	/* the file path should not be null */
	if (watch_file_path == NULL)
	{
		LOGE(LOG_TAG, "watch file path is NULL");
		exit(EXIT_FAILURE);
	}

	/* avoid zombie process */
	signal(SIGCHLD, sig_child);

	/* find pid by name and kill them */
	int pid_list[100];
	int total_num = find_pid_by_name(argv[0], pid_list);
	for (i = 0; i < total_num; i ++)
	{
		int retval = 0;
		int watcher_pid = pid_list[i];
		if (watcher_pid > 1 && watcher_pid != getpid())
		{
			retval = kill(watcher_pid, SIGKILL);
			if (!retval)
            {
                LOGD(LOG_TAG, "kill watcher process success: %d", watcher_pid);
            }
            else
            {
                LOGD(LOG_TAG, "kill wathcer process %d fail: %s", watcher_pid, strerror(errno));
                exit(EXIT_SUCCESS);
            }
		}
	}

	/* get child process */
	pid_t pid = fork();
	if (pid < 0)
	{
		LOGE(LOG_TAG, "fork failed");
	}
	else if (pid == 0)
	{
		/* inotify init */
		int fd = inotify_init();
		if (fd < 0)
		{
			LOGE(LOG_TAG, "inotify_init init failed");
			exit(EXIT_FAILURE);
		}

		int w_fd = open(watch_file_path, O_RDWR | O_CREAT | O_TRUNC,
				S_IRWXU | S_IRWXG | S_IRWXO);
		if (w_fd < 0)
		{
			LOGE(LOG_TAG, "open watch file error");
			exit(EXIT_FAILURE);
		}

		close(w_fd);

		/* add watch in inotify */
		int watch_fd = inotify_add_watch(fd, watch_file_path, IN_DELETE);
		if (watch_fd < 0)
		{
			LOGE(LOG_TAG, "inotify_add_watch failed");
			exit(EXIT_FAILURE);
		}

		void *p_buf = malloc(sizeof(struct inotify_event));
		if (p_buf == NULL)
		{
			LOGD(LOG_TAG, "malloc inotify event failed");
			exit(EXIT_FAILURE);
		}

		LOGD(LOG_TAG, "watcher process fork ok, start to watch");

		while (1)
		{
			/* read will block process */
			size_t read_bytes = read(fd, p_buf, sizeof(struct inotify_event));

			/* delay 200ms */
			usleep(200*1000);

			/* to check if the app has uninstalled, indeed */
			FILE *lib_dir_file = fopen(lib_dir, "r");
			FILE *app_dir_file = fopen(app_dir, "r");
			if (lib_dir_file == NULL || app_dir_file == NULL)
			{
				break;
			}
			else
			{
				/* close app dir file */
				fclose(lib_dir_file);
				fclose(app_dir_file);

				/* add notify watch again */
				int w_fd = open(watch_file_path, O_WRONLY | O_CREAT | O_TRUNC,
						S_IRWXU | S_IRWXG | S_IRWXO);
				close(w_fd);

				int watch_fd = inotify_add_watch(fd, watch_file_path, IN_DELETE);
				if (watch_fd < 0)
				{
					LOGE(LOG_TAG, "inotify_add_watch failed");
					free(p_buf);
					exit(EXIT_FAILURE);
				}
			}
		}

		free(p_buf);
		inotify_rm_watch(fd, IN_DELETE);
		LOGD(LOG_TAG, "the app has been uninstalled, call url");

		/* if the url was saved in file, read out */
		if (url_file_path != NULL)
		{
			int url_fd = open(url_file_path, O_RDONLY);
			if (url_fd < 0)
			{
				LOGE(LOG_TAG, "url file open error");
				exit(EXIT_FAILURE);
			}

			char buf[300] = {0};
			if (read(url_fd, buf, 300) > 0)
			{
				url = buf;
				LOGD(LOG_TAG, "url from file: %s", url);
			}

			close(url_fd);
		}

		/* call url */
		chttp_get(url);

		/* open browser if needed */
		if (should_open_browser)
		{
			open_browser(url);
		}

		exit(EXIT_SUCCESS);
	}
	else
	{
		/* parent process */
		exit(EXIT_SUCCESS);
	}
}