示例#1
0
static void _on_settings_number_edited(GtkCellRenderer * renderer, gchar * arg1,
		gchar * arg2, gpointer data)
{
	Blacklist * blacklist = data;
	PhonePluginHelper * helper = blacklist->helper;
	GtkTreeModel * model = GTK_TREE_MODEL(blacklist->store);
	GtkTreeIter iter;
	char * number = NULL;
	char const * reason;
	(void) renderer;

	if(gtk_tree_model_get_iter_from_string(model, &iter, arg1) == TRUE)
		gtk_tree_model_get(model, &iter, 0, &number, -1);
	if(number == NULL)
		return;
	/* FIXME check that there are no duplicates */
	reason = helper->config_get(helper->phone, "blacklist", number);
	if(helper->config_set(helper->phone, "blacklist", arg2, reason) == 0
			&& helper->config_set(helper->phone, "blacklist",
				number, NULL) == 0)
		gtk_list_store_set(blacklist->store, &iter, 0, arg2, -1);
	g_free(number);
}
示例#2
0
static void _on_settings_number_edited(GtkCellRenderer * renderer, gchar * arg1,
		gchar * arg2, gpointer data)
{
	SMSCrypt * smscrypt = data;
	PhonePluginHelper * helper = smscrypt->helper;
	GtkTreeModel * model = GTK_TREE_MODEL(smscrypt->store);
	GtkTreeIter iter;
	char * number = NULL;
	char const * secret;

	if(gtk_tree_model_get_iter_from_string(model, &iter, arg1) == TRUE)
		gtk_tree_model_get(model, &iter, SMSCC_NUMBER, &number, -1);
	if(number == NULL)
		return;
	/* FIXME check that there are no duplicates */
	secret = helper->config_get(helper->phone, "smscrypt", number);
	/* XXX report errors */
	if(helper->config_set(helper->phone, "smscrypt", arg2, secret) == 0
			&& helper->config_set(helper->phone, "smscrypt", number,
				NULL) == 0)
		gtk_list_store_set(smscrypt->store, &iter,
				SMSCC_NUMBER, arg2, -1);
	g_free(number);
}
示例#3
0
static void _on_settings_delete(gpointer data)
{
	SMSCrypt * smscrypt = data;
	PhonePluginHelper * helper = smscrypt->helper;
	GtkTreeSelection * treesel;
	GtkTreeIter iter;
	char * number = NULL;

	if((treesel = gtk_tree_view_get_selection(GTK_TREE_VIEW(
						smscrypt->view))) == NULL)
		return;
	if(gtk_tree_selection_get_selected(treesel, NULL, &iter) != TRUE)
		return;
	gtk_tree_model_get(GTK_TREE_MODEL(smscrypt->store), &iter,
			SMSCC_NUMBER, &number, -1);
	if(number == NULL)
		return;
	helper->config_set(helper->phone, "smscrypt", number, NULL);
	gtk_list_store_remove(smscrypt->store, &iter);
	g_free(number);
}