[save] add some code for notification
This commit is contained in:
@@ -233,7 +233,8 @@ do_get_response_json (SoupServer *server, SoupMessage *msg, const char *path)
|
||||
static void handle_incoming_file(const char *hash, const char *filename, const int size, const char *origin) {
|
||||
g_print("Got a new file form %s with size:%d with title: %s\n", origin, size, filename);
|
||||
|
||||
create_user_notification(filename, size, origin);
|
||||
//char* balance[2] = {"First", "Secound"};
|
||||
//create_user_notification(filename, size, origin, balance);
|
||||
//If the user accepts the file
|
||||
do_downloading(g_strdup_printf("http://%s:%d/transfer/%s", origin, port, hash), filename);
|
||||
}
|
||||
|
||||
@@ -7,10 +7,21 @@
|
||||
#include "publish.h"
|
||||
#include "server.h"
|
||||
|
||||
|
||||
void test_callback(GSimpleAction *simple,
|
||||
GVariant *parameter,
|
||||
gpointer user_data);
|
||||
|
||||
enum {
|
||||
NOTIFY_USER, NOTIFY_FINISED, N_SIGNALS
|
||||
};
|
||||
|
||||
static GActionEntry app_entries[] =
|
||||
{
|
||||
{ "save", test_callback, "*", NULL, NULL },
|
||||
{ "quit", test_callback, "s", NULL, NULL }
|
||||
};
|
||||
|
||||
static TeleportAppWindow *win;
|
||||
static GApplication *application;
|
||||
static gint signalIds [N_SIGNALS];
|
||||
@@ -22,7 +33,13 @@ struct _TeleportApp {
|
||||
G_DEFINE_TYPE (TeleportApp, teleport_app, GTK_TYPE_APPLICATION);
|
||||
|
||||
|
||||
void create_user_notification (const char *file_name, const int file_size, const char *origin_device) {
|
||||
void test_callback (GSimpleAction *simple,
|
||||
GVariant *parameter,
|
||||
gpointer user_data) {
|
||||
g_print("Working: %s\n", g_variant_get_string (parameter, NULL));
|
||||
}
|
||||
|
||||
void create_user_notification (const char *file_name, const int file_size, const char *origin_device, char *target[]) {
|
||||
GNotification *notification = g_notification_new ("Teleport");
|
||||
g_notification_set_body (notification,
|
||||
g_strdup_printf("%s is sending %s (%s)",
|
||||
@@ -31,8 +48,9 @@ void create_user_notification (const char *file_name, const int file_size, const
|
||||
g_format_size (file_size)));
|
||||
GIcon *icon = g_themed_icon_new ("dialog-information");
|
||||
g_notification_set_icon (notification, icon);
|
||||
g_notification_add_button (notification, "Decline", "app.reply-5-minutes");
|
||||
g_notification_add_button (notification, "Save", "app.reply-5-minutes");
|
||||
g_notification_set_default_action(notification, "");
|
||||
g_notification_add_button (notification, "Decline", "app.decline");
|
||||
g_notification_add_button_with_target (notification, "Save", "app.save", "*", target);
|
||||
g_application_send_notification (application, NULL, notification);
|
||||
g_object_unref (icon);
|
||||
g_object_unref (notification);
|
||||
@@ -71,7 +89,7 @@ void callback_remove_peer (GObject *instance, Peer *peer, TeleportAppWindow *win
|
||||
}
|
||||
|
||||
void callback_notify_user (GObject *instance, char *name, TeleportAppWindow *win ) {
|
||||
create_user_notification("icon.png", 2000, "Mark's laptop");
|
||||
//create_user_notification("icon.png", 2000, "Mark's laptop");
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -88,6 +106,10 @@ teleport_app_activate (GApplication *app) {
|
||||
win = teleport_app_window_new (TELEPORT_APP (app));
|
||||
gtk_window_present (GTK_WINDOW (win));
|
||||
|
||||
g_action_map_add_action_entries (G_ACTION_MAP (app),
|
||||
app_entries, G_N_ELEMENTS (app_entries),
|
||||
app);
|
||||
|
||||
g_signal_connect (peerList, "addpeer", (GCallback)callback_add_peer, win);
|
||||
g_signal_connect (peerList, "removepeer", (GCallback)callback_remove_peer, win);
|
||||
g_signal_connect (app, "notify_user", (GCallback)callback_notify_user, win);
|
||||
@@ -97,7 +119,8 @@ teleport_app_activate (GApplication *app) {
|
||||
g_print("Data: %d\n", teleport_peer_get_port(peerList, 0, NULL));
|
||||
*/
|
||||
|
||||
create_user_notification ("sdfdsff", 2000, "sdfdsfdsf");
|
||||
char* balance[2] = {"First", "Secound"};
|
||||
create_user_notification ("sdfdsff", 2000, "sdfdsfdsf", balance);
|
||||
run_http_server();
|
||||
run_avahi_publish_service((char *) g_get_host_name());
|
||||
run_avahi_service(peerList);
|
||||
|
||||
@@ -11,6 +11,7 @@ G_DECLARE_FINAL_TYPE (TeleportApp, teleport_app, TELEPORT, APP, GtkApplication)
|
||||
TeleportApp *teleport_app_new (void);
|
||||
extern void create_user_notification (const char *,
|
||||
const int,
|
||||
const char *);
|
||||
const char *,
|
||||
char *[]);
|
||||
|
||||
#endif /* __TELEPORTAPP_H */
|
||||
|
||||
Reference in New Issue
Block a user