[refactor] fix intent in some files
This commit is contained in:
@@ -48,7 +48,7 @@ G_DEFINE_TYPE (TeleportApp, teleport_app, GTK_TYPE_APPLICATION);
|
|||||||
void save_file_callback (GSimpleAction *simple,
|
void save_file_callback (GSimpleAction *simple,
|
||||||
GVariant *parameter,
|
GVariant *parameter,
|
||||||
gpointer user_data) {
|
gpointer user_data) {
|
||||||
do_downloading(g_variant_get_string (g_variant_get_child_value (parameter, 0), NULL),
|
teleport_get_do_downloading(g_variant_get_string (g_variant_get_child_value (parameter, 0), NULL),
|
||||||
g_variant_get_string (g_variant_get_child_value (parameter, 1), NULL),
|
g_variant_get_string (g_variant_get_child_value (parameter, 1), NULL),
|
||||||
g_variant_get_string (g_variant_get_child_value (parameter, 2), NULL));
|
g_variant_get_string (g_variant_get_child_value (parameter, 2), NULL));
|
||||||
}
|
}
|
||||||
@@ -173,7 +173,7 @@ teleport_app_activate (GApplication *app) {
|
|||||||
run_avahi_service(peerList);
|
run_avahi_service(peerList);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
teleport_app_open (GApplication *app,
|
teleport_app_open (GApplication *app,
|
||||||
GFile **files,
|
GFile **files,
|
||||||
gint n_files,
|
gint n_files,
|
||||||
@@ -194,7 +194,7 @@ teleport_app_open (GApplication *app,
|
|||||||
gtk_window_present (GTK_WINDOW (win));
|
gtk_window_present (GTK_WINDOW (win));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
teleport_app_class_init (TeleportAppClass *class)
|
teleport_app_class_init (TeleportAppClass *class)
|
||||||
{
|
{
|
||||||
G_APPLICATION_CLASS (class)->activate = teleport_app_activate;
|
G_APPLICATION_CLASS (class)->activate = teleport_app_activate;
|
||||||
@@ -212,7 +212,7 @@ teleport_app_class_init (TeleportAppClass *class)
|
|||||||
G_TYPE_STRING);
|
G_TYPE_STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
TeleportApp *
|
TeleportApp *
|
||||||
teleport_app_new (void)
|
teleport_app_new (void)
|
||||||
{
|
{
|
||||||
return g_object_new (TELEPORT_APP_TYPE,
|
return g_object_new (TELEPORT_APP_TYPE,
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ static AvahiThreadedPoll *threaded_poll = NULL;
|
|||||||
static AvahiClient *client = NULL;
|
static AvahiClient *client = NULL;
|
||||||
static TeleportPeer *peerList = NULL;
|
static TeleportPeer *peerList = NULL;
|
||||||
|
|
||||||
static void resolve_callback(
|
static void resolve_callback (AvahiServiceResolver *r,
|
||||||
AvahiServiceResolver *r,
|
|
||||||
AVAHI_GCC_UNUSED AvahiIfIndex interface,
|
AVAHI_GCC_UNUSED AvahiIfIndex interface,
|
||||||
AVAHI_GCC_UNUSED AvahiProtocol protocol,
|
AVAHI_GCC_UNUSED AvahiProtocol protocol,
|
||||||
AvahiResolverEvent event,
|
AvahiResolverEvent event,
|
||||||
|
|||||||
@@ -2,18 +2,20 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <libsoup/soup.h>
|
#include <libsoup/soup.h>
|
||||||
#include "teleport-app.h"
|
#include "teleport-app.h"
|
||||||
#include "teleport-get.h"
|
#include "teleport-get.h"
|
||||||
|
|
||||||
|
static int saveFile (SoupMessage *, const gchar *, const gchar *);
|
||||||
|
static gchar * getFilePath (const gchar *, const gchar *);
|
||||||
|
static int get (const gchar *, const gchar *, const gchar *, const gchar *);
|
||||||
|
|
||||||
static gboolean debug;
|
static gboolean debug;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
finished (SoupSession *session, SoupMessage *msg, gpointer target)
|
finished (SoupSession *session,
|
||||||
|
SoupMessage *msg,
|
||||||
|
gpointer target)
|
||||||
{
|
{
|
||||||
//GVariant *target array: {originDevice, url, filename, downloadDirectory}
|
//GVariant *target array: {originDevice, url, filename, downloadDirectory}
|
||||||
if ((char *) g_variant_get_string (
|
if ((char *) g_variant_get_string (
|
||||||
@@ -33,8 +35,8 @@ finished (SoupSession *session, SoupMessage *msg, gpointer target)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
get (char *url,
|
get (const gchar *url,
|
||||||
const gchar *originDevice,
|
const gchar *originDevice,
|
||||||
const gchar *downloadDirectory,
|
const gchar *downloadDirectory,
|
||||||
const gchar *outputFilename) {
|
const gchar *outputFilename) {
|
||||||
@@ -48,9 +50,12 @@ get (char *url,
|
|||||||
}
|
}
|
||||||
|
|
||||||
session = g_object_new (SOUP_TYPE_SESSION,
|
session = g_object_new (SOUP_TYPE_SESSION,
|
||||||
SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_CONTENT_DECODER,
|
SOUP_SESSION_ADD_FEATURE_BY_TYPE,
|
||||||
SOUP_SESSION_USER_AGENT, "teleport ",
|
SOUP_TYPE_CONTENT_DECODER,
|
||||||
SOUP_SESSION_ACCEPT_LANGUAGE_AUTO, TRUE,
|
SOUP_SESSION_USER_AGENT,
|
||||||
|
"teleport ",
|
||||||
|
SOUP_SESSION_ACCEPT_LANGUAGE_AUTO,
|
||||||
|
TRUE,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
@@ -85,7 +90,7 @@ get (char *url,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
saveFile (SoupMessage *msg,
|
saveFile (SoupMessage *msg,
|
||||||
const gchar *outputDirectory,
|
const gchar *outputDirectory,
|
||||||
const gchar *outputFilename) {
|
const gchar *outputFilename) {
|
||||||
@@ -123,14 +128,8 @@ saveFile (SoupMessage *msg,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
do_client_notify (char *url) {
|
|
||||||
get (g_strdup(url), NULL, NULL, NULL);
|
|
||||||
g_print("Offering selected file to other machine.\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
gchar *
|
static gchar *
|
||||||
getFilePath (const gchar *outputDirectory,
|
getFilePath (const gchar *outputDirectory,
|
||||||
const gchar *outputFilename) {
|
const gchar *outputFilename) {
|
||||||
return g_strdup_printf("%s/%s", outputDirectory,
|
return g_strdup_printf("%s/%s", outputDirectory,
|
||||||
@@ -138,7 +137,14 @@ getFilePath (const gchar *outputDirectory,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
do_downloading (const char *originDevice,
|
teleport_get_do_client_notify (const gchar *url) {
|
||||||
|
get (g_strdup(url), NULL, NULL, NULL);
|
||||||
|
g_print("Offering selected file to other machine.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
teleport_get_do_downloading (const char *originDevice,
|
||||||
const char *url,
|
const char *url,
|
||||||
const char *filename) {
|
const char *filename) {
|
||||||
const gchar *outputDirectory = g_get_user_special_dir(G_USER_DIRECTORY_DOWNLOAD);
|
const gchar *outputDirectory = g_get_user_special_dir(G_USER_DIRECTORY_DOWNLOAD);
|
||||||
|
|||||||
@@ -3,11 +3,9 @@
|
|||||||
|
|
||||||
#include <libsoup/soup.h>
|
#include <libsoup/soup.h>
|
||||||
|
|
||||||
extern int do_downloading(const char *, const char *, const char *);
|
int teleport_get_do_downloading (const gchar *,
|
||||||
extern int do_client_notify(char *);
|
const gchar *,
|
||||||
|
const gchar *);
|
||||||
int saveFile (SoupMessage *, const gchar *, const gchar *);
|
int teleport_get_do_client_notify (const gchar *);
|
||||||
gchar * getFilePath (const gchar *, const gchar *);
|
|
||||||
int get (char *, const gchar *, const gchar *, const gchar *);
|
|
||||||
|
|
||||||
#endif /* __TELEPORT_GET_H */
|
#endif /* __TELEPORT_GET_H */
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ static int port;
|
|||||||
static SoupServer *glob_server;
|
static SoupServer *glob_server;
|
||||||
//static const char *tls_cert_file, *tls_key_file;
|
//static const char *tls_cert_file, *tls_key_file;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
compare_strings (gconstpointer a, gconstpointer b)
|
compare_strings (gconstpointer a, gconstpointer b)
|
||||||
{
|
{
|
||||||
const char **sa = (const char **)a;
|
const char **sa = (const char **)a;
|
||||||
@@ -24,7 +24,7 @@ compare_strings (gconstpointer a, gconstpointer b)
|
|||||||
return strcmp (*sa, *sb);
|
return strcmp (*sa, *sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GString *
|
static GString *
|
||||||
get_directory_listing (const char *path)
|
get_directory_listing (const char *path)
|
||||||
{
|
{
|
||||||
GPtrArray *entries;
|
GPtrArray *entries;
|
||||||
@@ -67,7 +67,7 @@ get_directory_listing (const char *path)
|
|||||||
return listing;
|
return listing;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_get (SoupServer *server, SoupMessage *msg, const char *path)
|
do_get (SoupServer *server, SoupMessage *msg, const char *path)
|
||||||
{
|
{
|
||||||
char *slash;
|
char *slash;
|
||||||
@@ -169,7 +169,7 @@ static void handle_incoming_file(const char *hash, const char *filename, const i
|
|||||||
create_user_notification(filename, size, origin, value);
|
create_user_notification(filename, size, origin, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
server_callback (SoupServer *server, SoupMessage *msg,
|
server_callback (SoupServer *server, SoupMessage *msg,
|
||||||
const char *path, GHashTable *query,
|
const char *path, GHashTable *query,
|
||||||
SoupClientContext *context, gpointer data)
|
SoupClientContext *context, gpointer data)
|
||||||
@@ -252,7 +252,7 @@ int addRouteToServer(char *name, char *file_to_send, char *destination) {
|
|||||||
file = g_file_new_for_path(file_to_send);
|
file = g_file_new_for_path(file_to_send);
|
||||||
//G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, G_FILE_ATTRIBUTE_STANDARD_SIZE
|
//G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, G_FILE_ATTRIBUTE_STANDARD_SIZE
|
||||||
fileInfo = g_file_query_info(file, "standard::display-name,standard::size", G_FILE_QUERY_INFO_NONE, NULL, NULL);
|
fileInfo = g_file_query_info(file, "standard::display-name,standard::size", G_FILE_QUERY_INFO_NONE, NULL, NULL);
|
||||||
do_client_notify(g_strdup_printf("http://%s:%d/?token=%s&size=%jd&name=%s\n",
|
teleport_get_do_client_notify(g_strdup_printf("http://%s:%d/?token=%s&size=%jd&name=%s\n",
|
||||||
destination,
|
destination,
|
||||||
port,
|
port,
|
||||||
name,
|
name,
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ struct _TeleportAppWindowPrivate
|
|||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE(TeleportAppWindow, teleport_app_window, GTK_TYPE_APPLICATION_WINDOW);
|
G_DEFINE_TYPE_WITH_PRIVATE(TeleportAppWindow, teleport_app_window, GTK_TYPE_APPLICATION_WINDOW);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
teleport_app_window_init (TeleportAppWindow *win)
|
teleport_app_window_init (TeleportAppWindow *win)
|
||||||
{
|
{
|
||||||
TeleportAppWindowPrivate *priv;
|
TeleportAppWindowPrivate *priv;
|
||||||
@@ -140,7 +140,7 @@ void update_remote_device_list_remove(TeleportAppWindow *win, Peer *device) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
find_child(GtkWidget *parent, const gchar *name)
|
find_child(GtkWidget *parent, const gchar *name)
|
||||||
{
|
{
|
||||||
if (g_strcmp0(gtk_widget_get_name((GtkWidget *)parent), (gchar *)name) == 0) {
|
if (g_strcmp0(gtk_widget_get_name((GtkWidget *)parent), (gchar *)name) == 0) {
|
||||||
@@ -166,7 +166,7 @@ find_child(GtkWidget *parent, const gchar *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
teleport_app_window_dispose (GObject *object)
|
teleport_app_window_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
//TeleportAppWindow *win;
|
//TeleportAppWindow *win;
|
||||||
@@ -180,7 +180,7 @@ teleport_app_window_dispose (GObject *object)
|
|||||||
G_OBJECT_CLASS (teleport_app_window_parent_class)->dispose (object);
|
G_OBJECT_CLASS (teleport_app_window_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
teleport_app_window_class_init (TeleportAppWindowClass *class)
|
teleport_app_window_class_init (TeleportAppWindowClass *class)
|
||||||
{
|
{
|
||||||
G_OBJECT_CLASS (class)->dispose = teleport_app_window_dispose;
|
G_OBJECT_CLASS (class)->dispose = teleport_app_window_dispose;
|
||||||
@@ -194,13 +194,13 @@ teleport_app_window_class_init (TeleportAppWindowClass *class)
|
|||||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), TeleportAppWindow, remote_devices_list);
|
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), TeleportAppWindow, remote_devices_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
TeleportAppWindow *
|
TeleportAppWindow *
|
||||||
teleport_app_window_new (TeleportApp *app)
|
teleport_app_window_new (TeleportApp *app)
|
||||||
{
|
{
|
||||||
return g_object_new (TELEPORT_APP_WINDOW_TYPE, "application", app, NULL);
|
return g_object_new (TELEPORT_APP_WINDOW_TYPE, "application", app, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
teleport_app_window_open (TeleportAppWindow *win,
|
teleport_app_window_open (TeleportAppWindow *win,
|
||||||
GFile *file)
|
GFile *file)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user