//-----------------------------------------------------------------------------
// Re-do the command
//-----------------------------------------------------------------------------
MStatus CVstSmdIOCmd::redoIt()
{
	MStatus retVal;

	const MArgDatabase &mArgDatabase( m_undo.ArgDatabase() );

	if ( mArgDatabase.isFlagSet( kOptHelp ) )
	{
		PrintHelp();
	}
	else if ( mArgDatabase.isFlagSet( kOptExport ) )
	{
		retVal = DoExport( mArgDatabase );
	}
	else if ( mArgDatabase.isFlagSet( kOptImport ) )
	{
		retVal = DoImport( mArgDatabase );
	}
	else
	{
		MGlobal::displayError( "None of -help, -export or -import specified... nothing to do" );
		retVal = MS::kFailure;
	}

	return retVal;
}
Esempio n. 2
0
void MainWnd_OnImport(HWND hwnd)
{
    OPENFILENAMEW ofn = {0};
    WCHAR szFile[MAX_PATH] = L"";
    WCHAR szImportTitle[MAX_STRING];
    WCHAR szCannotImport[MAX_STRING];
    WCHAR szImportFilter[MAX_STRING];
    LoadStringW(g_hInstance, IDS_IMPORT, szImportTitle, _countof(szImportTitle));
    LoadStringW(g_hInstance, IDS_CANTIMPORT, szCannotImport, _countof(szCannotImport));
    LoadStringW(g_hInstance, IDS_INPFILTER, szImportFilter, _countof(szImportFilter));
    MakeFilter(szImportFilter);

    ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
    ofn.hwndOwner = hwnd;
    ofn.lpstrFilter = szImportFilter;
    ofn.lpstrFile = szFile;
    ofn.nMaxFile = _countof(szFile);
    ofn.lpstrTitle = szImportTitle;
    ofn.Flags = OFN_DONTADDTORECENT | OFN_ENABLESIZING |
                OFN_EXPLORER | OFN_FILEMUSTEXIST |
                OFN_HIDEREADONLY | OFN_LONGNAMES |
                OFN_PATHMUSTEXIST;
    ofn.lpstrDefExt = L"reg";
    if (GetOpenFileNameW(&ofn))
    {
        if (!DoImport(hwnd, szFile))
        {
            MessageBoxW(hwnd, szCannotImport, g_szTitle, MB_ICONERROR);
        }
    }
}
Esempio n. 3
0
ActionProc(sUIActionNotify_base * anBase) {
  sUIActionNotify_2params * an = (anBase->s_size>=sizeof(sUIActionNotify_2params))?static_cast<sUIActionNotify_2params*>(anBase):0;

  if ((anBase->act.id & IMIB_) == IMIB_CFG) return ActionCfgProc(anBase); 
  switch (anBase->act.id) {
	  case IMIA_MAIN_CFG_EXPIMP_ECFG: 
		  ACTIONONLY(anBase);
		  DoExport(DTCFG);
		  break;
	  case IMIA_MAIN_CFG_EXPIMP_ECNT: 
		  ACTIONONLY(anBase);
		  DoExport(DTCNT);
		  break;
	  case IMIA_MAIN_CFG_EXPIMP_ECNTSEL: {
		  ACTIONONLY(anBase);
		  int c = ICMessage(IMI_LST_SELCOUNT);
		  tAllowIDs allow;
		  for (int i=0; i<c; i++) {
			  int id = ICMessage(IMI_LST_GETSELPOS , i);
			  allow.push_back(id);
		  }
		  DoExport(DTCNT , allow);
		  break;}
	  case IMIA_MAIN_CFG_EXPIMP_IMPORT: 
		  ACTIONONLY(anBase);
		  DoImport();
		  break;
    
  }
  return 0;
}
Esempio n. 4
0
void WorkspaceWork::DoImport(const String& dir, const String& mask, bool sep, Progress& pi, bool tree)
{
	if(tree)
		DoImportTree(dir, mask, sep, pi);
	else
		DoImport(dir, mask, sep, pi);
}
Esempio n. 5
0
int __stdcall IMessageProc(sIMessage_base * msgBase) {
    sIMessage_2params * msg = (msgBase->s_size>=sizeof(sIMessage_2params))?static_cast<sIMessage_2params*>(msgBase):0;
    switch (msgBase->id) {
    /* Wiadomoœci na które TRZEBA odpowiedzieæ */
    case IM_PLUG_NET:        return NET_EXPIMP; // Zwracamy wartoœæ NET, która MUSI byæ ró¿na od 0 i UNIKATOWA!
	case IM_PLUG_TYPE:       return IMT_UI|IMT_CONFIG; // Zwracamy jakiego typu jest nasza wtyczka (które wiadomoœci bêdziemy obs³ugiwaæ)
    case IM_PLUG_VERSION:    return 0; // Wersja wtyczki tekstowo major.minor.release.build ...
    case IM_PLUG_SDKVERSION: return KONNEKT_SDK_V;  // Ta linijka jest wymagana!
    case IM_PLUG_SIG:        return (int)"EXPIMP"; // Sygnaturka wtyczki (krótka, kilkuliterowa nazwa)
    case IM_PLUG_CORE_V:     return (int)"W98"; // Wymagana wersja rdzenia
    case IM_PLUG_UI_V:       return 0; // Wymagana wersja UI
    case IM_PLUG_NAME:       return (int)"exPiMP"; // Pe³na nazwa wtyczki
    case IM_PLUG_NETNAME:    return 0; // Nazwa obs³ugiwanej sieci (o ile jak¹œ sieæ obs³uguje)
    case IM_PLUG_INIT:       Plug_Init(msg->p1,msg->p2);return Init();
    case IM_PLUG_DEINIT:     Plug_Deinit(msg->p1,msg->p2);return DeInit();

    case IM_SETCOLS:     return ISetCols();

    case IM_UI_PREPARE:      return IPrepare();
    case IM_START:           return IStart();
    case IM_END:             return IEnd();

    case IM_UIACTION:        return ActionProc((sUIActionNotify_base*)msg->p1);

	case IM_PLUG_ARGS: {
		sIMessage_plugArgs * pa = static_cast<sIMessage_plugArgs*> (msgBase);
		if (pa->argc < 2) return 0;
		const char * import_ = getArgV(pa->argv+1 , pa->argc-1 , "-import" , true);
		if (import_ && *import_) {
			CStdString import = import_;
			if (import.find("expimp:")==0) {
				import = import.substr(import.find(':') + 1);
			}
			DoImport(import);		
		}
		return 0;}

    /* Tutaj obs³ugujemy wszystkie pozosta³e wiadomoœci */

    default:
        if (Ctrl) Ctrl->setError(IMERROR_NORESULT);
        return 0;

 }
 return 0;
}
Esempio n. 6
0
void OpURLImport::Do(OpDescriptor*)
{
	//First display our Import from URL dialog and get a filename from it
	WebAddress urlToGet;
	
	BOOL ok=URLImportDlg::OpenAndGetURL(&urlToGet);

	//And if the user clicked OK
	if (ok)
	{

		//So, is the URL we've got back a local filename?
		if (urlToGet.IsLocalFile())
		{
			//Yes. So get it as a pathname
			PathName pthToGet=urlToGet.GetPathName();

			//And first get a pointer to the All filter
			Filter* pAllFilter=GetAllFilter();

			//And if we found it
			if (pAllFilter)
			{
				//Then import the pathname
				String_256 strToGet=pthToGet.GetPath();

				DoImport(pthToGet, pAllFilter, &strToGet);
			}

		}
		else
		{
			//No, it's a URL.

			//So download it
			ImportURL(urlToGet);
		}
	}





}
Esempio n. 7
0
void
SCMImportWindow::MessageReceived(BMessage *msg)
{
	switch (msg->what)
	{
		case M_USE_PROVIDER:
		{
			SCMProjectImporter *importer = fProviderMgr.ImporterAt(
												fProviderField->Menu()->IndexOf(
													fProviderField->Menu()->FindMarked()));
			if (importer)
				SetProvider(importer);
			break;
		}
		case M_USE_CUSTOM_PROVIDER:
		{
			SetProvider(NULL);
			break;
		}
		case M_TOGGLE_ANONYMOUS:
		{
			fUserNameBox->SetEnabled(fAnonymousBox->Value() != B_CONTROL_ON);
			UpdateCommand();
			break;
		}
		case M_UPDATE_COMMAND:
		{
			UpdateCommand();
			break;
		}
		case M_SCM_IMPORT:
		{
			DoImport();
			break;
		}
		default:
		{
			DWindow::MessageReceived(msg);
			break;
		}
	}
}
Esempio n. 8
0
void WorkspaceWork::Import()
{
	String active = GetActivePackage();
	if(active.IsEmpty()) return;
	ImportDlg dlg;
	if(dlg.Execute() != IDOK)
		return;
	Progress pi("Importing file %d");
	int fci = filelist.GetCursor();
	int cs = filelist.GetSbPos();
	try {
		DoImport(~dlg.folder, ~dlg.files, false, pi, ~dlg.tree);
	}
	catch(String msg) {
		if(!msg.IsEmpty())
			Exclamation(msg);
	}
	SaveLoadPackage(false);
	filelist.SetSbPos(cs);
	filelist.SetCursor(fci >= 0 ? fci : filelist.GetCount() - 1);
	FileSelected();
}
Esempio n. 9
0
INT_PTR ImportBirthdaysService(WPARAM, LPARAM)
{
	TCHAR fileName[1024] = { 0 };
	OPENFILENAME of = { 0 };
	of.lStructSize = sizeof(OPENFILENAME);
	//of.hInstance = hInstance;
	TCHAR filter[MAX_PATH];
	mir_sntprintf(filter, _T("%s (*") _T(BIRTHDAY_EXTENSION) _T(")%c*") _T(BIRTHDAY_EXTENSION) _T("%c"), TranslateT("Birthdays files"), 0, 0);
	of.lpstrFilter = filter;
	of.lpstrFile = fileName;
	of.nMaxFile = _countof(fileName);
	of.lpstrTitle = TranslateT("Please select a file to import birthdays from...");
	of.Flags = OFN_FILEMUSTEXIST;

	if (GetOpenFileName(&of)) {
		TCHAR buffer[2048];
		mir_sntprintf(buffer, TranslateT("Importing birthdays from file: %s"), fileName);
		ShowPopupMessage(TranslateT("WhenWasIt"), buffer, hImportBirthdays);
		DoImport(fileName);
		ShowPopupMessage(TranslateT("WhenWasIt"), TranslateT("Done importing birthdays"), hImportBirthdays);
	}

	return 0;
}
Esempio n. 10
0
void WorkspaceWork::DoImport(const String& dir, const String& mask, bool sep, Progress& pi)
{
	String active = GetActivePackage();
	if(active.IsEmpty()) return;
	FindFile ff(AppendFileName(dir, "*.*"));
	Vector<String> dirs, files;
	while(ff) {
		String p = AppendFileName(dir, ff.GetName());
		if(ff.IsFile() && PatternMatchMulti(mask, ff.GetName()))
			files.Add(p);
		if(ff.IsFolder())
			dirs.Add(p);
		ff.Next();
	}
	if(sep && files.GetCount()) {
		Package::File& f = actual.file.Add();
		f = GetFileTitle(dir);
		f.separator = f.readonly = true;
	}
	Sort(files, &FileOrder_);
	Sort(dirs, &FileOrder_);
	for(int i = 0; i < files.GetCount(); i++) {
		if(pi.StepCanceled())
			throw String();
		String name = GetFileName(files[i]);
		if(FileCopy(files[i], SourcePath(active, name))) {
			Package::File& f = actual.file.Add();
			f = name;
			f.separator = f.readonly = false;
		}
		else
			throw Format("An error occurred while copying the file:&\1%s", files[i]);
	}
	for(int i = 0; i < dirs.GetCount(); i++)
		DoImport(dirs[i], mask, true, pi);
}
Esempio n. 11
0
bool MSVC7Loader::DoSelectConfiguration(TiXmlElement* root)
{
    TiXmlElement* config = root->FirstChildElement("Configurations");
    if (!config)
    {
        Manager::Get()->GetLogManager()->DebugLog(_T("No 'Configurations' node..."));
        return false;
    }

    TiXmlElement* confs = config->FirstChildElement("Configuration");
    if (!confs)
    {
        Manager::Get()->GetLogManager()->DebugLog(_T("No 'Configuration' node..."));
        return false;
    }

    // build an array of all configurations
    wxArrayString configurations;
    wxString ConfigName;
    for (; confs; confs=confs->NextSiblingElement("Configuration"))
    {
        /*Replace all '|' with ' ' so that compilation does not fail.
        * This is vital as object directory names will be derived from target names
        */
        ConfigName = cbC2U(confs->Attribute("Name"));
        ConfigName.Replace(_T("|"), _T(" "), true);
        configurations.Add(ConfigName);
    }

    wxArrayInt selected_indices;
    if (ImportersGlobals::ImportAllTargets)
    {
        // don't ask; just fill selected_indices with all indices
        for (size_t i = 0; i < configurations.GetCount(); ++i)
            selected_indices.Add(i);
    }
    else
    {
        // ask the user to select a configuration - multiple choice ;)
        MultiSelectDlg dlg(0, configurations, true, _("Select configurations to import:"), m_pProject->GetTitle());
        PlaceWindow(&dlg);
        if (dlg.ShowModal() == wxID_CANCEL)
        {
            Manager::Get()->GetLogManager()->DebugLog(_T("Cancelled..."));
            return false;
        }
        selected_indices = dlg.GetSelectedIndices();
    }

    confs = config->FirstChildElement("Configuration");
    int current_sel = 0;
    bool success = true;
    for (size_t i = 0; i < selected_indices.GetCount(); ++i)
    {
        // re-iterate configurations to find each selected one
        while (confs && current_sel++ < selected_indices[i])
            confs = confs->NextSiblingElement("Configuration");
        if (!confs)
        {
            Manager::Get()->GetLogManager()->DebugLog(F(_T("Cannot find configuration nr %d..."), selected_indices[i]));
            success = false;
            break;
        }

        Manager::Get()->GetLogManager()->DebugLog(_T("Importing configuration: ") + configurations[selected_indices[i]]);

        // prepare the configuration name
        m_ConfigurationName = configurations[selected_indices[i]];

        // do not change the configuration name. we might have duplicates then...

//        int pos = m_ConfigurationName.Find(_T('|'));
//        if (pos != wxNOT_FOUND)
//            m_ConfigurationName.Remove(pos);

        // parse the selected configuration
        success = success && DoImport(confs);
        confs = confs->NextSiblingElement("Configuration");
    }
    return success && DoImportFiles(root, selected_indices.GetCount());
}
Esempio n. 12
0
static bool Run(const wxCmdLineParser& parser)
{
	// Read the various global flags
	s_bDoProgress = parser.Found(_T("g"));
	s_bDoVerbose = parser.Found(_T("v"));
	s_bDoCompress = parser.Found(_T("z"));

	bool bPrepareExport = parser.Found(_T("p"));
	bool bExport = parser.Found(_T("e"));
	bool bCanImport = parser.Found(_T("c"));
	bool bImport = parser.Found(_T("i"));

	bool bOnlyOneError = false;
	bool bRetVal = true;

	// There is almost certainly a much nicer way of doing this
	// When I find it or get around to deriving my own wxCmdLineParser
	// then I'll change it
	if (bPrepareExport)
	{
		if (bExport || bCanImport || bImport)
		{
			bOnlyOneError = true;
		}
		else
		{
			bRetVal = DoPrepareExport(parser);
		}
	}
	else if (bExport)
	{
		if (bCanImport || bImport)
		{
			bOnlyOneError = true;
		}
		else
		{
			bRetVal = DoExport(parser);
		}
	}
	else if (bCanImport)
	{
		if (bImport)
		{
			bOnlyOneError = true;
		}
		else
		{
			bRetVal = DoCanImport(parser);
		}
	}
	else if (bImport)
	{
		bRetVal = DoImport(parser);
	}
	else
	{
		bOnlyOneError = true;
	}

	if (bOnlyOneError)
	{
		ReportError(_T("Exactly one of -p, -e, -c or -i must be specified"));
		bRetVal = false;
	}

	return bRetVal;
}
int32 UInternationalizationExportCommandlet::Main( const FString& Params )
{
	TArray<FString> Tokens;
	TArray<FString> Switches;
	TMap<FString, FString> ParamVals;


	UCommandlet::ParseCommandLine(*Params, Tokens, Switches, ParamVals);

	const FString* ParamVal = ParamVals.Find(FString(TEXT("Config")));

	if ( ParamVal )
	{
		ConfigPath = *ParamVal;
	}
	else
	{
		UE_LOG(LogInternationalizationExportCommandlet, Error, TEXT("No config specified."));
		return -1;
	}

	//Set config section
	ParamVal = ParamVals.Find(FString(TEXT("Section")));


	if ( ParamVal )
	{
		SectionName = *ParamVal;
	}
	else
	{
		UE_LOG(LogInternationalizationExportCommandlet, Error, TEXT("No config section specified."));
		return -1;
	}


	FString SourcePath; // Source path to the root folder that manifest/archive files live in.
	if( !GetPathFromConfig( *SectionName, TEXT("SourcePath"), SourcePath, ConfigPath ) )
	{
		UE_LOG( LogInternationalizationExportCommandlet, Error, TEXT("No source path specified.") );
		return -1;
	}

	FString DestinationPath; // Destination path that we will write files to.
	if( !GetPathFromConfig( *SectionName, TEXT("DestinationPath"), DestinationPath, ConfigPath ) )
	{
		UE_LOG( LogInternationalizationExportCommandlet, Error, TEXT("No destination path specified.") );
		return -1;
	}

	FString Filename; // Name of the file to read or write from
	if (!GetStringFromConfig(*SectionName, TEXT("PortableObjectName"), Filename, ConfigPath))
	{
		UE_LOG(LogInternationalizationExportCommandlet, Error, TEXT("No portable object name specified."));
		return -1;
	}

	// Get cultures to generate.
	if( GetStringArrayFromConfig(*SectionName, TEXT("CulturesToGenerate"), CulturesToGenerate, ConfigPath) == 0 )
	{
		UE_LOG(LogInternationalizationExportCommandlet, Error, TEXT("No cultures specified for generation."));
		return -1;
	}


	bool bDoExport = false;
	bool bDoImport = false;
	ShouldPersistComments = false;

	GetBoolFromConfig( *SectionName, TEXT("bImportLoc"), bDoImport, ConfigPath );
	GetBoolFromConfig( *SectionName, TEXT("bExportLoc"), bDoExport, ConfigPath );
	GetBoolFromConfig(*SectionName, TEXT("ShouldPersistComments"), ShouldPersistComments, ConfigPath);

	// Reject the ShouldPersistComments flag and warn if not exporting - we're not writing to anything, so we can't persist.
	if (ShouldPersistComments && !bDoExport)
	{
		UE_LOG(LogInternationalizationExportCommandlet, Warning, TEXT("ShouldPersistComments is true, but bExportLoc is false - can't persist comments if not writing PO files."));
		ShouldPersistComments = false;
	}

	if( !bDoImport && !bDoExport )
	{
		UE_LOG(LogInternationalizationExportCommandlet, Error, TEXT("Import/Export operation not detected.  Use bExportLoc or bImportLoc in config section."));
		return -1;
	}

	if( bDoImport )
	{
		if (!DoImport(SourcePath, DestinationPath, Filename))
		{
			UE_LOG(LogInternationalizationExportCommandlet, Error, TEXT("Failed to import localization files."));
			return -1;
		}
	}

	if( bDoExport )
	{
		if (!DoExport(SourcePath, DestinationPath, Filename))
		{
			UE_LOG(LogInternationalizationExportCommandlet, Error, TEXT("Failed to export localization files."));
			return -1;
		}
	}

	return 0;
}