示例#1
0
void PHPWorkspaceView::OnToggleAutoUpload(wxCommandEvent& e)
{
    SSHWorkspaceSettings settings;
    settings.Load();
    settings.EnableRemoteUpload(e.IsChecked());
    settings.Save();
}
示例#2
0
void PHPWorkspaceView::OnSetupRemoteUpload(wxAuiToolBarEvent& event)
{

    if ( !event.IsDropDownClicked() ) {
        CallAfter( &PHPWorkspaceView::DoOpenSSHAccountManager );


    } else {
        SSHWorkspaceSettings settings;
        settings.Load();

        wxMenu menu;
        if ( !settings.IsRemoteUploadSet() ) {
            // We never setup remote upload for this workspace
            menu.AppendCheckItem(ID_TOGGLE_AUTOMATIC_UPLOAD, _("Enable automatic upload"));
            menu.Enable(ID_TOGGLE_AUTOMATIC_UPLOAD, false);
            menu.Check(ID_TOGGLE_AUTOMATIC_UPLOAD, false);

        } else {
            menu.AppendCheckItem(ID_TOGGLE_AUTOMATIC_UPLOAD, _("Enable automatic upload"));
            menu.Check(ID_TOGGLE_AUTOMATIC_UPLOAD, settings.IsRemoteUploadEnabled());
            menu.Connect(ID_TOGGLE_AUTOMATIC_UPLOAD, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(PHPWorkspaceView::OnToggleAutoUpload), NULL, this);
        }

        wxAuiToolBar* auibar = dynamic_cast<wxAuiToolBar*>(event.GetEventObject());
        if ( auibar ) {
            clAuiToolStickness ts(auibar, event.GetToolId());
            wxRect rect = auibar->GetToolRect(event.GetId());
            wxPoint pt = auibar->ClientToScreen(rect.GetBottomLeft());
            pt = ScreenToClient(pt);
            PopupMenu(&menu, pt);
        }
    }
}
示例#3
0
void PhpSFTPHandler::DoSyncFileWithRemote(const wxFileName& localFile)
{
    // Check to see if we got a remote-upload setup
    PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetProjectForFile(localFile);
    if(!pProject) {
        // Not a workspace file
        clDEBUG() << localFile << "is not a PHP workspace file, will not sync it with remote" << clEndl;
        return;
    }

    SSHWorkspaceSettings workspaceSettings;
    workspaceSettings.Load();
    
    if(!EnsureAccountExists(workspaceSettings)) { return; }
    
    // Convert the local path to remote path
    wxString remotePath = GetRemotePath(workspaceSettings, localFile.GetFullPath());
    if(remotePath.IsEmpty()) { return; }

    // Fire this event, if the sftp plugin is ON, it will handle it
    clSFTPEvent eventSave(wxEVT_SFTP_SAVE_FILE);
    eventSave.SetAccount(workspaceSettings.GetAccount());
    eventSave.SetLocalFile(localFile.GetFullPath());
    eventSave.SetRemoteFile(remotePath);
    EventNotifier::Get()->AddPendingEvent(eventSave);
}
示例#4
0
wxString PhpSFTPHandler::GetRemotePath(const SSHWorkspaceSettings& sshSettings, const wxString& localpath) const
{
    if(!sshSettings.IsRemoteUploadEnabled() || !sshSettings.IsRemoteUploadEnabled()) { return ""; }
    wxFileName fnLocalFile = localpath;
    fnLocalFile.MakeRelativeTo(PHPWorkspace::Get()->GetFilename().GetPath());
    fnLocalFile.MakeAbsolute(wxFileName(sshSettings.GetRemoteFolder(), "", wxPATH_UNIX).GetPath());
    return fnLocalFile.GetFullPath(wxPATH_UNIX);
}
示例#5
0
wxStringMap_t XDebugManager::GetFileMapping(PHPProject::Ptr_t pProject) const
{
    wxASSERT(pProject);
    wxStringMap_t mappings;
    const PHPProjectSettingsData& settings = pProject->GetSettings();
    mappings = settings.GetFileMapping();
    
    // Add the SFTP mappings
    SSHWorkspaceSettings sftpSettings;
    sftpSettings.Load();
    if ( !sftpSettings.GetRemoteFolder().IsEmpty() && sftpSettings.IsRemoteUploadEnabled() ) {
        mappings.insert( std::make_pair(PHPWorkspace::Get()->GetFilename().GetPath(), sftpSettings.GetRemoteFolder()) );
    }
    return mappings;
}
示例#6
0
void PhpSFTPHandler::OnReplaceInFiles(clFileSystemEvent& e)
{
    e.Skip();
    if(!PHPWorkspace::Get()->IsOpen()) { return; }
    
    SSHWorkspaceSettings settings;
    settings.Load();
    
    if(!EnsureAccountExists(settings)) { return; }
    
    const wxArrayString& files = e.GetStrings();
    for(size_t i = 0; i < files.size(); ++i) {
        DoSyncFileWithRemote(files.Item(i));
    }
}
示例#7
0
void PhpPlugin::OnFileSaved(clCommandEvent& e)
{
    e.Skip();

    // Check to see if we got a remote-upload setup
    SSHWorkspaceSettings settings;
    settings.Load();

    if(settings.IsRemoteUploadSet() && settings.IsRemoteUploadEnabled()) {
        // Post an event to the SFTP plugin and ask it to save our file
        wxFileName fnLocalFile(e.GetString());

        fnLocalFile.MakeRelativeTo(PHPWorkspace::Get()->GetFilename().GetPath());
        fnLocalFile.MakeAbsolute(wxFileName(settings.GetRemoteFolder(), "", wxPATH_UNIX).GetPath());
        wxString remoteFile = fnLocalFile.GetFullPath(wxPATH_UNIX);
        wxString localFile = e.GetString();

        JSONRoot root(cJSON_Object);
        root.toElement().addProperty("account", settings.GetAccount());
        root.toElement().addProperty("local_file", localFile);
        root.toElement().addProperty("remote_file", remoteFile);

        clCommandEvent eventSave(XRCID("wxEVT_SFTP_SAVE_FILE"));
        eventSave.SetString(root.toElement().format());
        EventNotifier::Get()->AddPendingEvent(eventSave);
    }
}
void PhpPlugin::DoSyncFileWithRemote(const wxFileName& localFile)
{
    // Check to see if we got a remote-upload setup
    PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetProjectForFile(localFile);
    if(!pProject) {
        // Not a workspace file
        clDEBUG() << localFile << "is not a PHP workspace file, will not sync it with remote" << clEndl;
        return;
    }
    
    SSHWorkspaceSettings settings;
    settings.Load();

    if(settings.IsRemoteUploadSet() && settings.IsRemoteUploadEnabled()) {
        // Post an event to the SFTP plugin and ask it to save our file
        wxFileName fnLocalFile = localFile;

        fnLocalFile.MakeRelativeTo(PHPWorkspace::Get()->GetFilename().GetPath());
        fnLocalFile.MakeAbsolute(wxFileName(settings.GetRemoteFolder(), "", wxPATH_UNIX).GetPath());

        wxString remoteFile = fnLocalFile.GetFullPath(wxPATH_UNIX);

        // Fire this event, if the sftp plugin is ON, it will handle it
        clSFTPEvent eventSave(wxEVT_SFTP_SAVE_FILE);
        eventSave.SetAccount(settings.GetAccount());
        eventSave.SetLocalFile(localFile.GetFullPath());
        eventSave.SetRemoteFile(remoteFile);
        EventNotifier::Get()->AddPendingEvent(eventSave);
    }
}
示例#9
0
void XDebugManager::DoApplyBreakpoints()
{
    CL_DEBUG("CodeLite >>> Applying breakpoints");
    CHECK_PTR_RET(m_readerThread);
    
    PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetActiveProject();
    CHECK_PTR_RET(pProject);
    
    const PHPProjectSettingsData& settings = pProject->GetSettings();
    bool bRunAsWebserver = ( pProject->GetSettings().GetRunAs() == PHPProjectSettingsData::kRunAsWebsite);
    
    XDebugBreakpoint::List_t& breakpoints = m_breakpointsMgr.GetBreakpoints();
    XDebugBreakpoint::List_t::iterator iter = breakpoints.begin();
    for( ; iter != breakpoints.end(); ++iter ) {

        // apply only breakpoints without xdebug-id attached to them
        if ( iter->IsApplied() ) { 
            continue;
        }
    
        wxStringMap_t sftpMapping;
        SSHWorkspaceSettings sftpSettings;
        sftpSettings.Load();
        if ( !sftpSettings.GetRemoteFolder().IsEmpty() && sftpSettings.IsRemoteUploadEnabled() ) {
            sftpMapping.insert( std::make_pair(PHPWorkspace::Get()->GetFilename().GetPath(), sftpSettings.GetRemoteFolder()) );
        }
        
        wxString command;
        XDebugCommandHandler::Ptr_t handler( new XDebugBreakpointCmdHandler(this, ++TranscationId, *iter) );
        wxString filepath = bRunAsWebserver ? settings.GetMappdPath( iter->GetFileName(), true , sftpMapping) : iter->GetFileName();
        command << "breakpoint_set -i " 
                << handler->GetTransactionId() 
                << " -t line"
                << " -f " << filepath
                << " -n " << iter->GetLine();
        DoSocketWrite( command );
        AddHandler( handler );
    }
}
示例#10
0
void PhpSFTPHandler::OnFileRenamed(clFileSystemEvent& e)
{
    e.Skip();
    if(!PHPWorkspace::Get()->IsOpen()) { return; }

    SSHWorkspaceSettings settings;
    settings.Load();
    
    if(!EnsureAccountExists(settings)) { return; }
    
    wxString oldPath = GetRemotePath(settings, e.GetPath());
    wxString newPath = GetRemotePath(settings, e.GetNewpath());
    if(oldPath.IsEmpty() || newPath.IsEmpty()) { return; }

    clDEBUG() << "PHP SFTP: Renaming:" << oldPath << "->" << newPath;

    // Fire this event, if the sftp plugin is ON, it will handle it
    clSFTPEvent eventRename(wxEVT_SFTP_RENAME_FILE);
    eventRename.SetAccount(settings.GetAccount());
    eventRename.SetRemoteFile(oldPath);
    eventRename.SetNewRemoteFile(newPath);
    EventNotifier::Get()->AddPendingEvent(eventRename);
}
示例#11
0
void PhpSFTPHandler::OnFileDeleted(clFileSystemEvent& e)
{
    e.Skip();
    if(!PHPWorkspace::Get()->IsOpen()) { return; }

    SSHWorkspaceSettings settings;
    settings.Load();
    
    if(!EnsureAccountExists(settings)) { return; }
    
    const wxArrayString& paths = e.GetPaths();
    if(paths.IsEmpty()) { return; }
    
    for(size_t i = 0; i < paths.size(); ++i) {
        wxString remotePath = GetRemotePath(settings, paths.Item(i));
        if(remotePath.IsEmpty()) { return; }
        
        // Fire this event, if the sftp plugin is ON, it will handle it
        clSFTPEvent eventDelete(wxEVT_SFTP_DELETE_FILE);
        eventDelete.SetAccount(settings.GetAccount());
        eventDelete.SetRemoteFile(remotePath);
        EventNotifier::Get()->AddPendingEvent(eventDelete);
    }
}
示例#12
0
void PHPWorkspaceView::DoOpenSSHAccountManager()
{
    SSHWorkspaceSettings settings;
    settings.Load();

    SFTPBrowserDlg dlg(EventNotifier::Get()->TopFrame(),
                       _("Select the remote folder corrseponding to the current workspace file"),
                       "",
                       clSFTP::SFTP_BROWSE_FOLDERS); // Browse for folders only
    dlg.Initialize(settings.GetAccount(), settings.GetRemoteFolder());

    if(dlg.ShowModal() == wxID_OK) {
        settings.SetAccount(dlg.GetAccount());
        settings.SetRemoteFolder(dlg.GetPath());
        settings.Save();
    }
}
示例#13
0
bool PhpSFTPHandler::EnsureAccountExists(SSHWorkspaceSettings& workspaceSettings)
{
    // Do we need to sync?
    if(!(workspaceSettings.IsRemoteUploadSet() && workspaceSettings.IsRemoteUploadEnabled())) { return false; }
    
    SFTPSettings sftpSettings;
    sftpSettings.Load();
    
    // Try to locate hte SSH account for this workspace
    SSHAccountInfo account;
    if(!sftpSettings.GetAccount(workspaceSettings.GetAccount(), account)) {
        // Failed to locate the SSH account, disable sync
        wxString msg;
        msg << _("Failed to locate SSH account: ") << workspaceSettings.GetAccount() << "\n";
        ::wxMessageBox(msg, _("SFTP"), wxOK | wxICON_ERROR);
        // Clear the sync settings and return
        workspaceSettings.Reset();
        workspaceSettings.Save();
        return false;
    }
    return true;
}