diff options
Diffstat (limited to 'src/plugins/chat/chat.c')
-rw-r--r-- | src/plugins/chat/chat.c | 61 |
1 files changed, 40 insertions, 21 deletions
diff --git a/src/plugins/chat/chat.c b/src/plugins/chat/chat.c index ab935b7d..33af07fe 100644 --- a/src/plugins/chat/chat.c +++ b/src/plugins/chat/chat.c | |||
@@ -28,6 +28,21 @@ | |||
28 | 28 | ||
29 | #include "chat.h" | 29 | #include "chat.h" |
30 | 30 | ||
31 | struct GNUNET_CHAT_safe_write_struct | ||
32 | { | ||
33 | GtkWidget *chatWindow; | ||
34 | const char *message; | ||
35 | const GNUNET_HashCode *sender; | ||
36 | }; | ||
37 | |||
38 | struct GNUNET_CHAT_safe_nick_write_struct | ||
39 | { | ||
40 | GtkWidget *nickList; | ||
41 | const char *nick; | ||
42 | }; | ||
43 | |||
44 | |||
45 | |||
31 | static struct GNUNET_ClientServerConnection *sock; | 46 | static struct GNUNET_ClientServerConnection *sock; |
32 | 47 | ||
33 | static struct GNUNET_Mutex *lock; | 48 | static struct GNUNET_Mutex *lock; |
@@ -52,11 +67,11 @@ write_save_call (void *arg) | |||
52 | 67 | ||
53 | buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (writeholder->chatWindow)); | 68 | buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (writeholder->chatWindow)); |
54 | message_buf_size = | 69 | message_buf_size = |
55 | snprintf (NULL, 0, "<%s> %s", writeholder->senderNick, | 70 | snprintf (NULL, 0, "<> %s", /* writeholder->senderNick,*/ |
56 | writeholder->message); | 71 | writeholder->message); |
57 | message_buf = GNUNET_malloc (message_buf_size + 2); | 72 | message_buf = GNUNET_malloc (message_buf_size + 2); |
58 | snprintf (message_buf, message_buf_size + 2, "<%s> %s\n", | 73 | snprintf (message_buf, message_buf_size + 2, "<FIXME> %s\n", |
59 | writeholder->senderNick, writeholder->message); | 74 | /*writeholder->senderNick,*/ writeholder->message); |
60 | gtk_text_buffer_insert_at_cursor (buffer, message_buf, | 75 | gtk_text_buffer_insert_at_cursor (buffer, message_buf, |
61 | message_buf_size + 1); | 76 | message_buf_size + 1); |
62 | 77 | ||
@@ -157,13 +172,12 @@ remove_nick_save_call (void *arg) | |||
157 | static int | 172 | static int |
158 | receive_callback (void *cls, | 173 | receive_callback (void *cls, |
159 | struct GNUNET_CHAT_Room *room, | 174 | struct GNUNET_CHAT_Room *room, |
160 | const char *senderNick, | 175 | const GNUNET_HashCode *sender, |
161 | const char *message, | 176 | const char *message, |
162 | GNUNET_CronTime timestamp, GNUNET_CHAT_MSG_OPTIONS options) | 177 | GNUNET_CHAT_MSG_OPTIONS options) |
163 | { | 178 | { |
164 | struct GNUNET_CHAT_gui_chat_client *client = cls; | 179 | struct GNUNET_CHAT_gui_chat_client *client = cls; |
165 | GtkWidget *chattextviewer; | 180 | GtkWidget *chattextviewer; |
166 | |||
167 | GList *children; | 181 | GList *children; |
168 | struct GNUNET_CHAT_safe_write_struct writearg; | 182 | struct GNUNET_CHAT_safe_write_struct writearg; |
169 | 183 | ||
@@ -177,7 +191,7 @@ receive_callback (void *cls, | |||
177 | 191 | ||
178 | writearg.chatWindow = chattextviewer; | 192 | writearg.chatWindow = chattextviewer; |
179 | writearg.message = message; | 193 | writearg.message = message; |
180 | writearg.senderNick = senderNick; | 194 | writearg.sender = sender; |
181 | GNUNET_GTK_save_call (&write_save_call, &writearg); | 195 | GNUNET_GTK_save_call (&write_save_call, &writearg); |
182 | 196 | ||
183 | /*Write the message to the appropriate room... | 197 | /*Write the message to the appropriate room... |
@@ -189,30 +203,31 @@ receive_callback (void *cls, | |||
189 | } | 203 | } |
190 | 204 | ||
191 | static int | 205 | static int |
192 | member_list_callback (void *cls, const char *senderNick, | 206 | member_list_callback (void *cls, |
193 | int is_joining, GNUNET_CronTime timestamp) | 207 | const struct GNUNET_ECRS_MetaData * member_info, |
208 | const GNUNET_RSA_PublicKey * pkey) | ||
194 | { | 209 | { |
195 | struct GNUNET_CHAT_gui_chat_client *client = cls; | 210 | struct GNUNET_CHAT_gui_chat_client *client = cls; |
196 | GtkWidget *chatnicklist; | 211 | GtkWidget *chatnicklist; |
212 | #if 0 | ||
197 | struct GNUNET_CHAT_safe_nick_write_struct writearg; | 213 | struct GNUNET_CHAT_safe_nick_write_struct writearg; |
198 | 214 | #endif | |
199 | chatnicklist = | 215 | chatnicklist = |
200 | g_list_nth_data (gtk_container_get_children | 216 | g_list_nth_data (gtk_container_get_children |
201 | (GTK_CONTAINER (client->chatFrame)), 1); | 217 | (GTK_CONTAINER (client->chatFrame)), 1); |
202 | chatnicklist = | 218 | chatnicklist = |
203 | g_list_nth_data (gtk_container_get_children | 219 | g_list_nth_data (gtk_container_get_children |
204 | (GTK_CONTAINER (chatnicklist)), 0); | 220 | (GTK_CONTAINER (chatnicklist)), 0); |
205 | 221 | #if 0 | |
206 | /* chatnicklist is the GtkTextView object */ | 222 | /* chatnicklist is the GtkTextView object */ |
207 | writearg.nick = senderNick; | 223 | writearg.nick = member_info; |
208 | writearg.nickList = chatnicklist; | 224 | writearg.nickList = chatnicklist; |
209 | 225 | ||
210 | g_print ("received nick %s calling safe write call\n", writearg.nick); | ||
211 | if (is_joining) | 226 | if (is_joining) |
212 | GNUNET_GTK_save_call (&write_nick_save_call, &writearg); | 227 | GNUNET_GTK_save_call (&write_nick_save_call, &writearg); |
213 | else | 228 | else |
214 | GNUNET_GTK_save_call (&remove_nick_save_call, &writearg); | 229 | GNUNET_GTK_save_call (&remove_nick_save_call, &writearg); |
215 | 230 | #endif | |
216 | return GNUNET_OK; | 231 | return GNUNET_OK; |
217 | } | 232 | } |
218 | 233 | ||
@@ -275,6 +290,7 @@ create_chat_room_tab (char *room_name, char *nick) | |||
275 | struct GNUNET_CHAT_Room *chatRoom; | 290 | struct GNUNET_CHAT_Room *chatRoom; |
276 | struct GNUNET_CHAT_gui_chat_client *client; | 291 | struct GNUNET_CHAT_gui_chat_client *client; |
277 | struct GNUNET_CHAT_gui_chat_client *pos; | 292 | struct GNUNET_CHAT_gui_chat_client *pos; |
293 | struct GNUNET_ECRS_MetaData * meta; | ||
278 | 294 | ||
279 | chatnotebook = | 295 | chatnotebook = |
280 | glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "chatnotebook"); | 296 | glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "chatnotebook"); |
@@ -295,12 +311,15 @@ create_chat_room_tab (char *room_name, char *nick) | |||
295 | strcpy (client->room_name, room_name); | 311 | strcpy (client->room_name, room_name); |
296 | 312 | ||
297 | /* We do a silly strdup later on member_info... either check for NULL or only pass "" for member_info!! */ | 313 | /* We do a silly strdup later on member_info... either check for NULL or only pass "" for member_info!! */ |
314 | meta = GNUNET_ECRS_meta_data_create(); | ||
298 | chatRoom = | 315 | chatRoom = |
299 | GNUNET_CHAT_join_room (chat_ectx, chat_cfg, nick, room_name, | 316 | GNUNET_CHAT_join_room (chat_ectx, chat_cfg, nick, |
300 | "", | 317 | meta, |
318 | room_name, | ||
301 | &receive_callback, client, &member_list_callback, | 319 | &receive_callback, client, &member_list_callback, |
302 | client); | 320 | client, |
303 | 321 | NULL, NULL); | |
322 | GNUNET_ECRS_meta_data_destroy(meta); | ||
304 | client->room = chatRoom; | 323 | client->room = chatRoom; |
305 | client->chatFrame = newChatWindow; | 324 | client->chatFrame = newChatWindow; |
306 | client->number = | 325 | client->number = |
@@ -337,7 +356,7 @@ on_chat_frame_send_button_click_event_chat (GtkWidget * widget, gpointer data) | |||
337 | GtkWidget *curr_page; | 356 | GtkWidget *curr_page; |
338 | GList *children; | 357 | GList *children; |
339 | GtkEntry *chat_entry; | 358 | GtkEntry *chat_entry; |
340 | 359 | unsigned int seq; | |
341 | char *message; | 360 | char *message; |
342 | const gchar *room_name; | 361 | const gchar *room_name; |
343 | struct GNUNET_CHAT_gui_chat_client *client; | 362 | struct GNUNET_CHAT_gui_chat_client *client; |
@@ -387,8 +406,8 @@ on_chat_frame_send_button_click_event_chat (GtkWidget * widget, gpointer data) | |||
387 | else | 406 | else |
388 | return; | 407 | return; |
389 | 408 | ||
390 | GNUNET_CHAT_send_message (client->room, message, NULL, | 409 | GNUNET_CHAT_send_message (client->room, message, |
391 | NULL, GNUNET_CHAT_MSG_OPTION_NONE, NULL); | 410 | GNUNET_CHAT_MSG_OPTION_NONE, NULL, &seq); |
392 | 411 | ||
393 | gtk_entry_set_text (chat_entry, ""); | 412 | gtk_entry_set_text (chat_entry, ""); |
394 | 413 | ||