summaryrefslogtreecommitdiff
path: root/migrationutility/sourceserver.h
diff options
context:
space:
mode:
Diffstat (limited to 'migrationutility/sourceserver.h')
-rw-r--r--migrationutility/sourceserver.h75
1 files changed, 69 insertions, 6 deletions
diff --git a/migrationutility/sourceserver.h b/migrationutility/sourceserver.h
index 08881d9..f3ab897 100644
--- a/migrationutility/sourceserver.h
+++ b/migrationutility/sourceserver.h
@@ -25,6 +25,34 @@
#include "sourceaccount.h"
/**
+ * Job interface to retrieve users from a server.
+ */
+class UserListJob: public KJob
+{
+ Q_OBJECT
+public:
+ explicit UserListJob(QObject* parent = 0);
+ virtual QStringList getUserList() const = 0;
+};
+
+class FixedUserListJob: public UserListJob
+{
+ Q_OBJECT
+public:
+ explicit FixedUserListJob(const QStringList &userList, QObject* parent = 0);
+ virtual void start();
+ virtual QStringList getUserList() const;
+
+private slots:
+ void doEmitResult();
+
+private:
+ QStringList mUserList;
+};
+
+
+
+/**
* The source server represents a server with user accounts that need to be migrated.
*
* The server can support multiple access protocols per user, that are each represented by a source account.
@@ -35,7 +63,7 @@ class SourceServer: public QObject
public:
explicit SourceServer(QObject* parent = 0);
QList<SourceAccount*> getSourceAccounts(const QString &user);
- QStringList getUserList();
+ UserListJob *listUsers();
void setSingleUser(const QString &);
void setStatefile(const QString &);
@@ -45,12 +73,12 @@ public:
void setIgnoredFolders(const QStringList &);
QStringList ignoredFolders() const;
protected:
+ virtual QList<SourceAccount*> getSourceAccountsImpl(const QString &user) = 0;
/**
* Reeimplement to retrieve a user list from the server.
* Note that the retrieved username is used to login to the users account on the source server.
*/
- virtual QStringList retrieveUserList();
- virtual QList<SourceAccount*> getSourceAccountsImpl(const QString &user) = 0;
+ virtual UserListJob *retrieveUserList();
QStringList mExplicitUsers;
QString mStatefile;
private:
@@ -66,10 +94,46 @@ public:
QStringList mUsers;
protected:
- virtual QStringList retrieveUserList();
+ virtual UserListJob *retrieveUserList();
virtual QList< SourceAccount* > getSourceAccountsImpl(const QString& user);
};
+class IMAPConnectionSettings {
+public:
+ IMAPConnectionSettings(const QString &username, const QString &pw, KIMAP::LoginJob::EncryptionMode encryptionMode, KIMAP::LoginJob::AuthenticationMode authenticationMode)
+ : mUsername(username), mPassword(pw), mEncryptionMode(encryptionMode), mAuthenticationMode(authenticationMode)
+ {}
+ QString username() const { return mUsername; }
+ QString password() const { return mPassword; }
+ KIMAP::LoginJob::EncryptionMode encryptionMode() const { return mEncryptionMode; }
+ KIMAP::LoginJob::AuthenticationMode authenticationMode() const { return mAuthenticationMode; }
+private:
+ const QString mUsername;
+ const QString mPassword;
+ const KIMAP::LoginJob::EncryptionMode mEncryptionMode;
+ const KIMAP::LoginJob::AuthenticationMode mAuthenticationMode;
+};
+
+class IMAPUserListJob: public UserListJob
+{
+ Q_OBJECT
+public:
+ explicit IMAPUserListJob(const QString &host, qint16 port, const IMAPConnectionSettings &settings, QObject* parent = 0);
+ virtual ~IMAPUserListJob();
+ virtual void start();
+ virtual QStringList getUserList() const;
+
+private slots:
+ void onLoginDone(KJob*);
+ void onUserListJobDone(KJob*);
+ void onLogoutDone(KJob*);
+
+private:
+ KIMAP::Session *mSession;
+ const IMAPConnectionSettings mConnectionSettings;
+ QStringList mUserList;
+};
+
class IMAPSourceServer: public SourceServer
{
Q_OBJECT
@@ -81,9 +145,8 @@ public:
void setEncryption(KIMAP::LoginJob::EncryptionMode);
void setAuthentication(KIMAP::LoginJob::AuthenticationMode);
protected:
- virtual QStringList retrieveUserList();
virtual QList< SourceAccount* > getSourceAccountsImpl(const QString& user);
- void logout();
+ virtual UserListJob *retrieveUserList();
KIMAP::Session *mSession;
QString mHost;
int mPort;