| 57 static void |
57 static void |
| 58 text_sent_cb(GtkEntry *entry) |
58 text_sent_cb(GtkEntry *entry) |
| 59 { |
59 { |
| 60 const char *txt; |
60 const char *txt; |
| 61 PurpleConnection *gc; |
61 PurpleConnection *gc; |
| 62 const char *prpl_id; |
62 const char *protocol_id; |
| 63 |
63 |
| 64 if (account == NULL) |
64 if (account == NULL) |
| 65 return; |
65 return; |
| 66 |
66 |
| 67 gc = purple_account_get_connection(account); |
67 gc = purple_account_get_connection(account); |
| 68 |
68 |
| 69 txt = gtk_entry_get_text(entry); |
69 txt = gtk_entry_get_text(entry); |
| 70 |
70 |
| 71 prpl_id = purple_account_get_protocol_id(account); |
71 protocol_id = purple_account_get_protocol_id(account); |
| 72 |
72 |
| 73 purple_debug_misc("raw", "prpl_id = %s\n", prpl_id); |
73 purple_debug_misc("raw", "protocol_id = %s\n", protocol_id); |
| 74 |
74 |
| 75 if (strcmp(prpl_id, "prpl-toc") == 0) { |
75 if (strcmp(protocol_id, "prpl-toc") == 0) { |
| 76 int *a = (int *)gc->proto_data; |
76 int *a = (int *)gc->proto_data; |
| 77 unsigned short seqno = htons(a[1]++ & 0xffff); |
77 unsigned short seqno = htons(a[1]++ & 0xffff); |
| 78 unsigned short len = htons(strlen(txt) + 1); |
78 unsigned short len = htons(strlen(txt) + 1); |
| 79 write(*a, "*\002", 2); |
79 write(*a, "*\002", 2); |
| 80 write(*a, &seqno, 2); |
80 write(*a, &seqno, 2); |
| 81 write(*a, &len, 2); |
81 write(*a, &len, 2); |
| 82 write(*a, txt, ntohs(len)); |
82 write(*a, txt, ntohs(len)); |
| 83 purple_debug(PURPLE_DEBUG_MISC, "raw", "TOC C: %s\n", txt); |
83 purple_debug(PURPLE_DEBUG_MISC, "raw", "TOC C: %s\n", txt); |
| 84 |
84 |
| 85 } else if (strcmp(prpl_id, "prpl-msn") == 0) { |
85 } else if (strcmp(protocol_id, "prpl-msn") == 0) { |
| 86 MsnSession *session = gc->proto_data; |
86 MsnSession *session = gc->proto_data; |
| 87 char buf[strlen(txt) + 3]; |
87 char buf[strlen(txt) + 3]; |
| 88 |
88 |
| 89 g_snprintf(buf, sizeof(buf), "%s\r\n", txt); |
89 g_snprintf(buf, sizeof(buf), "%s\r\n", txt); |
| 90 msn_servconn_write(session->notification->servconn, buf, strlen(buf)); |
90 msn_servconn_write(session->notification->servconn, buf, strlen(buf)); |
| 91 |
91 |
| 92 } else if (strcmp(prpl_id, "prpl-irc") == 0) { |
92 } else if (strcmp(protocol_id, "prpl-irc") == 0) { |
| 93 write(*(int *)gc->proto_data, txt, strlen(txt)); |
93 write(*(int *)gc->proto_data, txt, strlen(txt)); |
| 94 write(*(int *)gc->proto_data, "\r\n", 2); |
94 write(*(int *)gc->proto_data, "\r\n", 2); |
| 95 purple_debug(PURPLE_DEBUG_MISC, "raw", "IRC C: %s\n", txt); |
95 purple_debug(PURPLE_DEBUG_MISC, "raw", "IRC C: %s\n", txt); |
| 96 |
96 |
| 97 } else if (strcmp(prpl_id, "prpl-jabber") == 0) { |
97 } else if (strcmp(protocol_id, "prpl-jabber") == 0) { |
| 98 jabber_send_raw((JabberStream *)gc->proto_data, txt, -1); |
98 jabber_send_raw((JabberStream *)gc->proto_data, txt, -1); |
| 99 |
99 |
| 100 } else { |
100 } else { |
| 101 purple_debug_error("raw", "Unknown protocol ID %s\n", prpl_id); |
101 purple_debug_error("raw", "Unknown protocol ID %s\n", protocol_id); |
| 102 } |
102 } |
| 103 |
103 |
| 104 gtk_entry_set_text(entry, ""); |
104 gtk_entry_set_text(entry, ""); |
| 105 } |
105 } |
| 106 |
106 |