Http file upload for version :0 and other server setups
This commit is contained in:
parent
4aee95703d
commit
6bc950d042
|
@ -17,11 +17,13 @@ Build
|
||||||
**Run-time dependencies**
|
**Run-time dependencies**
|
||||||
|
|
||||||
* GLib (≥ 2.38)
|
* GLib (≥ 2.38)
|
||||||
|
* glib-networking
|
||||||
* GTK (≥ 3.22)
|
* GTK (≥ 3.22)
|
||||||
* GPGME (For the OpenPGP plugin)
|
* GPGME (For the OpenPGP plugin)
|
||||||
* libgee-0.8 (≥ 0.10)
|
* libgee-0.8 (≥ 0.10)
|
||||||
* libgcrypt (For the OMEMO plugin)
|
* libgcrypt (For the OMEMO plugin)
|
||||||
* libnotify
|
* libnotify
|
||||||
|
* libsoup (For the HTTP files plugin)
|
||||||
* SQLite3
|
* SQLite3
|
||||||
|
|
||||||
**Instructions**
|
**Instructions**
|
||||||
|
|
15
dino.spec
15
dino.spec
|
@ -43,6 +43,7 @@ BuildRequires: pkgconfig(gio-2.0)
|
||||||
BuildRequires: pkgconfig(gtk+-3.0) >= 3.22
|
BuildRequires: pkgconfig(gtk+-3.0) >= 3.22
|
||||||
BuildRequires: pkgconfig(gee-0.8) >= 0.10
|
BuildRequires: pkgconfig(gee-0.8) >= 0.10
|
||||||
BuildRequires: pkgconfig(libnotify)
|
BuildRequires: pkgconfig(libnotify)
|
||||||
|
BuildRequires: pkgconfig(libsoup-2.4)
|
||||||
BuildRequires: pkgconfig(sqlite3)
|
BuildRequires: pkgconfig(sqlite3)
|
||||||
BuildRequires: libgcrypt-devel
|
BuildRequires: libgcrypt-devel
|
||||||
BuildRequires: gpgme-devel
|
BuildRequires: gpgme-devel
|
||||||
|
@ -51,6 +52,7 @@ Requires: %{name}-libs%{?_isa} = %{version}-%{release}
|
||||||
# Technically these aren't requirements, we just want them always installed...
|
# Technically these aren't requirements, we just want them always installed...
|
||||||
Requires: %{name}-plugin-omemo%{?_isa} = %{version}-%{release}
|
Requires: %{name}-plugin-omemo%{?_isa} = %{version}-%{release}
|
||||||
Requires: %{name}-plugin-openpgp%{?_isa} = %{version}-%{release}
|
Requires: %{name}-plugin-openpgp%{?_isa} = %{version}-%{release}
|
||||||
|
Requires: %{name}-plugin-http-files%{?_isa} = %{version}-%{release}
|
||||||
|
|
||||||
%description
|
%description
|
||||||
Dino is an instant messaging client for the Jabber/XMPP network,
|
Dino is an instant messaging client for the Jabber/XMPP network,
|
||||||
|
@ -76,6 +78,10 @@ Requires: %{name}-libs%{?_isa} = %{version}-%{release}
|
||||||
Summary: OpenPGP plugin for %{name}
|
Summary: OpenPGP plugin for %{name}
|
||||||
Requires: %{name}-libs%{?_isa} = %{version}-%{release}
|
Requires: %{name}-libs%{?_isa} = %{version}-%{release}
|
||||||
|
|
||||||
|
%package plugin-http-files
|
||||||
|
Summary: Http files plugin for %{name}
|
||||||
|
Requires: %{name}-libs%{?_isa} = %{version}-%{release}
|
||||||
|
|
||||||
%description libs
|
%description libs
|
||||||
The %{name}-libs package contains libraries used and provided by %{name}.
|
The %{name}-libs package contains libraries used and provided by %{name}.
|
||||||
|
|
||||||
|
@ -91,6 +97,10 @@ OMEMO encryption to Dino.
|
||||||
The %{name}-plugin-openpgp package contains a plugin that adds support for
|
The %{name}-plugin-openpgp package contains a plugin that adds support for
|
||||||
OpenPGP encryption to Dino.
|
OpenPGP encryption to Dino.
|
||||||
|
|
||||||
|
%description plugin-http-files
|
||||||
|
The %{name}-plugin-http-files package contains a plugin that adds support for
|
||||||
|
http file upload and download to Dino.
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -n "dino-v%{version}"
|
%setup -n "dino-v%{version}"
|
||||||
#%setup -n "dino-%{commit}"
|
#%setup -n "dino-%{commit}"
|
||||||
|
@ -168,6 +178,11 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :
|
||||||
%{_libdir}/dino/plugins/openpgp.so
|
%{_libdir}/dino/plugins/openpgp.so
|
||||||
%{_datadir}/locale/*/LC_MESSAGES/dino-openpgp.mo
|
%{_datadir}/locale/*/LC_MESSAGES/dino-openpgp.mo
|
||||||
|
|
||||||
|
%files plugin-http-files
|
||||||
|
%license LICENSE
|
||||||
|
%doc README.md
|
||||||
|
%{_libdir}/dino/plugins/http-files.so
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Mon Apr 3 2017 - 0.0-1
|
* Mon Apr 3 2017 - 0.0-1
|
||||||
- Split packages
|
- Split packages
|
||||||
|
|
|
@ -15,6 +15,7 @@ public class UploadStreamModule : XmppStreamModule {
|
||||||
public delegate void OnUploadOk(XmppStream stream, string url_down);
|
public delegate void OnUploadOk(XmppStream stream, string url_down);
|
||||||
public delegate void OnError(XmppStream stream, string error);
|
public delegate void OnError(XmppStream stream, string error);
|
||||||
public void upload(XmppStream stream, string file_uri, owned OnUploadOk listener, owned OnError error_listener) {
|
public void upload(XmppStream stream, string file_uri, owned OnUploadOk listener, owned OnError error_listener) {
|
||||||
|
print("up!\n");
|
||||||
File file = File.new_for_path(file_uri);
|
File file = File.new_for_path(file_uri);
|
||||||
FileInfo file_info = file.query_info("*", FileQueryInfoFlags.NONE);
|
FileInfo file_info = file.query_info("*", FileQueryInfoFlags.NONE);
|
||||||
request_slot(stream, file.get_basename(), (int)file_info.get_size(), file_info.get_content_type(),
|
request_slot(stream, file.get_basename(), (int)file_info.get_size(), file_info.get_content_type(),
|
||||||
|
@ -27,7 +28,7 @@ public class UploadStreamModule : XmppStreamModule {
|
||||||
Soup.Session session = new Soup.Session();
|
Soup.Session session = new Soup.Session();
|
||||||
session.send_async(message);
|
session.send_async(message);
|
||||||
|
|
||||||
listener(stream, url_up);
|
listener(stream, url_down);
|
||||||
},
|
},
|
||||||
error_listener);
|
error_listener);
|
||||||
}
|
}
|
||||||
|
@ -35,30 +36,42 @@ public class UploadStreamModule : XmppStreamModule {
|
||||||
private delegate void OnSlotOk(XmppStream stream, string url_get, string url_put);
|
private delegate void OnSlotOk(XmppStream stream, string url_get, string url_put);
|
||||||
private void request_slot(XmppStream stream, string filename, int file_size, string? content_type, owned OnSlotOk listener, owned OnError error_listener) {
|
private void request_slot(XmppStream stream, string filename, int file_size, string? content_type, owned OnSlotOk listener, owned OnError error_listener) {
|
||||||
Flag? flag = stream.get_flag(Flag.IDENTITY);
|
Flag? flag = stream.get_flag(Flag.IDENTITY);
|
||||||
if (flag != null) return;
|
if (flag == null) return;
|
||||||
|
|
||||||
StanzaNode request_node;
|
StanzaNode? request_node = null;
|
||||||
if (flag.ns_ver == NS_URI_0) {
|
switch (flag.ns_ver) {
|
||||||
request_node = new StanzaNode.build("request", NS_URI_0).add_self_xmlns();
|
case NS_URI_0:
|
||||||
request_node.put_attribute("filename", filename).put_attribute("size", file_size.to_string());
|
request_node = new StanzaNode.build("request", NS_URI_0).add_self_xmlns();
|
||||||
if (content_type != null) request_node.put_attribute("content-type", content_type);
|
request_node.put_attribute("filename", filename).put_attribute("size", file_size.to_string());
|
||||||
} else{
|
if (content_type != null) request_node.put_attribute("content-type", content_type);
|
||||||
request_node = new StanzaNode.build("request", NS_URI).add_self_xmlns()
|
break;
|
||||||
.put_node(new StanzaNode.build("filename", NS_URI).put_node(new StanzaNode.text(filename)))
|
case NS_URI:
|
||||||
.put_node(new StanzaNode.build("size", NS_URI).put_node(new StanzaNode.text(file_size.to_string())));
|
request_node = new StanzaNode.build("request", NS_URI).add_self_xmlns()
|
||||||
if (content_type != null) {
|
.put_node(new StanzaNode.build("filename", NS_URI).put_node(new StanzaNode.text(filename)))
|
||||||
request_node.put_node(new StanzaNode.build("content-type", NS_URI).put_node(new StanzaNode.text(content_type)));
|
.put_node(new StanzaNode.build("size", NS_URI).put_node(new StanzaNode.text(file_size.to_string())));
|
||||||
}
|
if (content_type != null) {
|
||||||
|
request_node.put_node(new StanzaNode.build("content-type", NS_URI).put_node(new StanzaNode.text(content_type)));
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
Iq.Stanza iq = new Iq.Stanza.get(request_node) { to=flag.file_store_jid };
|
Iq.Stanza iq = new Iq.Stanza.get(request_node) { to=flag.file_store_jid };
|
||||||
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, iq) => {
|
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, iq) => {
|
||||||
if (iq.is_error()) {
|
if (iq.is_error()) {
|
||||||
error_listener(stream, "");
|
error_listener(stream, "");
|
||||||
} else {
|
return;
|
||||||
string? url_get = iq.stanza.get_deep_string_content(flag.ns_ver + ":slot", flag.ns_ver + ":get");
|
|
||||||
string? url_put = iq.stanza.get_deep_string_content(flag.ns_ver + ":slot", flag.ns_ver + ":put");
|
|
||||||
listener(stream, url_get, url_put);
|
|
||||||
}
|
}
|
||||||
|
string? url_get = null, url_put = null;
|
||||||
|
switch (flag.ns_ver) {
|
||||||
|
case NS_URI_0:
|
||||||
|
url_get = iq.stanza.get_deep_attribute(flag.ns_ver + ":slot", flag.ns_ver + ":get", flag.ns_ver + ":url");
|
||||||
|
url_put = iq.stanza.get_deep_attribute(flag.ns_ver + ":slot", flag.ns_ver + ":put", flag.ns_ver + ":url");
|
||||||
|
break;
|
||||||
|
case NS_URI:
|
||||||
|
url_get = iq.stanza.get_deep_string_content(flag.ns_ver + ":slot", flag.ns_ver + ":get");
|
||||||
|
url_put = iq.stanza.get_deep_string_content(flag.ns_ver + ":slot", flag.ns_ver + ":put");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
listener(stream, url_get, url_put);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,12 +99,9 @@ public class UploadStreamModule : XmppStreamModule {
|
||||||
if (!available) {
|
if (!available) {
|
||||||
stream.get_module(ServiceDiscovery.Module.IDENTITY).request_items(stream, stream.remote_name, (stream, items_result) => {
|
stream.get_module(ServiceDiscovery.Module.IDENTITY).request_items(stream, stream.remote_name, (stream, items_result) => {
|
||||||
foreach (Xep.ServiceDiscovery.Item item in items_result.items) {
|
foreach (Xep.ServiceDiscovery.Item item in items_result.items) {
|
||||||
if (item.name == "HTTP File Upload") {
|
stream.get_module(ServiceDiscovery.Module.IDENTITY).request_info(stream, item.jid, (stream, info_result) => {
|
||||||
stream.get_module(ServiceDiscovery.Module.IDENTITY).request_info(stream, item.jid, (stream, info_result) => {
|
check_ns_in_info(stream, item.jid, info_result);
|
||||||
check_ns_in_info(stream, item.jid, info_result);
|
});
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ public class ItemsResult {
|
||||||
public ArrayList<Item> items {
|
public ArrayList<Item> items {
|
||||||
owned get {
|
owned get {
|
||||||
ArrayList<Item> ret = new ArrayList<Item>();
|
ArrayList<Item> ret = new ArrayList<Item>();
|
||||||
foreach (StanzaNode feature_node in iq.stanza.get_subnode("query", NS_URI_ITEMS).get_subnodes("identity", NS_URI_INFO)) {
|
foreach (StanzaNode feature_node in iq.stanza.get_subnode("query", NS_URI_ITEMS).get_subnodes("item", NS_URI_ITEMS)) {
|
||||||
ret.add(new Item(feature_node.get_attribute("jid", NS_URI_ITEMS),
|
ret.add(new Item(feature_node.get_attribute("jid", NS_URI_ITEMS),
|
||||||
feature_node.get_attribute("name", NS_URI_ITEMS),
|
feature_node.get_attribute("name", NS_URI_ITEMS),
|
||||||
feature_node.get_attribute("node", NS_URI_ITEMS)));
|
feature_node.get_attribute("node", NS_URI_ITEMS)));
|
||||||
|
|
|
@ -54,7 +54,6 @@ public class Module : XmppStreamModule, Iq.Handler {
|
||||||
public void request_items(XmppStream stream, string jid, owned OnItemsResult listener) {
|
public void request_items(XmppStream stream, string jid, owned OnItemsResult listener) {
|
||||||
Iq.Stanza iq = new Iq.Stanza.get(new StanzaNode.build("query", NS_URI_ITEMS).add_self_xmlns());
|
Iq.Stanza iq = new Iq.Stanza.get(new StanzaNode.build("query", NS_URI_ITEMS).add_self_xmlns());
|
||||||
iq.to = jid;
|
iq.to = jid;
|
||||||
print(iq.stanza.to_string() + "\n");
|
|
||||||
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, iq) => {
|
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, iq) => {
|
||||||
ItemsResult? result = ItemsResult.create_from_iq(iq);
|
ItemsResult? result = ItemsResult.create_from_iq(iq);
|
||||||
stream.get_flag(Flag.IDENTITY).set_entity_items(iq.from, result != null ? result.items : null);
|
stream.get_flag(Flag.IDENTITY).set_entity_items(iq.from, result != null ? result.items : null);
|
||||||
|
|
Loading…
Reference in a new issue