Esempio n. 1
0
void Observer::killJob(int progressId)
{
    KIO::Job *job = m_dctJobs[progressId];
    if(!job)
    {
        kdWarning() << "Can't find job to kill ! There is no job with progressId=" << progressId << " in this process" << endl;
        return;
    }
    job->kill(false /* not quietly */);
}
Esempio n. 2
0
void ReadOnlyPart::abortLoad()
{
    m_file = "";
    if ( m_job )
    {
	KIO::Job *job = m_job;
	m_job = 0;
	job->kill();
    }
}
Esempio n. 3
0
void LdapConfigWidget::sendQuery()
{
  LDAPUrl _url;

  mQResult.clear();
  mCancelled = true;

  _url.setProtocol( ( mSecSSL && mSecSSL->isChecked() ) ? "ldaps" : "ldap" );
  if ( mHost ) _url.setHost( mHost->text() );
  if ( mPort ) _url.setPort( mPort->value() );
  _url.setDn( "" );
  _url.setAttributes( mAttr );
  _url.setScope( LDAPUrl::Base );
  if ( mVer ) _url.setExtension( "x-ver", QString::number( mVer->value() ) );
  if ( mSecTLS && mSecTLS->isChecked() ) _url.setExtension( "x-tls", "" );

  kdDebug(5700) << "sendQuery url: " << _url.prettyURL() << endl;
  mLdif.startParsing();
  KIO::Job *job = KIO::get( _url, true, false );
  job->addMetaData("no-auth-prompt","true");
  connect( job, SIGNAL( data( KIO::Job*, const QByteArray& ) ),
    this, SLOT( loadData( KIO::Job*, const QByteArray& ) ) );
  connect( job, SIGNAL( result( KIO::Job* ) ),
    this, SLOT( loadResult( KIO::Job* ) ) );

  if ( mProg == NULL )
    mProg = new KProgressDialog( this, 0, i18n("LDAP Query"), _url.prettyURL(), true );
  else
    mProg->setLabel( _url.prettyURL() );
  mProg->progressBar()->setValue( 0 );
  mProg->progressBar()->setTotalSteps( 1 );
  mProg->exec();
  if ( mCancelled ) {
    kdDebug(5700) << "query cancelled!" << endl;
    job->kill( true );
  } else {
    if ( !mErrorMsg.isEmpty() ) KMessageBox::error( this, mErrorMsg );
  }
}
Esempio n. 4
0
void PiwigoTalker::slotResult(KJob* job)
{
    KIO::Job* tempjob = static_cast<KIO::Job*>(job);
    State state = m_state; // Can change in the treatment itself
    // so we cache it

    if (tempjob->error())
    {
        if (state == GE_LOGIN)
        {
            emit signalLoginFailed(tempjob->errorString());
            kDebug() << tempjob->errorString();
        }
        else if (state == GE_GETVERSION) {
            kDebug() << tempjob->errorString();
            // Version isn't mandatory and errors can be ignored
            // As login succeeded, albums can be listed
            listAlbums();
        }
        else if (state == GE_CHECKPHOTOEXIST || state == GE_GETINFO ||
                 state == GE_SETINFO         || state == GE_ADDPHOTOCHUNK ||
                 state == GE_ADDPHOTOSUMMARY || state == GE_OLD_ADDPHOTOCHUNK ||
                 state == GE_OLD_ADDTHUMB    || state == GE_OLD_ADDHQ ||
                 state == GE_OLD_ADDPHOTOSUMMARY)
        {
            emit signalAddPhotoFailed(tempjob->errorString());
        }
        else
        {
            tempjob->ui()->setWindow(m_parent);
            tempjob->ui()->showErrorMessage();
        }
        emit signalBusy(false);
        return;
    }

    switch (state)
    {
    case(GE_LOGIN):
        parseResponseLogin(m_talker_buffer);
        break;
    case(GE_GETVERSION):
        parseResponseGetVersion(m_talker_buffer);
        break;
    case(GE_LISTALBUMS):
        parseResponseListAlbums(m_talker_buffer);
        break;
    case(GE_CHECKPHOTOEXIST):
        parseResponseDoesPhotoExist(m_talker_buffer);
        break;
    case(GE_GETINFO):
        parseResponseGetInfo(m_talker_buffer);
        break;
    case(GE_SETINFO):
        parseResponseSetInfo(m_talker_buffer);
        break;
    // Support for Web API >= 2.4
    case(GE_ADDPHOTOCHUNK):
        parseResponseAddPhotoChunk(m_talker_buffer);
        break;
    case(GE_ADDPHOTOSUMMARY):
        parseResponseAddPhotoSummary(m_talker_buffer);
        break;
    // Support for Web API < 2.4
    case(GE_OLD_ADDPHOTOCHUNK):
        parseResponseOldAddPhoto(m_talker_buffer);
        break;
    case(GE_OLD_ADDTHUMB):
        parseResponseOldAddThumbnail(m_talker_buffer);
        break;
    case(GE_OLD_ADDHQ):
        parseResponseOldAddHQPhoto(m_talker_buffer);
        break;
    case(GE_OLD_ADDPHOTOSUMMARY):
        parseResponseOldAddPhotoSummary(m_talker_buffer);
        break;
    }

    tempjob->kill();
    m_job = 0;

    if (state == GE_GETVERSION && m_loggedIn)
    {
        listAlbums();
    }
    emit signalBusy(false);
}
Esempio n. 5
0
void GalleryTalker::slotResult(KJob *job)
{
    KIO::Job *tempjob = static_cast<KIO::Job*>(job);

    if (tempjob->error())
    {
        if (m_state == GE_LOGIN)
        {
            emit signalLoginFailed(tempjob->errorString());
        }
        else
        {
            if (m_state == GE_ADDPHOTO)
            {
                emit signalAddPhotoFailed(tempjob->errorString());
            }
            else
            {
                tempjob->ui()->setWindow(m_parent);
                tempjob->ui()->showErrorMessage();
            }
        }
        emit signalBusy(false);
        return;
    }

    switch (m_state)
    {
        case(GE_LOGIN):
            parseResponseLogin(m_talker_buffer);
            break;
        case(GE_LISTALBUMS):
            parseResponseListAlbums(m_talker_buffer);
            break;
        case(GE_LISTPHOTOS):
            parseResponseListPhotos(m_talker_buffer);
            break;
        case(GE_CREATEALBUM):
            parseResponseCreateAlbum(m_talker_buffer);
            break;
        case(GE_ADDPHOTO):
            parseResponseAddPhoto(m_talker_buffer);
            break;
    }

    if (m_state == GE_LOGIN && m_loggedIn)
    {
        const QStringList cookielist = (tempjob->queryMetaData("setcookies")).split('\n');
        m_cookie = "Cookie:";


        if(!cookielist.isEmpty())
        {
            QRegExp rx("^GALLERYSID=.+");
            QString app;
            foreach(const QString &str, cookielist)
            {
                if(str.contains("Set-Cookie: "))
                {
                    const QStringList cl = str.split(' ');
                    int n = cl.lastIndexOf(rx);
                    if(n!= -1)
                    {
                        app = cl.at(n);
                    }
                }
            }
            m_cookie += app;
        }

        tempjob->kill();
        listAlbums();
    }