-
Notifications
You must be signed in to change notification settings - Fork 741
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
709 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# | ||
# Copyright (C) 2008-2014 The LuCI Team <[email protected]> | ||
# | ||
# This is free software, licensed under the Apache License, Version 2.0 . | ||
# | ||
|
||
include $(TOPDIR)/rules.mk | ||
|
||
LUCI_TITLE:=USB Printer Share via TCP/IP | ||
LUCI_DEPENDS:=+p910nd +kmod-usb-printer | ||
PKG_VERSION:=1.0 | ||
PKG_RELEASE:=2 | ||
|
||
include $(TOPDIR)/feeds/luci/luci.mk | ||
|
||
# call BuildPackage - OpenWrt buildroot signature | ||
#applications/luci-app-usb-printer/ | ||
#applications/luci-app-usb-printer/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
[ -n "${IPKG_INSTROOT}" ] || { | ||
( . /etc/uci-defaults/luci-usb-printer ) && rm -f /etc/uci-defaults/luci-usb-printer | ||
exit 0 | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--[[ | ||
LuCI - Lua Configuration Interface | ||
Copyright 2008 Steven Barth <[email protected]> | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
$Id$ | ||
]]-- | ||
|
||
require("luci.sys") | ||
|
||
module("luci.controller.usb_printer", package.seeall) | ||
|
||
function index() | ||
if not nixio.fs.access("/etc/config/usb_printer") then | ||
return | ||
end | ||
|
||
entry({"admin", "nas"}, firstchild(), "NAS", 44).dependent = false | ||
|
||
local page | ||
|
||
page = entry({"admin", "nas", "usb_printer"}, cbi("usb_printer"), _("USB Printer Server"), 50) | ||
page.acl_depends = { "luci-app-usb-printer" } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
--[[ | ||
LuCI - Lua Configuration Interface | ||
Copyright 2008 Steven Barth <[email protected]> | ||
Copyright 2005-2013 hackpascal <[email protected]> | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
$Id$ | ||
]]-- | ||
|
||
require "luci.util" | ||
local uci = luci.model.uci.cursor_state() | ||
local net = require "luci.model.network" | ||
|
||
m = Map("usb_printer", translate("USB Printer Server"), | ||
translate("Shares multiple USB printers via TCP/IP.<br />When modified bingings, re-plug usb connectors to take effect.<br />This module requires kmod-usb-printer.")) | ||
|
||
function hex_align(hex, num) | ||
local len = num - string.len(hex) | ||
|
||
return string.rep("0", len) .. hex | ||
end | ||
|
||
function detect_usb_printers() | ||
local data = {} | ||
|
||
local lps = luci.util.execi("/usr/bin/detectlp") | ||
|
||
for value in lps do | ||
local row = {} | ||
|
||
--[[ | ||
detectlp 的输出格式: | ||
设备名,VID/PID/?,描述,型号 | ||
]]-- | ||
|
||
local pos = string.find(value, ",") | ||
|
||
local devname = string.sub(value, 1, pos - 1) | ||
|
||
local value = string.sub(value, pos + 1, string.len(value)) | ||
|
||
pos = string.find(value, ",") | ||
local product = string.sub(value, 1, pos - 1) | ||
|
||
value = string.sub(value, pos + 1, string.len(value)) | ||
|
||
pos = string.find(value, ",") | ||
local model = string.sub(value, 1, pos - 1) | ||
|
||
local name = string.sub(value, pos + 1, string.len(value)) | ||
|
||
pos = string.find(product, "/"); | ||
|
||
local vid = string.sub(product, 1, pos - 1) | ||
|
||
local pid = string.sub(product, pos + 1, string.len(product)) | ||
|
||
pos = string.find(pid, "/") | ||
pid = string.sub(pid, 1, pos - 1) | ||
|
||
row["description"] = name | ||
row["model"] = model | ||
row["id"] = hex_align(vid, 4) .. ":" .. hex_align(pid, 4) | ||
row["name"] = devname | ||
row["product"] = product | ||
|
||
table.insert(data, row) | ||
end | ||
|
||
return data | ||
end | ||
|
||
local printers = detect_usb_printers() | ||
|
||
v = m:section(Table, printers, translate("Detected printers")) | ||
|
||
v:option(DummyValue, "description", translate("Description")) | ||
v:option(DummyValue, "model", translate("Printer Model")) | ||
v:option(DummyValue, "id", translate("VID/PID")) | ||
v:option(DummyValue, "name", translate("Device Name")) | ||
|
||
net = net.init(m.uci) | ||
|
||
s = m:section(TypedSection, "printer", translate("Bindings")) | ||
s.addremove = true | ||
s.anonymous = true | ||
|
||
s:option(Flag, "enabled", translate("enable")) | ||
|
||
d = s:option(Value, "device", translate("Device")) | ||
d.rmempty = true | ||
|
||
for key, item in ipairs(printers) do | ||
d:value(item["product"], item["description"] .. " [" .. item["id"] .. "]") | ||
end | ||
|
||
b = s:option(Value, "bind", translate("Interface"), translate("Specifies the interface to listen on.")) | ||
b.template = "cbi/network_netlist" | ||
b.nocreate = true | ||
b.unspecified = true | ||
|
||
function b.cfgvalue(...) | ||
local v = Value.cfgvalue(...) | ||
if v then | ||
return (net:get_status_by_address(v)) | ||
end | ||
end | ||
|
||
function b.write(self, section, value) | ||
local n = net:get_network(value) | ||
if n and n:ipaddr() then | ||
Value.write(self, section, n:ipaddr()) | ||
end | ||
end | ||
|
||
p = s:option(ListValue, "port", translate("Port"), translate("TCP listener port.")) | ||
p.rmempty = true | ||
for i = 0, 9 do | ||
p:value(i, 9100 + i) | ||
end | ||
|
||
s:option(Flag, "bidirectional", translate("Bidirectional mode")) | ||
|
||
return m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
zh_Hans |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
msgid "" | ||
msgstr "" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"Last-Translator: Automatically generated\n" | ||
"Language-Team: none\n" | ||
"Language: zh-Hans\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
|
||
#: luasrc/model/cbi/usb_printer.lua:128 | ||
msgid "Bidirectional mode" | ||
msgstr "双向模式" | ||
|
||
#: luasrc/model/cbi/usb_printer.lua:90 | ||
msgid "Bindings" | ||
msgstr "绑定" | ||
|
||
#: luasrc/model/cbi/usb_printer.lua:83 | ||
msgid "Description" | ||
msgstr "" | ||
|
||
#: luasrc/model/cbi/usb_printer.lua:81 | ||
msgid "Detected printers" | ||
msgstr "检测到的打印机" | ||
|
||
#: luasrc/model/cbi/usb_printer.lua:96 | ||
msgid "Device" | ||
msgstr "设备" | ||
|
||
#: luasrc/model/cbi/usb_printer.lua:86 | ||
msgid "Device Name" | ||
msgstr "设备名" | ||
|
||
#: luasrc/model/cbi/usb_printer.lua:103 | ||
msgid "Interface" | ||
msgstr "" | ||
|
||
#: luasrc/model/cbi/usb_printer.lua:122 | ||
msgid "Port" | ||
msgstr "端口" | ||
|
||
#: luasrc/model/cbi/usb_printer.lua:84 | ||
msgid "Printer Model" | ||
msgstr "打印机型号" | ||
|
||
#: luasrc/model/cbi/usb_printer.lua:21 | ||
msgid "" | ||
"Shares multiple USB printers via TCP/IP.<br />When modified bingings, re-" | ||
"plug usb connectors to take effect.<br />This module requires kmod-usb-" | ||
"printer." | ||
msgstr "" | ||
"通过 TCP/IP 共享 USB 打印机。<br />修改设置后,请重新连接打印机以使设置生效。" | ||
"<br />此模块需要 kmod-usb-printer 支持。" | ||
|
||
#: luasrc/model/cbi/usb_printer.lua:103 | ||
msgid "Specifies the interface to listen on." | ||
msgstr "指定要监听的接口。" | ||
|
||
#: luasrc/model/cbi/usb_printer.lua:122 | ||
msgid "TCP listener port." | ||
msgstr "TCP 监听端口。" | ||
|
||
#: luasrc/controller/usb_printer.lua:28 luasrc/model/cbi/usb_printer.lua:20 | ||
msgid "USB Printer Server" | ||
msgstr "USB 打印服务器" | ||
|
||
#: luasrc/model/cbi/usb_printer.lua:85 | ||
msgid "VID/PID" | ||
msgstr "" | ||
|
||
#: luasrc/model/cbi/usb_printer.lua:94 | ||
msgid "enable" | ||
msgstr "启用" | ||
|
||
#~ msgid "Settings" | ||
#~ msgstr "设置" | ||
|
||
#~ msgid "NAS" | ||
#~ msgstr "网络存储" | ||
|
||
#~ msgid "Architecture" | ||
#~ msgstr "架构" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2014-05-18 01:34+0800\n" | ||
"PO-Revision-Date: 2014-05-18 01:34+0800\n" | ||
"Last-Translator: hackpascal <[email protected]>\n" | ||
"Language-Team: \n" | ||
"Language: zh_Hans\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: nplurals=1; plural=0;\n" | ||
"X-Generator: Pootle 2.0.6\n" | ||
|
||
msgid "Bidirectional mode" | ||
msgstr "双向模式" | ||
|
||
msgid "Bindings" | ||
msgstr "绑定" | ||
|
||
msgid "Device" | ||
msgstr "设备" | ||
|
||
msgid "Device Name" | ||
msgstr "设备名" | ||
|
||
msgid "Detected printers" | ||
msgstr "检测到的打印机" | ||
|
||
msgid "" | ||
"Shares multiple USB printers via TCP/IP.<br />" | ||
"When modified bingings, re-plug usb connectors to take effect.<br />" | ||
"This module requires kmod-usb-printer." | ||
msgstr "" | ||
"通过 TCP/IP 共享 USB 打印机。<br />修改设置后,请重新连接打印机以使设置生效。<br />" | ||
"此模块需要 kmod-usb-printer 支持。" | ||
|
||
msgid "Port" | ||
msgstr "端口" | ||
|
||
msgid "Printer Model" | ||
msgstr "打印机型号" | ||
|
||
msgid "Settings" | ||
msgstr "设置" | ||
|
||
msgid "TCP listener port." | ||
msgstr "TCP 监听端口。" | ||
|
||
msgid "enable" | ||
msgstr "启用" | ||
|
||
msgid "USB Printer Server" | ||
msgstr "USB 打印服务器" | ||
|
||
msgid "Specifies the interface to listen on." | ||
msgstr "指定要监听的接口。" | ||
|
||
msgid "NAS" | ||
msgstr "网络存储" | ||
|
||
msgid "Architecture" | ||
msgstr "架构" | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
# Copyright (C) 2005-2014 NowRush Studio | ||
# Author: hackpascal <[email protected]> | ||
|
||
if [ x"$INTERFACE" = x"7/1/1" ] || [ x"$INTERFACE" = x"7/1/2" ]; then | ||
/usr/bin/usb_printer_hotplug "$PRODUCT" "$ACTION" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/sh /etc/rc.common | ||
# Copyright (C) 2005-2013 NowRush Studio | ||
# Author: hackpascal <[email protected]> | ||
|
||
START=70 | ||
|
||
stop() { | ||
killall p910nd 2>/dev/null | ||
} | ||
|
||
start() { | ||
for lps in `/usr/bin/detectlp`; do | ||
product=`echo $lps | cut -d , -f 2` | ||
|
||
/usr/bin/usb_printer_hotplug "$product" add | ||
done | ||
} | ||
|
||
restart() { | ||
stop | ||
start | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
|
||
[ -f /etc/init.d/p910nd ] && /etc/init.d/p910nd disable | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/sh | ||
|
||
lp_path=/sys/class/usbmisc | ||
|
||
if ! [ -d "$lp_path" ]; then | ||
exit | ||
fi | ||
|
||
cd $lp_path | ||
|
||
for lps in `ls`; do | ||
desc_file=$lp_path/$lps/device/ieee1284_id | ||
uevent_file=$lp_path/$lps/device/uevent | ||
|
||
name=`cat $desc_file | sed 's/.*DES:\(.*\);.*/\1/' | cut -d ';' -f 1` | ||
model=`cat $desc_file | sed 's/.*MDL:\(.*\);.*/\1/' | cut -d ';' -f 1` | ||
product=`cat $uevent_file | grep PRODUCT= | sed 's/PRODUCT=\(.*\)/\1/'` | ||
|
||
echo $lps,$product,$model,$name; | ||
done |
Oops, something went wrong.