本文整理汇总了C++中purple_strequal函数的典型用法代码示例。如果您正苦于以下问题:C++ purple_strequal函数的具体用法?C++ purple_strequal怎么用?C++ purple_strequal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了purple_strequal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: purple_xmlnode_remove_attrib_with_namespace
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;
}
}
示例2: purple_xmlnode_get_child_with_namespace
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;
}
示例3: bonjour_si_xfer_find
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;
}
示例4: does_reply_from_match_request_to
/**
* 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;
}
示例5: pb_process_frame
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);
}
示例6: purple_find_prpl
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;
}
示例7: google_session_handle_initiate
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;
}
示例8: purple_plugins_find_with_basename
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;
}
示例9: xep_cmp_addr
/**
* 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);
}
示例10: fb_util_get_locale
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);
}
示例11: purple_protocol_finalize
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);
}
示例12: reverse
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;
}
示例13: purple_prefs_set_string
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);
}
}
示例14: jabber_auth_handle_challenge
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");
}
示例15: purple_xmlnode_remove_attrib
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;
}
}