LINUX.ORG.RU

[патчи] Немного допилил MiniDLNA

 


1

3

Из-за небольших проблем взаимодействия Coherence с WD TV Live, я решил всё-таки попробовать MiniDLNA. C WD TV Live он сдружился сразу, дисконнекты пропали. Но меня не устраивало то, что minidlna пытается раскидать в своей БД мультимедиа-файлы по разным категориям, вместо того, чтобы оставить их как есть в соответствии с расположением в ФС (как они показываются в категории «Browse Files»). В процессе решения этой проблемы (и некоторых других) получились патчи:

  • 0001-add-russian-translation.patch - Добавляет русский перевод.
  • 0002-compile-and-install-translations.patch - Добавляет в мейкфайл правила для сборки и установки переводов. Без этого патча, переводы компилировать и ставить по нужным путям приходится вручную.
  • 0003-add-only-browsedir-option.patch - Добавляет опцию показа дерева файлов клиентам в том же виде, в котором они лежат в файловой системе. Скриншот (totem с upnp-плагином).
  • 0004-do-not-add-inaccessible-directories.patch - Не добавлять в БД недоступные директории (типа «lost+found»).

Все четыре патча я уже залил на сурсфорж. На всякий случай выложу ещё и тут, вдруг ещё кому-то пригодятся...

Deleted

0001-add-russian-translation.patch

diff --new-file -ru minidlna-1.0.19.p0000/po/ru.po minidlna-1.0.19.p0001/po/ru.po
--- minidlna-1.0.19.p0000/po/ru.po	1970-01-01 05:00:00.000000000 +0500
+++ minidlna-1.0.19.p0001/po/ru.po	2011-03-26 15:23:35.472442042 +0500
@@ -0,0 +1,130 @@
+# MiniDLNA translation template file
+# Justin Maggard <jmaggard@users.sourceforge.net>, 2010.
+#
+# MiniDLNA media server
+# Copyright (C) 2010  NETGEAR
+#
+# This file is part of MiniDLNA.
+#
+# MiniDLNA is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# MiniDLNA is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with MiniDLNA. If not, see <http://www.gnu.org/licenses/>.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: minidlna 1.0.18\n"
+"Report-Msgid-Bugs-To: jmaggard@users.sourceforge.net\n"
+"POT-Creation-Date: 2010-07-19 10:50-0700\n"
+"PO-Revision-Date: 2011-03-25 22:40+0500\n"
+"Last-Translator: Ivan Mironov <ivan.mironov@infra-it.ru>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Poedit-Language: Russian\n"
+"X-Poedit-Country: RUSSIAN FEDERATION\n"
+
+#: scanner.c:163
+msgid "Unknown Date"
+msgstr "Неизвестная Дата"
+
+#: scanner.c:191
+msgid "Unknown Camera"
+msgstr "Неизвестная Камера"
+
+#: scanner.c:282
+msgid "- All Albums -"
+msgstr "- Все Альбомы -"
+
+#: scanner.c:290
+#: scanner.c:297
+#: scanner.c:300
+msgid "Unknown Album"
+msgstr "Неизвестный Альбом"
+
+#: scanner.c:323
+msgid "- All Artists -"
+msgstr "- Все Исполнители -"
+
+#: scanner.c:331
+#: scanner.c:337
+#: scanner.c:340
+msgid "Unknown Artist"
+msgstr "Неизвестный Исполнитель"
+
+#: scanner.c:543
+msgid "Music"
+msgstr "Музыка"
+
+#: scanner.c:544
+msgid "All Music"
+msgstr "Вся Музыка"
+
+#: scanner.c:545
+msgid "Genre"
+msgstr "Жанр"
+
+#: scanner.c:546
+msgid "Artist"
+msgstr "Исполнитель"
+
+#: scanner.c:547
+msgid "Album"
+msgstr "Альбом"
+
+#: scanner.c:548
+#: scanner.c:552
+#: scanner.c:557
+msgid "Folders"
+msgstr "Папки"
+
+#: scanner.c:549
+msgid "Playlists"
+msgstr "Списки Воспроизведения"
+
+#: scanner.c:550
+msgid "Video"
+msgstr "Видео"
+
+#: scanner.c:551
+msgid "All Video"
+msgstr "Всё Видео"
+
+#: scanner.c:553
+msgid "Pictures"
+msgstr "Фотографии"
+
+#: scanner.c:554
+msgid "All Pictures"
+msgstr "Все Фотографии"
+
+#: scanner.c:555
+msgid "Date Taken"
+msgstr "Дата Съёмки"
+
+#: scanner.c:556
+msgid "Camera"
+msgstr "Камера"
+
+#: scanner.c:558
+msgid "Browse Folders"
+msgstr "Просмотреть Папки"
+
+#: scanner.c:721
+#, c-format
+msgid "Scanning %s\n"
+msgstr "Сканирование %s\n"
+
+#: scanner.c:789
+#, c-format
+msgid "Scanning %s finished (%llu files)!\n"
+msgstr "Сканирование %s завершено (%llu файлов)!\n"
+
Deleted
()

0002-compile-and-install-translations.patch

diff --new-file -ru minidlna-1.0.19.p0001/INSTALL minidlna-1.0.19.p0002/INSTALL
--- minidlna-1.0.19.p0001/INSTALL	2009-03-19 13:06:25.000000000 +0500
+++ minidlna-1.0.19.p0002/INSTALL	2011-03-26 15:27:41.058950044 +0500
@@ -13,6 +13,7 @@
 - sqlite3
 - libavformat (the ffmpeg libraries)
 - libuuid
+- gettext (for compiling translation files)
 
 To Build and install :
 
diff --new-file -ru minidlna-1.0.19.p0001/Makefile minidlna-1.0.19.p0002/Makefile
--- minidlna-1.0.19.p0001/Makefile	2011-03-07 03:25:37.000000000 +0500
+++ minidlna-1.0.19.p0002/Makefile	2011-03-26 15:31:08.741668021 +0500
@@ -21,10 +21,12 @@
 CC = gcc
 RM = rm -f
 INSTALL = install
+MSGFMT = msgfmt
 
 INSTALLPREFIX ?= $(DESTDIR)/usr
 SBININSTALLDIR = $(INSTALLPREFIX)/sbin
 ETCINSTALLDIR = $(DESTDIR)/etc
+LOCALEINSTALLDIR = $(INSTALLPREFIX)/share/locale
 
 BASEOBJS = minidlna.o upnphttp.o upnpdescgen.o upnpsoap.o \
            upnpreplyparse.o minixml.o \
@@ -44,24 +46,33 @@
 
 EXECUTABLES = minidlna testupnpdescgen
 
+TRANSLATIONS = po/da.mo po/de.mo po/es.mo po/fr.mo po/it.mo po/ja.mo po/nb.mo po/nl.mo po/ru.mo po/sv.mo
+
 .PHONY:	all clean distclean install depend
 
-all:	$(EXECUTABLES)
+all:	$(EXECUTABLES) $(TRANSLATIONS)
 
 clean:
 	$(RM) $(ALLOBJS)
 	$(RM) $(EXECUTABLES)
+	$(RM) $(TRANSLATIONS)
 	$(RM) testupnpdescgen.o
 
 distclean: clean
 	$(RM) config.h
 
-install:	minidlna
+install:	minidlna $(TRANSLATIONS)
 	$(INSTALL) -d $(SBININSTALLDIR)
 	$(INSTALL) minidlna $(SBININSTALLDIR)
 	$(INSTALL) -d $(ETCINSTALLDIR)
 	$(INSTALL) --mode=0644 minidlna.conf $(ETCINSTALLDIR)
 
+	@linguas=$$( echo $(TRANSLATIONS) | awk '{ gsub(/po\//,""); gsub(/\.mo/,"") }; 1' ); \
+	for i in $$linguas; do \
+		$(INSTALL) -d $(LOCALEINSTALLDIR)/$$i/LC_MESSAGES; \
+		$(INSTALL) -v --mode=0644 po/$$i.mo $(LOCALEINSTALLDIR)/$$i/LC_MESSAGES/minidlna.mo; \
+	done
+
 minidlna:	$(BASEOBJS) $(LNXOBJS) $(LIBS)
 	@echo Linking $@
 	@$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(BASEOBJS) $(LNXOBJS) $(LIBS)
@@ -131,3 +142,10 @@
 		echo "The following command failed:" 1>&2;\
 		echo "$(CC) $(CFLAGS) -o $@ -c $<";\
 		$(CC) $(CFLAGS) -o $@ -c $< &>/dev/null
+
+.SUFFIXES: .po .mo
+
+.po.mo:
+	@echo Compiling $*.po
+	@$(MSGFMT) -o $*.mo $*.po
+
Deleted
()

0003-add-only-browsedir-option.patch

diff --new-file -ru minidlna-1.0.19.p0002/minidlna.c minidlna-1.0.19.p0003/minidlna.c
--- minidlna-1.0.19.p0002/minidlna.c	2011-03-15 07:30:51.000000000 +0500
+++ minidlna-1.0.19.p0003/minidlna.c	2011-03-26 15:33:20.601858263 +0500
@@ -540,6 +540,10 @@
 				if( (strcmp(ary_options[i].value, "yes") == 0) || atoi(ary_options[i].value) )
 					SETFLAG(DLNA_STRICT_MASK);
 				break;
+			case ENABLE_ONLY_BROWSEDIR:
+				if( (strcmp(ary_options[i].value, "yes") == 0) || atoi(ary_options[i].value) )
+					SETFLAG(ONLY_BROWSEDIR_MASK);
+				break;
 			default:
 				fprintf(stderr, "Unknown option in file %s\n",
 				        optionsfile);
diff --new-file -ru minidlna-1.0.19.p0002/minidlna.conf minidlna-1.0.19.p0003/minidlna.conf
--- minidlna-1.0.19.p0002/minidlna.conf	2011-03-15 07:30:51.000000000 +0500
+++ minidlna-1.0.19.p0003/minidlna.conf	2011-03-26 15:33:20.601858263 +0500
@@ -38,6 +38,9 @@
 #   which may hurt JPEG serving performance on (at least) Sony DLNA products.
 strict_dlna=no
 
+# set this if you want to see only contents of "Browse Folders" on clients
+only_browsedir=no
+
 # default presentation url is http address on port 80
 #presentation_url=http://www.mylan/index.php
 
diff --new-file -ru minidlna-1.0.19.p0002/options.c minidlna-1.0.19.p0003/options.c
--- minidlna-1.0.19.p0002/options.c	2011-03-07 03:25:38.000000000 +0500
+++ minidlna-1.0.19.p0003/options.c	2011-03-26 15:33:20.608858220 +0500
@@ -59,7 +59,8 @@
 	{ UPNPDBDIR, "db_dir" },
 	{ UPNPLOGDIR, "log_dir" },
 	{ ENABLE_TIVO, "enable_tivo" },
-	{ ENABLE_DLNA_STRICT, "strict_dlna" }
+	{ ENABLE_DLNA_STRICT, "strict_dlna" },
+	{ ENABLE_ONLY_BROWSEDIR, "only_browsedir" }
 };
 
 int
diff --new-file -ru minidlna-1.0.19.p0002/options.h minidlna-1.0.19.p0003/options.h
--- minidlna-1.0.19.p0002/options.h	2011-03-07 03:25:38.000000000 +0500
+++ minidlna-1.0.19.p0003/options.h	2011-03-26 15:33:20.609858214 +0500
@@ -52,7 +52,8 @@
 	UPNPDBDIR,			/* base directory to store the database and album art cache */
 	UPNPLOGDIR,			/* base directory to store the log file */
 	ENABLE_TIVO,			/* enable support for streaming images and music to TiVo */
-	ENABLE_DLNA_STRICT		/* strictly adhere to DLNA specs */
+	ENABLE_DLNA_STRICT,		/* strictly adhere to DLNA specs */
+	ENABLE_ONLY_BROWSEDIR		/* show only contents of "Browse Folders" container */
 };
 
 /* readoptionsfile()
diff --new-file -ru minidlna-1.0.19.p0002/upnpglobalvars.h minidlna-1.0.19.p0003/upnpglobalvars.h
--- minidlna-1.0.19.p0002/upnpglobalvars.h	2011-03-07 03:25:38.000000000 +0500
+++ minidlna-1.0.19.p0003/upnpglobalvars.h	2011-03-26 15:33:20.609858214 +0500
@@ -158,6 +158,7 @@
 #define INOTIFY_MASK          0x0001
 #define TIVO_MASK             0x0002
 #define DLNA_STRICT_MASK      0x0004
+#define ONLY_BROWSEDIR_MASK   0x0008
 
 #define SETFLAG(mask)	runtime_flags |= mask
 #define GETFLAG(mask)	runtime_flags & mask
diff --new-file -ru minidlna-1.0.19.p0002/upnpsoap.c minidlna-1.0.19.p0003/upnpsoap.c
--- minidlna-1.0.19.p0002/upnpsoap.c	2011-03-07 03:25:57.000000000 +0500
+++ minidlna-1.0.19.p0003/upnpsoap.c	2011-03-26 15:33:20.610858208 +0500
@@ -1003,6 +1003,9 @@
 	}
 	memset(&args, 0, sizeof(args));
 
+	if( GETFLAG(ONLY_BROWSEDIR_MASK) && ( strcmp(ObjectId, "0") == 0 ) )
+		ObjectId = BROWSEDIR_ID;
+
 	args.alloced = 1048576;
 	args.resp = resp;
 	args.size = sprintf(resp, "%s", resp0);
Deleted
()

0004-do-not-add-inaccessible-directories.patch

diff --new-file -ru minidlna-1.0.19.p0003/inotify.c minidlna-1.0.19.p0004/inotify.c
--- minidlna-1.0.19.p0003/inotify.c	2011-03-07 03:25:37.000000000 +0500
+++ minidlna-1.0.19.p0004/inotify.c	2011-03-26 16:15:58.177064211 +0500
@@ -443,6 +443,12 @@
 	struct media_dir_s * media_path;
 	struct stat st;
 
+	if( access(path, R_OK | X_OK) != 0 )
+	{
+		DPRINTF(E_ERROR, L_INOTIFY, "could not access %s [%s]\n", path, strerror(errno));
+		return -1;
+	}
+
  	parent_buf = dirname(strdup(path));
 	sql = sqlite3_mprintf("SELECT OBJECT_ID from OBJECTS o left join DETAILS d on (d.ID = o.DETAIL_ID)"
 	                      " where d.PATH = '%q' and REF_ID is NULL", parent_buf);
diff --new-file -ru minidlna-1.0.19.p0003/scanner.c minidlna-1.0.19.p0004/scanner.c
--- minidlna-1.0.19.p0003/scanner.c	2011-03-15 07:50:13.000000000 +0500
+++ minidlna-1.0.19.p0004/scanner.c	2011-03-26 15:38:25.002000918 +0500
@@ -769,7 +769,7 @@
 		{
 			type = resolve_unknown_type(full_path, dir_type);
 		}
-		if( type == TYPE_DIR )
+		if( (type == TYPE_DIR) && (access(full_path, R_OK | X_OK) == 0) )
 		{
 			insert_directory(name?name:namelist[i]->d_name, full_path, BROWSEDIR_ID, (parent ? parent:""), i+startID);
 			sprintf(parent_id, "%s$%X", (parent ? parent:""), i+startID);
Deleted
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.