Use single process, accept xmpp:-URIs as program argument
This commit is contained in:
parent
f9436b63f1
commit
b672df94e8
|
@ -15,6 +15,8 @@ public interface Dino.Application : GLib.Application {
|
||||||
{ null }
|
{ null }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public abstract void handle_uri(string jid, string query, Gee.Map<string, string> options);
|
||||||
|
|
||||||
public void init() throws Error {
|
public void init() throws Error {
|
||||||
if (DirUtils.create_with_parents(get_storage_dir(), 0700) == -1) {
|
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());
|
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;
|
stream_interaction.connection_manager.log_options = print_xmpp;
|
||||||
restore();
|
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);
|
add_main_option_entries(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application {
|
||||||
public SearchPathGenerator? search_path_generator { get; set; }
|
public SearchPathGenerator? search_path_generator { get; set; }
|
||||||
|
|
||||||
public Application() throws Error {
|
public Application() throws Error {
|
||||||
|
Object(application_id: "im.dino.Dino", flags: ApplicationFlags.HANDLES_OPEN);
|
||||||
init();
|
init();
|
||||||
Notify.init("dino");
|
Notify.init("dino");
|
||||||
Environment.set_application_name("Dino");
|
Environment.set_application_name("Dino");
|
||||||
|
@ -21,15 +22,25 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application {
|
||||||
IconTheme.get_default().add_resource_path("/im/dino/icons");
|
IconTheme.get_default().add_resource_path("/im/dino/icons");
|
||||||
|
|
||||||
activate.connect(() => {
|
activate.connect(() => {
|
||||||
|
if (window == null) {
|
||||||
create_set_app_menu();
|
create_set_app_menu();
|
||||||
window = new UnifiedWindow(this, stream_interaction);
|
window = new UnifiedWindow(this, stream_interaction);
|
||||||
notifications = new Notifications(stream_interaction, window);
|
notifications = new Notifications(stream_interaction, window);
|
||||||
notifications.start();
|
notifications.start();
|
||||||
notifications.conversation_selected.connect(window.on_conversation_selected);
|
notifications.conversation_selected.connect(window.on_conversation_selected);
|
||||||
|
}
|
||||||
window.present();
|
window.present();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void handle_uri(string jid, string query, Gee.Map<string, string> options) {
|
||||||
|
switch (query) {
|
||||||
|
case "message":
|
||||||
|
// TODO
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void show_accounts_window() {
|
private void show_accounts_window() {
|
||||||
ManageAccounts.Dialog dialog = new ManageAccounts.Dialog(stream_interaction, db);
|
ManageAccounts.Dialog dialog = new ManageAccounts.Dialog(stream_interaction, db);
|
||||||
dialog.set_transient_for(window);
|
dialog.set_transient_for(window);
|
||||||
|
|
Loading…
Reference in a new issue