本文整理汇总了C++中xmpp_stanza_get_name函数的典型用法代码示例。如果您正苦于以下问题:C++ xmpp_stanza_get_name函数的具体用法?C++ xmpp_stanza_get_name怎么用?C++ xmpp_stanza_get_name使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xmpp_stanza_get_name函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _CreateReadParam
/**
* Creates the parameter structure for the Read callback
* @param[in] params This stanza is the params element in the XML-RPC format
* @return The structure or null if an error were found.
*/
static sdvp_ReadParam_t* _CreateReadParam (xmpp_stanza_t * params) {
const int expectedParams = 1;
sdvp_ReadParam_t* rv = NULL;
int i = 0;
bool elementNotFund = false;
xmpp_stanza_t *structure = NULL, *member = NULL, *value = NULL,
*type = NULL, *name = NULL;
char *text, *textname;
structure = _GetRpcStructureElementFromParams(params);
if (structure == NULL ) {
return NULL ;
}
rv = _InitiateReadParameters();
for (member = xmpp_stanza_get_children(structure);
member && !elementNotFund && (i < expectedParams); member =
xmpp_stanza_get_next(member)) {
if (xmpp_stanza_get_name(member)
&& strcmp(xmpp_stanza_get_name(member), "member") == 0) {
if (!(name = xmpp_stanza_get_child_by_name(member, "name"))) {
_FreeReadParameters(rv);
// TODO: Signal error back
return NULL ;
}
name = xmpp_stanza_get_children(name);
textname = xmpp_stanza_get_text(name);
if (strcmp(textname, "VariableAccessSpecification") == 0) {
if (!(value = xmpp_stanza_get_child_by_name(member, "value"))) {
_FreeReadParameters(rv);
// TODO: Signal error back
free(textname);
return NULL ;
}
if ((type = xmpp_stanza_get_child_by_name(value, "string"))) {
if (xmpp_stanza_get_children(type)) {
text = xmpp_stanza_get_text(type);
rv->reference = text;
} else {
rv->reference = NULL;
}
} else {
elementNotFund = true;
}
} else {
// if (!type) {
// _FreeReadParameters(rv);
// return NULL ;
// }
}
free(textname);
}
}
return rv;
}
示例2: stanza_is_muc_self_presence
gboolean
stanza_is_muc_self_presence(xmpp_stanza_t * const stanza,
const char * const self_jid)
{
if (stanza == NULL) {
return FALSE;
}
if (strcmp(xmpp_stanza_get_name(stanza), STANZA_NAME_PRESENCE) != 0) {
return FALSE;
}
xmpp_stanza_t *x = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_X);
if (x == NULL) {
return FALSE;
}
char *ns = xmpp_stanza_get_ns(x);
if (ns == NULL) {
return FALSE;
}
if (strcmp(ns, STANZA_NS_MUC_USER) != 0) {
return FALSE;
}
xmpp_stanza_t *x_children = xmpp_stanza_get_children(x);
if (x_children == NULL) {
return FALSE;
}
while (x_children != NULL) {
if (strcmp(xmpp_stanza_get_name(x_children), STANZA_NAME_STATUS) == 0) {
char *code = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_CODE);
if (strcmp(code, "110") == 0) {
return TRUE;
}
}
x_children = xmpp_stanza_get_next(x_children);
}
// for older server that don't send status 110
x_children = xmpp_stanza_get_children(x);
while (x_children != NULL) {
if (strcmp(xmpp_stanza_get_name(x_children), STANZA_NAME_ITEM) == 0) {
char *jid = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_JID);
if (jid != NULL) {
if (g_str_has_prefix(jid, self_jid)) {
return TRUE;
}
}
}
x_children = xmpp_stanza_get_next(x_children);
}
return FALSE;
}
示例3: blocked_set_handler
int
blocked_set_handler(xmpp_stanza_t *stanza)
{
xmpp_stanza_t *block = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BLOCK);
if (block) {
xmpp_stanza_t *child = xmpp_stanza_get_children(block);
while (child) {
if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_ITEM) == 0) {
const char *jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
if (jid) {
blocked = g_list_append(blocked, strdup(jid));
autocomplete_add(blocked_ac, jid);
}
}
child = xmpp_stanza_get_next(child);
}
}
xmpp_stanza_t *unblock = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_UNBLOCK);
if (unblock) {
xmpp_stanza_t *child = xmpp_stanza_get_children(unblock);
if (!child) {
g_list_free_full(blocked, free);
blocked = NULL;
autocomplete_clear(blocked_ac);
} else {
while (child) {
if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_ITEM) == 0) {
const char *jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
if (jid) {
GList *found = g_list_find_custom(blocked, jid, (GCompareFunc)g_strcmp0);
if (found) {
blocked = g_list_remove_link(blocked, found);
g_list_free_full(found, free);
autocomplete_remove(blocked_ac, jid);
}
}
}
child = xmpp_stanza_get_next(child);
}
}
}
return 1;
}
示例4: _handle_legacy
static int _handle_legacy(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza,
void * const userdata)
{
char *type, *name;
/* delete missing handler */
xmpp_timed_handler_delete(conn, _handle_missing_legacy);
/* server responded to legacy auth request */
type = xmpp_stanza_get_type(stanza);
name = xmpp_stanza_get_name(stanza);
if (!type || strcmp(name, "iq") != 0) {
xmpp_error(conn->ctx, "xmpp", "Server sent us an unexpected response "\
"to legacy authentication request.");
xmpp_disconnect(conn);
} else if (strcmp(type, "error") == 0) {
/* legacy client auth failed, no more fallbacks */
xmpp_error(conn->ctx, "xmpp", "Legacy client authentication failed.");
xmpp_disconnect(conn);
} else if (strcmp(type, "result") == 0) {
/* auth succeeded */
xmpp_debug(conn->ctx, "xmpp", "Legacy auth succeeded.");
conn->authenticated = 1;
conn->conn_handler(conn, XMPP_CONN_CONNECT, 0, NULL, conn->userdata);
} else {
xmpp_error(conn->ctx, "xmpp", "Server sent us a legacy authentication "\
"response with a bad type.");
xmpp_disconnect(conn);
}
return 0;
}
示例5: _receipt_request_handler
void
_receipt_request_handler(xmpp_stanza_t *const stanza)
{
if (!prefs_get_boolean(PREF_RECEIPTS_SEND)) {
return;
}
char *id = xmpp_stanza_get_id(stanza);
if (!id) {
return;
}
xmpp_stanza_t *receipts = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_RECEIPTS);
if (!receipts) {
return;
}
char *receipts_name = xmpp_stanza_get_name(receipts);
if (g_strcmp0(receipts_name, "request") != 0) {
return;
}
gchar *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
Jid *jid = jid_create(from);
_message_send_receipt(jid->fulljid, id);
jid_destroy(jid);
}
示例6: _receipt_received_handler
static int
_receipt_received_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata)
{
xmpp_stanza_t *receipt = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_RECEIPTS);
char *name = xmpp_stanza_get_name(receipt);
if (g_strcmp0(name, "received") != 0) {
return 1;
}
char *id = xmpp_stanza_get_attribute(receipt, STANZA_ATTR_ID);
if (!id) {
return 1;
}
char *fulljid = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
if (!fulljid) {
return 1;
}
Jid *jidp = jid_create(fulljid);
sv_ev_message_receipt(jidp->barejid, id);
jid_destroy(jidp);
return 1;
}
示例7: _handle_sasl_result
static int _handle_sasl_result(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza,
void * const userdata)
{
char *name;
name = xmpp_stanza_get_name(stanza);
/* the server should send a <success> or <failure> stanza */
if (strcmp(name, "failure") == 0) {
xmpp_debug(conn->ctx, "xmpp", "SASL %s auth failed",
(char *)userdata);
/* fall back to next auth method */
_auth(conn);
} else if (strcmp(name, "success") == 0) {
/* SASL PLAIN auth successful, we need to restart the stream */
xmpp_debug(conn->ctx, "xmpp", "SASL %s auth successful",
(char *)userdata);
/* reset parser */
conn_prepare_reset(conn, _handle_open_sasl);
/* send stream tag */
conn_open_stream(conn);
} else {
/* got unexpected reply */
xmpp_error(conn->ctx, "xmpp", "Got unexpected reply to SASL %s"\
"authentication.", (char *)userdata);
xmpp_disconnect(conn);
}
return 0;
}
示例8: _handle_digestmd5_rspauth
/* handle the rspauth phase of digest auth */
static int _handle_digestmd5_rspauth(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza,
void * const userdata)
{
xmpp_stanza_t *auth;
char *name;
name = xmpp_stanza_get_name(stanza);
xmpp_debug(conn->ctx, "xmpp",
"handle digest-md5 (rspauth) called for %s", name);
if (strcmp(name, "challenge") == 0) {
/* assume it's an rspauth response */
auth = xmpp_stanza_new(conn->ctx);
if (!auth) {
disconnect_mem_error(conn);
return 0;
}
xmpp_stanza_set_name(auth, "response");
xmpp_stanza_set_ns(auth, XMPP_NS_SASL);
xmpp_send(conn, auth);
xmpp_stanza_release(auth);
} else {
return _handle_sasl_result(conn, stanza, "DIGEST-MD5");
}
return 1;
}
示例9: _is_valid_form_element
static gboolean
_is_valid_form_element(xmpp_stanza_t *stanza)
{
const char *name = xmpp_stanza_get_name(stanza);
if (g_strcmp0(name, STANZA_NAME_X) != 0) {
log_error("Error parsing form, root element not <x/>.");
return FALSE;
}
const char *ns = xmpp_stanza_get_ns(stanza);
if (g_strcmp0(ns, STANZA_NS_DATA) != 0) {
log_error("Error parsing form, namespace not %s.", STANZA_NS_DATA);
return FALSE;
}
const char *type = xmpp_stanza_get_type(stanza);
if ((g_strcmp0(type, "form") != 0) &&
(g_strcmp0(type, "submit") != 0) &&
(g_strcmp0(type, "cancel") != 0) &&
(g_strcmp0(type, "result") != 0)) {
log_error("Error parsing form, unknown type.");
return FALSE;
}
return TRUE;
}
示例10: command_handler
static int command_handler(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza,
void * const userdata)
{
xmpp_stanza_t *reply = NULL, *req = NULL;
char *cmd = NULL;
/* Figure out what the command is */
req = xmpp_stanza_get_child_by_name(stanza, "command");
assert(req);
assert(strcmp(xmpp_stanza_get_name(req), "command") == 0);
cmd = xmpp_stanza_get_attribute(req, "node");
assert(cmd);
CONFLATE_LOG(((conflate_handle_t *)userdata), LOG_LVL_INFO,
"Command: %s", cmd);
reply = command_dispatch(conn, stanza, userdata, cmd, req, true);
if (reply) {
xmpp_send(conn, reply);
xmpp_stanza_release(reply);
}
return 1;
}
示例11: xmpp_message_set_body
/** Add <body/> child element to a <message/> stanza with the given text.
*
* @param msg a <message> stanza object without <body/> child element.
*
* @return 0 on success (XMPP_EOK), and a number less than 0 on failure
* (XMPP_EMEM, XMPP_EINVOP)
*
* @ingroup Stanza
*/
int xmpp_message_set_body(xmpp_stanza_t *msg, const char * const text)
{
xmpp_ctx_t *ctx = msg->ctx;
xmpp_stanza_t *body;
xmpp_stanza_t *text_stanza;
const char *name;
int ret;
/* check that msg is a <message/> stanza and doesn't contain <body/> */
name = xmpp_stanza_get_name(msg);
body = xmpp_stanza_get_child_by_name(msg, "body");
if (!name || strcmp(name, "message") != 0 || body)
return XMPP_EINVOP;
body = xmpp_stanza_new(ctx);
text_stanza = xmpp_stanza_new(ctx);
ret = body && text_stanza ? XMPP_EOK : XMPP_EMEM;
if (ret == XMPP_EOK)
ret = xmpp_stanza_set_name(body, "body");
if (ret == XMPP_EOK)
ret = xmpp_stanza_set_text(text_stanza, text);
if (ret == XMPP_EOK)
ret = xmpp_stanza_add_child(body, text_stanza);
if (ret == XMPP_EOK)
ret = xmpp_stanza_add_child(msg, body);
if (text_stanza)
xmpp_stanza_release(text_stanza);
if (body)
xmpp_stanza_release(body);
return ret;
}
示例12: _zkmuc_on_source_query
static int _zkmuc_on_source_query(xmpp_ua_t *ua, xmpp_stanza_t *stanza, void *userdata)
{
query_source_data *data = (query_source_data *)userdata;
char *from = xmpp_stanza_get_attribute(stanza, "from");
xmpp_stanza_t *x = xmpp_stanza_get_child_by_name(stanza, "x");
xmpp_stanza_t *item = xmpp_stanza_get_children(x);
zkmuc_source_t *head = NULL;
zkmuc_source_t **current = &head;
while (item)
{
if (!strcmp("item", xmpp_stanza_get_name(item)))
{
*current = (zkmuc_source_t *)malloc(sizeof(zkmuc_source_t));
(*current)->cid = atoi(xmpp_stanza_get_attribute(item, "cid"));
(*current)->sid = atoi(xmpp_stanza_get_attribute(item, "sid"));
(*current)->description = strdup(xmpp_stanza_get_attribute(item, "desc"));
(*current)->mcu = strdup(xmpp_stanza_get_attribute(item, "mcu"));
current = &(*current)->next;
}
item = xmpp_stanza_get_next(item);
}
*current = NULL;
data->cb(data->ctx, from, data->userdata, head);
_zkmuc_free_all_remote_source(head);
free(data);
return 1;
}
示例13: _handle_proceedtls_default
static int _handle_proceedtls_default(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza,
void * const userdata)
{
char *name;
name = xmpp_stanza_get_name(stanza);
xmpp_debug(conn->ctx, "xmpp",
"handle proceedtls called for %s", name);
if (strcmp(name, "proceed") == 0) {
xmpp_debug(conn->ctx, "xmpp", "proceeding with TLS");
conn->tls = tls_new(conn->ctx, conn->sock);
if (!tls_start(conn->tls))
{
xmpp_debug(conn->ctx, "xmpp", "Couldn't start TLS! error %d", tls_error(conn->tls));
tls_free(conn->tls);
conn->tls = NULL;
conn->tls_failed = 1;
/* failed tls spoils the connection, so disconnect */
xmpp_disconnect(conn);
}
else
{
conn->secured = 1;
conn_prepare_reset(conn, auth_handle_open);
conn_open_stream(conn);
}
}
return 0;
}
示例14: _handle_component_hs_response
/* Check if the received stanza is <handshake/> and set auth to true
* and fire connection handler.
*/
int _handle_component_hs_response(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza,
void * const userdata)
{
char *name;
xmpp_timed_handler_delete(conn, _handle_missing_handshake);
name = xmpp_stanza_get_name(stanza);
if (strcmp(name, "handshake") != 0) {
char *msg;
size_t msg_size;
xmpp_stanza_to_text(stanza, &msg, &msg_size);
if (msg) {
xmpp_debug(conn->ctx, "auth", "Handshake failed: %s", msg);
xmpp_free(conn->ctx, msg);
}
xmpp_disconnect(conn);
return XMPP_EINT;
} else {
conn->authenticated = 1;
conn->conn_handler(conn, XMPP_CONN_CONNECT, 0, NULL, conn->userdata);
}
/* We don't need this handler anymore, return 0 so it can be deleted
* from the list of handlers.
*/
return 0;
}
示例15: files_list
static void files_list(xmpp_stanza_t *stanza) {
int rc; /* Return code */
rc = pthread_mutex_lock(&mutex);
wsyserr(rc != 0, "pthread_mutex_lock");
char *error_attr = xmpp_stanza_get_attribute(stanza, "error"); /* error attribute */
wfatal(error_attr == NULL, "no error attribute in files stanza");
if (strcmp(error_attr, "0") != 0) {
wlog("Error in attributes: %s", error_attr);
} else {
char *path_attr = xmpp_stanza_get_attribute(stanza, "path"); /* path attribute */
wfatal(path_attr == NULL, "xmpp_stanza_get_attribute [attribute = path]");
xmpp_stanza_t *child = xmpp_stanza_get_children(stanza);
while (child != NULL) {
elem_t *elem = (elem_t *)malloc(sizeof(elem_t));
wsyserr(elem == NULL, "malloc");
elem->next = NULL;
char *name = xmpp_stanza_get_name(child);
wfatal(name == NULL, "xmpp_stanza_get_name");
if (strcmp(name, "directory") == 0) {
elem->type = DIR;
} else if (strcmp(name, "file") == 0) {
elem->type = REG;
} else {
werr("Unknown name: %s", name);
}
char *filename_attr = xmpp_stanza_get_attribute(child, "filename");
wfatal(filename_attr == NULL, "xmpp_stanza_get_attribute [attribute = filename]");
elem->filename = strdup(filename_attr);
wsyserr(elem->filename == NULL, "strdup");
/* Add elem in list */
if (root == NULL) {
root = elem;
} else {
last->next = elem;
}
last = elem;
child = xmpp_stanza_get_next(child);
}
}
/* Data set */
signal_list = true;
rc = pthread_cond_signal(&cond);
wsyserr(rc != 0, "pthread_cond_signal");
rc = pthread_mutex_unlock(&mutex);
wsyserr(rc != 0, "pthread_mutex_unlock");
}