Example #1
0
// adds %UserDnsDomain% to wxGetHostName()
//
bool wxGetFullHostName(wxChar *buf, int n)
{
    wxGetHostName(buf, n);

    const wxChar *domain = wxGetenv(wxT("UserDnsDomain"));

    if (domain)
        wxStrncat(wxStrncat(buf, wxT("."), n), domain, n);

    return true;
}
Example #2
0
wxString wxGetHostName()
{
    static const size_t hostnameSize = 257;

    wxString buf;
    bool ok = wxGetHostName(wxStringBuffer(buf, hostnameSize), hostnameSize);

    if ( !ok )
        buf.Empty();

    return buf;
}
Example #3
0
void wxTerminal::DoWritePrompt()
{
	wxString prompt;
	for ( size_t n=0; n < m_promptFormat.Len(); ++n ) {
		wxChar c = m_promptFormat[n];
		if ( c != wxT('%') ) prompt += c;             // If this is a standard character, add it to the string
		else {
			c = m_promptFormat[++n];                    // If it was '%', the next char determines what to do
			if ( c==wxT('%') ) {
				prompt += c;                          // %% really means it
				continue;
			}
			if ( c==wxT('H') ) {
				prompt += wxGetFullHostName();        // Full host-name
				continue;
			}
			if ( c==wxT('h') ) {
				prompt += wxGetHostName();            // Less-full host-name
				continue;
			}
			if ( c==wxT('u') ) {
				prompt += wxGetUserId();              // Add user-name to prompt
				continue;
			}
			if ( c==wxT('w') ) {
				prompt += m_workingDir;                 // Add Current Working Dir
				continue;
			}
			if ( c==wxT('W') ) {
				wxString tmpwd = m_workingDir;
				wxString sep   = wxFileName::GetPathSeparator();
				if(tmpwd.EndsWith(sep)) {
					tmpwd.RemoveLast();
				}
				prompt += tmpwd.AfterLast(wxFILE_SEP_PATH);    // Filename-bit only of cwd
				continue;
			}
		}
	}

	int promptStart = m_textCtrl->GetLastPosition();
	m_textCtrl->AppendText( prompt ); //   write the prompt,
	// Cancel it, whether there's a valid one or not:  even an old selection interferes
	m_textCtrl->SetSelection( m_textCtrl->GetLastPosition(), m_textCtrl->GetLastPosition() );
	m_textCtrl->SetInsertionPointEnd();
	m_commandStart = m_textCtrl->GetInsertionPoint();

	m_textCtrl->SetStyle(promptStart, m_commandStart-1, m_promptStyle);
	// restore default style
	m_textCtrl->SetDefaultStyle( m_defaultStyle );
	m_textCtrl->SetFocus();
}
Example #4
0
void wxXMergeDatabases (wxApp * theApp, Display * display)
{
    XrmDatabase homeDB, serverDB, applicationDB;
    char filenamebuf[1024];

    char *filename = &filenamebuf[0];
    char *environment;
    wxString classname = theApp->GetClassName();
    char name[256];
    (void) strcpy (name, "/usr/lib/X11/app-defaults/");
    (void) strcat (name, classname.c_str());

    /* Get application defaults file, if any */
    applicationDB = XrmGetFileDatabase (name);
    (void) XrmMergeDatabases (applicationDB, &wxResourceDatabase);

    /* Merge server defaults, created by xrdb, loaded as a property of the root
    * window when the server initializes and loaded into the display
    * structure on XOpenDisplay;
    * if not defined, use .Xdefaults
    */

    if (XResourceManagerString (display) != NULL)
    {
        serverDB = XrmGetStringDatabase (XResourceManagerString (display));
    }
    else
    {
        (void) GetIniFile (filename, NULL);
        serverDB = XrmGetFileDatabase (filename);
    }
    XrmMergeDatabases (serverDB, &wxResourceDatabase);

    /* Open XENVIRONMENT file, or if not defined, the .Xdefaults,
    * and merge into existing database
    */

    if ((environment = getenv ("XENVIRONMENT")) == NULL)
    {
        size_t len;
        environment = GetIniFile (filename, NULL);
        len = strlen (environment);
        wxString hostname = wxGetHostName();
        if ( !!hostname )
            strncat(environment, hostname, 1024 - len);
    }
    homeDB = XrmGetFileDatabase (environment);
    XrmMergeDatabases (homeDB, &wxResourceDatabase);
}
Example #5
0
void InteractiveOutputTestCase::TestOsInfo()
{
#ifdef TEST_INFO_FUNCTIONS
    wxPuts(wxT("*** Testing OS info functions ***\n"));

    int major, minor;
    wxGetOsVersion(&major, &minor);
    wxPrintf(wxT("Running under: %s, version %d.%d\n"),
            wxGetOsDescription().c_str(), major, minor);

    wxPrintf(wxT("%ld free bytes of memory left.\n"), wxGetFreeMemory().ToLong());

    wxPrintf(wxT("Host name is %s (%s).\n"),
           wxGetHostName().c_str(), wxGetFullHostName().c_str());

    wxPuts(wxEmptyString);
#endif // TEST_INFO_FUNCTIONS
}
Example #6
0
wxLuaDebuggerBase::wxLuaDebuggerBase(int port_number)
                  :wxEvtHandler(), m_port_number(port_number),
                   m_stackDialog(NULL),
                   m_debuggeeProcess(NULL), m_debuggeeProcessID(-1)
{
    // Initialize the debuggee program name if not already set
    if (sm_programName.IsEmpty())
        sm_programName = wxTheApp->argv[0];

    // Initialize the debuggee network name if not already set
    if (sm_networkName.IsEmpty())
    {
#ifdef __WXMSW__
        sm_networkName = wxGetHostName();
#else
        sm_networkName = wxT("localhost");
#endif // __WXMSW__
    }
}
Example #7
0
mxShareSourceWindow::mxShareSourceWindow(mxSource *source, wxString name, wxWindow* parent, wxWindowID id, const wxPoint& pos , const wxSize& size , long style) : wxDialog(parent, id, LANG(SHARESOURCE_CAPTION,"Compartir Archivo"), pos, size, style) {
	
	if (!share) share = new ShareManager();
	
	source_ctrl=source;
	
	wxBoxSizer *mySizer = new wxBoxSizer(wxVERTICAL);
	wxBoxSizer *bottomSizer= new wxBoxSizer(wxHORIZONTAL);

	source_name = new wxComboBox(this, wxID_ANY);
	share->GetMyList((wxControlWithItems*)source_name);
	
	freeze_check = new wxCheckBox(this, wxID_ANY, LANG(SHARESOURCE_SHARE_WITHOUT_MODIFICATIONS,"Compartir sin modificaciones"));
	freeze_check->SetValue(false);
	
	mySizer->Add(new wxStaticText(this, wxID_ANY, LANG(SHARESOURCE_ENTER_NAME,"Ingrese el nombre con el que desea compartir el archivo,\no seleccione uno de la lista para reemplazarlo: "), wxDefaultPosition, wxDefaultSize, 0), sizers->BLRT5);
	mySizer->Add(source_name,sizers->BLRB5_Exp0);
	mySizer->Add(freeze_check,sizers->BA5_Exp0);

	wxBitmapButton *help_button = new wxBitmapButton (this,mxID_HELP_BUTTON,*bitmaps->buttons.help);
	wxButton *cancel_button = new mxBitmapButton (this, wxID_CANCEL, bitmaps->buttons.cancel, LANG(GENERAL_CANCEL_BUTTON,"&Cancelar"));
	wxButton *ok_button = new mxBitmapButton (this, wxID_OK, bitmaps->buttons.ok, LANG(SHARESOURCE_SHARE_BUTTON,"Compartir"));
	ok_button->SetDefault();
	
	bottomSizer->Add(help_button,sizers->BA5_Exp0);
	bottomSizer->AddStretchSpacer();
	bottomSizer->Add(cancel_button,sizers->BA5);
	bottomSizer->Add(ok_button,sizers->BA5);
	
	wxString whoami=LANG(SHARESOURCE_YOUR_HOSTNAME,"Para que otros puedan descargar este codigo nesecitaran identificar tu PC.\n   Tu nombre de host es: ");
	mySizer->Add(new wxStaticText(this, wxID_ANY, whoami<<wxGetHostName(), wxDefaultPosition, wxDefaultSize, 0), sizers->BA5);
	
	mySizer->Add(bottomSizer,sizers->BA5_Exp0);
	
	SetSizerAndFit(mySizer);

	source_name->SetFocus();
	source_name->SetValue(name);
	source_name->SetSelection(-1,-1);
	
	Show();

}
Example #8
0
void Launcher::OnNSDStartButton(wxCommandEvent& WXUNUSED(event)) 
{
	if (nsd_started_){
		wxKill (nsd_pid_, wxSIGKILL);
		nsd_started_= false;
		NSDStartBtn->SetLabel("Start");
		NSDStartBtn -> SetBackgroundColour(wxColour(255, 0, 0));
		NSDStartBtn->Refresh();
	} else
	{
		wxString port_nr = port_number_->GetValue(); 
		
		wxString host_name = wxGetHostName();
		// get the computers name first 

		wxString cmd = "nsd -ORBIIOPAddr inet:";
		cmd.append(host_name);
		cmd.append(":");
		cmd.append(port_nr);

		wxProcess *process = new wxProcess (this);
	//	process->Redirect();
		nsd_pid_ = wxExecute(cmd, wxEXEC_ASYNC, process);
		if ( !nsd_pid_ )
		{
			wxLogError( _T("Execution of '%s' failed."), cmd.c_str() );

			delete process;
		}
		else
		{
			// change Button
			nsd_started_= true;
			NSDStartBtn->SetLabel("Stop");
			NSDStartBtn -> SetBackgroundColour(wxColour(0, 255, 0));
			NSDStartBtn->Refresh();


		}

	}
}
Example #9
0
// get full hostname (with domain name if possible)
bool wxGetFullHostName(wxChar *buf, int maxSize)
{
#if !defined( __WXMICROWIN__) && wxUSE_DYNAMIC_LOADER && wxUSE_SOCKETS
    // TODO should use GetComputerNameEx() when available

    // we don't want to always link with Winsock DLL as we might not use it at
    // all, so load it dynamically here if needed (and don't complain if it is
    // missing, we handle this)
    wxLogNull noLog;

    wxDynamicLibrary dllWinsock(_T("ws2_32.dll"), wxDL_VERBATIM);
    if ( dllWinsock.IsLoaded() )
    {
        typedef int (PASCAL *WSAStartup_t)(WORD, WSADATA *);
        typedef int (PASCAL *gethostname_t)(char *, int);
        typedef hostent* (PASCAL *gethostbyname_t)(const char *);
        typedef hostent* (PASCAL *gethostbyaddr_t)(const char *, int , int);
        typedef int (PASCAL *WSACleanup_t)(void);

        #define LOAD_WINSOCK_FUNC(func)                                       \
            func ## _t                                                        \
                pfn ## func = (func ## _t)dllWinsock.GetSymbol(_T(#func))

        LOAD_WINSOCK_FUNC(WSAStartup);

        WSADATA wsa;
        if ( pfnWSAStartup && pfnWSAStartup(MAKEWORD(1, 1), &wsa) == 0 )
        {
            LOAD_WINSOCK_FUNC(gethostname);

            wxString host;
            if ( pfngethostname )
            {
                char bufA[256];
                if ( pfngethostname(bufA, WXSIZEOF(bufA)) == 0 )
                {
                    // gethostname() won't usually include the DNS domain name,
                    // for this we need to work a bit more
                    if ( !strchr(bufA, '.') )
                    {
                        LOAD_WINSOCK_FUNC(gethostbyname);

                        struct hostent *pHostEnt = pfngethostbyname
                                                    ? pfngethostbyname(bufA)
                                                    : NULL;

                        if ( pHostEnt )
                        {
                            // Windows will use DNS internally now
                            LOAD_WINSOCK_FUNC(gethostbyaddr);

                            pHostEnt = pfngethostbyaddr
                                        ? pfngethostbyaddr(pHostEnt->h_addr,
                                                           4, AF_INET)
                                        : NULL;
                        }

                        if ( pHostEnt )
                        {
                            host = wxString::FromAscii(pHostEnt->h_name);
                        }
                    }
                }
            }

            LOAD_WINSOCK_FUNC(WSACleanup);
            if ( pfnWSACleanup )
                pfnWSACleanup();


            if ( !host.empty() )
            {
                wxStrncpy(buf, host, maxSize);

                return true;
            }
        }
    }
#endif // !__WXMICROWIN__

    return wxGetHostName(buf, maxSize);
}
Example #10
0
void xLightsFrame::SetDir(const wxString& newdir)
{
    static bool HasMenuSeparator=false;
    int idx, cnt, i;

    // reject change if something is playing
    if (play_mode == play_sched || play_mode == play_list || play_mode == play_single)
    {
        wxMessageBox(_("Cannot change directories during playback"),_("Error"));
        return;
    }

    // update most recently used array
    idx=mru.Index(newdir);
    if (idx != wxNOT_FOUND) mru.RemoveAt(idx);
    if (!CurrentDir.IsEmpty())
    {
        idx=mru.Index(CurrentDir);
        if (idx != wxNOT_FOUND) mru.RemoveAt(idx);
        mru.Insert(CurrentDir,0);
    }
    cnt=mru.GetCount();
    if (cnt > MRU_LENGTH)
    {
        mru.RemoveAt(MRU_LENGTH, cnt - MRU_LENGTH);
        cnt = MRU_LENGTH;
    }

    /*
    wxString msg=wxT("UpdateMRU:\n");
    for (int i=0; i<mru.GetCount(); i++) msg+=wxT("\n") + mru[i];
    wxMessageBox(msg);
    */

    // save config
    bool DirExists=wxFileName::DirExists(newdir);
    wxString mru_name, value;
    wxConfig* config = new wxConfig(_(XLIGHTS_CONFIG_ID));
    if (DirExists) config->Write(_("LastDir"), newdir);
    for (i=0; i<MRU_LENGTH; i++)
    {
        mru_name=wxString::Format(wxT("mru%d"),i);
        if (MenuFile->FindItem(mru_MenuItem[i]->GetItemLabel()) != wxNOT_FOUND)
        {
            MenuFile->Remove(mru_MenuItem[i]);
        }
        if (i < cnt)
        {
            value = mru[i];
        }
        else
        {
            value = wxEmptyString;
        }
        config->Write(mru_name, value);
    }
    delete config;

    // append mru items to menu
    cnt=mru.GetCount();
    if (!HasMenuSeparator && cnt > 0)
    {
        MenuFile->AppendSeparator();
        HasMenuSeparator=true;
    }
    for (i=0; i<cnt; i++)
    {
        mru_MenuItem[i]->SetItemLabel(mru[i]);
        MenuFile->Append(mru_MenuItem[i]);
    }

    if (!DirExists)
    {
        wxString msg=_("The show directory '") + newdir + ("' no longer exists.\nPlease choose a new show directory.");
        wxMessageBox(msg);
        return;
    }

    // update UI
    CheckBoxLightOutput->SetValue(false);
    CheckBoxRunSchedule->SetValue(false);
    if (xout)
    {
        delete xout;
        xout=0;
    }
    CurrentDir=newdir;
    StaticTextDirName->SetLabel(CurrentDir);
    UnsavedChanges=false;
    TextCtrlLog->Clear();
    while (Notebook1->GetPageCount() > FixedPages)
    {
        Notebook1->DeletePage(FixedPages);
    }
    ButtonTestLoad->Enable(true);
    ButtonTestSave->Enable(true);
    EnableNetworkChanges();
    DisplayXlightsFilename(wxT(""));

    // load network
    wxXmlNode* root = new wxXmlNode( wxXML_ELEMENT_NODE, wxT("Networks") );
    root->AddAttribute( wxT("computer"), wxGetHostName());
    NetworkXML.SetRoot( root ); // reset xml
    networkFile.AssignDir( CurrentDir );
    networkFile.SetFullName(_(XLIGHTS_NETWORK_FILE));
    if (networkFile.FileExists())
    {
        if (!NetworkXML.Load( networkFile.GetFullPath() ))
        {
            wxMessageBox(_("Unable to load network definition file"), _("Error"));
        }
    }

    // load schedule
    UpdateShowDates(wxDateTime::Now(),wxDateTime::Now());
    ShowEvents.Clear();
    scheduleFile.AssignDir( CurrentDir );
    scheduleFile.SetFullName(_(XLIGHTS_SCHEDULE_FILE));
    if (scheduleFile.FileExists())
    {
        LoadScheduleFile();
    }
    DisplaySchedule();

    // load sequence effects
    wxWindow* w;
    int ColorIdx;
    for(i=0; i<12; i++)
    {
        w=wxWindow::FindWindowByName(wxString::Format(wxT("ID_BUTTON_Palette%d_%d"),int(i/6+1),int(i%6+1)));
        switch (i%6)
        {
        case 0:
            w->SetBackgroundColour(*wxRED);
            break;
        case 1:
            w->SetBackgroundColour(*wxGREEN);
            break;
        case 2:
            w->SetBackgroundColour(*wxBLUE);
            break;
        case 3:
            w->SetBackgroundColour(*wxYELLOW);
            break;
        case 4:
            w->SetBackgroundColour(*wxWHITE);
            break;
        case 5:
            w->SetBackgroundColour(*wxBLACK);
            break;
        }
        SetTextColor(w);
    }
    LoadEffectsFile();
    PresetsSelect();
    EnableSequenceControls(true);
    UpdateNetworkList();

    Notebook1->ChangeSelection(SETUPTAB);
}
Example #11
0
bool wxGetFullHostName( wxChar* zBuf, int nMaxSize)
{
    return wxGetHostName( zBuf, nMaxSize );
}