32 #include <libaudtag/audtag.h>
35 #include "../libaudclient/audctrl.h"
51 #define AUTOSAVE_INTERVAL 300
72 const mode_t mode755 = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
74 const mode_t mode755 = S_IRWXU;
86 int len = strlen (path);
88 if (len > 3 && path[len - 1] ==
'\\')
90 if (len > 1 && path[len - 1] ==
'/')
97 char * slash = strrchr (path, G_DIR_SEPARATOR);
98 return (slash && slash[1]) ? slash + 1 :
NULL;
113 static void relocate_path (
char * * pathp,
const char * old,
const char *
new)
115 char * path = * pathp;
116 int oldlen = strlen (old);
117 int newlen = strlen (
new);
119 if (oldlen && old[oldlen - 1] == G_DIR_SEPARATOR)
121 if (newlen &&
new[newlen - 1] == G_DIR_SEPARATOR)
125 if (strncasecmp (path, old, oldlen) || (path[oldlen] && path[oldlen] != G_DIR_SEPARATOR))
127 if (strncmp (path, old, oldlen) || (path[oldlen] && path[oldlen] != G_DIR_SEPARATOR))
130 fprintf (stderr,
"Failed to relocate a data path. Falling back to "
131 "compile-time path: %s\n", path);
135 * pathp = g_strdup_printf (
"%.*s%s", newlen,
new, path + oldlen);
157 char * old = g_strdup (
aud_paths[AUD_PATH_BIN_DIR]);
204 const char * xdg_config_home = g_get_user_config_dir ();
205 const char * xdg_data_home = g_get_user_data_dir ();
210 g_setenv (
"HOME", g_get_home_dir (),
TRUE);
211 g_setenv (
"XDG_CONFIG_HOME", xdg_config_home,
TRUE);
212 g_setenv (
"XDG_DATA_HOME", xdg_data_home,
TRUE);
213 g_setenv (
"XDG_CACHE_HOME", g_get_user_cache_dir (),
TRUE);
232 {
"rew",
'r', 0, G_OPTION_ARG_NONE, &
options.rew,
N_(
"Skip backwards in playlist"),
NULL},
233 {
"play",
'p', 0, G_OPTION_ARG_NONE, &
options.play,
N_(
"Start playing current playlist"),
NULL},
234 {
"pause",
'u', 0, G_OPTION_ARG_NONE, &
options.pause,
N_(
"Pause current song"),
NULL},
235 {
"stop",
's', 0, G_OPTION_ARG_NONE, &
options.stop,
N_(
"Stop current song"),
NULL},
236 {
"play-pause",
't', 0, G_OPTION_ARG_NONE, &
options.play_pause,
N_(
"Pause if playing, play otherwise"),
NULL},
237 {
"fwd",
'f', 0, G_OPTION_ARG_NONE, &
options.fwd,
N_(
"Skip forward in playlist"),
NULL},
238 {
"show-jump-box",
'j', 0, G_OPTION_ARG_NONE, &
options.show_jump_box,
N_(
"Display Jump to File dialog"),
NULL},
239 {
"enqueue",
'e', 0, G_OPTION_ARG_NONE, &
options.enqueue,
N_(
"Add files to the playlist"),
NULL},
240 {
"enqueue-to-temp",
'E', 0, G_OPTION_ARG_NONE, &
options.enqueue_to_temp,
N_(
"Add new files to a temporary playlist"),
NULL},
241 {
"show-main-window",
'm', 0, G_OPTION_ARG_NONE, &
options.mainwin,
N_(
"Display the main window"),
NULL},
242 {
"headless",
'h', 0, G_OPTION_ARG_NONE, &
headless,
N_(
"Headless mode"),
NULL},
243 {
"quit-after-play",
'q', 0, G_OPTION_ARG_NONE, &
options.quit_after_play,
N_(
"Quit on playback stop"),
NULL},
244 {
"version",
'v', 0, G_OPTION_ARG_NONE, &
options.version,
N_(
"Show version"),
NULL},
245 {
"verbose",
'V', 0, G_OPTION_ARG_NONE, &
options.verbose,
N_(
"Print debugging messages"),
NULL},
246 {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &
options.filenames,
N_(
"FILE..."),
NULL},
252 GOptionContext *context;
258 context = g_option_context_new(
_(
"- play multimedia files"));
259 g_option_context_add_main_entries(context,
cmd_entries, PACKAGE);
260 g_option_context_add_group(context, gtk_get_option_group(
FALSE));
262 if (!g_option_context_parse(context, argc, argv, &error))
265 _(
"%s: %s\nTry `%s --help' for more information.\n"), (* argv)[0],
266 error->message, (* argv)[0]);
267 g_error_free (error);
271 g_option_context_free (context);
279 int handle = open (path, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
284 fprintf (stderr,
"Cannot create %s: %s.\n", path, strerror (errno));
308 char * * f =
options.filenames;
309 char * cur = g_get_current_dir ();
311 for (
int i = 0; f[i]; i ++)
315 if (strstr (f[i],
"://"))
317 else if (g_path_is_absolute (f[i]))
325 char * tmp = g_build_filename (cur, f[i],
NULL);
360 list = g_list_prepend (list,
index_get (filenames, f));
398 fprintf (stderr,
"WARNING: Audacious seems to be already running but is not responding.\n");
444 setlocale (LC_ALL,
"");
446 bind_textdomain_codeset (PACKAGE,
"UTF-8");
447 bindtextdomain (PACKAGE
"-plugins",
aud_paths[AUD_PATH_LOCALE_DIR]);
448 bind_textdomain_codeset (PACKAGE
"-plugins",
"UTF-8");
449 textdomain (PACKAGE);
452 static void init_two (
int * p_argc,
char * * * p_argv)
456 #if ! GLIB_CHECK_VERSION (2, 32, 0)
457 g_thread_init (
NULL);
459 gtk_init (p_argc, p_argv);
462 AUDDBG (
"Loading configuration.\n");
465 AUDDBG (
"Initializing.\n");
478 AUDDBG (
"Loading lowlevel plugins.\n");
481 AUDDBG (
"Starting worker threads.\n");
485 AUDDBG (
"Restoring state.\n");
490 AUDDBG (
"Loading highlevel plugins.\n");
504 AUDDBG (
"Saving playlist state.\n");
507 AUDDBG (
"Unloading highlevel plugins.\n");
514 AUDDBG (
"Stopping playback.\n");
518 AUDDBG (
"Stopping worker threads.\n");
522 AUDDBG (
"Unloading lowlevel plugins.\n");
525 AUDDBG (
"Saving configuration.\n");
529 AUDDBG (
"Cleaning up.\n");
540 AUDDBG (
"Saving configuration.\n");
558 int main(
int argc,
char ** argv)
565 printf (
"%s %s (%s)\n",
_(
"Audacious"), VERSION, BUILDSTAMP);
572 AUDDBG (
"No remote session; starting up.\n");
575 AUDDBG (
"Startup complete.\n");
EXPORT void audacious_remote_stop(DBusGProxy *proxy)
Tells audacious to stop.
EXPORT void audacious_remote_playlist_next(DBusGProxy *proxy)
Tells audacious to move forward in the playlist.
void strpool_shutdown(void)
void mpris_signals_init(void)
EXPORT void audacious_remote_playlist_open_list(DBusGProxy *proxy, GList *list)
Sends a list of URIs for Audacious to open.
static void make_dirs(void)
static void do_remote(void)
static void release_lock(void)
static void init_paths(void)
EXPORT Index * index_new(void)
static void shut_down(void)
EXPORT void audacious_remote_playlist_open_list_to_temp(DBusGProxy *proxy, GList *list)
Sends a list of URIs for Audacious to open in a temporary playlist.
static float a[EQ_BANDS][2]
EXPORT void audacious_remote_playlist_add(DBusGProxy *proxy, GList *list)
Sends a list of URIs to Audacious to add to the playlist.
void load_playlists(void)
void stop_plugins_two(void)
EXPORT gboolean audacious_remote_is_running(DBusGProxy *proxy)
Check if an Audacious instance is running.
static void maybe_quit(void)
static void strip_path_element(char *path, char *elem)
void stop_plugins_one(void)
static void parse_options(int *argc, char ***argv)
static float b[EQ_BANDS][2]
static char * last_path_element(char *path)
bool_t playlist_add_in_progress(int playlist)
EXPORT int index_count(Index *index)
void(* HookFunction)(void *data, void *user)
EXPORT void hook_associate(const char *name, HookFunction func, void *user)
EXPORT void string_replace_char(char *string, char old_c, char new_c)
void mpris_signals_cleanup(void)
static Index * convert_filenames(void)
void drct_pl_open_list(Index *filenames)
EXPORT void audacious_remote_main_win_toggle(DBusGProxy *proxy, gboolean show)
Toggles the main window's visibility.
#define hook_dissociate(n, f)
char * get_path_to_self(void)
void scanner_cleanup(void)
static bool_t get_lock(void)
EXPORT void * index_get(Index *index, int at)
EXPORT void index_append(Index *index, void *value)
static void relocate_path(char **pathp, const char *old, const char *new)
EXPORT void audacious_remote_play(DBusGProxy *proxy)
Requests audacious to begin playback.
void save_playlists(bool_t exiting)
void config_cleanup(void)
bool_t get_bool(const char *section, const char *name)
EXPORT void audacious_remote_pause(DBusGProxy *proxy)
Tells audacious to pause.
DBusGProxy * audacious_get_dbus_proxy(void)
static char * aud_paths[AUD_PATH_COUNT]
EXPORT void audacious_remote_playlist_prev(DBusGProxy *proxy)
audacious_remote_playlist_prev:
#define AUTOSAVE_INTERVAL
void str_unref(char *str)
EXPORT void index_free(Index *index)
const char * get_path(int id)
char * previous_session_id
void drct_pl_add_list(Index *filenames, int at)
bool_t drct_get_paused(void)
void interface_show_jump_to_track(void)
void history_cleanup(void)
void drct_pl_open_temp_list(Index *filenames)
EXPORT void hook_call(const char *name, void *data)
void start_plugins_one(void)
static GOptionEntry cmd_entries[]
static void do_commands(void)
void make_directory(const char *path, mode_t mode)
EXPORT void vfs_set_verbose(bool_t set)
static void normalize_path(char *path)
static void init_one(void)
EXPORT char * filename_to_uri(const char *name)
static void init_two(int *p_argc, char ***p_argv)
char * str_get(const char *str)
static bool_t check_should_quit(void)
void start_plugins_two(void)
void interface_show(bool_t show)
EXPORT void audacious_remote_play_pause(DBusGProxy *proxy)
Tells audacious to toggle between play and pause.
int main(int argc, char **argv)
EXPORT void audacious_remote_show_jtf_box(DBusGProxy *proxy)
Tells audacious to show the Jump-to-File pane.
void playlist_resume(void)
static void relocate_paths(void)
bool_t drct_get_playing(void)