void ConvertStoryboard(pugi::xml_document& doc) {
    pugi::xml_node curNode = doc.first_child();

    //  Storyboard XIB file - get topmost controller, then export it
    const char* initialController = curNode.attribute("initialViewController").value();

    for (; curNode; curNode = curNode.next_sibling()) {
        if (curNode.type() == pugi::xml_node_type::node_element) {
            XIBArray* root = new XIBArray();
            root->ScanStoryObjects(curNode);
        }
    }

    XIBObject::ParseAllStoryMembers();

    // Print which XML nodes we did not handle during the parse for diagnostic purpose.
    XIBObject::getDocumentCoverage(doc);

    NIBWriter::ExportController(initialController);

    Plist::dictionary_type viewControllerInfo;
    viewControllerInfo[std::string("UIStoryboardDesignatedEntryPointIdentifier")] =
        std::string("UIViewController-") + std::string(initialController);
    viewControllerInfo[std::string("UIStoryboardVersion")] = (int)1;

    Plist::dictionary_type viewControllerMappings;
    for (auto curController : _g_exportedControllers) {
        viewControllerMappings[curController.first] = curController.second;
    }
    viewControllerInfo[std::string("UIViewControllerIdentifiersToNibNames")] = viewControllerMappings;

    printf("Writing %s\n", GetOutputFilename("Info.plist").c_str());
    Plist::writePlistBinary(GetOutputFilename("Info.plist").c_str(), viewControllerInfo);
}
Beispiel #2
0
void NIBWriter::ExportController(const char *controllerId)
{
    char szFilename[255];

    XIBObject* controller = XIBObject::findReference(controllerId);
    UIViewController* uiViewController = dynamic_cast<UIViewController*>(controller);
    if (!uiViewController) {
        //object isn't really a controller
        printf("Object %s is not a controller\n", controller->stringValue());
        return;
    }

    const char* controllerIdentifier = uiViewController->_storyboardIdentifier;
    if (controllerIdentifier == NULL) {
        //not all viewcontrollers will have a storyboard identifier. If they don't use the controller Id for the key.
        controllerIdentifier = controllerId;
    }

    //  Check if we've already written out the controller
    if (_g_exportedControllers.find(controllerId) != _g_exportedControllers.end()) {
        return;
    }

    sprintf(szFilename, "%s.nib", controllerIdentifier);

    _g_exportedControllers[controllerIdentifier] = controllerIdentifier;

    XIBArray *objects = (XIBArray *) controller->_parent;

    printf("Writing %s\n", GetOutputFilename(szFilename).c_str());
    FILE *fpOut = fopen(GetOutputFilename(szFilename).c_str(), "wb");

    NIBWriter *writer = new NIBWriter(fpOut, NULL, NULL);

    XIBObject *firstResponderProxy = writer->AddProxy("IBFirstResponder");
    XIBObject *ownerProxy = writer->AddProxy("IBFilesOwner");
    XIBObject *storyboard = writer->AddProxy("UIStoryboardPlaceholder");

    XIBArray *arr = (XIBArray *) objects;
    for ( int i = 0; i < arr->count(); i ++ ) {
        XIBObject *curObj = arr->objectAtIndex(i);

        writer->ExportObject(curObj);
        if ( curObj->getAttrib("sceneMemberID") ) {
            if ( strcmp(curObj->getAttrib("sceneMemberID"), "viewController") == 0 ) {
                writer->AddOutletConnection(ownerProxy, curObj, "sceneViewController");
            }
        }
    }

    writer->WriteObjects();

    fclose(fpOut);
}
void MagnatuneDownloadDialog::DownloadFinished() {
  QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
  reply->deleteLater();

  // Close any open file
  download_file_.reset();

  QUrl redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
  if (redirect.isValid()) {
    // Open the output file
    QString output_filename = GetOutputFilename();
    download_file_.reset(new QFile(output_filename));
    if (!download_file_->open(QIODevice::WriteOnly)) {
      ShowError(tr("Couldn't open output file %1").arg(output_filename));
      return;
    }

    // Round and round we go
    redirect.setUserName(service_->username());
    redirect.setPassword(service_->password());

    current_reply_ = network_->get(QNetworkRequest(redirect));

    connect(current_reply_, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(Error(QNetworkReply::NetworkError)));
    connect(current_reply_, SIGNAL(finished()), SLOT(DownloadFinished()));
    connect(current_reply_, SIGNAL(downloadProgress(qint64,qint64)), SLOT(DownloadProgress(qint64,qint64)));
    connect(current_reply_, SIGNAL(readyRead()), SLOT(DownloadReadyRead()));
    return;
  }

  next_row_ ++;
  DownloadNext();
}
void MagnatuneDownloadDialog::MetadataFinished() {
  QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
  reply->deleteLater();

  // The reply isn't valid XML so we can't use QtXML to parse it :(
  QString data = QString::fromUtf8(reply->readAll());

  // Check for errors
  if (data.contains("<ERROR>")) {
    ShowError(tr("There was a problem fetching the metadata from Magnatune"));
    return;
  }

  // Work out what format we want
  QString type;
  switch (ui_->format->currentIndex()) {
    case MagnatuneService::Format_Ogg:     type = "URL_OGGZIP";    break;
    case MagnatuneService::Format_Flac:    type = "URL_FLACZIP";   break;
    case MagnatuneService::Format_Wav:     type = "URL_WAVZIP";    break;
    case MagnatuneService::Format_MP3_VBR: type = "URL_VBRZIP";    break;
    case MagnatuneService::Format_MP3_128: type = "URL_128KMP3ZIP"; break;
  }

  // Parse the XML (lol) to find the URL
  QRegExp re(QString("<%1>([^<]+)</%2>").arg(type, type));
  if (re.indexIn(data) == -1) {
    ShowError(tr("This album is not available in the requested format"));
    return;
  }

  // Munge the URL a bit
  QString url_text = Utilities::DecodeHtmlEntities(re.cap(1));

  QUrl url = QUrl(url_text);
  url.setUserName(service_->username());
  url.setPassword(service_->password());

  qLog(Debug) << "Downloading" << url;

  // Start the actual download
  current_reply_ = network_->get(QNetworkRequest(url));

  connect(current_reply_, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(Error(QNetworkReply::NetworkError)));
  connect(current_reply_, SIGNAL(finished()), SLOT(DownloadFinished()));
  connect(current_reply_, SIGNAL(downloadProgress(qint64,qint64)), SLOT(DownloadProgress(qint64,qint64)));
  connect(current_reply_, SIGNAL(readyRead()), SLOT(DownloadReadyRead()));

  // Close any open file
  download_file_.reset();

  // Open the output file
  QString output_filename = GetOutputFilename();
  download_file_.reset(new QFile(output_filename));
  if (!download_file_->open(QIODevice::WriteOnly)) {
    ShowError(tr("Couldn't open output file %1").arg(output_filename));
  }
}
wxString CompileTargetBase::GetWorkingDir()
{
    if (m_TargetType != ttConsoleOnly && m_TargetType != ttExecutable && m_TargetType != ttDynamicLib)
        return wxEmptyString;
    wxString out;
    if (m_WorkingDir.IsEmpty())
    {
        out = GetOutputFilename();
        return wxFileName(out).GetPath(wxPATH_GET_VOLUME);
    }
    return m_WorkingDir;
}
Beispiel #6
0
bool OBS::StartRecording(bool force)
{
    if (!bRunning || bRecording) return true;
    int networkMode = AppConfig->GetInt(TEXT("Publish"), TEXT("Mode"), 2);
    bool saveToFile = AppConfig->GetInt(L"Publish", L"SaveToFile") != 0;

    bWriteToFile = force || networkMode == 1 || saveToFile;

    // Don't request a keyframe while everything is starting up for the first time
    if(!bStartingUp) videoEncoder->RequestKeyframe();

    String strOutputFile;
    if (bWriteToFile)
        strOutputFile = GetOutputFilename();

    bool success = true;
    if(!bTestStream && bWriteToFile && strOutputFile.IsValid())
    {
        fileStream = CreateFileStream(strOutputFile);

        if(!fileStream)
        {
            Log(TEXT("Warning - OBSCapture::Start: Unable to create the file stream. Check the file path in Broadcast Settings."));
            OBSMessageBox(hwndMain, Str("Capture.Start.FileStream.Warning"), Str("Capture.Start.FileStream.WarningCaption"), MB_OK | MB_ICONWARNING);        
            bRecording = false;
            success = false;
            bRecordingReplayBuffer = false;
        }
        else {
            bRecording = true;
            ReportStartRecordingTrigger();
            lastOutputFile = strOutputFile;
        }
        ConfigureStreamButtons();
    }
    return success;
}
void CResourceCompilerHelper::ProcessIfNeeded(
	const char* originalFilename, 
	char* processedFilename, 
	size_t processedFilenameSizeInBytes)
{
	char sDestFile[512];
	GetOutputFilename(originalFilename, sDestFile, sizeof(sDestFile));

	for(uint32 dwIndex=0;;++dwIndex)		// check for all input files
	{
		char sSrcFile[512];
		GetInputFilename(originalFilename, dwIndex, sSrcFile, sizeof(sSrcFile));

		if(sSrcFile[0] == 0)
		{
			break;					// last input file
		}

		// compile if there is no destination
		// compare date of destination and source , recompile if needed
		// load dds header, check hash-value of the compile settings in the dds file, recompile if needed (not done yet)

		CDebugAllowFileAccess dafa;
		FILE* pDestFile = gEnv->pCryPak->FOpen(sDestFile,"rb");
		FILE* pSrcFile = gEnv->pCryPak->FOpen(sSrcFile,"rb");
		dafa.End();

		// files from the pak file do not count as date comparison do not seem to work there
		if(pDestFile)
		{
			if(gEnv->pCryPak->IsInPak(pDestFile))
			{
				gEnv->pCryPak->FClose(pDestFile);
				pDestFile=0;
			}
		}

		bool bInvokeResourceCompiler=false;

		// is there no destination file?
		if(pSrcFile && !pDestFile)
			bInvokeResourceCompiler=true;

		// if both files exist, is the source file newer?
		if(pDestFile && pSrcFile)
		{
			bInvokeResourceCompiler=true;

			ICryPak::FileTime timeSrc = gEnv->pCryPak->GetModificationTime(pSrcFile);
			ICryPak::FileTime timeDest = gEnv->pCryPak->GetModificationTime(pDestFile);

			if(timeDest>=timeSrc)
				bInvokeResourceCompiler=false;
		}

		if(pDestFile)
		{
			gEnv->pCryPak->FClose(pDestFile);pDestFile=0;
		}
		if(pSrcFile)
		{
			gEnv->pCryPak->FClose(pSrcFile);pSrcFile=0;
		}

		if(bInvokeResourceCompiler)
		{
			// Adjust filename so that they are global.
			char sFullSrcFilename[MAX_PATH];
			gEnv->pCryPak->AdjustFileName( sSrcFile,sFullSrcFilename,0 );
			// call rc.exe
			if(!InvokeResourceCompiler(sFullSrcFilename,false))		// false=no window
			{
				// rc failed
				m_bErrorFlag=true;
				assert(!pSrcFile);		// internal error
				assert(!pDestFile);
				strncpy_s(processedFilename, processedFilenameSizeInBytes, originalFilename, _TRUNCATE);
				return;
			}
		}

		assert(!pSrcFile);		// internal error
		assert(!pDestFile);
	}

	// load without using RC (e.g. TGA)
	strncpy_s(processedFilename, processedFilenameSizeInBytes, sDestFile, _TRUNCATE);
}
Beispiel #8
0
void UIViewController::ConvertStaticMappings(NIBWriter *writer, XIBObject *obj)
{
    Map(writer, obj, propertyMappings, numPropertyMappings);

    XIBArray *segueTemplates = new XIBArray();

    if ( _tabBarItem ) AddOutputMember(writer, "UITabBarItem", _tabBarItem);
    if ( _navigationItem ) AddOutputMember(writer, "UINavigationItem", _navigationItem);
    if ( !_resizesToFullSize ) AddBool(writer, "UIAutoresizesArchivedViewToFullSize", _resizesToFullSize);
    if ( _view ) {
        if ( !_isStory ) {
            AddOutputMember(writer, "UIView", _view);
        } else {
            ScanForSegues(segueTemplates, this);

            XIBDictionary *externalObjects = new XIBDictionary();

            char szNibName[255];

            sprintf(szNibName, "%s-view-%s", _id, _view->_id);
            AddString(writer, "UINibName", szNibName);

            char szOutputName[255];
            sprintf(szOutputName, "%s.nib", szNibName);
            printf("Writing %s\n", GetOutputFilename(szOutputName).c_str());
            FILE *fpOut = fopen(GetOutputFilename(szOutputName).c_str(), "wb");
    
            NIBWriter *viewWriter = new NIBWriter(fpOut, externalObjects, _view);
            viewWriter->ExportObject(_view);

            XIBObject *ownerProxy = viewWriter->AddProxy("IBFilesOwner");
            viewWriter->_topObjects->AddMember(NULL, ownerProxy);
            XIBObject *firstResponderProxy = viewWriter->AddProxy("IBFirstResponder");
            viewWriter->_topObjects->AddMember(NULL, firstResponderProxy);

            //  Add view connection
            viewWriter->AddOutletConnection(ownerProxy, _view, "view");

            viewWriter->WriteObjects();
            fclose(fpOut);

            if ( externalObjects->_members.size() > 1 ) AddOutputMember(writer, "UIExternalObjectsTableForViewLoading", externalObjects);
        }
    }
    if ( _parentViewController ) {
        AddOutputMember(writer, "UIParentViewController", _parentViewController);
    }
    if ( _isStory ) {
        XIBObject *storyboard = writer->AddProxy("UIStoryboardPlaceholder");
        writer->AddOutletConnection(this, storyboard, "storyboard");
        
        for ( int i = 0; i < segueTemplates->count(); i ++ ) {
            UIStoryboardSegue *curSegue = (UIStoryboardSegue *) segueTemplates->objectAtIndex(i);

            writer->AddOutletConnection(curSegue, this, "viewController");
        }
        if ( segueTemplates->count() > 0 ) {
            AddOutputMember(writer, "UIStoryboardSegueTemplates", segueTemplates);

            for ( int i = 0; i < segueTemplates->count(); i ++ ) {
                UIStoryboardSegue *curSegue = (UIStoryboardSegue *) segueTemplates->objectAtIndex(i);

                NIBWriter::ExportController(curSegue->getAttrib("destination"));
            }
        }
    }
    if ( _childViewControllers->count() > 0 ) {
        AddOutputMember(writer, "UIChildViewControllers", _childViewControllers);
    }
    if ( _viewControllers->count() > 0 ) {
        AddOutputMember(writer, "UIViewControllers", _viewControllers);
    }
    ObjectConverterSwapper::ConvertStaticMappings(writer, obj);
}