Esempio n. 1
0
// Takes the HTML output generated by GetHTML
// and puts it on the clipboard.  Simplenuff.
bool CStatisticsTree::CopyHTML(int copyMode)
{
	switch (copyMode) {
		case MP_STATTREE_HTMLCOPYSEL:
			{
				HTREEITEM selectedItem = GetSelectedItem();
				if (selectedItem != NULL) {
					CString theHTML = GetHTML(true, selectedItem);
					if (theHTML.IsEmpty())
						return false;
					theApp.CopyTextToClipboard(theHTML);
					return true;
				}
				return false;
			}
		case MP_STATTREE_HTMLCOPYVIS:
			{
				CString theHTML = GetHTML();
				if (theHTML.IsEmpty())
					return false;
				theApp.CopyTextToClipboard(theHTML);
				return true;
			}
		case MP_STATTREE_HTMLCOPYALL:
			{
				CString theHTML = GetHTML(false);
				if (theHTML.IsEmpty())
					return false;
				theApp.CopyTextToClipboard(theHTML);
				return true;
			}
	}

	return false;
}
Esempio n. 2
0
size_t wxHTMLDataObject::GetDataSize() const
{
    // Windows and Mac always use UTF-8, and docs suggest GTK does as well.
    wxCharBuffer buffer =  wxConvUTF8.cWX2MB( GetHTML().c_str() );

    return buffer ? strlen( buffer ) : 0;
}
Esempio n. 3
0
bool wxHTMLDataObject::GetDataHere(void *buf) const
{
    if ( !buf )
        return false;

    // Windows and Mac always use UTF-8, and docs suggest GTK does as well.
    const wxScopedCharBuffer html(GetHTML().utf8_str());
    if ( !html )
        return false;

    char* const buffer = static_cast<char*>(buf);

#ifdef __WXMSW__
    // add the extra info that the MSW clipboard format requires.

    // Create a template string for the HTML header...
    strcpy(buffer,
           "Version:0.9\r\n"
           "StartHTML:00000000\r\n"
           "EndHTML:00000000\r\n"
           "StartFragment:00000000\r\n"
           "EndFragment:00000000\r\n"
           "<html><body>\r\n"
           "<!--StartFragment -->\r\n");

    // Append the HTML...
    strcat(buffer, html);
    strcat(buffer, "\r\n");
    // Finish up the HTML format...
    strcat(buffer,
           "<!--EndFragment-->\r\n"
           "</body>\r\n"
           "</html>");

    // Now go back, calculate all the lengths, and write out the
    // necessary header information. Note, wsprintf() truncates the
    // string when you overwrite it so you follow up with code to replace
    // the 0 appended at the end with a '\r'...
    char *ptr = strstr(buffer, "StartHTML");
    sprintf(ptr+10, "%08u", (unsigned)(strstr(buffer, "<html>") - buffer));
    *(ptr+10+8) = '\r';

    ptr = strstr(buffer, "EndHTML");
    sprintf(ptr+8, "%08u", (unsigned)strlen(buffer));
    *(ptr+8+8) = '\r';

    ptr = strstr(buffer, "StartFragment");
    sprintf(ptr+14, "%08u", (unsigned)(strstr(buffer, "<!--StartFrag") - buffer));
    *(ptr+14+8) = '\r';

    ptr = strstr(buffer, "EndFragment");
    sprintf(ptr+12, "%08u", (unsigned)(strstr(buffer, "<!--EndFrag") - buffer));
    *(ptr+12+8) = '\r';
#else
    strcpy(buffer, html);
#endif // __WXMSW__

    return true;
}
Esempio n. 4
0
bool wxHTMLDataObject::GetDataHere(void *buf) const
{
    if ( !buf )
        return false;

    // Windows and Mac always use UTF-8, and docs suggest GTK does as well.
    wxCharBuffer buffer =  wxConvUTF8.cWX2MB( GetHTML().c_str() );
    if ( !buffer )
        return false;

    memcpy( (char*) buf, buffer, GetDataSize() );

    return true;
}
Esempio n. 5
0
size_t wxHTMLDataObject::GetDataSize() const
{
    const wxScopedCharBuffer buffer(GetHTML().utf8_str());

    size_t size = buffer.length();

#ifdef __WXMSW__
    // On Windows we need to add some stuff to the string to satisfy
    // its clipboard format requirements.
    size += 400;
#endif

    return size;
}
Esempio n. 6
0
//ゲーマーカードHTMLソース取得
string GetGamerData::GetCardSource(const string &strGamerTag)
{
	string strRet = "";
	string strCardFile;

	WORD wVersionRequested = WINSOCK_VERSION;
	WSADATA wsaData;
	int nRet;

	if(strGamerTag.size() == 0 || strGamerTag.size()  >= 16)
	{
		return strRet;
	}

	strCardFile = "";
	strCardFile += this->UrlEncode(strGamerTag);
	strCardFile += ".card";

	long lRet = 0;

	// WinSock.dllを初期化する
	nRet = WSAStartup(wVersionRequested, &wsaData);
	if (nRet)
	{
		//fprintf(stderr,"\nWSAStartup(): %d\n", nRet);
		WSACleanup();
		return strRet;
	}

	// WinSockのバージョンを調べる

	if (wsaData.wVersion != wVersionRequested)
	{
		//fprintf(stderr,"\nWinSock version not supported\n");
		WSACleanup();
		return strRet;
	}

	// .gifファイルおよび.jpgファイルのリダイレクションを機能させるために、stdoutをバイナリモードに設定する
	_setmode(_fileno(stdout), _O_BINARY);

	// GetHTTP()を呼び出してすべての処理を実行する
	strRet = GetHTML(this->GamerCardServer,strCardFile);

	// WinSockを解放する
	WSACleanup();
	
	return strRet;
}
Esempio n. 7
0
// This is the primary function for generating HTML output of the statistics tree.
// It is recursive.
CString CStatisticsTree::GetHTML(bool onlyVisible, HTREEITEM theItem, int theItemLevel, bool firstItem)
{
	HTREEITEM hCurrent;
	if (theItem == NULL)
	{
		if (!onlyVisible)
			theApp.emuledlg->statisticswnd->ShowStatistics(true);
		hCurrent = GetRootItem(); // Copy All Vis or Copy All
	}
	else
		hCurrent = theItem;

	CString	strBuffer;
	if (firstItem)
		//Xman // Maella -Support for tag ET_MOD_VERSION 0x55
		/*
		strBuffer.Format(_T("<font face=\"Tahoma,Verdana,Courier New,Helvetica\" size=\"2\">\r\n<b>eMule v%s %s [%s]</b>\r\n<br /><br />\r\n"), theApp.m_strCurVersionLong, GetResString(IDS_SF_STATISTICS), thePrefs.GetUserNick());
		*/
		// ==> ModID [itsonlyme/SiRoB] - Stulle
		/*
		strBuffer.Format(_T("<font face=\"Tahoma,Verdana,Courier New,Helvetica\" size=\"2\">\r\n<b>eMule v%s %s [%s]</b>\r\n<br /><br />\r\n"), theApp.m_strCurVersionLong + _T(" ") + MOD_VERSION, GetResString(IDS_SF_STATISTICS), thePrefs.GetUserNick());
		*/
		strBuffer.Format(_T("<font face=\"Tahoma,Verdana,Courier New,Helvetica\" size=\"2\">\r\n<b>eMule v%s [%s] %s [%s]</b>\r\n<br /><br />\r\n"), theApp.m_strCurVersionLong, theApp.m_strModLongVersion, GetResString(IDS_SF_STATISTICS), thePrefs.GetUserNick());
		// <== ModID [itsonlyme/SiRoB] - Stulle
		//Xman end

	while (hCurrent != NULL)
	{
		CString	strItem;
		if (IsBold(hCurrent))
			strItem = _T("<b>") + GetItemText(hCurrent) + _T("</b>");
		else
			strItem = GetItemText(hCurrent);
		for (int i = 0; i < theItemLevel; i++)
			strBuffer += _T("&nbsp;&nbsp;&nbsp;");
		if (theItemLevel == 0)
			strBuffer.Append(_T("\n"));
		strBuffer += strItem + _T("<br />");
		if (ItemHasChildren(hCurrent) && (!onlyVisible || IsExpanded(hCurrent)))
			strBuffer += GetHTML(onlyVisible, GetChildItem(hCurrent), theItemLevel+1, false);
		hCurrent = GetNextItem(hCurrent, TVGN_NEXT);
		if (firstItem && theItem != NULL)
			break; // Copy Selected Branch was used, so we don't want to copy all branches at this level.  Only the one that was selected.
	}
	if (firstItem)
		strBuffer += _T("</font>");
	return strBuffer;
}
int _tmain(int argc, _TCHAR* argv[])
{
    char message[100] = "[URL]https://www.youtube.com/watch?v=wCRStRWMdWM#t=39s[/URL]\0";

	CURLcode curlCode;
	const char *curlMessage = "";
	struct MemoryStruct chunk;

	htmlDocPtr doc;
	xmlXPathContextPtr context;
	xmlXPathObjectPtr result;
	char * keyword;

	int i;
	char newMessage[1024];
	char errorMessage[128];
	const char* url;

    //printf("Enter your message: ");
    //fgets(message, 100, stdin);
    printf("Your Message is: %s\n", message);

	system("pause");

	url = GetURLFromMessage(message);
			
	chunk.memory = (char *) malloc(1);  /* will be grown as needed by the realloc above */ 
	chunk.size = 0;    /* no data at this point */

	if (url == NULL) {
		printf("URL is null, exiting...\n");
		system("pause");
		free(chunk.memory);
		return 0;
	}

	printf("URL: ");
	printf(url);
	printf("\n");

	//ts3Functions.logMessage("Opening URL: ", LogLevel_INFO, "Plugin", serverConnectionHandlerID);
	//ts3Functions.logMessage(url, LogLevel_INFO, "Plugin", serverConnectionHandlerID);

	GetHTML(url, &chunk, &curlCode, curlMessage);
	
	printf("curlMessage: ");
	printf(curlMessage);
	printf("\n");

	//if (curlCode != 0) {
	//	ts3Functions.logMessage("cURL Error: ", LogLevel_ERROR, "Plugin", serverConnectionHandlerID);
	//	ts3Functions.logMessage(curlMessage, LogLevel_ERROR, "Plugin", serverConnectionHandlerID);
	//}

#if defined(_WIN32) || defined(WIN32) || defined(_WIN64) || defined(WIN64)
	sprintf_s(errorMessage, 128, "Reading HTML file that is the following bytes long: %d", chunk.size);
#else
	sprintf(errorMessage, "Reading HTML file that is the following bytes long: %d", chunk.size);
#endif
	//ts3Functions.logMessage(errorMessage, LogLevel_INFO, "Plugin", serverConnectionHandlerID);

	doc = htmlReadMemory(chunk.memory, chunk.size, url, NULL, HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING);
	if (!doc) {
		printf("Could not read HTML document from memory\n");

	system("pause");
		//ts3Functions.logMessage("Could not read HTML document from memory", LogLevel_ERROR, "Plugin", serverConnectionHandlerID);
		free(chunk.memory);
		return 0;
	}

	context = xmlXPathNewContext(doc);
	result = xmlXPathEvalExpression("/html/head/title", context);

	if (xmlXPathNodeSetIsEmpty(result->nodesetval)) {
		printf("Could not read HTML node set from memory\n");
		system("pause");
		//ts3Functions.logMessage("Could not read HTML node set from memory", LogLevel_ERROR, "Plugin", serverConnectionHandlerID);
		xmlXPathFreeObject(result);
		free(chunk.memory);
		return 0;
	}

	for (i=0; i < result->nodesetval->nodeNr; i++) {
		keyword = (char *) xmlNodeListGetString(doc, result->nodesetval->nodeTab[i]->xmlChildrenNode, 1);
		continue;
		//printf("keyword: %s\n", keyword);
	}

#if defined(_WIN32) || defined(WIN32) || defined(WIN64) || defined(_WIN64)
	strcpy_s(newMessage, 1024, "\"");
	strcat_s(newMessage, 1024, (const char *) keyword);
	strcat_s(newMessage, 1024, "\" <[URL]");
	strcat_s(newMessage, 1024, url);
	strcat_s(newMessage, 1024, "[/URL]>");
#else
	strcpy(newMessage, "\"");
	strcat(newMessage, (const char *) keyword);
	strcat(newMessage, "\" <");
	strcat(newMessage, message);
	strcat(newMessage, ">");
#endif
			
	//xmlFree(keyword);
	xmlXPathFreeObject(result);
	xmlFreeDoc(doc);
	free(chunk.memory);

	printf("New message: ");
	printf(newMessage);
	printf("\n");

	printf("End\n");
	system("pause");

    return 1;
}