Changeset 347:a3a136de36b4 in SMSSender


Ignore:
Timestamp:
Mar 27, 2014 4:14:25 PM (5 years ago)
Author:
Sämy Zehnder <saemy.zehnder@…>
Branch:
separation-frontend-backend
Message:
  • Separates backend and frontend code in the ETHZ gateway.
Location:
gateways
Files:
7 added
2 deleted
6 edited
18 moved

Legend:

Unmodified
Added
Removed
  • gateways/ETHZ/business/account.cpp

    r315 r347  
    11/*
    22 ETHZ gateway plugin - The smssender plugin for the ETHZ sms platform.
    3  Copyright (C) 2010-2012, gorrión. See http://smssender.gorrion.ch
     3 Copyright (C) 2010-2014, gorrión. See http://smssender.gorrion.ch
    44
    55 This program is free software: you can redistribute it and/or modify
     
    2222
    2323#include <QDebug>
    24 #include <QDialog>
    2524#include <QThread>
    2625
    27 #include <exceptions/stdexceptions.h>
    28 #include <exceptions/loginaccountexceptions.h>
    29 
    30 #include <business/impl/defaultlogininittask.h>
    31 #include <domain/snumber.h>
    32 #include <persistence/impl/defaultaccountstoragehelper.h>
    33 #include <validation/defaultaccountvalidator.h>
    34 
    35 #include "account_tasks.h"
    36 #include "gateway.h"
    37 #include "library.h"
     26#include "common/domain/snumber.h"
     27#include "common/exceptions/stdexceptions.h"
     28#include "common/exceptions/loginaccountexceptions.h"
     29#include "common/validation/defaultaccountvalidator.h"
     30#include "gateways/common/business/defaultlogininittask.h"
     31#include "gateways/common/persistence/defaultaccountstoragehelper.h"
     32#include "gateways/ETHZ/business/account_tasks.h"
     33#include "gateways/ETHZ/business/gateway.h"
    3834
    3935namespace ETHZ {
    4036
    4137Account::Account(IGateway *gateway)
    42     : AbstractAccount(gateway)
     38    : BaseAccount(gateway)
    4339    , m_httpHelper(new SNetworkHelper)
    4440{
     
    5955    return new AccountLoginTask(this);
    6056}
    61 ISMSSendTask* Account::doCreateSMSSendTask(const QString &message, const QSet<SContact> &recipients) {
     57ISMSSendTask* Account::doCreateSMSSendTask(const QString &message, const QSet<const SContact *> &recipients) {
    6258    return new SMSSendTask(this, message, recipients);
    6359}
  • gateways/ETHZ/business/account.h

    r315 r347  
    11/*
    22 ETHZ gateway plugin - The smssender plugin for the ETHZ sms platform.
    3  Copyright (C) 2010-2012, gorrión. See http://smssender.gorrion.ch
     3 Copyright (C) 2010-2014, gorrión. See http://smssender.gorrion.ch
    44
    55 This program is free software: you can redistribute it and/or modify
     
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #ifndef ETHZ_BCACCOUNT_H_
    19 #define ETHZ_BCACCOUNT_H_
     18#ifndef ETHZ_ACCOUNT_H
     19#define ETHZ_ACCOUNT_H
    2020
    2121#include <QScopedPointer>
    2222
    23 #include <business/impl/abstractaccount.h>
    24 #include <network/snetworkhelper.h>
    25 #include <persistence/imainstorage.h>
     23#include "gateways/common/business/baseaccount.h"
     24#include "common/network/snetworkhelper.h"
    2625
    2726namespace ETHZ {
    2827
    29 class Account : public AbstractAccount {
     28class Account : public BaseAccount {
    3029    Q_OBJECT
    31 
    32     friend class ContactImporter; // httpHelper()
    33     friend class AccountLoginTask; // httpHelper()
    34     friend class SMSSendTask; // httpHelper()
    3530
    3631public:
     
    4843    int               fragmentSize() const;
    4944
     45public:
     46    SNetworkHelper *httpHelper() const;
     47
    5048protected: /* AbstractAccount */
    5149    IAccountInitTask*  doCreateInitTask();
    5250    IAccountLoginTask* doCreateLoginTask();
    53     ISMSSendTask*      doCreateSMSSendTask(const QString &message, const QSet<SContact> &recipients);
     51    ISMSSendTask*      doCreateSMSSendTask(const QString &message, const QSet<const SContact *> &recipients);
    5452
    5553protected:
     
    5755
    5856private:
    59     SNetworkHelper* httpHelper() const; // TODO: data injection -> remove friends
    6057
    6158    void               haltIfCancelled();
     
    6966}
    7067
    71 #endif /* ETHZ_BCACCOUNT_H_ */
     68#endif /* ETHZ_ACCOUNT_H */
  • gateways/ETHZ/business/account_costs.cpp

    r315 r347  
    11/*
    22 ETHZ gateway plugin - The smssender plugin for the ETHZ sms platform.
    3   Copyright (C) 2007-2012, gorrión. See http://smssender.gorrion.ch
     3  Copyright (C) 2010-2014, gorrión. See http://smssender.gorrion.ch
    44
    55  This program is free software: you can redistribute it and/or modify
  • gateways/ETHZ/business/account_task_login.cpp

    r315 r347  
    11/*
    22  ETHZ gateway plugin - The smssender plugin for the ETHZ sms platform.
    3   Copyright (C) 2007-2012, gorrión. See http://smssender.gorrion.ch
     3  Copyright (C) 2010-2014, gorrión. See http://smssender.gorrion.ch
    44
    55  This program is free software: you can redistribute it and/or modify
     
    1818#include "account_tasks.h"
    1919
    20 #include <exceptions/eloginaccountloginexception.h>
    21 #include <network/snetworkreply.h>
    22 
    23 #include "gateway.h"
     20#include "common/exceptions/eloginaccountloginexception.h"
     21#include "common/network/snetworkreply.h"
     22#include "gateways/ETHZ/business/gateway.h"
    2423
    2524namespace ETHZ {
    2625
    2726AccountLoginTask::AccountLoginTask(Account *account)
    28     : AbstractAccountLoginTask(account)
     27    : BaseAccountLoginTask(account)
    2928{
    3029}
     
    6261
    6362Account *AccountLoginTask::account() const {
    64     return static_cast<Account*>(AbstractAccountLoginTask::account());
     63    return static_cast<Account*>(BaseAccountLoginTask::account());
    6564}
    6665
  • gateways/ETHZ/business/account_task_sendsms.cpp

    r315 r347  
    11/*
    22  ETHZ gateway plugin - The smssender plugin for the ETHZ sms platform.
    3   Copyright (C) 2007-2012, gorrión. See http://smssender.gorrion.ch
     3  Copyright (C) 2010-2014, gorrión. See http://smssender.gorrion.ch
    44
    55  This program is free software: you can redistribute it and/or modify
     
    2020#include <math.h>
    2121
    22 #include <domain/snumber.h>
    23 #include <network/snetworkreply.h>
    24 
    25 #include "business/gateway.h"
     22#include "common/domain/snumber.h"
     23#include "common/network/snetworkreply.h"
     24#include "gateways/ETHZ/business/gateway.h"
    2625
    2726namespace ETHZ {
    2827
    29 SMSSendTask::SMSSendTask(Account* account, const QString &message, const QSet<SContact> &recipients)
    30     : AbstractSMSSendTask(account, message, recipients)
     28SMSSendTask::SMSSendTask(Account* account, const QString &message, const QSet<const SContact *> &recipients)
     29    : BaseSMSSendTask(account, message, recipients)
    3130{
    3231}
     
    6059
    6160            int percent_per_sms = 70 / (longSMSList.size() * ceil(recipients().size() / (double)MAX_RECIPIENTS_PER_SMS));
    62             QSetIterator<SContact> i(recipients());
     61            QSetIterator<const SContact *> i(recipients());
    6362            foreach (QString msgPart, longSMSList) {
    6463                i.toFront();
     
    6665                    haltIfCancelRequested();
    6766                    setDetails(Action::SendingSMS);
    68                     sendSMS(msgPart, i.next());
     67                    sendSMS(msgPart, *i.next());
    6968
    7069                    setProgress(progress() + percent_per_sms);
     
    129128
    130129Account* SMSSendTask::account() const {
    131     return static_cast<Account*>(AbstractSMSSendTask::account());
     130    return static_cast<Account*>(BaseSMSSendTask::account());
    132131}
    133132
  • gateways/ETHZ/business/account_tasks.h

    r315 r347  
    11/*
    22 ETHZ gateway plugin - The smssender plugin for the ETHZ sms platform.
    3  Copyright (C) 2010-2012, gorrión. See http://smssender.gorrion.ch
     3 Copyright (C) 2010-2014, gorrión. See http://smssender.gorrion.ch
    44
    55 This program is free software: you can redistribute it and/or modify
     
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #ifndef ETHZ_ACCOUNT_TASKS_H_
    19 #define ETHZ_ACCOUNT_TASKS_H_
     18#ifndef ETHZ_ACCOUNT_TASKS_H
     19#define ETHZ_ACCOUNT_TASKS_H
    2020
    21 #include <business/impl/abstractaccount_tasks.h>
    22 
    23 #include "business/account.h"
     21#include "gateways/common/business/baseaccount_tasks.h"
     22#include "gateways/ETHZ/business/account.h"
    2423
    2524namespace ETHZ {
    2625
    27 class AccountLoginTask : public AbstractAccountLoginTask {
     26class AccountLoginTask : public BaseAccountLoginTask {
    2827    Q_OBJECT
    2928
     
    4039
    4140
    42 class SMSSendTask : public AbstractSMSSendTask {
     41class SMSSendTask : public BaseSMSSendTask {
    4342    Q_OBJECT
    4443
    4544public:
    46     SMSSendTask(Account *account, const QString &message, const QSet<SContact> &recipients);
     45    SMSSendTask(Account *account, const QString &message, const QSet<const SContact *> &recipients);
    4746
    4847protected: /* AbstractAccountSendSMSTask */
     
    6059} // namespace ETHZ
    6160
    62 #endif /* ETHZ_ACCOUNT_TASKS_H_ */
     61#endif /* ETHZ_ACCOUNT_TASKS_H */
  • gateways/ETHZ/business/contactimporter/contactimporter.cpp

    r315 r347  
    11/*
    22 ETHZ gateway plugin - The smssender plugin for the ETHZ sms platform.
    3  Copyright (C) 2010-2012, gorrión. See http://smssender.gorrion.ch
     3 Copyright (C) 2010-2014, gorrión. See http://smssender.gorrion.ch
    44
    55 This program is free software: you can redistribute it and/or modify
     
    1717 */
    1818#include "contactimporter.h"
    19 #include "contactimporter_p.h"
    2019
    21 #include <domain/scontact.h>
    22 #include <domain/snumber.h>
    23 #include <network/snetworkreply.h>
    24 
    25 #include "business/account.h"
    26 #include "business/gateway.h"
     20#include "common/domain/scontact.h"
     21#include "common/domain/snumber.h"
     22#include "common/network/snetworkreply.h"
     23#include "gateways/ETHZ/business/account.h"
     24#include "gateways/ETHZ/business/gateway.h"
    2725
    2826namespace ETHZ {
    2927
    30 ContactImporter::ContactImporter(const IAccountIntegrationHelper *accountHelper)
    31     : m_dataManager(new ContactImporterDataManager)
    32     , m_accountHelper(accountHelper)
     28ContactImporter::ContactImporter(Account *account)
     29    : m_account(account)
    3330{
    3431}
    3532
    36 QString ContactImporter::describingName() const {
     33void ContactImporter::importContacts(QSet<SContact *> *contacts) {
     34    QList<IParam*> posts;
     35    posts.append(new SKeyValueParam("username", m_account->username().toUtf8()));
     36    posts.append(new SKeyValueParam("password", m_account->password().toUtf8()));
     37    posts.append(new SKeyValueParam("action",   "listaddressbook"));
     38
     39    QString response =
     40            m_account->httpHelper()->syncPost(URL_SENDSMS, posts)->readAll();
     41    if (!response.startsWith("200")) {
     42        EException(response)
     43                .raise();
     44    }
     45
     46    /* "AAAh92AALAAAF5HACv","Hans","+4179991212","0"
     47       "AAAh92AALAAAF5HACw","Hansi","0766541234","0" */
     48    QRegExp rx("\"[^\"]+\",\"([^\"]+)\",\"([+]?\\d+)\"");
     49
     50    int pos = 0;
     51    while ((pos = rx.indexIn(response, pos)) != -1) {
     52        QString name = SNetworkHelper::urldecodeString(rx.cap(1));
     53        SNumber number(rx.cap(2));
     54        if (!name.isEmpty() && number.isValid()) {
     55            QScopedPointer<SContact> contact(new SContact);
     56            contact->setName(name);
     57            contact->setNumber(number);
     58
     59            contacts->insert(contact.take());
     60        }
     61
     62        pos += rx.matchedLength();
     63    }
     64}
     65
     66/********************************** Builder ***********************************/
     67
     68ContactImporter::Builder::Builder(IAccountIntegrationHelper *accountHelper)
     69    : m_accountHelper(accountHelper)
     70{
     71}
     72
     73QString ContactImporter::Builder::description() const {
    3774    if (isApplicable()) {
    3875        return QObject::tr("Import contacts from the ETHZ website.");
     
    4279}
    4380
    44 bool ContactImporter::isApplicable() const {
     81bool ContactImporter::Builder::isApplicable() const {
    4582    return !m_accountHelper->hasLoggedInAccounts();
    4683}
    4784
     85void ContactImporter::Builder::createImporters(QSet<IContactImporter *> *importers) {
     86    foreach (IAccount *iaccount, m_accountHelper->loggedInAccounts()) {
     87        Account *account = static_cast<Account*>(iaccount);
    4888
    49 void ContactImporter::init() {
    50     const QSet<IAccount*> &loggedInIAccounts = m_accountHelper->loggedInAccounts();
    51 
    52     // TODO: is this cast save?
    53     const QSet<Account*> &loggedInAccounts = reinterpret_cast<const QSet<Account*> &>(loggedInIAccounts);
    54     m_dataManager->setSelectedAccounts(loggedInAccounts);
    55 }
    56 
    57 QList<QWizardPage*> ContactImporter::preImportPages(QWidget* parent) {
    58     Q_UNUSED(parent);
    59     return QList<QWizardPage*>();
    60 }
    61 QSet<SContact> ContactImporter::importContacts() {
    62     QSet<SContact> contacts;
    63 
    64     foreach (Account *account, m_dataManager->selectedAccounts()) {
    65         if (!account->isLoggedIn()) continue;
    66 
    67         QList<IParam*> posts;
    68         posts.append(new SKeyValueParam("username", account->username().toUtf8()));
    69         posts.append(new SKeyValueParam("password", account->password().toUtf8()));
    70         posts.append(new SKeyValueParam("action",   "listaddressbook"));
    71 
    72         QString response = account->httpHelper()->syncPost(URL_SENDSMS, posts)->readAll();
    73         if (!response.startsWith("200")) {
    74             EException(response)
    75                     .raise();
    76         }
    77 
    78         /* "AAAh92AALAAAF5HACv","Hans","+4179991212","0"
    79            "AAAh92AALAAAF5HACw","Hansi","0766541234","0" */
    80         QRegExp rx("\"[^\"]+\",\"([^\"]+)\",\"([+]?\\d+)\"");
    81 
    82         int pos = 0;
    83         while ((pos = rx.indexIn(response, pos)) != -1) {
    84             QString name = SNetworkHelper::urldecodeString(rx.cap(1));
    85             SNumber number(rx.cap(2));
    86             if (!name.isEmpty() && number.isValid()) {
    87                 SContact contact;
    88                 contact.setName(name);
    89                 contact.setNumber(number);
    90 
    91                 contacts.insert(contact);
    92             }
    93 
    94             pos += rx.matchedLength();
    95         }
     89        importers->insert(new ContactImporter(account));
    9690    }
    97 
    98     return contacts;
    9991}
    10092
  • gateways/ETHZ/business/contactimporter/contactimporter.h

    r315 r347  
    11/*
    22 ETHZ gateway plugin - The smssender plugin for the ETHZ sms platform.
    3  Copyright (C) 2010-2012, gorrión. See http://smssender.gorrion.ch
     3 Copyright (C) 2010-2014, gorrión. See http://smssender.gorrion.ch
    44
    55 This program is free software: you can redistribute it and/or modify
     
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #ifndef ETHZ_CONTACTIMPORTER_H_
    19 #define ETHZ_CONTACTIMPORTER_H_
     18#ifndef ETHZ_CONTACTIMPORTER_CONTACTIMPORTER_H
     19#define ETHZ_CONTACTIMPORTER_CONTACTIMPORTER_H
    2020
    2121#include <QScopedPointer>
    2222
    23 #include <business/icontactimporter.h>
    24 #include <business/iintegration.h>
    25 #include <domain/scontact.h>
     23#include "common/business/icontactimporter.h"
     24#include "common/business/iintegration.h"
     25#include "common/domain/scontact.h"
     26#include "gateways/ETHZ/business/account.h"
    2627
    2728namespace ETHZ {
     
    3132class ContactImporter : public IContactImporter {
    3233public:
    33     explicit ContactImporter(const IAccountIntegrationHelper *accountHelper);
     34    explicit ContactImporter(Account *account);
    3435
    3536public: /* IContactImporter */
    36     QString describingName() const;
    37     bool isApplicable() const;
     37    void importContacts(QSet<SContact *> *contacts);
    3838
    39     void init();
    40     QList<QWizardPage*> preImportPages(QWidget* parent);
    41     QSet<SContact> importContacts();
     39
     40    class Builder : public IContactImporter::Builder {
     41    public:
     42        explicit Builder(IAccountIntegrationHelper *accountHelper);
     43
     44    public: /* IContactImporter::Builder */
     45        QString description() const;
     46        bool isApplicable() const;
     47
     48        void createImporters(QSet<IContactImporter *> *importers);
     49
     50    private:
     51        IAccountIntegrationHelper *m_accountHelper;
     52
     53        Q_DISABLE_COPY(Builder)
     54    };
    4255
    4356private:
    44     const QScopedPointer<ContactImporterDataManager> m_dataManager;
    45     const IAccountIntegrationHelper * const m_accountHelper;
     57    static const QString URL_CONTACT_LIST;
     58
     59    Account * const m_account;
     60
     61    Q_DISABLE_COPY(ContactImporter)
    4662};
    4763
    4864} // namespace ETHZ
    4965
    50 #endif /* ETHZ_CONTACTIMPORTER_H_ */
     66#endif /* ETHZ_CONTACTIMPORTER_CONTACTIMPORTER_H */
  • gateways/ETHZ/business/gateway.cpp

    r315 r347  
    11/*
    22 ETHZ gateway plugin - The smssender plugin for the ETHZ sms platform.
    3  Copyright (C) 2010-2012, gorrión. See http://smssender.gorrion.ch
     3 Copyright (C) 2010-2014, gorrión. See http://smssender.gorrion.ch
    44
    55 This program is free software: you can redistribute it and/or modify
     
    2020#include <math.h>
    2121
    22 #include "business/account.h"
    23 #include "ui/settingswidget.h"
     22#include "gateways/ETHZ/business/account.h"
    2423
    2524namespace ETHZ {
     
    2726QString Gateway::name() const {
    2827    return "ETHZ";
    29 }
    30 
    31 QImage Gateway::icon() const {
    32     return QImage(":/images/ethz.ico");
    3328}
    3429
     
    6055}
    6156
    62 IAccountSettingsWidget *Gateway::createAccountSettingsWidget(QWidget *parent) const {
    63     return new UI::SettingsWidget(parent);
    64 }
    65 
    6657::Persistence::IStorageHelper *Gateway::createStorageHelper(Persistence::IMainStorage *storage) {
    6758    Q_UNUSED(storage);
  • gateways/ETHZ/business/gateway.h

    r315 r347  
    11/*
    22 ETHZ gateway plugin - The smssender plugin for the ETHZ sms platform.
    3  Copyright (C) 2010-2012, gorrión. See http://smssender.gorrion.ch
     3 Copyright (C) 2010-2014, gorrión. See http://smssender.gorrion.ch
    44
    55 This program is free software: you can redistribute it and/or modify
     
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #ifndef ETHZ_GATEWAY_H_
    19 #define ETHZ_GATEWAY_H_
     18#ifndef ETHZ_GATEWAY_H
     19#define ETHZ_GATEWAY_H
    2020
    2121#include <QSet>
    2222
    23 #include <business/igateway.h>
     23#include "common/business/igateway.h"
    2424
    2525namespace ETHZ {
     
    3737public: /* IGateway */
    3838    QString name() const;
    39     QImage icon() const;
     39
     40#ifdef FRONTEND_GUI
     41    QIcon icon() const;
     42    IAccountSettingsWidget *createAccountSettingsWidget(QWidget *parent) const;
     43#endif
    4044
    4145public: /* IGateway */
     
    4549
    4650public: /* IGateway */
    47     IAccountSettingsWidget *createAccountSettingsWidget(QWidget *parent) const;
    4851    IAccount *createAccountInstance();
    4952
     
    5457}
    5558
    56 #endif /* ETHZ_GATEWAY_H_ */
     59#endif /* ETHZ_GATEWAY_H */
  • gateways/ETHZ/ethz-base.pro

    r315 r347  
     1include(../../smssender.pri)
     2
    13BASE_VERSION = 1.0
    2 !include(../gateways.pri):!include(/usr/include/smssender/gateways.pri):error("Could not include gateways.pri")
    3 TARGET = ETHZ
    4 include(locale/locale.pri)
    5 HEADERS += \
    6     src/library.h \
    7     src/business/contactimporter/contactimporter.h \
    8     src/business/contactimporter/contactimporter_p.h \
    9     src/business/gateway.h \
    10     src/business/account_tasks.h \
    11     src/business/account.h \
    12     src/ui/settingswidget.h
    13 SOURCES += \
    14     src/library.cpp \
    15     src/business/contactimporter/contactimporter.cpp \
    16     src/business/account.cpp \
    17     src/business/account_costs.cpp \
    18     src/business/account_task_login.cpp \
    19     src/business/account_task_sendsms.cpp \
    20     src/business/gateway.cpp \
    21     src/ui/settingswidget.cpp
    22 FORMS += \
    23     src/ui/settingswidget.ui
    24 RESOURCES += lib/ethz.qrc
     4
     5TARGET = ethz-base
     6
     7TEMPLATE = lib
     8CONFIG += \
     9    staticlib
     10
     11QT = \
     12    core \
     13    network \
     14    sql \
     15    xml
     16
     17LIBS += \
     18    -L../../ -l$$COMMON$$LIB_SUFFIX \
     19    -L../../ -lgateways-common$$LIB_SUFFIX
     20
     21# Needed so that this target gets rebuilt if they change,
     22PRE_TARGETDEPS += \
     23    ../../libgateways-common$${LIB_SUFFIX}.$$EXT_DYNAMICLIB \
     24    ../../lib$$COMMON$${LIB_SUFFIX}.$$EXT_DYNAMICLIB
     25
     26install_dev_files:unix {
     27    target.path = /usr/lib/smssender/gateways
     28    INSTALLS += target
     29}
     30
     31HEADERS = \
     32    business/account.h \
     33    business/account_tasks.h \
     34    business/contactimporter/contactimporter.h \
     35    business/gateway.h \
     36
     37SOURCES = \
     38    business/account.cpp \
     39    business/account_costs.cpp \
     40    business/account_task_login.cpp \
     41    business/account_task_sendsms.cpp \
     42    business/contactimporter/contactimporter.cpp \
     43    business/gateway.cpp \
     44
     45RESOURCES = \
     46    lib/ethz.qrc
     47
     48install_dev_files:unix {
     49    headers.path = /usr/include/smssender/gateways/ETHZ
     50    headers.files = $$HEADERS
     51    INSTALLS += headers
     52}
  • gateways/ETHZ/gui/ethz.cpp

    r315 r347  
    11/*
    22 ETHZ gateway plugin - The smssender plugin for the ETHZ sms platform.
    3  Copyright (C) 2010-2012, gorrión. See http://smssender.gorrion.ch
     3 Copyright (C) 2010-2014, gorrión. See http://smssender.gorrion.ch
    44
    55 This program is free software: you can redistribute it and/or modify
     
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #include "library.h"
     18#include "ethz.h"
    1919
    2020#include <QLocale>
    2121
    22 #include <domain/sversion.h>
    23 
    24 #include "business/contactimporter/contactimporter.h"
    25 #include "business/gateway.h"
     22#include "common/domain/sversion.h"
     23#include "gateways/ETHZ/business/contactimporter/contactimporter.h"
     24#include "gateways/ETHZ/business/gateway.h"
    2625
    2726namespace ETHZ {
    2827
    29 QString Library::compatibilityVersion() const {
    30     return COMPATIBILITY_VERSION;
     28Library::Library() {
    3129}
    3230
    33 QString Library::identificationKey() const {
    34     return "ETHZ";
    35 }
    36 SVersion Library::version() const {
    37     return SVersion(LIB_VERSION);
    38 }
    39 
    40 bool Library::doInit(QSet<QTranslator*> *translators, IGateway **gateway,
    41                      QSet<IContactImporter*> *contactImporters)
     31bool Library::doInit(
     32        const IBaseIntegrationHelper::Factory &integrationHelperFactory,
     33        QSet<QTranslator*> *translators, IGateway **gateway,
     34        QSet<IContactImporter::Builder *> *contactImporters)
    4235{
    4336    // Translators
    4437    QLocale l; // Loads default locale
    4538    QScopedPointer<QTranslator> t(new QTranslator);
    46     if (t->load("ethz-" + l.name(), ":/locale")) {
     39    if (t->load("schoolnet-" + l.name(), ":/locale")) {
    4740        translators->insert(t.take());
    4841    }
     
    5043    // Gateway
    5144    *gateway = new Gateway;
     45    m_integrationHelper.reset(integrationHelperFactory.createIntegrationHelper(*gateway));
    5246
    5347    // Contact importer
    54     contactImporters->insert(new ContactImporter(integrationHelper()->accountHelper()));
     48    contactImporters->insert(new ContactImporter::Builder(
     49                                 m_integrationHelper->accountHelper()));
    5550
    5651    return true;
  • gateways/ETHZ/gui/ethz.h

    r315 r347  
    11/*
    22 ETHZ gateway plugin - The smssender plugin for the ETHZ sms platform.
    3  Copyright (C) 2010-2012, gorrión. See http://smssender.gorrion.ch
     3 Copyright (C) 2010-2014, gorrión. See http://smssender.gorrion.ch
    44
    55 This program is free software: you can redistribute it and/or modify
     
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #ifndef ETHZ_MAIN_H_
    19 #define ETHZ_MAIN_H_
     18#ifndef ETHZ_GUI_ETHZ_H
     19#define ETHZ_GUI_ETHZ_H
    2020
    21 #include <business/impl/abstractlibrary.h>
     21#include <QScopedPointer>
     22
     23#include "gateways/common/business/baselibrary.h"
    2224
    2325namespace ETHZ {
    2426
    25 class Library : public AbstractLibrary {
    26 public: /* ILibrary */
    27     QString compatibilityVersion() const;
     27class Library : public BaseLibrary {
     28    S_LIBRARY("ETHZ")
    2829
    29     QString identificationKey() const;
    30     SVersion version() const;
     30public:
     31    Library();
    3132
    3233protected:
    33     bool doInit(QSet<QTranslator*> *translators, IGateway **gateway,
    34                 QSet<IContactImporter*> *contactImporters);
     34    bool doInit(const IIntegrationHelper::Factory &integrationHelperFactory,
     35                QSet<QTranslator*> *translators, IGateway **gateway,
     36                QSet<IContactImporter::Builder *> *contactImporters);
     37
     38private:
     39    QScopedPointer<IIntegrationHelper> m_integrationHelper;
    3540};
    3641
    3742} // namespace ETHZ
    3843
    39 #endif /* ETHZ_MAIN_H_ */
     44#endif /* ETHZ_GUI_ETHZ_H */
  • gateways/ETHZ/gui/ui/settingswidget.cpp

    r315 r347  
    11/*
    22 ETHZ gateway plugin - The smssender plugin for the ETHZ sms platform.
    3  Copyright (C) 2010-2012, gorrión. See http://smssender.gorrion.ch
     3 Copyright (C) 2010-2014, gorrión. See http://smssender.gorrion.ch
    44
    55 This program is free software: you can redistribute it and/or modify
     
    2121#include <QMessageBox>
    2222
    23 #include <exceptions/stdexceptions.h>
    24 
    25 #include "business/account.h"
    26 #include "business/gateway.h"
     23#include "common/exceptions/stdexceptions.h"
     24#include "gateways/ETHZ/business/account.h"
     25#include "gateways/ETHZ/business/gateway.h"
    2726
    2827namespace ETHZ {
  • gateways/ETHZ/gui/ui/settingswidget.h

    r315 r347  
    11/*
    22 ETHZ gateway plugin - The smssender plugin for the ETHZ sms platform.
    3  Copyright (C) 2010-2012, gorrión. See http://smssender.gorrion.ch
     3 Copyright (C) 2010-2014, gorrión. See http://smssender.gorrion.ch
    44
    55 This program is free software: you can redistribute it and/or modify
     
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 #ifndef ETHZ_SETTINGSWIDGET_H
    19 #define ETHZ_SETTINGSWIDGET_H
     18#ifndef ETHZ_GUI_UI_SETTINGSWIDGET_H
     19#define ETHZ_GUI_UI_SETTINGSWIDGET_H
     20
     21#include "ui_settingswidget.h"
    2022
    2123#include <QtGui/QWidget>
    22 #include "ui_settingswidget.h"
    2324
    24 #include <ui/iaccountsettingswidget.h>
     25#include "common/gui/ui/iaccountsettingswidget.h"
    2526
    2627namespace ETHZ {
     
    4647} // namespace ETHZ
    4748
    48 #endif // ETHZ_SETTINGSWIDGET_H
     49#endif // ETHZ_GUI_UI_SETTINGSWIDGET_H
  • gateways/ETHZ/lib/ethz.qrc

    r148 r347  
    11<RCC>
    2     <qresource prefix="/images">
    3         <file>ethz.ico</file>
    4     </qresource>
    52    <qresource prefix="/certs">
    63        <file>QuoVadisRootCA.crt</file>
  • gateways/ETHZ/locale/de.ts

    r231 r347  
    11<?xml version="1.0" encoding="utf-8"?>
    22<!DOCTYPE TS>
    3 <TS version="2.0" language="de_CH" sourcelanguage="en">
     3<TS version="2.1" language="de_CH" sourcelanguage="en">
    44<context>
    5     <name>ETHZ::BCAccount</name>
     5    <name>ETHZ::SMSSendTask</name>
    66    <message>
    7         <source>The ETHZ website has changed.</source>
    8         <translation type="obsolete">Die ETHZ Webseite wurde geändert.</translation>
    9     </message>
    10     <message>
    11         <source>You have only %1 SMS for free but you need at least %2 SMS left to send this message.</source>
    12         <translation type="obsolete">Du hast nur noch %1 Gratis-SMS. Es werden jedoch %2 Gratis-SMS benötigt, um diese Mitteilung verschicken zu können.</translation>
    13     </message>
    14     <message>
    15         <source>The sending of the sms was requested to cancel, but (a part of) the sms has already been sent.</source>
    16         <translation type="obsolete">Der SMS-Versandt wurde abgebrochen. Ein Teil der SMS wurde zu diesem Zeitpunkt jedoch bereits versendet.</translation>
    17     </message>
    18 </context>
    19 <context>
    20     <name>ETHZ::BCSMSSendTask</name>
    21     <message>
    22         <location filename="../src/business/bcaccount_task_sendsms.cpp" line="90"/>
     7        <location filename="../business/account_task_sendsms.cpp" line="90"/>
    238        <source>The sending of the sms was requested to cancel, but (a part of) the sms has already been sent.</source>
    249        <translation>Der SMS-Versandt wurde abgebrochen. Ein Teil der SMS wurde zu diesem Zeitpunkt jedoch bereits versendet.</translation>
     
    2611</context>
    2712<context>
    28     <name>ETHZ::BCSMSSendTaskPriv</name>
    29     <message>
    30         <source>The sending of the sms was requested to cancel, but (a part of) the sms has already been sent.</source>
    31         <translation type="obsolete">Der SMS-Versandt wurde abgebrochen. Ein Teil der SMS wurde zu diesem Zeitpunkt jedoch bereits versendet.</translation>
    32     </message>
    33 </context>
    34 <context>
    35     <name>ETHZ::VCSettingsWidgetClass</name>
    36     <message>
    37         <location filename="../src/ui/vcsettingswidget.ui" line="20"/>
    38         <source>Username:</source>
    39         <translation>Benutzername:</translation>
    40     </message>
    41     <message>
    42         <location filename="../src/ui/vcsettingswidget.ui" line="33"/>
    43         <source>Password:</source>
    44         <translation>Passwort:</translation>
    45     </message>
    46 </context>
    47 <context>
    4813    <name>QObject</name>
    4914    <message>
    50         <location filename="../src/business/contactimporter/bccontactimporter.cpp" line="39"/>
     15        <location filename="../business/contactimporter/contactimporter.cpp" line="75"/>
    5116        <source>Import contacts from the ETHZ website.</source>
    5217        <translation>Importiere Kontakte von der ETHZ Webseite.</translation>
    5318    </message>
    5419    <message>
    55         <location filename="../src/business/contactimporter/bccontactimporter.cpp" line="41"/>
     20        <location filename="../business/contactimporter/contactimporter.cpp" line="77"/>
    5621        <source>Import contacts from the ETHZ website. (No logged in accounts)</source>
    5722        <translation>Importiere Kontakte von der ETHZ Webseite. (Keine eingeloggten Konten vorhanden)</translation>
    5823    </message>
    5924</context>
    60 <context>
    61     <name>VCSettingsWidgetClass</name>
    62     <message>
    63         <source>Username:</source>
    64         <translation type="obsolete">Benutzername:</translation>
    65     </message>
    66     <message>
    67         <source>Password:</source>
    68         <translation type="obsolete">Passwort:</translation>
    69     </message>
    70 </context>
    7125</TS>
  • gateways/ETHZ/locale/de_CH.ts

    r282 r347  
    11<?xml version="1.0" encoding="utf-8"?>
    22<!DOCTYPE TS>
    3 <TS version="2.0" language="de_CH" sourcelanguage="en">
     3<TS version="2.1" language="de_CH" sourcelanguage="en">
    44<context>
    5     <name>ETHZ::BCSMSSendTask</name>
     5    <name>ETHZ::SMSSendTask</name>
    66    <message>
    7         <location filename="../src/business/bcaccount_task_sendsms.cpp" line="90"/>
     7        <location filename="../business/account_task_sendsms.cpp" line="90"/>
    88        <source>The sending of the sms was requested to cancel, but (a part of) the sms has already been sent.</source>
    99        <translation>Dr SMS-Versandt isch abbroche worde. E Teil vom SMS isch abr zu däm Zitpunkt scho versändet worde.</translation>
     
    1111</context>
    1212<context>
    13     <name>ETHZ::BCSMSSendTaskPriv</name>
    14     <message>
    15         <source>The sending of the sms was requested to cancel, but (a part of) the sms has already been sent.</source>
    16         <translation type="obsolete">S Sände vom SMS isch abbroche worde. Es isch abr bereits e Teil vo dr SMS vrschickt worde.</translation>
    17     </message>
    18 </context>
    19 <context>
    20     <name>ETHZ::VCSettingsWidgetClass</name>
    21     <message>
    22         <location filename="../src/ui/vcsettingswidget.ui" line="20"/>
    23         <source>Username:</source>
    24         <translation>Benutzername:</translation>
    25     </message>
    26     <message>
    27         <location filename="../src/ui/vcsettingswidget.ui" line="33"/>
    28         <source>Password:</source>
    29         <translation>Passwort:</translation>
    30     </message>
    31 </context>
    32 <context>
    3313    <name>QObject</name>
    3414    <message>
    35         <location filename="../src/business/contactimporter/bccontactimporter.cpp" line="39"/>
     15        <location filename="../business/contactimporter/contactimporter.cpp" line="75"/>
    3616        <source>Import contacts from the ETHZ website.</source>
    3717        <translation>Importier Kontäggt vo dr ETHZ Website.</translation>
    3818    </message>
    3919    <message>
    40         <location filename="../src/business/contactimporter/bccontactimporter.cpp" line="41"/>
     20        <location filename="../business/contactimporter/contactimporter.cpp" line="77"/>
    4121        <source>Import contacts from the ETHZ website. (No logged in accounts)</source>
    4222        <translation>Importier Kontäggt vo dr ETHZ Website. (Keini iigloggte Konte vorhande)</translation>
  • gateways/ETHZ/locale/fr.ts

    r231 r347  
    11<?xml version="1.0" encoding="utf-8"?>
    22<!DOCTYPE TS>
    3 <TS version="2.0" language="fr_CH" sourcelanguage="en_US">
     3<TS version="2.1" language="fr_CH" sourcelanguage="en_US">
    44<context>
    5     <name>ETHZ::BCAccount</name>
     5    <name>ETHZ::SMSSendTask</name>
    66    <message>
    7         <source>You have only %1 SMS for free but you need at least %2 SMS left to send this message.</source>
    8         <translation type="obsolete">Il vous reste seulement %1 des SMS gratuitement, mais vous avez besoin d&apos;au moins %2 SMS pour envoyer ce message.</translation>
    9     </message>
    10     <message>
    11         <source>The sending of the sms was requested to cancel, but (a part of) the sms has already been sent.</source>
    12         <translation type="obsolete">L&apos;envoi des sms a été prié d&apos;annuler, mais (une partie) du sms a déjà été envoyé.</translation>
    13     </message>
    14 </context>
    15 <context>
    16     <name>ETHZ::BCSMSSendTask</name>
    17     <message>
    18         <location filename="../src/business/bcaccount_task_sendsms.cpp" line="90"/>
     7        <location filename="../business/account_task_sendsms.cpp" line="90"/>
    198        <source>The sending of the sms was requested to cancel, but (a part of) the sms has already been sent.</source>
    209        <translation>L&apos;envoi des sms a été prié d&apos;annuler, mais (une partie) du sms a déjà été envoyé.</translation>
     
    2211</context>
    2312<context>
    24     <name>ETHZ::BCSMSSendTaskPriv</name>
    25     <message>
    26         <source>The sending of the sms was requested to cancel, but (a part of) the sms has already been sent.</source>
    27         <translation type="obsolete">L&apos;envoi des sms a été prié d&apos;annuler, mais (une partie) du sms a déjà été envoyé.</translation>
    28     </message>
    29 </context>
    30 <context>
    31     <name>ETHZ::VCSettingsWidgetClass</name>
    32     <message>
    33         <location filename="../src/ui/vcsettingswidget.ui" line="20"/>
    34         <source>Username:</source>
    35         <translation>Nom d&apos;utilisateur:</translation>
    36     </message>
    37     <message>
    38         <location filename="../src/ui/vcsettingswidget.ui" line="33"/>
    39         <source>Password:</source>
    40         <translation>Mot de passe:</translation>
    41     </message>
    42 </context>
    43 <context>
    4413    <name>QObject</name>
    4514    <message>
    46         <location filename="../src/business/contactimporter/bccontactimporter.cpp" line="39"/>
     15        <location filename="../business/contactimporter/contactimporter.cpp" line="75"/>
    4716        <source>Import contacts from the ETHZ website.</source>
    4817        <translation>Importer les contacts à partir du site Web ETHZ.</translation>
    4918    </message>
    5019    <message>
    51         <location filename="../src/business/contactimporter/bccontactimporter.cpp" line="41"/>
     20        <location filename="../business/contactimporter/contactimporter.cpp" line="77"/>
    5221        <source>Import contacts from the ETHZ website. (No logged in accounts)</source>
    5322        <translation>Importer des contacts à partir du site Web ETHZ. (Pas de comptes connectés)</translation>
  • gateways/ETHZ/locale/it.ts

    r231 r347  
    11<?xml version="1.0" encoding="utf-8"?>
    22<!DOCTYPE TS>
    3 <TS version="2.0" language="it" sourcelanguage="en">
     3<TS version="2.1" language="it" sourcelanguage="en">
    44<context>
    5     <name>ETHZ::BCSMSSendTask</name>
     5    <name>ETHZ::SMSSendTask</name>
    66    <message>
    7         <location filename="../src/business/bcaccount_task_sendsms.cpp" line="90"/>
     7        <location filename="../business/account_task_sendsms.cpp" line="90"/>
    88        <source>The sending of the sms was requested to cancel, but (a part of) the sms has already been sent.</source>
    9         <translation type="unfinished"></translation>
    10     </message>
    11 </context>
    12 <context>
    13     <name>ETHZ::VCSettingsWidgetClass</name>
    14     <message>
    15         <location filename="../src/ui/vcsettingswidget.ui" line="20"/>
    16         <source>Username:</source>
    17         <translation type="unfinished"></translation>
    18     </message>
    19     <message>
    20         <location filename="../src/ui/vcsettingswidget.ui" line="33"/>
    21         <source>Password:</source>
    229        <translation type="unfinished"></translation>
    2310    </message>
     
    2613    <name>QObject</name>
    2714    <message>
    28         <location filename="../src/business/contactimporter/bccontactimporter.cpp" line="39"/>
     15        <location filename="../business/contactimporter/contactimporter.cpp" line="75"/>
    2916        <source>Import contacts from the ETHZ website.</source>
    3017        <translation type="unfinished"></translation>
    3118    </message>
    3219    <message>
    33         <location filename="../src/business/contactimporter/bccontactimporter.cpp" line="41"/>
     20        <location filename="../business/contactimporter/contactimporter.cpp" line="77"/>
    3421        <source>Import contacts from the ETHZ website. (No logged in accounts)</source>
    3522        <translation type="unfinished"></translation>
  • gateways/gateways.pro

    r337 r347  
    11TEMPLATE = subdirs
    22
    3 #SUBDIRS += ethz orange post schoolnet sunrise smartphone
    4 SUBDIRS += gateways-common schoolnet smartphone sunrise
     3SUBDIRS += \
     4    gateways-common \
     5\
     6    ethz \
     7    schoolnet \
     8    smartphone \
     9    sunrise
    510
    611gateways-common.file = common/gateways-common.pro
    712
    8 #ethz.file = ETHZ/ethz.pro
    9 #orange.file = Orange/orange.pro
     13ethz.file = ETHZ/ethz.pro
    1014#post.file = Post/post.pro
    1115schoolnet.file = Schoolnet/schoolnet.pro
Note: See TracChangeset for help on using the changeset viewer.