void purple_xmlnode_remove_attrib_with_namespace(PurpleXmlNode *node, const char *attr, const char *xmlns) { PurpleXmlNode *attr_node, *sibling = NULL; g_return_if_fail(node != NULL); g_return_if_fail(attr != NULL); for(attr_node = node->child; attr_node; attr_node = attr_node->next) { if(attr_node->type == PURPLE_XMLNODE_TYPE_ATTRIB && purple_strequal(attr, attr_node->name) && purple_strequal(xmlns, attr_node->xmlns)) { if(sibling == NULL) { node->child = attr_node->next; } else { sibling->next = attr_node->next; } if (node->lastchild == attr_node) { node->lastchild = sibling; } purple_xmlnode_free(attr_node); return; } sibling = attr_node; } }
PurpleXmlNode * purple_xmlnode_get_child_with_namespace(const PurpleXmlNode *parent, const char *name, const char *ns) { PurpleXmlNode *x, *ret = NULL; char **names; char *parent_name, *child_name; g_return_val_if_fail(parent != NULL, NULL); g_return_val_if_fail(name != NULL, NULL); names = g_strsplit(name, "/", 2); parent_name = names[0]; child_name = names[1]; for(x = parent->child; x; x = x->next) { /* XXX: Is it correct to ignore the namespace for the match if none was specified? */ const char *xmlns = NULL; if(ns) xmlns = purple_xmlnode_get_namespace(x); if(x->type == PURPLE_XMLNODE_TYPE_TAG && purple_strequal(parent_name, x->name) && purple_strequal(ns, xmlns)) { ret = x; break; } } if(child_name && ret) ret = purple_xmlnode_get_child(ret, child_name); g_strfreev(names); return ret; }
static PurpleXfer* bonjour_si_xfer_find(BonjourData *bd, const char *sid, const char *from) { GSList *xfers; PurpleXfer *xfer; XepXfer *xf; if(!sid || !from || !bd) return NULL; purple_debug_info("bonjour", "Look for sid=%s from=%s xferlists.\n", sid, from); for(xfers = bd->xfer_lists; xfers; xfers = xfers->next) { xfer = xfers->data; if(xfer == NULL) break; xf = xfer->data; if(xf == NULL) break; if(purple_strequal(xf->sid, sid) && purple_strequal(xfer->who, from)) return xfer; } purple_debug_info("bonjour", "Look for xfer list fail\n"); return NULL; }
/** * Verify that the 'from' attribute of an IQ reply is a valid match for * a given IQ request. The expected behavior is outlined in section * 8.1.2.1 of the XMPP CORE spec (RFC 6120). We consider the reply to * be a valid match if any of the following is true: * - Request 'to' matches reply 'from' (including the case where * neither are set). * - Request 'to' was my JID (bare or full) and reply 'from' is empty. * - Request 'to' was empty and reply 'from' is my JID. The spec says * we should only allow bare JID, but we also allow full JID for * compatibility with some servers. * - Request 'to' was empty and reply 'from' is server JID. Not allowed by * any spec, but for compatibility with some servers. * * These rules should allow valid IQ replies while preventing spoofed * ones. * * For more discussion see the "Spoofing of iq ids and misbehaving * servers" email thread from January 2014 on the jdev and security * mailing lists. Also see https://developer.pidgin.im/ticket/15879 * * @return TRUE if this reply is valid for the given request. */ static gboolean does_reply_from_match_request_to(JabberStream *js, JabberID *to, JabberID *from) { if (jabber_id_equal(to, from)) { /* Request 'to' matches reply 'from' */ return TRUE; } if (!from && purple_strequal(to->node, js->user->node) && purple_strequal(to->domain, js->user->domain)) { /* Request 'to' was my JID (bare or full) and reply 'from' is empty */ return TRUE; } if (!to && purple_strequal(from->domain, js->user->domain)) { /* Request 'to' is empty and reply 'from' domain matches our domain */ if (!from->node && !from->resource) { /* Reply 'from' is server bare JID */ return TRUE; } if (purple_strequal(from->node, js->user->node) && (!from->resource || purple_strequal(from->resource, js->user->resource))) { /* Reply 'from' is my full or bare JID */ return TRUE; } } return FALSE; }
static void pb_process_frame(PushBulletAccount *pba, const gchar *frame) { JsonParser *parser = json_parser_new(); JsonNode *root; purple_debug_info("pushbullet", "got frame data: %s\n", frame); if (!json_parser_load_from_data(parser, frame, -1, NULL)) { purple_debug_error("pushbullet", "Error parsing response: %s\n", frame); return; } root = json_parser_get_root(parser); if (root != NULL) { JsonObject *message = json_node_get_object(root); const gchar *type = json_object_get_string_member(message, "type"); if (purple_strequal(type, "tickle")) { pb_get_everything_since(pba, purple_account_get_int(pba->account, "last_message_timestamp", 0)); } else if (purple_strequal(type, "push")) { JsonObject *push = json_object_get_object_member(message, "push"); //{"type":"push","targets":["stream","android","ios"],"push":{"guid":"purple6e94d282","type":"messaging_extension_reply","package_name":"com.pushbullet.android","target_device_iden":"uffvytgsjAoIRwhIL6","conversation_iden":"+6421478252","message":"test2"}} //{"type":"push","targets":["stream"],"push":{"type":"sms_changed"}} type = json_object_get_string_member(push, "type"); if (purple_strequal(type, "sms_changed")) { pb_get_phone_threads(pba, NULL); } } } g_object_unref(parser); }
PurplePlugin * purple_find_prpl(const char *id) { GList *l; PurplePlugin *plugin; g_return_val_if_fail(id != NULL, NULL); /* libpurple3 compatibility. * prpl-xmpp isn't used yet (it's prpl-jabber), * but may be used in the future. */ if (purple_strequal(id, "prpl-xmpp") || purple_strequal(id, "prpl-gtalk")) { id = "prpl-jabber"; } for (l = purple_plugins_get_protocols(); l != NULL; l = l->next) { plugin = (PurplePlugin *)l->data; if (purple_strequal(plugin->info->id, id)) return plugin; } return NULL; }
static gboolean google_session_handle_initiate(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id) { const gchar *xmlns; GoogleAVSessionData *session_data = (GoogleAVSessionData *) session->session_data; if (session->state != UNINIT) { purple_debug_error("jabber", "Received initiate for active session.\n"); return FALSE; } session->description = xmlnode_copy(xmlnode_get_child(sess, "description")); xmlns = xmlnode_get_namespace(session->description); if (purple_strequal(xmlns, NS_GOOGLE_SESSION_PHONE)) session_data->video = FALSE; else if (purple_strequal(xmlns, NS_GOOGLE_SESSION_VIDEO)) session_data->video = TRUE; else { purple_debug_error("jabber", "Received initiate with " "invalid namespace %s.\n", xmlns); return FALSE; } session_data->media = purple_media_manager_create_media( purple_media_manager_get(), purple_connection_get_account(js->gc), "fsrtpconference", session->remote_jid, FALSE); purple_media_set_prpl_data(session_data->media, session); g_signal_connect_swapped(G_OBJECT(session_data->media), "candidates-prepared", G_CALLBACK(google_session_ready), session); g_signal_connect_swapped(G_OBJECT(session_data->media), "codecs-changed", G_CALLBACK(google_session_ready), session); g_signal_connect(G_OBJECT(session_data->media), "state-changed", G_CALLBACK(google_session_state_changed_cb), session); g_signal_connect(G_OBJECT(session_data->media), "stream-info", G_CALLBACK(google_session_stream_info_cb), session); session->iq_id = g_strdup(iq_id); if (js->google_relay_host && js->google_relay_token) { jabber_google_do_relay_request(js, session, jabber_google_relay_response_session_handle_initiate_cb); } else { jabber_google_relay_response_session_handle_initiate_cb(session, NULL, 0, 0, 0, NULL, NULL); } return TRUE; }
PurplePlugin * purple_plugins_find_with_basename(const char *basename) { #ifdef PURPLE_PLUGINS PurplePlugin *plugin; GList *l; char *tmp; g_return_val_if_fail(basename != NULL, NULL); for (l = plugins; l != NULL; l = l->next) { plugin = (PurplePlugin *)l->data; if (plugin->path != NULL) { tmp = purple_plugin_get_basename(plugin->path); if (purple_strequal(tmp, basename)) { g_free(tmp); return plugin; } g_free(tmp); } } #endif /* PURPLE_PLUGINS */ return NULL; }
/** * Will compare a host with a buddy_ip. * * Additionally to a common 'purple_strequal(host, buddy_ip)', it will also return TRUE * if 'host' is a link local IPv6 address without an appended interface * identifier and 'buddy_ip' string is "host" + "%iface". * * Note: This may theoretically result in the attempt to connect to the wrong * host, because we do not know for sure which interface the according link * local IPv6 address might relate to and RFC4862 for instance only ensures the * uniqueness of this address on a given link. So we could possibly have two * distinct buddies with the same ipv6 link local address on two distinct * interfaces. Unfortunately XEP-0065 does not seem to specify how to deal with * link local ip addresses properly... * However, in practice the possiblity for such a conflict is relatively low * (2011 - might be different in the future though?). * * @param host ipv4 or ipv6 address string * @param buddy_ip ipv4 or ipv6 address string * @return TRUE if they match, FALSE otherwise */ static gboolean xep_cmp_addr(const char *host, const char *buddy_ip) { #if defined(AF_INET6) && defined(HAVE_GETADDRINFO) struct addrinfo hint, *res = NULL; int ret; memset(&hint, 0, sizeof(hint)); hint.ai_family = AF_UNSPEC; hint.ai_flags = AI_NUMERICHOST; ret = getaddrinfo(host, NULL, &hint, &res); if(ret) goto out; if(res->ai_family != AF_INET6 || !IN6_IS_ADDR_LINKLOCAL(&((struct sockaddr_in6 *)res->ai_addr)->sin6_addr)) { freeaddrinfo(res); goto out; } freeaddrinfo(res); if(strlen(buddy_ip) <= strlen(host) || buddy_ip[strlen(host)] != '%') return FALSE; return !strncmp(host, buddy_ip, strlen(host)); out: #endif return purple_strequal(host, buddy_ip); }
gchar * fb_util_get_locale(void) { const gchar * const *langs; const gchar *lang; gchar *chr; guint i; static const gchar chrs[] = {'.', '@'}; langs = g_get_language_names(); lang = langs[0]; if (purple_strequal(lang, "C")) { return g_strdup("en_US"); } for (i = 0; i < G_N_ELEMENTS(chrs); i++) { chr = strchr(lang, chrs[i]); if (chr != NULL) { return g_strndup(lang, chr - lang); } } return g_strdup(lang); }
static void purple_protocol_finalize(GObject *object) { PurpleProtocol *protocol = PURPLE_PROTOCOL(object); GList *accounts, *l; accounts = purple_accounts_get_all_active(); for (l = accounts; l != NULL; l = l->next) { PurpleAccount *account = PURPLE_ACCOUNT(l->data); if (purple_account_is_disconnected(account)) continue; if (purple_strequal(protocol->id, purple_account_get_protocol_id(account))) purple_account_disconnect(account); } g_list_free(accounts); purple_request_close_with_handle(protocol); purple_notify_close_with_handle(protocol); purple_signals_disconnect_by_handle(protocol); purple_signals_unregister_by_instance(protocol); purple_prefs_disconnect_by_handle(protocol); user_splits_free(protocol); account_options_free(protocol); icon_spec_free(protocol); PURPLE_DBUS_UNREGISTER_POINTER(protocol); parent_class->finalize(object); }
static gboolean reverse(PurpleAccount *account, char **who, char **message, PurpleConversation *conv, int *flags) { /* this will drive you insane. whenever you receive a message, * the text of the message (HTML and all) will be reversed. */ int i, l; char tmp; /* this check is necessary in case bad plugins do bad things */ if (message == NULL || *message == NULL) return FALSE; l = strlen(*message); if (purple_strequal(*who, purple_account_get_username(account))) return FALSE; for (i = 0; i < l/2; i++) { tmp = (*message)[i]; (*message)[i] = (*message)[l - i - 1]; (*message)[l - i - 1] = tmp; } return FALSE; }
void purple_prefs_set_string(const char *name, const char *value) { struct purple_pref *pref = find_pref(name); if(value != NULL && !g_utf8_validate(value, -1, NULL)) { purple_debug_error("prefs", "purple_prefs_set_string: Cannot store invalid UTF8 for string pref %s\n", name); return; } if(pref) { if(pref->type != PURPLE_PREF_STRING && pref->type != PURPLE_PREF_PATH) { purple_debug_error("prefs", "purple_prefs_set_string: %s not a string pref\n", name); return; } if (!purple_strequal(pref->value.string, value)) { g_free(pref->value.string); pref->value.string = g_strdup(value); do_callbacks(name, pref); } } else { purple_prefs_add_string(name, value); } }
void jabber_auth_handle_challenge(JabberStream *js, PurpleXmlNode *packet) { const char *ns = purple_xmlnode_get_namespace(packet); if (!purple_strequal(ns, NS_XMPP_SASL)) { purple_connection_error(js->gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Invalid response from server")); return; } if (js->auth_mech && js->auth_mech->handle_challenge) { PurpleXmlNode *response = NULL; char *msg = NULL; JabberSaslState state = js->auth_mech->handle_challenge(js, packet, &response, &msg); if (state == JABBER_SASL_STATE_FAIL) { purple_connection_error(js->gc, PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, msg ? msg : _("Invalid challenge from server")); } else if (response) { jabber_send(js, response); purple_xmlnode_free(response); } g_free(msg); } else purple_debug_warning("jabber", "Received unexpected (and unhandled) <challenge/>\n"); }
void purple_xmlnode_remove_attrib(PurpleXmlNode *node, const char *attr) { PurpleXmlNode *attr_node, *sibling = NULL; g_return_if_fail(node != NULL); g_return_if_fail(attr != NULL); attr_node = node->child; while (attr_node) { if(attr_node->type == PURPLE_XMLNODE_TYPE_ATTRIB && purple_strequal(attr_node->name, attr)) { if (node->lastchild == attr_node) { node->lastchild = sibling; } if (sibling == NULL) { node->child = attr_node->next; purple_xmlnode_free(attr_node); attr_node = node->child; } else { sibling->next = attr_node->next; sibling = attr_node->next; purple_xmlnode_free(attr_node); attr_node = sibling; } } else { attr_node = attr_node->next; } sibling = attr_node; } }
gboolean jabber_id_equal(const JabberID *jid1, const JabberID *jid2) { if (!jid1 && !jid2) { /* Both are null therefore equal */ return TRUE; } if (!jid1 || !jid2) { /* One is null, other is non-null, therefore not equal */ return FALSE; } return purple_strequal(jid1->node, jid2->node) && purple_strequal(jid1->domain, jid2->domain) && purple_strequal(jid1->resource, jid2->resource); }
const char * purple_xmlnode_get_attrib_with_namespace(const PurpleXmlNode *node, const char *attr, const char *xmlns) { const PurpleXmlNode *x; g_return_val_if_fail(node != NULL, NULL); g_return_val_if_fail(attr != NULL, NULL); for(x = node->child; x; x = x->next) { if(x->type == PURPLE_XMLNODE_TYPE_ATTRIB && purple_strequal(attr, x->name) && purple_strequal(xmlns, x->xmlns)) { return x->data; } } return NULL; }
static void prefs_end_element_handler(GMarkupParseContext *context, const gchar *element_name, gpointer user_data, GError **error) { if(prefs_stack && purple_strequal(element_name, "pref")) { g_free(prefs_stack->data); prefs_stack = g_list_delete_link(prefs_stack, prefs_stack); } }
void silcpurple_buddy_set_icon(PurpleConnection *gc, PurpleStoredImage *img) { SilcPurple sg = gc->proto_data; SilcClient client = sg->client; SilcClientConnection conn = sg->conn; SilcMime mime; char type[32]; unsigned char *icon; const char *t; SilcAttributeObjMime obj; /* Remove */ if (!img) { silc_client_attribute_del(client, conn, SILC_ATTRIBUTE_USER_ICON, NULL); return; } /* Add */ mime = silc_mime_alloc(); if (!mime) return; t = purple_imgstore_get_extension(img); if (!t || purple_strequal(t, "icon")) { silc_mime_free(mime); return; } if (purple_strequal(t, "jpg")) t = "jpeg"; g_snprintf(type, sizeof(type), "image/%s", t); silc_mime_add_field(mime, "Content-Type", type); silc_mime_add_data(mime, purple_imgstore_get_data(img), purple_imgstore_get_size(img)); obj.mime = icon = silc_mime_encode(mime, &obj.mime_len); if (obj.mime) silc_client_attribute_add(client, conn, SILC_ATTRIBUTE_USER_ICON, &obj, sizeof(obj)); silc_free(icon); silc_mime_free(mime); }
PurpleStunNatDiscovery *purple_stun_discover(StunCallback cb) { const char *servername = purple_prefs_get_string("/purple/network/stun_server"); purple_debug_info("stun", "using server %s\n", servername); if(nattype.status == PURPLE_STUN_STATUS_DISCOVERING) { if(cb) callbacks = g_slist_append(callbacks, cb); return &nattype; } if(nattype.status != PURPLE_STUN_STATUS_UNDISCOVERED) { gboolean use_cached_result = TRUE; /** Deal with the server name having changed since we did the lookup */ if (servername && strlen(servername) > 1 && !purple_strequal(servername, nattype.servername)) { use_cached_result = FALSE; } /* If we don't have a successful status and it has been 5 minutes since we last did a lookup, redo the lookup */ if (nattype.status != PURPLE_STUN_STATUS_DISCOVERED && (time(NULL) - nattype.lookup_time) > 300) { use_cached_result = FALSE; } if (use_cached_result) { if(cb) purple_timeout_add(10, call_callback, cb); return &nattype; } } if(!servername || (strlen(servername) < 2)) { nattype.status = PURPLE_STUN_STATUS_UNKNOWN; nattype.lookup_time = time(NULL); if(cb) purple_timeout_add(10, call_callback, cb); return &nattype; } nattype.status = PURPLE_STUN_STATUS_DISCOVERING; nattype.publicip[0] = '\0'; g_free(nattype.servername); nattype.servername = g_strdup(servername); callbacks = g_slist_append(callbacks, cb); purple_srv_resolve_account(NULL, "stun", "udp", servername, do_test1, (gpointer) servername); return &nattype; }
static JabberSaslState jabber_cyrus_handle_challenge(JabberStream *js, xmlnode *packet, xmlnode **reply, char **error) { char *enc_in = xmlnode_get_data(packet); unsigned char *dec_in; char *enc_out; const char *c_out; unsigned int clen; gsize declen; dec_in = purple_base64_decode(enc_in, &declen); js->sasl_state = sasl_client_step(js->sasl, (char*)dec_in, declen, NULL, &c_out, &clen); g_free(enc_in); g_free(dec_in); if (js->sasl_state != SASL_CONTINUE && js->sasl_state != SASL_OK) { gchar *tmp = g_strdup_printf(_("SASL error: %s"), sasl_errdetail(js->sasl)); purple_debug_error("jabber", "Error is %d : %s\n", js->sasl_state, sasl_errdetail(js->sasl)); *error = tmp; return JABBER_SASL_STATE_FAIL; } else { xmlnode *response = xmlnode_new("response"); xmlnode_set_namespace(response, NS_XMPP_SASL); if (clen > 0) { /* Cyrus SASL 2.1.22 appears to contain code to add the charset * to the response for DIGEST-MD5 but there is no possibility * it will be executed. * * My reading of the digestmd5 plugin indicates the username and * realm are always encoded in UTF-8 (they seem to be the values * we pass in), so we need to ensure charset=utf-8 is set. */ if (!purple_strequal(js->current_mech, "DIGEST-MD5") || strstr(c_out, ",charset=")) /* If we're not using DIGEST-MD5 or Cyrus SASL is fixed */ enc_out = purple_base64_encode((unsigned char*)c_out, clen); else { char *tmp = g_strdup_printf("%s,charset=utf-8", c_out); enc_out = purple_base64_encode((unsigned char*)tmp, clen + 14); g_free(tmp); } xmlnode_insert_data(response, enc_out, -1); g_free(enc_out); } *reply = response; return JABBER_SASL_STATE_CONTINUE; } }
static void delete_buddy_icon_settings(PurpleBlistNode *node, const char *setting_name) { purple_blist_node_remove_setting(node, setting_name); if (purple_strequal(setting_name, "buddy_icon")) { purple_blist_node_remove_setting(node, "avatar_hash"); purple_blist_node_remove_setting(node, "icon_checksum"); } }
static void jabber_google_relay_parse_response(const gchar *response, gchar **ip, guint *udp, guint *tcp, guint *ssltcp, gchar **username, gchar **password) { gchar **lines = g_strsplit(response, "\n", -1); int i = 0; for (; lines[i] ; i++) { gchar *line = lines[i]; gchar **parts = g_strsplit(line, "=", 2); if (parts[0] && parts[1]) { if (purple_strequal(parts[0], "relay.ip")) { *ip = g_strdup(parts[1]); } else if (purple_strequal(parts[0], "relay.udp_port")) { *udp = atoi(parts[1]); } else if (purple_strequal(parts[0], "relay.tcp_port")) { *tcp = atoi(parts[1]); } else if (purple_strequal(parts[0], "relay.ssltcp_port")) { *ssltcp = atoi(parts[1]); } else if (purple_strequal(parts[0], "username")) { *username = g_strdup(parts[1]); } else if (purple_strequal(parts[0], "password")) { *password = g_strdup(parts[1]); } } g_strfreev(parts); } g_strfreev(lines); }
GList *purple_pounces_get_all_for_ui(const char *ui) { GList *list = NULL, *iter; g_return_val_if_fail(ui != NULL, NULL); for (iter = pounces; iter; iter = iter->next) { PurplePounce *pounce = iter->data; if (purple_strequal(pounce->ui_type, ui)) list = g_list_prepend(list, pounce); } list = g_list_reverse(list); return list; }
gboolean jabber_is_own_account(JabberStream *js, const char *str) { JabberID *jid; gboolean equal; if (str == NULL) return TRUE; g_return_val_if_fail(*str != '\0', FALSE); jid = jabber_id_new(str); if (!jid) return FALSE; equal = (purple_strequal(jid->node, js->user->node) && purple_strequal(jid->domain, js->user->domain) && (jid->resource == NULL || purple_strequal(jid->resource, js->user->resource))); jabber_id_free(jid); return equal; }
JabberBuddyState jabber_buddy_status_id_get_state(const char *id) { gsize i; if (!id) return JABBER_BUDDY_STATE_UNKNOWN; for (i = 0; i < G_N_ELEMENTS(jabber_statuses); ++i) if (purple_strequal(id, jabber_statuses[i].status_id)) return jabber_statuses[i].state; return JABBER_BUDDY_STATE_UNKNOWN; }
PurpleXmlNode * purple_xmlnode_get_next_twin(PurpleXmlNode *node) { PurpleXmlNode *sibling; const char *ns = purple_xmlnode_get_namespace(node); g_return_val_if_fail(node != NULL, NULL); g_return_val_if_fail(node->type == PURPLE_XMLNODE_TYPE_TAG, NULL); for(sibling = node->next; sibling; sibling = sibling->next) { /* XXX: Is it correct to ignore the namespace for the match if none was specified? */ const char *xmlns = NULL; if(ns) xmlns = purple_xmlnode_get_namespace(sibling); if(sibling->type == PURPLE_XMLNODE_TYPE_TAG && purple_strequal(node->name, sibling->name) && purple_strequal(ns, xmlns)) return sibling; } return NULL; }
static struct purple_pref * find_pref_parent(const char *name) { char *parent_name = get_path_dirname(name); struct purple_pref *ret = &prefs; if(!purple_strequal(parent_name, "/")) { ret = find_pref(parent_name); } g_free(parent_name); return ret; }
int irc_send_len(struct irc_conn *irc, const char *buf, int buflen) { int ret; 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; if (!purple_strequal(tosend, buf)) { buflen = strlen(tosend); } if (purple_debug_is_verbose()) { char *clean = purple_utf8_salvage(tosend); clean = g_strstrip(clean); purple_debug_misc("irc", "<< %s\n", clean); g_free(clean); } /* 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) { PurpleConnection *gc = purple_account_get_connection(irc->account); gchar *tmp = g_strdup_printf(_("Lost connection with server: %s"), g_strerror(errno)); purple_connection_error_reason (gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); g_free(tmp); } 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; }
JabberBuddyState jabber_buddy_show_get_state(const char *id) { gsize i; g_return_val_if_fail(id != NULL, JABBER_BUDDY_STATE_UNKNOWN); for (i = 0; i < G_N_ELEMENTS(jabber_statuses); ++i) if (jabber_statuses[i].show && purple_strequal(id, jabber_statuses[i].show)) return jabber_statuses[i].state; purple_debug_warning("jabber", "Invalid value of presence <show/> " "attribute: %s\n", id); return JABBER_BUDDY_STATE_UNKNOWN; }