Changeset 217:1ed3ec64fc1f in SMSSender


Ignore:
Timestamp:
May 10, 2012 1:23:15 PM (8 years ago)
Author:
Sämy Zehnder <saemy.zehnder@…>
Branch:
default
Message:
  • Removed all Priv stuff. Using Qts parent mechanism for memory management now.
Files:
6 added
10 deleted
275 edited
13 moved

Legend:

Unmodified
Added
Removed
  • .cproject

    r193 r217  
    100100        <storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
    101101        <storageModule moduleId="org.eclipse.cdt.core.pathentry">
    102                 <pathentry include="/usr/include/qt4" kind="inc" path="" system="true"/>
    103                 <pathentry include="/usr/include/qt4/Qt" kind="inc" path="" system="true"/>
    104                 <pathentry include="/usr/include/qt4/QtCore" kind="inc" path="" system="true"/>
    105                 <pathentry include="/usr/include/qt4/QtGui" kind="inc" path="" system="true"/>
    106                 <pathentry include="/usr/include/qt4/QtNetwork" kind="inc" path="" system="true"/>
    107                 <pathentry include="/usr/include/qt4/QtSql" kind="inc" path="" system="true"/>
    108                 <pathentry include="/usr/include/qt4/QtXml" kind="inc" path="" system="true"/>
     102                <pathentry base-path="/usr/share/qt4/include/" include="" kind="inc" path="" system="true"/>
     103                <pathentry base-path="/usr/share/qt4/include/" include="QtXmlPatterns" kind="inc" path="" system="true"/>
     104                <pathentry base-path="/usr/share/qt4/include/" include="QtCore" kind="inc" path="" system="true"/>
     105                <pathentry base-path="/usr/share/qt4/include/" include="Qt" kind="inc" path="" system="true"/>
     106                <pathentry base-path="/usr/share/qt4/include/" include="QtSql" kind="inc" path="" system="true"/>
     107                <pathentry base-path="/usr/share/qt4/include/" include="QtGui" kind="inc" path="" system="true"/>
     108                <pathentry base-path="/usr/share/qt4/include/" include="QtDBus" kind="inc" path="" system="true"/>
     109                <pathentry base-path="/usr/share/qt4/include/" include="QtNetwork" kind="inc" path="" system="true"/>
     110                <pathentry base-path="/usr/share/qt4/include/" include="QtTest" kind="inc" path="" system="true"/>
     111                <pathentry base-path="/usr/share/qt4/include/" include="Qt3Support" kind="inc" path="" system="true"/>
     112                <pathentry base-path="/usr/share/qt4/include/" include="QtUiTools" kind="inc" path="" system="true"/>
     113                <pathentry base-path="/usr/share/qt4/include/" include="QtDesigner" kind="inc" path="" system="true"/>
     114                <pathentry base-path="/usr/share/qt4/include/" include="QtSvg" kind="inc" path="" system="true"/>
     115                <pathentry base-path="/usr/share/qt4/include/" include="QtScriptTools" kind="inc" path="" system="true"/>
     116                <pathentry base-path="/usr/share/qt4/include/" include="QtWebKit" kind="inc" path="" system="true"/>
     117                <pathentry base-path="/usr/share/qt4/include/" include="QtScript" kind="inc" path="" system="true"/>
     118                <pathentry base-path="/usr/share/qt4/include/" include="QtHelp" kind="inc" path="" system="true"/>
     119                <pathentry base-path="/usr/share/qt4/include/" include="QtOpenGL" kind="inc" path="" system="true"/>
     120                <pathentry base-path="/usr/share/qt4/include/" include="QtXml" kind="inc" path="" system="true"/>
    109121                <pathentry include="/usr/include" kind="inc" path="" system="true"/>
    110122                <pathentry include="/usr/include/c++/4.6" kind="inc" path="" system="true"/>
     
    115127                <pathentry kind="out" path=""/>
    116128                <pathentry kind="prj" path="/libdatatypes"/>
    117                 <pathentry kind="prj" path="/gateway_SwisscomXtraZone"/>
    118                 <pathentry kind="prj" path="/gateway_Schoolnet"/>
    119129                <pathentry kind="prj" path="/gateway_ETHZ"/>
    120                 <pathentry kind="prj" path="/gateway_Sunrise"/>
    121                 <pathentry kind="prj" path="/gateway_Post"/>
    122130        </storageModule>
    123131</cproject>
  • .project

    r148 r217  
    55        <projects>
    66                <project>gateway_ETHZ</project>
    7                 <project>gateway_Post</project>
    8                 <project>gateway_Schoolnet</project>
    9                 <project>gateway_Sunrise</project>
    10                 <project>gateway_SwisscomXtraZone</project>
    117                <project>libdatatypes</project>
    128        </projects>
  • gateways/ETHZ/ethz.pro

    r154 r217  
    11VERSION = 1.0.0
    2 !include(../gateways.pri) {
    3         !include(/usr/include/smssender/gateways.pri) {
    4                 error("Could not include gateways.pri")
    5         }
    6 }
    7 
    8 
     2!include(../gateways.pri):!include(/usr/include/smssender/gateways.pri):error("Could not include gateways.pri")
    93TARGET = ETHZ
    10 
    114include(locale/locale.pri)
    12 
    135HEADERS += src/business/bcaccount.h \
    146    src/business/bcaccount_tasks.h \
    157    src/business/bcgateway.h \
    168    src/business/contactimporter/bccontactimporter.h \
     9    src/business/contactimporter/bccontactimporter_p.h \
    1710    src/business/validation/bcaccountvalidator.h \
    1811    src/persistence/daaccountstorageofficer.h \
    1912    src/ui/vcsettingswidget.h \
    20     src/main.h
     13    src/library.h
    2114SOURCES += src/business/bcaccount.cpp \
    2215    src/business/bcaccount_costs.cpp \
     
    2821    src/persistence/daaccountstorageofficer.cpp \
    2922    src/ui/vcsettingswidget.cpp \
    30     src/main.cpp
     23    src/library.cpp
    3124FORMS += src/ui/vcsettingswidget.ui
    3225RESOURCES += lib/ethz.qrc
  • gateways/ETHZ/src/business/bcaccount.cpp

    r198 r217  
    3333#include <stask_predefined.h>
    3434
    35 #include "main.h"
     35#include "library.h"
    3636#include "bcaccount_tasks.h"
    3737#include "bcgateway.h"
     
    4141namespace ETHZ {
    4242
    43 BCAccountPriv::BCAccountPriv(const IStorage& storage)
    44     : AbstractAccountPriv()
     43BCAccount::BCAccount(QObject* parent, IStorage* storage)
     44    : AbstractAccount(parent)
     45    , httpHelper_(new SNetworkHelper(this))
    4546{
    46     init(DAAccountStorageOfficer(this, storage), BCAccountValidator(this));
     47    init(new DAAccountStorageOfficer(this, this, storage), new BCAccountValidator(this, this));
    4748
    4849    httpHelper_->addTrustedCA(":/certs/QuoVadisRootCA.crt");
    4950}
    5051
    51 BCAccountPriv::~BCAccountPriv(){
     52IAccount* BCAccount::createClonedInstance(QObject* parent) const {
     53    return new BCAccount(parent, getStorageOfficer()->storage());
    5254}
    53 
    54 IAccount BCAccountPriv::getClonedInstance() const {
    55     return BCAccount(getStorageOfficer()->storage());
    56 }
    57 IGateway BCAccountPriv::gateway() const {
     55IGateway* BCAccount::gateway() const {
    5856    return BCGateway::instance();
    5957}
    6058
    61 IAccountInitTask BCAccountPriv::doCreateInitTask() {
    62     return SDefaultLoginInitTask(this);
     59IAccountInitTask* BCAccount::doCreateInitTask() {
     60    return new SDefaultLoginInitTask(this);
    6361}
    64 IAccountLoginTask BCAccountPriv::doCreateLoginTask() {
    65     return BCAccountLoginTask(this);
     62IAccountLoginTask* BCAccount::doCreateLoginTask() {
     63    return new BCAccountLoginTask(this);
    6664}
    67 ISMSSendTask BCAccountPriv::doCreateSMSSendTask(const QString& message, const QSet<SContact>& recipients) {
    68     return BCSMSSendTask(this, message, recipients);
     65ISMSSendTask* BCAccount::doCreateSMSSendTask(const QString& message, const QSet<SContact>& recipients) {
     66    return new BCSMSSendTask(this, message, recipients);
    6967}
    7068
    71 SNetworkHelper BCAccountPriv::httpHelper() const {
     69SNetworkHelper* BCAccount::httpHelper() const {
    7270    return httpHelper_;
    7371}
    7472
    75 void BCAccountPriv::cancelSMSSending() {
    76     // TODO: Privement this
     73void BCAccount::cancelSMSSending() {
     74    // TODO: Implement this
    7775}
    7876
    79 bool BCAccountPriv::checkStillLoggedIn() {
     77bool BCAccount::checkStillLoggedIn() {
    8078    return isLoggedIn();
    8179}
  • gateways/ETHZ/src/business/bcaccount.h

    r198 r217  
    2121
    2222#include <snetworkhelper.h>
    23 #include <ssharedpointer.h>
    2423
    2524#include <abstract/abstractaccount.h>
    2625#include <persistence/istorage.h>
    2726
    28 #include "bcgateway.h"
    29 
    3027namespace ETHZ {
    3128
    32 class BCAccountPriv : public AbstractAccountPriv {
     29class BCAccount : public AbstractAccount {
    3330    Q_OBJECT
    3431
    35     friend class BCContactImporterPriv;
    36     friend class BCAccountLoginTaskPriv;
    37     friend class BCSMSSendTaskPriv;
     32    friend class BCContactImporter; // httpHelper()
     33    friend class BCAccountLoginTask; // httpHelper()
     34    friend class BCSMSSendTask; // httpHelper()
    3835
    3936public:
    40     explicit BCAccountPriv(const IStorage& storage);
    41     virtual ~BCAccountPriv();
     37    BCAccount(QObject* parent, IStorage* storage);
    4238
    4339public: /* IAccount */
    44     IGateway         gateway() const;
    45     IAccount         getClonedInstance() const;
     40    IGateway*         gateway() const;
     41    IAccount*         createClonedInstance(QObject* parent) const;
    4642
    4743public: /* IAccount - SMS sending */
    48     void             cancelSMSSending();
     44    void              cancelSMSSending();
    4945
    5046public: /* IAccount - costs */
    51     int              costsForText(const QString& message) const;
    52     QList<QString>   splitTextToLongSMS(const QString& text) const;
    53     int              shortSMSCount(const QString& text) const;
     47    int               costsForText(const QString& message) const;
     48    QList<QString>    splitTextToLongSMS(const QString& text) const;
     49    int               shortSMSCount(const QString& text) const;
    5450
    5551protected: /* AbstractAccount */
    56     IAccountInitTask  doCreateInitTask();
    57     IAccountLoginTask doCreateLoginTask();
    58     ISMSSendTask      doCreateSMSSendTask(const QString& message, const QSet<SContact>& recipients);
     52    IAccountInitTask*  doCreateInitTask();
     53    IAccountLoginTask* doCreateLoginTask();
     54    ISMSSendTask*      doCreateSMSSendTask(const QString& message, const QSet<SContact>& recipients);
    5955
    6056protected:
    61     bool             checkStillLoggedIn();
     57    bool              checkStillLoggedIn();
    6258
    6359private:
    64     SNetworkHelper   httpHelper() const;
     60    SNetworkHelper*   httpHelper() const;
    6561
    6662    void             haltIfCancelled();
    6763
    6864private:
    69     SNetworkHelper   httpHelper_;
     65    SNetworkHelper*   httpHelper_;
    7066
    71     Q_DISABLE_COPY(BCAccountPriv);
    72 };
    73 class BCAccount : public AbstractAccount {
    74     S_SHARED_INTERNAL(BCAccount, AbstractAccount, IAccount)
    75     S_SHARED_QOBJ_INTERNAL(BCAccount, AbstractAccount, IAccount)
    76 
    77 public:
    78     BCAccount()
    79         : AbstractAccount(NULL)
    80     {};
    81     explicit BCAccount(const IStorage& storage)
    82         : AbstractAccount(new BCAccountPriv(storage))
    83     {};
     67    Q_DISABLE_COPY(BCAccount)
    8468};
    8569
    86 };
    87 Q_DECLARE_METATYPE(ETHZ::BCAccount)
     70}
    8871
    8972#endif /* ETHZ_BCACCOUNT_H_ */
  • gateways/ETHZ/src/business/bcaccount_costs.cpp

    r194 r217  
    1616  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717*/
    18 
    1918#include "bcaccount.h"
    2019
    2120#include <math.h>
     21
     22#include "bcgateway.h"
    2223
    2324namespace ETHZ {
     
    3132 * @return The list of the long-sms texts
    3233 */
    33 QList<QString> BCAccountPriv::splitTextToLongSMS(const QString& text) const {
     34QList<QString> BCAccount::splitTextToLongSMS(const QString& text) const {
    3435    QList<QString> lst;
    3536    lst.append(text);
     
    4344 * @return The short-sms count.
    4445 */
    45 int BCAccountPriv::shortSMSCount(const QString& text) const {
     46int BCAccount::shortSMSCount(const QString& text) const {
    4647    QString txt(text);
    4748    foreach (QChar doublePriceChar, gateway()->doublePriceChars()) {
     
    6970 * @return The costs
    7071 */
    71 int BCAccountPriv::costsForText(const QString& message) const {
     72int BCAccount::costsForText(const QString& message) const {
    7273    return shortSMSCount(message);
    7374}
  • gateways/ETHZ/src/business/bcaccount_task_login.cpp

    r198 r217  
    1919#include "bcaccount_tasks.h"
    2020
     21#include <snetworkreply.h>
    2122#include <exceptions/eloginaccountloginexception.h>
     23
     24#include "bcgateway.h"
    2225
    2326namespace ETHZ {
    2427
    25 BCAccountLoginTaskPriv::BCAccountLoginTaskPriv(const BCAccount& account)
    26     : AbstractAccountLoginTaskPriv(account)
     28BCAccountLoginTask::BCAccountLoginTask(BCAccount* account)
     29    : AbstractAccountLoginTask(account)
    2730{
    2831}
    2932
    30 void BCAccountLoginTaskPriv::doLogin() {
     33void BCAccountLoginTask::doLogin() {
    3134    // Just check, if the password is correct
    32     QList<IParam> posts;
    33     posts.append(SKeyValueParam("username", account()->username().toUtf8()));
    34     posts.append(SKeyValueParam("password", account()->password().toUtf8()));
    35     posts.append(SKeyValueParam("action",   "listoriginators"));
     35    QList<IParam*> posts;
     36    posts.append(new SKeyValueParam("username", account()->username().toUtf8()));
     37    posts.append(new SKeyValueParam("password", account()->password().toUtf8()));
     38    posts.append(new SKeyValueParam("action",   "listoriginators"));
    3639
    3740    QString resp = http()->syncPost(URL_SENDSMS, posts)->readAll();
     
    5962}
    6063
    61 BCAccount BCAccountLoginTaskPriv::account() const {
    62     return AbstractAccountLoginTaskPriv::account();
     64BCAccount* BCAccountLoginTask::account() const {
     65    return static_cast<BCAccount*>(AbstractAccountLoginTask::account());
    6366}
    6467
    65 SNetworkHelper BCAccountLoginTaskPriv::http() const {
     68SNetworkHelper* BCAccountLoginTask::http() const {
    6669    return account()->httpHelper();
    6770}
  • gateways/ETHZ/src/business/bcaccount_task_sendsms.cpp

    r216 r217  
    2020#include <math.h>
    2121
     22#include <snetworkreply.h>
    2223#include <snumber.h>
    2324#include <exceptions/eabortloadingexception.h>
    2425
     26#include "bcgateway.h"
     27
    2528namespace ETHZ {
    2629
    27 BCSMSSendTaskPriv::BCSMSSendTaskPriv(const BCAccount& account, const QString& message, const QSet<SContact>& recipients)
    28     : AbstractSMSSendTaskPriv(account, message, recipients)
     30BCSMSSendTask::BCSMSSendTask(BCAccount* account, const QString& message, const QSet<SContact>& recipients)
     31    : AbstractSMSSendTask(account, message, recipients)
    2932{
    3033}
    3134
    3235
    33 void BCSMSSendTaskPriv::doSendSMS() {
     36void BCSMSSendTask::doSendSMS() {
    3437    Q_ASSERT(!message().isEmpty());
    3538    Q_ASSERT(!recipients().isEmpty());
     
    97100}
    98101
    99 void BCSMSSendTaskPriv::checkResponse(const QString& response) const {
     102void BCSMSSendTask::checkResponse(const QString& response) const {
    100103    switch (response.left(3).toInt()) {
    101104        case 200:
     
    107110}
    108111
    109 void BCSMSSendTaskPriv::sendPartOfSMS(const QString& text, const SContact& recipient) {
     112void BCSMSSendTask::sendPartOfSMS(const QString& text, const SContact& recipient) {
    110113    //haltIfCancelled();
    111114    qDebug() << "Start of sending part of SMS";
     
    113116    setDetails(Account::Action::SendingSMS);
    114117
    115     QList<IParam> posts;
    116     posts.append(SKeyValueParam("username",   account()->username().toUtf8()));
    117     posts.append(SKeyValueParam("password",   account()->password().toUtf8()));
    118     posts.append(SKeyValueParam("action",     "sendsms"));
    119     posts.append(SKeyValueParam("originator", "auto"));
    120     posts.append(SKeyValueParam("number",     recipient.number().toString("'00'CCAAAu").toUtf8()));
    121     posts.append(SKeyValueParam("message",    text.toUtf8()));
     118    QList<IParam*> posts;
     119    posts.append(new SKeyValueParam("username",   account()->username().toUtf8()));
     120    posts.append(new SKeyValueParam("password",   account()->password().toUtf8()));
     121    posts.append(new SKeyValueParam("action",     "sendsms"));
     122    posts.append(new SKeyValueParam("originator", "auto"));
     123    posts.append(new SKeyValueParam("number",     recipient.number().toString("'00'CCAAAu").toUtf8()));
     124    posts.append(new SKeyValueParam("message",    text.toUtf8()));
    122125
    123126    QString response = httpHelper()->syncPost(URL_SENDSMS, posts)->readAll();
     
    128131
    129132
    130 BCAccount BCSMSSendTaskPriv::account() const {
    131     return AbstractSMSSendTaskPriv::account();
     133BCAccount* BCSMSSendTask::account() const {
     134    return static_cast<BCAccount*>(AbstractSMSSendTask::account());
    132135}
    133136
    134 SNetworkHelper BCSMSSendTaskPriv::httpHelper() const {
     137SNetworkHelper* BCSMSSendTask::httpHelper() const {
    135138    return account()->httpHelper();
    136139}
  • gateways/ETHZ/src/business/bcaccount_tasks.h

    r198 r217  
    2727namespace ETHZ {
    2828
    29 class BCAccountLoginTaskPriv : public AbstractAccountLoginTaskPriv {
     29class BCAccountLoginTask : public AbstractAccountLoginTask {
    3030    Q_OBJECT
    3131
    3232public:
    33     explicit BCAccountLoginTaskPriv(const BCAccount& account);
     33    explicit BCAccountLoginTask(BCAccount* account);
    3434
    3535protected: /* AbstractAccountLoginTask */
    36     void      doLogin();
    37     BCAccount account() const;
     36    void       doLogin();
     37    BCAccount* account() const;
    3838
    3939private:
    40     SNetworkHelper http() const;
    41 };
    42 class BCAccountLoginTask : public AbstractAccountLoginTask {
    43     S_SHARED_INTERNAL(BCAccountLoginTask, AbstractAccountLoginTask, STask)
    44     S_SHARED_QOBJ_INTERNAL(BCAccountLoginTask, AbstractAccountLoginTask, STask)
    45 
    46 public:
    47     explicit BCAccountLoginTask(const BCAccount& account)
    48         : AbstractAccountLoginTask(new BCAccountLoginTaskPriv(account))
    49     {};
     40    SNetworkHelper* http() const;
    5041};
    5142
    5243
    53 class BCSMSSendTaskPriv : public AbstractSMSSendTaskPriv {
     44class BCSMSSendTask : public AbstractSMSSendTask {
    5445    Q_OBJECT
    5546
    5647public:
    57     BCSMSSendTaskPriv(const BCAccount& account, const QString& message, const QSet<SContact>& recipients);
     48    BCSMSSendTask(BCAccount* account, const QString& message, const QSet<SContact>& recipients);
    5849
    5950protected: /* AbstractAccountSendSMSTask */
    60     void      doSendSMS();
    61     BCAccount account() const;
     51    void       doSendSMS();
     52    BCAccount* account() const;
    6253
    6354private:
     
    6657
    6758private:
    68     SNetworkHelper httpHelper() const;
     59    SNetworkHelper* httpHelper() const;
    6960
    7061private:
    7162    QString recipientsStr_;
    72 };
    73 class BCSMSSendTask : public AbstractSMSSendTask {
    74     S_SHARED_INTERNAL(BCSMSSendTask, AbstractSMSSendTask, STask)
    75     S_SHARED_QOBJ_INTERNAL(BCSMSSendTask, AbstractSMSSendTask, STask)
    76 
    77 public:
    78     BCSMSSendTask(const BCAccount& account, const QString& message, const QSet<SContact>& recipients)
    79         : AbstractSMSSendTask(new BCSMSSendTaskPriv(account, message, recipients))
    80     {};
    8163};
    8264
  • gateways/ETHZ/src/business/bcgateway.cpp

    r194 r217  
    2626namespace ETHZ {
    2727
    28 QString BCGatewayPriv::name() const {
     28S_SINGLETON_IMPL(BCGateway)
     29
     30BCGateway::BCGateway()
     31    : AbstractGateway(NULL) // singleton
     32{
     33}
     34
     35
     36QString BCGateway::name() const {
    2937    return "ETHZ";
    3038}
    3139
    32 QImage BCGatewayPriv::icon() const {
     40QImage BCGateway::icon() const {
    3341    return QImage(":/images/ethz.ico");
    3442}
    3543
    36 QList<int> BCGatewayPriv::validRecipientCountryCodes() const {
     44QList<int> BCGateway::validRecipientCountryCodes() const {
    3745    QList<int> result;
    3846    result.append(41); // CH
    3947    return result;
    4048}
    41 QList<QChar> BCGatewayPriv::doublePriceChars() const {
     49QList<QChar> BCGateway::doublePriceChars() const {
    4250    QList<QChar> dpc;
    4351    dpc.append('|');
     
    5260    return dpc;
    5361}
    54 QList<QChar> BCGatewayPriv::disAllowedChars() const {
     62QList<QChar> BCGateway::disAllowedChars() const {
    5563    return QList<QChar>(); // TODO: Check this
    5664}
    5765
    5866
    59 IAccount BCGatewayPriv::createAccountInstance(const IStorage& storage) const {
    60     return BCAccount(storage);
     67IAccount* BCGateway::createAccountInstance(IStorage* storage) {
     68    return new BCAccount(this, storage);
    6169}
    6270
    63 IAccountSettingsWidget* BCGatewayPriv::getAccountSettingsWidget(QWidget* parent /* = 0 */) const {
     71IAccountSettingsWidget* BCGateway::createAccountSettingsWidget(QWidget* parent /* = 0 */) const {
    6472    return new VCSettingsWidget(parent);
    6573}
  • gateways/ETHZ/src/business/bcgateway.h

    r194 r217  
    2222#include <QSet>
    2323
    24 #include <ssingleton.h>
     24#include <smacros.h>
    2525
    2626#include <abstract/abstractgateway.h>
     
    3535const short   MULTISMS_SHORTSMS_LENGTH = 153;
    3636
    37 class BCGatewayPriv: public AbstractGatewayPriv {
     37class BCGateway: public AbstractGateway {
     38    Q_OBJECT
     39    S_SINGLETON(BCGateway)
     40
    3841public: /* IGateway */
    3942    QString       name() const;
     
    4144
    4245public: /* IGateway */
    43     IAccountSettingsWidget* getAccountSettingsWidget(QWidget* parent = 0) const;
    44     IAccount                createAccountInstance(const IStorage& storage) const;
     46    IAccountSettingsWidget* createAccountSettingsWidget(QWidget* parent = 0) const;
     47    IAccount*               createAccountInstance(IStorage* storage);
    4548
    4649public: /* IGateway */
     
    5255    QSet<QString> doublePriceChars_;
    5356};
    54 S_SINGLETON_DERIV(BCGateway, AbstractGateway, IGateway)
    5557
    5658}
  • gateways/ETHZ/src/business/contactimporter/bccontactimporter.cpp

    r216 r217  
    1818
    1919#include "bccontactimporter.h"
     20#include "bccontactimporter_p.h"
    2021
    2122#include <scontact.h>
     23#include <snetworkreply.h>
    2224#include <snumber.h>
    2325
     
    2628namespace ETHZ {
    2729
    28 BCContactImporterPriv::BCContactImporterPriv(const IManagerFactory& managerFactory)
    29     : dataManager_()
     30BCContactImporter::BCContactImporter(QObject* parent, IManagerFactory* managerFactory)
     31    : IContactImporter(parent)
     32    , dataManager_(new BCContactImporterDataManager(this))
    3033    , managerFactory_(managerFactory)
    3134{
    3235}
    33 BCContactImporterPriv::~BCContactImporterPriv() {
    34 }
    3536
    36 QString BCContactImporterPriv::describingName() const {
     37QString BCContactImporter::describingName() const {
    3738    if (isApplicable()) {
    3839        return QObject::tr("Import contacts from the ETHZ website.");
     
    4243}
    4344
    44 bool BCContactImporterPriv::isApplicable() const {
    45     foreach (IAccount account, managerFactory_->accountManager()->getAccountList()) {
     45bool BCContactImporter::isApplicable() const {
     46    foreach (IAccount* account, managerFactory_->accountManager()->getAccountList()) {
    4647        if (account->isEnabled() && (account->gateway() == BCGateway::instance())) {
    4748            if (account->isLoggedIn()) {
     
    5455
    5556
    56 void BCContactImporterPriv::init() {
    57     QSet<BCAccount> accounts;
    58     foreach (IAccount account, managerFactory_->accountManager()->getAccountList()) {
     57void BCContactImporter::init() {
     58    QSet<BCAccount*> accounts;
     59    foreach (IAccount* account, managerFactory_->accountManager()->getAccountList()) {
    5960        if (account->gateway() == BCGateway::instance()) {
    60             accounts.insert(account);
     61            accounts.insert(static_cast<BCAccount*>(account));
    6162        }
    6263    }
     
    6465
    6566}
    66 QList<QWizardPage*> BCContactImporterPriv::getPreImportPages() {
     67QList<QWizardPage*> BCContactImporter::createPreImportPages(QWidget* parent) {
     68    Q_UNUSED(parent);
    6769    return QList<QWizardPage*>();
    6870}
    69 QSet<SContact> BCContactImporterPriv::importContacts() {
     71QSet<SContact> BCContactImporter::importContacts() {
    7072    QSet<SContact> contacts;
    7173
    72     foreach (BCAccount account, dataManager_->selectedAccounts()) {
     74    foreach (BCAccount* account, dataManager_->selectedAccounts()) {
    7375        if (!account->isLoggedIn()) continue;
    7476
    75         QList<IParam> posts;
    76         posts.append(SKeyValueParam("username", account->username().toUtf8()));
    77         posts.append(SKeyValueParam("password", account->password().toUtf8()));
    78         posts.append(SKeyValueParam("action",   "listaddressbook"));
     77        QList<IParam*> posts;
     78        posts.append(new SKeyValueParam("username", account->username().toUtf8()));
     79        posts.append(new SKeyValueParam("password", account->password().toUtf8()));
     80        posts.append(new SKeyValueParam("action",   "listaddressbook"));
    7981
    8082        QString response = account->httpHelper()->syncPost(URL_SENDSMS, posts)->readAll();
     
    109111/********************************************************************************/
    110112
    111 QSet<BCAccount> BCContactImporterDataManagerPriv::selectedAccounts() const {
     113QSet<BCAccount*> BCContactImporterDataManager::selectedAccounts() const {
    112114    return selectedAccounts_;
    113115}
    114116
    115 void BCContactImporterDataManagerPriv::setSelectedAccounts(const QSet<BCAccount>& selectedAccounts) {
     117void BCContactImporterDataManager::setSelectedAccounts(const QSet<BCAccount*>& selectedAccounts) {
    116118    selectedAccounts_ = selectedAccounts;
    117119    emit selectedAccountsChanged();
  • gateways/ETHZ/src/business/contactimporter/bccontactimporter.h

    r194 r217  
    3030namespace ETHZ {
    3131
    32 class BCContactImporterDataManagerPriv : public QObject, public SShareable {
     32class BCContactImporterDataManager;
     33
     34class BCContactImporter : public IContactImporter {
    3335    Q_OBJECT
    3436
    3537public:
    36     QSet<BCAccount> selectedAccounts() const;
    37     void            setSelectedAccounts(const QSet<BCAccount>& selectedAccounts);
    38 
    39 signals:
    40     void selectedAccountsChanged();
    41 
    42 private:
    43     QSet<BCAccount> selectedAccounts_;
    44 };
    45 class BCContactImporterDataManager : protected SSharedQObj<BCContactImporterDataManagerPriv> {
    46     S_SHARED_INTERNAL(BCContactImporterDataManager, SSharedQObj<BCContactImporterDataManagerPriv>, SSharedQObj<BCContactImporterDataManagerPriv>)
    47     S_SHARED_QOBJ_INTERNAL(BCContactImporterDataManager, SSharedQObj<BCContactImporterDataManagerPriv>, SSharedQObj<BCContactImporterDataManagerPriv>)
    48 
    49 public:
    50     BCContactImporterDataManager()
    51         : SSharedQObj<BCContactImporterDataManagerPriv>(new BCContactImporterDataManagerPriv)
    52     {};
    53 };
    54 
    55 
    56 class BCContactImporterPriv : public IContactImporterPriv {
    57 public:
    58     BCContactImporterPriv(const IManagerFactory& managerFactory);
    59     ~BCContactImporterPriv();
     38    BCContactImporter(QObject* parent, IManagerFactory* managerFactory);
    6039
    6140public: /* IContactImporter */
     
    6443
    6544    void                init();
    66     QList<QWizardPage*> getPreImportPages();
     45    QList<QWizardPage*> createPreImportPages(QWidget* parent);
    6746    QSet<SContact>      importContacts();
    6847
    6948private:
    70     BCContactImporterDataManager dataManager_;
    71     IManagerFactory              managerFactory_;
    72 };
    73 class BCContactImporter : public IContactImporter {
    74     S_SHARED_INTERNAL(BCContactImporter, IContactImporter, IContactImporter)
    75 
    76 public:
    77     explicit BCContactImporter(const IManagerFactory& managerFactory)
    78         : IContactImporter(new BCContactImporterPriv(managerFactory))
    79     {};
     49    BCContactImporterDataManager* dataManager_;
     50    IManagerFactory*              managerFactory_;
    8051};
    8152
  • gateways/ETHZ/src/business/validation/bcaccountvalidator.cpp

    r194 r217  
    2323namespace ETHZ {
    2424
    25 SValidationResult BCAccountValidatorPriv::validate() const {
    26     return SStdAccountValidatorPriv::validate();
     25SValidationResult BCAccountValidator::validate() const {
     26    return SStdAccountValidator::validate();
    2727}
    2828
  • gateways/ETHZ/src/business/validation/bcaccountvalidator.h

    r194 r217  
    2424namespace ETHZ {
    2525
    26 class BCAccountValidatorPriv : public SStdAccountValidatorPriv {
     26class BCAccountValidator : public SStdAccountValidator {
     27    Q_OBJECT
     28
    2729public:
    28     explicit BCAccountValidatorPriv(const IAccount& account)
    29         : SStdAccountValidatorPriv(account)
     30    explicit BCAccountValidator(QObject* parent, IAccount* account)
     31        : SStdAccountValidator(parent, account)
    3032    {};
    3133
     
    3436    SValidationResult validate() const;
    3537};
    36 class BCAccountValidator : public SStdAccountValidator {
    37     S_SHARED_INTERNAL(BCAccountValidator, SStdAccountValidator, IValidator)
    38 
    39 public:
    40     explicit BCAccountValidator(const IAccount& account)
    41         : SStdAccountValidator(new BCAccountValidatorPriv(account))
    42     {};
    43 };
    4438
    4539}
  • gateways/ETHZ/src/library.cpp

    r194 r217  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 
    19 #include "main.h"
     18#include "library.h"
    2019
    2120#include <QCoreApplication>
    22 #include <QDebug>
    2321#include <QDir>
    2422
     
    3028namespace ETHZ {
    3129
    32 LibraryPriv::LibraryPriv()
    33     : managerFactory_(NULL)
    34 {}
    35 LibraryPriv::~LibraryPriv() {
     30S_SINGLETON_IMPL(Library)
     31
     32Library::Library()
     33    : ILibrary(NULL) // singleton
     34    , managerFactory_(NULL)
     35{
    3636}
    3737
    38 
    39 
    40 void LibraryPriv::init(const IManagerFactory& managerFactory) {
     38void Library::init(IManagerFactory* managerFactory) {
    4139    managerFactory_ = managerFactory;
    4240
    4341    contactImporters_.clear();
    44     contactImporters_.append(BCContactImporter(managerFactory_));
     42    contactImporters_.append(new BCContactImporter(this, managerFactory));
    4543}
    4644
    47 QString LibraryPriv::identificationKey() const {
     45QString Library::identificationKey() const {
    4846    return "ETHZ";
    4947}
    50 SVersion LibraryPriv::version() const {
     48SVersion Library::version() const {
    5149    return SVersion(LIB_VERSION);
    5250}
    53 QString LibraryPriv::compatibilityVersion() const {
     51QString Library::compatibilityVersion() const {
    5452    return ILibrary::COMPATIBILITY_VERSION;
    5553}
    5654
    57 QList<QTranslator*> LibraryPriv::getTranslators() const {
     55QList<QTranslator*> Library::getTranslators() const {
    5856    QList<QTranslator*> result;
    5957
     
    6765}
    6866
    69 IGateway LibraryPriv::getGateway() const {
     67IGateway* Library::getGateway() const {
    7068    return BCGateway::instance();
    7169}
    7270
    73 QList<IContactImporter> LibraryPriv::getContactImporters() const {
     71QList<IContactImporter*> Library::getContactImporters() const {
    7472    return contactImporters_;
    7573}
    7674
    77 IManagerFactory LibraryPriv::managerFactory() const {
     75IManagerFactory* Library::managerFactory() const {
    7876    return managerFactory_;
    7977}
     
    8179}
    8280
    83 extern "C" LIBRARY_EXPORT ILibrary getLibrary() {
     81extern "C" LIBRARY_EXPORT ILibrary* getLibrary() {
    8482    return ETHZ::Library::instance();
    8583}
  • gateways/ETHZ/src/library.h

    r194 r217  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 
    1918#ifndef ETHZ_MAIN_H_
    2019#define ETHZ_MAIN_H_
     
    2322
    2423#include <icontactimporter.h>
     24#include <igateway.h>
    2525#include <ilibrary.h>
    26 #include <igateway.h>
    2726#include <imanagers.h>
    2827
    29 #include <ssingleton.h>
     28#include <smacros.h>
    3029
    3130namespace ETHZ {
    3231
    33 class LibraryPriv : public ILibraryPriv {
    34     Q_INTERFACES(ILibraryPriv)
     32class Library : public ILibrary {
     33    Q_OBJECT
     34    Q_INTERFACES(ILibrary)
     35    S_SINGLETON(Library)
     36
     37public: /* ILibrary */
     38    void                     init(IManagerFactory* managerFactory);
     39
     40    QString                  identificationKey() const;
     41    SVersion                 version() const;
     42    QString                  compatibilityVersion() const;
     43
     44    QList<QTranslator*>      getTranslators() const;
     45    IGateway*                getGateway() const;
     46    QList<IContactImporter*> getContactImporters() const;
    3547
    3648public:
    37     LibraryPriv();
    38 
    39 public:
    40     /* ILibrary */
    41     void                    init(const IManagerFactory& managerFactory);
    42 
    43     QString                 identificationKey() const;
    44     SVersion                version() const;
    45     QString                 compatibilityVersion() const;
    46 
    47     QList<QTranslator*>     getTranslators() const;
    48     IGateway                getGateway() const;
    49     QList<IContactImporter> getContactImporters() const;
    50 
    51 public:
    52     IManagerFactory         managerFactory() const;
    53 
    54 public:
    55     ~LibraryPriv();
     49    IManagerFactory*         managerFactory() const;
    5650
    5751private:
    58     IManagerFactory managerFactory_;
    59 
    60     QList<IContactImporter> contactImporters_;
     52    IManagerFactory* managerFactory_;
     53    QList<IContactImporter*> contactImporters_;
    6154};
    62 class LIBRARY_EXPORT Library : public ILibrary {
    63     S_SINGLETON_INTERNAL_UNIMPL(Library, ILibrary, ILibrary)
    64 };
    65 S_SINGLETON_INTERNAL_IMPL(Library, ILibrary, ILibrary)
    6655
    6756}
  • gateways/ETHZ/src/persistence/daaccountstorageofficer.cpp

    r194 r217  
    2323namespace ETHZ {
    2424
    25 void DAAccountStorageOfficerPriv::readFromStorage() {
    26     AbstractAccountStorageOfficerPriv::readFromStorage();
     25void DAAccountStorageOfficer::readFromStorage() {
     26    AbstractAccountStorageOfficer::readFromStorage();
    2727}
    2828
    29 void DAAccountStorageOfficerPriv::writeToStorage() const {
    30     AbstractAccountStorageOfficerPriv::writeToStorage();
     29void DAAccountStorageOfficer::writeToStorage() const {
     30    AbstractAccountStorageOfficer::writeToStorage();
    3131}
    3232
  • gateways/ETHZ/src/persistence/daaccountstorageofficer.h

    r194 r217  
    2424namespace ETHZ {
    2525
    26 class DAAccountStorageOfficerPriv : public AbstractAccountStorageOfficerPriv {
     26class DAAccountStorageOfficer : public AbstractAccountStorageOfficer {
     27    Q_OBJECT
     28
    2729public:
    28     DAAccountStorageOfficerPriv(const AbstractAccount& account, const IStorage& storage)
    29         : AbstractAccountStorageOfficerPriv(account, storage, "s_arfoPo20fWcdp;ISh2984710asfd,p.ymd:dwqs")
     30    DAAccountStorageOfficer(QObject* parent, AbstractAccount* account, IStorage* storage)
     31        : AbstractAccountStorageOfficer(parent, account, storage, "s_arfoPo20fWcdp;ISh2984710asfd,p.ymd:dwqs")
    3032    {};
    3133
     
    3537    void writeToStorage() const;
    3638};
    37 class DAAccountStorageOfficer : public AbstractAccountStorageOfficer {
    38     S_SHARED_INTERNAL(DAAccountStorageOfficer, AbstractAccountStorageOfficer, IStorageOfficer)
    39 
    40 public:
    41     DAAccountStorageOfficer(const AbstractAccount& account, const IStorage& storage)
    42         : AbstractAccountStorageOfficer(new DAAccountStorageOfficerPriv(account, storage))
    43     {};
    44 };
    4539
    4640}
  • gateways/ETHZ/src/ui/vcsettingswidget.cpp

    r194 r217  
    2525
    2626#include "business/bcaccount.h"
     27#include "business/bcgateway.h"
    2728
    2829namespace ETHZ {
     
    3536
    3637
    37 void VCSettingsWidget::loadFromAccount(const IAccount& account) {
     38void VCSettingsWidget::loadFromAccount(IAccount* account) {
    3839    Q_ASSERT(account);
    3940    Q_ASSERT(account->gateway() == BCGateway::instance());
    4041
    41     BCAccount acc = account;
     42    BCAccount* acc = static_cast<BCAccount*>(account);
    4243
    4344    ui.edtUsername->setText(acc->username());
     
    4546}
    4647
    47 void VCSettingsWidget::saveToAccount(const IAccount& account) {
     48void VCSettingsWidget::saveToAccount(IAccount* account) {
    4849    Q_ASSERT(account);
    4950    Q_ASSERT(account->gateway() == BCGateway::instance());
    5051
    51     BCAccount acc = account;
     52    BCAccount* acc = static_cast<BCAccount*>(account);
    5253
    5354    acc->setUsername(ui.edtUsername->text());
  • gateways/ETHZ/src/ui/vcsettingswidget.h

    r194 r217  
    3232
    3333public:
    34     VCSettingsWidget(QWidget* parent = 0);
     34    VCSettingsWidget(QWidget* parent);
    3535
    3636public:
    3737    /* IAccountSettingsWidget */
    38     void loadFromAccount(const IAccount& account);
    39     void saveToAccount(const IAccount& account);
     38    void loadFromAccount(IAccount* account);
     39    void saveToAccount(IAccount* account);
    4040
    4141private:
  • gateways/Post/post.pro

    r193 r217  
    44include(locale/locale.pri)
    55HEADERS += src/business/contactimporter/bccontactimporter.h \
    6     src/business/validation/bcaccountvalidator.h \
    76    src/business/bcaccount.h \
    87    src/business/bcaccount_tasks.h \
     
    109    src/persistence/daaccountstorageofficer.h \
    1110    src/ui/vcsettingswidget.h \
    12     src/main.h
     11    src/library.h
    1312SOURCES += src/business/contactimporter/bccontactimporter.cpp \
    14     src/business/validation/bcaccountvalidator.cpp \
    1513    src/business/bcaccount.cpp \
    1614    src/business/bcaccount_costs.cpp \
     
    2018    src/persistence/daaccountstorageofficer.cpp \
    2119    src/ui/vcsettingswidget.cpp \
    22     src/main.cpp
     20    src/library.cpp
    2321FORMS += src/ui/vcsettingswidget.ui
    2422RESOURCES += lib/Post.qrc
  • gateways/Post/src/business/bcaccount.cpp

    r215 r217  
    3030#include <exceptions/loginaccountexceptions.h>
    3131
     32#include <snetworkreply.h>
    3233#include <snumber.h>
    3334#include <stask_predefined.h>
     35#include <sstdaccountvalidator.h>
    3436
    35 #include "main.h"
     37#include "library.h"
    3638#include "bcgateway.h"
    37 #include "validation/bcaccountvalidator.h"
    3839#include "persistence/daaccountstorageofficer.h"
    3940
    4041namespace Post {
    4142
    42 BCAccountPriv::BCAccountPriv(const IStorage& storage)
    43     : AbstractAccountPriv()
     43BCAccount::BCAccount(QObject* parent, IStorage* storage)
     44    : AbstractAccount(parent)
     45    , networkHelper_(new SNetworkHelper(this))
    4446    , adTextLength_(0)
    4547{
    46     init(DAAccountStorageOfficer(this, storage), BCAccountValidator(this));
     48    init(new DAAccountStorageOfficer(this, this, storage), new SStdAccountValidator(this, this));
    4749
    4850    networkHelper_->addTrustedCA(":/certs/VerisignCA3.crt");
    4951
    50     connect(this, SIGNAL(initStateChanged()), this, SLOT(onInitStateChanged()));
     52    connect(this, SIGNAL(initStateChanged(IAccount*)), this, SLOT(onInitStateChanged()));
    5153}
    5254
    53 BCAccountPriv::~BCAccountPriv(){
     55
     56IAccount* BCAccount::createClonedInstance(QObject* parent) const {
     57    return new BCAccount(parent, getStorageOfficer()->storage());
    5458}
    55 
    56 IAccount BCAccountPriv::getClonedInstance() const {
    57     return BCAccount(getStorageOfficer()->storage());
    58 }
    59 IGateway BCAccountPriv::gateway() const {
     59IGateway* BCAccount::gateway() const {
    6060    return BCGateway::instance();
    6161}
    6262
    63 IAccountInitTask BCAccountPriv::doCreateInitTask() {
    64     return SDefaultLoginInitTask(this);
     63IAccountInitTask* BCAccount::doCreateInitTask() {
     64    return new SDefaultLoginInitTask(this);
    6565}
    66 IAccountLoginTask BCAccountPriv::doCreateLoginTask() {
    67     return BCAccountLoginTask(this);
     66IAccountLoginTask* BCAccount::doCreateLoginTask() {
     67    return new BCAccountLoginTask(this);
    6868}
    69 ISMSSendTask BCAccountPriv::doCreateSMSSendTask(const QString& message, const QSet<SContact>& recipients) {
    70     return BCSMSSendTask(this, message, recipients);
     69ISMSSendTask* BCAccount::doCreateSMSSendTask(const QString& message, const QSet<SContact>& recipients) {
     70    return new BCSMSSendTask(this, message, recipients);
    7171}
    7272
     
    7777 * @return The networkHelper
    7878 */
    79 SNetworkHelper BCAccountPriv::networkHelper() {
     79SNetworkHelper* BCAccount::networkHelper() const {
    8080    return networkHelper_;
    8181}
    8282
    83 void BCAccountPriv::cancelSMSSending() {
     83void BCAccount::cancelSMSSending() {
    8484}
    8585
    86 bool BCAccountPriv::checkStillLoggedIn() {
     86bool BCAccount::checkStillLoggedIn() {
    8787    //haltIfCancelled();
    8888    qDebug() << "Starting still-logged-in-check";
     
    103103}
    104104
    105 void BCAccountPriv::reloadOnlineParams() {
     105void BCAccount::reloadOnlineParams() {
    106106    reloadFreeSMSCount();
    107107}
    108 void BCAccountPriv::reloadFreeSMSCount(QString html) {
     108void BCAccount::reloadFreeSMSCount(QString html) {
    109109    /*<td class="label">50 von 50 TextSMS im Monat xxx</td> */
    110110
     
    125125
    126126
    127 void BCAccountPriv::onInitStateChanged() {
     127void BCAccount::onInitStateChanged() {
    128128    if (!isInitialized()) {
    129129        // Reset the current state
  • gateways/Post/src/business/bcaccount.h

    r198 r217  
    2828namespace Post {
    2929
    30 class BCAccountPriv : public AbstractAccountPriv {
     30class BCAccount : public AbstractAccount {
    3131    Q_OBJECT
    3232
    33     friend class BCContactImporterPriv;
    34     friend class BCAccountLoginTaskPriv;
    35     friend class BCAccountLogoutTaskPriv;
    36     friend class BCSMSSendTaskPriv;
     33    friend class BCContactImporter; // networkHelper()
     34    friend class BCAccountLoginTask; // reloadOnlineParams(), networkHelper()
     35    friend class BCSMSSendTask; // reloadOnlineParams(), networkHelper()
    3736
    3837public:
    39     explicit BCAccountPriv(const IStorage& storage);
    40     virtual ~BCAccountPriv();
     38    explicit BCAccount(QObject* parent, IStorage* storage);
    4139
    4240public: /* IAccount */
    43     IGateway         gateway() const;
    44     IAccount         getClonedInstance() const;
     41    IGateway*          gateway() const;
     42    IAccount*          createClonedInstance(QObject* parent) const;
    4543
    4644public: /* IAccount - SMS sending */
    47     void             cancelSMSSending();
     45    void               cancelSMSSending();
    4846
    4947public: /* IAccount - costs */
    50     int              costsForText(const QString& message) const;
    51     QList<QString>   splitTextToLongSMS(const QString& text) const;
    52     int              shortSMSCount(const QString& text) const;
     48    int                costsForText(const QString& message) const;
     49    QList<QString>     splitTextToLongSMS(const QString& text) const;
     50    int                shortSMSCount(const QString& text) const;
    5351
    5452public: /* Properties */
    5553
    5654protected: /* AbstractAccount */
    57     IAccountInitTask  doCreateInitTask();
    58     IAccountLoginTask doCreateLoginTask();
    59     ISMSSendTask      doCreateSMSSendTask(const QString& message, const QSet<SContact>& recipients);
     55    IAccountInitTask*  doCreateInitTask();
     56    IAccountLoginTask* doCreateLoginTask();
     57    ISMSSendTask*      doCreateSMSSendTask(const QString& message, const QSet<SContact>& recipients);
    6058
    6159protected: /* AbstractLoginAccount */
    62     bool              checkStillLoggedIn();
     60    bool               checkStillLoggedIn();
    6361
    6462private:
    65     int               adTextLength() const;
    66     void              setAdTextLength(int length);
     63    int                adTextLength() const;
     64    void               setAdTextLength(int length);
    6765
    68     int               longSMSLength() const;
    69     void              setLongSMSLength(int longSMSLength);
     66    int                longSMSLength() const;
     67    void               setLongSMSLength(int longSMSLength);
    7068
    7169private:
    72     SNetworkHelper    networkHelper();
    73     void              reloadOnlineParams();
    74     void              reloadFreeSMSCount(QString html = QString());
     70    SNetworkHelper*    networkHelper() const;
     71    void               reloadOnlineParams();
     72    void               reloadFreeSMSCount(QString html = QString());
    7573
    7674private:
    77     Q_DISABLE_COPY(BCAccountPriv);
     75    Q_DISABLE_COPY(BCAccount)
    7876
    7977private slots:
    80     void             onInitStateChanged();
     78    void               onInitStateChanged();
    8179
    8280private:
    83     SNetworkHelper   networkHelper_;
    84 
    85     int              adTextLength_;
    86 };
    87 class BCAccount : public AbstractAccount {
    88     S_SHARED_INTERNAL(BCAccount, AbstractAccount, IAccount)
    89     S_SHARED_QOBJ_INTERNAL(BCAccount, AbstractAccount, IAccount)
    90 
    91 public:
    92     BCAccount()
    93         : AbstractAccount(NULL)
    94     {};
    95     explicit BCAccount(const IStorage& storage)
    96         : AbstractAccount(new BCAccountPriv(storage))
    97     {};
     81    SNetworkHelper*    networkHelper_;
     82    int                adTextLength_;
    9883};
    9984
  • gateways/Post/src/business/bcaccount_costs.cpp

    r194 r217  
    3232 * @return Returns a list of the long-sms texts
    3333 */
    34 QList<QString> BCAccountPriv::splitTextToLongSMS(const QString& text) const {
     34QList<QString> BCAccount::splitTextToLongSMS(const QString& text) const {
    3535    QList<QString> longSMSList;
    3636    QString text_(text);
     
    6565 * @return Returns a list of the short-sms texts
    6666 */
    67 int BCAccountPriv::shortSMSCount(const QString& text) const {
     67int BCAccount::shortSMSCount(const QString& text) const {
    6868    QString txt(text);
    6969    foreach (QChar doublePriceChar, gateway()->doublePriceChars()) {
     
    9595 * @return The costs
    9696 */
    97 int BCAccountPriv::costsForText(const QString& message) const {
     97int BCAccount::costsForText(const QString& message) const {
    9898    return shortSMSCount(message);
    9999}
     
    106106 * @return The length of the ad text
    107107 */
    108 int BCAccountPriv::adTextLength() const {
     108int BCAccount::adTextLength() const {
    109109    return adTextLength_;
    110110}
    111 void BCAccountPriv::setAdTextLength(int length) {
     111void BCAccount::setAdTextLength(int length) {
    112112    adTextLength_ = length;
    113113}
    114114
    115115
    116 int BCAccountPriv::longSMSLength() const {
     116int BCAccount::longSMSLength() const {
    117117    return LONGSMS_LENGTH;
    118118}
  • gateways/Post/src/business/bcaccount_task_login.cpp

    r198 r217  
    2222#include <QSslKey>
    2323
     24#include <snetworkreply.h>
    2425#include <exceptions/eloginaccountloginexception.h>
    2526
    26 #include "main.h"
     27#include "library.h"
    2728
    2829namespace Post {
    2930
    30 BCAccountLoginTaskPriv::BCAccountLoginTaskPriv(const BCAccount& account)
    31     : AbstractAccountLoginTaskPriv(account)
    32 {};
     31BCAccountLoginTask::BCAccountLoginTask(BCAccount* account)
     32    : AbstractAccountLoginTask(account)
     33{}
    3334
    34 void BCAccountLoginTaskPriv::doLogin() {
     35void BCAccountLoginTask::doLogin() {
    3536    setProgress(10);
    3637
     
    4849}
    4950
    50 QString BCAccountLoginTaskPriv::postLogin() {
     51QString BCAccountLoginTask::postLogin() {
    5152    QString html = http()->syncGet(URL_LOGIN)->readAll();
    5253
    53     QList<IParam> posts;
    54     posts.append(SKeyValueParam("isiwebuserid", account()->username().toUtf8()));
    55     posts.append(SKeyValueParam("isiwebpasswd", account()->password().toUtf8()));
    56     posts.append(SKeyValueParam("checkIsSubmitted", "fromFormLoginhtml"));
     54    QList<IParam*> posts;
     55    posts.append(new SKeyValueParam("isiwebuserid", account()->username().toUtf8()));
     56    posts.append(new SKeyValueParam("isiwebpasswd", account()->password().toUtf8()));
     57    posts.append(new SKeyValueParam("checkIsSubmitted", "fromFormLoginhtml"));
    5758
    5859    html = http()->syncPost(URL_LOGIN, posts)->readAll();
     
    6970}
    7071
    71 QString BCAccountLoginTaskPriv::postSamlRequest(QString lastHtml) {
     72QString BCAccountLoginTask::postSamlRequest(QString lastHtml) {
    7273    /* Find URL */
    7374    QRegExp rx("<form method=\"post\" action=\"([^\"]+)\">");
     
    102103
    103104    // Post the saml request
    104     QList<IParam> posts;
    105     posts.append(SKeyValueParam("SAMLRequest", samlRequest.toUtf8()));
    106     posts.append(SKeyValueParam("RelayState", relayState.toUtf8()));
     105    QList<IParam*> posts;
     106    posts.append(new SKeyValueParam("SAMLRequest", samlRequest.toUtf8()));
     107    posts.append(new SKeyValueParam("RelayState", relayState.toUtf8()));
    107108
    108109    return http()->syncPost(url, posts)->readAll();
    109110}
    110111
    111 QString BCAccountLoginTaskPriv::postSamlResponse(QString lastHtml) {
     112QString BCAccountLoginTask::postSamlResponse(QString lastHtml) {
    112113    /*
    113114                <form id="saml_form" action="https://organizer.sso.post.ch/sso-navi/assertion_consumer.php" method="POST" enctype="application/x-www-form-urlencoded">
     
    148149
    149150    // Post the saml response
    150     QList<IParam> posts;
    151     posts.append(SKeyValueParam("SAMLResponse", samlRequest.toUtf8()));
    152     posts.append(SKeyValueParam("RelayState", relayState.toUtf8()));
     151    QList<IParam*> posts;
     152    posts.append(new SKeyValueParam("SAMLResponse", samlRequest.toUtf8()));
     153    posts.append(new SKeyValueParam("RelayState", relayState.toUtf8()));
    153154
    154155    return http()->syncPost(url, posts)->readAll();
     
    156157
    157158
    158 BCAccount BCAccountLoginTaskPriv::account() const {
    159     return AbstractAccountLoginTaskPriv::account();
     159BCAccount* BCAccountLoginTask::account() const {
     160    return static_cast<BCAccount*>(AbstractAccountLoginTask::account());
    160161}
    161162
    162 SNetworkHelper BCAccountLoginTaskPriv::http() const {
     163SNetworkHelper* BCAccountLoginTask::http() const {
    163164    return account()->networkHelper();
    164165}
  • gateways/Post/src/business/bcaccount_task_sendsms.cpp

    r216 r217  
    2020#include <math.h>
    2121
     22#include <snetworkreply.h>
    2223#include <snumber.h>
    2324#include <exceptions/eabortloadingexception.h>
     
    2526namespace Post {
    2627
    27 BCSMSSendTaskPriv::BCSMSSendTaskPriv(const BCAccount& account, const QString& message, const QSet<SContact>& recipients)
    28     : AbstractSMSSendTaskPriv(account, message, recipients)
    29 {};
     28BCSMSSendTask::BCSMSSendTask(BCAccount* account, const QString& message, const QSet<SContact>& recipients)
     29    : AbstractSMSSendTask(account, message, recipients)
     30{
     31}
    3032
    31 void BCSMSSendTaskPriv::doSendSMS() {
     33void BCSMSSendTask::doSendSMS() {
    3234    Q_ASSERT(!message().isEmpty());
    3335    Q_ASSERT(!recipients().isEmpty());
     
    114116}
    115117
    116 void BCSMSSendTaskPriv::addRecipient(const SContact& recipient) {
     118void BCSMSSendTask::addRecipient(const SContact& recipient) {
    117119    haltIfCancelRequested();
    118120    qDebug() << "Starting adding recipient " + recipient.number().toString();
     
    126128    qDebug() << "Recipient added";
    127129}
    128 void BCSMSSendTaskPriv::removeRecipients() {
     130void BCSMSSendTask::removeRecipients() {
    129131    haltIfCancelRequested();
    130132    qDebug() << "Removing recipients";
     
    135137    qDebug() << "Recipients removed";
    136138}
    137 void BCSMSSendTaskPriv::sendLongSMS(const QString& text) {
     139void BCSMSSendTask::sendLongSMS(const QString& text) {
    138140    haltIfCancelRequested();
    139141    qDebug() << "Start of sending part of SMS";
     
    141143    setDetails(Account::Action::SendingSMS);
    142144
    143     QList<IParam> posts;
    144     posts.append(SKeyValueParam("my_action", "sms"));
    145     posts.append(SKeyValueParam("draft_id", ""));
    146     posts.append(SKeyValueParam("later_id", ""));
    147     posts.append(SKeyValueParam("sms_number", recipientsStr_.toUtf8()));
    148     posts.append(SKeyValueParam("sms_body", text.toUtf8()));
     145    QList<IParam*> posts;
     146    posts.append(new SKeyValueParam("my_action", "sms"));
     147    posts.append(new SKeyValueParam("draft_id", ""));
     148    posts.append(new SKeyValueParam("later_id", ""));
     149    posts.append(new SKeyValueParam("sms_number", recipientsStr_.toUtf8()));
     150    posts.append(new SKeyValueParam("sms_body", text.toUtf8()));
    149151
    150152    http()->syncPost(URL_SENDSMS, posts, SNetworkHelper::ptUrlEncoded);
     
    154156}
    155157
    156 BCAccount BCSMSSendTaskPriv::account() const {
    157     return AbstractSMSSendTaskPriv::account();
     158BCAccount* BCSMSSendTask::account() const {
     159    return static_cast<BCAccount*>(AbstractSMSSendTask::account());
    158160}
    159161
    160 SNetworkHelper BCSMSSendTaskPriv::http() const {
     162SNetworkHelper* BCSMSSendTask::http() const {
    161163    return account()->networkHelper();
    162164}
  • gateways/Post/src/business/bcaccount_tasks.h

    r198 r217  
    1616  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717*/
    18 
    1918#ifndef POST_BCACCOUNT_TASKS_H_
    2019#define POST_BCACCOUNT_TASKS_H_
    21 
    2220
    2321#include <abstract/abstractaccount_tasks.h>
     
    2725namespace Post {
    2826
    29 class BCAccountLoginTaskPriv : public AbstractAccountLoginTaskPriv {
     27class BCAccountLoginTask : public AbstractAccountLoginTask {
    3028    Q_OBJECT
    3129
    3230public:
    33     explicit BCAccountLoginTaskPriv(const BCAccount& account);
     31    explicit BCAccountLoginTask(BCAccount* account);
    3432
    3533protected: /* AbstractAccountLoginTask */
    3634    void       doLogin();
    37     BCAccount  account() const;
     35    BCAccount* account() const;
    3836
    3937private:
    40     SNetworkHelper http() const;
     38    SNetworkHelper* http() const;
    4139
    4240private:
     
    4543    QString postSamlResponse(QString lastHtml);
    4644};
    47 class BCAccountLoginTask : public AbstractAccountLoginTask {
    48     S_SHARED_INTERNAL(BCAccountLoginTask, AbstractAccountLoginTask, STask)
    49     S_SHARED_QOBJ_INTERNAL(BCAccountLoginTask, AbstractAccountLoginTask, STask)
    50 
    51 public:
    52     explicit BCAccountLoginTask(const BCAccount& account)
    53         : AbstractAccountLoginTask(new BCAccountLoginTaskPriv(account))
    54     {};
    55 };
    5645
    5746
    58 class BCSMSSendTaskPriv : public AbstractSMSSendTaskPriv {
     47class BCSMSSendTask : public AbstractSMSSendTask {
    5948    Q_OBJECT
    6049
    6150public:
    62     BCSMSSendTaskPriv(const BCAccount& account, const QString& message, const QSet<SContact>& recipients);
     51    BCSMSSendTask(BCAccount* account, const QString& message, const QSet<SContact>& recipients);
    6352
    6453protected: /* AbstractAccountSendSMSTask */
    65     void      doSendSMS();
    66     BCAccount account() const;
     54    void       doSendSMS();
     55    BCAccount* account() const;
    6756
    6857private:
     
    7261
    7362private:
    74     SNetworkHelper http() const;
     63    SNetworkHelper* http() const;
    7564
    7665private:
    7766    QString recipientsStr_;
    7867};
    79 class BCSMSSendTask : public AbstractSMSSendTask {
    80     S_SHARED_INTERNAL(BCSMSSendTask, AbstractSMSSendTask, STask)
    81     S_SHARED_QOBJ_INTERNAL(BCSMSSendTask, AbstractSMSSendTask, STask)
    8268
    83 public:
    84     BCSMSSendTask(const BCAccount& account, const QString& message, const QSet<SContact>& recipients)
    85         : AbstractSMSSendTask(new BCSMSSendTaskPriv(account, message, recipients))
    86     {};
    87 };
    8869}
    8970
  • gateways/Post/src/business/bcgateway.cpp

    r194 r217  
    2323namespace Post {
    2424
    25 QString BCGatewayPriv::name() const {
     25S_SINGLETON_IMPL(BCGateway)
     26
     27BCGateway::BCGateway()
     28    : AbstractGateway(NULL) // singleton
     29{
     30}
     31
     32
     33QString BCGateway::name() const {
    2634    return "Post";
    2735}
    2836
    29 QImage BCGatewayPriv::icon() const {
     37QImage BCGateway::icon() const {
    3038    return QImage(":/images/Post.ico");
    3139}
    3240
    33 QList<int> BCGatewayPriv::validRecipientCountryCodes() const {
     41QList<int> BCGateway::validRecipientCountryCodes() const {
    3442    QList<int> result;
    3543    result.append(41); // CH
    3644    return result;
    3745}
    38 QList<QChar> BCGatewayPriv::doublePriceChars() const {
     46QList<QChar> BCGateway::doublePriceChars() const {
    3947    // Got them from URL_SENDSMS -> function left_char(fld) { ... }
    4048
     
    5159    return dpc;
    5260}
    53 QList<QChar> BCGatewayPriv::disAllowedChars() const {
     61QList<QChar> BCGateway::disAllowedChars() const {
    5462    return QList<QChar>(); // TODO: Check this
    5563}
    5664
    5765
    58 IAccount BCGatewayPriv::createAccountInstance(const IStorage& storage) const {
    59     return BCAccount(storage);
     66IAccount* BCGateway::createAccountInstance(IStorage* storage) {
     67    return new BCAccount(this, storage);
    6068}
    6169
    62 IAccountSettingsWidget* BCGatewayPriv::getAccountSettingsWidget(QWidget* parent /* = 0 */) const {
     70IAccountSettingsWidget* BCGateway::createAccountSettingsWidget(QWidget* parent) const {
    6371    return new VCSettingsWidget(parent);
    6472}
  • gateways/Post/src/business/bcgateway.h

    r194 r217  
    2121#include <QSet>
    2222
    23 #include <ssingleton.h>
    24 
     23#include <smacros.h>
    2524#include <abstract/abstractgateway.h>
    26 #include <persistence/istorage.h>
    2725
    2826namespace Post {
     
    3634const short   LONGSMS_LENGTH         = 435;
    3735
    38 class BCGatewayPriv : public AbstractGatewayPriv {
     36class BCGateway : public AbstractGateway {
     37    Q_OBJECT
     38    S_SINGLETON(BCGateway)
     39
    3940public: /* IGateway */
    4041    QString        name() const;
     
    4243
    4344public: /* IGateway */
    44     IAccountSettingsWidget* getAccountSettingsWidget(QWidget* parent = 0) const;
    45     IAccount                createAccountInstance(const IStorage& storage) const;
     45    IAccountSettingsWidget* createAccountSettingsWidget(QWidget* parent) const;
     46    IAccount*               createAccountInstance(IStorage* storage);
    4647
    4748public: /* IGateway */
     
    5051    QList<QChar>   disAllowedChars() const;
    5152};
    52 S_SINGLETON_DERIV(BCGateway, AbstractGateway, IGateway)
    5353
    5454}
  • gateways/Post/src/business/contactimporter/bccontactimporter.cpp

    r216 r217  
    2020
    2121#include <scontact.h>
     22#include <snetworkreply.h>
    2223#include <snumber.h>
    2324
     
    2627namespace Post {
    2728
    28 BCContactImporterPriv::BCContactImporterPriv(const IManagerFactory& managerFactory)
    29     : dataManager_()
     29BCContactImporter::BCContactImporter(QObject* parent, IManagerFactory* managerFactory)
     30    : IContactImporter(parent)
     31    , dataManager_(new BCContactImporterDataManager(this))
    3032    , managerFactory_(managerFactory)
    3133{
    3234}
    33 BCContactImporterPriv::~BCContactImporterPriv() {
    34 }
    3535
    36 QString BCContactImporterPriv::describingName() const {
     36QString BCContactImporter::describingName() const {
    3737    if (isApplicable()) {
    3838        return QObject::tr("Import contacts from the Post website.");
     
    4242}
    4343
    44 bool BCContactImporterPriv::isApplicable() const {
    45     foreach (IAccount account, managerFactory_->accountManager()->getAccountList()) {
     44bool BCContactImporter::isApplicable() const {
     45    foreach (IAccount* account, managerFactory_->accountManager()->getAccountList()) {
    4646        if (account->isEnabled() && (account->gateway() == BCGateway::instance())) {
    4747            if (account->isLoggedIn()) {
     
    5454
    5555
    56 void BCContactImporterPriv::init() {
    57     QSet<BCAccount> accounts;
    58     foreach (IAccount account, managerFactory_->accountManager()->getAccountList()) {
     56void BCContactImporter::init() {
     57    QSet<BCAccount*> accounts;
     58    foreach (IAccount* account, managerFactory_->accountManager()->getAccountList()) {
    5959        if (account->gateway() == BCGateway::instance()) {
    60             accounts.insert(account);
     60            accounts.insert(static_cast<BCAccount*>(account));
    6161        }
    6262    }
     
    6464
    6565}
    66 QList<QWizardPage*> BCContactImporterPriv::getPreImportPages() {
     66QList<QWizardPage*> BCContactImporter::createPreImportPages(QWidget* parent) {
     67    Q_UNUSED(parent)
     68
    6769    return QList<QWizardPage*>();
    6870}
    69 QSet<SContact> BCContactImporterPriv::importContacts() {
     71QSet<SContact> BCContactImporter::importContacts() {
    7072    QSet<SContact> contacts;
    7173
    72     foreach (BCAccount account, dataManager_->selectedAccounts()) {
     74    foreach (BCAccount* account, dataManager_->selectedAccounts()) {
    7375        if (!account->isLoggedIn()) continue;
    7476
     
    8688        int lastnameCol = columnDescriptor.indexOf(QRegExp("^Nachname$"));
    8789        int mobileCol = columnDescriptor.indexOf(QRegExp("^Mobil-Nummer$"));
    88         int mobileCol2 = columnDescriptor.indexOf(QRegExp("^Mobil-Nummer privat$"));
     90        int mobileCol2 = columnDescriptor.indexOf(QRegExp("^Mobil-Nummer at$"));
    8991
    9092
     
    112114}
    113115
    114 QStringList BCContactImporterPriv::splitIntoCells(QString csvRow) {
     116QStringList BCContactImporter::splitIntoCells(QString csvRow) {
    115117    csvRow = csvRow.mid(1, csvRow.length()-2); // Remove first and last "
    116118    return csvRow.split(QRegExp("\";\""), QString::KeepEmptyParts);
     
    119121/********************************************************************************/
    120122
    121 QSet<BCAccount> BCContactImporterDataManagerPriv::selectedAccounts() const {
     123QSet<BCAccount*> BCContactImporterDataManager::selectedAccounts() const {
    122124    return selectedAccounts_;
    123125}
    124126
    125 void BCContactImporterDataManagerPriv::setSelectedAccounts(const QSet<BCAccount>& selectedAccounts) {
     127void BCContactImporterDataManager::setSelectedAccounts(const QSet<BCAccount*>& selectedAccounts) {
    126128    selectedAccounts_ = selectedAccounts;
    127129    emit selectedAccountsChanged();
    128130}
    129131
    130 };
     132}
  • gateways/Post/src/business/contactimporter/bccontactimporter.h

    r194 r217  
    3232const QString URL_EXPORT_CONTACTS = "https://organizer.sso.post.ch/addresses/adr_csv_export_action.html";
    3333
    34 class BCContactImporterDataManagerPriv : public QObject, public SShareable {
     34class BCContactImporterDataManager : public QObject {
    3535    Q_OBJECT
    3636
    3737public:
    38     QSet<BCAccount> selectedAccounts() const;
    39     void            setSelectedAccounts(const QSet<BCAccount>& selectedAccounts);
     38    BCContactImporterDataManager(QObject* parent)
     39        : QObject(parent)
     40    {}
     41
     42public:
     43    QSet<BCAccount*> selectedAccounts() const;
     44    void             setSelectedAccounts(const QSet<BCAccount*>& selectedAccounts);
    4045
    4146signals:
     
    4348
    4449private:
    45     QSet<BCAccount> selectedAccounts_;
    46 };
    47 class BCContactImporterDataManager : protected SSharedQObj<BCContactImporterDataManagerPriv> {
    48     S_SHARED_INTERNAL(BCContactImporterDataManager, SSharedQObj<BCContactImporterDataManagerPriv>, SSharedQObj<BCContactImporterDataManagerPriv>)
    49     S_SHARED_QOBJ_INTERNAL(BCContactImporterDataManager, SSharedQObj<BCContactImporterDataManagerPriv>, SSharedQObj<BCContactImporterDataManagerPriv>)
    50 
    51 public:
    52     BCContactImporterDataManager()
    53         : SSharedQObj<BCContactImporterDataManagerPriv>(new BCContactImporterDataManagerPriv)
    54     {};
     50    QSet<BCAccount*> selectedAccounts_;
    5551};
    5652
    5753
    58 class BCContactImporterPriv : public IContactImporterPriv {
     54class BCContactImporter : public IContactImporter {
    5955public:
    60     BCContactImporterPriv(const IManagerFactory& managerFactory);
    61     ~BCContactImporterPriv();
     56    BCContactImporter(QObject* parent, IManagerFactory* managerFactory);
    6257
    6358public: /* IContactImporter */
     
    6661
    6762    void                init();
    68     QList<QWizardPage*> getPreImportPages();
     63    QList<QWizardPage*> createPreImportPages(QWidget* parent);
    6964    QSet<SContact>      importContacts();
    7065
     
    7368
    7469private:
    75     BCContactImporterDataManager dataManager_;
    76     IManagerFactory              managerFactory_;
    77 };
    78 class BCContactImporter : public IContactImporter {
    79     S_SHARED_INTERNAL(BCContactImporter, IContactImporter, IContactImporter)
    80 
    81 public:
    82     explicit BCContactImporter(const IManagerFactory& managerFactory)
    83         : IContactImporter(new BCContactImporterPriv(managerFactory))
    84     {};
     70    BCContactImporterDataManager* dataManager_;
     71    IManagerFactory*              managerFactory_;
    8572};
    8673
    87 };
     74}
    8875
    8976#endif /* POST_BCCONTACTIMPORTER_H_ */
  • gateways/Post/src/library.cpp

    r194 r217  
    1616  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717*/
    18 #include "main.h"
     18#include "library.h"
    1919
    2020#include <QCoreApplication>
     
    2929namespace Post {
    3030
    31 LibraryPriv::LibraryPriv()
    32     : managerFactory_(NULL)
    33 {}
    34 LibraryPriv::~LibraryPriv() {
     31S_SINGLETON_IMPL(Library)
     32
     33Library::Library()
     34    : ILibrary(NULL) // singleton
     35    , managerFactory_(NULL)
     36{
    3537}
    3638
    37 
    38 
    39 void LibraryPriv::init(const IManagerFactory& managerFactory) {
     39void Library::init(IManagerFactory* managerFactory) {
    4040    managerFactory_ = managerFactory;
    4141
    4242    contactImporters_.clear();
    43     contactImporters_.append(BCContactImporter(managerFactory_));
     43    contactImporters_.append(new BCContactImporter(this, managerFactory_));
    4444}
    4545
    46 QString LibraryPriv::identificationKey() const {
     46QString Library::identificationKey() const {
    4747    return "Post";
    4848}
    49 SVersion LibraryPriv::version() const {
     49SVersion Library::version() const {
    5050    return SVersion(LIB_VERSION);
    5151}
    52 QString LibraryPriv::compatibilityVersion() const {
     52QString Library::compatibilityVersion() const {
    5353    return ILibrary::COMPATIBILITY_VERSION;
    5454}
    5555
    56 QList<QTranslator*> LibraryPriv::getTranslators() const {
     56QList<QTranslator*> Library::getTranslators() const {
    5757    QList<QTranslator*> result;
    5858
     
    6666}
    6767
    68 IGateway LibraryPriv::getGateway() const {
     68IGateway* Library::getGateway() const {
    6969    return BCGateway::instance();
    7070}
    7171
    72 QList<IContactImporter> LibraryPriv::getContactImporters() const {
     72QList<IContactImporter*> Library::getContactImporters() const {
    7373    return contactImporters_;
    7474}
    7575
    76 IManagerFactory LibraryPriv::managerFactory() const {
     76IManagerFactory* Library::managerFactory() const {
    7777    return managerFactory_;
    7878}
     
    8080}
    8181
    82 extern "C" LIBRARY_EXPORT ILibrary getLibrary() {
     82extern "C" LIBRARY_EXPORT ILibrary* getLibrary() {
    8383    return Post::Library::instance();
    8484}
  • gateways/Post/src/library.h

    r194 r217  
    2626#include <imanagers.h>
    2727
    28 #include <ssingleton.h>
     28#include <smacros.h>
    2929
    3030namespace Post {
    3131
    32 class LibraryPriv : public ILibraryPriv {
    33     Q_INTERFACES(ILibraryPriv)
     32class Library : public ILibrary {
     33    Q_OBJECT
     34    Q_INTERFACES(ILibrary)
     35    S_SINGLETON(Library)
    3436
    35 public:
    36     /* ILibrary */
    37     void                     init(const IManagerFactory& managerFactory);
     37public: /* ILibrary */
     38    void                     init(IManagerFactory* managerFactory);
    3839
    3940    QString                  identificationKey() const;
     
    4243
    4344    QList<QTranslator*>      getTranslators() const;
    44     IGateway                 getGateway() const;
    45     QList<IContactImporter> getContactImporters() const;
     45    IGateway*                getGateway() const;
     46    QList<IContactImporter*> getContactImporters() const;
    4647
    4748public:
    48     IManagerFactory          managerFactory() const;
    49 
    50 public:
    51     LibraryPriv();
    52     ~LibraryPriv();
     49    IManagerFactory*         managerFactory() const;
    5350
    5451private:
    55     IManagerFactory managerFactory_;
    56 
    57     QList<IContactImporter> contactImporters_;
     52    IManagerFactory* managerFactory_;
     53    QList<IContactImporter*> contactImporters_;
    5854};
    59 class LIBRARY_EXPORT Library : public ILibrary {
    60     S_SINGLETON_INTERNAL_UNIMPL(Library, ILibrary, ILibrary)
    61 };
    62 S_SINGLETON_INTERNAL_IMPL(Library, ILibrary, ILibrary)
    6355
    6456}
  • gateways/Post/src/persistence/daaccountstorageofficer.cpp

    r194 r217  
    2222namespace Post {
    2323
    24 void DAAccountStorageOfficerPriv::readFromStorage() {
    25     AbstractAccountStorageOfficerPriv::readFromStorage();
     24DAAccountStorageOfficer::DAAccountStorageOfficer(QObject *parent, AbstractAccount *account, IStorage *storage)
     25    : AbstractAccountStorageOfficer(parent, account, storage, "s2uh98dWe9D_wf98h23:*EOnqei8D")
     26{
    2627}
    2728
    28 void DAAccountStorageOfficerPriv::writeToStorage() const {
    29     AbstractAccountStorageOfficerPriv::writeToStorage();
     29
     30void DAAccountStorageOfficer::readFromStorage() {
     31    AbstractAccountStorageOfficer::readFromStorage();
     32}
     33
     34void DAAccountStorageOfficer::writeToStorage() const {
     35    AbstractAccountStorageOfficer::writeToStorage();
    3036}
    3137
  • gateways/Post/src/persistence/daaccountstorageofficer.h

    r194 r217  
    2323namespace Post {
    2424
    25 class DAAccountStorageOfficerPriv: public AbstractAccountStorageOfficerPriv {
     25class DAAccountStorageOfficer : public AbstractAccountStorageOfficer {
     26    Q_OBJECT
     27
    2628public:
    27     DAAccountStorageOfficerPriv(const AbstractAccount& account, const IStorage& storage)
    28         : AbstractAccountStorageOfficerPriv(account, storage, "s2uh98dWe9D_wf98h23:*EOnqei8D")
    29     {};
     29    DAAccountStorageOfficer(QObject* parent, AbstractAccount* account, IStorage* storage);
    3030
    3131public:
     
    3434    void writeToStorage() const;
    3535};
    36 class DAAccountStorageOfficer : public AbstractAccountStorageOfficer {
    37     S_SHARED_INTERNAL(DAAccountStorageOfficer, AbstractAccountStorageOfficer, IStorageOfficer)
    38 
    39 public:
    40     DAAccountStorageOfficer(const AbstractAccount& account, const IStorage& storage)
    41         : AbstractAccountStorageOfficer(new DAAccountStorageOfficerPriv(account, storage))
    42     {};
    43 };
    4436
    4537}
  • gateways/Post/src/ui/vcsettingswidget.cpp

    r194 r217  
    3434
    3535
    36 void VCSettingsWidget::loadFromAccount(const IAccount& account) {
     36void VCSettingsWidget::loadFromAccount(IAccount* account) {
    3737    Q_ASSERT(account);
    3838    Q_ASSERT(account->gateway() == BCGateway::instance());
    3939
    40     BCAccount acc = account;
     40    BCAccount* acc = static_cast<BCAccount*>(account);
    4141
    4242    ui.edtUsername->setText(acc->username());
     
    4444}
    4545
    46 void VCSettingsWidget::saveToAccount(const IAccount& account) {
     46void VCSettingsWidget::saveToAccount(IAccount* account) {
    4747    Q_ASSERT(account);
    4848    Q_ASSERT(account->gateway() == BCGateway::instance());
    4949
    50     BCAccount acc = account;
     50    BCAccount* acc = static_cast<BCAccount*>(account);
    5151
    5252    acc->setUsername(ui.edtUsername->text());
  • gateways/Post/src/ui/vcsettingswidget.h

    r194 r217  
    3535public:
    3636    /* IAccountSettingsWidget */
    37     void loadFromAccount(const IAccount& account);
    38     void saveToAccount(const IAccount& account);
     37    void loadFromAccount(IAccount* account);
     38    void saveToAccount(IAccount* account);
    3939
    4040private:
  • gateways/Schoolnet/schoolnet.pro

    r193 r217  
    1010    src/business/deepthought/deepthought_tasks.h \
    1111    src/business/deepthought/questionmanager.h \
    12     src/business/validation/bcaccountvalidator.h \
    1312    src/business/bcaccount.h \
    1413    src/business/bcaccount_tasks.h \
     
    2524    src/ui/vcquestionlist/vcquestionlist.h \
    2625    src/ui/vcaccount_guiintegration.h \
    27     src/main.h
     26    src/library.h
    2827SOURCES += src/business/contactimporter/bccontactimporter.cpp \
    2928    src/business/deepthought/datatypes.cpp \
     
    3635    src/business/deepthought/deepthought_task_fetchdatafromdeepthought.cpp \
    3736    src/business/deepthought/questionmanager.cpp \
    38     src/business/validation/bcaccountvalidator.cpp \
    3937    src/business/bcaccount.cpp \
    4038    src/business/bcaccount_costs.cpp \
     
    5250    src/ui/vcquestionlist/vcquestionlist.cpp \
    5351    src/ui/vcaccount_guiintegration.cpp \
    54     src/main.cpp
     52    src/library.cpp
    5553FORMS += src/ui/vcquestionlist/vcquestionlist.ui \
    5654    src/ui/widgets/vcquestionbox/vcquestionbox.ui \
  • gateways/Schoolnet/src/business/bcaccount.cpp

    r198 r217  
    99
    1010 This program is distributed in the hope that it will be useful,
    11  but WITHOUT ANY WARRANTY; without even the Privied warranty of
     11 but WITHOUT ANY WARRANTY; without even the implied warranty of
    1212 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1313 GNU General Public License for more details.
     
    3939#include <smacros.h>
    4040#include <snumber.h>
     41#include <sstdaccountvalidator.h>
    4142#include <stask_predefined.h>
    4243
     
    4546#include "persistence/daaccountstorageofficer.h"
    4647#include "ui/vcaccount_guiintegration.h"
    47 #include "validation/bcaccountvalidator.h"
    48 #include "main.h"
     48#include "library.h"
    4949
    5050namespace Schoolnet {
    5151
    52 BCAccountPriv::BCAccountPriv(const IStorage& storage)
    53     : AbstractAccountPriv()
     52BCAccount::BCAccount(QObject* parent, IStorage* storage)
     53    : AbstractAccount(parent)
    5454    , sendAs_(saNumber)
    5555    , useDeepThought_(true)
    5656{
    57     init(DAAccountStorageOfficer(this, storage), BCAccountValidator(this));
     57    init(new DAAccountStorageOfficer(this, this, storage), new SStdAccountValidator(this, this));
    5858
    59     guiIntegration_ = new VCAccountGuiIntegration(this);
     59    guiIntegration_ = new VCAccountGuiIntegration(this, this);
    6060
    61     connect(this, SIGNAL(initStateChanged()), this, SLOT(onInitStateChanged()));
     61    connect(this, SIGNAL(initStateChanged(IAccount*)), this, SLOT(onInitStateChanged()));
    6262}
    6363
    64 BCAccountPriv::~BCAccountPriv(){
    65     delete guiIntegration_;
     64IAccount* BCAccount::createClonedInstance(QObject* parent) const {
     65    return new BCAccount(parent, getStorageOfficer()->storage());
    6666}
    67 
    68 IAccount BCAccountPriv::getClonedInstance() const {
    69     return BCAccount(getStorageOfficer()->storage());
    70 }
    71 IGateway BCAccountPriv::gateway() const {
     67IGateway* BCAccount::gateway() const {
    7268    return BCGateway::instance();
    7369}
    7470
    75 IAccountInitTask BCAccountPriv::doCreateInitTask() {
    76     return SDefaultLoginInitTask(this);
     71IAccountInitTask* BCAccount::doCreateInitTask() {
     72    return new SDefaultLoginInitTask(this);
    7773}
    78 IAccountLoginTask BCAccountPriv::doCreateLoginTask() {
    79     return BCAccountLoginTask(this);
     74IAccountLoginTask* BCAccount::doCreateLoginTask() {
     75    return new BCAccountLoginTask(this);
    8076}
    81 ISMSSendTask BCAccountPriv::doCreateSMSSendTask(const QString& message, const QSet<SContact>& recipients) {
    82     return BCSMSSendTask(this, message, recipients);
     77ISMSSendTask* BCAccount::doCreateSMSSendTask(const QString& message, const QSet<SContact>& recipients) {
     78    return new BCSMSSendTask(this, message, recipients);
    8379}
    8480
    8581
    86 BCHttpHelper BCAccountPriv::httpHelper() {
     82BCHttpHelper* BCAccount::httpHelper() {
    8783    return httpHelper_;
    8884}
    8985
    90 void BCAccountPriv::cancelSMSSending() {
    91     // TODO: Privement this
     86void BCAccount::cancelSMSSending() {
     87    // TODO: implement this
    9288/*    cancelSending_ = true;
    9389    setStatus(LoginAccount::Action::CancellingSendingSMS);*/
    9490}
    9591
    96 bool BCAccountPriv::checkStillLoggedIn() {
     92bool BCAccount::checkStillLoggedIn() {
    9793    QString html = httpHelper()->syncGet(URL_SMSPAGE);
    9894    return tryFetchFreeSMSCount(html);
     
    10096
    10197
    102 void BCAccountPriv::reloadOnlineParams() {
     98void BCAccount::reloadOnlineParams() {
    10399    QString html = httpHelper()->syncGet(URL_SMSPAGE);
    104100    parsePage(html);
    105101}
    106102
    107 void BCAccountPriv::parsePage(const QString& html) {
     103void BCAccount::parsePage(const QString& html) {
    108104    fetchFreeSMSCount(html);
    109105}
    110106
    111 void BCAccountPriv::fetchFreeSMSCount(const QString& html) {
     107void BCAccount::fetchFreeSMSCount(const QString& html) {
    112108    if (!tryFetchFreeSMSCount(html)) {
    113109        EException(tr("Error while reading the schoolnet page."))
     
    116112    }
    117113}
    118 bool BCAccountPriv::tryFetchFreeSMSCount(const QString& html) {
     114bool BCAccount::tryFetchFreeSMSCount(const QString& html) {
    119115    QRegExp rx("<span id=\"userSnPoints\"><b>(\\d+)</b></span>");
    120116    rx.setCaseSensitivity(Qt::CaseInsensitive);
     
    128124}
    129125
    130 void BCAccountPriv::onInitStateChanged() {
     126void BCAccount::onInitStateChanged() {
    131127    if (!isInitialized()) {
    132128        // Reset the current state
     
    135131}
    136132
    137 BCAccountPriv::ESendAs BCAccountPriv::sendAs() const {
     133BCAccount::ESendAs BCAccount::sendAs() const {
    138134    return sendAs_;
    139135}
    140 void BCAccountPriv::setSendAs(BCAccountPriv::ESendAs sendAs) {
     136void BCAccount::setSendAs(BCAccount::ESendAs sendAs) {
    141137    SET_IF_DIFFERENT(sendAs_, sendAs);
    142     emit dataChanged(BCAccountPriv::SendAs);
     138    emit dataChanged(this, BCAccount::SendAs);
    143139}
    144140
    145 bool BCAccountPriv::useDeepThought() const {
     141bool BCAccount::useDeepThought() const {
    146142    return useDeepThought_;
    147143}
    148 void BCAccountPriv::setUseDeepThought(bool useDeepThought) {
     144void BCAccount::setUseDeepThought(bool useDeepThought) {
    149145    SET_IF_DIFFERENT(useDeepThought_, useDeepThought);
    150     emit dataChanged(BCAccountPriv::UseDeepThought);
     146    emit dataChanged(this, BCAccount::UseDeepThought);
    151147}
    152148
    153 QStringList BCAccountPriv::deepThoughtQuestionLanguages() const {
     149QStringList BCAccount::deepThoughtQuestionLanguages() const {
    154150    return deepThoughtQuestionLanguages_;
    155151}
    156 void BCAccountPriv::setDeepThoughtQuestionLanguages(const QStringList& languages) {
     152void BCAccount::setDeepThoughtQuestionLanguages(const QStringList& languages) {
    157153    deepThoughtQuestionLanguages_ = languages;
    158154}
  • gateways/Schoolnet/src/business/bcaccount.h

    r198 r217  
    1616  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 
    1918#ifndef SCHOOLNET_BCACCOUNT_H_
    2019#define SCHOOLNET_BCACCOUNT_H_
     
    3736//const static uint RESSOURCE_SCHOOLNET = 0x00;
    3837
    39 class BCAccountPriv: public AbstractAccountPriv {
     38class BCAccount: public AbstractAccount {
    4039    Q_OBJECT
    4140
    42 friend class BCContactImporterPriv;
    43 friend class DeepThoughtHelperPriv;
     41    friend class BCContactImporter; // httpHelper()
    4442
    45 friend class AnswerToSchoolnetTaskPriv;
    46 friend class CheckQuestionStatusAtSchoolnetTaskPriv;
     43    friend class AnswerToSchoolnetTask; // httpHelper()
     44    friend class CheckQuestionStatusAtSchoolnetTask; // httpHelper()
    4745
    48 friend class BCAccountLoginTaskPriv;
    49 friend class BCSMSSendTaskPriv;
     46    friend class BCAccountLoginTask; // reloadOnlineParams(), httpHelper()
     47    friend class BCSMSSendTask; // reloadOnlineParams(), httpHelper()
    5048
    5149public:
     
    6361
    6462public:
    65     explicit BCAccountPriv(const IStorage& storage);
    66     ~BCAccountPriv();
     63    BCAccount(QObject* parent, IStorage* storage);
    6764
    6865public: /* IAccount */
    69     IGateway         gateway() const;
    70     IAccount         getClonedInstance() const;
     66    IGateway*        gateway() const;
     67    IAccount*        createClonedInstance(QObject* parent) const;
    7168
    7269public: /* IAccount - SMS sending */
     
    9087
    9188protected: /* AbstractAccount */
    92     IAccountInitTask  doCreateInitTask();
    93     IAccountLoginTask doCreateLoginTask();
    94     ISMSSendTask      doCreateSMSSendTask(const QString& message, const QSet<SContact>& recipients);
     89    IAccountInitTask*  doCreateInitTask();
     90    IAccountLoginTask* doCreateLoginTask();
     91    ISMSSendTask*      doCreateSMSSendTask(const QString& message, const QSet<SContact>& recipients);
    9592
    9693protected:
    97     bool             checkStillLoggedIn();
     94    bool               checkStillLoggedIn();
    9895
    9996private:
    100     void             reloadOnlineParams();
    101     void             parsePage(const QString& html);
    102     void             fetchFreeSMSCount(const QString& html);
    103     bool             tryFetchFreeSMSCount(const QString& html);
     97    void               reloadOnlineParams();
     98    void               parsePage(const QString& html);
     99    void               fetchFreeSMSCount(const QString& html);
     100    bool               tryFetchFreeSMSCount(const QString& html);
    104101
    105     BCHttpHelper     httpHelper();
     102    BCHttpHelper*      httpHelper();
    106103
    107104private slots:
    108     void             onInitStateChanged();
     105    void               onInitStateChanged();
    109106
    110107private:
    111     BCHttpHelper                 httpHelper_;
    112     VCAccountGuiIntegration*     guiIntegration_;
     108    BCHttpHelper*            httpHelper_;
     109    VCAccountGuiIntegration* guiIntegration_;
    113110
    114     ESendAs                      sendAs_;
    115     bool                         useDeepThought_;
    116     QStringList                  deepThoughtQuestionLanguages_;
     111    ESendAs                  sendAs_;
     112    bool                     useDeepThought_;
     113    QStringList              deepThoughtQuestionLanguages_;
    117114
    118115
    119     Q_DISABLE_COPY(BCAccountPriv);
    120 };
    121 class BCAccount : public AbstractAccount {
    122     S_SHARED_INTERNAL(BCAccount, AbstractAccount, IAccount)
    123     S_SHARED_QOBJ_INTERNAL(BCAccount, AbstractAccount, IAccount)
    124 
    125 public:
    126     BCAccount()
    127         : AbstractAccount(NULL)
    128     {};
    129     explicit BCAccount(const IStorage& storage)
    130         : AbstractAccount(new BCAccountPriv(storage))
    131     {};
     116    Q_DISABLE_COPY(BCAccount)
    132117};
    133118
    134 };
    135 Q_DECLARE_METATYPE(Schoolnet::BCAccount)
     119}
    136120
    137121#endif /* SCHOOLNET_BCACCOUNT_H_ */
  • gateways/Schoolnet/src/business/bcaccount_costs.cpp

    r194 r217  
    1616  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717*/
    18 
    1918#include "bcaccount.h"
    2019
     
    3231 * @return Returns a list of the long-sms texts
    3332 */
    34 QList<QString> BCAccountPriv::splitTextToLongSMS(const QString& text) const {
     33QList<QString> BCAccount::splitTextToLongSMS(const QString& text) const {
    3534    QList<QString> longSMSList;
    3635    QString text_(text);
     
    6564 * @return Returns a list of the short-sms texts
    6665 */
    67 int BCAccountPriv::shortSMSCount(const QString& text) const {
     66int BCAccount::shortSMSCount(const QString& text) const {
    6867    QString txt(text);
    6968    foreach (QChar doublePriceChar, gateway()->doublePriceChars()) {
     
    9190 * @return The costs
    9291 */
    93 int BCAccountPriv::costsForText(const QString& message) const {
     92int BCAccount::costsForText(const QString& message) const {
    9493    return shortSMSCount(message);
    9594}
  • gateways/Schoolnet/src/business/bcaccount_task_login.cpp

    r198 r217  
    1616  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717*/
    18 
    1918#include "bcaccount_tasks.h"
    2019
     
    2423#include <exceptions/eloginaccountloginexception.h>
    2524
    26 #include "main.h"
     25#include "library.h"
    2726#include "business/bchttphelper.h"
    2827
    2928namespace Schoolnet {
    3029
    31 BCAccountLoginTaskPriv::BCAccountLoginTaskPriv(const BCAccount& account)
    32     : AbstractAccountLoginTaskPriv(account)
    33 {};
     30BCAccountLoginTask::BCAccountLoginTask(BCAccount* account)
     31    : AbstractAccountLoginTask(account)
     32{
     33}
    3434
    35 void BCAccountLoginTaskPriv::doLogin() {
     35void BCAccountLoginTask::doLogin() {
    3636    setProgress(10);
    3737
     
    4040    setProgress(30);
    4141
    42     QList<IParam> postValues;
    43     postValues.append(SKeyValueParam("BotM:ucUser:ucUser1Col:txtUsername", account()->username().toUtf8()));
    44     postValues.append(SKeyValueParam("BotM:ucUser:ucUser1Col:txtPassword", account()->password().toUtf8()));
     42    QList<IParam*> postValues;
     43    postValues.append(new SKeyValueParam("BotM:ucUser:ucUser1Col:txtUsername", account()->username().toUtf8()));
     44    postValues.append(new SKeyValueParam("BotM:ucUser:ucUser1Col:txtPassword", account()->password().toUtf8()));
    4545    QString html = httpHelper()->syncPostByTarget("BotM$ucUser$ucUser1Col$cmdLogin", "", postValues);
    4646
     
    4949    rx.setMinimal(true);
    5050    if (rx.indexIn(html) != -1) {
    51         QString error = httpHelper().htmldecodeString(rx.cap(1)).trimmed();
     51        QString error = SNetworkHelper::htmldecodeString(rx.cap(1)).trimmed();
    5252        if (error == "Login fehlgeschlagen!") {
    5353            LoginAccount::ELoginException(LoginAccount::ELoginException::InvalidLoginData)
     
    6767
    6868
    69 BCAccount BCAccountLoginTaskPriv::account() const {
    70     return AbstractAccountLoginTaskPriv::account();
     69BCAccount* BCAccountLoginTask::account() const {
     70    return static_cast<BCAccount*>(AbstractAccountLoginTask::account());
    7171}
    7272
    73 BCHttpHelper BCAccountLoginTaskPriv::httpHelper() const {
     73BCHttpHelper* BCAccountLoginTask::httpHelper() const {
    7474    return account()->httpHelper();
    7575}
  • gateways/Schoolnet/src/business/bcaccount_task_sendsms.cpp

    r216 r217  
    2727namespace Schoolnet {
    2828
    29 BCSMSSendTaskPriv::BCSMSSendTaskPriv(const BCAccount& account, const QString& message, const QSet<SContact>& recipients)
    30     : AbstractSMSSendTaskPriv(account, message, recipients)
    31 {};
     29BCSMSSendTask::BCSMSSendTask(BCAccount* account, const QString& message, const QSet<SContact>& recipients)
     30    : AbstractSMSSendTask(account, message, recipients)
     31{
     32}
    3233
    33 void BCSMSSendTaskPriv::doSendSMS() {
     34void BCSMSSendTask::doSendSMS() {
    3435    Q_ASSERT(!message().isEmpty());
    3536    Q_ASSERT(!recipients().isEmpty());
     
    117118
    118119
    119 void BCSMSSendTaskPriv::addRecipient(const SContact& recipient) {
     120void BCSMSSendTask::addRecipient(const SContact& recipient) {
    120121    //TODO: haltIfCancelled();
    121122    qDebug() << "Starting adding recipient " + recipient.number().toString();
     
    123124    setDetails(Account::Action::AddingRecipients);
    124125
    125     QList<IParam> posts;
    126     posts.append(SKeyValueParam("Layout1:PresentationModeControlsContainer:_ctl2:_ctl0:_ctl0:txtSmsListPrefix", recipient.number().toString("aaa").toUtf8()));
    127     posts.append(SKeyValueParam("Layout1:PresentationModeControlsContainer:_ctl2:_ctl0:_ctl0:txtSmsListHandy", recipient.number().toString("u").toUtf8()));
    128     posts.append(SKeyValueParam("Layout1:PresentationModeControlsContainer:_ctl2:_ctl0:_ctl0:imgBtnAddrAddToGridForSms.x", "10"));
    129     posts.append(SKeyValueParam("Layout1:PresentationModeControlsContainer:_ctl2:_ctl0:_ctl0:imgBtnAddrAddToGridForSms.y", "10"));
     126    QList<IParam*> posts;
     127    posts.append(new SKeyValueParam("Layout1:PresentationModeControlsContainer:_ctl2:_ctl0:_ctl0:txtSmsListPrefix", recipient.number().toString("aaa").toUtf8()));
     128    posts.append(new SKeyValueParam("Layout1:PresentationModeControlsContainer:_ctl2:_ctl0:_ctl0:txtSmsListHandy", recipient.number().toString("u").toUtf8()));
     129    posts.append(new SKeyValueParam("Layout1:PresentationModeControlsContainer:_ctl2:_ctl0:_ctl0:imgBtnAddrAddToGridForSms.x", "10"));
     130    posts.append(new SKeyValueParam("Layout1:PresentationModeControlsContainer:_ctl2:_ctl0:_ctl0:imgBtnAddrAddToGridForSms.y", "10"));
    130131
    131132    httpHelper()->syncPostByTarget("", "", posts);
     
    134135    qDebug() << "Recipient added";
    135136}
    136 void BCSMSSendTaskPriv::removeRecipients() {
     137void BCSMSSendTask::removeRecipients() {
    137138    //TODO: haltIfCancelled();
    138139    qDebug() << "Removing recipients";
     
    140141    setDetails(Account::Action::RemovingRecipients);
    141142
    142     QList<IParam> posts;
    143     posts.append(SKeyValueParam("Layout1:PresentationModeControlsContainer:_ctl2:_ctl0:_ctl0:dgSmsList:_ctl2:imgContactSelection.x", "10"));
    144     posts.append(SKeyValueParam("Layout1:PresentationModeControlsContainer:_ctl2:_ctl0:_ctl0:dgSmsList:_ctl2:imgContactSelection.y", "10"));
     143    QList<IParam*> posts;
     144    posts.append(new SKeyValueParam("Layout1:PresentationModeControlsContainer:_ctl2:_ctl0:_ctl0:dgSmsList:_ctl2:imgContactSelection.x", "10"));
     145    posts.append(new SKeyValueParam("Layout1:PresentationModeControlsContainer:_ctl2:_ctl0:_ctl0:dgSmsList:_ctl2:imgContactSelection.y", "10"));
    145146
    146147    while (httpHelper()->lastResponse().contains("Layout1:PresentationModeControlsContainer:_ctl2:_ctl0:_ctl0:dgSmsList:_ctl2:imgContactSelection")) {
     
    150151    qDebug() << "Recipients removed";
    151152}
    152 void BCSMSSendTaskPriv::sendLongSMS(const QString& text) {
     153void BCSMSSendTask::sendLongSMS(const QString& text) {
    153154    qDebug() << "Start of sending part of SMS";
    154155
     
    156157
    157158    QString sa = "rbSendNumber";
    158     if (account()->sendAs() == BCAccountPriv::saNickname) {
     159    if (account()->sendAs() == BCAccount::saNickname) {
    159160        sa = "rbSendName";
    160161    }
    161162
    162     QList<IParam> posts;
    163     posts.append(SKeyValueParam("Layout1:PresentationModeControlsContainer:_ctl2:_ctl0:_ctl0:noSelec", sa.toUtf8()));
    164     posts.append(SKeyValueParam("Layout1:PresentationModeControlsContainer:_ctl2:_ctl0:_ctl0:txt_Message", text.toUtf8()));
     163    QList<IParam*> posts;
     164    posts.append(new SKeyValueParam("Layout1:PresentationModeControlsContainer:_ctl2:_ctl0:_ctl0:noSelec", sa.toUtf8()));
     165    posts.append(new SKeyValueParam("Layout1:PresentationModeControlsContainer:_ctl2:_ctl0:_ctl0:txt_Message", text.toUtf8()));
    165166
    166167    httpHelper()->syncPostByTarget("Layout1$PresentationModeControlsContainer$_ctl2$_ctl0$_ctl0$cmdAnswer", "", posts);
     
    170171
    171172
    172 BCAccount BCSMSSendTaskPriv::account() const {
    173     return AbstractSMSSendTaskPriv::account();
     173BCAccount* BCSMSSendTask::account() const {
     174    return static_cast<BCAccount*>(AbstractSMSSendTask::account());
    174175}
    175176
    176 BCHttpHelper BCSMSSendTaskPriv::httpHelper() const {
     177BCHttpHelper* BCSMSSendTask::httpHelper() const {
    177178    return account()->httpHelper();
    178179}
  • gateways/Schoolnet/src/business/bcaccount_tasks.h

    r198 r217  
    2727namespace Schoolnet {
    2828
    29 class BCAccountLoginTaskPriv : public AbstractAccountLoginTaskPriv {
     29class BCAccountLoginTask : public AbstractAccountLoginTask {
    3030    Q_OBJECT
    3131
    3232public:
    33     explicit BCAccountLoginTaskPriv(const BCAccount& account);
     33    explicit BCAccountLoginTask(BCAccount* account);
    3434
    3535protected: /* AbstractAccountLoginTask */
    36     void      doLogin();
    37     BCAccount account() const;
     36    void       doLogin();
     37    BCAccount* account() const;
    3838
    3939private:
    40     BCHttpHelper httpHelper() const;
    41 };
    42 class BCAccountLoginTask : public AbstractAccountLoginTask {
    43     S_SHARED_INTERNAL(BCAccountLoginTask, AbstractAccountLoginTask, STask)
    44     S_SHARED_QOBJ_INTERNAL(BCAccountLoginTask, AbstractAccountLoginTask, STask)
    45 
    46 public:
    47     explicit BCAccountLoginTask(const BCAccount& account)
    48         : AbstractAccountLoginTask(new BCAccountLoginTaskPriv(account))
    49     {};
     40    BCHttpHelper* httpHelper() const;
    5041};
    5142
    5243
    53 class BCSMSSendTaskPriv : public AbstractSMSSendTaskPriv {
     44class BCSMSSendTask : public AbstractSMSSendTask {
    5445    Q_OBJECT
    5546
    5647public:
    57     BCSMSSendTaskPriv(const BCAccount& account, const QString& message, const QSet<SContact>& recipients);
     48    BCSMSSendTask(BCAccount* account, const QString& message, const QSet<SContact>& recipients);
    5849
    5950protected: /* AbstractAccountSendSMSTask */
    60     void      doSendSMS();
    61     BCAccount account() const;
     51    void       doSendSMS();
     52    BCAccount* account() const;
    6253
    6354private:
     
    6758
    6859private:
    69     BCHttpHelper httpHelper() const;
     60    BCHttpHelper* httpHelper() const;
    7061
    7162private:
    7263    QString recipientsStr_;
    73 };
    74 class BCSMSSendTask : public AbstractSMSSendTask {
    75     S_SHARED_INTERNAL(BCSMSSendTask, AbstractSMSSendTask, STask)
    76     S_SHARED_QOBJ_INTERNAL(BCSMSSendTask, AbstractSMSSendTask, STask)
    77 
    78 public:
    79     BCSMSSendTask(const BCAccount& account, const QString& message, const QSet<SContact>& recipients)
    80         : AbstractSMSSendTask(new BCSMSSendTaskPriv(account, message, recipients))
    81     {};
    8264};
    8365
  • gateways/Schoolnet/src/business/bcgateway.cpp

    r194 r217  
    2626namespace Schoolnet {
    2727
    28 QString BCGatewayPriv::name() const {
     28S_SINGLETON_IMPL(BCGateway)
     29
     30BCGateway::BCGateway()
     31    : AbstractGateway(NULL) // singleton
     32{
     33}
     34
     35
     36QString BCGateway::name() const {
    2937    return "Schoolnet";
    3038}
    3139
    32 QImage BCGatewayPriv::icon() const {
     40QImage BCGateway::icon() const {
    3341    return QImage(":/images/schoolnet.ico");
    3442}
    3543
    36 QList<int> BCGatewayPriv::validRecipientCountryCodes() const {
     44QList<int> BCGateway::validRecipientCountryCodes() const {
    3745    QList<int> result; // TODO: Check this
    3846    result.append(41); // CH
    3947    return result;
    4048}
    41 QList<QChar> BCGatewayPriv::doublePriceChars() const {
     49QList<QChar> BCGateway::doublePriceChars() const {
    4250    return QList<QChar>(); // TODO: Check this
    4351}
    44 QList<QChar> BCGatewayPriv::disAllowedChars() const {
     52QList<QChar> BCGateway::disAllowedChars() const {
    4553    return QList<QChar>(); // TODO: Check this
    4654}
    4755
    48 IAccount BCGatewayPriv::createAccountInstance(const IStorage& storage) const {
    49     return BCAccount(storage);
     56IAccount* BCGateway::createAccountInstance(IStorage* storage) {
     57    return new BCAccount(this, storage);
    5058}
    5159
    52 IAccountSettingsWidget* BCGatewayPriv::getAccountSettingsWidget(QWidget* parent) const {
     60IAccountSettingsWidget* BCGateway::createAccountSettingsWidget(QWidget* parent) const {
    5361    return new VCSettingsWidget(parent);
    5462}
  • gateways/Schoolnet/src/business/bcgateway.h

    r194 r217  
    2222#include <QSet>
    2323
    24 #include <ssingleton.h>
     24#include <abstract/abstractgateway.h>
    2525
    26 #include <abstract/abstractgateway.h>
    27 #include <persistence/istorage.h>
     26#include <smacros.h>
    2827
    2928namespace Schoolnet {
     
    3635const short   LONGSMS_LENGTH         = 600;
    3736
    38 class BCGatewayPriv: public AbstractGatewayPriv {
    39 public: /* IGateway */
    40     QString        name() const;
    41     QImage         icon() const;
     37class BCGateway : public AbstractGateway {
     38    Q_OBJECT
     39    S_SINGLETON(BCGateway)
    4240
    4341public: /* IGateway */
    44     IAccountSettingsWidget* getAccountSettingsWidget(QWidget* parent = 0) const;
    45     IAccount                createAccountInstance(const IStorage& storage) const;
     42    QString      name() const;
     43    QImage       icon() const;
    4644
    4745public: /* IGateway */
    48     QList<int>     validRecipientCountryCodes() const;
    49     QList<QChar>   doublePriceChars() const;
    50     QList<QChar>   disAllowedChars() const;
     46    IAccountSettingsWidget* createAccountSettingsWidget(QWidget* parent) const;
     47    IAccount*               createAccountInstance(IStorage* storage);
     48
     49public: /* IGateway */
     50    QList<int>   validRecipientCountryCodes() const;
     51    QList<QChar> doublePriceChars() const;
     52    QList<QChar> disAllowedChars() const;
    5153
    5254private:
    5355    QSet<QString> doublePriceChars_;
    5456};
    55 S_SINGLETON_DERIV(BCGateway, AbstractGateway, IGateway)
    5657
    5758}
  • gateways/Schoolnet/src/business/bchttphelper.cpp

    r198 r217  
    1919#include "bchttphelper.h"
    2020
     21#include <snetworkreply.h>
    2122#include <exceptions/eparseexception.h>
    2223
     
    2526namespace Schoolnet {
    2627
    27 QByteArray BCHttpHelperPriv::postback(QString eventTarget, const QString& eventArgument, QList<IParam>& postValues) {
     28QByteArray BCHttpHelper::postback(QString eventTarget, const QString& eventArgument, QList<IParam*>& postValues) {
    2829    eventTarget.replace('$', ':');
    29     postValues.append(SKeyValueParam("__EVENTTARGET", eventTarget.toUtf8()));
    30     postValues.append(SKeyValueParam("__EVENTARGUMENT", eventArgument.toUtf8()));
     30    postValues.append(new SKeyValueParam("__EVENTTARGET", eventTarget.toUtf8()));
     31    postValues.append(new SKeyValueParam("__EVENTARGUMENT", eventArgument.toUtf8()));
    3132
    3233    // Get postback parameters
     
    4142                .raise();
    4243    }
    43     postValues.append(SKeyValueParam("__VIEWSTATE", rx.cap(1).toUtf8()));
     44    postValues.append(new SKeyValueParam("__VIEWSTATE", rx.cap(1).toUtf8()));
    4445
    4546    rx.setPattern("var __CMS_CurrentUrl = \"(.*)\";");
     
    5455}
    5556
    56 QByteArray BCHttpHelperPriv::syncPostByTarget(const QString& eventTarget, const QString& eventArgument, QList<IParam>& postValues) {
     57QByteArray BCHttpHelper::syncPostByTarget(const QString& eventTarget, const QString& eventArgument, QList<IParam*>& postValues) {
    5758    QByteArray html = postback(eventTarget, eventArgument, postValues);
    5859
     
    7071}
    7172
    72 QByteArray BCHttpHelperPriv::syncGet(const QUrl& destination, SNetworkHelper::RedirectHandling redirectHandling) {
    73     QByteArray response = SNetworkHelperPriv::syncGet(destination, redirectHandling)->readAll();
     73QByteArray BCHttpHelper::syncGet(const QUrl& destination, SNetworkHelper::RedirectHandling redirectHandling) {
     74    QByteArray response = SNetworkHelper::syncGet(destination, redirectHandling)->readAll();
    7475    setLastResponse(response);
    7576    return response;
    7677}
    77 QByteArray BCHttpHelperPriv::syncPost(const QUrl& destination, const QList<IParam>& posts, SNetworkHelper::PostType postType, SNetworkHelper::RedirectHandling redirectHandling) {
    78     QByteArray response = SNetworkHelperPriv::syncPost(destination, posts, postType, redirectHandling)->readAll();
     78QByteArray BCHttpHelper::syncPost(const QUrl& destination, QList<IParam*>& posts, SNetworkHelper::PostType postType, SNetworkHelper::RedirectHandling redirectHandling) {
     79    QByteArray response = SNetworkHelper::syncPost(destination, posts, postType, redirectHandling)->readAll();
    7980    setLastResponse(response);
    8081    return response;
    8182}
    8283
    83 QByteArray BCHttpHelperPriv::lastResponse() {
     84QByteArray BCHttpHelper::lastResponse() {
    8485    QMutexLocker locker(&lastResponseLock_);
    8586
     
    8788}
    8889
    89 void BCHttpHelperPriv::setLastResponse(const QByteArray& lastResponse) {
     90void BCHttpHelper::setLastResponse(const QByteArray& lastResponse) {
    9091    QMutexLocker locker(&lastResponseLock_);
    9192
     
    9495
    9596
    96 void BCHttpHelperPriv::clearCookies() {
    97     SNetworkHelperPriv::clearCookies();
    9897}
    99 }
  • gateways/Schoolnet/src/business/bchttphelper.h

    r198 r217  
    2626namespace Schoolnet {
    2727
    28 class BCHttpHelperPriv : protected SNetworkHelperPriv {
     28class BCHttpHelper : protected SNetworkHelper {
    2929    Q_OBJECT
    3030
    31     friend class BCHttpHelper; // To see SNetworkHelperPriv as parent
    32 
    3331public:
    34     QByteArray syncPostByTarget(const QString& eventTarget, const QString& eventArgument, QList<IParam>& postValues);
     32    QByteArray syncPostByTarget(const QString& eventTarget, const QString& eventArgument, QList<IParam*>& postValues);
    3533
    3634    QByteArray syncGet(const QUrl& destination, SNetworkHelper::RedirectHandling redirectHandling = SNetworkHelper::rhHandleRedirects);
    37     QByteArray syncPost(const QUrl& destination, const QList<IParam>& posts, SNetworkHelper::PostType postType = SNetworkHelper::ptUrlEncoded, SNetworkHelper::RedirectHandling redirectHandling = SNetworkHelper::rhHandleRedirects);
     35    QByteArray syncPost(const QUrl& destination, QList<IParam*>& posts, SNetworkHelper::PostType postType = SNetworkHelper::ptUrlEncoded, SNetworkHelper::RedirectHandling redirectHandling = SNetworkHelper::rhHandleRedirects);
    3836
    3937    QByteArray lastResponse();
    4038
    41 public: /* Wrapper for SNetworkHelperPriv */
    42     void clearCookies();
     39public: /* Wrapper for SNetworkHelper */
     40    void clearCookies() { SNetworkHelper::clearCookies(); }
    4341
    4442private:
    45     QByteArray postback(QString eventTarget, const QString& eventArgument, QList<IParam>& postValues);
     43    QByteArray postback(QString eventTarget, const QString& eventArgument, QList<IParam*>& postValues);
    4644
    4745    void       setLastResponse(const QByteArray& response);
     
    5149    QMap<QThread*, QByteArray> lastResponse_;
    5250};
    53 class BCHttpHelper : public SNetworkHelper {
    54     S_SHARED_INTERNAL(BCHttpHelper, SNetworkHelper, SNetworkHelper)
    55 
    56 public:
    57     BCHttpHelper()
    58         : SNetworkHelper(new BCHttpHelperPriv)
    59     {};
    60 };
    6151
    6252}
  • gateways/Schoolnet/src/business/contactimporter/bccontactimporter.cpp

    r216 r217  
    2727namespace Schoolnet {
    2828
    29 BCContactImporterPriv::BCContactImporterPriv(const IManagerFactory& managerFactory)
    30     : dataManager_()
     29BCContactImporter::BCContactImporter(QObject* parent, IManagerFactory* managerFactory)
     30    : IContactImporter(parent)
     31    , dataManager_(new BCContactImporterDataManager(this))
    3132    , managerFactory_(managerFactory)
    3233{
    3334}
    34 BCContactImporterPriv::~BCContactImporterPriv() {
    35 }
    3635
    37 QString BCContactImporterPriv::describingName() const {
     36QString BCContactImporter::describingName() const {
    3837    if (isApplicable()) {
    3938        return QObject::tr("Import contacts from the Schoolnet website.");
     
    4342}
    4443
    45 bool BCContactImporterPriv::isApplicable() const {
    46     foreach (IAccount account, managerFactory_->accountManager()->getAccountList()) {
     44bool BCContactImporter::isApplicable() const {
     45    foreach (IAccount* account, managerFactory_->accountManager()->getAccountList()) {
    4746        if (account->isEnabled() && (account->gateway() == BCGateway::instance())) {
    4847            if (account->isLoggedIn()) {
     
    5554
    5655
    57 void BCContactImporterPriv::init() {
    58     QSet<BCAccount> accounts;
    59     foreach (IAccount account, managerFactory_->accountManager()->getAccountList()) {
     56void BCContactImporter::init() {
     57    QSet<BCAccount*> accounts;
     58    foreach (IAccount* account, managerFactory_->accountManager()->getAccountList()) {
    6059        if (account->gateway() == BCGateway::instance()) {
    61             accounts.insert(account);
     60            accounts.insert(static_cast<BCAccount*>(account));
    6261        }
    6362    }
     
    6564
    6665}
    67 QList<QWizardPage*> BCContactImporterPriv::getPreImportPages() {
     66QList<QWizardPage*> BCContactImporter::createPreImportPages(QWidget* parent) {
     67    Q_UNUSED(parent)
     68
    6869    return QList<QWizardPage*>();
    6970}
    70 QSet<SContact> BCContactImporterPriv::importContacts() {
     71QSet<SContact> BCContactImporter::importContacts() {
    7172    QSet<SContact> contacts;
    7273
    7374    QString html;
    74     foreach (BCAccount account, dataManager_->selectedAccounts()) {
     75    foreach (BCAccount* account, dataManager_->selectedAccounts()) {
    7576        if (!account->isLoggedIn()) continue;
    7677
     
    128129            // Load next page
    129130            if (continueProcessing) {
    130                 QList<IParam> posts;
    131                 posts.append(SKeyValueParam("__EVENTTARGET", ""));
    132                 posts.append(SKeyValueParam("__EVENTARGUMENT", ""));
    133                 posts.append(SKeyValueParam("btnNext", ">>"));
     131                QList<IParam*> posts;
     132                posts.append(new SKeyValueParam("__EVENTTARGET", ""));
     133                posts.append(new SKeyValueParam("__EVENTARGUMENT", ""));
     134                posts.append(new SKeyValueParam("btnNext", ">>"));
    134135
    135136                rx.setPattern("<input.*name=\"__VIEWSTATE\".*value=\"(.*)\".*/?>");
     
    138139                            .raise();
    139140                }
    140                 posts.append(SKeyValueParam("__VIEWSTATE", rx.cap(1).toUtf8()));
     141                posts.append(new SKeyValueParam("__VIEWSTATE", rx.cap(1).toUtf8()));
    141142
    142143                html = QString::fromUtf8(account->httpHelper()->syncPost(URL_CONTACT_LIST, posts));
     
    151152/********************************************************************************/
    152153
    153 QSet<BCAccount> BCContactImporterDataManagerPriv::selectedAccounts() const {
     154QSet<BCAccount*> BCContactImporterDataManager::selectedAccounts() const {
    154155    return selectedAccounts_;
    155156}
    156157
    157 void BCContactImporterDataManagerPriv::setSelectedAccounts(const QSet<BCAccount>& selectedAccounts) {
     158void BCContactImporterDataManager::setSelectedAccounts(const QSet<BCAccount*>& selectedAccounts) {
    158159    selectedAccounts_ = selectedAccounts;
    159160    emit selectedAccountsChanged();
  • gateways/Schoolnet/src/business/contactimporter/bccontactimporter.h

    r194 r217  
    3232const QString URL_CONTACT_LIST = "http://www.schoolnet.ch/schoolnet/AddressBookSchoolnet/AddressbookDetails.aspx?culture=de-CH";
    3333
    34 class BCContactImporterDataManagerPriv : public QObject, public SShareable {
     34class BCContactImporterDataManager : public QObject {
    3535    Q_OBJECT
    3636
    3737public:
    38     QSet<BCAccount> selectedAccounts() const;
    39     void            setSelectedAccounts(const QSet<BCAccount>& selectedAccounts);
     38    BCContactImporterDataManager(QObject* parent)
     39        : QObject(parent)
     40    {}
     41
     42public:
     43    QSet<BCAccount*> selectedAccounts() const;
     44    void             setSelectedAccounts(const QSet<BCAccount*>& selectedAccounts);
    4045
    4146signals:
     
    4348
    4449private:
    45     QSet<BCAccount> selectedAccounts_;
    46 };
    47 class BCContactImporterDataManager : protected SSharedQObj<BCContactImporterDataManagerPriv> {
    48     S_SHARED_INTERNAL(BCContactImporterDataManager, SSharedQObj<BCContactImporterDataManagerPriv>, SSharedQObj<BCContactImporterDataManagerPriv>)
    49     S_SHARED_QOBJ_INTERNAL(BCContactImporterDataManager, SSharedQObj<BCContactImporterDataManagerPriv>, SSharedQObj<BCContactImporterDataManagerPriv>)
    50 
    51 public:
    52     BCContactImporterDataManager()
    53         : SSharedQObj<BCContactImporterDataManagerPriv>(new BCContactImporterDataManagerPriv)
    54     {};
     50    QSet<BCAccount*> selectedAccounts_;
    5551};
    5652
    5753
    58 class BCContactImporterPriv : public IContactImporterPriv {
     54class BCContactImporter : public IContactImporter {
     55    Q_OBJECT
     56
    5957public:
    60     BCContactImporterPriv(const IManagerFactory& managerFactory);
    61     ~BCContactImporterPriv();
     58    BCContactImporter(QObject* parent, IManagerFactory* managerFactory);
    6259
    6360public: /* IContactImporter */
     
    6663
    6764    void                init();
    68     QList<QWizardPage*> getPreImportPages();
     65    QList<QWizardPage*> createPreImportPages(QWidget* parent);
    6966    QSet<SContact>      importContacts();
    7067
    7168private:
    72     BCContactImporterDataManager dataManager_;
    73     IManagerFactory              managerFactory_;
    74 };
    75 class BCContactImporter : public IContactImporter {
    76     S_SHARED_INTERNAL(BCContactImporter, IContactImporter, IContactImporter)
    77 
    78 public:
    79     explicit BCContactImporter(const IManagerFactory& managerFactory)
    80         : IContactImporter(new BCContactImporterPriv(managerFactory))
    81     {};
     69    BCContactImporterDataManager* dataManager_;
     70    IManagerFactory*              managerFactory_;
    8271};
    8372
    84 };
     73}
    8574
    8675#endif /* SCHOOLNET_BCCONTACTIMPORTER_H_ */
  • gateways/Schoolnet/src/business/deepthought/datatypes.cpp

    r194 r217  
    2424#include "business/bcaccount.h"
    2525
     26S_QHASH_IMPL(Schoolnet::Question)
     27S_QHASH_IMPL(Schoolnet::Answer)
     28
    2629namespace Schoolnet {
    2730
    2831/************** QUESTION **************/
    2932
    30 QuestionPriv::QuestionPriv()
    31     : id_(0)
    32     , status_(0)
    33 {
    34 }
    35 void QuestionPriv::assign(const Question& other) {
    36     id_          = other->id_;
    37     nrNodeGuId_  = other->nrNodeGuId_;
    38     eventTarget_ = other->eventTarget_;
    39     language_    = other->language_;
    40     text_        = other->text_;
    41     hint_        = other->hint_;
    42     status_      = other->status_;
     33S_SHARED_IMPL_WITHOUT_EQUALS(Question)
    4334
    44     foreach (Answer answer, other->answers()) {
    45         addAnswer(answer.clone(this));
    46     }
     35Question::~Question() {
    4736}
    4837
    49 int QuestionPriv::id() const {
    50     return id_;
    51 }
    52 QString QuestionPriv::nrNodeGuId() const {
    53     return nrNodeGuId_;
    54 }
    55 QString QuestionPriv::eventTarget() const {
    56     return eventTarget_;
    57 }
    58 QString QuestionPriv::language() const {
    59     return language_;
    60 }
    61 QString QuestionPriv::text() const {
    62     return text_;
    63 }
    64 QString QuestionPriv::hint() const {
    65     return hint_;
    66 }
    67 QList<Answer> QuestionPriv::answers() const {
    68     return answers_;
    69 }
    70 uint QuestionPriv::status() const {
    71     return status_;
     38Question Question::clone() const {
     39    Question newQ(*this);
     40    newQ.d.detach();
     41    newQ.d->answers.clear();
     42    foreach (Answer answer, answers()) {
     43        newQ.d->answers.append(answer.clone(*this));
     44    }
     45    return newQ;
    7246}
    7347
    74 bool QuestionPriv::isStatusAtSchoolnetChecked() const {
     48int Question::id() const {
     49    return d->id;
     50}
     51QString Question::nrNodeGuId() const {
     52    return d->nrNodeGuId;
     53}
     54QString Question::eventTarget() const {
     55    return d->eventTarget;
     56}
     57QString Question::language() const {
     58    return d->language;
     59}
     60QString Question::text() const {
     61    return d->text;
     62}
     63QString Question::hint() const {
     64    return d->hint;
     65}
     66QList<Answer> Question::answers() const {
     67    return d->answers;
     68}
     69uint Question::status() const {
     70    return d->status;
     71}
     72
     73bool Question::isStatusAtSchoolnetChecked() const {
    7574    return status() & StatusAtSchoolnetChecked;
    7675}
    7776
    78 bool QuestionPriv::hasCorrectAnswer() const {
     77bool Question::hasCorrectAnswer() const {
    7978    return correctAnswer();
    8079}
    81 Answer QuestionPriv::correctAnswer() const {
     80Answer Question::correctAnswer() const {
    8281    foreach (Answer answer, answers()) {
    83         if (answer->isCorrect()) {
     82        if (answer.isCorrect()) {
    8483            return answer;
    8584        }
     
    8887}
    8988
    90 void QuestionPriv::setId(int id) {
    91     id_ = id;
     89void Question::setId(int id) {
     90    SET_IF_DIFFERENT(d->id, id)
    9291}
    93 void QuestionPriv::setNrNodeGuId(const QString& nrNodeGuId) {
    94     nrNodeGuId_ = nrNodeGuId.trimmed();
     92void Question::setNrNodeGuId(const QString& nrNodeGuId) {
     93    SET_IF_DIFFERENT(d->nrNodeGuId, nrNodeGuId.trimmed())
    9594}
    96 void QuestionPriv::setEventTarget(const QString& eventTarget) {
    97     eventTarget_ = eventTarget.trimmed();
     95void Question::setEventTarget(const QString& eventTarget) {
     96    SET_IF_DIFFERENT(d->eventTarget, eventTarget.trimmed())
    9897}
    99 void QuestionPriv::setLanguage(const QString& language) {
    100     language_ = language.trimmed();
     98void Question::setLanguage(const QString& language) {
     99    SET_IF_DIFFERENT(d->language, language.trimmed())
    101100}
    102 void QuestionPriv::setText(const QString& questionText) {
    103     text_ = questionText.trimmed();
     101void Question::setText(const QString& questionText) {
     102    SET_IF_DIFFERENT(d->text, questionText.trimmed())
    104103}
    105 void QuestionPriv::setHint(const QString& hint) {
    106     hint_ = hint.trimmed();
     104void Question::setHint(const QString& hint) {
     105    SET_IF_DIFFERENT(d->hint, hint.trimmed())
    107106}
    108 void QuestionPriv::setAnswers(const QList<Answer>& answers) {
    109     answers_ = answers;
     107void Question::setAnswers(const QList<Answer>& answers) {
     108    SET_IF_DIFFERENT(d->answers, answers)
    110109}
    111 void QuestionPriv::setStatus(uint status) {
    112     status_ = status;
     110void Question::setStatus(uint status) {
     111    SET_IF_DIFFERENT(d->status, status)
    113112}
    114113
    115 void QuestionPriv::setStatusAtSchoolnetChecked(bool isIt) {
     114void Question::setStatusAtSchoolnetChecked(bool isIt) {
    116115    if (isIt) {
    117         setStatus(status_ | StatusAtSchoolnetChecked);
     116        setStatus(d->status | StatusAtSchoolnetChecked);
    118117    } else {
    119         setStatus(status_ & !StatusAtSchoolnetChecked);
     118        setStatus(d->status & !StatusAtSchoolnetChecked);
    120119    }
    121120}
    122121
    123 /**
    124  * Attention: Takes ownership!
    125  */
    126 void QuestionPriv::addAnswer(const Answer& answer) {
    127     answers_.append(answer);
     122void Question::addAnswer(const Answer& answer) {
     123    d->answers.append(answer);
    128124}
    129125
    130 bool QuestionPriv::operator==(const QuestionPriv& other) const {
     126bool Question::operator==(const Question& other) const {
    131127    return id() == other.id();
    132128}
     
    135131/************** ANSWER **************/
    136132
    137 AnswerPriv::AnswerPriv(const Question& question)
    138     : question_(question)
    139     , id_("")
    140     , text_("")
    141     , answered_(false)
    142     , correct_(false)
    143     , deepThoughtKnowsCorrectness_(false)
     133S_SHARED_IMPL_WITHOUT_EQUALS(Answer)
     134
     135Answer::Answer(const Question& question)
     136    : d(new AnswerData(question))
    144137{
    145138}
    146139
    147 void AnswerPriv::assign(const Answer& other, const Question& question) {
    148     question_                    = question; // This is used to allow reassigning an answer to a different question object
    149     id_                          = other->id_;
    150     text_                        = other->text_;
    151     answered_                    = other->answered_;
    152     correct_                     = other->correct_;
    153     deepThoughtKnowsCorrectness_ = other->deepThoughtKnowsCorrectness_;
     140Answer::~Answer() {
    154141}
    155142
    156 Question AnswerPriv::question() const {
    157     return question_;
     143Answer Answer::clone(const Question& question) const {
     144    Answer newA(*this);
     145    newA.d.detach();
     146    newA.d->question = question;
     147    return newA;
     148}
     149
     150Question Answer::question() const {
     151    return d->question;
    158152}
    159153
    160154
    161 QString AnswerPriv::id() const {
    162     return id_;
     155QString Answer::id() const {
     156    return d->id;
    163157}
    164 QString AnswerPriv::text() const {
    165     return text_;
     158QString Answer::text() const {
     159    return d->text;
    166160}
    167 bool AnswerPriv::isAnswered() const {
    168     return answered_;
     161bool Answer::isAnswered() const {
     162    return d->answered;
    169163}
    170 bool AnswerPriv::isCorrect() const {
    171     return correct_;
     164bool Answer::isCorrect() const {
     165    return d->correct;
    172166}
    173 bool AnswerPriv::doesDeepThoughtKnowsCorrectness() const {
    174     return deepThoughtKnowsCorrectness_;
     167bool Answer::doesDeepThoughtKnowsCorrectness() const {
     168    return d->deepThoughtKnowsCorrectness;
    175169}
    176170
    177 void AnswerPriv::setId(const QString& id) {
    178     id_ = id;
     171void Answer::setId(const QString& id) {
     172    SET_IF_DIFFERENT(d->id, id)
    179173}
    180 void AnswerPriv::setText(const QString& answerText) {
    181     text_ = answerText;
     174void Answer::setText(const QString& answerText) {
     175    SET_IF_DIFFERENT(d->text, answerText)
    182176}
    183 void AnswerPriv::setAnswered(bool answered) {
    184     answered_ = answered;
     177void Answer::setAnswered(bool answered) {
     178    SET_IF_DIFFERENT(d->answered, answered)
    185179}
    186 void AnswerPriv::setCorrect(bool correct) {
     180void Answer::setCorrect(bool correct) {
    187181    Q_ASSERT(!correct || isAnswered()); // correct implies isAnswered
    188182
    189     correct_ = correct;
     183    SET_IF_DIFFERENT(d->correct, correct)
    190184}
    191 void AnswerPriv::setDeepThoughtKnowsCorrectness(bool doesHe) {
     185void Answer::setDeepThoughtKnowsCorrectness(bool doesHe) {
    192186    Q_ASSERT(!doesHe || isAnswered()); // doesHe implies isAnswered
    193187
    194     deepThoughtKnowsCorrectness_ = doesHe;
     188    SET_IF_DIFFERENT(d->deepThoughtKnowsCorrectness, doesHe)
    195189}
    196190
    197 bool AnswerPriv::operator==(const AnswerPriv& other) const {
     191bool Answer::operator==(const Answer& other) const {
    198192    return (this->question() == other.question()) &&
    199193           (id() == other.id());
  • gateways/Schoolnet/src/business/deepthought/datatypes.h

    r194 r217  
    2222#include <QList>
    2323#include <QMap>
     24#include <QMetaType>
    2425#include <QString>
    2526#include <QStringList>
    2627
    27 #include <ssharedpointer.h>
     28#include <smacros.h>
     29#include <sshared.h>
     30
     31namespace Schoolnet {
     32    class Answer;
     33    class Question;
     34}
     35uint qHash(const Schoolnet::Question& ref);
     36uint qHash(const Schoolnet::Answer& ref);
    2837
    2938namespace Schoolnet {
    3039
    31 class Answer;
    32 class Question;
    33 
    3440class BCAccount;
    3541
    36 class QuestionPriv : public SShareable {
    37     friend class Question; // assign()
     42class QuestionData : public SShareable {
     43    Q_OBJECT
     44
     45public:
     46    QuestionData()
     47        : status(0)
     48    {}
     49    QuestionData(const QuestionData& other)
     50        : SShareable()
     51        , id(other.id)
     52        , nrNodeGuId(other.nrNodeGuId)
     53        , eventTarget(other.eventTarget)
     54        , language(other.language)
     55        , text(other.text)
     56        , hint(other.hint)
     57        , answers(other.answers)
     58        , status(other.status)
     59    {}
     60
     61public:
     62    int            id;
     63    QString        nrNodeGuId;
     64    QString        eventTarget;
     65    QString        language;
     66    QString        text;
     67    QString        hint;
     68    QList<Answer>  answers;
     69    uint           status;
     70};
     71
     72class Question {
     73    S_SHARED(Question, public)
     74    S_QHASH_FRIEND(Question)
    3875
    3976public:
     
    4380
    4481public:
    45     QuestionPriv();
     82    ~Question();
    4683
    4784public:
     
    5390    QString        hint() const;
    5491    uint           status() const;
    55 
    5692    bool           isStatusAtSchoolnetChecked() const;
    5793
    5894    QList<Answer>  answers() const;
     95
    5996
    6097    void           setId(int id);
     
    66103    void           setAnswers(const QList<Answer>& answers);
    67104    void           setStatus(const uint status);
    68 
    69105    void           setStatusAtSchoolnetChecked(bool isIt);
    70106
     
    76112
    77113public:
    78     bool           operator ==(const QuestionPriv& other) const;
    79     inline bool    operator !=(const QuestionPriv& other) const { return !(*this == other); }
    80 
    81 private:
    82     void           assign(const Question& other);
    83 
    84 private:
    85     int            id_;
    86     QString        nrNodeGuId_;
    87     QString        eventTarget_;
    88     QString        language_;
    89     QString        text_;
    90     QString        hint_;
    91     QList<Answer>  answers_;
    92 
    93     uint           status_;
    94 };
    95 class Question : protected SShared<QuestionPriv> {
    96     S_SHARED_INTERNAL(Question, SShared<QuestionPriv>, SShared<QuestionPriv>)
    97 
    98     friend class FetchDataFromDeepThoughtTaskPriv; // clone()
    99 
    100 public:
    101     Question()
    102         : SShared<QuestionPriv>(new QuestionPriv)
    103     {};
    104 
    105 private:
    106     Question clone() const {
    107         Question ret;
    108         ret->assign(*this);
    109         return ret;
    110     }
     114    Question       clone() const;
    111115};
    112116
    113117
    114 class AnswerPriv : public SShareable {
    115     friend class Answer; // assign()
    116 
    117     friend class FetchDataFromDeepThoughtTaskPriv; // setters
    118     friend class QuestionManagerPriv; // setters
    119     friend class DADeepThoughtStoragePriv; // setters
     118class AnswerData : public SShareable {
     119    Q_OBJECT
    120120
    121121public:
    122     explicit AnswerPriv(const Question& question);
     122    AnswerData()
     123        : question(NULL)
     124    {}
     125    AnswerData(const Question& question)
     126        : question(question)
     127    {}
     128    AnswerData(const AnswerData& other)
     129        : SShareable()
     130        , question(other.question)
     131        , id(other.id)
     132        , text(other.text)
     133        , answered(other.answered)
     134        , correct(other.correct)
     135        , deepThoughtKnowsCorrectness(other.deepThoughtKnowsCorrectness)
     136    {}
    123137
    124138public:
    125     Question       question() const;
     139    Question question;
     140    QString  id;
     141    QString  text;
     142    bool     answered;
     143    bool     correct;
     144    bool     deepThoughtKnowsCorrectness;
     145};
    126146
    127     QString        id() const;
    128     QString        text() const;
    129     bool           isAnswered() const;
    130     bool           isCorrect() const;
    131     bool           doesDeepThoughtKnowsCorrectness() const;
     147class Answer {
     148    S_SHARED(Answer, public)
     149    S_QHASH_FRIEND(Answer)
    132150
    133     void           setId(const QString& id);
    134     void           setText(const QString& answerText);
     151    friend class FetchDataFromDeepThoughtTask; // setters
     152    friend class QuestionManager; // setters
     153    friend class DADeepThoughtStorage; // setters
    135154
    136155public:
    137     virtual bool   operator ==(const AnswerPriv& other) const;
    138     inline bool    operator !=(const AnswerPriv& other) const { return !(*this == other); }
     156    explicit Answer(const Question& question);
     157    ~Answer();
     158
     159public:
     160    Question question() const;
     161
     162    QString  id() const;
     163    QString  text() const;
     164    bool     isAnswered() const;
     165    bool     isCorrect() const;
     166    bool     doesDeepThoughtKnowsCorrectness() const;
     167
     168    void     setId(const QString& id);
     169    void     setText(const QString& answerText);
    139170
    140171private:
    141     void           setAnswered(bool answered);
    142     void           setCorrect(bool correct);
    143     void           setDeepThoughtKnowsCorrectness(bool doesHe);
    144 
    145 private:
    146     void           assign(const Answer& other, const Question& question);
    147 
    148 private:
    149     Question question_;
    150     QString  id_;
    151     QString  text_;
    152     bool     answered_;
    153     bool     correct_;
    154     bool     deepThoughtKnowsCorrectness_;
    155 };
    156 class Answer : protected SShared<AnswerPriv> {
    157     S_SHARED_INTERNAL(Answer, SShared<AnswerPriv>, SShared<AnswerPriv>)
    158 
    159     friend class FetchDataFromDeepThoughtTaskPriv; // clone()
    160     friend class QuestionPriv; // clone()
     172    void     setAnswered(bool answered);
     173    void     setCorrect(bool correct);
     174    void     setDeepThoughtKnowsCorrectness(bool doesHe);
    161175
    162176public:
    163     Answer()
    164         : SShared<AnswerPriv>(NULL)
    165     {};
    166     explicit Answer(const Question& question)
    167         : SShared<AnswerPriv>(new AnswerPriv(question))
    168     {};
    169 
    170 private:
    171     Answer clone(const Question& question) const {
    172         Answer ret;
    173         ret->assign(*this, question);
    174         return ret;
    175     }
     177    Answer   clone(const Question& question) const;
    176178};
    177179
    178180}
    179 
    180 Q_DECLARE_METATYPE(Schoolnet::Question);
    181 Q_DECLARE_METATYPE(Schoolnet::Answer);
     181S_QHASH(Schoolnet::Answer)
     182Q_DECLARE_METATYPE(Schoolnet::Question)
     183Q_DECLARE_METATYPE(Schoolnet::Answer)
    182184
    183185#endif /* SCHOOLNET_DATATYPES_H_ */
  • gateways/Schoolnet/src/business/deepthought/deepthought_daemon_deepthought.cpp

    r198 r217  
    2222
    2323#include "business/bcaccount.h"
    24 #include "main.h"
     24#include "library.h"
    2525
    2626#include "deepthought_tasks.h"
     
    2929namespace Schoolnet {
    3030
    31 DeepThoughtDaemonPriv::DeepThoughtDaemonPriv() {
     31DeepThoughtDaemon::DeepThoughtDaemon(QObject* parent)
     32    : QObject(parent)
     33{
    3234    connect(QuestionManager::instance(), SIGNAL(answerProvided(const Answer&)),
    3335            this, SLOT(onAnswerProvided(const Answer&)));
    3436
    35     connect(Library::instance()->managerFactory()->accountManager(), SIGNAL(accountAdded(const IAccount&)),
    36             this, SLOT(accountAdded(const IAccount&)));
    37     connect(Library::instance()->managerFactory()->accountManager(), SIGNAL(accountDataChanged(const IAccount&, int)),
    38             SLOT(accountAdded(const IAccount&)));
     37    connect(Library::instance()->managerFactory()->accountManager(), SIGNAL(accountAdded(IAccount*)),
     38            this, SLOT(accountAdded(IAccount*)));
     39    connect(Library::instance()->managerFactory()->accountManager(), SIGNAL(accountDataChanged(IAccount*, int)),
     40            SLOT(accountAdded(IAccount*)));
    3941
    4042    timer_ = new QTimer(this);
     
    4648
    4749/*** This part is used to fetch question data from the deepthought server at a regular basis. ***/
    48 void DeepThoughtDaemonPriv::start() {
     50void DeepThoughtDaemon::start() {
    4951    if (!timer_->isActive()) {
    5052        fetchRemoteQuestions(); // Does an immediate call
     
    5254    }
    5355}
    54 void DeepThoughtDaemonPriv::stop() {
     56void DeepThoughtDaemon::stop() {
    5557    timer_->stop();
    5658}
    5759
    5860
    59 void DeepThoughtDaemonPriv::fetchRemoteQuestions() {
     61void DeepThoughtDaemon::fetchRemoteQuestions() {
    6062    // Check if we should run
    6163    bool hasDeepThoughtUser = false;
    62     foreach(IAccount account, Library::instance()->managerFactory()->accountManager()->getAccountList()) {
     64    foreach(IAccount* account, Library::instance()->managerFactory()->accountManager()->getAccountList()) {
    6365        if (account->gateway() != BCGateway::instance()) {
    6466            // Different account type
    6567            continue;
    6668        }
    67 
    68         BCAccount acc = account;
     69        BCAccount* acc = static_cast<BCAccount*>(account);
    6970
    7071        hasDeepThoughtUser |= acc->isEnabled() && acc->useDeepThought();
     
    7778
    7879    // Do run
    79     STask task = FetchDataFromDeepThoughtTask();
    80     connect(task, SIGNAL(finished(STask::Result, uint)), this, SIGNAL(dataFetchFinished(STask::Result, uint)));
     80    STask* task = new FetchDataFromDeepThoughtTask();
     81    connect(task, SIGNAL(finished(STask*)), this, SIGNAL(dataFetchFinished(STask*)));
    8182    task->start();
    8283
     
    8586}
    8687
    87 void DeepThoughtDaemonPriv::accountAdded(const IAccount& account) {
     88void DeepThoughtDaemon::accountAdded(IAccount* account) {
    8889    if (account->gateway() != BCGateway::instance()) {
    8990        return;
    9091    }
     92    BCAccount* acc = static_cast<BCAccount*>(account);
    9193
    92     BCAccount acc = account;
    9394    if (!acc->useDeepThought()) {
    9495        return;
     
    100101
    101102/*** This part comes in touch if answers are provided by the user and are checked for their correctness at schoolnet. ***/
    102 void DeepThoughtDaemonPriv::onAnswerProvided(const Answer& answer) {
    103     if (answer->doesDeepThoughtKnowsCorrectness()) {
     103void DeepThoughtDaemon::onAnswerProvided(const Answer& answer) {
     104    if (answer.doesDeepThoughtKnowsCorrectness()) {
    104105        // Don't bother DeepThought with things he already knows...
    105106        return;
    106107    }
    107108
    108     STask task = AnswerToDeepThoughtTask(answer);
     109    STask* task = new AnswerToDeepThoughtTask(answer);
    109110    task->start();
    110111}
  • gateways/Schoolnet/src/business/deepthought/deepthought_daemon_schoolnet.cpp

    r194 r217  
    2828namespace Schoolnet {
    2929
    30 SchoolnetDaemonPriv::SchoolnetDaemonPriv(const BCAccount& account)
    31     : QObject(0)
     30SchoolnetDaemon::SchoolnetDaemon(QObject* parent, BCAccount* account)
     31    : QObject(parent)
    3232    , account_(account)
    3333{
     
    3535            this, SLOT(onAnswerProvided(const Answer&)));
    3636
    37     connect(account, SIGNAL(loggedIn()), this, SLOT(onAccountLoggedIn()));
     37    connect(account, SIGNAL(loggedIn(IAccount*)), this, SLOT(onAccountLoggedIn()));
    3838    if (account->isLoggedIn()) {
    3939        sendCorrectQuestionsToSchoolnet();
    4040    }
    4141
    42     connect(DeepThoughtHelper::instance()->deepThoughtDaemon(), SIGNAL(dataFetchFinished(STask::Result, uint)),
    43             this, SLOT(onDeepThoughtDataFetchFinished(STask::Result)));
     42    connect(DeepThoughtHelper::instance()->deepThoughtDaemon(), SIGNAL(dataFetchFinished(STask*)),
     43            this, SLOT(onDeepThoughtDataFetchFinished(STask*)));
    4444}
    4545
    4646
    4747/* This part gets in touch if the user sets an answer to a question */
    48 STask SchoolnetDaemonPriv::proposeAnswer(const Answer& answer) {
    49     if (QuestionManager::instance()->isQuestionAnsweredAtSchoolnet(account(), answer->question())) {
     48STask* SchoolnetDaemon::proposeAnswer(const Answer& answer) {
     49    if (QuestionManager::instance()->isQuestionAnsweredAtSchoolnet(account(), answer.question())) {
    5050        // This question is already answered at schoolnet
    5151        return NULL;
    5252    }
    5353
    54     STask atSchoolnet(AnswerToSchoolnetTask(account(), answer));
     54    STask* atSchoolnet = new AnswerToSchoolnetTask(account(), answer);
    5555    atSchoolnet->start();
    5656
     
    6060
    6161/* This part is used to profit from correct answers which are provided by either the user (on an other account) or deepthought. */
    62 void SchoolnetDaemonPriv::onAnswerProvided(const Answer& answer) {
    63     if (!answer->isCorrect()) {
     62void SchoolnetDaemon::onAnswerProvided(const Answer& answer) {
     63    if (!answer.isCorrect()) {
    6464        // The answer is incorrect and therefore not interresting for us
    6565        return;
    6666    }
    6767
    68     if (QuestionManager::instance()->isQuestionAnsweredAtSchoolnet(account(), answer->question())) {
     68    if (QuestionManager::instance()->isQuestionAnsweredAtSchoolnet(account(), answer.question())) {
    6969        // The answer has already been answered at this account.
    7070        return;
     
    7474}
    7575
    76 void SchoolnetDaemonPriv::sendCorrectQuestionsToSchoolnet() {
     76void SchoolnetDaemon::sendCorrectQuestionsToSchoolnet() {
    7777    foreach (Question question, QuestionManager::instance()->questions()) {
    78         if (!question->hasCorrectAnswer() || QuestionManager::instance()->isQuestionAnsweredAtSchoolnet(account(), question)) {
     78        if (!question.hasCorrectAnswer() || QuestionManager::instance()->isQuestionAnsweredAtSchoolnet(account(), question)) {
    7979            continue;
    8080        }
    8181
    82         proposeAnswer(question->correctAnswer());
     82        proposeAnswer(question.correctAnswer());
    8383    }
    8484}
    8585
    86 void SchoolnetDaemonPriv::onAccountLoggedIn() {
     86void SchoolnetDaemon::onAccountLoggedIn() {
    8787    sendCorrectQuestionsToSchoolnet();
    88     onDeepThoughtDataFetchFinished(STask::rSuccess);
     88
     89    STask* cqsas = new CheckQuestionStatusAtSchoolnetTask(account());
     90    cqsas->start();
    8991}
    9092
    91 void SchoolnetDaemonPriv::onDeepThoughtDataFetchFinished(STask::Result taskResult) {
    92     if (taskResult != STask::rSuccess) {
     93void SchoolnetDaemon::onDeepThoughtDataFetchFinished(STask* task) {
     94    if (task->taskResult() != STask::rSuccess) {
    9395        return;
    9496    }
     
    98100    }
    99101
    100     STask cqsas = CheckQuestionStatusAtSchoolnetTask(account());
     102    STask* cqsas = new CheckQuestionStatusAtSchoolnetTask(account());
    101103    cqsas->start();
    102104}
    103105
    104 BCAccount SchoolnetDaemonPriv::account() const {
     106BCAccount* SchoolnetDaemon::account() const {
    105107    return account_;
    106108}
  • gateways/Schoolnet/src/business/deepthought/deepthought_daemons.h

    r194 r217  
    2424#include <iaccount.h>
    2525
    26 #include <ssharedpointer.h>
     26#include <smacros.h>
    2727#include <stask.h>
    2828
     
    3535class BCAccount;
    3636
    37 class SchoolnetDaemon;
    38 class SchoolnetDaemonPriv : public QObject, public SShareable {
     37class SchoolnetDaemon : public QObject {
    3938    Q_OBJECT
    4039
    4140public:
    42     explicit SchoolnetDaemonPriv(const BCAccount& account);
     41    explicit SchoolnetDaemon(QObject* parent, BCAccount* account);
    4342
    44     STask proposeAnswer(const Answer& answer);
     43    STask* proposeAnswer(const Answer& answer);
    4544
    4645private:
    47     BCAccount account() const;
     46    BCAccount* account() const;
    4847    void sendCorrectQuestionsToSchoolnet();
    4948
     
    5150    void onAnswerProvided(const Answer& answer);
    5251    void onAccountLoggedIn();
    53     void onDeepThoughtDataFetchFinished(STask::Result taskResult);
     52    void onDeepThoughtDataFetchFinished(STask* task);
    5453
    5554private:
    56     IAccount account_;
    57 };
    58 class SchoolnetDaemon : protected SSharedQObj<SchoolnetDaemonPriv> {
    59     S_SHARED_INTERNAL(SchoolnetDaemon, SSharedQObj<SchoolnetDaemonPriv>, SSharedQObj<SchoolnetDaemonPriv>)
    60     S_SHARED_QOBJ_INTERNAL(SchoolnetDaemon, SSharedQObj<SchoolnetDaemonPriv>, SSharedQObj<SchoolnetDaemonPriv>)
    61 
    62 public:
    63     SchoolnetDaemon()
    64         : SSharedQObj<SchoolnetDaemonPriv>(NULL)
    65     {};
    66     explicit SchoolnetDaemon(const BCAccount& account)
    67         : SSharedQObj<SchoolnetDaemonPriv>(new SchoolnetDaemonPriv(account))
    68     {};
     55    BCAccount* account_;
    6956};
    7057
    7158
    72 class DeepThoughtDaemonPriv : public QObject, public SShareable {
     59class DeepThoughtDaemon : public QObject {
    7360    Q_OBJECT
    7461
    7562public:
    76     DeepThoughtDaemonPriv();
     63    DeepThoughtDaemon(QObject* parent);
    7764
    7865signals:
    79     void dataFetchFinished(STask::Result taskResult, uint specialResult);
     66    void dataFetchFinished(STask* task);
    8067
    8168private:
     
    8471
    8572private slots:
    86     void accountAdded(const IAccount& account);
     73    void accountAdded(IAccount* account);
    8774    void fetchRemoteQuestions();
    8875
     
    9279    QTimer* timer_;
    9380};
    94 class DeepThoughtDaemon : protected SSharedQObj<DeepThoughtDaemonPriv> {
    95     S_SHARED_INTERNAL(DeepThoughtDaemon, SSharedQObj<DeepThoughtDaemonPriv>, SSharedQObj<DeepThoughtDaemonPriv>)
    96     S_SHARED_QOBJ_INTERNAL(DeepThoughtDaemon, SSharedQObj<DeepThoughtDaemonPriv>, SSharedQObj<DeepThoughtDaemonPriv>)
    97 
    98 public:
    99     DeepThoughtDaemon()
    100         : SSharedQObj<DeepThoughtDaemonPriv>(new DeepThoughtDaemonPriv)
    101     {};
    102 };
    10381
    10482}
    105 Q_DECLARE_METATYPE(Schoolnet::SchoolnetDaemon);
    106 Q_DECLARE_METATYPE(Schoolnet::DeepThoughtDaemon);
    107 
    10883
    10984#endif /* DEEPTHOUGHT_DAEMONS_H_ */
  • gateways/Schoolnet/src/business/deepthought/deepthought_task_answertodeepthougth.cpp

    r198 r217  
    2020
    2121#include <snetworkhelper.h>
     22#include <snetworkreply.h>
    2223
    2324#include "datatypes.h"
     
    2728
    2829
    29 AnswerToDeepThoughtTaskPriv::AnswerToDeepThoughtTaskPriv(const Answer& answer)
    30     : SThreadedTaskPriv(0xf00ba7, "Schoolnet::DeepThought")
     30AnswerToDeepThoughtTask::AnswerToDeepThoughtTask(const Answer& answer)
     31    : SThreadedTask(0xf00ba7, "Schoolnet::DeepThought")
    3132    , answer_(answer)
    3233{
    33     Q_ASSERT(answer->isAnswered());
     34    Q_ASSERT(answer.isAnswered());
    3435
    3536    setTitle(tr("Telling DeepThought about the correct answer"));
    3637}
    3738
    38 void AnswerToDeepThoughtTaskPriv::doTheWork() {
    39     Question question = answer()->question();
    40     SNetworkHelper httpHelper = DeepThoughtHelper::instance()->httpHelper();
     39void AnswerToDeepThoughtTask::doTheWork() {
     40    Question question = answer().question();
     41    SNetworkHelper* httpHelper = DeepThoughtHelper::instance()->httpHelper();
    4142
    4243    SNetworkReply reply = httpHelper->syncGet(URL_DEEPTHOUGHT + QString("&action=iHaveAnAnswer&nrNodeGuId=%1&eventTarget=%2"
    4344                                                                        "&correct=%3&answerId=%4&hint=%5")
    44                                                                             .arg(question->nrNodeGuId())
    45                                                                             .arg(question->eventTarget())
    46                                                                             .arg((int)answer()->isCorrect())
    47                                                                             .arg(answer()->id())
    48                                                                             .arg(question->hint()));
     45                                                                            .arg(question.nrNodeGuId())
     46                                                                            .arg(question.eventTarget())
     47                                                                            .arg((int)answer().isCorrect())
     48                                                                            .arg(answer().id())
     49                                                                            .arg(question.hint()));
    4950    // TODO: Check if the proposal was successful
    5051    Q_UNUSED(reply);
     
    5253
    5354
    54 Answer AnswerToDeepThoughtTaskPriv::answer() const {
     55Answer AnswerToDeepThoughtTask::answer() const {
    5556    return answer_;
    5657}
  • gateways/Schoolnet/src/business/deepthought/deepthought_task_answertoschoolnet.cpp

    r198 r217  
    2929namespace Schoolnet {
    3030
    31 AnswerToSchoolnetTaskPriv::AnswerToSchoolnetTaskPriv(const BCAccount& account, const Answer& answer)
    32     : SThreadedTaskPriv(0x5c001437, "Schoolnet::DeepThought")
     31AnswerToSchoolnetTask::AnswerToSchoolnetTask(BCAccount* account, const Answer& answer)
     32    : SThreadedTask(0x5c001437, "Schoolnet::DeepThought")
    3333    , account_(account)
    3434    , answer_(answer)
     
    4242
    4343
    44 void AnswerToSchoolnetTaskPriv::doTheWork() {
    45     if (answer()->question()->hasCorrectAnswer() && !answer()->isCorrect()) {
     44void AnswerToSchoolnetTask::doTheWork() {
     45    if (answer().question().hasCorrectAnswer() && !answer().isCorrect()) {
    4646        // Don't waste effort on already correctly answered questions!
    4747        setSpecialResult(aCancelled);
     
    4949    }
    5050
    51     STask login = account()->createLoginTask();
     51    STask* login = account()->createLoginTask();
    5252    startSubTask(login, true);
    5353
    54     Question question = answer()->question();
     54    Question question = answer().question();
    5555
    5656    // Check if the question is already answered
    57     QString html = QString::fromUtf8(account()->httpHelper()->syncGet(URL_GETPOINTSPAGE + question->nrNodeGuId()));
     57    QString html = QString::fromUtf8(account()->httpHelper()->syncGet(URL_GETPOINTSPAGE + question.nrNodeGuId()));
    5858    if (qiAlreadyAnswered == setCorrectAnswerFromHtml(question, html)) {
    5959        // The question is already answered on schoolnet
     
    6464
    6565    // Answer it!
    66     QList<IParam> posts;
    67     posts.append(SKeyValueParam(QString(question->eventTarget()+":Answers").toUtf8(), answer()->id().toUtf8()));
    68     html = QString::fromUtf8(account()->httpHelper()->syncPostByTarget(question->eventTarget() + "$cmdAnswer", "", posts));
     66    QList<IParam*> posts;
     67    posts.append(new SKeyValueParam(QString(question.eventTarget()+":Answers").toUtf8(), answer().id().toUtf8()));
     68    html = QString::fromUtf8(account()->httpHelper()->syncPostByTarget(question.eventTarget() + "$cmdAnswer", "", posts));
    6969
    7070    // Check the correctness of our answer
     
    9797 * @return QuestionInfo The info about the correct answer which was extracted from schoolnet.
    9898 */
    99 AnswerToSchoolnetTaskPriv::QuestionInfo AnswerToSchoolnetTaskPriv::setCorrectAnswerFromHtml(const Question& question, const QString& html) {
    100     QString submitId = question->eventTarget().replace(':', '_') + "_cmdAnswer";
     99AnswerToSchoolnetTask::QuestionInfo AnswerToSchoolnetTask::setCorrectAnswerFromHtml(Question& question, const QString& html) {
     100    QString submitId = question.eventTarget().replace(':', '_') + "_cmdAnswer";
    101101
    102102    QRegExp rx("<div class=\"boxChildContent[^\"]*\">.*"
    103103                 "<div id=\"quizPrompt\">([^<]+)</div>.*"
    104                  "(<input[^>]*name=\"" + question->eventTarget() + ":Answers\"[^>]*checked=\"checked\"[^>]*>)?.*"
     104                 "(<input[^>]*name=\"" + question.eventTarget() + ":Answers\"[^>]*checked=\"checked\"[^>]*>)?.*"
    105105                 "<a id=\"" + submitId + "\" disabled=\"disabled\">Get it!</a>");
    106106    rx.setMinimal(true);
     
    125125            QString selectedAnswerId = rx2.cap(1);
    126126
    127             foreach(Answer answer, question->answers()) {
    128                 if (answer->id() == selectedAnswerId) {
     127            foreach(Answer answer, question.answers()) {
     128                if (answer.id() == selectedAnswerId) {
    129129                    selectedAnswer = answer;
    130130                    break;
     
    189189                hint.remove(QRegExp("^" + sorryHint));
    190190            }
    191             question->setHint(hint.trimmed());
    192 
    193             foreach (Answer answer, question->answers()) {
    194                 if (answerStr.toLower().contains(answer->text().toLower())) {
     191            question.setHint(hint.trimmed());
     192
     193            foreach (Answer answer, question.answers()) {
     194                if (answerStr.toLower().contains(answer.text().toLower())) {
    195195                    // Would have been correct.
    196196                    QuestionManager::instance()->provideAnswer(answer, true);
     
    222222}
    223223
    224 BCAccount AnswerToSchoolnetTaskPriv::account() const {
     224BCAccount* AnswerToSchoolnetTask::account() const {
    225225    return account_;
    226226}
    227 Answer AnswerToSchoolnetTaskPriv::answer() const {
     227Answer AnswerToSchoolnetTask::answer() const {
    228228    return answer_;
    229229}
  • gateways/Schoolnet/src/business/deepthought/deepthought_task_check_questionstatus_at_schoolnet.cpp

    r198 r217  
    2727namespace Schoolnet {
    2828
    29 CheckQuestionStatusAtSchoolnetTaskPriv::CheckQuestionStatusAtSchoolnetTaskPriv(const BCAccount& account)
    30     : SThreadedTaskPriv(0x245924, "Schoolnet::DeepThought")
     29CheckQuestionStatusAtSchoolnetTask::CheckQuestionStatusAtSchoolnetTask(BCAccount* account)
     30    : SThreadedTask(0x245924, "Schoolnet::DeepThought")
    3131    , account_(account)
    3232{
     
    3535}
    3636
    37 void CheckQuestionStatusAtSchoolnetTaskPriv::doTheWork() {
     37void CheckQuestionStatusAtSchoolnetTask::doTheWork() {
    3838    QList<Question> questions = QuestionManager::instance()->questions();
    3939
     
    4242        setProgress(pos++ / (double)questions.size() * 100);
    4343
    44         if (question->isStatusAtSchoolnetChecked()) {
     44        if (question.isStatusAtSchoolnetChecked()) {
    4545            continue;
    4646        }
    4747
    4848        if (!QuestionManager::instance()->isQuestionAnsweredAtSchoolnet(account(), question)) {
    49             QString html = QString::fromUtf8(account()->httpHelper()->syncGet(URL_GETPOINTSPAGE + question->nrNodeGuId()));
     49            QString html = QString::fromUtf8(account()->httpHelper()->syncGet(URL_GETPOINTSPAGE + question.nrNodeGuId()));
    5050
    51             QString submitId = question->eventTarget().replace(':', '_') + "_cmdAnswer";
     51            QString submitId = question.eventTarget().replace(':', '_') + "_cmdAnswer";
    5252            QRegExp rx("<a disabled=\"disabled\" id=\"" + submitId + "\">Get it!</a>");
    5353            rx.setCaseSensitivity(Qt::CaseInsensitive);
     
    5858        }
    5959
    60         question->setStatusAtSchoolnetChecked(true);
     60        question.setStatusAtSchoolnetChecked(true);
    6161        QuestionManager::instance()->saveQuestion(question);
    6262    }
     
    6464
    6565
    66 BCAccount CheckQuestionStatusAtSchoolnetTaskPriv::account() const {
     66BCAccount* CheckQuestionStatusAtSchoolnetTask::account() const {
    6767    return account_;
    6868}
  • gateways/Schoolnet/src/business/deepthought/deepthought_task_fetchdatafromdeepthought.cpp

    r198 r217  
    2525
    2626#include <snetworkhelper.h>
     27#include <snetworkreply.h>
    2728
    2829#include "datatypes.h"
     
    3435namespace Schoolnet {
    3536
    36 FetchDataFromDeepThoughtTaskPriv::FetchDataFromDeepThoughtTaskPriv()
    37     : SThreadedTaskPriv(0xab912, "Schoolnet::DeepThought")
     37FetchDataFromDeepThoughtTask::FetchDataFromDeepThoughtTask()
     38    : SThreadedTask(0xab912, "Schoolnet::DeepThought")
    3839{
    3940    setTitle(tr("Updating question cache from DeepThought"));
     
    4142}
    4243
    43 void FetchDataFromDeepThoughtTaskPriv::doTheWork() {
     44void FetchDataFromDeepThoughtTask::doTheWork() {
    4445    QDateTime lastRun     = DADeepThoughtStorage::instance()->lastDeepThoughtRun();
    4546    QDateTime nextLastRun = QDateTime::currentDateTime();
    4647
    4748    setDetails(tr("Fetching question updates"));
    48     SNetworkHelper httpHelper = DeepThoughtHelper::instance()->httpHelper();
     49    SNetworkHelper* httpHelper = DeepThoughtHelper::instance()->httpHelper();
    4950
    5051    QString lastRunS = !lastRun.isNull() ? QString::number(lastRun.toTime_t()) : "0";
     
    5960}
    6061
    61 void FetchDataFromDeepThoughtTaskPriv::processQuestionUpdate(const QList<Question>& questions) {
     62void FetchDataFromDeepThoughtTask::processQuestionUpdate(const QList<Question>& questions) {
    6263    QList<Question> dbQuestions = QuestionManager::instance()->questions();
    6364
    6465    QMap<QString, Question> dbQuestionMap;
    6566    foreach (Question question, dbQuestions) {
    66         dbQuestionMap.insert(question->nrNodeGuId() + "_" + question->eventTarget(), question);
     67        dbQuestionMap.insert(question.nrNodeGuId() + "_" + question.eventTarget(), question);
    6768    }
    6869
     
    7172        setProgress(10 + 90 * (i++)/(double)questions.size());
    7273
    73         QString key = question->nrNodeGuId() + "_" + question->eventTarget();
     74        QString key = question.nrNodeGuId() + "_" + question.eventTarget();
    7475        if (dbQuestionMap.contains(key) &&
    75             (question->text() != dbQuestionMap.value(key)->text()))
     76            (question.text() != dbQuestionMap.value(key).text()))
    7677        { // A new question with already used, old ids
    7778            QuestionManager::instance()->deleteQuestion(dbQuestionMap.value(key));
     
    8081
    8182        // Insert new question if it is not already there
    82         if (!dbQuestionMap.contains(question->nrNodeGuId() + "_" + question->eventTarget())) {
    83             dbQuestionMap.insert(question->nrNodeGuId() + "_" + question->eventTarget(), question.clone());
     83        if (!dbQuestionMap.contains(question.nrNodeGuId() + "_" + question.eventTarget())) {
     84            dbQuestionMap.insert(question.nrNodeGuId() + "_" + question.eventTarget(), question.clone());
    8485        }
    8586
    8687        /* Update the question */
    87         Question dbQuestion = dbQuestionMap.value(question->nrNodeGuId() + "_" + question->eventTarget());
    88         if (!question->hint().isEmpty()) {
    89             dbQuestion->setHint(question->hint());
     88        Question dbQuestion = dbQuestionMap.value(question.nrNodeGuId() + "_" + question.eventTarget());
     89        if (!question.hint().isEmpty()) {
     90            dbQuestion.setHint(question.hint());
    9091        }
    9192
    9293        QMap<QString, Answer> dbAnswerMap;
    93         foreach (Answer answer, dbQuestion->answers()) {
    94             dbAnswerMap.insert(answer->id(), answer);
     94        foreach (Answer answer, dbQuestion.answers()) {
     95            dbAnswerMap.insert(answer.id(), answer);
    9596        }
    9697
     
    9899
    99100        /* Update the answers */
    100         foreach (Answer answer, question->answers()) {
     101        foreach (Answer answer, question.answers()) {
    101102            // Insert new answer if it is not already there
    102             if (!dbAnswerMap.contains(answer->id())) {
     103            if (!dbAnswerMap.contains(answer.id())) {
    103104                Answer newAnswer = answer.clone(dbQuestion);
    104                 dbAnswerMap.insert(newAnswer->id(), newAnswer);
    105                 dbQuestion->addAnswer(newAnswer);
     105                dbAnswerMap.insert(newAnswer.id(), newAnswer);
     106                dbQuestion.addAnswer(newAnswer);
    106107            }
    107108
    108109            /* Update the answer */
    109             Answer dbAnswer = dbAnswerMap.value(answer->id());
    110             if (answer->isAnswered()) {
    111                 dbAnswer->setAnswered(true);
    112                 dbAnswer->setDeepThoughtKnowsCorrectness(true);
    113                 if (answer->isCorrect()) {
    114                     dbAnswer->setCorrect(true);
     110            Answer dbAnswer = dbAnswerMap.value(answer.id());
     111            if (answer.isAnswered()) {
     112                dbAnswer.setAnswered(true);
     113                dbAnswer.setDeepThoughtKnowsCorrectness(true);
     114                if (answer.isCorrect()) {
     115                    dbAnswer.setCorrect(true);
    115116                }
    116117                answeredAnswers.append(dbAnswer);
     
    121122        // Now send updates about answers which were marked as answered
    122123        foreach (Answer answer, answeredAnswers) {
    123             QuestionManager::instance()->provideAnswer(answer, answer->isCorrect());
    124         }
    125     }
    126 }
    127 
    128 QList<Question> FetchDataFromDeepThoughtTaskPriv::parseResponse(const QString& xml) {
     124            QuestionManager::instance()->provideAnswer(answer, answer.isCorrect());
     125        }
     126    }
     127}
     128
     129QList<Question> FetchDataFromDeepThoughtTask::parseResponse(const QString& xml) {
    129130    QList<Question> questions;
    130131
     
    154155}
    155156
    156 Question FetchDataFromDeepThoughtTaskPriv::parseQuestion(const QDomElement& parent) {
     157Question FetchDataFromDeepThoughtTask::parseQuestion(const QDomElement& parent) {
    157158    Question question;
    158159
     
    165166
    166167        if (element.tagName().toLower() == "nrnodeguid") {
    167             question->setNrNodeGuId(element.firstChild().nodeValue());
     168            question.setNrNodeGuId(element.firstChild().nodeValue());
    168169        }
    169170        if (element.tagName().toLower() == "eventtarget") {
    170             question->setEventTarget(element.firstChild().nodeValue());
     171            question.setEventTarget(element.firstChild().nodeValue());
    171172        }
    172173        if (element.tagName().toLower() == "language") {
    173             question->setLanguage(element.firstChild().nodeValue());
     174            question.setLanguage(element.firstChild().nodeValue());
    174175        }
    175176        if (element.tagName().toLower() == "text") {
    176             question->setText(element.firstChild().nodeValue());
     177            question.setText(element.firstChild().nodeValue());
    177178        }
    178179        if (element.tagName().toLower() == "hint") {
    179             question->setHint(element.firstChild().nodeValue());
     180            question.setHint(element.firstChild().nodeValue());
    180181        }
    181182        if (element.tagName().toLower() == "answers") {
    182             question->setAnswers(parseAnswers(element, question));
     183            question.setAnswers(parseAnswers(element, question));
    183184        }
    184185    }
     
    186187}
    187188
    188 Answer FetchDataFromDeepThoughtTaskPriv::parseAnswer(const QDomElement& parent, const Question& question) {
     189Answer FetchDataFromDeepThoughtTask::parseAnswer(const QDomElement& parent, const Question& question) {
    189190    Answer answer(question);
    190     answer->setAnswered((bool)parent.attribute("tried", "0").toInt());
    191     answer->setCorrect((bool)parent.attribute("correct", "0").toInt());
     191    answer.setAnswered((bool)parent.attribute("tried", "0").toInt());
     192    answer.setCorrect((bool)parent.attribute("correct", "0").toInt());
    192193
    193194    QDomNodeList children = parent.childNodes();
     
    199200
    200201        if (element.tagName().toLower() == "id") {
    201             answer->setId(element.firstChild().nodeValue());
     202            answer.setId(element.firstChild().nodeValue());
    202203        }
    203204        if (element.tagName().toLower() == "text") {
    204             answer->setText(element.firstChild().nodeValue());
     205            answer.setText(element.firstChild().nodeValue());
    205206        }
    206207    }
     
    209210}
    210211
    211 QList<Answer> FetchDataFromDeepThoughtTaskPriv::parseAnswers(const QDomElement& parent, const Question& question) {
     212QList<Answer> FetchDataFromDeepThoughtTask::parseAnswers(const QDomElement& parent, const Question& question) {
    212213    QList<Answer> answers;
    213214    QDomNodeList children = parent.childNodes();
  • gateways/Schoolnet/src/business/deepthought/deepthought_tasks.h

    r194 r217  
    3838const QString URL_GETPOINTSPAGE = "http://www.schoolnet.ch/schoolnet/Templates/Template5Slots.aspx?NRMODE=Published&NRNODEGUID=";
    3939
    40 class FetchDataFromDeepThoughtTaskPriv : public SThreadedTaskPriv {
     40class FetchDataFromDeepThoughtTask : public SThreadedTask {
    4141    Q_OBJECT
    4242
    4343public:
    44     FetchDataFromDeepThoughtTaskPriv();
     44    FetchDataFromDeepThoughtTask();
    4545
    4646protected:
     
    5555    void            processQuestionUpdate(const QList<Question>& questions);
    5656};
    57 class FetchDataFromDeepThoughtTask : public SThreadedTask {
    58     S_SHARED_INTERNAL(FetchDataFromDeepThoughtTask, SThreadedTask, STask)
    59     S_SHARED_QOBJ_INTERNAL(FetchDataFromDeepThoughtTask, SThreadedTask, STask)
    60 
    61 public:
    62     FetchDataFromDeepThoughtTask()
    63         : SThreadedTask(new FetchDataFromDeepThoughtTaskPriv)
    64     {};
    65 };
    6657
    6758
    68 class AnswerToSchoolnetTaskPriv : public SThreadedTaskPriv {
     59class AnswerToSchoolnetTask : public SThreadedTask {
    6960    Q_OBJECT
    7061
     
    8576
    8677public:
    87     AnswerToSchoolnetTaskPriv(const BCAccount& account, const Answer& answer);
     78    AnswerToSchoolnetTask(BCAccount* account, const Answer& answer);
    8879
    89     BCAccount account() const;
    90     Answer    answer() const;
     80    BCAccount* account() const;
     81    Answer     answer() const;
    9182
    9283protected:
     
    9485
    9586private:
    96     QuestionInfo setCorrectAnswerFromHtml(const Question& question, const QString& html);
     87    QuestionInfo setCorrectAnswerFromHtml(Question& question, const QString& html);
    9788
    9889private:
    99     IAccount account_;
    100     Answer   answer_;
    101 };
    102 class AnswerToSchoolnetTask : public SThreadedTask {
    103     S_SHARED_INTERNAL(AnswerToSchoolnetTask, SThreadedTask, STask)
    104     S_SHARED_QOBJ_INTERNAL(AnswerToSchoolnetTask, SThreadedTask, STask)
    105 
    106 public:
    107     AnswerToSchoolnetTask(const BCAccount& account, const Answer& answer)
    108         : SThreadedTask(new AnswerToSchoolnetTaskPriv(account, answer))
    109     {};
     90    BCAccount* account_;
     91    Answer     answer_;
    11092};
    11193
    11294
    113 class AnswerToDeepThoughtTaskPriv : public SThreadedTaskPriv {
     95class AnswerToDeepThoughtTask : public SThreadedTask {
    11496    Q_OBJECT
    11597
    11698public:
    117     explicit AnswerToDeepThoughtTaskPriv(const Answer& answer);
     99    explicit AnswerToDeepThoughtTask(const Answer& answer);
    118100
    119101    Answer answer() const;
     
    125107    Answer answer_;
    126108};
    127 class AnswerToDeepThoughtTask : public SThreadedTask {
    128     S_SHARED_INTERNAL(AnswerToDeepThoughtTask, SThreadedTask, STask)
    129     S_SHARED_QOBJ_INTERNAL(AnswerToDeepThoughtTask, SThreadedTask, STask)
    130 
    131 public:
    132     explicit AnswerToDeepThoughtTask(const Answer& answer)
    133         : SThreadedTask(new AnswerToDeepThoughtTaskPriv(answer))
    134     {};
    135 };
    136109
    137110
    138 class CheckQuestionStatusAtSchoolnetTaskPriv : public SThreadedTaskPriv {
     111class CheckQuestionStatusAtSchoolnetTask : public SThreadedTask {
    139112    Q_OBJECT
    140113
    141114public:
    142     explicit CheckQuestionStatusAtSchoolnetTaskPriv(const BCAccount& account);
     115    explicit CheckQuestionStatusAtSchoolnetTask(BCAccount* account);
    143116
    144     BCAccount account() const;
     117    BCAccount* account() const;
    145118
    146119protected:
     
    148121
    149122private:
    150     IAccount account_;
     123    BCAccount* account_;
    151124
    152 };
    153 class CheckQuestionStatusAtSchoolnetTask : public SThreadedTask {
    154     S_SHARED_INTERNAL(CheckQuestionStatusAtSchoolnetTask, SThreadedTask, STask)
    155     S_SHARED_QOBJ_INTERNAL(CheckQuestionStatusAtSchoolnetTask, SThreadedTask, STask)
    156 
    157 public:
    158     explicit CheckQuestionStatusAtSchoolnetTask(const BCAccount& account)
    159         : SThreadedTask(new CheckQuestionStatusAtSchoolnetTaskPriv(account))
    160     {};
    161125};
    162126
  • gateways/Schoolnet/src/business/deepthought/deepthoughthelper.cpp

    r198 r217  
    2525#include <stask.h>
    2626
    27 #include "main.h"
     27#include "library.h"
    2828
    2929#include "deepthought_daemons.h"
     
    3232namespace Schoolnet {
    3333
     34S_SINGLETON_IMPL(DeepThoughtHelper)
    3435
    35 DeepThoughtHelperPriv::DeepThoughtHelperPriv()
    36     : deepThoughtDaemon_()
    37     , httpHelper_()
     36DeepThoughtHelper::DeepThoughtHelper()
     37    : QObject(NULL) // singleton
     38    , deepThoughtDaemon_(new DeepThoughtDaemon(this))
     39    , httpHelper_(new SNetworkHelper(this))
    3840{
    3941    /* Set the client certificate */
     
    5153
    5254
    53     connect(Library::instance()->managerFactory()->accountManager(), SIGNAL(accountAdded(const IAccount&)),
    54             SLOT(accountAdded(const IAccount&)));
    55     connect(Library::instance()->managerFactory()->accountManager(), SIGNAL(accountRemoved(const IAccount&)),
    56             SLOT(accountRemoved(const IAccount&)));
     55    connect(Library::instance()->managerFactory()->accountManager(), SIGNAL(accountAdded(IAccount*)),
     56            SLOT(accountAdded(IAccount*)));
     57    connect(Library::instance()->managerFactory()->accountManager(), SIGNAL(accountRemoved(IAccount*)),
     58            SLOT(accountRemoved(IAccount*)));
    5759}
    5860
     
    6264 * @return The next open question.
    6365 */
    64 Question DeepThoughtHelperPriv::getNextOpenQuestion(const BCAccount& account) {
     66Question DeepThoughtHelper::getNextOpenQuestion(BCAccount* account) {
    6567    QList<Question> questions = QuestionManager::instance()->openQuestions(account, account->deepThoughtQuestionLanguages());
    6668
     
    7274    return questions.first(); //value(qrand() % questions.size());
    7375}
    74 void DeepThoughtHelperPriv::pushQuestionBack(const Question& question) {
     76void DeepThoughtHelper::pushQuestionBack(const Question& question) {
    7577    QuestionManager::instance()->pushQuestionBack(question);
    7678}
    77 STask DeepThoughtHelperPriv::proposeAnswer(const BCAccount& account, const Answer& answer) {
     79STask* DeepThoughtHelper::proposeAnswer(BCAccount* account, const Answer& answer) {
    7880    Q_ASSERT(schoolnetDaemons_.contains(account));
    7981
     
    8183}
    8284
    83 void DeepThoughtHelperPriv::accountAdded(const IAccount& account) {
     85void DeepThoughtHelper::accountAdded(IAccount* account) {
    8486    if (account->gateway() != BCGateway::instance()) {
    8587        return;
    8688    }
     89    BCAccount* acc = static_cast<BCAccount*>(account);
    8790
    88     if (!schoolnetDaemons_.contains(account)) {
    89         schoolnetDaemons_.insert(account, SchoolnetDaemon(account));
     91    if (!schoolnetDaemons_.contains(acc)) {
     92        schoolnetDaemons_.insert(acc, new SchoolnetDaemon(this, acc));
    9093    }
    9194}
    92 void DeepThoughtHelperPriv::accountRemoved(const IAccount& account) {
     95void DeepThoughtHelper::accountRemoved(IAccount* account) {
    9396    if (account->gateway() != BCGateway::instance()) {
    9497        return;
    9598    }
     99    BCAccount* acc = static_cast<BCAccount*>(account);
    96100
    97     schoolnetDaemons_.remove(account);
     101    schoolnetDaemons_.take(acc)->deleteLater();
    98102}
    99103
    100 DeepThoughtDaemon DeepThoughtHelperPriv::deepThoughtDaemon() const {
     104DeepThoughtDaemon* DeepThoughtHelper::deepThoughtDaemon() const {
    101105    return deepThoughtDaemon_;
    102106}
    103107
    104 SNetworkHelper DeepThoughtHelperPriv::httpHelper() const {
     108SNetworkHelper* DeepThoughtHelper::httpHelper() const {
    105109    return httpHelper_;
    106110}
  • gateways/Schoolnet/src/business/deepthought/deepthoughthelper.h

    r198 r217  
    2323#include <QThread>
    2424
     25#include <smacros.h>
    2526#include <snetworkhelper.h>
    26 #include <ssingleton.h>
    2727
    2828#include "datatypes.h"
     
    3939class VCDeepThoughtQuestionDialogManager;
    4040
    41 class DeepThoughtHelperPriv : public QObject, public SShareable {
     41class DeepThoughtHelper : public QObject {
    4242    Q_OBJECT
     43    S_SINGLETON(DeepThoughtHelper)
    4344
    44     friend class AnswerToDeepThoughtTaskPriv;
    45     friend class FetchDataFromDeepThoughtTaskPriv;
     45    friend class AnswerToDeepThoughtTask; // httpHelper()
     46    friend class FetchDataFromDeepThoughtTask; // httpHelper()
    4647
    4748public:
    48     DeepThoughtHelperPriv();
     49    Question getNextOpenQuestion(BCAccount* account);
     50    void     pushQuestionBack(const Question& question);
     51    STask*   proposeAnswer(BCAccount* account, const Answer& answer);
    4952
    50 public:
    51     Question getNextOpenQuestion(const BCAccount& account);
    52     void     pushQuestionBack(const Question& question);
    53     STask    proposeAnswer(const BCAccount& account, const Answer& answer);
    54 
    55     DeepThoughtDaemon deepThoughtDaemon() const;
     53    DeepThoughtDaemon* deepThoughtDaemon() const;
    5654
    5755private:
    58     SNetworkHelper    httpHelper() const;
     56    SNetworkHelper*   httpHelper() const;
    5957
    6058    void              processQuestionUpdate(const QList<Question>& questions);
    6159
    6260private slots:
    63     void accountAdded(const IAccount& account);
    64     void accountRemoved(const IAccount& account);
     61    void accountAdded(IAccount* account);
     62    void accountRemoved(IAccount* account);
    6563
    6664private:
    67     QMap<BCAccount, SchoolnetDaemon> schoolnetDaemons_;
    68     DeepThoughtDaemon                deepThoughtDaemon_;
     65    QMap<BCAccount*, SchoolnetDaemon*> schoolnetDaemons_;
     66    DeepThoughtDaemon*                 deepThoughtDaemon_;
    6967
    70     SNetworkHelper httpHelper_;
     68    SNetworkHelper* httpHelper_;
    7169};
    72 S_SINGLETON_QOBJ(DeepThoughtHelper)
    7370
    7471}
  • gateways/Schoolnet/src/business/deepthought/questionmanager.cpp

    r194 r217  
    2626namespace Schoolnet {
    2727
    28 QuestionManagerPriv::QuestionManagerPriv()
    29     : questionListInitialized_(false)
     28S_SINGLETON_IMPL(QuestionManager)
     29
     30QuestionManager::QuestionManager()
     31    : QObject(NULL) // singleton
     32    , questionListInitialized_(false)
    3033{
    3134}
    3235
    33 QList<Question> QuestionManagerPriv::questions() {
     36QList<Question> QuestionManager::questions() {
    3437    if (!questionListInitialized_) {
    3538        questionListInitialized_ = true;
     
    5154 * @return The open questions
    5255 */
    53 QList<Question> QuestionManagerPriv::openQuestions(const BCAccount& account, const QStringList& acceptedLanguages) {
     56QList<Question> QuestionManager::openQuestions(BCAccount* account, const QStringList& acceptedLanguages) {
    5457    QList<Question> openQuestions;
    5558    foreach (Question question, questions()) {
    56         if (acceptedLanguages.contains(question->language()) &&  // Correct language?
    57             !question->hasCorrectAnswer() &&                     // Not already answered?
    58             question->isStatusAtSchoolnetChecked() &&            // Has the status at schoolnet been checked?
    59             !isQuestionAnsweredAtSchoolnet(account, question))   // Not already answered at schoolnet?
     59        if (acceptedLanguages.contains(question.language()) &&  // Correct language?
     60            !question.hasCorrectAnswer() &&                     // Not already answered?
     61            question.isStatusAtSchoolnetChecked() &&            // Has the status at schoolnet been checked?
     62            !isQuestionAnsweredAtSchoolnet(account, question))  // Not already answered at schoolnet?
    6063        {
    6164            openQuestions.append(question);
     
    6871 * @see DADeepThoughtStorage::isQuestionAnsweredAtSchoolnet()
    6972 */
    70 bool QuestionManagerPriv::isQuestionAnsweredAtSchoolnet(const BCAccount& account, const Question& question) const {
     73bool QuestionManager::isQuestionAnsweredAtSchoolnet(BCAccount* account, const Question& question) const {
    7174    return DADeepThoughtStorage::instance()->isQuestionAnsweredAtSchoolnet(account, question);
    7275}
     
    7578 * @see DADeepThoughtStorage::setQuestionAnsweredAtSchoolnet()
    7679 */
    77 void QuestionManagerPriv::setQuestionAnsweredAtSchoolnet(const BCAccount& account, const Question& question) const {
     80void QuestionManager::setQuestionAnsweredAtSchoolnet(BCAccount* account, const Question& question) const {
    7881    DADeepThoughtStorage::instance()->setQuestionAnsweredAtSchoolnet(account, question);
    7982}
    8083
    8184
    82 void QuestionManagerPriv::pushQuestionBack(const Question& question) {
     85void QuestionManager::pushQuestionBack(const Question& question) {
    8386    questions_.removeAll(question);
    8487    questions_.append(question);
     
    8689}
    8790
    88 void QuestionManagerPriv::saveQuestion(const Question& question) {
     91void QuestionManager::saveQuestion(Question question) {
    8992    DADeepThoughtStorage::instance()->updateQuestion(question);
    9093
     
    9497}
    9598
    96 void QuestionManagerPriv::deleteQuestion(const Question& question) {
     99void QuestionManager::deleteQuestion(Question question) {
    97100    // Should only very rarely be used!!
    98101    DADeepThoughtStorage::instance()->removeQuestion(question);
     
    104107 * Afterwards it emits the answerProvided signal.
    105108 */
    106 void QuestionManagerPriv::provideAnswer(const Answer& answer, bool correct) {
    107     answer->setAnswered(true);
    108     answer->setCorrect(correct);
    109     saveQuestion(answer->question());
     109void QuestionManager::provideAnswer(Answer answer, bool correct) {
     110    answer.setAnswered(true);
     111    answer.setCorrect(correct);
     112    saveQuestion(answer.question());
    110113
    111114    emit answerProvided(answer);
  • gateways/Schoolnet/src/business/deepthought/questionmanager.h

    r194 r217  
    2222#include <QObject>
    2323
    24 #include <ssingleton.h>
     24#include <smacros.h>
    2525
    2626#include "datatypes.h"
     
    3333class ProposedAnswer;
    3434
    35 class QuestionManagerPriv : public QObject, public SShareable {
     35class QuestionManager : public QObject {
    3636    Q_OBJECT
    37 
    38 public:
    39     QuestionManagerPriv();
     37    S_SINGLETON(QuestionManager)
    4038
    4139public:
    4240    QList<Question> questions();
    43     QList<Question> openQuestions(const BCAccount& account, const QStringList& acceptedLanguages);
     41    QList<Question> openQuestions(BCAccount* account, const QStringList& acceptedLanguages);
    4442
    4543    void            pushQuestionBack(const Question& question);
    46     void            saveQuestion(const Question& question);
    47     void            deleteQuestion(const Question& question);
     44    void            saveQuestion(Question question);
     45    void            deleteQuestion(Question question);
    4846
    49     bool            isQuestionAnsweredAtSchoolnet(const BCAccount& account, const Question& question) const;
    50     void            setQuestionAnsweredAtSchoolnet(const BCAccount& account, const Question& question) const;
     47    bool            isQuestionAnsweredAtSchoolnet(BCAccount* account, const Question& question) const;
     48    void            setQuestionAnsweredAtSchoolnet(BCAccount* account, const Question& question) const;
    5149
    52     void            provideAnswer(const Answer& answer, bool correct);
     50    void            provideAnswer(Answer answer, bool correct);
    5351
    5452signals:
     
    6361    QList<Question> questions_;
    6462};
    65 S_SINGLETON_QOBJ(QuestionManager)
    66 
    6763
    6864}
  • gateways/Schoolnet/src/library.cpp

    r194 r217  
    1616 along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 
    19 #include "main.h"
     18#include "library.h"
    2019
    2120#include <QCoreApplication>
    22 #include <QDebug>
    2321#include <QDir>
    2422
     
    3129namespace Schoolnet {
    3230
     31//S_SINGLETON_IMPL(Library)
     32Library* Library::instance_ = NULL;
     33Library* Library::instance() {
     34