Esempio n. 1
0
/**
* Fonction de vérification et traitement des données avant l'envoi au serveur
*/
void submit_network_cb(GtkWidget *submit, Project *project)
{
    Device *device = (Device *)g_object_get_data(G_OBJECT(submit), "device");

    if(g_strcmp0(gtk_entry_get_text(GTK_ENTRY(project->networksetup.entry[1])), "") != 0
       && g_strcmp0(gtk_entry_get_text(GTK_ENTRY(project->networksetup.entry[2])), "") != 0
       && g_strcmp0(gtk_entry_get_text(GTK_ENTRY(project->networksetup.entry[3])), "") != 0
       && g_strcmp0(gtk_entry_get_text(GTK_ENTRY(project->networksetup.entry[4])), "") != 0)
    {
        if(regex_verification(gtk_entry_get_text(GTK_ENTRY(project->networksetup.entry[1])), IP_ADDR)
           && regex_verification(gtk_entry_get_text(GTK_ENTRY(project->networksetup.entry[2])), IP_ADDR)
           && regex_verification(gtk_entry_get_text(GTK_ENTRY(project->networksetup.entry[3])), IP_ADDR))
           /*&& regex_verification(gtk_entry_get_text(GTK_ENTRY(project->networksetup.entry[4])), MAC_ADDR))*/
        {
            save_network(project, device);
            gtk_widget_destroy(project->networksetup.dialog);
        }
        else
            warning_dialog(project->networksetup.dialog,
                           "\nWrong IP Address (format : x.x.x.x) "
                           "or MAC address (format : xx:xx:xx:xx:xx:xx or xx-xx-xx-xx-xx-xx)");
    }
    else
        warning_dialog(project->networksetup.dialog, "\nAt least one field is empty.");
}
Esempio n. 2
0
void GameList::UninstallWAD()
{
  const auto game = GetSelectedGame();
  if (!game)
    return;

  ModalMessageBox warning_dialog(this);

  warning_dialog.setIcon(QMessageBox::Information);
  warning_dialog.setWindowTitle(tr("Confirm"));
  warning_dialog.setText(tr("Uninstalling the WAD will remove the currently installed version of "
                            "this title from the NAND without deleting its save data. Continue?"));
  warning_dialog.setStandardButtons(QMessageBox::No | QMessageBox::Yes);

  if (warning_dialog.exec() == QMessageBox::No)
    return;

  ModalMessageBox result_dialog(this);

  const bool success = WiiUtils::UninstallTitle(game->GetTitleID());

  result_dialog.setIcon(success ? QMessageBox::Information : QMessageBox::Critical);
  result_dialog.setWindowTitle(success ? tr("Success") : tr("Failure"));
  result_dialog.setText(success ? tr("Successfully removed this title from the NAND.") :
                                  tr("Failed to remove this title from the NAND."));
  result_dialog.exec();
}
Esempio n. 3
0
static void cache_manager_render_start_cb(GenericDialog *fd, gpointer data)
{
	CleanData *cd = data;
	gchar *path;

	if (cd->list || !gtk_widget_get_sensitive(cd->button_start)) return;

	path = remove_trailing_slash((gtk_entry_get_text(GTK_ENTRY(cd->entry))));
	parse_out_relatives(path);

	if (!isdir(path))
		{
		warning_dialog(_("Invalid folder"),
				_("The specified folder can not be found."),
			       GTK_STOCK_DIALOG_WARNING, cd->gd->dialog);
		}
	else
		{
		FileData *dir_fd;
		gtk_widget_set_sensitive(cd->group, FALSE);
		gtk_widget_set_sensitive(cd->button_start, FALSE);
		gtk_widget_set_sensitive(cd->button_stop, TRUE);
		gtk_widget_set_sensitive(cd->button_close, FALSE);

		spinner_set_interval(cd->spinner, SPINNER_SPEED);

		dir_fd = file_data_new_dir(path);
		cache_manager_render_folder(cd, dir_fd);
		file_data_unref(dir_fd);
		while (cache_manager_render_file(cd));
		}

	g_free(path);
}
Esempio n. 4
0
int main(int argc, char **argv)
{
	GtkWidget *window;
	char *cmd;

	gtk_init(&argc, &argv);
	gtk_window_set_default_icon_from_file(
		DATA_DIR "/pixmaps/stoken-gui.png", NULL);

	cmd = parse_cmdline(argc, argv, IS_GUI);

	/* check for a couple of error conditions */

	if (common_init(cmd))
		error_dialog("Application error",
			"Unable to initialize crypto library.");

	if (!current_token)
		error_dialog("Missing token",
			"Please use 'stoken import' to add a new seed.");

	if (securid_devid_required(current_token))
		error_dialog("Unsupported token",
			"Please use 'stoken' to handle tokens encrypted with a device ID.");

	/* check for token expiration */
	token_days_left = securid_check_exp(current_token, time(NULL));
	if (!opt_force && !opt_small) {
		if (token_days_left < 0)
			error_dialog("Token expired",
				"Please obtain a new token from your administrator.");

		if (token_days_left < EXP_WARN_DAYS) {
			char msg[BUFLEN];

			sprintf(msg, "This token will expire in %d day%s.",
				token_days_left,
				token_days_left == 1 ? "" : "s");
			warning_dialog(NULL, "Expiration warning", msg);
		}
	}

	/* request password / PIN, if missing */
	if (request_credentials(current_token) != ERR_NONE)
		return 1;

	token_interval = securid_token_interval(current_token);
	token_uses_pin = securid_pin_required(current_token);

	window = opt_small ? create_small_app_window() : create_app_window();

	update_tokencode(NULL);
	gtk_widget_show_all(window);

	g_timeout_add(250, update_tokencode, NULL);
	gtk_main();

	return 0;
}
Esempio n. 5
0
static void editor_list_window_delete_dlg_ok_cb(GenericDialog *gd, gpointer data)
{
	EditorWindowDel_Data *ewdl = data;

	if (!unlink_file(ewdl->path))
		{
		gchar *text = g_strdup_printf(_("Unable to delete file:\n%s"), ewdl->path);
		warning_dialog(_("File deletion failed"), text, GTK_STOCK_DIALOG_WARNING, NULL);
		g_free(text);
		}
	else
		{
		/* refresh list */
		layout_editors_reload_start();
		/* idle function is not needed, everything should be cached */
		layout_editors_reload_finish(); 
		}

	editor_list_window_delete_dlg_cancel(gd, data);
}
Esempio n. 6
0
void GameList::UninstallWAD()
{
  QMessageBox warning_dialog(this);

  warning_dialog.setIcon(QMessageBox::Information);
  warning_dialog.setText(tr("Uninstalling the WAD will remove the currently installed version of "
                            "this title from the NAND without deleting its save data. Continue?"));
  warning_dialog.setStandardButtons(QMessageBox::No | QMessageBox::Yes);

  if (warning_dialog.exec() == QMessageBox::No)
    return;

  QMessageBox result_dialog(this);

  const bool success = GameFile(GetSelectedGame()).Uninstall();

  result_dialog.setIcon(success ? QMessageBox::Information : QMessageBox::Critical);
  result_dialog.setText(success ? tr("Succesfully removed title from the NAND") :
                                  tr("Failed to remove title from the NAND"));
  result_dialog.exec();
}
Esempio n. 7
0
static void collection_close_save_cb(GenericDialog *gd, gpointer data)
{
	CollectWindow *cw = data;

	cw->close_dialog = NULL;
	generic_dialog_close(gd);

	if (!cw->cd->path)
		{
		collection_dialog_save_close(NULL, cw->cd);
		return;
		}
	else if (!collection_save(cw->cd, cw->cd->path))
		{
		gchar *buf;
		buf = g_strdup_printf(_("Failed to save the collection:\n%s"), cw->cd->path);
		warning_dialog(_("Save Failed"), buf, GTK_STOCK_DIALOG_ERROR, cw->window);
		g_free(buf);
		return;
		}

	collection_window_close_final(cw);
}
Esempio n. 8
0
static void
clone_repository (GiggleCloneDialog *dialog, GtkButton *button)
{
	GiggleJob *job;
	GtkFileChooser *chooser;
	const gchar  *repo, *name;
	gchar *base;

	if (input_is_valid (dialog) == FALSE) {
		warning_dialog (GTK_WINDOW (dialog));
		return;
	}

	gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE);
	gtk_widget_set_sensitive (dialog->priv->remote_entry, FALSE);
	gtk_widget_set_sensitive (dialog->priv->local_entry, FALSE);
	gtk_widget_set_sensitive (dialog->priv->folder_button, FALSE);

	dialog->priv->pulse_timeout_id = g_timeout_add (100,
	                                                update_progress_bar,
	                                                dialog);

	chooser = GTK_FILE_CHOOSER (dialog->priv->folder_button);
	base = gtk_file_chooser_get_filename (chooser);

	name = gtk_entry_get_text (GTK_ENTRY (dialog->priv->local_entry));
	repo = gtk_entry_get_text (GTK_ENTRY (dialog->priv->remote_entry));

	dialog->priv->git_directory = g_build_filename (base, name, NULL);
	g_free (base);

	job = giggle_git_clone_new (repo, dialog->priv->git_directory);

	giggle_git_run_job (dialog->priv->git, job,
	                    clone_repository_finished, dialog);
}
Esempio n. 9
0
static int request_credentials(struct securid_token *t)
{
	int rc, pass_required = 0, pin_required = 0;

	if (securid_pass_required(t)) {
		pass_required = 1;
		if (opt_password) {
			rc = securid_decrypt_seed(t, opt_password, NULL);
			if (rc == ERR_DECRYPT_FAILED)
				warn("warning: --password parameter is incorrect\n");
			else if (rc != ERR_NONE)
				error_dialog("Token decrypt error",
					stoken_errstr[rc]);
			else
				pass_required = 0;
		}
	} else {
		rc = securid_decrypt_seed(t, opt_password, NULL);
		if (rc != ERR_NONE)
			error_dialog("Token decrypt error", stoken_errstr[rc]);
	}

	while (pass_required) {
		const char *pass =
			do_password_dialog(UIDIR "/password-dialog.ui");
		if (!pass)
			return ERR_MISSING_PASSWORD;
		rc = securid_decrypt_seed(t, pass, NULL);
		if (rc == ERR_NONE) {
			if (t->enc_pin_str) {
				rc = securid_decrypt_pin(t->enc_pin_str,
							 pass, t->pin);
				if (rc != ERR_NONE)
					error_dialog("PIN decrypt error",
						     stoken_errstr[rc]);
			}

			pass_required = 0;
		} else if (rc == ERR_DECRYPT_FAILED)
			warning_dialog(NULL, "Bad password",
				"Please enter the correct password for this seed.");
		else
			error_dialog("Token decrypt error", stoken_errstr[rc]);
	}

	if (securid_pin_required(t)) {
		pin_required = 1;
		if (opt_pin) {
			if (securid_pin_format_ok(opt_pin) == ERR_NONE) {
				xstrncpy(t->pin, opt_pin, MAX_PIN + 1);
				pin_required = 0;
			} else
				warn("warning: --pin argument is invalid\n");
		} else if (strlen(t->pin) || t->enc_pin_str)
			pin_required = 0;
	}

	while (pin_required) {
		const char *pin =
			do_password_dialog(UIDIR "/pin-dialog.ui");
		if (!pin) {
			skipped_pin = 1;
			xstrncpy(t->pin, "0000", MAX_PIN + 1);
			break;
		}
		if (securid_pin_format_ok(pin) != ERR_NONE) {
			warning_dialog(NULL, "Bad PIN",
				"Please enter 4-8 digits, or click Skip for no PIN.");
		} else {
			xstrncpy(t->pin, pin, MAX_PIN + 1);
			break;
		}
	}

	return ERR_NONE;
}
Esempio n. 10
0
/**
 * msg_queue_check:
 *
 * checks the queue for any messages
 * this is called by the master program, usually by gtk_timeout_add()
 * the messages it will listen to are the types:
 * - MSG_QUEUE_ASK_ALIVE - we should respond with a type MSG_QUEUE_SEND_ALIVE
 * - MSG_QUEUE_OPENFILE - open a filename
 * - MSG_QUEUE_OPENPROJECT - open a filename as project
 * - MSG_QUEUE_OPENNEWWIN - open a new window
 */
static gboolean msg_queue_check(gint started_by_gtk_timeout)
{
	struct msgbuf {
		long mtype;
		char mtext[MSQ_QUEUE_SIZE];
	} msgp;
	gint retval;
	if (main_v->bfwinlist == NULL || BFWIN(main_v->bfwinlist->data)->documentlist == NULL) {
		DEBUG_MSG("msg_queue_check, no documentlist yet, so we do not continue\n");
		return TRUE;
	}

	if (msg_queue.msgid == -1) {
		return FALSE;
	}
	retval =	msgrcv(msg_queue.msgid, &msgp, MSQ_QUEUE_SIZE, -MSG_QUEUE_OPENFILE, IPC_NOWAIT);
	if (retval != -1) {
		DEBUG_MSG("msg_queue_check, found type %ld\n", msgp.mtype);
		if (msgp.mtype == MSG_QUEUE_ASK_ALIVE) {
			struct small_msgbuf {
				long mtype;
				char mtext[MSQ_QUEUE_SMALL_SIZE];
			} small_msgp;
			DEBUG_MSG("msg_queue_check, a keepalive is asked from %s, sending!\n", msgp.mtext);
			small_msgp.mtype = MSG_QUEUE_SEND_ALIVE;
			strncpy(small_msgp.mtext, msgp.mtext, MSQ_QUEUE_SMALL_SIZE - 1);
			msgsnd(msg_queue.msgid, (void *) &small_msgp, MSQ_QUEUE_SMALL_SIZE * sizeof(char),
				   IPC_NOWAIT);
		} else if (msgp.mtype == MSG_QUEUE_OPENFILE) {
			GList *lastlist = g_list_last(main_v->bfwinlist);
			gboolean delay_activate = TRUE;
			if (g_list_length(BFWIN(lastlist->data)->documentlist) < 2 && 
			       doc_is_empty_non_modified_and_nameless(BFWIN(lastlist->data)->current_document)) {
                       delay_activate = FALSE;
			}
			DEBUG_MSG("msg_queue_check, a filename %s is received\n", msgp.mtext);
			if (!doc_new_with_file(BFWIN(lastlist->data),msgp.mtext, delay_activate, FALSE)) {
				msg_queue.file_error_list = g_list_append(msg_queue.file_error_list, g_strdup(msgp.mtext));
			}
			msg_queue_check(0);	/* call myself again, there may have been multiple files */
			if (started_by_gtk_timeout) {
				if (msg_queue.file_error_list) {
					gchar *message, *tmp;
					tmp = stringlist_to_string(msg_queue.file_error_list, "\n");
					free_stringlist(msg_queue.file_error_list);
					msg_queue.file_error_list = NULL;
					message = g_strconcat(_("These files were not opened:\n"), tmp, NULL);
					g_free(tmp);
					warning_dialog(BFWIN(main_v->bfwinlist->data)->main_window,_("Unable to open file(s)\n"), message);
					g_free(message);
				}
/*				gtk_notebook_set_page(GTK_NOTEBOOK(main_v->notebook),g_list_length(main_v->documentlist) - 1);
				notebook_changed(-1);*/
			}
		} else if (msgp.mtype == MSG_QUEUE_OPENPROJECT) {
			GList *lastlist = g_list_last(main_v->bfwinlist);
			DEBUG_MSG("msg_queue_check, a project %s is received\n", msgp.mtext);
			project_open_from_file(BFWIN(lastlist->data), msgp.mtext);
			msg_queue_check(0);	/* call myself again, there may have been multiple projects */
		} else if (msgp.mtype == MSG_QUEUE_OPENNEWWIN) {
			/* now check if this is indeed send by another process
			if the message queue was dead during the startup of this process,
			it might be started by this very process */
			int otherpid = atoi(msgp.mtext);
			DEBUG_MSG("msg_queue_check, a new window is requested by PID=%d\n",otherpid);
			if (otherpid != (int) getpid()) {
				DEBUG_MSG("msg_queue_check, the PID is not ours, opening new window\n");
				gui_new_window(NULL, NULL);
			}
		}
#ifdef DEBUG
		 else {
		 	DEBUG_MSG("msg_queue_check, unknown message queue type %ld\n", msgp.mtype);
		 }
#endif
		
	} else {
#ifdef MSG_QUEUE_DEBUG
		DEBUG_MSG("msg_queue_check, found errno(%d)=%s\n", errno, g_strerror(errno));
#endif
	/*
	43 = Identifier removed
	*/
		if (errno == 22 || errno == 43) {
			DEBUG_MSG("msg_queue_check, re-opening message queue ?!?!?\n");
			/* the msg_queue was removed !?!?! */
			if (msg_queue_open()) {
				DEBUG_MSG("msg_queue_check, another process has opened the message_queue, stopping server\n");
				msg_queue.server = FALSE;
				return FALSE;
			}
		}
	}
	return TRUE;
}
Esempio n. 11
0
static void mqueue_handler(int id, void *data, void *arg)
{
	struct gtk_mod *mod = arg;
	const char *uri;
	struct call *call;
	int err;
	struct ua *ua = uag_current();
	(void)mod;

	switch ((enum gtk_mod_events)id) {

	case MQ_POPUP:
		gdk_threads_enter();
		popup_menu(mod, NULL, NULL, 0, GPOINTER_TO_UINT(data));
		gdk_threads_leave();
		break;

	case MQ_CONNECT:
		uri = data;
		err = ua_connect(ua, &call, NULL, uri, NULL, VIDMODE_ON);
		if (err) {
			gdk_threads_enter();
			warning_dialog("Call failed",
					"Connecting to \"%s\" failed.\n"
					"Error: %m", uri, err);
			gdk_threads_leave();
			break;
		}
		gdk_threads_enter();
		err = new_call_window(mod, call) == NULL;
		gdk_threads_leave();
		if (err) {
			ua_hangup(ua, call, 500, "Server Error");
		}
		break;

	case MQ_HANGUP:
		call = data;
		ua_hangup(ua, call, 0, NULL);
		break;

	case MQ_QUIT:
		ua_stop_all(false);
		break;

	case MQ_ANSWER:
		call = data;
		err = ua_answer(ua, call);
		if (err) {
			gdk_threads_enter();
			warning_dialog("Call failed",
					"Answering the call "
					"from \"%s\" failed.\n"
					"Error: %m",
					call_peername(call), err);
			gdk_threads_leave();
			break;
		}

		gdk_threads_enter();
		err = new_call_window(mod, call) == NULL;
		gdk_threads_leave();
		if (err) {
			ua_hangup(ua, call, 500, "Server Error");
		}
		break;

	case MQ_SELECT_UA:
		ua = data;
		uag_current_set(ua);
		break;
	}
}
Esempio n. 12
0
File: gui.c Progetto: MufriA/stoken
static int do_password_dialog(struct securid_token *t)
{
	GtkWidget *dialog;
	GtkWidget *pass_entry = NULL, *pin_entry = NULL;
	gint resp;
	int rc, pass_required = 0, pin_required = 0;

	if (securid_pass_required(t)) {
		pass_required = 1;
		if (opt_password) {
			rc = securid_decrypt_seed(t, opt_password, NULL);
			if (rc == ERR_DECRYPT_FAILED)
				warn("warning: --password parameter is incorrect\n");
			else if (rc != ERR_NONE)
				error_dialog("Token decrypt error",
					stoken_errstr[rc]);
			else
				pass_required = 0;
		}
	} else {
		rc = securid_decrypt_seed(t, opt_password, NULL);
		if (rc != ERR_NONE)
			error_dialog("Token decrypt error", stoken_errstr[rc]);
	}

	if (securid_pin_required(t)) {
		pin_required = 1;
		if (opt_pin) {
			if (securid_pin_format_ok(opt_pin) == ERR_NONE) {
				xstrncpy(t->pin, opt_pin, MAX_PIN + 1);
				pin_required = 0;
			} else
				warn("warning: --pin argument is invalid\n");
		} else if (strlen(t->pin) || t->enc_pin_str)
			pin_required = 0;
	}

	if (!pin_required && !pass_required)
		return ERR_NONE;

	if (pass_required)
		pass_entry = gtk_entry_new();
	if (pin_required)
		pin_entry = gtk_entry_new();

	create_password_dialog(&dialog, pass_entry, pin_entry);

	while (1) {
		const char *pass = NULL, *pin = NULL;

		resp = gtk_dialog_run(GTK_DIALOG(dialog));
		if (resp != GTK_RESPONSE_ACCEPT) {
			gtk_widget_destroy(dialog);
			return 1;
		}

		if (pass_required) {
			pass = gtk_entry_get_text(GTK_ENTRY(pass_entry));
			rc = securid_decrypt_seed(current_token, pass, NULL);
			if (rc == ERR_DECRYPT_FAILED) {
				warning_dialog(dialog, "Bad password",
					"Please enter the correct password for this seed.");
				continue;
			} else if (rc != ERR_NONE)
				error_dialog("Token decrypt error",
					stoken_errstr[rc]);
		}

		if (t->enc_pin_str) {
			rc = securid_decrypt_pin(t->enc_pin_str, pass, t->pin);
			if (rc != ERR_NONE)
				error_dialog("PIN decrypt error",
					stoken_errstr[rc]);
		}

		if (pin_required) {
			pin = gtk_entry_get_text(GTK_ENTRY(pin_entry));
			if (securid_pin_format_ok(pin) != ERR_NONE) {
				warning_dialog(dialog, "Bad PIN",
					"Please enter 4-8 digits, or '0000' to skip.");
				continue;
			}
			xstrncpy(t->pin, pin, MAX_PIN + 1);
		}
		break;
	}
	gtk_widget_destroy(dialog);

	return ERR_NONE;
}