blokkalaccount.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef BLOKKALACCOUNT_H
00021 #define BLOKKALACCOUNT_H
00022
00023 #include <QtCore/QObject>
00024
00025 #include "blokkal_export.h"
00026
00027 class QAction;
00028
00029 class KUrl;
00030 class QDomElement;
00031 class KIcon;
00032
00033 namespace KWallet {
00034 class Wallet;
00035 }
00036
00037 namespace Blokkal {
00038 class Protocol;
00039 class AccountConfig;
00040 class Blog;
00041 class BlogConfig;
00042 namespace Io {
00043 class CategoryManager;
00044 }
00045
00052 class BLOKKAL_EXPORT Account : public QObject
00053 {
00054 Q_OBJECT
00055 public:
00059 enum ConnectionStatus {
00060 Connected = 1,
00061 Connecting = 2,
00062 Disconnected = 3,
00063 };
00064
00068 enum DisconnectReason {
00069 UserDisconnect = 1,
00070 IOErrorDisconnect = 2,
00071 OtherDisconnect = 3,
00072 AuthenticationDisconnect = 4,
00073 };
00074
00080 virtual ~Account( void );
00081
00086 Blokkal::Protocol * protocol( void ) const;
00087
00095 QString serverName( void ) const;
00096
00101 void setServerName( const QString & serverName );
00102
00107 KUrl connectAddress( void ) const;
00108
00113 void setConnectAddress( const QString & address );
00114
00121 bool usesDefaultConnectAddress( void ) const;
00122
00128 void setUsesDefaultConnectAddress( bool useDefault );
00129
00134 bool autoConnect( void ) const;
00135
00140 void setAutoConnect( bool enable ) const;
00141
00146 QString id( void ) const;
00147
00154 QString userName( void ) const;
00155
00160 void setUserName( const QString & user );
00161
00166 virtual KIcon icon( void ) const;
00167
00173 virtual void removeAccount( void );
00174
00180 Blokkal::Account::ConnectionStatus connectionStatus( void ) const;
00181
00186 bool isConnected( void ) const;
00187
00192 bool isDisconnected( void ) const;
00193
00198 QList< Blokkal::Blog * > blogs( void ) const;
00199
00205 Blokkal::Blog * blog( const QString & id ) const;
00206
00212 QString dataDirectory( void ) const;
00213
00219 virtual QList<QAction*> actionList( void );
00220
00221 public Q_SLOTS:
00229 virtual void connectAccount( void ) = 0;
00230
00242 virtual void disconnectAccount( Blokkal::Account::DisconnectReason reason = UserDisconnect,
00243 const QString & reasonString = 0 );
00244
00248 void restoreBlogs( void );
00249
00254 Blokkal::Io::CategoryManager * categoryManager( void ) const;
00255
00256 Q_SIGNALS:
00260 void accountDestroyed( Blokkal::Account * account );
00261
00266 void connectionStatusChanged( Blokkal::Account * account );
00267
00271 void blogRegistered( Blokkal::Blog * blog );
00272
00276 void blogUnregistered( Blokkal::Blog * blog );
00277
00278 protected:
00284 Account( Blokkal::Protocol * protocol, const QString & id = 0 );
00285
00291 void setConnectionStatus( Blokkal::Account::ConnectionStatus status );
00292
00297 Blokkal::AccountConfig * config( void ) const;
00298
00307 QDomElement blogNode( const QString & id );
00308
00317 virtual Blokkal::Blog * restoreBlog( Blokkal::BlogConfig * config ) = 0;
00318
00319 protected Q_SLOTS:
00328 Blokkal::Blog * registerBlog( Blokkal::Blog * blog );
00329
00335 void unregisterBlog( Blokkal::Blog * blog );
00336
00337 private:
00338 class Private;
00339 Private * const d;
00340 friend class BlogConfig;
00341 };
00342
00350 class BLOKKAL_EXPORT PasswordedAccount : public Blokkal::Account
00351 {
00352 Q_OBJECT
00353 public:
00359 virtual ~PasswordedAccount( void );
00360
00366 virtual void removeAccount( void );
00367
00368 public Q_SLOTS:
00373 virtual void connectAccount( void );
00374
00382 virtual void disconnectAccount( Blokkal::Account::DisconnectReason reason = UserDisconnect,
00383 const QString & reasonString = 0 );
00384
00385 protected:
00391 PasswordedAccount( Blokkal::Protocol * protocol, const QString & id = 0 );
00392
00397 const QString & password( void ) const;
00398
00399 protected Q_SLOTS:
00407 virtual void connectInner( void ) = 0;
00408
00409 private Q_SLOTS:
00410 void slotWalletOpened( KWallet::Wallet * wallet );
00411
00412 private:
00413 QString promptUser( bool & success, KWallet::Wallet * wallet );
00414
00415 class Private;
00416 Private * const d;
00417
00418 };
00419
00420 }
00421
00422
00423
00424
00425 #endif