static void msn_session_sync_users(MsnSession *session) { PurpleConnection *gc = purple_account_get_connection(session->account); GList *to_remove = NULL; GSList *buddies; g_return_if_fail(gc != NULL); /* The core used to use msn_add_buddy to add all buddies before * being logged in. This no longer happens, so we manually iterate * over the whole buddy list to identify sync issues. */ for (buddies = purple_find_buddies(session->account, NULL); buddies; buddies = g_slist_delete_link(buddies, buddies)) { PurpleBuddy *buddy = buddies->data; const gchar *buddy_name = purple_buddy_get_name(buddy); const gchar *group_name = purple_group_get_name(purple_buddy_get_group(buddy)); MsnUser *remote_user; gboolean found = FALSE; remote_user = msn_userlist_find_user(session->userlist, buddy_name); if (remote_user && remote_user->list_op & MSN_LIST_FL_OP) { GList *l; for (l = remote_user->group_ids; l; l = l->next) { const char *name = msn_userlist_find_group_name(remote_user->userlist, l->data); if (name && !g_ascii_strcasecmp(group_name, name)) { found = TRUE; break; } } /* We don't care if they're in a different group, as long as they're on the * list somewhere. If we check for the group, we cause pain, agony and * suffering for people who decide to re-arrange their buddy list elsewhere. */ if (!found) { if ((remote_user == NULL) || !(remote_user->list_op & MSN_LIST_FL_OP)) { /* The user is not on the server list */ msn_error_sync_issue(session, buddy_name, group_name); } else { /* The user is not in that group on the server list */ to_remove = g_list_prepend(to_remove, buddy); } } } } if (to_remove != NULL) { g_list_foreach(to_remove, (GFunc)purple_blist_remove_buddy, NULL); g_list_free(to_remove); } }
static char *waprpl_status_text(PurpleBuddy * buddy) { char *statusmsg; whatsapp_connection *wconn = purple_connection_get_protocol_data(purple_account_get_connection(purple_buddy_get_account(buddy))); if (!wconn) return 0; statusmsg = waAPI_getuserstatusstring(wconn->waAPI, purple_buddy_get_name(buddy)); if (!statusmsg || strlen(statusmsg) == 0) return NULL; return statusmsg; }
void oscar_auth_sendrequest_menu(PurpleBlistNode *node, gpointer ignored) { PurpleBuddy *buddy; PurpleConnection *gc; g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); buddy = (PurpleBuddy *) node; gc = purple_account_get_connection(purple_buddy_get_account(buddy)); oscar_auth_sendrequest(gc, purple_buddy_get_name(buddy), NULL); }
static void adc_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error) { MsnSession *session; PurpleAccount *account; PurpleConnection *gc; const char *list, *passport; const char *reason; char *msg = NULL; char **params; session = cmdproc->session; account = session->account; gc = purple_account_get_connection(account); params = g_strsplit(trans->params, " ", 0); list = params[0]; passport = params[1]; if (!strcmp(list, "FL")) msg = pecan_strdup_printf(_("Unable to add user on %s (%s)"), purple_account_get_username(account), purple_account_get_protocol_name(account)); else if (!strcmp(list, "BL")) msg = pecan_strdup_printf(_("Unable to block user on %s (%s)"), purple_account_get_username(account), purple_account_get_protocol_name(account)); else if (!strcmp(list, "AL")) msg = pecan_strdup_printf(_("Unable to permit user on %s (%s)"), purple_account_get_username(account), purple_account_get_protocol_name(account)); reason = pecan_error_to_string (error); if (msg != NULL) { purple_notify_error(gc, NULL, msg, reason); g_free(msg); } if (!strcmp(list, "FL")) { PurpleBuddy *buddy; buddy = purple_find_buddy(account, passport); if (buddy != NULL) purple_blist_remove_buddy(buddy); } g_strfreev(params); }
static void irc_dccsend_network_listen_cb(int sock, gpointer data) { PurpleXfer *xfer = data; struct irc_xfer_send_data *xd; PurpleConnection *gc; struct irc_conn *irc; const char *arg[2]; char *tmp; struct in_addr addr; unsigned short int port; xd = xfer->data; xd->listen_data = NULL; if (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_CANCEL_LOCAL || purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_CANCEL_REMOTE) { purple_xfer_unref(xfer); return; } xd = xfer->data; gc = purple_account_get_connection(purple_xfer_get_account(xfer)); irc = gc->proto_data; purple_xfer_unref(xfer); if (sock < 0) { purple_notify_error(gc, NULL, _("File Transfer Failed"), _("Could not open a listening port.")); purple_xfer_cancel_local(xfer); return; } xd->fd = sock; port = purple_network_get_port_from_fd(sock); purple_debug_misc("irc", "port is %hu\n", port); /* Monitor the listening socket */ xfer->watcher = purple_input_add(sock, PURPLE_INPUT_READ, irc_dccsend_send_connected, xfer); /* Send the intended recipient the DCC request */ arg[0] = xfer->who; inet_aton(purple_network_get_my_ip(irc->fd), &addr); arg[1] = tmp = g_strdup_printf("\001DCC SEND \"%s\" %u %hu %" G_GSIZE_FORMAT "\001", xfer->filename, ntohl(addr.s_addr), port, xfer->size); irc_cmd_privmsg(gc->proto_data, "msg", NULL, arg); g_free(tmp); }
void irc_msg_join(struct irc_conn *irc, const char *name, const char *from, char **args) { PurpleConnection *gc = purple_account_get_connection(irc->account); PurpleConversation *convo; char *nick = irc_mask_nick(from), *userhost; struct irc_buddy *ib; static int id = 1; if (!gc) { g_free(nick); return; } if (!purple_utf8_strcasecmp(nick, purple_connection_get_display_name(gc))) { /* We are joining a channel for the first time */ serv_got_joined_chat(gc, id++, args[0]); g_free(nick); convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[0], irc->account); if (convo == NULL) { purple_debug_error("irc", "tried to join %s but couldn't\n", args[0]); return; } purple_conversation_set_data(convo, IRC_NAMES_FLAG, GINT_TO_POINTER(FALSE)); /* Until purple_conversation_present does something that * one would expect in Pidgin, this call produces buggy * behavior both for the /join and auto-join cases. */ /* purple_conversation_present(convo); */ return; } convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[0], irc->account); if (convo == NULL) { purple_debug(PURPLE_DEBUG_ERROR, "irc", "JOIN for %s failed\n", args[0]); g_free(nick); return; } userhost = irc_mask_userhost(from); purple_conv_chat_add_user(PURPLE_CONV_CHAT(convo), nick, userhost, PURPLE_CBFLAGS_NONE, TRUE); if ((ib = g_hash_table_lookup(irc->buddies, nick)) != NULL) { ib->flag = TRUE; irc_buddy_status(nick, ib, irc); } g_free(userhost); g_free(nick); }
static void bonjour_bytestreams_connect(PurpleXfer *xfer) { PurpleBuddy *pb; PurpleAccount *account = NULL; XepXfer *xf; char dstaddr[41]; const gchar *name = NULL; unsigned char hashval[20]; char *p; int i; if(xfer == NULL) return; purple_debug_info("bonjour", "bonjour-bytestreams-connect.\n"); xf = (XepXfer*)xfer->data; if(!xf) return; pb = xf->pb; name = purple_buddy_get_name(pb); account = purple_buddy_get_account(pb); p = g_strdup_printf("%s%s%s", xf->sid, name, bonjour_get_jid(account)); purple_cipher_digest_region("sha1", (guchar *)p, strlen(p), sizeof(hashval), hashval, NULL); g_free(p); memset(dstaddr, 0, 41); p = dstaddr; for(i = 0; i < 20; i++, p += 2) snprintf(p, 3, "%02x", hashval[i]); xf->proxy_info = purple_proxy_info_new(); purple_proxy_info_set_type(xf->proxy_info, PURPLE_PROXY_SOCKS5); purple_proxy_info_set_host(xf->proxy_info, xf->proxy_host); purple_proxy_info_set_port(xf->proxy_info, xf->proxy_port); xf->proxy_connection = purple_proxy_connect_socks5_account( purple_account_get_connection(account), account, xf->proxy_info, dstaddr, 0, bonjour_bytestreams_connect_cb, xfer); if(xf->proxy_connection == NULL) { xep_ft_si_reject(xf->data, xf->iq_id, xfer->who, "404", "cancel"); /* Cancel the connection */ purple_xfer_cancel_local(xfer); } }
static void stress_login(PurpleAccount *account) { PurpleConnection *pc = NULL; PurpleGroup *g = NULL; gint n_buddies = 0, i = 0, interval = 0, maxevents = 0; /* build our possible events from the account settings */ add_event("trigger_signon", STRESS_EVENT_SIGN_ON, STRESS_EVENT_SIGN_OFF); add_event("trigger_idle", STRESS_EVENT_IDLE, STRESS_EVENT_UNIDLE); add_event("trigger_away", STRESS_EVENT_AWAY, STRESS_EVENT_BACK); add_event("trigger_typing", STRESS_EVENT_TYPING, STRESS_EVENT_STOPPED_TYPING); add_event("send_messages", STRESS_EVENT_SEND_MESSAGE, -1); nevents = g_list_length(events); /* get our connection and set it as online */ pc = purple_account_get_connection(account); purple_connection_set_state(pc, PURPLE_CONNECTED); /* grab the account settings we need for buddies */ n_buddies = purple_account_get_int(account, "nbuddies", 50); maxevents = purple_account_get_int(account, "maxevents", 100); interval = (guint)purple_account_get_int(account, "interval", 500); message_min = purple_account_get_int(account, "message_min", 16); message_max = purple_account_get_int(account, "message_max", 128); g = purple_group_new("prpl-stress"); for(i = 0; i < n_buddies; i++) { PurpleBuddy *b = NULL; StressBuddy *sb = NULL; gchar *name = NULL; /* create the buddy and it's name */ name = g_strdup_printf("stress-%04x", i); b = purple_buddy_new(account, name, NULL); g_free(name); /* add our data to the buddy */ sb = g_new0(StressBuddy, 1); sb->buddy = b; sb->maxevents = maxevents; purple_buddy_set_protocol_data(b, sb); /* add the buddy to our list and the purple blist */ buddies = g_list_prepend(buddies, sb); purple_blist_add_buddy(b, NULL, g, NULL); /* add our event timer to the buddy */ sb->timer_id = g_timeout_add(interval, stress_event_cb, sb); } }
void tgprpl_roomlist_cancel (PurpleRoomlist *list) { PurpleConnection *gc = purple_account_get_connection (list->account); if (! gc) { return; } connection_data *conn = purple_connection_get_protocol_data (gc); purple_roomlist_set_in_progress (list, FALSE); if (conn->roomlist == list) { conn->roomlist = NULL; purple_roomlist_unref (list); } }
void yahoo_doodle_send_draw_list(PurpleWhiteboard *wb, GList *draw_list) { PurpleAccount *account = purple_whiteboard_get_account(wb); PurpleConnection *gc = purple_account_get_connection(account); doodle_session *ds = purple_whiteboard_get_protocol_data(wb); char *message; g_return_if_fail(draw_list != NULL); message = yahoo_doodle_build_draw_string(ds, draw_list); yahoo_doodle_command_send_draw(gc, purple_whiteboard_get_who(wb), message, ds->imv_key); g_free(message); }
static void silcpurple_buddy_getkey_menu(PurpleBlistNode *node, gpointer data) { PurpleBuddy *buddy; PurpleConnection *gc; g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); buddy = (PurpleBuddy *) node; gc = purple_account_get_connection(buddy->account); silcpurple_buddy_getkey(gc, buddy->name); }
static void netsoul_set_away(PurpleAccount *account, PurpleStatus* status) { int ns_state; PurplePresence* state = purple_status_get_presence (status); if (purple_presence_is_available (state)) ns_state = NS_STATE_ACTIF; else if (purple_presence_is_idle (state)) ns_state = NS_STATE_IDLE; else ns_state = NS_STATE_AWAY; ns_send_state(purple_account_get_connection (account), ns_state, time(NULL)); }
void yahoo_doodle_end(PurpleWhiteboard *wb) { PurpleConnection *gc = purple_account_get_connection(wb->account); doodle_session *ds = wb->proto_data; /* g_debug_debug("yahoo", "doodle: yahoo_doodle_end()\n"); */ if (gc && wb->state != DOODLE_STATE_CANCELLED) yahoo_doodle_command_send_shutdown(gc, wb->who); g_free(ds->imv_key); g_free(wb->proto_data); }
static void notify_button_activated(GntWidget *widget, PurpleNotifySearchButton *b) { GList *list = NULL; PurpleAccount *account = g_object_get_data(G_OBJECT(widget), "notify-account"); gpointer data = g_object_get_data(G_OBJECT(widget), "notify-data"); list = gnt_tree_get_selection_text_list(GNT_TREE(g_object_get_data(G_OBJECT(widget), "notify-tree"))); b->callback(purple_account_get_connection(account), list, data); g_list_foreach(list, (GFunc)g_free, NULL); g_list_free(list); }
static void iln_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { MsnSession *session; PurpleAccount *account; PurpleConnection *gc; PecanContact *user; #if defined(PECAN_CVR) MsnObject *msnobj; #endif /* defined(PECAN_CVR) */ const char *state, *passport; gchar *friendly; session = cmdproc->session; account = session->account; gc = purple_account_get_connection(account); state = cmd->params[1]; passport = cmd->params[2]; friendly = pecan_url_decode(cmd->params[3]); user = pecan_contactlist_find_contact(session->contactlist, passport); pecan_contact_set_state(user, state); pecan_contact_set_friendly_name(user, friendly); if (cmd->param_count >= 5) { gulong client_id; client_id = atol (cmd->params[4]); pecan_contact_set_client_id (user, client_id); } #if defined(PECAN_CVR) if (session->use_userdisplay) { if (cmd->param_count == 6) { gchar *tmp; tmp = pecan_url_decode (cmd->params[5]); msnobj = msn_object_new_from_string (tmp); pecan_contact_set_object(user, msnobj); g_free (tmp); } } #endif /* defined(PECAN_CVR) */ pecan_contact_update(user); g_free (friendly); }
static void campfire_login(PurpleAccount * account) { /*don't really login (it's stateless), but init the CampfireConn */ PurpleConnection *gc = purple_account_get_connection(account); const char *username = purple_account_get_username(account); CampfireConn *conn; char *pos; PurpleCmdFlag f = PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY; gchar *prpl_id = "prpl-analog_g-campfire"; /* analog_g = developer.pidgin.im Trac username */ conn = g_new0(CampfireConn, 1); purple_debug_info("campfire", "num_xaction_malloc:%d: num_xaction_free:%d\n", conn->num_xaction_malloc, conn->num_xaction_free); conn->gc = gc; conn->account = account; /* Find the last '@'; usernames can have '@' in them. */ pos = strrchr(username, '@'); conn->hostname = g_strdup(pos+1); pos[0] = 0; purple_connection_set_display_name(gc, username); pos[0] = '@'; purple_debug_info("campfire", "username: %s\n", username); purple_debug_info("campfire", "hostname: %s\n", conn->hostname); gc->proto_data = conn; /*register campfire commands */ purple_cmd_register(CAMPFIRE_CMD_ME, "s", PURPLE_CMD_P_PRPL, f, prpl_id, campfire_parse_cmd, "me <action to perform>: Perform an action.", conn); purple_cmd_register(CAMPFIRE_CMD_TOPIC, "s", PURPLE_CMD_P_PRPL, f | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, prpl_id, campfire_parse_cmd, "topic <new topic>: Change the room topic.", conn); purple_cmd_register(CAMPFIRE_CMD_ROOM, "s", PURPLE_CMD_P_PRPL, f, prpl_id, campfire_parse_cmd, "room <new room name>: Change the room name (admin only).", conn); purple_cmd_register(CAMPFIRE_CMD_PLAY, "w", PURPLE_CMD_P_PRPL, f, prpl_id, campfire_parse_cmd, "play <sound>: Play a sound (trombone, rimshot, crickets, live).", conn); purple_connection_set_state(gc, PURPLE_CONNECTED); }
int irc_send(struct irc_conn *irc, const char *buf) { int ret, buflen; char *tosend= g_strdup(buf); purple_signal_emit(_irc_plugin, "irc-sending-text", purple_account_get_connection(irc->account), &tosend); if (tosend == NULL) return 0; buflen = strlen(tosend); /* If we're not buffering writes, try to send immediately */ if (!irc->writeh) ret = do_send(irc, tosend, buflen); else { ret = -1; errno = EAGAIN; } /* purple_debug(PURPLE_DEBUG_MISC, "irc", "sent%s: %s", irc->gsc ? " (ssl)" : "", tosend); */ if (ret <= 0 && errno != EAGAIN) { purple_connection_error(purple_account_get_connection(irc->account), _("Server has disconnected")); } else if (ret < buflen) { if (ret < 0) ret = 0; if (!irc->writeh) irc->writeh = purple_input_add( irc->gsc ? irc->gsc->fd : irc->fd, PURPLE_INPUT_WRITE, irc_send_cb, irc); purple_circ_buffer_append(irc->outbuf, tosend + ret, buflen - ret); } g_free(tosend); return ret; }
void flist_purple_set_status(PurpleAccount *account, PurpleStatus *status) { PurpleConnection *pc = purple_account_get_connection(account); FListAccount *fla = pc->proto_data; PurpleStatusType *statusType = purple_status_get_type(status); GList *statusTypes = flist_status_types(account); GList *cur = statusTypes; FListStatus fStatus = FLIST_STATUS_UNKNOWN; // The status isn't active! bail! if (!purple_status_is_active(status)) return; // First, get the presence. If it's idle, we default to idle. PurplePresence *presence = purple_status_get_presence(status); if(purple_presence_is_idle(presence)) { flist_set_status(fla, FLIST_STATUS_IDLE, purple_status_get_attr_string(status, FLIST_STATUS_MESSAGE_KEY)); } // Alright, not idle. Next, compare StatusType IDs. If it's a match, use that. while(cur) { PurpleStatusType *type = cur->data; if(strcmp(purple_status_type_get_id(type), purple_status_type_get_id(statusType)) == 0){ fStatus = flist_parse_status(purple_status_type_get_id(statusType)); break; } else { cur = g_list_next(cur); } } // Found a matching F-list Status. Use it! if(fStatus != FLIST_STATUS_UNKNOWN) { flist_set_status(fla, fStatus, purple_status_get_attr_string(status, FLIST_STATUS_MESSAGE_KEY)); } else { // Alright, seems the status we chose isn't an F-list one. Let's convert to the next best primitive. switch (purple_status_type_get_primitive(statusType)) { case PURPLE_STATUS_AWAY: case PURPLE_STATUS_EXTENDED_AWAY: flist_set_status(fla, FLIST_STATUS_AWAY, purple_status_get_attr_string(status, FLIST_STATUS_MESSAGE_KEY)); break; case PURPLE_STATUS_UNAVAILABLE: flist_set_status(fla, FLIST_STATUS_DND, purple_status_get_attr_string(status, FLIST_STATUS_MESSAGE_KEY)); break; // Assume AVAILABLE by default if it's not an AWAY/DND status default: flist_set_status(fla, FLIST_STATUS_AVAILABLE, purple_status_get_attr_string(status, FLIST_STATUS_MESSAGE_KEY)); } } g_list_free(statusTypes); flist_update_server_status(fla); }
void irc_msg_nosend(struct irc_conn *irc, const char *name, const char *from, char **args) { PurpleConnection *gc; PurpleConversation *convo; convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); if (convo) { purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[1], args[2], PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); } else { if ((gc = purple_account_get_connection(irc->account)) == NULL) return; purple_notify_error(gc, NULL, _("Could not send"), args[2]); } }
void irc_msg_wallops(struct irc_conn *irc, const char *name, const char *from, char **args) { PurpleConnection *gc = purple_account_get_connection(irc->account); char *nick, *msg; if (!args || !args[0] || !gc) return; nick = irc_mask_nick(from); msg = g_strdup_printf (_("Wallops from %s"), nick); g_free(nick); purple_notify_info(gc, NULL, msg, args[0]); g_free(msg); }
void irc_msg_badnick(struct irc_conn *irc, const char *name, const char *from, char **args) { PurpleConnection *gc = purple_account_get_connection(irc->account); if (purple_connection_get_state(gc) == PURPLE_CONNECTED) { purple_notify_error(gc, _("Invalid nickname"), _("Invalid nickname"), _("Your selected nickname was rejected by the server. It probably contains invalid characters.")); } else { purple_connection_error_reason (gc, PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, _("Your selected account name was rejected by the server. It probably contains invalid characters.")); } }
/*------------------------------------------------------------------------ * Re-Invite was selected from the buddy-list menu. * * @param node The entry in the buddy list. * @param ignored (not used) */ static void mxit_reinvite( PurpleBlistNode *node, gpointer ignored ) { PurpleBuddy* buddy = (PurpleBuddy *) node; PurpleConnection* gc = purple_account_get_connection( purple_buddy_get_account( buddy ) ); struct MXitSession* session = purple_connection_get_protocol_data( gc ); struct contact* contact; contact = purple_buddy_get_protocol_data( (PurpleBuddy*) node ); if ( !contact ) return; /* send a new invite */ mxit_send_invite( session, contact->username, TRUE, contact->alias, contact->groupname, NULL ); }
static int purple_send_typing( struct im_connection *ic, char *who, int flags ) { PurpleTypingState state = PURPLE_NOT_TYPING; PurpleAccount *pa = ic->proto_data; if( flags & OPT_TYPING ) state = PURPLE_TYPING; else if( flags & OPT_THINKING ) state = PURPLE_TYPED; serv_send_typing( purple_account_get_connection( pa ), who, state ); return 1; }
static void visibility_cb(PurpleBlistNode *node, gpointer whatever) { PurpleBuddy *buddy = PURPLE_BUDDY(node); const char* bname = purple_buddy_get_name(buddy); OscarData *od = purple_connection_get_protocol_data(purple_account_get_connection(purple_buddy_get_account(buddy))); guint16 list_type = get_buddy_list_type(od); if (!is_buddy_on_list(od, bname)) { aim_ssi_add_to_private_list(od, bname, list_type); } else { aim_ssi_del_from_private_list(od, bname, list_type); } }
static void nap_login(PurpleAccount *account) { PurpleConnection *gc = purple_account_get_connection(account); purple_connection_update_progress(gc, _("Connecting"), 0, NAPSTER_CONNECT_STEPS); gc->proto_data = g_new0(struct nap_data, 1); if (purple_proxy_connect(gc, account, purple_account_get_string(account, "server", NAP_SERVER), purple_account_get_int(account, "port", NAP_PORT), nap_login_connect, gc) != 0) { purple_connection_error(gc, _("Unable to connect.")); } }
static void send_offline_file_receipt(LwqqAsyncEvent* ev,PurpleXfer* xfer) { int errno = lwqq_async_event_get_result(ev); qq_account* ac = purple_connection_get_protocol_data(purple_account_get_connection(xfer->account)); LwqqMsgOffFile* file = xfer->data; if(errno == 0){ qq_sys_msg_write(ac, LWQQ_MT_BUDDY_MSG, file->to, "发送离线文件成功", PURPLE_MESSAGE_SYSTEM, time(NULL)); }else{ qq_sys_msg_write(ac, LWQQ_MT_BUDDY_MSG, file->to, "发送离线文件失败", PURPLE_MESSAGE_ERROR, time(NULL)); } lwqq_msg_offfile_free(file); purple_xfer_set_completed(xfer,1); }
void purple_prpl_got_user_status(PurpleAccount *account, const char *name, const char *status_id, ...) { GSList *list, *l; PurpleBuddy *buddy; PurplePresence *presence; PurpleStatus *status; PurpleStatus *old_status; va_list args; g_return_if_fail(account != NULL); g_return_if_fail(name != NULL); g_return_if_fail(status_id != NULL); g_return_if_fail(purple_account_is_connected(account) || purple_account_is_connecting(account)); if((list = purple_find_buddies(account, name)) == NULL) return; for(l = list; l != NULL; l = l->next) { buddy = l->data; presence = purple_buddy_get_presence(buddy); status = purple_presence_get_status(presence, status_id); if(NULL == status) /* * TODO: This should never happen, right? We should call * g_warning() or something. */ continue; old_status = purple_presence_get_active_status(presence); va_start(args, status_id); purple_status_set_active_with_attrs(status, TRUE, args); va_end(args); purple_blist_update_buddy_status(buddy, old_status); } g_slist_free(list); /* The buddy is no longer online, they are therefore by definition not * still typing to us. */ if (!purple_status_is_online(status)) { serv_got_typing_stopped(purple_account_get_connection(account), name); purple_prpl_got_media_caps(account, name); } }
char *irc_parse_ctcp(struct irc_conn *irc, const char *from, const char *to, const char *msg, int notice) { PurpleConnection *gc; const char *cur = msg + 1; char *buf, *ctcp; time_t timestamp; /* Note that this is NOT correct w.r.t. multiple CTCPs in one * message and low-level quoting ... but if you want that crap, * use a real IRC client. */ if (msg[0] != '\001' || msg[strlen(msg) - 1] != '\001') return g_strdup(msg); if (!strncmp(cur, "ACTION ", 7)) { cur += 7; buf = g_strdup_printf("/me %s", cur); buf[strlen(buf) - 1] = '\0'; return buf; } else if (!strncmp(cur, "PING ", 5)) { if (notice) { /* reply */ /* TODO: Should this read in the timestamp as a double? */ sscanf(cur, "PING %lu", ×tamp); gc = purple_account_get_connection(irc->account); if (!gc) return NULL; buf = g_strdup_printf(_("Reply time from %s: %lu seconds"), from, time(NULL) - timestamp); purple_notify_info(gc, _("PONG"), _("CTCP PING reply"), buf); g_free(buf); return NULL; } else { buf = irc_format(irc, "vt:", "NOTICE", from, msg); irc_send(irc, buf); g_free(buf); } } else if (!strncmp(cur, "VERSION", 7) && !notice) { buf = irc_format(irc, "vt:", "NOTICE", from, "\001VERSION Purple IRC\001"); irc_send(irc, buf); g_free(buf); } else if (!strncmp(cur, "DCC SEND ", 9)) { irc_dccsend_recv(irc, from, msg + 10); return NULL; } ctcp = g_strdup(msg + 1); ctcp[strlen(ctcp) - 1] = '\0'; buf = g_strdup_printf("Received CTCP '%s' (to %s) from %s", ctcp, to, from); g_free(ctcp); return buf; }
struct groupchat *purple_chat_join( struct im_connection *ic, const char *room, const char *nick, const char *password, set_t **sets ) { PurpleAccount *pa = ic->proto_data; PurplePlugin *prpl = purple_plugins_find_with_id( pa->protocol_id ); PurplePluginProtocolInfo *pi = prpl->info->extra_info; GHashTable *chat_hash; PurpleConversation *conv; GList *info, *l; if( !pi->chat_info || !pi->chat_info_defaults || !( info = pi->chat_info( purple_account_get_connection( pa ) ) ) ) { imcb_error( ic, "Joining chatrooms not supported by this protocol" ); return NULL; } if( ( conv = purple_find_conversation_with_account( PURPLE_CONV_TYPE_CHAT, room, pa ) ) ) purple_conversation_destroy( conv ); chat_hash = pi->chat_info_defaults( purple_account_get_connection( pa ), room ); for( l = info; l; l = l->next ) { struct proto_chat_entry *pce = l->data; if( strcmp( pce->identifier, "handle" ) == 0 ) g_hash_table_replace( chat_hash, "handle", g_strdup( nick ) ); else if( strcmp( pce->identifier, "password" ) == 0 ) g_hash_table_replace( chat_hash, "password", g_strdup( password ) ); else if( strcmp( pce->identifier, "passwd" ) == 0 ) g_hash_table_replace( chat_hash, "passwd", g_strdup( password ) ); } serv_join_chat( purple_account_get_connection( pa ), chat_hash ); return NULL; }
static void purple_xfer_ask_recv(PurpleXfer *xfer) { char *buf, *size_buf; size_t size; gconstpointer thumb; gsize thumb_size; /* If we have already accepted the request, ask the destination file name directly */ if (purple_xfer_get_status(xfer) != PURPLE_XFER_STATUS_ACCEPTED) { PurpleBuddy *buddy = purple_find_buddy(xfer->account, xfer->who); if (purple_xfer_get_filename(xfer) != NULL) { size = purple_xfer_get_size(xfer); size_buf = purple_str_size_to_units(size); buf = g_strdup_printf(_("%s wants to send you %s (%s)"), buddy ? purple_buddy_get_alias(buddy) : xfer->who, purple_xfer_get_filename(xfer), size_buf); g_free(size_buf); } else { buf = g_strdup_printf(_("%s wants to send you a file"), buddy ? purple_buddy_get_alias(buddy) : xfer->who); } if (xfer->message != NULL) serv_got_im(purple_account_get_connection(xfer->account), xfer->who, xfer->message, 0, time(NULL)); if ((thumb = purple_xfer_get_thumbnail(xfer, &thumb_size))) { purple_request_accept_cancel_with_icon(xfer, NULL, buf, NULL, PURPLE_DEFAULT_ACTION_NONE, xfer->account, xfer->who, NULL, thumb, thumb_size, xfer, G_CALLBACK(purple_xfer_choose_file), G_CALLBACK(cancel_recv_cb)); } else { purple_request_accept_cancel(xfer, NULL, buf, NULL, PURPLE_DEFAULT_ACTION_NONE, xfer->account, xfer->who, NULL, xfer, G_CALLBACK(purple_xfer_choose_file), G_CALLBACK(cancel_recv_cb)); } g_free(buf); } else purple_xfer_choose_file(xfer); }