Exemple #1
0
bool bugzilla_send_with_progress(const char *title, const char *content) {
	data_submitted = false;
	cancel_sending = false;

	bdata = bugzilla_new(EDE_BUGZILLA_XMLRPC_URL);
	if(!bdata) {
		alert(_("Unable to initialize bugzilla interface!"));
		return false;
	}

	if(pipe(report_pipe) != 0) {
		alert(_("Unable to initialize communication pipe"));
		return false;
	}

	/* prepare mutex */
	pthread_mutex_init(&runner_mutex, NULL);

	/* register our callback on pipe */
	Fl::add_fd(report_pipe[0], FL_READ, report_pipe_cb);

	win = new Fl_Double_Window(275, 90, _("Sending report data"));
	win->begin();
		progress = new PulseProgress(10, 20, 255, 25, _("Sending report..."));
		progress->selection_color((Fl_Color)137);

		Fl_Button *cancel = new Fl_Button(175, 55, 90, 25, _("&Cancel"));
		cancel->callback(cancel_cb);
	win->end();

	win->set_modal();
	win->show();

	progress->label(_("Preparing data..."));
	Fl::add_timeout(PROGRESS_STEP_REFRESH, progress_timeout);

	perform_send(title, content);

	while(win->shown())
		Fl::wait();

	/* clear pipe callback */
	Fl::remove_fd(report_pipe[0]);
	clear_timeouts();

	pthread_mutex_destroy(&runner_mutex);

	close(report_pipe[0]);
	close(report_pipe[1]);

	bugzilla_free(bdata);

	/* true if we completed all stages */
	return data_submitted;
}
Exemple #2
0
int main(int argc, char** argv) {
    createDirectory(".");
    if(argc >= 2) {
        if(strcmp(argv[1], "status") == 0) {
            GList* changed_list = NULL;
            GList* untracked_list = NULL;
            getFilesRecursive(".", &changed_list, &untracked_list);
            printStatus(changed_list, untracked_list);
        } else if(strcmp(argv[1], "add") == 0) {
            //DO THE ADDING
            if(argc < 3) {
                printf("# No files to add were specified\n");
                printf("#\n");
            } else {
                GList* list = NULL;
                for(int i=2; i<argc; i++) {
                    list = g_list_append(list, argv[i]);
                }
                for(GList* current = list; current != NULL; current = g_list_next(current)) {
                    char* filename = (char*) current->data;
                    int result = addFile(filename);
                    if(result != 1) {
                        printf("# Error adding file");
                    }
                }
            }
        } else if(strcmp(argv[1], "send") == 0) {
            if(argc < 3) {
                printf("# No host name given. Format: %s hostname\n", argv[0]);
                exit(EXIT_FAILURE);
            }
            perform_send(argv[2]);
        } else if(strcmp(argv[1], "receive") == 0) {
            perform_receive();
        }
    }
}