diff --git a/src/common.c b/src/common.c index 98466231..035a0505 100644 --- a/src/common.c +++ b/src/common.c @@ -285,7 +285,7 @@ utf8_display_len(const char *const str) } char* -prof_getline(FILE *stream) +file_getline(FILE *stream) { char *buf; char *result; @@ -380,75 +380,6 @@ release_is_new(char *found_version) } } -gboolean -valid_resource_presence_string(const char *const str) -{ - assert(str != NULL); - if ((strcmp(str, "online") == 0) || (strcmp(str, "chat") == 0) || - (strcmp(str, "away") == 0) || (strcmp(str, "xa") == 0) || - (strcmp(str, "dnd") == 0)) { - return TRUE; - } else { - return FALSE; - } -} - -const char* -string_from_resource_presence(resource_presence_t presence) -{ - switch(presence) - { - case RESOURCE_CHAT: - return "chat"; - case RESOURCE_AWAY: - return "away"; - case RESOURCE_XA: - return "xa"; - case RESOURCE_DND: - return "dnd"; - default: - return "online"; - } -} - -resource_presence_t -resource_presence_from_string(const char *const str) -{ - if (str == NULL) { - return RESOURCE_ONLINE; - } else if (strcmp(str, "online") == 0) { - return RESOURCE_ONLINE; - } else if (strcmp(str, "chat") == 0) { - return RESOURCE_CHAT; - } else if (strcmp(str, "away") == 0) { - return RESOURCE_AWAY; - } else if (strcmp(str, "xa") == 0) { - return RESOURCE_XA; - } else if (strcmp(str, "dnd") == 0) { - return RESOURCE_DND; - } else { - return RESOURCE_ONLINE; - } -} - -contact_presence_t -contact_presence_from_resource_presence(resource_presence_t resource_presence) -{ - switch(resource_presence) - { - case RESOURCE_CHAT: - return CONTACT_CHAT; - case RESOURCE_AWAY: - return CONTACT_AWAY; - case RESOURCE_XA: - return CONTACT_XA; - case RESOURCE_DND: - return CONTACT_DND; - default: - return CONTACT_ONLINE; - } -} - char* create_unique_id(char *prefix) { diff --git a/src/common.h b/src/common.h index 678a12ff..9d8c99a7 100644 --- a/src/common.h +++ b/src/common.h @@ -107,15 +107,10 @@ char* str_replace(const char *string, const char *substr, const char *replacemen int str_contains(const char str[], int size, char ch); gboolean strtoi_range(char *str, int *saveptr, int min, int max, char **err_msg); int utf8_display_len(const char *const str); -char* prof_getline(FILE *stream); +char* file_getline(FILE *stream); char* release_get_latest(void); gboolean release_is_new(char *found_version); -gboolean valid_resource_presence_string(const char *const str); -const char* string_from_resource_presence(resource_presence_t presence); -resource_presence_t resource_presence_from_string(const char *const str); -contact_presence_t contact_presence_from_resource_presence(resource_presence_t resource_presence); - char* p_sha1_hash(char *str); char* create_unique_id(char *prefix); void reset_unique_id(void); diff --git a/src/config/account.c b/src/config/account.c index 879759f5..3e8c8cf1 100644 --- a/src/config/account.c +++ b/src/config/account.c @@ -42,6 +42,7 @@ #include "log.h" #include "config/account.h" #include "xmpp/jid.h" +#include "xmpp/resource.h" ProfAccount* account_new(const gchar *const name, const gchar *const jid, diff --git a/src/log.c b/src/log.c index e0a50055..7fcef45f 100644 --- a/src/log.c +++ b/src/log.c @@ -472,7 +472,7 @@ chat_log_get_previous(const gchar *const login, const gchar *const recipient) g_string_free(header, FALSE); char *line; - while ((line = prof_getline(logp)) != NULL) { + while ((line = file_getline(logp)) != NULL) { history = g_slist_append(history, line); } diff --git a/src/xmpp/resource.c b/src/xmpp/resource.c index 6e6bc5f0..2309883c 100644 --- a/src/xmpp/resource.c +++ b/src/xmpp/resource.c @@ -95,3 +95,72 @@ resource_destroy(Resource *resource) free(resource); } } + +gboolean +valid_resource_presence_string(const char *const str) +{ + assert(str != NULL); + if ((strcmp(str, "online") == 0) || (strcmp(str, "chat") == 0) || + (strcmp(str, "away") == 0) || (strcmp(str, "xa") == 0) || + (strcmp(str, "dnd") == 0)) { + return TRUE; + } else { + return FALSE; + } +} + +const char* +string_from_resource_presence(resource_presence_t presence) +{ + switch(presence) + { + case RESOURCE_CHAT: + return "chat"; + case RESOURCE_AWAY: + return "away"; + case RESOURCE_XA: + return "xa"; + case RESOURCE_DND: + return "dnd"; + default: + return "online"; + } +} + +resource_presence_t +resource_presence_from_string(const char *const str) +{ + if (str == NULL) { + return RESOURCE_ONLINE; + } else if (strcmp(str, "online") == 0) { + return RESOURCE_ONLINE; + } else if (strcmp(str, "chat") == 0) { + return RESOURCE_CHAT; + } else if (strcmp(str, "away") == 0) { + return RESOURCE_AWAY; + } else if (strcmp(str, "xa") == 0) { + return RESOURCE_XA; + } else if (strcmp(str, "dnd") == 0) { + return RESOURCE_DND; + } else { + return RESOURCE_ONLINE; + } +} + +contact_presence_t +contact_presence_from_resource_presence(resource_presence_t resource_presence) +{ + switch(resource_presence) + { + case RESOURCE_CHAT: + return CONTACT_CHAT; + case RESOURCE_AWAY: + return CONTACT_AWAY; + case RESOURCE_XA: + return CONTACT_XA; + case RESOURCE_DND: + return CONTACT_DND; + default: + return CONTACT_ONLINE; + } +} diff --git a/src/xmpp/resource.h b/src/xmpp/resource.h index 22681013..ec22569a 100644 --- a/src/xmpp/resource.h +++ b/src/xmpp/resource.h @@ -49,4 +49,9 @@ Resource* resource_new(const char *const name, resource_presence_t presence, con void resource_destroy(Resource *resource); int resource_compare_availability(Resource *first, Resource *second); +gboolean valid_resource_presence_string(const char *const str); +const char* string_from_resource_presence(resource_presence_t presence); +resource_presence_t resource_presence_from_string(const char *const str); +contact_presence_t contact_presence_from_resource_presence(resource_presence_t resource_presence); + #endif