comparison src/protocols/oscar/oscar.c @ 2501:227cc42ffa6e

[gaim-migrate @ 2514] i should have hidden something ultra-secret in this. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Sun, 14 Oct 2001 11:36:36 +0000
parents 2a4a50036e25
children 1069b0940237
comparison
equal deleted inserted replaced
2500:1697ecbf1bcc 2501:227cc42ffa6e
28 #include <netdb.h> 28 #include <netdb.h>
29 #include <unistd.h> 29 #include <unistd.h>
30 #include <errno.h> 30 #include <errno.h>
31 #include <netinet/in.h> 31 #include <netinet/in.h>
32 #include <arpa/inet.h> 32 #include <arpa/inet.h>
33 #include <ctype.h>
33 #include <string.h> 34 #include <string.h>
34 #include <stdlib.h> 35 #include <stdlib.h>
35 #include <stdio.h> 36 #include <stdio.h>
36 #include <time.h> 37 #include <time.h>
37 #include <sys/socket.h> 38 #include <sys/socket.h>
40 #include "prpl.h" 41 #include "prpl.h"
41 #include "gaim.h" 42 #include "gaim.h"
42 #include "aim.h" 43 #include "aim.h"
43 #include "proxy.h" 44 #include "proxy.h"
44 45
45 /*#include "pixmaps/cancel.xpm"*/
46 #include "pixmaps/ab.xpm" 46 #include "pixmaps/ab.xpm"
47 #include "pixmaps/admin_icon.xpm" 47 #include "pixmaps/admin_icon.xpm"
48 #include "pixmaps/aol_icon.xpm" 48 #include "pixmaps/aol_icon.xpm"
49 #include "pixmaps/away_icon.xpm" 49 #include "pixmaps/away_icon.xpm"
50 #include "pixmaps/dt_icon.xpm" 50 #include "pixmaps/dt_icon.xpm"
51 #include "pixmaps/free_icon.xpm" 51 #include "pixmaps/free_icon.xpm"
52 52
53 #include "pixmaps/gnomeicu-online.xpm"
54 #include "pixmaps/gnomeicu-offline.xpm"
55 #include "pixmaps/gnomeicu-away.xpm"
56 #include "pixmaps/gnomeicu-dnd.xpm"
57 #include "pixmaps/gnomeicu-na.xpm"
58 #include "pixmaps/gnomeicu-occ.xpm"
59 #include "pixmaps/gnomeicu-ffc.xpm"
60
53 /* constants to identify proto_opts */ 61 /* constants to identify proto_opts */
54 #define USEROPT_AUTH 0 62 #define USEROPT_AUTH 0
55 #define USEROPT_AUTHPORT 1 63 #define USEROPT_AUTHPORT 1
56 64
57 #define UC_AB 32 65 #define UC_AOL 0x02
66 #define UC_ADMIN 0x04
67 #define UC_UNCONFIRMED 0x08
68 #define UC_NORMAL 0x10
69 #define UC_AB 0x20
70
71 #define ICQ_ONLINE 0x0000
72 #define ICQ_AWAY 0x0001
73 #define ICQ_DND 0x0002
74 #define ICQ_NA 0x0004
75 #define ICQ_OCCUPIED 0x0010
76 #define ICQ_CHAT 0x0020
77 #define ICQ_INVISIBLE 0x0100
58 78
59 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" 79 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3"
60 80
61 static int gaim_caps = AIM_CAPS_CHAT | 81 static int gaim_caps = AIM_CAPS_CHAT |
62 AIM_CAPS_BUDDYICON | 82 AIM_CAPS_BUDDYICON |
81 101
82 GSList *oscar_chats; 102 GSList *oscar_chats;
83 GSList *direct_ims; 103 GSList *direct_ims;
84 GSList *hasicons; 104 GSList *hasicons;
85 105
86 gboolean killme; 106 gboolean killme;
107 gboolean icq;
87 }; 108 };
88 109
89 struct chat_connection { 110 struct chat_connection {
90 char *name; 111 char *name;
91 char *show; /* AOL did something funny to us */ 112 char *show; /* AOL did something funny to us */
425 struct gaim_connection *gc = new_gaim_conn(user); 446 struct gaim_connection *gc = new_gaim_conn(user);
426 struct oscar_data *odata = gc->proto_data = g_new0(struct oscar_data, 1); 447 struct oscar_data *odata = gc->proto_data = g_new0(struct oscar_data, 1);
427 odata->create_exchange = 0; 448 odata->create_exchange = 0;
428 449
429 debug_printf(_("Logging in %s\n"), user->username); 450 debug_printf(_("Logging in %s\n"), user->username);
451 if (isdigit(*user->username))
452 odata->icq = TRUE;
430 453
431 sess = g_new0(aim_session_t, 1); 454 sess = g_new0(aim_session_t, 1);
432 455
433 aim_session_init(sess, AIM_SESS_FLAGS_NONBLOCKCONNECT, 0); 456 aim_session_init(sess, AIM_SESS_FLAGS_NONBLOCKCONNECT, 0);
434 aim_setdebuggingcb(sess, oscar_debug); 457 aim_setdebuggingcb(sess, oscar_debug);
1123 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) { 1146 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) {
1124 aim_userinfo_t *info; 1147 aim_userinfo_t *info;
1125 time_t time_idle; 1148 time_t time_idle;
1126 int type = 0; 1149 int type = 0;
1127 struct gaim_connection *gc = sess->aux_data; 1150 struct gaim_connection *gc = sess->aux_data;
1151 struct oscar_data *od = gc->proto_data;
1128 char *tmp; 1152 char *tmp;
1129 1153
1130 va_list ap; 1154 va_list ap;
1131 va_start(ap, fr); 1155 va_start(ap, fr);
1132 info = va_arg(ap, aim_userinfo_t *); 1156 info = va_arg(ap, aim_userinfo_t *);
1133 va_end(ap); 1157 va_end(ap);
1134 1158
1135 if (info->flags & AIM_FLAG_ACTIVEBUDDY) 1159 if (!od->icq) {
1136 type |= UC_AB; 1160 if (info->flags & AIM_FLAG_ACTIVEBUDDY)
1137 if (info->flags & AIM_FLAG_UNCONFIRMED) 1161 type |= UC_AB;
1138 type |= UC_UNCONFIRMED; 1162 if (info->flags & AIM_FLAG_UNCONFIRMED)
1139 if (info->flags & AIM_FLAG_ADMINISTRATOR) 1163 type |= UC_UNCONFIRMED;
1140 type |= UC_ADMIN; 1164 if (info->flags & AIM_FLAG_ADMINISTRATOR)
1141 if (info->flags & AIM_FLAG_AOL) 1165 type |= UC_ADMIN;
1142 type |= UC_AOL; 1166 if (info->flags & AIM_FLAG_AOL)
1143 if (info->flags & AIM_FLAG_FREE) 1167 type |= UC_AOL;
1144 type |= UC_NORMAL; 1168 if (info->flags & AIM_FLAG_FREE)
1145 if (info->flags & AIM_FLAG_AWAY) 1169 type |= UC_NORMAL;
1146 type |= UC_UNAVAILABLE; 1170 if (info->flags & AIM_FLAG_AWAY)
1171 type |= UC_UNAVAILABLE;
1172 } else {
1173 if (info->icqinfo.status) {
1174 type = (info->icqinfo.status << 6);
1175 if (!(info->icqinfo.status & ICQ_CHAT))
1176 type |= UC_UNAVAILABLE;
1177 }
1178 debug_printf("icq status: %d\n", info->icqinfo.status);
1179 }
1147 1180
1148 if (info->idletime) { 1181 if (info->idletime) {
1149 time(&time_idle); 1182 time(&time_idle);
1150 time_idle -= info->idletime*60; 1183 time_idle -= info->idletime*60;
1151 } else 1184 } else
2178 if (strlen(info) > 1024) 2211 if (strlen(info) > 1024)
2179 do_error_dialog("Maximum info length (1024) exceeded, truncating", "Info Too Long"); 2212 do_error_dialog("Maximum info length (1024) exceeded, truncating", "Info Too Long");
2180 aim_bos_setprofile(odata->sess, odata->conn, inforeal, g->away ? NULL : "", gaim_caps); 2213 aim_bos_setprofile(odata->sess, odata->conn, inforeal, g->away ? NULL : "", gaim_caps);
2181 } 2214 }
2182 2215
2183 static void oscar_set_away(struct gaim_connection *g, char *state, char *message) { 2216 static void oscar_set_away(struct gaim_connection *gc, char *state, char *message) {
2184 struct oscar_data *odata = (struct oscar_data *)g->proto_data; 2217 struct oscar_data *od = (struct oscar_data *)gc->proto_data;
2185 char info[1025], away[1025]; 2218 char away[1025];
2186 g_snprintf(info, sizeof(info), "%s", g->user->user_info); 2219 if (!od->icq) {
2187 if (message) 2220 if (message)
2188 g_snprintf(away, sizeof(away), "%s", message); 2221 g_snprintf(away, sizeof(away), "%s", message);
2189 aim_bos_setprofile(odata->sess, odata->conn, NULL, message ? away : "", gaim_caps); 2222 aim_bos_setprofile(od->sess, od->conn, NULL, message ? away : "", gaim_caps);
2190 if (g->away) 2223 if (gc->away)
2191 g_free (g->away); 2224 g_free (gc->away);
2192 g->away = NULL; 2225 gc->away = NULL;
2193 if (message) { 2226 if (message) {
2194 if (strlen(message) > 1024) 2227 if (strlen(message) > 1024)
2195 do_error_dialog("Maximum away length (1024) exceeded, truncating", 2228 do_error_dialog("Maximum away length (1024) exceeded, truncating",
2196 "Info Too Long"); 2229 "Info Too Long");
2197 g->away = g_strdup (message); 2230 gc->away = g_strdup (message);
2231 }
2232 return;
2233 }
2234
2235 if (gc->away)
2236 gc->away = NULL;
2237
2238 if (!strcmp(state, "Online"))
2239 aim_icq_setstatus(od->sess, od->conn, ICQ_ONLINE);
2240 else if (!strcmp(state, "Away")) {
2241 aim_icq_setstatus(od->sess, od->conn, ICQ_AWAY);
2242 gc->away = "";
2243 } else if (!strcmp(state, "Do Not Disturb")) {
2244 aim_icq_setstatus(od->sess, od->conn, ICQ_DND);
2245 gc->away = "";
2246 } else if (!strcmp(state, "Not Available")) {
2247 aim_icq_setstatus(od->sess, od->conn, ICQ_NA);
2248 gc->away = "";
2249 } else if (!strcmp(state, "Occupied")) {
2250 aim_icq_setstatus(od->sess, od->conn, ICQ_OCCUPIED);
2251 gc->away = "";
2252 } else if (!strcmp(state, "Free For Chat")) {
2253 aim_icq_setstatus(od->sess, od->conn, ICQ_CHAT);
2254 gc->away = "";
2255 } else if (!strcmp(state, "Invisible")) {
2256 aim_icq_setstatus(od->sess, od->conn, ICQ_INVISIBLE);
2257 gc->away = "";
2258 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) {
2259 if (message) {
2260 aim_icq_setstatus(od->sess, od->conn, ICQ_NA);
2261 gc->away = "";
2262 } else {
2263 aim_icq_setstatus(od->sess, od->conn, ICQ_ONLINE);
2264 }
2198 } 2265 }
2199 } 2266 }
2200 2267
2201 static void oscar_warn(struct gaim_connection *g, char *name, int anon) { 2268 static void oscar_warn(struct gaim_connection *g, char *name, int anon) {
2202 struct oscar_data *odata = (struct oscar_data *)g->proto_data; 2269 struct oscar_data *odata = (struct oscar_data *)g->proto_data;
2382 g_free(buf); 2449 g_free(buf);
2383 return 0; 2450 return 0;
2384 } 2451 }
2385 2452
2386 static char **oscar_list_icon(int uc) { 2453 static char **oscar_list_icon(int uc) {
2454 if (uc == 0)
2455 return (char **)icon_online_xpm;
2456 if (uc & 0x7fc0) {
2457 uc >>= 6;
2458 if (uc & ICQ_AWAY)
2459 return icon_away_xpm;
2460 if (uc & ICQ_DND)
2461 return icon_dnd_xpm;
2462 if (uc & ICQ_NA)
2463 return icon_na_xpm;
2464 if (uc & ICQ_OCCUPIED)
2465 return icon_occ_xpm;
2466 if (uc & ICQ_CHAT)
2467 return icon_ffc_xpm;
2468 if (uc & ICQ_INVISIBLE)
2469 return icon_offline_xpm;
2470 return icon_online_xpm;
2471 }
2387 if (uc & UC_AB) 2472 if (uc & UC_AB)
2388 return (char **)ab_xpm; 2473 return (char **)ab_xpm;
2389 if (uc & UC_UNAVAILABLE) 2474 if (uc & UC_UNAVAILABLE)
2390 return (char **)away_icon_xpm; 2475 return (char **)away_icon_xpm;
2391 if (uc & UC_AOL) 2476 if (uc & UC_AOL)
2621 static void oscar_rem_deny(struct gaim_connection *gc, char *who) { 2706 static void oscar_rem_deny(struct gaim_connection *gc, char *who) {
2622 if (gc->permdeny != 4) return; 2707 if (gc->permdeny != 4) return;
2623 oscar_set_permit_deny(gc); 2708 oscar_set_permit_deny(gc);
2624 } 2709 }
2625 2710
2626 static GList *oscar_away_states() 2711 static GList *oscar_away_states(struct gaim_connection *gc)
2627 { 2712 {
2628 return g_list_append(NULL, GAIM_AWAY_CUSTOM); 2713 struct oscar_data *od = gc->proto_data;
2714 GList *m = NULL;
2715
2716 if (!od->icq)
2717 return g_list_append(m, GAIM_AWAY_CUSTOM);
2718
2719 m = g_list_append(m, "Online");
2720 m = g_list_append(m, "Away");
2721 m = g_list_append(m, "Do Not Disturb");
2722 m = g_list_append(m, "Not Available");
2723 m = g_list_append(m, "Occupied");
2724 m = g_list_append(m, "Free For Chat");
2725 m = g_list_append(m, "Invisible");
2726
2727 return m;
2629 } 2728 }
2630 2729
2631 static void oscar_do_action(struct gaim_connection *gc, char *act) 2730 static void oscar_do_action(struct gaim_connection *gc, char *act)
2632 { 2731 {
2633 struct oscar_data *od = gc->proto_data; 2732 struct oscar_data *od = gc->proto_data;