Commit 56bfde0a authored by Julian Sparber's avatar Julian Sparber

[feat] start implementing device lookup

parent a2d4cce3
......@@ -78,7 +78,7 @@ get (const gchar *url,
GVariant *target;
builder = g_variant_builder_new (G_VARIANT_TYPE ("as"));
g_variant_builder_add (builder, "s", originDevice);
g_variant_builder_add (builder, "s", teleport_peer_get_name_by_addr(self, originDevice));
g_variant_builder_add (builder, "s", url);
g_variant_builder_add (builder, "s", outputFilename);
g_variant_builder_add (builder, "s", downloadDirectory);
......
......@@ -126,3 +126,19 @@ void teleport_peer_remove_peer_by_name (TeleportPeer *self, gchar *name)
}
g_signal_emit (self, signalIds[REMOVE], 0, element);
}
gchar *
teleport_peer_get_name_by_addr (TeleportPeer *self, gchar *addr)
{
Peer *element = NULL;
gchar *name = NULL;
gboolean found = FALSE;
for (int i = 0; i < self->list->len && !found; i++) {
element = g_array_index(self->list, Peer *, i);
if (g_strcmp0(element->ip, addr) == 0) {
found = TRUE;
name = element->name;
}
}
return name;
}
......@@ -13,11 +13,12 @@ typedef struct Peers {
} Peer;
gchar* teleport_peer_get_name (TeleportPeer *self, gint index, GError **error);
gchar* teleport_peer_get_ip (TeleportPeer *self, gint index, GError **error);
gchar * teleport_peer_get_name (TeleportPeer *self, gint index, GError **error);
gchar * teleport_peer_get_ip (TeleportPeer *self, gint index, GError **error);
gint teleport_peer_get_port (TeleportPeer *self, gint index, GError **error);
void teleport_peer_add_peer (TeleportPeer *self, gchar * name, gchar * ip, gint port);
void teleport_peer_remove_peer (TeleportPeer *, Peer *);
void teleport_peer_remove_peer_by_name (TeleportPeer *, gchar *);
gchar * teleport_peer_get_name_by_addr (TeleportPeer *, gchar *);
#endif /* __TELEPORT_PEER_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment