Merge branch 'master' into master
This commit is contained in:
commit
b4f5155a3f
8 changed files with 153 additions and 87 deletions
|
@ -7,7 +7,8 @@ Dialog {
|
|||
|
||||
property string value
|
||||
property string ssid
|
||||
canAccept: printer_label.text != ""
|
||||
property var printerName: false
|
||||
canAccept: printerName != false
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
|
@ -43,12 +44,12 @@ Dialog {
|
|||
|
||||
Label {
|
||||
id: found_label
|
||||
text: printer_label.text != "" ? qsTr("Found:") : qsTr("No printer found")
|
||||
text: printerName != false ? qsTr("Found:") : qsTr("No printer found")
|
||||
}
|
||||
Label {
|
||||
id: printer_label
|
||||
color: Theme.secondaryColor
|
||||
text: ""
|
||||
text: printerName ? printerName : ""
|
||||
}
|
||||
}
|
||||
IppPrinter {
|
||||
|
@ -56,11 +57,11 @@ Dialog {
|
|||
url: valueField.text
|
||||
onAttrsChanged: {
|
||||
if(printer.attrs["printer-name"]) {
|
||||
printer_label.text = printer.attrs["printer-name"].value
|
||||
printerName = printer.attrs["printer-name"].value == "" ? qsTr("Unknown") : printer.attrs["printer-name"].value
|
||||
}
|
||||
else
|
||||
{
|
||||
printer_label.text = ""
|
||||
printerName = false
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,6 +31,9 @@ Page {
|
|||
}
|
||||
|
||||
}
|
||||
onSsidChanged: {
|
||||
discovery.reset();
|
||||
}
|
||||
}
|
||||
|
||||
signal refreshed()
|
||||
|
@ -84,7 +87,7 @@ Page {
|
|||
|
||||
visible: false
|
||||
|
||||
property string name: printer.attrs["printer-name"] ? printer.attrs["printer-name"].value : qsTr("Unknown")
|
||||
property string name: printer.attrs["printer-name"].value != "" ? printer.attrs["printer-name"].value : qsTr("Unknown")
|
||||
property bool canPrint: Utils.can_print(printer, selectedFile)
|
||||
|
||||
Connections {
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#define AAAA 28
|
||||
#define SRV 33
|
||||
|
||||
#define ALL 255 //for querying
|
||||
|
||||
void put_addr(Bytestream& bts, QStringList addr)
|
||||
{
|
||||
for(int i = 0; i < addr.length(); i++)
|
||||
|
@ -55,8 +57,24 @@ IppDiscovery::~IppDiscovery() {
|
|||
delete socket;
|
||||
}
|
||||
|
||||
|
||||
void IppDiscovery::discover() {
|
||||
sendQuery(PTR, {"_ipp","_tcp","local"});
|
||||
}
|
||||
|
||||
void IppDiscovery::reset() {
|
||||
_ipp = QStringList();
|
||||
_rps = QMap<QString,QString>();
|
||||
_ports = QMap<QString,quint16>();
|
||||
_targets = QMap<QString,QString>();
|
||||
|
||||
_AAs = QMultiMap<QString,QString>();
|
||||
_AAAAs = QMultiMap<QString,QString>();
|
||||
|
||||
discover();
|
||||
}
|
||||
|
||||
void IppDiscovery::sendQuery(quint16 qtype, QStringList addr) {
|
||||
qDebug() << "discovering" << qtype << addr;
|
||||
|
||||
Bytestream query;
|
||||
quint16 transactionid = 0;
|
||||
|
@ -64,20 +82,42 @@ void IppDiscovery::discover() {
|
|||
quint16 questions = 1;
|
||||
|
||||
query << transactionid << flags << questions << (quint16)0 << (quint16)0 << (quint16)0;
|
||||
put_addr(query, {"_ipp","_tcp","local"});
|
||||
query << (quint16)0x000C << (quint16)0x0001;
|
||||
put_addr(query, addr);
|
||||
query << qtype << (quint16)0x0001;
|
||||
|
||||
QByteArray bytes((char*)(query.raw()), query.size());
|
||||
socket->writeDatagram(bytes, QHostAddress("224.0.0.251"), 5353);
|
||||
|
||||
qDebug() << "discovering";
|
||||
|
||||
}
|
||||
|
||||
|
||||
void IppDiscovery::update()
|
||||
{
|
||||
qDebug() << _favourites << _found;
|
||||
this->setStringList(_favourites+_found);
|
||||
QStringList found;
|
||||
|
||||
for(QStringList::Iterator it = _ipp.begin(); it != _ipp.end(); it++)
|
||||
{
|
||||
quint16 port = _ports[*it];
|
||||
QString target = _targets[*it];
|
||||
QString rp = _rps[*it];
|
||||
|
||||
for(QMultiMap<QString,QString>::Iterator ait = _AAs.begin(); ait != _AAs.end(); ait++)
|
||||
{
|
||||
if(ait.key() == target)
|
||||
{
|
||||
QString ip = ait.value();
|
||||
QString addr = ip+":"+QString::number(port)+"/"+rp;
|
||||
if(!found.contains(addr))
|
||||
{
|
||||
found.append(addr);
|
||||
found.sort(Qt::CaseInsensitive);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() << _favourites << found;
|
||||
this->setStringList(_favourites+found);
|
||||
}
|
||||
|
||||
void IppDiscovery::readPendingDatagrams()
|
||||
|
@ -89,12 +129,7 @@ void IppDiscovery::readPendingDatagrams()
|
|||
QHostAddress sender;
|
||||
quint16 senderPort;
|
||||
|
||||
QMap<QString,QString> ptrs;
|
||||
QMap<QString,QString> rps;
|
||||
QMap<QString,quint16> ports;
|
||||
QMap<QString,QString> targets;
|
||||
QMultiMap<QString,QString> AAs;
|
||||
QMultiMap<QString,QString> AAAAs;
|
||||
QStringList ipp_ptrs;
|
||||
|
||||
socket->readDatagram((char*)(resp.raw()), size, &sender, &senderPort);
|
||||
sender = QHostAddress(sender.toIPv4Address());
|
||||
|
@ -121,7 +156,10 @@ void IppDiscovery::readPendingDatagrams()
|
|||
if (atype == PTR)
|
||||
{
|
||||
QString tmpname = get_addr(resp).join(".");
|
||||
ptrs[aaddr] = tmpname;
|
||||
if(aaddr.endsWith("_ipp._tcp.local"))
|
||||
{
|
||||
ipp_ptrs.append(tmpname);
|
||||
}
|
||||
}
|
||||
else if(atype == TXT)
|
||||
{
|
||||
|
@ -133,7 +171,7 @@ void IppDiscovery::readPendingDatagrams()
|
|||
{
|
||||
std::string tmprp;
|
||||
tmp/tmp.remaining() >> tmprp;
|
||||
rps[aaddr] = tmprp.c_str();
|
||||
_rps[aaddr] = tmprp.c_str();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -142,15 +180,15 @@ void IppDiscovery::readPendingDatagrams()
|
|||
quint16 prio, w, port;
|
||||
resp >> prio >> w >> port;
|
||||
QString target = get_addr(resp).join(".");
|
||||
ports[aaddr] = port;
|
||||
targets[aaddr] = target;
|
||||
_ports[aaddr] = port;
|
||||
_targets[aaddr] = target;
|
||||
}
|
||||
else if(atype == A)
|
||||
{
|
||||
quint32 addr;
|
||||
resp >> addr;
|
||||
QHostAddress haddr(addr);
|
||||
AAs.insert(aaddr, haddr.toString());
|
||||
_AAs.insert(aaddr, haddr.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -160,33 +198,26 @@ void IppDiscovery::readPendingDatagrams()
|
|||
|
||||
}
|
||||
|
||||
qDebug() << "ptrs" << ptrs;
|
||||
qDebug() << "rps" << rps;
|
||||
qDebug() << "ports" << ports;
|
||||
qDebug() << "targets" << targets;
|
||||
qDebug() << "AAs" << AAs;
|
||||
qDebug() << "AAAAs" << AAAAs;
|
||||
qDebug() << "new ipp ptrs" << ipp_ptrs;
|
||||
qDebug() << "ipp ptrs" << _ipp;
|
||||
qDebug() << "rps" << _rps;
|
||||
qDebug() << "ports" << _ports;
|
||||
qDebug() << "targets" << _targets;
|
||||
qDebug() << "AAs" << _AAs;
|
||||
qDebug() << "AAAAs" << _AAAAs;
|
||||
|
||||
for(QMap<QString,QString>::Iterator it = ptrs.begin(); it != ptrs.end(); it++)
|
||||
for(QStringList::Iterator it = ipp_ptrs.begin(); it != ipp_ptrs.end(); it++)
|
||||
{
|
||||
quint16 port = ports[it.value()];
|
||||
QString target = targets[it.value()];
|
||||
QString rp = rps[it.value()];
|
||||
|
||||
for(QMultiMap<QString,QString>::Iterator ait = AAs.begin(); ait != AAs.end(); ait++)
|
||||
if(!_ipp.contains(*it))
|
||||
{
|
||||
if(ait.key() == target)
|
||||
{
|
||||
QString ip = ait.value();
|
||||
QString addr = ip+":"+QString::number(port)+"/"+rp;
|
||||
if(!_found.contains(addr))
|
||||
{
|
||||
_found.append(addr);
|
||||
_found.sort(Qt::CaseInsensitive);
|
||||
}
|
||||
}
|
||||
_ipp.append(*it);
|
||||
}
|
||||
if(!_ports.contains(*it) || !_targets.contains(*it) || !_rps.contains(*it))
|
||||
{ // if the PTR doesn't already resolve, ask for everything about it
|
||||
sendQuery(ALL, it->split('.'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
this->update();
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ public:
|
|||
~IppDiscovery();
|
||||
Q_PROPERTY(QStringList favourites MEMBER _favourites NOTIFY favouritesChanged)
|
||||
Q_INVOKABLE void discover();
|
||||
Q_INVOKABLE void reset();
|
||||
|
||||
signals:
|
||||
void favouritesChanged();
|
||||
|
@ -19,10 +20,20 @@ signals:
|
|||
public slots:
|
||||
void readPendingDatagrams();
|
||||
void update();
|
||||
|
||||
protected:
|
||||
private:
|
||||
void sendQuery(quint16 qtype, QStringList addr);
|
||||
|
||||
QStringList _ipp;
|
||||
QMap<QString,QString> _rps;
|
||||
QMap<QString,quint16> _ports;
|
||||
QMap<QString,QString> _targets;
|
||||
|
||||
QMultiMap<QString,QString> _AAs;
|
||||
QMultiMap<QString,QString> _AAAAs;
|
||||
|
||||
QStringList _favourites;
|
||||
QStringList _found;
|
||||
QUdpSocket* socket;
|
||||
};
|
||||
|
||||
|
|
|
@ -78,6 +78,10 @@
|
|||
<source>No printer found</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unknown</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ChoiceSetting</name>
|
||||
|
@ -167,10 +171,6 @@
|
|||
<source>Remove printer</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unknown</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Removing printer</source>
|
||||
<translation type="unfinished"></translation>
|
||||
|
@ -179,6 +179,10 @@
|
|||
<source>About SeaPrint</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unknown</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>JobsPage</name>
|
||||
|
|
|
@ -78,6 +78,10 @@
|
|||
<source>No printer found</source>
|
||||
<translation>Aucune imprimante détectée</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unknown</source>
|
||||
<translation type="unfinished">Inconnu</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ChoiceSetting</name>
|
||||
|
@ -167,10 +171,6 @@
|
|||
<source>Remove printer</source>
|
||||
<translation>Supprimer l'imprimante</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unknown</source>
|
||||
<translation>Inconnu</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Removing printer</source>
|
||||
<translation>Suppression de l'imprimante</translation>
|
||||
|
@ -179,6 +179,10 @@
|
|||
<source>About SeaPrint</source>
|
||||
<translation>À propos de SeaPrint</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unknown</source>
|
||||
<translation type="unfinished">Inconnu</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>JobsPage</name>
|
||||
|
|
|
@ -5,59 +5,59 @@
|
|||
<name>AboutPage</name>
|
||||
<message>
|
||||
<source>GitHub repository</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Github 库</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Report an Issue</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>报告缺陷</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>About</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation><关于/translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Network printing for Sailfish OS.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>旗鱼系统网络打印机软件。</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Icons</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>图标</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Icon made by Gregguh.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>图标制作者为 Gregguh 。</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>General contributions</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>一般贡献</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Translations</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>翻译</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Chinese</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>汉语</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Licensing</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>许可协议</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Source code is available at GitHub. Translations, bug reports and other contributions are welcome!</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>源代码位于 Github 。欢迎提供翻译,报告缺陷及其它贡献!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>SeaPrint licencing is still TBD, but will be some flavor of open.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Seaprint 仍然采用 TBD 许可协议,但是我非常愿意使它更加开放。</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>French</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation><法语/translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Code and Testing - Rudi Timmermans</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation type="unfinished">代码及测试 - Rudi Timmermans</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
@ -78,6 +78,10 @@
|
|||
<source>No printer found</source>
|
||||
<translation>没有找到打印机</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unknown</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ChoiceSetting</name>
|
||||
|
@ -130,7 +134,7 @@
|
|||
<name>CoverPage</name>
|
||||
<message>
|
||||
<source>SeaPrint</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>SeaPrint(海印)</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
@ -161,22 +165,26 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>About SeaPrint</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>关于 SeaPrint(海印)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unknown</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>未知</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>View jobs</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>查看作业</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Remove printer</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>移除打印机</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Removing printer</source>
|
||||
<translation>正在移除打印机</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unknown</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
|
@ -184,27 +192,27 @@
|
|||
<name>JobsPage</name>
|
||||
<message>
|
||||
<source>Refresh</source>
|
||||
<translation type="unfinished">刷新</translation>
|
||||
<translation>刷新</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>job</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>作业</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>jobs</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>作业</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Untitled job</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>无标题作业</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cancel job</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>取消作业</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cancelling job</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>正在取消作业</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
@ -235,15 +243,15 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>Unknown</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>未知</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Print success: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>打印成功:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Print failed: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>打印失败:</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
|
@ -78,6 +78,10 @@
|
|||
<source>No printer found</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unknown</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ChoiceSetting</name>
|
||||
|
@ -167,10 +171,6 @@
|
|||
<source>Remove printer</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unknown</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Removing printer</source>
|
||||
<translation type="unfinished"></translation>
|
||||
|
@ -179,6 +179,10 @@
|
|||
<source>About SeaPrint</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unknown</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>JobsPage</name>
|
||||
|
|
Loading…
Reference in a new issue