Ejemplo n.º 1
0
bool wxGISServer::SetupLoc(const wxString &sLoc, const wxString &sLocPath)
{
    wxLogVerbose(_("wxGISServer: Initialize locale"));

  //  if(m_pszOldLocale != NULL)
		//setlocale(LC_NUMERIC, m_pszOldLocale);
	//wxDELETE(m_pszOldLocale);
    wxDELETE(m_pLocale);

	//init locale
    if ( !sLoc.IsEmpty() )
    {
		int iLocale(0);
		const wxLanguageInfo* loc_info = wxLocale::FindLanguageInfo(sLoc);
		if(loc_info != NULL)
		{
			iLocale = loc_info->Language;
			wxLogMessage(_("wxGISServer: Language is set to %s"), loc_info->Description.c_str());
		}

        // don't use wxLOCALE_LOAD_DEFAULT flag so that Init() doesn't return
        // false just because it failed to load wxstd catalog

        m_pLocale = new wxLocale();
        if ( !m_pLocale->Init(iLocale) )
        {
            wxLogError(wxT("wxGISServer: This language is not supported by the system."));
            return false;
        }
    }

	//m_locale.Init(wxLANGUAGE_DEFAULT);

    // normally this wouldn't be necessary as the catalog files would be found
    // in the default locations, but when the program is not installed the
    // catalogs are in the build directory where we wouldn't find them by
    // default
	wxString sLocalePath = sLocPath + wxFileName::GetPathSeparator() + sLoc;
	if(wxDirExists(sLocalePath))
	{
		wxLocale::AddCatalogLookupPathPrefix(sLocalePath);

		// Initialize the catalogs we'll be using
		//load multicat from locale
		wxArrayString trans_arr;
		wxDir::GetAllFiles(sLocalePath, &trans_arr, wxT("*.mo"));

		for(size_t i = 0; i < trans_arr.size(); ++i)
		{
			wxFileName name(trans_arr[i]);
			m_pLocale->AddCatalog(name.GetName());
		}

		// this catalog is installed in standard location on Linux systems and
		// shows that you may make use of the standard message catalogs as well
		//
		// if it's not installed on your system, it is just silently ignored
	#ifdef __LINUX__
		{
			wxLogNull noLog;
			m_pLocale->AddCatalog(_T("fileutils"));
		}
	#endif
	}

	//support of dot in doubles and floats
	//m_pszOldLocale = strdup(setlocale(LC_NUMERIC, NULL));
 //   if( setlocale(LC_NUMERIC,"C") == NULL )
 //       m_pszOldLocale = NULL;

    return true;
}
Ejemplo n.º 2
0
bool MoveDirWithFilebackupRename(wxString from, wxString to, bool backup, bool silent)
{
	// first make sure that the source dir exists
	if (!wxDir::Exists(from)) {
		ErrorMsgBox(from + _T(" does not exist.  Can not copy directory."), silent);
		return false;
	}

	if (from == to) {
		ErrorMsgBox(_T("Cannot copy: source == destination: ") + from, silent);
		return false;
	}

	if (from.empty() || to.empty()) {
		ErrorMsgBox(_T("Cannot copy empty directory"), silent);
		return false;
	}

	SafeMkdir(to);

	wxString sep = wxFileName::GetPathSeparator();

	wxDir dir(from);
	wxString filename;
	if (!dir.GetFirst(&filename)) {
		return false;
	}

	// append a slash if there is not one (for easier parsing)
	// because who knows what people will pass to the function.
	if (!to.EndsWith(sep)) {
		to += sep;
	}
	// for both dirs
	if (!from.EndsWith(sep)) {
		from += sep;
	}

	do {
		const wxString srcfile = from + filename;
		const wxString dstfile = to + filename;
		if (wxDirExists(srcfile)) {					      //check if srcfile is a directory
			MoveDirWithFilebackupRename(srcfile, dstfile, false, silent); //no backup in subdirs
		} else {
			//if files exists move it to backup, this way we can use this func on windows to replace 'active' files

			if (backup && wxFileExists(dstfile)) {
				const wxString backupfile = dstfile + _T(".old");
				if (!MoveFile(dstfile, backupfile)) {
					ErrorMsgBox(wxString::Format(_T("could not rename %s to %s. copydir aborted"), dstfile.c_str(), backupfile.c_str()), silent);
					return false;
				}
			}
			//do the actual copy
			if (!wxCopyFile(srcfile, dstfile, true)) {
				ErrorMsgBox(wxString::Format(_T("could not copy %s to %s, copydir aborted"), srcfile, dstfile), silent);
				return false;
			}
		}
	} while (dir.GetNext(&filename));
	return true;
}
Ejemplo n.º 3
0
void RegisterVSTEffects()
{
   PluginManager & pm = PluginManager::Get();

   pm.Open();

   if (gPrefs->Read(wxT("/VST/Rescan"), (long) false) != false) {
      pm.PurgeType(VSTPLUGINTYPE);
      gPrefs->Write(wxT("/VST/Rescan"), false);
   }

   if (!pm.HasType(VSTPLUGINTYPE)) {
      pm.Close();
      VSTEffect::Scan();
      pm.Open();
   }

   EffectManager & em = EffectManager::Get();

   wxString path = pm.GetFirstPlugin(VSTPLUGINTYPE);
   while (!path.IsEmpty()) {
#if defined(__WXMAC__)
      if (wxDirExists(path)) {
#else
      if (wxFileExists(path)) {
#endif
         em.RegisterEffect(new VSTEffect(path));
      }
      
      path = pm.GetNextPlugin(VSTPLUGINTYPE);
   }

   pm.Close();
}

///////////////////////////////////////////////////////////////////////////////
//
// VSTEffectDialog
//
///////////////////////////////////////////////////////////////////////////////

class VSTEffectDialog:public wxDialog, XMLTagHandler
{
 public:
   VSTEffectDialog(wxWindow * parent,
                   const wxString & title,
                   VSTEffect *effect,
                   AEffect *aeffect);
   virtual ~VSTEffectDialog();

   void RemoveHandler();

   void OnIdle(wxIdleEvent & evt);

   void OnProgram(wxCommandEvent & evt);
   void OnProgramText(wxCommandEvent & evt);
   void OnLoad(wxCommandEvent & evt);
   void OnSave(wxCommandEvent & evt);

   void OnSlider(wxCommandEvent &event);

   void OnOk(wxCommandEvent & evt);
   void OnCancel(wxCommandEvent & evt);
   void OnClose(wxCloseEvent & evt);
   void OnPreview(wxCommandEvent & evt);

 private:
Ejemplo n.º 4
0
void DescriptorFrame::save()
{
	bool empty=true;
	FILE *cadfile_;
	FILE *outputfile;
	char line[100];
	

	// check unbound components
	if (!(noDestinationInfoList.size()==0)) {
		empty=false;
		wxString message="placements without destination are left. Continue ?";
		wxMessageDialog* mess_dialog=new wxMessageDialog(this,message,"Message box",wxYES_NO | wxCENTRE | wxICON_QUESTION, wxDefaultPosition);
		int t=mess_dialog->ShowModal();
		if (t==wxID_YES)
		{
			empty=true;
		}
		mess_dialog->~wxMessageDialog();
	}

	/** create tomporary directory for zipping the package */
	if (!(wxDirExists("meta-inf"))) 
	{
		if (!wxMkdir("meta-inf"))
		{
			wxLogMessage(_T("Unable to create meta-inf directory temporarily"));
		}
	}

	cadfile_=fopen(tmp_file.c_str(),"r");
	wxString c_file="meta-inf/";
	c_file.Append(cadfile.c_str());
	outputfile=fopen(c_file,"w+");
		
	wxString tmp_string;
	wxString tmp_before_partit;
	wxString tmp_after_partit;
	wxString tmp_partit;

	// reading the cadfile 
	while (!feof(cadfile_))
	{
		fgets(line,100,cadfile_);
		tmp_string.Append(line);
	}

	// erase old partitioning
	// divide into two strings
	
	int erase_start=tmp_string.find("<partitioning>");
	int erase_end=tmp_string.find("</partitioning>")+15;

	tmp_before_partit=tmp_string.Mid(0,erase_start);
	tmp_after_partit=tmp_string.Mid(erase_end,wxSTRING_MAXLEN);
	tmp_partit=tmp_string.Mid(erase_start,erase_end-erase_start);
	

	tmp_string.Empty();

	// put new partitioning 
	tmp_string.Append(tmp_before_partit);
	tmp_string.Append(get_partitioning_str(tmp_partit));
	tmp_string.Append(tmp_after_partit);

	// write into cad file
	if (fputs(tmp_string ,outputfile) > -1) 
	{ 
		//wxLogMessage(_T(line));

	} else {
		wxLogMessage(_T("Error writing"));		
	}
	
	fclose(outputfile);
	fclose(cadfile_);

    // cadfile into assembly zip
	into_zip(c_file.c_str(),file);

	// delete tmp_cadfile

    wxLogMessage("Save OK");

}
Ejemplo n.º 5
0
int CProxyParse::RunFromMem( wxString content )
{
	char *pBuffer;
	//http://www.51proxied.com/http_non_anonymous.html
	//wxString path = wxT("f:/work/windows/wxUrlRefresh/data/最新透明HTTP代理服务器.htm");
	//wxString path1 = wxT("f:/work/windows/wxUrlRefresh/data/result.xml");

	wxString data_path = wxGetCwd() + "/data/";
	wxString path1 = data_path + "_tmp.xml";

	if (!wxDirExists(data_path))
		wxMkdir(data_path);

	pBuffer = (char*)calloc(content.Length()+1, 1);
	wxStrncpy(pBuffer, content, content.Len()+1);


	wxLogMessage("Run Tidy!");
	TidyBuffer output;
	TidyBuffer errbuf;
	int rc = -1;
	Bool ok;
	TidyDoc tdoc = tidyCreate();                     // Initialize "document"
	tidyBufInit( &output );
	tidyBufInit( &errbuf );
	//printf( "Tidying:\t\%s\\n", input );
	tidySetCharEncoding(tdoc, "utf8");
	ok = tidyOptSetBool( tdoc, TidyXhtmlOut, yes );  // Convert to XHTML
	if ( ok )
		rc = tidySetErrorBuffer( tdoc, &errbuf );      // Capture diagnostics
	if ( rc >= 0 )
		rc = tidyParseString( tdoc, pBuffer );           // Parse the input
	if ( rc >= 0 )
		rc = tidyCleanAndRepair( tdoc );               // Tidy it up!
	if ( rc >= 0 )
		rc = tidyRunDiagnostics( tdoc );               // Kvetch
	if ( rc > 1 )                                    // If error, force output.
		rc = ( tidyOptSetBool(tdoc, TidyForceOutput, yes) ? rc : -1 );
	if ( rc >= 0 )
		rc = tidySaveBuffer( tdoc, &output );          // Pretty Print
	if ( rc >= 0 )
	{
#ifdef _DEBUG
		//if ( rc > 0 )
		//	WriteAllToFile("f:/work/windows/wxUrlRefresh/data/error.xml", (char*)errbuf.bp, errbuf.size);
		WriteAllToFile(path1, (char*)output.bp, output.size);
#endif

	}
	else
		wxLogError("tidyFail");

	tidyBufFree( &output );
	tidyBufFree( &errbuf );
	tidyRelease( tdoc );
	if (pBuffer) free(pBuffer);


	wxLogMessage("Fetch data!");
	// 解析数据
	TiXmlDocument doc(path1);
	if (doc.LoadFile()) 
	{
		// root
		CTiXmlProxyVistor vistor(&m_array);
		TiXmlElement *pRoot = doc.RootElement();
		pRoot->Accept(&vistor);
	}
	else
	{
		wxLogMessage("shit");
		return -2;
	}
	return 0;
}
Ejemplo n.º 6
0
InstIconList::InstIconList(int width, int height, wxString customIconDirName)
{
	if (customIconDirName == wxEmptyString)
		customIconDirName = settings->GetIconsDir().GetFullPath();

	this->width = width;
	this->height = height;
	
	const InstIconDef builtInIcons[] =
	{
		InstIconDef("default", _("Default icon"), wxMEMORY_IMAGE(grass)),
		InstIconDef("grass", _("Grass block"), wxMEMORY_IMAGE(grass)),
		InstIconDef("dirt", _("Dirt block"), wxMEMORY_IMAGE(dirt)),
		InstIconDef("stone", _("Stone block"), wxMEMORY_IMAGE(stone)),
		InstIconDef("planks", _("Planks"), wxMEMORY_IMAGE(planks)),
		InstIconDef("iron", _("Solid iron"), wxMEMORY_IMAGE(iron)),
		InstIconDef("gold", _("Shiny gold"), wxMEMORY_IMAGE(gold)),
		InstIconDef("diamond", _("Diamond!"), wxMEMORY_IMAGE(diamond)),
		InstIconDef("tnt", _("TNT"), wxMEMORY_IMAGE(tnt)),
		InstIconDef("enderman",_("Enderman"), wxMEMORY_IMAGE(enderman)),
		InstIconDef("ftb-logo",_("FTB logo"), wxMEMORY_IMAGE(ftb_logo), wxMEMORY_IMAGE(ftb_logo128)),
		InstIconDef("ftb-glow",_("FTB glow"), wxMEMORY_IMAGE(ftb_glow), wxMEMORY_IMAGE(ftb_glow128)),
		InstIconDef("infinity",_("Infinity"), wxMEMORY_IMAGE(infinity), wxMEMORY_IMAGE(infinity128)),
		InstIconDef("netherstar",_("Nether Star"), wxMEMORY_IMAGE(netherstar), wxMEMORY_IMAGE(netherstar128)),
		InstIconDef("creeper",_("Creeper"), wxMEMORY_IMAGE(creeper), wxMEMORY_IMAGE(creeper128)),
		InstIconDef("square creeper",_("Square creeper"), wxMEMORY_IMAGE(squarecreeper), wxMEMORY_IMAGE(squarecreeper128)),
		InstIconDef("skeleton",_("Skeleton"), wxMEMORY_IMAGE(skeleton), wxMEMORY_IMAGE(skeleton128)),
		InstIconDef("gear",_("Golden gear"), wxMEMORY_IMAGE(gear), wxMEMORY_IMAGE(gear128)),
		InstIconDef("magitech",_("Magitech"), wxMEMORY_IMAGE(magitech), wxMEMORY_IMAGE(magitech128)),
		InstIconDef("enderpearl",_("Enderpearl"), wxMEMORY_IMAGE(enderpearl), wxMEMORY_IMAGE(enderpearl128)),
		InstIconDef("herobrine",_("Herobrine"), wxMEMORY_IMAGE(herobrine), wxMEMORY_IMAGE(herobrine128)),
		InstIconDef("meat",_("The Meat"), wxMEMORY_IMAGE(meat), wxMEMORY_IMAGE(meat128)),
		InstIconDef("chicken",_("Chicken"), wxMEMORY_IMAGE(chicken), wxMEMORY_IMAGE(chicken128)),
		InstIconDef("steve",_("Steve"), wxMEMORY_IMAGE(steve), wxMEMORY_IMAGE(steve128)),
		InstIconDef("derp",_("Derp"), wxMEMORY_IMAGE(derp)),
	};
	const int builtInIconCount = sizeof(builtInIcons)/sizeof(InstIconDef);

	for (int i = 0; i < builtInIconCount; i++)
	{
#ifdef DEBUG_ICONS
		if(!builtInIcons[i].image.HasAlpha())
		{
			wxLogMessage(_("Image %d %s has no alpha."), i, builtInIcons[i].key.c_str()  );
		}
#endif
		wxImage highlightIcon = tintImage(builtInIcons[i].image,wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
		Add(builtInIcons[i].image, highlightIcon, builtInIcons[i].image128, builtInIcons[i].key, builtInIcons[i].name);
	}

	if (wxDirExists(customIconDirName))
	{
		wxDir customIconDir(customIconDirName);

		if (!customIconDir.IsOpened())
			return;

		wxString iconFile;
		
		if (customIconDir.GetFirst(&iconFile))
		{
			do 
			{
				// Check file extensions
				bool isAllowedImage = false;
				for (int i = 0; i < allowedImgExtensionsCount; i++)
				{
					if (iconFile.Lower().EndsWith(allowedImgExtensions[i]))
					{
						isAllowedImage = true;
						break;
					}
				}
				if (!isAllowedImage)
					continue;

				if (!AddFile(Path::Combine(customIconDirName, iconFile)))
				{
					if(customIconDir.GetNext(&iconFile))
						continue;
					break;
				}
			} while (customIconDir.GetNext(&iconFile));
		}
	}
}
Ejemplo n.º 7
0
void wxGenericFileDialog::HandleAction( const wxString &fn )
{
    if (ignoreChanges)
        return;

    wxString filename( fn );
    if (filename.empty())
    {
#ifdef __WXWINCE__
        EndModal(wxID_CANCEL);
#endif
        return;
    }
    if (filename == wxT(".")) return;

    wxString dir = m_list->GetDir();

    // "some/place/" means they want to chdir not try to load "place"
    bool want_dir = filename.Last() == wxFILE_SEP_PATH;
    if (want_dir)
        filename = filename.RemoveLast();

    if (filename == wxT(".."))
    {
        ignoreChanges = true;
        m_list->GoToParentDir();
        m_list->SetFocus();
        UpdateControls();
        ignoreChanges = false;
        return;
    }

#ifdef __UNIX__
    if (filename == wxT("~"))
    {
        ignoreChanges = true;
        m_list->GoToHomeDir();
        m_list->SetFocus();
        UpdateControls();
        ignoreChanges = false;
        return;
    }

    if (filename.BeforeFirst(wxT('/')) == wxT("~"))
    {
        filename = wxString(wxGetUserHome()) + filename.Remove(0, 1);
    }
#endif // __UNIX__

    if (!HasFdFlag(wxFD_SAVE))
    {
        if ((filename.Find(wxT('*')) != wxNOT_FOUND) ||
            (filename.Find(wxT('?')) != wxNOT_FOUND))
        {
            if (filename.Find(wxFILE_SEP_PATH) != wxNOT_FOUND)
            {
                wxMessageBox(_("Illegal file specification."), _("Error"), wxOK | wxICON_ERROR );
                return;
            }
            m_list->SetWild( filename );
            return;
        }
    }

    if (!IsTopMostDir(dir))
        dir += wxFILE_SEP_PATH;
    if (!wxIsAbsolutePath(filename))
    {
        dir += filename;
        filename = dir;
    }

    if (wxDirExists(filename))
    {
        ignoreChanges = true;
        m_list->GoToDir( filename );
        UpdateControls();
        ignoreChanges = false;
        return;
    }

    // they really wanted a dir, but it doesn't exist
    if (want_dir)
    {
        wxMessageBox(_("Directory doesn't exist."), _("Error"),
                     wxOK | wxICON_ERROR );
        return;
    }

    // append the default extension to the filename if it doesn't have any
    //
    // VZ: the logic of testing for !wxFileExists() only for the open file
    //     dialog is not entirely clear to me, why don't we allow saving to a
    //     file without extension as well?
    if ( !HasFdFlag(wxFD_OPEN) || !wxFileExists(filename) )
    {
        filename = AppendExtension(filename, m_filterExtension);
    }

    // check that the file [doesn't] exist if necessary
    if ( HasFdFlag(wxFD_SAVE) && HasFdFlag(wxFD_OVERWRITE_PROMPT) &&
                wxFileExists( filename ) )
    {
        wxString msg;
        msg.Printf( _("File '%s' already exists, do you really want to overwrite it?"), filename.c_str() );

        if (wxMessageBox(msg, _("Confirm"), wxYES_NO) != wxYES)
            return;
    }
    else if ( HasFdFlag(wxFD_OPEN) && HasFdFlag(wxFD_FILE_MUST_EXIST) &&
                    !wxFileExists(filename) )
    {
        wxMessageBox(_("Please choose an existing file."), _("Error"),
                     wxOK | wxICON_ERROR );
        return;
    }

    SetPath( filename );

    // change to the directory where the user went if asked
    if ( HasFdFlag(wxFD_CHANGE_DIR) )
    {
        wxString cwd;
        wxSplitPath(filename, &cwd, NULL, NULL);

        if ( cwd != wxGetCwd() )
        {
            wxSetWorkingDirectory(cwd);
        }
    }

    EndModal(wxID_OK);
}
Ejemplo n.º 8
0
wxString wxStandardPaths::GetUserDir(Dir userDir) const
{
    {
        wxLogNull logNull;
        wxString homeDir = wxFileName::GetHomeDir();
        wxString configPath;
        if (wxGetenv(wxT("XDG_CONFIG_HOME")))
            configPath = wxGetenv(wxT("XDG_CONFIG_HOME"));
        else
            configPath = homeDir + wxT("/.config");
        wxString dirsFile = configPath + wxT("/user-dirs.dirs");
        if (wxFileExists(dirsFile))
        {
            wxString userDirId;
            switch (userDir)
            {
                case Dir_Desktop:
                    userDirId = "XDG_DESKTOP_DIR";
                    break;
                case Dir_Downloads:
                    userDirId = "XDG_DOWNLOAD_DIR";
                    break;
                case Dir_Music:
                    userDirId = "XDG_MUSIC_DIR";
                    break;
                case Dir_Pictures:
                    userDirId = "XDG_PICTURES_DIR";
                    break;
                case Dir_Videos:
                    userDirId = "XDG_VIDEOS_DIR";
                    break;
                default:
                    userDirId = "XDG_DOCUMENTS_DIR";
                    break;
            }

            wxTextFile textFile;
            if (textFile.Open(dirsFile))
            {
                size_t i;
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
                for (i = 0; i < textFile.GetLineCount(); i++)
                {
                    wxString line(textFile[i]);
                    int pos = line.Find(userDirId);
                    if (pos != wxNOT_FOUND)
                    {
                        wxString value = line.AfterFirst(wxT('='));
                        value.Replace(wxT("$HOME"), homeDir);
                        value.Trim(true);
                        value.Trim(false);
                        // Remove quotes
                        value.Replace("\"", "", true /* replace all */);
                        if (!value.IsEmpty() && wxDirExists(value))
                            return value;
                        else
                            break;
                    }
                }
            }
        }
    }

    return wxStandardPathsBase::GetUserDir(userDir);
}
void KICAD_MANAGER_FRAME::CreateNewProject( const wxString& aPrjFullFileName,
                                            bool aTemplateSelector = false )
{
    wxFileName  newProjectName = aPrjFullFileName;
    wxChar      sep[2] = { SEP(), 0 };  // nul terminated separator wxChar string.

    ClearMsg();

    // If we are creating a project from a template, make sure the template directory is sane
    if( aTemplateSelector )
    {
        DIALOG_TEMPLATE_SELECTOR* ps = new DIALOG_TEMPLATE_SELECTOR( this );

        wxFileName  templatePath;
        wxString    envStr;

#ifndef __WXMAC__
        wxGetEnv( wxT( "KICAD" ), &envStr );

        // Add a new tab for system templates
        if( !envStr.empty() )
        {
            // user may or may not have including terminating separator.
            if( !envStr.EndsWith( sep ) )
                envStr += sep;

            templatePath = envStr + wxT( "template" ) + sep;
        }
        else
        {
            // The standard path should be in the share directory for kicad. As
            // it is normal on Windows to only have the share directory and not
            // the kicad sub-directory we fall back to that if the directory
            // doesn't exist
            templatePath = wxPathOnly( wxStandardPaths::Get().GetExecutablePath() ) +
                sep + wxT( ".." ) + sep + wxT( "share" ) + sep + wxT( "kicad" ) +
                sep + wxT( "template" ) + sep;

            if( !wxDirExists( templatePath.GetFullPath() ) )
            {
                templatePath = wxPathOnly( wxStandardPaths::Get().GetExecutablePath() ) +
                sep + wxT( ".." ) + sep + wxT( "share" ) + sep + wxT( "template" ) + sep;
            }
        }
#else
        // Use what is provided in the bundle data dir
        templatePath = GetOSXKicadDataDir() + sep + wxT( "template" );
#endif

        ps->AddTemplatesPage( _( "System Templates" ), templatePath );

        // Add a new tab for user templates
        wxFileName userPath = wxStandardPaths::Get().GetDocumentsDir() +
                sep + wxT( "kicad" ) + sep + wxT( "template" ) + sep;

        ps->AddTemplatesPage( _( "User Templates" ), userPath );

        // Check to see if a custom template location is available and setup a
        // new selection tab if there is.
        envStr.clear();
        wxGetEnv( wxT( "KICAD_PTEMPLATES" ), &envStr );

        if( !envStr.empty() )
        {
            if( !envStr.EndsWith( sep ) )
                envStr += sep;

            wxFileName envPath = envStr;

            ps->AddTemplatesPage( _( "Portable Templates" ), envPath );
        }

        // Show the project template selector dialog
        int result = ps->ShowModal();

        if( ( result != wxID_OK ) || ( ps->GetSelectedTemplate() == NULL ) )
        {
            if( ps->GetSelectedTemplate() == NULL )
            {
                wxMessageBox( _( "No project template was selected.  Cannot generate new "
                                 "project." ),
                              _( "Error" ),
                              wxOK | wxICON_ERROR,
                              this );
            }
        }
        else
        {
            // The selected template widget contains the template we're attempting to use to
            // create a project
            if( !ps->GetSelectedTemplate()->CreateProject( newProjectName ) )
            {
                wxMessageBox( _( "Problem whilst creating new project from template!" ),
                              _( "Template Error" ),
                              wxOK | wxICON_ERROR,
                              this );
            }
        }
    }

    // Init project filename
    SetProjectFileName( newProjectName.GetFullPath() );

    // Write settings to project file
    // was: wxGetApp().WriteProjectConfig( aPrjFullFileName, GeneralGroupName, s_KicadManagerParams );
    Prj().ConfigSave( PgmTop().SysSearch(), GeneralGroupName, s_KicadManagerParams );

    // Ensure a "stub" for a schematic root sheet and a board exist.
    // It will avoid messages from the schematic editor or the board editor to create a new file
    // And forces the user to create main files under the right name for the project manager
    wxFileName fn( newProjectName.GetFullPath() );
    fn.SetExt( SchematicFileExtension );

    // If a <project>.sch file does not exist, create a "stub" file
    // ( minimal schematic file )
    if( !fn.FileExists() )
    {
        wxFile file( fn.GetFullPath(), wxFile::write );

        if( file.IsOpened() )
            file.Write( wxT( "EESchema Schematic File Version 2\n"
                             "EELAYER 25 0\nEELAYER END\n$EndSCHEMATC\n" ) );

        // wxFile dtor will close the file
    }

    // If a <project>.kicad_pcb or <project>.brd file does not exist,
    // create a .kicad_pcb "stub" file
    fn.SetExt( KiCadPcbFileExtension );
    wxFileName leg_fn( fn );
    leg_fn.SetExt( LegacyPcbFileExtension );

    if( !fn.FileExists() && !leg_fn.FileExists() )
    {
        wxFile file( fn.GetFullPath(), wxFile::write );

        if( file.IsOpened() )
            file.Write( wxT( "(kicad_pcb (version 4) (host kicad \"dummy file\") )\n" ) );

        // wxFile dtor will close the file
    }

    // Enable the toolbar and menubar buttons and clear the help text.
    m_active_project = true;
    m_MessagesBox->Clear();
}
Ejemplo n.º 10
0
bool CBOINCGUIApp::OnInit() {
    // Initialize globals
#ifdef SANDBOX
    g_use_sandbox = true;
#else
    g_use_sandbox = false;
#endif

    s_bSkipExitConfirmation = false;
    m_bFilterEvents = false;
    m_bAboutDialogIsOpen = false;

    // Initialize class variables
    m_pLocale = NULL;
    m_pSkinManager = NULL;
    m_pFrame = NULL;
    m_pDocument = NULL;
    m_pTaskBarIcon = NULL;
    m_pEventLog = NULL;
#ifdef __WXMAC__
    m_pMacDockIcon = NULL;
#endif
    m_strBOINCMGRExecutableName = wxEmptyString;
    m_strBOINCMGRRootDirectory = wxEmptyString;
    m_strBOINCMGRDataDirectory = wxEmptyString;
    m_strHostNameArg = wxEmptyString;
    m_strPasswordArg = wxEmptyString;
    m_iRPCPortArg = GUI_RPC_PORT;
    m_strBOINCArguments = wxEmptyString;
    m_bGUIVisible = true;
    m_bDebugSkins = false;
    m_bMultipleInstancesOK = false;
    m_bBOINCMGRAutoStarted = false;
    m_iBOINCMGRDisableAutoStart = 0;
    m_iShutdownCoreClient = 0;
    m_iDisplayExitDialog = 1;
    m_iGUISelected = BOINC_SIMPLEGUI;
    m_bSafeMessageBoxDisplayed = 0;
#ifdef __WXMSW__
    m_hClientLibraryDll = NULL;
#endif

    // Initialize local variables
    int      iErrorCode = 0;
    int      iSelectedLanguage = 0;
    bool     bOpenEventLog = false;
    wxString strDesiredSkinName = wxEmptyString;
    wxString strDialogMessage = wxEmptyString;
    bool     success = false;

    // Configure wxWidgets platform specific code
#ifdef __WXMSW__
    wxSystemOptions::SetOption(wxT("msw.staticbox.optimized-paint"), 0);
#endif
#ifdef __WXMAC__
    // In wxMac-2.8.7, default wxListCtrl::RefreshItem() does not work
    // so use traditional generic implementation.
    // This has been fixed in wxMac-2.8.8, but the Mac native implementation:
    //  - takes 3 times the CPU time as the Mac generic version.
    //  - seems to always redraw entire control even if asked to refresh only one row.
    //  - causes major flicker of progress bars, (probably due to full redraws.)
    wxSystemOptions::SetOption(wxT("mac.listctrl.always_use_generic"), 1);

    AEInstallEventHandler( kCoreEventClass, kAEQuitApplication, NewAEEventHandlerUPP((AEEventHandlerProcPtr)QuitAppleEventHandler), 0, false );

    // Cache the current process serial number
    GetCurrentProcess(&m_psnCurrentProcess);
#endif


    // Commandline parsing is done in wxApp::OnInit()
    if (!wxApp::OnInit()) {
        return false;
    }

    if (g_use_sandbox) {
        wxCHANGE_UMASK(2);  // Set file creation mask to be writable by both user and group
                            // Our umask will be inherited by all our child processes
    }

    // Setup application and company information
    SetAppName(wxT("BOINC Manager"));
    SetVendorName(wxT("Space Sciences Laboratory, U.C. Berkeley"));


    // Initialize the configuration storage module
    m_pConfig = new wxConfig(GetAppName());
    wxConfigBase::Set(m_pConfig);
    wxASSERT(m_pConfig);


    // Restore Application State
    m_pConfig->SetPath(wxT("/"));
    m_pConfig->Read(wxT("AutomaticallyShutdownClient"), &m_iShutdownCoreClient, 0L);
    m_pConfig->Read(wxT("DisplayShutdownClientDialog"), &m_iDisplayExitDialog, 1L);
    m_pConfig->Read(wxT("DisableAutoStart"), &m_iBOINCMGRDisableAutoStart, 0L);
    m_pConfig->Read(wxT("Language"), &iSelectedLanguage, 0L);
    m_pConfig->Read(wxT("GUISelection"), &m_iGUISelected, BOINC_SIMPLEGUI);
    m_pConfig->Read(wxT("EventLogOpen"), &bOpenEventLog);


    // Should we abort the BOINC Manager startup process?
    if (m_bBOINCMGRAutoStarted && m_iBOINCMGRDisableAutoStart) {
        return false;
    }

    // Detect where BOINC Manager executable name.
    DetectExecutableName();

    // Detect where BOINC Manager was installed too.
    DetectRootDirectory();

    // Detect where the BOINC Data files are.
    DetectDataDirectory();


    // Switch the current directory to the BOINC Data directory
    if (!GetDataDirectory().IsEmpty()) {
    	success = wxSetWorkingDirectory(GetDataDirectory());
        if (!success) {
            if (!g_use_sandbox) {
                if (!wxDirExists(GetDataDirectory())) {
                    success = wxMkdir(GetDataDirectory(), 0777);    // Does nothing if dir exists
                }
            }
        }
    }

    if (!success) iErrorCode = -1016;

    // Initialize the BOINC Diagnostics Framework
    int dwDiagnosticsFlags =
        BOINC_DIAG_DUMPCALLSTACKENABLED | 
        BOINC_DIAG_HEAPCHECKENABLED |
        BOINC_DIAG_MEMORYLEAKCHECKENABLED |
#if defined(__WXMSW__) || defined(__WXMAC__)
        BOINC_DIAG_REDIRECTSTDERR |
        BOINC_DIAG_REDIRECTSTDOUT |
#endif
        BOINC_DIAG_TRACETOSTDOUT;

    diagnostics_init(
        dwDiagnosticsFlags,
        "stdoutgui",
        "stderrgui"
    );


    // Enable Logging and Trace Masks
    m_pLog = new wxLogBOINC();
    wxLog::SetActiveTarget(m_pLog);

    m_pLog->AddTraceMask(wxT("Function Start/End"));
    m_pLog->AddTraceMask(wxT("Function Status"));


    // Initialize the internationalization module
#ifdef __WXMSW__
    // On Windows, set all locales for this thread on a per-thread basis
    _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
#endif
    m_pLocale = new wxLocale();
    wxASSERT(m_pLocale);

    // Look for the localization files by absolute and relative locations.
    //   preference given to the absolute location.
    m_pLocale->Init(iSelectedLanguage);
    if (!m_strBOINCMGRRootDirectory.IsEmpty()) {
        m_pLocale->AddCatalogLookupPathPrefix(
            wxString(m_strBOINCMGRRootDirectory + wxT("locale"))
        );
    }
    m_pLocale->AddCatalogLookupPathPrefix(wxT("locale"));
    m_pLocale->AddCatalog(wxT("BOINC-Manager"));
    m_pLocale->AddCatalog(wxT("BOINC-Client"));
    m_pLocale->AddCatalog(wxT("BOINC-Web"));

    InitSupportedLanguages();

	language = m_pLocale->GetCanonicalName();

    // Note: JAWS for Windows will only speak the context-sensitive
    // help if you use this help provider:
    wxHelpProvider::Set(new wxHelpControllerHelpProvider());

    // Enable known image types
    wxInitAllImageHandlers();

    // Initialize the skin manager
    m_pSkinManager = new CSkinManager(m_bDebugSkins);
    wxASSERT(m_pSkinManager);


    // Load desired manager skin
    m_pConfig->Read(wxT("Skin"), &strDesiredSkinName, m_pSkinManager->GetDefaultSkinName());
    m_pSkinManager->ReloadSkin(strDesiredSkinName);


#ifdef SANDBOX
    // Make sure owners, groups and permissions are correct for the current setting of g_use_sandbox
    char path_to_error[MAXPATHLEN];
    path_to_error[0] = '\0';
    
    if (!iErrorCode) {
#if (defined(__WXMAC__) && defined(_DEBUG))     // TODO: implement this for other platforms
        // GDB can't attach to applications which are running as a different user   
        //  or group, so fix up data with current user and group during debugging
        if (check_security(g_use_sandbox, true, NULL, 0)) {
            CreateBOINCUsersAndGroups();
            SetBOINCDataOwnersGroupsAndPermissions();
            SetBOINCAppOwnersGroupsAndPermissions(NULL);
        }
#endif
        iErrorCode = check_security(
            g_use_sandbox, true, path_to_error, sizeof(path_to_error)
        );
    }

    if (iErrorCode) {

        ShowApplication(true);

        if (iErrorCode == -1099) {
            strDialogMessage.Printf(
                _("You currently are not authorized to manage the client.\n\nTo run %s as this user, please:\n  - reinstall %s answering \"Yes\" to the question about\n     non-administrative users\n or\n  - contact your administrator to add you to the 'boinc_master'\n     user group."),
                m_pSkinManager->GetAdvanced()->GetApplicationShortName().c_str(),
                m_pSkinManager->GetAdvanced()->GetApplicationShortName().c_str()
            );
        } else {
            strDialogMessage.Printf(
                _("%s ownership or permissions are not set properly; please reinstall %s.\n(Error code %d"),
                m_pSkinManager->GetAdvanced()->GetApplicationShortName().c_str(),
                m_pSkinManager->GetAdvanced()->GetApplicationShortName().c_str(),
                iErrorCode
            );
            if (path_to_error[0]) {
                strDialogMessage += _(" at ");
                strDialogMessage += wxString::FromUTF8(path_to_error);
            }
            strDialogMessage += _(")");
            
            fprintf(stderr, "%s\n", (const char*)strDialogMessage.utf8_str());
        }

        wxMessageDialog* pDlg = new wxMessageDialog(
                                    NULL, 
                                    strDialogMessage, 
                                    m_pSkinManager->GetAdvanced()->GetApplicationName(), 
                                    wxOK
                                    );

        pDlg->ShowModal();
        if (pDlg)
            pDlg->Destroy();

        return false;
    }
#endif      // SANDBOX


#ifdef __WXMSW__
    // Perform any last minute checks that should keep the manager
    // from starting up.
    wxString strRebootPendingFile = 
        GetRootDirectory() + wxFileName::GetPathSeparator() + wxT("RebootPending.txt");
    
    if (wxFile::Exists(strRebootPendingFile)) {
        wxMessageDialog dialog(
            NULL,
            _("A reboot is required in order for BOINC to run properly.\nPlease reboot your computer and try again."),
            _("BOINC Manager"),
            wxOK|wxICON_ERROR
        );

        dialog.ShowModal();
        return false;
    }
#endif

    // Detect if BOINC Manager is already running, if so, bring it into the
    // foreground and then exit.
    if (!m_bMultipleInstancesOK) {
        if (DetectDuplicateInstance()) {
            return false;
        }
    }

    // Initialize the main document
    m_pDocument = new CMainDocument();
    wxASSERT(m_pDocument);

    m_pDocument->OnInit();


    // Is there a condition in which the Simple GUI should not be used?
    if (BOINC_SIMPLEGUI == m_iGUISelected) {
        // Screen too small?
        if (wxGetDisplaySize().GetHeight() < 600) {
            m_iGUISelected = BOINC_ADVANCEDGUI;
        }
    }


    // Initialize the task bar icon
	m_pTaskBarIcon = new CTaskBarIcon(
        m_pSkinManager->GetAdvanced()->GetApplicationName(), 
#ifdef __WXMSW__
        new wxIcon(wxICON(BOINCGUIAPP)),
#else
        m_pSkinManager->GetAdvanced()->GetApplicationIcon(),
#endif
        m_pSkinManager->GetAdvanced()->GetApplicationDisconnectedIcon(),
        m_pSkinManager->GetAdvanced()->GetApplicationSnoozeIcon()
#ifdef __WXMAC__
        , wxTBI_CUSTOM_STATUSITEM
#endif
    );
#ifdef __WXMAC__
    m_pMacDockIcon = new CTaskBarIcon(
        m_pSkinManager->GetAdvanced()->GetApplicationName(), 
        m_pSkinManager->GetAdvanced()->GetApplicationIcon(),
        m_pSkinManager->GetAdvanced()->GetApplicationDisconnectedIcon(),
        m_pSkinManager->GetAdvanced()->GetApplicationSnoozeIcon()
        , wxTBI_DOCK
    );
    wxASSERT(m_pMacDockIcon);
#endif
    wxASSERT(m_pTaskBarIcon);

    // Startup the System Idle Detection code
    IdleTrackerAttach();
    
#ifdef __WXMAC__
    ProcessSerialNumber psn;
    ProcessInfoRec pInfo;
    OSStatus err;
    
    memset(&pInfo, 0, sizeof(pInfo));
    pInfo.processInfoLength = sizeof( ProcessInfoRec );
    err = GetProcessInformation(&m_psnCurrentProcess, &pInfo);
    if (!err) {
        psn = pInfo.processLauncher;
        memset(&pInfo, 0, sizeof(pInfo));
        pInfo.processInfoLength = sizeof( ProcessInfoRec );
        err = GetProcessInformation(&psn, &pInfo);
    }
    // Don't open main window if we were started automatically at login
    if (pInfo.processSignature == 'lgnw') {  // Login Window app
        m_bGUIVisible = false;

        // If the system was just started, we usually get a "Connection 
        // failed" error if we try to connect too soon, so delay a bit.
        sleep(10);
    }
#endif

    // Show the UI
    SetActiveGUI(m_iGUISelected, m_bGUIVisible);

    if (!m_bGUIVisible) {
#ifdef __WXMAC__
        // We don't call Hide() or Show(false) for the main frame
        // under wxCocoa 2.9.5 because it bounces the Dock icon
        // (as in notification.)  We work around this by moving
        // the main window/frame off screen here.
        // The position will be restored in one of these methods:
        // CBOINCGUIApp::OnActivateApp(), CSimpleFrame::SaveState()
        // or CAdvancedFrame::SaveWindowDimensions().
        if (m_pFrame) {
            m_pFrame->MoveFrameOffScreen();
            m_pFrame->Show();
        }
#endif
        ShowApplication(false);
	}

    if (bOpenEventLog) {
        DisplayEventLog(m_bGUIVisible);
        if (m_bGUIVisible && m_pFrame) {
            m_pFrame->Raise();
        }
    }
    
    return true;
}
Ejemplo n.º 11
0
Calendario::Calendario(const wxString& title, const wxPoint& pos, const wxSize& size)
       : wxFrame((wxFrame *)NULL, -1, title, pos, size)
{
	
	//SetIcon(wxICON(ICONOCAL));
    wxMenu *archivo = new wxMenu;
	wxMenu* ventana=new wxMenu;
	wxMenu* ayuda=new wxMenu;
	this->SetTitle(_("Divel Calendar"));
	this->SetSize(800,600);
	
    ayuda->Append(ID_OPT, _("Configuracion"),_("Ajuste las configuraciones"));
	ayuda->Append( ID_About, _("&Acerca") );
	
	archivo->Append(ID_ADDEVT, _("&Anadir evento"));
	archivo->Append(ID_ADDREC, _("A&nadir recordatorio"));
    //archivo->AppendSeparator();
	//archivo->Append(ID_OPEN, "A&brir calendario");
	//archivo->Append(ID_SAVE, "&Guardar calendario");
	archivo->AppendSeparator();
    archivo->Append( ID_Quit, _("&Salir") );
	ventana->Append(ID_CHAT,_("&DivChat"),_("Abre la ventana de chat"));
	//ventana->Append(ID_EVENTS, "D&ivelEvents","Abre la ventana de eventos Divel");
	//ventana->Append(ID_NOTES, "Divel &Notes","Abre la ventana de apuntes");

    wxMenuBar *menuBar = new wxMenuBar;
    menuBar->Append( archivo, _("&Archivo") );
	menuBar->Append(ventana,_("&Ventana"));
	menuBar->Append(ayuda,_("A&yuda"));
    SetMenuBar( menuBar );
	//Crear Frame principal
	wxInitAllImageHandlers();
	
	wxString appdata=wxString::FromUTF8(getenv("HOME"));
	if(wxDirExists(appdata+_("/Divel/Calendar"))==false)
	{
	
		wxMkdir(appdata+_("/Divel"));
		wxMkdir(appdata+_("/Divel/Calendar"));
		//wxCopyFile("./conf.cfg",appdata+"\\Divel\\Calendar\\conf.cfg");
	
	
	}else if(wxFileExists(appdata+_("/Divel/Calendar/conf.cfg"))==true){
		int fuente=0, color=0,posicion=0,premium=0;
		wxString situacionconf=appdata+_("/Divel/Calendar/conf.cfg");
		ifstream configfile(situacionconf.mb_str(),ifstream::in);
		if(configfile.good())
		{

			char buffer;
			buffer=configfile.get();
			wxString conffile=wxChar(buffer);
			while(!configfile.eof())
			{
				buffer=configfile.get();

				if(buffer=='1'){
					printf("Uno detectado");
				switch(posicion){
				case 0: {fondo=1;posicion++;}break;
				case 1: {fuente=1;posicion++;}break;
				case 2: {color=1;posicion++;}break;
				case 3: {premium=1;posicion++;}break;

				}}
				if(buffer=='0'){
					printf("Cero detectado");
				posicion++;
				}
				conffile+=buffer;
			}
			configfile.close();
			
		}
		
		if(fondo==1){
	
		}
		if(premium==1){
			wxMessageBox(_("Bienvenido usuario premium"));
		}
	
	}
	
	panel=new wxPanel(this);
	panel->SetBackgroundColour(wxColour(_("white")));
	calendar=new wxPanel(panel,1,1,600,400);
	//calendar->SetBackgroundColour(wxColour("red"));
	calendar->Connect(wxEVT_PAINT,wxPaintEventHandler(Calendario::Paint));


	/*this->SetFont(wxFont(14,1,1,3,true));
	this->SetFont(wxFont(12,2,1,3,true));
	panel->SetFont(wxFont(12,3,1,3,true));*/
	//wxFontPickerCtrl* fuentedlg=new wxFontPickerCtrl(panel,wxID_ANY,wxNullFont,wxPoint(-1,-1));


	//Sistema de fuentes
	/*
	wxFontDialog* fuente=new wxFontDialog();
	fuente->ShowModal();
	wxFontData mifuente=fuente->GetFontData();
	wxFont lafuente=mifuente.GetChosenFont();
	panel->SetFont(lafuente);
	this->SetFont(lafuente);
	*/
	if(fondo==1){
	wxBitmap fondo(appdata+_("/Divel/Calendar/fondo.png"),wxBITMAP_TYPE_PNG);
	wxStaticBitmap* fonpantalla=new wxStaticBitmap(panel,wxID_ANY,fondo,wxDefaultPosition,wxDefaultSize);
	}
	wxButton* anadirevt=new wxButton(panel,ID_ADDEVT,_("Anadir evento"),wxPoint(610,20),wxSize(150,50));
	wxButton* anadirrec=new wxButton(panel,ID_ADDREC,_("Anadir recordatorio"),wxPoint(610,80),wxSize(150,50));
	wxButton* del=new wxButton(panel,ID_DELETE,_("Borrar evento"),wxPoint(610,140),wxSize(150,50));
	wxButton* ver=new wxButton(panel,ID_VER,_("Ver evento"),wxPoint(610,200),wxSize(150,50));
	wxButton* divchat=new wxButton(panel,ID_CHAT,_("DivChat"),wxPoint(610,260),wxSize(150,50));
	desc=new wxStaticText(panel,wxID_ANY,_("Ningun evento seleccionado"),wxPoint(1,410));
	//wxPanel* calendar=new wxPanel(panel,-1,-1,600,400);
	/*wxMemoryDC* memoria=new wxMemoryDC;
	wxClientDC calendario(panel);
	//memoria->DrawCircle(wxPoint(1,1),wxCoord(32));
	//calendario.Blit(wxPoint(-1,-1),wxSize(600,400),memoria,wxPoint(-1,-1));
	calendario.DrawCircle(wxPoint(1,1),wxCoord(32));*/
	wxCalendarCtrl* calendarctrl=new wxCalendarCtrl(calendar,ID_CAL,wxDefaultDateTime,wxPoint(1,1),wxSize(600,400),wxCAL_MONDAY_FIRST);
	Connect(ID_ADDEVT, wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(Calendario::CrearEvento));
	Connect(ID_ADDREC, wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(Calendario::CrearRecordatorio));
	Connect(ID_VER, wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(Calendario::VerEvento));
	Connect(ID_DELETE, wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(Calendario::BorrarEvento));
	Connect(ID_CHAT,wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(Calendario::DivelChat));

    CreateStatusBar();
    SetStatusText(_("Bienvenido a Divel Calendar"));
}
Ejemplo n.º 12
0
void ThemeBase::SaveComponents()
{
   // IF directory doesn't exist THEN create it
   if( !wxDirExists( FileNames::ThemeComponentsDir() ))
   {
      /// \bug 1 in wxWidgets documentation; wxMkDir returns false if 
      /// directory didn't exist, even if it successfully creates it.
      /// so we create and then test if it exists instead.
      /// \bug 2 in wxWidgets documentation; wxMkDir has only one argument
      /// under MSW
#ifdef __WXMSW__
      wxMkDir( FileNames::ThemeComponentsDir().fn_str() );
#else
      wxMkDir( FileNames::ThemeComponentsDir().fn_str(), 0700 );
#endif
      if( !wxDirExists( FileNames::ThemeComponentsDir() ))
      {
         wxMessageBox(
            wxString::Format( 
            _("Could not create directory:\n  %s"),
               FileNames::ThemeComponentsDir().c_str() ));
         return;
      }
   }

   wxBusyCursor busy;
   int i;
   int n=0;
   wxString FileName;
   for(i=0;i<(int)mImages.GetCount();i++)
   {
      if( (mBitmapFlags[i] & resFlagInternal)==0)
      {
         FileName = FileNames::ThemeComponent( mBitmapNames[i] );
         if( !wxFileExists( FileName ))
         {
            if( !mImages[i].SaveFile( FileName, wxBITMAP_TYPE_PNG ))
            {
               wxMessageBox(
                  wxString::Format( 
                  _("Audacity could not save file:\n  %s"),
                     FileName.c_str() ));
               return;
            }
            n++;
         }
      }
   }
   if( n==0 )
   {
      wxMessageBox(
         wxString::Format( 
         _("All required files in:\n  %s\nwere already present."),
            FileNames::ThemeComponentsDir().c_str() ));
      return;
   }
   wxMessageBox(
      wxString::Format( 
         wxT("Theme written to:\n  %s."),
         FileNames::ThemeComponentsDir().c_str() ));
}
Ejemplo n.º 13
0
void OnOptions2(int event_id)
{//==========================
	wxString string;
	int value;

	switch(event_id)
	{
	case MENU_OPT_SPEED:
		value = wxGetNumberFromUser(_T(""),_T(""),_T("Speed"),option_speed,80,500);
		if(value > 0)
		{
			option_speed = value;
			SetParameter(espeakRATE,option_speed,0);
			SetSpeed(3);
		}
		break;

	case MENU_OPT_PUNCT:
		transldlg->t_source->SetValue(_T("<tts:style field=\"punctuation\" mode=\"all\">\n"));
		transldlg->t_source->SetInsertionPointEnd();
		notebook->SetSelection(1);
		break;

	case MENU_OPT_SPELL:
		transldlg->t_source->SetValue(_T("<say-as interpret-as=\"characters\">\n"));
		transldlg->t_source->SetInsertionPointEnd();
		notebook->SetSelection(1);
		break;

	case MENU_OPT_SPELL2:
		transldlg->t_source->SetValue(_T("<say-as interpret-as=\"tts:char\">\n"));
		transldlg->t_source->SetInsertionPointEnd();
		notebook->SetSelection(1);
		break;

	case MENU_PATH_DATA:
		string = wxDirSelector(_T("espeak_data directory"), wxEmptyString);
		if(!string.IsEmpty())
		{
			if(!wxDirExists(string+_T("/voices")))
			{
				wxLogError(_T("No 'voices' directory in ") + string);
				break;
			}
			path_espeakdata = string;
			wxLogMessage(_T("Quit and restart espeakedit to use the new espeak_data location"));
		}
		break;

	case MENU_PATH0:
		string = wxFileSelector(_T("Master phonemes file"),wxFileName(path_phfile).GetPath(),
			_T("phonemes"),_T(""),_T("*"),wxOPEN);
		if(!string.IsEmpty())
		{
			path_phfile = string;
		}
		break;

	case MENU_PATH1:
		string = wxDirSelector(_T("Phoneme source directory"),path_phsource);
		if(!string.IsEmpty())
		{
			path_phsource = string;
		}
		break;

	case MENU_PATH2:
		string = wxDirSelector(_T("Dictionary source directory"),path_dictsource);
		if(!string.IsEmpty())
		{
			path_dictsource = string;
		}
		break;

	case MENU_PATH3:
		string = wxFileSelector(_T("Sound output file"),wxFileName(path_speech).GetPath(),
			_T(""),_T("WAV"),_T("*"),wxSAVE);
		if(!string.IsEmpty())
		{
			path_speech = string;
		}
		break;

	case MENU_PATH4:
		string = wxFileSelector(_T("Voice file to modify formant peaks"),wxFileName(path_speech).GetPath(),
			_T(""),_T(""),_T("*"),wxOPEN);
		if(!string.IsEmpty())
		{
			path_modifiervoice = string;
		}
		break;
	}

	ConfigSetPaths();
}
Ejemplo n.º 14
0
void wxGenericFileCtrl::HandleAction( const wxString &fn )
{
    if ( m_ignoreChanges )
        return;

    wxString filename( fn );
    if ( filename.empty() )
    {
        return;
    }
    if ( filename == wxT( "." ) ) return;

    wxString dir = m_list->GetDir();

    // "some/place/" means they want to chdir not try to load "place"
    const bool want_dir = filename.Last() == wxFILE_SEP_PATH;
    if ( want_dir )
        filename = filename.RemoveLast();

    if ( filename == wxT( ".." ) )
    {
        m_ignoreChanges = true;
        m_list->GoToParentDir();

        GenerateFolderChangedEvent( this, this );

        UpdateControls();
        m_ignoreChanges = false;
        return;
    }

#ifdef __UNIX__
    if ( filename == wxT( "~" ) )
    {
        m_ignoreChanges = true;
        m_list->GoToHomeDir();

        GenerateFolderChangedEvent( this, this );

        UpdateControls();
        m_ignoreChanges = false;
        return;
    }

    if ( filename.BeforeFirst( wxT( '/' ) ) == wxT( "~" ) )
    {
        filename = wxString( wxGetUserHome() ) + filename.Remove( 0, 1 );
    }
#endif // __UNIX__

    if ( !( m_style & wxFC_SAVE ) )
    {
        if ( ( filename.Find( wxT( '*' ) ) != wxNOT_FOUND ) ||
                ( filename.Find( wxT( '?' ) ) != wxNOT_FOUND ) )
        {
            if ( filename.Find( wxFILE_SEP_PATH ) != wxNOT_FOUND )
            {
                wxMessageBox( _( "Illegal file specification." ),
                              _( "Error" ), wxOK | wxICON_ERROR, this );
                return;
            }
            m_list->SetWild( filename );
            return;
        }
    }

    if ( !IsTopMostDir( dir ) )
        dir += wxFILE_SEP_PATH;
    if ( !wxIsAbsolutePath( filename ) )
    {
        dir += filename;
        filename = dir;
    }

    if ( wxDirExists( filename ) )
    {
        m_ignoreChanges = true;
        m_list->GoToDir( filename );
        UpdateControls();

        GenerateFolderChangedEvent( this, this );

        m_ignoreChanges = false;
        return;
    }

    // they really wanted a dir, but it doesn't exist
    if ( want_dir )
    {
        wxMessageBox( _( "Directory doesn't exist." ), _( "Error" ),
                      wxOK | wxICON_ERROR, this );
        return;
    }

    // append the default extension to the filename if it doesn't have any
    //
    // VZ: the logic of testing for !wxFileExists() only for the open file
    //     dialog is not entirely clear to me, why don't we allow saving to a
    //     file without extension as well?
    if ( !( m_style & wxFC_OPEN ) || !wxFileExists( filename ) )
    {
        filename = wxFileDialogBase::AppendExtension( filename, m_filterExtension );
        GenerateFileActivatedEvent( this, this, wxFileName( filename ).GetFullName() );
        return;
    }

    GenerateFileActivatedEvent( this, this );
}
Ejemplo n.º 15
0
 bool AbstractFileManager::isDirectory(const String& path) {
     return wxDirExists(path);
 }
Ejemplo n.º 16
0
bool NativeFileSystem::DirExists(const std::string & path)
{
	return wxDirExists(path);
}
Ejemplo n.º 17
0
//////////////////////////////////////////////////////////////////////////
// Get system wide configuration file names
//////////////////////////////////////////////////////////////////////////
wxString sysSettings::GetConfigFile(configFileName cfgname)
{
    wxASSERT_MSG(cfgname == sysSettings::PGPASS,
                 wxT("Handles only pgpass configuration"));
    if (cfgname == PGPASS)
    {
#if wxCHECK_VERSION(2, 9, 5)
        wxStandardPaths &stdp = wxStandardPaths::Get();
#else
        wxStandardPaths stdp;
#endif
        wxString fname;
        bool bpsfile = wxGetEnv(wxT("PGPASSFILE"), &fname);
        if (!bpsfile)
        {
            fname = stdp.GetUserConfigDir();
#ifdef WIN32
            fname += wxT("\\postgresql");
            if (!wxDirExists(fname))
                wxMkdir(fname);
            fname += wxT("\\pgpass.conf");
        }
#else
            fname += wxT("/.pgpass");
        }
#endif
        else
        {
            if(!wxFileName::FileExists(fname))
            {
                wxFileName dirTemp = wxFileName::DirName(fname);
                /*
                 * wxFileName::DirName() does not return the directory path of
                 * the file. It assumes that the given path is of a directory,
                 * when the specified file/directory does not exist.
                 *
                 * Hence - removeing it to get the actual parent directory.
                 */
                dirTemp.RemoveLastDir();

                if (!dirTemp.DirExists())
                {
                    wxFileName dir = dirTemp;

                    // Decide which are folders we need to create
                    wxString sRemoveOnError = dirTemp.GetPath();

                    while(!dirTemp.DirExists())
                    {
                        sRemoveOnError = dirTemp.GetPath();
                        dirTemp.RemoveLastDir();
                    }

                    if (!dir.Mkdir(0755, wxPATH_MKDIR_FULL))
                    {
                        // In case of failure decide - we may need to delete
                        // the created directory structure from exists parent
                        // directory.
                        if (wxDir::Exists(sRemoveOnError))
                            wxFileName::Rmdir(sRemoveOnError);
                    }
                }
            }
        }

        wxFile f;
        if (!f.Exists(fname))
            f.Create(fname, false, wxS_IRUSR | wxS_IWUSR);

        return fname;
    }
Ejemplo n.º 18
0
bool wxvbamApp::OnInit()
{
	// use consistent names for config
	SetAppName(_("vbam"));
#if (wxMAJOR_VERSION >= 3)
	SetAppDisplayName(_T("VisualBoyAdvance-M"));
#endif
	// load system default locale, if available
	locale.Init();
	locale.AddCatalog(_T("wxvbam"));
	// make built-in xrc file available
	// this has to be done before parent OnInit() so xrc dump works
	wxFileSystem::AddHandler(new wxMemoryFSHandler);
	wxFileSystem::AddHandler(new wxArchiveFSHandler);
	wxMemoryFSHandler::AddFileWithMimeType(wxT("wxvbam.xrs"), builtin_xrs, sizeof(builtin_xrs), wxT("application/zip"));

	if (!wxApp::OnInit())
		return false;

	// prepare for loading xrc files
	wxXmlResource* xr = wxXmlResource::Get();
	// note: if linking statically, next 2 pull in lot of unused code
	// maybe in future if not wxSHARED, load only builtin-needed handlers
	xr->InitAllHandlers();
	wxInitAllImageHandlers();
	get_config_path(config_path);
	// first, load override xrcs
	// this can only override entire root nodes
	// 2.9 has LoadAllFiles(), but this is 2.8, so we'll do it manually
	wxString cwd = wxGetCwd();

	for (int i = 0; i < config_path.size(); i++)
		if (wxDirExists(config_path[i]) && wxSetWorkingDirectory(config_path[i]))
		{
			// *.xr[cs] doesn't work (double the number of scans)
			// 2.9 gives errors for no files found, so manual precheck needed
			// (yet another double the number of scans)
			if (!wxFindFirstFile(wxT("*.xrc")).empty())
				xr->Load(wxT("*.xrc"));

			if (!wxFindFirstFile(wxT("*.xrs")).empty())
				xr->Load(wxT("*.xrs"));
		}

	wxFileName xrcDir(GetConfigurationPath() + wxT("//xrc"), wxEmptyString);

	if (xrcDir.DirExists() && wxSetWorkingDirectory(xrcDir.GetFullPath()) && !wxFindFirstFile(wxT("*.xrc")).empty())
	{
		xr->Load(wxT("*.xrc"));
	}
	else
	{
		// finally, load built-in xrc
		xr->Load(wxT("memory:wxvbam.xrs"));
	}

	wxSetWorkingDirectory(cwd);
	// set up config file
	// this needs to be in a subdir to support other config as well
	// but subdir flag behaves differently 2.8 vs. 2.9.  Oh well.
	// NOTE: this does not support XDG (freedesktop.org) paths
#if defined(__WXMSW__) || defined(__APPLE__)
	wxFileName vbamconf(GetConfigurationPath(), _T("vbam.ini"));
	cfg = new wxFileConfig(wxT("vbam"), wxEmptyString,
	                       vbamconf.GetFullPath(),
	                       wxEmptyString, wxCONFIG_USE_LOCAL_FILE);
#else
	cfg = new wxFileConfig(wxEmptyString, wxEmptyString, wxEmptyString,
	                       wxEmptyString,
	                       // style =
	                       wxCONFIG_USE_GLOBAL_FILE | wxCONFIG_USE_LOCAL_FILE |
	                       wxCONFIG_USE_SUBDIR);
#endif
	// set global config for e.g. Windows font mapping
	wxFileConfig::Set(cfg);
	// yet another bug/deficiency in wxConfig: dirs are not created if needed
	// since a default config is always written, dirs are always needed
	// Can't figure out statically if using wxFileConfig w/o duplicating wx's
	// logic, so do it at run-time
	// wxFileConfig *f = wxDynamicCast(cfg, wxFileConfig);
	// wxConfigBase does not derive from wxObject!!! so no wxDynamicCast
	wxFileConfig* fc = dynamic_cast<wxFileConfig*>(cfg);

	if (fc)
	{
		wxFileName s(wxFileConfig::GetLocalFileName(GetAppName()));
		// at least up to 2.8.12, GetLocalFileName returns the dir if
		// SUBDIR is specified instead of actual file name
		// and SUBDIR only affects UNIX
#if defined(__UNIX__) && !wxCHECK_VERSION(2,9,0)
		s.AppendDir(s.GetFullName());
#endif
		// only the path part gets created
		// note that 0777 is default (assumes umask will do og-w)
		s.Mkdir(0777, wxPATH_MKDIR_FULL);
		s = wxFileName::DirName(GetConfigurationPath());
		s.Mkdir(0777, wxPATH_MKDIR_FULL);
	}

	load_opts();

	// process command-line options
	for (int i = 0; i < pending_optset.size(); i++)
	{
		wxString p = pending_optset[i];
		size_t eqat = p.find(wxT('='));
		p[eqat] = 0;
		opt_set(p.c_str(), p.c_str() + eqat + 1);
	}

	pending_optset.clear();
	wxFileName vba_over(GetConfigurationPath(), wxT("vba-over.ini"));
	wxFileName rdb(GetConfigurationPath(), wxT("Nintendo - Game Boy Advance*.dat"));
	wxFileName scene_rdb(GetConfigurationPath(), wxT("Nintendo - Game Boy Advance (Scene)*.dat"));
	wxFileName nointro_rdb(GetConfigurationPath(), wxT("Official No-Intro Nintendo Gameboy Advance Number (Date).xml"));
	wxString f = wxFindFirstFile(nointro_rdb.GetFullPath(), wxFILE);

	if (!f.empty() && wxFileName(f).IsFileReadable())
		rom_database_nointro = f;

	f = wxFindFirstFile(scene_rdb.GetFullPath(), wxFILE);

	if (!f.empty() && wxFileName(f).IsFileReadable())
		rom_database_scene = f;

	f = wxFindFirstFile(rdb.GetFullPath(), wxFILE);

	while (!f.empty())
	{
		if (f == rom_database_scene.GetFullPath())
		{
			f = wxFindNextFile();
		}
		else if (wxFileName(f).IsFileReadable())
		{
			rom_database = f;
			break;
		}
	}

	// load vba-over.ini
	// rather than dealing with wxConfig's broken search path, just use
	// the same one that the xrc overrides use
	// this also allows us to override a group at a time, add commments, and
	// add the file from which the group came
	wxMemoryInputStream mis(builtin_over, sizeof(builtin_over));
	overrides = new wxFileConfig(mis);
	wxRegEx cmtre;
	// not the most efficient thing to do: read entire file into a string
	// just to parse the comments out
	wxString bovs((const char*)builtin_over, wxConvUTF8, sizeof(builtin_over));
	bool cont;
	wxString s;
	long grp_idx;
#define CMT_RE_START wxT("(^|[\n\r])# ?([^\n\r]*)(\r?\n|\r)\\[")

	for (cont = overrides->GetFirstGroup(s, grp_idx); cont;
	        cont = overrides->GetNextGroup(s, grp_idx))
	{
		// apparently even MacOSX sometimes uses the old \r by itself
		wxString cmt(CMT_RE_START);
		cmt += s + wxT("\\]");

		if (cmtre.Compile(cmt) && cmtre.Matches(bovs))
			cmt = cmtre.GetMatch(bovs, 2);
		else
			cmt = wxEmptyString;

		overrides->Write(s + wxT("/comment"), cmt);
	}

	if (vba_over.FileExists())
	{
		wxStringOutputStream sos;
		wxFileInputStream fis(vba_over.GetFullPath());
		// not the most efficient thing to do: read entire file into a string
		// just to parse the comments out
		fis.Read(sos);
		// rather than assuming the file is seekable, use the string we just
		// read as an input stream
		wxStringInputStream sis(sos.GetString());
		wxFileConfig ov(sis);

		for (cont = ov.GetFirstGroup(s, grp_idx); cont;
		        cont = ov.GetNextGroup(s, grp_idx))
		{
			overrides->DeleteGroup(s);
			overrides->SetPath(s);
			ov.SetPath(s);
			overrides->Write(wxT("path"), GetConfigurationPath());
			// apparently even MacOSX sometimes uses \r by itself
			wxString cmt(CMT_RE_START);
			cmt += s + wxT("\\]");

			if (cmtre.Compile(cmt) && cmtre.Matches(sos.GetString()))
				cmt = cmtre.GetMatch(sos.GetString(), 2);
			else
				cmt = wxEmptyString;

			overrides->Write(wxT("comment"), cmt);
			long ent_idx;

			for (cont = ov.GetFirstEntry(s, ent_idx); cont;
			        cont = ov.GetNextEntry(s, ent_idx))
				overrides->Write(s, ov.Read(s, wxEmptyString));

			ov.SetPath(wxT("/"));
			overrides->SetPath(wxT("/"));
		}
	}

	// create the main window
	frame = wxDynamicCast(xr->LoadFrame(NULL, wxT("MainFrame")), MainFrame);

	if (!frame)
	{
		wxLogError(_("Could not create main window"));
		return false;
	}

	// Create() cannot be overridden easily
	if (!frame->BindControls())
		return false;

	frame->Show(true);
	return true;
}
Ejemplo n.º 19
0
void EditorColourSet::LoadAvailableSets()
{
    // no need for syntax highlighting if batch building
    if (Manager::IsBatchBuild())
        return;

    wxDir dir;
    wxString filename;
    FileManager *fm = FileManager::Get();
    std::list<LoaderBase*> loaders;
    int count = 0;

    // user paths first
    wxString path = ConfigManager::GetFolder(sdDataUser) + _T("/lexers/");
    if (wxDirExists(path) && dir.Open(path))
    {
        Manager::Get()->GetLogManager()->Log(F(_("Scanning for lexers in %s..."), path.wx_str()));
        bool ok = dir.GetFirst(&filename, _T("lexer_*.xml"), wxDIR_FILES);
        while (ok)
        {
            loaders.push_back(fm->Load(path + filename));
            ok = dir.GetNext(&filename);
            ++count;
        }
        Manager::Get()->GetLogManager()->Log(F(_("Found %d lexers"), count));
        count = 0;
    }

    // global paths next
    path = ConfigManager::GetFolder(sdDataGlobal) + _T("/lexers/");
    if (wxDirExists(path) && dir.Open(path))
    {
        Manager::Get()->GetLogManager()->Log(F(_("Scanning for lexers in %s..."), path.wx_str()));
        bool ok = dir.GetFirst(&filename, _T("lexer_*.xml"), wxDIR_FILES);
        while (ok)
        {
            loaders.push_back(fm->Load(path + filename));
            ok = dir.GetNext(&filename);
            ++count;
        }
        Manager::Get()->GetLogManager()->Log(F(_("Found %d lexers"), count));
    }

    EditorLexerLoader lex(this);
    for (std::list<LoaderBase*>::iterator it = loaders.begin(); it != loaders.end(); ++it)
        lex.Load(*it);

    ::Delete(loaders);


    for (OptionSetsMap::iterator it = m_Sets.begin(); it != m_Sets.end(); ++it)
    {
        wxString lang = it->second.m_Langs;
        if (lang.IsEmpty())
            continue;

        // keep the original filemasks and keywords, so we know what needs saving later
        for (int i = 0; i <= wxSCI_KEYWORDSET_MAX; ++i)
        {
            it->second.m_originalKeywords[i] = it->second.m_Keywords[i];
        }
        it->second.m_originalFileMasks = it->second.m_FileMasks;

        // remove old settings, no longer used
        unsigned int i = 0;
        while (i < it->second.m_Colours.GetCount())
        {
            OptionColour* opt = it->second.m_Colours.Item(i);
            // valid values are:
            if (opt->value < 0 &&               // styles >= 0
                opt->value != cbSELECTION &&    // cbSELECTION
                opt->value != cbHIGHLIGHT_LINE) // cbHIGHLIGHT_LINE
            {
                it->second.m_Colours.Remove(opt);
                delete opt;
            }
            else
                ++i;
        }
    }
}
Ejemplo n.º 20
0
/* static */
bool wxDir::Exists(const wxString& dir)
{
    return wxDirExists(dir);
}
Ejemplo n.º 21
0
//=============================================================================
// Function: BuildListFromNN
// Purpose: Append or remove items from the list
// Notes: - There is no way to find all disconnected NN items, or even to find
//          all items while determining which are connected and not.  So this
//          function will find either all items or connected items.
//=============================================================================
static void BuildListFromNN(wxArrayString& list, NETRESOURCE* pResSrc,
                            unsigned flagsSet, unsigned flagsUnset)
{
    HANDLE hEnum;
    int rc;

    //-----------------------------------------------
    // Scope may be all drives or all mounted drives.
    //-----------------------------------------------
    unsigned scope = RESOURCE_GLOBALNET;
    if (flagsSet & wxFS_VOL_MOUNTED)
        scope = RESOURCE_CONNECTED;

    //----------------------------------------------------------------------
    // Enumerate all items, adding only non-containers (ie. network shares).
    // Containers cause a recursive call to this function for their own
    // enumeration.
    //----------------------------------------------------------------------
    if (rc = s_pWNetOpenEnum(scope, RESOURCETYPE_DISK, 0, pResSrc, &hEnum), rc == NO_ERROR)
    {
        DWORD count = 1;
        DWORD size = 256;
        NETRESOURCE* pRes = (NETRESOURCE*)malloc(size);
        memset(pRes, 0, sizeof(NETRESOURCE));
        while (rc = s_pWNetEnumResource(hEnum, &count, pRes, &size), rc == NO_ERROR || rc == ERROR_MORE_DATA)
        {
            if (s_cancelSearch)
                break;

            if (rc == ERROR_MORE_DATA)
            {
                pRes = (NETRESOURCE*)realloc(pRes, size);
                count = 1;
            }
            else if (count == 1)
            {
                // Enumerate the container.
                if (pRes->dwUsage & RESOURCEUSAGE_CONTAINER)
                {
                    BuildListFromNN(list, pRes, flagsSet, flagsUnset);
                }

                // Add the network share.
                else
                {
                    wxString filename(pRes->lpRemoteName);

                    // if the drive is unavailable, FilteredAdd() can hang for
                    // a long time and, moreover, its failure appears to be not
                    // cached so this will happen every time we use it, so try
                    // a much quicker wxDirExists() test (which still hangs but
                    // for much shorter time) for locally mapped drives first
                    // to try to avoid this
                    if ( pRes->lpLocalName &&
                            *pRes->lpLocalName &&
                                !wxDirExists(pRes->lpLocalName) )
                        continue;

                    if (!filename.empty())
                    {
                        if (filename.Last() != '\\')
                            filename.Append('\\');

                        // The filter function will not know mounted from unmounted, and neither do we unless
                        // we are iterating using RESOURCE_CONNECTED, in which case they all are mounted.
                        // Volumes on disconnected servers, however, will correctly show as unmounted.
                        FilteredAdd(list, filename.t_str(), flagsSet, flagsUnset&~wxFS_VOL_MOUNTED);
                        if (scope == RESOURCE_GLOBALNET)
                            s_fileInfo[filename].m_flags &= ~wxFS_VOL_MOUNTED;
                    }
                }
            }
            else if (count == 0)
                break;
        }
        free(pRes);
        s_pWNetCloseEnum(hEnum);
    }
} // BuildListFromNN
Ejemplo n.º 22
0
//! @brief Initializes the application.
//!
//! It will open the main window and connect default to server or open the connect window.
bool SpringLobbyApp::OnInit()
{
    //this triggers the Cli Parser amongst other stuff
    if (!wxApp::OnInit())
        return false;
    SetAppName( m_appname );

    if (!m_crash_handle_disable) {
#if wxUSE_ON_FATAL_EXCEPTION
        wxHandleFatalExceptions( true );
#endif
#if defined(__WXMSW__) && defined(ENABLE_DEBUG_REPORT)
        //this undocumented function acts as a workaround for the dysfunctional
        // wxUSE_ON_FATAL_EXCEPTION on msw when mingw is used (or any other non SEH-capable compiler )
        SetUnhandledExceptionFilter(filter);
#endif
    }

    //initialize all loggers, we'll use the returned pointer to set correct parent window later
    wxLogChain* logchain = 0;
    wxLogWindow *loggerwin = InitializeLoggingTargets( 0, m_log_console, m_log_file_path, m_log_window_show, !m_crash_handle_disable, m_log_verbosity, logchain );

    //this needs to called _before_ mainwindow instance is created
    wxInitAllImageHandlers();
    wxFileSystem::AddHandler(new wxZipFSHandler);
    wxSocketBase::Initialize();


#ifdef __WXMSW__
    wxString path = wxPathOnly( wxStandardPaths::Get().GetExecutablePath() ) + wxFileName::GetPathSeparator() + _T("locale");
#else
#if defined(LOCALE_INSTALL_DIR)
    wxString path ( _T(LOCALE_INSTALL_DIR) );
#else
    // use a dummy name here, we're only interested in the base path
    wxString path = wxStandardPaths::Get().GetLocalizedResourcesDir(_T("noneWH"),wxStandardPaths::ResourceCat_Messages);
    path = path.Left( path.First(_T("noneWH") ) );
#endif
#endif
    m_translationhelper = new wxTranslationHelper( *( (wxApp*)this ), path );
    m_translationhelper->Load();

    if ( !wxDirExists( GetConfigfileDir() ) )
        wxMkdir( GetConfigfileDir() );

#ifdef __WXMSW__
    sett().SetSearchSpringOnlyInSLPath( sett().GetSearchSpringOnlyInSLPath() );
#endif
    sett().SetSpringBinary( sett().GetCurrentUsedSpringIndex(), sett().GetCurrentUsedSpringBinary() );
    sett().SetUnitSync( sett().GetCurrentUsedSpringIndex(), sett().GetCurrentUsedUnitSync() );

    if ( sett().DoResetPerspectives() )
    {
        //we do this early on and reset the config var a little later so we can save a def. perps once mw is created
        sett().RemoveLayouts();
        sett().SetDoResetPerspectives( false );
        ui().mw().SavePerspectives( _T("SpringLobby-default") );
    }

    sett().RefreshSpringVersionList();

    //!currently we cannot use the dialog in simple, because it uses Ui and therefore creates mainwindow
    if ( !m_start_simple_interface )
        //this should take off the firstload time considerably *ie nil it :P )
        mapSelectDialog();
    //unitsync first load, NEEDS to be blocking
    usync().ReloadUnitSyncLib();

#ifndef DISABLE_SOUND
    //sound sources/buffer init
    sound();
#endif


    CacheAndSettingsSetup();

    if ( !m_customizer_modname.IsEmpty() ) {
        if ( SLcustomizations().Init( m_customizer_modname ) ) {
            if ( m_start_simple_interface ) {
                SimpleFront* sp = new SimpleFront( 0 );
                SetTopWindow( sp );
                sp->Show();
                return true;
            }
            ui().mw().SetIcon( SLcustomizations().GetAppIcon() );
        }
        else {
            customMessageBox( 3, _("Couldn't load customizations for ") + m_customizer_modname + _("\nPlease check that that is the correct name, passed in qoutation"), _("Fatal error"), wxOK );
//            wxLogError( _("Couldn't load customizations for ") + m_customizer_modname + _("\nPlease check that that is the correct name, passed in qoutation"), _("Fatal error") );
            exit( OnExit() );//for some twisted reason returning false here does not terminate the app
        }
    }

    notificationManager(); //needs to be initialized too
    ui().ShowMainWindow();
    SetTopWindow( &ui().mw() );
    if ( sett().DoResetPerspectives() )
    {
        //now that mainwindow is shown, we can save what is the default layout and remove the flag to reset
        sett().SetDoResetPerspectives( false );
        ui().mw().SavePerspectives( _T("SpringLobby-default") );
    }

    //interim fix for resize crashes on metacity and kwin
#ifdef __WXMSW__
    mapSelectDialog().Reparent( &ui().mw() );
#endif

    ui().FirstRunWelcome();
    m_timer->Start( TIMER_INTERVAL );

    ui().mw().SetLogWin( loggerwin, logchain );

#ifndef NO_TORRENT_SYSTEM
    plasmaInterface();
//    plasmaInterface().InitResourceList();
//	plasmaInterface().FetchResourceList();
#endif


    return true;
}
Ejemplo n.º 23
0
Archivo: phd.cpp Proyecto: knro/phd2
bool PhdApp::OnInit()
{
    if (!wxApp::OnInit())
    {
        return false;
    }

    m_instanceChecker = new wxSingleInstanceChecker(wxString::Format("%s.%ld", GetAppName(), m_instanceNumber));
    if (m_instanceChecker->IsAnotherRunning())
    {
        wxLogError(wxString::Format(_("PHD2 instance %ld is already running. Use the "
            "-i INSTANCE_NUM command-line option to start a different instance."), m_instanceNumber));
        delete m_instanceChecker; // OnExit() won't be called if we return false
        m_instanceChecker = 0;
        return false;
    }

#ifndef DEBUG
    #if (wxMAJOR_VERSION > 2 || wxMINOR_VERSION > 8)
    wxDisableAsserts();
    #endif
#endif

    SetVendorName(_T("StarkLabs"));
    pConfig = new PhdConfig(_T("PHDGuidingV2"), m_instanceNumber);

    Debug.Init("debug", true);

    Debug.AddLine(wxString::Format("PHD2 version %s begins execution with:", FULLVER));
    Debug.AddLine(wxString::Format("   %s", wxVERSION_STRING));
    float dummy;
    Debug.AddLine(wxString::Format("   cfitsio %.2lf", ffvers(&dummy)));
#if defined(CV_VERSION)
    Debug.AddLine(wxString::Format("   opencv %s", CV_VERSION));
#endif

#if defined(__WINDOWS__)
    HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
    Debug.AddLine("CoInitializeEx returns %x", hr);
#endif

    DisableOSXAppNap();

    if (m_resetConfig)
    {
        pConfig->DeleteAll();
    }

    wxString ldir = wxStandardPaths::Get().GetResourcesDir() + PATHSEPSTR "locale";
    if (!wxDirExists(ldir))
    {
        // for development environments
        ldir = _T("locale");
    }
    bool ex = wxDirExists(ldir);
    Debug.AddLine(wxString::Format("Using Locale Dir %s exists=%d", ldir, ex));
    wxLocale::AddCatalogLookupPathPrefix(ldir);
    m_localeDir = ldir;

    m_locale.Init(pConfig->Global.GetInt("/wxLanguage", wxLANGUAGE_DEFAULT));
    if (!m_locale.AddCatalog(PHD_MESSAGES_CATALOG))
    {
        Debug.AddLine("locale.AddCatalog failed");
    }
    wxSetlocale(LC_NUMERIC, "C");

    pConfig->InitializeProfile();

    PhdController::OnAppInit();

    wxImage::AddHandler(new wxJPEGHandler);
    wxImage::AddHandler(new wxPNGHandler);

    pFrame = new MyFrame(m_instanceNumber, &m_locale);

    pFrame->Show(true);

    if (pConfig->IsNewInstance() || (pConfig->NumProfiles() == 1 && pFrame->pGearDialog->IsEmptyProfile()))
    {
        pFrame->pGearDialog->ShowProfileWizard();               // First-light version of profile wizard
    }

    return true;
}
Ejemplo n.º 24
0
void SpringLobbyApp::CacheAndSettingsSetup()
{
    SetSettingsStandAlone( false );

    const wxString userConfigDir = GetConfigfileDir();
    if ( sett().IsFirstRun() && !wxDirExists( userConfigDir ) )
    {
        wxMkdir( userConfigDir );
    }
    if ( (sett().GetCacheVersion() < CACHE_VERSION) && !sett().IsFirstRun() )
    {
        sett().SetMapCachingThreadProgress( 0 ); // reset map cache thread
        sett().SetModCachingThreadProgress( 0 ); // reset mod cache thread
        if ( wxDirExists( sett().GetCachePath() )  )
        {
            wxLogWarning( _T("erasing old cache ver %d (app cache ver %d)"), sett().GetCacheVersion(), CACHE_VERSION );
            wxString file = wxFindFirstFile( sett().GetCachePath() + wxFILE_SEP_PATH + _T("*") );
            while ( !file.empty() )
            {
                wxRemoveFile( file );
                file = wxFindNextFile();
            }
        }
    }

    if ( !sett().IsFirstRun() )
    {
        int settversion = sett().GetSettingsVersion();
        if ( settversion < 3 )
        {
            sett().ConvertOldSpringDirsOptions();
        }
        if ( settversion < 4 )
        {
            if ( sett().GetTorrentPort() == DEFSETT_SPRING_PORT ) sett().SetTorrentPort( DEFSETT_SPRING_PORT + 1 );
        }
        if ( settversion < 5 )
        {
            wxArrayString list = sett().GetServers();
            int count = list.GetCount();
            wxArrayString wordlist = sett().GetHighlightedWords();
            for ( int i= 0; i < count; i++ )
            {
                wxString nick = sett().GetServerAccountNick( list[i] );
                if ( wordlist.Index( nick ) == -1 )
                {
                    wordlist.Add( nick );
                }
            }
            sett().SetHighlightedWords( wordlist );
        }
        if ( settversion < 6 )
        {
            sett().ConvertOldServerSettings();
        }
        if ( settversion < 7 )
        {
            sett().AddChannelJoin( _T("springlobby"), _T("") );
        }
        if ( settversion < 8 )
        {
            sett().DeleteServer( _T("Backup server") );
            sett().SetServer( _T("Backup server 1"), _T("springbackup1.servegame.com"), 8200 );
            sett().SetServer( _T("Backup server 2"), _T("springbackup2.servegame.org"), 8200 );
            sett().SetServer( _T("Test server"), _T("taspringmaster.servegame.com"), 8300 );
        }
        if ( settversion < 10 )
        {
            sett().ConvertOldColorSettings();
        }
        if ( settversion < 11 )
        {
            if( IsUACenabled() )
            {
                usync().ReloadUnitSyncLib();
                if ( usync().IsLoaded() ) usync().SetSpringDataPath(_T("")); // UAC is on, fix the spring data path
            }
        }
        if ( settversion < 12 )
        {
            sett().ConvertOldChannelSettings();
        }
        if ( settversion < 13 )
        {
            sett().ConvertOldHiglightSettings();
        }
        if ( settversion < 15 )
        {
            sett().TranslateSavedColumWidths();
        }
        if ( settversion < 21 )
        {
            sett().RemoveLayouts();
        }
        if ( settversion < 18 )
        {
            //new downloader was introduced
            sett().ClearTorrentListToResume();
        }
        if( settversion < 19 )
        {
            //the dummy column hack was removed on win
            sett().NukeColumnWidths();
        }
        if ( settversion < 22 )
        {
            if ( m_translationhelper )
            {
                // add locale's language code to autojoin
                if ( m_translationhelper->GetLocale() )
                {
                    wxString localecode = m_translationhelper->GetLocale()->GetCanonicalName();
                    if ( localecode.Find(_T("_")) != -1 ) localecode = localecode.BeforeFirst(_T('_'));
                    if ( localecode == _T("en") ) // we'll skip en for now, maybe in the future we'll reactivate it
                        sett().AddChannelJoin( localecode, _T("") );
                }
            }
        }
    }

    if ( sett().ShouldAddDefaultServerSettings() || ( sett().GetSettingsVersion() < 14 && sett().GetServers().Count() < 2  ) )
        sett().SetDefaultServerSettings();

    if ( sett().ShouldAddDefaultChannelSettings() )
    {
        sett().AddChannelJoin( _T("main"), _T("") );
        sett().AddChannelJoin( _T("newbies"), _T("") );
        if ( m_translationhelper )
        {
            if ( m_translationhelper->GetLocale() )
            {
                wxString localecode = m_translationhelper->GetLocale()->GetCanonicalName();
                if ( localecode.Find(_T("_")) != -1 ) localecode = localecode.BeforeFirst(_T('_'));
                sett().AddChannelJoin( localecode, _T("") ); // add locale's language code to autojoin
            }
        }
    }

    if ( sett().ShouldAddDefaultGroupSettings() )
    {
        sett().AddGroup( _("Default") );
        sett().AddGroup( _("Ignore PM") );
        useractions().ChangeAction( _("Ignore PM"), UserActions::ActIgnorePM );
        sett().AddGroup( _("Ignore chat") );
        useractions().ChangeAction( _("Ignore chat"), UserActions::ActIgnoreChat );
        sett().AddGroup( _("Battle Autokick") );
        useractions().ChangeAction( _("Battle Autokick"), UserActions::ActAutokick );
        sett().AddGroup( _("Friends") );
        useractions().ChangeAction( _("Friends"), UserActions::ActNotifBattle );
        useractions().ChangeAction( _("Friends"), UserActions::ActHighlight );
        useractions().ChangeAction( _("Friends"), UserActions::ActNotifLogin );
        useractions().SetGroupColor( _("Friends"), wxColour( 0, 0, 255 ) );
    }
}
Ejemplo n.º 25
0
static bool SafeMkdir(const wxString& dir)
{
	if (!wxDirExists(dir))
		return wxMkdir(dir);
	return true;
}
Ejemplo n.º 26
0
bool DirManager::SetProject(wxString & projPath, wxString & projName,
                            bool create)
{
   wxString oldPath = this->projPath;
   wxString oldName = this->projName;
   wxString oldFull = projFull;
   wxString oldLoc = projFull;
   if (oldLoc == wxT(""))
      oldLoc = mytemp;

   if (projPath == wxT(""))
      projPath = ::wxGetCwd();

   this->projPath = projPath;
   this->projName = projName;
   this->projFull = projPath + wxFILE_SEP_PATH + projName;

   wxString cleanupLoc1=oldLoc;
   wxString cleanupLoc2=projFull;

   if (create) {
      if (!wxDirExists(projFull))
         if (!wxMkdir(projFull))
            return false;

      #ifdef __UNIX__
      chmod(OSFILENAME(projFull), 0775);
      #endif

   } else {
      #ifndef __WXMAC__
      if (!wxDirExists(projFull))
         return false;
      #endif
   }

   /* Move all files into this new directory.  Files which are
      "locked" get copied instead of moved.  (This happens when
      we perform a Save As - the files which belonged to the last
      saved version of the old project must not be moved,
      otherwise the old project would not be safe. */

   AudacityProject *p = GetActiveProject();
   if (p)
      p->ProgressShow(_("Progress"),
                      _("Saving project data files"));

   int total=blockFileHash.size();
   int count=0;

   BlockHash::iterator i=blockFileHash.begin();
   bool success = true;
   while(i != blockFileHash.end() && success) {
      BlockFile *b = i->second;
      
      if (b->IsLocked())
         success = CopyToNewProjectDirectory(b);
      else{
         success = MoveToNewProjectDirectory(b);
      }

      if (p)
         p->ProgressUpdate(int ((count * 1000.0) / total));

      i++;
      count++;
   }

   if (!success) {
      // If the move failed, we try to move/copy as many files
      // back as possible so that no damage was done.  (No sense
      // in checking for errors this time around - there's nothing
      // that could be done about it.)
      // Likely causes: directory was not writeable, disk was full

      projFull = oldLoc;

      BlockHash::iterator i=blockFileHash.begin();
      while(i != blockFileHash.end()) {
         BlockFile *b = i->second;
         MoveToNewProjectDirectory(b);

         if (count>=0 && p)
            p->ProgressUpdate(int ((count * 1000.0) / total));

         i++;
         count--;
      }

      this->projFull = oldFull;
      this->projPath = oldPath;
      this->projName = oldName;

      if (p)
         p->ProgressHide();

      return false;
   }

   if (p)
      p->ProgressHide();

   // Some subtlety; SetProject is used both to move a temp project
   // into a permanent home as well as just set up path variables when
   // loading a project; in this latter case, the movement code does
   // nothing because SetProject is called before there are any
   // blockfiles.  Cleanup code trigger is the same
   if(blockFileHash.size()>0){
      // Clean up after ourselves; look for empty directories in the old
      // and new project directories.  The easiest way to do this is to
      // recurse depth-first and rmdir every directory seen in old and
      // new; rmdir will fail on non-empty dirs.
      
      wxArrayString dirlist;
      count=rm_dash_rf_enumerate(cleanupLoc1,dirlist,wxEmptyString,0,1);
      count+=rm_dash_rf_enumerate(cleanupLoc2,dirlist,wxEmptyString,0,1);
      
      if(count)
         rm_dash_rf_execute(dirlist,count,0,1,_("Cleaning up cache directories"));
   }
   return true;
}
Ejemplo n.º 27
0
bool vfsDirBase::IsExists(const wxString& path) const
{
	return wxDirExists(path);
}
Ejemplo n.º 28
0
wxString KicadDatasPath()
{
    bool     found = false;
    wxString data_path;

    if( Pgm().IsKicadEnvVariableDefined() ) // Path defined by the KICAD environment variable.
    {
        data_path = Pgm().GetKicadEnvVariable();
        found = true;
    }
    else    // Path of executables.
    {
        wxString tmp = Pgm().GetExecutablePath();
#ifdef __WINDOWS__
        tmp.MakeLower();
#endif
        if( tmp.Contains( wxT( "kicad" ) ) )
        {
#ifdef __WINDOWS__
            tmp = Pgm().GetExecutablePath();
#endif
            if( tmp.Last() == '/' )
                tmp.RemoveLast();

            data_path  = tmp.BeforeLast( '/' ); // id cd ../
            data_path += UNIX_STRING_DIR_SEP;

            // Old versions of KiCad use kicad/ as default for data
            // and last versions kicad/share/
            // So we search for kicad/share/ first
            wxString old_path = data_path;
            data_path += wxT( "share/" );

            if( wxDirExists( data_path ) )
            {
                found = true;
            }
            else if( wxDirExists( old_path ) )
            {
                data_path = old_path;
                found = true;
            }
        }
    }

    if( !found )
    {
        // find KiCad from possibilities list:
        //  /usr/local/kicad/ or c:/kicad/

        const static wxChar*  possibilities[] = {
#ifdef __WINDOWS__
            wxT( "c:/kicad/share/" ),
            wxT( "d:/kicad/share/" ),
            wxT( "c:/kicad/" ),
            wxT( "d:/kicad/" ),
            wxT( "c:/Program Files/kicad/share/" ),
            wxT( "d:/Program Files/kicad/share/" ),
            wxT( "c:/Program Files/kicad/" ),
            wxT( "d:/Program Files/kicad/" ),
#else
            wxT( "/usr/share/kicad/" ),
            wxT( "/usr/local/share/kicad/" ),
            wxT( "/usr/local/kicad/share/" ),   // default data path for "universal
                                                // tarballs" and build for a server
                                                // (new)
            wxT( "/usr/local/kicad/" ),         // default data path for "universal
                                                // tarballs" and build for a server
                                                // (old)
#endif
        };

        for( unsigned i=0;  i<DIM(possibilities);  ++i )
        {
            data_path = possibilities[i];

            if( wxDirExists( data_path ) )
            {
                found = true;
                break;
            }
        }
    }

    if( found )
    {
        data_path.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );

        if( data_path.Last() != '/' )
            data_path += UNIX_STRING_DIR_SEP;
    }
    else
    {
        data_path.Empty();
    }

    return data_path;
}
Ejemplo n.º 29
0
bool wxWebUpdateActionExtract::Run() const
{
	wxArrayString orig, output;
	wxLogUsrMsg(wxT("wxWebUpdateActionExtract::Run - going to extract the file [")
				+ m_strFile + wxT("] of type [") + m_strType + wxT("] in [")
				+ m_strWhere + wxT("]"));

	// wxFileName wants a path separator at the end of directory names
	wxString dir(m_strWhere);
	if (dir.Last() != wxFileName::GetPathSeparator())
		dir += wxFileName::GetPathSeparator();

	// be sure that the destination directory exists
	wxFileName f(dir), f2(m_strFile);
	if (!f.DirExists() || !f2.FileExists()) {

		wxLogUsrMsg(wxT("wxWebUpdateActionExtract::Run - the folder \"") + m_strWhere +
				wxT("\" or the file \"") + m_strFile + wxT("\" does not exist !"));
		return FALSE;
	}
	
	// parse the namemap
	wxArrayString compressed, extracted;
	int count = wxWebUpdateInstaller::Get()->ParsePairValueList(m_strNameMap, compressed, extracted);

	// do the substitutions also on the compressed filenames
	for (int i=0; i < count; i++)
		compressed[i] = wxWebUpdateInstaller::Get()->DoSubstitution(compressed[i]);

	// create the archive factory
	wxArchiveClassFactory *factory = NULL;
	if (m_strType == wxT("zip"))
		factory = new wxZipClassFactory;	

	// extract the package 
	wxArchiveEntryPtr entry;
	wxFFileInputStream input(m_strFile);
	wxArchiveInputStream *in = factory->NewStream(input);
	delete factory;

    while (entry.reset(in->GetNextEntry()), entry.get() != NULL)
    {
        // access meta-data
        wxString name = entry->GetName();
        
        // is this file/dir registered in the name map ?
        int idx = compressed.Index(name);
        if (idx != wxNOT_FOUND)
        	name = extracted[idx];
        wxString output = dir + name;

		// can be different from "dir" if "name" includes a relative path...
		wxString outputdir = wxFileName(output).GetPath();

		// intercept directories...
		if (!wxDirExists(outputdir)) {

			if (wxFileName(outputdir).Mkdir(0777, wxPATH_MKDIR_FULL))
				wxLogAdvMsg(wxT("wxWebUpdateActionExtract::Run - created the [") + 
							outputdir + wxT("] folder"));
			else
				wxLogAdvMsg(wxT("wxWebUpdateActionExtract::Run - could not create the [") + 
							outputdir + wxT("] folder.. proceeding anyway"));
		
			continue;		// this entry contains no data
		}

		// this is a file...
		wxLogUsrMsg(wxT("wxWebUpdateActionExtract::Run - extracting [") + name +
			wxT("] as [") + output + wxT("]..."));

        // now just dump this entry to a new uncompressed file...
		wxFileOutputStream out(output);
		if (!out.IsOk() || !out.Write(*in)) {

			wxLogUsrMsg(wxT("wxWebUpdateActionExtract::Run - couldn't decompress ") + name);
			delete in;
			return FALSE;
		}
    }

	delete in;
	return TRUE;
}
Ejemplo n.º 30
0
void MyDialog::OnButton_GA(wxCommandEvent& event )
{
	wxString aid=assemblyid->GetValue();
	if (aid.IsEmpty()) 
	{
		wxLogMessage("Sorry, you have to specify an AssemblyID !");
	} else {
	wxFileDialog* file_dialog=new wxFileDialog(this,"Save AssemblyPackage as...","","","*.zip",wxSAVE,wxDefaultPosition);
	int t=file_dialog->ShowModal();
	
	wxString file;
	wxString path;
	wxString filename;
	if (t==wxID_OK) {
		
		file=file_dialog->GetPath();
		path=file_dialog->GetDirectory();
		filename=file_dialog->GetFilename();
		
		wxString current_directory=wxGetCwd();
		std::vector <AComponentTreeCtrl::fileinfo> filelist=a_TreeCtrl->getFiles();

		std::vector <AComponentTreeCtrl::fileinfo> ::iterator iter;
		for(iter = filelist.begin(); 
		iter != filelist.end(); 
			iter++)
			{
				AComponentTreeCtrl::fileinfo finfo=(*iter);
				
				if (!(wxDirExists("tempqxml"))) 
				{
					wxMkdir("tempqxml");
				}
				//wxSetWorkingDirectory(current_directory.Append("tempqxml"));

				wxString temp="tempqxml/";
				
				wxCopyFile(finfo.link,temp.Append(finfo.filename), TRUE);

				
			}

			if (!(wxDirExists("tempqxml/meta-inf")))
			{
					wxMkdir("tempqxml/meta-inf");
			}
			
			// copy the instantiation properties fillearchives
			p_TreeCtrl->copy_filearchive("tempqxml/meta-inf");

			wxString cadfile="tempqxml/meta-inf/";
			cadfile.Append(filename);
			cadfile.Replace(".zip",".cad",TRUE);

			wxFile* outputfile = new wxFile(cadfile,wxFile::write);
			outputfile->Write(getOutputText().c_str(),wxConvLibc);
			outputfile->Close();

			wxString newDirectory=current_directory;
			newDirectory.Append("\\");
			newDirectory.Append("tempqxml");
			wxSetWorkingDirectory(newDirectory);
						
			//bool value;
			wxProcess *process = new wxProcess(this);
					
			wxString cmd = "zip -u  ";
			cmd.append(filename);
			cmd.append(" ");
			cmd.append("*.*");
	
			std::cout << cmd.c_str() << std::endl;
	
			wxExecute(cmd, wxEXEC_SYNC, NULL);
			cadfile.Replace("tempqxml/","",TRUE);
			wxString cmd2 = "zip -u ";
			cmd2.append(filename);
			cmd2.append(" ");
			cmd2.append("meta-inf/*.*");
			
			wxExecute(cmd2, wxEXEC_SYNC, NULL);
			delete process;
			
			wxCopyFile(filename,file, TRUE);
			
			wxRemoveFile(filename);

			for(iter = filelist.begin(); 
			iter != filelist.end(); 
			iter++)
			{
				AComponentTreeCtrl::fileinfo finfo=(*iter);
				
				wxRemoveFile(finfo.filename);
								
			}

			p_TreeCtrl->remove_files();
			wxRemoveFile(cadfile);
			wxRmdir("meta-inf");

			
			
	}

	file_dialog->~wxFileDialog();
	}
}