45 g_autoptr (GError) error = NULL;
49 gboolean is_reachable = g_network_monitor_can_reach_finish (netmonitor, result, &error);
51 const gchar *addr_tostr = g_strdup(g_socket_connectable_to_string (monitor->
addr));
56 REMMINA_DEBUG (
"Network object %s is reachable", g_socket_connectable_to_string (monitor->
addr));
57 status = g_strdup (
"online");
61 REMMINA_DEBUG (
"Network object %s is not reachable", g_socket_connectable_to_string (monitor->
addr));
62 status = g_strdup (
"offline");
65 if (g_hash_table_replace (monitor->
server_status, g_strdup(addr_tostr), g_strdup(status))) {
66 REMMINA_DEBUG (
"Inserting %s -> %s", addr_tostr, status);
68 REMMINA_DEBUG (
"Replacing %s -> %s", addr_tostr, status);
82 const gchar *ssh_tunnel_server;
83 const gchar *addr_tostr = NULL;
85 gchar *ssh_tunnel_host, *srv_host;
86 gint netmonit, srv_port, ssh_tunnel_port;
87 const gchar *protocol;
88 gint default_port = 0;
92 status = g_strdup (
"I/O Error");
93 REMMINA_DEBUG (status);
100 status = g_strdup (
"Monitoring disabled");
101 REMMINA_DEBUG (status);
107 if (protocol && protocol[0] !=
'\0') {
108 REMMINA_DEBUG (
"Evaluating protocol %s for monitoring", protocol);
109 if (g_strcmp0(
"RDP", protocol) == 0)
111 if (g_strcmp0(
"VNC", protocol) == 0)
113 if (g_strcmp0(
"GVNC", protocol) == 0)
115 if (g_strcmp0(
"SPICE", protocol) == 0)
117 if (g_strcmp0(
"WWW", protocol) == 0)
119 if (g_strcmp0(
"X2GO", protocol) == 0)
121 if (g_strcmp0(
"SSH", protocol) == 0)
123 if (g_strcmp0(
"SFTP", protocol) == 0)
125 if (g_strcmp0(
"EXEC", protocol) == 0)
128 if (default_port == 0) {
129 status = g_strdup (
"Unknown protocol");
130 REMMINA_DEBUG (status);
133 if (default_port < 0) {
134 status = g_strdup (
"Cannot monitor");
135 REMMINA_DEBUG (status);
142 monitor->
addr = g_network_address_new (ssh_tunnel_host, ssh_tunnel_port);
143 g_free(ssh_tunnel_host), ssh_tunnel_host = NULL;
147 monitor->
addr = g_network_address_new (srv_host, srv_port);
148 g_free(srv_host), srv_host = NULL;
150 addr_tostr = g_strdup(g_socket_connectable_to_string (monitor->
addr));
152 REMMINA_DEBUG (
"addr is %s", addr_tostr);
154 REMMINA_DEBUG (
"Testing for %s", addr_tostr);
155 g_network_monitor_can_reach_async (
164 status = (gchar *)g_hash_table_lookup (monitor->
server_status, addr_tostr);
171 return g_strdup(addr_tostr);
183 TRACE_CALL(__func__);
185 gboolean status = g_network_monitor_get_connectivity (rm_monitor->
netmonitor);
190 (GDestroyNotify)g_free,
191 (GDestroyNotify)g_free);
195 case G_NETWORK_CONNECTIVITY_LOCAL:
196 REMMINA_DEBUG (
"G_NETWORK_CONNECTIVITY_LOCAL");
200 case G_NETWORK_CONNECTIVITY_LIMITED:
201 REMMINA_DEBUG (
"G_NETWORK_CONNECTIVITY_LIMITED");
205 case G_NETWORK_CONNECTIVITY_PORTAL:
206 REMMINA_DEBUG (
"G_NETWORK_CONNECTIVITY_PORTAL");
210 case G_NETWORK_CONNECTIVITY_FULL:
211 REMMINA_DEBUG (
"G_NETWORK_CONNECTIVITY_FULL");
222 TRACE_CALL(__func__);
226 rm_monitor->
netmonitor = g_network_monitor_get_default ();
const gchar * remmina_file_get_string(RemminaFile *remminafile, const gchar *setting)
typedefG_BEGIN_DECLS struct _RemminaFile RemminaFile
GSocketConnectable * addr
gboolean remmina_network_monitor_status(RemminaMonitor *rm_monitor)
RemminaMonitor * remmina_network_monitor_new()
gchar * remmina_monitor_can_reach(RemminaFile *remminafile, RemminaMonitor *monitor)
static void remmina_monitor_can_reach_cb(GNetworkMonitor *netmonitor, GAsyncResult *result, RemminaMonitor *monitor)
gint remmina_file_get_int(RemminaFile *remminafile, const gchar *setting, gint default_value)
RemminaMonitor * rm_monitor
GHashTable * server_status
GNetworkMonitor * netmonitor
void remmina_public_get_server_port(const gchar *server, gint defaultport, gchar **host, gint *port)