diff options
author | xengineering <me@xengineering.eu> | 2022-08-20 17:52:16 +0200 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2022-08-20 17:52:16 +0200 |
commit | 4e61f83b432350303aee5635e98d3bc147e8fffa (patch) | |
tree | 4ac40e73bbdc648b4cafefd4917df6cd6d1a5983 | |
parent | b661cc4bde4004f4d7085716680969f4659222a1 (diff) | |
download | limox-4e61f83b432350303aee5635e98d3bc147e8fffa.tar limox-4e61f83b432350303aee5635e98d3bc147e8fffa.tar.zst limox-4e61f83b432350303aee5635e98d3bc147e8fffa.zip |
Rename limox.{c,h} to net.{c,h}
-rw-r--r-- | gtk.c | 10 | ||||
-rw-r--r-- | gui.h | 3 | ||||
-rw-r--r-- | limox.h | 13 | ||||
-rw-r--r-- | main.c | 4 | ||||
-rw-r--r-- | meson.build | 2 | ||||
-rw-r--r-- | net.c (renamed from limox.c) | 30 | ||||
-rw-r--r-- | net.h | 13 |
7 files changed, 36 insertions, 39 deletions
@@ -3,7 +3,7 @@ #include <gtk/gtk.h> #include <stdio.h> -#include "limox.h" +#include "net.h" #include "data.h" @@ -32,7 +32,7 @@ static GtkWidget* roster_button; static void quit_cb(void) { - limox_quit(); + net_quit(); g_application_quit(G_APPLICATION(app)); } @@ -46,7 +46,7 @@ static void connect_cb(void) { // just dummy output printf("Connecting with:\nJID: %s\nPWD: %s\n", jid_text, pwd_text); - limox_connect(jid_text, pwd_text); + net_connect(jid_text, pwd_text); } static void disconnect_cb(void) { @@ -56,7 +56,7 @@ static void disconnect_cb(void) { // just dummy output printf("Disconnected!\n"); - limox_disconnect(); + net_disconnect(); } void send_message() { @@ -131,7 +131,7 @@ static void activate(void) { static void idle_cb(void) { - limox_run_once(); + net_run_once(); } @@ -3,10 +3,7 @@ #include "data.h" -// interface for main.c void gui_run(void); - -// interface for limox.c void gui_connected(char* jid, char* password); void gui_disconnected(void); void gui_suspended(void); diff --git a/limox.h b/limox.h deleted file mode 100644 index 4f2d8c1..0000000 --- a/limox.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef LIMOX_H -#define LIMOX_H - -// life cycle / event loop related functions -void limox_init(void); // initialize limox -void limox_run_once(void); // process event loop for a short amount of time -void limox_quit(void); // disconnect and clean up - -// interface for the GUI implementation -void limox_connect(const char* jid, const char* password); -void limox_disconnect(void); - -#endif @@ -5,7 +5,7 @@ #include <unistd.h> #include "gui.h" -#include "limox.h" +#include "net.h" // error code definition @@ -38,7 +38,7 @@ int main(int argc, char* argv[]) { if (opts.unknown || opts.help) { print_help(); } else { - limox_init(); + net_init(); gui_run(); } diff --git a/meson.build b/meson.build index a16a3c0..9bd034a 100644 --- a/meson.build +++ b/meson.build @@ -1,4 +1,4 @@ project('LimoX', 'c') gtkdep = dependency('gtk4') strophedep = dependency('libstrophe') -executable('limox', ['main.c', 'gtk.c', 'limox.c', 'data.c'], dependencies : [gtkdep, strophedep]) +executable('limox', ['main.c', 'gtk.c', 'net.c', 'data.c'], dependencies : [gtkdep, strophedep]) @@ -10,22 +10,22 @@ #include <strophe.h> #include <gui.h> -#include <limox.h> +#include <net.h> #include <data.h> -// the state of limox +// the state of net typedef enum { DISCONNECTED, // initial state CONNECTING, // connection was requested but is not yet established CONNECTED, // there is an active XMPP connetion to the server SUSPENDED // not connected, but there is an open XMPP stream to be // reconnected (see XEP-0198 for details) -} limox_state_t; +} net_state_t; // these variables stay initialized for the whole runtime -static limox_state_t state; +static net_state_t state; static xmpp_log_t* log; static xmpp_ctx_t* ctx; @@ -122,9 +122,9 @@ static void conn_handler(xmpp_conn_t *conn, xmpp_conn_event_t status,int error, } } -void limox_init(void) { +void net_init(void) { - printf("limox_init()\n"); + printf("net_init()\n"); xmpp_initialize(); log = xmpp_get_default_logger(XMPP_LEVEL_DEBUG); // or NULL for silence @@ -141,14 +141,14 @@ static void delay(unsigned long int micros) { } -void limox_run_once(void) { +void net_run_once(void) { if (state == CONNECTING) { if (xmpp_connect_client(conn, NULL, 0, conn_handler, NULL) == XMPP_EOK) { state = CONNECTED; } else { - limox_disconnect(); + net_disconnect(); } } @@ -162,11 +162,11 @@ void limox_run_once(void) { } -void limox_quit(void) { +void net_quit(void) { - printf("limox_quit()\n"); + printf("net_quit()\n"); - limox_disconnect(); + net_disconnect(); // TODO is it possible to free xmpp_log_t ? log = NULL; xmpp_ctx_free(ctx); @@ -174,9 +174,9 @@ void limox_quit(void) { } -void limox_connect(const char* jid, const char* password) { +void net_connect(const char* jid, const char* password) { - printf("limox_connect()\n"); + printf("net_connect()\n"); conn = xmpp_conn_new(ctx); @@ -191,9 +191,9 @@ void limox_connect(const char* jid, const char* password) { } -void limox_disconnect(void) { +void net_disconnect(void) { - printf("limox_disconnect()\n"); + printf("net_disconnect()\n"); if (sm_state) { xmpp_free_sm_state(sm_state); @@ -0,0 +1,13 @@ +#ifndef NET_H +#define NET_H + +// life cycle / event loop related functions +void net_init(void); // initialize net +void net_run_once(void); // process event loop for a short amount of time +void net_quit(void); // disconnect and clean up + +// interface for the GUI implementation +void net_connect(const char* jid, const char* password); +void net_disconnect(void); + +#endif |