KissMangaCom::KissMangaCom() { type = CONNECTOR_TYPE_MANGA; label = wxT("KissManga"); baseURL = wxT("http://kissmanga.com"); referrerURL = wxT("http://kissmanga.com"); mangaListFile.Assign(GetConfigurationPath(), wxT("kissmanga"), wxT("list")); LoadLocalMangaList(); agent = wxT("Mozilla"); CFCookie(3); }
wxString wxvbamApp::GetAbsolutePath(wxString path) { wxFileName dir(path); if (dir.IsRelative()) { wxFileName fn(GetConfigurationPath(), path); fn.Normalize(); return fn.GetFullPath(); } return path; }
bool wxvbamApp::OnInit() { // use consistent names for config SetAppName(_("vbam")); #if (wxMAJOR_VERSION >= 3) SetAppDisplayName(_T("VisualBoyAdvance-M")); #endif // load system default locale, if available locale.Init(); locale.AddCatalog(_T("wxvbam")); // make built-in xrc file available // this has to be done before parent OnInit() so xrc dump works wxFileSystem::AddHandler(new wxMemoryFSHandler); wxFileSystem::AddHandler(new wxArchiveFSHandler); wxMemoryFSHandler::AddFileWithMimeType(wxT("wxvbam.xrs"), builtin_xrs, sizeof(builtin_xrs), wxT("application/zip")); if (!wxApp::OnInit()) return false; // prepare for loading xrc files wxXmlResource* xr = wxXmlResource::Get(); // note: if linking statically, next 2 pull in lot of unused code // maybe in future if not wxSHARED, load only builtin-needed handlers xr->InitAllHandlers(); wxInitAllImageHandlers(); get_config_path(config_path); // first, load override xrcs // this can only override entire root nodes // 2.9 has LoadAllFiles(), but this is 2.8, so we'll do it manually wxString cwd = wxGetCwd(); for (int i = 0; i < config_path.size(); i++) if (wxDirExists(config_path[i]) && wxSetWorkingDirectory(config_path[i])) { // *.xr[cs] doesn't work (double the number of scans) // 2.9 gives errors for no files found, so manual precheck needed // (yet another double the number of scans) if (!wxFindFirstFile(wxT("*.xrc")).empty()) xr->Load(wxT("*.xrc")); if (!wxFindFirstFile(wxT("*.xrs")).empty()) xr->Load(wxT("*.xrs")); } wxFileName xrcDir(GetConfigurationPath() + wxT("//xrc"), wxEmptyString); if (xrcDir.DirExists() && wxSetWorkingDirectory(xrcDir.GetFullPath()) && !wxFindFirstFile(wxT("*.xrc")).empty()) { xr->Load(wxT("*.xrc")); } else { // finally, load built-in xrc xr->Load(wxT("memory:wxvbam.xrs")); } wxSetWorkingDirectory(cwd); // set up config file // this needs to be in a subdir to support other config as well // but subdir flag behaves differently 2.8 vs. 2.9. Oh well. // NOTE: this does not support XDG (freedesktop.org) paths #if defined(__WXMSW__) || defined(__APPLE__) wxFileName vbamconf(GetConfigurationPath(), _T("vbam.ini")); cfg = new wxFileConfig(wxT("vbam"), wxEmptyString, vbamconf.GetFullPath(), wxEmptyString, wxCONFIG_USE_LOCAL_FILE); #else cfg = new wxFileConfig(wxEmptyString, wxEmptyString, wxEmptyString, wxEmptyString, // style = wxCONFIG_USE_GLOBAL_FILE | wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_SUBDIR); #endif // set global config for e.g. Windows font mapping wxFileConfig::Set(cfg); // yet another bug/deficiency in wxConfig: dirs are not created if needed // since a default config is always written, dirs are always needed // Can't figure out statically if using wxFileConfig w/o duplicating wx's // logic, so do it at run-time // wxFileConfig *f = wxDynamicCast(cfg, wxFileConfig); // wxConfigBase does not derive from wxObject!!! so no wxDynamicCast wxFileConfig* fc = dynamic_cast<wxFileConfig*>(cfg); if (fc) { wxFileName s(wxFileConfig::GetLocalFileName(GetAppName())); // at least up to 2.8.12, GetLocalFileName returns the dir if // SUBDIR is specified instead of actual file name // and SUBDIR only affects UNIX #if defined(__UNIX__) && !wxCHECK_VERSION(2,9,0) s.AppendDir(s.GetFullName()); #endif // only the path part gets created // note that 0777 is default (assumes umask will do og-w) s.Mkdir(0777, wxPATH_MKDIR_FULL); s = wxFileName::DirName(GetConfigurationPath()); s.Mkdir(0777, wxPATH_MKDIR_FULL); } load_opts(); // process command-line options for (int i = 0; i < pending_optset.size(); i++) { wxString p = pending_optset[i]; size_t eqat = p.find(wxT('=')); p[eqat] = 0; opt_set(p.c_str(), p.c_str() + eqat + 1); } pending_optset.clear(); wxFileName vba_over(GetConfigurationPath(), wxT("vba-over.ini")); wxFileName rdb(GetConfigurationPath(), wxT("Nintendo - Game Boy Advance*.dat")); wxFileName scene_rdb(GetConfigurationPath(), wxT("Nintendo - Game Boy Advance (Scene)*.dat")); wxFileName nointro_rdb(GetConfigurationPath(), wxT("Official No-Intro Nintendo Gameboy Advance Number (Date).xml")); wxString f = wxFindFirstFile(nointro_rdb.GetFullPath(), wxFILE); if (!f.empty() && wxFileName(f).IsFileReadable()) rom_database_nointro = f; f = wxFindFirstFile(scene_rdb.GetFullPath(), wxFILE); if (!f.empty() && wxFileName(f).IsFileReadable()) rom_database_scene = f; f = wxFindFirstFile(rdb.GetFullPath(), wxFILE); while (!f.empty()) { if (f == rom_database_scene.GetFullPath()) { f = wxFindNextFile(); } else if (wxFileName(f).IsFileReadable()) { rom_database = f; break; } } // load vba-over.ini // rather than dealing with wxConfig's broken search path, just use // the same one that the xrc overrides use // this also allows us to override a group at a time, add commments, and // add the file from which the group came wxMemoryInputStream mis(builtin_over, sizeof(builtin_over)); overrides = new wxFileConfig(mis); wxRegEx cmtre; // not the most efficient thing to do: read entire file into a string // just to parse the comments out wxString bovs((const char*)builtin_over, wxConvUTF8, sizeof(builtin_over)); bool cont; wxString s; long grp_idx; #define CMT_RE_START wxT("(^|[\n\r])# ?([^\n\r]*)(\r?\n|\r)\\[") for (cont = overrides->GetFirstGroup(s, grp_idx); cont; cont = overrides->GetNextGroup(s, grp_idx)) { // apparently even MacOSX sometimes uses the old \r by itself wxString cmt(CMT_RE_START); cmt += s + wxT("\\]"); if (cmtre.Compile(cmt) && cmtre.Matches(bovs)) cmt = cmtre.GetMatch(bovs, 2); else cmt = wxEmptyString; overrides->Write(s + wxT("/comment"), cmt); } if (vba_over.FileExists()) { wxStringOutputStream sos; wxFileInputStream fis(vba_over.GetFullPath()); // not the most efficient thing to do: read entire file into a string // just to parse the comments out fis.Read(sos); // rather than assuming the file is seekable, use the string we just // read as an input stream wxStringInputStream sis(sos.GetString()); wxFileConfig ov(sis); for (cont = ov.GetFirstGroup(s, grp_idx); cont; cont = ov.GetNextGroup(s, grp_idx)) { overrides->DeleteGroup(s); overrides->SetPath(s); ov.SetPath(s); overrides->Write(wxT("path"), GetConfigurationPath()); // apparently even MacOSX sometimes uses \r by itself wxString cmt(CMT_RE_START); cmt += s + wxT("\\]"); if (cmtre.Compile(cmt) && cmtre.Matches(sos.GetString())) cmt = cmtre.GetMatch(sos.GetString(), 2); else cmt = wxEmptyString; overrides->Write(wxT("comment"), cmt); long ent_idx; for (cont = ov.GetFirstEntry(s, ent_idx); cont; cont = ov.GetNextEntry(s, ent_idx)) overrides->Write(s, ov.Read(s, wxEmptyString)); ov.SetPath(wxT("/")); overrides->SetPath(wxT("/")); } } // create the main window frame = wxDynamicCast(xr->LoadFrame(NULL, wxT("MainFrame")), MainFrame); if (!frame) { wxLogError(_("Could not create main window")); return false; } // Create() cannot be overridden easily if (!frame->BindControls()) return false; frame->Show(true); return true; }