Esempio n. 1
0
void reopen_radio() {
  if (!attempt_reopen) return;

  if (open_radio() != -1) {
      start_mute_timer();
      radio_setfreq(radio_getfreq());
      set_text_freq(radio_getfreq());
      onoff_state = 1;		/* on */
  }
  set_onoff_button(onoff_state);
}
Esempio n. 2
0
void 
do_switch_station(int nr) {
  gchar *text_utf8 = NULL, *text_locale = NULL;
  nr %= nstations;
  currentstation = nr;
  start_mute_timer();
  radio_setfreq(stations[nr].freq);
  gkrellm_locale_dup_string(&text_utf8, stations[nr].station_name, &text_locale);
  gkrellm_draw_decal_text(panel, station_text, 
      text_locale, -1);
  gkrellm_draw_panel_layers(panel);
  gkrellm_config_modified();
}
Esempio n. 3
0
void load_config(gchar *s) {
  char *key, *value;

  key = s;
  value = strchr(s, ' ');
  if (value == NULL)
    return;
  *value = '\0';
  value++;

  if (strcmp(key, "freq") == 0) {
    start_mute_timer();
    radio_setfreq(atof(value));
  } else if (strcmp(key, "nstations") == 0) {
    free_stations();
    nstations = atoi(value);
    if (nstations < 0)
      nstations = 0;
    stations = malloc(sizeof(station) * nstations);
    memset(stations, 0, sizeof(station) * nstations);
  }
  else if (strncmp(key, "stationname", 11) == 0) {
    int stnum;
    stnum = atoi(key+11);
    if (stnum >= 0 && stnum < nstations) {
      stations[stnum].station_name = strdup(value);
    }
  }
  else if (strncmp(key, "stationfreq", 11) == 0) {
    int stnum;
    stnum = atoi(key+11);
    if (stnum >= 0 && stnum < nstations) {
      stations[stnum].freq = atof(value);
    }
  }
  else if (strcmp(key, "mutetime") == 0) {
    mutetime = atof(value);
  }
  else if (strcmp(key, "attemptreopen") == 0) {
    attempt_reopen = atoi(value);
  } else if (strcmp(key, "close_atexit") == 0) {
    close_atexit = atoi(value);
  }

}
Esempio n. 4
0
void gkrellm_radio_turn_onoff(void) {
    if (!onoff_state) {  
      if (open_radio() == -1) {
        	gkrellm_message_window("GKrellM radio plugin",
			      _("Couldn't open /dev/radio"), NULL);
      } else {
	    /* radio was opened */
        onoff_state = 1; /* on */
      	start_mute_timer();
      	radio_setfreq(radio_getfreq());
        set_text_freq(radio_getfreq());
       	set_onoff_button(onoff_state);
      }
    } else {
      onoff_state = 0; /* off */
      set_onoff_button(onoff_state);
      close_radio();
    }
}
Esempio n. 5
0
/**************************************************************************
* D-Bus callback handler...
*
**************************************************************************/
gint dbus_req_handler(const gchar * interface, const gchar * method, GArray *arguments, gpointer data, osso_rpc_t * retval)
{
	osso_rpc_t argValue;
	long alarmTime = 0;	//Used for triggerAlarm call
	int alarmIndex = -1;	//Used for triggerAlarm call (-1 means no index passed)
	int alarmDResult = 0;	//Status of alarmD calls.
	unsigned int frequency = 107100;
	

	//char test[100];
	

	//osso_system_note_infoprint(ossoAppContext, test, NULL);
	
	if (arguments->len > 0) {
		argValue = g_array_index(arguments, osso_rpc_t, 0);
		
		if (argValue.type == DBUS_TYPE_UINT32) {
			frequency = argValue.value.u;
		}
		
		//printf("args len: %i\n", arguments->len);
		
		//check for fadeIn time
		if (arguments->len > 1) {
			argValue = g_array_index(arguments, osso_rpc_t, 1);
			
			if (argValue.type == DBUS_TYPE_UINT32) {
				//printf("new max vol is %u\n", argValue.value.u);
				fadeTime = argValue.value.u;
			}
		}
		
		//check for max volume
		if (arguments->len > 2) {
			argValue = g_array_index(arguments, osso_rpc_t, 2);
			
			if (argValue.type == DBUS_TYPE_UINT32) {
				//printf("new max vol is %u\n", argValue.value.u);
				maxVol = argValue.value.u;
			}
		}
	}
	
	

	//Handle dbus calls here!
	if (strcmp(method, "radioOn") == 0) {
		printf("Turn radio on!\n");
		//Just turn the radio on
		radio_unmute(radioObj);
		radio_setfreq(radioObj, frequency);	
		radio_setvolume(radioObj, maxVol);
	} else if (strcmp(method, "radioFadeIn") == 0) {
		//Fade the radio in like a regular alarm
		radio_unmute(radioObj);
		radio_setfreq(radioObj, frequency);	
		radio_setvolume(radioObj, 0);
		
		//Start the fade in
		stepVolumeUp(fadeTime / 20);
		
		
	} else if (strcmp(method, "radioOff") == 0) {
		printf("turn radio off!\n");
		//Just turn the radio on
		radio_mute(radioObj);
		
	} else if (strcmp(method, "exit") == 0) {
		//Request to exit
		osso_rpc_free_val(retval);
		deinitializeApp();
   		exit(0);
	} 
	
	
	//Cleanup
	osso_rpc_free_val(retval);

	return OSSO_OK;
}