- if (root==NULL) return;
-
- if ( strcmp(root->name().c_str(), "freesound") == 0) {
-
- XMLNode *node = 0;
- XMLNodeList children = root->children();
- XMLNodeConstIterator niter;
- for (niter = children.begin(); niter != children.end() && !canceling; ++niter) {
- node = *niter;
- if( strcmp( node->name().c_str(), "sample") == 0 ){
- XMLProperty *prop=node->property ("id");
- string filename = theMootcher.getFile( prop->value().c_str() );
- if ( filename != "" ) {
- TreeModel::iterator new_row = freesound_list->append();
- TreeModel::Row row = *new_row;
- string path = Glib::filename_from_uri (string ("file:") + filename);
- row[freesound_list_columns.pathname] = path;
- }
+ if (!root) {
+ cerr << "no root XML node!" << endl;
+ break;
+ }
+
+ if ( strcmp(root->name().c_str(), "response") != 0) {
+ cerr << "root node name == " << root->name() << ", != \"response\"!" << endl;
+ break;
+ }
+
+ XMLNode *sounds_root = root->child("sounds");
+
+ if (!sounds_root) {
+ cerr << "no child node \"sounds\" found!" << endl;
+ break;
+ }
+
+ XMLNodeList sounds = sounds_root->children();
+ XMLNodeConstIterator niter;
+ XMLNode *node;
+ for (niter = sounds.begin(); niter != sounds.end(); ++niter) {
+ node = *niter;
+ if( strcmp( node->name().c_str(), "resource") != 0 ){
+ cerr << "node->name()=" << node->name() << ",!= \"resource\"!" << endl;
+ freesound_search_cancel = true;
+ break;
+ }
+
+ // node->dump(cerr, "node:");
+
+ XMLNode *id_node = node->child ("id");
+ XMLNode *uri_node = node->child ("serve");
+ XMLNode *ofn_node = node->child ("original_filename");
+ XMLNode *dur_node = node->child ("duration");
+
+ if (id_node && uri_node && ofn_node && dur_node) {
+
+ std::string id = id_node->child("text")->content();
+ std::string uri = uri_node->child("text")->content();
+ std::string ofn = ofn_node->child("text")->content();
+ std::string dur = dur_node->child("text")->content();
+
+ std::string r;
+ // cerr << "id=" << id << ",uri=" << uri << ",ofn=" << ofn << ",dur=" << dur << endl;
+
+ double duration_seconds = atof(dur.c_str());
+ double h, m, s;
+ char duration_hhmmss[16];
+ if (duration_seconds >= 99 * 60 * 60) {
+ strcpy(duration_hhmmss, ">99h");
+ } else {
+ s = modf(duration_seconds/60, &m) * 60;
+ m = modf(m/60, &h) * 60;
+ sprintf(duration_hhmmss, "%02.fh:%02.fm:%04.1fs",
+ h, m, s
+ );