示例#1
0
/* smscrypt_secret */
static int _smscrypt_secret(SMSCrypt * smscrypt, char const * number)
{
	PhonePluginHelper * helper = smscrypt->helper;
	char const * secret = NULL;
	SHA_CTX sha1;

	if(number != NULL)
		secret = helper->config_get(helper->phone, "smscrypt", number);
	if(secret == NULL)
		secret = helper->config_get(helper->phone, "smscrypt",
				"secret");
	if(secret == NULL)
		return 1;
	SHA1_Init(&sha1);
	SHA1_Update(&sha1, (unsigned char const *)secret, strlen(secret));
	SHA1_Final(smscrypt->buf, &sha1);
	return 0;
}
示例#2
0
/* openmoko_deepsleep */
static void _openmoko_deepsleep(Openmoko * openmoko)
{
	PhonePluginHelper * helper = openmoko->helper;
	char const * cmd = "AT%SLEEP=4"; /* allow deep sleep */
	char const * p;

	if((p = helper->config_get(helper->phone, "openmoko", "deepsleep"))
			!= NULL && strtoul(p, NULL, 10) != 0)
		cmd = "AT%SLEEP=2"; /* prevent deep sleep */
	/* XXX this may reset the hardware modem */
	_openmoko_queue(openmoko, cmd);
}
示例#3
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);
}
示例#4
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);
}
示例#5
0
/* blacklist_event */
static int _blacklist_event(Blacklist * blacklist, PhoneEvent * event)
{
	PhonePluginHelper * helper = blacklist->helper;
	char const * number = NULL;
	char const * reason;

	switch(event->type)
	{
		case PHONE_EVENT_TYPE_MODEM_EVENT:
			if(event->modem_event.event->type
					!= MODEM_EVENT_TYPE_CALL)
				break; /* FIXME many more events to handle */
			number = event->modem_event.event->call.number;
			break;
		default:
			return 0;
	}
	if(number == NULL)
		return 0;
	reason = helper->config_get(helper->phone, "blacklist", number);
	if(reason == NULL)
		return 0;
	return helper->error(helper->phone, reason, 1);
}
示例#6
0
/* openmoko_mixer_open */
static int _openmoko_mixer_open(Openmoko * openmoko)
{
#ifdef __linux__
	PhonePluginHelper * helper = openmoko->helper;
	char const * audio_device;
	snd_mixer_elem_t * elem;

	openmoko->mixer_elem = NULL;
	openmoko->mixer_elem_headphone = NULL;
	openmoko->mixer_elem_speaker = NULL;
	if((audio_device = helper->config_get(helper->phone, "openmoko",
					"audio_device")) == NULL)
		audio_device = "hw:0";
	if(snd_mixer_open(&openmoko->mixer, 0) != 0)
	{
		openmoko->mixer = NULL;
		return -1;
	}
	if(snd_mixer_attach(openmoko->mixer, audio_device) != 0
			|| snd_mixer_selem_register(openmoko->mixer, NULL, NULL)
			|| snd_mixer_load(openmoko->mixer) != 0)
	{
		_openmoko_mixer_close(openmoko);
		return -1;
	}
	for(elem = snd_mixer_first_elem(openmoko->mixer); elem != NULL;
			elem = snd_mixer_elem_next(elem))
		if(strcmp(snd_mixer_selem_get_name(elem), "Headphone") == 0
				&& snd_mixer_selem_has_playback_volume(elem))
			openmoko->mixer_elem_headphone = elem;
		else if(strcmp(snd_mixer_selem_get_name(elem), "Speaker") == 0
				&& snd_mixer_selem_has_playback_volume(elem))
			openmoko->mixer_elem_speaker = elem;
#endif /* __linux__ */
	return 0;
}