[feat] show user error msg when the avahi deamon is not running, close #3
This commit is contained in:
@@ -91,6 +91,45 @@ struct _TeleportApp {
|
|||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (TeleportApp, teleport_app, GTK_TYPE_APPLICATION);
|
G_DEFINE_TYPE_WITH_PRIVATE (TeleportApp, teleport_app, GTK_TYPE_APPLICATION);
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_avahi_appeared (GDBusConnection *connection,
|
||||||
|
const gchar *name,
|
||||||
|
const gchar *name_owner,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
TeleportApp *app = user_data;
|
||||||
|
TeleportAppPrivate *priv = app->priv;
|
||||||
|
GtkWidget *window = priv->window;
|
||||||
|
|
||||||
|
teleport_show_no_device_message (TELEPORT_WINDOW (window), TRUE);
|
||||||
|
teleport_publish_run (teleport_get_device_name());
|
||||||
|
teleport_browser_run_avahi_service(priv->peerList);
|
||||||
|
teleport_show_no_avahi_message (TELEPORT_WINDOW (window), FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_avahi_vanished (GDBusConnection *connection,
|
||||||
|
const gchar *name,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
TeleportApp *app = user_data;
|
||||||
|
TeleportAppPrivate *priv = app->priv;
|
||||||
|
GtkWidget *window = priv->window;
|
||||||
|
|
||||||
|
teleport_show_no_device_message (TELEPORT_WINDOW (window), FALSE);
|
||||||
|
teleport_show_no_avahi_message (TELEPORT_WINDOW (window), TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
watch_for_avahi_service (TeleportApp *application) {
|
||||||
|
g_bus_watch_name (G_BUS_TYPE_SYSTEM,
|
||||||
|
"org.freedesktop.Avahi",
|
||||||
|
G_BUS_NAME_WATCHER_FLAGS_NONE,
|
||||||
|
on_avahi_appeared,
|
||||||
|
on_avahi_vanished,
|
||||||
|
application,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
save_file_callback (GSimpleAction *simple,
|
save_file_callback (GSimpleAction *simple,
|
||||||
@@ -239,7 +278,7 @@ mainLoopRemovePeerCallback (gpointer peer) {
|
|||||||
update_remote_device_list_remove((TeleportWindow *) window, (Peer *) peer);
|
update_remote_device_list_remove((TeleportWindow *) window, (Peer *) peer);
|
||||||
//if (teleport_peer_get_number (priv->peerList) == 0)
|
//if (teleport_peer_get_number (priv->peerList) == 0)
|
||||||
if (teleport_peer_get_number (priv->peerList) == 0)
|
if (teleport_peer_get_number (priv->peerList) == 0)
|
||||||
teleport_show_no_device_message (TELEPORT_WINDOW (window));
|
teleport_show_no_device_message (TELEPORT_WINDOW (window), TRUE);
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,10 +334,7 @@ teleport_app_startup (GApplication *app) {
|
|||||||
|
|
||||||
teleport_server_run();
|
teleport_server_run();
|
||||||
|
|
||||||
if (!teleport_publish_run (teleport_get_device_name()))
|
watch_for_avahi_service (TELEPORT_APP (app));
|
||||||
if (!teleport_browser_run_avahi_service(priv->peerList)) {
|
|
||||||
/* Error when avahi doesn't run */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -219,11 +219,25 @@ teleport_get_download_directory (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
teleport_show_no_device_message (TeleportWindow *self)
|
teleport_show_no_device_message (TeleportWindow *self, gboolean show)
|
||||||
{
|
{
|
||||||
TeleportWindowPrivate *priv;
|
TeleportWindowPrivate *priv;
|
||||||
priv = teleport_window_get_instance_private (self);
|
priv = teleport_window_get_instance_private (self);
|
||||||
gtk_widget_show (priv->remote_no_devices);
|
if (show)
|
||||||
|
gtk_widget_show (priv->remote_no_devices);
|
||||||
|
else
|
||||||
|
gtk_widget_hide (priv->remote_no_devices);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
teleport_show_no_avahi_message (TeleportWindow *self, gboolean show)
|
||||||
|
{
|
||||||
|
TeleportWindowPrivate *priv;
|
||||||
|
priv = teleport_window_get_instance_private (self);
|
||||||
|
if (show)
|
||||||
|
gtk_widget_show (priv->remote_no_avahi);
|
||||||
|
else
|
||||||
|
gtk_widget_hide (priv->remote_no_avahi);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ void update_remote_device_list_remove (TeleportWindow *,
|
|||||||
|
|
||||||
gchar * teleport_get_download_directory (void);
|
gchar * teleport_get_download_directory (void);
|
||||||
gchar * teleport_get_device_name (void);
|
gchar * teleport_get_device_name (void);
|
||||||
void teleport_show_no_device_message (TeleportWindow *);
|
void teleport_show_no_device_message (TeleportWindow *,
|
||||||
|
gboolean);
|
||||||
|
void teleport_show_no_avahi_message (TeleportWindow *,
|
||||||
|
gboolean);
|
||||||
|
|
||||||
#endif /* __TELEPORT_WINDOW_H */
|
#endif /* __TELEPORT_WINDOW_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user