src/protocols/oscar/oscar.c

changeset 5131
ce6d77bc4102
parent 5129
c1cfbdfcd381
child 5134
2fe0e6406f52
equal deleted inserted replaced
5130:f21e25392d02 5131:ce6d77bc4102
3088 bit <<= 1; 3088 bit <<= 1;
3089 } 3089 }
3090 return buf; 3090 return buf;
3091 } 3091 }
3092 3092
3093 static char *oscar_tooltip_text(struct buddy *b) {
3094 struct gaim_connection *gc = b->account->gc;
3095 struct oscar_data *od = gc->proto_data;
3096 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, normalize(b->name));
3097
3098 if (bi) {
3099 gchar *yay;
3100 char *caps = caps_string(bi->caps);
3101 char *tstr = sec_to_text(time(NULL) - bi->signon +
3102 (gc->login_time_official ? gc->login_time_official - gc->login_time : 0));
3103 yay = g_strdup_printf(_("<b>Logged In:</b> %s%s%s"), tstr,
3104 caps ? _("\n<b>Capabilities:</b> ") : "", caps ? caps : "");
3105 free(tstr);
3106
3107 if (isdigit(b->name[0])) {
3108 char *tmp, *status = gaim_icq_status((b->uc & 0xffff0000) >> 16);
3109 tmp = yay;
3110 yay = g_strconcat(tmp, _("\n<b>Status:</b> "), status, NULL);
3111 g_free(tmp);
3112 g_free(status);
3113 }
3114
3115 return yay;
3116 } else {
3117 return NULL;
3118 }
3119 }
3120
3121 static int gaim_parse_user_info(aim_session_t *sess, aim_frame_t *fr, ...) { 3093 static int gaim_parse_user_info(aim_session_t *sess, aim_frame_t *fr, ...) {
3122 struct gaim_connection *gc = sess->aux_data; 3094 struct gaim_connection *gc = sess->aux_data;
3123 struct oscar_data *od = gc->proto_data; 3095 struct oscar_data *od = gc->proto_data;
3124 char header[BUF_LONG]; 3096 char header[BUF_LONG];
3125 GSList *l = od->evilhack; 3097 GSList *l = od->evilhack;
4738 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { 4710 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) {
4739 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); 4711 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans"));
4740 gaim_blist_add_group(g, NULL); 4712 gaim_blist_add_group(g, NULL);
4741 } 4713 }
4742 4714
4743 debug_printf("ssi: adding buddy %s to group %s to local list\n", curitem->name, gname); 4715 debug_printf("ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans"));
4744 gaim_blist_add_buddy(buddy, g, NULL); 4716 gaim_blist_add_buddy(buddy, g, NULL);
4745 export = TRUE; 4717 export = TRUE;
4746 } 4718 }
4747 free(gname_utf8); 4719 free(gname_utf8);
4748 free(alias_utf8); 4720 free(alias_utf8);
5227 static void oscar_list_emblems(struct buddy *b, char **se, char **sw, char **nw, char **ne) 5199 static void oscar_list_emblems(struct buddy *b, char **se, char **sw, char **nw, char **ne)
5228 { 5200 {
5229 char *emblems[4] = {NULL,NULL,NULL,NULL}; 5201 char *emblems[4] = {NULL,NULL,NULL,NULL};
5230 int i = 0; 5202 int i = 0;
5231 5203
5232 if (b->present == GAIM_BUDDY_OFFLINE) 5204 if (!GAIM_BUDDY_IS_ONLINE(b)) {
5233 emblems[i++] = "offline"; 5205 struct gaim_account *account;
5206 struct gaim_connection *gc;
5207 struct oscar_data *od;
5208 char *gname;
5209 if ((b->name) && (account = b->account) && (gc = account->gc) &&
5210 (od = gc->proto_data) && (od->sess->ssi.received_data) &&
5211 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) &&
5212 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) {
5213 emblems[i++] = "notauthorized";
5214 } else {
5215 emblems[i++] = "offline";
5216 }
5217 }
5234 5218
5235 if (b->name && (b->uc & 0xffff0000) && isdigit(b->name[0])) { 5219 if (b->name && (b->uc & 0xffff0000) && isdigit(b->name[0])) {
5236 int uc = b->uc >> 16; 5220 int uc = b->uc >> 16;
5237 if (uc & AIM_ICQ_STATE_INVISIBLE) 5221 if (uc & AIM_ICQ_STATE_INVISIBLE)
5238 emblems[i++] = "invisible"; 5222 emblems[i++] = "invisible";
5264 *sw = emblems[1]; 5248 *sw = emblems[1];
5265 *nw = emblems[2]; 5249 *nw = emblems[2];
5266 *ne = emblems[3]; 5250 *ne = emblems[3];
5267 } 5251 }
5268 5252
5253 static char *oscar_tooltip_text(struct buddy *b) {
5254 struct gaim_connection *gc = b->account->gc;
5255 struct oscar_data *od = gc->proto_data;
5256 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, normalize(b->name));
5257 gchar *tmp, *yay = g_strdup("");
5258
5259 if (GAIM_BUDDY_IS_ONLINE(b)) {
5260 if (isdigit(b->name[0])) {
5261 char *tmp, *status;
5262 status = gaim_icq_status((b->uc & 0xffff0000) >> 16);
5263 tmp = yay;
5264 yay = g_strconcat(tmp, _("<b>Status:</b> "), status, "\n", NULL);
5265 g_free(tmp);
5266 g_free(status);
5267 }
5268
5269 if (bi) {
5270 char *tstr = sec_to_text(time(NULL) - bi->signon +
5271 (gc->login_time_official ? gc->login_time_official - gc->login_time : 0));
5272 tmp = yay;
5273 yay = g_strconcat(tmp, _("<b>Logged In:</b> "), tstr, "\n", NULL);
5274 free(tmp);
5275 free(tstr);
5276
5277 if (bi->caps) {
5278 char *caps = caps_string(bi->caps);
5279 tmp = yay;
5280 yay = g_strconcat(tmp, _("<b>Capabilities:</b> "), caps, "\n", NULL);
5281 free(tmp);
5282 }
5283 }
5284 } else {
5285 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name);
5286 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) {
5287 tmp = yay;
5288 yay = g_strconcat(tmp, _("<b>Status:</b> Not Authorized"), "\n", NULL);
5289 g_free(tmp);
5290 } else {
5291 tmp = yay;
5292 yay = g_strconcat(tmp, _("<b>Status:</b> Offline"), "\n", NULL);
5293 g_free(tmp);
5294 }
5295 }
5296
5297 /* remove the trailing newline character */
5298 if (yay)
5299 yay[strlen(yay)-1] = '\0';
5300 return yay;
5301 }
5302
5269 /* 5303 /*
5270 * We have just established a socket with the other dude, so set up some handlers. 5304 * We have just established a socket with the other dude, so set up some handlers.
5271 */ 5305 */
5272 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { 5306 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) {
5273 struct gaim_connection *gc = sess->aux_data; 5307 struct gaim_connection *gc = sess->aux_data;
5611 pbm->callback = oscar_ask_getfile; 5645 pbm->callback = oscar_ask_getfile;
5612 pbm->gc = gc; 5646 pbm->gc = gc;
5613 m = g_list_append(m, pbm); 5647 m = g_list_append(m, pbm);
5614 #endif 5648 #endif
5615 } 5649 }
5650 }
5616 5651
5617 if (od->sess->ssi.received_data) { 5652 if (od->sess->ssi.received_data) {
5618 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, who); 5653 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, who);
5619 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, who)) { 5654 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, who)) {
5620 pbm = g_new0(struct proto_buddy_menu, 1); 5655 pbm = g_new0(struct proto_buddy_menu, 1);
5621 pbm->label = _("Re-request Authorization"); 5656 pbm->label = _("Re-request Authorization");
5622 pbm->callback = gaim_auth_sendrequest; 5657 pbm->callback = gaim_auth_sendrequest;
5623 pbm->gc = gc; 5658 pbm->gc = gc;
5624 m = g_list_append(m, pbm); 5659 m = g_list_append(m, pbm);
5625 } 5660 }
5626 }
5627
5628 } 5661 }
5629 5662
5630 return m; 5663 return m;
5631 } 5664 }
5632 5665
5866 ret->protocol = PROTO_OSCAR; 5899 ret->protocol = PROTO_OSCAR;
5867 ret->options = OPT_PROTO_MAIL_CHECK | OPT_PROTO_BUDDY_ICON | OPT_PROTO_IM_IMAGE; 5900 ret->options = OPT_PROTO_MAIL_CHECK | OPT_PROTO_BUDDY_ICON | OPT_PROTO_IM_IMAGE;
5868 ret->name = g_strdup("AIM/ICQ"); 5901 ret->name = g_strdup("AIM/ICQ");
5869 ret->list_icon = oscar_list_icon; 5902 ret->list_icon = oscar_list_icon;
5870 ret->list_emblems = oscar_list_emblems; 5903 ret->list_emblems = oscar_list_emblems;
5904 ret->tooltip_text = oscar_tooltip_text;
5871 ret->away_states = oscar_away_states; 5905 ret->away_states = oscar_away_states;
5872 ret->actions = oscar_actions; 5906 ret->actions = oscar_actions;
5873 ret->buddy_menu = oscar_buddy_menu; 5907 ret->buddy_menu = oscar_buddy_menu;
5874 ret->login = oscar_login; 5908 ret->login = oscar_login;
5875 ret->close = oscar_close; 5909 ret->close = oscar_close;
5906 ret->chat_leave = oscar_chat_leave; 5940 ret->chat_leave = oscar_chat_leave;
5907 ret->chat_whisper = NULL; 5941 ret->chat_whisper = NULL;
5908 ret->chat_send = oscar_chat_send; 5942 ret->chat_send = oscar_chat_send;
5909 ret->keepalive = oscar_keepalive; 5943 ret->keepalive = oscar_keepalive;
5910 ret->convo_closed = oscar_convo_closed; 5944 ret->convo_closed = oscar_convo_closed;
5911 ret->tooltip_text = oscar_tooltip_text;
5912 5945
5913 puo = g_new0(struct proto_user_opt, 1); 5946 puo = g_new0(struct proto_user_opt, 1);
5914 puo->label = g_strdup("Auth Host:"); 5947 puo->label = g_strdup("Auth Host:");
5915 puo->def = g_strdup("login.oscar.aol.com"); 5948 puo->def = g_strdup("login.oscar.aol.com");
5916 puo->pos = USEROPT_AUTH; 5949 puo->pos = USEROPT_AUTH;

mercurial