about summary refs log tree commit diff stats
path: root/src/jabber.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/jabber.c')
-rw-r--r--src/jabber.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/src/jabber.c b/src/jabber.c
index d7809b03..8cd13310 100644
--- a/src/jabber.c
+++ b/src/jabber.c
@@ -1,8 +1,8 @@
-/* 
+/*
  * jabber.c
  *
  * Copyright (C) 2012 James Booth <boothj5@gmail.com>
- * 
+ *
  * This file is part of Profanity.
  *
  * Profanity is free software: you can redistribute it and/or modify
@@ -44,20 +44,20 @@ static struct _jabber_conn_t {
 
 static log_level_t _get_log_level(xmpp_log_level_t xmpp_level);
 static xmpp_log_level_t _get_xmpp_log_level();
-static void _xmpp_file_logger(void * const userdata, 
-    const xmpp_log_level_t level, const char * const area, 
+static void _xmpp_file_logger(void * const userdata,
+    const xmpp_log_level_t level, const char * const area,
     const char * const msg);
 static xmpp_log_t * _xmpp_get_file_logger();
 
 // XMPP event handlers
-static void _connection_handler(xmpp_conn_t * const conn, 
-    const xmpp_conn_event_t status, const int error, 
+static void _connection_handler(xmpp_conn_t * const conn,
+    const xmpp_conn_event_t status, const int error,
     xmpp_stream_error_t * const stream_error, void * const userdata);
-static int _message_handler(xmpp_conn_t * const conn, 
+static int _message_handler(xmpp_conn_t * const conn,
     xmpp_stanza_t * const stanza, void * const userdata);
-static int _roster_handler(xmpp_conn_t * const conn, 
+static int _roster_handler(xmpp_conn_t * const conn,
     xmpp_stanza_t * const stanza, void * const userdata);
-static int _presence_handler(xmpp_conn_t * const conn, 
+static int _presence_handler(xmpp_conn_t * const conn,
     xmpp_stanza_t * const stanza, void * const userdata);
 static int _ping_timed_handler(xmpp_conn_t * const conn, void * const userdata);
 
@@ -71,7 +71,7 @@ jabber_init(const int disable_tls)
 }
 
 jabber_conn_status_t
-jabber_connect(const char * const user, 
+jabber_connect(const char * const user,
     const char * const passwd)
 {
     log_info("Connecting as %s", user);
@@ -87,12 +87,12 @@ jabber_connect(const char * const user,
     if (jabber_conn.tls_disabled)
         xmpp_conn_disable_tls(jabber_conn.conn);
 
-    int connect_status = xmpp_connect_client(jabber_conn.conn, NULL, 0, 
+    int connect_status = xmpp_connect_client(jabber_conn.conn, NULL, 0,
         _connection_handler, jabber_conn.ctx);
 
     if (connect_status == 0)
         jabber_conn.conn_status = JABBER_CONNECTING;
-    else  
+    else
         jabber_conn.conn_status = JABBER_DISCONNECTED;
 
     return jabber_conn.conn_status;
@@ -122,7 +122,7 @@ jabber_disconnect(void)
 void
 jabber_process_events(void)
 {
-    if (jabber_conn.conn_status == JABBER_CONNECTED 
+    if (jabber_conn.conn_status == JABBER_CONNECTED
             || jabber_conn.conn_status == JABBER_CONNECTING
             || jabber_conn.conn_status == JABBER_DISCONNECTING)
         xmpp_run_once(jabber_conn.ctx, 10);
@@ -136,7 +136,7 @@ jabber_send(const char * const msg, const char * const recipient)
     char *coded_msg3 = str_replace(coded_msg2, ">", "&gt;");
 
     xmpp_stanza_t *reply, *body, *text, *active;
-    
+
     active = xmpp_stanza_new(jabber_conn.ctx);
     xmpp_stanza_set_name(active, "active");
     xmpp_stanza_set_ns(active, "http://jabber.org/protocol/chatstates");
@@ -191,7 +191,7 @@ jabber_update_presence(jabber_presence_t status, const char * const msg)
 
     pres = xmpp_stanza_new(jabber_conn.ctx);
     xmpp_stanza_set_name(pres, "presence");
-    
+
     if (status != PRESENCE_ONLINE) {
         show = xmpp_stanza_new(jabber_conn.ctx);
         xmpp_stanza_set_name(show, "show");
@@ -205,7 +205,7 @@ jabber_update_presence(jabber_presence_t status, const char * const msg)
             xmpp_stanza_set_text(text, "chat");
         else if (status == PRESENCE_XA)
             xmpp_stanza_set_text(text, "xa");
-        else 
+        else
             xmpp_stanza_set_text(text, "online");
 
         xmpp_stanza_add_child(show, text);
@@ -252,7 +252,7 @@ jabber_free_resources(void)
 }
 
 static int
-_message_handler(xmpp_conn_t * const conn, 
+_message_handler(xmpp_conn_t * const conn,
     xmpp_stanza_t * const stanza, void * const userdata)
 {
     char *type;
@@ -294,7 +294,7 @@ _message_handler(xmpp_conn_t * const conn,
                 prof_handle_typing(from);
             }
         }
-        
+
         return 1;
     }
 
@@ -306,15 +306,15 @@ _message_handler(xmpp_conn_t * const conn,
 }
 
 static void
-_connection_handler(xmpp_conn_t * const conn, 
-    const xmpp_conn_event_t status, const int error, 
+_connection_handler(xmpp_conn_t * const conn,
+    const xmpp_conn_event_t status, const int error,
     xmpp_stream_error_t * const stream_error, void * const userdata)
 {
     xmpp_ctx_t *ctx = (xmpp_ctx_t *)userdata;
 
     if (status == XMPP_CONN_CONNECT) {
         const char *jid = xmpp_conn_get_jid(conn);
-        prof_handle_login_success(jid);    
+        prof_handle_login_success(jid);
 
         xmpp_stanza_t* pres;
         xmpp_handler_add(conn, _message_handler, NULL, "message", NULL, ctx);
@@ -331,15 +331,15 @@ _connection_handler(xmpp_conn_t * const conn,
         jabber_conn.presence = PRESENCE_ONLINE;
         jabber_roster_request();
     } else {
-    
+
         // received close stream response from server after disconnect
         if (jabber_conn.conn_status == JABBER_DISCONNECTING) {
             jabber_conn.conn_status = JABBER_DISCONNECTED;
             jabber_conn.presence = PRESENCE_OFFLINE;
-            
+
         // lost connection for unkown reason
         } else if (jabber_conn.conn_status == JABBER_CONNECTED) {
-            prof_handle_lost_connection();    
+            prof_handle_lost_connection();
             xmpp_stop(ctx);
             jabber_conn.conn_status = JABBER_DISCONNECTED;
             jabber_conn.presence = PRESENCE_OFFLINE;
@@ -355,19 +355,19 @@ _connection_handler(xmpp_conn_t * const conn,
 }
 
 static int
-_roster_handler(xmpp_conn_t * const conn, 
+_roster_handler(xmpp_conn_t * const conn,
     xmpp_stanza_t * const stanza, void * const userdata)
 {
     xmpp_stanza_t *query, *item;
     char *type = xmpp_stanza_get_type(stanza);
-    
+
     if (strcmp(type, "error") == 0)
         log_error("Roster query failed");
     else {
         query = xmpp_stanza_get_child_by_name(stanza, "query");
         GSList *roster = NULL;
         item = xmpp_stanza_get_children(query);
-        
+
         while (item != NULL) {
             const char *name = xmpp_stanza_get_attribute(item, "name");
             const char *jid = xmpp_stanza_get_attribute(item, "jid");
@@ -387,7 +387,7 @@ _roster_handler(xmpp_conn_t * const conn,
 
         prof_handle_roster(roster);
     }
-    
+
     return 1;
 }
 
@@ -396,7 +396,7 @@ _ping_timed_handler(xmpp_conn_t * const conn, void * const userdata)
 {
     if (jabber_conn.conn_status == JABBER_CONNECTED) {
         xmpp_ctx_t *ctx = (xmpp_ctx_t *)userdata;
-        
+
         xmpp_stanza_t *iq, *ping;
 
         iq = xmpp_stanza_new(ctx);
@@ -419,20 +419,20 @@ _ping_timed_handler(xmpp_conn_t * const conn, void * const userdata)
 }
 
 static int
-_presence_handler(xmpp_conn_t * const conn, 
+_presence_handler(xmpp_conn_t * const conn,
     xmpp_stanza_t * const stanza, void * const userdata)
 {
     const char *jid = xmpp_conn_get_jid(jabber_conn.conn);
     char jid_cpy[strlen(jid) + 1];
     strcpy(jid_cpy, jid);
     char *short_jid = strtok(jid_cpy, "/");
-    
+
     char *from = xmpp_stanza_get_attribute(stanza, "from");
     char *short_from = strtok(from, "/");
     char *type = xmpp_stanza_get_attribute(stanza, "type");
 
     char *show_str, *status_str;
-   
+
     xmpp_stanza_t *show = xmpp_stanza_get_child_by_name(stanza, "show");
     if (show != NULL)
         show_str = xmpp_stanza_get_text(show);
@@ -440,9 +440,9 @@ _presence_handler(xmpp_conn_t * const conn,
         show_str = NULL;
 
     xmpp_stanza_t *status = xmpp_stanza_get_child_by_name(stanza, "status");
-    if (status != NULL)    
+    if (status != NULL)
         status_str = xmpp_stanza_get_text(status);
-    else 
+    else
         status_str = NULL;
 
     if (strcmp(short_jid, short_from) !=0) {