FXint ASXParser::begin(const FXchar * element,const FXchar ** attributes){ switch(elem) { case Elem_None: { if (comparecase(element,"asx")==0) { elem=Elem_ASX; return 1; } } break; case Elem_ASX: { if (comparecase(element,"entry")==0) { elem=Elem_ASX_Entry; return 1; } } break; case Elem_ASX_Entry: { if (comparecase(element,"ref")==0) { elem=Elem_ASX_Entry_Ref; for (FXint i=0;attributes[i];i+=2){ if (comparecase(attributes[i],"href")==0) { files.append(FXString(attributes[i+1])); } } return 1; } } break; default: return 0; // skip } return 0; }
void ap_parse_pls(const FXString & data,FXStringList & mrl) { FXint start=0,end=0,pos,next; for (FXint i=0;i<data.length();i++) { if (data[i]=='\n') { end=i; next=i+1; /// Skip white space while(start<end && Ascii::isSpace(data[start])) start++; /// Skip white space while(end>start && Ascii::isSpace(data[end])) end--; /// Parse the actual line. if ((end-start)>6) { if (compare(&data[start],"File",4)==0) { pos = data.find('=',start+4); if (pos==-1) continue; pos++; if (end-pos>0) { mrl.append(data.mid(pos,1+end-pos)); } } } start=next; } } }
static FXbool updateTrackFilenames(GMTrackDatabase * db,FXIntList & tracks) { register FXint i=0; FXint numchanges=0; FXString url; GMTrack trackinfo; FXStringList newurls; FXStringList oldurls; if (!GMPlayerManager::instance()->getPreferences().export_format_template.contains("%T")) { FXMessageBox::error(GMPlayerManager::instance()->getMainWindow(),MBOX_OK,fxtr("Invalid Template"),fxtr("The provided template is invalid. The track title %%T needs to be specified.\nPlease fix the filename template in the preference panel.")); return false; } FXTextCodec * codec = GMFilename::findcodec(GMPlayerManager::instance()->getPreferences().export_encoding); FXuint options=0; if (GMPlayerManager::instance()->getPreferences().export_lowercase) options|=GMFilename::LOWERCASE; if (GMPlayerManager::instance()->getPreferences().export_lowercase_extension) options|=GMFilename::LOWERCASE_EXTENSION; if (GMPlayerManager::instance()->getPreferences().export_underscore) options|=GMFilename::NOSPACES; /// Create New Mrls. for (i=0;i<tracks.no();i++) { db->begin(); if (!db->getTrack(tracks[i],trackinfo)) { db->commit(); FXMessageBox::error(GMPlayerManager::instance()->getMainWindow(),MBOX_OK,fxtr("Database Error"),fxtr("Oops. Database Error")); return true; } db->commit(); if (GMFilename::create(url,trackinfo,GMPlayerManager::instance()->getPreferences().export_format_template,GMPlayerManager::instance()->getPreferences().export_character_filter,options,codec) && url!=trackinfo.url) { newurls.append(url); oldurls.append(trackinfo.url); numchanges++; } else { newurls.append(FXString::null); oldurls.append(FXString::null); } } if (numchanges==0){ FXMessageBox::information(GMPlayerManager::instance()->getMainWindow(),MBOX_OK,fxtr("No changes"),fxtr("Filenames did not require any changes")); delete codec; return false; } /// Ask For Permission FXDialogBox dialog(GMPlayerManager::instance()->getMainWindow(),fxtr("Rename Audio Files?"),DECOR_TITLE|DECOR_BORDER|DECOR_RESIZE|DECOR_CLOSE,0,0,600,400,0,0,0,0,0,0); GMPlayerManager::instance()->getMainWindow()->create_dialog_header(&dialog,fxtr("Renaming Audio Files…"),fxtr("The following audio files are going to be renamed")); FXHorizontalFrame *closebox=new FXHorizontalFrame(&dialog,LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|PACK_UNIFORM_WIDTH,0,0,0,0); new GMButton(closebox,fxtr("&Rename"),NULL,&dialog,FXDialogBox::ID_ACCEPT,BUTTON_INITIAL|BUTTON_DEFAULT|LAYOUT_RIGHT|FRAME_RAISED|FRAME_THICK,0,0,0,0, 15,15); new GMButton(closebox,fxtr("&Cancel"),NULL,&dialog,FXDialogBox::ID_CANCEL,BUTTON_DEFAULT|LAYOUT_RIGHT|FRAME_RAISED|FRAME_THICK,0,0,0,0, 15,15); FXVerticalFrame * main = new FXVerticalFrame(&dialog,LAYOUT_FILL_X|LAYOUT_FILL_Y); GMScrollFrame * sunken = new GMScrollFrame(main); GMList * list = new GMList(sunken,NULL,0,LAYOUT_FILL_X|LAYOUT_FILL_Y); for (i=0;i<tracks.no();i++) { if (!newurls[i].empty()) { list->appendItem(newurls[i]); } } if (dialog.execute()) { GMRenameTask * task = new GMRenameTask(db,tracks,newurls,oldurls); // task->setTarget(GMPlayerManager::instance()->getTrackView()->getSource()); // task->setSelector( GMPlayerManager::instance()->runTask(task); /* for (i=0;i<tracks.no();i++){ if (!newmrls[i].empty()) { if (gm_make_path(FXPath::directory(newmrls[i]))) { if (!FXStat::exists(newmrls[i])) { if (FXFile::rename(oldmrls[i],newmrls[i])){ db->setTrackFilename(tracks[i],newmrls[i]); } else { if (i+1<tracks.no()) { if (FXMessageBox::error(GMPlayerManager::instance()->getMainWindow(),MBOX_YES_NO,fxtr("Unable to rename file"),fxtrformat("Unable to rename:\n%s\n\nto:%s\nContinue renaming files?"),oldmrls[i].text(),newmrls[i].text())==MBOX_CLICKED_NO) break; } else { FXMessageBox::error(GMPlayerManager::instance()->getMainWindow(),MBOX_OK,fxtr("Unable to rename file"),fxtrformat("Unable to rename:\n%s\n\nto:%s"),oldmrls[i].text(),newmrls[i].text()); } } } } } } */ return true; } delete codec; return false; }
static FXbool updateTrackFilenames(GMTrackDatabase * db,FXIntList & tracks) { FXint i=0; FXint numchanges=0; FXString url; GMTrack trackinfo; FXStringList newurls; FXStringList oldurls; if (!GMPlayerManager::instance()->getPreferences().export_format_template.contains("%T")) { FXMessageBox::error(GMPlayerManager::instance()->getMainWindow(),MBOX_OK,fxtr("Invalid Template"),fxtr("The provided template is invalid. The track title %%T needs to be specified.\nPlease fix the filename template in the preference panel.")); return false; } const FXTextCodec * const codec = ap_get_usercodec(GMPlayerManager::instance()->getPreferences().export_encoding); FXuint options=0; if (GMPlayerManager::instance()->getPreferences().export_lowercase) options|=gm::TrackFormatter::LOWERCASE; if (GMPlayerManager::instance()->getPreferences().export_lowercase_extension) options|=gm::TrackFormatter::LOWERCASE_EXTENSION; if (GMPlayerManager::instance()->getPreferences().export_underscore) options|=gm::TrackFormatter::NOSPACE; gm::TrackFormatter trackformat(GMPlayerManager::instance()->getPreferences().export_format_template, codec, GMPlayerManager::instance()->getPreferences().export_character_filter, options); try { GMLockTransaction transaction(db); /// Create New Mrls. for (i=0;i<tracks.no();i++) { if (!db->getTrack(tracks[i],trackinfo)) { FXMessageBox::error(GMPlayerManager::instance()->getMainWindow(),MBOX_OK,fxtr("Database Error"),fxtr("Oops. Database Error")); return true; } url = trackformat.getPath(trackinfo); if (!url.empty() && url!=trackinfo.url) { newurls.append(url); oldurls.append(trackinfo.url); numchanges++; } else { newurls.append(FXString::null); oldurls.append(FXString::null); } } } catch(GMDatabaseException&) { FXMessageBox::error(GMPlayerManager::instance()->getMainWindow(),MBOX_OK,fxtr("Database Error"),fxtr("Failed to retrieve track filenames")); return false; } if (numchanges==0){ FXMessageBox::information(GMPlayerManager::instance()->getMainWindow(),MBOX_OK,fxtr("No changes"),fxtr("Filenames did not require any changes")); return false; } /// Ask For Permission FXDialogBox dialog(GMPlayerManager::instance()->getMainWindow(),fxtr("Rename Audio Files?"),DECOR_TITLE|DECOR_BORDER|DECOR_RESIZE|DECOR_CLOSE,0,0,600,400,0,0,0,0,0,0); GMPlayerManager::instance()->getMainWindow()->create_dialog_header(&dialog,fxtr("Renaming Audio Files…"),fxtr("The following audio files are going to be renamed")); FXHorizontalFrame *closebox=new FXHorizontalFrame(&dialog,LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|PACK_UNIFORM_WIDTH,0,0,0,0); new GMButton(closebox,fxtr("&Rename"),nullptr,&dialog,FXDialogBox::ID_ACCEPT,BUTTON_INITIAL|BUTTON_DEFAULT|LAYOUT_RIGHT|FRAME_RAISED|FRAME_THICK,0,0,0,0, 15,15); new GMButton(closebox,fxtr("&Cancel"),nullptr,&dialog,FXDialogBox::ID_CANCEL,BUTTON_DEFAULT|LAYOUT_RIGHT|FRAME_RAISED|FRAME_THICK,0,0,0,0, 15,15); FXVerticalFrame * main = new FXVerticalFrame(&dialog,LAYOUT_FILL_X|LAYOUT_FILL_Y); GMScrollFrame * sunken = new GMScrollFrame(main); GMList * list = new GMList(sunken,nullptr,0,LAYOUT_FILL_X|LAYOUT_FILL_Y); for (i=0;i<tracks.no();i++) { if (!newurls[i].empty()) { if (codec && codec->mibEnum()!=106) { // Not UTF8 or Ascii // Translate back to UTF-8 list->appendItem(codec->mb2utf(newurls[i])); } else { list->appendItem(newurls[i]); } } } if (dialog.execute()) { GMRenameTask * task = new GMRenameTask(db,tracks,newurls,oldurls); GMPlayerManager::instance()->runTask(task); return true; } return false; }