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

console/kabcclient

  • sources
  • kde-4.14
  • kdepim
  • console
  • kabcclient
  • src
kabcclient.cpp
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005 - 2008 Kevin Krammer <kevin.krammer@gmx.at>
3 // Copyright (C) 2005 Tobias Koenig <tokoe@kde.org>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 //
19 
20 // local includes
21 #include "kabcclient.h"
22 #include "formatfactory.h"
23 #include "inputformat.h"
24 #include "outputformat.h"
25 
26 // standard includes
27 #include <iostream>
28 #include <set>
29 #include <string>
30 
31 // Qt includes
32 #include <QtCore/QTextCodec>
33 #include <QtCore/QTimer>
34 
35 // KDE includes
36 #include <kapplication.h>
37 #include <klocale.h>
38 #include <krandom.h>
39 
40 // KABC includes
41 #include <kabc/addressee.h>
42 #include <kabc/addresseelist.h>
43 #include <kabc/stdaddressbook.h>
44 
45 using namespace KABC;
46 
47 // error messages
48 static const char saveError[] = I18N_NOOP("Saving modifications to address book failed");
49 static const char ambiguousMatch[] = I18N_NOOP("Input number %1 matches more than one contact. "
50  "Skipping it to avoid undesired results");
51 
53 
54 KABCClient::KABCClient(Operation operation, FormatFactory* factory)
55  : QObject(0),
56  m_operation(operation),
57  m_formatFactory(factory),
58  m_inputFormat(0),
59  m_outputFormat(0),
60  m_inputCodec(0),
61  m_outputCodec(0),
62  m_addressBook(0),
63  m_inputStream(0),
64  m_matchCaseSensitivity(Qt::CaseInsensitive),
65  m_allowSaving(true)
66 {
67 }
68 
70 
71 KABCClient::~KABCClient()
72 {
73  delete m_inputFormat;
74  delete m_outputFormat;
75 }
76 
78 
79 bool KABCClient::setInputFormat(const QByteArray& name)
80 {
81  switch (m_operation)
82  {
83  // no formatted input
84  case List:
85  return true;
86 
87  case Add:
88  case Merge:
89  if (name == "uid" || name == "search" || name == "dialog")
90  {
91  QString operation = QString::fromUtf8(m_operation == Add ? "add" : "merge");
92  QString error = i18n("Input format '%1' not usable with operation '%2'",
93  QString::fromLocal8Bit(name), operation);
94  std::cerr << error.toLocal8Bit().data();
95  std::cerr << std::endl;
96  return false;
97  }
98 
99  default:
100  break;
101  }
102 
103  m_inputFormat = m_formatFactory->inputFormat(name);
104 
105  return m_inputFormat != 0;
106 }
107 
109 
110 bool KABCClient::setOutputFormat(const QByteArray& name)
111 {
112  m_outputFormat = m_formatFactory->outputFormat(name);
113 
114  return m_outputFormat != 0;
115 }
116 
118 
119 bool KABCClient::setInputOptions(const QByteArray& options)
120 {
121  if (m_operation == List) return true;
122 
123  if (m_inputFormat == 0) return false;
124 
125  return m_inputFormat->setOptions(options);
126 }
127 
129 
130 bool KABCClient::setOutputOptions(const QByteArray& options)
131 {
132  if (m_outputFormat == 0) return false;
133 
134  return m_outputFormat->setOptions(options);
135 }
136 
138 
139 bool KABCClient::setInputCodec(const QByteArray& name)
140 {
141  if (m_operation == List) return true; // no input -> no input codec
142 
143  if (m_inputFormat == 0) return false;
144 
145  m_inputCodec = codecForName(name);
146 
147  if (m_inputCodec == 0) return false;
148 
149  return m_inputFormat->setCodec(m_inputCodec);
150 }
151 
153 
154 bool KABCClient::setOutputCodec(const QByteArray& name)
155 {
156  if (m_outputFormat == 0) return false;
157 
158  m_outputCodec = codecForName(name);
159 
160  if (m_outputCodec == 0) return false;
161 
162  return m_outputFormat->setCodec(m_outputCodec);
163 }
164 
166 
167 void KABCClient::setInputStream(std::istream* stream)
168 {
169  m_inputStream = stream;
170 }
171 
173 
174 bool KABCClient::initOperation()
175 {
176  if (m_inputStream == 0 && m_operation != List) return false;
177 
178 // Async Loading and starting operation of signal does not work
179 // in case no resources can be loaded and a new standard resource is created
180 // because in this case AddressBook doesn't emit signals :(
181 // Workaround by loading synchronous and having the slot called by a
182 // single shot timer
183 
184 // m_addressBook = KABC::StdAddressBook::self(true);
185  m_addressBook = KABC::StdAddressBook::self(false);
186  if (m_addressBook == 0) return false;
187 
188  KABC::StdAddressBook::setAutomaticSave(false);
189 
190 // QObject::connect(m_addressBook, SIGNAL(addressBookChanged(AddressBook*)),
191 // this, SLOT(slotAddressBookLoaded()));
192  QTimer::singleShot(0, this, SLOT(slotAddressBookLoaded()));
193 
194  return true;
195 }
196 
198 
199 int KABCClient::performAdd()
200 {
201  // create a set of all currently existing UIDs
202  std::set<QString> uids;
203  AddressBook::ConstIterator it = m_addressBook->constBegin();
204  AddressBook::ConstIterator endIt = m_addressBook->constEnd();
205  for (; it != endIt; ++it)
206  {
207  uids.insert((*it).uid());
208  }
209 
210  bool wantSave = false;
211  while (!m_inputStream->bad() && !m_inputStream->eof())
212  {
213  Addressee addressee = m_inputFormat->readAddressee(*m_inputStream);
214  if (addressee.isEmpty()) continue;
215 
216  // make sure we really append and don't overwrite
217  if (addressee.uid().isEmpty() || uids.find(addressee.uid()) != uids.end())
218  {
219  addressee.setUid(KRandom::randomString(10));
220  uids.insert(addressee.uid());
221  }
222 
223  m_addressBook->insertAddressee(addressee);
224  wantSave = true;
225 
226  m_outputFormat->writeAddressee(addressee, std::cout);
227  std::cout << std::endl;
228  }
229 
230  if (!wantSave) return 2; // nothing added
231 
232  if (m_allowSaving)
233  {
234  Ticket* saveTicket = m_addressBook->requestSaveTicket();
235  if (saveTicket == 0)
236  {
237  std::cerr << i18n(saveError).toLocal8Bit().data() << std::endl;
238  return 3;
239  }
240 
241  bool saved = m_addressBook->save(saveTicket);
242 
243  if (!saved)
244  {
245  std::cerr << i18n(saveError).toLocal8Bit().data() << std::endl;
246  return 3;
247  }
248  }
249 
250  return (m_inputStream->bad() ? 1 : 0);
251 }
252 
254 
255 int KABCClient::performRemove()
256 {
257  bool wantSave = false;
258 
259  uint count = 0;
260  while (!m_inputStream->bad() && !m_inputStream->eof())
261  {
262  Addressee search = m_inputFormat->readAddressee(*m_inputStream);
263  if (search.isEmpty()) continue;
264 
265  count++;
266 
267  AddresseeList result;
268 
269  AddressBook::ConstIterator it = m_addressBook->constBegin();
270  AddressBook::ConstIterator endIt = m_addressBook->constEnd();
271  for (; it != endIt; ++it)
272  {
273  if (!search.uid().isEmpty() && (*it).uid() == search.uid())
274  {
275  result.append(*it);
276  }
277  else if (!search.realName().isEmpty() &&
278  (*it).realName().indexOf(search.realName(), 0, m_matchCaseSensitivity) != -1)
279  {
280  result.append(*it);
281  }
282  else if (!search.familyName().isEmpty() &&
283  (*it).realName().indexOf(search.familyName(), 0, m_matchCaseSensitivity) != -1)
284  {
285  if (!search.givenName().isEmpty())
286  {
287  if ((*it).realName().indexOf(search.givenName(), 0, m_matchCaseSensitivity) != -1)
288  {
289  result.append(*it);
290  }
291  }
292  else
293  result.append(*it);
294  }
295  else if (!search.givenName().isEmpty() &&
296  (*it).realName().indexOf(search.givenName(), 0, m_matchCaseSensitivity) != -1)
297  {
298  result.append(*it);
299  }
300  else if (!search.preferredEmail().isEmpty())
301  {
302  QStringList matches =
303  (*it).emails().filter(search.preferredEmail(), m_matchCaseSensitivity);
304  if (matches.count() > 0)
305  {
306  result.append(*it);
307  }
308  }
309 
310  if (result.count() > 1) break;
311  }
312 
313  // only work with unambiguous matches
314  if (result.count() == 1)
315  {
316  m_addressBook->removeAddressee(result[0]);
317  wantSave = true;
318 
319  m_outputFormat->writeAddressee(result[0], std::cout);
320  std::cout << std::endl;
321  }
322  else if (result.count() > 1)
323  {
324  std::cerr << i18n(ambiguousMatch).arg(count).toLocal8Bit().data() << std::endl;
325  }
326  }
327 
328  if (!wantSave) return 2; // nothing removed
329 
330  if (m_allowSaving)
331  {
332  Ticket* saveTicket = m_addressBook->requestSaveTicket();
333  if (saveTicket == 0)
334  {
335  std::cerr << i18n(saveError).toLocal8Bit().data() << std::endl;
336  return 3;
337  }
338 
339  bool saved = m_addressBook->save(saveTicket);
340 
341  if (!saved)
342  {
343  std::cerr << i18n(saveError).toLocal8Bit().data() << std::endl;
344  return 3;
345  }
346  }
347 
348  return (m_inputStream->bad() ? 1 : 0);
349 }
350 
352 
353 int KABCClient::performMerge()
354 {
355  bool wantSave = false;
356 
357  uint count = 0;
358  while (!m_inputStream->bad() && !m_inputStream->eof())
359  {
360  Addressee addressee = m_inputFormat->readAddressee(*m_inputStream);
361  if (addressee.isEmpty()) continue;
362 
363  count++;
364 
365  AddresseeList result;
366 
367  AddressBook::ConstIterator it = m_addressBook->constBegin();
368  AddressBook::ConstIterator endIt = m_addressBook->constEnd();
369  for (; it != endIt; ++it)
370  {
371  if (!addressee.uid().isEmpty() && (*it).uid() == addressee.uid())
372  {
373  result.append(*it);
374  }
375  else if (!addressee.realName().isEmpty() &&
376  (*it).realName().indexOf(addressee.realName(), 0, m_matchCaseSensitivity) != -1)
377  {
378  result.append(*it);
379  }
380  else if (!addressee.familyName().isEmpty() &&
381  (*it).realName().indexOf(addressee.familyName(), 0, m_matchCaseSensitivity) != -1)
382  {
383  if (!addressee.givenName().isEmpty())
384  {
385  if ((*it).realName().indexOf(addressee.givenName(),
386  0, m_matchCaseSensitivity) != -1)
387  {
388  result.append(*it);
389  }
390  }
391  else
392  result.append(*it);
393  }
394  else if (!addressee.givenName().isEmpty() &&
395  (*it).realName().indexOf(addressee.givenName(), 0, m_matchCaseSensitivity) != -1)
396  {
397  result.append(*it);
398  }
399  else if (!addressee.preferredEmail().isEmpty())
400  {
401  QStringList matches =
402  (*it).emails().filter(addressee.preferredEmail(), m_matchCaseSensitivity);
403  if (matches.count() > 0)
404  {
405  result.append(*it);
406  }
407  }
408 
409  if (result.count() > 1) break;
410  }
411 
412  // only work with unambiguous matches
413  if (result.count() == 1)
414  {
415  Addressee master = result[0];
416  mergeAddressees(master, addressee);
417 
418  m_addressBook->insertAddressee(master);
419  wantSave = true;
420 
421  m_outputFormat->writeAddressee(master, std::cout);
422  std::cout << std::endl;
423  }
424  else if (result.count() > 1)
425  {
426  std::cerr << i18n(ambiguousMatch).arg(count).toLocal8Bit().data() << std::endl;
427  }
428  }
429 
430  if (!wantSave) return 2; // nothing merged
431 
432  if (m_allowSaving)
433  {
434  Ticket* saveTicket = m_addressBook->requestSaveTicket();
435  if (saveTicket == 0)
436  {
437  std::cerr << i18n(saveError).toLocal8Bit().data() << std::endl;
438  return 3;
439  }
440 
441  bool saved = m_addressBook->save(saveTicket);
442 
443  if (!saved)
444  {
445  std::cerr << i18n(saveError).toLocal8Bit().data() << std::endl;
446  return 3;
447  }
448  }
449 
450  return (m_inputStream->bad() ? 1 : 0);
451 }
452 
454 
455 int KABCClient::performList()
456 {
457  AddresseeList list = m_addressBook->allAddressees();
458 
459  return m_outputFormat->writeAddresseeList(list, std::cout) ? 0 : 1;
460 }
461 
463 
464 int KABCClient::performSearch()
465 {
466  int resultValue = 2; // i.e. search didn't find any match
467 
468  AddressBook::ConstIterator endIt = m_addressBook->constEnd();
469 
470  while (!m_inputStream->bad() && !m_inputStream->eof())
471  {
472  Addressee search = m_inputFormat->readAddressee(*m_inputStream);
473  if (search.isEmpty()) continue;
474 
475  AddresseeList result;
476 
477  AddressBook::ConstIterator it = m_addressBook->constBegin();
478  for (; it != endIt; ++it)
479  {
480  if (!search.uid().isEmpty() && (*it).uid() == search.uid())
481  {
482  result.append(*it);
483  }
484  else if (!search.realName().isEmpty() &&
485  (*it).realName().indexOf(search.realName(), 0, m_matchCaseSensitivity) != -1)
486  {
487  result.append(*it);
488  }
489  else if (!search.familyName().isEmpty() &&
490  (*it).realName().indexOf(search.familyName(), 0, m_matchCaseSensitivity) != -1)
491  {
492  if (!search.givenName().isEmpty())
493  {
494  if ((*it).realName().indexOf(search.givenName(), 0, m_matchCaseSensitivity) != -1)
495  {
496  result.append(*it);
497  }
498  }
499  else
500  result.append(*it);
501  }
502  else if (!search.givenName().isEmpty() &&
503  (*it).realName().indexOf(search.givenName(), 0, m_matchCaseSensitivity) != -1)
504  {
505  result.append(*it);
506  }
507  else if (!search.preferredEmail().isEmpty())
508  {
509  QStringList matches =
510  (*it).emails().filter(search.preferredEmail(), m_matchCaseSensitivity);
511  if (matches.count() > 0)
512  {
513  result.append(*it);
514  }
515  }
516  }
517 
518  if (result.count() > 0)
519  {
520  resultValue = 0;
521 
522  if (!m_outputFormat->writeAddresseeList(result, std::cout))
523  {
524  return 1;
525  }
526  }
527  }
528 
529  return resultValue;
530 }
531 
533 // taken from KAddressBook/KABCTools (c) Tobias Koenig
534 
535 void KABCClient::mergePictures(KABC::Picture& master, const KABC::Picture slave)
536 {
537  if (master.isIntern())
538  {
539  if (master.data().isNull())
540  {
541  if (slave.isIntern() && !slave.data().isNull())
542  master.setData(slave.data());
543  else if (!slave.isIntern() && !slave.url().isEmpty())
544  master.setUrl(slave.url());
545  }
546  }
547  else
548  {
549  if (master.url().isEmpty())
550  {
551  if (slave.isIntern() && !slave.data().isNull())
552  master.setData( slave.data() );
553  else if (!slave.isIntern() && !slave.url().isEmpty())
554  master.setUrl(slave.url());
555  }
556  }
557 }
558 
560 // derived from KAddressBook/KABCTools::mergeContacts (c) Tobias Koenig
561 
562 void KABCClient::mergeAddressees(KABC::Addressee& master, const KABC::Addressee& slave)
563 {
564  if (slave.isEmpty()) return;
565 
566  // ADR + LABEL
567  const KABC::Address::List addresses = slave.addresses();
568  KABC::Address::List masterAddresses = master.addresses();
569  KABC::Address::List::ConstIterator addrIt ;
570  for (addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt)
571  {
572  if (!masterAddresses.contains(*addrIt))
573  master.insertAddress(*addrIt);
574  }
575 
576  // BIRTHDAY
577  if (master.birthday().isNull() && !slave.birthday().isNull())
578  master.setBirthday(slave.birthday());
579 
580  // CATEGORIES
581  const QStringList categories = slave.categories();
582  const QStringList masterCategories = master.categories();
583 
584  QStringList newCategories = masterCategories;
585  QStringList::ConstIterator it;
586  for (it = categories.begin(); it != categories.end(); ++it)
587  {
588  if (!masterCategories.contains(*it))
589  newCategories.append(*it);
590  }
591  master.setCategories(newCategories);
592 
593  // CLASS
594  if (!master.secrecy().isValid() && slave.secrecy().isValid())
595  master.setSecrecy(slave.secrecy());
596 
597  // EMAIL
598  const QStringList emails = slave.emails();
599  const QStringList masterEmails = master.emails();
600 
601  for (it = emails.begin(); it != emails.end(); ++it)
602  {
603  if (!masterEmails.contains(*it))
604  master.insertEmail(*it, false);
605  }
606 
607  // FN
608  if (master.formattedName().isEmpty() && !slave.formattedName().isEmpty())
609  master.setFormattedName(slave.formattedName());
610 
611  // GEO
612  if (!master.geo().isValid() && slave.geo().isValid())
613  master.setGeo(slave.geo());
614 
615  /*
616  // KEY
617  */
618  // LOGO
619  KABC::Picture logo = master.logo();
620  mergePictures(logo, slave.logo());
621  master.setLogo(logo);
622 
623  // MAILER
624  if (master.mailer().isEmpty() && !slave.mailer().isEmpty())
625  master.setMailer(slave.mailer());
626 
627  // N
628  if (master.assembledName().isEmpty() && !slave.assembledName().isEmpty())
629  master.setNameFromString(slave.assembledName());
630 
631  // NICKNAME
632  if (master.nickName().isEmpty() && !slave.nickName().isEmpty())
633  master.setNickName(slave.nickName());
634 
635  // NOTE
636  if (master.note().isEmpty() && !slave.note().isEmpty())
637  master.setNote(slave.note());
638 
639  // ORG
640  if (master.organization().isEmpty() && !slave.organization().isEmpty())
641  master.setOrganization(slave.organization());
642 
643  // PHOTO
644  KABC::Picture photo = master.photo();
645  mergePictures(photo, slave.photo());
646  master.setPhoto( photo );
647 
648  // PROID
649  if (master.productId().isEmpty() && !slave.productId().isEmpty())
650  master.setProductId(slave.productId());
651 
652  // REV
653  if (master.revision().isNull() && !slave.revision().isNull())
654  master.setRevision(slave.revision());
655 
656  // ROLE
657  if (master.role().isEmpty() && !slave.role().isEmpty())
658  master.setRole(slave.role());
659 
660  // SORT-STRING
661  if (master.sortString().isEmpty() && !slave.sortString().isEmpty())
662  master.setSortString(slave.sortString());
663 
664  /*
665  // SOUND
666  */
667 
668  // TEL
669  const KABC::PhoneNumber::List phones = slave.phoneNumbers();
670  const KABC::PhoneNumber::List masterPhones = master.phoneNumbers();
671 
672  KABC::PhoneNumber::List::ConstIterator phoneIt;
673  for (phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt)
674  {
675  if (!masterPhones.contains(*phoneIt))
676  master.insertPhoneNumber(*phoneIt);
677  }
678 
679  // TITLE
680  if (master.title().isEmpty() && !slave.title().isEmpty())
681  master.setTitle(slave.title());
682 
683  // TZ
684  if (!master.timeZone().isValid() && slave.timeZone().isValid())
685  master.setTimeZone(slave.timeZone());
686 
687  // ignore UID we keep the master's one
688 
689  // URL
690  if (master.url().isEmpty() && !slave.url().isEmpty())
691  master.setUrl(slave.url());
692 
693  // X-
694  const QStringList customs = slave.customs();
695  const QStringList masterCustoms = master.customs();
696 
697  QStringList newCustoms = masterCustoms;
698  for (it = customs.begin(); it != customs.end(); ++it)
699  {
700  if (!masterCustoms.contains(*it))
701  newCustoms.append(*it);
702  }
703  master.setCustoms(newCustoms);
704 }
705 
707 
708 QTextCodec* KABCClient::codecForName(const QByteArray& name)
709 {
710  if (name.isEmpty()) return 0;
711 
712  if (name.toLower() == "utf-8" || name.toLower() == "utf8" || name == "utf")
713  {
714  return QTextCodec::codecForName("UTF-8");
715  }
716 
717  if (name.toLower() == "local" || name.toLower() == "locale")
718  {
719  return QTextCodec::codecForLocale();
720  }
721 
722  return QTextCodec::codecForName(name.toUpper());
723 }
724 
726 
727 void KABCClient::slotAddressBookLoaded()
728 {
729  // disconnect so we are not disturbed during operations
730  QObject::disconnect(m_addressBook, SIGNAL(addressBookChanged(AddressBook*)),
731  this, SLOT(slotAddressBookLoaded()));
732 
733  int result = 1;
734 
735  switch (m_operation)
736  {
737  case Add:
738  result = performAdd();
739  break;
740 
741  case Remove:
742  result = performRemove();
743  break;
744 
745  case Merge:
746  result = performMerge();
747  break;
748 
749  case List:
750  result = performList();
751  break;
752 
753  case Search:
754  result = performSearch();
755  break;
756 
757  default:
758  break;
759  }
760 
761  KApplication::kApplication()->exit(result);
762 }
763 
764 // End of file
765 
KABCClient::setOutputFormat
bool setOutputFormat(const QByteArray &name)
Sets the output format to use.
Definition: kabcclient.cpp:110
KABCClient::setInputFormat
bool setInputFormat(const QByteArray &name)
Sets the input format to use.
Definition: kabcclient.cpp:79
KABCClient::Add
Adds the input to the address book.
Definition: kabcclient.h:78
QByteArray::toLower
QByteArray toLower() const
saveError
static const char saveError[]
Definition: kabcclient.cpp:48
QByteArray
KABCClient::Merge
Merges input data into the address book.
Definition: kabcclient.h:112
QByteArray::toUpper
QByteArray toUpper() const
QStringList::contains
bool contains(const QString &str, Qt::CaseSensitivity cs) const
QByteArray::isEmpty
bool isEmpty() const
KABCClient::setOutputCodec
bool setOutputCodec(const QByteArray &name)
Sets the text codec for writing the output data.
Definition: kabcclient.cpp:154
KABCClient::setInputOptions
bool setInputOptions(const QByteArray &options)
Sets the options for the input format.
Definition: kabcclient.cpp:119
KABCClient::setOutputOptions
bool setOutputOptions(const QByteArray &options)
Sets the options for the output format.
Definition: kabcclient.cpp:130
QObject::disconnect
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
OutputFormat::writeAddresseeList
virtual bool writeAddresseeList(const KABC::AddresseeList &addresseeList, std::ostream &stream)=0
Writes the data from each addressee in the given list to the given output stream. ...
InputFormat::readAddressee
virtual KABC::Addressee readAddressee(std::istream &stream)=0
Reads one addressee from the input stream.
KABCClient::KABCClient
KABCClient(Operation operation, FormatFactory *factory)
Creates and initializes the instance.
Definition: kabcclient.cpp:54
QTextCodec::codecForLocale
QTextCodec * codecForLocale()
KABCClient::initOperation
bool initOperation()
Checks if Operation setup is correct and schedules execution.
Definition: kabcclient.cpp:174
FormatFactory::inputFormat
InputFormat * inputFormat(const QByteArray &name)
Creates an InputFormat instance for the given name.
Definition: formatfactory.cpp:53
OutputFormat::writeAddressee
virtual bool writeAddressee(const KABC::Addressee &addressee, std::ostream &stream)=0
Writes the data of a given addressee to the given output stream.
QList::count
int count(const T &value) const
QString::fromLocal8Bit
QString fromLocal8Bit(const char *str, int size)
QList::append
void append(const T &value)
QString::fromUtf8
QString fromUtf8(const char *str, int size)
formatfactory.h
KABCClient::setInputCodec
bool setInputCodec(const QByteArray &name)
Sets the text codec for reading the input data.
Definition: kabcclient.cpp:139
QObject
FormatFactory::outputFormat
OutputFormat * outputFormat(const QByteArray &name)
Creates an OutputFormat instance for the given name.
Definition: formatfactory.cpp:81
outputformat.h
OutputFormat::setCodec
virtual bool setCodec(QTextCodec *codec)=0
Sets the text codec to use.
InputFormat::setOptions
virtual bool setOptions(const QByteArray &options)=0
Configures the input format.
QString
QTextCodec
ambiguousMatch
static const char ambiguousMatch[]
Definition: kabcclient.cpp:49
QStringList
QList::end
iterator end()
QString::toLocal8Bit
QByteArray toLocal8Bit() const
KABCClient::setInputStream
void setInputStream(std::istream *stream)
Sets the input stream to read data from.
Definition: kabcclient.cpp:167
KABCClient::~KABCClient
virtual ~KABCClient()
Destroys the instance.
Definition: kabcclient.cpp:71
OutputFormat::setOptions
virtual bool setOptions(const QByteArray &options)=0
Configures the output format.
kabcclient.h
KABCClient::Remove
Removes matching contact from the address book.
Definition: kabcclient.h:95
QTextCodec::codecForName
QTextCodec * codecForName(const QByteArray &name)
QList::ConstIterator
typedef ConstIterator
FormatFactory
Factory for input parsers and output formatters.
Definition: formatfactory.h:102
QByteArray::data
char * data()
KABCClient::Search
Searches for matching entries in the address book.
Definition: kabcclient.h:124
QStringList::filter
QStringList filter(const QString &str, Qt::CaseSensitivity cs) const
QList::begin
iterator begin()
KABCClient::List
Writes all contacts of the address book.
Definition: kabcclient.h:65
InputFormat::setCodec
virtual bool setCodec(QTextCodec *codec)=0
Sets the text codec to use.
KABCClient::Operation
Operation
List of supported operations.
Definition: kabcclient.h:58
inputformat.h
QTimer::singleShot
singleShot
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:31:23 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

console/kabcclient

Skip menu "console/kabcclient"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

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