本文整理汇总了C++中xmpp_stanza_get_text函数的典型用法代码示例。如果您正苦于以下问题:C++ xmpp_stanza_get_text函数的具体用法?C++ xmpp_stanza_get_text怎么用?C++ xmpp_stanza_get_text使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xmpp_stanza_get_text函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: _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;
}
示例3: _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;
}
示例4: _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;
}
示例5: _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;
}
示例6: files_read
static void files_read(xmpp_stanza_t *stanza) {
int rc;
rc = pthread_mutex_lock(&mutex);
wsyserr(rc != 0, "pthread_mutex_lock");
char *text = xmpp_stanza_get_text(stanza);
if(text == NULL) {
werr("xmpp_stanza_get_text returned NULL (%s, error %s)", xmpp_stanza_get_attribute(stanza, "path"), xmpp_stanza_get_attribute(stanza, "error"));
read_data = strdup ("");
}
else
{
int dec_size = strlen(text) * 3 / 4 + 1;
uint8_t *dec_text = (uint8_t *)calloc(dec_size, sizeof(uint8_t));
rc = base64_decode(dec_text, text, dec_size);
wfatal(rc < 0, "base64_decode");
if (read_data != NULL) {
free(read_data);
}
read_data = strdup((char *)dec_text);
wsyserr(read_data == NULL, "strdup");
free(text);
free(dec_text);
}
signal_read = true;
rc = pthread_cond_signal(&cond);
wsyserr(rc != 0, "pthread_cond_signal");
rc = pthread_mutex_unlock(&mutex);
wsyserr(rc != 0, "pthread_mutex_unlock");
}
示例7: _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;
}
示例8: 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;
}
示例9: 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;
}
示例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);
#endif
error:
xmpp_free(ctx, szSid);
xmpp_free(ctx, szSeq);
xmpp_free(ctx, intext);
xmpp_free(ctx, result);
return 1;
}
示例11: _handle_digestmd5_challenge
/* handle the challenge phase of digest auth */
static int _handle_digestmd5_challenge(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza,
void * const userdata)
{
char *text;
char *response;
xmpp_stanza_t *auth, *authdata;
char *name;
name = xmpp_stanza_get_name(stanza);
xmpp_debug(conn->ctx, "xmpp",\
"handle digest-md5 (challenge) called for %s", name);
if (strcmp(name, "challenge") == 0) {
text = xmpp_stanza_get_text(stanza);
response = sasl_digest_md5(conn->ctx, text, conn->jid, conn->pass);
if (!response) {
disconnect_mem_error(conn);
return 0;
}
xmpp_free(conn->ctx, text);
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);
authdata = xmpp_stanza_new(conn->ctx);
if (!authdata) {
disconnect_mem_error(conn);
return 0;
}
xmpp_stanza_set_text(authdata, response);
xmpp_free(conn->ctx, response);
xmpp_stanza_add_child(auth, authdata);
xmpp_stanza_release(authdata);
handler_add(conn, _handle_digestmd5_rspauth,
XMPP_NS_SASL, NULL, NULL, NULL);
xmpp_send(conn, auth);
xmpp_stanza_release(auth);
} else {
return _handle_sasl_result(conn, stanza, "DIGEST-MD5");
}
/* remove ourselves */
return 0;
}
示例12: 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;
}
示例13: xmpp_stanza_get_name
/** Get text from <body/> child element.
* This function returns new allocated string. The caller is responsible
* for freeing this string with xmpp_free().
*
* @param msg well formed <message/> stanza
*
* @return allocated string or NULL on failure (no <body/> element or
* memory allocation error)
*
* @ingroup Stanza
*/
char *xmpp_message_get_body(xmpp_stanza_t *msg)
{
xmpp_stanza_t *body;
const char *name;
char *text = NULL;
name = xmpp_stanza_get_name(msg);
body = xmpp_stanza_get_child_by_name(msg, "body");
if (name && strcmp(name, "message") == 0 && body) {
text = xmpp_stanza_get_text(body);
}
return text;
}
示例14: _zkmuc_on_rcv_invite
static int _zkmuc_on_rcv_invite(xmpp_ua_t *ua, xmpp_stanza_t *stanza, void *userdata)
{
char *ns = xmpp_stanza_get_ns(stanza);
if (ns != NULL && !strcmp(ns, XMPP_NS_CONFERECE))
{
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, "body");
if (stanza_body)
{
char *room_id = xmpp_stanza_get_text(stanza_body);
ctx->invite_cb(ctx, from, room_id, ctx->invite_data);
}
return 1;
}
return 0;
}
示例15: _get_property
static char*
_get_property(xmpp_stanza_t *const stanza, const char *const property)
{
char *result = NULL;
xmpp_ctx_t *ctx = connection_get_ctx();
xmpp_stanza_t *child = xmpp_stanza_get_child_by_name(stanza, property);
if (child) {
char *child_text = xmpp_stanza_get_text(child);
if (child_text) {
result = strdup(child_text);
xmpp_free(ctx, child_text);
}
}
return result;
}