Merge branch 'devicename'
This commit is contained in:
@@ -36,6 +36,7 @@ static GActionEntry app_entries[] =
|
|||||||
|
|
||||||
static TeleportWindow *win;
|
static TeleportWindow *win;
|
||||||
static GApplication *application;
|
static GApplication *application;
|
||||||
|
static TeleportPeer *peerList;
|
||||||
static gint signalIds [N_SIGNALS];
|
static gint signalIds [N_SIGNALS];
|
||||||
|
|
||||||
struct _TeleportApp {
|
struct _TeleportApp {
|
||||||
@@ -75,7 +76,7 @@ void create_user_notification (const char *file_name, const int file_size, const
|
|||||||
GNotification *notification = g_notification_new ("Teleport");
|
GNotification *notification = g_notification_new ("Teleport");
|
||||||
g_notification_set_body (notification,
|
g_notification_set_body (notification,
|
||||||
g_strdup_printf("%s is sending %s (%s)",
|
g_strdup_printf("%s is sending %s (%s)",
|
||||||
origin_device,
|
teleport_peer_get_name_by_addr (peerList, origin_device),
|
||||||
file_name,
|
file_name,
|
||||||
g_format_size (file_size)));
|
g_format_size (file_size)));
|
||||||
icon = g_themed_icon_new ("dialog-information");
|
icon = g_themed_icon_new ("dialog-information");
|
||||||
@@ -94,7 +95,10 @@ void create_user_notification (const char *file_name, const int file_size, const
|
|||||||
void create_finished_notification (const char *origin, const int filesize, const char *filename, GVariant *target) {
|
void create_finished_notification (const char *origin, const int filesize, const char *filename, GVariant *target) {
|
||||||
GIcon *icon;
|
GIcon *icon;
|
||||||
GNotification *notification = g_notification_new ("Teleport");
|
GNotification *notification = g_notification_new ("Teleport");
|
||||||
g_notification_set_body (notification, g_strdup_printf("Transfer of %s from %s is complete", filename, origin));
|
g_notification_set_body (notification,
|
||||||
|
g_strdup_printf("Transfer of %s from %s is complete",
|
||||||
|
teleport_peer_get_name_by_addr (peerList, origin),
|
||||||
|
origin));
|
||||||
icon = g_themed_icon_new ("dialog-information");
|
icon = g_themed_icon_new ("dialog-information");
|
||||||
g_notification_set_icon (notification, icon);
|
g_notification_set_icon (notification, icon);
|
||||||
g_notification_set_default_action_and_target_value (notification, "app.do-nothing", target);
|
g_notification_set_default_action_and_target_value (notification, "app.do-nothing", target);
|
||||||
@@ -137,7 +141,7 @@ teleport_app_init (TeleportApp *app) {
|
|||||||
static void
|
static void
|
||||||
teleport_app_activate (GApplication *app) {
|
teleport_app_activate (GApplication *app) {
|
||||||
//TeleportWindow *win;
|
//TeleportWindow *win;
|
||||||
TeleportPeer *peerList = g_object_new (TELEPORT_TYPE_PEER, NULL);
|
peerList = g_object_new (TELEPORT_TYPE_PEER, NULL);
|
||||||
application = app;
|
application = app;
|
||||||
|
|
||||||
win = teleport_window_new (TELEPORT_APP (app));
|
win = teleport_window_new (TELEPORT_APP (app));
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ void teleport_peer_remove_peer (TeleportPeer *self, Peer *device)
|
|||||||
g_signal_emit (self, signalIds[REMOVE], 0, device);
|
g_signal_emit (self, signalIds[REMOVE], 0, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
void teleport_peer_remove_peer_by_name (TeleportPeer *self, gchar *name)
|
void teleport_peer_remove_peer_by_name (TeleportPeer *self, const gchar *name)
|
||||||
{
|
{
|
||||||
Peer *element = NULL;
|
Peer *element = NULL;
|
||||||
gboolean found = FALSE;
|
gboolean found = FALSE;
|
||||||
@@ -126,3 +126,19 @@ void teleport_peer_remove_peer_by_name (TeleportPeer *self, gchar *name)
|
|||||||
}
|
}
|
||||||
g_signal_emit (self, signalIds[REMOVE], 0, element);
|
g_signal_emit (self, signalIds[REMOVE], 0, element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gchar *
|
||||||
|
teleport_peer_get_name_by_addr (TeleportPeer *self, const 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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ gchar* teleport_peer_get_ip (TeleportPeer *self, gint index, GError **error);
|
|||||||
gint teleport_peer_get_port (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_add_peer (TeleportPeer *self, gchar * name, gchar * ip, gint port);
|
||||||
void teleport_peer_remove_peer (TeleportPeer *, Peer *);
|
void teleport_peer_remove_peer (TeleportPeer *, Peer *);
|
||||||
void teleport_peer_remove_peer_by_name (TeleportPeer *, gchar *);
|
void teleport_peer_remove_peer_by_name (TeleportPeer *, const gchar *);
|
||||||
|
gchar * teleport_peer_get_name_by_addr (TeleportPeer *, const gchar *);
|
||||||
|
|
||||||
#endif /* __TELEPORT_PEER_H */
|
#endif /* __TELEPORT_PEER_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user