当前位置: 首页>>代码示例>>C++>>正文


C++ xmpp_stanza_get_attribute函数代码示例

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


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

示例1: files

void files(const char *from, const char *to, int error, xmpp_stanza_t *stanza,
           xmpp_conn_t *const conn, void *const userdata)
{
  wlog("files()");
  if (error == 0) {
    char *action_attr = xmpp_stanza_get_attribute(stanza, "action"); /* action attribute */
    if (action_attr == NULL) {
      werr("xmpp_stanza_get_attribute attribute = action");
    }
    wfatal(action_attr == NULL, "xmpp_stanza_get_attribute [attribute = action]");

    if (strcmp(action_attr, "attributes") == 0) {
      files_attr(stanza);
    } else if (strcmp(action_attr, "list") == 0) {
      files_list(stanza);
    } else if (strncasecmp(action_attr, "read", 4) == 0) {
      files_read(stanza);
    } else {
      werr("Unknown action: %s", action_attr);
    }
  } else {
    werr("error stanza %s %s", xmpp_stanza_get_attribute(stanza, "path"), xmpp_stanza_get_attribute(stanza, "action"));
  }

  wlog("Return from files()");
}
开发者ID:RedPitaya,项目名称:wyliodrin-server,代码行数:26,代码来源:files.c

示例2: _iq_handle_ping_get

static int
_iq_handle_ping_get(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
    void * const userdata)
{
    xmpp_ctx_t *ctx = (xmpp_ctx_t *)userdata;
    const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID);
    const char *to = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_TO);
    const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);

    if ((from == NULL) || (to == NULL)) {
        return 1;
    }

    xmpp_stanza_t *pong = xmpp_stanza_new(ctx);
    xmpp_stanza_set_name(pong, STANZA_NAME_IQ);
    xmpp_stanza_set_attribute(pong, STANZA_ATTR_TO, from);
    xmpp_stanza_set_attribute(pong, STANZA_ATTR_FROM, to);
    xmpp_stanza_set_attribute(pong, STANZA_ATTR_TYPE, STANZA_TYPE_RESULT);

    if (id != NULL) {
        xmpp_stanza_set_attribute(pong, STANZA_ATTR_ID, id);
    }

    xmpp_send(conn, pong);
    xmpp_stanza_release(pong);

    return 1;
}
开发者ID:louiecaulfield,项目名称:profanity,代码行数:28,代码来源:iq.c

示例3: _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,代码来源:iq.c

示例4: stanza_get_delay

gboolean
stanza_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,代码来源:stanza.c

示例5: _conference_handler

static int
_conference_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata)
{
    xmpp_stanza_t *xns_conference = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CONFERENCE);

    char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
    if (!from) {
        log_warning("Message received with no from attribute, ignoring");
        return 1;
    }

    Jid *jidp = jid_create(from);
    if (!jidp) {
        return 1;
    }

    // XEP-0249
    char *room = xmpp_stanza_get_attribute(xns_conference, STANZA_ATTR_JID);
    if (!room) {
        jid_destroy(jidp);
        return 1;
    }

    char *reason = xmpp_stanza_get_attribute(xns_conference, STANZA_ATTR_REASON);
    char *password = xmpp_stanza_get_attribute(xns_conference, STANZA_ATTR_PASSWORD);

    sv_ev_room_invite(INVITE_DIRECT, jidp->barejid, room, reason, password);
    jid_destroy(jidp);

    return 1;
}
开发者ID:KThand1,项目名称:profanity,代码行数:31,代码来源:message.c

示例6: _room_config_submit_handler

static int
_room_config_submit_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
    void * const userdata)
{
    const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID);
    const char *type = xmpp_stanza_get_type(stanza);
    const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);

    if (id != NULL) {
        log_debug("IQ room config submit handler fired, id: %s.", id);
    } else {
        log_debug("IQ room config submit handler fired.");
    }

    // handle error responses
    if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
        char *error_message = stanza_get_error_message(stanza);
        handle_room_config_submit_result_error(from, error_message);
        free(error_message);
        return 0;
    }

    handle_room_config_submit_result(from);

    return 0;
}
开发者ID:dotoole,项目名称:profanity,代码行数:26,代码来源:iq.c

示例7: _respond_iq_with_error

static void _respond_iq_with_error(xmpp_conn_t *conn, xmpp_stanza_t *stanza, const char *type, const char* condition)
{
	char *id = xmpp_stanza_get_attribute(stanza, "id");
	if (!id)
		return;
	xmpp_stanza_t *response = xmpp_stanza_new(_xmpp_ctx);
	xmpp_stanza_set_name(response, "iq");
	xmpp_stanza_set_attribute(response, "type", "error");
	xmpp_stanza_set_attribute(response, "id", id);

	char *req_from = xmpp_stanza_get_attribute(stanza, "from");
	//当req_from为NULL时, to属性应该设为服务器, 不设应该默认是服务器;
	if (req_from)
		xmpp_stanza_set_attribute(response, "to", req_from);

	xmpp_stanza_t *stanza_error = xmpp_stanza_new(_xmpp_ctx);
	xmpp_stanza_set_name(stanza_error, "error");
	xmpp_stanza_set_attribute(stanza_error, "type", type);

	xmpp_stanza_t *stanza_condition = xmpp_stanza_new(_xmpp_ctx);
	xmpp_stanza_set_name(stanza_condition, condition);
	xmpp_stanza_set_ns(stanza_condition, XMPP_NS_STANZA);

	xmpp_stanza_add_child(stanza_error, stanza_condition);
	xmpp_stanza_add_child(response, stanza_error);

	xmpp_stanza_release(stanza_condition);
	xmpp_stanza_release(stanza_error);

	xmpp_send(conn, response);
	xmpp_stanza_release(response);
}
开发者ID:FihlaTV,项目名称:conference,代码行数:32,代码来源:zkxmpp_ua.cpp

示例8: _disco_items_get_handler

static int
_disco_items_get_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
    void * const userdata)
{
    xmpp_ctx_t *ctx = (xmpp_ctx_t *)userdata;
    const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID);
    const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);

    if (id != NULL) {
        log_debug("IQ disco items get handler fired, id: %s.", id);
    } else {
        log_debug("IQ disco items get handler fired.");
    }

    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 = xmpp_stanza_new(ctx);
        xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
        xmpp_stanza_set_ns(query, XMPP_NS_DISCO_ITEMS);
        xmpp_stanza_add_child(response, query);
        xmpp_send(conn, response);

        xmpp_stanza_release(response);
    }

    return 1;
}
开发者ID:dotoole,项目名称:profanity,代码行数:31,代码来源:iq.c

示例9: _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;
}
开发者ID:KThand1,项目名称:profanity,代码行数:25,代码来源:message.c

示例10: 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,代码来源:roster.c

示例11: _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,代码来源:zksignal.cpp

示例12: 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,代码来源:basic.c

示例13: 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,代码来源:main.c

示例14: PresenceHandler

/**
 * This handles a status response iq be printing it out
 */
int PresenceHandler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
		void * const userdata) {
//    xmpp_stanza_t *reply;
	char *type;
//    char *id;
	char *sender;
	xmpp_ctx_t *ctx = (xmpp_ctx_t *) userdata;

	sdvpIdleCounter = 0;
	sdvpPingsSent = 0;

// type is NULL if initial presence is received
	type = xmpp_stanza_get_type(stanza);
	if (type != NULL ) {
		if (strcmp(type, "error") == 0) {
			syslog(LOG_WARNING, "ERROR: Received presence with type of error\n");
		} else {
//            id = xmpp_stanza_get_id(stanza);
			sender = xmpp_stanza_get_attribute(stanza, "from");

//            reply = xmpp_stanza_new(ctx);
//            xmpp_stanza_set_name(reply, "presence");
//            xmpp_stanza_set_type(reply, "result");
//            if (id != NULL ) {
//                xmpp_stanza_set_id(reply, id);
//            }
//            xmpp_stanza_set_attribute(reply, "to", sender);
//            xmpp_send(conn, reply);
//            xmpp_stanza_release(reply);
		}
	} else {
//        id = xmpp_stanza_get_id(stanza);
		sender = strdup(xmpp_stanza_get_attribute(stanza, "from"));

		// Check if the presence is from the server user
		char *senderUsername;
		senderUsername = GetUsernameFromJid(sender);
		if (strcmp(sdvpServerUsername, senderUsername) == 0) {
			sdvpServerFullJid = strdup(sender);
			// Send status-request
			_SendRpcCall(conn, ctx, sdvpServerFullJid);
		}
		free(sender);

		// Dont send reply as the server should do this automatically
		// to all connected users on the roster
//        reply = xmpp_stanza_new(ctx);
//        xmpp_stanza_set_name(reply, "presence");
//        xmpp_stanza_set_type(reply, "result");
//        if (id != NULL ) {
//            xmpp_stanza_set_id(reply, id);
//        }
//        xmpp_stanza_set_attribute(reply, "to", sender);
//        xmpp_send(conn, reply);
//        xmpp_stanza_release(reply);

	}
	return 1;
}
开发者ID:energinet,项目名称:datalogger-client,代码行数:62,代码来源:sdvp.c

示例15: _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,代码来源:message.c


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