~ubuntu-branches/ubuntu/karmic/amarok/karmic

« back to all changes in this revision

Viewing changes to src/aboutdialog/libattica-ocsclient/folderlistjob.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2009-09-03 23:49:07 UTC
  • mfrom: (1.77.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090903234907-rk4lt6hnxwckvuon
Tags: 2:2.1.80-0ubuntu1
New upstream beta release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    This file is part of KDE.
 
3
 
 
4
    Copyright (c) 2008 Cornelius Schumacher <schumacher@kde.org>
 
5
 
 
6
    This program is free software; you can redistribute it and/or modify
 
7
    it under the terms of the GNU General Public License as published by
 
8
    the Free Software Foundation; either version 2 of the License, or
 
9
    (at your option) any later version.
 
10
 
 
11
    This program is distributed in the hope that it will be useful,
 
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
14
    GNU General Public License for more details.
 
15
 
 
16
    You should have received a copy of the GNU General Public License
 
17
    along with this program; if not, write to the Free Software
 
18
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
 
19
    USA.
 
20
*/
 
21
 
 
22
#include "folderlistjob.h"
 
23
 
 
24
#include "folderparser.h"
 
25
 
 
26
#include <kio/job.h>
 
27
#include <klocale.h>
 
28
#include <QTimer>
 
29
#include <QDebug>
 
30
 
 
31
using namespace Attica;
 
32
 
 
33
FolderListJob::FolderListJob()
 
34
  : m_job( 0 )
 
35
{
 
36
}
 
37
 
 
38
void FolderListJob::setUrl( const KUrl &url )
 
39
{
 
40
  m_url = url;
 
41
}
 
42
 
 
43
void FolderListJob::start()
 
44
{
 
45
  QTimer::singleShot( 0, this, SLOT( doWork() ) );
 
46
}
 
47
 
 
48
Folder::List FolderListJob::folderList() const
 
49
{
 
50
  return m_folderList;
 
51
}
 
52
 
 
53
void FolderListJob::doWork()
 
54
{
 
55
  qDebug() << m_url;
 
56
 
 
57
  m_job = KIO::get( m_url, KIO::NoReload, KIO::HideProgressInfo );
 
58
  connect( m_job, SIGNAL( result( KJob * ) ),
 
59
    SLOT( slotJobResult( KJob * ) ) );
 
60
  connect( m_job, SIGNAL( data( KIO::Job *, const QByteArray & ) ),
 
61
    SLOT( slotJobData( KIO::Job *, const QByteArray & ) ) );
 
62
}
 
63
 
 
64
void FolderListJob::slotJobResult( KJob *job )
 
65
{
 
66
  m_job = 0;
 
67
 
 
68
  if ( job->error() ) {
 
69
    setError( job->error() );
 
70
    setErrorText( job->errorText() );
 
71
  
 
72
    emitResult();
 
73
  } else {
 
74
    qDebug() << m_data;
 
75
    m_folderList = FolderParser().parseList(
 
76
      QString::fromUtf8( m_data.data() ) );
 
77
 
 
78
    emitResult();
 
79
  }
 
80
}
 
81
 
 
82
void FolderListJob::slotJobData( KIO::Job *, const QByteArray &data )
 
83
{
 
84
  m_data.append( data );
 
85
}