forked from mirrors/linphone-iphone
Enable Linphone to open URIs from chat room on Windows and MacOSX
This commit is contained in:
parent
e95b401dc3
commit
37a85f2e41
1 changed files with 36 additions and 24 deletions
60
gtk/chat.c
60
gtk/chat.c
|
|
@ -407,33 +407,45 @@ static GdkColor *_linphone_gtk_chatroom_get_link_color(GtkWidget *chatview) {
|
|||
}
|
||||
|
||||
static void open_uri(const char *uri) {
|
||||
#ifdef __linux
|
||||
const char *cmd = NULL;
|
||||
GError *error = NULL;
|
||||
gchar *argv[3] = {
|
||||
g_strdup("xdg-open"),
|
||||
g_strdup(uri),
|
||||
NULL
|
||||
};
|
||||
g_spawn_async(
|
||||
NULL,
|
||||
argv,
|
||||
NULL,
|
||||
G_SPAWN_SEARCH_PATH,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&error
|
||||
);
|
||||
g_free(argv[0]);
|
||||
g_free(argv[1]);
|
||||
|
||||
if(error) {
|
||||
g_warning("Cannot open %s: %s", uri, error->message);
|
||||
g_error_free(error);
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
cmd = "open";
|
||||
#elseif __linux
|
||||
cmd = "xdg-open";
|
||||
#elseif WIN32
|
||||
cmd = "start";
|
||||
#else
|
||||
g_warning("Cannot open URIs from chat room on this platform");
|
||||
cmd = NULL;
|
||||
#endif
|
||||
|
||||
if(cmd) {
|
||||
gchar *argv[3] = {
|
||||
g_strdup(cmd),
|
||||
g_strdup(uri),
|
||||
NULL
|
||||
};
|
||||
g_spawn_async(
|
||||
NULL,
|
||||
argv,
|
||||
NULL,
|
||||
G_SPAWN_SEARCH_PATH,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&error
|
||||
);
|
||||
g_free(argv[0]);
|
||||
g_free(argv[1]);
|
||||
|
||||
if(error) {
|
||||
g_warning("Cannot open %s: %s", uri, error->message);
|
||||
g_error_free(error);
|
||||
}
|
||||
} else {
|
||||
g_warning("Cannot open URIs from chat room on this platform");
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean link_event_handler(GtkTextTag *tag, GObject *object,GdkEvent *event, GtkTextIter *iter, gpointer user_data) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue