Ejemplo n.º 1
0
void action_search_form(LmConnection * connection, LmMessage * message, gpointer data)
{
	GGaduDialog *dialog;
	LmMessageNode *node;
	
	dialog =  ggadu_dialog_new_full(GGADU_DIALOG_GENERIC,_("Jabber search: form"),"search", 
			    (gpointer) g_strdup(lm_message_node_get_attribute(message->node, "from")));

	node = lm_message_node_get_child(message->node, "query");
	if (!strcmp(lm_message_node_get_attribute(node, "xmlns"), "jabber:iq:search"))
	{
		/* child_instr = lm_message_node_get_child(node, "instructions"); */   

		if (lm_message_node_get_child(node, "first"))
			ggadu_dialog_add_entry(dialog, GGADU_SEARCH_FIRSTNAME, _("First name:"), VAR_STR, NULL,
					       VAR_FLAG_NONE);
		if (lm_message_node_get_child(node, "last"))
			ggadu_dialog_add_entry(dialog, GGADU_SEARCH_LASTNAME, _("Last name:"), VAR_STR, NULL,
					       VAR_FLAG_NONE);
		if (lm_message_node_get_child(node, "nick"))
			ggadu_dialog_add_entry(dialog, GGADU_SEARCH_NICKNAME, _("Nick:"), VAR_STR, NULL,
					       VAR_FLAG_NONE);
		if (lm_message_node_get_child(node, "email"))
			ggadu_dialog_add_entry(dialog, GGADU_SEARCH_EMAIL, _("Email:"), VAR_STR, NULL,
					       VAR_FLAG_NONE);

		signal_emit("jabber", "gui show dialog", dialog, "main-gui");
	}
}
Ejemplo n.º 2
0
static void
sig_recv_message(XMPP_SERVER_REC *server, LmMessage *lmsg, const int type,
    const char *id, const char *from, const char *to)
{
	LmMessageNode *node;

	if ((type != LM_MESSAGE_SUB_TYPE_NOT_SET
	    && type != LM_MESSAGE_SUB_TYPE_HEADLINE
	    && type != LM_MESSAGE_SUB_TYPE_NORMAL
	    && type != LM_MESSAGE_SUB_TYPE_CHAT)
	    || server->ischannel(SERVER(server), from))
		return;
	node = lm_find_node(lmsg->node, "x", XMLNS, XMLNS_EVENT);
	if (node == NULL) {
		signal_emit("xmpp composing hide", 2, server, from);
		return;
	}
	if (lm_message_node_get_child(lmsg->node, "body") != NULL
	    || lm_message_node_get_child(lmsg->node, "subject") != NULL) {
		if (lm_message_node_get_child(node, "composing") != NULL)
			datalist_add(composings, server, from, g_strdup(id));
		else
			datalist_remove(composings, server, from);
		signal_emit("xmpp composing hide", 2, server, from);
	} else {
		if (lm_message_node_get_child(node, "composing") != NULL)
			signal_emit("xmpp composing show", 2, server, from);
		else
			signal_emit("xmpp composing hide", 2, server, from);
	}
}
Ejemplo n.º 3
0
boolean
xmpp_connect (const char *user, const char * passwd, const char * server, unsigned short port)
{

  GError * error = NULL;
  LmMessage * m;
  LmMessage * reply;
  LmMessageNode * query;
  LmMessageNode * item;
  gboolean success;

  lm_connection_set_server (connection, server);
  lm_connection_set_port (connection, port);

  g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, _("Connecting to %s..."), server);
  success = lm_connection_open_and_block (connection, &error);
  if (!success) goto error;

  g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, _("Authenticating with JID %s..."), user);
  success = lm_connection_authenticate_and_block (connection, user, passwd, CONN_XMPP_RESOURCE, &error);
  if (!success) goto error;
  g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, _("Connected successfully."), user);

  /* Fetch roster */
  m = lm_message_new_with_sub_type (NULL, LM_MESSAGE_TYPE_IQ, LM_MESSAGE_SUB_TYPE_GET);
  query = lm_message_node_add_child (m->node, "query", NULL);
  lm_message_node_set_attributes (query, "xmlns", "jabber:iq:roster", NULL);
  reply = lm_connection_send_with_reply_and_block (connection, m, &error);
  query = lm_message_node_get_child (reply->node, "query");
  item  = lm_message_node_get_child (query, "item");
  while (item)
    {
      xmpp_user_t user;
      const gchar *jid, *name;
      jid = lm_message_node_get_attribute (item, "jid");
      name = lm_message_node_get_attribute (item, "name");
      user = intern_user (jid);
      user->name = g_strdup (name);
      user->status = OFFLINE;
      item = item->next;
    }
  lm_message_unref (reply);
  lm_message_unref (m);

  m = lm_message_new_with_sub_type (NULL, LM_MESSAGE_TYPE_PRESENCE, LM_MESSAGE_SUB_TYPE_AVAILABLE);
  lm_connection_send(connection, m, NULL);
  lm_message_unref (m);

  return TRUE;

  /* Error handling */
 error:
  g_message ("%s", error->message);
  return FALSE;
}
Ejemplo n.º 4
0
LmHandlerResult handle_iq_commands(LmMessageHandler *h,
                                   LmConnection *c,
                                   LmMessage *m, gpointer ud)
{
  const char *requester_jid = NULL;
  LmMessageNode *cmd;
  const struct adhoc_command *command;

  // mcabber has only partial XEP-0146 support...
  if (LM_MESSAGE_SUB_TYPE_SET != lm_message_get_sub_type(m))
    return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;

  requester_jid = lm_message_get_from(m);

  cmd = lm_message_node_get_child(m->node, "command");
  if (!cmd) {
    //send_iq_error(c, m, XMPP_ERROR_BAD_REQUEST);
    return LM_HANDLER_RESULT_REMOVE_MESSAGE;
  }
  if (jid_equal(lm_connection_get_jid(c), requester_jid)) {
    const char *action, *node;
    action = lm_message_node_get_attribute(cmd, "action");
    node = lm_message_node_get_attribute(cmd, "node");
    // action can be NULL, in which case it seems to take the default,
    // ie execute
    if (!action || !strcmp(action, "execute") || !strcmp(action, "cancel")
        || !strcmp(action, "next") || !strcmp(action, "complete")) {
      for (command = adhoc_command_list; command->name; command++) {
        if (!strcmp(node, command->name))
          command->callback(h, c, m, ud);
      }
      // "prev" action will get there, as we do not implement it,
      // and do not authorize it
    } else {
      LmMessage *r;
      LmMessageNode *err;
      r = lm_message_new_iq_error(m, XMPP_ERROR_BAD_REQUEST);
      if (r) {
        err = lm_message_node_get_child(r->node, "error");
        lm_message_node_set_attribute
          (lm_message_node_add_child(err, "malformed-action", NULL),
           "xmlns", NS_COMMANDS);
        lm_connection_send(c, r, NULL);
        lm_message_unref(r);
      }
    }
  } else {
    send_iq_error(c, m, XMPP_ERROR_FORBIDDEN);
  }
  return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
Ejemplo n.º 5
0
Archivo: harmony.c Proyecto: KDE/amarok
LmHandlerResult harmony_iq_callback(LmMessageHandler* handler, LmConnection *connection, LmMessage *message, gpointer void_harmony) {
    GError *err = NULL;
    MP3tunesHarmony *harmony = MP3TUNES_HARMONY(void_harmony);
    LmMessageNode *harmony_download_node, *harmony_email_node;

    mp3tunes_harmony_download_t *download;
    gchar *email;
    
    (void)handler;

    harmony_download_node = lm_message_node_get_child(message->node, "download");
    if (harmony_download_node) {
        mp3tunes_harmony_download_init(&download);
        mp3tunes_harmony_download_set_file_key(download, (char*)lm_message_node_get_attribute(harmony_download_node, "fileKey"));
        mp3tunes_harmony_download_set_file_name(download, (char*)lm_message_node_get_attribute(harmony_download_node, "fileName"));
        mp3tunes_harmony_download_set_file_format(download, (char*)lm_message_node_get_attribute(harmony_download_node, "fileFormat"));
        mp3tunes_harmony_download_set_file_size(download, atoi(lm_message_node_get_attribute(harmony_download_node, "fileSize")));
        mp3tunes_harmony_download_set_track_title(download, (char*)lm_message_node_get_attribute(harmony_download_node, "trackTitle"));
        mp3tunes_harmony_download_set_artist_name(download, (char*)lm_message_node_get_attribute(harmony_download_node, "artistName"));
        mp3tunes_harmony_download_set_album_title(download, (char*)lm_message_node_get_attribute(harmony_download_node, "albumTitle"));
        mp3tunes_harmony_download_set_device_bitrate(download, (char*)lm_message_node_get_attribute(harmony_download_node, "deviceBitrate"));
        mp3tunes_harmony_download_set_file_bitrate(download, (char*)lm_message_node_get_attribute(harmony_download_node, "fileBitrate"));
        
        download_pending_emit(harmony, download);
        
        mp3tunes_harmony_add_download_to_queue(harmony, download);
     
        harmony_success_reply(connection, message, &err);
        
        if (err != NULL) {
           error_emit(harmony, MP3TUNES_HARMONY_ERROR_MISC, "Sending success reply failed", err);
        }
        return LM_HANDLER_RESULT_REMOVE_MESSAGE;
    }
    
    harmony_email_node = lm_message_node_get_child(message->node, "email");
    if (harmony_email_node) {
        email = g_strdup(lm_message_node_get_value(harmony_email_node));
        mp3tunes_harmony_set_email(harmony, email);
        g_free(email);
        harmony_success_reply(connection, message, &err);
        if (err != NULL) {
           error_emit(harmony, MP3TUNES_HARMONY_ERROR_MISC, "Sending success reply failed", err);
        }
        close_connection(harmony);
        open_connection(harmony);
        return LM_HANDLER_RESULT_REMOVE_MESSAGE;
    }

    return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
}
Ejemplo n.º 6
0
Archivo: harmony.c Proyecto: KDE/amarok
LmHandlerResult harmony_get_device_email_callback(LmMessageHandler* handler, LmConnection *connection, LmMessage *message, gpointer void_harmony) {
    char *email;
    MP3tunesHarmony *harmony = MP3TUNES_HARMONY(void_harmony);
    LmMessageNode *harmony_email_node;

    (void)handler;
    (void)connection;

    harmony_email_node = lm_message_node_get_child(message->node, "email");
    if (harmony_email_node) {
        email = g_strdup(lm_message_node_get_value(harmony_email_node));
        sleep(2); /*
                     FIXME: This exists because mp3tunes website logins cannot 
                     exceed 1 per second. When a device connects that has been
                     fully authenticated previously it will rapidly reconnect
                     three times as it grabs pin, then email, then connects completely.
                  */
        mp3tunes_harmony_set_email(harmony, email);
        g_free(email);
        close_connection(harmony);
        open_connection(harmony);
        return LM_HANDLER_RESULT_REMOVE_MESSAGE;
    }
    return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
}
Ejemplo n.º 7
0
static LmHandlerResult
ft_msg_iq_handler (LmMessageHandler *handler, LmConnection *conn,
                   LmMessage *msg, gpointer user_data)
{
        /* Currently the only IQ message we'll handle is the roster */
        LmMessageNode *query = lm_message_node_get_child (msg->node, "query");

        int type = lm_message_get_sub_type (msg);

        if (query) {
                const char *ns = lm_message_node_get_attribute (query, "xmlns");

                if (ns && !g_ascii_strcasecmp (ns, "jabber:iq:roster"))
                        ft_roster_cb (msg);
                else if (ns && !g_ascii_strcasecmp (ns,
                                                    "jabber:iq:version")) {
                        if (type == LM_MESSAGE_SUB_TYPE_GET)
                                ft_msg_iq_version_cb (msg);
                } else if (ns && !g_ascii_strcasecmp (ns, "jabber:iq:last")) {
                        if (type == LM_MESSAGE_SUB_TYPE_GET)
                                ft_msg_iq_last_cb (msg);
                } else
                        PRINTF (_("[iq received: %s (unhandled yet)]"), ns);

        }
        return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
Ejemplo n.º 8
0
static LmHandlerResult
handle_register(LmMessageHandler *handler, LmConnection *connection,
    LmMessage *lmsg, gpointer user_data)
{
	LmMessageNode *node;
	struct register_data *rd;
	const char *id;
	char *cmd;
	int error;

	rd = user_data;
	id = lm_message_node_get_attribute(lmsg->node, "id");
	if (id == NULL || (id != NULL && strcmp(id, rd->id) != 0))
		return LM_HANDLER_RESULT_REMOVE_MESSAGE;
	if ((node = lm_message_node_get_child(lmsg->node, "error")) != NULL) {
		error = atoi(lm_message_node_get_attribute(node, "code"));
		signal_emit("xmpp registration failed", 3, rd->username,
		    rd->domain, GINT_TO_POINTER(error));
	} else {
		signal_emit("xmpp registration succeed", 2, rd->username,
		    rd->domain);
		cmd = g_strdup_printf(
		    "%sXMPPCONNECT %s-host %s -port %d %s@%s %s",
		    settings_get_str("cmdchars"),
		    rd->use_ssl ? "-ssl " : "", rd->address, rd->port,
		    rd->username, rd->domain, rd->password);
		signal_emit("send command", 3, cmd, NULL, NULL);
		g_free(cmd);
	}
	rd_cleanup(rd);
	return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
Ejemplo n.º 9
0
static LmHandlerResult cb_vcard(LmMessageHandler *h, LmConnection *c,
                               LmMessage *m, gpointer user_data)
{
  LmMessageNode *ansqry;
  const char *bjid;
  char *buf, *tmp;

  // Check IQ result sender
  bjid = lm_message_get_from(m);
  if (!bjid)
    bjid = lm_connection_get_jid(lconnection); // No from means our JID...
  if (!bjid) {
    scr_LogPrint(LPRINT_LOGNORM, "Invalid IQ:vCard result (no sender name).");
    return LM_HANDLER_RESULT_REMOVE_MESSAGE;
  }

  // Check for error message
  if (lm_message_get_sub_type(m) == LM_MESSAGE_SUB_TYPE_ERROR) {
    scr_LogPrint(LPRINT_LOGNORM, "Received error IQ message (%s)", bjid);
    display_server_error(lm_message_node_get_child(m->node, "error"), NULL);
    return LM_HANDLER_RESULT_REMOVE_MESSAGE;
  }

  buf = g_strdup_printf("Received IQ:vCard result from <%s>", bjid);
  scr_LogPrint(LPRINT_LOGNORM, "%s", buf);

  // Get the vCard node
  ansqry = lm_message_node_get_child(m->node, "vCard");
  if (!ansqry) {
    scr_LogPrint(LPRINT_LOGNORM, "Empty IQ:vCard result!");
    g_free(buf);
    return LM_HANDLER_RESULT_REMOVE_MESSAGE;
  }

  // bjid should really be the "bare JID", let's strip the resource
  tmp = strchr(bjid, JID_RESOURCE_SEPARATOR);
  if (tmp) *tmp = '\0';

  scr_WriteIncomingMessage(bjid, buf, 0, HBB_PREFIX_INFO, 0);
  g_free(buf);

  // Get result data...
  handle_vcard_node(bjid, ansqry);
  return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
Ejemplo n.º 10
0
static LmHandlerResult cb_storage_bookmarks(LmMessageHandler *h,
                                            LmConnection *c,
                                            LmMessage *m, gpointer user_data)
{
  LmMessageNode *x, *ansqry;
  char *p = NULL;

  if (lm_message_get_sub_type(m) == LM_MESSAGE_SUB_TYPE_ERROR) {
    LmMessageNode *error = lm_message_node_get_child(m->node, "error");
    // No server support, or no bookmarks?
    if (error && error->children)
      p = error->children->name;
    if (p && !strcmp(p, "item-not-found")) {
      // item-no-found means the server has Private Storage, but it's
      // currently empty.
      if (bookmarks)
        lm_message_node_unref(bookmarks);
      bookmarks = lm_message_node_new("storage", "storage:bookmarks");
      // We return 0 so that the IQ error message be
      // not displayed, as it isn't a real error.
    } else
      scr_LogPrint(LPRINT_LOGNORM, "Server does not support bookmarks storage.");
    return LM_HANDLER_RESULT_REMOVE_MESSAGE;
  }

  ansqry = lm_message_node_get_child(m->node, "query");
  ansqry = lm_message_node_get_child(ansqry, "storage");
  if (!ansqry) {
    scr_LogPrint(LPRINT_LOG, "Invalid IQ:private result! (storage:bookmarks)");
    return 0;
  }

  // Walk through the storage tags
  for (x = ansqry->children ; x; x = x->next) {
    // If the current node is a conference item, parse it and update the roster
    if (x->name && !strcmp(x->name, "conference"))
      storage_bookmarks_parse_conference(x);
  }
  // "Copy" the bookmarks node
  if (bookmarks)
    lm_message_node_unref(bookmarks);
  lm_message_node_deep_ref(ansqry);
  bookmarks = ansqry;
  return 0;
}
Ejemplo n.º 11
0
static LmHandlerResult cb_ping(LmMessageHandler *h, LmConnection *c,
                               LmMessage *m, gpointer user_data)
{
  struct timeval *timestamp = (struct timeval *)user_data;
  struct timeval now;
  time_t         dsec;
  suseconds_t    dusec;
  const gchar    *fjid;
  gchar          *bjid, *mesg = NULL;

  gettimeofday(&now, NULL);
  dsec = now.tv_sec - timestamp->tv_sec;
  if (now.tv_usec < timestamp->tv_usec) {
    dusec = now.tv_usec + 1000000 - timestamp->tv_usec;
    --dsec;
  } else
    dusec = now.tv_usec - timestamp->tv_usec;

  // Check IQ result sender
  fjid = lm_message_get_from(m);
  if (!fjid)
    fjid = lm_connection_get_jid(lconnection); // No from means our JID...
  if (!fjid) {
    scr_LogPrint(LPRINT_LOGNORM, "Invalid IQ:version result (no sender name).");
    return LM_HANDLER_RESULT_REMOVE_MESSAGE;
  }

  bjid  = jidtodisp(fjid);

  switch (lm_message_get_sub_type(m)) {
    case LM_MESSAGE_SUB_TYPE_RESULT:
        mesg = g_strdup_printf("Pong from <%s>: %d second%s %d ms.", fjid,
                               (int)dsec, dsec > 1 ? "s" : "",
                               (int)(dusec/1000L));
        break;

    case LM_MESSAGE_SUB_TYPE_ERROR:
        display_server_error(lm_message_node_get_child(m->node, "error"),
                             fjid);
        mesg = g_strdup_printf("Ping to <%s> failed.  "
                               "Response time: %d second%s %d ms.",
                               fjid, (int)dsec, dsec > 1 ? "s" : "",
                               (int)(dusec/1000L));
        break;

    default:
        g_free(bjid);
        return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
        break;
  }

  if (mesg)
    scr_WriteIncomingMessage(bjid, mesg, 0, HBB_PREFIX_INFO, 0);
  g_free(mesg);
  g_free(bjid);
  return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
Ejemplo n.º 12
0
// Dummy handler to ignore IQ response
LmHandlerResult handle_iq_dummy(LmMessageHandler *h, LmConnection *c,
                                 LmMessage *m, gpointer ud)
{
  LmMessageSubType mstype = lm_message_get_sub_type(m);
  if (mstype == LM_MESSAGE_SUB_TYPE_ERROR) {
    display_server_error(lm_message_node_get_child(m->node, "error"),
                         lm_message_get_from(m));
  }
  return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
Ejemplo n.º 13
0
static void
sig_send_message(XMPP_SERVER_REC *server, LmMessage *lmsg)
{
	LmMessageNode *node;
	LmMessageSubType type;

	type = lm_message_get_sub_type(lmsg);
	if ((type != LM_MESSAGE_SUB_TYPE_NOT_SET
	    && type != LM_MESSAGE_SUB_TYPE_HEADLINE
	    && type != LM_MESSAGE_SUB_TYPE_NORMAL
	    && type != LM_MESSAGE_SUB_TYPE_CHAT)
	    || (lm_message_node_get_child(lmsg->node, "body") == NULL
	    && lm_message_node_get_child(lmsg->node, "subject") == NULL))
		return;
	/* request composing events */
	node = lm_message_node_add_child(lmsg->node, "x", NULL);
	lm_message_node_set_attribute(node, XMLNS, XMLNS_EVENT);
	lm_message_node_add_child(node, "composing", NULL);
}
Ejemplo n.º 14
0
static LmHandlerResult cb_disco_info(LmMessageHandler *h, LmConnection *c,
                               LmMessage *m, gpointer user_data)
{
  LmMessageNode *ansqry;
  LmMessageNode *feature;

  ansqry = lm_message_node_get_child(m->node, "query");

  feature = lm_message_node_get_child(ansqry, "feature");
  for (; feature; feature = feature->next) {
    const char *v = lm_message_node_get_attribute(feature, "var");

    if (!g_strcmp0(v, NS_CARBONS_2)) {
      carbons_available();
    }
  }

  return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
Ejemplo n.º 15
0
static void
sig_recv_message(XMPP_SERVER_REC *server, LmMessage *lmsg, const int type,
    const char *id, const char *from, const char *to)
{
	LmMessageNode *node;
	MUC_REC *channel;
	const char *stamp;
	char *nick, *str;
	time_t t;

	node = lm_find_node(lmsg->node, "delay", "xmlns", XMLNS_DELAY);
	if (node == NULL) {
		/* XEP-0091: Delayed Delivery (deprecated) */
		node = lm_find_node(lmsg->node, "x", "xmlns", XMLNS_OLD_DELAY);
		if (node == NULL)
			return;
	}
	stamp = lm_message_node_get_attribute(node, "stamp");
	if ((t = xep82_datetime(stamp)) == (time_t)-1)
		return;
	node = lm_message_node_get_child(lmsg->node, "body");
	if (node == NULL || node->value == NULL || *node->value == '\0')
		return;
	if (type == LM_MESSAGE_SUB_TYPE_GROUPCHAT
	    && (channel = get_muc(server, from)) != NULL
	    && (nick = muc_extract_nick(from)) != NULL) {
		str = xmpp_recode_in(node->value);
		if (g_ascii_strncasecmp(str, "/me ", 4) == 0)
			 signal_emit("message xmpp delay action", 6,
			     server, str+4, nick, channel->name, &t,
			     GINT_TO_POINTER(SEND_TARGET_CHANNEL));
		else
			 signal_emit("message xmpp delay", 6, server,
			     str, nick, channel->name, &t,
			     GINT_TO_POINTER(SEND_TARGET_CHANNEL));
		g_free(str);
		g_free(nick);
	} else if ((type == LM_MESSAGE_SUB_TYPE_NOT_SET
	    || type == LM_MESSAGE_SUB_TYPE_HEADLINE
	    || type == LM_MESSAGE_SUB_TYPE_NORMAL
	    || type == LM_MESSAGE_SUB_TYPE_CHAT)) {
		str = xmpp_recode_in(node->value);
		if (g_ascii_strncasecmp(str, "/me ", 4) == 0)
			signal_emit("message xmpp delay action", 6,
			    server, str+4, from, from, &t,
			    GINT_TO_POINTER(SEND_TARGET_NICK));
		else
			signal_emit("message xmpp delay", 6, server,
			    str+4, from, from, &t,
			    GINT_TO_POINTER(SEND_TARGET_NICK));
		g_free(str);
	} else
		return;
	signal_stop();
}
Ejemplo n.º 16
0
static LmHandlerResult cb_storage_rosternotes(LmMessageHandler *h,
                                              LmConnection *c,
                                              LmMessage *m, gpointer user_data)
{
  LmMessageNode *ansqry;

  if (lm_message_get_sub_type(m) == LM_MESSAGE_SUB_TYPE_ERROR) {
    const char *p = NULL;
    LmMessageNode *error = lm_message_node_get_child(m->node, "error");
    // No server support, or no roster notes?
    if (error && error->children)
      p = error->children->name;
    if (p && !strcmp(p, "item-not-found")) {
      // item-no-found means the server has Private Storage, but it's
      // currently empty.
      if (rosternotes)
        lm_message_node_unref(rosternotes);
      rosternotes = lm_message_node_new("storage", "storage:rosternotes");
      // We return 0 so that the IQ error message be
      // not displayed, as it isn't a real error.
    } else
      scr_LogPrint(LPRINT_LOGNORM, "Server does not support roster notes storage.");
    return LM_HANDLER_RESULT_REMOVE_MESSAGE;
  }

  ansqry = lm_message_node_get_child(m->node, "query");
  ansqry = lm_message_node_get_child(ansqry, "storage");
  if (!ansqry) {
    scr_LogPrint(LPRINT_LOG, "Invalid IQ:private result! "
                 "(storage:rosternotes)");
    return LM_HANDLER_RESULT_REMOVE_MESSAGE;
  }
  // Copy the rosternotes node
  if (rosternotes)
    lm_message_node_unref(rosternotes);
  lm_message_node_deep_ref(ansqry);
  rosternotes = ansqry;
  return 0;
}
Ejemplo n.º 17
0
Archivo: harmony.c Proyecto: KDE/amarok
void harmony_success_reply(LmConnection *connection, LmMessage *message, GError **err) {
    LmMessage *message_out;
    LmMessageNode *harmony_download_node;
    LmMessageNode *message_out_node;
    
    message_out = lm_message_new_with_sub_type(MP3TUNES_HARMONY_CONDUCTOR, LM_MESSAGE_TYPE_IQ, LM_MESSAGE_SUB_TYPE_RESULT);
    lm_message_node_set_attribute(message_out->node, "id", lm_message_node_get_attribute(message->node, "id"));
    message_out_node = lm_message_node_add_child(message_out->node, "success", NULL);

    harmony_download_node = lm_message_node_get_child(message->node, "download");
    if (harmony_download_node) {
        lm_message_node_set_attribute(message_out_node, "messageId", lm_message_node_get_attribute(harmony_download_node, "messageId"));
    }
    lm_message_node_set_attribute(message_out_node, "xmlns", MP3TUNES_HARMONY_XMLNS);

    lm_connection_send(connection, message_out, err);
    lm_message_unref(message_out);
}
Ejemplo n.º 18
0
Archivo: harmony.c Proyecto: KDE/amarok
LmHandlerResult harmony_get_device_pin_callback(LmMessageHandler* handler, LmConnection *connection, LmMessage *message, gpointer void_harmony) {
    char *pin;
    MP3tunesHarmony *harmony = MP3TUNES_HARMONY(void_harmony);
    LmMessageNode *harmony_pin_node;

    (void)handler;
    (void)connection;

    harmony_pin_node = lm_message_node_get_child(message->node, "pin");
    if (harmony_pin_node) {
        pin = g_strdup(lm_message_node_get_value(harmony_pin_node));
        mp3tunes_harmony_set_pin(harmony, pin);
        g_free(pin);
        close_connection(harmony);
        open_connection(harmony);
        return LM_HANDLER_RESULT_REMOVE_MESSAGE;
    }
    return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
}
Ejemplo n.º 19
0
Archivo: harmony.c Proyecto: KDE/amarok
LmHandlerResult harmony_get_session_id_callback(LmMessageHandler* handler, LmConnection *connection, LmMessage *message, gpointer void_harmony) {
    char *session_id;
    MP3tunesHarmony *harmony = MP3TUNES_HARMONY(void_harmony);
    LmMessageNode *harmony_session_node;

    (void)handler;
    (void)connection;

    harmony_session_node = lm_message_node_get_child(message->node, "sessionId");
    if (harmony_session_node) {
        session_id = g_strdup(lm_message_node_get_value(harmony_session_node));
        harmony->mp3tunes_locker->session_id = session_id;
        harmony->sid_state = MP3TUNES_HARMONY_SID_STATE_READY;
        
        harmony_reprocess_queue(harmony);
        return LM_HANDLER_RESULT_REMOVE_MESSAGE;
    }
    return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
}
Ejemplo n.º 20
0
void action_search_result(LmConnection * connection, LmMessage * message, gpointer data)
{
	LmMessageNode *node;
	LmMessageNode *child;
	GSList *list = NULL;

	node = lm_message_node_get_child(message->node, "query");
	if (!strcmp(lm_message_node_get_attribute(node, "xmlns"), "jabber:iq:search"))
	{
		child = lm_message_node_get_child(node, "item");
		if (!child)
		{
			signal_emit("jabber", "gui show message", g_strdup(_("No users have been found!")), "main-gui");
			return;
		}

		while (child)
		{
			gchar *jid = (gchar *) lm_message_node_get_attribute(child, "jid");
			GGaduContact *k;
			LmMessageNode *child_node;

			k = g_new0(GGaduContact, 1);
			k->id = g_strdup(jid ? jid : "?");


			child_node = lm_message_node_get_child(node, "first");
			if (child_node)
				k->first_name = g_strdup((gchar *) lm_message_node_get_value(child_node));

			child_node = lm_message_node_get_child(node, "last");
			if (child_node)
				k->last_name = g_strdup((gchar *) lm_message_node_get_value(child_node));

			child_node = lm_message_node_get_child(node, "nick");
			if (child_node)
				k->nick = g_strdup((gchar *) lm_message_node_get_value(child_node));

			child_node = lm_message_node_get_child(node, "email");
			if (child_node)
				k->email = g_strdup((gchar *) lm_message_node_get_value(child_node));

			k->status = JABBER_STATUS_UNAVAILABLE;
			list = g_slist_append(list, k);
			child = child->next;
		}

		signal_emit("jabber", "gui show search results", list, "main-gui");
	}
}
Ejemplo n.º 21
0
LmHandlerResult handle_iq_disco_items(LmMessageHandler *h,
                                      LmConnection *c,
                                      LmMessage *m, gpointer ud)
{
  LmMessageNode *query;
  const char *node;
  query = lm_message_node_get_child(m->node, "query");
  node = lm_message_node_get_attribute(query, "node");
  if (node) {
    if (!strcmp(node, NS_COMMANDS)) {
      return handle_iq_commands_list(NULL, c, m, ud);
    } else {
      send_iq_error(c, m, XMPP_ERROR_NOT_IMPLEMENTED);
    }
  } else {
    // not sure about this one
    send_iq_error(c, m, XMPP_ERROR_NOT_IMPLEMENTED);
  }
  return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
Ejemplo n.º 22
0
LmHandlerResult
xmpp_mesg_handler(LmMessageHandler *h, LmConnection *c,
		LmMessage *m, gpointer udata)
{
	const char *from, *to, *body;
	LmMessageNode *node;
	from = lm_message_node_get_attribute(m->node, "from");
	to = lm_message_node_get_attribute(m->node, "to");
	node = lm_message_node_get_child(m->node, "body");
	if(node && (body = lm_message_node_get_value(node))) {
		ui_tab_print_message(from, body);
		lua_msg_callback(from, to, body);
	}
	/* we're actually ignoring <subject> and <thread> elements,
	 * as I've never actually seen them being used. If you do, and you care,
	 * feel obliged to mail me and yell at me */
	return LM_HANDLER_RESULT_REMOVE_MESSAGE;
	UNUSED(h);
	UNUSED(c);
	UNUSED(udata);
} /* xmpp_mesg_handler */
Ejemplo n.º 23
0
LmHandlerResult
LM::HeapRoster::handle_initial_roster_reply (LmConnection* /*connection*/,
					     LmMessage* message)
{
  LmHandlerResult result = LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
  if (lm_message_get_sub_type (message) == LM_MESSAGE_SUB_TYPE_RESULT) {

    LmMessageNode* node = lm_message_node_get_child (lm_message_get_node (message), "query");
    if (node != NULL) {

      const gchar* xmlns = lm_message_node_get_attribute (node, "xmlns");
      if (xmlns != NULL && g_strcmp0 (xmlns, "jabber:iq:roster") == 0) {

	parse_roster (node);
	result = LM_HANDLER_RESULT_REMOVE_MESSAGE;
      }
    }
  }

  return result;
}
Ejemplo n.º 24
0
static LmHandlerResult handle_iq_commands_list(LmMessageHandler *h,
                                               LmConnection *c,
                                               LmMessage *m, gpointer ud)
{
  LmMessage *iq;
  LmMessageNode *query;
  const char *requester_jid;
  const struct adhoc_command *command;
  const char *node;
  gboolean from_self;

  iq = lm_message_new_iq_from_query(m, LM_MESSAGE_SUB_TYPE_RESULT);
  query = lm_message_node_add_child(iq->node, "query", NULL);
  lm_message_node_set_attribute(query, "xmlns", NS_COMMANDS);
  node = lm_message_node_get_attribute
          (lm_message_node_get_child(m->node, "query"),
           "node");
  if (node)
    lm_message_node_set_attribute(query, "node", node);

  requester_jid = lm_message_get_from(m);
  from_self = jid_equal(lm_connection_get_jid(c), requester_jid);

  for (command = adhoc_command_list ; command->name ; command++) {
    if (!command->only_for_self || from_self) {
      lm_message_node_set_attributes
              (lm_message_node_add_child(query, "item", NULL),
               "node", command->name,
               "name", command->description,
               "jid", lm_connection_get_jid(c),
               NULL);
    }
  }

  lm_connection_send(c, iq, NULL);
  lm_message_unref(iq);
  return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
Ejemplo n.º 25
0
static LmHandlerResult
ft_msg_msg_handler (LmMessageHandler *handler, LmConnection *conn,
                    LmMessage *msg, gpointer user_data)
{
        LmMessageNode *root, *body, *x;
        const char *from, *msg_str, *type;
        char *ts = NULL;
        char *new_from = NULL;

        root = lm_message_get_node (msg);
        if (!root)
                goto out;

        body = lm_message_node_get_child (root, "body");
        if (!body)
                goto out;

        from = lm_message_node_get_attribute (msg->node, "from");
        if (!from)
                goto out;

        msg_str = lm_message_node_get_value (body);

        type = lm_message_node_get_attribute (msg->node, "type");
        if (type && g_ascii_strcasecmp (type, "chat") != 0) {
                PRINTF (_("[message of type '%s']"), type);
                goto out;
        }

        // Offline messages
        for (x = root->children; x != NULL; x = x->next) {
                if (!g_ascii_strcasecmp (x->name, "x")) {
                        const char *xmlns = lm_message_node_get_attribute (x,
                                                                           "xmlns");
                        if (xmlns &&
                            !g_ascii_strcasecmp (xmlns, "jabber:x:delay")) {
                                ts = parse_timestamp ((char *)lm_message_node_get_attribute (x, "stamp"));
                        }
                }
        }

        set_hook_return (0);
        {
                FtRosterItem *item = NULL;
                char *nickname;

                new_from = g_strdup (from);
                item = ft_roster_lookup (new_from);

                if (!item)
                        nickname = NULL;
                else
                        nickname = item->nickname;

                scm_run_hook (ex_message_receive_hook,
                              scm_list_n (ts ? scm_from_locale_string (ts) :
                                          scm_from_locale_string (""),
                                          scm_from_locale_string (new_from),
                                          nickname ?
                                          scm_from_locale_string (nickname) :
                                          scm_from_locale_string (""),
                                          scm_from_locale_string (msg_str),
                                          SCM_UNDEFINED));
        }

        if (get_hook_return () == 1)
                goto out;

        PRINTF ("%s: %s", new_from, msg_str);
out:
        if (ts)
                g_free (ts);

        if (new_from)
                g_free (new_from);

        return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
Ejemplo n.º 26
0
static LmHandlerResult cb_time(LmMessageHandler *h, LmConnection *c,
                               LmMessage *m, gpointer user_data)
{
  LmMessageNode *ansqry;
  const char *p, *bjid;
  char *buf, *tmp;

  // Check IQ result sender
  bjid = lm_message_get_from(m);
  if (!bjid)
    bjid = lm_connection_get_jid(lconnection); // No from means our JID...
  if (!bjid) {
    scr_LogPrint(LPRINT_LOGNORM, "Invalid IQ:time result (no sender name).");
    return LM_HANDLER_RESULT_REMOVE_MESSAGE;
  }

  // Check for error message
  if (lm_message_get_sub_type(m) == LM_MESSAGE_SUB_TYPE_ERROR) {
    scr_LogPrint(LPRINT_LOGNORM, "Received error IQ message (%s)", bjid);
    display_server_error(lm_message_node_get_child(m->node, "error"), NULL);
    return LM_HANDLER_RESULT_REMOVE_MESSAGE;
  }

  // Check message contents
  ansqry = lm_message_node_get_child(m->node, "query");
  if (!ansqry) {
    scr_LogPrint(LPRINT_LOGNORM, "Invalid IQ:time result from <%s>!", bjid);
    return LM_HANDLER_RESULT_REMOVE_MESSAGE;
  }

  buf = g_strdup_printf("Received IQ:time result from <%s>", bjid);
  scr_LogPrint(LPRINT_LOGNORM, "%s", buf);

  // bjid should now really be the "bare JID", let's strip the resource
  tmp = strchr(bjid, JID_RESOURCE_SEPARATOR);
  if (tmp) *tmp = '\0';

  scr_WriteIncomingMessage(bjid, buf, 0, HBB_PREFIX_INFO, 0);
  g_free(buf);

  // Get result data...
  p = lm_message_node_get_child_value(ansqry, "utc");
  if (p && *p) {
    buf = g_strdup_printf("UTC:  %s", p);
    scr_WriteIncomingMessage(bjid, buf,
                             0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0);
    g_free(buf);
  }
  p = lm_message_node_get_child_value(ansqry, "tz");
  if (p && *p) {
    buf = g_strdup_printf("TZ:   %s", p);
    scr_WriteIncomingMessage(bjid, buf,
                             0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0);
    g_free(buf);
  }
  p = lm_message_node_get_child_value(ansqry, "display");
  if (p && *p) {
    buf = g_strdup_printf("Time: %s", p);
    scr_WriteIncomingMessage(bjid, buf,
                             0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0);
    g_free(buf);
  }
  return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
Ejemplo n.º 27
0
/**
 * @brief Check if a node description with xmlns of JFT is correct 
 *
 * @param cn the jinglecontent a node description
 * @param err contain an error of the domain JINGLE_CHECK_ERROR
 * @return a gconstpointer, which is a new allocated JingleFT
 */
static gconstpointer newfrommessage(JingleContent *cn, GError **err)
{
  JingleFT *ft = NULL;
  LmMessageNode *node;
  gint64 tmpsize;
  const gchar *datestr, *sizestr;

  node = lm_message_node_get_child(cn->description, "offer");
 
  if (!node) {
    g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_MISSING,
                "the offer element is missing");
    return NULL;
  }

  node = lm_message_node_get_child(node, "file");
  if (!node) {
    g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_MISSING,
                "the file element is missing");
    return NULL;
  }

  if (g_strcmp0(lm_message_node_get_attribute(node, "xmlns"), NS_SI_FT)) {
    g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_MISSING,
                "the file transfer offer has an invalid/unsupported namespace");
    return NULL;
  }

  ft = g_new0(JingleFT, 1);
  datestr  = lm_message_node_get_attribute(node, "date");
  ft->hash = (gchar *) lm_message_node_get_attribute(node, "hash");
  ft->name = (gchar *) lm_message_node_get_attribute(node, "name");
  sizestr  = lm_message_node_get_attribute(node, "size");
  ft->transmit = 0;
  ft->dir = JINGLE_FT_INCOMING;
  
  if (!ft->name || !sizestr) {
    g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_MISSING,
                "an attribute of the file element is missing");
    g_free(ft);
    return NULL;
  }

  ft->date = from_iso8601(datestr, 1);
  tmpsize = g_ascii_strtoll(sizestr, NULL, 10);

  // the size attribute is a xs:integer an therefore can be negative.
  if (tmpsize < 0) {
    g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_BADVALUE,
                "the offered file has a negative size");
    g_free(ft);
    return NULL;
  }
  ft->size = tmpsize;

  ft->name = g_path_get_basename(ft->name);
  
  if (settings_opt_get("jingle_ft_dir") != NULL)
    ft->name = g_build_filename(settings_opt_get("jingle_ft_dir"), ft->name, NULL);
  else
    ft->name = g_build_filename("/tmp", ft->name, NULL);

  if (!g_strcmp0(ft->name, ".")) {
    g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_BADVALUE,
                "the offered file has an invalid filename");
    g_free(ft->name);
    g_free(ft);
    return NULL;
  }

  // check if the md5 hash is valid ([a-fA-F0-9){32})
  if (ft->hash != NULL && (strlen(ft->hash) != 32 || !_is_md5_hash(ft->hash))) {
    g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_BADVALUE,
                "the offered file has an invalid hash");
    g_free(ft->name);
    g_free(ft);
    return NULL;
  }
  ft->hash = g_strndup(ft->hash, 32);

  {
    JingleFTInfo *jfti = g_new0(JingleFTInfo, 1);
    jfti->index = _next_index();
    jfti->jft = ft;
    info_list = g_slist_append(info_list, jfti);
  }

  return (gconstpointer) ft;
}
Ejemplo n.º 28
0
static LmHandlerResult cb_last(LmMessageHandler *h, LmConnection *c,
                               LmMessage *m, gpointer user_data)
{
  LmMessageNode *ansqry;
  const char *p, *bjid;
  char *buf, *tmp;

  // Check IQ result sender
  bjid = lm_message_get_from(m);
  if (!bjid)
    bjid = lm_connection_get_jid(lconnection); // No from means our JID...
  if (!bjid) {
    scr_LogPrint(LPRINT_LOGNORM, "Invalid IQ:last result (no sender name).");
    return LM_HANDLER_RESULT_REMOVE_MESSAGE;
  }

  // Check for error message
  if (lm_message_get_sub_type(m) == LM_MESSAGE_SUB_TYPE_ERROR) {
    scr_LogPrint(LPRINT_LOGNORM, "Received error IQ message (%s)", bjid);
    display_server_error(lm_message_node_get_child(m->node, "error"), NULL);
    return LM_HANDLER_RESULT_REMOVE_MESSAGE;
  }

  // Check message contents
  ansqry = lm_message_node_get_child(m->node, "query");
  if (!ansqry) {
    scr_LogPrint(LPRINT_LOGNORM, "Invalid IQ:version result from <%s>!", bjid);
    return LM_HANDLER_RESULT_REMOVE_MESSAGE;
  }

  buf = g_strdup_printf("Received IQ:last result from <%s>", bjid);
  scr_LogPrint(LPRINT_LOGNORM, "%s", buf);

  // bjid should now really be the "bare JID", let's strip the resource
  tmp = strchr(bjid, JID_RESOURCE_SEPARATOR);
  if (tmp) *tmp = '\0';

  scr_WriteIncomingMessage(bjid, buf, 0, HBB_PREFIX_INFO, 0);
  g_free(buf);

  // Get result data...
  p = lm_message_node_get_attribute(ansqry, "seconds");
  if (p) {
    long int s;
    GString *sbuf;
    sbuf = g_string_new("Idle time: ");
    s = atol(p);
    // Days
    if (s > 86400L) {
      g_string_append_printf(sbuf, "%ldd ", s/86400L);
      s %= 86400L;
    }
    // hh:mm:ss
    g_string_append_printf(sbuf, "%02ld:", s/3600L);
    s %= 3600L;
    g_string_append_printf(sbuf, "%02ld:%02ld", s/60L, s%60L);
    scr_WriteIncomingMessage(bjid, sbuf->str,
                             0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0);
    g_string_free(sbuf, TRUE);
  } else {
    scr_WriteIncomingMessage(bjid, "No idle time reported.",
                             0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0);
  }
  p = lm_message_node_get_value(ansqry);
  if (p) {
    buf = g_strdup_printf("Status message: %s", p);
    scr_WriteIncomingMessage(bjid, buf, 0, HBB_PREFIX_INFO, 0);
    g_free(buf);
  }
  return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
Ejemplo n.º 29
0
GSList* soy_net_xmpp_agent_get_remote_candidates (soynetXMPPAgent* self, LmMessageNode* transport, guint stream_id) {
	GSList* result = NULL;
	GSList* rcands = NULL;
	LmMessageNode* candidate = NULL;
	LmMessageNode* _tmp0_ = NULL;
	LmMessageNode* _tmp1_ = NULL;
	LmMessageNode* _tmp2_ = NULL;
	LmMessageNode* _tmp3_ = NULL;
	GSList* _tmp45_ = NULL;
	GSList* _tmp46_ = NULL;
#line 119 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	g_return_val_if_fail (self != NULL, NULL);
#line 119 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	g_return_val_if_fail (transport != NULL, NULL);
#line 120 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	rcands = NULL;
#line 121 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	_tmp0_ = transport;
#line 121 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	_tmp1_ = lm_message_node_get_child (_tmp0_, "candidate");
#line 121 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	_tmp2_ = _lm_message_node_ref0 (_tmp1_);
#line 121 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	candidate = _tmp2_;
#line 124 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	_tmp3_ = candidate;
#line 124 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	if (_tmp3_ == NULL) {
#line 125 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		result = rcands;
#line 125 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_lm_message_node_unref0 (candidate);
#line 125 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		return result;
#line 584 "XMPPAgent.c"
	}
#line 127 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	while (TRUE) {
#line 588 "XMPPAgent.c"
		LmMessageNode* _tmp4_ = NULL;
		NiceCandidate* rcand = NULL;
		GeeHashMap* _tmp5_ = NULL;
		LmMessageNode* _tmp6_ = NULL;
		const gchar* _tmp7_ = NULL;
		gpointer _tmp8_ = NULL;
		NiceCandidate* _tmp9_ = NULL;
		LmMessageNode* _tmp10_ = NULL;
		const gchar* _tmp11_ = NULL;
		LmMessageNode* _tmp12_ = NULL;
		const gchar* _tmp13_ = NULL;
		LmMessageNode* _tmp14_ = NULL;
		const gchar* _tmp15_ = NULL;
		LmMessageNode* _tmp16_ = NULL;
		const gchar* _tmp17_ = NULL;
		NiceCandidate* _tmp18_ = NULL;
		LmMessageNode* _tmp19_ = NULL;
		const gchar* _tmp20_ = NULL;
		NiceCandidate* _tmp21_ = NULL;
		LmMessageNode* _tmp22_ = NULL;
		const gchar* _tmp23_ = NULL;
		gint _tmp24_ = 0;
		NiceCandidate* _tmp25_ = NULL;
		NiceCandidate* _tmp26_ = NULL;
		LmMessageNode* _tmp27_ = NULL;
		const gchar* _tmp28_ = NULL;
		gint _tmp29_ = 0;
		NiceCandidate* _tmp30_ = NULL;
		LmMessageNode* _tmp31_ = NULL;
		const gchar* _tmp32_ = NULL;
		gint _tmp33_ = 0;
		NiceCandidate* _tmp34_ = NULL;
		guint _tmp35_ = 0U;
		NiceCandidate* _tmp36_ = NULL;
		gboolean _tmp37_ = FALSE;
		gchar* _tmp38_ = NULL;
		gchar* _tmp39_ = NULL;
		NiceCandidate* _tmp40_ = NULL;
		NiceCandidate* _tmp41_ = NULL;
		LmMessageNode* _tmp42_ = NULL;
		LmMessageNode* _tmp43_ = NULL;
		LmMessageNode* _tmp44_ = NULL;
#line 127 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp4_ = candidate;
#line 127 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		if (!(_tmp4_ != NULL)) {
#line 127 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
			break;
#line 637 "XMPPAgent.c"
		}
#line 129 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp5_ = soy_net_xmpp_agent_candidate_type_dict;
#line 129 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp6_ = candidate;
#line 129 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp7_ = lm_message_node_get_attribute (_tmp6_, "type");
#line 129 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp8_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp5_, _tmp7_);
#line 129 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp9_ = nice_candidate_new ((guint) ((gint) ((gintptr) _tmp8_)));
#line 129 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		rcand = _tmp9_;
#line 131 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		g_print ("Remote Candidate\n");
#line 132 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp10_ = candidate;
#line 132 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp11_ = lm_message_node_get_attribute (_tmp10_, "ip");
#line 132 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		g_print ("%s\n", _tmp11_);
#line 133 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp12_ = candidate;
#line 133 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp13_ = lm_message_node_get_attribute (_tmp12_, "port");
#line 133 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		g_print ("port: %s\n", _tmp13_);
#line 134 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp14_ = candidate;
#line 134 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp15_ = lm_message_node_get_attribute (_tmp14_, "priority");
#line 134 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		g_print ("priority:  %s\n", _tmp15_);
#line 135 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp16_ = candidate;
#line 135 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp17_ = lm_message_node_get_attribute (_tmp16_, "component");
#line 135 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		g_print ("component %s\n", _tmp17_);
#line 138 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp18_ = rcand;
#line 138 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp19_ = candidate;
#line 138 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp20_ = lm_message_node_get_attribute (_tmp19_, "ip");
#line 138 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		nice_address_set_from_string (&_tmp18_->addr, _tmp20_);
#line 139 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp21_ = rcand;
#line 139 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp22_ = candidate;
#line 139 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp23_ = lm_message_node_get_attribute (_tmp22_, "port");
#line 139 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp24_ = atoi (_tmp23_);
#line 139 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		nice_address_set_port (&_tmp21_->addr, (guint) _tmp24_);
#line 140 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp25_ = rcand;
#line 140 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp25_->transport = NICE_CANDIDATE_TRANSPORT_UDP;
#line 141 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp26_ = rcand;
#line 141 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp27_ = candidate;
#line 141 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp28_ = lm_message_node_get_attribute (_tmp27_, "priority");
#line 141 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp29_ = atoi (_tmp28_);
#line 141 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp26_->priority = (guint32) _tmp29_;
#line 142 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp30_ = rcand;
#line 142 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp31_ = candidate;
#line 142 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp32_ = lm_message_node_get_attribute (_tmp31_, "component");
#line 142 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp33_ = atoi (_tmp32_);
#line 142 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp30_->component_id = (guint) _tmp33_;
#line 143 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp34_ = rcand;
#line 143 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp35_ = stream_id;
#line 143 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp34_->stream_id = _tmp35_;
#line 145 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp36_ = rcand;
#line 145 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp37_ = nice_address_is_valid (&_tmp36_->addr);
#line 145 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp38_ = bool_to_string (_tmp37_);
#line 145 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp39_ = _tmp38_;
#line 145 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		g_print ("%s\n", _tmp39_);
#line 145 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_g_free0 (_tmp39_);
#line 146 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp40_ = rcand;
#line 146 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp41_ = nice_candidate_copy (_tmp40_);
#line 146 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		rcands = g_slist_append (rcands, _tmp41_);
#line 147 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp42_ = candidate;
#line 147 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp43_ = _tmp42_->next;
#line 147 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp44_ = _lm_message_node_ref0 (_tmp43_);
#line 147 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_lm_message_node_unref0 (candidate);
#line 147 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		candidate = _tmp44_;
#line 127 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_nice_candidate_free0 (rcand);
#line 755 "XMPPAgent.c"
	}
#line 148 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	_tmp45_ = rcands;
#line 148 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	_tmp46_ = g_slist_copy (_tmp45_);
#line 148 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	result = _tmp46_;
#line 148 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	_lm_message_node_unref0 (candidate);
#line 148 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	_g_slist_free0 (rcands);
#line 148 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	return result;
#line 769 "XMPPAgent.c"
}
Ejemplo n.º 30
0
static void handle_vcard_node(const char *barejid, LmMessageNode *vcardnode)
{
  LmMessageNode *x;
  const char *p;

  for (x = vcardnode->children ; x; x = x->next) {
    const char *data;
    enum vcard_attr vcard_attrib = 0;

    p = x->name;
    if (!p)
      continue;

    data = lm_message_node_get_value(x);

    if (!g_strcmp0(p, "FN"))
      display_vcard_item(barejid, "Name", vcard_attrib, data);
    else if (!g_strcmp0(p, "NICKNAME"))
      display_vcard_item(barejid, "Nickname", vcard_attrib, data);
    else if (!g_strcmp0(p, "URL"))
      display_vcard_item(barejid, "URL", vcard_attrib, data);
    else if (!g_strcmp0(p, "BDAY"))
      display_vcard_item(barejid, "Birthday", vcard_attrib, data);
    else if (!g_strcmp0(p, "TZ"))
      display_vcard_item(barejid, "Timezone", vcard_attrib, data);
    else if (!g_strcmp0(p, "TITLE"))
      display_vcard_item(barejid, "Title", vcard_attrib, data);
    else if (!g_strcmp0(p, "ROLE"))
      display_vcard_item(barejid, "Role", vcard_attrib, data);
    else if (!g_strcmp0(p, "DESC"))
      display_vcard_item(barejid, "Comment", vcard_attrib, data);
    else if (!g_strcmp0(p, "N")) {
      data = lm_message_node_get_child_value(x, "FAMILY");
      display_vcard_item(barejid, "Family Name", vcard_attrib, data);
      data = lm_message_node_get_child_value(x, "GIVEN");
      display_vcard_item(barejid, "Given Name", vcard_attrib, data);
      data = lm_message_node_get_child_value(x, "MIDDLE");
      display_vcard_item(barejid, "Middle Name", vcard_attrib, data);
    } else if (!g_strcmp0(p, "ORG")) {
      data = lm_message_node_get_child_value(x, "ORGNAME");
      display_vcard_item(barejid, "Organisation name", vcard_attrib, data);
      data = lm_message_node_get_child_value(x, "ORGUNIT");
      display_vcard_item(barejid, "Organisation unit", vcard_attrib, data);
    } else {
      // The HOME, WORK and PREF attributes are common to the remaining fields
      // (ADR, TEL & EMAIL)
      if (lm_message_node_get_child(x, "HOME"))
        vcard_attrib |= vcard_home;
      if (lm_message_node_get_child(x, "WORK"))
        vcard_attrib |= vcard_work;
      if (lm_message_node_get_child(x, "PREF"))
        vcard_attrib |= vcard_pref;
      if (!g_strcmp0(p, "ADR")) {          // Address
        if (lm_message_node_get_child(x, "POSTAL"))
          vcard_attrib |= vcard_postal;
        data = lm_message_node_get_child_value(x, "EXTADD");
        display_vcard_item(barejid, "Addr (ext)", vcard_attrib, data);
        data = lm_message_node_get_child_value(x, "STREET");
        display_vcard_item(barejid, "Street", vcard_attrib, data);
        data = lm_message_node_get_child_value(x, "LOCALITY");
        display_vcard_item(barejid, "Locality", vcard_attrib, data);
        data = lm_message_node_get_child_value(x, "REGION");
        display_vcard_item(barejid, "Region", vcard_attrib, data);
        data = lm_message_node_get_child_value(x, "PCODE");
        display_vcard_item(barejid, "Postal code", vcard_attrib, data);
        data = lm_message_node_get_child_value(x, "CTRY");
        display_vcard_item(barejid, "Country", vcard_attrib, data);
      } else if (!g_strcmp0(p, "TEL")) {   // Telephone
        data = lm_message_node_get_child_value(x, "NUMBER");
        if (data) {
          if (lm_message_node_get_child(x, "VOICE"))
            vcard_attrib |= vcard_voice;
          if (lm_message_node_get_child(x, "FAX"))
            vcard_attrib |= vcard_fax;
          if (lm_message_node_get_child(x, "CELL"))
            vcard_attrib |= vcard_cell;
          display_vcard_item(barejid, "Phone", vcard_attrib, data);
        }
      } else if (!g_strcmp0(p, "EMAIL")) { // Email
        if (lm_message_node_get_child(x, "INTERNET"))
          vcard_attrib |= vcard_inet;
        data = lm_message_node_get_child_value(x, "USERID");
        display_vcard_item(barejid, "Email", vcard_attrib, data);
      }
    }
  }
}