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