void register_all_cocos2dx_extension_manual(JSContext* cx, JS::HandleObject global)
{
    JS::RootedObject am(cx, jsb_cocos2d_extension_AssetsManagerEx_prototype); 
    JS_DefineFunction(cx, am, "retain", js_cocos2dx_ext_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);
    JS_DefineFunction(cx, am, "release", js_cocos2dx_ext_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);
    JS::RootedObject manifest(cx, jsb_cocos2d_extension_Manifest_prototype); 
    JS_DefineFunction(cx, manifest, "retain", js_cocos2dx_ext_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);
    JS_DefineFunction(cx, manifest, "release", js_cocos2dx_ext_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);
    
    //JS_DefineFunction(cx, jsb_cocos2d_extension_AssetsManager_prototype, "updateAssets", js_cocos2dx_ext_AssetsManager_updateAssets, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
    //JS_DefineFunction(cx, jsb_cocos2d_extension_AssetsManager_prototype, "getFailedAssets", js_cocos2dx_ext_AssetsManager_getFailedAssets, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);
    
    JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_extension_ScrollView_prototype), "setDelegate", js_cocos2dx_CCScrollView_setDelegate, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
    JS::RootedObject tableview(cx, jsb_cocos2d_extension_TableView_prototype);
    JS_DefineFunction(cx, tableview, "setDelegate", js_cocos2dx_CCTableView_setDelegate, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
    JS_DefineFunction(cx, tableview, "setDataSource", js_cocos2dx_CCTableView_setDataSource, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
    JS_DefineFunction(cx, tableview, "_init", js_cocos2dx_CCTableView_init, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
    JS::RootedObject control(cx, jsb_cocos2d_extension_Control_prototype);
    JS_DefineFunction(cx, control, "addTargetWithActionForControlEvents", js_cocos2dx_CCControl_addTargetWithActionForControlEvents, 3, JSPROP_ENUMERATE | JSPROP_PERMANENT);
    JS_DefineFunction(cx, control, "removeTargetWithActionForControlEvents", js_cocos2dx_CCControl_removeTargetWithActionForControlEvents, 3, JSPROP_ENUMERATE | JSPROP_PERMANENT);
    
    JS::RootedObject tmpObj(cx, anonEvaluate(cx, global, "(function () { return cc.TableView; })()").toObjectOrNull());
    JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCTableView_create, 3, JSPROP_READONLY | JSPROP_PERMANENT);
    
    
    JS::RootedObject jsbObj(cx);
    create_js_root_obj(cx, global, "jsb", &jsbObj);
    
    JS_DefineFunction(cx, jsbObj, "loadRemoteImg", js_load_remote_image, 2, JSPROP_READONLY | JSPROP_PERMANENT);
}
Esempio n. 2
0
signed fdmanifest (signed fd, char const * filename, struct nvm_header2 * nvm_header, unsigned module)

{
	off_t extent = LE32TOH (nvm_header->ImageLength);
	void * memory = malloc (extent);
	if (!memory)
	{
		error (1, 0, FILE_CANTLOAD, filename);
	}
	if (read (fd, memory, extent) != (signed)(extent))
	{
		error (1, errno, FILE_CANTREAD, filename);
	}
	if (lseek (fd, (off_t)(0) - extent, SEEK_CUR) == -1)
	{
		error (1, errno, FILE_CANTSEEK, filename);
	}
	printf ("------- %s (%d) -------\n", filename, module);
	if (manifest (memory, extent))
	{
		error (1, 0, "Bad manifest: %s", filename);
	}
	free (memory);
	return (0);
}
Esempio n. 3
0
void CreateManifestForModule(std::wstring &fileName, bool doTrace, std::wstring assemblyName, std::wstring assemblyVersion, bool generateHash, std::wstring outputFileName, bool directoryMode = false)
{
    ManifestWriter manifest(assemblyName, assemblyVersion);

    manifest.AddFileSection(fileName, generateHash);
    manifest.ProcessData(CaptureManifestForModule(fileName, doTrace));

    manifest.WriteToFile(outputFileName);
}
Esempio n. 4
0
void RelaysPlugin::onInstalled()
{
	qff::MainWindow *fwk = qff::MainWindow::frameWork();
	m_partWidget = new ThisPartWidget();
	fwk->addPartWidget(m_partWidget, manifest()->featureId());

	connect(eventPlugin(), &Event::EventPlugin::dbEventNotify, this, &RelaysPlugin::onDbEventNotify);

	emit nativeInstalled();
}
Esempio n. 5
0
bool isManifestFileValid(const char *filename)
{
    if (!checkFileExists(filename))
    {
        ERRLOG("Error: MANIFEST file '%s' does not exist", filename);
        return false;
    }

    ResourceManifest manifest(filename);
    return manifest.checkResourceFilesExist();
}
Esempio n. 6
0
void 
Powerup::Spawn (void)
{
	if (type < 0 || MAX_POWERUP <= type)
	{
		Msg ("Bad powerup type; removing...\n");
		Remove ();
	}
	Precache ();
	manifest ();
}
Esempio n. 7
0
void BitmapLoader::doLoadManifest()
{
    wxString targetFile;
    if(ExtractFileFromZip(
           m_zipPath.GetFullPath(), wxT("manifest.ini"), clStandardPaths::Get().GetUserDataDir(), targetFile)) {
        // we got the file extracted, read it
        wxFileName manifest(targetFile);
        wxFFile fp(manifest.GetFullPath(), wxT("r"));
        if(fp.IsOpened()) {

            wxString content;
            fp.ReadAll(&content);

            m_manifest.clear();
            wxArrayString entries = wxStringTokenize(content, wxT("\n"), wxTOKEN_STRTOK);
            for(size_t i = 0; i < entries.size(); i++) {
                wxString entry = entries[i];
                entry.Trim().Trim(false);

                // empty?
                if(entry.empty())
                    continue;

                // comment?
                if(entry.StartsWith(wxT(";")))
                    continue;

                wxString key = entry.BeforeFirst(wxT('='));
                wxString val = entry.AfterFirst(wxT('='));
                key.Trim().Trim(false);
                val.Trim().Trim(false);

                wxString key16, key24;
                key16 = key;
                key24 = key;

                key16.Replace(wxT("<size>"), wxT("16"));
                key24.Replace(wxT("<size>"), wxT("24"));

                key16.Replace(wxT("."), wxT("/"));
                key24.Replace(wxT("."), wxT("/"));

                m_manifest[key16] = val;
                m_manifest[key24] = val;
            }

            fp.Close();
            wxRemoveFile(manifest.GetFullPath());
        }
        wxRemoveFile(targetFile);
    }
}
Esempio n. 8
0
bool ReceiptsPlugin::printCard(int card_id)
{
	qfLogFuncFrame() << "card id:" << card_id;
	QF_TIME_SCOPE("ReceiptsPlugin::printCard()");
	try {
		QVariantMap dt = readCardTablesData(card_id);
		receiptsPrinter()->printReceipt(manifest()->homeDir() + "/reports/sicard.qml", dt);
		return true;
	}
	catch(const qf::core::Exception &e) {
		qfError() << e.toString();
	}
	return false;
}
Esempio n. 9
0
void ReceiptsPlugin::previewReceipt_classic(int card_id)
{
	qfLogFuncFrame() << "card id:" << card_id;
	//qfInfo() << "previewReceipe_classic, card id:" << card_id;
	auto *w = new qf::qmlwidgets::reports::ReportViewWidget();
	w->setPersistentSettingsId("cardPreview");
	w->setWindowTitle(tr("Receipt"));
	w->setReport(manifest()->homeDir() + "/reports/receiptClassic.qml");
	QVariantMap dt = receiptTablesData(card_id);
	for(auto key : dt.keys())
		w->setTableData(key, dt.value(key));
	qff::MainWindow *fwk = qff::MainWindow::frameWork();
	qf::qmlwidgets::dialogs::Dialog dlg(fwk);
	dlg.setCentralWidget(w);
	dlg.exec();
}
Esempio n. 10
0
string Utility::importMedia(string pathname) {
  string container;
  
  if(file::exists(pathname) && file::size(pathname) <= 0x10000) {
    // Check if it's one of the system ROMs
    if(auto manifest = program->getUserResource("Nintendo DS.sys/manifest.bml")) {
      auto elem     = Markup::Document(vectorstream(manifest()).text());
      auto contents = file::read(pathname);
      auto hash     = sha256(contents.data(), contents.size());
      auto sysfolder = program->savePath("Nintendo DS.sys/");
      
      if(hash == elem["system/memory/arm9/sha256"].text()) {
        string dest = {sysfolder, elem["system/memory/arm9/data"].text()};
        file::write(dest, contents);
        return "<system>";
      }
      else if(hash == elem["system/memory/arm7/sha256"].text()) {
        string dest = {sysfolder, elem["system/memory/arm7/data"].text()};
        file::write(dest, contents);
        return "<system>";
      }
    }
  }
  
  if(!NintendoDS::validateHeader(filestream(pathname, file::mode::read))) {
    MessageWindow().setTitle("Import failed").setText(
      {"Couldn't import ",pathname,".\n"
       "\n"
       "This file doesn't look like a Nintendo DS title.\n"})
      .error();
    return "";
  }
  else if(!NintendoDS::importROMImage(container, libraryPath(), pathname)) {
    MessageWindow().setTitle("Import failed").setText(
      {"Couldn't import ",pathname,".\n"
       "\n"
       "Check to see if you've got sufficient permissions and disk space."})
      .error();
    return "";
  }
  return container;
}
Esempio n. 11
0
void CompetitorsPlugin::onInstalled()
{
	qff::MainWindow *fwk = qff::MainWindow::frameWork();
	m_partWidget = new ThisPartWidget();
	fwk->addPartWidget(m_partWidget, manifest()->featureId());
	{
		m_registrationsDockWidget = new qff::DockWidget(nullptr);
		m_registrationsDockWidget->setObjectName("registrationsDockWidget");
		m_registrationsDockWidget->setWindowTitle(tr("Registrations"));
		fwk->addDockWidget(Qt::RightDockWidgetArea, m_registrationsDockWidget);
		m_registrationsDockWidget->hide();
		connect(m_registrationsDockWidget, &qff::DockWidget::visibilityChanged, this, &CompetitorsPlugin::onRegistrationsDockVisibleChanged);

		auto *a = m_registrationsDockWidget->toggleViewAction();
		//a->setCheckable(true);
		a->setShortcut(QKeySequence("ctrl+shift+R"));
		fwk->menuBar()->actionForPath("view")->addActionInto(a);
	}
	emit nativeInstalled();
}
Esempio n. 12
0
void CreateManifestForDirectory(std::wstring &directoryPath, bool doTrace, std::wstring assemblyName, std::wstring assemblyVersion, bool generateHash, std::wstring outputFileName)
{
    int size = GetCurrentDirectory(0, 0);

    std::wstring initialDirectory;
    initialDirectory.resize(size - 1);

    GetCurrentDirectory(size, &*initialDirectory.begin());
    if (!SetCurrentDirectory(directoryPath.c_str()))
    {
        std::wcout << L"SetCurrentDirectory failed!, GetLastError: 0x" << std::hex << GetLastError() << std::endl;
    }

    WIN32_FIND_DATA findData = {0};
    HANDLE findHandle = FindFirstFile(L"*.*", &findData);

    ManifestWriter manifest(assemblyName, assemblyVersion);
    while (FindNextFile(findHandle, &findData) != 0) 
    {
        std::wstring file = findData.cFileName;

        if (file == L".." || file == L".")
        {
            continue;
        }

        Interceptor::ValuesListType data = CaptureManifestForModule(file, doTrace);

        if (data.size())
        {
            manifest.AddFileSection(file, generateHash);
            manifest.ProcessData(data);
        }
    }

    manifest.WriteToFile(outputFileName);

    FindClose(findHandle);
    SetCurrentDirectory(initialDirectory.c_str());
}
Esempio n. 13
0
static signed nvmchain2 (void const * memory, size_t extent, char const * filename, flag_t flags)

{
	struct nvm_header2 * nvm_header;
	unsigned module = 0;
	uint32_t origin = ~0;
	uint32_t offset = 0;
	uint32_t length = 0;
	do
	{
		nvm_header = (struct nvm_header2 *)((char *)(memory) + offset);
		if (LE16TOH (nvm_header->MajorVersion) != 1)
		{
			if (_allclr (flags, NVM_SILENCE))
			{
				error (0, errno, NVM_HDR_VERSION, filename, module);
			}
			return (-1);
		}
		if (LE16TOH (nvm_header->MinorVersion) != 1)
		{
			if (_allclr (flags, NVM_SILENCE))
			{
				error (0, errno, NVM_HDR_VERSION, filename, module);
			}
			return (-1);
		}
		if (LE32TOH (nvm_header->PrevHeader) != origin)
		{
			if (_allclr (flags, NVM_SILENCE))
			{
				error (0, errno, NVM_HDR_LINK, filename, module);
			}
			return (-1);
		}
		if (checksum32 (nvm_header, sizeof (* nvm_header), 0))
		{
			if (_allclr (flags, NVM_SILENCE))
			{
				error (0, 0, NVM_HDR_CHECKSUM, filename, module);
			}
			return (-1);
		}
		origin = offset;
		offset += sizeof (* nvm_header);
		extent -= sizeof (* nvm_header);
		length = LE32TOH (nvm_header->ImageLength);
		if (_anyset (flags, NVM_VERBOSE))
		{
			printf ("------- %s (%d) -------\n", filename, module);
			nvmpeek2 (nvm_header);
		}
		if (LE32TOH (nvm_header->ImageType) == NVM_IMAGE_MANIFEST)
		{
			if (_anyset (flags, NVM_MANIFEST))
			{
				printf ("------- %s (%d) -------\n", filename, module);
				manifest ((char *)(memory) + offset, length);
				return (0);
			}
		}
		if (checksum32 ((char *)(memory) + offset, length, nvm_header->ImageChecksum))
		{
			if (_allclr (flags, NVM_SILENCE))
			{
				error (0, errno, NVM_IMG_CHECKSUM, filename, module);
			}
			return (-1);
		}
		offset += length;
		extent -= length;
		module++;
	}
	while (~nvm_header->NextHeader);
	if (extent)
	{
		if (_allclr (flags, NVM_SILENCE))
		{
			error (0, errno, NVM_HDR_LINK, filename, module);
		}
	}
	return (0);
}
Esempio n. 14
0
void ReceiptsPlugin::printReceipt_classic(int card_id)
{
	qfLogFuncFrame() << "card id:" << card_id;
	QVariantMap dt = receiptTablesData(card_id);
	receiptsPrinter()->printReceipt(manifest()->homeDir() + "/reports/receiptClassic.qml", dt);
}
Esempio n. 15
0
int main(int argc, const char *argv[]) {
	// Needs 3 arguments
	if (argc != 4) {
		std::cout << "Usage: <manifest>[in] <c++ file>[out] <header>[out]" << std::endl;
		return 1;
	}

	std::cout << "Manifest: " << argv[1] << "  CPP: " << argv[2] << "  Header: " << argv[3] << std::endl;

	std::ifstream file_manifest(argv[1]);
	std::ofstream file_cpp(argv[2]);
	std::ofstream file_h(argv[3]);

	if (!file_manifest.good()) {
		std::cout << "Failed to open manifest" << std::endl;
		return 1;
	}

	if (!file_cpp.good()) {
		std::cout << "Failed to open output CPP file" << std::endl;
		return 1;
	}

	if (!file_h.good()) {
		std::cout << "Failed to open output H file" << std::endl;
		return 1;
	}

	// If the manifest has a path use that as the base for finding files.
	std::string manifest(argv[1]);
	std::string path_base;
	std::string::size_type pos = manifest.rfind('/');
	if (pos != std::string::npos) {
		path_base = manifest.substr(0, pos+1);
	}

	file_cpp << "#include \"libresrc.h\"\n";

	std::string file;
	while (std::getline(file_manifest, file)) {
		if (file.empty()) continue;

		std::ifstream ifp((path_base + file).c_str(), std::ios_base::binary);

		if (!ifp.is_open()) {
			std::cout << "Error opening file: " << file << std::endl;
			return 1;
		}

		clean(file);
		file_cpp << "const unsigned char " << file << "[] = {";

		size_t length = 0;
		for (std::istreambuf_iterator<char> it(ifp), end; it != end; ++it) {
			if (length > 0) file_cpp << ",";
			file_cpp << (unsigned int)(unsigned char)*it;
			++length;
		}

		file_cpp << "};\n";

		file_h << "extern const unsigned char " << file << "[" << length << "];\n";
	}

	return 0;
}
Esempio n. 16
0
void addManifestResourcesToArchive(IPropertyTree *archive, const char *filename)
{
    ResourceManifest manifest(filename);
    manifest.addToArchive(archive);
}
Esempio n. 17
0
/**
 * Parses manifest file and checks that files described in manifest exist, also
 * checks that no extra file do exist that are not described in manifest.xml.
 *
 * Note: If non-ascii characters are present in XML data, we depend on the LANG variable to be set properly 
 * (see iconv --list for the list of supported encoding values for libiconv).
 *
 * @param path directory on disk of the BDOC container.
 * @throws IOException exception is thrown if the manifest.xml file parsing failed.
 * @throws BDocException
 */
void digidoc::BDoc::parseManifestAndLoadFiles(std::string path) throw(IOException, BDocException)
{
    DEBUG("BDoc::readManifest(path = '%s')", path.c_str());

    try
    {
        // Parse manifest file.
        std::string fileName = util::File::path(path, "META-INF/manifest.xml");
        xml_schema::Properties properties;
        properties.schema_location(MANIFEST_NAMESPACE, Conf::getInstance()->getManifestXsdPath());
        std::auto_ptr<manifest::Manifest> manifest(manifest::manifest(fileName, xml_schema::Flags::dont_initialize, properties));

        // Extract and validate file list from manifest.
        std::set<std::string> manifestFiles;
        bool mimetypeChecked = false;
        for(manifest::Manifest::File_entrySequence::const_iterator iter = manifest->file_entry().begin(); iter != manifest->file_entry().end(); iter++)
        {
            DEBUG("full_path = '%s', media_type = '%s'", iter->full_path().c_str(), iter->media_type().c_str());
            // Check container mimetype.
            if(std::string("/").compare(iter->full_path()) == 0)
            {
                if(mimetypeChecked)
                {
                    THROW_BDOCEXCEPTION("Manifest has more than one container media type defined.");
                }

                if(getMimeType().compare(iter->media_type()) != 0)
                {
                    THROW_BDOCEXCEPTION("Manifest has incorrect BDCO container media type defined '%s', expecting '%s'.", iter->media_type().c_str(), getMimeType().c_str());
                }

                DEBUG("BDOC mimetype OK");
                mimetypeChecked = true;
                continue;
            }

            // Check that file reference is not defined already and add relative file reference to set.
            if(manifestFiles.find(iter->full_path()) != manifestFiles.end())
            {
                THROW_BDOCEXCEPTION("Manifest multiple entries defined for file '%s'.", iter->media_type().c_str());
            }
            manifestFiles.insert(iter->full_path());

            // Add document to documents list.
            if(iter->full_path().find_first_of("/") == std::string::npos)
            {
                if(!util::File::fileExists(util::File::path(path, iter->full_path())))
                {
                    THROW_BDOCEXCEPTION("File described in manifest '%s' does not exist in BDOC container.", iter->full_path().c_str());
                }
                documents.push_back(Document(util::File::path(path, iter->full_path()), iter->media_type()));
                continue;
            }

            // Add signature to signatures list.
            DEBUG("%s :: %u", iter->full_path().c_str(), iter->full_path().find_first_of("META-INF/"));
            std::string signatureFileName = (iter->full_path().substr((iter->full_path().find('/'))+1));

            if(iter->full_path().find_first_of("META-INF/") == 0)
            {
                DEBUG("signature filename :: '%s'", signatureFileName.c_str());

                if(signatureFileName.find_first_of("/") != std::string::npos)
                {
                    THROW_BDOCEXCEPTION("Unexpected file described in manifest '%s'.", iter->full_path().c_str());
                }

                if(!util::File::fileExists(util::File::path(util::File::path(path, "META-INF"), signatureFileName)))
                {
                    THROW_BDOCEXCEPTION("File described in manifest '%s' does not exist in BDOC container.", iter->full_path().c_str());
                }

                std::string signaturePath = util::File::path(util::File::path(path, "META-INF"), signatureFileName);    

                try
                {
                    if(SignatureBES::MEDIA_TYPE == iter->media_type())
                    {
                        signatures.push_back(new SignatureBES(signaturePath, *this));
                    }
                    else if(SignatureTM::MEDIA_TYPE == iter->media_type())
                    {
                        signatures.push_back(new SignatureTM(signaturePath, *this));
                    }
                    else
                    {
                        THROW_BDOCEXCEPTION("Unknown signature media type '%s'.", iter->media_type().c_str());
                    }
                }
                catch(const SignatureException& e)
                {
                    THROW_BDOCEXCEPTION_CAUSE(e, "Failed to parse signature '%s', type '%s'.", signaturePath.c_str(), iter->media_type().c_str());
                }

                continue;
            }

            // Found unexpected file description in manifest.
            THROW_BDOCEXCEPTION("Unexpected file description found in container manifest.");
        }

        if(!mimetypeChecked)
        {
            THROW_BDOCEXCEPTION("Manifest file does not have BDOC media type described.");
        }

        // Check that there are no unexpected files in container.
        std::vector<std::string> containerFiles = util::File::listFiles(path, true, true, true);
        for(std::vector<std::string>::const_iterator iter = containerFiles.begin(); iter != containerFiles.end(); iter++)
        {

            std::string containerFile = *iter;
            if(std::string("mimetype").compare(containerFile) == 0
            || std::string("META-INF/manifest.xml").compare(containerFile) == 0)
            {
                continue;
            }

            std::replace(containerFile.begin(), containerFile.end(), '\\', '/');
            if(manifestFiles.find(containerFile) == manifestFiles.end())
            {
                THROW_BDOCEXCEPTION("File '%s' found in BDOC container is not described in manifest.", containerFile.c_str());
            }
        }
    }
    catch(const xml_schema::Exception& e)
    {
        std::ostringstream oss;
        oss << e;
        THROW_IOEXCEPTION("Failed to parse manifest XML: %s", oss.str().c_str());
    }
}