• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.9.1 API Reference
  • KDE Home
  • Contact Us
 

KIMAP Library

  • kimap
job.cpp
1 /*
2  Copyright (c) 2009 Kevin Ottens <ervin@kde.org>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #include "job.h"
21 #include "job_p.h"
22 #include "message_p.h"
23 #include "session_p.h"
24 
25 #include <KDE/KLocale>
26 #include <KDE/KDebug>
27 
28 using namespace KIMAP;
29 
30 Job::Job( Session *session )
31  : KJob( session ), d_ptr(new JobPrivate(session, i18n("Job")))
32 {
33 
34 }
35 
36 Job::Job( JobPrivate &dd )
37  : KJob( dd.m_session ), d_ptr(&dd)
38 {
39 
40 }
41 
42 Job::~Job()
43 {
44  delete d_ptr;
45 }
46 
47 Session *Job::session() const
48 {
49  Q_D(const Job);
50  return d->m_session;
51 }
52 
53 void Job::start()
54 {
55  Q_D(Job);
56  d->sessionInternal()->addJob(this);
57 }
58 
59 void Job::handleResponse(const Message &response)
60 {
61  handleErrorReplies(response);
62 }
63 
64 void Job::connectionLost()
65 {
66  setError( KJob::UserDefinedError );
67  setErrorText( i18n("Connection to server lost.") );
68  emitResult();
69 }
70 
71 Job::HandlerResponse Job::handleErrorReplies(const Message &response)
72 {
73  Q_D(Job);
74 // kDebug() << response.toString();
75 
76  if ( !response.content.isEmpty()
77  && d->tags.contains( response.content.first().toString() ) ) {
78  if ( response.content.size() < 2 ) {
79  setErrorText( i18n("%1 failed, malformed reply from the server.", d->m_name) );
80  } else if ( response.content[1].toString() != "OK" ) {
81  setError( UserDefinedError );
82  setErrorText( i18n("%1 failed, server replied: %2", d->m_name, response.toString().constData()) );
83  }
84  d->tags.removeAll( response.content.first().toString() );
85  if ( d->tags.isEmpty() ) { // Only emit result when the last command returned
86  emitResult();
87  }
88  return Handled;
89  }
90 
91  return NotHandled;
92 }
93 
94 
95 #include "job.moc"
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Sep 24 2012 09:02:26 by doxygen 1.8.1.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIMAP Library

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

kdepimlibs-4.9.1 API Reference

Skip menu "kdepimlibs-4.9.1 API Reference"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal