icecast.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "icecast.h"
00022 #include <KUrl>
00023 #include "includekio.h"
00024
00025 icecast::icecast(QObject *parent) : streamDirectoryModel(parent)
00026 {
00027 qRegisterMetaType<icecast_internalThread::streamEntryList>();
00028 m_copyjob = KIO::copy(KUrl("http://dir.xiph.org/yp.xml"),
00029 KUrl::fromPath(m_tempdir.name()),
00030 KIO::HideProgressInfo);
00031 connect(m_copyjob,
00032 SIGNAL(result(KJob *)),
00033 this,
00034 SLOT(process_file(KJob *)));
00035 };
00036
00037 icecast::~icecast()
00038 {
00039 if (!m_copyjob.isNull()) {
00040 m_copyjob->kill();
00041 };
00042 }
00043
00044 void icecast::process_file(KJob *job)
00045 {
00046 if (job->error() == 0) {
00047 connect(&m_thread,
00048 SIGNAL(streamlist_ready(icecast_internalThread::streamEntryList)),
00049 this,
00050 SLOT(use_data(icecast_internalThread::streamEntryList)));
00051 m_thread.setFilename(m_tempdir.name() + "/yp.xml");
00052 m_thread.start();
00053 }
00054 }
00055
00056 void icecast::use_data(icecast_internalThread::streamEntryList list)
00057 {
00058 m_tempdir.unlink();
00059 beginInsertRows(QModelIndex(), 0, list.count()-1);
00060 foreach (streamDirectoryEntry_stream *entry, list) {
00061 rootEntry->appendChild(entry);
00062 };
00063 endInsertRows();
00064 disconnect(this, SLOT(use_data(icecast_internalThread::streamEntryList)));
00065 }