const char * GetPath(const std::string & _label) { split_vector_type labels; boost::algorithm::split(labels, _label, boost::algorithm::is_any_of(","), boost::algorithm::token_compress_on); for(split_vector_type::const_iterator itr = labels.begin(); itr != labels.end(); ++itr) { StringStringMap::const_iterator found = m_familynamePath.find(*itr); if (found != m_familynamePath.end()) return found->second.c_str(); found = m_stemPath.find(*itr); if (found != m_stemPath.end()) return found->second.c_str(); } return GetDefaultPath(); }
const TCHAR *GetECLType(const std::_tstring & colID) const { clib::recursive_mutex::scoped_lock proc(m_mutex); StringStringMap::const_iterator found = m_schemaMap.find(colID); if (found != m_schemaMap.end()) { return found->second.c_str(); } return NULL; }
static int handle_request(void* /*cls*/, MHD_Connection* connection, const char* url, const char* method, const char*, const char*, unsigned int*, void** /*con_cls*/) { if (std::string(method) != "GET") { return report_error(connection, MHD_HTTP_NOT_IMPLEMENTED, "501 Not Implemented"); } if (mp3d_debug_httpd) { MHD_get_connection_values(connection, MHD_HEADER_KIND, dump_key, NULL); MHD_get_connection_values(connection, MHD_COOKIE_KIND, dump_key, NULL); MHD_get_connection_values(connection, MHD_GET_ARGUMENT_KIND, dump_key, NULL); std::cout << "*** " << method << " request for '" << url << "'" << std::endl; } const char* q = MHD_lookup_connection_value(connection, MHD_GET_ARGUMENT_KIND, "mp3d_q"); const std::string request_url(url); if (request_url == "/") { std::string page_data; make_main_page(page_data, q); return send_string_response(connection, MHD_HTTP_OK, page_data); } else if (boost::starts_with(request_url, "/static/")) { StringStringMap::const_iterator it = static_file_map.find(request_url); if (it == static_file_map.end()) { return report_error(connection, MHD_HTTP_NOT_FOUND, "404 Not Found"); } return send_string_response(connection, MHD_HTTP_OK, it->second); } else if (boost::starts_with(request_url, "/play/")) { const size_t id = strtoul(request_url.substr(6).c_str(), 0, 10); // FIXME: error checking. play_queue.clear(); play_queue.push_back(all_mp3s[id]); // FIXME: lookup by id (don't assume id == index). return see_other(connection, "/"); } else if (boost::starts_with(request_url, "/add/")) { const size_t id = strtoul(request_url.substr(5).c_str(), 0, 10); // FIXME: error checking. play_queue.push_back(all_mp3s[id]); // FIXME: lookup by id (don't assume id == index). return see_other(connection, "/"); } else if (boost::starts_with(request_url, "/remove/")) { const size_t id = strtoul(request_url.substr(8).c_str(), 0, 10); // FIXME: error checking. play_queue.remove(id); // FIXME: is this set-like behavior the behavior we want? return see_other(connection, "/"); } else { return report_error(connection, MHD_HTTP_NOT_FOUND, "404 Not Found"); } }
BEGIN_CUNKNOWN END_CUNKNOWN CFontResolver() { m_ftLibraryLoaded = false; FT_Error error = FT_Init_FreeType(&m_ftLibrary); if (!error) m_ftLibraryLoaded = true; split_vector_type searchFolders; boost::algorithm::split(searchFolders, DEFAULT_FONTPATH, boost::algorithm::is_any_of(";"), boost::algorithm::token_compress_on); for(split_vector_type::const_iterator itr = searchFolders.begin(); itr != searchFolders.end(); ++itr) { findFilesByExt(*itr, ".ttf", m_stemPath); findFilesByExt(*itr, ".ttc", m_stemPath); } split_vector_type defaultFonts; boost::algorithm::split(defaultFonts, DEFAULT_FONT, boost::algorithm::is_any_of(";"), boost::algorithm::token_compress_on); for(split_vector_type::const_iterator itr = defaultFonts.begin(); itr != defaultFonts.end(); ++itr) { StringStringMap::const_iterator found = m_stemPath.find(*itr); if (found != m_stemPath.end()) { m_defaultPath = found->second; break; } } if (m_defaultPath.empty()) { #if defined WIN32 m_defaultPath = "c:/windows/fonts/verdana.ttf"; #else m_defaultPath = "/usr/share/fonts/truetype/freefont/FreeSans.ttf"; #endif } }