您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ xmpp_stanza_get_child_by_name函数代码示例

51自学网 2021-06-03 11:49:52
  C++
这篇教程C++ xmpp_stanza_get_child_by_name函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中xmpp_stanza_get_child_by_name函数的典型用法代码示例。如果您正苦于以下问题:C++ xmpp_stanza_get_child_by_name函数的具体用法?C++ xmpp_stanza_get_child_by_name怎么用?C++ xmpp_stanza_get_child_by_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了xmpp_stanza_get_child_by_name函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: message_handler

int message_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata){	xmpp_stanza_t *reply, *body, *text;	char *intext;	xmpp_ctx_t *ctx = (xmpp_ctx_t*)userdata;	if (!xmpp_stanza_get_child_by_name(stanza, "body")) return 1;	if (xmpp_stanza_get_attribute(stanza, "type") != NULL && !strcmp(xmpp_stanza_get_attribute(stanza, "type"), "error")) return 1;	intext = xmpp_stanza_get_text(xmpp_stanza_get_child_by_name(stanza, "body"));	printf("Incoming message from %s: %s/n", xmpp_stanza_get_attribute(stanza, "from"), intext);	reply = xmpp_stanza_new(ctx);	xmpp_stanza_set_name(reply, "message");	xmpp_stanza_set_type(reply, xmpp_stanza_get_type(stanza) ? xmpp_stanza_get_type(stanza) : "chat");	xmpp_stanza_set_attribute(reply, "to", xmpp_stanza_get_attribute(stanza, "from"));	body = xmpp_stanza_new(ctx);	xmpp_stanza_set_name(body, "body");	char replytext[1024];	scanf("%[^/n]", replytext);	text = xmpp_stanza_new(ctx);	xmpp_stanza_set_text(text, replytext);	xmpp_stanza_add_child(body, text);	xmpp_stanza_add_child(reply, body);	xmpp_send(conn, reply);	xmpp_stanza_release(reply);	return 1;}
开发者ID:jasjeetIM,项目名称:PingMe,代码行数:35,


示例2: _on_room_info

static int _on_room_info(xmpp_ua_t *ua, xmpp_stanza_t * const stanza, void * const userdata){	room_info_data *info_data = (room_info_data *)userdata;	char *type = xmpp_stanza_get_type(stanza);	if (strcmp(type, "result"))	{		info_data->cb(info_data->ctx, NULL, -2, info_data->user_data);		free(info_data);		return 1;	}	xmpp_stanza_t *stanza_query = xmpp_stanza_get_child_by_name(stanza, "query");	if (stanza_query)	{		xmpp_stanza_t *stanza_identity = xmpp_stanza_get_child_by_name(stanza_query, "identity");		if (stanza_identity)		{			char *room_desc = xmpp_stanza_get_attribute(stanza_identity, "name");			info_data->cb(info_data->ctx, room_desc, 0, info_data->user_data);			free(info_data);			return 1;		}	}	info_data->cb(info_data->ctx, NULL, -1, info_data->user_data);	free(info_data);	return 1;}
开发者ID:FihlaTV,项目名称:conference,代码行数:28,


示例3: zkmuc_group_msg_handler

static int zkmuc_group_msg_handler(xmpp_ua_t *ua, xmpp_stanza_t *stanza, void *userdata){	char *type = xmpp_stanza_get_type(stanza);	if (type && !strcmp(type, "groupchat"))	{		zkmuc_ctx_t *ctx = (zkmuc_ctx_t *)userdata;	//	char *from = xmpp_stanza_get_attribute(stanza, "from");		xmpp_stanza_t *stanza_body = xmpp_stanza_get_child_by_name(stanza, "zonekey");		if (!stanza_body)		{			return 0;		}		xmpp_stanza_t *stanza_jid = xmpp_stanza_get_child_by_name(stanza_body, "jid");		char *jid_value = xmpp_stanza_get_text(stanza_jid);		char *text = xmpp_stanza_get_text(stanza_body);		if (text && ctx->room_cbs.on_broadcast_message)		{			ctx->room_cbs.on_broadcast_message(ctx, /*from*/jid_value, text, ctx->room_data);		}		xmpp_free(_xmpp_ctx, jid_value);		xmpp_free(_xmpp_ctx, text);		return 1;	}		return 0;}
开发者ID:FihlaTV,项目名称:conference,代码行数:26,


示例4: stanza_get_delay

gbooleanstanza_get_delay(xmpp_stanza_t * const stanza, GTimeVal *tv_stamp){    // first check for XEP-0203 delayed delivery    xmpp_stanza_t *delay = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_DELAY);    if (delay != NULL) {        char *xmlns = xmpp_stanza_get_attribute(delay, STANZA_ATTR_XMLNS);        if ((xmlns != NULL) && (strcmp(xmlns, "urn:xmpp:delay") == 0)) {            char *stamp = xmpp_stanza_get_attribute(delay, STANZA_ATTR_STAMP);            if ((stamp != NULL) && (g_time_val_from_iso8601(stamp, tv_stamp))) {                return TRUE;            }        }    }    // otherwise check for XEP-0091 legacy delayed delivery    // stanp format : CCYYMMDDThh:mm:ss    xmpp_stanza_t *x = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_X);    if (x != NULL) {        char *xmlns = xmpp_stanza_get_attribute(x, STANZA_ATTR_XMLNS);        if ((xmlns != NULL) && (strcmp(xmlns, "jabber:x:delay") == 0)) {            char *stamp = xmpp_stanza_get_attribute(x, STANZA_ATTR_STAMP);            if ((stamp != NULL) && (g_time_val_from_iso8601(stamp, tv_stamp))) {                return TRUE;            }        }    }    return FALSE;}
开发者ID:backalor,项目名称:profanity,代码行数:30,


示例5: message_handler

int message_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata) {   xmpp_stanza_t *reply, *body, *text;   char *intext, *replytext;   xmpp_ctx_t *ctx = (xmpp_ctx_t*)userdata;   if(!xmpp_stanza_get_child_by_name(stanza, "body")) return 1;   intext = xmpp_stanza_get_text(xmpp_stanza_get_child_by_name(stanza, "body"));   printf("Incoming message from %s: %s/n", xmpp_stanza_get_attribute(stanza, "from"), intext);   reply = xmpp_stanza_new(ctx);   xmpp_stanza_set_name(reply, "message");   xmpp_stanza_set_type(reply, xmpp_stanza_get_type(stanza)?xmpp_stanza_get_type(stanza):"chat");   xmpp_stanza_set_attribute(reply, "to", xmpp_stanza_get_attribute(stanza, "from"));   body = xmpp_stanza_new(ctx);   xmpp_stanza_set_name(body, "body");   replytext = malloc(strlen(" to you too!") + strlen(intext) + 1);   strcpy(replytext, intext);   strcat(replytext, " to you too!");   text = xmpp_stanza_new(ctx);   xmpp_stanza_set_text(text, replytext);   xmpp_stanza_add_child(body, text);   xmpp_stanza_add_child(reply, body);   xmpp_send(conn, reply);   xmpp_stanza_release(reply);   free(replytext);   return 1; } 
开发者ID:nazda,项目名称:wippien,代码行数:34,


示例6: _handle_carbons

static gboolean_handle_carbons(xmpp_stanza_t *const stanza){    xmpp_stanza_t *carbons = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CARBONS);    if (!carbons) {        return FALSE;    }    char *name = xmpp_stanza_get_name(carbons);    if ((g_strcmp0(name, "received") == 0) || (g_strcmp0(name, "sent")) == 0) {        xmpp_stanza_t *forwarded = xmpp_stanza_get_child_by_ns(carbons, STANZA_NS_FORWARD);        xmpp_stanza_t *message = xmpp_stanza_get_child_by_name(forwarded, STANZA_NAME_MESSAGE);        xmpp_ctx_t *ctx = connection_get_ctx();        gchar *to = xmpp_stanza_get_attribute(message, STANZA_ATTR_TO);        gchar *from = xmpp_stanza_get_attribute(message, STANZA_ATTR_FROM);        // happens when receive a carbon of a self sent message        if (!to) to = from;        Jid *jid_from = jid_create(from);        Jid *jid_to = jid_create(to);        Jid *my_jid = jid_create(jabber_get_fulljid());        // check for and deal with message        xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(message, STANZA_NAME_BODY);        if (body) {            char *message_txt = xmpp_stanza_get_text(body);            if (message_txt) {                // check for pgp encrypted message                char *enc_message = NULL;                xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(message, STANZA_NS_ENCRYPTED);                if (x) {                    enc_message = xmpp_stanza_get_text(x);                }                // if we are the recipient, treat as standard incoming message                if(g_strcmp0(my_jid->barejid, jid_to->barejid) == 0){                    sv_ev_incoming_carbon(jid_from->barejid, jid_from->resourcepart, message_txt, enc_message);                // else treat as a sent message                } else {                    sv_ev_outgoing_carbon(jid_to->barejid, message_txt, enc_message);                }                xmpp_free(ctx, message_txt);                xmpp_free(ctx, enc_message);            }        }        jid_destroy(jid_from);        jid_destroy(jid_to);        jid_destroy(my_jid);        return TRUE;    }    return FALSE;}
开发者ID:0xPoly,项目名称:profanity,代码行数:59,


示例7: stanza_contains_chat_state

gbooleanstanza_contains_chat_state(xmpp_stanza_t *stanza){    return ((xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ACTIVE) != NULL) ||            (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_COMPOSING) != NULL) ||            (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_PAUSED) != NULL) ||            (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_GONE) != NULL) ||            (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_INACTIVE) != NULL));}
开发者ID:backalor,项目名称:profanity,代码行数:9,


示例8: n_handler

static xmpp_stanza_t* n_handler(const char *cmd,                                xmpp_stanza_t* cmd_stanza,                                xmpp_conn_t * const conn,                                xmpp_stanza_t * const stanza,                                void * const userdata,                                bool direct,                                conflate_mgmt_cb_t cb){    conflate_handle_t *handle = (conflate_handle_t*) userdata;    xmpp_ctx_t *ctx = handle->ctx;    conflate_form_result result = { .conn = conn,                                    .ctx = ctx,                                    .reply = NULL,                                    .cmd_res = NULL,                                    .container = NULL };    kvpair_t *form = NULL;    assert(cb);    result.reply = create_reply(ctx, stanza);    result.cmd_res = create_cmd_response(ctx, cmd_stanza);    add_and_release(result.reply, result.cmd_res);    xmpp_stanza_t *x = xmpp_stanza_get_child_by_name(cmd_stanza, "x");    if (x) {        xmpp_stanza_t *fields = xmpp_stanza_get_child_by_name(x, "field");        if (fields) {            form = grok_form(fields);        }    }    enum conflate_mgmt_cb_result rv = cb(handle->conf->userdata, handle,                                         cmd, direct, form, &result);    CONFLATE_LOG(handle, LOG_LVL_DEBUG, "Result of %s:  %s", cmd, cb_name(rv));    switch (rv) {    case RV_ERROR:        add_cmd_error(ctx, result.reply, "500",                      "urn:ietf:params:xml:ns:xmpp-stanzas",                      "internal-server-error", NULL, NULL);        break;    case RV_BADARG:        add_cmd_error(ctx, result.reply, "400",                      "urn:ietf:params:xml:ns:xmpp-stanzas", "bad-request",                      "http://jabber.org/protocol/commands", "bad-payload");        break;    case RV_OK:        /* Things are good, use the built form */        break;    }    free_kvpair(form);    return result.reply;}
开发者ID:strategist922,项目名称:libconflate,代码行数:57,


示例9: _version_result_handler

static int_version_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,    void * const userdata){    char *id = xmpp_stanza_get_id(stanza);    if (id != NULL) {        log_debug("IQ version result handler fired, id: %s.", id);    } else {        log_debug("IQ version result handler fired.");    }    const char *jid = xmpp_stanza_get_attribute(stanza, "from");    xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);    if (query == NULL) {        return 1;    }    char *ns = xmpp_stanza_get_ns(query);    if (g_strcmp0(ns, STANZA_NS_VERSION) != 0) {        return 1;    }    char *name_str = NULL;    char *version_str = NULL;    char *os_str = NULL;    xmpp_stanza_t *name = xmpp_stanza_get_child_by_name(query, "name");    xmpp_stanza_t *version = xmpp_stanza_get_child_by_name(query, "version");    xmpp_stanza_t *os = xmpp_stanza_get_child_by_name(query, "os");    if (name != NULL) {        name_str = xmpp_stanza_get_text(name);    }    if (version != NULL) {        version_str = xmpp_stanza_get_text(version);    }    if (os != NULL) {        os_str = xmpp_stanza_get_text(os);    }    PContact contact;    Jid *jidp = jid_create(jid);    if (muc_room_is_active(jidp->barejid)) {        contact = muc_get_participant(jidp->barejid, jidp->resourcepart);    } else {        contact = roster_get_contact(jidp->barejid);    }    Resource *resource = p_contact_get_resource(contact, jidp->resourcepart);    const char *presence = string_from_resource_presence(resource->presence);    handle_software_version_result(jid, presence, name_str, version_str, os_str);    jid_destroy(jidp);    return 1;}
开发者ID:dotoole,项目名称:profanity,代码行数:57,


示例10: XMPP_IBB_Data_Process

int XMPP_IBB_Data_Process(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata){    char* intext;    unsigned char *result;    xmpp_ctx_t *ctx = (xmpp_ctx_t*)userdata;    char *szSid, szSeq;	//    xmpp_ibb_session_t* ibb_ssn;        szSid = /	xmpp_stanza_get_attribute(xmpp_stanza_get_child_by_name(stanza, "data"), "sid");     szSeq = / 	xmpp_stanza_get_attribute(xmpp_stanza_get_child_by_name(stanza, "data"), "seq");     intext = xmpp_stanza_get_text(xmpp_stanza_get_child_by_name(stanza, "data"));    printf("[Sid=%s][Seq=%s][Raw Data=%s]/n", szSid, szSeq, intext);    result = base64_decode(ctx, intext, strlen(intext));    printf("Decode result=%s/n", result);    gRecv = malloc(strlen(result)+1);    strcpy(gRecv, result);        if(gStanza == NULL)        gStanza = xmpp_stanza_copy(stanza);#if 0  //data queue function has not been verified.  	                ibb_ssn = XMPP_Get_IBB_Session_Handle(szSid);    if( ibb_ssn == NULL)		    {        printf("Opened Session ID not found/n"); 	goto error;    }    xmpp_ibb_data_t* ibb_data_new = malloc(sizeof(xmpp_ibb_data_t));    ibb_data_new->seq_num = malloc(strlen(szSeq)+1);    ibb_data_new->recv_data =  malloc(strlen(result)+1);        strcpy(ibb_data_new->seq_num, szSeq);       strcpy(ibb_data_new->recv_data, result);       XMPP_IBB_Add_Session_Data_Queue(ibb_ssn, ibb_data_new);#endiferror:    xmpp_free(ctx, szSid);    xmpp_free(ctx, szSeq);    xmpp_free(ctx, intext);    xmpp_free(ctx, result);    return 1;}
开发者ID:RyanHong-2015,项目名称:libstrophe-xep,代码行数:56,


示例11: _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;}
开发者ID:energinet,项目名称:datalogger-client,代码行数:61,


示例12: _muc_user_handler

static int_muc_user_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata){    xmpp_ctx_t *ctx = connection_get_ctx();    xmpp_stanza_t *xns_muc_user = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);    char *room = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);    if (!room) {        log_warning("Message received with no from attribute, ignoring");        return 1;    }    // XEP-0045    xmpp_stanza_t *invite = xmpp_stanza_get_child_by_name(xns_muc_user, STANZA_NAME_INVITE);    if (!invite) {        return 1;    }    char *invitor_jid = xmpp_stanza_get_attribute(invite, STANZA_ATTR_FROM);    if (!invitor_jid) {        log_warning("Chat room invite received with no from attribute");        return 1;    }    Jid *jidp = jid_create(invitor_jid);    if (!jidp) {        return 1;    }    char *invitor = jidp->barejid;    char *reason = NULL;    xmpp_stanza_t *reason_st = xmpp_stanza_get_child_by_name(invite, STANZA_NAME_REASON);    if (reason_st) {        reason = xmpp_stanza_get_text(reason_st);    }    char *password = NULL;    xmpp_stanza_t *password_st = xmpp_stanza_get_child_by_name(xns_muc_user, STANZA_NAME_PASSWORD);    if (password_st) {        password = xmpp_stanza_get_text(password_st);    }    sv_ev_room_invite(INVITE_MEDIATED, invitor, room, reason, password);    jid_destroy(jidp);    if (reason) {        xmpp_free(ctx, reason);    }    if (password) {        xmpp_free(ctx, password);    }    return 1;}
开发者ID:KThand1,项目名称:profanity,代码行数:53,


示例13: message_handler

int message_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata){    char *intext, *decoded_intext;    if(!xmpp_stanza_get_child_by_name(stanza, "body")) return 1;    if(!strcmp(xmpp_stanza_get_attribute(stanza, "type"), "error")) return 1;    intext = xmpp_stanza_get_text(xmpp_stanza_get_child_by_name(stanza, "body"));    decoded_intext = from_base64(intext, strlen(intext));    fwrite((const void*)decoded_intext, 1, strlen(intext), stdout);    free(decoded_intext);    return 1;}
开发者ID:chmduquesne,项目名称:xmppipe,代码行数:12,


示例14: blocked_set_handler

intblocked_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;}
开发者ID:incertia,项目名称:profanity,代码行数:49,


示例15: XMPP_IBB_handler

/** Main callback function to dispatch XEP-0047 open/data/close stanzas *   @param conn   a Strophe connection object  *   @param stanza  a Strophe stanza object received from sender.*   @param userdata  a callback interface to pass xmpp_ctx. */int XMPP_IBB_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata){    char*  szBlock_size;    char*  szSid;	    printf("XMPP IBB Handler/n");    if( xmpp_stanza_get_child_by_name(stanza, "open") != NULL)    {        printf(" =====XEP0047 Open Handle/n");        szBlock_size =  /            xmpp_stanza_get_attribute(  xmpp_stanza_get_child_by_name(stanza, "open"), "block-size");        szSid =  /            xmpp_stanza_get_attribute(xmpp_stanza_get_child_by_name(stanza, "open"), "sid");    printf("XEP0047 IQ blocksize=%s sid=%s /n",szBlock_size, szSid );#if 0   // The is used to support multi sesssion. not verified. 	xmpp_ibb_session_t* ibb_ssn_p;		ibb_ssn_p = malloc(sizeof(xmpp_ibb_session_t));        ibb_ssn_p->sid = malloc(strlen(szSid)+1);			ibb_ssn_p->szblock_size = malloc(strlen(szBlock_size)+1);	ibb_ssn_p->ibb_data_queue = NULL;        ibb_ssn_p->next = NULL;		strcpy(ibb_ssn_p->sid, szBlock_size);	strcpy(ibb_ssn_p->szblock_size, szSid);	//=================> gXMPP_IBB_handle-> next = ibb_ssn_p;	XMPP_IBB_Add_Session_Queue(ibb_ssn_p);#endif        XMPP_IBB_Ack_Send(conn, stanza, userdata);    }    else  if( xmpp_stanza_get_child_by_name(stanza, "data") != NULL)    {        XMPP_IBB_Ack_Send(conn, stanza, userdata);        printf("========XEP0047 Data process/n");        XMPP_IBB_Data_Process(conn, stanza  , userdata);              }    else if( xmpp_stanza_get_child_by_name(stanza, "close")  )    {        XMPP_IBB_Ack_Send(conn, stanza, userdata);    }    return 1;}
开发者ID:RyanHong-2015,项目名称:libstrophe-xep,代码行数:55,


示例16: _captcha_handler

static int_captcha_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata){    xmpp_ctx_t *ctx = connection_get_ctx();    char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);    if (!from) {        log_warning("Message received with no from attribute, ignoring");        return 1;    }    // XEP-0158    xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY);    if (!body) {        return 1;    }    char *message = xmpp_stanza_get_text(body);    if (!message) {        return 1;    }    sv_ev_room_broadcast(from, message);    xmpp_free(ctx, message);    return 1;}
开发者ID:KThand1,项目名称:profanity,代码行数:27,


示例17: _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;}
开发者ID:FihlaTV,项目名称:conference,代码行数:28,


示例18: _pong_handler

static int_pong_handler(xmpp_conn_t *const conn, xmpp_stanza_t * const stanza,    void * const userdata){    char *id = xmpp_stanza_get_id(stanza);    char *type = xmpp_stanza_get_type(stanza);    if (id != NULL && type != NULL) {        // show warning if error        if (strcmp(type, STANZA_TYPE_ERROR) == 0) {            log_warning("Server ping (id=%s) responded with error", id);            // turn off autoping if error type is 'cancel'            xmpp_stanza_t *error = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR);            if (error != NULL) {                char *errtype = xmpp_stanza_get_type(error);                if (errtype != NULL) {                    if (strcmp(errtype, "cancel") == 0) {                        log_warning("Server ping (id=%s) error type 'cancel', disabling autoping.", id);                        handle_autoping_cancel();                        xmpp_timed_handler_delete(conn, _ping_timed_handler);                    }                }            }        }    }    // remove this handler    return 0;}
开发者ID:NYAMNYAM3,项目名称:profanity,代码行数:30,


示例19: 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;}
开发者ID:strategist922,项目名称:libconflate,代码行数:26,


示例20: stanza_get_idle_time

intstanza_get_idle_time(xmpp_stanza_t * const stanza){    xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);    if (query == NULL) {        return 0;    }    char *ns = xmpp_stanza_get_ns(query);    if (ns == NULL) {        return 0;    }    if (strcmp(ns, STANZA_NS_LASTACTIVITY) != 0) {        return 0;    }    char *seconds_str = xmpp_stanza_get_attribute(query, STANZA_ATTR_SECONDS);    if (seconds_str == NULL) {        return 0;    }    int result = atoi(seconds_str);    if (result < 1) {        return 0;    } else {        return result;    }}
开发者ID:backalor,项目名称:profanity,代码行数:30,


示例21: handle_reply

int handle_reply(xmpp_conn_t * const conn,		 xmpp_stanza_t * const stanza,		 void * const userdata){    xmpp_stanza_t *query, *item;    char *type, *name;    type = xmpp_stanza_get_type(stanza);    if (strcmp(type, "error") == 0)	fprintf(stderr, "ERROR: query failed/n");    else {	query = xmpp_stanza_get_child_by_name(stanza, "query");	printf("Roster:/n");	for (item = xmpp_stanza_get_children(query); item; 	     item = xmpp_stanza_get_next(item))	    if ((name = xmpp_stanza_get_attribute(item, "name")))		printf("/t %s (%s) sub=%s/n", 		       name,		       xmpp_stanza_get_attribute(item, "jid"),		       xmpp_stanza_get_attribute(item, "subscription"));	    else		printf("/t %s sub=%s/n",		       xmpp_stanza_get_attribute(item, "jid"),		       xmpp_stanza_get_attribute(item, "subscription"));	printf("END OF LIST/n");    }    /* disconnect */    xmpp_disconnect(conn);    return 0;}
开发者ID:1Project,项目名称:SafeBoardMessenger,代码行数:32,


示例22: _iq_handle_discoinfo_get

static int_iq_handle_discoinfo_get(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,    void * const userdata){    xmpp_ctx_t *ctx = (xmpp_ctx_t *)userdata;    const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);    xmpp_stanza_t *incoming_query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);    const char *node_str = xmpp_stanza_get_attribute(incoming_query, STANZA_ATTR_NODE);    if (from != NULL) {        xmpp_stanza_t *response = xmpp_stanza_new(ctx);        xmpp_stanza_set_name(response, STANZA_NAME_IQ);        xmpp_stanza_set_id(response, xmpp_stanza_get_id(stanza));        xmpp_stanza_set_attribute(response, STANZA_ATTR_TO, from);        xmpp_stanza_set_type(response, STANZA_TYPE_RESULT);        xmpp_stanza_t *query = caps_create_query_response_stanza(ctx);        if (node_str != NULL) {            xmpp_stanza_set_attribute(query, STANZA_ATTR_NODE, node_str);        }        xmpp_stanza_add_child(response, query);        xmpp_send(conn, response);        xmpp_stanza_release(query);        xmpp_stanza_release(response);    }    return 1;}
开发者ID:louiecaulfield,项目名称:profanity,代码行数:29,


示例23: 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;}
开发者ID:apophys,项目名称:libstrophe,代码行数:43,


示例24: _handle_features

static int _handle_features(xmpp_conn_t * const conn,			    xmpp_stanza_t * const stanza,			    void * const userdata){    xmpp_stanza_t *child, *mech;    char *text;    /* remove the handler that detects missing stream:features */    xmpp_timed_handler_delete(conn, _handle_missing_features);    /* check for TLS */    if (!conn->secured) {        if (!conn->tls_disabled) {            child = xmpp_stanza_get_child_by_name(stanza, "starttls");            if (child && (strcmp(xmpp_stanza_get_ns(child), XMPP_NS_TLS) == 0))                conn->tls_support = 1;        } else {            conn->tls_support = 0;        }    }    /* check for SASL */    child = xmpp_stanza_get_child_by_name(stanza, "mechanisms");    if (child && (strcmp(xmpp_stanza_get_ns(child), XMPP_NS_SASL) == 0)) {	for (mech = xmpp_stanza_get_children(child); mech;	     mech = xmpp_stanza_get_next(mech)) {	    if (xmpp_stanza_get_name(mech) && strcmp(xmpp_stanza_get_name(mech), "mechanism") == 0) {		text = xmpp_stanza_get_text(mech);		if (strcasecmp(text, "PLAIN") == 0)		    conn->sasl_support |= SASL_MASK_PLAIN;		else if (strcasecmp(text, "DIGEST-MD5") == 0)		    conn->sasl_support |= SASL_MASK_DIGESTMD5;                else if (strcasecmp(text, "SCRAM-SHA-1") == 0)                    conn->sasl_support |= SASL_MASK_SCRAMSHA1;		else if (strcasecmp(text, "ANONYMOUS") == 0)		    conn->sasl_support |= SASL_MASK_ANONYMOUS;		xmpp_free(conn->ctx, text);	    }	}    }    _auth(conn);    return 0;}
开发者ID:mcanthony,项目名称:libstrophe,代码行数:46,


示例25: stanza_is_muc_self_presence

gbooleanstanza_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;}
开发者ID:backalor,项目名称:profanity,代码行数:56,


示例26: _is_required

static gboolean_is_required(xmpp_stanza_t *const stanza){    xmpp_stanza_t *child = xmpp_stanza_get_child_by_name(stanza, "required");    if (child) {        return TRUE;    } else {        return FALSE;    }}
开发者ID:sizeofvoid,项目名称:profanity,代码行数:10,


示例27: handle_disco_items

    inthandle_disco_items(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,        void * const userdata){    xmpp_stanza_t *query, *item;    xmppipe_state_t *state = userdata;    xmpp_ctx_t *ctx = state->ctx;    query = xmpp_stanza_get_child_by_name(stanza, "query");    if (query == NULL)        return 1;    for (item = xmpp_stanza_get_children(query); item != NULL;            item = xmpp_stanza_get_next(item)) {        xmpp_stanza_t *iq, *reply;        const char *jid = NULL;        const char *name = NULL;        char *id = NULL;        name = xmpp_stanza_get_name(item);        if (name == NULL)            continue;        if (XMPPIPE_STRNEQ(name, "item"))            continue;        jid = xmpp_stanza_get_attribute(item, "jid");        if (jid == NULL)            continue;        iq = xmppipe_stanza_new(ctx);        xmppipe_stanza_set_name(iq, "iq");        xmppipe_stanza_set_type(iq, "get");        xmppipe_stanza_set_attribute(iq, "to", jid);        id = xmpp_uuid_gen(state->ctx);        if (id == NULL) {            errx(EXIT_FAILURE, "unable to allocate message id");        }        xmppipe_stanza_set_id(iq, id);        reply = xmppipe_stanza_new(ctx);        xmppipe_stanza_set_name(reply, "query");        xmppipe_stanza_set_ns(reply, "http://jabber.org/protocol/disco#info");        xmppipe_stanza_add_child(iq, reply);        xmppipe_send(state, iq);        (void)xmpp_stanza_release(iq);        xmpp_free(state->ctx, id);    }    return 0;}
开发者ID:msantos,项目名称:xmppipe,代码行数:55,


示例28: _chat_handler

static int _chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata){    xmppdata_t xdata;    char *intext;    xmppchat_userdata_t *udata = (xmppchat_userdata_t *) userdata;    if (!xmpp_stanza_get_child_by_name(stanza, "body"))        return 1;    if (xmpp_stanza_get_attribute(stanza, "type") != NULL && !strcmp(xmpp_stanza_get_attribute(stanza, "type"), "error"))        return 1;    intext = xmpp_stanza_get_text(xmpp_stanza_get_child_by_name(stanza, "body"));    //printf("Incoming message from %s: %s/n", xmpp_stanza_get_attribute(stanza, "from"), intext);    xdata.from = xmpp_stanza_get_attribute(stanza, "from");    xdata.data = (void *) intext;    if (udata != NULL && udata->handler != NULL)        udata->handler(conn, &xdata, udata->userdata);    return 1;}
开发者ID:WorksSystems,项目名称:wks_xep0047,代码行数:20,


示例29: XMPP_IBB_SendPayload

void XMPP_IBB_SendPayload(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata, char* resp ){    static int seq = 0;    int data_seq = 0;    char Data_Seq_Buf[32];    char ID_Buf[32];    char* encoded_data;    xmpp_ctx_t *ctx = (xmpp_ctx_t *)userdata;    xmpp_stanza_t *iq, *data,  *text;    iq  = xmpp_stanza_new(ctx);    data = xmpp_stanza_new(ctx);    text = xmpp_stanza_new(ctx);    xmpp_stanza_set_name(iq, "iq");    xmpp_stanza_set_type(iq, "set");    sprintf(ID_Buf, "ID-seq-%d", seq);    seq++;    xmpp_stanza_set_id(iq, ID_Buf);    xmpp_stanza_set_attribute(iq, "to", xmpp_stanza_get_attribute(stanza, "from"));    xmpp_stanza_set_attribute(iq, "from", xmpp_stanza_get_attribute(stanza, "to"));    xmpp_stanza_set_name(data, "data");    xmpp_stanza_set_ns(data, XMLNS_IBB);    xmpp_stanza_set_attribute(data, "sid",   /    xmpp_stanza_get_attribute(xmpp_stanza_get_child_by_name(stanza, "data"), "sid"));      sprintf(Data_Seq_Buf , "%d", data_seq);    xmpp_stanza_set_attribute(data, "seq", Data_Seq_Buf);           printf("/n[Response =%s]/n", resp);    encoded_data = base64_encode(ctx, (unsigned char*)resp, strlen(resp));    xmpp_stanza_set_text_with_size(text, encoded_data, strlen(encoded_data));    xmpp_stanza_add_child(data, text);    xmpp_stanza_add_child(iq, data);    xmpp_send(conn, iq);    seq++;    free(resp);    xmpp_free(ctx, encoded_data);    xmpp_stanza_release(data);    xmpp_stanza_release(iq);    xmpp_stanza_release(text);    xmpp_stanza_release(stanza);  //copied by IBB IQ receiver handler}
开发者ID:RyanHong-2015,项目名称:libstrophe-xep,代码行数:54,



注:本文中的xmpp_stanza_get_child_by_name函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ xmpp_stanza_get_name函数代码示例
C++ xmpp_stanza_get_attribute函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。