mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Changed ChatSession typedef
This commit is contained in:
parent
60de515b2b
commit
0f7519663d
@ -45,7 +45,6 @@
|
|||||||
#define PAUSED_TIMOUT 10.0
|
#define PAUSED_TIMOUT 10.0
|
||||||
#define INACTIVE_TIMOUT 30.0
|
#define INACTIVE_TIMOUT 30.0
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CHAT_STATE_STARTED,
|
CHAT_STATE_STARTED,
|
||||||
CHAT_STATE_ACTIVE,
|
CHAT_STATE_ACTIVE,
|
||||||
@ -55,19 +54,18 @@ typedef enum {
|
|||||||
CHAT_STATE_GONE
|
CHAT_STATE_GONE
|
||||||
} chat_state_t;
|
} chat_state_t;
|
||||||
|
|
||||||
struct chat_session_t {
|
typedef struct chat_session_t {
|
||||||
char *recipient;
|
char *recipient;
|
||||||
|
char *resource;
|
||||||
gboolean recipient_supports;
|
gboolean recipient_supports;
|
||||||
chat_state_t state;
|
chat_state_t state;
|
||||||
GTimer *active_timer;
|
GTimer *active_timer;
|
||||||
gboolean sent;
|
gboolean sent;
|
||||||
};
|
} ChatSession;
|
||||||
|
|
||||||
typedef struct chat_session_t *ChatSession;
|
|
||||||
|
|
||||||
static GHashTable *sessions;
|
static GHashTable *sessions;
|
||||||
|
|
||||||
static void _chat_session_free(ChatSession session);
|
static void _chat_session_free(ChatSession *session);
|
||||||
|
|
||||||
void
|
void
|
||||||
chat_sessions_init(void)
|
chat_sessions_init(void)
|
||||||
@ -86,7 +84,7 @@ chat_sessions_clear(void)
|
|||||||
void
|
void
|
||||||
chat_session_start(const char * const recipient, gboolean recipient_supports)
|
chat_session_start(const char * const recipient, gboolean recipient_supports)
|
||||||
{
|
{
|
||||||
ChatSession new_session = malloc(sizeof(struct chat_session_t));
|
ChatSession *new_session = malloc(sizeof(struct chat_session_t));
|
||||||
new_session->recipient = strdup(recipient);
|
new_session->recipient = strdup(recipient);
|
||||||
new_session->recipient_supports = recipient_supports;
|
new_session->recipient_supports = recipient_supports;
|
||||||
new_session->state = CHAT_STATE_STARTED;
|
new_session->state = CHAT_STATE_STARTED;
|
||||||
@ -98,7 +96,7 @@ chat_session_start(const char * const recipient, gboolean recipient_supports)
|
|||||||
gboolean
|
gboolean
|
||||||
chat_session_exists(const char * const recipient)
|
chat_session_exists(const char * const recipient)
|
||||||
{
|
{
|
||||||
ChatSession session = g_hash_table_lookup(sessions, recipient);
|
ChatSession *session = g_hash_table_lookup(sessions, recipient);
|
||||||
|
|
||||||
if (session != NULL) {
|
if (session != NULL) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -110,7 +108,7 @@ chat_session_exists(const char * const recipient)
|
|||||||
void
|
void
|
||||||
chat_session_set_composing(const char * const recipient)
|
chat_session_set_composing(const char * const recipient)
|
||||||
{
|
{
|
||||||
ChatSession session = g_hash_table_lookup(sessions, recipient);
|
ChatSession *session = g_hash_table_lookup(sessions, recipient);
|
||||||
|
|
||||||
if (session != NULL) {
|
if (session != NULL) {
|
||||||
if (session->state != CHAT_STATE_COMPOSING) {
|
if (session->state != CHAT_STATE_COMPOSING) {
|
||||||
@ -124,7 +122,7 @@ chat_session_set_composing(const char * const recipient)
|
|||||||
void
|
void
|
||||||
chat_session_no_activity(const char * const recipient)
|
chat_session_no_activity(const char * const recipient)
|
||||||
{
|
{
|
||||||
ChatSession session = g_hash_table_lookup(sessions, recipient);
|
ChatSession *session = g_hash_table_lookup(sessions, recipient);
|
||||||
|
|
||||||
if (session != NULL) {
|
if (session != NULL) {
|
||||||
if (session->active_timer != NULL) {
|
if (session->active_timer != NULL) {
|
||||||
@ -156,7 +154,7 @@ chat_session_no_activity(const char * const recipient)
|
|||||||
void
|
void
|
||||||
chat_session_set_sent(const char * const recipient)
|
chat_session_set_sent(const char * const recipient)
|
||||||
{
|
{
|
||||||
ChatSession session = g_hash_table_lookup(sessions, recipient);
|
ChatSession *session = g_hash_table_lookup(sessions, recipient);
|
||||||
|
|
||||||
if (session != NULL) {
|
if (session != NULL) {
|
||||||
session->sent = TRUE;
|
session->sent = TRUE;
|
||||||
@ -166,7 +164,7 @@ chat_session_set_sent(const char * const recipient)
|
|||||||
gboolean
|
gboolean
|
||||||
chat_session_get_sent(const char * const recipient)
|
chat_session_get_sent(const char * const recipient)
|
||||||
{
|
{
|
||||||
ChatSession session = g_hash_table_lookup(sessions, recipient);
|
ChatSession *session = g_hash_table_lookup(sessions, recipient);
|
||||||
|
|
||||||
if (session == NULL) {
|
if (session == NULL) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -184,7 +182,7 @@ chat_session_end(const char * const recipient)
|
|||||||
gboolean
|
gboolean
|
||||||
chat_session_is_inactive(const char * const recipient)
|
chat_session_is_inactive(const char * const recipient)
|
||||||
{
|
{
|
||||||
ChatSession session = g_hash_table_lookup(sessions, recipient);
|
ChatSession *session = g_hash_table_lookup(sessions, recipient);
|
||||||
|
|
||||||
if (session == NULL) {
|
if (session == NULL) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -196,7 +194,7 @@ chat_session_is_inactive(const char * const recipient)
|
|||||||
void
|
void
|
||||||
chat_session_set_active(const char * const recipient)
|
chat_session_set_active(const char * const recipient)
|
||||||
{
|
{
|
||||||
ChatSession session = g_hash_table_lookup(sessions, recipient);
|
ChatSession *session = g_hash_table_lookup(sessions, recipient);
|
||||||
|
|
||||||
if (session != NULL) {
|
if (session != NULL) {
|
||||||
session->state = CHAT_STATE_ACTIVE;
|
session->state = CHAT_STATE_ACTIVE;
|
||||||
@ -208,7 +206,7 @@ chat_session_set_active(const char * const recipient)
|
|||||||
gboolean
|
gboolean
|
||||||
chat_session_is_paused(const char * const recipient)
|
chat_session_is_paused(const char * const recipient)
|
||||||
{
|
{
|
||||||
ChatSession session = g_hash_table_lookup(sessions, recipient);
|
ChatSession *session = g_hash_table_lookup(sessions, recipient);
|
||||||
|
|
||||||
if (session == NULL) {
|
if (session == NULL) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -220,7 +218,7 @@ chat_session_is_paused(const char * const recipient)
|
|||||||
gboolean
|
gboolean
|
||||||
chat_session_is_gone(const char * const recipient)
|
chat_session_is_gone(const char * const recipient)
|
||||||
{
|
{
|
||||||
ChatSession session = g_hash_table_lookup(sessions, recipient);
|
ChatSession *session = g_hash_table_lookup(sessions, recipient);
|
||||||
|
|
||||||
if (session == NULL) {
|
if (session == NULL) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -232,7 +230,7 @@ chat_session_is_gone(const char * const recipient)
|
|||||||
void
|
void
|
||||||
chat_session_set_gone(const char * const recipient)
|
chat_session_set_gone(const char * const recipient)
|
||||||
{
|
{
|
||||||
ChatSession session = g_hash_table_lookup(sessions, recipient);
|
ChatSession *session = g_hash_table_lookup(sessions, recipient);
|
||||||
|
|
||||||
if (session != NULL) {
|
if (session != NULL) {
|
||||||
session->state = CHAT_STATE_GONE;
|
session->state = CHAT_STATE_GONE;
|
||||||
@ -242,7 +240,7 @@ chat_session_set_gone(const char * const recipient)
|
|||||||
gboolean
|
gboolean
|
||||||
chat_session_get_recipient_supports(const char * const recipient)
|
chat_session_get_recipient_supports(const char * const recipient)
|
||||||
{
|
{
|
||||||
ChatSession session = g_hash_table_lookup(sessions, recipient);
|
ChatSession *session = g_hash_table_lookup(sessions, recipient);
|
||||||
|
|
||||||
if (session == NULL) {
|
if (session == NULL) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -255,7 +253,7 @@ void
|
|||||||
chat_session_set_recipient_supports(const char * const recipient,
|
chat_session_set_recipient_supports(const char * const recipient,
|
||||||
gboolean recipient_supports)
|
gboolean recipient_supports)
|
||||||
{
|
{
|
||||||
ChatSession session = g_hash_table_lookup(sessions, recipient);
|
ChatSession *session = g_hash_table_lookup(sessions, recipient);
|
||||||
|
|
||||||
if (session != NULL) {
|
if (session != NULL) {
|
||||||
session->recipient_supports = recipient_supports;
|
session->recipient_supports = recipient_supports;
|
||||||
@ -263,7 +261,7 @@ chat_session_set_recipient_supports(const char * const recipient,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_chat_session_free(ChatSession session)
|
_chat_session_free(ChatSession *session)
|
||||||
{
|
{
|
||||||
if (session != NULL) {
|
if (session != NULL) {
|
||||||
free(session->recipient);
|
free(session->recipient);
|
||||||
|
Loading…
Reference in New Issue
Block a user