comparison src/toc.c @ 981:7e231bc0018a

[gaim-migrate @ 991] I think I need a Pepsi. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Fri, 13 Oct 2000 07:24:40 +0000
parents 82c5865f7cfe
children 9523b772e546
comparison
equal deleted inserted replaced
980:82c5865f7cfe 981:7e231bc0018a
33 #include <string.h> 33 #include <string.h>
34 #include <stdlib.h> 34 #include <stdlib.h>
35 #include <stdio.h> 35 #include <stdio.h>
36 #include <time.h> 36 #include <time.h>
37 #include <sys/socket.h> 37 #include <sys/socket.h>
38 #include "prpl.h"
38 #include "multi.h" 39 #include "multi.h"
39 #include "gaim.h" 40 #include "gaim.h"
40 #include "gnome_applet_mgr.h" 41 #include "gnome_applet_mgr.h"
41 42
42 #define REVISION "gaim:$Revision: 990 $" 43 #define REVISION "gaim:$Revision: 991 $"
43 44
44 45
45 static unsigned int peer_ver=0; 46 static unsigned int peer_ver=0;
46 #ifdef _WIN32 47 #ifdef _WIN32
47 static int win32_r; 48 static int win32_r;
930 do_import( (GtkWidget *) NULL, gc ); 931 do_import( (GtkWidget *) NULL, gc );
931 } else if ( gc && (bud_list_cache_exists(gc) == FALSE) ) { 932 } else if ( gc && (bud_list_cache_exists(gc) == FALSE) ) {
932 do_export( (GtkWidget *) NULL, 0 ); 933 do_export( (GtkWidget *) NULL, 0 );
933 } 934 }
934 } 935 }
936
937 static char *toc_name() {
938 return "TOC";
939 }
940
941 static void toc_send_im(struct gaim_connection *gc, char *name, char *message, int away) {
942 char buf[MSG_LEN - 7];
943
944 escape_text(message);
945 g_snprintf(buf, MSG_LEN - 8, "toc_send_im %s \"%s\"%s", normalize(name),
946 message, ((away) ? " auto" : ""));
947 sflap_send(gc, buf, -1, TYPE_DATA);
948 }
949
950 static void toc_get_info(struct gaim_connection *g, char *name) {
951 char buf[MSG_LEN];
952 g_snprintf(buf, MSG_LEN, "toc_get_info %s", normalize(name));
953 sflap_send(g, buf, -1, TYPE_DATA);
954 }
955
956 static void toc_get_dir(struct gaim_connection *g, char *name) {
957 char buf[MSG_LEN];
958 g_snprintf(buf, MSG_LEN, "toc_get_dir %s", normalize(name));
959 sflap_send(g, buf, -1, TYPE_DATA);
960 }
961
962 static void toc_set_dir(struct gaim_connection *g, char *first, char *middle, char *last,
963 char *maiden, char *city, char *state, char *country, int web) {
964 char buf2[BUF_LEN*4], buf[BUF_LEN];
965 g_snprintf(buf2, sizeof(buf2), "%s:%s:%s:%s:%s:%s:%s:%s", first,
966 middle, last, maiden, city, state, country,
967 (web == 1) ? "Y" : "");
968 escape_text(buf2);
969 g_snprintf(buf, sizeof(buf), "toc_set_dir %s", buf2);
970 sflap_send(g, buf, -1, TYPE_DATA);
971 }
972
973 static void toc_dir_search(struct gaim_connection *g, char *first, char *middle, char *last,
974 char *maiden, char *city, char *state, char *country, char *email) {
975 char buf[BUF_LONG];
976 g_snprintf(buf, sizeof(buf)/2, "toc_dir_search %s:%s:%s:%s:%s:%s:%s:%s", first, middle,
977 last, maiden, city, state, country, email);
978 sprintf(debug_buff,"Searching for: %s,%s,%s,%s,%s,%s,%s\n", first, middle, last, maiden,
979 city, state, country);
980 debug_print(debug_buff);
981 sflap_send(g, buf, -1, TYPE_DATA);
982 }
983
984 static void toc_set_away(struct gaim_connection *g, char *message) {
985 char buf[MSG_LEN];
986 if (message) {
987 escape_text(message);
988 g_snprintf(buf, MSG_LEN, "toc_set_away \"%s\"", message);
989 } else
990 g_snprintf(buf, MSG_LEN, "toc_set_away \"\"");
991 sflap_send(g, buf, -1, TYPE_DATA);
992 }
993
994 static void toc_set_info(struct gaim_connection *g, char *info) {
995 char buf[MSG_LEN];
996 escape_text(info);
997 g_snprintf(buf, sizeof(buf), "toc_set_info \"%s\n\"", info);
998 sflap_send(g, buf, -1, TYPE_DATA);
999 }
1000
1001 static void toc_change_passwd(struct gaim_connection *g, char *orig, char *new) {
1002 char buf[MSG_LEN];
1003 g_snprintf(buf, BUF_LONG, "toc_change_passwd %s %s", orig, new);
1004 sflap_send(g, buf, strlen(buf), TYPE_DATA);
1005 }
1006
1007 static void toc_add_buddy(struct gaim_connection *g, char *name) {
1008 char buf[1024];
1009 g_snprintf(buf, sizeof(buf), "toc_add_buddy %s", normalize(name));
1010 sflap_send(g, buf, -1, TYPE_DATA);
1011 }
1012
1013 static void toc_add_buddies(struct gaim_connection *g, GList *buddies) {
1014 char buf[MSG_LEN];
1015 int n;
1016
1017 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy");
1018 while (buddies) {
1019 if (strlen(normalize(buddies->data)) > MSG_LEN - n - 16) {
1020 sflap_send(g, buf, -1, TYPE_DATA);
1021 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy");
1022 }
1023 n += g_snprintf(buf + n, sizeof(buf)-n, " %s", normalize(buddies->data));
1024 buddies = buddies->next;
1025 }
1026 sflap_send(g, buf, -1, TYPE_DATA);
1027 }
1028
1029 static void toc_remove_buddy(struct gaim_connection *g, char *name) {
1030 char buf[1024];
1031 g_snprintf(buf, sizeof(buf), "toc_remove_buddy %s", normalize(name));
1032 sflap_send(g, buf, -1, TYPE_DATA);
1033 }
1034
1035 static void toc_set_idle(struct gaim_connection *g, int time) {
1036 char buf[256];
1037 g_snprintf(buf, sizeof(buf), "toc_set_idle %d", time);
1038 sflap_send(g, buf, -1, TYPE_DATA);
1039 }
1040
1041 static void toc_warn(struct gaim_connection *g, char *name, int anon) {
1042 char send[256];
1043 g_snprintf(send, 255, "toc_evil %s %s", name, ((anon) ? "anon" : "norm"));
1044 sflap_send(g, send, -1, TYPE_DATA);
1045 }
1046
1047 static void toc_accept_chat(struct gaim_connection *g, int i) {
1048 char buf[256];
1049 g_snprintf(buf, 255, "toc_chat_accept %d", i);
1050 sflap_send(g, buf, -1, TYPE_DATA);
1051 }
1052
1053 static void toc_join_chat(struct gaim_connection *g, int exchange, char *name) {
1054 char buf[BUF_LONG];
1055 g_snprintf(buf, sizeof(buf)/2, "toc_chat_join %d \"%s\"", exchange, name);
1056 sflap_send(g, buf, -1, TYPE_DATA);
1057 }
1058
1059 static void toc_chat_invite(struct gaim_connection *g, int id, char *message, char *name) {
1060 char buf[BUF_LONG];
1061 g_snprintf(buf, sizeof(buf)/2, "toc_chat_invite %d \"%s\" %s", id, message, normalize(name));
1062 sflap_send(g, buf, -1, TYPE_DATA);
1063 }
1064
1065 static void toc_chat_leave(struct gaim_connection *g, int id) {
1066 char buf[256];
1067 g_snprintf(buf, 255, "toc_chat_leave %d", id);
1068 sflap_send(g, buf, -1, TYPE_DATA);
1069 }
1070
1071 static void toc_chat_whisper(struct gaim_connection *g, int id, char *who, char *message) {
1072 char buf2[MSG_LEN];
1073 g_snprintf(buf2, sizeof(buf2), "toc_chat_whisper %d %s \"%s\"", id, who, message);
1074 sflap_send(g, buf2, -1, TYPE_DATA);
1075 }
1076
1077 static void toc_chat_send(struct gaim_connection *g, int id, char *message) {
1078 char buf[MSG_LEN];
1079 escape_text(message);
1080 g_snprintf(buf, sizeof(buf), "toc_chat_send %d \"%s\"",id, message);
1081 sflap_send(g, buf, -1, TYPE_DATA);
1082 }
1083
1084 static void toc_keepalive(struct gaim_connection *gc) {
1085 sflap_send(gc, "", 0, TYPE_KEEPALIVE);
1086 }
1087
1088 struct prpl *toc_init() {
1089 struct prpl *ret = g_new0(struct prpl, 1);
1090
1091 ret->protocol = PROTO_TOC;
1092 ret->name = toc_name;
1093 ret->login = toc_login;
1094 ret->close = toc_close;
1095 ret->send_im = toc_send_im;
1096 ret->set_info = toc_set_info;
1097 ret->get_info = toc_get_info;
1098 ret->set_away = toc_set_away;
1099 ret->get_away_msg = NULL;
1100 ret->set_dir = toc_set_dir;
1101 ret->get_dir = toc_get_dir;
1102 ret->dir_search = toc_dir_search;
1103 ret->set_idle = toc_set_idle;
1104 ret->change_passwd = toc_change_passwd;
1105 ret->add_buddy = toc_add_buddy;
1106 ret->add_buddies = toc_add_buddies;
1107 ret->remove_buddy = toc_remove_buddy;
1108 ret->add_permit = NULL; /* FIXME */
1109 ret->add_deny = NULL;
1110 ret->warn = toc_warn;
1111 ret->accept_chat = toc_accept_chat;
1112 ret->join_chat = toc_join_chat;
1113 ret->chat_invite = toc_chat_invite;
1114 ret->chat_leave = toc_chat_leave;
1115 ret->chat_whisper = toc_chat_whisper;
1116 ret->chat_send = toc_chat_send;
1117 ret->keepalive = toc_keepalive;
1118
1119 return ret;
1120 }