void sword_logic_install_module (string source_name, string module_name) { Database_Logs::log ("Install SWORD module " + module_name + " from source " + source_name); string sword_path = sword_logic_get_path (); // Installation through SWORD InstallMgr does not yet work. // When running it from the ~/.sword/InstallMgr directory, it works. #ifdef HAVE_SWORD sword::SWMgr *mgr = new sword::SWMgr(); sword::SWBuf baseDir = sword_logic_get_path ().c_str (); sword::InstallMgr *installMgr = new sword::InstallMgr (baseDir, NULL); installMgr->setUserDisclaimerConfirmed (true); sword::InstallSourceMap::iterator source = installMgr->sources.find(source_name.c_str ()); if (source == installMgr->sources.end()) { Database_Logs::log ("Could not find remote source " + source_name); } else { sword::InstallSource *is = source->second; sword::SWMgr *rmgr = is->getMgr(); sword::SWModule *module; sword::ModMap::iterator it = rmgr->Modules.find(module_name.c_str()); if (it == rmgr->Modules.end()) { Database_Logs::log ("Remote source " + source_name + " does not make available module " + module_name); } else { module = it->second; int error = installMgr->installModule(mgr, 0, module->getName(), is); if (error) { Database_Logs::log ("Error installing module " + module_name); } else { Database_Logs::log ("Installed module " + module_name); } } } delete installMgr; delete mgr; #else string out_err; filter_shell_run ("cd " + sword_path + "; echo yes | installmgr -ri \"" + source_name + "\" \"" + module_name + "\"", out_err); sword_logic_log (out_err); #endif // After the installation is complete, cache some data. // This cached data indicates the last access time for this SWORD module. string url = sword_logic_virtual_url (module_name, 0, 0, 0); database_filebased_cache_put (url, "SWORD"); }
// In Cloud mode, this function wraps around http GET. // It fetches existing content from the cache, and caches new content. string resource_logic_web_cache_get (string url, string & error) { // On the Cloud, check if the URL is in the cache. if (!config_logic_client_prepared ()) { if (database_filebased_cache_exists (url)) { return database_filebased_cache_get (url); } } // Fetch the URL from the network. // Do not cache the response in an error situation. error.clear (); string html = filter_url_http_get (url, error); if (!error.empty ()) { return html; } // In the Cloud, cache the response. if (!config_logic_client_prepared ()) { database_filebased_cache_put (url, html); } // Done. return html; }