aboutsummaryrefslogtreecommitdiff
path: root/src/chat.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/chat.c')
-rw-r--r--src/chat.c45
1 files changed, 30 insertions, 15 deletions
diff --git a/src/chat.c b/src/chat.c
index 4645c6b..82fd43f 100644
--- a/src/chat.c
+++ b/src/chat.c
@@ -34,15 +34,19 @@ _chat_refresh(MESSENGER_Application *app)
34 ); 34 );
35 35
36 app->accounts.window = NULL; 36 app->accounts.window = NULL;
37 app->chats.window = NULL;
37 app->messages.window = NULL; 38 app->messages.window = NULL;
38 39
39 if (!account) 40 if (!account)
40 app->accounts.window = stdscr; 41 app->accounts.window = stdscr;
41 else if (app->chat.context) 42 else if (app->chat.context)
42 app->messages.window = stdscr; 43 app->messages.window = stdscr;
44 else
45 app->chats.window = stdscr;
43 46
44 accounts_print(&(app->accounts), app); 47 accounts_print(&(app->accounts), app);
45 messages_print(&(app->messages), app); 48 chats_print(&(app->chats), app);
49 messages_print(&(app->messages));
46} 50}
47 51
48static int 52static int
@@ -56,36 +60,43 @@ _chat_event(MESSENGER_Application *app,
56 app->chat.handle 60 app->chat.handle
57 ); 61 );
58 62
59 if ('q' == key)
60 return 1;
61
62 if (!account) 63 if (!account)
63 accounts_event(&(app->accounts), app, key); 64 accounts_event(&(app->accounts), app, key);
64 else if (app->chat.context) 65 else if (app->chat.context)
65 messages_event(&(app->messages), app, key); 66 messages_event(&(app->messages), app, key);
66 else 67 else
67 { 68 chats_event(&(app->chats), app, key);
68 struct GNUNET_CHAT_Group *test = GNUNET_CHAT_group_create(
69 app->chat.handle,
70 "test"
71 );
72 69
73 app->chat.context = GNUNET_CHAT_group_get_context(test); 70 if (GNUNET_YES == app->chat.quit)
74 } 71 return 1;
75 72
76refresh: 73refresh:
77 _chat_refresh(app); 74 _chat_refresh(app);
78 return 0; 75 return 0;
79} 76}
80 77
81int lc = 0;
82
83static int 78static int
84_chat_message(void *cls, 79_chat_message(void *cls,
85 UNUSED struct GNUNET_CHAT_Context *context, 80 struct GNUNET_CHAT_Context *context,
86 UNUSED const struct GNUNET_CHAT_Message *message) 81 const struct GNUNET_CHAT_Message *message)
87{ 82{
88 MESSENGER_Application *app = cls; 83 MESSENGER_Application *app = cls;
84
85 UI_MESSAGES_Handle *messages = (UI_MESSAGES_Handle*) (
86 GNUNET_CHAT_context_get_user_pointer(context)
87 );
88
89 if (messages)
90 {
91 if (GNUNET_CHAT_KIND_DELETION == GNUNET_CHAT_message_get_kind(message))
92 messages_remove(
93 &(app->messages),
94 GNUNET_CHAT_message_get_target(message)
95 );
96
97 messages_add(&(app->messages), message);
98 }
99
89 _chat_event(app, KEY_RESIZE); 100 _chat_event(app, KEY_RESIZE);
90 return GNUNET_YES; 101 return GNUNET_YES;
91} 102}
@@ -130,6 +141,8 @@ chat_start(MESSENGER_Chat *chat,
130 &_chat_idle, 141 &_chat_idle,
131 app 142 app
132 ); 143 );
144
145 chat->quit = GNUNET_NO;
133} 146}
134 147
135void 148void
@@ -143,4 +156,6 @@ chat_stop(MESSENGER_Chat *chat)
143 156
144 GNUNET_CHAT_stop(chat->handle); 157 GNUNET_CHAT_stop(chat->handle);
145 chat->handle = NULL; 158 chat->handle = NULL;
159
160 chat->quit = GNUNET_YES;
146} 161}