• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

KIMAP Library

job.cpp

00001 /*
00002     Copyright (c) 2009 Kevin Ottens <ervin@kde.org>
00003 
00004     This library is free software; you can redistribute it and/or modify it
00005     under the terms of the GNU Library General Public License as published by
00006     the Free Software Foundation; either version 2 of the License, or (at your
00007     option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful, but WITHOUT
00010     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00011     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00012     License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to the
00016     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017     02110-1301, USA.
00018 */
00019 
00020 #include "job.h"
00021 #include "job_p.h"
00022 #include "message_p.h"
00023 #include "session_p.h"
00024 
00025 #include <KDE/KLocale>
00026 #include <KDE/KDebug>
00027 
00028 using namespace KIMAP;
00029 
00030 Job::Job( Session *session )
00031   : d_ptr(new JobPrivate(session, i18n("Job")))
00032 {
00033 
00034 }
00035 
00036 Job::Job( JobPrivate &dd )
00037   : d_ptr(&dd)
00038 {
00039 
00040 }
00041 
00042 Job::~Job()
00043 {
00044   delete d_ptr;
00045 }
00046 
00047 void Job::start()
00048 {
00049   Q_D(Job);
00050   d->sessionInternal()->addJob(this);
00051 }
00052 
00053 void Job::handleResponse(const Message &response)
00054 {
00055   handleErrorReplies(response);
00056 }
00057 
00058 void Job::connectionLost()
00059 {
00060   setError( KJob::UserDefinedError );
00061   setErrorText( i18n("Connection to server lost.") );
00062   emitResult();
00063 }
00064 
00065 Job::HandlerResponse Job::handleErrorReplies(const Message &response)
00066 {
00067   Q_D(Job);
00068 //   kDebug() << response.toString();
00069 
00070   if ( !response.content.isEmpty()
00071        && response.content.first().toString() == d->tag ) {
00072     if ( response.content.size() < 2 ) {
00073       setErrorText( i18n("%1 failed, malformed reply from the server.", d->m_name) );
00074     } else if ( response.content[1].toString() != "OK" ) {
00075       setError( UserDefinedError );
00076       setErrorText( i18n("%1 failed, server replied: %2", d->m_name, response.toString().constData()) );
00077     }
00078     emitResult();
00079     return Handled;
00080   }
00081 
00082   return NotHandled;
00083 }
00084 
00085 
00086 #include "job.moc"

KIMAP Library

Skip menu "KIMAP Library"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  • kabc
  • kblog
  • kcal
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.5.8
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal