summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/yahoo/libkyahoo/yahoobuddyiconloader.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-05 08:45:53 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-05 08:45:53 +0000
commit5527e01e0675fbb06b632ccdae423756fbff622b (patch)
treec2dd1a478a7789d3b01e77fdf31f9011a96a81c5 /kopete/protocols/yahoo/libkyahoo/yahoobuddyiconloader.cpp
parent1fc8db48741fae272e2d29078b266a3d0f2e2dd1 (diff)
downloadtdenetwork-5527e01e0675fbb06b632ccdae423756fbff622b.tar.gz
tdenetwork-5527e01e0675fbb06b632ccdae423756fbff622b.zip
Many fixes to the Yahoo protocol, courtesy of Serghei Amelian
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1146108 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kopete/protocols/yahoo/libkyahoo/yahoobuddyiconloader.cpp')
-rw-r--r--kopete/protocols/yahoo/libkyahoo/yahoobuddyiconloader.cpp37
1 files changed, 13 insertions, 24 deletions
diff --git a/kopete/protocols/yahoo/libkyahoo/yahoobuddyiconloader.cpp b/kopete/protocols/yahoo/libkyahoo/yahoobuddyiconloader.cpp
index 1608cd6f..5e704efa 100644
--- a/kopete/protocols/yahoo/libkyahoo/yahoobuddyiconloader.cpp
+++ b/kopete/protocols/yahoo/libkyahoo/yahoobuddyiconloader.cpp
@@ -1,7 +1,7 @@
/*
yahoobuddyiconloader.cpp - Fetches YahooBuddyIcons
- Copyright (c) 2005 by André Duffeck <andre@duffeck.de>
+ Copyright (c) 2005 by André Duffeck <duffeck@kde.org>
*************************************************************************
* *
@@ -42,12 +42,12 @@ YahooBuddyIconLoader::~YahooBuddyIconLoader()
void YahooBuddyIconLoader::fetchBuddyIcon( const QString &who, KURL url, int checksum )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << url << endl;
KIO::TransferJob *transfer;
QString Url = url.url();
QString ext = Url.left( Url.findRev( "?" ) );
ext = ext.right( ext.length() - ext.findRev( "." ) );
-
+
transfer = KIO::get( url, false, false );
connect( transfer, SIGNAL( result( KIO::Job* ) ), this, SLOT( slotComplete( KIO::Job* ) ) );
connect( transfer, SIGNAL( data( KIO::Job*, const QByteArray& ) ), this, SLOT( slotData( KIO::Job*, const QByteArray& ) ) );
@@ -55,48 +55,37 @@ void YahooBuddyIconLoader::fetchBuddyIcon( const QString &who, KURL url, int che
m_jobs[transfer].url = url;
m_jobs[transfer].who = who;
m_jobs[transfer].checksum = checksum;
- m_jobs[transfer].file = new KTempFile( locateLocal( "tmp", "yahoobuddyicon-" ), ext );
- m_jobs[transfer].file->setAutoDelete( true );
}
void YahooBuddyIconLoader::slotData( KIO::Job *job, const QByteArray& data )
{
-
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
KIO::TransferJob *transfer = static_cast< KIO::TransferJob * >(job);
- if( m_jobs[transfer].file )
- m_jobs[transfer].file->file()->writeBlock( data.data() , data.size() );
-
+ // FIXME need to check
+ //m_jobs[transfer].icon.append( data );
+ int oldsize = m_jobs[transfer].icon.size();
+ m_jobs[transfer].icon.resize( data.size() + oldsize );
+ memcpy( m_jobs[transfer].icon.data() + oldsize, data.data(), data.size() );
}
void YahooBuddyIconLoader::slotComplete( KIO::Job *job )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << endl;
+ kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
KIO::TransferJob *transfer = static_cast< KIO::TransferJob * >(job);
if ( job->error () || transfer->isErrorPage () )
{
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "An error occured while downloading buddy icon." << endl;
+ kdDebug(YAHOO_RAW_DEBUG) << "An error occurred while downloading buddy icon." << endl;
if( m_client )
- m_client->notifyError( i18n( "An error occured while downloading buddy icon (%1)" ).arg(m_jobs[transfer].url.url()), job->errorString(), Client::Info );
+ m_client->notifyError( i18n( "An error occurred while downloading a buddy icon (%1)").arg( m_jobs[transfer].url.url() ), job->errorString(), Client::Info );
}
else
{
- if ( m_jobs[transfer].file )
- {
- m_jobs[transfer].file->close();
- emit fetchedBuddyIcon( m_jobs[transfer].who, m_jobs[transfer].file, m_jobs[transfer].checksum );
- }
- else
- {
- kdDebug(YAHOO_RAW_DEBUG) << k_funcinfo << "Fatal Error occured. IconLoadJob has an empty KTempFile pointer." << endl;
- if( m_client )
- m_client->notifyError( i18n( "Fatal Error occured while downloading buddy icon." ), i18n( "IconLoadJob has an empty KTempFile pointer." ), Client::Info );
- }
+ emit fetchedBuddyIcon( m_jobs[transfer].who, m_jobs[transfer].icon, m_jobs[transfer].checksum );
}
m_jobs.remove( transfer );