static void jabber_xmlconsole_enable(struct im_connection *ic) { struct jabber_data *jd = ic->proto_data; const char *handle = JABBER_XMLCONSOLE_HANDLE; bee_user_t *bu; jd->flags |= JFLAG_XMLCONSOLE; if (!(bu = bee_user_by_handle(ic->bee, ic, handle))) { bu = bee_user_new(ic->bee, ic, handle, 0); bu->flags |= BEE_USER_NOOTR; } }
/* IM->UI callbacks */ void imcb_buddy_status(struct im_connection *ic, const char *handle, int flags, const char *state, const char *message) { bee_t *bee = ic->bee; bee_user_t *bu, *old; if (!(bu = bee_user_by_handle(bee, ic, handle))) { if (g_strcasecmp(set_getstr(&ic->bee->set, "handle_unknown"), "add") == 0) { bu = bee_user_new(bee, ic, handle, BEE_USER_LOCAL); } else { if (g_strcasecmp(set_getstr(&ic->bee->set, "handle_unknown"), "ignore") != 0) { imcb_log(ic, "imcb_buddy_status() for unknown handle %s:\n" "flags = %d, state = %s, message = %s", handle, flags, state ? state : "NULL", message ? message : "NULL"); } return; } } /* May be nice to give the UI something to compare against. */ old = g_memdup(bu, sizeof(bee_user_t)); /* TODO(wilmer): OPT_AWAY, or just state == NULL ? */ bu->flags = flags; bu->status_msg = g_strdup(message); if (state && *state) { bu->status = g_strdup(state); } else if (flags & OPT_AWAY) { bu->status = g_strdup("Away"); } else { bu->status = NULL; } if (bu->status == NULL && (flags & OPT_MOBILE) && set_getbool(&bee->set, "mobile_is_away")) { bu->flags |= BEE_USER_AWAY; bu->status = g_strdup("Mobile"); } if (bee->ui->user_status) { bee->ui->user_status(bee, bu, old); } g_free(old->status_msg); g_free(old->status); g_free(old); }
void imcb_buddy_msg(struct im_connection *ic, const char *handle, const char *msg, uint32_t flags, time_t sent_at) { bee_t *bee = ic->bee; bee_user_t *bu; bu = bee_user_by_handle(bee, ic, handle); if (!bu && !(ic->flags & OPT_LOGGING_OUT)) { char *h = set_getstr(&bee->set, "handle_unknown"); if (g_strcasecmp(h, "ignore") == 0) { return; } else if (g_strncasecmp(h, "add", 3) == 0) { bu = bee_user_new(bee, ic, handle, BEE_USER_LOCAL); } } if (bee->ui->user_msg && bu) { bee->ui->user_msg(bee, bu, msg, sent_at); } else { imcb_log(ic, "Message from unknown handle %s:\n%s", handle, msg); } }
static void cmd_add(irc_t *irc, char **cmd) { account_t *a; int add_on_server = 1; char *handle = NULL, *s; if (g_strcasecmp(cmd[1], "-tmp") == 0) { MIN_ARGS(3); add_on_server = 0; cmd++; } if (!(a = account_get(irc->b, cmd[1]))) { irc_rootmsg(irc, "Invalid account"); return; } else if (!(a->ic && (a->ic->flags & OPT_LOGGED_IN))) { irc_rootmsg(irc, "That account is not on-line"); return; } if (cmd[3]) { if (!nick_ok(irc, cmd[3])) { irc_rootmsg(irc, "The requested nick `%s' is invalid", cmd[3]); return; } else if (irc_user_by_name(irc, cmd[3])) { irc_rootmsg(irc, "The requested nick `%s' already exists", cmd[3]); return; } else { nick_set_raw(a, cmd[2], cmd[3]); } } if ((a->flags & ACC_FLAG_HANDLE_DOMAINS) && cmd[2][0] != '_' && (!(s = strchr(cmd[2], '@')) || s[1] == '\0')) { /* If there's no @ or it's the last char, append the user's domain name now. Exclude handles starting with a _ so adding _xmlconsole will keep working. */ if (s) { *s = '\0'; } if ((s = strchr(a->user, '@'))) { cmd[2] = handle = g_strconcat(cmd[2], s, NULL); } } if (add_on_server) { irc_channel_t *ic; char *s, *group = NULL;; if ((ic = irc->root->last_channel) && (s = set_getstr(&ic->set, "fill_by")) && strcmp(s, "group") == 0 && (group = set_getstr(&ic->set, "group"))) { irc_rootmsg(irc, "Adding `%s' to contact list (group %s)", cmd[2], group); } else { irc_rootmsg(irc, "Adding `%s' to contact list", cmd[2]); } a->prpl->add_buddy(a->ic, cmd[2], group); } else { bee_user_t *bu; irc_user_t *iu; /* Only for add -tmp. For regular adds, this callback will be called once the IM server confirms. */ if ((bu = bee_user_new(irc->b, a->ic, cmd[2], BEE_USER_LOCAL)) && (iu = bu->ui_data)) { irc_rootmsg(irc, "Temporarily assigned nickname `%s' " "to contact `%s'", iu->nick, cmd[2]); } } g_free(handle); }
int msn_buddy_list_add( struct im_connection *ic, msn_buddy_flags_t list, const char *who, const char *realname, const char *group ) { struct msn_data *md = ic->proto_data; char groupid[8]; bee_user_t *bu; struct msn_buddy_data *bd; char *adl; *groupid = '\0'; #if 0 if( group ) { int i; for( i = 0; i < md->groupcount; i ++ ) if( g_strcasecmp( md->grouplist[i], group ) == 0 ) { g_snprintf( groupid, sizeof( groupid ), " %d", i ); break; } if( *groupid == '\0' ) { /* Have to create this group, it doesn't exist yet. */ struct msn_groupadd *ga; GSList *l; for( l = md->grpq; l; l = l->next ) { ga = l->data; if( g_strcasecmp( ga->group, group ) == 0 ) break; } ga = g_new0( struct msn_groupadd, 1 ); ga->who = g_strdup( who ); ga->group = g_strdup( group ); md->grpq = g_slist_prepend( md->grpq, ga ); if( l == NULL ) { char groupname[strlen(group)+1]; strcpy( groupname, group ); http_encode( groupname ); g_snprintf( buf, sizeof( buf ), "ADG %d %s %d\r\n", ++md->trId, groupname, 0 ); return msn_write( ic, buf, strlen( buf ) ); } else { /* This can happen if the user's doing lots of adds to a new group at once; we're still waiting for the server to confirm group creation. */ return 1; } } } #endif if( !( ( bu = bee_user_by_handle( ic->bee, ic, who ) ) || ( bu = bee_user_new( ic->bee, ic, who, 0 ) ) ) || !( bd = bu->data ) || bd->flags & list ) return 1; bd->flags |= list; if( list == MSN_BUDDY_FL ) msn_soap_ab_contact_add( ic, bu ); else msn_soap_memlist_edit( ic, who, TRUE, list ); if( ( adl = adlrml_entry( who, list ) ) ) { int st = msn_ns_write( ic, -1, "ADL %d %zd\r\n%s", ++md->trId, strlen( adl ), adl ); g_free( adl ); return st; } return 1; }