summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 06aafa1)
raw | patch | inline | side by side (parent: 06aafa1)
author | Max Kellermann <max@duempel.org> | |
Fri, 7 Nov 2008 15:14:39 +0000 (16:14 +0100) | ||
committer | Max Kellermann <max@duempel.org> | |
Fri, 7 Nov 2008 15:14:39 +0000 (16:14 +0100) |
Don't convert the character set of strings to and from the current
locale. This library cannot know what the strings are going to be
used for, so it should not mess with them.
locale. This library cannot know what the strings are going to be
used for, so it should not mess with them.
diff --git a/src/main.c b/src/main.c
index 1e65cfeb8bf16145b6415dfb2737ae2a28e690fa..b9fb3cd0e58642c95dd19d3f2c8f2a8b274ef80d 100644 (file)
--- a/src/main.c
+++ b/src/main.c
}
static void
-error_callback(mpd_unused mpdclient_t *c, gint error, const gchar *msg)
+error_callback(mpd_unused mpdclient_t *c, gint error, const gchar *_msg)
{
+ char *msg = utf8_to_locale(_msg);
+
error = error & 0xFF;
switch (error) {
case MPD_ERROR_CONNPORT:
doupdate();
connected = FALSE;
}
+
+ g_free(msg);
}
#ifndef NCMPC_MINI
diff --git a/src/mpdclient.c b/src/mpdclient.c
index df636a566caea042d455aa648d673d8293c24c6c..7907eead5d293862265a95b2bfea884d40b70036 100644 (file)
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
#include "mpdclient.h"
#include "screen_utils.h"
#include "config.h"
-#include "charset.h"
#include "options.h"
#include "strfsong.h"
if (c->connection->error) {
gint error = c->connection->error;
- gchar *msg;
if (error == MPD_ERROR_ACK &&
c->connection->errorCode == MPD_ACK_ERROR_PERMISSION &&
if (error == MPD_ERROR_ACK)
error = error | (c->connection->errorCode << 8);
- msg = locale_to_utf8(c->connection->errorStr);
- error_cb(c, error, msg);
- g_free(msg);
+ error_cb(c, error, c->connection->errorStr);
return error;
}
}
gint
-mpdclient_cmd_add_path_utf8(mpdclient_t *c, gchar *path_utf8)
+mpdclient_cmd_add_path(mpdclient_t *c, gchar *path_utf8)
{
mpd_sendAddCommand(c->connection, path_utf8);
return mpdclient_finish_command(c);
}
-gint
-mpdclient_cmd_add_path(mpdclient_t *c, gchar *path)
-{
- gint retval;
- gchar *path_utf8 = locale_to_utf8(path);
-
- retval=mpdclient_cmd_add_path_utf8(c, path_utf8);
- g_free(path_utf8);
- return retval;
-}
-
gint
mpdclient_cmd_add(mpdclient_t *c, struct mpd_song *song)
{
}
gint
-mpdclient_cmd_save_playlist_utf8(mpdclient_t *c, gchar *filename_utf8)
+mpdclient_cmd_save_playlist(mpdclient_t *c, gchar *filename_utf8)
{
gint retval = 0;
return retval;
}
-gint
-mpdclient_cmd_save_playlist(mpdclient_t *c, gchar *filename)
-{
- gint retval = 0;
- gchar *filename_utf8 = locale_to_utf8(filename);
-
- retval = mpdclient_cmd_save_playlist_utf8(c, filename);
- g_free(filename_utf8);
- return retval;
-}
-
gint
mpdclient_cmd_load_playlist_utf8(mpdclient_t *c, gchar *filename_utf8)
{
}
gint
-mpdclient_cmd_delete_playlist_utf8(mpdclient_t *c, gchar *filename_utf8)
+mpdclient_cmd_delete_playlist(mpdclient_t *c, gchar *filename_utf8)
{
gint retval = 0;
return retval;
}
-gint
-mpdclient_cmd_delete_playlist(mpdclient_t *c, gchar *filename)
-{
- gint retval = 0;
- gchar *filename_utf8 = locale_to_utf8(filename);
-
- retval = mpdclient_cmd_delete_playlist_utf8(c, filename_utf8);
- g_free(filename_utf8);
- return retval;
-}
-
/****************************************************************************/
/*** Callback managment functions *******************************************/
{
mpdclient_filelist_t *filelist;
mpd_InfoEntity *entity;
- gchar *path_utf8 = locale_to_utf8(path);
gboolean has_dirs_only = TRUE;
- mpd_sendLsInfoCommand(c->connection, path_utf8);
+ mpd_sendLsInfoCommand(c->connection, path);
filelist = filelist_new(path);
if (path && path[0] && strcmp(path, "/"))
/* add a dummy entry for ./.. */
/* If there's an error, ignore it. We'll return an empty filelist. */
mpdclient_finish_command(c);
- g_free(path_utf8);
-
// If there are only directory entities in the filelist, we sort it
if (has_dirs_only)
filelist_sort(filelist, compare_filelistentry_dir);
}
mpdclient_filelist_t *
-mpdclient_filelist_search_utf8(mpdclient_t *c,
- int exact_match,
- int table,
- gchar *filter_utf8)
+mpdclient_filelist_search(mpdclient_t *c,
+ int exact_match,
+ int table,
+ gchar *filter_utf8)
{
mpdclient_filelist_t *filelist;
mpd_InfoEntity *entity;
return filelist;
}
-
-mpdclient_filelist_t *
-mpdclient_filelist_search(mpdclient_t *c,
- int exact_match,
- int table,
- gchar *_filter)
-{
- mpdclient_filelist_t *filelist;
- gchar *filter_utf8 = locale_to_utf8(_filter);
-
- filelist = mpdclient_filelist_search_utf8(c, exact_match, table,
- filter_utf8);
- g_free(filter_utf8);
-
- return filelist;
-}
-
mpdclient_filelist_t *
mpdclient_filelist_update(mpdclient_t *c, mpdclient_filelist_t *filelist)
{
diff --git a/src/mpdclient.h b/src/mpdclient.h
index a78aafa345d9278214bdfea68d9dbdc09cd535f8..d0d5cdfd23f62488d034eb2237c462571d68637b 100644 (file)
--- a/src/mpdclient.h
+++ b/src/mpdclient.h
gint mpdclient_cmd_db_update_utf8(mpdclient_t *c, gchar *path);
gint mpdclient_cmd_volume(mpdclient_t *c, gint value);
gint mpdclient_cmd_add_path(mpdclient_t *c, gchar *path);
-gint mpdclient_cmd_add_path_utf8(mpdclient_t *c, gchar *path);
gint mpdclient_cmd_add(mpdclient_t *c, struct mpd_song *song);
gint mpdclient_cmd_delete(mpdclient_t *c, gint index);
gint mpdclient_cmd_move(mpdclient_t *c, gint old_index, gint new_index);
gint mpdclient_cmd_save_playlist(mpdclient_t *c, gchar *filename);
-gint mpdclient_cmd_save_playlist_utf8(mpdclient_t *c, gchar *filename);
gint mpdclient_cmd_load_playlist_utf8(mpdclient_t *c, gchar *filename_utf8);
-gint mpdclient_cmd_delete_playlist(mpdclient_t *c, gchar *filename);
-gint mpdclient_cmd_delete_playlist_utf8(mpdclient_t *c, gchar *filename_utf8);
+gint mpdclient_cmd_delete_playlist(mpdclient_t *c, gchar *filename_utf8);
/* list functions */
GList *mpdclient_get_artists_utf8(mpdclient_t *c);
@@ -124,11 +121,7 @@ mpdclient_filelist_t *mpdclient_filelist_get(mpdclient_t *c, const gchar *path);
mpdclient_filelist_t *mpdclient_filelist_search(mpdclient_t *c,
int exact_match,
int table,
- gchar *path);
-mpdclient_filelist_t *mpdclient_filelist_search_utf8(mpdclient_t *c,
- int exact_match,
- int table,
- gchar *path);
+ gchar *filter_utf8);
mpdclient_filelist_t *mpdclient_filelist_update(mpdclient_t *c,
mpdclient_filelist_t *flist);
diff --git a/src/screen_artist.c b/src/screen_artist.c
index 5fec3c04c980c178b2172e001694eb471dadb3ca..35db917762e1ec76f1dfaa094edc7091d760baac 100644 (file)
--- a/src/screen_artist.c
+++ b/src/screen_artist.c
if (album[0] == 0)
browser.filelist =
- mpdclient_filelist_search_utf8(c, TRUE,
- MPD_TABLE_ARTIST,
- artist);
+ mpdclient_filelist_search(c, TRUE,
+ MPD_TABLE_ARTIST,
+ artist);
else
browser.filelist =
- mpdclient_filelist_search_utf8(c, TRUE,
- MPD_TABLE_ALBUM,
- album);
+ mpdclient_filelist_search(c, TRUE,
+ MPD_TABLE_ALBUM,
+ album);
if (browser.filelist == NULL)
browser.filelist = filelist_new(NULL);
screen_status_printf("Adding %s...", str);
g_free(str);
- addlist = mpdclient_filelist_search_utf8(c, TRUE, table, _filter);
+ addlist = mpdclient_filelist_search(c, TRUE, table, _filter);
if (addlist) {
mpdclient_filelist_add_all(c, addlist);
filelist_free(addlist);
diff --git a/src/screen_browser.c b/src/screen_browser.c
index a09e2554ccd5ef48e67d95badbd191c9c727d264..69e39ffaf57f2023944f794a561116e69b731378 100644 (file)
--- a/src/screen_browser.c
+++ b/src/screen_browser.c
} else if( entity->type==MPD_INFO_ENTITY_TYPE_DIRECTORY) {
/* enter sub */
mpd_Directory *dir = entity->info.directory;
- path = utf8_to_locale(dir->path);
+ path = g_strdup(dir->path);
} else
return -1;
#ifdef USE_OLD_ADD
add_directory(c, tmp);
#else
- if (mpdclient_cmd_add_path_utf8(c, dir->path) == 0) {
+ if (mpdclient_cmd_add_path(c, dir->path) == 0) {
char *tmp = utf8_to_locale(dir->path);
screen_status_printf(_("Adding \'%s\' to playlist\n"), tmp);
diff --git a/src/screen_file.c b/src/screen_file.c
index 75e4d163111e4fadec0d503f7577c3bd4aecff46..f4229797137d598498f675e0b0df5266e8a7d1fd 100644 (file)
--- a/src/screen_file.c
+++ b/src/screen_file.c
{
filelist_entry_t *entry;
char *defaultname = NULL;
+ int ret;
if (browser.lw->selected >= filelist_length(browser.filelist))
return -1;
}
}
- return playlist_save(c, NULL, defaultname);
+ defaultname = utf8_to_locale(defaultname);
+ ret = playlist_save(c, NULL, defaultname);
+ g_free(defaultname);
+
+ return ret;
}
static int
return 0;
}
- if( mpdclient_cmd_delete_playlist_utf8(c, plf->path) )
+ if( mpdclient_cmd_delete_playlist(c, plf->path) )
return -1;
screen_status_printf(_("Playlist deleted!"));
browse_title(char *str, size_t size)
{
const char *path = NULL, *prev = NULL, *slash = browser.filelist->path;
+ char *path_locale;
/* determine the last 2 parts of the path */
while ((slash = strchr(slash, '/')) != NULL) {
/* fall back to full path */
path = browser.filelist->path;
- g_snprintf(str, size, _("Browse: %s"), path);
+ path_locale = utf8_to_locale(path);
+ g_snprintf(str, size, _("Browse: %s"), path_locale);
+ g_free(path_locale);
return str;
}
if (!c->status->updatingDb) {
if (mpdclient_cmd_db_update_utf8(c, browser.filelist->path) == 0) {
- if (strcmp(browser.filelist->path, ""))
+ if (strcmp(browser.filelist->path, "")) {
+ char *path_locale =
+ utf8_to_locale(browser.filelist->path);
screen_status_printf(_("Database update of %s started!"),
- browser.filelist->path);
- else
+ path_locale);
+ g_free(path_locale);
+ } else
screen_status_printf(_("Database update started!"));
/* set updatingDb to make shure the browse callback gets called
diff --git a/src/screen_play.c b/src/screen_play.c
index d4fb7cee239f3076f6202f889379c4270fd98300..8855ffc7816e93912f932e253d3ee160a4be9e1c 100644 (file)
--- a/src/screen_play.c
+++ b/src/screen_play.c
#include "config.h"
#include "i18n.h"
+#include "charset.h"
#include "options.h"
#include "support.h"
#include "mpdclient.h"
int
playlist_save(mpdclient_t *c, char *name, char *defaultname)
{
- gchar *filename;
+ gchar *filename, *filename_utf8;
gint error;
#ifndef NCMPC_MINI
GCompletion *gcmp;
return -1;
/* send save command to mpd */
- if ((error = mpdclient_cmd_save_playlist(c, filename))) {
+
+ filename_utf8 = locale_to_utf8(filename);
+ error = mpdclient_cmd_save_playlist(c, filename_utf8);
+ g_free(filename_utf8);
+
+ if (error) {
gint code = GET_ACK_ERROR_CODE(error);
if (code == MPD_ACK_ERROR_EXIST) {
g_free(buf);
if (key == YES[0]) {
- if (mpdclient_cmd_delete_playlist(c, filename)) {
+ filename_utf8 = locale_to_utf8(filename);
+ error = mpdclient_cmd_delete_playlist(c, filename_utf8);
+ g_free(filename_utf8);
+
+ if (error) {
g_free(filename);
return -1;
}
#endif
/* add the path to the playlist */
- if (path && path[0])
- mpdclient_cmd_add_path(c, path);
+ if (path && path[0]) {
+ char *path_utf8 = locale_to_utf8(path);
+ mpdclient_cmd_add_path(c, path_utf8);
+ g_free(path_utf8);
+ }
g_free(path);
return 0;
diff --git a/src/screen_search.c b/src/screen_search.c
index 51a8a2966c064f29f873ef2d799f6d9f1ff4468f..7cb04e85fb6ea29634874dbae1de902f40151ffb 100644 (file)
--- a/src/screen_search.c
+++ b/src/screen_search.c
gchar *local_pattern)
{
mpdclient_filelist_t *list, *list2;
+ gchar *filter_utf8 = locale_to_utf8(local_pattern);
if (table == SEARCH_ARTIST_TITLE) {
list = mpdclient_filelist_search(c, FALSE, MPD_TABLE_ARTIST,
- local_pattern);
+ filter_utf8);
if (list == NULL)
list = filelist_new(NULL);
list2 = mpdclient_filelist_search(c, FALSE, MPD_TABLE_TITLE,
- local_pattern);
+ filter_utf8);
if (list2 != NULL) {
filelist_move(list, list2);
filelist_free(list2);
filelist_sort(list, compare_filelistentry_format);
} else {
- list = mpdclient_filelist_search(c, FALSE, table, local_pattern);
+ list = mpdclient_filelist_search(c, FALSE, table, filter_utf8);
if (list == NULL)
list = filelist_new(NULL);
}
+ g_free(filter_utf8);
return list;
}