kopete/libkopete
kopeteaccount.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KOPETEACCOUNT_H
00022 #define KOPETEACCOUNT_H
00023
00024 #include "kopeteonlinestatus.h"
00025 #include "kopetestatusmessage.h"
00026 #include "kopete_export.h"
00027
00028 #include <QtCore/QObject>
00029 #include <QtGui/QPixmap>
00030 #include <QtCore/QHash>
00031
00032 #include <kconfiggroup.h>
00033
00034 class KActionMenu;
00035 class KConfigGroup;
00036
00037 namespace Kopete
00038 {
00039 class Contact;
00040 class Protocol;
00041 class MetaContact;
00042 class Group;
00043 class OnlineStatus;
00044 class BlackLister;
00045 class StatusMessage;
00046 class Identity;
00047 class PropertyContainer;
00048
00072 class KOPETE_EXPORT Account : public QObject
00073 {
00074 Q_OBJECT
00075
00076 Q_ENUMS( AddMode )
00077 Q_PROPERTY( QString accountId READ accountId )
00078 Q_PROPERTY( bool excludeConnect READ excludeConnect WRITE setExcludeConnect )
00079 Q_PROPERTY( QColor color READ color WRITE setColor )
00080 Q_PROPERTY( QPixmap accountIcon READ accountIcon )
00081 Q_PROPERTY( bool isConnected READ isConnected )
00082 Q_PROPERTY( bool isAway READ isAway )
00083 Q_PROPERTY( bool suppressStatusNotification READ suppressStatusNotification )
00084 Q_PROPERTY( uint priority READ priority WRITE setPriority )
00085
00086 public:
00095 enum DisconnectReason {
00096 OtherClient = -4,
00097 BadPassword = -3,
00098 BadUserName = -2,
00099 InvalidHost = -1,
00100 Manual = 0,
00101 ConnectionReset = 1,
00102 Unknown = 99
00103 };
00104
00109 enum AddMode {
00110 ChangeKABC = 0,
00111 DontChangeKABC = 1,
00112 Temporary = 2
00113 };
00114
00121 Account(Protocol *parent, const QString &accountID);
00122 ~Account();
00123
00127 Protocol *protocol() const ;
00128
00132 QString accountId() const;
00133
00137 QString accountLabel() const;
00138
00144 uint priority() const;
00145
00151 void setPriority( uint priority );
00152
00159 void setExcludeConnect(bool);
00160
00166 bool excludeConnect() const;
00167
00176 const QColor color() const;
00177
00185 void setColor( const QColor &color);
00186
00195 QPixmap accountIcon( const int size = 0 ) const;
00196
00204 void setCustomIcon( const QString& );
00205
00211 QString customIcon() const;
00212
00220 Identity * identity() const;
00221
00233 virtual bool setIdentity( Kopete::Identity *ident );
00234
00242 Contact * myself() const;
00243
00258 virtual KActionMenu* actionMenu() ;
00259
00267 const QHash<QString,Contact*>& contacts();
00268
00278 bool suppressStatusNotification() const;
00279
00298 MetaContact* addContact( const QString &contactId, const QString &displayName = QString(), Group *group = 0, AddMode mode = DontChangeKABC );
00299
00313 bool addContact( const QString &contactId, MetaContact *parent, AddMode mode = DontChangeKABC );
00314
00323 bool isConnected() const;
00324
00331 bool isAway() const;
00332
00341 KConfigGroup *configGroup() const;
00342
00356 virtual bool removeAccount();
00357
00362 BlackLister* blackLister();
00363
00368 virtual bool isBlocked( const QString &contactId );
00369
00370 protected:
00385 void setMyself( Contact *myself );
00386
00402 virtual bool createContact( const QString &contactId, MetaContact *parentContact ) =0;
00403
00404
00410 void setAccountLabel( const QString &label );
00411
00412 protected slots:
00424 virtual void disconnected( Kopete::Account::DisconnectReason reason );
00425
00438 void setAllContactsStatus( const Kopete::OnlineStatus &status );
00439
00440 signals:
00447 void colorChanged( const QColor & );
00448
00453 void accountDestroyed( const Kopete::Account *account );
00454
00458 void isConnectedChanged();
00459
00460 private:
00465 void readConfig();
00466
00467 public:
00473 void registerContact( Contact *c );
00474
00475 public slots:
00483 virtual void connect( const Kopete::OnlineStatus& initialStatus = OnlineStatus() ) = 0;
00484
00493 virtual void disconnect( ) = 0 ;
00494
00495 public slots:
00502 virtual void setOnlineStatus( const Kopete::OnlineStatus& status , const Kopete::StatusMessage &reason = Kopete::StatusMessage() ) = 0;
00508 virtual void setStatusMessage( const Kopete::StatusMessage &statusMessage ) = 0;
00509
00513 void editAccount( QWidget* parent = 0L );
00514
00522 virtual void block( const QString &contactId );
00523
00531 virtual void unblock( const QString &contactId );
00532
00533 private slots:
00537 virtual void reconnect();
00538
00542 void contactDestroyed( Kopete::Contact * );
00543
00547 void slotOnlineStatusChanged( Kopete::Contact *contact, const Kopete::OnlineStatus &newStatus, const Kopete::OnlineStatus &oldStatus );
00548
00552 void slotContactPropertyChanged( Kopete::PropertyContainer *, const QString &, const QVariant &, const QVariant & );
00553
00557 void slotStopSuppression();
00558
00559 private:
00560 class Private;
00561 Private *d;
00562 };
00563
00564 }
00565
00566 #endif
00567