• 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
kopeteaccount.cpp
Go to the documentation of this file.
1 /*
2  kopeteaccount.cpp - Kopete Account
3 
4  Copyright (c) 2003-2005 by Olivier Goffart <ogoffart@kde.org>
5  Copyright (c) 2003-2004 by Martijn Klingens <klingens@kde.org>
6  Copyright (c) 2004 by Richard Smith <kde@metafoo.co.uk>
7  Copyright (c) 2007 Will Stephenson <wstephenson@kde.org>
8 
9  Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
10 
11  *************************************************************************
12  * *
13  * This library is free software; you can redistribute it and/or *
14  * modify it under the terms of the GNU Lesser General Public *
15  * License as published by the Free Software Foundation; either *
16  * version 2 of the License, or (at your option) any later version. *
17  * *
18  *************************************************************************
19 */
20 
21 #include "kopeteaccount.h"
22 
23 #include <qapplication.h>
24 #include <QTimer>
25 #include <QPixmap>
26 #include <QIcon>
27 #include <QPointer>
28 
29 #include <kconfig.h>
30 #include <kdebug.h>
31 #include <kdialog.h>
32 #include <kdeversion.h>
33 #include <klocale.h>
34 #include <kiconeffect.h>
35 #include <kicon.h>
36 #include <kaction.h>
37 #include <kmenu.h>
38 #include <kmessagebox.h>
39 #include <kcomponentdata.h>
40 #include <kactionmenu.h>
41 #include <kconfiggroup.h>
42 
43 #include "kopeteidentity.h"
44 #include "kopeteidentitymanager.h"
45 #include "kabcpersistence.h"
46 #include "kopetecontactlist.h"
47 #include "kopeteaccountmanager.h"
48 #include "kopetecontact.h"
49 #include "kopetemetacontact.h"
50 #include "kopeteprotocol.h"
51 #include "kopetepluginmanager.h"
52 #include "kopetegroup.h"
53 #include "kopetebehaviorsettings.h"
54 #include "kopeteutils.h"
55 #include "kopeteuiglobal.h"
56 #include "kopeteblacklister.h"
57 #include "kopeteonlinestatusmanager.h"
58 #include "editaccountwidget.h"
59 
60 namespace Kopete
61 {
62 
63 
64 class Account::Private
65 {
66 public:
67  Private( Protocol *protocol, const QString &accountId )
68  : protocol( protocol ), id( accountId )
69  , excludeconnect( true ), priority( 0 )
70  , connectionTry(0), identity( 0 ), myself( 0 )
71  , suppressStatusTimer( 0 ), suppressStatusNotification( false )
72  , blackList( new Kopete::BlackLister( protocol->pluginId(), accountId ) )
73  { }
74 
75 
76  ~Private() { delete blackList; }
77 
78  QPointer <Protocol> protocol;
79  QString id;
80  QString accountLabel;
81  bool excludeconnect;
82  uint priority;
83  QHash<QString, Contact*> contacts;
84  QColor color;
85  uint connectionTry;
86  QPointer <Identity> identity;
87  QPointer <Contact> myself;
88  QTimer suppressStatusTimer;
89  QTimer reconnectTimer;
90  bool reconnectOnNetworkIsOnline;
91  bool suppressStatusNotification;
92  Kopete::BlackLister *blackList;
93  KConfigGroup *configGroup;
94  QString customIcon;
95  Kopete::OnlineStatus restoreStatus;
96  Kopete::StatusMessage restoreMessage;
97  QDateTime lastLoginTime;
98  bool suspended;
99  Kopete::OnlineStatus suspendStatus;
100 };
101 
102 Account::Account( Protocol *parent, const QString &accountId )
103  : QObject( parent ), d( new Private( parent, accountId ) )
104 {
105  d->configGroup=new KConfigGroup(KGlobal::config(), QString::fromLatin1( "Account_%1_%2" ).arg( d->protocol->pluginId(), d->id ));
106 
107  d->excludeconnect = d->configGroup->readEntry( "ExcludeConnect", false );
108  d->color = d->configGroup->readEntry( "Color" , QColor() );
109  d->customIcon = d->configGroup->readEntry( "Icon", QString() );
110  d->priority = d->configGroup->readEntry( "Priority", 0 );
111 
112  d->restoreStatus = Kopete::OnlineStatus::Online;
113  d->restoreMessage = Kopete::StatusMessage();
114  d->reconnectOnNetworkIsOnline = false;
115 
116  d->reconnectTimer.setSingleShot( true );
117  QObject::connect( &d->reconnectTimer, SIGNAL(timeout()),
118  this, SLOT(reconnect()) );
119 
120  QObject::connect(Solid::Networking::notifier(), SIGNAL(statusChanged(Solid::Networking::Status)), this, SLOT(networkingStatusChanged(Solid::Networking::Status)));
121 
122  QObject::connect( &d->suppressStatusTimer, SIGNAL(timeout()),
123  this, SLOT(slotStopSuppression()) );
124 
125  d->suspended = false;
126  d->suspendStatus = Kopete::OnlineStatus::Offline;
127 }
128 
129 Account::~Account()
130 {
131  // Delete all registered child contacts first
132  foreach (Contact* c, d->contacts) QObject::disconnect(c, SIGNAL(contactDestroyed(Kopete::Contact*)), this, 0);
133  qDeleteAll(d->contacts);
134  d->contacts.clear();
135 
136  kDebug( 14010 ) << " account '" << d->id << "' about to emit accountDestroyed ";
137  emit accountDestroyed(this);
138 
139  delete d->myself;
140  delete d->configGroup;
141  delete d;
142 }
143 
144 void Account::reconnect()
145 {
146  if ( isConnected() )
147  return; // Already connected
148 
149  kDebug( 14010 ) << "account " << d->id << " restoreStatus " << d->restoreStatus.status()
150  << " restoreTitle " << d->restoreMessage.title()
151  << " restoreMessage " << d->restoreMessage.message();
152  setOnlineStatus( d->restoreStatus, d->restoreMessage );
153 }
154 
155 void Account::networkingStatusChanged( const Solid::Networking::Status status )
156 {
157  switch(status) {
158  case Solid::Networking::Connected:
159  if (d->reconnectOnNetworkIsOnline && ! excludeConnect()) {
160  reconnect();
161  }
162  break;
163 
164  case Solid::Networking::Unconnected:
165  case Solid::Networking::Disconnecting:
166  setOnlineStatus( OnlineStatus::Offline );
167  if (Kopete::BehaviorSettings::self()->reconnectOnDisconnect()) {
168  d->reconnectOnNetworkIsOnline = true;
169  }
170  break;
171 
172  case Solid::Networking::Unknown:
173  case Solid::Networking::Connecting:
174  break;
175  }
176 }
177 
178 void Account::disconnected( DisconnectReason reason )
179 {
180  kDebug( 14010 ) << reason;
181  //reconnect if needed
182  if ( reason == BadPassword )
183  {
184  d->reconnectTimer.start( 0 );
185  }
186  else if ( Kopete::BehaviorSettings::self()->reconnectOnDisconnect() == true && reason > Manual )
187  {
188  bool networkAvailable = ( Solid::Networking::status() == Solid::Networking::Unknown || Solid::Networking::status() == Solid::Networking::Connected );
189  if ( reason == ConnectionReset && ! networkAvailable ) {
190  d->reconnectOnNetworkIsOnline = true;
191  d->reconnectTimer.stop();
192  } else {
193  if ( d->reconnectTimer.isActive() )
194  return; // In case protocol calls disconnected more than one time on disconnect.
195 
196  d->connectionTry++;
197  //use a timer to allow the plugins to clean up after return
198  if ( d->connectionTry < 3 )
199  d->reconnectTimer.start( 10000 ); // wait 10 seconds before reconnect
200  else if ( d->connectionTry <= 10 )
201  d->reconnectTimer.start( ((2 * (d->connectionTry - 2)) - 1) * 60000 ); // wait 1,3,5...15 minutes => stops after 64 min
202  }
203  }
204  else
205  {
206  d->reconnectOnNetworkIsOnline = false;
207  d->reconnectTimer.stop();
208  }
209 
210  if ( reason == OtherClient )
211  {
212  Kopete::Utils::notifyConnectionLost(this, i18n("You have been disconnected"), i18n( "You have connected from another client or computer to the account '%1'" , d->id), i18n("Most proprietary Instant Messaging services do not allow you to connect from more than one location. Check that nobody is using your account without your permission. If you need a service that supports connection from various locations at the same time, use the Jabber protocol."));
213  }
214 }
215 
216 Protocol *Account::protocol() const
217 {
218  return d->protocol;
219 }
220 
221 QString Account::accountId() const
222 {
223  return d->id;
224 }
225 
226 const QColor Account::color() const
227 {
228  return d->color;
229 }
230 
231 void Account::setColor( const QColor &color )
232 {
233  d->color = color;
234  if ( d->color.isValid() )
235  d->configGroup->writeEntry( "Color", d->color );
236  else
237  d->configGroup->deleteEntry( "Color" );
238  emit colorChanged( color );
239 }
240 
241 void Account::setPriority( uint priority )
242 {
243  d->priority = priority;
244  d->configGroup->writeEntry( "Priority", d->priority );
245 }
246 
247 uint Account::priority() const
248 {
249  return d->priority;
250 }
251 
252 
253 QPixmap Account::accountIcon(const int size) const
254 {
255  QString icon= d->customIcon.isEmpty() ? d->protocol->pluginIcon() : d->customIcon;
256 
257  // FIXME: this code is duplicated with OnlineStatus, can we merge it somehow?
258  QPixmap base = KIconLoader::global()->loadIcon(
259  icon, KIconLoader::Small, size );
260 
261  if ( d->color.isValid() )
262  {
263  KIconEffect effect;
264  base = effect.apply( base, KIconEffect::Colorize, 1, d->color, 0);
265  }
266 
267  if ( size > 0 && base.width() != size )
268  {
269  base.scaled( size, size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
270  }
271 
272  return base;
273 }
274 
275 QString Account::accountIconPath(const KIconLoader::Group size) const
276 {
277  return KIconLoader::global()->iconPath(d->customIcon.isEmpty() ?
278  d->protocol->pluginIcon() :
279  d->customIcon, size);
280 }
281 
282 KConfigGroup* Kopete::Account::configGroup() const
283 {
284  return d->configGroup;
285 }
286 
287 void Account::setAccountLabel( const QString &label )
288 {
289  d->accountLabel = label;
290 }
291 
292 QString Account::accountLabel() const
293 {
294  if( d->accountLabel.isNull() )
295  return d->id;
296  return d->accountLabel;
297 }
298 
299 void Account::setExcludeConnect( bool b )
300 {
301  d->excludeconnect = b;
302  d->configGroup->writeEntry( "ExcludeConnect", d->excludeconnect );
303 }
304 
305 bool Account::excludeConnect() const
306 {
307  return d->excludeconnect;
308 }
309 
310 bool Account::registerContact( Contact *c )
311 {
312  Q_ASSERT ( c->metaContact() != Kopete::ContactList::self()->myself() );
313 
314  if ( d->contacts.value( c->contactId() ) )
315  {
316  kWarning(14010) << "Contact already exists!!! accountId: " << c->account() << " contactId: " << c->contactId();
317  return false;
318  }
319 
320  d->contacts.insert( c->contactId(), c );
321  QObject::connect( c, SIGNAL(contactDestroyed(Kopete::Contact*)),
322  SLOT(contactDestroyed(Kopete::Contact*)) );
323 
324  return true;
325 }
326 
327 void Account::contactDestroyed( Contact *c )
328 {
329  d->contacts.remove( c->contactId() );
330 }
331 
332 
333 const QHash<QString, Contact*>& Account::contacts()
334 {
335  return d->contacts;
336 }
337 
338 
339 Kopete::MetaContact* Account::addContact( const QString &contactId, const QString &displayName , Group *group, AddMode mode )
340 {
341 
342  if ( !protocol()->canAddMyself() && contactId == d->myself->contactId() )
343  {
344  if ( isConnected() && d->lastLoginTime.secsTo(QDateTime::currentDateTime()) > 30 )
345  {
346  KMessageBox::queuedMessageBox( Kopete::UI::Global::mainWidget(), KMessageBox::Error,
347  i18n("You are not allowed to add yourself to the contact list. The addition of \"%1\" to account \"%2\" will not take place.", contactId, accountId()), i18n("Error Creating Contact")
348  );
349  }
350  else
351  {
352  kWarning(14010) << "You are not allowed to add yourself to the contact list. The addition of" << contactId
353  << "to account" << accountId() << "will not take place.";
354  }
355  return 0;
356  }
357 
358  bool isTemporary = (mode == Temporary);
359 
360  Contact *c = d->contacts.value( contactId );
361 
362  if(!group)
363  group=Group::topLevel();
364 
365  if ( c && c->metaContact() )
366  {
367  if ( c->metaContact()->isTemporary() && !isTemporary )
368  {
369  kDebug( 14010 ) << " You are trying to add an existing temporary contact. Just add it on the list";
370 
371  c->metaContact()->setTemporary(false, group );
372  ContactList::self()->addMetaContact(c->metaContact());
373  }
374  else
375  {
376  // should we here add the contact to the parentContact if any?
377  kDebug( 14010 ) << "Contact already exists";
378  }
379  return c->metaContact();
380  }
381 
382  MetaContact *parentContact = new MetaContact();
383  if(!displayName.isEmpty())
384  parentContact->setDisplayName( displayName );
385 
386  //Set it as a temporary contact if requested
387  if ( isTemporary )
388  parentContact->setTemporary( true );
389  else
390  parentContact->addToGroup( group );
391 
392  if ( c )
393  {
394  c->setMetaContact( parentContact );
395  if ( mode == ChangeKABC )
396  {
397  kDebug( 14010 ) << " changing KABC";
398  KABCPersistence::self()->write( parentContact );
399  }
400  }
401  else
402  {
403  if ( !createContact( contactId, parentContact ) )
404  {
405  delete parentContact;
406  return 0L;
407  }
408  }
409 
410  ContactList::self()->addMetaContact( parentContact );
411  return parentContact;
412 }
413 
414 bool Account::addContact(const QString &contactId , MetaContact *parent, AddMode mode )
415 {
416  if ( !protocol()->canAddMyself() && contactId == myself()->contactId() )
417  {
418  if ( isConnected() && d->lastLoginTime.secsTo(QDateTime::currentDateTime()) > 30 )
419  {
420  KMessageBox::queuedMessageBox( Kopete::UI::Global::mainWidget(), KMessageBox::Error,
421  i18n("You are not allowed to add yourself to the contact list. The addition of \"%1\" to account \"%2\" will not take place.", contactId, accountId()), i18n("Error Creating Contact")
422  );
423  }
424  else
425  {
426  kWarning(14010) << "You are not allowed to add yourself to the contact list. The addition of" << contactId
427  << "to account" << accountId() << "will not take place.";
428  }
429 
430  return 0L;
431  }
432 
433  const bool isTemporary= parent->isTemporary();
434  Contact *c = d->contacts.value( contactId );
435  if ( c && c->metaContact() )
436  {
437  if ( c->metaContact()->isTemporary() && !isTemporary )
438  {
439  kDebug( 14010 ) <<
440  "Account::addContact: You are trying to add an existing temporary contact. Just add it on the list" << endl;
441 
442  //setMetaContact ill take care about the deletion of the old contact
443  c->setMetaContact(parent);
444  return true;
445  }
446  else
447  {
448  // should we here add the contact to the parentContact if any?
449  kDebug( 14010 ) << "Account::addContact: Contact already exists";
450  }
451  return false; //(the contact is not in the correct metacontact, so false)
452  }
453 
454  const bool success = createContact(contactId, parent);
455 
456  if ( success && mode == ChangeKABC )
457  {
458  kDebug( 14010 ) << " changing KABC";
459  KABCPersistence::self()->write( parent );
460  }
461 
462  return success;
463 }
464 
465 void Account::fillActionMenu( KActionMenu *actionMenu )
466 {
467  //default implementation
468 // KActionMenu *menu = new KActionMenu( QIcon(myself()->onlineStatus().iconFor( this )), accountId(), 0, 0);
469 #ifdef __GNUC__
470 #warning No icon shown, we should go away from QPixmap genered icons with overlays.
471 #endif
472  QString nick;
473  if (identity()->hasProperty( Kopete::Global::Properties::self()->nickName().key() ))
474  nick = identity()->property( Kopete::Global::Properties::self()->nickName() ).value().toString();
475  else
476  nick = myself()->displayName();
477 
478  // Always add title at the beginning of actionMenu
479  QAction *before = actionMenu->menu()->actions().value( 0, 0 );
480  actionMenu->menu()->addTitle( myself()->onlineStatus().iconFor( myself() ),
481  nick.isNull() ? accountLabel() : i18n( "%2 <%1>", accountLabel(), nick ),
482  before
483  );
484 
485  actionMenu->menu()->addSeparator();
486 
487  KAction *propertiesAction = new KAction( i18n("Properties"), actionMenu );
488  QObject::connect( propertiesAction, SIGNAL(triggered(bool)), this, SLOT(editAccount()) );
489  actionMenu->addAction( propertiesAction );
490 }
491 
492 bool Account::hasCustomStatusMenu() const
493 {
494  return false;
495 }
496 
497 bool Account::isConnected() const
498 {
499  return myself() && myself()->isOnline();
500 }
501 
502 bool Account::isAway() const
503 {
504  //We might want to change the method name here.
505  return d->myself && ( d->myself->onlineStatus().status() == Kopete::OnlineStatus::Away ||
506  d->myself->onlineStatus().status() == Kopete::OnlineStatus::Busy );
507 }
508 
509 bool Account::isBusy() const
510 {
511  return d->myself && ( d->myself->onlineStatus().status() == Kopete::OnlineStatus::Busy );
512 }
513 
514 Identity * Account::identity() const
515 {
516  return d->identity;
517 }
518 
519 bool Account::setIdentity( Identity *ident )
520 {
521  if ( d->identity == ident )
522  {
523  return false;
524  }
525 
526  if (d->identity)
527  {
528  d->identity->removeAccount( this );
529  }
530 
531  ident->addAccount( this );
532  d->identity = ident;
533  d->configGroup->writeEntry("Identity", ident->id());
534  return true;
535 }
536 
537 Contact * Account::myself() const
538 {
539  return d->myself;
540 }
541 
542 void Account::setMyself( Contact *myself )
543 {
544  Q_ASSERT( !d->myself );
545 
546  d->myself = myself;
547 
548  QObject::connect( d->myself, SIGNAL(onlineStatusChanged(Kopete::Contact*,Kopete::OnlineStatus,Kopete::OnlineStatus)),
549  this, SLOT(slotOnlineStatusChanged(Kopete::Contact*,Kopete::OnlineStatus,Kopete::OnlineStatus)) );
550  QObject::connect( d->myself, SIGNAL(propertyChanged(Kopete::PropertyContainer*,QString,QVariant,QVariant)),
551  this, SLOT(slotContactPropertyChanged(Kopete::PropertyContainer*,QString,QVariant,QVariant)) );
552 
553  if ( isConnected() )
554  emit isConnectedChanged();
555 }
556 
557 void Account::slotOnlineStatusChanged( Contact * /* contact */,
558  const OnlineStatus &newStatus, const OnlineStatus &oldStatus )
559 {
560  const bool wasOffline = !oldStatus.isDefinitelyOnline();
561  const bool isOffline = !newStatus.isDefinitelyOnline();
562  d->suspended = false;
563 
564  if ( wasOffline && !isOffline )
565  d->lastLoginTime = QDateTime::currentDateTime();
566 
567  // If we went offline we have to ensure that all of our contacts
568  // are online too. Otherwise the "Last Seen" tooltip won't work
569  // properly. See bug 266580.
570  if ( !wasOffline && isOffline )
571  setAllContactsStatus( Kopete::OnlineStatus::Offline );
572 
573  if ( wasOffline || newStatus.status() == OnlineStatus::Offline )
574  {
575  // Wait for twenty seconds until we treat status notifications for contacts
576  // as unrelated to our own status change.
577  // Twenty seconds may seem like a long time, but just after your own
578  // connection it's basically neglectible, and depending on your own
579  // contact list's size, the protocol you are using, your internet
580  // connection's speed and your computer's speed you *will* need it.
581  d->suppressStatusNotification = true;
582  d->suppressStatusTimer.setSingleShot( true );
583  d->suppressStatusTimer.start( 20000 );
584  //the timer is also used to reset the d->connectionTry
585  }
586 
587  if ( !isOffline )
588  {
589  d->restoreStatus = newStatus;
590  d->restoreMessage.setTitle( myself()->property( Kopete::Global::Properties::self()->statusTitle() ).value().toString() );
591  d->restoreMessage.setMessage( myself()->property( Kopete::Global::Properties::self()->statusMessage() ).value().toString() );
592  }
593 
594 /* kDebug(14010) << "account " << d->id << " changed status. was "
595  << Kopete::OnlineStatus::statusTypeToString(oldStatus.status()) << ", is "
596  << Kopete::OnlineStatus::statusTypeToString(newStatus.status()) << endl;*/
597  if ( wasOffline != isOffline )
598  emit isConnectedChanged();
599 }
600 
601 bool Account::suspend( const Kopete::StatusMessage &reason )
602 {
603  if ( d->suspended )
604  return false;
605 
606  d->suspendStatus = myself()->onlineStatus();
607  if( myself()->onlineStatus().status() == OnlineStatus::Connecting )
608  d->suspendStatus = d->restoreStatus;
609  setOnlineStatus( OnlineStatus::Offline, reason );
610  d->suspended = true;
611  return true;
612 }
613 
614 bool Account::resume()
615 {
616  if ( !d->suspended )
617  return false;
618 
619  if ( d->suspendStatus != Kopete::OnlineStatus::Offline )
620  setOnlineStatus( d->suspendStatus, d->restoreMessage, Kopete::Account::None );
621 
622  return true;
623 }
624 
625 void Account::setAllContactsStatus( const Kopete::OnlineStatus &status )
626 {
627  d->suppressStatusNotification = true;
628  d->suppressStatusTimer.setSingleShot( true );
629  d->suppressStatusTimer.start( 20000 );
630 
631  QHashIterator<QString, Contact*> it(d->contacts);
632  for ( ; it.hasNext(); ) {
633  it.next();
634 
635  Contact *c = it.value();
636  if ( c )
637  c->setOnlineStatus( status );
638  }
639 }
640 
641 void Account::slotContactPropertyChanged( PropertyContainer * /* contact */,
642  const QString &key, const QVariant &old, const QVariant &newVal )
643 {
644  if ( key == Kopete::Global::Properties::self()->statusTitle().key() && old != newVal && isConnected() )
645  d->restoreMessage.setTitle( newVal.toString() );
646  else if ( key == Kopete::Global::Properties::self()->statusMessage().key() && old != newVal && isConnected() )
647  d->restoreMessage.setMessage( newVal.toString() );
648 }
649 
650 void Account::slotStopSuppression()
651 {
652  d->suppressStatusNotification = false;
653  if(isConnected())
654  d->connectionTry=0;
655 }
656 
657 bool Account::suppressStatusNotification() const
658 {
659  return d->suppressStatusNotification;
660 }
661 
662 bool Account::removeAccount()
663 {
664  //default implementation
665  return true;
666 }
667 
668 
669 BlackLister* Account::blackLister()
670 {
671  return d->blackList;
672 }
673 
674 void Account::block( const QString &contactId )
675 {
676  d->blackList->addContact( contactId );
677 }
678 
679 void Account::unblock( const QString &contactId )
680 {
681  d->blackList->removeContact( contactId );
682 }
683 
684 bool Account::isBlocked( const QString &contactId )
685 {
686  return d->blackList->isBlocked( contactId );
687 }
688 
689 void Account::editAccount(QWidget *parent)
690 {
691  QPointer <KDialog> editDialog = new KDialog( parent );
692  editDialog->setCaption( i18n( "Edit Account" ) );
693  editDialog->setButtons( KDialog::Ok | KDialog::Apply | KDialog::Cancel );
694 
695  KopeteEditAccountWidget *m_accountWidget = protocol()->createEditAccountWidget( this, editDialog );
696  if ( !m_accountWidget )
697  {
698  delete editDialog;
699  return;
700  }
701  // FIXME: Why the #### is EditAccountWidget not a QWidget?!? This sideways casting
702  // is braindead and error-prone. Looking at MSN the only reason I can see is
703  // because it allows direct subclassing of designer widgets. But what is
704  // wrong with embedding the designer widget in an empty QWidget instead?
705  // Also, if this REALLY has to be a pure class and not a widget, then the
706  // class should at least be renamed to EditAccountIface instead - Martijn
707  QWidget *w = dynamic_cast<QWidget *>( m_accountWidget );
708  if ( !w )
709  {
710  delete editDialog;
711  return;
712  }
713  editDialog->setMainWidget( w );
714  if ( editDialog->exec() == QDialog::Accepted )
715  {
716  if( editDialog && m_accountWidget->validateData() )
717  m_accountWidget->apply();
718  }
719 
720  delete editDialog;
721 }
722 
723 void Account::setCustomIcon( const QString & i)
724 {
725  d->customIcon = i;
726  if(!i.isEmpty())
727  d->configGroup->writeEntry( "Icon", i );
728  else
729  d->configGroup->deleteEntry( "Icon" );
730  emit colorChanged( color() );
731 }
732 
733 QString Account::customIcon() const
734 {
735  return d->customIcon;
736 }
737 
738 } // END namespace Kopete
739 
740 #include "kopeteaccount.moc"
741 
Kopete::Account::setAccountLabel
void setAccountLabel(const QString &label)
Sets the account label.
Definition: kopeteaccount.cpp:287
Kopete::Account::fillActionMenu
virtual void fillActionMenu(KActionMenu *actionMenu)
Fill the menu with actions for this account.
Definition: kopeteaccount.cpp:465
Kopete::Account::accountLabel
QString accountLabel() const
The label for this account.
Definition: kopeteaccount.cpp:292
Kopete::ContactList::myself
MetaContact * myself()
return the metacontact that represent the user itself.
Definition: kopetecontactlist.cpp:349
kopetemetacontact.h
Kopete::ContactList::self
static ContactList * self()
The contact list is a singleton object.
Definition: kopetecontactlist.cpp:71
Kopete::Account::setIdentity
virtual bool setIdentity(Kopete::Identity *ident)
Sets the identity this account belongs to.
Definition: kopeteaccount.cpp:519
Kopete::OnlineStatus
Definition: kopeteonlinestatus.h:68
Kopete::Account::protocol
Protocol * protocol() const
Definition: kopeteaccount.cpp:216
status
OnlineStatus::StatusType status
Definition: kopeteonlinestatus.cpp:103
QWidget
Kopete::Account::myself
Contact * myself() const
Retrieve the 'myself' contact.
Definition: kopeteaccount.cpp:537
Kopete::MetaContact::addToGroup
void addToGroup(Kopete::Group *to)
Add a contact to another group.
Definition: kopetemetacontact.cpp:1045
Kopete::Account::setAllContactsStatus
void setAllContactsStatus(const Kopete::OnlineStatus &status)
Sets the online status of all contacts in this account to the same value.
Definition: kopeteaccount.cpp:625
Kopete::Account::priority
uint priority() const
Get the priority of this account.
Kopete::Account::accountId
QString accountId() const
kopeteutils.h
Kopete::MetaContact::setTemporary
void setTemporary(bool b=true, Kopete::Group *group=0L)
Set if this is a temporary contact.
Definition: kopetemetacontact.cpp:1150
QPixmap::width
int width() const
Kopete::MetaContact::setDisplayName
void setDisplayName(const QString &name)
Set the custom displayName.
Definition: kopetemetacontact.cpp:620
Kopete::Global::Properties::self
static Properties * self()
Singleton accessor for this class.
Definition: kopeteglobal.cpp:49
kopeteaccount.h
Kopete::Account::BadPassword
connection failed because password was incorrect
Definition: kopeteaccount.h:97
Kopete::Account::Account
Account(Protocol *parent, const QString &accountID)
Constructor for the Account object.
Definition: kopeteaccount.cpp:102
Kopete::Contact::contactId
QString contactId
Definition: kopetecontact.h:70
Kopete::Contact::setMetaContact
void setMetaContact(MetaContact *m)
Move this contact to a new MetaContact.
Definition: kopetecontact.cpp:420
kopeteidentitymanager.h
Kopete::StatusMessage
This class encapsulate a status message.
Definition: kopetestatusmessage.h:48
Kopete::Account::unblock
virtual void unblock(const QString &contactId)
Remove a user from the blacklist.
Definition: kopeteaccount.cpp:679
QHashIterator::hasNext
bool hasNext() const
Kopete::KABCPersistence::write
void write(MetaContact *mc)
Change the KABC data associated with this metacontact.
Definition: kabcpersistence.cpp:102
Kopete::Protocol
base class of every protocol.
Definition: kopeteprotocol.h:62
editaccountwidget.h
kabcpersistence.h
Kopete::PropertyContainer::property
const Kopete::Property & property(const QString &key) const
Get the value of a property with key "key".
Definition: kopetepropertycontainer.cpp:111
QPointer
Kopete::OnlineStatus::Offline
State where you really cannot be contacted.
Definition: kopeteonlinestatus.h:98
kopetegroup.h
Kopete::Contact::isOnline
bool isOnline
Definition: kopetecontact.h:66
Kopete::Contact::account
Account * account() const
Get the account that this contact belongs to.
Definition: kopetecontact.cpp:538
KDialog
Kopete::Account::OtherClient
connection went down because another client connected the same account
Definition: kopeteaccount.h:96
Kopete::OnlineStatus::status
StatusType status() const
Return the status.
Definition: kopeteonlinestatus.cpp:242
Kopete::OnlineStatus::isDefinitelyOnline
bool isDefinitelyOnline() const
Definition: kopeteonlinestatus.cpp:287
QObject::disconnect
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
Kopete::Account::isAway
bool isAway() const
Indicate whether the account is away.
Kopete::Account::removeAccount
virtual bool removeAccount()
Remove the account from the server.
Definition: kopeteaccount.cpp:662
NetworkStatus::Connected
Definition: networkstatuscommon.h:10
Kopete::Account::None
Use the online status.
Definition: kopeteaccount.h:120
Kopete::Account::~Account
~Account()
Destroy the Account object.
Definition: kopeteaccount.cpp:129
kopeteuiglobal.h
Kopete::Account::isConnectedChanged
void isConnectedChanged()
Emitted whenever isConnected() changes.
QString::isNull
bool isNull() const
Kopete::Account::createContact
virtual bool createContact(const QString &contactId, MetaContact *parentContact)=0
Create a new contact in the specified metacontact.
Kopete::Account::excludeConnect
bool excludeConnect() const
Get if the account should not log in.
Kopete::Account::disconnected
virtual void disconnected(Kopete::Account::DisconnectReason reason)
The service has been disconnected.
Definition: kopeteaccount.cpp:178
Kopete::Account::suppressStatusNotification
bool suppressStatusNotification() const
Indicates whether or not we should suppress status notifications for contacts belonging to this accou...
Kopete::Contact::onlineStatus
OnlineStatus onlineStatus() const
Get the online status of the contact.
Definition: kopetecontact.cpp:173
Kopete::Account::colorChanged
void colorChanged(const QColor &)
The color of the account has been changed.
Kopete::Account::hasCustomStatusMenu
virtual bool hasCustomStatusMenu() const
Return true if account has custom status menu.
Definition: kopeteaccount.cpp:492
QObject::property
QVariant property(const char *name) const
QTimer
QHash
Kopete::OnlineStatus::Busy
Means that you have other things to do and don't want to get involved in messaging ('Busy' or 'Do not...
Definition: kopeteonlinestatus.h:123
Kopete::Account::setPriority
void setPriority(uint priority)
Set the priority of this account.
Definition: kopeteaccount.cpp:241
QObject
Kopete::Account::setCustomIcon
void setCustomIcon(const QString &)
change the account icon.
Definition: kopeteaccount.cpp:723
Kopete::Account::setOnlineStatus
virtual void setOnlineStatus(const Kopete::OnlineStatus &status, const Kopete::StatusMessage &reason=Kopete::StatusMessage(), const OnlineStatusOptions &options=None)=0
Reimplement this function to set the online status.
Kopete::Account::setExcludeConnect
void setExcludeConnect(bool)
Set if the account should not log in automatically.
Definition: kopeteaccount.cpp:299
kopeteprotocol.h
QHashIterator
QString::isEmpty
bool isEmpty() const
Kopete::Account::configGroup
KConfigGroup * configGroup() const
Return the KConfigGroup used to write and read special properties.
Definition: kopeteaccount.cpp:282
Kopete::Account::accountDestroyed
void accountDestroyed(const Kopete::Account *account)
Emitted when the account is deleted.
kopetecontactlist.h
Kopete::Account::AddMode
AddMode
Describes what should be done when the contact is added to a metacontact.
Definition: kopeteaccount.h:109
QPixmap::scaled
QPixmap scaled(int width, int height, Qt::AspectRatioMode aspectRatioMode, Qt::TransformationMode transformMode) const
QString
QColor
Kopete::Account::identity
Identity * identity() const
Retrieve the identity this account belongs to.
Definition: kopeteaccount.cpp:514
Kopete::Contact
Definition: kopetecontact.h:58
Kopete::Account::accountIcon
QPixmap accountIcon
Definition: kopeteaccount.h:80
Kopete::Account::Temporary
The contact will not be added on the contact list.
Definition: kopeteaccount.h:112
Kopete::MetaContact::isTemporary
bool isTemporary
Definition: kopetemetacontact.h:63
QPixmap
Kopete::Utils::notifyConnectionLost
void notifyConnectionLost(const Account *account, const QString caption, const QString message, const QString explanation, const QString debugInfo)
Notifies the user connection has been lost without coupling plugins with GUI code.
Definition: kopeteutils.cpp:91
Kopete::OnlineStatus::Online
Refers to a true online state, i.e.
Definition: kopeteonlinestatus.h:129
Kopete::Account::editAccount
void editAccount(QWidget *parent=0L)
Display the edit account widget for the account.
Definition: kopeteaccount.cpp:689
KopeteEditAccountWidget
Definition: editaccountwidget.h:55
QHashIterator::next
Item next()
Kopete::Account::ChangeKABC
The KDE Address book may be updated.
Definition: kopeteaccount.h:110
Kopete::Account::setColor
void setColor(const QColor &color)
Set the color for this account.
Definition: kopeteaccount.cpp:231
Kopete::Account::registerContact
bool registerContact(Contact *c)
Definition: kopeteaccount.cpp:310
Kopete::Account::isConnected
bool isConnected() const
Indicate whether the account is connected at all.
Kopete::UI::Global::mainWidget
KOPETE_EXPORT QWidget * mainWidget()
Returns the main widget - this is the widget that message boxes and KNotify stuff should use as a par...
Definition: kopeteuiglobal.cpp:37
Kopete::ContactList::addMetaContact
void addMetaContact(Kopete::MetaContact *c)
Add the metacontact into the contact list When calling this method, the contact has to be already pla...
Definition: kopetecontactlist.cpp:235
Kopete::Global::Properties::statusMessage
const PropertyTmpl & statusMessage() const
Definition: kopeteglobal.cpp:158
Kopete::Account::suspend
bool suspend(const Kopete::StatusMessage &reason=Kopete::StatusMessage())
Disconnects account, required before resume() Returns false if account is already suspended...
Definition: kopeteaccount.cpp:601
Kopete::Group::topLevel
static Group * topLevel()
Definition: kopetegroup.cpp:35
QDateTime::currentDateTime
QDateTime currentDateTime()
KopeteEditAccountWidget::apply
virtual Kopete::Account * apply()=0
Create a new account if we are in the 'add account wizard', otherwise update the existing account...
Kopete::Account::blackLister
BlackLister * blackLister()
Definition: kopeteaccount.cpp:669
Kopete::Contact::metaContact
MetaContact * metaContact() const
Get the metacontact for this contact.
Definition: kopetecontact.cpp:523
Kopete::BlackLister
Manages the list of blacklisted contacts for an account.
Definition: kopeteblacklister.h:45
Kopete::BehaviorSettings::self
static BehaviorSettings * self()
Definition: kopetebehaviorsettings.cpp:23
kopeteaccountmanager.h
Kopete::Account::customIcon
QString customIcon() const
return the icon base This is the custom account icon set with setIcon.
Definition: kopeteaccount.cpp:733
QAction
KAction
Kopete::Identity::id
QString id() const
The id is a unique internal handle and should not be exposed in the UI.
Definition: kopeteidentity.cpp:91
Kopete::Account::isBlocked
virtual bool isBlocked(const QString &contactId)
Definition: kopeteaccount.cpp:684
Kopete::Protocol::createEditAccountWidget
virtual KopeteEditAccountWidget * createEditAccountWidget(Account *account, QWidget *parent)=0
Create a new KopeteEditAccountWidget.
Kopete::Group
Class which represents the Group.
Definition: kopetegroup.h:44
Kopete::Account::block
virtual void block(const QString &contactId)
Add a user to the blacklist.
Definition: kopeteaccount.cpp:674
Kopete::PropertyContainer
Definition: kopetepropertycontainer.h:39
Kopete::Contact::displayName
QString displayName() const
Returns display name of contact.
Definition: kopetecontact.cpp:913
Kopete::Property::value
const QVariant & value() const
Getter for this properties value.
Definition: kopeteproperty.cpp:229
kopeteblacklister.h
Kopete::Account::resume
bool resume()
Sets account to the online status that was active when suspend() was called.
Definition: kopeteaccount.cpp:614
Kopete::MetaContact
Definition: kopetemetacontact.h:54
QString::fromLatin1
QString fromLatin1(const char *str, int size)
Kopete::Account::DisconnectReason
DisconnectReason
Describes how the account was disconnected.
Definition: kopeteaccount.h:95
Kopete::OnlineStatus::Away
Refers to a state where you can be technically reached, but for one reason or another it is often not...
Definition: kopeteonlinestatus.h:117
Kopete::Account::networkingStatusChanged
void networkingStatusChanged(const Solid::Networking::Status status)
React to network status changes.
Definition: kopeteaccount.cpp:155
Kopete::Account::setMyself
void setMyself(Contact *myself)
Set the 'myself' contact.
Definition: kopeteaccount.cpp:542
QHashIterator::value
const T & value() const
Kopete::PropertyTmpl::key
const QString & key() const
Getter for the unique key.
Definition: kopeteproperty.cpp:137
KopeteEditAccountWidget::validateData
virtual bool validateData()=0
This method must be reimplemented.
Kopete::Account::ConnectionReset
the connection was lost
Definition: kopeteaccount.h:101
Kopete::KABCPersistence::self
static KABCPersistence * self()
Retrieve the instance of AccountManager.
Definition: kabcpersistence.cpp:86
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QWidget::actions
QList< QAction * > actions() const
QAction::menu
QMenu * menu() const
kopetebehaviorsettings.h
Kopete::Account::contacts
const QHash< QString, Contact * > & contacts()
Retrieve the list of contacts for this account (except myself contact)
Definition: kopeteaccount.cpp:333
QVariant::toString
QString toString() const
Kopete::Contact::setOnlineStatus
void setOnlineStatus(const OnlineStatus &status)
Set the contact's online status.
Definition: kopetecontact.cpp:181
Kopete::Identity
Definition: kopeteidentity.h:41
Kopete::Account::color
const QColor color() const
Get the color for this account.
kopeteidentity.h
kopetepluginmanager.h
Kopete::Account::isBusy
bool isBusy() const
Indicate whether the account is busy.
Definition: kopeteaccount.cpp:509
kopetecontact.h
Kopete::Account::addContact
MetaContact * addContact(const QString &contactId, const QString &displayName=QString(), Group *group=0, AddMode mode=DontChangeKABC)
Create a contact (creating a new metacontact if necessary)
Definition: kopeteaccount.cpp:339
Kopete::Identity::addAccount
void addAccount(Kopete::Account *account)
Adds an account to the identity.
Definition: kopeteidentity.cpp:194
kopeteonlinestatusmanager.h
Kopete::Account::accountIconPath
QString accountIconPath(const KIconLoader::Group size) const
Definition: kopeteaccount.cpp:275
QDateTime
Kopete::Account::Manual
the user disconnected normally
Definition: kopeteaccount.h:100
QVariant
Kopete::OnlineStatus::Connecting
State where the user is not available on the network yet but trying to get onto.
Definition: kopeteonlinestatus.h:104
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:29:19 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