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

kopete/libkopete

  • sources
  • kde-4.14
  • kdenetwork
  • kopete
  • libkopete
  • contactlist
xmlcontactstorage.cpp
Go to the documentation of this file.
1 /*
2  Kopete Contact List XML Storage Class
3 
4  Copyright 2006 by Matt Rogers <mattr@kde.org>
5  Copyright 2006 by MichaĆ«l Larouche <larouche@kde.org>
6  Copyright 2006 by Roman Jarosz <kedgedev@centrum.cz>
7 
8  Kopete 2002-2006 by the Kopete developers <kopete-devel@kde.org>
9 
10  *************************************************************************
11  * *
12  * This library is free software; you can redistribute it and/or *
13  * modify it under the terms of the GNU Lesser General Public *
14  * License as published by the Free Software Foundation; either *
15  * version 2 of the License, or (at your option) any later version. *
16  * *
17  *************************************************************************
18 */
19 #include "xmlcontactstorage.h"
20 #ifdef Q_WS_X11
21 #include <fixx11h.h>
22 #endif
23 
24 // Qt includes
25 #include <QtCore/QFile>
26 #include <QtCore/QUuid>
27 #include <QtCore/QRegExp>
28 #include <QtCore/QLatin1String>
29 #include <QtCore/QTextCodec>
30 #include <QtCore/QTextStream>
31 #include <QtXml/QDomDocument>
32 #include <QtXml/QDomElement>
33 
34 // KDE includes
35 #include <kdebug.h>
36 #include <kstandarddirs.h>
37 #include <klocale.h>
38 #include <ksavefile.h>
39 
40 // Kopete includes
41 #include "kopetecontactlist.h"
42 #include "kopetemetacontact.h"
43 #include "kopetegroup.h"
44 #include "kopetecontact.h"
45 #include "kopeteprotocol.h"
46 #include "kopeteaccount.h"
47 #include "kopetepluginmanager.h"
48 
49 namespace Kopete
50 {
51 
52  // this is just to save typing
53  const QString NSCID_ELEM = QString::fromUtf8( "nameSourceContactId" );
54  const QString NSPID_ELEM = QString::fromUtf8( "nameSourcePluginId" );
55  const QString NSAID_ELEM = QString::fromUtf8( "nameSourceAccountId" );
56  const QString PSCID_ELEM = QString::fromUtf8( "photoSourceContactId" );
57  const QString PSPID_ELEM = QString::fromUtf8( "photoSourcePluginId" );
58  const QString PSAID_ELEM = QString::fromUtf8( "photoSourceAccountId" );
59 
60 class XmlContactStorage::Private
61 {
62 public:
63  Private()
64  : isBusy(false), isValid(false), version(0)
65  {}
66 
67  bool isBusy;
68  bool isValid;
69  QString xmlFilename;
70  QString errorMessage;
71  uint version;
72 
76  static const uint ContactListVersion = 12;
77 };
78 
79 
80 XmlContactStorage::XmlContactStorage()
81  : ContactListStorage(), d(new Private)
82 {
83 }
84 
85 XmlContactStorage::XmlContactStorage(const QString &fileName)
86  : ContactListStorage(), d(new Private)
87 {
88  d->xmlFilename = fileName;
89 }
90 
91 XmlContactStorage::~XmlContactStorage()
92 {
93  delete d;
94 }
95 
96 bool XmlContactStorage::isValid() const
97 {
98  return d->isValid;
99 }
100 
101 QString XmlContactStorage::errorMessage() const
102 {
103  return d->errorMessage;
104 }
105 
106 bool XmlContactStorage::isBusy() const
107 {
108  return d->isBusy;
109 }
110 
111 void XmlContactStorage::load()
112 {
113  if ( isBusy() )
114  return;
115 
116  d->isBusy = true;
117 
118  QString filename;
119  if( !d->xmlFilename.isEmpty() )
120  {
121  filename = d->xmlFilename;
122  }
123  else
124  {
125  filename = KStandardDirs::locateLocal( "appdata", QLatin1String( "contactlist.xml" ) );
126  }
127 
128  if( filename.isEmpty() )
129  {
130  d->isValid = false;
131  d->errorMessage = i18n("Could not find contactlist.xml in Kopete application data.");
132  d->isBusy = false;
133  return;
134  }
135 
136  QDomDocument contactList( QString::fromLatin1( "kopete-contact-list" ) );
137 
138  QFile contactListFile( filename );
139  contactListFile.open( QIODevice::ReadOnly );
140  contactList.setContent( &contactListFile );
141 
142  QDomElement list = contactList.documentElement();
143 
144  d->version = readVersion( list );
145  if( d->version < Private::ContactListVersion )
146  {
147  QFile::copy( filename, filename + QString::fromLatin1(".bak_v%1").arg( d->version ) );
148 
149  if ( d->version == 10 )
150  {
151  updateFrom10to11( list );
152  d->version = readVersion( list );
153  }
154  if ( d->version == 11 )
155  {
156  updateFrom11to12( list );
157  d->version = readVersion( list );
158  }
159 
160  if ( d->version < Private::ContactListVersion )
161  {
162  contactListFile.close();
163  kWarning(14010) << "The contact list on disk is older than expected or cannot be updated!"
164  << "No contact list will be loaded";
165  d->isValid = false;
166  d->isBusy = false;
167  return;
168  }
169  }
170 
171  // First load all groups so we can assign them to metaContacts
172  QDomElement element = list.firstChild().toElement();
173  while( !element.isNull() )
174  {
175  if( element.tagName() == QString::fromLatin1("kopete-group") )
176  {
177  Kopete::Group *group = new Kopete::Group();
178  if( !parseGroup( group, element ) )
179  {
180  delete group;
181  group = 0;
182  }
183  else
184  {
185  addGroup( group );
186  }
187  }
188  element = element.nextSibling().toElement();
189  }
190 
191  // above parseGroup will always fail for top level group, so add it here
192  addGroup( Kopete::Group::topLevel() );
193 
194  // Load metaContacts
195  element = list.firstChild().toElement();
196  while( !element.isNull() )
197  {
198  if( element.tagName() == QString::fromLatin1("meta-contact") )
199  {
200  Kopete::MetaContact *metaContact = new Kopete::MetaContact();
201  if ( !parseMetaContact( metaContact, element ) )
202  {
203  delete metaContact;
204  metaContact = 0;
205  }
206  else
207  {
208  addMetaContact( metaContact );
209  }
210  }
211  else if( element.tagName() != QString::fromLatin1("kopete-group") )
212  {
213  kWarning(14010) << "Unknown element '" << element.tagName() << "' in XML contact list storage!" << endl;
214  }
215  element = element.nextSibling().toElement();
216  }
217 
218  checkGroupIds();
219 
220  contactListFile.close();
221  d->isValid = true;
222  d->isBusy = false;
223 }
224 
225 void XmlContactStorage::save()
226 {
227  if ( isBusy() )
228  return;
229 
230  d->isBusy = true;
231 
232  QString filename;
233  if( !d->xmlFilename.isEmpty() )
234  {
235  filename = d->xmlFilename;
236  }
237  else
238  {
239  filename = KStandardDirs::locateLocal( "appdata", QLatin1String( "contactlist.xml" ) );
240  }
241 
242  KSaveFile contactListFile( filename );
243  if( !contactListFile.open() )
244  {
245  d->isValid = false;
246  d->errorMessage = i18n( "Could not open contact list file." );
247  d->isBusy = false;
248  return;
249  }
250 
251  QDomDocument doc;
252  doc.appendChild( doc.createElement( QLatin1String("kopete-contact-list") ) );
253  doc.documentElement().setAttribute( QLatin1String("version"), QLatin1String("1.2"));
254 
255  // Save group information. ie: Open/Closed, pehaps later icons? Who knows.
256  doc.documentElement().appendChild( doc.importNode( storeGroup( Kopete::Group::topLevel() ), true ) );
257 
258  Kopete::Group::List groupList = Kopete::ContactList::self()->groups();
259  foreach( Kopete::Group *group, groupList )
260  {
261  QDomNode node = doc.importNode( storeGroup( group ), true );
262  doc.documentElement().appendChild( node );
263  }
264 
265  // Save metacontact information.
266  Kopete::MetaContact::List metaContactList = Kopete::ContactList::self()->metaContacts();
267  foreach( Kopete::MetaContact *metaContact, metaContactList )
268  {
269  if( !metaContact->isTemporary() )
270  {
271  QDomNode node = doc.importNode( storeMetaContact( metaContact ), true );
272  doc.documentElement().appendChild( node );
273  }
274  }
275 
276  QTextStream stream ( &contactListFile );
277  stream.setCodec(QTextCodec::codecForName("UTF-8"));
278  doc.save( stream, 4 );
279 
280  if ( !contactListFile.finalize() )
281  {
282  d->isValid = false;
283  d->errorMessage = i18n( "Could not write contact list to a file." );
284  d->isBusy = false;
285  return;
286  }
287 
288  d->isValid = true;
289  d->isBusy = false;
290 }
291 
292 bool XmlContactStorage::parseMetaContact( Kopete::MetaContact *metaContact, const QDomElement &element )
293 {
294  if( !element.hasChildNodes() )
295  return false;
296 
297  bool oldPhotoTracking = false;
298  bool oldNameTracking = false;
299  QString nameSourcePID, nameSourceAID, nameSourceCID;
300  QString photoSourcePID, photoSourceAID, photoSourceCID;
301 
302  metaContact->setLoading( true );
303 
304  QString strContactId = element.attribute( QString::fromUtf8("contactId") );
305  if( !strContactId.isEmpty() )
306  {
307  metaContact->setMetaContactId( QUuid( strContactId ) );
308  }
309  else
310  return false; // we can't handle metacontacts that on't have unique ids
311 
312  QString strKabcId = element.attribute( QString::fromUtf8( "kabcId" ) );
313  if ( !strKabcId.isEmpty() )
314  metaContact->setKabcId( strKabcId );
315 
316  QDomElement contactElement = element.firstChild().toElement();
317  while( !contactElement.isNull() )
318  {
319  if( contactElement.tagName() == QString::fromUtf8( "display-name" ) )
320  { // custom display name, used for the custom name source
321 
322  //the replace is there to workaround the Bug 95444
323  metaContact->setDisplayName( contactElement.text().remove('\n') );
324 
325  if ( contactElement.hasAttribute(NSCID_ELEM) && contactElement.hasAttribute(NSPID_ELEM) && contactElement.hasAttribute(NSAID_ELEM))
326  {
327  oldNameTracking = true;
328  //kDebug(14010) << "old name tracking";
329  // retrieve deprecated data (now stored in property-sources)
330  // save temporarely, we will find a Contact* with this later
331  nameSourceCID = contactElement.attribute( NSCID_ELEM );
332  nameSourcePID = contactElement.attribute( NSPID_ELEM );
333  nameSourceAID = contactElement.attribute( NSAID_ELEM );
334  }
335  }
336  else if( contactElement.tagName() == QString::fromUtf8( "photo" ) )
337  {
338  // custom photo, used for custom photo source
339  metaContact->setPhoto( KUrl(contactElement.text()) );
340 
341  bool photoSyncedWithKABC = (contactElement.attribute(QString::fromUtf8("syncWithKABC")) == QString::fromUtf8("1")) || (contactElement.attribute(QString::fromUtf8("syncWithKABC")) == QString::fromUtf8("true"));
342  metaContact->setPhotoSyncedWithKABC( photoSyncedWithKABC );
343 
344  // retrieve deprecated data (now stored in property-sources)
345  // save temporarely, we will find a Contact* with this later
346  if ( contactElement.hasAttribute(PSCID_ELEM) && contactElement.hasAttribute(PSPID_ELEM) && contactElement.hasAttribute(PSAID_ELEM))
347  {
348  oldPhotoTracking = true;
349 // kDebug(14010) << "old photo tracking";
350  photoSourceCID = contactElement.attribute( PSCID_ELEM );
351  photoSourcePID = contactElement.attribute( PSPID_ELEM );
352  photoSourceAID = contactElement.attribute( PSAID_ELEM );
353  }
354 // else
355 // kDebug(14010) << "no old photo tracking";
356  }
357  else if( contactElement.tagName() == QString::fromUtf8( "property-sources" ) )
358  {
359  QDomNode property = contactElement.firstChild();
360  while( !property.isNull() )
361  {
362  QDomElement propertyElement = property.toElement();
363 
364  if( propertyElement.tagName() == QString::fromUtf8( "name" ) )
365  {
366  QString source = propertyElement.attribute( QString::fromUtf8("source") );
367  metaContact->setDisplayNameSource(stringToSource(source));
368  // find contact sources now.
369  QDomNode propertyParam = propertyElement.firstChild();
370  while( !propertyParam.isNull() )
371  {
372  QDomElement propertyParamElement = propertyParam.toElement();
373  if( propertyParamElement.tagName() == QString::fromUtf8( "contact-source" ) )
374  {
375  nameSourceCID = propertyParamElement.attribute( NSCID_ELEM );
376  nameSourcePID = propertyParamElement.attribute( NSPID_ELEM );
377  nameSourceAID = propertyParamElement.attribute( NSAID_ELEM );
378  }
379  propertyParam = propertyParam.nextSibling();
380  }
381  }
382  if( propertyElement.tagName() == QString::fromUtf8( "photo" ) )
383  {
384  QString source = propertyElement.attribute( QString::fromUtf8("source") );
385  metaContact->setPhotoSource(stringToSource(source));
386  // find contact sources now.
387  QDomNode propertyParam = propertyElement.firstChild();
388  while( !propertyParam.isNull() )
389  {
390  QDomElement propertyParamElement = propertyParam.toElement();
391  if( propertyParamElement.tagName() == QString::fromUtf8( "contact-source" ) )
392  {
393  photoSourceCID = propertyParamElement.attribute( NSCID_ELEM );
394  photoSourcePID = propertyParamElement.attribute( NSPID_ELEM );
395  photoSourceAID = propertyParamElement.attribute( NSAID_ELEM );
396  }
397  propertyParam = propertyParam.nextSibling();
398  }
399  }
400  property = property.nextSibling();
401  }
402  }
403  else if( contactElement.tagName() == QString::fromUtf8( "groups" ) )
404  {
405  QDomNode group = contactElement.firstChild();
406  while( !group.isNull() )
407  {
408  QDomElement groupElement = group.toElement();
409 
410  if( groupElement.tagName() == QString::fromUtf8( "group" ) )
411  {
412  QString strGroupId = groupElement.attribute( QString::fromUtf8("id") );
413  if( !strGroupId.isEmpty() )
414  metaContact->addToGroup( this->group( strGroupId.toUInt() ) );
415  else //kopete 0.6 contact list
416  metaContact->addToGroup( this->findGroup( groupElement.text() ) );
417  }
418  else if( groupElement.tagName() == QString::fromUtf8( "top-level" ) ) //kopete 0.6 contactlist
419  metaContact->addToGroup( Kopete::Group::topLevel() );
420 
421  group = group.nextSibling();
422  }
423  }
424  else if( contactElement.tagName() == QString::fromUtf8( "address-book-field" ) )
425  {
426  QString app = contactElement.attribute( QString::fromUtf8( "app" ), QString() );
427  QString key = contactElement.attribute( QString::fromUtf8( "key" ), QString() );
428  QString val = contactElement.text();
429  metaContact->setAddressBookField( 0, app, key , val );
430  }
431  else //if( groupElement.tagName() == QString::fromUtf8( "plugin-data" ) || groupElement.tagName() == QString::fromUtf8("custom-icons" ))
432  {
433  parseContactListElement( metaContact, contactElement );
434  }
435  contactElement = contactElement.nextSibling().toElement();
436  }
437 
438  if( oldNameTracking )
439  {
440  /* if (displayNameSourceContact() ) <- doesn't work because the contact is only set up when all plugin are loaded (BUG 111956) */
441  if ( !nameSourceCID.isEmpty() )
442  {
443 // kDebug(14010) << "Converting old name source";
444  // even if the old tracking attributes exists, they could have been null, that means custom
445  metaContact->setDisplayNameSource( Kopete::MetaContact::SourceContact );
446  }
447  else
448  {
449  // lets do the best conversion for the old name tracking
450  // if the custom display name is the same as kabc name, set the source to kabc
451  if ( !metaContact->kabcId().isEmpty() && ( metaContact->customDisplayName() == nameFromKABC( metaContact->kabcId() )) )
452  metaContact->setDisplayNameSource( Kopete::MetaContact::SourceKABC );
453  else
454  metaContact->setDisplayNameSource( Kopete::MetaContact::SourceCustom );
455  }
456  }
457 
458  if ( oldPhotoTracking )
459  {
460 // kDebug(14010) << "Converting old photo source";
461  if ( !photoSourceCID.isEmpty() )
462  {
463  metaContact->setPhotoSource( Kopete::MetaContact::SourceContact );
464  }
465  else
466  {
467  if ( !metaContact->kabcId().isEmpty() && !photoFromKABC( metaContact->kabcId() ).isNull() )
468  metaContact->setPhotoSource( Kopete::MetaContact::SourceKABC );
469  else
470  metaContact->setPhotoSource( Kopete::MetaContact::SourceCustom );
471  }
472  }
473 
474  //FIXME if we ensure that XmlContactStorage is still in memory when signal allPluginsLoaded is emitted than
475  // slotAllPluginsLoaded can be in this object with helper QStrings from MetaConctact ( nameSourcePID, nameSourceAID, nameSourceCID,
476  // photoSourcePID, photoSourceAID, photoSourceCID ).
477  metaContact->setPhotoSource( photoSourcePID, photoSourceAID, photoSourceCID );
478  metaContact->setDisplayNameSource( nameSourcePID, nameSourceAID, nameSourceCID );
479 
480  // If a plugin is loaded, load data cached
481  QObject::connect( Kopete::PluginManager::self(), SIGNAL(pluginLoaded(Kopete::Plugin*)),
482  metaContact, SLOT(slotPluginLoaded(Kopete::Plugin*)) );
483  QObject::connect( Kopete::PluginManager::self(), SIGNAL(protocolLoaded(Kopete::Protocol*)),
484  metaContact, SLOT(slotProtocolLoaded(Kopete::Protocol*)) );
485 
486  // All plugins are already loaded, call manually the contact setting slot.
487  if( Kopete::PluginManager::self()->isAllPluginsLoaded() )
488  metaContact->slotAllPluginsLoaded();
489  else
490  // When all plugins are loaded, set the source contact.
491  QObject::connect( Kopete::PluginManager::self(), SIGNAL(allPluginsLoaded()),
492  metaContact, SLOT(slotAllPluginsLoaded()) );
493 
494  metaContact->setLoading( false );
495  return true;
496 }
497 
498 bool XmlContactStorage::parseGroup(Kopete::Group *group, const QDomElement &element)
499 {
500  group->setLoading( true );
501 
502  QString strGroupId = element.attribute( QLatin1String( "groupId" ) );
503  if ( !strGroupId.isEmpty() )
504  {
505  group->setGroupId( strGroupId.toUInt() );
506  if ( group->groupId() > group->uniqueGroupId() )
507  group->setUniqueGroupId( group->groupId() );
508  }
509 
510  // Don't overwrite type for Temporary and TopLevel groups
511  if ( group->type() != Kopete::Group::Temporary && group->type() != Kopete::Group::TopLevel && group->type() != Kopete::Group::Offline )
512  {
513  QString type = element.attribute( QLatin1String( "type" ), QLatin1String( "standard" ) );
514  if ( type == QLatin1String( "temporary" ) )
515  {
516  if ( group->type() != Kopete::Group::Temporary )
517  {
518  parseGroup( Kopete::Group::temporary(), element );
519  return false;
520  }
521  }
522  else if ( type == QLatin1String( "top-level" ) )
523  {
524  if ( group->type() != Kopete::Group::TopLevel )
525  {
526  parseGroup( Kopete::Group::topLevel(), element );
527  return false;
528  }
529  }
530  else if ( type == QLatin1String( "offline" ) )
531  {
532  if ( group->type() != Kopete::Group::Offline )
533  {
534  parseGroup( Kopete::Group::offline(), element );
535  return false;
536  }
537  }
538  }
539 
540  QString view = element.attribute( QLatin1String( "view" ), QLatin1String( "expanded" ) );
541  bool expanded = ( view != QLatin1String( "collapsed" ) );
542  group->setExpanded( expanded );
543 
544  QDomNode groupData = element.firstChild();
545  while ( !groupData.isNull() )
546  {
547  QDomElement groupElement = groupData.toElement();
548  if ( groupElement.tagName() == QLatin1String( "display-name" ) )
549  {
550  // Don't set display name for temporary or top-level items
551  if ( group->type() == Kopete::Group::Normal )
552  group->setDisplayName( groupElement.text() );
553  }
554  else
555  {
556  parseContactListElement( group, groupElement );
557  }
558 
559  groupData = groupData.nextSibling();
560  }
561 
562  // Sanity checks. We must not have groups without a displayname.
563  // FIXME or TODO: This sanity check should be done once, not by each ContactListStorage
564  if ( group->displayName().isEmpty() )
565  {
566  switch ( group->type() )
567  {
568  case Kopete::Group::Temporary:
569  group->setDisplayName( QLatin1String( "Temporary" ) );
570  break;
571  case Kopete::Group::TopLevel:
572  group->setDisplayName( QLatin1String( "Top-Level" ) );
573  break;
574  case Kopete::Group::Offline:
575  group->setDisplayName( QLatin1String( "Offline" ) );
576  break;
577  default:
578  group->setLoading( false );
579  return false;
580  }
581  }
582 
583  group->setLoading( false );
584 
585  //this allows to save data for the top-level group in the top-level group
586  return ( group->type() == Kopete::Group::Normal );
587 }
588 
589 bool XmlContactStorage::parseContactListElement( Kopete::ContactListElement *contactListElement, const QDomElement &element )
590 {
591  if ( element.tagName() == QLatin1String( "plugin-data" ) )
592  {
593  QMap<QString, QString> pluginData;
594  QString pluginId = element.attribute( QLatin1String( "plugin-id" ), QString() );
595 
596  QDomNode field = element.firstChild();
597  while( !field.isNull() )
598  {
599  QDomElement fieldElement = field.toElement();
600  if ( fieldElement.tagName() == QLatin1String( "plugin-data-field" ) )
601  {
602  pluginData.insert( fieldElement.attribute( QLatin1String( "key" ),
603  QLatin1String( "undefined-key" ) ), fieldElement.text() );
604  }
605  field = field.nextSibling();
606  }
607  contactListElement->setPluginData( pluginId, pluginData );
608  }
609  else if ( element.tagName() == QLatin1String( "plugin-contact-data" ) )
610  {
611  QMap<QString, QString> pluginData;
612  QString pluginId = element.attribute( QLatin1String( "plugin-id" ), QString() );
613 
614  QDomNode field = element.firstChild();
615  while( !field.isNull() )
616  {
617  QDomElement fieldElement = field.toElement();
618  if ( fieldElement.tagName() == QLatin1String( "plugin-data-field" ) )
619  {
620  pluginData.insert( fieldElement.attribute( QLatin1String( "key" ),
621  QLatin1String( "undefined-key" ) ), fieldElement.text() );
622  }
623  field = field.nextSibling();
624  }
625  contactListElement->appendPluginContactData( pluginId, pluginData );
626  }
627  else if ( element.tagName() == QLatin1String( "custom-icons" ) )
628  {
629  contactListElement->setUseCustomIcon( element.attribute( QLatin1String( "use" ), QLatin1String( "1" ) ) == QLatin1String( "1" ) );
630  QDomNode ic = element.firstChild();
631  while( !ic.isNull() )
632  {
633  QDomElement iconElement = ic.toElement();
634  if ( iconElement.tagName() == QLatin1String( "icon" ) )
635  {
636  QString stateStr = iconElement.attribute( QLatin1String( "state" ), QString() );
637  QString icon = iconElement.text();
638  ContactListElement::IconState state = ContactListElement::None;
639 
640  if ( stateStr == QLatin1String( "open" ) )
641  state = ContactListElement::Open;
642  if ( stateStr == QLatin1String( "closed" ) )
643  state = ContactListElement::Closed;
644  if ( stateStr == QLatin1String( "online" ) )
645  state = ContactListElement::Online;
646  if ( stateStr == QLatin1String( "offline" ) )
647  state = ContactListElement::Offline;
648  if ( stateStr == QLatin1String( "away" ) )
649  state = ContactListElement::Away;
650  if ( stateStr == QLatin1String( "unknown" ) )
651  state = ContactListElement::Unknown;
652 
653  contactListElement->setIcon( icon, state );
654  }
655  ic = ic.nextSibling();
656  }
657  }
658  else
659  {
660  return false;
661  }
662 
663  return true;
664 }
665 
666 const QDomElement XmlContactStorage::storeMetaContact( Kopete::MetaContact *metaContact, bool minimal ) const
667 {
668  // This causes each Kopete::Protocol subclass to serialise its contacts' data into the metacontact's plugin data and address book data
669  metaContact->serialize();
670 
671  QDomDocument metaContactDoc;
672  metaContactDoc.appendChild( metaContactDoc.createElement( QString::fromUtf8( "meta-contact" ) ) );
673  metaContactDoc.documentElement().setAttribute( QString::fromUtf8( "contactId" ), metaContact->metaContactId() );
674  metaContactDoc.documentElement().setAttribute( QString::fromUtf8( "kabcId" ), metaContact->kabcId() );
675 
676  // the custom display name, used for the custom name source
677  QDomElement displayName = metaContactDoc.createElement( QString::fromUtf8("display-name" ) );
678  displayName.appendChild( metaContactDoc.createTextNode( metaContact->customDisplayName() ) );
679  metaContactDoc.documentElement().appendChild( displayName );
680 
681  QDomElement photo = metaContactDoc.createElement( QString::fromUtf8("photo" ) );
682  photo.appendChild( metaContactDoc.createTextNode( metaContact->customPhoto().url() ) );
683  metaContactDoc.documentElement().appendChild( photo );
684 
685  // Property sources
686  QDomElement propertySources = metaContactDoc.createElement( QString::fromUtf8("property-sources" ) );
687  QDomElement _nameSource = metaContactDoc.createElement( QString::fromUtf8("name") );
688  QDomElement _photoSource = metaContactDoc.createElement( QString::fromUtf8("photo") );
689 
690  // set the contact source for display name
691  _nameSource.setAttribute( QString::fromUtf8("source"), sourceToString( metaContact->displayNameSource() ) );
692 
693  // set contact source metadata
694  if( metaContact->displayNameSourceContact() )
695  {
696  QDomElement contactNameSource = metaContactDoc.createElement( QString::fromUtf8("contact-source") );
697  contactNameSource.setAttribute( NSCID_ELEM, metaContact->displayNameSourceContact()->contactId() );
698  contactNameSource.setAttribute( NSPID_ELEM, metaContact->displayNameSourceContact()->protocol()->pluginId() );
699  contactNameSource.setAttribute( NSAID_ELEM, metaContact->displayNameSourceContact()->account()->accountId() );
700  _nameSource.appendChild( contactNameSource );
701  }
702 
703  // set the contact source for photo
704  _photoSource.setAttribute( QString::fromUtf8("source"), sourceToString( metaContact->photoSource() ) );
705 
706  if( !metaContact->kabcId().isEmpty() )
707  photo.setAttribute( QString::fromUtf8("syncWithKABC") , QString::fromUtf8( metaContact->isPhotoSyncedWithKABC() ? "true" : "false" ) );
708 
709  if( metaContact->photoSourceContact() )
710  {
711  //kDebug(14010) << "serializing photo source " << nameFromContact(photoSourceContact());
712  // set contact source metadata for photo
713  QDomElement contactPhotoSource = metaContactDoc.createElement( QString::fromUtf8("contact-source") );
714  contactPhotoSource.setAttribute( NSCID_ELEM, metaContact->photoSourceContact()->contactId() );
715  contactPhotoSource.setAttribute( NSPID_ELEM, metaContact->photoSourceContact()->protocol()->pluginId() );
716  contactPhotoSource.setAttribute( NSAID_ELEM, metaContact->photoSourceContact()->account()->accountId() );
717  _photoSource.appendChild( contactPhotoSource );
718  }
719  // apend name and photo sources to property sources
720  propertySources.appendChild( _nameSource );
721  propertySources.appendChild( _photoSource );
722 
723  metaContactDoc.documentElement().appendChild( propertySources );
724 
725  // Don't store these information in minimal mode.
726  if(!minimal)
727  {
728  // Store groups
729  if ( !metaContact->groups().isEmpty() )
730  {
731  QDomElement groups = metaContactDoc.createElement( QString::fromUtf8("groups") );
732  foreach( Group *g, metaContact->groups() )
733  {
734  QDomElement group = metaContactDoc.createElement( QString::fromUtf8("group") );
735  group.setAttribute( QString::fromUtf8("id"), g->groupId() );
736  groups.appendChild( group );
737  }
738  metaContactDoc.documentElement().appendChild( groups );
739  }
740 
741  // Store other plugin data
742  const QList<QDomElement> pluginNodes = storeContactListElement( metaContact );
743  foreach ( const QDomElement &it , pluginNodes )
744  metaContactDoc.documentElement().appendChild( metaContactDoc.importNode( it, true ) );
745  }
746  return metaContactDoc.documentElement();
747 }
748 
749 const QDomElement XmlContactStorage::storeGroup( Kopete::Group *group ) const
750 {
751  QDomDocument groupDoc;
752  groupDoc.appendChild( groupDoc.createElement( QLatin1String( "kopete-group" ) ) );
753  groupDoc.documentElement().setAttribute( QLatin1String( "groupId" ), QString::number( group->groupId() ) );
754 
755  QString type;
756  switch ( group->type() )
757  {
758  case Kopete::Group::Temporary:
759  type = QLatin1String( "temporary" );
760  break;
761  case Kopete::Group::TopLevel:
762  type = QLatin1String( "top-level" );
763  break;
764  case Kopete::Group::Offline:
765  type = QLatin1String( "offline" );
766  break;
767 
768  default:
769  type = QLatin1String( "standard" ); // == Normal
770  break;
771  }
772 
773  groupDoc.documentElement().setAttribute( QLatin1String( "type" ), type );
774  groupDoc.documentElement().setAttribute( QLatin1String( "view" ), QLatin1String( group->isExpanded() ? "expanded" : "collapsed" ) );
775 
776  QDomElement displayName = groupDoc.createElement( QLatin1String( "display-name" ) );
777  displayName.appendChild( groupDoc.createTextNode( group->displayName() ) );
778  groupDoc.documentElement().appendChild( displayName );
779 
780  // Store other plugin data
781  const QList<QDomElement> pluginNodes = storeContactListElement( group );
782  foreach ( const QDomElement &it , pluginNodes )
783  groupDoc.documentElement().appendChild( groupDoc.importNode( it, true ) );
784 
785 
786  return groupDoc.documentElement();
787 
788 }
789 
790 const QList<QDomElement> XmlContactStorage::storeContactListElement( Kopete::ContactListElement *contactListElement ) const
791 {
792  QDomDocument pluginData;
793  QList<QDomElement> pluginNodes;
794  pluginData.appendChild( pluginData.createElement( QLatin1String( "plugin-data" ) ) );
795 
796  const Kopete::ContactListElement::PluginDataMap plugins = contactListElement->pluginData();
797  if ( !plugins.isEmpty() )
798  {
799  Kopete::ContactListElement::PluginDataMap::ConstIterator pluginIt, pluginItEnd = plugins.end();
800  for ( pluginIt = plugins.begin(); pluginIt != pluginItEnd; ++pluginIt )
801  {
802  QDomElement pluginElement = pluginData.createElement( QLatin1String( "plugin-data" ) );
803  pluginElement.setAttribute( QLatin1String( "plugin-id" ), pluginIt.key() );
804 
805  QMap<QString, QString>::ConstIterator it;
806  for ( it = pluginIt.value().begin(); it != pluginIt.value().end(); ++it )
807  {
808  QDomElement pluginDataField = pluginData.createElement( QLatin1String( "plugin-data-field" ) );
809  pluginDataField.setAttribute( QLatin1String( "key" ), it.key() );
810  pluginDataField.appendChild( pluginData.createTextNode( it.value() ) );
811  pluginElement.appendChild( pluginDataField );
812  }
813 
814  pluginData.documentElement().appendChild( pluginElement );
815  pluginNodes.append( pluginElement );
816  }
817  }
818 
819  const QMap<QString, Kopete::ContactListElement::ContactDataList > pluginsContactData = contactListElement->pluginContactData();
820  if ( !pluginsContactData.isEmpty() )
821  {
822  QMap<QString, Kopete::ContactListElement::ContactDataList >::ConstIterator pluginIt, pluginItEnd = pluginsContactData.end();
823  for ( pluginIt = pluginsContactData.begin(); pluginIt != pluginItEnd; ++pluginIt )
824  {
825  foreach ( Kopete::ContactListElement::ContactData dataItem, pluginIt.value() )
826  {
827  QDomElement pluginElement = pluginData.createElement( QLatin1String( "plugin-contact-data" ) );
828  pluginElement.setAttribute( QLatin1String( "plugin-id" ), pluginIt.key() );
829 
830  QMap<QString, QString>::ConstIterator it;
831  for ( it = dataItem.constBegin(); it != dataItem.constEnd(); ++it )
832  {
833  QDomElement pluginDataField = pluginData.createElement( QLatin1String( "plugin-data-field" ) );
834  pluginDataField.setAttribute( QLatin1String( "key" ), it.key() );
835  pluginDataField.appendChild( pluginData.createTextNode( it.value() ) );
836  pluginElement.appendChild( pluginDataField );
837  }
838 
839  pluginData.documentElement().appendChild( pluginElement );
840  pluginNodes.append( pluginElement );
841  }
842  }
843  }
844 
845  const Kopete::ContactListElement::IconMap icons = contactListElement->icons();
846  if ( !icons.isEmpty() )
847  {
848  QDomElement iconsElement = pluginData.createElement( QLatin1String( "custom-icons" ) );
849  iconsElement.setAttribute( QLatin1String( "use" ), contactListElement->useCustomIcon() ? QLatin1String( "1" ) : QLatin1String( "0" ) );
850 
851  Kopete::ContactListElement::IconMap::ConstIterator it, itEnd = icons.end();
852  for ( it = icons.begin(); it != itEnd; ++it )
853  {
854  QDomElement iconElement = pluginData.createElement( QLatin1String( "icon" ) );
855  QString stateStr;
856  switch ( it.key() )
857  {
858  case ContactListElement::Open:
859  stateStr = QLatin1String( "open" );
860  break;
861  case ContactListElement::Closed:
862  stateStr = QLatin1String( "closed" );
863  break;
864  case ContactListElement::Online:
865  stateStr = QLatin1String( "online" );
866  break;
867  case ContactListElement::Away:
868  stateStr = QLatin1String( "away" );
869  break;
870  case ContactListElement::Offline:
871  stateStr = QLatin1String( "offline" );
872  break;
873  case ContactListElement::Unknown:
874  stateStr = QLatin1String( "unknown" );
875  break;
876  case ContactListElement::None:
877  default:
878  stateStr = QLatin1String( "none" );
879  break;
880  }
881  iconElement.setAttribute( QLatin1String( "state" ), stateStr );
882  iconElement.appendChild( pluginData.createTextNode( it.value() ) );
883  iconsElement.appendChild( iconElement );
884  }
885  pluginData.documentElement().appendChild( iconsElement );
886  pluginNodes.append( iconsElement );
887  }
888  return pluginNodes;
889 }
890 
891 bool XmlContactStorage::updateFrom10to11( QDomElement &rootElement ) const
892 {
893  QDomNodeList metaContactElements = rootElement.elementsByTagName( QLatin1String( "meta-contact" ) );
894  for ( int i = 0; i < metaContactElements.count(); ++i )
895  {
896  QDomNode node = metaContactElements.at( i );
897  QDomElement element = node.toElement();
898  if ( element.hasAttribute( QLatin1String("contactId") ) )
899  {
900  QString kabcId;
901  QString contactId = element.attribute( "contactId" );
902  QUuid newContactId = QUuid::createUuid();
903 
904  if ( !contactId.contains( ':' ) )
905  element.setAttribute( QLatin1String("kabcId"), contactId );
906 
907  element.setAttribute( QLatin1String("contactId"), newContactId.toString() );
908  }
909  }
910  rootElement.setAttribute( QString("version"), "1.1" );
911  return true;
912 }
913 
914 bool XmlContactStorage::updateFrom11to12( QDomElement &rootElement ) const
915 {
916  QDomNodeList metaContactElementList = rootElement.elementsByTagName( QLatin1String( "meta-contact" ) );
917  for ( int i = 0; i < metaContactElementList.count(); ++i )
918  {
919  typedef QMap<QString, QString> PluginData;
920  typedef QPair<QString, PluginData> ProtocolIdDataPair;
921 
922  QList<QDomElement> removeList;
923  QList<ProtocolIdDataPair> newList;
924 
925  QDomElement metaContactElement = metaContactElementList.at( i ).toElement();
926  QDomNodeList pluginElementList = metaContactElement.elementsByTagName( QLatin1String( "plugin-data" ) );
927  for ( int j = 0; j < pluginElementList.count(); ++j )
928  {
929  QDomElement element = pluginElementList.at( j ).toElement();
930  QString pluginId = element.attribute( QLatin1String( "plugin-id" ), QString() );
931  if ( !pluginId.endsWith( "Protocol" ) )
932  continue;
933 
934  QMap<QString, QStringList> serializedData;
935 
936  // Read data to serializedData
937  QDomNode field = element.firstChild();
938  while ( !field.isNull() )
939  {
940  QDomElement fieldElement = field.toElement();
941  if ( fieldElement.tagName() == QLatin1String( "plugin-data-field" ) )
942  {
943  QString key = fieldElement.attribute( QLatin1String( "key" ), QLatin1String( "undefined-key" ) );
944  serializedData[key] = fieldElement.text().split( QChar( 0xE000 ), QString::KeepEmptyParts );
945  }
946  field = field.nextSibling();
947  }
948 
949  // Split serializedData by contact
950  int count = serializedData[QLatin1String("contactId")].count();
951  for ( int i = 0; i < count ; i++ )
952  {
953  QMap<QString, QString> sd;
954 
955  QMap<QString, QStringList>::Iterator it;
956  QMap<QString, QStringList>::Iterator itEnd = serializedData.end();
957  for ( it = serializedData.begin(); it != itEnd; ++it )
958  {
959  QStringList sl = it.value();
960  if( sl.count() > i)
961  sd[it.key()] = sl.value( i );
962  }
963  newList.append( ProtocolIdDataPair( pluginId, sd ) );
964  }
965 
966  removeList.append( element );
967  }
968 
969  foreach( QDomElement e, removeList )
970  metaContactElement.removeChild( e );
971 
972  foreach( ProtocolIdDataPair pdp, newList )
973  {
974  QDomElement pluginElement = metaContactElement.ownerDocument().createElement( QLatin1String( "plugin-contact-data" ) );
975  pluginElement.setAttribute( QLatin1String( "plugin-id" ), pdp.first );
976 
977  QMap<QString, QString>::ConstIterator it;
978  for ( it = pdp.second.constBegin(); it != pdp.second.constEnd(); ++it )
979  {
980  QDomElement pluginDataField = metaContactElement.ownerDocument().createElement( QLatin1String( "plugin-data-field" ) );
981  pluginDataField.setAttribute( QLatin1String( "key" ), it.key() );
982  pluginDataField.appendChild( metaContactElement.ownerDocument().createTextNode( it.value() ) );
983  pluginElement.appendChild( pluginDataField );
984  }
985 
986  metaContactElement.appendChild( pluginElement );
987  }
988  }
989  rootElement.setAttribute( QString("version"), "1.2" );
990  return true;
991 }
992 
993 uint XmlContactStorage::readVersion( QDomElement &rootElement ) const
994 {
995  QString versionString = rootElement.attribute( QString::fromLatin1( "version" ), QString() );
996  if( QRegExp( QString::fromLatin1( "[0-9]+\\.[0-9]" ) ).exactMatch( versionString ) )
997  return versionString.remove( QLatin1Char( '.' ) ).toUInt();
998  else
999  return 0;
1000 }
1001 
1002 QString XmlContactStorage::sourceToString( Kopete::MetaContact::PropertySource source ) const
1003 {
1004  if ( source == Kopete::MetaContact::SourceCustom )
1005  return QString::fromUtf8("custom");
1006  else if ( source == Kopete::MetaContact::SourceKABC )
1007  return QString::fromUtf8("addressbook");
1008  else if ( source == Kopete::MetaContact::SourceContact )
1009  return QString::fromUtf8("contact");
1010  else // recovery
1011  return sourceToString( Kopete::MetaContact::SourceCustom );
1012 }
1013 
1014 Kopete::MetaContact::PropertySource XmlContactStorage::stringToSource( const QString &name ) const
1015 {
1016  if ( name == QString::fromUtf8("custom") )
1017  return Kopete::MetaContact::SourceCustom;
1018  else if ( name == QString::fromUtf8("addressbook") )
1019  return Kopete::MetaContact::SourceKABC;
1020  else if ( name == QString::fromUtf8("contact") )
1021  return Kopete::MetaContact::SourceContact;
1022  else // recovery
1023  return Kopete::MetaContact::SourceCustom;
1024 }
1025 
1026 void XmlContactStorage::checkGroupIds()
1027 {
1028  // HACK: Check if we don't have duplicate groupIds => broken contactlist.xml,
1029  // if so reset all groupIds so there are unique.
1030  // Will break manual group sorting but we want consistent contactlist.
1031 
1032  QSet<uint> groupIdSet;
1033 
1034  bool idsUnique = true;
1035  bool haveTemporary = false;
1036  bool haveTopLevel = false;
1037 
1038  foreach( Kopete::Group * group, groups() )
1039  {
1040  if ( groupIdSet.contains( group->groupId() ) )
1041  {
1042  idsUnique = false;
1043  break;
1044  }
1045  groupIdSet.insert( group->groupId() );
1046  if ( group->type() == Kopete::Group::Temporary )
1047  haveTemporary = true;
1048  else if ( group->type() == Kopete::Group::TopLevel )
1049  haveTopLevel = true;
1050  }
1051 
1052  if ( !haveTemporary )
1053  groupIdSet.insert(Kopete::Group::topLevel()->groupId());
1054 
1055  if ( !haveTopLevel )
1056  groupIdSet.insert(Kopete::Group::topLevel()->groupId());
1057 
1058  if ( !idsUnique )
1059  {
1060  uint uniqueGroupId = 0;
1061  Kopete::Group::topLevel()->setGroupId( ++uniqueGroupId );
1062  Kopete::Group::temporary()->setGroupId( ++uniqueGroupId );
1063 
1064  foreach( Kopete::Group * group, groups() )
1065  group->setGroupId( ++uniqueGroupId );
1066 
1067  Kopete::Group::topLevel()->setUniqueGroupId( uniqueGroupId );
1068  }
1069 }
1070 
1071 }
1072 
1073 //kate: indent-mode cstyle; indent-width 4; indent-spaces on; replace-tabs on;
QTextStream::setCodec
void setCodec(QTextCodec *codec)
Kopete::ContactListElement::pluginContactData
QMap< QString, ContactDataList > pluginContactData() const
Get the settings as stored previously by calls to setPluginContactData() Note that plugins shouldn't ...
Definition: kopetecontactlistelement.cpp:112
kopetemetacontact.h
Kopete::ContactList::self
static ContactList * self()
The contact list is a singleton object.
Definition: kopetecontactlist.cpp:71
QDomElement::elementsByTagName
QDomNodeList elementsByTagName(const QString &tagname) const
Kopete::ContactListStorage::findGroup
Kopete::Group * findGroup(const QString &displayName, int type=Kopete::Group::Normal)
Find a group with his displayName.
Definition: kopetecontactliststorage.cpp:77
Kopete::ContactListElement::setPluginData
void setPluginData(Plugin *plugin, const QMap< QString, QString > &value)
Set the plugin-specific data.
Definition: kopetecontactlistelement.cpp:66
Kopete::ContactListElement::appendPluginContactData
void appendPluginContactData(const QString &pluginId, const ContactData &data)
Convenience method to append plugin specific data for single contact Note that plugins shouldn't use ...
Definition: kopetecontactlistelement.cpp:144
Kopete::Group::setUniqueGroupId
void setUniqueGroupId(uint uniqueGroupId)
Definition: kopetegroup.cpp:160
Kopete::MetaContact::addToGroup
void addToGroup(Kopete::Group *to)
Add a contact to another group.
Definition: kopetemetacontact.cpp:1045
Kopete::Group::offline
static Group * offline()
Definition: kopetegroup.cpp:51
Kopete::ContactListElement::setUseCustomIcon
void setUseCustomIcon(bool useCustomIcon)
set if the user want to show custom icon he set with setIcon this does not clear icons string if you ...
Definition: kopetecontactlistelement.cpp:186
Kopete::MetaContact::setDisplayName
void setDisplayName(const QString &name)
Set the custom displayName.
Definition: kopetemetacontact.cpp:620
Kopete::MetaContact::kabcId
QString kabcId() const
Get the KABC id for this metacontact.
Definition: kopetemetacontact.cpp:1169
Kopete::Group::setExpanded
void setExpanded(bool expanded)
Set if the group is expanded.
Definition: kopetegroup.cpp:132
Kopete::ContactList::groups
QList< Group * > groups() const
Definition: kopetecontactlist.cpp:118
Kopete::ContactListStorage::group
Kopete::Group * group(unsigned int groupId) const
Get the Group with the given id for this storage.
Definition: kopetecontactliststorage.cpp:67
Kopete::ContactListElement::icons
const IconMap icons() const
return all registered icons
Definition: kopetecontactlistelement.cpp:157
Kopete::PSCID_ELEM
const QString PSCID_ELEM
Definition: xmlcontactstorage.cpp:56
QDomNode::appendChild
QDomNode appendChild(const QDomNode &newChild)
kopeteaccount.h
Kopete::ContactListStorage::groups
Group::List groups() const
Get the Group list for this storage.
Definition: kopetecontactliststorage.cpp:47
QDomElement::attribute
QString attribute(const QString &name, const QString &defValue) const
Kopete::Contact::contactId
QString contactId
Definition: kopetecontact.h:70
QChar
Kopete::XmlContactStorage::~XmlContactStorage
~XmlContactStorage()
Definition: xmlcontactstorage.cpp:91
QString::split
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
Kopete::Protocol
base class of every protocol.
Definition: kopeteprotocol.h:62
QDomNodeList
QMap::constBegin
const_iterator constBegin() const
QMap
Kopete::MetaContact::slotAllPluginsLoaded
void slotAllPluginsLoaded()
When all the plugins are loaded, set the Contact Source.
Definition: kopetemetacontact.cpp:1116
QUuid
kopetegroup.h
Kopete::Contact::account
Account * account() const
Get the account that this contact belongs to.
Definition: kopetecontact.cpp:538
Kopete::ContactList::metaContacts
QList< MetaContact * > metaContacts() const
return a list of all metacontact of the contact list Retrieve the list of all available meta contacts...
Definition: kopetecontactlist.cpp:112
QDomDocument::documentElement
QDomElement documentElement() const
QDomNode
Kopete::MetaContact::customPhoto
KUrl customPhoto() const
Returns the custom display photo.
Definition: kopetemetacontact.cpp:729
QSet::insert
const_iterator insert(const T &value)
QString::remove
QString & remove(int position, int n)
Kopete::ContactListElement::setIcon
void setIcon(const QString &icon, IconState=None)
Set the icon in the given state To clear an entry, set a QString()
Definition: kopetecontactlistelement.cpp:170
Kopete::Group::isExpanded
bool isExpanded() const
Definition: kopetegroup.cpp:137
Kopete::ContactListElement::setLoading
void setLoading(bool value)
Set if we are in loading stage.
Definition: kopetecontactlistelement.cpp:56
Kopete::MetaContact::PropertySource
PropertySource
Enumeration of possible sources for a property (which may be photos, see setPhotoSource() for instanc...
Definition: kopetemetacontact.h:75
Kopete::MetaContact::photoSourceContact
Contact * photoSourceContact() const
get the subcontact being tracked for its photo
Definition: kopetemetacontact.cpp:825
Kopete::PSPID_ELEM
const QString PSPID_ELEM
Definition: xmlcontactstorage.cpp:57
QFile
QFile::copy
bool copy(const QString &newName)
Kopete::XmlContactStorage::parseMetaContact
bool parseMetaContact(Kopete::MetaContact *metaContact, const QDomElement &element)
Definition: xmlcontactstorage.cpp:292
QTextStream
Kopete::XmlContactStorage::save
virtual void save()
Save the contact list.
Definition: xmlcontactstorage.cpp:225
QDomNode::nextSibling
QDomNode nextSibling() const
Kopete::MetaContact::SourceCustom
Data comes from somewhere else.
Definition: kopetemetacontact.h:78
QDomDocument::importNode
QDomNode importNode(const QDomNode &importedNode, bool deep)
QList::value
T value(int i) const
QDomNode::toElement
QDomElement toElement() const
Kopete::XmlContactStorage::readVersion
uint readVersion(QDomElement &rootElement) const
Definition: xmlcontactstorage.cpp:993
Kopete::MetaContact::customDisplayName
QString customDisplayName() const
Returns the custom display name.
Definition: kopetemetacontact.cpp:663
Kopete::MetaContact::setPhotoSyncedWithKABC
void setPhotoSyncedWithKABC(bool b)
Set if the photo should be synced with the adressbook when the photosource change his photo...
Definition: kopetemetacontact.cpp:1216
QRegExp
Kopete::ContactListElement::Offline
Definition: kopetecontactlistelement.h:158
Kopete::MetaContact::SourceContact
Data comes from the contact itself.
Definition: kopetemetacontact.h:76
Kopete::XmlContactStorage::parseGroup
bool parseGroup(Kopete::Group *group, const QDomElement &element)
Definition: xmlcontactstorage.cpp:498
Kopete::MetaContact::setDisplayNameSource
void setDisplayNameSource(PropertySource source)
Set the source of metacontact displayName.
Definition: kopetemetacontact.cpp:282
Kopete::photoFromKABC
QImage photoFromKABC(const QString &id)
Definition: kopetemetacontact.cpp:790
Kopete::XmlContactStorage::storeContactListElement
const QList< QDomElement > storeContactListElement(Kopete::ContactListElement *contactListElement) const
Definition: xmlcontactstorage.cpp:790
QDomNodeList::count
int count() const
QString::number
QString number(int n, int base)
Kopete::MetaContact::displayNameSource
PropertySource displayNameSource() const
get the source of metacontact display name
Definition: kopetemetacontact.cpp:302
QList::count
int count(const T &value) const
Kopete::XmlContactStorage::updateFrom10to11
bool updateFrom10to11(QDomElement &rootElement) const
Definition: xmlcontactstorage.cpp:891
Kopete::Contact::protocol
Protocol * protocol() const
Get the protocol that the contact belongs to.
Definition: kopetecontact.cpp:533
QList::append
void append(const T &value)
QString::fromUtf8
QString fromUtf8(const char *str, int size)
Kopete::XmlContactStorage::errorMessage
virtual QString errorMessage() const
Get a nice error message.
Definition: xmlcontactstorage.cpp:101
QDomNode::ownerDocument
QDomDocument ownerDocument() const
Kopete::ContactListElement::Open
Definition: kopetecontactlistelement.h:158
QDomElement::text
QString text() const
Kopete::ContactListElement
Definition: kopetecontactlistelement.h:46
QDomElement::hasAttribute
bool hasAttribute(const QString &name) const
Kopete::ContactListElement::Closed
Definition: kopetecontactlistelement.h:158
Kopete::Group::groupId
uint groupId
Definition: kopetegroup.h:47
Kopete::Account::accountId
QString accountId
Definition: kopeteaccount.h:77
QDomElement::setAttribute
void setAttribute(const QString &name, const QString &value)
Kopete::Group::setGroupId
void setGroupId(uint groupId)
Definition: kopetegroup.cpp:150
Kopete::Plugin::pluginId
QString pluginId() const
Get the plugin id.
Definition: kopeteplugin.cpp:46
Kopete::MetaContact::SourceKABC
Data comes from KABC (addressbook).
Definition: kopetemetacontact.h:77
Kopete::MetaContact::metaContactId
QUuid metaContactId
Definition: kopetemetacontact.h:66
kopeteprotocol.h
Kopete::XmlContactStorage::isBusy
virtual bool isBusy() const
Check if the current ContactListStorage is busy.
Definition: xmlcontactstorage.cpp:106
QList::isEmpty
bool isEmpty() const
Kopete::PSAID_ELEM
const QString PSAID_ELEM
Definition: xmlcontactstorage.cpp:58
QString::isEmpty
bool isEmpty() const
QMap::constEnd
const_iterator constEnd() const
Kopete::Group::uniqueGroupId
uint uniqueGroupId() const
Definition: kopetegroup.cpp:155
Kopete::XmlContactStorage::XmlContactStorage
XmlContactStorage()
Definition: xmlcontactstorage.cpp:80
kopetecontactlist.h
QString::endsWith
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
QSet
Kopete::Group::Offline
Definition: kopetegroup.h:56
QString
QList
QMap::end
iterator end()
Kopete::XmlContactStorage::parseContactListElement
bool parseContactListElement(Kopete::ContactListElement *contactListElement, const QDomElement &element)
Definition: xmlcontactstorage.cpp:589
QFile::open
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
QMap::begin
iterator begin()
QDomNode::hasChildNodes
bool hasChildNodes() const
QStringList
QPair
Kopete::MetaContact::isTemporary
bool isTemporary
Definition: kopetemetacontact.h:63
QDomDocument::createTextNode
QDomText createTextNode(const QString &value)
Kopete::NSAID_ELEM
const QString NSAID_ELEM
Definition: xmlcontactstorage.cpp:55
Kopete::Plugin
Base class for all plugins or protocols.
Definition: kopeteplugin.h:84
Kopete::Group::Normal
Definition: kopetegroup.h:56
QDomNode::removeChild
QDomNode removeChild(const QDomNode &oldChild)
QString::contains
bool contains(QChar ch, Qt::CaseSensitivity cs) const
QLatin1Char
Kopete::XmlContactStorage::storeGroup
const QDomElement storeGroup(Kopete::Group *group) const
Definition: xmlcontactstorage.cpp:749
QDomDocument
Kopete::XmlContactStorage::updateFrom11to12
bool updateFrom11to12(QDomElement &rootElement) const
Definition: xmlcontactstorage.cpp:914
QFile::close
virtual void close()
QSet::contains
bool contains(const T &value) const
QDomNode::isNull
bool isNull() const
Kopete::MetaContact::photoSource
PropertySource photoSource() const
get the source of metacontact photo
Definition: kopetemetacontact.cpp:324
Kopete::PluginManager::self
static PluginManager * self()
Retrieve the plugin loader instance.
Definition: kopetepluginmanager.cpp:104
QMap::key
const Key key(const T &value) const
Kopete::Group::topLevel
static Group * topLevel()
Definition: kopetegroup.cpp:35
QDomNode::save
void save(QTextStream &str, int indent) const
xmlcontactstorage.h
QDomNode::firstChild
QDomNode firstChild() const
Kopete::MetaContact::setMetaContactId
void setMetaContactId(const QUuid &newMetaContactId)
Definition: kopetemetacontact.cpp:86
Kopete::MetaContact::setPhotoSource
void setPhotoSource(PropertySource source)
Set the source of metacontact photo.
Definition: kopetemetacontact.cpp:307
QLatin1String
Kopete::MetaContact::serialize
void serialize()
Serialize this metaContact This causes each Kopete::Protocol subclass to serialise its contacts' data...
Definition: kopetemetacontact.cpp:595
Kopete::XmlContactStorage::storeMetaContact
const QDomElement storeMetaContact(Kopete::MetaContact *metaContact, bool minimal=false) const
Definition: xmlcontactstorage.cpp:666
Kopete::Group::TopLevel
Definition: kopetegroup.h:56
QTextCodec::codecForName
QTextCodec * codecForName(const QByteArray &name)
Kopete::ContactListElement::Unknown
Definition: kopetecontactlistelement.h:158
Kopete::NSCID_ELEM
const QString NSCID_ELEM
Definition: xmlcontactstorage.cpp:53
Kopete::MetaContact::groups
QList< Group * > groups() const
The groups the contact is stored in.
Definition: kopetemetacontact.cpp:1069
Kopete::Group
Class which represents the Group.
Definition: kopetegroup.h:44
Kopete::ContactListElement::pluginData
QMap< QString, QString > pluginData(Plugin *plugin) const
Get the settings as stored previously by calls to setPluginData()
Definition: kopetecontactlistelement.cpp:91
Kopete::Group::setDisplayName
void setDisplayName(const QString &newName)
Rename the group.
Definition: kopetegroup.cpp:110
Kopete::XmlContactStorage::isValid
virtual bool isValid() const
Check if the current ContactListStorage.
Definition: xmlcontactstorage.cpp:96
Kopete::ContactListElement::Away
Definition: kopetecontactlistelement.h:158
Kopete::ContactListElement::Online
Definition: kopetecontactlistelement.h:158
Kopete::nameFromKABC
QString nameFromKABC(const QString &id)
Definition: kopetemetacontact.cpp:700
Kopete::MetaContact
Definition: kopetemetacontact.h:54
QString::fromLatin1
QString fromLatin1(const char *str, int size)
Kopete::Group::Temporary
Definition: kopetegroup.h:56
QMap::insert
iterator insert(const Key &key, const T &value)
Kopete::MetaContact::setAddressBookField
void setAddressBookField(Plugin *p, const QString &app, const QString &key, const QString &value)
set an address book field
Definition: kopetemetacontact.cpp:1084
QMap::isEmpty
bool isEmpty() const
QDomElement::tagName
QString tagName() const
Kopete::XmlContactStorage::load
virtual void load()
Load the contact list.
Definition: xmlcontactstorage.cpp:111
Kopete::MetaContact::setKabcId
void setKabcId(const QString &newKabcId)
Set the KABC id for this metacontact Use with care! You could create a one to many relationship...
Definition: kopetemetacontact.cpp:1183
QDomDocument::createElement
QDomElement createElement(const QString &tagName)
Kopete::Group::type
GroupType type() const
Definition: kopetegroup.cpp:127
QMap::ConstIterator
typedef ConstIterator
Kopete::ContactListStorage::addGroup
void addGroup(Kopete::Group *group)
Add a Group to internal list.
Definition: kopetecontactliststorage.cpp:62
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Kopete::ContactListElement::IconState
IconState
The various icon states.
Definition: kopetecontactlistelement.h:158
Kopete::ContactListStorage
Provide a storage for Kopete Contact List.
Definition: kopetecontactliststorage.h:34
QDomElement
QUuid::toString
QString toString() const
QMap::count
int count(const Key &key) const
Kopete::ContactListElement::useCustomIcon
bool useCustomIcon() const
return if yes or no the user wants to display some custom icon.
Definition: kopetecontactlistelement.cpp:181
kopetepluginmanager.h
Kopete::ContactListStorage::addMetaContact
void addMetaContact(Kopete::MetaContact *metaContact)
Add a MetaContact to internal list.
Definition: kopetecontactliststorage.cpp:57
kopetecontact.h
Kopete::MetaContact::setPhoto
void setPhoto(const KUrl &url)
Set the custom photo.
Definition: kopetemetacontact.cpp:734
QUuid::createUuid
QUuid createUuid()
Kopete::Group::temporary
static Group * temporary()
Definition: kopetegroup.cpp:43
Kopete::Group::displayName
QString displayName
Definition: kopetegroup.h:46
Kopete::NSPID_ELEM
const QString NSPID_ELEM
Definition: xmlcontactstorage.cpp:54
name
const char * name
Definition: kopeteonlinestatus.cpp:104
Kopete::MetaContact::isPhotoSyncedWithKABC
bool isPhotoSyncedWithKABC() const
Definition: kopetemetacontact.cpp:1211
QDomNodeList::at
QDomNode at(int index) const
QDomDocument::setContent
bool setContent(const QByteArray &data, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn)
QMap::value
const T value(const Key &key) const
QString::toUInt
uint toUInt(bool *ok, int base) const
Kopete::MetaContact::displayNameSourceContact
Contact * displayNameSourceContact() const
get the subcontact being tracked for its displayname (null if not set)
Definition: kopetemetacontact.cpp:820
Kopete::ContactListElement::None
Definition: kopetecontactlistelement.h:158
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:29:20 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kopete/libkopete

Skip menu "kopete/libkopete"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

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