~ubuntu-branches/ubuntu/lucid/kchmviewer/lucid

« back to all changes in this revision

Viewing changes to kio-msits/msits.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jose Luis Tallon
  • Date: 2006-06-08 20:08:39 UTC
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20060608200839-8b7jodug8yvtj126
Tags: upstream-2.5
ImportĀ upstreamĀ versionĀ 2.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#include <qvaluevector.h>
35
35
 
36
36
#include "msits.h"
37
 
 
 
37
#include "../src/filetype_handler.h"
38
38
 
39
39
using namespace KIO;
40
40
 
84
84
 
85
85
void ProtocolMSITS::get( const KURL& url )
86
86
{
87
 
        QString fileName;
 
87
        QString htmdata, fileName;
88
88
        chmUnitInfo ui;
 
89
        QByteArray buf;
89
90
 
90
91
    kdDebug() << "kio_msits::get() " << url.path() << endl;
91
92
 
94
95
 
95
96
        kdDebug() << "kio_msits::get: parseLoadAndLookup returned " << fileName << endl;
96
97
 
97
 
        if ( isDirectory (fileName) )
98
 
        {
99
 
                error( KIO::ERR_IS_DIRECTORY, url.prettyURL() );
100
 
                return;
101
 
        }
102
 
 
103
 
        if ( !ResolveObject ( fileName, &ui) )
104
 
        {
105
 
                kdDebug() << "kio_msits::get: could not resolve filename " << fileName << endl;
106
 
        error( KIO::ERR_DOES_NOT_EXIST, url.prettyURL() );
107
 
                return;
108
 
        }
109
 
 
110
 
    QByteArray buf (ui.length);
111
 
 
112
 
        if ( RetrieveObject (&ui, (unsigned char*) buf.data(), 0, ui.length) == 0 )
113
 
        {
114
 
                kdDebug() << "kio_msits::get: could not retrieve filename " << fileName << endl;
115
 
        error( KIO::ERR_NO_CONTENT, url.prettyURL() );
116
 
                return;
117
 
        }
118
 
 
119
 
    totalSize( ui.length );
 
98
        if ( handleFileType( url.path(), htmdata ) )
 
99
        {
 
100
                buf = htmdata.utf8();
 
101
                kdDebug() << "Using special handling for image pages: " << htmdata << endl;
 
102
        }
 
103
        else
 
104
        {
 
105
                if ( isDirectory (fileName) )
 
106
                {
 
107
                        error( KIO::ERR_IS_DIRECTORY, url.prettyURL() );
 
108
                        return;
 
109
                }
 
110
 
 
111
                if ( !ResolveObject ( fileName, &ui) )
 
112
                {
 
113
                        kdDebug() << "kio_msits::get: could not resolve filename " << fileName << endl;
 
114
                error( KIO::ERR_DOES_NOT_EXIST, url.prettyURL() );
 
115
                        return;
 
116
                }
 
117
 
 
118
        buf.resize( ui.length );
 
119
 
 
120
                if ( RetrieveObject (&ui, (unsigned char*) buf.data(), 0, ui.length) == 0 )
 
121
                {
 
122
                        kdDebug() << "kio_msits::get: could not retrieve filename " << fileName << endl;
 
123
                error( KIO::ERR_NO_CONTENT, url.prettyURL() );
 
124
                        return;
 
125
                }
 
126
        }
 
127
 
 
128
    totalSize( buf.size() );
120
129
    KMimeMagicResult * result = KMimeMagic::self()->findBufferFileType( buf, fileName );
121
130
    kdDebug() << "Emitting mimetype " << result->mimeType() << endl;
122
131
 
123
132
        mimeType( result->mimeType() );
124
133
    data( buf );
125
 
        processedSize( ui.length );
 
134
        processedSize( buf.size() );
126
135
 
127
136
    finished();
128
137
}