aboutsummaryrefslogtreecommitdiff
path: root/libdino
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2017-08-17 11:38:41 +0200
committerfiaxh <git@mx.ax.lt>2017-08-25 22:30:03 +0200
commitb672df94e82032f265255ea756b459251cadfef1 (patch)
tree68b24e86eba206cc660326fc0ec6dd787d9b5b1f /libdino
parentf9436b63f1f7de08f8c2c97878c183495bb3c6f6 (diff)
downloaddino-b672df94e82032f265255ea756b459251cadfef1.tar.gz
dino-b672df94e82032f265255ea756b459251cadfef1.zip
Use single process, accept xmpp:-URIs as program argument
Diffstat (limited to 'libdino')
-rw-r--r--libdino/src/application.vala36
1 files changed, 36 insertions, 0 deletions
diff --git a/libdino/src/application.vala b/libdino/src/application.vala
index 4b5f3b64..a04f6897 100644
--- a/libdino/src/application.vala
+++ b/libdino/src/application.vala
@@ -15,6 +15,8 @@ public interface Dino.Application : GLib.Application {
{ null }
};
+ public abstract void handle_uri(string jid, string query, Gee.Map<string, string> options);
+
public void init() throws Error {
if (DirUtils.create_with_parents(get_storage_dir(), 0700) == -1) {
throw new Error(-1, 0, "Could not create storage dir \"%s\": %s", get_storage_dir(), FileUtils.error_from_errno(errno).to_string());
@@ -38,6 +40,40 @@ public interface Dino.Application : GLib.Application {
stream_interaction.connection_manager.log_options = print_xmpp;
restore();
});
+ open.connect((files, hint) => {
+ if (files.length != 1) {
+ warning("Can't handle more than one URI at once.");
+ return;
+ }
+ File file = files[0];
+ if (!file.has_uri_scheme("xmpp")) {
+ warning("xmpp:-URI expected");
+ return;
+ }
+ string uri = file.get_uri();
+ if (!uri.contains(":")) {
+ warning("Invalid URI");
+ return;
+ }
+ string r = uri.split(":", 2)[1];
+ string[] m = r.split("?", 2);
+ string jid = m[0];
+ while (jid[0] == '/') {
+ jid = jid.substring(1);
+ }
+ string query = "message";
+ Gee.Map<string, string> options = new Gee.HashMap<string,string>();
+ if (m.length == 2) {
+ string[] cmds = m[1].split(";");
+ query = cmds[0];
+ for (int i = 1; i < cmds.length; ++i) {
+ string[] opt = cmds[i].split("=", 2);
+ options[opt[0]] = opt.length == 2 ? opt[1] : "";
+ }
+ }
+ activate();
+ handle_uri(jid, query, options);
+ });
add_main_option_entries(options);
}