ButeoSynchronizationFramework
AccountsHelper.h
1 /*
2  * This file is part of buteo-syncfw package
3  *
4  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5  *
6  * Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * version 2.1 as published by the Free Software Foundation.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA
21  *
22  */
23 #ifndef ACCOUNTSHELPER_H
24 #define ACCOUNTSHELPER_H
25 
26 #include <QObject>
27 
28 #include <Accounts/manager.h>
29 #include <Accounts/account.h>
30 
31 namespace Buteo {
32 
33 class Profile;
34 class AccountsHelperTest;
35 class ProfileManager;
36 class SyncProfile;
37 
38 const QString REMOTE_SERVICE_NAME("remote_service_name");
39 
43 class AccountsHelper : public QObject
44 {
45  Q_OBJECT
46 
47 public:
48 
54  AccountsHelper(ProfileManager &aProfileManager, QObject *aParent = NULL);
55 
59  virtual ~AccountsHelper();
60 
67  QList<SyncProfile*> getProfilesByAccountId(Accounts::AccountId id);
68 
69 public Q_SLOTS:
70 
76  QString createProfileForAccount(Accounts::AccountId id);
77 
82  void slotAccountRemoved(Accounts::AccountId id);
83 
90  void slotAccountEnabledChanged(const QString &serviceName, bool enabled);
91 
96  void slotAccountUpdated(Accounts::AccountId id);
97 
98  void slotSchedulerSettingsChanged(const char *aKey);
99 Q_SIGNALS:
100 
101  void enableSOC(const QString& aProfileName);
102  void scheduleUpdated(const QString& aProfileName);
103  void removeProfile(QString profileId);
104  void removeScheduledSync(const QString& profileId);
105 
106 private Q_SLOTS:
107 
108  void registerAccountListeners();
109 
110 private:
111  void createProfileForAccount(Accounts::Account* account,
112  const QString profileName,
113  const SyncProfile* baseProfile);
114 
115  QString addAccountIfNotExists(Accounts::Account *account,
116  Accounts::Service service,
117  const SyncProfile *baseProfile);
118 
119  void setSyncSchedule(SyncProfile *syncProfile, Accounts::AccountId id, bool aCreateNew = false);
120 
121  void addSetting(Accounts::AccountId id, QString key, QVariant value);
122 
123  void registerAccountListener(Accounts::AccountId id);
124 
125  Accounts::Manager *iAccountManager;
126 
127  ProfileManager &iProfileManager;
128 
129  QList<Accounts::Account*> iAccountList;
131 
132 #ifdef SYNCFW_UNIT_TESTS
133  friend class AccountsHelperTest;
134 #endif
135 };
136 
137 }
138 
139 #endif // ACCOUNTSHELPER_H
void slotAccountRemoved(Accounts::AccountId id)
slot for Accounts::Manager accountRemoved signal
Definition: AccountsHelper.cpp:116
Definition: AccountsHelper.h:31
void slotAccountUpdated(Accounts::AccountId id)
slot for Accounts::Manager displayNameChanged signal
Definition: AccountsHelper.cpp:280
AccountsHelper(ProfileManager &aProfileManager, QObject *aParent=NULL)
Constructor.
Definition: AccountsHelper.cpp:35
QString createProfileForAccount(Accounts::AccountId id)
This method is used to create a profile for a specified account.
Definition: AccountsHelper.cpp:61
Helper Class towards Accounts::Manager and various SSO related operations.
Definition: AccountsHelper.h:43
ProfileManager is responsible for storing and retrieving the profiles.
Definition: ProfileManager.h:45
void slotAccountEnabledChanged(const QString &serviceName, bool enabled)
slot for Accounts::Account enabledChanged signal
Definition: AccountsHelper.cpp:138
virtual ~AccountsHelper()
Destructor.
Definition: AccountsHelper.cpp:52
A top level synchronization profile.
Definition: SyncProfile.h:47
Definition: SyncBackupAdaptor.h:40
QList< SyncProfile * > getProfilesByAccountId(Accounts::AccountId id)
Returns sync profiles that correspond to a given account ID.
Definition: AccountsHelper.cpp:299