• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

kmail

  • sources
  • kde-4.14
  • kdepim
  • kmail
  • job
addemailtoexistingcontactjob.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2013-2015 Montel Laurent <montel@kde.org>
3 
4  This program is free software; you can redistribute it and/or modify it
5  under the terms of the GNU General Public License, version 2, as
6  published by the Free Software Foundation.
7 
8  This program is distributed in the hope that it will be useful, but
9  WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License along
14  with this program; if not, write to the Free Software Foundation, Inc.,
15  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #include "addemailtoexistingcontactjob.h"
19 
20 #include <libkdepim/misc/broadcaststatus.h>
21 
22 
23 #include <Akonadi/ItemModifyJob>
24 
25 #include <KABC/Addressee>
26 
27 #include <KLocalizedString>
28 
29 AddEmailToExistingContactJob::AddEmailToExistingContactJob(const Akonadi::Item &item, const QString &email, QObject *parent)
30  : KJob(parent),
31  mItem(item)
32 {
33  QString name;
34  KABC::Addressee::parseEmailAddress( email, name, mEmail );
35 }
36 
37 AddEmailToExistingContactJob::~AddEmailToExistingContactJob()
38 {
39 
40 }
41 
42 void AddEmailToExistingContactJob::start()
43 {
44  if (mItem.hasPayload<KABC::Addressee>()) {
45  KABC::Addressee address = mItem.payload<KABC::Addressee>();
46  QStringList emails = address.emails();
47  if (emails.contains(mEmail)) {
48  Q_EMIT emitResult();
49  } else {
50  emails.append(mEmail);
51  address.setEmails(emails);
52  mItem.setPayload<KABC::Addressee>(address);
53  Akonadi::ItemModifyJob *job = new Akonadi::ItemModifyJob( mItem );
54  connect( job, SIGNAL(result(KJob*)), SLOT(slotAddEmailDone(KJob*)) );
55  }
56  } else {
57  qDebug()<<" not a KABC::Addressee item ";
58  //TODO add error
59  Q_EMIT emitResult();
60  }
61 }
62 
63 void AddEmailToExistingContactJob::slotAddEmailDone(KJob *job)
64 {
65  if ( job->error() ) {
66  setError( job->error() );
67  setErrorText( job->errorText() );
68  } else {
69  KPIM::BroadcastStatus::instance()->setStatusMsg( i18n( "Email added successfully." ) );
70  }
71  Q_EMIT emitResult();
72 }
73 
74 #include "moc_addemailtoexistingcontactjob.cpp"
KPIM::BroadcastStatus::instance
static BroadcastStatus * instance()
email
const QString email
Definition: identitydialog.cpp:640
AddEmailToExistingContactJob::AddEmailToExistingContactJob
AddEmailToExistingContactJob(const Akonadi::Item &item, const QString &email, QObject *parent=0)
Definition: addemailtoexistingcontactjob.cpp:29
KPIM::BroadcastStatus::setStatusMsg
void setStatusMsg(const QString &message)
QObject
addemailtoexistingcontactjob.h
QString
QStringList
AddEmailToExistingContactJob::start
void start()
Definition: addemailtoexistingcontactjob.cpp:42
AddEmailToExistingContactJob::~AddEmailToExistingContactJob
~AddEmailToExistingContactJob()
Definition: addemailtoexistingcontactjob.cpp:37
broadcaststatus.h
KJob
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:32 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kmail

Skip menu "kmail"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



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