Пример #1
0
/// Add an URL to the URL list box
void
AlcFrame::OnAddUrlButton (wxCommandEvent & WXUNUSED(event))
{
  wxString url(m_inputAddTextCtrl->GetValue());

  if (!url.IsEmpty())
    {
      // Check if the URL already exist in list
      size_t i;
      bool UrlNotExists = true;
      for (i=0;i < m_inputUrlListBox->GetCount();++i)
        {
          if (url == m_inputUrlListBox->GetString(i))
            {
              UrlNotExists =false;
              break;
            }
        }

      // Add only a not already existant URL
      if (UrlNotExists)
        {
	  m_inputUrlListBox->Append(wxURI(url).BuildURI());
          m_inputAddTextCtrl->SetValue(wxEmptyString);
        }
      else
        {
          wxLogError(_("You have already added this URL !"));
        }
    }
  else
    {
      SetStatusText (_("Please, enter a non empty URL"));
    }
}
Пример #2
0
void ReminderDialog::OnsendBtClick(wxCommandEvent& event)
{
	if (feedbackEdit->GetValue().empty() || !feedbackWritten ) {
		gd::LogMessage(_("You didn't entered any feedback! :O"));
		return;
	}
    wxString report;
    report += "User mail: "+mailEdit->GetValue()+"\n";
    report += "Feedback: "+feedbackEdit->GetValue()+"\n";
    report.Replace("&", "%26");

    wxString encodedReportURI = wxURI("www.compilgames.net/feedback/send.php?msg="+report).BuildURI();
    wxURI requestURI(encodedReportURI);
    std::cout << "Sending feedback with these data:" << requestURI.GetQuery() << std::endl;

    // Create request
    sf::Http Http;
    Http.setHost("http://www.compilgames.net");
    sf::Http::Request request;
    request.setMethod(sf::Http::Request::Post);
    request.setField("Content-Type", "application/x-www-form-urlencoded");
    request.setUri("/feedback/send.php");
    request.setBody(gd::ToString(requestURI.GetQuery()));

    // Send the request
    sf::Http::Response response = Http.sendRequest(request, sf::seconds(5));

    if (response.getStatus() != sf::Http::Response::Ok)
        std::cout << "Unable to connect to the server for sending the feedback!" << std::endl;
    else {
        gd::LogMessage(_("Thanks for your feedback!"));
        sendBt->Disable();
    }
}
Пример #3
0
wxString wxMakeFileURI(const wxFileName &fn)
{
    wxString path = fn.GetFullPath();

    // in case we are using win32 paths with backslashes...
    // (this must be done also under Unix since even there we could
    //  be forced to handle win32 paths)
    path.Replace(wxT("\\"), wxT("/"));

    // now use wxURI as filter
    return wxURI(wxT("file:") + path).BuildURI();
}
Пример #4
0
void Model_Usage::pageview(const wxWindow* window, int plt /* = 0 msec*/)
{
    if (!window) return;
    if (window->GetName().IsEmpty()) return;

    const wxWindow *current = window;

    wxString documentTitle = window->GetLabel();
    if (documentTitle.IsEmpty()) documentTitle = window->GetName();

    wxString documentPath;
    while (current)
    {
        if (current->GetName().IsEmpty())
        {
            current = current->GetParent();
            continue;
        }
        documentPath = "/" + current->GetName() + documentPath; 
        current = current->GetParent();
    }

    return pageview(wxURI(documentPath).BuildURI(), wxURI(documentTitle).BuildURI(), plt);
}
Пример #5
0
// }}}
// {{{ void MainFrame::OnConnection(DBGp::ConnectionEvent &event)
void MainFrame::OnConnection(DBGp::ConnectionEvent &event) {
	wxString expectedKey(config->Read(wxT("Network/IDEKey"), wxEmptyString));
	if (expectedKey.Len() == 0 || expectedKey == event.GetIDEKey()) {
		wxFileName name(wxURI::Unescape(wxURI(event.GetFileURI()).GetPath()));
		notebook->AddPage(new ConnectionPage(notebook, event.GetConnection(), event.GetFileURI(), event.GetLanguage()), name.GetFullName(), true);

		if (!IsActive()) {
			RequestUserAttention(wxUSER_ATTENTION_INFO);
		}
	}
	else {
		// TODO: Ponder how we want to notify the user of this. Indeed,
		// ponder if we want to notify the user of this.
		wxLogDebug(wxT("Connection refused due to IDE key mismatch: expected %s; got %s."), expectedKey.c_str(), event.GetIDEKey().c_str());
		event.GetConnection()->Close();
	}
}
Пример #6
0
void KICAD_MANAGER_FRAME::OnUnarchiveFiles( wxCommandEvent& event )
{
    wxFileName fn = GetProjectFileName();

    fn.SetExt( ZipFileExtension );

    wxFileDialog zipfiledlg( this, _( "Unzip Project" ), fn.GetPath(),
                             fn.GetFullName(), ZipFileWildcard(),
                             wxFD_OPEN | wxFD_FILE_MUST_EXIST );

    if( zipfiledlg.ShowModal() == wxID_CANCEL )
        return;

    wxString msg = wxString::Format( _( "\nOpen \"%s\"\n" ), GetChars( zipfiledlg.GetPath() ) );
    PrintMsg( msg );

    wxDirDialog dirDlg( this, _( "Target Directory" ), fn.GetPath(),
                        wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );

    if( dirDlg.ShowModal() == wxID_CANCEL )
        return;

    wxString unzipDir = dirDlg.GetPath() + wxT( "/" );
    msg.Printf( _( "Unzipping project in \"%s\"\n" ), GetChars( unzipDir ) );
    PrintMsg( msg );

    wxFileSystem zipfilesys;

    zipfilesys.AddHandler( new wxZipFSHandler );
    auto path = wxURI( zipfiledlg.GetPath() + wxT( "#zip:" ) ).BuildURI();
    zipfilesys.ChangePathTo( path, true );

    wxFSFile* zipfile = NULL;
    wxString  localfilename = zipfilesys.FindFirst( wxFileSelectorDefaultWildcardStr, wxFILE );

    while( !localfilename.IsEmpty() )
    {
        zipfile = zipfilesys.OpenFile( localfilename );
        if( !zipfile )
        {
            DisplayError( this, wxT( "Zip file read error" ) );
            break;
        }

        wxFileName uzfn = localfilename.AfterLast( ':' );
        uzfn.MakeAbsolute( unzipDir );
        wxString unzipfilename = uzfn.GetFullPath();

        msg.Printf( _( "Extract file \"%s\"" ), GetChars( unzipfilename ) );
        PrintMsg( msg );

        wxInputStream* stream = zipfile->GetStream();
        wxFFileOutputStream* ofile = new wxFFileOutputStream( unzipfilename );

        if( ofile->Ok() )
        {
            ofile->Write( *stream );
            PrintMsg( _( " OK\n" ) );
        }
        else
            PrintMsg( _( " *ERROR*\n" ) );

        delete ofile;
        delete zipfile;

        localfilename = zipfilesys.FindNext();
    }

    PrintMsg( wxT( "** end **\n" ) );

    if( unzipDir == Prj().GetProjectPath() )
    {
        wxCommandEvent dummy;
        OnRefresh( dummy );
    }
}
Пример #7
0
/// Compute Hashes on Start Button
void AlcFrame::OnStartButton (wxCommandEvent & WXUNUSED(event))
{
  size_t i;
  wxString filename = m_inputFileTextCtrl->GetValue();

  if (!filename.empty ())
    {
      // Initialize computation
      m_goAhead=true;

      // Chrono
      wxStopWatch chrono;

      // wxFileName needed for base name
      wxFileName fileToHash(filename);

      // Set waiting msg
      m_e2kHashTextCtrl->SetValue(_("Hashing..."));
      m_ed2kTextCtrl->SetValue(_("Hashing..."));

#ifdef WANT_MD4SUM
      // Create MD4 progress bar dialog
      m_progressBar=new wxProgressDialog  (_("aLinkCreator is working for you"), _("Computing MD4 Hash..."),
                                           100, this, wxPD_AUTO_HIDE | wxPD_CAN_ABORT | wxPD_REMAINING_TIME);
      m_md4HashTextCtrl->SetValue(_("Hashing..."));

      // Md4 hash
      MD4 md4;
      m_md4HashTextCtrl->SetValue(md4.calcMd4FromFile(filename,Hook));

      // Deleting MD4 progress bar dialog
      delete m_progressBar;
      m_progressBar=NULL;

#endif

      // Create ED2K progress bar dialog
      m_progressBar=new wxProgressDialog  (_("aLinkCreator is working for you"), _("Computing eD2k Hashes..."),
                                           100, this, wxPD_AUTO_HIDE | wxPD_CAN_ABORT | wxPD_REMAINING_TIME);

      // Compute ed2k Hash
      Ed2kHash hash;

      // Test the return value to see if was aborted.
      if (hash.SetED2KHashFromFile(filename, Hook))
        {

          wxArrayString ed2kHash (hash.GetED2KHash());

          // Get URLs
          wxArrayString arrayOfUrls;
          wxString url;
          for (i=0;i < m_inputUrlListBox->GetCount();++i)
            {
              url=m_inputUrlListBox->GetString(i);
              if (url.Right(1) == wxT("/"))
                {
                  url += fileToHash.GetFullName();
                }
		arrayOfUrls.Add(wxURI(url).BuildURI());
            }
          arrayOfUrls.Shrink(); // Reduce memory usage

          // Ed2k hash
          m_e2kHashTextCtrl->SetValue(ed2kHash.Last());

          // Ed2k link
          m_ed2kTextCtrl->SetValue(hash.GetED2KLink(m_parthashesCheck->IsChecked(), &arrayOfUrls));
        }
      else
        {
          // Set cancelled msg
          m_e2kHashTextCtrl->SetValue(_("Cancelled !"));
          m_ed2kTextCtrl->SetValue(_("Cancelled !"));
        }

      // Deleting progress bar dialog
      delete m_progressBar;
      m_progressBar=NULL;

      // Set status text
      SetStatusText (wxString::Format(_("Done in %.2f s"),
                                      chrono.Time()*.001));
    }
  else
    {
      // Set status text
      SetStatusText (_("Please, enter a non empty file name"));
    }
}