Mercurial > pidgin
comparison src/protocols/toc/toc.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 | 0c68d402f59f |
| children | 2afc0f845e74 |
comparison
equal
deleted
inserted
replaced
| 4358:2b8abf7f9cc1 | 4359:5fb47ec9bfe4 |
|---|---|
| 743 serv_got_chat_in(gc, id, who, w, m, time((time_t)NULL)); | 743 serv_got_chat_in(gc, id, who, w, m, time((time_t)NULL)); |
| 744 } else if (!strcasecmp(c, "CHAT_UPDATE_BUDDY")) { | 744 } else if (!strcasecmp(c, "CHAT_UPDATE_BUDDY")) { |
| 745 int id; | 745 int id; |
| 746 char *in, *buddy; | 746 char *in, *buddy; |
| 747 GSList *bcs = gc->buddy_chats; | 747 GSList *bcs = gc->buddy_chats; |
| 748 struct conversation *b = NULL; | 748 struct gaim_conversation *b = NULL; |
| 749 struct gaim_chat *chat; | |
| 749 | 750 |
| 750 sscanf(strtok(NULL, ":"), "%d", &id); | 751 sscanf(strtok(NULL, ":"), "%d", &id); |
| 751 in = strtok(NULL, ":"); | 752 in = strtok(NULL, ":"); |
| 752 | 753 |
| 754 chat = GAIM_CHAT(b); | |
| 755 | |
| 753 while (bcs) { | 756 while (bcs) { |
| 754 b = (struct conversation *)bcs->data; | 757 b = (struct gaim_conversation *)bcs->data; |
| 755 if (id == b->id) | 758 if (id == gaim_chat_get_id(chat)) |
| 756 break; | 759 break; |
| 757 bcs = bcs->next; | 760 bcs = bcs->next; |
| 758 b = NULL; | 761 b = NULL; |
| 759 } | 762 } |
| 760 | 763 |
| 761 if (!b) | 764 if (!b) |
| 762 return; | 765 return; |
| 763 | 766 |
| 764 if (in && (*in == 'T')) | 767 if (in && (*in == 'T')) |
| 765 while ((buddy = strtok(NULL, ":")) != NULL) | 768 while ((buddy = strtok(NULL, ":")) != NULL) |
| 766 add_chat_buddy(b, buddy, NULL); | 769 gaim_chat_add_user(chat, buddy, NULL); |
| 767 else | 770 else |
| 768 while ((buddy = strtok(NULL, ":")) != NULL) | 771 while ((buddy = strtok(NULL, ":")) != NULL) |
| 769 remove_chat_buddy(b, buddy, NULL); | 772 gaim_chat_remove_user(chat, buddy, NULL); |
| 770 } else if (!strcasecmp(c, "CHAT_INVITE")) { | 773 } else if (!strcasecmp(c, "CHAT_INVITE")) { |
| 771 char *name, *who, *message; | 774 char *name, *who, *message; |
| 772 int *id = g_new0(int, 1); | 775 int *id = g_new0(int, 1); |
| 773 | 776 |
| 774 name = strtok(NULL, ":"); | 777 name = strtok(NULL, ":"); |
| 777 message = strtok(NULL, ":"); | 780 message = strtok(NULL, ":"); |
| 778 | 781 |
| 779 serv_got_chat_invite(gc, name, who, message, g_list_append(NULL, id)); | 782 serv_got_chat_invite(gc, name, who, message, g_list_append(NULL, id)); |
| 780 } else if (!strcasecmp(c, "CHAT_LEFT")) { | 783 } else if (!strcasecmp(c, "CHAT_LEFT")) { |
| 781 GSList *bcs = gc->buddy_chats; | 784 GSList *bcs = gc->buddy_chats; |
| 782 struct conversation *b = NULL; | 785 struct gaim_conversation *b = NULL; |
| 783 int id; | 786 int id; |
| 784 | 787 |
| 785 sscanf(strtok(NULL, ":"), "%d", &id); | 788 sscanf(strtok(NULL, ":"), "%d", &id); |
| 786 | 789 |
| 787 while (bcs) { | 790 while (bcs) { |
| 788 b = (struct conversation *)bcs->data; | 791 b = (struct gaim_conversation *)bcs->data; |
| 789 if (id == b->id) | 792 if (id == gaim_chat_get_id(GAIM_CHAT(b))) |
| 790 break; | 793 break; |
| 791 b = NULL; | 794 b = NULL; |
| 792 bcs = bcs->next; | 795 bcs = bcs->next; |
| 793 } | 796 } |
| 794 | 797 |
| 795 if (!b) | 798 if (!b) |
| 796 return; | 799 return; |
| 797 | 800 |
| 798 if (b->window) { | 801 if (b->window) { |
| 799 char error_buf[BUF_LONG]; | 802 char error_buf[BUF_LONG]; |
| 800 b->gc = NULL; | 803 gaim_conversation_set_user(b, NULL); |
| 801 g_snprintf(error_buf, sizeof error_buf, _("You have been disconnected" | 804 g_snprintf(error_buf, sizeof error_buf, _("You have been disconnected" |
| 802 " from chat room %s."), b->name); | 805 " from chat room %s."), b->name); |
| 803 do_error_dialog(error_buf, NULL, GAIM_ERROR); | 806 do_error_dialog(error_buf, NULL, GAIM_ERROR); |
| 804 } else | 807 } else |
| 805 serv_got_chat_left(gc, id); | 808 serv_got_chat_left(gc, id); |
| 1181 } | 1184 } |
| 1182 | 1185 |
| 1183 static void toc_chat_leave(struct gaim_connection *g, int id) | 1186 static void toc_chat_leave(struct gaim_connection *g, int id) |
| 1184 { | 1187 { |
| 1185 GSList *bcs = g->buddy_chats; | 1188 GSList *bcs = g->buddy_chats; |
| 1186 struct conversation *b = NULL; | 1189 struct gaim_conversation *b = NULL; |
| 1187 char buf[BUF_LEN * 2]; | 1190 char buf[BUF_LEN * 2]; |
| 1188 | 1191 |
| 1189 while (bcs) { | 1192 while (bcs) { |
| 1190 b = (struct conversation *)bcs->data; | 1193 b = (struct gaim_conversation *)bcs->data; |
| 1191 if (id == b->id) | 1194 if (id == gaim_chat_get_id(GAIM_CHAT(b))) |
| 1192 break; | 1195 break; |
| 1193 b = NULL; | 1196 b = NULL; |
| 1194 bcs = bcs->next; | 1197 bcs = bcs->next; |
| 1195 } | 1198 } |
| 1196 | 1199 |
| 1197 if (!b) | 1200 if (!b) |
| 1198 return; /* can this happen? */ | 1201 return; /* can this happen? */ |
| 1199 | 1202 |
| 1200 if (!b->gc) /* TOC already kicked us out of this room */ | 1203 if (gaim_conversation_get_user(b) == NULL) { |
| 1204 /* TOC already kicked us out of this room */ | |
| 1201 serv_got_chat_left(g, id); | 1205 serv_got_chat_left(g, id); |
| 1206 } | |
| 1202 else { | 1207 else { |
| 1203 g_snprintf(buf, 255, "toc_chat_leave %d", id); | 1208 g_snprintf(buf, 255, "toc_chat_leave %d", id); |
| 1204 sflap_send(g, buf, -1, TYPE_DATA); | 1209 sflap_send(g, buf, -1, TYPE_DATA); |
| 1205 } | 1210 } |
| 1206 } | 1211 } |
