Changeset 315:e6c8bb244ecd in SMSSender


Ignore:
Timestamp:
Feb 5, 2014 7:11:10 PM (6 years ago)
Author:
Sämy Zehnder <saemy.zehnder@…>
Branch:
separation-frontend-backend
Message:
  • Separates the frontend from the backend code.
  • At this point the schoolnet gateway is converted only.
  • Removes bc & da prefixes from the filenames.
Files:
71 added
39 deleted
37 edited
4 copied
394 moved

Legend:

Unmodified
Added
Removed
  • common/business/iaccount.cpp

    r217 r315  
    1818#include "iaccount.h"
    1919
    20 const QString Account::Action::Sleeping                 = QObject::tr("Sleeping");
     20const QString Action::Sleeping                 = QObject::tr("Sleeping");
    2121
    22 const QString Account::Action::Initializing             = QObject::tr("Initializing");
    23 const QString Account::Action::CancellingInitialization = QObject::tr("Cancelling initialization");
     22const QString Action::Initializing             = QObject::tr("Initializing");
     23const QString Action::CancellingInitialization = QObject::tr("Cancelling initialization");
    2424
    25 const QString Account::Action::AddingRecipients         = QObject::tr("Adding recipients");
    26 const QString Account::Action::RemovingRecipients       = QObject::tr("Removing old recipients");
    27 const QString Account::Action::SendingSMS               = QObject::tr("Sending sms");
    28 const QString Account::Action::CancellingSendingSMS     = QObject::tr("Cancelling sending sms");
     25const QString Action::AddingRecipients         = QObject::tr("Adding recipients");
     26const QString Action::RemovingRecipients       = QObject::tr("Removing old recipients");
     27const QString Action::SendingSMS               = QObject::tr("Sending sms");
     28const QString Action::CancellingSendingSMS     = QObject::tr("Cancelling sending sms");
  • common/business/iaccount.h

    r275 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #ifndef IACCOUNT_H_
    19 #define IACCOUNT_H_
     18#ifndef COMMON_IACCOUNT_H
     19#define COMMON_IACCOUNT_H
    2020
    2121#include <limits.h>
     
    2626#include <QString>
    2727
    28 #include "istorable.h"
    29 #include "ivalidatable.h"
    30 
    31 #include "scontact.h"
    32 #include "sdatatypes.h"
    33 #include "stask.h"
    34 
    35 #include "datatypes_global.h"
    36 
    37 class IAccount;
    38 class IGateway;
     28#include "common/business/igateway.h"
     29#include "common/business/istorable.h"
     30#include "common/business/ivalidatable.h"
     31#include "common/domain/scontact.h"
     32#include "common/domain/sdatatypes.h"
     33#include "common/domain/stask.h"
     34#include "common/global.h"
    3935
    4036class IAccountInitTask;
     
    4238class ISMSSendTask;
    4339
    44 class DATATYPES_SHARED_EXPORT IAccount: public QObject, public IStorable, public IValidatable {
     40namespace Persistence {
     41    class AccountManager;
     42}
     43
     44class COMMON_EXPORT IAccount: public QObject, public IStorable, public IValidatable {
    4545    Q_OBJECT
    4646    Q_INTERFACES(IStorable IValidatable)
     
    5959
    6060public:
    61     virtual IGateway* gateway() const =0;
     61    virtual IGateway *gateway() const =0;
    6262
    6363    virtual int     id() const =0;
     
    8484public:
    8585    virtual IAccountLoginTask* createLoginTask() =0;
    86     virtual bool               isLoggedIn() const =0;
    87     virtual void               ensureLoggedIn() =0;
     86    virtual bool isLoggedIn() const =0;
     87    virtual bool stillLoggedIn() =0; // TODO: remove this or at least move it into _impl
     88    virtual void ensureLoggedIn() =0;
    8889
    8990public:
    90     virtual ISMSSendTask*      createSMSSendTask(const QString& message, const QSet<SContact>& recipients) =0;
    91 
    92 public:
    93     virtual IAccount* createClonedInstance(QObject* parent) const =0;
     91    virtual ISMSSendTask *createSMSSendTask(const QString& message, const QSet<const SContact*>& recipients) =0;
    9492
    9593signals:
     
    104102    void loggedOut(IAccount* account);
    105103
    106     void smsSendingDone(IAccount* account, Account::SendingResult result);
     104    void smsSendingDone(IAccount* account, SendingResult result);
    107105    void smsSendingErrorOccured(IAccount* account, const EException& exception);
    108106
     107protected:
     108    friend class Persistence::AccountManager;
     109
     110    virtual void setId(int id) =0;
     111
    109112public:
    110     IAccount(QObject* parent)
    111         : QObject(parent)
    112     {}
    113113    virtual ~IAccount() {}
    114114};
    115115Q_DECLARE_INTERFACE(IAccount, "ch.gorrion.smssender.IAccount/1.0")
    116116
    117 #endif /* IACCOUNT_H_ */
     117#endif /* COMMON_IACCOUNT_H */
  • common/business/iaccount_tasks.h

    r218 r315  
    1616  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717*/
    18 #ifndef IACCOUNT_TASKS_H_
    19 #define IACCOUNT_TASKS_H_
     18#ifndef COMMON_IACCOUNT_TASKS_H
     19#define COMMON_IACCOUNT_TASKS_H
    2020
    2121#include <QSet>
    2222#include <QString>
    2323
    24 #include "datatypes_global.h"
    25 
    26 #include "scontact.h"
    27 #include "stask.h"
     24#include "common/domain/scontact.h"
     25#include "common/domain/stask.h"
     26#include "common/global.h"
    2827
    2928class IAccount;
     
    3534const uint UID_SEND_SMS      = 300;
    3635
    37 class DATATYPES_SHARED_EXPORT IAccountTask : public SThreadedTask {
     36class COMMON_EXPORT IAccountTask : public SThreadedTask {
    3837    Q_OBJECT
    3938
     
    5150
    5251
    53 class DATATYPES_SHARED_EXPORT IAccountInitTask : public IAccountTask {
     52class COMMON_EXPORT IAccountInitTask : public IAccountTask {
    5453    Q_OBJECT
    5554
     
    6160
    6261
    63 class DATATYPES_SHARED_EXPORT IAccountLoginTask : public IAccountTask {
     62class COMMON_EXPORT IAccountLoginTask : public IAccountTask {
    6463    Q_OBJECT
    6564
     
    7170
    7271
    73 class DATATYPES_SHARED_EXPORT ISMSSendTask : public IAccountTask {
     72class COMMON_EXPORT ISMSSendTask : public IAccountTask {
    7473    Q_OBJECT
    7574
     
    7978
    8079public:
    81     virtual QString        message() const =0;
    82     virtual QSet<SContact> recipients() const =0;
     80    virtual QString message() const =0;
     81    virtual QSet<const SContact*> recipients() const =0;
    8382};
    8483Q_DECLARE_INTERFACE(ISMSSendTask, "ch.gorrion.smssender.ISMSSendTask/1.0")
    8584
    86 #endif /* IACCOUNT_TASKS_H_ */
     85#endif /* COMMON_IACCOUNT_TASKS_H */
  • common/business/icontactimporter_base.h

    r218 r315  
    1616  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717*/
    18 #ifndef ICONTACTIMPORTER_H_
    19 #define ICONTACTIMPORTER_H_
     18#ifndef COMMON_ICONTACTIMPORTER_BASE_H
     19#define COMMON_ICONTACTIMPORTER_BASE_H
    2020
    2121#include <QList>
     
    2323#include <QSet>
    2424#include <QString>
    25 #include <QWizardPage>
    26 
    27 #include "datatypes_global.h"
    2825
    2926class SContact;
    3027
    31 class DATATYPES_SHARED_EXPORT IContactImporter : public QObject {
    32     Q_OBJECT
     28class IBaseContactImporter {
     29public:
     30    virtual QString describingName() const =0;
     31    virtual bool isApplicable() const =0;
     32
     33    virtual void init() =0;
     34
     35    // Caller takes ownership of contacts.
     36    virtual void importContacts(QSet<SContact*> *contacts) =0;
    3337
    3438public:
    35     virtual QString describingName() const =0;
    36     virtual bool    isApplicable() const =0;
     39    virtual ~IBaseContactImporter() {}
     40};
    3741
    38     virtual void    init() =0;
    39 
    40     virtual QList<QWizardPage *> createPreImportPages(QWidget *parent) =0;
    41 
    42     virtual QSet<SContact> importContacts() =0;
    43 
    44 public:
    45     IContactImporter(QObject *parent);
    46     virtual ~IContactImporter() {}
    47 };
    48 Q_DECLARE_INTERFACE(IContactImporter, "ch.gorrion.smssender.IContactImporter/1.0")
    49 
    50 #endif /* ICONTACTIMPORTER_H_ */
     42#endif /* COMMON_ICONTACTIMPORTER_BASE_H */
  • common/business/igateway_base.h

    r218 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #ifndef IGATEWAY_H_
    19 #define IGATEWAY_H_
     18#ifndef COMMON_IGATEWAY_BASE_H
     19#define COMMON_IGATEWAY_BASE_H
    2020
    21 #include <QImage>
    2221#include <QList>
    2322#include <QMetaType>
    2423#include <QObject>
    2524#include <QString>
    26 #include <QWidget>
    2725
    28 #include "datatypes_global.h"
     26#include "common/business/istorable.h"
     27#include "common/domain/sdatatypes.h"
     28#include "common/global.h"
    2929
    30 #include "sdatatypes.h"
    31 
     30class IAccount;
    3231class IAccountSettingsWidget;
    3332
    34 class IAccount;
    3533class IGateway;
    36 class IStorage;
    3734
    38 class DATATYPES_SHARED_EXPORT IGateway : public QObject {
    39     Q_OBJECT
     35class COMMON_EXPORT IBaseGateway : public IStorable {
     36    Q_INTERFACES(IStorable)
    4037
    4138public:
    42     virtual QString      name() const =0;
    43     virtual QImage       icon() const =0;
    44 
    45     virtual IAccount*    createAccountInstance() =0;
    46     virtual IAccount*    createAccountInstance(IStorage* storage) =0;
    47 
    48     virtual IStorage*    defaultStorage() const =0;
    49     virtual void         setDefaultStorage(IStorage* storage) =0;
    50 
    51     virtual IAccountSettingsWidget* createAccountSettingsWidget(QWidget* parent) const =0;
     39    virtual QString name() const =0;
    5240
    5341public:
    54     virtual QList<int>   validRecipientCountryCodes() const =0;
     42    virtual QList<int> validRecipientCountryCodes() const =0;
    5543    virtual QList<QChar> doublePriceChars() const =0;
    5644    virtual QList<QChar> disAllowedChars() const =0;
    5745
    5846public:
    59     IGateway(QObject* parent)
    60         : QObject(parent)
    61     {}
    62     virtual ~IGateway() {}
     47    virtual IAccount *createAccountInstance() =0;
    6348};
    64 Q_DECLARE_INTERFACE(IGateway, "ch.gorrion.smssender.IGateway/1.0")
     49Q_DECLARE_INTERFACE(IBaseGateway, "ch.gorrion.smssender.IBaseGateway/1.0")
    6550
    66 #endif /* IGATEWAY_H_ */
     51#endif /* COMMON_IGATEWAY_BASE_H */
  • common/business/ilibrary.cpp

    r194 r315  
    1818#include "ilibrary.h"
    1919
    20 const QString ILibrary::COMPATIBILITY_VERSION = LIBDATATYPES_COMPATIBILITY_VERSION;
     20const QString ILibrary::COMPATIBILITY_VERSION = LIB_COMPATIBILITY_VERSION;
  • common/business/ilibrary.h

    r218 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #ifndef ILIBRARY_H_
    19 #define ILIBRARY_H_
     18#ifndef COMMON_ILIBRARY_H
     19#define COMMON_ILIBRARY_H
    2020
    21 #include <QObject>
    22 #include <QList>
    23 #include <QLocale>
    2421#include <QMetaType>
    25 #include <QSharedPointer>
     22#include <QSet>
    2623#include <QString>
    2724#include <QTranslator>
    2825
    29 #include "datatypes_global.h"
    30 
    31 #include "smacros.h"
    32 #include "sshared.h"
     26#include "common/business/iintegration.h"
     27#include "common/domain/sversion.h"
     28#include "common/global.h"
    3329
    3430class IContactImporter;
    3531class IGateway;
    36 class ILibrary;
    37 class IManagerFactory;
    3832
    39 class SVersion;
    40 
    41 class DATATYPES_SHARED_EXPORT ILibrary : public QObject {
    42     Q_OBJECT
    43 
     33class COMMON_EXPORT ILibrary {
    4434public:
    4535    const static QString COMPATIBILITY_VERSION;
    4636
    4737public:
    48     virtual void                     init(IManagerFactory* managerFactory) =0;
     38    /**
     39     * Initializes this library.
     40     * @param integrationHelperFactory A helper to make integration
     41     *      of the library easy. Call createIntegrationHelper with your
     42     *      gateway to get access. It is implemented in such a way,
     43     *      that only objects defined in this library are accessible.
     44     *      This includes events which are only emitted for such
     45     *      objects.
     46     *      The integrationHelperFactory is owned by the caller, created
     47     *      integrationHelpers are owned by the library.
     48     * @return True, if initialization is successful
     49     */
     50    virtual bool init(const IIntegrationHelper::Factory &integrationHelperFactory) =0;
    4951
    50     virtual QString                  identificationKey() const =0;
    51     virtual SVersion                 version() const =0;
    52     virtual QString                  compatibilityVersion() const =0; // To prevent loading of too old/new libraries
     52    virtual QString identificationKey() const =0;
     53    virtual SVersion version() const =0;
     54    virtual QString compatibilityVersion() const =0; // To prevent loading too old/new libraries
    5355
    54     virtual QList<QTranslator*>      getTranslators() const =0;
    55     virtual IGateway*                getGateway() const =0;
    56     virtual QList<IContactImporter*> getContactImporters() const =0;
     56    virtual QSet<QTranslator*> translators() const =0;
     57    virtual QSet<IContactImporter*> contactImporters() const =0;
     58    /**
     59     * @brief Returns the gateway which is defined in this library.
     60     *        Can be NULL if no gateway is defined.
     61     * @return
     62     */
     63    virtual IGateway* gateway() const =0;
    5764
    5865public:
    59     ILibrary(QObject* parent)
    60         : QObject(parent)
    61     {}
    6266    virtual ~ILibrary() {}
    6367};
    6468Q_DECLARE_INTERFACE(ILibrary, "ch.gorrion.smssender.ILibrary/1.0")
    6569
    66 #define LIBRARY_EXPORT Q_DECL_EXPORT
     70extern "C" Q_DECL_EXPORT ILibrary *createLibrary();
    6771
    68 #endif /* ILIBRARY_H_ */
     72#endif /* COMMON_ILIBRARY_H */
  • common/business/imanagers.h

    r275 r315  
    1616  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717*/
    18 
    1918#ifndef IMANAGERSFACTORY_H_
    2019#define IMANAGERSFACTORY_H_
    2120
    22 #include <QDir>
    23 #include <QHash>
    24 #include <QList>
    25 #include <QLocale>
    26 #include <QMessageBox>
    27 #include <QNetworkProxy>
    28 #include <QSet>
    29 #include <QString>
    30 
    31 #include "datatypes_global.h"
    32 
    33 #include "sdatatypes.h"
    34 #include "stask.h"
    35 
    36 #include "exceptions/eexception.h"
    37 
    38 class IAccount;
    39 class IAccountManager;
    40 class IAccountInitManager;
    41 class IContactManager;
    42 class IGateway;
    43 class IGatewayManager;
    44 class IGuiManager;
    45 class IGroupManager;
    46 class IManagerFactory;
    47 class ISendingDialog;
    48 class ISettingsManager;
    49 class ISMSSendTask;
    50 
    51 class SContact;
    52 class SDummyAccount;
    53 class SGroup;
    54 class SNumber;
    55 
    56 class DATATYPES_SHARED_EXPORT IManagerFactory {
    57 public:
    58     virtual IAccountManager*     accountManager() const =0;
    59     virtual IAccountInitManager* accountInitManager() const =0;
    60     virtual IContactManager*     contactManager() const =0;
    61     virtual IGatewayManager*     gatewayManager() const =0;
    62     virtual IGroupManager*       groupManager() const =0;
    63     virtual IGuiManager*         guiManager() const =0;
    64     virtual ISettingsManager*    settingsManager() const =0;
    65 
    66 public:
    67     virtual ~IManagerFactory() {}
    68 };
    69 Q_DECLARE_INTERFACE(IManagerFactory, "ch.gorrion.smssender.IManagerFactory/1.0")
    70 
    71 
    72 class DATATYPES_SHARED_EXPORT IAccountManager : public QObject {
    73     Q_OBJECT
    74 
    75 public:
    76     virtual QHash<SDummyAccount*, const EException*> readAccountsFromStorage() =0;
    77 
    78     virtual IAccount*       getAccount(int accountId) =0;
    79     virtual QSet<IAccount*> getAccountList() =0;
    80     virtual void            saveAccount(IAccount* account) =0;
    81     virtual void            removeAccount(int accountId) =0;
    82 
    83 signals:
    84     void accountAdded(IAccount* account);
    85     void accountDataChanged(IAccount* account, int property);
    86     void accountRemoved(IAccount* account);
    87     void accountInitStateChanged(IAccount* account);
    88     void accountLoginStateChanged(IAccount *account);
    89 
    90 public:
    91     IAccountManager(QObject* parent)
    92         : QObject(parent)
    93     {}
    94     virtual ~IAccountManager() {}
    95 };
    96 Q_DECLARE_INTERFACE(IAccountManager, "ch.gorrion.smssender.IAccountManager/1.0")
    97 
    98 
    99 class DATATYPES_SHARED_EXPORT IAccountInitManager : public QObject {
    100     Q_OBJECT
    101 
    102 public:
    103     virtual void initAccount(IAccount* account) =0;
    104     virtual void initAccounts(const QSet<IAccount*>& accounts) =0;
    105 
    106 signals:
    107     void accountInitStateChanged(IAccount* account); // Called when a account gets initialized or un-initialized
    108     void accountInitFinished(IAccount* account, STask::Result result);
    109     void accountInitFailed(IAccount* account, const EException& exception);
    110 
    111 public:
    112     IAccountInitManager(QObject* parent)
    113         : QObject(parent)
    114     {}
    115     virtual ~IAccountInitManager() {}
    116 };
    117 Q_DECLARE_INTERFACE(IAccountInitManager, "ch.gorrion.smssender.IAccountInitManager/1.0")
    118 
    119 
    120 class DATATYPES_SHARED_EXPORT IContactManager : public QObject {
    121     Q_OBJECT
    122 
    123 public:
    124     virtual SContact       getContact(int contactId) const =0;
    125     virtual QSet<SContact> getContactList() const =0;
    126     virtual void           saveContact(SContact& contact) =0;
    127     virtual void           removeContact(int contactId) =0;
    128     virtual bool           hasContact(int contactId) const =0;
    129 
    130     virtual SContact       getContactByNumber(const SNumber& number) const =0;
    131 
    132 signals:
    133     void contactAdded(const SContact& contact);
    134     void contactUpdated(const SContact& contact);
    135     void contactRemoved(const SContact& contact);
    136 
    137 public:
    138     IContactManager(QObject* parent)
    139         : QObject(parent)
    140     {}
    141     virtual ~IContactManager() {}
    142 };
    143 Q_DECLARE_INTERFACE(IContactManager, "ch.gorrion.smssender.IContactManager/1.0")
    144 
    145 
    146 class DATATYPES_SHARED_EXPORT IGatewayManager {
    147 public:
    148     virtual void            loadGatewaysFromLibraryPath(const QDir& libraryPath) =0;
    149 
    150     virtual IGateway*       getGateway(const QString& gatewayName) =0;
    151     virtual QSet<IGateway*> getGatewayList() =0;
    152 
    153 public:
    154     virtual ~IGatewayManager() {}
    155 };
    156 Q_DECLARE_INTERFACE(IGatewayManager, "ch.gorrion.smssender.IGatewayManager/1.0")
    157 
    158 
    159 class DATATYPES_SHARED_EXPORT IGroupManager : public QObject {
    160     Q_OBJECT
    161 
    162 public:
    163     virtual SGroup       getGroup(int groupId) =0;
    164     virtual QSet<SGroup> getGroupList() =0;
    165     virtual void         saveGroup(SGroup& group) =0;
    166     virtual void         removeGroup(int groupId) =0;
    167     virtual bool         hasGroup(int groupId) const =0;
    168 
    169 signals:
    170     void groupAdded(const SGroup& group);
    171     void groupUpdated(const SGroup& group);
    172     void groupRemoved(const SGroup& group);
    173 
    174 public:
    175     IGroupManager(QObject* parent)
    176         : QObject(parent)
    177     {}
    178     virtual ~IGroupManager() {}
    179 };
    180 Q_DECLARE_INTERFACE(IGroupManager, "ch.gorrion.smssender.IGroupManager/1.0")
    181 
    182 
    183 class QMenuBar;
    184 
    185 class DATATYPES_SHARED_EXPORT IGuiManager : public QObject {
    186     Q_OBJECT
    187 
    188 public:
    189     enum Menu {
    190         File,
    191         Edit,
    192         Help
    193     };
    194 
    195 public:
    196     virtual ISendingDialog* createNewSendingDialog(QWidget* parent, ISMSSendTask* smsSendTask) =0;
    197     virtual int             execDialog(IDialogWrapper* dialogWrapper) =0;
    198     virtual int             execDialog(QMessageBox* msgBox) =0;
    199     virtual int             execErrorDialog(const QString& message, const EException& exception) =0;
    200 
    201     virtual void            addMenuAction(IGuiManager::Menu menu, QAction* action) =0;
    202 
    203 signals:
    204     void sendingDialogCreated(ISendingDialog* sendingDialog);
    205 
    206 public:
    207     IGuiManager(QObject* parent)
    208         : QObject(parent)
    209     {}
    210     virtual ~IGuiManager() {}
    211 };
    212 Q_DECLARE_INTERFACE(IGuiManager, "ch.gorrion.smssender.IGuiManager/1.0")
    213 
    214 
    215 class IStorage;
    216 
    217 class DATATYPES_SHARED_EXPORT ISettingsManager : public QObject {
    218     Q_OBJECT
    219 
    220 public:
    221     virtual const QDir     getLocalePath() const =0;
    222     virtual QLocale        getLocale() =0;
    223     virtual QList<QLocale> getLocales() =0;
    224 
    225     virtual bool    getCheckForUpdates() =0;
    226     virtual bool    getAddSuffix() =0;
    227     virtual QString getActiveAccountId() =0;
    228     virtual bool    getShowSentConfirmation() =0;
    229 
    230     virtual bool    isProxyEnabled() =0;
    231     virtual QNetworkProxy::ProxyType getProxyType() =0;
    232     virtual QString getProxyHost() =0;
    233     virtual int     getProxyPort() =0;
    234     virtual bool    isProxyAuthEnabled() =0;
    235     virtual QString getProxyUsername() =0;
    236     virtual QString getProxyPassword() =0;
    237 
    238     virtual QKeySequence getNewMessageShortCut() =0;
    239     virtual QKeySequence getClearMessageTextShortCut() =0;
    240     virtual QKeySequence getClearRecipientsShortCut() =0;
    241     virtual QKeySequence getSendShortCut() =0;
    242 
    243     virtual QString getUpdateUrl() =0;
    244 
    245     virtual QDir getSettingsPath() =0;
    246 
    247 
    248     virtual void setLocale(const QLocale& locale) =0;
    249 
    250     virtual void setCheckForUpdates(bool checkForUpdates) =0;
    251     virtual void setAddSuffix(bool addSuffix) =0;
    252     virtual void setActiveAccountId(const QString& accountId) =0;
    253     virtual void setShowSentConfirmation(bool showSentConfirmation) =0;
    254 
    255     virtual void setProxyEnabled(bool enabled) =0;
    256     virtual void setProxyType(QNetworkProxy::ProxyType type) =0;
    257     virtual void setProxyHost(const QString& host) =0;
    258     virtual void setProxyPort(int port) =0;
    259     virtual void setProxyAuthEnabled(bool enabled) =0;
    260     virtual void setProxyUsername(const QString& username) =0;
    261     virtual void setProxyPassword(const QString& password) =0;
    262 
    263     virtual void setNewMessageShortCut(const QKeySequence& shortcut) =0;
    264     virtual void setClearMessageTextShortCut(const QKeySequence& shortcut) =0;
    265     virtual void setClearRecipientsShortCut(const QKeySequence& shortcut) =0;
    266     virtual void setSendShortCut(const QKeySequence& shortcut) =0;
    267 
    268 public:
    269     virtual IStorage * storage() const =0;
    270 
    271 signals:
    272     void settingChanged(Settings::Setting setting);
    273 
    274 public:
    275     ISettingsManager(QObject* parent)
    276         : QObject(parent)
    277     {}
    278     virtual ~ISettingsManager() {}
    279 };
    280 Q_DECLARE_INTERFACE(ISettingsManager, "ch.gorrion.smssender.ISettingsManager/1.0")
     21// #include <QDir>
     22// #include <QHash>
     23// #include <QList>
     24// #include <QLocale>
     25// #include <QNetworkProxy>
     26// #include <QSet>
     27// #include <QString>
     28//
     29// #include "common/domain/sdatatypes.h"
     30// #include "common/domain/stask.h"
     31// #include "common/exceptions/eexception.h"
     32// #include "common/global.h"
     33//
     34// class IAccount;
     35// class IAccountManager;
     36// class IAccountInitManager;
     37// class IContactManager;
     38// class IGateway;
     39// class IGuiManager;
     40// class IGroupManager;
     41// class ISendingDialog;
     42// class ISettingsManager;
     43// class ISMSSendTask;
     44//
     45// class SContact;
     46// class ErrorAccount;
     47// class SGroup;
     48// class SNumber;
     49//
     50// class COMMON_EXPORT IAccountManager : public QObject {
     51//     Q_OBJECT
     52//
     53// public:
     54//     virtual void readAccountsFromStorage() =0;
     55//
     56//     virtual IAccount*       account(int accountId) const =0;
     57//     virtual QSet<IAccount*> accounts() const =0;
     58//     virtual QSet<IAccount*> erroneousAccounts() const =0;
     59//
     60//     virtual void            saveAccount(IAccount* account) =0;
     61//     virtual void            removeAccount(int accountId) =0;
     62//
     63// signals:
     64//     void accountAdded(IAccount* account);
     65//     void accountDataChanged(IAccount* account, int property);
     66//     void accountRemoved(IAccount* account);
     67//     void accountInitStateChanged(IAccount* account);
     68//     void accountLoginStateChanged(IAccount *account);
     69//
     70// public:
     71//     virtual ~IAccountManager() {}
     72// };
     73// Q_DECLARE_INTERFACE(IAccountManager, "ch.gorrion.smssender.IAccountManager/1.0")
     74//
     75//
     76// class COMMON_EXPORT IAccountInitManager : public QObject {
     77//     Q_OBJECT
     78//
     79// public:
     80//     /**
     81//      * Starts the initialization process of the given account and connects
     82//      * the signals to it.
     83//      * If the account is already initialized, nothing happens.
     84//      * If the account is already initializing, we only connect to the signals, if not already done.
     85//      *
     86//      * @param account The to be initialized account
     87//      */
     88//     virtual void initAccount(IAccount* account) =0;
     89//
     90//     /**
     91//      * Starts the initialization process of the given accounts.
     92//      *
     93//      * @param accounts The to be initialized accounts
     94//      */
     95//     virtual void initAccounts(const QSet<IAccount*> &accounts) =0;
     96//
     97// signals:
     98//     void accountInitStateChanged(IAccount* account); // Called when a account gets initialized or un-initialized
     99//     void accountInitFinished(IAccount* account, STask::Result result);
     100//     void accountInitFailed(IAccount* account, const EException &exception);
     101//
     102// public:
     103//     virtual ~IAccountInitManager() {}
     104// };
     105// Q_DECLARE_INTERFACE(IAccountInitManager, "ch.gorrion.smssender.IAccountInitManager/1.0")
     106//
     107//
     108// class COMMON_EXPORT IContactManager : public QObject {
     109//     Q_OBJECT
     110//
     111// public:
     112//     virtual bool           hasContact(int contactId) const =0;
     113//     virtual SContact       contact(int contactId) const =0;
     114//     virtual SContact       contactByNumber(const SNumber &number) const =0;
     115//     virtual QSet<SContact> contacts() const =0;
     116//
     117//     virtual void           saveContact(SContact &contact) =0;
     118//     virtual void           removeContact(int contactId) =0;
     119//
     120//
     121// signals:
     122//     void contactAdded(const SContact &contact);
     123//     void contactUpdated(const SContact &contact);
     124//     void contactRemoved(const SContact &contact);
     125//
     126// public:
     127//     virtual ~IContactManager() {}
     128// };
     129// Q_DECLARE_INTERFACE(IContactManager, "ch.gorrion.smssender.IContactManager/1.0")
     130//
     131//
     132// template <class Gateway>
     133// class COMMON_EXPORT IGatewayManager {
     134// public:
     135//     virtual Gateway* gateway(const QString &gatewayName) const =0;
     136//     virtual QSet<Gateway*> gateways() const =0;
     137//
     138//     virtual void registerGateway(Gateway *gateway) =0;
     139//
     140// public:
     141//     virtual ~IGatewayManager() {}
     142// };
     143// //Q_DECLARE_INTERFACE(IGatewayManager<G>, "ch.gorrion.smssender.IGatewayManager/1.0")
     144//
     145//
     146// class COMMON_EXPORT IGroupManager : public QObject {
     147//     Q_OBJECT
     148//
     149// public:
     150//     virtual bool         hasGroup(int groupId) const =0;
     151//     virtual SGroup       group(int groupId) const =0;
     152//     virtual QSet<SGroup> groups() const =0;
     153//
     154//     virtual void         saveGroup(SGroup &group) =0;
     155//     virtual void         removeGroup(int groupId) =0;
     156//
     157// signals:
     158//     void groupAdded(const SGroup &group);
     159//     void groupUpdated(const SGroup &group);
     160//     void groupRemoved(const SGroup &group);
     161//
     162// public:
     163//     virtual ~IGroupManager() {}
     164// };
     165// Q_DECLARE_INTERFACE(IGroupManager, "ch.gorrion.smssender.IGroupManager/1.0")
     166//
     167//
     168// /*class QMenu;
     169// class QMenuBar;
     170//
     171// class CORE_SHARED_EXPORT IGuiManager : public QObject {
     172//     Q_OBJECT
     173//
     174// public:
     175//     enum Menu {
     176//         File,
     177//         Edit,
     178//         Help
     179//     };
     180//
     181// public:
     182//     virtual ISendingDialog* createNewSendingDialog(QWidget* parent, ISMSSendTask* smsSendTask) =0;
     183//     virtual int             execDialog(IDialogWrapper* dialogWrapper) =0;
     184//     virtual int             execDialog(QMessageBox* msgBox) =0;
     185//     virtual int             execErrorDialog(const QString &message, const EException &exception) =0;
     186//
     187//     virtual void            addMenuAction(IGuiManager::Menu menu, QAction* action) =0;
     188//
     189//     virtual void            setMainMenu(IGuiManager::Menu menu, QMenu* mainMenu, QAction* actionBefore) =0;
     190//
     191// signals:
     192//     void sendingDialogCreated(ISendingDialog* sendingDialog);
     193//
     194// public:
     195//     virtual ~IGuiManager() {}
     196// };
     197// Q_DECLARE_INTERFACE(IGuiManager, "ch.gorrion.smssender.IGuiManager/1.0")*/
     198//
     199//
     200// class COMMON_EXPORT ISettingsManager : public QObject {
     201//     Q_OBJECT
     202//
     203// public:
     204//     enum Setting {
     205//         Locale,
     206//
     207//         CheckForUpdates,
     208//         AddSuffix,
     209//         SMSSuffix,
     210//         ActiveAccountId,
     211//         ShowSentConfirmation,
     212//
     213//         ProxyEnabled,
     214//         ProxyType,
     215//         ProxyHost,
     216//         ProxyPort,
     217//         ProxyAuthEnabled,
     218//         ProxyUsername,
     219//         ProxyPassword,
     220//
     221//         ShortcutNewMessage,
     222//         ShortcutClearMessageText,
     223//         ShortcutCleanRecipients,
     224//         ShortcutSend
     225//     };
     226//
     227// public:
     228//     virtual const QDir     getLocalePath() const =0;
     229//     virtual QLocale        getLocale() =0;
     230//     virtual QList<QLocale> getLocales() =0;
     231//
     232//     virtual bool    getCheckForUpdates() =0;
     233//     virtual bool    getAddSuffix() =0;
     234//     virtual QString getActiveAccountId() =0;
     235//     virtual bool    getShowSentConfirmation() =0;
     236//
     237//     virtual bool    isProxyEnabled() =0;
     238//     virtual QNetworkProxy::ProxyType getProxyType() =0;
     239//     virtual QString getProxyHost() =0;
     240//     virtual int     getProxyPort() =0;
     241//     virtual bool    isProxyAuthEnabled() =0;
     242//     virtual QString getProxyUsername() =0;
     243//     virtual QString getProxyPassword() =0;
     244//
     245// /*    virtual QKeySequence getNewMessageShortCut() =0;
     246//     virtual QKeySequence getClearMessageTextShortCut() =0;
     247//     virtual QKeySequence getClearRecipientsShortCut() =0;
     248//     virtual QKeySequence getSendShortCut() =0;*/
     249//
     250//     virtual QString getUpdateUrl() =0;
     251//
     252//     virtual QString getSMSSuffix() =0;
     253//
     254//
     255//     virtual void setLocale(const QLocale &locale) =0;
     256//
     257//     virtual void setCheckForUpdates(bool checkForUpdates) =0;
     258//     virtual void setAddSuffix(bool addSuffix) =0;
     259//     virtual void setActiveAccountId(const QString &accountId) =0;
     260//     virtual void setShowSentConfirmation(bool showSentConfirmation) =0;
     261//
     262//     virtual void setProxyEnabled(bool enabled) =0;
     263//     virtual void setProxyType(QNetworkProxy::ProxyType type) =0;
     264//     virtual void setProxyHost(const QString &host) =0;
     265//     virtual void setProxyPort(int port) =0;
     266//     virtual void setProxyAuthEnabled(bool enabled) =0;
     267//     virtual void setProxyUsername(const QString &username) =0;
     268//     virtual void setProxyPassword(const QString &password) =0;
     269//
     270// /*    virtual void setNewMessageShortCut(const QKeySequence &shortcut) =0;
     271//     virtual void setClearMessageTextShortCut(const QKeySequence &shortcut) =0;
     272//     virtual void setClearRecipientsShortCut(const QKeySequence &shortcut) =0;
     273//     virtual void setSendShortCut(const QKeySequence &shortcut) =0;*/
     274//
     275//     virtual void setSMSSuffix(const QString &smsSuffix) =0;
     276//
     277// signals:
     278//     void settingChanged(Setting setting);
     279//
     280// public:
     281//     virtual ~ISettingsManager() {}
     282// };
     283// Q_DECLARE_INTERFACE(ISettingsManager, "ch.gorrion.smssender.ISettingsManager/1.0")
    281284
    282285#endif /* IMANAGERSFACTORY_H_ */
  • common/business/istorable.h

    r218 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #ifndef ISTORABLE_H_
    19 #define ISTORABLE_H_
     18#ifndef COMMON_ISTORABLE_H
     19#define COMMON_ISTORABLE_H
    2020
    21 #include "datatypes_global.h"
     21#include <QSharedPointer>
    2222
    23 class IStorageOfficer;
     23#include "common/global.h"
    2424
    25 class DATATYPES_SHARED_EXPORT IStorable {
     25namespace Persistence {
     26class IMainStorage;
     27class IStorageHelper;
     28}
     29
     30class COMMON_EXPORT IStorable {
    2631public:
    27     virtual IStorageOfficer* getStorageOfficer() const =0;
     32    /**
     33     * Creates a storage helper to load and save this storable object.
     34     * @param storage The storage to write the object into.
     35     *                Does NOT take ownership.
     36     * @return The storage helper.
     37     */
     38    virtual Persistence::IStorageHelper *createStorageHelper(Persistence::IMainStorage *storage) =0;
    2839
    2940public:
     
    3243Q_DECLARE_INTERFACE(IStorable, "ch.gorrion.smssender.IStorable/1.0")
    3344
    34 #endif /* ISTORABLE_H_ */
     45#endif /* COMMON_ISTORABLE_H */
  • common/business/ivalidatable.h

    r218 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #ifndef IVALIDATABLE_H_
    19 #define IVALIDATABLE_H_
     18#ifndef COMMON_IVALIDATABLE_H
     19#define COMMON_IVALIDATABLE_H
    2020
    21 #include "datatypes_global.h"
     21#include "common/global.h"
    2222
    2323class IValidator;
    2424
    25 class DATATYPES_SHARED_EXPORT IValidatable {
     25class COMMON_EXPORT IValidatable {
    2626public:
    27     virtual IValidator* getValidator() const =0;
     27    virtual IValidator* createValidator() const =0;
    2828
    2929public:
     
    3232Q_DECLARE_INTERFACE(IValidatable, "ch.gorrion.smssender.IValidatable/1.0")
    3333
    34 #endif /* IVALIDATABLE_H_ */
     34#endif /* COMMON_IVALIDATABLE_H */
  • common/business/ivalidator.h

    r218 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #ifndef IVALIDATOR_H_
    19 #define IVALIDATOR_H_
     18#ifndef COMMON_IVALIDATOR_H
     19#define COMMON_IVALIDATOR_H
    2020
    2121#include <QObject>
    2222
    23 #include "datatypes_global.h"
     23#include "common/global.h"
    2424
    2525class SValidationResult;
    2626
    27 class DATATYPES_SHARED_EXPORT IValidator : public QObject {
    28     Q_OBJECT
    29 
     27class COMMON_EXPORT IValidator {
    3028public:
    3129    virtual SValidationResult validate() const =0;
    3230
    3331public:
    34     IValidator(QObject* parent)
    35         : QObject(parent)
    36     {}
    3732    virtual ~IValidator() {}
    3833};
    3934Q_DECLARE_INTERFACE(IValidator, "ch.gorrion.smssender.IValidator/1.0")
    4035
    41 #endif /* IVALIDATOR_H_ */
     36#endif /* COMMON_IVALIDATOR_H */
  • common/common-base.pro

    r278 r315  
    1 include(datatypes.inc)
    2 
    3 # Load the global smssender settings
    4 !include($$PWD/../../smssender.pri):!include($$PWD/smssender.pri):error("Could not include smssender.pri")
     1include(../smssender.pri)
    52
    63# The major version of the library which is required to load it.
    74# Increase this, if interfaces in libdatatypes have changed.
    8 DEFINES += LIBDATATYPES_COMPATIBILITY_VERSION=\\\"$${VERSION}\\\"
     5DEFINES += LIB_COMPATIBILITY_VERSION=\\\"$${VERSION}\\\"
    96TEMPLATE = lib
    10 CONFIG += thread \
     7CONFIG += \
    118    exceptions \
    129    rtti \
    13     shared
    14 DESTDIR = ../
     10    staticlib \
     11    thread
     12
     13TARGET = common-base
    1514QMAKE_CLEAN += $$DESTDIR/lib$$TARGET*
    16 TARGET = datatypes
    17 QT += core \
     15QT = core \
    1816    network \
    19     sql \
    20     gui
     17    sql
    2118
    22 DEFINES += DATATYPES_LIBRARY
     19DEFINES += COMMON_LIBRARY
    2320
    24 LIBS += -lcrypto++
     21LIBS += -lcryptopp
    2522
    2623# Input
    27 HEADERS += src/scontact.h \
    28     src/scontact_p.h \
    29     src/sdatatypes.h \
    30     src/datatypes_global.h \
    31     src/sdummyaccount.h \
    32     src/sgroup.h \
    33     src/sgroup_p.h \
    34     src/smacros.h \
    35     src/snetworkhelper.h \
    36     src/snetworkreply.h \
    37     src/snetworkreply_p.h \
    38     src/snumber.h \
    39     src/snumber_p.h \
    40     src/sshared.h \
    41     src/stask.h \
    42     src/stask_p.h \
    43     src/stask_predefined.h \
    44     src/sutils.h \
    45     src/sversion.h \
    46     src/abstract/abstractaccount.h \
    47     src/abstract/abstractaccount_tasks.h \
    48     src/abstract/abstractaccount_utils.h \
    49     src/abstract/abstractgateway.h \
    50     src/abstract/persistence/abstractaccountstorageofficer.h \
    51     src/abstract/persistence/abstractstorageofficer.h \
    52     src/abstract/persistence/versionedstorage.h \
    53     src/exceptions/eexception.h \
    54     src/exceptions/elibraryloadexception.h \
    55     src/exceptions/eloginaccountloginexception.h \
    56     src/exceptions/enetworkexception.h \
    57     src/exceptions/eparseexception.h \
    58     src/exceptions/httpexceptions.h \
    59     src/exceptions/libraryexceptions.h \
    60     src/exceptions/loginaccountexceptions.h \
    61     src/exceptions/stdexceptions.h \
    62     src/exceptions/persistence/estoragereadexception.h \
    63     src/exceptions/persistence/estoragewriteexception.h \
    64     src/exceptions/persistence/storageexceptions.h \
    65     src/interfaces/iaccount.h \
    66     src/interfaces/iaccount_tasks.h \
    67     src/interfaces/icontactimporter.h \
    68     src/interfaces/igateway.h \
    69     src/interfaces/ilibrary.h \
    70     src/interfaces/ilibraryloader.h \
    71     src/interfaces/imanagers.h \
    72     src/interfaces/istorable.h \
    73     src/interfaces/ivalidatable.h \
    74     src/interfaces/ivalidator.h \
    75     src/interfaces/persistence/iaccountlistmanager.h \
    76     src/interfaces/persistence/iaccountstoragemanager.h \
    77     src/interfaces/persistence/icontactstoragemanager.h \
    78     src/interfaces/persistence/igroupstoragemanager.h \
    79     src/interfaces/persistence/isettings.h \
    80     src/interfaces/persistence/istorage.h \
    81     src/interfaces/persistence/istorageofficer.h \
    82     src/interfaces/ui/iaccountsettingswidget.h \
    83     src/interfaces/ui/iclosepreventabledialog.h \
    84     src/interfaces/ui/isendingdialog.h \
    85     src/managers/staskmanager.h \
    86     src/validation/sstdaccountvalidator.h \
    87     src/validation/svalidationresult.h
    88 SOURCES += src/scontact.cpp \
    89     src/sdatatypes.cpp \
    90     src/sdummyaccount.cpp \
    91     src/sgroup.cpp \
    92     src/snetworkhelper.cpp \
    93     src/snetworkhelper_escapechars.cpp \
    94     src/snetworkhelper_params.cpp \
    95     src/snetworkreply.cpp \
    96     src/snumber.cpp \
    97     src/stask.cpp \
    98     src/stask_predefined.cpp \
    99     src/sutils.cpp \
    100     src/sversion.cpp \
    101     src/abstract/abstractaccount.cpp \
    102     src/abstract/abstractaccount_tasks.cpp \
    103     src/abstract/abstractgateway.cpp \
    104     src/abstract/persistence/abstractaccountstorageofficer.cpp \
    105     src/abstract/persistence/abstractstorageofficer.cpp \
    106     src/abstract/persistence/versionedstorage.cpp \
    107     src/exceptions/eexception.cpp \
    108     src/exceptions/enetworkexception.cpp \
    109     src/exceptions/persistence/estoragewriteexception.cpp \
    110     src/exceptions/persistence/estoragereadexception.cpp \
    111     src/exceptions/httpexceptions.cpp \
    112     src/exceptions/eparseexception.cpp \
    113     src/exceptions/eloginaccountloginexception.cpp \
    114     src/exceptions/elibraryloadexception.cpp \
    115     src/interfaces/iaccount.cpp \
    116     src/interfaces/iaccount_tasks.cpp \
    117     src/interfaces/icontactimporter.cpp \
    118     src/interfaces/ilibrary.cpp \
    119     src/interfaces/persistence/iaccountlistmanager.cpp \
    120     src/interfaces/persistence/istorage.cpp \
    121     src/interfaces/persistence/istorageofficer.cpp \
    122     src/interfaces/ui/iclosepreventabledialog.cpp \
    123     src/interfaces/ui/isendingdialog.cpp \
    124     src/managers/staskmanager.cpp \
    125     src/validation/sstdaccountvalidator.cpp \
    126     src/validation/svalidationresult.cpp
    127 RESOURCES = lib/datatypes.qrc
    128 unix {
     24HEADERS += \
     25    domain/sdatatypes.h \
     26    domain/sgroup.h \
     27    utils/smacros.h \
     28    network/snetworkhelper.h \
     29    network/snetworkreply.h \
     30    network/snetworkreply_p.h \
     31    domain/snumber.h \
     32    domain/snumber_p.h \
     33    utils/sshared.h \
     34    domain/stask.h \
     35    domain/stask_p.h \
     36    utils/sutils.h \
     37    domain/sversion.h \
     38    exceptions/eexception.h \
     39    exceptions/elibraryloadexception.h \
     40    exceptions/eloginaccountloginexception.h \
     41    exceptions/enetworkexception.h \
     42    exceptions/eparseexception.h \
     43    exceptions/httpexceptions.h \
     44    exceptions/libraryexceptions.h \
     45    exceptions/loginaccountexceptions.h \
     46    exceptions/stdexceptions.h \
     47    exceptions/persistence/estoragereadexception.h \
     48    exceptions/persistence/estoragewriteexception.h \
     49    exceptions/persistence/storageexceptions.h \
     50    business/iaccount_tasks.h \
     51    business/ilibrary.h \
     52    business/imanagers.h \
     53    business/istorable.h \
     54    business/ivalidatable.h \
     55    business/ivalidator.h \
     56    utils/staskmanager.h \
     57    validation/svalidationresult.h \
     58    persistence/istoragehelper.h \
     59    persistence/igroupmanager.h \
     60    persistence/iaccountmanager.h \
     61    persistence/icontactmanager.h \
     62    persistence/impl/versionedstorage.h \
     63    validation/defaultaccountvalidator.h \
     64    persistence/idatabase.h \
     65    global.h \
     66    business/iaccount.h \
     67    business/igateway_base.h \
     68    business/igateway.h \
     69    domain/scontact.h \
     70    business/icontactimporter_base.h \
     71    business/icontactimporter.h \
     72    business/iintegration_base.h \
     73    business/iintegration.h \
     74    persistence/imainstorage_base.h \
     75    persistence/imainstorage.h \
     76    persistence/impl/encryptedstoragehelper_base.h \
     77    persistence/impl/encryptedstoragehelper.h \
     78    persistence/impl/storageconnectionhelper.h \
     79    persistence/impl/storageconnectionhelper_p.h
     80SOURCES += domain/scontact.cpp \
     81    domain/sdatatypes.cpp \
     82    domain/sgroup.cpp \
     83    network/snetworkhelper.cpp \
     84    network/snetworkhelper_escapechars.cpp \
     85    network/snetworkhelper_params.cpp \
     86    network/snetworkreply.cpp \
     87    domain/snumber.cpp \
     88    domain/stask.cpp \
     89    utils/sutils.cpp \
     90    domain/sversion.cpp \
     91    exceptions/eexception.cpp \
     92    exceptions/enetworkexception.cpp \
     93    exceptions/persistence/estoragewriteexception.cpp \
     94    exceptions/persistence/estoragereadexception.cpp \
     95    exceptions/httpexceptions.cpp \
     96    exceptions/eparseexception.cpp \
     97    exceptions/eloginaccountloginexception.cpp \
     98    exceptions/elibraryloadexception.cpp \
     99    business/iaccount.cpp \
     100    business/iaccount_tasks.cpp \
     101    business/ilibrary.cpp \
     102    utils/staskmanager.cpp \
     103    validation/svalidationresult.cpp \
     104    persistence/iaccountmanager.cpp \
     105    persistence/icontactmanager.cpp \
     106    persistence/igroupmanager.cpp \
     107    persistence/impl/versionedstorage.cpp \
     108    validation/defaultaccountvalidator.cpp \
     109    persistence/impl/encryptedstoragehelper_base.cpp \
     110    persistence/impl/storageconnectionhelper.cpp
     111RESOURCES += \
     112    lib/common.qrc
     113unix {
    129114    target.path = /usr/lib/smssender
    130115    INSTALLS += target
    131    
     116
    132117    # headers
    133118    headers.path = /usr/include/smssender
    134     headers.files = $$HEADERS \
    135         datatypes.inc
     119    headers.files = $$HEADERS
    136120}
  • common/domain/scontact.cpp

    r217 r315  
    1717 */
    1818#include "scontact.h"
    19 #include "scontact_p.h"
    2019
    21 #include "smacros.h"
    22 
    23 S_SHARED_IMPL(SContact)
    24 S_QHASH_IMPL(SContact)
    25 
     20SContact::SContact() {
     21}
    2622SContact::~SContact() {
    2723}
    2824
    2925int SContact::id() const {
    30     return d->id;
     26    return m_id;
    3127}
    3228QString SContact::name() const {
    33     return d->name;
     29    return m_name;
    3430}
    3531SNumber SContact::number() const {
    36     return d->number;
     32    return m_number;
    3733}
    3834QStringList SContact::aliases() const {
    39     return d->aliases;
    40 }
    41 QImage SContact::image() const {
    42     return d->image;
     35    return m_aliases;
    4336}
    4437
    4538void SContact::setId(int id) {
    46     int oldId = d->id;
    47     SET_IF_DIFFERENT(d->id, id);
     39    int oldId = m_id;
     40    SET_IF_DIFFERENT(m_id, id);
    4841
    49     emit d->idChanged(*this, oldId);
    50     emit d->dataChanged(*this);
     42    emit idChanged(this, oldId);
     43    emit dataChanged(this);
    5144}
    5245void SContact::setName(const QString& name) {
    53     SET_IF_DIFFERENT(d->name, name.trimmed());
    54     d->aliases.removeAll(d->name);
    55     emit d->dataChanged(*this);
     46    SET_IF_DIFFERENT(m_name, name.trimmed());
     47    m_aliases.removeAll(m_name);
     48    emit dataChanged(this);
    5649}
    5750void SContact::setNumber(const SNumber& number) {
    58     SET_IF_DIFFERENT(d->number, number);
    59     emit d->dataChanged(*this);
     51    SET_IF_DIFFERENT(m_number, number);
     52    emit dataChanged(this);
    6053}
    6154void SContact::setAliases(const QStringList& aliases) {
    62     SET_IF_DIFFERENT(d->aliases, aliases);
    63     d->aliases.removeDuplicates();
    64     d->aliases.removeAll(name());
    65     emit d->dataChanged(*this);
     55    SET_IF_DIFFERENT(m_aliases, aliases);
     56    m_aliases.removeDuplicates();
     57    m_aliases.removeAll(name());
     58    emit dataChanged(this);
     59}
     60
     61#ifdef FRONTEND_GUI
     62QImage SContact::image() const {
     63    return m_image;
    6664}
    6765void SContact::setImage(const QImage& image) {
    68     SET_IF_DIFFERENT(d->image, image);
    69     if (!d->image.isNull()) {
    70         d->image = d->image.scaledToWidth(50, Qt::SmoothTransformation);
     66    SET_IF_DIFFERENT(m_image, image);
     67    if (!m_image.isNull()) {
     68        m_image = m_image.scaledToWidth(50, Qt::SmoothTransformation);
    7169    }
    72     emit d->dataChanged(*this);
     70    emit dataChanged(this);
    7371}
    74 
    75 SContact SContact::clone() const {
    76     SContact newC(*this);
    77     newC.d.detach();
    78     return newC;
    79 }
     72#endif
  • common/domain/scontact.h

    r236 r315  
    2020
    2121#include <QMetaType>
    22 #include <QImage>
    2322#include <QStringList>
    2423
    25 #include "datatypes_global.h"
     24#ifdef FRONTEND_GUI
     25#include <QtGui/QImage>
     26#endif
    2627
    27 #include "smacros.h"
    28 #include "sshared.h"
     28#include "common/domain/snumber.h"
     29#include "common/global.h"
    2930
    30 class SContactData;
    31 class SNumber;
    32 
    33 class DATATYPES_SHARED_EXPORT SContact {
    34     S_SHARED(SContact, public)
    35     S_QHASH_FRIEND(SContact)
    36 
    37     friend class IStorage; // setId
     31class COMMON_EXPORT SContact : public QObject {
     32    Q_OBJECT
    3833
    3934public:
     35    SContact();
    4036    ~SContact();
    4137
    42 public:
    43     int         id() const;
    44     QString     name() const;
    45     SNumber     number() const;
     38    int id() const;
     39    QString name() const;
     40    SNumber number() const;
    4641    QStringList aliases() const;
    47     QImage      image() const;
    4842
    49     void        setName(const QString& name);
    50     void        setNumber(const SNumber& number);
    51     void        setAliases(const QStringList& aliases);
    52     void        setImage(const QImage& image);
     43    void setId(int id);
     44    void setName(const QString& name);
     45    void setNumber(const SNumber& number);
     46    void setAliases(const QStringList& aliases);
    5347
    54     SContact    clone() const;
     48#ifdef FRONTEND_GUI
     49    QImage image() const;
     50    void setImage(const QImage& image);
     51#endif
    5552
    56 protected:
    57     void        setId(int id);
     53signals:
     54    void idChanged(SContact *contact, int oldId);
     55    void dataChanged(SContact *contact);
     56
     57private:
     58    int m_id;
     59    QString m_name;
     60    SNumber m_number;
     61    QStringList m_aliases;
     62
     63#ifdef FRONTEND_GUI
     64    QImage m_image;
     65#endif
     66
     67    Q_DISABLE_COPY(SContact)
    5868};
    59 Q_DECLARE_METATYPE(SContact)
    60 DATATYPES_SHARED_EXPORT S_QHASH(SContact)
    6169
    6270#endif /* SCONTACT_H_ */
  • common/domain/sdatatypes.h

    r218 r315  
    2121#include <QObject>
    2222
    23 #include "datatypes_global.h"
     23#include "common/global.h"
    2424
    25 namespace Account {
    26     class DATATYPES_SHARED_EXPORT Action {
    27     public:
    28         static const QString Sleeping;
     25class COMMON_EXPORT Action {
     26public:
     27    static const QString Sleeping;
    2928
    30         static const QString Initializing;
    31         static const QString CancellingInitialization;
     29    static const QString Initializing;
     30    static const QString CancellingInitialization;
    3231
    33         static const QString AddingRecipients;
    34         static const QString RemovingRecipients;
    35         static const QString SendingSMS;
    36         static const QString CancellingSendingSMS;
    37     };
     32    static const QString AddingRecipients;
     33    static const QString RemovingRecipients;
     34    static const QString SendingSMS;
     35    static const QString CancellingSendingSMS;
     36};
    3837
    39     namespace Initialization {
    40         enum State {
    41             isUninitialized = 0x00,
    42             isInitializing  = 0x01,
    43             isInitialized   = 0x02,
    44             isCancelling    = 0x03,
     38namespace Initialization {
     39enum State {
     40    isUninitialized = 0x00,
     41    isInitializing  = 0x01,
     42    isInitialized   = 0x02,
     43    isCancelling    = 0x03,
    4544
    46             lastStateId     = isCancelling
    47         };
    48     }
    49 
    50     enum SendingResult {
    51         srSuccess,
    52         srError,
    53         srCancelled
    54     };
     45    lastStateId     = isCancelling
     46};
    5547}
    5648
    57 namespace Settings {
    58     enum Setting {
    59         Locale,
     49enum SendingResult {
     50    srSuccess,
     51    srError,
     52    srCancelled
     53};
    6054
    61         CheckForUpdates,
    62         AddSuffix,
    63         SMSSuffix,
    64         ActiveAccountId,
    65         ShowSentConfirmation,
    66 
    67         ProxyEnabled,
    68         ProxyType,
    69         ProxyHost,
    70         ProxyPort,
    71         ProxyAuthEnabled,
    72         ProxyUsername,
    73         ProxyPassword,
    74 
    75         ShortcutNewMessage,
    76         ShortcutClearMessageText,
    77         ShortcutCleanRecipients,
    78         ShortcutSend
    79     };
    80 }
    81 
    82 
    83 class DATATYPES_SHARED_EXPORT IDialogWrapper : public QObject {
     55class COMMON_EXPORT IDialogWrapper : public QObject {
    8456    Q_OBJECT
    8557
  • common/domain/sgroup.cpp

    r217 r315  
    1717 */
    1818#include "sgroup.h"
    19 #include "sgroup_p.h"
    2019
    21 #include "scontact.h"
    22 #include "smacros.h"
     20#include "domain/scontact.h"
    2321
    24 S_SHARED_IMPL(SGroup)
    25 S_QHASH_IMPL(SGroup)
    26 
     22SGroup::SGroup() {
     23}
    2724SGroup::~SGroup() {
    2825}
    2926
    3027int SGroup::id() const{
    31     return d->id;
     28    return m_id;
    3229}
    3330QString SGroup::name() const{
    34     return d->name;
     31    return m_name;
    3532}
    36 QImage SGroup::image() const{
    37     return d->image;
    38 }
    39 QSet<SContact> SGroup::contacts() const{
    40     return d->contactList;
     33QSet<const SContact*> SGroup::contacts() const{
     34    return m_contactList;
    4135}
    4236
    4337
    4438void SGroup::setId(int id){
    45     int oldId = d->id;
    46     SET_IF_DIFFERENT(d->id, id);
     39    int oldId = m_id;
     40    SET_IF_DIFFERENT(m_id, id);
    4741
    48     emit d->idChanged(*this, oldId);
    49     emit d->dataChanged(*this);
     42    emit idChanged(this, oldId);
     43    emit dataChanged(this);
    5044}
    5145void SGroup::setName(const QString& name){
    52     SET_IF_DIFFERENT(d->name, name.trimmed());
    53     emit d->dataChanged(*this);
     46    SET_IF_DIFFERENT(m_name, name.trimmed());
     47    emit dataChanged(this);
     48}
     49
     50#ifdef FRONTEND_GUI
     51QImage SGroup::image() const{
     52    return m_image;
    5453}
    5554void SGroup::setImage(const QImage& image){
    56     SET_IF_DIFFERENT(d->image, image);
    57     if (!d->image.isNull()) {
    58         d->image = d->image.scaledToWidth(50, Qt::SmoothTransformation);
     55    SET_IF_DIFFERENT(m_image, image);
     56    if (!m_image.isNull()) {
     57        m_image = m_image.scaledToWidth(50, Qt::SmoothTransformation);
    5958    }
    60     emit d->dataChanged(*this);
     59    emit dataChanged(this);
    6160}
    62 void SGroup::setContacts(const QSet<SContact>& contacts){
    63     foreach (SContact contact, d->contactList) {
     61#endif
     62
     63
     64void SGroup::setContacts(const QSet<const SContact *> &contacts){
     65    foreach (const SContact *contact, m_contactList) {
    6466        removeContactFromList(contact);
    6567    }
    66     foreach (SContact contact, contacts) {
     68    foreach (const SContact *contact, contacts) {
    6769        addContactToList(contact);
    6870    }
    6971}
    7072void SGroup::addContact(const SContact& contact){
    71     addContactToList(contact);
     73    addContactToList(&contact);
    7274}
    7375void SGroup::removeContact(const SContact& contact){
    74     removeContactFromList(contact);
     76    removeContactFromList(&contact);
    7577}
    7678
    7779
    78 void SGroup::addContactToList(const SContact& contact) {
    79     if (d->contactList.contains(contact)) {
     80void SGroup::addContactToList(const SContact* contact) {
     81    if (m_contactList.contains(contact)) {
    8082        return;
    8183    }
    8284
    83     d->contactList.insert(contact);
    84     emit d->contactAdded(*this, contact);
     85    m_contactList.insert(contact);
     86    emit contactAdded(this, *contact);
    8587}
    86 void SGroup::removeContactFromList(const SContact& contact) {
    87     if (!d->contactList.contains(contact)) {
    88         return;
     88void SGroup::removeContactFromList(const SContact* contact) {
     89    if (m_contactList.remove(contact)) {
     90        emit contactRemoved(this, *contact);
    8991    }
    90 
    91     d->contactList.remove(contact);
    92     emit d->contactRemoved(*this, contact);
    9392}
  • common/domain/sgroup.h

    r236 r315  
    1919#define SGROUP_H_
    2020
    21 #include <QMetaType>
    22 #include <QImage>
    2321#include <QSet>
    2422#include <QString>
    2523
    26 #include "datatypes_global.h"
     24#ifdef FRONTEND_GUI
     25#include <QtGui/QImage>
     26#endif
    2727
    28 #include "smacros.h"
    29 #include "sshared.h"
     28#include "common/global.h"
    3029
    3130class SContact;
    32 class SGroupData;
    3331
    34 class DATATYPES_SHARED_EXPORT SGroup {
    35     S_SHARED(SGroup, public)
    36     S_QHASH_FRIEND(SGroup)
    37 
    38     friend class IStorage; // setId
     32class COMMON_EXPORT SGroup : public QObject {
     33    Q_OBJECT
    3934
    4035public:
     36    SGroup();
    4137    ~SGroup();
    4238
    4339public:
    44     int            id() const;
    45     QString        name() const;
    46     QImage         image() const;
    47     QSet<SContact> contacts() const;
     40    int id() const;
     41    QString name() const;
     42    QSet<const SContact *> contacts() const;
    4843
    49     void           setName(const QString& name);
    50     void           setImage(const QImage& image);
    51     void           setContacts(const QSet<SContact>& contacts);
     44    void setId(int id);
     45    void setName(const QString& name);
     46    void setContacts(const QSet<const SContact *> &contacts);
    5247
    53     void           addContact(const SContact& contact);
    54     void           removeContact(const SContact& contact);
     48#ifdef FRONTEND_GUI
     49    QImage image() const;
     50    void setImage(const QImage& image);
     51#endif
    5552
    56 protected:
    57     void           setId(int id);
     53    // Does NOT take ownership.
     54    void addContact(const SContact& contact);
     55    void removeContact(const SContact& contact);
     56
     57signals:
     58    void idChanged(SGroup *group, int oldId);
     59    void dataChanged(SGroup *group);
     60    void contactAdded(SGroup *group, const SContact& contact);
     61    void contactRemoved(SGroup *group, const SContact& contact);
    5862
    5963private:
    60     void           addContactToList(const SContact& contact);
    61     void           removeContactFromList(const SContact& contact);
     64    void addContactToList(const SContact *contact);
     65    void removeContactFromList(const SContact *contact);
     66
     67    int m_id;
     68    QString m_name;
     69    QSet<const SContact*> m_contactList;
     70
     71#ifdef FRONTEND_GUI
     72    QImage m_image;
     73#endif
     74
     75    Q_DISABLE_COPY(SGroup)
    6276};
    63 Q_DECLARE_METATYPE(SGroup)
    64 DATATYPES_SHARED_EXPORT S_QHASH(SGroup)
    6577
    6678#endif /* SGROUP_H_ */
  • common/domain/snumber.cpp

    r217 r315  
    2222#include <QStringList>
    2323
    24 #include "smacros.h"
     24#include "utils/smacros.h"
    2525
    2626S_SHARED_IMPL_WITHOUT_EQUALS(SNumber)
  • common/domain/snumber.h

    r236 r315  
    2222#include <QString>
    2323
    24 #include "datatypes_global.h"
    25 
    26 #include "sdatatypes.h"
    27 #include "smacros.h"
    28 #include "sshared.h"
     24#include "common/domain/sdatatypes.h"
     25#include "common/global.h"
     26#include "common/utils/smacros.h"
     27#include "common/utils/sshared.h"
    2928
    3029class SNumberData;
    3130
    32 class DATATYPES_SHARED_EXPORT SNumber {
     31class COMMON_EXPORT SNumber {
    3332    S_SHARED(SNumber, public)
    3433    S_QHASH_FRIEND(SNumber)
     
    6665};
    6766Q_DECLARE_METATYPE(SNumber)
    68 DATATYPES_SHARED_EXPORT S_QHASH(SNumber)
     67COMMON_EXPORT S_QHASH(SNumber)
    6968
    7069#endif /* SNUMBER_H_ */
  • common/domain/snumber_p.h

    r217 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717*/
    18 
    1918#ifndef SNUMBER_P_H_
    2019#define SNUMBER_P_H_
     
    2221#include <QString>
    2322
    24 #include "sshared.h"
     23#include "common/utils/sshared.h"
    2524
    2625class SNumberData : public SShareable {
  • common/domain/stask.cpp

    r242 r315  
    2020#include "stask_p.h"
    2121
    22 #include <QApplication>
     22#include <QCoreApplication>
    2323#include <QDebug>
    2424#include <QMetaType>
     
    2626#include <QTimer>
    2727
    28 #include "smacros.h"
    29 #include "managers/staskmanager.h"
     28#include "utils/smacros.h"
     29#include "utils/staskmanager.h"
    3030
    3131STask::STask(uint UID, const QString& nmespace)
     
    233233         *   o) you have forgotten to add the "-shared-libgcc" compiler flag
    234234         *   o) the exception (or one of its parents) has implementation data in its header file
    235          *   o) you have forgotten to add DATATYPES_SHARED_EXPORT in the class definition of the exception
     235         *   o) you have forgotten to add CORE_SHARED_EXPORT in the class definition of the exception
    236236         * (These points hold only, if the implementation of the task lies in a shared library)
    237237         */
  • common/domain/stask.h

    r240 r315  
    2727#include <QWaitCondition>
    2828
    29 #include "datatypes_global.h"
    30 
    31 #include "exceptions/eexception.h"
     29#include "common/exceptions/eexception.h"
     30#include "common/global.h"
    3231
    3332typedef struct {
     
    3837inline bool operator<(const SUIdNamespaceIdent& a, const SUIdNamespaceIdent& b) { return (a.nmespace + QString::number(a.uid)) < (b.nmespace + QString::number(b.uid)); }
    3938
    40 class DATATYPES_SHARED_EXPORT STask : public QObject {
     39class COMMON_EXPORT STask : public QObject {
    4140    Q_OBJECT
    4241
     
    202201
    203202
    204 class DATATYPES_SHARED_EXPORT SThreadedTask : public STask {
     203class COMMON_EXPORT SThreadedTask : public STask {
    205204    Q_OBJECT
    206205
     
    220219
    221220
    222 class DATATYPES_SHARED_EXPORT SAsynchroneousTask : public STask {
     221class COMMON_EXPORT SAsynchroneousTask : public STask {
    223222    Q_OBJECT
    224223
     
    236235 * Exception which gets thrown when calling SThread::haltIfCancelRequested().
    237236 */
    238 class DATATYPES_SHARED_EXPORT EAbortException : public EException {
     237class COMMON_EXPORT EAbortException : public EException {
    239238public:
    240239    EAbortException();
  • common/domain/stask_p.h

    r220 r315  
    2424#include <QMutex>
    2525
    26 #include "exceptions/eexception.h"
    27 #include "smacros.h"
    28 
    29 #include "stask.h"
     26#include "common/domain/stask.h"
     27#include "common/exceptions/eexception.h"
     28#include "common/utils/smacros.h"
    3029
    3130class SRessourceMutex : public QObject {
  • common/domain/sversion.h

    r256 r315  
    2121#include <QString>
    2222
    23 #include "datatypes_global.h"
     23#include "common/global.h"
    2424
    25 class DATATYPES_SHARED_EXPORT SVersion {
     25class COMMON_EXPORT SVersion {
    2626public:
    2727    enum DevelopmentStage {
  • common/exceptions/eexception.h

    r220 r315  
    2626#include <QStringList>
    2727
    28 #include "datatypes_global.h"
     28#include "common/global.h"
    2929
    30 class DATATYPES_SHARED_EXPORT EException /*: public std::runtime_error */ {
     30class COMMON_EXPORT EException /*: public std::runtime_error */ {
    3131public:
    3232    EException();
  • common/exceptions/elibraryloadexception.h

    r220 r315  
    2121#include <QString>
    2222
    23 #include "eexception.h"
     23#include "common/exceptions/eexception.h"
    2424
    2525namespace Library {
    2626
    27 class DATATYPES_SHARED_EXPORT ELoadException : public EException {
     27class COMMON_EXPORT ELoadException : public EException {
    2828public:
    2929    enum Purpose {
  • common/exceptions/eloginaccountloginexception.h

    r220 r315  
    2121#include <QString>
    2222
    23 #include "eexception.h"
     23#include "common/exceptions/eexception.h"
    2424
    2525namespace LoginAccount {
    2626
    27 class DATATYPES_SHARED_EXPORT ELoginException : public EException {
     27class COMMON_EXPORT ELoginException : public EException {
    2828public:
    2929    enum Purpose {
  • common/exceptions/enetworkexception.h

    r220 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 
    1918#ifndef ENETWORKEXCEPTION_H_
    2019#define ENETWORKEXCEPTION_H_
    2120
    22 
    23 #include "eexception.h"
    24 
    2521#include <QNetworkReply>
    2622
    27 class DATATYPES_SHARED_EXPORT ENetworkException : public EException {
     23#include "common/exceptions/eexception.h"
     24
     25class COMMON_EXPORT ENetworkException : public EException {
    2826public:
    2927    ENetworkException(QNetworkReply::NetworkError networkError, const QString& message);
  • common/exceptions/eparseexception.h

    r220 r315  
    1919#define EPARSEEXCEPTION_H_
    2020
    21 #include "eexception.h"
     21#include "common/exceptions/eexception.h"
    2222
    23 class DATATYPES_SHARED_EXPORT EParseException : public EException {
     23class COMMON_EXPORT EParseException : public EException {
    2424public:
    2525    explicit EParseException(const QString& msg);
  • common/exceptions/httpexceptions.h

    r220 r315  
    2525
    2626namespace Http {
    27     class DATATYPES_SHARED_EXPORT EReadException : public EException {
     27    class COMMON_EXPORT EReadException : public EException {
    2828    public:
    2929        explicit EReadException(const QString& msg);
     
    3636    };
    3737
    38     class DATATYPES_SHARED_EXPORT ESSLException : public EException {
     38    class COMMON_EXPORT ESSLException : public EException {
    3939    public:
    4040        explicit ESSLException(const QList<QSslError>& errors);
  • common/exceptions/libraryexceptions.h

    r194 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #include "elibraryloadexception.h"
     18#include "common/exceptions/elibraryloadexception.h"
  • common/exceptions/loginaccountexceptions.h

    r194 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #include "eloginaccountloginexception.h"
     18#include "common/exceptions/eloginaccountloginexception.h"
  • common/exceptions/persistence/estoragereadexception.h

    r220 r315  
    2121#include <QString>
    2222
    23 #include "exceptions/stdexceptions.h"
     23#include "common/exceptions/stdexceptions.h"
    2424
    2525namespace Storage {
    26     class DATATYPES_SHARED_EXPORT EReadException : public EException {
     26    class COMMON_EXPORT EReadException : public EException {
    2727    public:
    2828        explicit EReadException(const QString& msg);
  • common/exceptions/persistence/estoragewriteexception.h

    r220 r315  
    2121#include <QString>
    2222
    23 #include "exceptions/stdexceptions.h"
     23#include "common/exceptions/stdexceptions.h"
    2424
    2525namespace Storage {
    26     class DATATYPES_SHARED_EXPORT EWriteException : public EException {
     26    class COMMON_EXPORT EWriteException : public EException {
    2727    public:
    2828        explicit EWriteException(const QString& msg);
  • common/exceptions/persistence/storageexceptions.h

    r194 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #include "estoragereadexception.h"
    19 #include "estoragewriteexception.h"
     18#include "common/exceptions/persistence/estoragereadexception.h"
     19#include "common/exceptions/persistence/estoragewriteexception.h"
  • common/exceptions/stdexceptions.h

    r194 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #include "eexception.h"
    19 #include "eparseexception.h"
     18#include "common/exceptions/eexception.h"
     19#include "common/exceptions/eparseexception.h"
  • common/global.h

    r218 r315  
    1 #ifndef DATATYPES_GLOBAL_H
    2 #define DATATYPES_GLOBAL_H
     1/*
     2 smssender - A frontend for fast and easy SMS sending over different gateways.
     3 Copyright (C) 2007-2012, gorrión. See http://smssender.gorrion.ch
     4
     5 This program is free software: you can redistribute it and/or modify
     6 it under the terms of the GNU General Public License as published by
     7 the Free Software Foundation, either version 3 of the License, or
     8 (at your option) any later version.
     9
     10 This program is distributed in the hope that it will be useful,
     11 but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 GNU General Public License for more details.
     14
     15 You should have received a copy of the GNU General Public License
     16 along with this program.  If not, see <http://www.gnu.org/licenses/>.
     17 */
     18#ifndef COMMON_GLOBAL_H
     19#define COMMON_GLOBAL_H
    320
    421#include <QtCore/qglobal.h>
    522
    6 #if defined(DATATYPES_LIBRARY)
    7 #  define DATATYPES_SHARED_EXPORT Q_DECL_EXPORT
     23#if defined(COMMON_LIBRARY)
     24#  define COMMON_EXPORT
     25//#  define COMMON_EXPORT Q_DECL_EXPORT
    826#else
    9 #  define DATATYPES_SHARED_EXPORT Q_DECL_IMPORT
     27#  define COMMON_EXPORT
     28//#  define COMMON_EXPORT Q_DECL_IMPORT
    1029#endif
    1130
    12 
    13 #endif // DATATYPES_GLOBAL_H
     31#endif // COMMON_GLOBAL_H
  • common/gui/ui/iaccountsettingswidget.h

    r218 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #ifndef IACCOUNTSETTINGSWIDGET_H_
    19 #define IACCOUNTSETTINGSWIDGET_H_
     18#ifndef COMMON_GUI_IACCOUNTSETTINGSWIDGET_H_
     19#define COMMON_GUI_IACCOUNTSETTINGSWIDGET_H_
    2020
    21 #include <QWidget>
     21#include <QtGui/QWidget>
    2222
    23 #include "datatypes_global.h"
     23#include "common/gui/global.h"
    2424
    2525class IAccount;
    2626
    27 class DATATYPES_SHARED_EXPORT IAccountSettingsWidget: public QWidget {
     27class COMMON_GUI_EXPORT IAccountSettingsWidget : public QWidget {
    2828    Q_OBJECT
    2929
     
    4040Q_DECLARE_INTERFACE(IAccountSettingsWidget, "ch.gorrion.smssender.IAccountSettingsWidget/1.0")
    4141
    42 #endif /* IACCOUNTSETTINGSWIDGET_H_ */
     42#endif /* COMMON_GUI_IACCOUNTSETTINGSWIDGET_H_ */
  • common/gui/ui/iclosepreventabledialog.cpp

    r218 r315  
    1616  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717*/
    18 
    1918#include "iclosepreventabledialog.h"
    2019
     
    2322IClosePreventableDialog::IClosePreventableDialog(QWidget* parent)
    2423    : QDialog(parent)
    25     , preventCount_(0)
     24    , m_preventCount(0)
    2625{
    2726}
    2827
    2928void IClosePreventableDialog::preventClose() {
    30     preventCount_++;
     29    ++m_preventCount;
    3130}
    3231void IClosePreventableDialog::allowClose() {
    33     if (preventCount_ == 0)
     32    if (m_preventCount == 0) {
     33        if (m_closeRequested) {
     34            QDialog::done(m_closeResult);
     35        }
    3436        return;
     37    }
    3538
    36     preventCount_--;
     39    --m_preventCount;
    3740}
    3841
    39 void IClosePreventableDialog::done(int r) {
    40     if (preventCount_ > 0) {
    41         emit closeRequested(r);
     42void IClosePreventableDialog::done(int closeResult) {
     43    if (m_preventCount > 0) {
     44        m_closeRequested = true;
     45        m_closeResult = closeResult;
     46
     47        emit closeRequested(closeResult);
    4248    } else {
    43         QDialog::done(r);
     49        QDialog::done(closeResult);
    4450    }
    4551}
  • common/gui/ui/iclosepreventabledialog.h

    r218 r315  
    1616  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717*/
     18#ifndef COMMON_GUI_ICLOSEPREVENTABLEDIALOG_H
     19#define COMMON_GUI_ICLOSEPREVENTABLEDIALOG_H
    1820
    19 #ifndef IDIALOG_H_
    20 #define IDIALOG_H_
     21#include <QtGui/QDialog>
     22#include <QtGui/QWidget>
    2123
    22 #include <QDialog>
     24#include "common/gui/global.h"
    2325
    24 #include "datatypes_global.h"
    25 
    26 class DATATYPES_SHARED_EXPORT IClosePreventableDialog : public QDialog {
     26class COMMON_GUI_EXPORT IClosePreventableDialog : public QDialog {
    2727    Q_OBJECT
    2828
     
    3232
    3333public: /* QDialog */
    34     void done(int r);
     34    void done(int closeResult);
    3535
    3636signals:
     
    4242
    4343private:
    44     unsigned int preventCount_;
     44    unsigned int m_preventCount;
     45    bool m_closeRequested;
     46    int m_closeResult;
    4547};
    4648Q_DECLARE_INTERFACE(IClosePreventableDialog, "ch.gorrion.smssender.IClosePreventableDialog/1.0")
    4749
    4850
    49 #endif /* IDIALOG_H_ */
     51#endif /* COMMON_GUI_ICLOSEPREVENTABLEDIALOG_H */
  • common/gui/ui/isendingdialog.cpp

    r218 r315  
    1616  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717*/
    18 
    1918#include "isendingdialog.h"
    2019
  • common/gui/ui/isendingdialog.h

    r218 r315  
    1616  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717*/
     18#ifndef COMMON_GUI_ISENDINGDIALOG_H
     19#define COMMON_GUI_ISENDINGDIALOG_H
    1820
    19 #ifndef ISENDINGDIALOG_H_
    20 #define ISENDINGDIALOG_H_
     21#include <QtGui/QWidget>
    2122
    22 #include "iclosepreventabledialog.h"
     23#include "common/gui/global.h"
     24#include "common/gui/ui/iclosepreventabledialog.h"
    2325
     26class IAccount;
    2427class ISMSSendTask;
    2528
    26 class DATATYPES_SHARED_EXPORT ISendingDialog: public IClosePreventableDialog {
     29class COMMON_GUI_EXPORT ISendingDialog: public IClosePreventableDialog {
    2730    Q_OBJECT
    2831    Q_INTERFACES(IClosePreventableDialog)
     
    3740Q_DECLARE_INTERFACE(ISendingDialog, "ch.gorrion.smssender.ISendingDialog/1.0")
    3841
    39 #endif /* ISENDINGDIALOG_H_ */
     42#endif /* COMMON_GUI_ISENDINGDIALOG_H */
  • common/lib/common.qrc

    r217 r315  
    33        <file>GorrionRootCA.crt</file>
    44    </qresource>
    5     <qresource prefix="/icons">
    6         <file>warning.png</file>
    7     </qresource>
    85</RCC>
  • common/network/snetworkhelper.cpp

    r308 r315  
    2323#include <QNetworkCookieJar>
    2424
    25 #include "snetworkreply.h"
    26 #include "sversion.h"
     25#include "domain/sversion.h"
    2726#include "exceptions/enetworkexception.h"
     27#include "network/snetworkreply.h"
    2828
    2929const uint SNetworkHelper::MAX_REDIRECT_COUNT = 10;
  • common/network/snetworkhelper.h

    r219 r315  
    3131#include <QUrl>
    3232
    33 #include "datatypes_global.h"
    34 
    35 #include "sshared.h"
     33#include "common/global.h"
     34#include "common/utils/sshared.h"
    3635
    3736typedef QMap<QByteArray, QByteArray> HeadersMap;
     
    4039class SNetworkReply;
    4140
    42 class DATATYPES_SHARED_EXPORT SNetworkHelper : public QObject {
     41// TODO: rename into SHttpHelper
     42class COMMON_EXPORT SNetworkHelper : public QObject {
    4343    Q_OBJECT
    4444
     
    5757
    5858public:
    59     SNetworkHelper(QObject *parent);
     59    SNetworkHelper(QObject *parent = NULL);
    6060    ~SNetworkHelper();
    6161
     
    123123
    124124
    125 class DATATYPES_SHARED_EXPORT IParam {
     125class COMMON_EXPORT IParam {
    126126public:
    127127    virtual QByteArray encode(SNetworkHelper::PostType postType) const =0;
     
    133133
    134134
    135 class DATATYPES_SHARED_EXPORT SKeyValueParam : public IParam {
     135class COMMON_EXPORT SKeyValueParam : public IParam {
    136136    Q_INTERFACES(IParam)
    137137
     
    152152
    153153
    154 class DATATYPES_SHARED_EXPORT SFileParam : public SKeyValueParam {
     154class COMMON_EXPORT SFileParam : public SKeyValueParam {
    155155public:
    156156    SFileParam(const QByteArray& key, const QByteArray& fileName, const QByteArray& fileType, const QByteArray& value);
  • common/network/snetworkreply.h

    r236 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717*/
    18 
    1918#ifndef SNETWORKREPLY_H_
    2019#define SNETWORKREPLY_H_
     
    2322#include <QSharedData>
    2423
    25 #include "datatypes_global.h"
    26 
    27 #include "smacros.h"
    28 #include "sshared.h"
     24#include "common/global.h"
     25#include "common/utils/smacros.h"
     26#include "common/utils/sshared.h"
    2927
    3028class QNetworkReply;
     
    3230class SNetworkReplyData;
    3331
    34 class DATATYPES_SHARED_EXPORT SNetworkReply {
     32class COMMON_EXPORT SNetworkReply {
    3533    S_SHARED(SNetworkReply, public)
    3634    S_QHASH_FRIEND(SNetworkReply)
     
    4846    QNetworkReply* operator->() const;
    4947};
    50 DATATYPES_SHARED_EXPORT S_QHASH(SNetworkReply)
     48COMMON_EXPORT S_QHASH(SNetworkReply)
    5149
    5250#endif /* SNETWORKREPLY_H_ */
  • common/network/snetworkreply_p.h

    r217 r315  
    2323#include <QObject>
    2424
    25 #include "snetworkreply.h"
     25#include "common/network/snetworkreply.h"
    2626
    2727class SNetworkReplyDataSignalHelper;
  • common/persistence/iaccountmanager.h

    r236 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #ifndef IACCOUNTSTORAGEMANAGER_H_
    19 #define IACCOUNTSTORAGEMANAGER_H_
     18#ifndef IACCOUNTMANAGER_H_
     19#define IACCOUNTMANAGER_H_
    2020
    2121#include <QHash>
     
    2424#include <QString>
    2525
    26 #include "datatypes_global.h"
    27 #include "eexception.h"
     26#include "common/exceptions/eexception.h"
     27#include "common/global.h"
    2828
    29 class IAccount;
    30 class SDummyAccount;
     29/*class IAccount;
     30class ErrorAccount;
    3131
    32 class DATATYPES_SHARED_EXPORT IAccountStorageManager : public QObject {
    33     Q_OBJECT
     32namespace Persistence {
     33
     34class COMMON_EXPORT IAccountManager {
     35public:
     36    struct AccountLoadResult {
     37        QSet<IAccount*> validAccounts;
     38        QSet<IAccount*> erroneousAccounts;
     39    };
    3440
    3541public:
    36     virtual IAccount*       getAccount(const QString& name) =0;
    37     virtual QSet<IAccount*> getAccountList(QObject* dummyParent, QHash<SDummyAccount*, const EException*>& exceptions) =0;
     42    virtual IAccount* loadAccount(int accountId) =0;
     43    virtual AccountLoadResult loadAccountList() =0;
    3844
    3945    virtual void saveAccount(IAccount* account) =0;
    40     virtual void removeAccount(IAccount* account) =0;
     46    virtual void removeAccount(int accountId) =0;
    4147
    4248public:
    43     IAccountStorageManager(QObject *parent)
    44         : QObject(parent)
    45     {}
    46     virtual ~IAccountStorageManager() {}
     49    virtual ~IAccountManager() {}
    4750
     51protected:
     52    void setAccountId(IAccount *account, int accountId) const;
    4853};
    49 Q_DECLARE_INTERFACE(IAccountStorageManager, "ch.gorrion.smssender.IAccountStorageManager/1.0")
    5054
    51 #endif /* IACCOUNTSTORAGEMANAGER_H_ */
     55}
     56Q_DECLARE_INTERFACE(Persistence::IAccountManager, "ch.gorrion.smssender.persistence.IAccountManager/1.0") */
     57
     58#endif /* IACCOUNTMANAGER_H_ */
  • common/persistence/icontactmanager.h

    r236 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #ifndef ICONTACTSTORAGEMANAGER_H_
    19 #define ICONTACTSTORAGEMANAGER_H_
     18#ifndef ICONTACTMANAGER_H_
     19#define ICONTACTMANAGER_H_
    2020
    21 #include <QSet>
     21/*
     22 *#include <QSet>
    2223
    23 #include "datatypes_global.h"
     24#include "common/global.h"
    2425
    2526class SContact;
    2627
    27 class DATATYPES_SHARED_EXPORT IContactStorageManager : public QObject {
    28     Q_OBJECT
     28namespace Persistence {
    2929
     30class COMMON_EXPORT IContactManager {
    3031public:
    31     virtual SContact       getContact(int contactId) =0;
    32     virtual QSet<SContact> getContactList() =0;
     32    virtual SContact       loadContact(int contactId) =0;
     33    virtual QSet<SContact> loadContactList() =0;
    3334
    3435    virtual void saveContact(SContact& contact) =0;
    35     virtual void removeContact(const SContact& contact) =0;
    3636    virtual void removeContact(int contactId) =0;
    3737
    3838public:
    39     IContactStorageManager(QObject *parent)
    40         : QObject(parent)
    41     {}
    42     virtual ~IContactStorageManager() {}
     39    virtual ~IContactManager() {}
     40
     41protected:
     42    void setContactId(SContact &contact, int contactId) const;
    4343};
    44 Q_DECLARE_INTERFACE(IContactStorageManager, "ch.gorrion.smssender.IContactStorageManager/1.0")
    4544
    46 #endif /* ICONTACTSTORAGEMANAGER_H_ */
     45}
     46
     47Q_DECLARE_INTERFACE(Persistence::IContactManager, "ch.gorrion.smssender.persistence.IContactManager/1.0")
     48*/
     49
     50#endif /* ICONTACTMANAGER_H_ */
  • common/persistence/igroupmanager.h

    r236 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #ifndef IGROUPSTORAGEMANAGER_H_
    19 #define IGROUPSTORAGEMANAGER_H_
     18#ifndef IGROUPMANAGER_H_
     19#define IGROUPMANAGER_H_
    2020
     21#ifdef false
    2122#include <QSet>
    2223
    23 #include "datatypes_global.h"
     24#include "common/global.h"
    2425
    2526class SGroup;
    2627
    27 class DATATYPES_SHARED_EXPORT IGroupStorageManager : public QObject {
    28     Q_OBJECT
     28namespace Persistence {
    2929
     30class COMMON_EXPORT IGroupManager {
    3031public:
    31     virtual SGroup       getGroup(int groupId) =0;
    32     virtual QSet<SGroup> getGroupList() =0;
     32    virtual SGroup       loadGroup(int groupId) =0;
     33    virtual QSet<SGroup> loadGroupList() =0;
    3334
    3435    virtual void saveGroup(SGroup& group) =0;
    35     virtual void removeGroup(const SGroup& group) =0;
    3636    virtual void removeGroup(int groupId) =0;
    3737
    3838public:
    39     IGroupStorageManager(QObject *parent)
    40         : QObject(parent)
    41     {}
    42     virtual ~IGroupStorageManager() {}
     39    virtual ~IGroupManager() {}
     40
     41protected:
     42    void setGroupId(SGroup &group, int groupId) const;
    4343};
    44 Q_DECLARE_INTERFACE(IGroupStorageManager, "ch.gorrion.smssender.IGroupStorageManager/1.0")
    4544
    46 #endif /* IGROUPSTORAGEMANAGER_H_ */
     45}
     46
     47Q_DECLARE_INTERFACE(Persistence::IGroupManager, "ch.gorrion.smssender.persistence.IGroupManager/1.0")
     48
     49#endif
     50
     51#endif /* IGROUPMANAGER_H_ */
  • common/persistence/imainstorage_base.h

    r275 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #ifndef ISTORAGE_H_
    19 #define ISTORAGE_H_
     18#ifndef IMAINSTORAGE_BASE_H_
     19#define IMAINSTORAGE_BASE_H_
    2020
    21 #include <QImage>
    22 #include <QKeySequence>
    23 #include <QObject>
    2421#include <QSet>
    2522#include <QString>
     
    2825#include <QVariant>
    2926
    30 #include "datatypes_global.h"
     27#include "common/persistence/idatabase.h"
    3128
    32 class SContact;
    33 class SGroup;
     29namespace Persistence {
    3430
    35 class DATATYPES_SHARED_EXPORT IStorage : public QObject {
    36     Q_OBJECT
     31class IBaseMainStorage : public IDatabase::Storage {
     32public:
     33    virtual QVariant     readValue(const QString &_namespace, const QString &key, const QVariant &defaultValue = QVariant()) =0;
     34    virtual bool         readBool(const QString &_namespace, const QString &key, bool defaultValue = false) =0;
     35    virtual int          readInt(const QString &_namespace, const QString &key, int defaultValue = 0) =0;
     36    virtual QString      readString(const QString &_namespace, const QString &key, const QString &defaultValue = QString()) =0;
     37    virtual QString      readEncryptedString(const QString &_namespace, const QString &key, const QString &password, const QString &defaultValue = "") =0;
    3738
    38 public:
    39     virtual QVariant     readValue(const QString& _namespace, const QString& key, const QVariant& defaultValue = QVariant()) =0;
    40     virtual bool         readBool(const QString& _namespace, const QString& key, bool defaultValue = false) =0;
    41     virtual int          readInt(const QString& _namespace, const QString& key, int defaultValue = 0) =0;
    42     virtual QString      readString(const QString& _namespace, const QString& key, const QString& defaultValue = QString()) =0;
    43     virtual QString      readEncryptedString(const QString& _namespace, const QString& key, const QString& password, const QString& defaultValue = "") =0;
    44     virtual QImage       readImage(const QString& _namespace, const QString& key, const QImage& defaultValue = QImage()) =0;
    45     virtual SContact     readContact(int contactId) =0; // TODO: Exclude this from here!
    46     virtual SGroup       readGroup(int groupId) =0; // TODO: Exclude this from here!
    47     virtual QKeySequence readShortcut(const QString& key, const QKeySequence& defaultValue = QKeySequence()) =0;
     39    virtual void writeValue(const QString &_namespace, const QString &key, const QVariant &value) =0;
     40    virtual void writeBool(const QString &_namespace, const QString &key, bool value) =0;
     41    virtual void writeInt(const QString &_namespace, const QString &key, int value) =0;
     42    virtual void writeString(const QString &_namespace, const QString &key, const QString &value) =0;
     43    virtual void writeEncryptedString(const QString &_namespace, const QString &key, const QString &password, const QString &value) =0;
    4844
    49     virtual QSet<SContact> readContactList() =0;
    50     virtual QSet<SGroup>   readGroupList() =0;
     45    virtual void removeValue(const QString &_namespace, const QString &key) =0;
     46    virtual void removeValues(const QString &_namespace) =0;
     47};
    5148
    52     virtual void writeValue(const QString& _namespace, const QString& key, const QVariant& value) =0;
    53     virtual void writeBool(const QString& _namespace, const QString& key, bool value) =0;
    54     virtual void writeInt(const QString& _namespace, const QString& key, int value) =0;
    55     virtual void writeString(const QString& _namespace, const QString& key, const QString& value) =0;
    56     virtual void writeEncryptedString(const QString& _namespace, const QString& key, const QString& password, const QString& value) =0;
    57     virtual void writeImage(const QString& _namespace, const QString& key, const QImage& image) =0;
    58     virtual void writeContact(SContact& contact) =0;
    59     virtual void writeGroup(SGroup& group) =0;
    60     virtual void writeShortcut(const QString& key, const QKeySequence& shortcut) =0;
     49}
    6150
    62     virtual void removeValue(const QString& _namespace, const QString& key) =0;
    63     virtual void removeValues(const QString& _namespace) =0;
    64 
    65     virtual void removeContact(int contactId) =0;
    66     virtual void removeGroup(int groupId) =0;
    67 
    68     virtual QSqlDatabase connection() const =0;
    69     virtual QSqlQuery    createQuery() const =0;
    70 
    71 public:
    72     IStorage(QObject* parent);
    73     virtual ~IStorage() {}
    74 
    75 protected:
    76     void setContactId(SContact& contact, int id);
    77     void setGroupId(SGroup& group, int id);
    78 };
    79 Q_DECLARE_INTERFACE(IStorage, "ch.gorrion.smssender.IStorage/1.0")
    80 
    81 #endif /* ISTORAGE_H_ */
     51#endif /* IMAINSTORAGE_BASE_H_ */
  • common/persistence/impl/versionedstorage.cpp

    r220 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 
    1918#include "versionedstorage.h"
    2019
     20#include <QDebug>
    2121#include <QSqlError>
    2222#include <QSqlQuery>
    2323#include <QVariant>
    2424
    25 #include "eexception.h"
     25#include "exceptions/eexception.h"
    2626
    27 void VersionedStorage::init(const QSqlDatabase& db, uint newestVersion) {
    28     QSqlQuery query = QSqlQuery(db);
    29     if (!query.exec("PRAGMA user_version;"))
     27namespace Persistence {
     28
     29VersionedStorage::VersionedStorage(const QString &environment, uint newestVersion)
     30    : m_environment(environment)
     31    , m_newestVersion(newestVersion)
     32{
     33}
     34
     35void VersionedStorage::init(const QSqlDatabase& db) {
     36    m_database = db;
     37
     38    setDatabaseOptions();
     39    updateDatabase();
     40}
     41QSqlDatabase VersionedStorage::database() {
     42    Q_ASSERT(m_database.isValid());
     43    return m_connection_helper.connection(m_database);
     44}
     45
     46/**
     47 * This does nothing. However children can overwride this and set their options there.
     48 */
     49void VersionedStorage::setDatabaseOptions() {
     50}
     51
     52void VersionedStorage::updateDatabase() {
     53    createVersionsTable();
     54
     55    QSqlQuery query(m_database);
     56    query.prepare("SELECT version "
     57                  "FROM t_versions "
     58                  "WHERE (environment = :environment);");
     59    query.bindValue(":environment", m_environment);
     60
     61    if (!query.exec()) {
     62        Q_ASSERT(false);
     63        qWarning() << query.lastError().text();
     64    }
     65
     66    uint currentVersion;
     67    if (query.next()) {
     68        currentVersion = query.value(0).toUInt();
     69    } else {
     70        currentVersion = 0;
     71    }
     72
     73    if (currentVersion < m_newestVersion) {
     74        bool handled = doDatabaseUpgrade(currentVersion);
     75
     76        if (!handled) {
     77            Q_ASSERT(false);
     78            EException("Unimplemented newest version update").raise();
     79        }
     80
     81        // Set the version.
     82        query.prepare("REPLACE INTO t_versions (environment, version) VALUES (:environment, :version);");
     83        query.bindValue(":environment", m_environment);
     84        query.bindValue(":version", m_newestVersion);
     85        if (!query.exec()) {
     86            Q_ASSERT(false);
     87            qWarning() << "Could not update the storage version in the database. "
     88                       << query.lastError().text();
     89        }
     90    }
     91}
     92
     93void VersionedStorage::createVersionsTable() {
     94    QSqlQuery query(m_database);
     95    if (!query.exec("CREATE TABLE IF NOT EXISTS t_versions ("
     96                    "  environment TEXT    NOT NULL, "
     97                    "  version     INTEGER NOT NULL, "
     98                    "  PRIMARY KEY(environment, version) "
     99                    ");"))
    30100    {
    31         EException("Could not get the version information of the database.")
     101        EException(QObject::tr("Could not write the table definitions to the database"))
    32102                .addDebugInfo("sql-error", query.lastError().text())
    33103                .raise();
    34104    }
     105}
    35106
    36     query.next();
    37     uint storageVersion = query.value(0).toUInt();
    38 
    39     if (storageVersion > newestVersion) {
    40         EException(QObject::tr("This storage is of a newer version of smssender."))
    41                 .addDebugInfo("storageVersion", storageVersion)
    42                 .addDebugInfo("newestVersion", newestVersion)
    43                 .raise();
    44     }
    45 
    46     if (!query.exec("SELECT COUNT(*) "
    47                       "FROM sqlite_master "
    48                       "WHERE (type = 'table')"
    49                         "AND (NOT name LIKE 'sqlite_%'); "))
    50     {
    51         EException("Could not get the table count from the database.")
    52                 .addDebugInfo("sql-error", query.lastError().text())
    53                 .raise();
    54     }
    55 
    56     if (!query.next() || (query.value(0).toInt() <= 0)) {
    57         /* No tables in the database -> set the storageVersion to uninitialized. */
    58         storageVersion = 0;
    59     }
    60     query.clear(); // Freeup the ressources
    61 
    62     if (storageVersion < newestVersion) {
    63         doVersionUpdate(storageVersion);
    64 
    65         if (!query.exec(QString("PRAGMA user_version=%1;").arg(newestVersion))) {
    66             EException("Could not update the version information of the database.")
    67                     .addDebugInfo("sql-error", query.lastError().text())
    68                     .raise();
    69         }
    70     }
    71107}
  • common/persistence/impl/versionedstorage.h

    r218 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
     18#ifndef PERS_VERSIONEDSTORAGE_H_
     19#define PERS_VERSIONEDSTORAGE_H_
    1820
    19 #ifndef VERSIONEDSTORAGE_H_
    20 #define VERSIONEDSTORAGE_H_
    21 
     21#include <QString>
    2222#include <QSqlDatabase>
    2323
    24 #include "datatypes_global.h"
     24#include "common/global.h"
     25#include "common/persistence/idatabase.h"
     26#include "common/persistence/impl/storageconnectionhelper.h"
    2527
    26 class DATATYPES_SHARED_EXPORT VersionedStorage {
     28namespace Persistence {
     29
     30class COMMON_EXPORT VersionedStorage : public IDatabase::Storage {
     31public:
     32    VersionedStorage(const QString &environment, uint newestVersion);
     33
     34    void init(const QSqlDatabase &db);
     35    QSqlDatabase database();
     36
    2737protected:
    28     void init(const QSqlDatabase& db, uint newestVersion);
    29     virtual void doVersionUpdate(uint storageVersion) =0;
     38    virtual void setDatabaseOptions();
     39    virtual bool doDatabaseUpgrade(uint currentDbVersion) =0;
    3040
    31 public:
    32     virtual ~VersionedStorage() {}
     41private:
     42    void createVersionsTable();
     43    void updateDatabase();
     44
     45private:
     46    const QString m_environment;
     47    const uint m_newestVersion;
     48
     49    StorageConnectionHelper m_connection_helper;
     50    QSqlDatabase m_database;
    3351};
    3452
    35 #endif /* VERSIONEDSTORAGE_H_ */
     53}
     54
     55#endif /* PERS_VERSIONEDSTORAGE_H_ */
  • common/persistence/istoragehelper.h

    r218 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #ifndef ISTORAGEOFFICER_H_
    19 #define ISTORAGEOFFICER_H_
     18#ifndef ISTORAGEHELPER_H
     19#define ISTORAGEHELPER_H
    2020
    21 #include <QObject>
    22 #include <QString>
     21#include "common/global.h"
    2322
    24 #include "datatypes_global.h"
     23namespace Persistence {
    2524
    26 class IStorage;
     25class IMainStorage;
    2726
    28 class DATATYPES_SHARED_EXPORT IStorageOfficer : public QObject {
    29     Q_OBJECT
     27class COMMON_EXPORT IStorageHelper {
     28public:
     29    virtual void load() const =0;
     30    virtual void save() const =0;
    3031
    3132public:
    32     virtual void readFromStorage() =0;
    33     virtual void writeToStorage() const =0;
    34     virtual void removeFromStorage() =0;
     33    virtual ~IStorageHelper() {}
     34};
    3535
    36     virtual IStorage* storage() const =0;
    37     virtual QString   getNamespace() const =0;
     36}
     37Q_DECLARE_INTERFACE(Persistence::IStorageHelper, "ch.gorrion.smssender.IStorageHelper/1.0")
    3838
    39 public:
    40     IStorageOfficer(QObject* parent);
    41     virtual ~IStorageOfficer() {}
    42 };
    43 Q_DECLARE_INTERFACE(IStorageOfficer, "ch.gorrion.smssender.IStorageOfficer/1.0")
    44 
    45 #endif /* ISTORAGEOFFICER_H_ */
     39#endif // ISTORAGEHELPER_H
  • common/utils/smacros.h

    r262 r315  
    2323#include <QMutex>
    2424#include <QMutexLocker>
     25#include <QSharedPointer>
    2526
    2627#define SET_IF_DIFFERENT(local, other) \
     
    4849// **************
    4950
    50 #define S_SINGLETON(Class) \
     51/*#define S_SINGLETON(Class) \
    5152public: \
    5253    static Class* instance(); \
     
    7677Class* Class::instance_ = NULL; \
    7778Class* Class::instance() { \
    78     static CGuard guard; /* To delete the instance at the end */ \
     79    static CGuard guard; /-* To delete the instance at the end *-/ \
    7980    QMutexLocker locker(&guard.mutex); \
    8081    if (!instance_) { \
     
    8283    } \
    8384    return instance_; \
    84 }
     85}*/
     86
     87#define S_SINGLETON(Class) \
     88public: \
     89    static QSharedPointer<Class> instance() { \
     90        static QMutex mutex; \
     91        static QSharedPointer<Class> instance; \
     92        \
     93        QMutexLocker locker(&mutex); \
     94        if (instance.isNull()) { \
     95            instance = QSharedPointer<Class>(new Class); \
     96        } \
     97        return instance; \
     98    } \
     99\
     100private: \
     101    Class(); \
     102    Class(const Class& other); \
     103    bool operator =(const Class& other); \
     104\
     105private: \
     106    static QMutex m_instanceMutex;
     107
     108
     109// If all works correctly, just remove this macro
     110#define S_SINGLETON_IMPL(Class)
    85111
    86112#endif /* SMACROS_H_ */
  • common/utils/sshared.h

    r218 r315  
    2525#include <QtGlobal>
    2626
    27 #include "datatypes_global.h"
     27#include "common/global.h"
    2828
    29 class DATATYPES_SHARED_EXPORT SShareable : public QObject, public QSharedData {
     29class COMMON_EXPORT SShareable : public QObject, public QSharedData {
    3030protected:
    3131    SShareable() {}
  • common/utils/staskmanager.cpp

    r240 r315  
    2525
    2626STaskManager::STaskManager()
    27     : QObject(NULL) // singleton
    28     , tasksMutex_(QMutex::Recursive)
     27    : tasksMutex_(QMutex::Recursive)
    2928    , tornDown_(false)
    3029{
  • common/utils/staskmanager.h

    r220 r315  
    2424#include <QMutex>
    2525
    26 #include "smacros.h"
    27 #include "stask.h"
     26#include "common/domain/stask.h"
     27#include "common/utils/smacros.h"
    2828
    29 class DATATYPES_SHARED_EXPORT STaskManager : public QObject {
     29class COMMON_EXPORT STaskManager : public QObject {
    3030    Q_OBJECT
    3131    S_SINGLETON(STaskManager)
  • common/utils/sutils.cpp

    r278 r315  
    1919
    2020#include <QtGlobal>
    21 #include <crypto++/default.h>
     21#include <cryptopp/default.h>
    2222
    23 #include "eexception.h"
     23#include "exceptions/eexception.h"
    2424
    2525QString SUtils::getRandomString(int length, const QString &alphabet) {
  • common/validation/defaultaccountvalidator.cpp

    r217 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #include "sstdaccountvalidator.h"
     18#include "defaultaccountvalidator.h"
    1919
    2020#include <QString>
     
    2222#include "svalidationresult.h"
    2323
    24 SStdAccountValidator::SStdAccountValidator(QObject* parent, IAccount* account)
    25     : IValidator(parent)
    26     , account_(account)
     24DefaultAccountValidator::DefaultAccountValidator(const IAccount *account)
     25    : m_account(account)
    2726{
    2827}
    2928
    30 SValidationResult SStdAccountValidator::validate() const {
     29SValidationResult DefaultAccountValidator::validate() const {
    3130    SValidationResult result;
    3231
     
    4544}
    4645
    47 IAccount* SStdAccountValidator::account() const {
    48     return account_;
     46const IAccount* DefaultAccountValidator::account() const {
     47    return m_account;
    4948}
  • common/validation/defaultaccountvalidator.h

    r218 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #ifndef SSTDACCOUNTVALIDATOR_H_
    19 #define SSTDACCOUNTVALIDATOR_H_
     18#ifndef DEFAULTACCOUNTVALIDATOR_H_
     19#define DEFAULTACCOUNTVALIDATOR_H_
    2020
    21 #include "iaccount.h"
    22 #include "ivalidator.h"
     21#include "common/business/iaccount.h"
     22#include "common/business/ivalidator.h"
    2323
    24 class DATATYPES_SHARED_EXPORT SStdAccountValidator : public IValidator {
    25     Q_OBJECT
     24class COMMON_EXPORT DefaultAccountValidator : public IValidator {
    2625    Q_INTERFACES(IValidator)
    2726
    2827public:
    29     explicit SStdAccountValidator(QObject* parent, IAccount* account);
     28    explicit DefaultAccountValidator(const IAccount *account);
    3029
    3130    virtual SValidationResult validate() const;
    3231
    3332protected:
    34     virtual IAccount* account() const;
     33    virtual const IAccount* account() const;
    3534
    3635private:
    37     IAccount* account_;
     36    const IAccount *m_account;
    3837};
    3938
    40 #endif /* SSTDACCOUNTVALIDATOR_H_ */
     39#endif /* DEFAULTACCOUNTVALIDATOR_H_ */
  • common/validation/svalidationresult.h

    r218 r315  
    2222#include <QStringList>
    2323
    24 #include "datatypes_global.h"
     24#include "common/global.h"
    2525
    26 class DATATYPES_SHARED_EXPORT SValidationResult {
     26class COMMON_EXPORT SValidationResult {
    2727public:
    2828    enum ValidationType {
  • frontend/business/accountinitmanager.cpp

    r240 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #include "bcaccountinitmanager.h"
     18#include "accountinitmanager.h"
    1919
    2020#include <QString>
    2121#include <QSet>
    2222
    23 #include <iaccount_tasks.h>
    24 #include <managers/staskmanager.h>
     23#include "common/business/iaccount_tasks.h"
     24#include "common/utils/staskmanager.h"
    2525
    26 S_SINGLETON_IMPL(BCAccountInitManager)
    27 
    28 BCAccountInitManager::BCAccountInitManager()
    29     : IAccountInitManager(NULL) // singleton
    30 {
    31 }
    32 
    33 /**
    34  * Starts the initialization process of the given account and connects
    35  * the signals to it.
    36  * If the account is already initialized, nothing happens.
    37  * If the account is already initializing, we only connect to the signals, if not already done
    38  *
    39  * @param account The to be initialized account
    40  */
    41 void BCAccountInitManager::initAccount(IAccount* account) {
    42     if (initializingAccounts_.contains(account)) {
     26void AccountInitManager::initAccount(IAccount *account) {
     27    if (m_initializingAccounts.contains(account)) {
    4328        // The initialization of this account is already under our control
    4429        return;
     
    5237    }
    5338
    54     IAccountInitTask* initTask = account->createInitTask();
     39    QScopedPointer<IAccountInitTask> initTask(account->createInitTask());
    5540    if (initTask) {
    56         initializingAccounts_.insert(account);
     41        m_initializingAccounts.insert(account);
    5742
    58         connect(initTask, SIGNAL(finished(STask*)),
     43        connect(initTask.data(), SIGNAL(finished(STask*)),
    5944                this, SLOT(onAccountInitFinished(STask*)), Qt::DirectConnection);
    60         connect(initTask, SIGNAL(exceptionOccured(STask*)),
     45        connect(initTask.data(), SIGNAL(exceptionOccured(STask*)),
    6146                this, SLOT(onAccountInitFailed(STask*)), Qt::DirectConnection);
    6247        connect(account, SIGNAL(initStateChanged(IAccount*)),
    6348                this, SIGNAL(accountInitStateChanged(IAccount*)));
    6449
    65         initTask->start();
     50        initTask.take()->start();
    6651    }
    6752}
    6853
    69 /**
    70  * Starts the initialization process of the given accounts.
    71  *
    72  * @param accounts The to be initialized accounts
    73  */
    74 void BCAccountInitManager::initAccounts(const QSet<IAccount*>& accounts) {
     54void AccountInitManager::initAccounts(const QSet<IAccount*> &accounts) {
    7555    foreach (IAccount* account, accounts) {
    7656        initAccount(account);
     
    7959
    8060
    81 void BCAccountInitManager::onAccountInitFinished(STask* task) {
     61void AccountInitManager::onAccountInitFinished(STask *task) {
    8262    IAccount* account = static_cast<IAccountInitTask*>(task)->account();
    8363
    84     initializingAccounts_.remove(account);
     64    m_initializingAccounts.remove(account);
    8565    emit accountInitFinished(account, task->taskResult());
    8666}
    87 void BCAccountInitManager::onAccountInitFailed(STask* task) {
     67void AccountInitManager::onAccountInitFailed(STask *task) {
    8868    IAccount* account = static_cast<IAccountInitTask*>(task)->account();
    8969
  • frontend/business/accountinitmanager.h

    r217 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #ifndef BCACCOUNTINITMANAGER_H_
    19 #define BCACCOUNTINITMANAGER_H_
     18#ifndef ACCOUNTINITMANAGER_H_
     19#define ACCOUNTINITMANAGER_H_
    2020
    2121#include <QList>
    2222
    23 #include <iaccount.h>
    24 #include <imanagers.h>
     23#include "common/business/iaccount.h"
     24#include "common/exceptions/stdexceptions.h"
    2525
    26 #include <smacros.h>
    27 #include <stdexceptions.h>
     26class AccountInitManager : public QObject {
     27    Q_OBJECT
    2828
    29 class BCAccountInitManager : public IAccountInitManager {
    30     Q_OBJECT
    31     Q_INTERFACES(IAccountInitManager)
    32     S_SINGLETON(BCAccountInitManager)
     29public:
     30    /**
     31     * Starts the initialization process of the given account and connects
     32     * the signals to it.
     33     * If the account is already initialized, nothing happens.
     34     * If the account is already initializing, we only connect to the signals, if not already done.
     35     *
     36     * @param account The to be initialized account
     37     */
     38    virtual void initAccount(IAccount* account);
    3339
    34 public: /* IAccountInitManager */
    35     void initAccount(IAccount* account);
    36     void initAccounts(const QSet<IAccount*>& accounts);
     40    /**
     41     * Starts the initialization process of the given accounts.
     42     *
     43     * @param accounts The to be initialized accounts
     44     */
     45    virtual void initAccounts(const QSet<IAccount*> &accounts);
    3746
    38 private:
    39     QSet<IAccount*> initializingAccounts_;
     47signals:
     48    void accountInitStateChanged(IAccount* account); // Called when a account gets initialized or un-initialized
     49    void accountInitFinished(IAccount* account, STask::Result result);
     50    void accountInitFailed(IAccount* account, const EException &exception);
    4051
    4152private slots:
    4253    void onAccountInitFinished(STask* task);
    4354    void onAccountInitFailed(STask* task);
     55
     56private:
     57    QSet<IAccount*> m_initializingAccounts;
    4458};
    4559
    46 #endif /* BCACCOUNTINITMANAGER_H_ */
     60#endif /* ACCOUNTINITMANAGER_H_ */
  • frontend/business/accountmanager.cpp

    r275 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #include "bcaccountmanager.h"
     18#include "accountmanager.h"
    1919
    20 #include "persistence/persistencefactory.h"
     20#include "frontend/business/accountinitmanager.h"
     21#include "frontend/persistence/accountmanager.h"
    2122
    22 S_SINGLETON_IMPL(BCAccountManager)
    23 
    24 BCAccountManager::BCAccountManager()
    25     : IAccountManager(NULL) // singleton
     23AccountManager::AccountManager(AccountInitManager *accountInitManager, Persistence::AccountManager *accountManager)
     24    // FIXME: Shouldn't we create an own init helper for each account when it is due?
     25    : m_accountInitManager(accountInitManager)
     26    , m_persAccountManager(accountManager)
    2627{
    27     connect(accountInitManager(), SIGNAL(accountInitStateChanged(IAccount*)),
     28    connect(m_accountInitManager, SIGNAL(accountInitStateChanged(IAccount*)),
    2829            this, SIGNAL(accountInitStateChanged(IAccount*)));
    2930}
     31AccountManager::~AccountManager() {
     32}
    3033
    31 void BCAccountManager::addAccountToList(IAccount* account) {
     34void AccountManager::addAccountToList(IAccount* account) {
    3235    Q_ASSERT(account);
    33     if (accountList_.contains(account->id()))
     36    if (m_accountList.contains(account->id()))
    3437        return;
    3538
    36     accountList_.insert(account->id(), account);
     39    m_accountList.insert(account->id(), account);
    3740
    3841    connect(account, SIGNAL(idChanged(IAccount*, int)),
     
    4851    account->resetInitialization();
    4952    if (account->isEnabled()) {
    50         accountInitManager()->initAccount(account);
     53        m_accountInitManager->initAccount(account);
    5154    }
    5255}
    5356
    54 void BCAccountManager::removeAccountFromList(IAccount* account) {
    55     Q_ASSERT(account);
    56     if (!accountList_.contains(account->id()))
     57void AccountManager::removeAccountFromList(int id) {
     58    QMap<int, IAccount *> *accountList = &m_accountList;
     59    IAccount *account = m_accountList.value(id);
     60    if (!account) {
     61        account = m_erroneousAccounts.value(id);
     62        accountList = &m_erroneousAccounts;
     63    }
     64    if (!account) {
    5765        return;
     66    }
    5867
    5968    disconnect(account, 0, this, 0);
    6069
    61     accountList_.remove(account->id());
     70    accountList->remove(account->id());
    6271    emit accountRemoved(account);
    6372}
    6473
    65 QHash<SDummyAccount*, const EException*> BCAccountManager::readAccountsFromStorage() {
    66     QHash<SDummyAccount*, const EException*> exceptions;
    67     QSet<IAccount*> accountList = PersistenceFactory::instance()->getAccountManager()->getAccountList(this, exceptions);
     74void AccountManager::readAccountsFromStorage() {
     75    Q_ASSERT(m_accountList.isEmpty());
    6876
    69     foreach(IAccount* account, accountList_.values().toSet().subtract(accountList)) {
    70         removeAccountFromList(account);
    71     }
     77    typename Persistence::AccountManager::AccountLoadResult accountLoadResult =
     78            m_persAccountManager->loadAccountList();
    7279
    73     foreach(IAccount* account, accountList.subtract(accountList_.values().toSet())) {
     80    // Process valid accounts
     81    foreach(IAccount* account, accountLoadResult.validAccounts) {
    7482        addAccountToList(account);
    7583    }
    7684
    77     // Add erroneous accounts
    78     foreach(SDummyAccount* dummy, exceptions.keys()) {
    79         if (accountList_.values().contains(dummy)) {
    80             continue;
    81         }
    82 
    83         addAccountToList(dummy);
     85    // Process erroneous accounts
     86    foreach (IAccount *account, accountLoadResult.erroneousAccounts) {
     87        m_erroneousAccounts[account->id()] = account;
    8488    }
    85 
    86     return exceptions;
    87 }
    88 
    89 IAccountInitManager* BCAccountManager::accountInitManager() {
    90     return BCAccountInitManager::instance();
    9189}
    9290
    9391
    94 IAccount* BCAccountManager::getAccount(int accountId){
    95     return accountList_.value(accountId);
     92IAccount *AccountManager::account(int accountId) const {
     93    return m_accountList.value(accountId);
    9694}
    9795
    98 QSet<IAccount*> BCAccountManager::getAccountList(){
    99     return accountList_.values().toSet();
     96QSet<IAccount*> AccountManager::accounts() const {
     97    return m_accountList.values().toSet();
     98}
     99QSet<IAccount *> AccountManager::erroneousAccounts() const {
     100    return m_erroneousAccounts.values().toSet();
    100101}
    101102
    102 void BCAccountManager::saveAccount(IAccount* account){
     103
     104void AccountManager::saveAccount(IAccount* account){
    103105    Q_ASSERT(account);
    104     PersistenceFactory::instance()->getAccountManager()->saveAccount(account);
     106    m_persAccountManager->saveAccount(account);
    105107    addAccountToList(account);
    106108}
    107109
    108 void BCAccountManager::removeAccount(int accountId){
    109     IAccount* account = getAccount(accountId);
    110     if (!account)
    111         return;
    112 
    113     PersistenceFactory::instance()->getAccountManager()->removeAccount(account);
    114     removeAccountFromList(account);
     110void AccountManager::removeAccount(int accountId){
     111    removeAccountFromList(accountId);
     112    m_persAccountManager->removeAccount(accountId);
    115113}
    116114
    117115
    118 void BCAccountManager::onAccountIdChanged(IAccount* account, int oldId) {
    119     IAccount* acc = accountList_.take(oldId);
     116void AccountManager::onAccountIdChanged(IAccount* account, int oldId) {
     117    IAccount* acc = m_accountList.take(oldId);
    120118    if (acc) {
    121119        Q_ASSERT(acc == account);
    122         accountList_.insert(acc->id(), acc);
     120        m_accountList.insert(acc->id(), acc);
    123121    }
    124122}
    125 void BCAccountManager::onAccountDataChanged(IAccount* account, int property) {
     123void AccountManager::onAccountDataChanged(IAccount* account, int property) {
    126124    emit accountDataChanged(account, property);
    127125
     
    132130            // If the account has been en-/disabled or the username/password has been changed, then just reset the initialization
    133131            account->resetInitialization();
    134             accountInitManager()->initAccount(account);
     132            m_accountInitManager->initAccount(account);
    135133
    136134            break;
    137135        }
    138136    }
    139 
    140137}
  • frontend/business/accountmanager.h

    r217 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #ifndef BCACCOUNTMANAGER_H_
    19 #define BCACCOUNTMANAGER_H_
     18#ifndef ACCOUNTMANAGER_H_
     19#define ACCOUNTMANAGER_H_
    2020
    21 #include <iaccount.h>
    22 #include <imanagers.h>
     21#include <QScopedPointer>
    2322
    24 #include <sdummyaccount.h>
    25 #include <smacros.h>
    26 #include <eexception.h>
     23#include "common/business/iaccount.h"
     24#include "common/exceptions/eexception.h"
    2725
    28 #include "bcaccountinitmanager.h"
     26class AccountInitManager;
     27namespace Persistence {
     28class AccountManager;
     29} // namespace Persistence
    2930
    30 class BCAccountManager : public IAccountManager {
     31class AccountManager : public QObject {
    3132    Q_OBJECT
    32     Q_INTERFACES(IAccountManager)
    33     S_SINGLETON(BCAccountManager)
    3433
    3534public:
    36     QHash<SDummyAccount*, const EException*> readAccountsFromStorage();
     35    AccountManager(AccountInitManager *accountInitManager,
     36                   Persistence::AccountManager *accountManager);
     37    ~AccountManager();
    3738
    38     IAccountInitManager* accountInitManager();
     39public:
     40    void readAccountsFromStorage();
    3941
    40     IAccount*            getAccount(int accountId);
    41     QSet<IAccount*>      getAccountList();
    42     void                 saveAccount(IAccount* account);
    43     void                 removeAccount(int accountId);
     42    IAccount *account(int accountId) const;
     43    QSet<IAccount *> accounts() const;
     44    QSet<IAccount*> erroneousAccounts() const;
     45
     46    void saveAccount(IAccount* account);
     47    void removeAccount(int accountId);
     48
     49signals:
     50    void accountAdded(IAccount* account);
     51    void accountDataChanged(IAccount* account, int property);
     52    void accountRemoved(IAccount* account);
     53    void accountInitStateChanged(IAccount* account);
     54    void accountLoginStateChanged(IAccount *account);
    4455
    4556private:
    46     void                 addAccountToList(IAccount* account);
    47     void                 removeAccountFromList(IAccount* account);
     57    void addAccountToList(IAccount* account);
     58    void removeAccountFromList(int id);
     59
     60private slots:
     61    void onAccountIdChanged(IAccount* account, int oldId);
     62    void onAccountDataChanged(IAccount* account, int property);
    4863
    4964private:
    50     QMap<int, IAccount*> accountList_;
     65    AccountInitManager * const m_accountInitManager;
     66    const QScopedPointer<Persistence::AccountManager> m_persAccountManager;
    5167
    52 private slots:
    53     void                 onAccountIdChanged(IAccount* account, int oldId);
    54     void                 onAccountDataChanged(IAccount* account, int property);
     68    QMap<int, IAccount*> m_accountList;
     69    QMap<int, IAccount*> m_erroneousAccounts;
    5570};
    5671
    57 #endif /* BCACCOUNTMANAGER_H_ */
     72#endif /* ACCOUNTMANAGER_H_ */
  • frontend/business/contactimporter/abstractgooglecontactimporter.cpp

    r243 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 
    19 #include "googlecontactimporter.h"
     18#include "abstractgooglecontactimporter.h"
    2019
    2120#include <QRegExp>
    2221
    23 #include <scontact.h>
    24 #include <snetworkreply.h>
    25 #include <snumber.h>
     22#include "common/domain/scontact.h"
     23#include "common/domain/snumber.h"
     24#include "common/exceptions/eexception.h"
     25#include "common/network/snetworkreply.h"
    2626
    27 #include <exceptions/eexception.h>
    28 
    29 GoogleContactImporter::GoogleContactImporter(QObject* parent)
    30     : IContactImporter(parent)
    31     , configPage_(NULL)
    32     , networkHelper_(new SNetworkHelper(this))
     27AbstractGoogleContactImporter::AbstractGoogleContactImporter(SNetworkHelper *httpHelper)
     28    : m_httpHelper(httpHelper)
    3329{
    34     networkHelper_->addTrustedCA(":/certs/VerisignClass3PublicPrimaryCertificationAuthority.crt");
     30    m_httpHelper->addTrustedCA(":/certs/VerisignClass3PublicPrimaryCertificationAuthority.crt");
    3531}
    3632
    37 QString GoogleContactImporter::describingName() const {
    38     return tr("Import contacts from google contacts.");
     33QString AbstractGoogleContactImporter::describingName() const {
     34    return QObject::tr("Import contacts from google contacts.");
    3935}
    4036
    41 bool GoogleContactImporter::isApplicable() const {
     37bool AbstractGoogleContactImporter::isApplicable() const {
    4238    return true;
    4339}
    4440
    4541
    46 void GoogleContactImporter::init() {
     42void AbstractGoogleContactImporter::init() {
    4743}
    4844
    49 QList<QWizardPage*> GoogleContactImporter::createPreImportPages(QWidget* parent) {
    50     configPage_ = new GCI::PageConfig(parent);
     45/*QList<IContactImporter::Page> AbstractGoogleContactImporter::preImportPages() {
     46    m_authPage.reset(createAuthPage());
    5147
    52     QList<QWizardPage*> pages;
    53     pages.append(configPage_);
     48    QList<IContactImporter::Page> pages;
     49    pages.append(m_authPage.data());
    5450    return pages;
    55 }
     51}*/
    5652
    57 QSet<SContact> GoogleContactImporter::importContacts() {
    58     QSet<SContact> contacts;
     53QSet<SContact*> AbstractGoogleContactImporter::importContacts() {
     54    QSet<SContact*> contacts;
    5955
     56    // TODO Use OAuth2
    6057    requestAuthToken();
    61     networkHelper_->defaultHeaders().insert("GData-Version", "3.0");
     58    m_httpHelper->defaultHeaders().insert("GData-Version", "3.0");
    6259
    6360    QString nextUrl = "http://www.google.com/m8/feeds/contacts/default/thin?max-results=10000";
    6461    do {
    65         QString contactsFeed = networkHelper_->syncGet(nextUrl)->readAll();
     62        QString contactsFeed = m_httpHelper->syncGet(nextUrl)->readAll();
    6663        contactsFeed = SNetworkHelper::urldecodeString(contactsFeed);
    67         parseContactsFeed(contactsFeed, contacts);
     64        parseContactsFeed(contactsFeed, &contacts);
    6865
    6966        QRegExp rx("<link rel='next' type='application/atom\\+xml' href='([^']+)'/>");
     
    7875}
    7976
    80 void GoogleContactImporter::parseContactsFeed(const QString& feed, QSet<SContact>& contacts) {
     77void AbstractGoogleContactImporter::parseContactsFeed(const QString& feed, QSet<SContact *> *contacts) {
    8178    /*<entry gd:etag=""SXszeTVSLyt7ImA9WxFbFk8ORQU."">
    8279        <id>http://www.google.com/m8/feeds/contacts/saemy.zehnder%40gmail.com/base/59ea8d658e87e360</id>
     
    119116
    120117            if (!name.isEmpty() && number.isValid()) {
    121                 SContact contact;
    122                 contact.setName(name);
    123                 contact.setNumber(number);
     118                QScopedPointer<SContact> contact(new SContact);
     119                contact->setName(name);
     120                contact->setNumber(number);
    124121
    125122                rx2.setPattern("<gContact:nickname>(.*)</gContact:nickname>");
     
    128125                    QStringList aliases;
    129126                    aliases.append(rx2.cap(1));
    130                     contact.setAliases(aliases);
     127                    contact->setAliases(aliases);
    131128                }
    132129
     130#ifdef FRONTEND_GUI
    133131                rx2.setPattern("<link rel='http://schemas.google.com/contacts/2008/rel#photo' type='image/\\*' href='([^']+)' gd:etag='([^']+)'/>");
    134132                if (rx2.indexIn(entry) != -1) {
    135                     QImage img = QImage::fromData(networkHelper_->syncGet(rx2.cap(1))->readAll());
     133                    QImage img = QImage::fromData(m_httpHelper->syncGet(rx2.cap(1))->readAll());
    136134                    if (!img.isNull()) {
    137                         contact.setImage(img);
     135                        contact->setImage(img);
    138136                    }
    139137                }
     138#endif
    140139
    141                 contacts.insert(contact);
     140                contacts->insert(contact.take());
    142141            }
    143142        } catch (...) {
     
    147146}
    148147
    149 void GoogleContactImporter::requestAuthToken() {
    150     Q_ASSERT(configPage_);
     148void AbstractGoogleContactImporter::requestAuthToken() {
     149    const AuthData &authData = getAuthData();
    151150
    152151    QList<IParam*> posts;
    153152    posts.append(new SKeyValueParam("accountType", "GOOGLE"));
    154     posts.append(new SKeyValueParam("Email",       configPage_->username().toUtf8()));
    155     posts.append(new SKeyValueParam("Passwd",      configPage_->password().toUtf8()));
     153    posts.append(new SKeyValueParam("Email",       authData.m_username.toUtf8()));
     154    posts.append(new SKeyValueParam("Passwd",      authData.m_password.toUtf8()));
    156155    posts.append(new SKeyValueParam("service",     "cp"));
    157156    posts.append(new SKeyValueParam("source",      "gorrion-smssender-3"));
     
    159158    QString result;
    160159    try {
    161         result = networkHelper_->syncPost(QUrl::fromEncoded("https://www.google.com/accounts/ClientLogin"), posts)->readAll();
     160        result = m_httpHelper->syncPost(QUrl::fromEncoded("https://www.google.com/accounts/ClientLogin"), posts)->readAll();
    162161    } catch (EException& e) {
    163162        result = "";
     
    166165    QRegExp rx("Auth=(\\S+)");
    167166    if (rx.indexIn(result) != -1) {
    168         networkHelper_->defaultHeaders().insert("Authorization", QString("GoogleLogin auth=" + rx.cap(1)).toUtf8());
     167        m_httpHelper->defaultHeaders().insert("Authorization", QString("GoogleLogin auth=" + rx.cap(1)).toUtf8());
    169168    } else {
    170169        EException("Login failed. You have probably entered incorrect userdata.")
  • frontend/business/contactimporter/abstractgooglecontactimporter.h

    r217 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
     18#ifndef ABSTRACTGOOGLECONTACTIMPORTER_H_
     19#define ABSTRACTGOOGLECONTACTIMPORTER_H_
    1820
    19 #ifndef GOOGLECONTACTIMPORTER_H_
    20 #define GOOGLECONTACTIMPORTER_H_
     21#include <QScopedPointer>
    2122
    22 #include <icontactimporter.h>
    23 #include <snetworkhelper.h>
     23#include "common/business/icontactimporter.h"
     24#include "common/network/snetworkhelper.h"
    2425
    25 #include "ui/contactimporterpages/googlecontactsimporter/gci_page_config.h"
    26 
    27 class GoogleContactImporter : public IContactImporter {
    28     Q_OBJECT
     26class AbstractGoogleContactImporter : public IContactImporter {
    2927    Q_INTERFACES(IContactImporter)
    3028
    3129public:
    32     GoogleContactImporter(QObject* parent);
     30    // Takes ownership of the httpHelper.
     31    explicit AbstractGoogleContactImporter(SNetworkHelper *httpHelper);
    3332
    3433public: /* IContactImporter */
    3534    QString describingName() const;
    36     bool    isApplicable() const;
     35    bool isApplicable() const;
    3736
    38     void                init();
    39     QList<QWizardPage*> createPreImportPages(QWidget* parent);
    40     QSet<SContact>      importContacts();
     37    void init();
     38    QSet<SContact*> importContacts();
     39
     40protected:
     41    struct AuthData {
     42        QString m_username;
     43        QString m_password;
     44    };
     45    virtual AuthData getAuthData() const =0;
    4146
    4247private:
    43     void                requestAuthToken();
    44     void                parseContactsFeed(const QString& feed, QSet<SContact>& contacts);
     48    void requestAuthToken();
     49    void parseContactsFeed(const QString& feed, QSet<SContact *> *contacts);
    4550
    4651private:
    47     GCI::PageConfig* configPage_;
    48     SNetworkHelper*  networkHelper_;
     52    QScopedPointer<SNetworkHelper> m_httpHelper;
    4953};
    5054
    51 #endif /* GOOGLECONTACTIMPORTER_H_ */
     55#endif /* ABSTRACTGOOGLECONTACTIMPORTER_H_ */
  • frontend/business/contactimporter/contactfilesimporter.cpp

    r305 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 
    1918#include "contactfilesimporter.h"
    20 #include "contactfilesimporter_datamanager.h"
    2119
    2220#include <QDebug>
    23 #include <QDesktopServices>
    2421#include <QFileInfo>
    2522
    26 #include <scontact.h>
    27 #include <snumber.h>
    28 
    29 #include "ui/contactimporterpages/contactfilesimporter/cfi_page_config.h"
    30 
    31 ContactFilesImporter::ContactFilesImporter(QObject* parent)
    32     : IContactImporter(parent)
    33     , dataManager_(new ContactFilesImporterDataManager(this))
     23#include "common/domain/scontact.h"
     24#include "common/domain/snumber.h"
     25
     26ContactFilesImporter::ContactFilesImporter()
     27    : m_dataManager(new ContactFilesImporterDataManager)
    3428{
    3529}
    3630
    3731QString ContactFilesImporter::describingName() const {
    38     return tr("Import contacts from contact files (Old smssender contact files, CSV).");
     32    return QObject::tr("Import contacts from contact files (Old smssender contact files, CSV).");
    3933}
    4034
     
    4539
    4640void ContactFilesImporter::init() {
    47     dataManager_->setContactFiles(defaultContactsFiles().toSet());
    48     dataManager_->setSelectedContactFiles(defaultContactsFiles().toSet());
    49 }
    50 
    51 QList<QWizardPage*> ContactFilesImporter::createPreImportPages(QWidget* parent) {
     41}
     42
     43/*QList<IContactImporter::Page*> ContactFilesImporter::preImportPages() {
    5244    QList<QWizardPage*> pages;
    53     pages.append(new CFI::PageConfig(parent, dataManager_));
     45    pages.append(new UI::CFI::PageConfig(parent, m_dataManager.data()));
    5446
    5547    return pages;
    56 }
    57 
    58 QSet<SContact> ContactFilesImporter::importContacts() {
    59     QSet<SContact> contacts;
    60 
    61     foreach (QString contactsFile, dataManager_->selectedContactFiles()) {
    62         if (!QFile::exists(contactsFile)) continue;
    63 
    64         QFileInfo fi(contactsFile);
     48}*/
     49
     50void ContactFilesImporter::importContacts(QSet<SContact*> *contacts) {
     51    const QMap<QString, bool> &selectedFilesMap = m_dataManager->selectionMap();
     52    for (QMap<QString, bool>::ConstIterator it = selectedFilesMap.begin(); it != selectedFilesMap.end(); ++it) {
     53        if (!it.value()) continue; // Not selected
     54
     55        QFileInfo fi(it.key());
     56        if (!fi.isReadable()) continue;
     57
    6558        if (fi.completeSuffix().toLower() == "ini") {
    66             QSettings ini(contactsFile, QSettings::IniFormat);
     59            QSettings ini(fi.fileName(), QSettings::IniFormat);
    6760            if (ini.childGroups().contains("contacts")) {
    6861                // V1 contacts file
    69                 contacts.unite(readV1ContactsFile(ini));
     62                readV1ContactsFile(ini, contacts);
    7063            } else {
    7164                // V2 contacts file
    72                 contacts.unite(readV2ContactsFile(ini));
     65                readV2ContactsFile(ini, contacts);
    7366            }
    7467
     
    7871
    7972        } else if (fi.completeSuffix().toLower() == "csv") {
    80             CSVFile csv = parseCSV(contactsFile);
    81             contacts.unite(readCSV(csv));
    82         }
    83     }
    84 
    85     return contacts;
    86 }
    87 
    88 
    89 void _addDefaultFile(QStringList& files, QString filename) {
    90     QFileInfo fi(filename);
    91     if (fi.exists()) {
    92         files.append(fi.absoluteFilePath());
    93     }
    94 }
    95 QStringList ContactFilesImporter::defaultContactsFiles() const {
     73            CSVFile csv = parseCSV(fi.fileName());
     74            readCSV(csv, contacts);
     75        }
     76    }
     77}
     78
     79
     80/*QStringList ContactFilesImporter::defaultContactsFiles() const {
    9681    QStringList r;
    9782
     
    10085
    10186    return r;
    102 }
    103 
    104 QSet<SContact> ContactFilesImporter::readV1ContactsFile(const QSettings& ini) const {
    105     QSet<SContact> result;
    106 
     87}*/
     88
     89void ContactFilesImporter::readV1ContactsFile(const QSettings& ini, QSet<SContact *> *contacts) const {
    10790    int i = 0;
    10891    while (ini.contains("contacts/contact_" + QString::number(i) + "_nr")) {
     
    11093        SNumber number(ini.value("contacts/contact_" + QString::number(i) + "_nr").toString());
    11194        if (!name.trimmed().isEmpty() && number.isValid()) {
    112             SContact contact;
    113             contact.setName(name);
    114             contact.setNumber(number);
    115 
    116             result.insert(contact);
     95            QScopedPointer<SContact> contact(new SContact);
     96            contact->setName(name);
     97            contact->setNumber(number);
     98
     99            contacts->insert(contact.take());
    117100        }
    118101
    119102        ++i;
    120103    }
    121 
    122     return result;
    123 }
    124 
    125 QSet<SContact> ContactFilesImporter::readV2ContactsFile(const QSettings& ini) const {
    126     QSet<SContact> result;
    127 
     104}
     105
     106void ContactFilesImporter::readV2ContactsFile(const QSettings& ini, QSet<SContact *> *contacts) const {
    128107    foreach (QString name, ini.childGroups()) {
    129108        SNumber number(ini.value(name + "/" + "number").toString());
    130109        if (!name.trimmed().isEmpty() && number.isValid()) {
    131             SContact contact;
    132             contact.setName(name);
    133             contact.setNumber(number);
    134 
    135             result.insert(contact);
    136         }
    137     }
    138 
    139     return result;
     110            QScopedPointer<SContact> contact(new SContact);
     111            contact->setName(name);
     112            contact->setNumber(number);
     113
     114            contacts->insert(contact.take());
     115        }
     116    }
    140117}
    141118
     
    188165}
    189166
    190 QSet<SContact> ContactFilesImporter::readCSV(const CSVFile& csv) const {
    191     QSet<SContact> result;
    192 
     167void ContactFilesImporter::readCSV(const CSVFile& csv, QSet<SContact*> *contacts) const {
    193168    QStringList nameKeys;
    194169    nameKeys.append("[Name]");      // Google CSV
     
    247222
    248223        if ((names.count() > 0) && number.isValid()) {
    249             SContact contact;
    250             contact.setName(names.takeFirst());
    251             contact.setNumber(number);
    252             contact.setAliases(names);
    253 
    254             result.insert(contact);
    255         }
    256     }
    257 
    258     return result;
    259 }
    260 
    261 
    262 /**********************************************************************************************/
    263 
    264 ContactFilesImporterDataManager::ContactFilesImporterDataManager(QObject* parent)
    265     : QObject(parent)
    266 {
    267 }
    268 
    269 QSet<QString> ContactFilesImporterDataManager::contactFiles() const {
    270     return contactFiles_;
    271 }
    272 void ContactFilesImporterDataManager::setContactFiles(const QSet<QString>& contactFiles) {
    273     contactFiles_ = contactFiles;
    274     emit contactFilesChanged();
    275 }
    276 
    277 QSet<QString> ContactFilesImporterDataManager::selectedContactFiles() const {
    278     return selectedContactFiles_;
    279 }
    280 void ContactFilesImporterDataManager::setSelectedContactFiles(const QSet<QString>& contactFiles) {
    281     selectedContactFiles_.clear();
    282     foreach (QString selected, contactFiles) {
    283         if (contactFiles_.contains(selected)) {
    284             selectedContactFiles_.insert(selected);
    285         }
    286     }
    287     emit selectedContactFilesChanged();
    288 }
     224            QScopedPointer<SContact> contact(new SContact);
     225            contact->setName(names.takeFirst());
     226            contact->setNumber(number);
     227            contact->setAliases(names);
     228
     229            contacts->insert(contact.take());
     230        }
     231    }
     232}
     233
     234ContactFilesImporterDataManager *ContactFilesImporter::dataManager() const {
     235    return m_dataManager.data();
     236}
     237
     238// *************************** DataManager *************************** //
     239
     240void ContactFilesImporterDataManager::addContactFile(const QString &path) {
     241    QFileInfo fi(path);
     242    if (!fi.isReadable()) return;
     243
     244    setContactFileSelected(path, true);
     245}
     246
     247void ContactFilesImporterDataManager::setContactFileSelected(const QString &path, bool selected) {
     248    m_selectedFileMap[path] = selected;
     249    emit dataChanged();
     250}
     251
     252bool ContactFilesImporterDataManager::isContactFileSelected(const QString &path) const {
     253    return m_selectedFileMap.value(path, false);
     254}
     255
     256const QMap<QString, bool> &ContactFilesImporterDataManager::selectionMap() const {
     257    return m_selectedFileMap;
     258}
     259
  • frontend/business/contactimporter/contactfilesimporter.h

    r217 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 
    1918#ifndef CONTACTFILESIMPORTER_H_
    2019#define CONTACTFILESIMPORTER_H_
    2120
     21#include <QMap>
    2222#include <QSettings>
     23#include <QString>
     24#include <QStringList>
    2325
    24 #include <icontactimporter.h>
     26#include "common/business/icontactimporter.h"
    2527
    2628class ContactFilesImporterDataManager;
    27 
    2829class ContactFilesImporter : public IContactImporter {
    29     Q_OBJECT
    3030    Q_INTERFACES(IContactImporter)
    3131
    3232public:
    33     ContactFilesImporter(QObject* parent);
     33    ContactFilesImporter();
    3434
    35 public: /* IContactImporterImpl */
    3635    QString describingName() const;
    37     bool    isApplicable() const;
     36    bool isApplicable() const;
    3837
    39     void                init();
    40     QList<QWizardPage*> createPreImportPages(QWidget* parent);
    41     QSet<SContact>      importContacts();
     38    void init();
     39
     40    // Caller takes ownership of contacts.
     41    void importContacts(QSet<SContact*> *contacts);
     42
     43    ContactFilesImporterDataManager *dataManager() const;
    4244
    4345private:
     
    4850
    4951private:
    50     QStringList    defaultContactsFiles() const;
     52    const QScopedPointer<ContactFilesImporterDataManager> m_dataManager;
    5153
    52     QSet<SContact> readV1ContactsFile(const QSettings& ini) const;
    53     QSet<SContact> readV2ContactsFile(const QSettings& ini) const;
     54    // Caller takes ownership of contacts.
     55    void readV1ContactsFile(const QSettings& ini, QSet<SContact*> *contacts) const;
    5456
    55     CSVFile        parseCSV(const QString& filename) const;
    56     QSet<SContact> readCSV(const CSVFile& csv) const;
     57    // Caller takes ownership of contacts.
     58    void readV2ContactsFile(const QSettings& ini, QSet<SContact*> *contacts) const;
     59
     60    CSVFile parseCSV(const QString& filename) const;
     61    void readCSV(const CSVFile& csv, QSet<SContact*> *contacts) const;
     62};
     63
     64class ContactFilesImporterDataManager : public QObject {
     65    Q_OBJECT
     66
     67public:
     68    ContactFilesImporterDataManager() {}
     69
     70    void addContactFile(const QString &path);
     71    void setContactFileSelected(const QString &path, bool selected);
     72
     73    bool isContactFileSelected(const QString &path) const;
     74    const QMap<QString, bool> &selectionMap() const;
     75
     76signals:
     77    void dataChanged();
    5778
    5879private:
    59     ContactFilesImporterDataManager* dataManager_;
     80    QMap<QString, bool> m_selectedFileMap;
    6081};
    6182
    62 #endif /* CONTACTFILESIMPORTER_H_ */
     83#endif /* ABSTRACTCONTACTFILESIMPORTER_H_ */
  • frontend/business/contactimportermanager.cpp

    r217 r315  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
     18#include "contactimportermanager.h"
    1819
    19 #include "bccontactimportermanager.h"
    20 
    21 #include "contactimporters/contactfilesimporter.h"
    22 #include "contactimporters/googlecontactimporter.h"
    23 
    24 S_SINGLETON_IMPL(BCContactImporterManager)
    25 
    26 BCContactImporterManager::BCContactImporterManager()
    27     : QObject(NULL) // singleton
    28 {
    29     registerContactImporter(new ContactFilesImporter(this));
    30     registerContactImporter(new GoogleContactImporter(this));
     20ContactImporterManager::ContactImporterManager() {
     21}
     22ContactImporterManager::~ContactImporterManager() {
     23    qDeleteAll(m_managedImporters);
    3124}
    3225
    33 void BCContactImporterManager::registerContactImporter(IContactImporter* importer) {
    34     importers_.insert(importer);
     26void ContactImporterManager::registerContactImporter(IContactImporter *importer) {
     27    m_importers.insert(importer);
    3528}
    3629
    37 void BCContactImporterManager::unregisterContactImporter(IContactImporter* importer) {
    38     importers_.remove(importer);
     30void ContactImporterManager::registerManagedContactImporter(IContactImporter *importer) {
     31    m_managedImporters.insert(importer);
     32    registerContactImporter(importer);
    3933}
    4034
    41 QSet<IContactImporter*> BCContactImporterManager::contactImporters() const {
    42     return importers_;
     35void ContactImporterManager::unregisterContactImporter(IContactImporter *importer) {
     36    m_importers.remove(importer);
     37    m_managedImporters.remove(importer);
    4338}
     39
     40QSet<IContactImporter *> ContactImporterManager::contactImporters() const {
     41    return m_importers;
     42}
  • frontend/business/contactimportermanager.h

    r217 r315  
    1717 */
    1818
    19 #ifndef BCCONTACTIMPORTERMANAGER_H_
    20 #define BCCONTACTIMPORTERMANAGER_H_
     19#ifndef CONTACTIMPORTERMANAGER_H_
     20#define CONTACTIMPORTERMANAGER_H_
    2121
    2222#include <QObject>
    2323#include <QSet>
    2424
    25 #include <smacros.h>
     25#include "common/business/icontactimporter.h"
    2626
    27 #include <icontactimporter.h>
     27class ContactImporterManager {
     28public:
     29    ContactImporterManager();
     30    ~ContactImporterManager();
    2831
    29 class BCContactImporterManager : public QObject {
    30     Q_OBJECT
    31     S_SINGLETON(BCContactImporterManager)
     32    /**
     33     * @param importer Does not take o