KitaThreadView::KitaThreadView(QWidget *parent, const char *name)
: KitaThreadViewBase(parent, name)
, m_parent( parent )
- , m_currentJob( 0 )
+// , m_currentJob( 0 )
, m_labelMaxLength( 60 )
{
m_threadPart = new KitaHTMLPart(threadFrame);
m_threadPart->resetHit();
m_threadPart->resetHitCount();
m_writeResult = "";
- m_threadData = "";
m_threadPart->setContents("");
m_threadPart->clearPosition();
}
-// m_board = *(thread.getBoard());
m_thread = thread;
-/* if ( m_thread.datURL().protocol() != "k2ch" ) {
- KIO::SlaveConfig::self()->setConfigData("http", m_thread.datURL().host() ,
- "UserAgent", "Monazilla/1.00 (Kita/0.4)");
- }
-
- KIO::TransferJob* job = KIO::get(m_thread.datURL(), true, true);
- m_currentJob = job;
-
- connect(job, SIGNAL(data(KIO::Job*, const QByteArray&)),
- SLOT(slotReceiveThreadData(KIO::Job*, const QByteArray&)));
- connect(job, SIGNAL(result(KIO::Job*)), SLOT(slotThreadResult(KIO::Job*)));
- connect(job, SIGNAL(redirection(KIO::Job *, const KURL&) ), SLOT(slotRedirection(KIO::Job *, const KURL&) ) );
- // use 'HTTP-Headers' metadata.
- job->addMetaData("PropagateHttpHeader", "true");*/
-
-// if( m_access ) delete m_access;
m_access = new Kita::ThreadAccess( thread );
+ connect( m_access, SIGNAL( redirection( const KURL& ) ), SIGNAL( setLocationBarURL( const KURL& ) ) );
QString result = m_access->get();
m_serverTime = getServerTimeFromHttpHeaders( m_access->getHeader() );
update( result );
}
-void KitaThreadView::slotRedirection(KIO::Job *, const KURL & newURL)
-{
- printf(" Redirected to newURL: %s\n", newURL.url().latin1() );
- m_thread = Kita::Thread( m_thread.getBoard(), newURL);
- emit setLocationBarURL(newURL.url());
-}
-
-void KitaThreadView::slotReceiveThreadData( KIO::Job*, const QByteArray& data )
-{
- QCString cstr(data.data(), data.size()+1);
- m_threadData.append(cstr);
-}
-
int KitaThreadView::getServerTimeFromHttpHeaders( const QString& headers )
{
// parse HTTP headers
subjectLabel->setText( disp );
}
-void KitaThreadView::slotThreadResult(KIO::Job* job)
-{
- m_currentJob = 0;
- if(job->error()) {
- job->showErrorDialog();
- return;
- }
-
- m_serverTime = getServerTimeFromHttpHeaders(job->queryMetaData("HTTP-Headers"));
-
- QCp932Codec codec;
- QTextStream stream(m_threadData, IO_ReadOnly);
- stream.setCodec(&codec);
- QString result = stream.read();
-
- update( result );
-}
-
void KitaThreadView::update( const QString& result )
{
QStringList lines = QStringList::split( "\n", result );
text += footer();
text += "</body></html>";
- m_threadData.truncate(0);
m_threadPart->displayContentsAndGotoURL( text, m_thread );
if( m_access ) {
m_access->killJob();
}
-/* if ( m_currentJob ) {
- m_currentJob->kill();
- }*/
}
KParts::BrowserExtension* KitaThreadView::browserExtension()
{
return m_threadPart->browserExtension();
}
-
// vim:sw=2:
void slotOpenURLRequest( const KURL&, const KParts::URLArgs& );
private: // Private attributes
-// Kita::Board m_board;
Kita::ThreadAccess* m_access;
Kita::Thread m_thread;
KitaHTMLPart* m_threadPart;
- QCString m_threadData;
QCString m_writeResult;
int m_serverTime;
QWidget * m_parent;
- KIO::Job * m_currentJob;
int m_labelMaxLength;
Kita::PostInfo m_postInfo;
void slotReloadButton();
void slotPostStarted( KIO::Job*, const Kita::PostInfo& );
void slotBookmarkButtonClicked( bool on );
- void slotReceiveThreadData( KIO::Job* job, const QByteArray& data );
- void slotRedirection( KIO::Job* job, const KURL& );
- void slotThreadResult( KIO::Job* job );
void slotWriteButtonClicked();
void slotShowErrorDialog( const QString& input, const KURL& urlOfInput = 0 );