void Lua4RSNotify::notifyChatMessage(const ChatMessage &msg) { struct LuaEvent *e = new LuaEvent(); e->eventId = L4R_LOBBY_MESSAGERECEIVED; e->timeStamp = QDateTime::currentDateTime(); e->dataParm->setValue("strchatid", QString::fromUtf8(msg.chat_id.toStdString().c_str())); std::string msg2 = msg.msg; msg2 = stripHTMLTags(msg2); e->dataParm->setValue("strmsg", QString::fromUtf8(msg2.c_str())); RsGxsId gxsid = msg.lobby_peer_gxs_id; RsIdentityDetails gxsIdDetails; rsIdentity->getIdDetails(gxsid, gxsIdDetails); e->dataParm->setValue("strgxsid", QString::fromUtf8(gxsid.toStdString().c_str())); e->dataParm->setValue("strnick", QString::fromUtf8(gxsIdDetails.mNickname.c_str())); L4R::L4RConfig->getCore()->processEvent(e); }
int chttpc_runner::run(chttpc_conf* cc, wstring& out) { wstring nResult = L""; bool replaced = false; wstring saveTo_fullpath = cc->module_path + cc->saveOrginal; int getResult = CInetHelper::getUrlContent(cc->url.c_str(), (!cc->charset.empty() ? cc->charset.c_str() : NULL), nResult, (!cc->saveOrginal.empty() ? saveTo_fullpath.c_str() : NULL), cc->isLocalFile); if ( getResult == CIH_FAIL ) { out = nResult; return CR_FAIL; } if(!cc->saveUtf8.empty()) { string aResult = SAORI_FUNC::UnicodeToMultiByte(nResult, CP_UTF8); wstring fullpath = cc->module_path + cc->saveUtf8; save(aResult,fullpath); } if(!cc->searchStart.empty() && !cc->searchEnd.empty()) { UINT start, end; if(!cc->isMultiSearch) { if((start = nResult.find(cc->searchStart, 0)) != string::npos && (end = nResult.find(cc->searchEnd, start + cc->searchStart.size())) != string::npos) { nResult = nResult.substr(start + cc->searchStart.size(), end - start - cc->searchStart.size()); } } else { wstring mResult = L""; start = 0; while((start = nResult.find(cc->searchStart, start)) != string::npos && (end = nResult.find(cc->searchEnd, start + cc->searchStart.size())) != string::npos) { mResult += nResult.substr(start + cc->searchStart.size(), end - start - cc->searchStart.size()) + L"\2"; start++; } nResult = mResult; } } if(cc->isStripTag) { nResult = stripHTMLTags(nResult); } #if TRANSLATE if(cc->isTranslateTag) { nResult = CHTML2SS::translate(nResult,cc->url,cc->stripTags); } #endif if(!cc->saveParsed.empty()) { string aResult = SAORI_FUNC::UnicodeToMultiByte(nResult, cc->codepage); wstring fullpath = cc->module_path + cc->saveParsed; save(aResult,fullpath); } if(cc->isNoOutput) { out = L""; } else { nResult = replaceAll(nResult,L"\r\n",L"\\n"); nResult = replaceAll(nResult,L"\n",L"\\n"); nResult = overReplaceAll(nResult,L"\\n\\n\\n",L"\\n"); nResult = overReplaceAll(nResult, L" ", L" "); out = nResult; } return CR_OK; }