Mercurial > pidgin.yaz
comparison src/log.c @ 4359:5fb47ec9bfe4
[gaim-migrate @ 4625]
Wow, okay, where to begin with this one ;)
I rewrote the whole conversation backend. It is now core/UI split. Here's
how it works..
Every conversation is represented by a gaim_conversation structure. This
branches out into gaim_im and gaim_chat structures. Every conversation
lives in (well, normally, but it doesn't have to) a gaim_window structure.
This is a _CORE_ representation of a window. There can be multiple
gaim_window structures around.
The gaim_window and gaim_conversation structures have UI-specific operation
structures associated with them. At the moment, the only UI is GTK+, and
this will be for some time. Don't start thinking you can write a QT UI now.
It's just not going to happen.
Everything that is done on a conversation is done through the core API.
This API does core processing and then calls the UI operations for the
rendering and anything else.
Now, what does this give the user?
- Multiple windows.
- Multiple tabs per window.
- Draggable tabs.
- Send As menu is moved to the menubar.
- Menubar for chats.
- Some very cool stuff in the future, like replacing, say, IRC chat windows
with an X-Chat interface, or whatever.
- Later on, customizable window/conversation positioning.
For developers:
- Fully documented API
- Core/UI split
- Variable checking and mostly sane handling of incorrect variables.
- Logical structure to conversations, both core and UI.
- Some very cool stuff in the future, like replacing, say, IRC chat windows
with an X-Chat interface, or whatever.
- Later on, customizable window/conversation positioning.
- Oh yeah, and the beginning of a stock icon system.
Now, there are things that aren't there yet. You will see tabs even if you
have them turned off. This will be fixed in time. Also, the preferences
will change to work with the new structure. I'm starting school in 2 days,
so it may not be done immediately, but hopefully in the next week.
Enjoy!
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Mon, 20 Jan 2003 09:10:23 +0000 |
parents | a614423c648f |
children | a8249a5250b6 |
comparison
equal
deleted
inserted
replaced
4358:2b8abf7f9cc1 | 4359:5fb47ec9bfe4 |
---|---|
13 | 13 |
14 #include "gaim.h" | 14 #include "gaim.h" |
15 #include "core.h" | 15 #include "core.h" |
16 #include "multi.h" | 16 #include "multi.h" |
17 #include "prpl.h" | 17 #include "prpl.h" |
18 #include <string.h> | |
18 #include <sys/stat.h> | 19 #include <sys/stat.h> |
20 #include <unistd.h> | |
19 | 21 |
20 #ifdef _WIN32 | 22 #ifdef _WIN32 |
21 #include "win32dep.h" | 23 #include "win32dep.h" |
22 #endif | 24 #endif |
23 | 25 |
24 void rm_log(struct log_conversation *a) | 26 void rm_log(struct log_conversation *a) |
25 { | 27 { |
26 struct conversation *cnv = find_conversation(a->name); | 28 struct gaim_conversation *cnv = gaim_find_conversation(a->name); |
27 | 29 |
28 log_conversations = g_list_remove(log_conversations, a); | 30 log_conversations = g_list_remove(log_conversations, a); |
29 | 31 |
30 save_prefs(); | 32 save_prefs(); |
31 | 33 |
32 if (cnv && !(im_options & OPT_IM_ONE_WINDOW)) | 34 if (cnv && !(im_options & OPT_IM_ONE_WINDOW)) |
33 set_convo_title(cnv); | 35 gaim_conversation_autoset_title(cnv); |
34 } | 36 } |
35 | 37 |
36 struct log_conversation *find_log_info(const char *name) | 38 struct log_conversation *find_log_info(const char *name) |
37 { | 39 { |
38 char *pname = g_malloc(BUF_LEN); | 40 char *pname = g_malloc(BUF_LEN); |
54 return NULL; | 56 return NULL; |
55 } | 57 } |
56 | 58 |
57 void update_log_convs() | 59 void update_log_convs() |
58 { | 60 { |
59 GSList *C = connections; | 61 GList *cnv; |
60 struct gaim_connection *g; | 62 struct gaim_conversation *c; |
61 GSList *bcs; | 63 struct gaim_gtk_conversation *gtkconv; |
62 GList *cnv = conversations; | 64 |
63 struct conversation *c; | 65 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) { |
64 | 66 |
65 while (cnv) { | 67 c = (struct gaim_conversation *)cnv->data; |
66 c = (struct conversation *)cnv->data; | 68 |
67 if (c->log_button) { | 69 if (gaim_conversation_get_ops(c) != gaim_get_gtk_conversation_ops()) |
68 if (c->is_chat) | 70 continue; |
69 gtk_widget_set_sensitive(GTK_WIDGET(c->log_button), | 71 |
72 gtkconv = GAIM_GTK_CONVERSATION(c); | |
73 | |
74 if (gtkconv->toolbar.log) { | |
75 if (gaim_conversation_get_type(c) == GAIM_CONV_CHAT) | |
76 gtk_widget_set_sensitive(GTK_WIDGET(gtkconv->toolbar.log), | |
70 ((logging_options & OPT_LOG_CHATS)) ? FALSE : TRUE); | 77 ((logging_options & OPT_LOG_CHATS)) ? FALSE : TRUE); |
71 else | 78 else |
72 gtk_widget_set_sensitive(GTK_WIDGET(c->log_button), | 79 gtk_widget_set_sensitive(GTK_WIDGET(gtkconv->toolbar.log), |
73 ((logging_options & OPT_LOG_CONVOS)) ? FALSE : TRUE); | 80 ((logging_options & OPT_LOG_CONVOS)) ? FALSE : TRUE); |
74 } | 81 } |
75 | |
76 cnv = cnv->next; | |
77 } | |
78 | |
79 while (C) { | |
80 g = (struct gaim_connection *)C->data; | |
81 bcs = g->buddy_chats; | |
82 while (bcs) { | |
83 c = (struct conversation *)bcs->data; | |
84 if (c->log_button) { | |
85 if (c->is_chat) | |
86 gtk_widget_set_sensitive(GTK_WIDGET(c->log_button), | |
87 ((logging_options & OPT_LOG_CHATS)) ? FALSE : | |
88 TRUE); | |
89 else | |
90 gtk_widget_set_sensitive(GTK_WIDGET(c->log_button), | |
91 ((logging_options & OPT_LOG_CONVOS)) ? FALSE : | |
92 TRUE); | |
93 } | |
94 | |
95 bcs = bcs->next; | |
96 } | |
97 C = C->next; | |
98 } | 82 } |
99 } | 83 } |
100 | 84 |
101 static void do_save_convo(GtkObject *obj, GtkWidget *wid) | 85 static void do_save_convo(GtkObject *obj, GtkWidget *wid) |
102 { | 86 { |
103 struct conversation *c = gtk_object_get_user_data(obj); | 87 struct gaim_conversation *c = gtk_object_get_user_data(obj); |
104 const char *filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(wid)); | 88 const char *filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(wid)); |
105 FILE *f; | 89 FILE *f; |
90 | |
106 if (file_is_dir(filename, wid)) | 91 if (file_is_dir(filename, wid)) |
107 return; | 92 return; |
108 if (!((!c->is_chat && g_list_find(conversations, c)) || | 93 |
109 (c->is_chat && g_slist_find(connections, c->gc) && g_slist_find(c->gc->buddy_chats, c)))) | 94 if (!((gaim_conversation_get_type(c) != GAIM_CONV_CHAT && |
95 g_list_find(gaim_get_ims(), c)) || | |
96 (gaim_conversation_get_type(c) == GAIM_CONV_CHAT && | |
97 g_list_find(gaim_get_chats(), c)))) | |
110 filename = NULL; | 98 filename = NULL; |
99 | |
111 gtk_widget_destroy(wid); | 100 gtk_widget_destroy(wid); |
101 | |
112 if (!filename) | 102 if (!filename) |
113 return; | 103 return; |
104 | |
114 f = fopen(filename, "w+"); | 105 f = fopen(filename, "w+"); |
106 | |
115 if (!f) | 107 if (!f) |
116 return; | 108 return; |
109 | |
117 fprintf(f, "%s", c->history->str); | 110 fprintf(f, "%s", c->history->str); |
118 fclose(f); | 111 fclose(f); |
119 } | 112 } |
120 | 113 |
121 | 114 |
122 void save_convo(GtkWidget *save, struct conversation *c) | 115 void save_convo(GtkWidget *save, struct gaim_conversation *c) |
123 { | 116 { |
124 char buf[BUF_LONG]; | 117 char buf[BUF_LONG]; |
125 GtkWidget *window = gtk_file_selection_new(_("Gaim - Save Conversation")); | 118 GtkWidget *window = gtk_file_selection_new(_("Gaim - Save Conversation")); |
126 g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "%s.log", gaim_home_dir(), normalize(c->name)); | 119 g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "%s.log", gaim_home_dir(), normalize(c->name)); |
127 gtk_file_selection_set_filename(GTK_FILE_SELECTION(window), buf); | 120 gtk_file_selection_set_filename(GTK_FILE_SELECTION(window), buf); |
131 g_signal_connect_swapped(GTK_OBJECT(GTK_FILE_SELECTION(window)->cancel_button), | 124 g_signal_connect_swapped(GTK_OBJECT(GTK_FILE_SELECTION(window)->cancel_button), |
132 "clicked", G_CALLBACK(gtk_widget_destroy), (gpointer)window); | 125 "clicked", G_CALLBACK(gtk_widget_destroy), (gpointer)window); |
133 gtk_widget_show(window); | 126 gtk_widget_show(window); |
134 } | 127 } |
135 | 128 |
136 char *html_logize(char *p) | |
137 { | |
138 char *temp_p = p; | |
139 char *buffer_p; | |
140 char *buffer_start; | |
141 int num_cr = 0; | |
142 int char_len = 0; | |
143 | |
144 while (*temp_p != '\0') { | |
145 char_len++; | |
146 if ((*temp_p == '\n') || ((*temp_p == '<') && (*(temp_p + 1) == '!'))) | |
147 num_cr++; | |
148 ++temp_p; | |
149 } | |
150 | |
151 temp_p = p; | |
152 buffer_p = g_malloc(char_len + (4 * num_cr) + 1); | |
153 buffer_start = buffer_p; | |
154 | |
155 while (*temp_p != '\0') { | |
156 if (*temp_p == '\n') { | |
157 *buffer_p++ = '<'; | |
158 *buffer_p++ = 'B'; | |
159 *buffer_p++ = 'R'; | |
160 *buffer_p++ = '>'; | |
161 *buffer_p++ = '\n'; | |
162 } else if ((*temp_p == '<') && (*(temp_p + 1) == '!')) { | |
163 *buffer_p++ = '&'; | |
164 *buffer_p++ = 'l'; | |
165 *buffer_p++ = 't'; | |
166 *buffer_p++ = ';'; | |
167 } else | |
168 *buffer_p++ = *temp_p; | |
169 ++temp_p; | |
170 } | |
171 *buffer_p = '\0'; | |
172 | |
173 return buffer_start; | |
174 } | |
175 | |
176 static FILE *open_gaim_log_file(const char *name, int *flag) | 129 static FILE *open_gaim_log_file(const char *name, int *flag) |
177 { | 130 { |
178 char *buf; | 131 char *buf; |
179 char *buf2; | 132 char *buf2; |
180 char log_all_file[256]; | 133 char log_all_file[256]; |
461 fprintf(fd, "%s<BR>\n", html); | 414 fprintf(fd, "%s<BR>\n", html); |
462 } | 415 } |
463 | 416 |
464 fclose(fd); | 417 fclose(fd); |
465 } | 418 } |
419 | |
420 char *html_logize(const char *p) | |
421 { | |
422 const char *temp_p; | |
423 char *buffer_p; | |
424 char *buffer_start; | |
425 int num_cr = 0; | |
426 int char_len = 0; | |
427 | |
428 for (temp_p = p; *temp_p != '\0'; temp_p++) { | |
429 char_len++; | |
430 | |
431 if ((*temp_p == '\n') || ((*temp_p == '<') && (*(temp_p + 1) == '!'))) | |
432 num_cr++; | |
433 } | |
434 | |
435 buffer_p = g_malloc(char_len + (4 * num_cr) + 1); | |
436 | |
437 for (temp_p = p, buffer_start = buffer_p; | |
438 *temp_p != '\0'; | |
439 temp_p++) { | |
440 | |
441 if (*temp_p == '\n') { | |
442 *buffer_p++ = '<'; | |
443 *buffer_p++ = 'B'; | |
444 *buffer_p++ = 'R'; | |
445 *buffer_p++ = '>'; | |
446 *buffer_p++ = '\n'; | |
447 | |
448 } else if ((*temp_p == '<') && (*(temp_p + 1) == '!')) { | |
449 *buffer_p++ = '&'; | |
450 *buffer_p++ = 'l'; | |
451 *buffer_p++ = 't'; | |
452 *buffer_p++ = ';'; | |
453 | |
454 } else | |
455 *buffer_p++ = *temp_p; | |
456 } | |
457 | |
458 *buffer_p = '\0'; | |
459 | |
460 return buffer_start; | |
461 } |