Exemplo n.º 1
0
HX_RESULT
CBaseArchiver2::Abort(void)
{
    HX_RESULT retVal;

    retVal = OnAbort();

    if (m_pFileCreator)
    {
	m_pFileCreator->Done();
	HX_RELEASE(m_pFileCreator);
    }

    return retVal;
}
Exemplo n.º 2
0
void *wxDownloadThread::Entry()
{
    wxInputStream *in = m_url.GetInputStream();

    // check the stream
    if (in == NULL)
    {
        // something is wrong with the input URL...
        OnAbort();
        return NULL;
    }
    if (!in->IsOk())
    {
        delete in;

        // something is wrong with the input URL...
        OnAbort();
        return NULL;
    }

    // we successfully connected with the server
    OnConnect();

    // we are starting the download of a file; update our datetime field
    wxLogDebug(_("wxDownloadThread::Entry - downloading [%s]"),
               m_url.GetURL().c_str());
    m_dtStart = wxDateTime::UNow();

    wxASSERT(m_output->IsOk());

    // get size of download, if available
    size_t sz = in->GetSize();
    m_nFinalSize = (sz == (size_t)-1) ? wxInvalidSize : sz;

    // begin the download
    char buf[wxDT_BUF_TEMP_SIZE];
    bool paused = false;
    while (!TestDestroy())
    {
        if (GetFlag() == wxDTF_ABORT)
        {
            wxLogDebug(wxS("wxDownloadThread::Entry - user-aborting"));
            delete in;
            OnUserAbort();
            return NULL;
        }
        else if (GetFlag() == wxDTF_PAUSE)
        {
            wxLogDebug(wxS("wxDownloadThread::Entry - sleeping"));

            // did we warn our event handler that the download was paused?
            if (!paused)
            {
                paused = true;
                OnPause();
            }

            // sleep 100 msec and then test again our flag to see
            // if it has changed to wxDTF_CONTINUE or to wxDTF_ABORT
            wxMilliSleep(100);
            continue;
        }

        paused = false;

        // write the downloaded stuff in the output file
        // without using the
        //      out.Write(*in);
        // command; that would be easier but would not allow
        // the program to stop this thread while downloading
        // the file since the TestDestroy() function would not
        // be called in that way...
        size_t bytes_read = in->Read(buf, WXSIZEOF(buf)).LastRead();
        if ( !bytes_read )
            break;      // no more data to read

        if ( m_output->Write(buf, bytes_read).LastWrite() != bytes_read )
        {
            // something wrong with saving downloaded data!
            OnAbort();
            return NULL;
        }

        // update our downloaded bytes var
        m_nCurrentSize = m_output->GetSize();

        // notify our even handler that we made progress
        OnUpdate();
    }

    // we don't need the INPUT stream anymore...
    delete in;

    wxASSERT_MSG(m_nCurrentSize == m_nFinalSize || m_nFinalSize == wxInvalidSize,
                 wxS("All errors should have already been catched!"));

    wxLogDebug(_("wxDownloadThread::Entry - completed download of %lu bytes"),
               m_nCurrentSize.ToULong());

    // download is complete
    OnComplete();
    wxLogDebug(wxS("sent complete event"));
    return NULL;
}
Exemplo n.º 3
0
void wxCurlTransferDialog::OnClose(wxCloseEvent &WXUNUSED(ev))
{
    wxCommandEvent fake;
    OnAbort(fake);
}