summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/menus/playlist_menu.c14
-rw-r--r--apps/misc.c7
-rw-r--r--apps/misc.h1
-rw-r--r--apps/onplay.c9
-rw-r--r--apps/playlist_catalog.c48
-rw-r--r--apps/playlist_catalog.h3
6 files changed, 55 insertions, 27 deletions
diff --git a/apps/menus/playlist_menu.c b/apps/menus/playlist_menu.c
index 9db87aa7a5..0983f9c338 100644
--- a/apps/menus/playlist_menu.c
+++ b/apps/menus/playlist_menu.c
@@ -65,18 +65,10 @@ int save_playlist_screen(struct playlist_info* playlist)
65 strlcat(temp, DEFAULT_DYNAMIC_PLAYLIST_NAME, sizeof(temp)); 65 strlcat(temp, DEFAULT_DYNAMIC_PLAYLIST_NAME, sizeof(temp));
66 } 66 }
67 67
68 dot = strrchr(temp, '.'); 68 if (catalog_pick_new_playlist_name(temp, sizeof(temp),
69 if (dot) /* remove extension */ 69 playlist ? playlist->filename :
70 *dot = '\0'; 70 playlist_get_current()->filename))
71
72 if (!kbd_input(temp, sizeof(temp), NULL))
73 { 71 {
74 len = strlen(temp);
75 if(len > 4 && !strcasecmp(&temp[len-4], ".m3u"))
76 strlcat(temp, "8", sizeof(temp));
77 else if(len <= 5 || strcasecmp(&temp[len-5], ".m3u8"))
78 strlcat(temp, ".m3u8", sizeof(temp));
79
80 playlist_save(playlist, temp, NULL, 0); 72 playlist_save(playlist, temp, NULL, 0);
81 73
82 /* reload in case playlist was saved to cwd */ 74 /* reload in case playlist was saved to cwd */
diff --git a/apps/misc.c b/apps/misc.c
index 21a45037ad..a054cfa7b6 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -1227,6 +1227,13 @@ int confirm_delete_yesno(const char *name)
1227 return gui_syncyesno_run(&message, &yes_message, NULL); 1227 return gui_syncyesno_run(&message, &yes_message, NULL);
1228} 1228}
1229 1229
1230int confirm_overwrite_yesno(void)
1231{
1232 static const char *lines[] = { ID2P(LANG_REALLY_OVERWRITE) };
1233 static const struct text_message message = { lines, 1 };
1234 return gui_syncyesno_run(&message, NULL, NULL);
1235}
1236
1230/* time_split_units() 1237/* time_split_units()
1231 split time values depending on base unit 1238 split time values depending on base unit
1232 unit_idx: UNIT_HOUR, UNIT_MIN, UNIT_SEC, UNIT_MS 1239 unit_idx: UNIT_HOUR, UNIT_MIN, UNIT_SEC, UNIT_MS
diff --git a/apps/misc.h b/apps/misc.h
index b7a9a5c42c..497aa04c78 100644
--- a/apps/misc.h
+++ b/apps/misc.h
@@ -159,6 +159,7 @@ int hex_to_rgb(const char* hex, int* color);
159#endif 159#endif
160 160
161int confirm_delete_yesno(const char *name); 161int confirm_delete_yesno(const char *name);
162int confirm_overwrite_yesno(void);
162 163
163char* strrsplt(char* str, int c); 164char* strrsplt(char* str, int c);
164char* skip_whitespace(char* const str); 165char* skip_whitespace(char* const str);
diff --git a/apps/onplay.c b/apps/onplay.c
index 341da62840..a9cbc64598 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -948,13 +948,6 @@ static bool poll_cancel_action(const char *path)
948 return ACTION_STD_CANCEL == get_action(CONTEXT_STD, TIMEOUT_NOBLOCK); 948 return ACTION_STD_CANCEL == get_action(CONTEXT_STD, TIMEOUT_NOBLOCK);
949} 949}
950 950
951static int confirm_overwrite(void)
952{
953 static const char *lines[] = { ID2P(LANG_REALLY_OVERWRITE) };
954 static const struct text_message message = { lines, 1 };
955 return gui_syncyesno_run(&message, NULL, NULL);
956}
957
958static bool check_new_name(const char *basename) 951static bool check_new_name(const char *basename)
959{ 952{
960 /* at least prevent escapes out of the base directory from keyboard- 953 /* at least prevent escapes out of the base directory from keyboard-
@@ -1426,7 +1419,7 @@ static int clipboard_paste(void)
1426 case RELATE_DIFFERENT: 1419 case RELATE_DIFFERENT:
1427 if (file_exists(target.path)) { 1420 if (file_exists(target.path)) {
1428 /* If user chooses not to overwrite, cancel */ 1421 /* If user chooses not to overwrite, cancel */
1429 if (confirm_overwrite() == YESNO_NO) { 1422 if (confirm_overwrite_yesno() == YESNO_NO) {
1430 rc = OPRC_NOOVERWRT; 1423 rc = OPRC_NOOVERWRT;
1431 break; 1424 break;
1432 } 1425 }
diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c
index b6939208ac..be992645ee 100644
--- a/apps/playlist_catalog.c
+++ b/apps/playlist_catalog.c
@@ -389,6 +389,43 @@ bool catalog_view_playlists(void)
389 return (display_playlists(NULL, CATBROWSE_CATVIEW) >= 0); 389 return (display_playlists(NULL, CATBROWSE_CATVIEW) >= 0);
390} 390}
391 391
392static void apply_playlist_extension(char* buf, size_t buf_size)
393{
394 size_t len = strlen(buf);
395 if(len > 4 && !strcasecmp(&buf[len-4], ".m3u"))
396 strlcat(buf, "8", buf_size);
397 else if(len <= 5 || strcasecmp(&buf[len-5], ".m3u8"))
398 strlcat(buf, ".m3u8", buf_size);
399}
400
401static int remove_extension(char* path)
402{
403 char *dot = strrchr(path, '.');
404 if (dot)
405 *dot = '\0';
406
407 return 0;
408}
409
410
411bool catalog_pick_new_playlist_name(char *pl_name, size_t buf_size,
412 const char* curr_pl_name)
413{
414 bool do_save = false;
415 while (!do_save && !remove_extension(pl_name) &&
416 !kbd_input(pl_name, buf_size - 7, NULL))
417 {
418 do_save = true;
419 apply_playlist_extension(pl_name, buf_size);
420
421 /* warn before overwriting existing (different) playlist */
422 if ((!curr_pl_name || strcmp(curr_pl_name, pl_name)) &&
423 file_exists(pl_name))
424 do_save = confirm_overwrite_yesno() == YESNO_YES;
425 }
426 return do_save;
427}
428
392static int (*ctx_add_to_playlist)(const char* playlist, bool new_playlist); 429static int (*ctx_add_to_playlist)(const char* playlist, bool new_playlist);
393bool catalog_add_to_a_playlist(const char* sel, int sel_attr, 430bool catalog_add_to_a_playlist(const char* sel, int sel_attr,
394 bool new_playlist, char *m3u8name, 431 bool new_playlist, char *m3u8name,
@@ -404,7 +441,6 @@ bool catalog_add_to_a_playlist(const char* sel, int sel_attr,
404 441
405 if (new_playlist) 442 if (new_playlist)
406 { 443 {
407 size_t len;
408 if (m3u8name == NULL) 444 if (m3u8name == NULL)
409 { 445 {
410 const char *name; 446 const char *name;
@@ -425,14 +461,10 @@ bool catalog_add_to_a_playlist(const char* sel, int sel_attr,
425 else 461 else
426 strmemccpy(playlist, m3u8name, MAX_PATH); 462 strmemccpy(playlist, m3u8name, MAX_PATH);
427 463
428 if (kbd_input(playlist, MAX_PATH, NULL)) 464 apply_playlist_extension(playlist, sizeof(playlist));
465
466 if (!catalog_pick_new_playlist_name(playlist, sizeof(playlist), NULL))
429 return false; 467 return false;
430
431 len = strlen(playlist);
432 if(len > 4 && !strcasecmp(&playlist[len-4], ".m3u"))
433 strlcat(playlist, "8", sizeof(playlist));
434 else if(len <= 5 || strcasecmp(&playlist[len-5], ".m3u8"))
435 strlcat(playlist, ".m3u8", sizeof(playlist));
436 } 468 }
437 else 469 else
438 { 470 {
diff --git a/apps/playlist_catalog.h b/apps/playlist_catalog.h
index fb71821093..756a1e1129 100644
--- a/apps/playlist_catalog.h
+++ b/apps/playlist_catalog.h
@@ -33,6 +33,9 @@ void catalog_set_directory(const char* directory);
33 */ 33 */
34bool catalog_view_playlists(void); 34bool catalog_view_playlists(void);
35 35
36bool catalog_pick_new_playlist_name(char *pl_name, size_t buf_size,
37 const char* curr_pl_name);
38
36/* 39/*
37 * Add something to a playlist (new or select from list of playlists in 40 * Add something to a playlist (new or select from list of playlists in
38 * catalog). 41 * catalog).