本文整理汇总了C++中fb::JSObjectPtr类的典型用法代码示例。如果您正苦于以下问题:C++ JSObjectPtr类的具体用法?C++ JSObjectPtr怎么用?C++ JSObjectPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JSObjectPtr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: getURLCallback
void FBTestPluginAPI::getURLCallback(const FB::JSObjectPtr& callback, bool success,
const FB::HeaderMap& headers, const boost::shared_array<uint8_t>& data, const size_t size) {
FB::VariantMap outHeaders;
for (FB::HeaderMap::const_iterator it = headers.begin(); it != headers.end(); ++it) {
if (headers.count(it->first) > 1) {
if (outHeaders.find(it->first) != outHeaders.end()) {
outHeaders[it->first].cast<FB::VariantList>().push_back(it->second);
} else {
outHeaders[it->first] = FB::VariantList(FB::variant_list_of(it->second));
}
} else {
outHeaders[it->first] = it->second;
}
}
if (success) {
std::string dstr(reinterpret_cast<const char*>(data.get()), size);
callback->InvokeAsync("", FB::variant_list_of
(true)
(outHeaders)
(dstr)
);
} else {
callback->InvokeAsync("", FB::variant_list_of(false));
}
}
开发者ID:NoAntzWk,项目名称:FireBreath,代码行数:25,代码来源:FBTestPluginAPI.cpp
示例2: copy
FileTransferAPIPtr FileManagerAPI::copy(std::string const &sourceUrl, std::string const &targetUrl, FB::JSObjectPtr const &callback) {
FBLOG_DEBUG("FileManagerAPI::copy", "this=" << this << "\t" << "sourceUrl=" << sourceUrl << "\t" << "targetUrl=" << targetUrl << "\t" << "callback=" << callback);
FB::URI sourceUri(sourceUrl);
FB::URI targetUri(targetUrl);
if(FileManagerAPI::isHttp(sourceUri) && FileManagerAPI::isHttp(targetUri)) {
FBLOG_DEBUG("FileManagerAPI::copy", "Can't copy two Remote resources");
callback->InvokeAsync("", FB::variant_list_of(false)("Can't copy two Remote resources"));
return FileTransferAPIPtr();
}
if(FileManagerAPI::isInternal(targetUri)) {
FBLOG_DEBUG("FileManagerAPI::copy", "Can't copy file into Internal resources");
callback->InvokeAsync("", FB::variant_list_of(false)("Can't copy file into Internal resources"));
return FileTransferAPIPtr();
}
if(FileManagerAPI::isHttp(sourceUri) && !isSameHost(sourceUri)) {
FBLOG_DEBUG("FileManagerAPI::copy", "Can't use different host with remote resource (XSS)");
callback->InvokeAsync("", FB::variant_list_of(false)("Can't use different host with remote resource (XSS)"));
return FileTransferAPIPtr();
}
if(FileManagerAPI::isHttp(targetUri) && !isSameHost(targetUri)) {
FBLOG_DEBUG("FileManagerAPI::copy", "Can't use different host with remote resource (XSS)");
callback->InvokeAsync("", FB::variant_list_of(false)("Can't use different host with remote resource (XSS)"));
return FileTransferAPIPtr();
}
FileTransferAPIPtr fileTransfer = getFactory()->getFileTransfer(sourceUri, targetUri, callback);
return fileTransfer;
}
开发者ID:techstormteam,项目名称:08-phonegap-netcastdigital,代码行数:27,代码来源:filemanagerapi.cpp
示例3: exists
void FileManagerAPI::exists(std::string const &url, FB::JSObjectPtr const &callback) {
FBLOG_DEBUG("FileManagerAPI::exists", "this=" << this << "\t" << "url=" << url << "\t" << "callback=" << callback);
FB::URI uri(url);
if(!FileManagerAPI::isFile(uri)) {
FBLOG_DEBUG("FileManagerAPI::exists", "Can't check Remote resource");
callback->InvokeAsync("", FB::variant_list_of(false)("Can't check Remote resource"));
return;
}
try {
std::string pathStr = uriToFile(uri);
if(pathStr.empty()) {
FBLOG_DEBUG("FileManagerAPI::exists", "Invalid path");
callback->InvokeAsync("", FB::variant_list_of(false)("Invalid path"));
return;
}
boost::filesystem::path path(pathStr);
FBLOG_DEBUG("FileManagerAPI::exists", "Test \"" << pathStr << "\"");
bool b = boost::filesystem::exists(path);
callback->InvokeAsync("", FB::variant_list_of(b)(""));
} catch(boost::filesystem::filesystem_error &) {
FBLOG_DEBUG("FileManagerAPI::exists", "Internal error");
callback->InvokeAsync("", FB::variant_list_of(false)("Internal error"));
}
}
开发者ID:techstormteam,项目名称:08-phonegap-netcastdigital,代码行数:25,代码来源:filemanagerapi.cpp
示例4: executeCommandWork
void AsinbowAPI::executeCommandWork(const std::string& command, const FB::JSObjectPtr& callback) {
char buf[4096];
FILE* pipe = popen(
#ifdef _WIN32
utf8_to_ansi(command).c_str(),
#else
command.c_str(),
#endif
"r");
if (!pipe) {
callback->Invoke("", FB::variant_list_of(true)("popen failed!"));
return;
}
std::string result;
int c;
while ((c = fgetc(pipe)) != EOF) {
result += (char)c;
if (c=='\n') {
#ifdef _WIN32
result = ansi_to_utf8(result);
#endif
callback->Invoke("", FB::variant_list_of(false)(result));
result = "";
}
}
pclose(pipe);
callback->Invoke("", FB::variant_list_of(true));
}
开发者ID:asinbow,项目名称:fbTest,代码行数:28,代码来源:AsinbowAPI.cpp
示例5: SetRemoteDescription
void GCPAPI::SetRemoteDescription(const FB::variant& action,
const FB::variant& sdp,
const FB::JSObjectPtr& succCb,
const FB::JSObjectPtr& failCb)
{
GoCast::RtcCenter* pCtr = GoCast::RtcCenter::Instance();
m_onsetsdpsuccessCb = succCb;
m_onsetsdpfailureCb = failCb;
if(false == pCtr->Inited())
{
std::string msg = m_htmlId.convert_cast<std::string>();
msg += ": Failed to init RtcCenter singleton...";
FBLOG_ERROR_CUSTOM("GCPAPI::SetRemoteDescription", msg);
if(NULL != failCb.get())
{
failCb->InvokeAsync("", FB::variant_list_of("RtcCenter init failed"));
}
return;
}
pCtr->SetRemoteDescription(m_htmlId.convert_cast<std::string>(),
m_pSetRemoteSDPObserver,
action.convert_cast<std::string>(),
sdp.convert_cast<std::string>());
}
开发者ID:Bayerner,项目名称:webrtc_plugin,代码行数:27,代码来源:GCPAPI.cpp
示例6: gotDownloadProgram
void btlauncherAPI::gotDownloadProgram(const FB::JSObjectPtr& callback,
std::wstring& program,
std::string& version,
bool success,
const FB::HeaderMap& headers,
const boost::shared_array<uint8_t>& data,
const size_t size) {
TCHAR temppath[500];
DWORD gettempresult = GetTempPath(500, temppath);
if (! gettempresult) {
callback->InvokeAsync("", FB::variant_list_of(false)("GetTempPath")(GetLastError()));
return;
}
std::wstring syspath(temppath);
syspath.append( program.c_str() );
boost::uuids::random_generator gen;
boost::uuids::uuid u = gen();
syspath.append( _T("_") );
std::wstring wversion;
wversion.assign( version.begin(), version.end() );
syspath.append( wversion );
syspath.append( _T("_") );
syspath.append( boost::uuids::to_wstring(u) );
syspath.append(_T(".exe"));
HANDLE hFile = CreateFile( syspath.c_str(), GENERIC_WRITE | GENERIC_EXECUTE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, NULL, NULL );
if (hFile == INVALID_HANDLE_VALUE) {
callback->InvokeAsync("", FB::variant_list_of(false)(GetLastError()));
return;
}
PVOID ptr = (VOID*) data.get();
DWORD written = 0;
BOOL RESULT = WriteFile( hFile, ptr, size, &written, NULL);
CloseHandle(hFile);
if (! RESULT) {
callback->InvokeAsync("", FB::variant_list_of("FILE")(false)(GetLastError()));
return;
}
std::wstring installcommand = std::wstring(syspath);
installcommand.append(_T(" /NOINSTALL /MINIMIZED /HIDE"));
STARTUPINFO info;
PROCESS_INFORMATION procinfo;
memset(&info,0,sizeof(info));
info.cb = sizeof(STARTUPINFO);
/* CreateProcessW can modify installcommand thus we allocate needed memory */
wchar_t * pwszParam = new wchar_t[installcommand.size() + 1];
const wchar_t* pchrTemp = installcommand.c_str();
wcscpy_s(pwszParam, installcommand.size() + 1, pchrTemp);
BOOL bProc = CreateProcess(NULL, pwszParam, NULL, NULL, FALSE, 0, NULL, NULL, &info, &procinfo);
if(bProc) {
callback->InvokeAsync("", FB::variant_list_of("PROCESS")(true)(installcommand.c_str())(GetLastError()));
} else {
callback->InvokeAsync("", FB::variant_list_of("PROCESS")(false)(installcommand.c_str())(GetLastError()));
}
}
开发者ID:bbarrows,项目名称:btlauncher,代码行数:60,代码来源:btlauncherAPI.cpp
示例7: countArrayLength
long FBTestPluginAPI::countArrayLength(const FB::JSObjectPtr &jso)
{
if (!jso->HasProperty("getArray"))
throw FB::invalid_arguments();
FB::VariantList array = jso->GetProperty("getArray").cast<FB::VariantList>();
long len = array.size();// array->GetProperty("length").convert_cast<long>();
return len;
}
开发者ID:scjohn,项目名称:FireBreath,代码行数:8,代码来源:FBTestPluginAPI.cpp
示例8: assertMainThread
int FB::BrowserHost::delayedInvoke(const int delayms, const FB::JSObjectPtr& func,
const FB::VariantList& args, const std::string& fname)
{
assertMainThread();
FB::JSObjectPtr delegate = getDelayedInvokeDelegate();
assert(delegate);
if (fname.empty())
return delegate->Invoke("", FB::variant_list_of(delayms)(func)(args)).convert_cast<int>();
else
return delegate->Invoke("", FB::variant_list_of(delayms)(func)(args)(fname)).convert_cast<int>();
}
开发者ID:gotomypc,项目名称:AmbientLib,代码行数:11,代码来源:BrowserHost.cpp
示例9: assertMainThread
int FB::BrowserHost::delayedInvoke(const int delayms, const FB::JSObjectPtr& func,
const FB::VariantList& args, const std::string& fname)
{
assertMainThread();
FB::JSObjectPtr delegate = getDelayedInvokeDelegate();
if (!delegate)
return -1; // this is wrong (the return is meant to be the result of setTimeout)
if (fname.empty())
return delegate->Invoke("", FB::variant_list_of(delayms)(func)(args)).convert_cast<int>();
else
return delegate->Invoke("", FB::variant_list_of(delayms)(func)(args)(fname)).convert_cast<int>();
}
开发者ID:linkotec,项目名称:FireBreath,代码行数:12,代码来源:BrowserHost.cpp
示例10: cupdateDaemon
void OfficeDriveAPI::cupdateDaemon(FB::JSObjectPtr callback)
{
/*FB::PluginEventSinkPtr eventSinkPtr;
boost::optional<std::string> codeBase = getPlugin()->getParam("codeBase");
std::string codeBaseUrl = "None";
if (codeBase) {
codeBaseUrl = *codeBase;
}
*/
intptr_t ret = -1;
char exePath[512];
memset(&exePath, 0, sizeof(exePath));
char * appData;
#ifdef FB_WIN
appData = getenv("LOCALAPPDATA");
sprintf(exePath, "%s\\OfficeDrive\\dist\Update.exe", appData);
const char *localName[] = {exePath};
char* const localArgs[] = {exePath, NULL};
ret = _spawnv(_P_WAIT, localName[0], localArgs);
#endif
callback->Invoke("",FB::variant_list_of(ret));
}
开发者ID:OfficeDrive,项目名称:OfficeDrive_Plugin,代码行数:28,代码来源:OfficeDriveAPI.cpp
示例11: callbackTest
bool OfficeDriveAPI::callbackTest(FB::JSObjectPtr callback)
{
callback->Invoke("", FB::variant_list_of(""));
m_host->htmlLog("callbackTest success");
return true;
}
开发者ID:OfficeDrive,项目名称:OfficeDrive_Plugin,代码行数:7,代码来源:OfficeDriveAPI.cpp
示例12: setReady
// If you override this, you probably want to call it again, since this is what calls back into the page
// to indicate that we're done.
void PluginCore::setReady()
{
FBLOG_INFO("PluginCore", "Plugin Ready");
// Ensure that the JSAPI object has been created, in case the browser hasn't requested it yet.
getRootJSAPI();
try {
FB::VariantMap::iterator fnd = m_params.find("onload");
if (fnd != m_params.end()) {
FB::JSObjectPtr method = fnd->second.convert_cast<FB::JSObjectPtr>();
method->InvokeAsync("", FB::variant_list_of(getRootJSAPI()));
}
} catch(...) {
// Usually this would be if it isn't a JSObjectPtr or the object can't be called
}
onPluginReady();
}
开发者ID:epitech-labfree,项目名称:FireBreath,代码行数:18,代码来源:PluginCore.cpp
示例13: runProgram
FB::variant btlauncherAPI::runProgram(const std::string& program, const FB::JSObjectPtr& callback) {
FBLOG_INFO("runProgram()", "START");
string exe = this->installPath;
if (program == "SoShare")
exe += SOSHARE_EXE_PATH;
else if (program == "Torque")
exe += TORQUE_EXE_PATH;
else
exe += BTLIVE_EXE_PATH;
FBLOG_INFO("runProgram()", exe.c_str());
struct stat st;
if (stat(exe.c_str(), &st) == -1 || !S_ISREG(st.st_mode)) {
FBLOG_INFO("runProgram()", "stat check problem");
callback->InvokeAsync("", FB::variant_list_of(false)(0));
FBLOG_INFO("runProgram()", "END");
return 0;
}
FB::VariantList list = isRunning(program);
if (list.empty()) {
switch(fork())
{
case -1: {
perror("BTLauncher Run Program Fork");
FBLOG_INFO("runProgram()", "fork - failure");
break;
}
case 0: {
FBLOG_INFO("runProgram()", "fork - child process");
FBLOG_INFO("runProgram()", exe.c_str());
execlp(exe.c_str(), exe.c_str(), NULL);
FBLOG_INFO("runProgram()", "child process exit");
exit(1);
}
default: {
break;
}
}
}
callback->InvokeAsync("", FB::variant_list_of(true)(1));
FBLOG_INFO("runProgram()", "END");
return 0;
}
开发者ID:beride,项目名称:btlauncher,代码行数:45,代码来源:btlauncherAPI.cpp
示例14: gotDownloadProgram
void btlauncherAPI::gotDownloadProgram(const FB::JSObjectPtr& callback,
std::string& program,
bool success,
const FB::HeaderMap& headers,
const boost::shared_array<uint8_t>& data,
const size_t size) {
FBLOG_INFO("gotDownloadProgram()", "START");
FBLOG_INFO("gotDownloadProgram()", program.c_str());
char *tmpname = strdup("/tmp/btlauncherXXXXXX");
mkstemp(tmpname);
ofstream f(tmpname);
if (f.fail()) {
FBLOG_INFO("gotDownloadProgram()", "f.fail");
callback->InvokeAsync("", FB::variant_list_of(false)(-1));
return;
}
f.write((char *)data.get(), size);
f.close();
std::string url;
if (program == "SoShare")
url = SOSHARE_DOWNLOAD_URL;
else if (program == "Torque")
url = TORQUE_DOWNLOAD_URL;
else
url = BTLIVE_DOWNLOAD_URL;
FBLOG_INFO("gotDownloadProgram()", url.c_str());
const char *tarFlags = "-xf";
if (url.find(".gz") != std::string::npos)
tarFlags = "-xzf";
pid_t tarPid;
int status;
switch(tarPid = fork())
{
case -1:
FBLOG_INFO("gotDownloadProgram()", "fork failed");
break;
case 0:
FBLOG_INFO("gotDownloadProgram()", "running tar");
execl("/usr/bin/tar", "tar", tarFlags, tmpname, "-C", this->installPath.c_str(), NULL);
break;
default:
FBLOG_INFO("gotDownloadProgram()", "waitpid");
waitpid(tarPid, &status, 0);
break;
}
runProgram(program, callback);
FBLOG_INFO("gotDownloadProgram()", "END");
}
开发者ID:beride,项目名称:btlauncher,代码行数:56,代码来源:btlauncherAPI.cpp
示例15: printf
void FB::BrowserHost::AsyncHtmlLog(void *logReq)
{
FB::AsyncLogRequest *req = (FB::AsyncLogRequest*)logReq;
try {
FB::DOM::WindowPtr window = req->m_host->getDOMWindow();
if (window->getJSObject()->HasProperty("console")) {
FB::JSObjectPtr obj = window->getProperty<FB::JSObjectPtr>("console");
printf("Logging: %s\n", req->m_msg.c_str());
obj->Invoke("log", FB::variant_list_of(req->m_msg));
}
} catch (const std::exception &) {
// printf("Exception: %s\n", e.what());
// Fail silently; logging should not require success.
FBLOG_TRACE("BrowserHost", "Logging to browser console failed");
return;
}
delete req;
}
开发者ID:epitech-labfree,项目名称:FireBreath,代码行数:19,代码来源:BrowserHost.cpp
示例16: getObjectValues
FB::VariantList FBTestPluginAPI::getObjectValues(const FB::JSObjectPtr& arr)
{
FB::VariantList outArr;
std::map<std::string, FB::variant> inMap;
arr->GetObjectValues(arr, inMap);
for (std::map<std::string, FB::variant>::iterator it = inMap.begin(); it != inMap.end(); it++) {
outArr.push_back(it->second);
}
return outArr;
}
开发者ID:NoAntzWk,项目名称:FireBreath,代码行数:11,代码来源:FBTestPluginAPI.cpp
示例17: gotCheckForUpdate
void btlauncherAPI::gotCheckForUpdate(const FB::JSObjectPtr& callback,
bool success,
const FB::HeaderMap& header,
const boost::shared_array<uint8_t>& data,
const size_t size) {
FBLOG_INFO("gotCheckForUpdate()", "START");
char *tmpname = strdup("/tmp/btlauncherXXXXXX.pkg");
mkstemp(tmpname);
ofstream f(tmpname);
if (f.fail()) {
FBLOG_INFO("gotCheckForUpdate()", "f.fail");
callback->InvokeAsync("", FB::variant_list_of(false)(-1));
return;
}
f.write((char *)data.get(), size);
f.close();
switch(fork())
{
case -1: {
FBLOG_INFO("gotCheckForUpdate()", "fork - failure");
break;
}
case 0: {
FBLOG_INFO("gotCheckForUpdate()", "fork - child process");
FBLOG_INFO("gotCheckForUpdate()", tmpname);
execlp("installer", "installer", "-pkg", tmpname, "-target", "CurrentUserHomeDirectory", NULL);
FBLOG_INFO("gotCheckForUpdate()", "child process exit");
exit(1);
}
default: {
FBLOG_INFO("gotCheckForUpdate()", "fork - parent process");
break;
}
}
callback->InvokeAsync("", FB::variant_list_of(true)(1));
FBLOG_INFO("gotCheckForUpdate()", "END");
}
开发者ID:beride,项目名称:btlauncher,代码行数:41,代码来源:btlauncherAPI.cpp
示例18: has_user_ack
bool ProfileManager::has_user_ack(std::string profilename, FB::DOM::WindowPtr window) {
try {
if (window && window->getJSObject()->HasProperty("location")) {
// Create a reference to the browswer console object
FB::JSObjectPtr obj = window->getProperty<FB::JSObjectPtr>("location");
std::string origin = obj->GetProperty("origin").convert_cast<std::string>();
std::string href = obj->GetProperty("href").convert_cast<std::string>();
// Return the result of authorized domain entry, if found
std::map<std::string, bool>::iterator it = authorized_domains.find(origin);
if (it != authorized_domains.end())
return it->second;
// Ask user
FB::variant ack_result;
std::stringstream ss;
ss << "The following page requests access to the BroadMask profile ";
ss << "'" << profilename << "' :" << endl;
ss << href << endl << endl;
ss << "Do you want to authorize the domain?";
ack_result = window->getJSObject()->Invoke("confirm", FB::variant_list_of(ss.str()));
bool ack = ack_result.convert_cast<bool>();
if (ack == true) {
authorized_domains.insert(std::pair<std::string, bool>(origin, true));
return true;
} else {
return false;
}
}
} catch (exception& e) {
cerr << "[BroadMask ProfileManager] Error getting user ack: " << e.what() << endl;
return false;
}
return false;
}
开发者ID:oliverguenther,项目名称:broadmask-npapi,代码行数:41,代码来源:ProfileManager.cpp
示例19: runProgram
FB::variant btlauncherAPI::runProgram(const std::wstring& program, const FB::JSObjectPtr& callback) {
if (!this->isSupported(program)) {
return _T(NOT_SUPPORTED_MESSAGE);
}
HINSTANCE ret = (HINSTANCE)0;
if (isRunning(program).size() == 0) {
ret = launch_program(program);
callback->InvokeAsync("", FB::variant_list_of(false)(ret));
}
return ret;
}
开发者ID:bbarrows,项目名称:btlauncher,代码行数:12,代码来源:btlauncherAPI.cpp
示例20: mkdir
void FileManagerAPI::mkdir(std::string const &url, FB::JSObjectPtr const &callback) {
FBLOG_DEBUG("FileManagerAPI::mkdir", "this=" << this << "\t" << "url=" << url << "\t" << "callback=" << callback);
FB::URI uri(url);
try {
if(!FileManagerAPI::isFile(uri)) {
FBLOG_DEBUG("FileManagerAPI::mkdir", "Can't create Remote directories");
callback->InvokeAsync("", FB::variant_list_of(false)("Can't create Remote directories"));
return;
}
if(FileManagerAPI::isInternal(uri)) {
FBLOG_DEBUG("FileManagerAPI::mkdir", "Can't create Internal directories");
callback->InvokeAsync("", FB::variant_list_of(false)("Can't create Internal directories"));
return;
}
std::string pathStr = uriToFile(uri);
if(pathStr.empty()) {
FBLOG_DEBUG("FileManagerAPI::mkdir", "Invalid path");
callback->InvokeAsync("", FB::variant_list_of(false)("Invalid path"));
return;
}
boost::filesystem::path path(pathStr);
if(boost::filesystem::exists(path)) {
FBLOG_DEBUG("FileManagerAPI::mkdir", "The path \"" << pathStr << "\" already exists");
callback->InvokeAsync("", FB::variant_list_of(false)("Invalid file"));
return;
}
FBLOG_DEBUG("FileManagerAPI::mkdir", "Make directories \"" << pathStr << "\"");
boost::filesystem::create_directories(path);
callback->InvokeAsync("", FB::variant_list_of(true)(""));
} catch(boost::filesystem::filesystem_error &) {
FBLOG_DEBUG("FileManagerAPI::mkdir", "Internal error");
callback->InvokeAsync("", FB::variant_list_of(false)("Internal error"));
}
}
开发者ID:techstormteam,项目名称:08-phonegap-netcastdigital,代码行数:35,代码来源:filemanagerapi.cpp
注:本文中的fb::JSObjectPtr类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论