Пример #1
0
gchar *
__lyrictracker_get_id (xmlDocPtr results_doc, gchar *artist, gchar *songtitle, int exact)
{
  gchar *hid = NULL;
  xmlNodePtr results, node;

  results = xmlDocGetRootElement(results_doc);
  if (!results)
    return NULL;

  /* If no results returned, don't even search in them */
  if (strcmp((gchar *)xmlGetProp(results, (xmlChar *)"count"), "0") == 0)
    return NULL;

  node = get_node_by_name (results->xmlChildrenNode, (xmlChar *)"result");
  while (node)
    {
	// TODO: figure out how to match exact when lyrictracker comes back up again
      if (/*(strcasecmp((gchar *)xmlGetProp(node, (xmlChar *)"artist"),
                      artist) == 0) &&*/
          (strcasecmp((gchar *)xmlGetProp(node, (xmlChar *)"title"),
                      songtitle) == 0))
        {
          hid = (gchar *)xmlGetProp(node, (xmlChar *)"id");
          if (hid)
            return hid;
        }

      node = get_node_by_name (node->next, (xmlChar *)"result");
    }

  return NULL;
}
Пример #2
0
void Graph::press_and_hold_node(QString node_name)
{
    QQmlComponent component(engine, QUrl("qrc:/qml_files/node_dialog.qml"));
    QObject *object = component.create();
    object->setParent(panel);
    QQuickItem *item = qobject_cast<QQuickItem*>(object);
    item->setParentItem(qobject_cast<QQuickItem*>(panel));
    QObject::connect(object,SIGNAL(destroy_dialog(void)),this,SLOT(destroy_dialog(void)));
    if (started && !paused)
        this->pause_animation();
    Node* node = get_node_by_name(node_name);
}
Пример #3
0
/**
 * acquire_phb
 *
 */
static int acquire_phb(char *drc_name, struct dr_node **phb)
{
    struct dr_connector drc;
    struct of_node *of_nodes;
    char path[DR_PATH_MAX];
    int rc;

    rc = get_drc_by_name(drc_name, &drc, path, OFDT_BASE);
    if (rc) {
        say(ERROR, "Could not find drc index for %s, unable to add the"
            "PHB.\n", drc_name);
        return rc;
    }

    rc = acquire_drc(drc.index);
    if (rc)
        return rc;

    of_nodes = configure_connector(drc.index);
    if (of_nodes == NULL) {
        release_drc(drc.index, PHB_DEV);
        return -1;
    }

    rc = add_device_tree_nodes(path, of_nodes);
    free_of_node(of_nodes);
    if (rc) {
        say(ERROR, "add_device_tree_nodes failed at %s\n", path);
        release_drc(drc.index, PHB_DEV);
        return -1;
    }

    /* Now that the node has been added to the device-tree, retrieve it.
     * This also acts as a sanity check that everything up to this
     * point has succeeded.
     */
    *phb = get_node_by_name(drc_name, PHB_NODES);
    if (*phb == NULL) {
        say(ERROR, "Could not get find \"%s\"\n", drc_name);
        /* or should we call release_drc? but need device type */
        release_drc(drc.index, PHB_DEV);
        return -1;
    }

    return 0;
}
Пример #4
0
Node* Graph::add_node(QString name, int x, int y, int id)
{
    Node *node = get_node_by_name(name);
    if (node != NULL)
        return NULL;
    node = get_node_by_id(id);
    if (node != NULL)
        return NULL;
    node = new Node();
    node->setup_node(name, x, y, panel, engine);
    node->set_id(id);
    QObject::connect(node->get_q_object(),SIGNAL(position_changed_sig(qreal,qreal,QString)),this,SLOT(update_node_position(qreal,qreal,QString)));
    QObject::connect(node->get_q_object(), SIGNAL(press_and_hold_node(QString)), this, SLOT(press_and_hold_node(QString)));
    QObject::connect(node->get_q_object(), SIGNAL(show_routing_table(QString)), this, SLOT(show_routing_table(QString)));
    node_pool.push_back(node);
    update_algorithm(0);
    return node;
}
Пример #5
0
/**
 * query_phb
 *
 * @param op
 * @returns 0 if a remove would succeed, or if it's alreday been removed
 * @returns 1 if a remove would not succeed
 */
static int
query_phb(struct options *opts)
{
    struct dr_node *phb;
    struct dr_node *child;

    phb = get_node_by_name(opts->usr_drc_name, PHB_NODES);
    if (phb == NULL)
        return RC_NONEXISTENT;

    /* If this PHB still owns children that are not hotplug, fail. */
    for (child = phb->children; child; child = child->next) {
        if ((child->is_owned) && (child->dev_type != PCI_HP_DEV)) {
            free_node(phb);
            return RC_IN_USE;
        }
    }

    free_node(phb);
    return RC_LINUX_SLOT;
}
Пример #6
0
void Graph::update_node_position(qreal x, qreal y, QString string)
{
    Node *node = get_node_by_name(string);
    QObject *obj = node->get_q_object();
    std::vector<Link*> lnks = get_link_from_node(node);
    for (std::vector<Link*>::iterator iter = lnks.begin(); iter != lnks.end(); iter++)
    {
        Link *temp = *iter;
        QQuickItem *tmp = qobject_cast<QQuickItem*>(temp->get_q_object());
        QQuickItem *node1 = qobject_cast<QQuickItem*>(obj);
        int y_off = node1->height();
        int x_off = node1->width();
        if (temp->get_source()->get_id() == node->get_id()) {
            tmp->setProperty("x1", x + x_off/2);
            tmp->setProperty("y1", y + y_off/2);
        } else {
            tmp->setProperty("x2", x + x_off/2);
            tmp->setProperty("y2", y + y_off/2);
        }
    }
    node->set_x(x);
    node->set_y(y);
}
Пример #7
0
void Graph::show_routing_table(QString node_name)
{
    Node *node = get_node_by_name(node_name);
    node->show_routing_table(engine, qobject_cast<QQuickItem*>(panel));

}
Пример #8
0
/**
 * add_phb
 *
 * @param op
 * @returns 0 on success, !0 otherwise
 */
static int
add_phb(struct options *opts)
{
    struct dr_node *phb = NULL;
    int rc, n_children = 0;

    phb = get_node_by_name(opts->usr_drc_name, PHB_NODES);
    if (phb) {
        say(ERROR, "PHB is already owned by this partition\n");
        rc = RC_ALREADY_OWN;
        goto phb_add_error;
    }

    rc = acquire_phb(opts->usr_drc_name, &phb);
    if (rc)
        return rc;

    rc = acquire_hp_children(phb->ofdt_path, &n_children);
    if (rc) {
        if (release_phb(phb)) {
            say(ERROR, "Unknown failure. Data may be out of sync "
                "and\nthe system may require a reboot.\n");
        }
        goto phb_add_error;
    }

    rc = dlpar_add_slot(phb->drc_name);
    if (rc) {
        if (n_children) {
            if (release_hp_children(phb->drc_name)) {
                say(ERROR, "Unknown failure. Data may be out "
                    "of sync and\nthe system may require "
                    "a reboot.\n");
            }
        }

        if (release_phb(phb)) {
            say(ERROR, "Unknown failure. Data may be out of sync "
                "and\nthe system may require a reboot.\n");
        }
        goto phb_add_error;
    }

    if (n_children) {
        rc = enable_hp_children(phb->drc_name);
        if (rc) {
            say(ERROR, "Adapter configuration failed.\n");
            if (release_hp_children(phb->drc_name)) {
                say(ERROR, "Unknown failure. Data may be out "
                    "of sync and \nthe system may require "
                    "a reboot.\n");
            }

            if (dlpar_remove_slot(phb->drc_name)) {
                say(DEBUG, "remove %s from hotplug subsystem "
                    "failed\n", phb->drc_name);
                say(ERROR, "Unknown failure. Data may be out "
                    "of sync and \nthe system may require "
                    "a reboot.\n");
            }

            if (release_phb(phb)) {
                say(ERROR, "Unknown failure. Data may be out "
                    "of sync and \nthe system may require "
                    "a reboot.\n");
            }
        }
    }

phb_add_error:
    if (phb)
        free_node(phb);

    return rc;
}
Пример #9
0
/**
 * remove_phb
 *
 * @param op
 * @returns 0 on success, !0 otherwise
 */
static int
remove_phb(struct options *opts)
{
    struct dr_node *phb;
    struct dr_node *child;
    struct dr_node *hp_list;
    int rc = 0;

    phb = get_node_by_name(opts->usr_drc_name, PHB_NODES);
    if (phb == NULL) {
        say(ERROR, "Could not find PHB %s\n", opts->usr_drc_name);
        return RC_NONEXISTENT;
    }

    /* If this PHB still owns children that are not hotplug, fail. */
    for (child = phb->children; child; child = child->next) {
        if ((child->is_owned) && (child->dev_type != PCI_HP_DEV)) {
            rc = -1;
            goto phb_remove_error;
        }
    }

    /* Now, disable any hotplug children */
    hp_list = get_hp_nodes();

    for (child = phb->children; child; child = child->next) {
        struct dr_node *slot;

        if (child->dev_type == PCI_HP_DEV) {
            rc = disable_hp_children(child->drc_name);
            if (rc)
                say(ERROR,
                    "failed to disable hotplug children\n");

            /* find dr_node corresponding to child slot's drc_name */
            for (slot = hp_list; slot; slot = slot->next)
                if (!strcmp(child->drc_name, slot->drc_name))
                    break;

            /* release any hp children from the slot */
            rc = release_hp_children_from_node(slot);
            if (rc && rc != -EINVAL) {
                say(ERROR,
                    "failed to release hotplug children\n");
                goto phb_remove_error;
            }
        }
    }

    /* If there are any directories under the phb left at this point,
     * they are OS hotplug devies.  Note: this is different from DR
     * hotplug devices.  This really occurs on systems that do not
     * support DR hotplug devices.  The device tree does not get populated
     * with drc information for these devices and such they do not appear
     * on the list generated by the calls to get_node_*
     *
     * For these devices we simply hotplug remove them from the OS.
     */
    rc = disable_os_hp_children(phb);
    if (rc)
        goto phb_remove_error;

    rc = dlpar_remove_slot(phb->drc_name);
    if (rc) {
        say(ERROR, "kernel remove failed for %s, rc = %d\n",
            phb->drc_name, rc);
        goto phb_remove_error;
    }

    rc = release_phb(phb);

phb_remove_error:
    if (phb)
        free_node(phb);

    return rc;
}