Changeset 376:0d8179eea17f in SMSSender
- Timestamp:
- Apr 14, 2014 1:28:38 PM (7 years ago)
- Branch:
- separation-frontend-backend
- Location:
- gateways
- Files:
-
- 10 added
- 3 deleted
- 2 edited
- 1 copied
- 18 moved
Legend:
- Unmodified
- Added
- Removed
-
gateways/Post/business/account.cpp
r315 r376 1 1 /* 2 2 Swiss Post gateway plugin - The smssender plugin for the Swiss Post platform. 3 Copyright (C) 2011-201 2, gorrión. See http://smssender.gorrion.ch3 Copyright (C) 2011-2014, gorrión. See http://smssender.gorrion.ch 4 4 5 5 This program is free software: you can redistribute it and/or modify … … 22 22 23 23 #include <QDebug> 24 #include <QDialog>25 24 #include <QThread> 26 25 27 #include <business/impl/defaultlogininittask.h> 28 #include <domain/snumber.h> 29 #include <exceptions/stdexceptions.h> 30 #include <exceptions/loginaccountexceptions.h> 31 #include <network/snetworkreply.h> 32 #include <persistence/impl/defaultaccountstoragehelper.h> 33 #include <validation/defaultaccountvalidator.h> 34 35 #include "business/account_tasks.h" 36 #include "business/gateway.h" 37 #include "library.h" 26 #include "common/domain/snumber.h" 27 #include "common/exceptions/loginaccountexceptions.h" 28 #include "common/exceptions/stdexceptions.h" 29 #include "common/network/snetworkreply.h" 30 #include "common/validation/defaultaccountvalidator.h" 31 #include "gateways/common/business/defaultlogininittask.h" 32 #include "gateways/common/persistence/defaultaccountstoragehelper.h" 33 #include "gateways/Post/business/account_tasks.h" 34 #include "gateways/Post/business/gateway.h" 38 35 39 36 namespace Post { 40 37 41 38 Account::Account(IGateway *gateway) 42 : AbstractAccount(gateway)39 : BaseAccount(gateway) 43 40 , m_httpHelper(new SNetworkHelper) 44 41 , m_longSMSLength(435) // Default value from post.ch 45 42 { 46 m_httpHelper->addTrustedCA(":/certs/VerisignCA3.crt"); 43 m_httpHelper->addTrustedCA(":/certs/Verisign_class3_root.crt"); 44 m_httpHelper->addTrustedCA(":/certs/VerisignCA_G3.crt"); 45 m_httpHelper->addTrustedCA(":/certs/VerisignCA_G5.crt"); 47 46 48 47 connect(this, SIGNAL(initStateChanged(IAccount*)), … … 50 49 } 51 50 52 Persistence::IStorageHelper* Account::createStorageHelper(Persistence::IMainStorage *storage) { 53 return new Persistence::DefaultAccountStorageHelper(this, storage, "s2uh98dWe9D_wf98h23:*EOnqei8D"); 51 Persistence::IStorageHelper* Account::createStorageHelper( 52 Persistence::IMainStorage *storage) { 53 return new Persistence::DefaultAccountStorageHelper( 54 this, storage, "s2uh98dWe9D_wf98h23:*EOnqei8D"); 54 55 } 55 56 IValidator* Account::createValidator() const { … … 63 64 return new AccountLoginTask(this); 64 65 } 65 ISMSSendTask* Account::doCreateSMSSendTask(const QString &message, const QSet<SContact> &recipients) { 66 ISMSSendTask* Account::doCreateSMSSendTask( 67 const QString &message, const QSet<const SContact *> &recipients) 68 { 66 69 return new SMSSendTask(this, message, recipients); 67 70 } … … 86 89 result = html.contains("Error", Qt::CaseSensitive); 87 90 } catch (EException &e) { 88 qWarning() << "Error while checking if we are still logged in: " + e.what(); 89 qWarning() << "But ignoring it, since we just do a new login attempt."; 91 qWarning() << "Error while checking if we are still logged in: " 92 << e.what() 93 << "But ignoring it, since we just do a new login attempt."; 90 94 result = false; 91 95 } … … 104 108 } 105 109 void Account::reloadLongSMSLength(QString html) { 106 /*<textarea name="sms_body" style="width: 100%; height: 117px" cols=2 rows=2 maxlength="435" onKeyUp="left_char(this)"></textarea>*/ 110 /*<textarea name="sms_body" style="width: 100%; height: 117px" cols=2 rows=2 111 * maxlength="435" onKeyUp="left_char(this)"></textarea>*/ 107 112 108 113 QRegExp rx("<textarea name=\"sms_body\"[^>]*maxlength=\"(\\d+)\""); … … 119 124 /*<td class="label">50 von 50 TextSMS im Monat xxx</td> */ 120 125 121 QRegExp rx("<td class=\"label\">(\\d+) von \\d+ TextSMS im Monat [a-zA-Zäöü]+</td>"); 122 rx.setCaseSensitivity(Qt::CaseSensitive); 123 if (rx.indexIn(html) == -1) { 124 EException(tr("Could not get the free sms count.")) 125 .addDebugInfo("html", html) 126 .raise(); // Will be made userfriendly in parsePage 126 QRegExp rx("TextSMS-Kontingent von \\d+ SMS verbraucht!"); 127 rx.setCaseSensitivity(Qt::CaseInsensitive); 128 if (rx.indexIn(html) != -1) { 129 setFreeSMSCount(0); 130 } else { 131 rx.setPattern("<td class=\"label\">(\\d+) von \\d+ TextSMS im Monat [a-zA-Zäöü]+</td>"); 132 if (rx.indexIn(html) == -1) { 133 EException(tr("Could not get the free sms count.")) 134 .addDebugInfo("html", html) 135 .raise(); // Will be made userfriendly in parsePage 136 } 137 setFreeSMSCount(rx.cap(1).toInt()); 127 138 } 128 setFreeSMSCount(rx.cap(1).toInt());129 139 qDebug() << " Free SMS count: " + rx.cap(1); 130 140 } -
gateways/Post/business/account.h
r315 r376 1 1 /* 2 2 Swiss Post gateway plugin - The smssender plugin for the Swiss Post platform. 3 Copyright (C) 2011-201 2, gorrión. See http://smssender.gorrion.ch3 Copyright (C) 2011-2014, gorrión. See http://smssender.gorrion.ch 4 4 5 5 This program is free software: you can redistribute it and/or modify … … 16 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 17 */ 18 #ifndef POST_ BCACCOUNT_H_19 #define POST_ BCACCOUNT_H_18 #ifndef POST_ACCOUNT_H 19 #define POST_ACCOUNT_H 20 20 21 21 #include <QScopedPointer> 22 22 23 #include <business/impl/abstractaccount.h> 24 #include <network/snetworkhelper.h> 25 #include <persistence/imainstorage.h> 23 #include "common/network/snetworkhelper.h" 24 #include "gateways/common/business/baseaccount.h" 26 25 27 26 namespace Post { 28 27 29 class Account : public AbstractAccount {28 class Account : public BaseAccount { 30 29 Q_OBJECT 31 30 32 friend class ContactImporter; // networkHelper() 33 friend class AccountLoginTask; // reloadOnlineParams(), httpHelper() 34 friend class SMSSendTask; // reloadOnlineParams(), httpHelper() 31 friend class AccountLoginTask; // reloadOnlineParams 32 friend class SMSSendTask; // reloadOnlineParams 35 33 36 34 public: … … 38 36 39 37 public: /* IAccount */ 40 Persistence::IStorageHelper* createStorageHelper(Persistence::IMainStorage *storage); 41 IValidator* createValidator() const; 38 Persistence::IStorageHelper *createStorageHelper( 39 Persistence::IMainStorage *storage); 40 IValidator *createValidator() const; 42 41 43 42 public: /* IAccount - SMS sending */ 44 void 43 void cancelSMSSending(); 45 44 46 45 public: /* IAccount - costs */ 47 int 48 int 46 int costsForText(const QString &text) const; 47 int fragmentSize() const; 49 48 50 public: /* Properties */ 49 public: 50 SNetworkHelper *httpHelper() const; 51 51 52 52 protected: /* AbstractAccount */ 53 IAccountInitTask* doCreateInitTask(); 54 IAccountLoginTask* doCreateLoginTask(); 55 ISMSSendTask* doCreateSMSSendTask(const QString& message, const QSet<SContact>& recipients); 53 IAccountInitTask *doCreateInitTask(); 54 IAccountLoginTask *doCreateLoginTask(); 55 ISMSSendTask *doCreateSMSSendTask(const QString& message, 56 const QSet<const SContact *>& recipients); 56 57 57 58 protected: /* AbstractLoginAccount */ 58 bool 59 bool checkStillLoggedIn(); 59 60 60 61 private: 61 int 62 void 62 int longSMSLength() const; 63 void setLongSMSLength(int longSMSLength); 63 64 64 65 private: 65 void 66 void 66 void reloadOnlineParams(); 67 void reloadOnlineParams(QString html); 67 68 68 void reloadLongSMSLength(QString html); 69 void reloadFreeSMSCount(QString html); 70 71 private: 72 SNetworkHelper *httpHelper() const; // TODO: dependency injection -> remove friends 69 void reloadLongSMSLength(QString html); 70 void reloadFreeSMSCount(QString html); 73 71 74 72 private slots: 75 void 73 void onInitStateChanged(); 76 74 77 75 private: … … 84 82 } 85 83 86 #endif /* POST_ BCACCOUNT_H_*/84 #endif /* POST_ACCOUNT_H */ -
gateways/Post/business/account_costs.cpp
r315 r376 1 1 /* 2 2 Swiss Post gateway plugin - The smssender plugin for the Swiss Post platform. 3 Copyright (C) 2011-201 2, gorrión. See http://smssender.gorrion.ch3 Copyright (C) 2011-2014, gorrión. See http://smssender.gorrion.ch 4 4 5 5 This program is free software: you can redistribute it and/or modify -
gateways/Post/business/account_task_login.cpp
r315 r376 1 1 /* 2 2 Swiss Post gateway plugin - The smssender plugin for the Swiss Post platform. 3 Copyright (C) 2011-201 2, gorrión. See http://smssender.gorrion.ch3 Copyright (C) 2011-2014, gorrión. See http://smssender.gorrion.ch 4 4 5 5 This program is free software: you can redistribute it and/or modify … … 18 18 #include "account_tasks.h" 19 19 20 #include <exceptions/eloginaccountloginexception.h> 21 #include <network/snetworkreply.h> 22 23 #include "business/gateway.h" 24 #include "library.h" 20 #include "common/exceptions/eloginaccountloginexception.h" 21 #include "common/network/snetworkreply.h" 22 #include "gateways/Post/business/gateway.h" 25 23 26 24 namespace Post { 27 25 28 26 AccountLoginTask::AccountLoginTask(Account *account) 29 : AbstractAccountLoginTask(account)27 : BaseAccountLoginTask(account) 30 28 { 31 29 } … … 69 67 } 70 68 71 QString AccountLoginTask::postSamlRequest( QStringlastHtml) {69 QString AccountLoginTask::postSamlRequest(const QString &lastHtml) { 72 70 /* Find URL */ 73 QRegExp rx("<form method=\"post\" action=\"([^\"]+)\">"); 71 QRegExp rx("<form.*action=\"([^\"]+)\".*>"); 72 rx.setMinimal(true); 74 73 if (rx.indexIn(lastHtml) == -1) { 75 74 LoginAccount::ELoginException(LoginAccount::ELoginException::RequestError) … … 109 108 } 110 109 111 QString AccountLoginTask::postSamlResponse( QStringlastHtml) {110 QString AccountLoginTask::postSamlResponse(const QString &lastHtml) { 112 111 /* 113 112 <form id="saml_form" action="https://organizer.sso.post.ch/sso-navi/assertion_consumer.php" method="POST" enctype="application/x-www-form-urlencoded"> … … 117 116 */ 118 117 /* Find URL */ 119 QRegExp rx("<form id=\"saml_form\" action=\"([^\"]+)\""); 118 QRegExp rx("<form.*action=\"([^\"]+)\".*"); 119 rx.setMinimal(true); 120 120 if (rx.indexIn(lastHtml) == -1) { 121 121 LoginAccount::ELoginException(LoginAccount::ELoginException::RequestError) … … 157 157 158 158 Account* AccountLoginTask::account() const { 159 return static_cast<Account*>( AbstractAccountLoginTask::account());159 return static_cast<Account*>(BaseAccountLoginTask::account()); 160 160 } 161 161 -
gateways/Post/business/account_task_sendsms.cpp
r315 r376 1 1 /* 2 2 Swiss Post gateway plugin - The smssender plugin for the Swiss Post platform. 3 Copyright (C) 2011-201 2, gorrión. See http://smssender.gorrion.ch3 Copyright (C) 2011-2014, gorrión. See http://smssender.gorrion.ch 4 4 5 5 This program is free software: you can redistribute it and/or modify … … 20 20 #include <math.h> 21 21 22 #include <business/impl/abstractaccount_utils.h> 23 #include <domain/sdatatypes.h> 24 #include <domain/snumber.h> 25 #include <network/snetworkreply.h> 26 27 #include "business/gateway.h" 22 #include "common/domain/sdatatypes.h" 23 #include "common/domain/snumber.h" 24 #include "common/network/snetworkreply.h" 25 #include "gateways/common/business/baseaccount_utils.h" 26 #include "gateways/Post/business/gateway.h" 28 27 29 28 namespace Post { 30 29 31 SMSSendTask::SMSSendTask(Account* account, const QString &message, const QSet<SContact> &recipients) 32 : AbstractSMSSendTask(account, message, recipients) 30 SMSSendTask::SMSSendTask(Account *account, const QString &message, 31 const QSet<const SContact *> &recipients) 32 : BaseSMSSendTask(account, message, recipients) 33 33 { 34 34 } … … 64 64 65 65 int percent_per_sms = 70 / (longSMSList.size() * ceil(recipients().size() / (double)MAX_RECIPIENTS_PER_SMS)); 66 QSetIterator< SContact> i(recipients());66 QSetIterator<const SContact *> i(recipients()); 67 67 foreach (QString msgPart, longSMSList) { 68 68 i.toFront(); … … 73 73 int recipientsCount = 0; 74 74 while (i.hasNext() && (recipientsCount < MAX_RECIPIENTS_PER_SMS)) { 75 addRecipient( i.next(), &recipientsStr);75 addRecipient(*i.next(), &recipientsStr); 76 76 ++recipientsCount; 77 77 } … … 146 146 147 147 Account* SMSSendTask::account() const { 148 return static_cast<Account*>( AbstractSMSSendTask::account());148 return static_cast<Account*>(BaseSMSSendTask::account()); 149 149 } 150 150 -
gateways/Post/business/account_tasks.h
r315 r376 1 1 /* 2 2 Swiss Post gateway plugin - The smssender plugin for the Swiss Post platform. 3 Copyright (C) 2011-201 2, gorrión. See http://smssender.gorrion.ch3 Copyright (C) 2011-2014, gorrión. See http://smssender.gorrion.ch 4 4 5 5 This program is free software: you can redistribute it and/or modify … … 16 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 17 */ 18 #ifndef POST_ BCACCOUNT_TASKS_H_19 #define POST_ BCACCOUNT_TASKS_H_18 #ifndef POST_ACCOUNT_TASKS_H 19 #define POST_ACCOUNT_TASKS_H 20 20 21 #include <business/impl/abstractaccount_tasks.h> 22 23 #include "business/account.h" 21 #include "gateways/common/business/baseaccount_tasks.h" 22 #include "gateways/Post/business/account.h" 24 23 25 24 namespace Post { 26 25 27 class AccountLoginTask : public AbstractAccountLoginTask {26 class AccountLoginTask : public BaseAccountLoginTask { 28 27 Q_OBJECT 29 28 … … 33 32 protected: /* AbstractAccountLoginTask */ 34 33 void doLogin(); 35 Account *account() const;34 Account *account() const; 36 35 37 36 private: … … 40 39 private: 41 40 QString postLogin(); 42 QString postSamlRequest( QStringlastHtml);43 QString postSamlResponse( QStringlastHtml);41 QString postSamlRequest(const QString &lastHtml); 42 QString postSamlResponse(const QString &lastHtml); 44 43 }; 45 44 46 45 47 class SMSSendTask : public AbstractSMSSendTask {46 class SMSSendTask : public BaseSMSSendTask { 48 47 Q_OBJECT 49 48 50 49 public: 51 SMSSendTask(Account *account, const QString &message, const QSet<SContact> &recipients); 50 SMSSendTask(Account *account, const QString &message, 51 const QSet<const SContact *> &recipients); 52 52 53 53 protected: /* AbstractAccountSendSMSTask */ 54 54 void doSendSMS(); 55 Account *account() const;55 Account *account() const; 56 56 57 57 private: … … 65 65 } // namespace Post 66 66 67 #endif /* POST_ BCACCOUNT_TASKS_H_*/67 #endif /* POST_ACCOUNT_TASKS_H */ -
gateways/Post/business/contactimporter/contactimporter.cpp
r315 r376 1 1 /* 2 2 Swiss Post gateway plugin - The smssender plugin for the Swiss Post platform. 3 Copyright (C) 2011-201 2, gorrión. See http://smssender.gorrion.ch3 Copyright (C) 2011-2014, gorrión. See http://smssender.gorrion.ch 4 4 5 5 This program is free software: you can redistribute it and/or modify … … 17 17 */ 18 18 #include "contactimporter.h" 19 #include "contactimporter_p.h"20 19 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/Post/business/account.h" 24 #include "gateways/Post/business/gateway.h" 27 25 28 26 namespace Post { 29 27 30 const QString ContactImporter::URL_EXPORT_CONTACTS = "https://organizer.sso.post.ch/addresses/adr_csv_export_action.html"; 28 const QString ContactImporter::URL_EXPORT_CONTACTS = 29 "https://organizer.sso.post.ch/addresses/adr_csv_export_action.html"; 31 30 32 ContactImporter::ContactImporter(const IAccountIntegrationHelper *accountHelper) 33 : m_dataManager(new ContactImporterDataManager) 34 , m_accountHelper(accountHelper) 31 ContactImporter::ContactImporter(Account *account) 32 : m_account(account) 35 33 { 36 34 } 37 35 38 QString ContactImporter::describingName() const { 36 void ContactImporter::importContacts(QSet<SContact *> *contacts) { 37 // Fetch the contacts 38 QString csv = 39 m_account->httpHelper()->syncGet(URL_EXPORT_CONTACTS)->readAll(); 40 csv.replace("\r", ""); 41 42 // Split csv into rows 43 QStringList rows = csv.split('\n', QString::SkipEmptyParts); 44 45 // Get the interresting columns 46 QString columnDescriptorRow = rows.takeFirst(); 47 QStringList columnDescriptor = splitIntoCells(columnDescriptorRow); 48 int prenameCol = columnDescriptor.indexOf(QRegExp("^Vorname$")); 49 int lastnameCol = columnDescriptor.indexOf(QRegExp("^Nachname$")); 50 int mobileCol = columnDescriptor.indexOf(QRegExp("^Mobil-Nummer$")); 51 int mobileCol2 = columnDescriptor.indexOf(QRegExp("^Mobil-Nummer at$")); 52 53 54 // Parse the contacts 55 foreach (QString row, rows) { 56 QStringList contactData = splitIntoCells(row); 57 58 QString name = QString("%1 %2") 59 .arg(contactData.value(prenameCol)) 60 .arg(contactData.value(lastnameCol)) 61 .trimmed(); 62 SNumber number(contactData.value(mobileCol)); 63 if (!number.isValid()) { 64 number = SNumber(contactData.value(mobileCol2)); 65 } 66 67 if (!name.isEmpty() && number.isValid()) { 68 QScopedPointer<SContact> contact(new SContact); 69 contact->setName(name); 70 contact->setNumber(number); 71 72 contacts->insert(contact.take()); 73 } 74 } 75 } 76 77 QStringList ContactImporter::splitIntoCells(QString csvRow) { 78 csvRow = csvRow.mid(1, csvRow.length()-2); // Remove first and last " 79 return csvRow.split(QRegExp("\";\""), QString::KeepEmptyParts); 80 } 81 82 /********************************** Builder ***********************************/ 83 84 ContactImporter::Builder::Builder(IAccountIntegrationHelper *accountHelper) 85 : m_accountHelper(accountHelper) 86 { 87 } 88 89 QString ContactImporter::Builder::description() const { 39 90 if (isApplicable()) { 40 91 return QObject::tr("Import contacts from the Post website."); … … 44 95 } 45 96 46 bool ContactImporter:: isApplicable() const {97 bool ContactImporter::Builder::isApplicable() const { 47 98 return m_accountHelper->hasLoggedInAccounts(); 48 99 } 49 100 101 void ContactImporter::Builder::createImporters(QSet<IContactImporter *> *importers) { 102 foreach (IAccount *iaccount, m_accountHelper->loggedInAccounts()) { 103 Account *account = static_cast<Account*>(iaccount); 50 104 51 void ContactImporter::init() { 52 const QSet<IAccount*> &loggedInIAccounts = m_accountHelper->loggedInAccounts(); 53 54 // FIXME: is this cast save? 55 const QSet<Account*> &loggedInAccounts = reinterpret_cast<const QSet<Account*> &>(loggedInIAccounts); 56 m_dataManager->setSelectedAccounts(loggedInAccounts); 57 } 58 QList<QWizardPage*> ContactImporter::preImportPages(QWidget *parent) { 59 Q_UNUSED(parent) 60 return QList<QWizardPage*>(); 61 } 62 QSet<SContact> ContactImporter::importContacts() { 63 QSet<SContact> contacts; 64 65 foreach (Account *account, m_dataManager->selectedAccounts()) { 66 if (!account->isLoggedIn()) continue; 67 68 // Fetch the contacts 69 QString csv = account->httpHelper()->syncGet(URL_EXPORT_CONTACTS)->readAll(); 70 csv.replace("\r", ""); 71 72 // Split csv into rows 73 QStringList rows = csv.split('\n', QString::SkipEmptyParts); 74 75 // Get the interresting columns 76 QString columnDescriptorRow = rows.takeFirst(); 77 QStringList columnDescriptor = splitIntoCells(columnDescriptorRow); 78 int prenameCol = columnDescriptor.indexOf(QRegExp("^Vorname$")); 79 int lastnameCol = columnDescriptor.indexOf(QRegExp("^Nachname$")); 80 int mobileCol = columnDescriptor.indexOf(QRegExp("^Mobil-Nummer$")); 81 int mobileCol2 = columnDescriptor.indexOf(QRegExp("^Mobil-Nummer at$")); 82 83 84 // Parse the contacts 85 foreach (QString row, rows) { 86 QStringList contactData = splitIntoCells(row); 87 88 QString name = QString(contactData.value(prenameCol) + " " + contactData.value(lastnameCol)).trimmed(); 89 SNumber number(contactData.value(mobileCol)); 90 if (!number.isValid()) { 91 number = SNumber(contactData.value(mobileCol2)); 92 } 93 94 if (!name.isEmpty() && number.isValid()) { 95 SContact contact; 96 contact.setName(name); 97 contact.setNumber(number); 98 99 contacts.insert(contact); 100 } 101 } 105 importers->insert(new ContactImporter(account)); 102 106 } 103 104 return contacts;105 }106 107 QStringList ContactImporter::splitIntoCells(QString csvRow) {108 csvRow = csvRow.mid(1, csvRow.length()-2); // Remove first and last "109 return csvRow.split(QRegExp("\";\""), QString::KeepEmptyParts);110 107 } 111 108 -
gateways/Post/business/contactimporter/contactimporter.h
r315 r376 1 1 /* 2 2 Swiss Post gateway plugin - The smssender plugin for the Swiss Post platform. 3 Copyright (C) 2011-201 2, gorrión. See http://smssender.gorrion.ch3 Copyright (C) 2011-2014, gorrión. See http://smssender.gorrion.ch 4 4 5 5 This program is free software: you can redistribute it and/or modify … … 16 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 17 */ 18 19 #ifndef POST_BCCONTACTIMPORTER_H_ 20 #define POST_BCCONTACTIMPORTER_H_ 18 #ifndef POST_CONTACTIMPORTER_CONTACTIMPORTER_H 19 #define POST_CONTACTIMPORTER_CONTACTIMPORTER_H 21 20 22 21 #include <QScopedPointer> 23 22 #include <QString> 24 23 25 #include <business/icontactimporter.h> 26 #include <business/iintegration.h> 27 #include <domain/scontact.h> 24 #include "common/business/icontactimporter.h" 25 #include "common/business/iintegration.h" 26 #include "common/domain/scontact.h" 27 #include "gateways/Post/business/account.h" 28 28 29 class IAccountManager2;30 29 class IGateway; 31 30 … … 36 35 class ContactImporter : public IContactImporter { 37 36 public: 38 explicit ContactImporter( const IAccountIntegrationHelper *accountHelper);37 explicit ContactImporter(Account *account); 39 38 40 39 public: /* IContactImporter */ 41 QString describingName() const; 42 bool isApplicable() const; 40 void importContacts(QSet<SContact *> *contacts); 43 41 44 void init(); 45 QList<QWizardPage*> preImportPages(QWidget* parent); 46 QSet<SContact> importContacts(); 42 class Builder : public IContactImporter::Builder { 43 public: 44 explicit Builder(IAccountIntegrationHelper *accountHelper); 45 46 public: /* IContactImporter::Builder */ 47 QString description() const; 48 bool isApplicable() const; 49 50 void createImporters(QSet<IContactImporter *> *importers); 51 52 private: 53 IAccountIntegrationHelper *m_accountHelper; 54 55 Q_DISABLE_COPY(Builder) 56 }; 47 57 48 58 private: … … 52 62 static const QString URL_EXPORT_CONTACTS; 53 63 54 const QScopedPointer<ContactImporterDataManager> m_dataManager; 55 const IAccountIntegrationHelper * const m_accountHelper; 64 Account * const m_account; 65 66 Q_DISABLE_COPY(ContactImporter) 56 67 }; 57 68 58 } 69 } // namespace Post 59 70 60 #endif /* POST_ BCCONTACTIMPORTER_H_*/71 #endif /* POST_CONTACTIMPORTER_CONTACTIMPORTER_H */ -
gateways/Post/business/gateway.cpp
r315 r376 1 1 /* 2 2 Swiss Post gateway plugin - The smssender plugin for the Swiss Post platform. 3 Copyright (C) 2011-201 2, gorrión. See http://smssender.gorrion.ch3 Copyright (C) 2011-2014, gorrión. See http://smssender.gorrion.ch 4 4 5 5 This program is free software: you can redistribute it and/or modify … … 18 18 #include "gateway.h" 19 19 20 #include "business/account.h" 21 #include "ui/settingswidget.h" 20 #include "gateways/Post/business/account.h" 22 21 23 22 namespace Post { … … 25 24 QString Gateway::name() const { 26 25 return "Post"; 27 }28 29 QImage Gateway::icon() const {30 return QImage(":/images/Post.ico");31 26 } 32 27 … … 60 55 } 61 56 62 IAccountSettingsWidget* Gateway::createAccountSettingsWidget(QWidget *parent) const { 63 return new UI::SettingsWidget(parent); 64 } 65 66 ::Persistence::IStorageHelper *Gateway::createStorageHelper(Persistence::IMainStorage *storage) { 57 ::Persistence::IStorageHelper *Gateway::createStorageHelper( 58 Persistence::IMainStorage *storage) { 67 59 Q_UNUSED(storage); 68 60 return NULL; -
gateways/Post/business/gateway.h
r315 r376 1 1 /* 2 2 Swiss Post gateway plugin - The smssender plugin for the Swiss Post platform. 3 Copyright (C) 2011-201 2, gorrión. See http://smssender.gorrion.ch3 Copyright (C) 2011-2014, gorrión. See http://smssender.gorrion.ch 4 4 5 5 This program is free software: you can redistribute it and/or modify … … 16 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 17 */ 18 #ifndef POST_ BCGATEWAY_H_19 #define POST_ BCGATEWAY_H_18 #ifndef POST_GATEWAY_H 19 #define POST_GATEWAY_H 20 20 21 21 #include <QSet> 22 22 23 #include <business/igateway.h> 24 #include <utils/smacros.h> 23 #include "common/business/igateway.h" 24 25 #ifdef FRONTEND_GUI 26 class QIcon; 27 #endif 25 28 26 29 namespace Post { … … 38 41 public: /* IGateway */ 39 42 QString name() const; 40 QImage icon() const; 43 44 #ifdef FRONTEND_GUI 45 QIcon icon() const; 46 IAccountSettingsWidget *createAccountSettingsWidget(QWidget *parent) const; 47 #endif 41 48 42 49 public: /* IGateway */ 43 QList<int> 50 QList<int> validRecipientCountryCodes() const; 44 51 QList<QChar> doublePriceChars() const; 45 52 QList<QChar> disAllowedChars() const; 46 53 47 54 public: /* IGateway */ 48 IAccountSettingsWidget* createAccountSettingsWidget(QWidget *parent) const; 49 IAccount* createAccountInstance(); 55 IAccount *createAccountInstance(); 50 56 51 57 public: /* IStorable */ 52 ::Persistence::IStorageHelper *createStorageHelper(Persistence::IMainStorage *storage); 58 ::Persistence::IStorageHelper *createStorageHelper( 59 Persistence::IMainStorage *storage); 53 60 }; 54 61 55 62 } 56 63 57 #endif /* POST _BCGATEWAY_H_*/64 #endif /* POSTATEWAY_H */ -
gateways/Post/gui/post.cpp
r315 r376 1 1 /* 2 2 Swiss Post gateway plugin - The smssender plugin for the Swiss Post platform. 3 Copyright (C) 2011-201 2, gorrión. See http://smssender.gorrion.ch3 Copyright (C) 2011-2014, gorrión. See http://smssender.gorrion.ch 4 4 5 5 This program is free software: you can redistribute it and/or modify … … 16 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 17 */ 18 #include " library.h"18 #include "post.h" 19 19 20 20 #include <QLocale> 21 #include <QScopedPointer>22 21 23 #include <domain/sversion.h> 24 25 #include "business/contactimporter/contactimporter.h" 26 #include "business/gateway.h" 22 #include "common/domain/sversion.h" 23 #include "gateways/Post/business/contactimporter/contactimporter.h" 24 #include "gateways/Post/business/gateway.h" 27 25 28 26 namespace Post { 29 27 30 QString Library::compatibilityVersion() const { 31 return COMPATIBILITY_VERSION; 28 Library::Library() { 32 29 } 33 30 34 QString Library::identificationKey() const { 35 return "Post"; 36 } 37 SVersion Library::version() const { 38 return SVersion(LIB_VERSION); 39 } 40 41 bool Library::doInit(QSet<QTranslator*> *translators, IGateway **gateway, 42 QSet<IContactImporter*> *contactImporters) 31 bool Library::doInit( 32 const IBaseIntegrationHelper::Factory &integrationHelperFactory, 33 IGateway **gateway, QSet<IContactImporter::Builder *> *contactImporters) 43 34 { 44 // Translators45 QLocale l; // Loads default locale46 QScopedPointer<QTranslator> t(new QTranslator);47 if (t->load("post-" + l.name(), ":/locale")) {48 translators->insert(t.take());49 }50 51 35 // Gateway 52 36 *gateway = new Gateway; 37 m_integrationHelper.reset( 38 integrationHelperFactory.createIntegrationHelper(*gateway)); 53 39 54 40 // Contact importer 55 contactImporters->insert(new ContactImporter(integrationHelper()->accountHelper())); 41 contactImporters->insert(new ContactImporter::Builder( 42 m_integrationHelper->accountHelper())); 56 43 57 44 return true; -
gateways/Post/gui/post.h
r315 r376 1 1 /* 2 2 Swiss Post gateway plugin - The smssender plugin for the Swiss Post platform. 3 Copyright (C) 2011-201 2, gorrión. See http://smssender.gorrion.ch3 Copyright (C) 2011-2014, gorrión. See http://smssender.gorrion.ch 4 4 5 5 This program is free software: you can redistribute it and/or modify … … 16 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 17 */ 18 #ifndef POST_ MAIN_H_19 #define POST_ MAIN_H_18 #ifndef POST_GUI_POST_H 19 #define POST_GUI_POST_H 20 20 21 #include <business/impl/abstractlibrary.h>21 #include "gateways/common/business/baselibrary.h" 22 22 23 23 namespace Post { 24 24 25 class Library : public AbstractLibrary { 26 public: /* ILibrary */ 27 QString compatibilityVersion() const; 25 class Library : public BaseLibrary { 26 S_LIBRARY("Post") 28 27 29 QString identificationKey() const; 30 SVersion version() const;28 public: 29 Library(); 31 30 32 31 protected: 33 bool doInit(QSet<QTranslator*> *translators, IGateway **gateway, 34 QSet<IContactImporter*> *contactImporters); 32 bool doInit(const IIntegrationHelper::Factory &integrationHelperFactory, 33 IGateway **gateway, 34 QSet<IContactImporter::Builder *> *contactImporters); 35 36 private: 37 QScopedPointer<IIntegrationHelper> m_integrationHelper; 35 38 }; 36 39 37 40 } // namespace Post 38 41 39 #endif /* POST_ MAIN_H_*/42 #endif /* POST_GUI_POST_H */ -
gateways/Post/gui/ui/settingswidget.cpp
r315 r376 1 1 /* 2 2 Swiss Post gateway plugin - The smssender plugin for the Swiss Post platform. 3 Copyright (C) 2011-201 2, gorrión. See http://smssender.gorrion.ch3 Copyright (C) 2011-2014, gorrión. See http://smssender.gorrion.ch 4 4 5 5 This program is free software: you can redistribute it and/or modify … … 19 19 20 20 #include <QString> 21 #include <QMessageBox>22 21 23 #include <stdexceptions.h> 24 25 #include "business/account.h" 26 #include "business/gateway.h" 22 #include "common/exceptions/stdexceptions.h" 23 #include "gateways/Post/business/account.h" 24 #include "gateways/Post/business/gateway.h" 27 25 28 26 namespace Post { -
gateways/Post/gui/ui/settingswidget.h
r315 r376 1 1 /* 2 2 Swiss Post gateway plugin - The smssender plugin for the Swiss Post platform. 3 Copyright (C) 2011-201 2, gorrión. See http://smssender.gorrion.ch3 Copyright (C) 2011-2014, gorrión. See http://smssender.gorrion.ch 4 4 5 5 This program is free software: you can redistribute it and/or modify … … 16 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 17 */ 18 #ifndef POST_ VCSETTINGSWIDGET_H19 #define POS t_VCSETTINGSWIDGET_H18 #ifndef POST_GUI_UI_SETTINGSWIDGET_H 19 #define POST_GUI_UI_SETTINGSWIDGET_H 20 20 21 21 #include <QtGui/QWidget> 22 22 #include "ui_settingswidget.h" 23 23 24 #include <ui/iaccountsettingswidget.h>24 #include "common/gui/ui/iaccountsettingswidget.h" 25 25 26 26 namespace Post { … … 32 32 33 33 public: 34 SettingsWidget(QWidget *parent);34 SettingsWidget(QWidget *parent); 35 35 36 36 public: … … 46 46 } // namespace Post 47 47 48 #endif // POST_ VCSETTINGSWIDGET_H48 #endif // POST_GUI_UI_SETTINGSWIDGET_H -
gateways/Post/lib/post.qrc
r151 r376 1 1 <RCC> 2 2 <qresource prefix="/certs"> 3 <file>VerisignCA3.crt</file> 4 </qresource> 5 <qresource prefix="/images"> 6 <file>Post.ico</file> 3 <file>Verisign_class3_root.crt</file> 4 <file>VerisignCA_G3.crt</file> 5 <file>VerisignCA_G5.crt</file> 7 6 </qresource> 8 7 <qresource prefix="/locale"> 9 <file alias="post- de.qm">../locale/de.qm</file>10 <file alias="post- fr.qm">../locale/fr.qm</file>11 <file alias="post- it.qm">../locale/it.qm</file>12 <file alias="post- de_CH.qm">../locale/de_CH.qm</file>8 <file alias="post-base.de.qm">../locale/de.qm</file> 9 <file alias="post-base.de_CH.qm">../locale/de_CH.qm</file> 10 <file alias="post-base.fr.qm">../locale/fr.qm</file> 11 <file alias="post-base.it.qm">../locale/it.qm</file> 13 12 </qresource> 14 13 </RCC> -
gateways/Post/post-base.pro
r315 r376 1 BASE_VERSION = 1.0 2 !include(../gateways.pri):!include(/usr/include/smssender/gateways.pri):error("Could not include gateways.pri") 3 TARGET = Post 4 include(locale/locale.pri) 1 include(../../smssender-base.pri) 2 3 QT += \ 4 core \ 5 network \ 6 sql 7 5 8 HEADERS += \ 6 src/library.h \ 7 src/business/contactimporter/contactimporter.h \ 8 src/business/contactimporter/contactimporter_p.h \ 9 src/business/account.h \ 10 src/business/account_tasks.h \ 11 src/business/gateway.h \ 12 src/ui/settingswidget.h 9 business/account.h \ 10 business/account_tasks.h \ 11 business/contactimporter/contactimporter.h \ 12 business/gateway.h \ 13 13 14 SOURCES += \ 14 src/library.cpp \ 15 src/business/contactimporter/contactimporter.cpp \ 16 src/business/gateway.cpp \ 17 src/business/account_task_sendsms.cpp \ 18 src/business/account.cpp \ 19 src/business/account_costs.cpp \ 20 src/business/account_task_login.cpp \ 21 src/ui/settingswidget.cpp 22 FORMS += \ 23 src/ui/settingswidget.ui 24 RESOURCES += lib/Post.qrc 15 business/account.cpp \ 16 business/account_costs.cpp \ 17 business/account_task_login.cpp \ 18 business/account_task_sendsms.cpp \ 19 business/contactimporter/contactimporter.cpp \ 20 business/gateway.cpp \ 21 22 RESOURCES += \ 23 lib/post.qrc 24 25 install-dev-files:unix { 26 ADDITIONAL_INSTALLS = $$HEADERS 27 ADDITIONAL_INSTALLS_BASE = /usr/include/smssender/gateways/Post 28 include(../../additional_installs.pri) 29 } -
gateways/Post/post.pro
r315 r376 1 BASE_VERSION = 1.0 2 !include(../gateways.pri):!include(/usr/include/smssender/gateways.pri):error("Could not include gateways.pri") 3 TARGET = Post 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/account.h \ 10 src/business/account_tasks.h \ 11 src/business/gateway.h \ 12 src/ui/settingswidget.h 13 SOURCES += \ 14 src/library.cpp \ 15 src/business/contactimporter/contactimporter.cpp \ 16 src/business/gateway.cpp \ 17 src/business/account_task_sendsms.cpp \ 18 src/business/account.cpp \ 19 src/business/account_costs.cpp \ 20 src/business/account_task_login.cpp \ 21 src/ui/settingswidget.cpp 22 FORMS += \ 23 src/ui/settingswidget.ui 24 RESOURCES += lib/Post.qrc 1 TEMPLATE = subdirs 2 3 your-princess-is-in-another-castle { 4 SUBDIRS = post-base 5 post-base.file = post-base.pro 6 } 7 8 build-frontend-gui { 9 SUBDIRS += post-gui 10 post-gui.file = gui/post-gui.pro 11 } 12 -
gateways/gateways.pro
r349 r376 5 5 \ 6 6 ethz \ 7 post \ 7 8 schoolnet \ 8 9 smartphone \ … … 14 15 ethz.depends = gateways-common 15 16 16 #post.file = Post/post.pro 17 post.file = Post/post.pro 18 post.depends = gateways-common 17 19 18 20 schoolnet.file = Schoolnet/schoolnet.pro
Note: See TracChangeset
for help on using the changeset viewer.