static void read_config(void) { cmd_line = aud_get_str("song_change", "cmd_line"); cmd_line_after = aud_get_str("song_change", "cmd_line_after"); cmd_line_end = aud_get_str("song_change", "cmd_line_end"); cmd_line_ttc = aud_get_str("song_change", "cmd_line_ttc"); }
static int neon_proxy_auth_cb (void * userdata, const char * realm, int attempt, char * username, char * password) { char * value = aud_get_str (NULL, "proxy_user"); g_strlcpy (username, value, NE_ABUFSIZ); str_unref (value); value = aud_get_str (NULL, "proxy_pass"); g_strlcpy (password, value, NE_ABUFSIZ); str_unref (value); return attempt; }
static void load_enabled_from_config (void) { int count = aud_get_int ("ladspa", "plugin_count"); for (int i = 0; i < count; i ++) { char key[32]; snprintf (key, sizeof key, "plugin%d_path", i); char * path = aud_get_str ("ladspa", key); snprintf (key, sizeof key, "plugin%d_label", i); char * label = aud_get_str ("ladspa", key); PluginData * plugin = find_plugin (path, label); if (plugin) { LoadedPlugin * loaded = enable_plugin_locked (plugin); snprintf (key, sizeof key, "plugin%d_controls", i); int ccount = index_count (loaded->plugin->controls); double temp[ccount]; char * controls = aud_get_str ("ladspa", key); if (str_to_double_array (controls, temp, ccount)) { for (int ci = 0; ci < ccount; ci ++) loaded->values[ci] = temp[ci]; } else { /* migrate from old config format */ for (int ci = 0; ci < ccount; ci ++) { snprintf (key, sizeof key, "plugin%d_control%d", i, ci); loaded->values[ci] = aud_get_double ("ladspa", key); aud_set_str ("ladspa", key, ""); } } str_unref (controls); } str_unref (path); str_unref (label); } }
void pw_col_init (void) { pw_num_cols = 0; char * columns = aud_get_str ("gtkui", "playlist_columns"); Index * index = str_list_to_index (columns, " "); int count = index_count (index); if (count > PW_COLS) count = PW_COLS; for (int c = 0; c < count; c ++) { char * column = index_get (index, c); int i = 0; while (i < PW_COLS && strcmp (column, pw_col_keys[i])) i ++; if (i == PW_COLS) break; pw_cols[pw_num_cols ++] = i; } index_free_full (index, (IndexFreeFunc) str_unref); str_unref (columns); }
static char * get_path (void) { char * path = aud_get_str ("search-tool", "path"); if (g_file_test (path, G_FILE_TEST_EXISTS)) return path; str_unref (path); path = filename_build (g_get_home_dir (), "Music"); if (g_file_test (path, G_FILE_TEST_EXISTS)) return path; str_unref (path); return str_get (g_get_home_dir ()); }
static int init (void) { pthread_mutex_lock (& mutex); modules = index_new (); plugins = index_new (); loadeds = index_new (); aud_config_set_defaults ("ladspa", ladspa_defaults); module_path = aud_get_str ("ladspa", "module_path"); open_modules (); load_enabled_from_config (); pthread_mutex_unlock (& mutex); return 1; }
static GtkWidget * start_job (bool_t save) { int list = aud_playlist_get_active (); char * filename = aud_playlist_get_filename (list); char * folder = aud_get_str ("audgui", "playlist_path"); ImportExportJob * job = g_slice_new0 (ImportExportJob); job->save = save; job->list_id = aud_playlist_get_unique_id (list); create_selector (job, filename, folder[0] ? folder : NULL); str_unref (filename); str_unref (folder); return job->selector; }
void jack_set_port_connection_mode() { /* setup the port connection mode that determines how bio2jack will connect ports */ char * mode_str = aud_get_str ("jack", "port_connection_mode"); enum JACK_PORT_CONNECTION_MODE mode; if(strcmp(mode_str, "CONNECT_ALL") == 0) mode = CONNECT_ALL; else if(strcmp(mode_str, "CONNECT_OUTPUT") == 0) mode = CONNECT_OUTPUT; else if(strcmp(mode_str, "CONNECT_NONE") == 0) mode = CONNECT_NONE; else { TRACE("Defaulting to CONNECT_ALL"); mode = CONNECT_ALL; } JACK_SetPortConnectionMode(mode); str_unref (mode_str); }
static gboolean file_init (void) { aud_config_set_defaults ("filewriter", filewriter_defaults); fileext = aud_get_int ("filewriter", "fileext"); filenamefromtags = aud_get_bool ("filewriter", "filenamefromtags"); file_path = aud_get_str ("filewriter", "file_path"); prependnumber = aud_get_bool ("filewriter", "prependnumber"); save_original = aud_get_bool ("filewriter", "save_original"); use_suffix = aud_get_bool ("filewriter", "use_suffix"); if (! file_path[0]) { str_unref (file_path); file_path = filename_to_uri (g_get_home_dir ()); g_return_val_if_fail (file_path != NULL, FALSE); } set_plugin(); if (plugin->init) plugin->init(&file_write_output); return TRUE; }
static int open_handle (struct neon_handle * handle, uint64_t startbyte) { int ret; char * proxy_host = NULL; int proxy_port = 0; bool_t use_proxy = aud_get_bool (NULL, "use_proxy"); bool_t use_proxy_auth = aud_get_bool (NULL, "use_proxy_auth"); if (use_proxy) { proxy_host = aud_get_str (NULL, "proxy_host"); proxy_port = aud_get_int (NULL, "proxy_port"); } handle->redircount = 0; _DEBUG ("<%p> Parsing URL", handle); if (ne_uri_parse (handle->url, handle->purl) != 0) { _ERROR ("<%p> Could not parse URL '%s'", (void *) handle, handle->url); return -1; } while (handle->redircount < 10) { if (! handle->purl->port) handle->purl->port = ne_uri_defaultport (handle->purl->scheme); _DEBUG ("<%p> Creating session to %s://%s:%d", handle, handle->purl->scheme, handle->purl->host, handle->purl->port); handle->session = ne_session_create (handle->purl->scheme, handle->purl->host, handle->purl->port); ne_redirect_register (handle->session); ne_add_server_auth (handle->session, NE_AUTH_BASIC, server_auth_callback, (void *) handle); ne_set_session_flag (handle->session, NE_SESSFLAG_ICYPROTO, 1); ne_set_session_flag (handle->session, NE_SESSFLAG_PERSIST, 0); #ifdef HAVE_NE_SET_CONNECT_TIMEOUT ne_set_connect_timeout (handle->session, 10); #endif ne_set_read_timeout (handle->session, 10); ne_set_useragent (handle->session, "Audacious/" PACKAGE_VERSION); if (use_proxy) { _DEBUG ("<%p> Using proxy: %s:%d", handle, proxy_host, proxy_port); ne_session_proxy (handle->session, proxy_host, proxy_port); if (use_proxy_auth) { _DEBUG ("<%p> Using proxy authentication", handle); ne_add_proxy_auth (handle->session, NE_AUTH_BASIC, neon_proxy_auth_cb, (void *) handle); } } if (! strcmp ("https", handle->purl->scheme)) { ne_ssl_trust_default_ca (handle->session); ne_ssl_set_verify (handle->session, neon_vfs_verify_environment_ssl_certs, handle->session); } _DEBUG ("<%p> Creating request", handle); ret = open_request (handle, startbyte); if (! ret) { str_unref (proxy_host); return 0; } if (ret == -1) { ne_session_destroy (handle->session); handle->session = NULL; str_unref (proxy_host); return -1; } _DEBUG ("<%p> Following redirect...", handle); ne_session_destroy (handle->session); handle->session = NULL; } /* If we get here, our redirect count exceeded */ _ERROR ("<%p> Redirect count exceeded for URL %s", (void *) handle, handle->url); str_unref (proxy_host); return 1; }
/* the main alarm thread */ static gboolean alarm_timeout (void * unused) { struct tm *currtime; time_t timenow; guint today; AUDDBG("Getting time\n"); timenow = time(NULL); currtime = localtime(&timenow); today = currtime->tm_wday; AUDDBG("Today is %d\n", today); /* already went off? */ if (timenow < play_start + 60) return TRUE; if(alarm_conf.day[today].flags & ALARM_OFF) return TRUE; else { /* set the alarm_h and alarm_m for today, if not default */ if(!(alarm_conf.day[today].flags & ALARM_DEFAULT)) { alarm_h = alarm_conf.day[today].hour; alarm_m = alarm_conf.day[today].min; } else { alarm_h = alarm_conf.default_hour; alarm_m = alarm_conf.default_min; } } AUDDBG("Alarm time is %d:%d (def: %d:%d)\n", alarm_h, alarm_m, alarm_conf.default_hour, alarm_conf.default_min); AUDDBG("Checking time (%d:%d)\n", currtime->tm_hour, currtime->tm_min); if((currtime->tm_hour != alarm_h) || (currtime->tm_min != alarm_m)) return TRUE; if(cmd_on == TRUE) { char * cmdstr = aud_get_str ("alarm", "cmdstr"); AUDDBG("Executing %s, cmd_on is true\n", cmdstr); if(system(cmdstr) == -1) AUDDBG("Executing %s failed\n",cmdstr); str_unref (cmdstr); } bool_t started = FALSE; char * playlist = aud_get_str ("alarm", "playlist"); if (playlist[0]) { aud_drct_pl_open (playlist); started = TRUE; } str_unref (playlist); if(fading) { fader fade_vols; AUDDBG("Fading is true\n"); aud_drct_set_volume_main(quietvol); /* start playing */ play_start = time(NULL); if (! started) aud_drct_play (); /* fade volume */ fade_vols.start = quietvol; fade_vols.end = volume; //alarm_fade(quietvol, volume); alarm_thread_create(alarm_fade, &fade_vols, 0); } else { /* no fading */ /* set volume */ aud_drct_set_volume_main(volume); /* start playing */ play_start = time(NULL); aud_drct_play(); } if(alarm_conf.reminder_on == TRUE) { char * reminder_msg = aud_get_str ("alarm", "reminder_msg"); GtkWidget *reminder_dialog; AUDDBG("Showing reminder '%s'\n", reminder_msg); reminder_dialog = (GtkWidget*) create_reminder_dialog(reminder_msg); gtk_widget_show_all(reminder_dialog); str_unref (reminder_msg); } /* bring up the wakeup call dialog if stop_on is set TRUE, this * has been moved to after making Audacious play so that it doesnt * get in the way for people with manual window placement turned on * * this means that the dialog doesnt get shown until the volume has * finished fading though !, so thats something else to fix */ if(stop_on == TRUE) { alarm_dialog = create_alarm_dialog(); AUDDBG("now starting stop thread\n"); stop = alarm_thread_create(alarm_stop_thread, NULL, 0); AUDDBG("Created wakeup dialog and started stop thread\n"); } return TRUE; }
/* * displays the configuration window and opens the config file. */ static void alarm_configure(void) { int daynum = 0; // used to loop days GtkWidget *w; if (config_dialog) { gtk_window_present(GTK_WINDOW(config_dialog)); return; } alarm_read_config(); /* * Create the widgets */ config_dialog = create_config_dialog(); w = lookup_widget(config_dialog, "alarm_h_spin"); alarm_conf.alarm_h = GTK_SPIN_BUTTON(w); gtk_spin_button_set_value(alarm_conf.alarm_h, alarm_h); w = lookup_widget(config_dialog, "alarm_m_spin"); alarm_conf.alarm_m = GTK_SPIN_BUTTON(w); gtk_spin_button_set_value(alarm_conf.alarm_m, alarm_m); w = lookup_widget(config_dialog, "stop_h_spin"); alarm_conf.stop_h = GTK_SPIN_BUTTON(w); gtk_spin_button_set_value(alarm_conf.stop_h, stop_h); w = lookup_widget(config_dialog, "stop_m_spin"); alarm_conf.stop_m = GTK_SPIN_BUTTON(w); gtk_spin_button_set_value(alarm_conf.stop_m, stop_m); w = lookup_widget(config_dialog, "stop_checkb"); alarm_conf.stop_on = GTK_TOGGLE_BUTTON(w); gtk_toggle_button_set_active(alarm_conf.stop_on, stop_on); w = lookup_widget(config_dialog, "vol_scale"); alarm_conf.volume = GTK_RANGE(w); gtk_range_set_adjustment(alarm_conf.volume, GTK_ADJUSTMENT(gtk_adjustment_new(volume, 0, 100, 1, 5, 0))); w = lookup_widget(config_dialog, "quiet_vol_scale"); alarm_conf.quietvol = GTK_RANGE(w); gtk_range_set_adjustment(alarm_conf.quietvol, GTK_ADJUSTMENT(gtk_adjustment_new(quietvol, 0, 100, 1, 5, 0))); /* days of week */ for(; daynum < 7; daynum++) { w = lookup_widget(config_dialog, day_cb[daynum]); alarm_conf.day[daynum].cb = GTK_CHECK_BUTTON(w); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alarm_conf.day[daynum].cb), !(alarm_conf.day[daynum].flags & ALARM_OFF)); w = lookup_widget(config_dialog, day_def[daynum]); alarm_conf.day[daynum].cb_def = GTK_CHECK_BUTTON(w); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alarm_conf.day[daynum].cb_def), alarm_conf.day[daynum].flags & ALARM_DEFAULT); /* Changed to show default time instead of set time when ALARM_DEFAULT set, * as suggested by Mark Brown */ /* w = lookup_widget(config_dialog, day_h[daynum]); alarm_conf.day[daynum].spin_hr = GTK_SPIN_BUTTON(w); gtk_spin_button_set_value(alarm_conf.day[daynum].spin_hr, alarm_conf.day[daynum].hour); w = lookup_widget(config_dialog, day_m[daynum]); alarm_conf.day[daynum].spin_min = GTK_SPIN_BUTTON(w); gtk_spin_button_set_value(alarm_conf.day[daynum].spin_min, alarm_conf.day[daynum].min); */ if(alarm_conf.day[daynum].flags & ALARM_DEFAULT) { w = lookup_widget(config_dialog, day_h[daynum]); alarm_conf.day[daynum].spin_hr = GTK_SPIN_BUTTON(w); gtk_spin_button_set_value(alarm_conf.day[daynum].spin_hr, alarm_conf.default_hour); w = lookup_widget(config_dialog, day_m[daynum]); alarm_conf.day[daynum].spin_min = GTK_SPIN_BUTTON(w); gtk_spin_button_set_value(alarm_conf.day[daynum].spin_min, alarm_conf.default_min); gtk_widget_set_sensitive((GtkWidget *)alarm_conf.day[daynum].spin_hr, FALSE); gtk_widget_set_sensitive((GtkWidget *)alarm_conf.day[daynum].spin_min, FALSE); } else { w = lookup_widget(config_dialog, day_h[daynum]); alarm_conf.day[daynum].spin_hr = GTK_SPIN_BUTTON(w); gtk_spin_button_set_value(alarm_conf.day[daynum].spin_hr, alarm_conf.day[daynum].hour); w = lookup_widget(config_dialog, day_m[daynum]); alarm_conf.day[daynum].spin_min = GTK_SPIN_BUTTON(w); gtk_spin_button_set_value(alarm_conf.day[daynum].spin_min, alarm_conf.day[daynum].min); gtk_widget_set_sensitive((GtkWidget *)alarm_conf.day[daynum].spin_hr, TRUE); gtk_widget_set_sensitive((GtkWidget *)alarm_conf.day[daynum].spin_min, TRUE); } } /* END: days of week */ w = lookup_widget(config_dialog,"fading_spin"); alarm_conf.fading = GTK_SPIN_BUTTON(w); gtk_spin_button_set_value(alarm_conf.fading, fading); char * cmdstr = aud_get_str ("alarm", "cmdstr"); w = lookup_widget(config_dialog, "cmd_entry"); alarm_conf.cmdstr = GTK_ENTRY(w); gtk_entry_set_text(alarm_conf.cmdstr, cmdstr); str_unref (cmdstr); w = lookup_widget(config_dialog, "cmd_checkb"); alarm_conf.cmd_on = GTK_TOGGLE_BUTTON(w); gtk_toggle_button_set_active(alarm_conf.cmd_on, cmd_on); char * playlist = aud_get_str ("alarm", "playlist"); w = lookup_widget(config_dialog, "playlist"); alarm_conf.playlist = GTK_ENTRY(w); gtk_entry_set_text(alarm_conf.playlist, playlist); str_unref (playlist); char * reminder_msg = aud_get_str ("alarm", "reminder_msg"); w = lookup_widget(config_dialog, "reminder_text"); alarm_conf.reminder = GTK_ENTRY(w); gtk_entry_set_text(alarm_conf.reminder, reminder_msg); str_unref (reminder_msg); w = lookup_widget(config_dialog, "reminder_cb"); alarm_conf.reminder_cb = GTK_TOGGLE_BUTTON(w); gtk_toggle_button_set_active(alarm_conf.reminder_cb, alarm_conf.reminder_on); g_signal_connect (config_dialog, "destroy", (GCallback) gtk_widget_destroyed, & config_dialog); AUDDBG("END alarm_configure\n"); }
void try_init(void) { bool_t init_success = TRUE; char *md5_file = aud_get_str (PLUGIN_NAME, MODLAND_ALLMODS_MD5_FILE); str_unref(md5_file); char line[LINE_MAX]; if (!strncmp(previous_md5_file, md5_file, FILENAME_MAX)) { return; } DEBUG("Modland allmods_md5.txt location changed\n"); previous_md5_file = md5_file; initialized = FALSE; modland_cleanup(); if (!strnlen(md5_file, FILENAME_MAX)) { DEBUG("Modland allmods_md5.txt location not defined\n"); return; } FILE *file = fopen(md5_file, "r"); if (!file) { ERROR("Could not open modland file %s\n", md5_file); return; } while(fgets(line, LINE_MAX, file)) { char md5[33]; char path[LINE_MAX]; // sanity check if (strnlen(line, LINE_MAX) <= 34) { ERROR("Too short line %s\n", line); init_success = FALSE; goto out; } strlcpy(md5, line, sizeof(md5)); if (modland_internal_lookup(md5)) { DEBUG("Duplicate md5: %s", line); continue; } strlcpy(path, line + 33, sizeof(path)); modland_data_t *item = calloc(1, sizeof(modland_data_t)); switch (parse_modland_path(path, item)) { case 0: multihash_lookup (&ml_table, str_get(md5), md5_hash(md5), add_cb, NULL, item); break; case 1: continue; default: init_success = FALSE; goto out; } TRACE("%s -> format = %s, author = %s, album = %s\n", line, item->format, item->author, item->album); } out: fclose(file); if (init_success) { initialized = TRUE; } else { modland_cleanup(); } return; }