From 63e8c7f9d095fe0b1e0b44f950230c0e238f166d Mon Sep 17 00:00:00 2001 From: nirav Date: Sun, 10 Mar 2019 23:45:19 +0530 Subject: Add config and log --- src/main.c | 49 ++++++++++++------------------------------------- 1 file changed, 12 insertions(+), 37 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 45ea3cd..bf23496 100644 --- a/src/main.c +++ b/src/main.c @@ -8,23 +8,28 @@ #include "http.h" #include "timeline.h" #include "login_window.h" - +#include "config.h" +#include "timeline_window.h" +#include "log.h" static void activate(GtkApplication *app, gpointer user_data) { - create_login_window(app, user_data); + if (read_local_credentials()) { + create_login_window(app, user_data); + return; + } + create_timeline_window(app, NULL); } int main(int argc, char **argv) { - /* gtk_init(&argc, &argv); */ - /* create_main_window(); */ - /* gtk_main(); */ if (http_init()) { - fprintf(stderr, "main(): failed to load http library\n"); + log_msg(LOG_ERROR, "main", "failed to load http library"); return EXIT_FAILURE; } + config_load(); + GtkApplication *app; int status; @@ -34,37 +39,7 @@ int main(int argc, char **argv) g_object_unref(app); http_cleanup(); - auth_cleanup(); + config_cleanup(); return status; - - /* char *text; */ - /* struct timeline *t; */ - /* char *url = "https://mstdn.io/api/v1/timelines/home"; */ - /* char *token = */ - /* "580acfb412e927c2030fb5519f417b03ced1482c862d44376922cd81ee8a3655"; - */ - - /* text = request(url, token); */ - /* if (!text) { */ - /* fprintf(stderr, "main(): failed to get http response\n"); */ - /* return EXIT_FAILURE; */ - /* } */ - - /* t = timeline_from_json(text); */ - /* if (t == NULL) { */ - /* fprintf(stderr, "main(): failed to parse timeline\n"); */ - /* return EXIT_FAILURE; */ - /* } */ - - /* for (size_t i = 0; i < t->size; i++) { */ - /* printf("status id: %s\n", t->statuses[i]->id); */ - /* printf("content: %s\n", t->statuses[i]->content); */ - /* printf("reblog count: %d\n", t->statuses[i]->reblogs_count); */ - /* printf("fav count: %d\n", t->statuses[i]->favourites_count); */ - /* printf("\n"); */ - /* } */ - - /* free(text); */ - /* timeline_free(t); */ } -- cgit v1.2.3