Beispiel #1
0
string DirectoryListing::loadXML(InputStream& is, bool updating, bool p_is_own_list)
{
	CFlyLog l_log("[loadXML]");
	ListLoader ll(this, getRoot(), updating, getUser(), p_is_own_list);
	//l_log.step("start parse");
	SimpleXMLReader(&ll).parse(is);
	l_log.step("Stop parse file:" + m_file);
	m_is_mediainfo = ll.isMediainfoList();
	m_is_own_list = p_is_own_list;
	return ll.getBase();
}
Beispiel #2
0
int
main(int argc, const char *argv[])
{
    l_log_set_threshold(L_VERBOSE);
    l_random_setup();
    l_log(L_INFO, "starting up");

    if (argc <= 1) {
        fprintf(stderr, "usage: lcoltest CONFIG_FILE\n");
        return EXIT_FAILURE;
    }

    l_column_test_app_t app;
    l_column_test_app_init(&app, &(l_column_test_app_spec_t) {
        config_path: argv[1],
        request_type: argv[2],
        num_args: argc - 3,
        args: argv + 3,
    });
Beispiel #3
0
void preparingCoreToShutdown() // [+] IRainamn fix.
{
	static bool g_is_first = false;
	if (!g_is_first)
	{
		g_is_first = true;
		CFlyLog l_log("[Core shutdown]");
		TimerManager::getInstance()->shutdown();
		ClientManager::shutdown();
#ifdef STRONG_USE_DHT
		dht::BootstrapManager::shutdown_http();
#endif
		UploadManager::shutdown();
		WebServerManager::getInstance()->shutdown();
		HashManager::getInstance()->shutdown();
		ClientManager::getInstance()->prepareClose();
		FavoriteManager::getInstance()->prepareClose();
		ShareManager::getInstance()->shutdown();
		QueueManager::getInstance()->shutdown();
		SearchManager::getInstance()->disconnect();
		ClientManager::getInstance()->clear();
		CFlylinkDBManager::getInstance()->flush();
	}
}
void PublicHubsFrame::loadISPHubs()
{
	CWaitCursor l_cursor_wait; //-V808
	CFlyLockWindowUpdate l_lock_update(m_ctrlTree);
	CLockRedraw<true> l_lock_draw(m_ctrlTree);
	m_ISPRootItem = 0;
	m_PublicListRootItem = 0;
	m_ctrlTree.DeleteAllItems();
	m_country_map.m_country.clear();
	g_ISPImage.init();
	m_ctrlTree.SetImageList(g_ISPImage.getIconList(), TVSIL_NORMAL);
	CFlyLog l_log("[ISP Hub Loader]");
	if (m_isp_raw_data.empty())
	{
		const string l_url_config_file = "http://etc.fly-server.ru/etc/isp-hub-list.txt";
		l_log.step("Download:" + l_url_config_file);
		if (Util::getDataFromInet(true, l_url_config_file, m_isp_raw_data, 0) == 0)
		{
			l_log.step("Error download! Config will be loaded from internal resources");
			LPCSTR l_res_data;
			if (const auto l_size_res = Util::GetTextResource(IDR_ISP_HUB_LIST_EXAMPLE, l_res_data))
			{
				m_isp_raw_data = string(l_res_data, l_size_res);
			}
			else
			{
				l_log.step("Error load resource Util::GetTextResource(IDR_FLY_SERVER_CONFIG");
			}
		}
	}
	l_log.step("Parse ISP Hub list");
	if (!m_isp_raw_data.empty())
	{
		loadPublicListHubs();
		m_ISPRootItem = m_ctrlTree.InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT | TVIF_PARAM,
		                                      _T("ISP"),
		                                      g_ISPImage.m_flagImageCount + 14, // nImage
		                                      g_ISPImage.m_flagImageCount + 14, // nSelectedImage
		                                      0, // nState
		                                      0, // nStateMask
		                                      e_ISPRoot, // lParam
		                                      0, // aParent,
		                                      0  // hInsertAfter
		                                     );
		string::size_type linestart = 0;
		string::size_type lineend = 0;
		for (;;)
		{
			lineend = m_isp_raw_data.find('\n', linestart);
			if (lineend == string::npos)
			{
				const string l_line = m_isp_raw_data.substr(linestart);
				if (!l_line.empty())
				{
					parseISPHubsLine(l_line, l_log);
				}
				break;
			}
			else
			{
				string l_line = m_isp_raw_data.substr(linestart, lineend - linestart - 1);
				parseISPHubsLine(l_line, l_log);
				linestart = lineend + 1;
			}
		}
		m_ctrlTree.Expand(m_ISPRootItem);
		m_ctrlTree.Expand(m_PublicListRootItem);
	}
}
LRESULT PublicHubsFrame::onSelChangedISPTree(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/)
{
	NMTREEVIEW* p = (NMTREEVIEW*) pnmh;
	if (p->itemNew.state & TVIS_SELECTED)
	{
		CWaitCursor l_cursor_wait; //-V808
		m_ctrlHubs.DeleteAllItems();
		if (p->itemNew.lParam == e_HubListItem)
		{
			tstring buf;
			buf.resize(100);
			if (m_ctrlTree.GetItemText(p->itemNew.hItem, &buf[0], buf.size()))
			{
				const string l_url = Text::fromT(buf.c_str());
				CFlyLog l_log("Download Hub List");
				std::vector<byte> l_data;
				l_log.step("URL = " + l_url);
				CFlyHTTPDownloader l_http_downloader;
				//l_http_downloader.setInetFlag(INTERNET_FLAG_RESYNCHRONIZE);
				l_http_downloader.m_is_use_cache = true;
				if (l_http_downloader.getBinaryDataFromInet(l_url, l_data, 1000))
				{
					const string ext = Util::getFileExt(l_url);
					if (stricmp(ext, ".bz2") == 0)
					{
						std::vector<byte> l_out(l_data.size() * 20);
						size_t outSize = l_out.size();
						size_t sizeRead = l_data.size();
						UnBZFilter unbzip;
						try
						{
							unbzip(l_data.data(), (size_t &)sizeRead, &l_out[0], outSize);
							l_out[outSize] = 0;
							HubEntryList& l_list = m_publicListMatrix[l_url];
							l_list.clear();
							try
							{
								PubHubListXmlListLoader loader(l_list);
								SimpleXMLReader(&loader).parse((const char*)l_out.data(), outSize, false);
								m_hubs = l_list;
								updateList();
							}
							catch (const Exception& e)
							{
								l_log.step("XML parse error = " + e.getError());
							}
						}
						catch (const Exception& e)
						{
							l_log.step("Unpack error = " + e.getError());
						}
					}
				}
			}
		}
		else
		{
			TStringSet l_items;
			LoadTreeItems(l_items, p->itemNew.hItem);
			int cnt = 0;
			for (auto i = l_items.cbegin(); i != l_items.end(); ++i)
			{
				TStringList l;
				l.resize(COLUMN_LAST);
				l[COLUMN_SERVER] = *i;
				m_ctrlHubs.insert(cnt++, l, I_IMAGECALLBACK); // !SMT!-IP
			}
		}
		m_ctrlHubs.resort();
		updateStatus();
	}
	return 0;
}