Changeset 95:f799f4c2e48f in SMSSender


Ignore:
Timestamp:
Jul 7, 2010 12:41:47 PM (8 years ago)
Author:
Sämy Zehnder <saemy.zehnder@…>
Branch:
3.0
Convert:
svn:3639001d-8e34-449c-bb86-3782b86c4877/branches/3.0@98
Message:
  • Created interfaces for the BC*Manager classes and implemenented IManagerFactory to give the manager instances to the gateways. (The gateways have now access to the gateway list, the contacts, ...)
  • Extended ILibrary to allow exchange of contact importers.
  • Implemented the contact import from the Swisscom XtraZone? website.
  • In the old config files contact importer, contact files are now deselectable. The list can also be manualy extended.
  • Fixed the translation issue, that strings from the gateway SwisscomXtraZone? were not translated.
  • Fixed issue, that numbers, which were entered in the recipient edit were not resolved to a contact but the first (invisible) completion was taken.
Files:
18 added
4 deleted
47 edited

Legend:

Unmodified
Added
Removed
  • do_lupdate

    r92 r95  
    44
    55cd gateways/SwisscomXtraZone
    6 lupdate SwisscomXtraZone.pro
     6lupdate swisscomxtrazone.pro
    77cd ../../
    88
  • gateways/SwisscomXtraZone/lib/SwisscomXtraZone.qrc

    r89 r95  
    88    </qresource>
    99    <qresource prefix="/locale">
    10         <file>de.qm</file>
     10        <file>xtra-de.qm</file>
    1111    </qresource>
    1212</RCC>
  • gateways/SwisscomXtraZone/locale/de.ts

    r88 r95  
    55    <name>QObject</name>
    66    <message>
    7         <location filename="../src/business/BCAccount.cpp" line="46"/>
     7        <location filename="../src/business/bcaccount.cpp" line="45"/>
    88        <source>Doing anticaptcha</source>
    99        <translation>Erkenne Captcha</translation>
     10    </message>
     11    <message>
     12        <location filename="../src/business/contactimporter/bccontactimporter.cpp" line="39"/>
     13        <source>Import contacts from the swisscom xtrazone website.</source>
     14        <translation>Importiere Kontakte von der Swisscom XtraZone Webseite.</translation>
     15    </message>
     16    <message>
     17        <location filename="../src/business/contactimporter/bccontactimporter.cpp" line="41"/>
     18        <source>Import contacts from the swisscom xtrazone website. (No logged in accounts)</source>
     19        <translation>Importiere Kontakte von der Swisscom XtraZone Webseite. (Keine eingeloggten Konten vorhanden)</translation>
    1020    </message>
    1121</context>
     
    1323    <name>SwisscomXtraZone::BCAccount</name>
    1424    <message>
    15         <location filename="../src/business/BCAccount.cpp" line="157"/>
     25        <location filename="../src/business/bcaccount.cpp" line="148"/>
    1626        <source>Could not get the captcha token.</source>
    1727        <translation>Konnte das Captcha-Token nicht laden.</translation>
    1828    </message>
    1929    <message>
    20         <location filename="../src/business/BCAccount.cpp" line="328"/>
     30        <location filename="../src/business/bcaccount.cpp" line="186"/>
     31        <source>Starting login.</source>
     32        <translation>Starte login.</translation>
     33    </message>
     34    <message>
     35        <location filename="../src/business/bcaccount.cpp" line="200"/>
     36        <source>Finished login.</source>
     37        <translation>Login beendet.</translation>
     38    </message>
     39    <message>
     40        <location filename="../src/business/bcaccount.cpp" line="204"/>
     41        <source>Starting login via the customer center.</source>
     42        <translation>Starte Login via das Kundenzenter.</translation>
     43    </message>
     44    <message>
     45        <location filename="../src/business/bcaccount.cpp" line="227"/>
     46        <source>The login via the customer center succeeded.</source>
     47        <translation>Das Login via das Kundenzenter ist geglückt.</translation>
     48    </message>
     49    <message>
     50        <location filename="../src/business/bcaccount.cpp" line="230"/>
     51        <source>The login via the customer center failed.</source>
     52        <translation>Das Login via das Kundenzenter ist fehlgeschlagen.</translation>
     53    </message>
     54    <message>
     55        <location filename="../src/business/bcaccount.cpp" line="236"/>
     56        <source>Starting login via the XtraZone login form.</source>
     57        <translation>Starte Login via die XtraZone-Anmeldeoberfläche.</translation>
     58    </message>
     59    <message>
     60        <location filename="../src/business/bcaccount.cpp" line="357"/>
    2161        <source>Could not autodetect the captcha.</source>
    2262        <translation>Konnte das Captcha nicht automatisch erkennen.</translation>
    2363    </message>
    2464    <message>
    25         <location filename="../src/business/BCAccount.cpp" line="339"/>
     65        <location filename="../src/business/bcaccount.cpp" line="368"/>
    2666        <source>Anticaptcha check aborted by user.</source>
    2767        <translation>Die Anticaptcha-Eingabe wurde durch den Benutzer abgebrochen.</translation>
    2868    </message>
    2969    <message>
    30         <location filename="../src/business/BCAccount.cpp" line="378"/>
     70        <location filename="../src/business/bcaccount.cpp" line="395"/>
     71        <source>The login via the XtraZone login form succeeded.</source>
     72        <translation>Das Login via die XtraZone-Anmeldeoberfläche ist geglückt.</translation>
     73    </message>
     74    <message>
     75        <location filename="../src/business/bcaccount.cpp" line="408"/>
    3176        <source>Error during logout: </source>
    3277        <translation>Fehler wärend dem Abmeldevorgang: </translation>
    3378    </message>
    3479    <message>
    35         <location filename="../src/business/BCAccount.cpp" line="379"/>
    36         <location filename="../src/business/BCAccount.cpp" line="382"/>
     80        <location filename="../src/business/bcaccount.cpp" line="409"/>
     81        <location filename="../src/business/bcaccount.cpp" line="412"/>
    3782        <source>But ignoring it, since we clear the cookies and are therefore also logged out</source>
    3883        <translation>Der Fehler wird jedoch ignoriert, da wir die Cookies löschen und damit auch abgemeldet werden</translation>
    3984    </message>
    4085    <message>
    41         <location filename="../src/business/BCAccount.cpp" line="381"/>
     86        <location filename="../src/business/bcaccount.cpp" line="411"/>
    4287        <source>Error during logout: Unknown error</source>
    4388        <translation>Fehler wärend dem Abmeldevorgang: Unbekannter Fehler</translation>
    4489    </message>
    4590    <message>
    46         <location filename="../src/business/BCAccount.cpp" line="397"/>
     91        <location filename="../src/business/bcaccount.cpp" line="427"/>
    4792        <source>Error while checking if we are still logged in: </source>
    4893        <translation>Fehler wärend der Überprüfung, ob wir noch angemeldet sind: </translation>
    4994    </message>
    5095    <message>
    51         <location filename="../src/business/BCAccount.cpp" line="398"/>
     96        <location filename="../src/business/bcaccount.cpp" line="428"/>
    5297        <source>But ignoring it, since we just do a new login attempt.</source>
    5398        <translation>Der Fehler wird jedoch ignoriert, da wir einfach einen neuen Loginversuch starten.</translation>
    5499    </message>
    55100    <message>
    56         <location filename="../src/business/BCAccount.cpp" line="439"/>
     101        <location filename="../src/business/bcaccount.cpp" line="469"/>
    57102        <source>Could not get the longSMSLength!</source>
    58103        <translation>Konnte die Maximallänge der SMS nicht finden!</translation>
    59104    </message>
    60105    <message>
    61         <location filename="../src/business/BCAccount.cpp" line="447"/>
     106        <location filename="../src/business/bcaccount.cpp" line="477"/>
    62107        <source>Error while parsing the sms-page</source>
    63108        <translation>Fehler wärend dem Verarbeiten der SMS Seite</translation>
    64109    </message>
    65110    <message>
    66         <location filename="../src/business/BCAccount.cpp" line="505"/>
     111        <location filename="../src/business/bcaccount.cpp" line="535"/>
    67112        <source>Could not get the free sms count!</source>
    68113        <translation>Konnte die übrigen Gratis-SMS nicht finden!</translation>
    69114    </message>
    70115    <message>
    71         <location filename="../src/business/BCAccount.cpp" line="608"/>
     116        <location filename="../src/business/bcaccount.cpp" line="638"/>
    72117        <source>You have only %1 SMS for free but you need at least %2 SMS left to send this message.</source>
    73118        <translation>Du hast nur noch %1 Gratis-SMS, würdest aber %2 Gratis-SMS benötigen, um diese Mitteilung zu verschicken.</translation>
    74119    </message>
    75120    <message>
    76         <location filename="../src/business/BCAccount.cpp" line="654"/>
     121        <location filename="../src/business/bcaccount.cpp" line="684"/>
    77122        <source>The sending of the sms was requested to cancel, but (a part of) the sms has already been sent.</source>
    78123        <translation>Der SMS-Versandt sollte abgebrochen werden, ein Teil der SMS wurde zu diesem Zeitpunkt jedoch bereits versendet.</translation>
     
    82127    <name>SwisscomXtraZone::VCCaptchaDialog</name>
    83128    <message>
    84         <location filename="../src/main.cpp" line="49"/>
    85129        <location filename="../src/ui/vccaptchadialog.cpp" line="57"/>
    86130        <source>Error occured</source>
  • gateways/SwisscomXtraZone/src/business/bcaccount.cpp

    r92 r95  
    185185    haltIfCancelled();
    186186    qDebug() << tr("Starting login.");
    187 
    188     if (!_doLoginViaCustomerCenter()) {
     187    setStatus(LoginAccount::Action::LoggingIn);
     188
     189    bool succeeded;
     190    try {
     191        succeeded = _doLoginViaCustomerCenter();
     192    } catch (...) {
     193        succeeded = false;
     194    }
     195
     196    if (!succeeded) {
    189197        _doLoginViaXtraZoneLoginForm();
    190198    }
     
    195203    haltIfCancelled();
    196204    qDebug() << tr("Starting login via the customer center.");
    197 
    198     setStatus(LoginAccount::Action::LoggingIn);
    199205
    200206    QMap<QString, QString> params;
     
    213219    rx.setCaseSensitivity(Qt::CaseInsensitive);
    214220    if (rx.indexIn(html) != -1) {
    215         QString error = rx.cap(1);
    216         error.replace("&uuml;", QString::fromUtf8("ü"));
     221        QString error = SHttpHelper::unescapeString(rx.cap(1));
    217222        EException(error).raise();
    218223    }
     
    323328*/
    324329
    325     setStatus(LoginAccount::Action::LoggingIn);
    326 
    327330    QString lastCaptchaError;
    328331    int anticaptchaTryCount = 0;
     
    378381        }
    379382
    380         lastCaptchaError = rx.cap(1);
    381         lastCaptchaError.replace("&uuml;", QString::fromUtf8("ü"));
     383        lastCaptchaError = SHttpHelper::unescapeString(rx.cap(1));
    382384    }
    383385
  • gateways/SwisscomXtraZone/src/business/bcaccount.h

    r92 r95  
    3030class BCAccount: public AbstractLoginAccount {
    3131    Q_OBJECT
     32
     33friend class BCContactImporter;
    3234
    3335public:
  • gateways/SwisscomXtraZone/src/main.cpp

    r92 r95  
    2020#include <QCoreApplication>
    2121#include <QDebug>
     22#include <QDir>
    2223
     24#include "business/contactimporter/bccontactimporter.h"
    2325#include "business/bcgateway.h"
     26
     27inline void initResource() { Q_INIT_RESOURCE(SwisscomXtraZone); }
    2428
    2529namespace SwisscomXtraZone {
     
    2832ILibrary* Library::instance() {
    2933    return instance_ ? instance_ : (instance_ = new Library);
     34}
     35
     36Library::Library()
     37    : managerFactory_(NULL)
     38{}
     39Library::~Library() {
     40    foreach (IContactImporter* importer, contactImporters_) {
     41        delete importer;
     42    }
     43}
     44
     45
     46
     47void Library::init(IManagerFactory* managerFactory) {
     48    managerFactory_ = managerFactory;
     49
     50    contactImporters_.clear();
     51    contactImporters_.insert(new BCContactImporter(managerFactory_));
    3052}
    3153
     
    4668    QTranslator* t = new QTranslator();
    4769    qDebug() << l.name();
    48     t->load(l.name(), ":/locale");
     70    t->load("xtra-" + l.name(), ":/locale");
    4971    result.insert(t);
    5072
     
    5678}
    5779
     80QSet<IContactImporter*> Library::getContactImporters() const {
     81    return contactImporters_;
     82}
     83
    5884}
    5985
  • gateways/SwisscomXtraZone/src/main.h

    r92 r95  
    3535public:
    3636    /* ILibrary */
    37     QString            identificationKey() const;
    38     SVersion           version() const;
    39     int                compatibilityVersion() const;
     37    void                    init(IManagerFactory* managerFactory);
    4038
    41     QSet<QTranslator*> getTranslators() const;
    42     IGateway*          getGateway() const;
     39    QString                 identificationKey() const;
     40    SVersion                version() const;
     41    int                     compatibilityVersion() const;
     42
     43    QSet<QTranslator*>      getTranslators() const;
     44    IGateway*               getGateway() const;
     45    QSet<IContactImporter*> getContactImporters() const;
    4346
    4447private:
    45     Library() {};
     48    Library();
     49    ~Library();
     50    Q_DISABLE_COPY(Library);
    4651
    4752private:
    4853    static ILibrary* instance_;
     54    IManagerFactory* managerFactory_;
    4955
    50     Q_DISABLE_COPY(Library);
     56    QSet<IContactImporter*> contactImporters_;
    5157};
    5258
  • gateways/SwisscomXtraZone/swisscomxtrazone.pro

    r94 r95  
    1 VERSION = 1.0.0.2
     1VERSION = 1.0.0.3
    22DEFINES += LIB_VERSION=\\\"$$VERSION\\\"
    33TEMPLATE = lib
     
    1717LIBS += -ldatatypes \
    1818    -lutils
    19    
    2019INCLUDEPATH += src/ \
    2120    ../../lib/libdatatypes/src/interfaces \
     
    2322    ../../lib/libdatatypes/src \
    2423    ../../lib/libutils/src/
    25 HEADERS += src/business/validation/bcaccountvalidator.h \
     24HEADERS += src/business/contactimporter/bccontactimporter.h \
     25    src/business/validation/bcaccountvalidator.h \
    2626    src/business/bcaccount.h \
    2727    src/business/bcgateway.h \
     
    3131    src/ui/vcsettingswidget.h \
    3232    src/main.h
    33 SOURCES += src/business/validation/bcaccountvalidator.cpp \
     33SOURCES += src/business/contactimporter/bccontactimporter.cpp \
     34    src/business/validation/bcaccountvalidator.cpp \
    3435    src/business/bcaccount.cpp \
    3536    src/business/bcgateway.cpp \
     
    4344RESOURCES += lib/SwisscomXtraZone.qrc
    4445TRANSLATIONS += locale/de.ts
    45 unix {
     46unix { 
    4647    target.path = /usr/lib/smssender/gateways
    4748    INSTALLS += target
  • lib/libdatatypes/libdatatypes.pro

    r94 r95  
    4949    src/abstract/persistence/abstractloginaccountstorageofficer.h \
    5050    src/abstract/persistence/abstractstorageofficer.h \
     51    src/eventmappers/eventinterfaces.h \
     52    src/eventmappers/saccounteventmapper.h \
     53    src/eventmappers/scontacteventmapper.h \
     54    src/eventmappers/sgroupeventmapper.h \
     55    src/eventmappers/sloginaccounteventmapper.h \
     56    src/eventmappers/managereventinterfaces.h \
     57    src/eventmappers/managereventmappers.h \
    5158    src/exceptions/eexception.h \
    5259    src/exceptions/elibraryloadexception.h \
     
    6673    src/interfaces/ilibrary.h \
    6774    src/interfaces/ilibraryloader.h \
     75    src/interfaces/imanagers.h \
    6876    src/interfaces/istorable.h \
    6977    src/interfaces/istreamable.h \
    7078    src/interfaces/ivalidatable.h \
    7179    src/interfaces/ivalidator.h \
    72     src/interfaces/persistence/iaccountmanager.h \
    73     src/interfaces/persistence/icontactmanager.h \
    74     src/interfaces/persistence/igroupmanager.h \
     80    src/interfaces/persistence/iaccountstoragemanager.h \
     81    src/interfaces/persistence/icontactstoragemanager.h \
     82    src/interfaces/persistence/igroupstoragemanager.h \
    7583    src/interfaces/persistence/isettings.h \
    7684    src/interfaces/persistence/istorage.h \
    7785    src/interfaces/persistence/istorageofficer.h \
    78     src/eventmappers/eventinterfaces.h \
    79     src/eventmappers/saccounteventmapper.h \
    80     src/eventmappers/scontacteventmapper.h \
    81     src/eventmappers/sgroupeventmapper.h \
    82     src/eventmappers/sloginaccounteventmapper.h \
    8386    src/ui/iaccountsettingswidget.h \
    8487    src/validation/sloginaccountvalidator.h \
     
    9093    src/shttpcookiemanager.cpp \
    9194    src/shttphelper.cpp \
     95    src/shttphelper_escapechars.cpp \
    9296    src/snumber.cpp \
    9397    src/sversion.cpp \
     
    100104    src/abstract/persistence/abstractstorageofficer.cpp \
    101105    src/eventmappers/saccounteventmapper.cpp \
     106    src/eventmappers/managereventmappers.cpp \
    102107    src/exceptions/eexception.cpp \
    103108    src/exceptions/persistence/estoragewriteexception.cpp \
  • lib/libdatatypes/src/interfaces/icontactimporter.h

    r94 r95  
    3232    virtual bool    isApplicable() const =0;
    3333
     34    virtual void    init() =0;
     35
    3436    virtual QList<QWizardPage*> getPreImportPages() =0;
    3537
  • lib/libdatatypes/src/interfaces/ilibrary.h

    r92 r95  
    2727#include "sversion.h"
    2828
     29#include "icontactimporter.h"
     30#include "igateway.h"
    2931#include "iinterface.h"
    30 #include "igateway.h"
     32#include "imanagers.h"
    3133
    3234class ILibrary: public IInterface {
     
    3739
    3840public:
    39     virtual QString            identificationKey() const =0;
    40     virtual SVersion           version() const =0;
    41     virtual int                compatibilityVersion() const =0; // To prevent loading of too old/new libraries
     41    virtual void                    init(IManagerFactory* managerFactory) =0;
    4242
    43     virtual QSet<QTranslator*> getTranslators() const =0;
    44     virtual IGateway*          getGateway() const =0;
     43    virtual QString                 identificationKey() const =0;
     44    virtual SVersion                version() const =0;
     45    virtual int                     compatibilityVersion() const =0; // To prevent loading of too old/new libraries
     46
     47    virtual QSet<QTranslator*>      getTranslators() const =0;
     48    virtual IGateway*               getGateway() const =0;
     49    virtual QSet<IContactImporter*> getContactImporters() const =0;
    4550};
    46 
    4751Q_DECLARE_INTERFACE(ILibrary,
    4852                     "ch.gorrion.smssender.ILibrary/1.0")
  • lib/libdatatypes/src/shttphelper.cpp

    r92 r95  
    9191}
    9292
    93 QString SHttpHelper::syncGet(const QString& destination, const QMap<QString, QString>& requests) {
     93QByteArray SHttpHelper::syncGet(const QString& destination, const QMap<QString, QString>& requests) {
    9494    asyncGet(destination, requests);
    9595    waitForRequest();
     
    106106}
    107107
    108 QString SHttpHelper::syncPost(const QString& destination, const QMap<QString, QString>& posts,
     108QByteArray SHttpHelper::syncPost(const QString& destination, const QMap<QString, QString>& posts,
    109109        const QMap<QString, QString>& requests)
    110110{
     
    223223    requestLoop_.exec(QEventLoop::AllEvents|QEventLoop::WaitForMoreEvents);
    224224
    225     //requestLoop_.exec(QEventLoop::WaitForMoreEvents/*QEventLoop::ExcludeUserInputEvents|QEventLoop::ExcludeSocketNotifiers|QEventLoop::WaitForMoreEvents*/);
    226225    qDebug() << "The request finished -> continuing";
    227226}
     
    291290     request_.finished = true;
    292291     if (error) {
    293          errorOccured(httpRequestId, Http::EReadException(http_->errorString()));
     292         QString error = http_->errorString();
     293         errorOccured(httpRequestId, Http::EReadException(unescapeString(error)));
    294294     } else {
    295295         qDebug() << "Request [" + QString::number(httpRequestId) + "] finished";
  • lib/libdatatypes/src/shttphelper.h

    r92 r95  
    5656    SHttpCookieManager*        cookieManager() const;
    5757
    58     QString                    syncGet(const QString& destination, const QMap<QString, QString>& requests = (QMap<QString, QString>()));
     58    QByteArray                 syncGet(const QString& destination, const QMap<QString, QString>& requests = (QMap<QString, QString>()));
    5959    void                       asyncGet(const QString& destination, const QMap<QString, QString>& requests = (QMap<QString, QString>()));
    60     QString                    syncPost(const QString& destination, const QMap<QString, QString>& posts = (QMap<QString, QString>()), const QMap<QString, QString>& requests = (QMap<QString, QString>()));
     60    QByteArray                 syncPost(const QString& destination, const QMap<QString, QString>& posts = (QMap<QString, QString>()), const QMap<QString, QString>& requests = (QMap<QString, QString>()));
    6161    void                       asyncPost(const QString& destination, const QMap<QString, QString>& posts = (QMap<QString, QString>()), const QMap<QString, QString>& requests = (QMap<QString, QString>()));
    6262
     
    6868    QSslSocket*                httpSocket() const;
    6969
     70    static QString             unescapeString(const QString& str);
     71
    7072signals:
    7173    void                       errorOccured(const EException& e);
     
    7476protected:
    7577    virtual QHttpRequestHeader defaultHeader(const QUrl& url) const;
     78
     79private:
     80    QString getParamStr(const QMap<QString, QString>& params);
     81    void    startRequest(const QString& method, const QString& destination, const QMap<QString, QString>& requests = (QMap<QString, QString>()), const QMap<QString, QString>& posts = (QMap<QString, QString>()));
     82    int     doRequest(const QString& destination);
     83    void    waitForRequest(bool createIfNotExisting = true);
     84
     85    void    errorOccured(int requestId, const EException& exception);
     86
     87    static void fillEscapeChars();
     88    static QMap<QString, QString> escapeChars();
    7689
    7790private:
     
    89102    QSslSocket*         sslSocket_;
    90103
    91     QString getParamStr(const QMap<QString, QString>& params);
    92     void    startRequest(const QString& method, const QString& destination, const QMap<QString, QString>& requests = (QMap<QString, QString>()), const QMap<QString, QString>& posts = (QMap<QString, QString>()));
    93     int     doRequest(const QString& destination);
    94     void    waitForRequest(bool createIfNotExisting = true);
    95 
    96     void    errorOccured(int requestId, const EException& exception);
     104    static QMap<QString, QString> escapeChars_;
    97105
    98106private slots:
  • locale/de.ts

    r94 r95  
    7272</context>
    7373<context>
     74    <name>ContactFilesModel</name>
     75    <message>
     76        <location filename="../src/ui/vcoldsettingscontactimporter/contactfilesmodel.cpp" line="32"/>
     77        <source>Import</source>
     78        <translation>Importieren</translation>
     79    </message>
     80    <message>
     81        <location filename="../src/ui/vcoldsettingscontactimporter/contactfilesmodel.cpp" line="33"/>
     82        <source>Filename</source>
     83        <translation>Dateiname</translation>
     84    </message>
     85</context>
     86<context>
    7487    <name>ContactTableModel</name>
    7588    <message>
     
    173186    </message>
    174187    <message>
    175         <location filename="../src/persistence/storage/dastorage.cpp" line="392"/>
    176         <location filename="../src/persistence/storage/dastorage.cpp" line="403"/>
    177         <location filename="../src/persistence/storage/dastorage.cpp" line="418"/>
     188        <location filename="../src/persistence/storage/dastorage.cpp" line="400"/>
     189        <location filename="../src/persistence/storage/dastorage.cpp" line="411"/>
     190        <location filename="../src/persistence/storage/dastorage.cpp" line="426"/>
    178191        <source>The group could not have been written to the database.</source>
    179192        <translation>Die Gruppe konnte nicht in die Datenbank geschrieben werden.</translation>
    180193    </message>
    181194    <message>
    182         <location filename="../src/persistence/storage/dastorage.cpp" line="450"/>
     195        <location filename="../src/persistence/storage/dastorage.cpp" line="458"/>
    183196        <source>Could not remove the setting from the database.</source>
    184197        <translation>Konnte eine Einstellung nicht aus der Datenbank entfernen.</translation>
    185198    </message>
    186199    <message>
    187         <location filename="../src/persistence/storage/dastorage.cpp" line="463"/>
     200        <location filename="../src/persistence/storage/dastorage.cpp" line="471"/>
    188201        <source>Could not remove the settings from the database.</source>
    189202        <translation>Konnte die Einstellungen nicht aus der Datenbank entfernen.</translation>
    190203    </message>
    191204    <message>
    192         <location filename="../src/persistence/storage/dastorage.cpp" line="484"/>
     205        <location filename="../src/persistence/storage/dastorage.cpp" line="492"/>
    193206        <source>Could not remove the contact from the database</source>
    194207        <translation>Konnte den Kontakt nicht aus der Datenbank entfernen</translation>
    195208    </message>
    196209    <message>
    197         <location filename="../src/persistence/storage/dastorage.cpp" line="504"/>
     210        <location filename="../src/persistence/storage/dastorage.cpp" line="512"/>
    198211        <source>Could not remove the group from the database</source>
    199212        <translation>Konnte die Gruppe nicht aus der Datenbank entfernen</translation>
     
    211224        <source>Members</source>
    212225        <translation>Mitglieder</translation>
     226    </message>
     227</context>
     228<context>
     229    <name>PageConfig</name>
     230    <message>
     231        <location filename="../src/ui/vcoldsettingscontactimporter/page_config.cpp" line="42"/>
     232        <source>Select the contacts file</source>
     233        <translation>Wähle die Kontaktdatei</translation>
     234    </message>
     235</context>
     236<context>
     237    <name>PageConfigClass</name>
     238    <message>
     239        <location filename="../src/ui/vcoldsettingscontactimporter/page_config.ui" line="14"/>
     240        <source>PageConfig</source>
     241        <translation>PageConfig</translation>
     242    </message>
     243    <message>
     244        <location filename="../src/ui/vcoldsettingscontactimporter/page_config.ui" line="20"/>
     245        <source>Please select the contact files from where the contacts should be imported. If you wish to import from a settings file which is not listed, you can manually add it to the list.</source>
     246        <translation>Wähle die Kontaktdateien von welchen importiert werden soll. Sollte deine Kontaktdatei nicht aufgeführt sein, kannst du sie manuell zur Liste hinzufügen.</translation>
    213247    </message>
    214248</context>
     
    318352    </message>
    319353    <message>
    320         <location filename="../src/business/bcoldsettingscontactimporter.cpp" line="28"/>
     354        <location filename="../src/business/bcoldsettingscontactimporter.cpp" line="37"/>
    321355        <source>Import contacts from older versions of smssender.</source>
    322356        <translation>Importiere Kontakte von älteren SMSSender-Versionen.</translation>
     
    326360    <name>SHttpHelper</name>
    327361    <message>
    328         <location filename="../lib/libdatatypes/src/shttphelper.cpp" line="279"/>
     362        <location filename="../lib/libdatatypes/src/shttphelper.cpp" line="278"/>
    329363        <source>Unknown response code: %1</source>
    330364        <translation>Unbekannter Antwort-Code: %1</translation>
     
    823857        <location filename="../src/ui/vcimportcontacts/vcimportcontacts_page_editcontacts.ui" line="20"/>
    824858        <source>The import of your contacts has been done. Please review them and, if needed, fix some merge errors.</source>
    825         <translation>Der Kontakt-Import wurde abgeschlossen. Bitte überprüfe die Kontaktdaten und, wenn nötig, behebe allfällige Fehler.</translation>
     859        <translation>Der Kontakt-Import wurde abgeschlossen. Bitte überprüfe die Kontaktdaten und, sofern nötig, behebe allfällige Fehler.</translation>
    826860    </message>
    827861    <message>
     
    888922    <name>VCMain</name>
    889923    <message>
    890         <location filename="../src/ui/vcmain/vcmain.cpp" line="392"/>
     924        <location filename="../src/ui/vcmain/vcmain.cpp" line="395"/>
    891925        <source>SMSSender</source>
    892926        <translation>SMSSender</translation>
    893927    </message>
    894928    <message>
    895         <location filename="../src/ui/vcmain/vcmain.cpp" line="393"/>
     929        <location filename="../src/ui/vcmain/vcmain.cpp" line="396"/>
    896930        <source>This number is not yet in your address book. Do you want to add it?</source>
    897931        <translation>Diese Nummer ist noch nicht im Adressbuch eingetragen. Willst du sie hinzufügen?</translation>
    898932    </message>
    899933    <message>
    900         <location filename="../src/ui/vcmain/vcmain.cpp" line="489"/>
     934        <location filename="../src/ui/vcmain/vcmain.cpp" line="492"/>
    901935        <source>%1 SMS</source>
    902936        <translation>%1 SMS</translation>
    903937    </message>
    904938    <message>
    905         <location filename="../src/ui/vcmain/vcmain.cpp" line="566"/>
    906         <location filename="../src/ui/vcmain/vcmain.cpp" line="580"/>
    907         <location filename="../src/ui/vcmain/vcmain.cpp" line="615"/>
     939        <location filename="../src/ui/vcmain/vcmain.cpp" line="569"/>
     940        <location filename="../src/ui/vcmain/vcmain.cpp" line="583"/>
     941        <location filename="../src/ui/vcmain/vcmain.cpp" line="618"/>
    908942        <source>Error occured</source>
    909943        <translation>Fehler aufgetreten</translation>
    910944    </message>
    911945    <message>
    912         <location filename="../src/ui/vcmain/vcmain.cpp" line="567"/>
     946        <location filename="../src/ui/vcmain/vcmain.cpp" line="570"/>
    913947        <source>An error occured while initializing the account &quot;%1&quot;:</source>
    914948        <translation>Ein Fehler trat wärend dem Initialisieren des Kontos &quot;%1&quot; auf:</translation>
    915949    </message>
    916950    <message>
    917         <location filename="../src/ui/vcmain/vcmain.cpp" line="576"/>
     951        <location filename="../src/ui/vcmain/vcmain.cpp" line="579"/>
    918952        <source>Errors occured while loading your accounts.</source>
    919953        <translation>Beim Laden der Konten trat ein Fehler auf.</translation>
    920954    </message>
    921955    <message>
    922         <location filename="../src/ui/vcmain/vcmain.cpp" line="598"/>
     956        <location filename="../src/ui/vcmain/vcmain.cpp" line="601"/>
    923957        <source>SMS sent</source>
    924958        <translation>SMS gesendet</translation>
    925959    </message>
    926960    <message>
    927         <location filename="../src/ui/vcmain/vcmain.cpp" line="599"/>
     961        <location filename="../src/ui/vcmain/vcmain.cpp" line="602"/>
    928962        <source>The sms has been sent.</source>
    929963        <translation>Die SMS wurde vesendet.</translation>
    930964    </message>
    931965    <message>
    932         <location filename="../src/ui/vcmain/vcmain.cpp" line="614"/>
     966        <location filename="../src/ui/vcmain/vcmain.cpp" line="617"/>
    933967        <source>Error occured while sending the sms.</source>
    934968        <translation>Ein Fehler trat wärend dem Senden der SMS auf.</translation>
  • smssender.pro

    r94 r95  
    1 VERSION = 3.0.0.3
     1VERSION = 3.0.0.4
    22DEFINES += APP_VERSION=\\\"$$VERSION\\\"
    33CONFIG += qt \
     
    2929    src/business/bcgroupmanager.h \
    3030    src/business/bclibraryloader.h \
     31    src/business/bcmanagerfactory.h \
    3132    src/business/bcoldsettingscontactimporter.h \
    3233    src/business/bcsettings.h \
     
    6566    src/ui/vcimportcontacts/vcimportcontacts_page_intro.h \
    6667    src/ui/vcmain/vcmain.h \
     68    src/ui/vcoldsettingscontactimporter/contactfilesmodel.h \
     69    src/ui/vcoldsettingscontactimporter/page_config.h \
    6770    src/ui/vcsendingdialog/vcsendingdialog.h \
    6871    src/ui/vcsettings/vcsettings.h \
     
    7578    src/business/bcgroupmanager.cpp \
    7679    src/business/bclibraryloader.cpp \
     80    src/business/bcmanagerfactory.cpp \
    7781    src/business/bcoldsettingscontactimporter.cpp \
    7882    src/business/bcsettings.cpp \
     
    112116    src/ui/vcimportcontacts/vcimportcontacts_page_intro.cpp \
    113117    src/ui/vcmain/vcmain.cpp \
     118    src/ui/vcoldsettingscontactimporter/contactfilesmodel.cpp \
     119    src/ui/vcoldsettingscontactimporter/page_config.cpp \
    114120    src/ui/vcsendingdialog/vcsendingdialog.cpp \
    115121    src/ui/vcsettings/vcsettings.cpp \
     
    127133    src/ui/vcimportcontacts/vcimportcontacts_page_intro.ui \
    128134    src/ui/vcmain/vcmain.ui \
     135    src/ui/vcoldsettingscontactimporter/page_config.ui \
    129136    src/ui/vcsendingdialog/vcsendingdialog.ui \
    130137    src/ui/vcsettings/vcsettings.ui
  • src/business/bcaccountinitmanager.cpp

    r92 r95  
    2727    return instance_ ? instance_ : (instance_ = new BCAccountInitManager);
    2828}
     29
     30BCAccountInitManager::BCAccountInitManager() {
     31    eventMapper_ = new SAccountInitManagerEventMapper();
     32}
     33BCAccountInitManager::~BCAccountInitManager() {
     34    delete eventMapper_;
     35}
     36
    2937
    3038void BCAccountInitManager::initAccount(IAccount* account) {
     
    5765    Q_ASSERT(account);
    5866
    59     emit accountInitStateChanged(account);
     67    emit accountEvents()->accountInitStateChanged(account);
    6068}
    6169void BCAccountInitManager::accountInitDone(Account::InitializationResult result) {
     
    6775    disconnect(account->eventMapper(), 0, this, 0);
    6876
    69     emit accountInitDone(account, result);
     77    emit accountEvents()->accountInitDone(account, result);
    7078}
    7179void BCAccountInitManager::accountInitFailed(const EException& exception) {
     
    7583    Q_ASSERT(account);
    7684
    77     emit accountInitFailed(account, exception);
     85    emit accountEvents()->accountInitFailed(account, exception);
    7886}
     87
     88
     89SAccountInitManagerEventMapper* BCAccountInitManager::eventMapper() const {
     90    return eventMapper_;
     91}
     92IAccountInitManagerEvents* BCAccountInitManager::accountEvents() const {
     93    return static_cast<IAccountInitManagerEvents*>(eventMapper());
     94}
     95
  • src/business/bcaccountinitmanager.h

    r92 r95  
    2525#include <stdexceptions.h>
    2626
    27 class BCAccountInitManager : public QObject {
     27#include <imanagers.h>
     28
     29class BCAccountInitManager : public QObject, public IAccountInitManager {
    2830    Q_OBJECT
     31    Q_INTERFACES(IAccountInitManager)
    2932
    3033public:
    31     static BCAccountInitManager* instance();
     34    static BCAccountInitManager*    instance();
     35    SAccountInitManagerEventMapper* eventMapper() const;
    3236
    3337    void initAccount(IAccount* account);
     
    3640    void initAccounts(const QSet<IAccount*>& accounts);
    3741
    38 signals:
    39     void accountInitStateChanged(IAccount* account);
    40     void accountInitialized(IAccount* account);
    41     void accountInitDone(IAccount* account, Account::InitializationResult result);
    42     void accountInitFailed(IAccount* account, const EException& exception);
     42private:
     43    BCAccountInitManager();
     44    virtual ~BCAccountInitManager();
     45    Q_DISABLE_COPY(BCAccountInitManager);
    4346
    44 private:
    45     BCAccountInitManager(){}
    46     virtual ~BCAccountInitManager() {};
     47    IAccountInitManagerEvents* accountEvents() const;
    4748
    4849private:
    4950    static BCAccountInitManager* instance_;
    50 
    51     Q_DISABLE_COPY(BCAccountInitManager);
     51    SAccountInitManagerEventMapper* eventMapper_;
    5252
    5353private slots:
  • src/business/bcaccountmanager.cpp

    r92 r95  
    2727}
    2828
     29BCAccountManager::BCAccountManager() {
     30    eventMapper_ = new SAccountManagerEventMapper();
     31}
     32BCAccountManager::~BCAccountManager() {
     33    delete eventMapper_;
     34}
     35
     36
    2937void BCAccountManager::addAccountToList(IAccount* account) {
    3038    if ((account == NULL) || accountList_.contains(account->id()))
     
    4048            this, SLOT(accountInitStateChanged()));
    4149
    42     emit accountAdded(account);
     50    emit accountEvents()->accountAdded(account);
    4351
    4452    // Init the newly added account
     
    5664
    5765    accountList_.remove(account->id());
    58     emit accountRemoved(account);
     66    emit accountEvents()->accountRemoved(account);
    5967}
    6068
     
    122130    IAccount* account = em->account();
    123131    Q_ASSERT(account);
    124     emit accountDataChanged(account, property);
     132    emit accountEvents()->accountDataChanged(account, property);
    125133
    126134    // If the account has been en-/disabled just reset the initialization
     
    141149    IAccount* account = em->account();
    142150    Q_ASSERT(account);
    143     emit accountInitStateChanged(account);
     151    emit accountEvents()->accountInitStateChanged(account);
    144152}
     153
     154
     155
     156SAccountManagerEventMapper* BCAccountManager::eventMapper() const {
     157    return eventMapper_;
     158}
     159IAccountManagerEvents* BCAccountManager::accountEvents() const {
     160    return static_cast<IAccountManagerEvents*>(eventMapper());
     161}
  • src/business/bcaccountmanager.h

    r92 r95  
    2828#include <eexception.h>
    2929
     30#include <imanagers.h>
     31
    3032#include "bcaccountinitmanager.h"
    3133
    32 class BCAccountManager: public QObject {
     34class BCAccountManager: public QObject, public IAccountManager {
    3335    Q_OBJECT
     36    Q_INTERFACES(IAccountManager)
    3437
    3538public:
    36     static BCAccountManager*   instance();
     39    static BCAccountManager*    instance();
     40    SAccountManagerEventMapper* eventMapper() const;
    3741
    3842    QHash<SDummyAccount*, EException> readAccountsFromStorage();
     
    4549    void                       removeAccount(int accountId);
    4650
    47 signals:
    48     void                       accountAdded(IAccount* account);
    49     void                       accountDataChanged(IAccount* account, int property);
    50     void                       accountRemoved(IAccount* account);
    51     void                       accountInitStateChanged(IAccount* account);
     51private:
     52    BCAccountManager();
     53    ~BCAccountManager();
     54    Q_DISABLE_COPY(BCAccountManager);
    5255
    53 private:
    54     BCAccountManager() {};
    55     Q_DISABLE_COPY(BCAccountManager);
     56    IAccountManagerEvents*     accountEvents() const;
    5657
    5758    void                       addAccountToList(IAccount* account);
     
    5960
    6061private:
    61     static BCAccountManager* instance_;
     62    static BCAccountManager*    instance_;
     63    SAccountManagerEventMapper* eventMapper_;
    6264
    6365    QMap<int, IAccount*> accountList_;
  • src/business/bccontactimportermanager.cpp

    r94 r95  
    3131
    3232void BCContactImporterManager::registerContactImporter(IContactImporter* importer) {
    33     importers_.insert(importer);
     33    if (importers_.contains(importer)) return;
     34    importers_.append(importer);
    3435}
    3536
    3637void BCContactImporterManager::unregisterContactImporter(IContactImporter* importer) {
    37     importers_.remove(importer);
     38    importers_.removeAll(importer);
    3839}
    3940
    40 QSet<IContactImporter*> BCContactImporterManager::contactImporters() const {
     41QList<IContactImporter*> BCContactImporterManager::contactImporters() const {
    4142    return importers_;
    4243}
  • src/business/bccontactimportermanager.h

    r94 r95  
    2121
    2222#include <QtGlobal>
    23 #include <QSet>
     23#include <QList>
    2424
    2525#include <icontactimporter.h>
     
    3232    void unregisterContactImporter(IContactImporter* importer);
    3333
    34     QSet<IContactImporter*> contactImporters() const;
     34    QList<IContactImporter*> contactImporters() const;
    3535
    3636private:
     
    4141    static BCContactImporterManager* instance_;
    4242
    43     QSet<IContactImporter*> importers_;
     43    QList<IContactImporter*> importers_;
    4444};
    4545
  • src/business/bccontactmanager.cpp

    r92 r95  
    2626
    2727BCContactManager::BCContactManager(){
     28    eventMapper_ = new SContactManagerEventMapper();
    2829    readContactsFromStorage();
     30}
     31BCContactManager::~BCContactManager() {
     32    delete eventMapper_;
    2933}
    3034
     
    4246            this, SLOT(contactDataChanged()));
    4347
    44     emit contactAdded(contact);
     48    emit contactEvents()->contactAdded(contact);
    4549}
    4650
     
    5357
    5458    contactList_.remove(contact->id());
    55     emit contactRemoved(contact);
     59    emit contactEvents()->contactRemoved(contact);
    5660}
    5761
     
    118122void BCContactManager::contactDataChanged() {
    119123    SContact* contact = static_cast<SContactEventMapper*>(sender())->contact();
    120     emit contactUpdated(contact);
     124    emit contactEvents()->contactUpdated(contact);
    121125}
     126
     127
     128
     129SContactManagerEventMapper* BCContactManager::eventMapper() const {
     130    return eventMapper_;
     131}
     132IContactManagerEvents* BCContactManager::contactEvents() const {
     133    return static_cast<IContactManagerEvents*>(eventMapper());
     134}
     135
  • src/business/bccontactmanager.h

    r92 r95  
    2323#include <QSet>
    2424
     25#include <imanagers.h>
     26
    2527#include <scontact.h>
    2628#include <snumber.h>
    2729
    28 class BCContactManager: public QObject {
     30class BCContactManager: public QObject, public IContactManager {
    2931    Q_OBJECT
     32    Q_INTERFACES(IContactManager)
    3033
    3134public:
    32     static BCContactManager* instance();
     35    static BCContactManager*    instance();
     36    SContactManagerEventMapper* eventMapper() const;
    3337
    3438    SContact*        getContact(int contactId) const;
     
    4044    SContact*        getContactByNumber(const SNumber& number) const;
    4145
    42 signals:
    43     void             contactAdded(SContact* contact);
    44     void             contactUpdated(SContact* contact);
    45     void             contactRemoved(SContact* contact);
    46 
    4746private:
    4847    BCContactManager();
     48    ~BCContactManager();
    4949    Q_DISABLE_COPY(BCContactManager);
     50
     51    IContactManagerEvents* contactEvents() const;
    5052
    5153    void             readContactsFromStorage();
     
    5456
    5557private:
    56     static BCContactManager* instance_;
     58    static BCContactManager*    instance_;
     59    SContactManagerEventMapper* eventMapper_;
    5760
    5861    QMap<int, SContact*>     contactList_;
  • src/business/bcgatewaymanager.h

    r92 r95  
    2424
    2525#include <igateway.h>
     26#include <imanagers.h>
    2627
    27 class BCGatewayManager {
     28class BCGatewayManager : public IGatewayManager {
     29    Q_INTERFACES(IGatewayManager)
     30
    2831public:
    2932    static BCGatewayManager* instance();
  • src/business/bcgroupmanager.cpp

    r92 r95  
    2626
    2727BCGroupManager::BCGroupManager(){
     28    eventMapper_ = new SGroupManagerEventMapper();
    2829    readGroupsFromStorage();
    2930}
     31BCGroupManager::~BCGroupManager() {
     32    delete eventMapper_;
     33}
     34
    3035
    3136void BCGroupManager::addGroupToList(SGroup* group) {
     
    4247            this, SLOT(groupDataChanged()));
    4348
    44     emit groupAdded(group);
     49    emit groupEvents()->groupAdded(group);
    4550}
    4651
     
    5358
    5459    groupList_.remove(group->id());
    55     emit groupRemoved(group);
     60    emit groupEvents()->groupRemoved(group);
    5661}
    5762
     
    106111void BCGroupManager::groupDataChanged() {
    107112    SGroup* group = static_cast<SGroupEventMapper*>(sender())->group();
    108     emit groupUpdated(group);
     113    emit groupEvents()->groupUpdated(group);
    109114}
     115
     116
     117SGroupManagerEventMapper* BCGroupManager::eventMapper() const {
     118    return eventMapper_;
     119}
     120IGroupManagerEvents* BCGroupManager::groupEvents() const {
     121    return static_cast<IGroupManagerEvents*>(eventMapper());
     122}
  • src/business/bcgroupmanager.h

    r92 r95  
    2323#include <QSet>
    2424
     25#include <imanagers.h>
     26
    2527#include <sgroup.h>
    2628
    27 class BCGroupManager: public QObject {
     29class BCGroupManager: public QObject, public IGroupManager {
    2830    Q_OBJECT
     31    Q_INTERFACES(IGroupManager)
    2932
    3033public:
    31     static BCGroupManager* instance();
     34    static BCGroupManager*    instance();
     35    SGroupManagerEventMapper* eventMapper() const;
    3236
    3337    SGroup*               getGroup(int groupId);
     
    3741    bool                  hasGroup(int groupId) const;
    3842
    39 signals:
    40     void                  groupAdded(SGroup* group);
    41     void                  groupUpdated(SGroup* group);
    42     void                  groupRemoved(SGroup* group);
    43 
    4443private:
    4544    BCGroupManager();
     45    ~BCGroupManager();
    4646    Q_DISABLE_COPY(BCGroupManager);
     47
     48    IGroupManagerEvents*  groupEvents() const;
    4749
    4850    void                  readGroupsFromStorage();
     
    5254
    5355private:
    54     static BCGroupManager* instance_;
     56    static BCGroupManager*    instance_;
     57    SGroupManagerEventMapper* eventMapper_;
    5558
    56     QMap<int, SGroup*>     groupList_;
     59    QMap<int, SGroup*>        groupList_;
    5760
    5861private slots:
  • src/business/bclibraryloader.cpp

    r92 r95  
    2626#include <ilibrary.h>
    2727#include <libraryexceptions.h>
     28
     29#include "bccontactimportermanager.h"
     30#include "bcmanagerfactory.h"
    2831
    2932BCLibraryLoader* BCLibraryLoader::instance_=0;
     
    7982                }
    8083
     84                lib->init(BCManagerFactory::instance());
     85
    8186                libraries_.insert(filename, lib);
    8287                librariesByIdentificationKey_.insert(lib->identificationKey(), lib);
     
    8590                if (gateway != NULL) {
    8691                    gateways_.insert(lib, gateway);
     92                }
     93                foreach (IContactImporter* importer, lib->getContactImporters()) {
     94                    BCContactImporterManager::instance()->registerContactImporter(importer);
    8795                }
    8896
  • src/business/bcoldsettingscontactimporter.cpp

    r94 r95  
    2121#include <QDebug>
    2222#include <QDesktopServices>
    23 #include <QFile>
     23#include <QFileInfo>
    2424
    2525#include <snumber.h>
     26
     27#include "ui/vcoldsettingscontactimporter/page_config.h"
     28
     29BCOldSettingsContactImporter::BCOldSettingsContactImporter() {
     30    dataManager_ = new BCOldSettingsContactImporterDataManager();
     31}
     32BCOldSettingsContactImporter::~BCOldSettingsContactImporter() {
     33    delete dataManager_;
     34}
    2635
    2736QString BCOldSettingsContactImporter::describingName() const {
     
    3039
    3140bool BCOldSettingsContactImporter::isApplicable() const {
    32     return hasValidOldContactsFile();
    33 }
    34 
    35 bool BCOldSettingsContactImporter::hasValidOldContactsFile() const {
    36     foreach (QString contactsFile, contactsFiles()) {
    37         if (QFile::exists(contactsFile))
    38             return true;
    39     }
    40 
    41     return false;
     41    return true;
    4242}
    4343
    4444
     45void BCOldSettingsContactImporter::init() {
     46    dataManager_->setContactFiles(defaultContactsFiles().toSet());
     47    dataManager_->setSelectedContactFiles(defaultContactsFiles().toSet());
     48}
     49
    4550QList<QWizardPage*> BCOldSettingsContactImporter::getPreImportPages() {
    46     return QList<QWizardPage*>();
     51    QList<QWizardPage*> pages;
     52    pages.append(new PageConfig(dataManager_));
     53
     54    return pages;
    4755}
    4856
    4957QSet<SContact*> BCOldSettingsContactImporter::importContacts() {
    50     foreach (QString contactsFile, contactsFiles()) {
     58    QSet<SContact*> contacts;
     59
     60    foreach (QString contactsFile, dataManager_->selectedContactFiles()) {
    5161        if (!QFile::exists(contactsFile)) continue;
    5262
    5363        QSettings ini(contactsFile, QSettings::IniFormat);
    54         if (ini.contains("contacts")) {
     64        if (ini.childGroups().contains("contacts")) {
    5565            // V1 contacts file
    56             return readV1ContactsFile(ini);
     66            contacts.unite(readV1ContactsFile(ini));
    5767        } else {
    5868            // V2 contacts file
    59             return readV2ContactsFile(ini);
     69            contacts.unite(readV2ContactsFile(ini));
    6070        }
    6171    }
    6272
    63     return QSet<SContact*>();
     73    return contacts;
    6474}
    6575
    66 QStringList BCOldSettingsContactImporter::contactsFiles() const {
     76
     77void _addDefaultFile(QStringList& files, QString filename) {
     78    QFileInfo fi(filename);
     79    if (fi.exists()) {
     80        files.append(fi.absoluteFilePath());
     81    }
     82}
     83QStringList BCOldSettingsContactImporter::defaultContactsFiles() const {
    6784    QStringList r;
    68     r.append(QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/gorrion/SMSSender/contacts.ini");
    69     r.append(QDesktopServices::storageLocation(QDesktopServices::ApplicationsLocation) + "/gorrion/SMSSender/contacts.ini");
     85
     86    _addDefaultFile(r, QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/gorrion/SMSSender/contacts.ini");
     87    _addDefaultFile(r, QDesktopServices::storageLocation(QDesktopServices::ApplicationsLocation) + "/gorrion/SMSSender/contacts.ini");
    7088
    7189    return r;
     
    7694
    7795    int i = 0;
    78     while (ini.contains("contacts/contact_" + QString::number(i))) {
     96    while (ini.contains("contacts/contact_" + QString::number(i) + "_nr")) {
    7997        QString name = ini.value("contacts/contact_" + QString::number(i) + "_name").toString();
    8098        SNumber number(ini.value("contacts/contact_" + QString::number(i) + "_nr").toString());
     
    86104            result.insert(c);
    87105        }
     106
     107        ++i;
    88108    }
    89109
     
    107127    return result;
    108128}
     129
     130
     131/**********************************************************************************************/
     132
     133
     134QSet<QString> BCOldSettingsContactImporterDataManager::contactFiles() const {
     135    return contactFiles_;
     136}
     137void BCOldSettingsContactImporterDataManager::setContactFiles(const QSet<QString>& contactFiles) {
     138    contactFiles_ = contactFiles;
     139    emit contactFilesChanged();
     140}
     141
     142QSet<QString> BCOldSettingsContactImporterDataManager::selectedContactFiles() const {
     143    return selectedContactFiles_;
     144}
     145void BCOldSettingsContactImporterDataManager::setSelectedContactFiles(const QSet<QString>& contactFiles) {
     146    selectedContactFiles_.clear();
     147    foreach (QString selected, contactFiles) {
     148        if (contactFiles_.contains(selected)) {
     149            selectedContactFiles_.insert(selected);
     150        }
     151    }
     152    emit selectedContactFilesChanged();
     153}
  • src/business/bcoldsettingscontactimporter.h

    r94 r95  
    2222#include <icontactimporter.h>
    2323
     24#include <QFile>
    2425#include <QSettings>
     26
     27class BCOldSettingsContactImporterDataManager;
    2528
    2629class BCOldSettingsContactImporter : public IContactImporter {
    2730public:
    28     BCOldSettingsContactImporter() {};
     31    BCOldSettingsContactImporter();
     32    ~BCOldSettingsContactImporter();
    2933
    3034public: /* IContactImporter */
     
    3236    bool    isApplicable() const;
    3337
     38    void                init();
    3439    QList<QWizardPage*> getPreImportPages();
    35 
    3640    QSet<SContact*>     importContacts();
    3741
    3842
    3943private:
    40     bool        hasValidOldContactsFile() const;
    41     QStringList contactsFiles() const;
     44    QStringList     defaultContactsFiles() const;
     45
     46    QSet<SContact*> readV1ContactsFile(const QSettings& ini) const;
     47    QSet<SContact*> readV2ContactsFile(const QSettings& ini) const;
    4248
    4349private:
    44     QSet<SContact*> readV1ContactsFile(const QSettings& ini) const;
    45     QSet<SContact*> readV2ContactsFile(const QSettings& ini) const;
     50    BCOldSettingsContactImporterDataManager* dataManager_;
     51};
     52
     53class BCOldSettingsContactImporterDataManager : public QObject {
     54    Q_OBJECT
     55
     56public:
     57    QSet<QString> contactFiles() const;
     58    void setContactFiles(const QSet<QString>& contactFiles);
     59
     60    QSet<QString> selectedContactFiles() const;
     61    void setSelectedContactFiles(const QSet<QString>& contactFiles);
     62
     63signals:
     64    void contactFilesChanged();
     65    void selectedContactFilesChanged();
     66
     67private:
     68    QSet<QString> contactFiles_;
     69    QSet<QString> selectedContactFiles_;
    4670};
    4771
  • src/persistence/daaccountmanager.h

    r92 r95  
    2323#include <iaccount.h>
    2424
    25 #include <persistence/iaccountmanager.h>
     25#include <persistence/iaccountstoragemanager.h>
    2626#include <persistence/istorage.h>
    2727
    28 class DAAccountManager: public QObject, public IAccountManager {
     28class DAAccountManager: public QObject, public IAccountStorageManager {
    2929    Q_OBJECT
    30     Q_INTERFACES(IAccountManager)
     30    Q_INTERFACES(IAccountStorageManager)
    3131
    3232public:
  • src/persistence/dacontactmanager.h

    r92 r95  
    2121#include <QObject>
    2222
    23 #include <persistence/icontactmanager.h>
     23#include <persistence/icontactstoragemanager.h>
    2424#include <persistence/istorage.h>
    2525
    26 class DAContactManager: public QObject, public IContactManager {
     26class DAContactManager: public QObject, public IContactStorageManager {
    2727    Q_OBJECT
    28     Q_INTERFACES(IContactManager)
     28    Q_INTERFACES(IContactStorageManager)
    2929
    3030public:
  • src/persistence/dagroupmanager.h

    r92 r95  
    2121#include <QObject>
    2222
    23 #include <persistence/igroupmanager.h>
     23#include <persistence/igroupstoragemanager.h>
    2424#include <persistence/istorage.h>
    2525
    26 class DAGroupManager: public QObject, public IGroupManager {
     26class DAGroupManager: public QObject, public IGroupStorageManager {
    2727    Q_OBJECT
    28     Q_INTERFACES(IGroupManager)
     28    Q_INTERFACES(IGroupStorageManager)
    2929
    3030public:
  • src/persistence/persistencefactory.cpp

    r92 r95  
    3131
    3232
    33 IAccountManager* PersistenceFactory::getAccountManager(){
     33IAccountStorageManager* PersistenceFactory::getAccountManager(){
    3434    return DAAccountManager::instance();
    3535}
    3636
    37 IContactManager* PersistenceFactory::getContactManager(){
     37IContactStorageManager* PersistenceFactory::getContactManager(){
    3838    return DAContactManager::instance();
    3939}
    4040
    41 IGroupManager* PersistenceFactory::getGroupManager(){
     41IGroupStorageManager* PersistenceFactory::getGroupManager(){
    4242    return DAGroupManager::instance();
    4343}
  • src/persistence/persistencefactory.h

    r92 r95  
    2121#include <QObject>
    2222
    23 #include <persistence/iaccountmanager.h>
    24 #include <persistence/icontactmanager.h>
    25 #include <persistence/igroupmanager.h>
     23#include <persistence/iaccountstoragemanager.h>
     24#include <persistence/icontactstoragemanager.h>
     25#include <persistence/igroupstoragemanager.h>
    2626#include <persistence/isettings.h>
    2727#include <persistence/istorage.h>
     
    3333    static PersistenceFactory* instance();
    3434
    35     IAccountManager* getAccountManager();
    36     IContactManager* getContactManager();
    37     IGroupManager* getGroupManager();
     35    IAccountStorageManager* getAccountManager();
     36    IContactStorageManager* getContactManager();
     37    IGroupStorageManager* getGroupManager();
    3838    ISettings* getSettings();
    3939    IStorage* getStorage();
  • src/persistence/storage/dastorage.cpp

    r92 r95  
    373373    }
    374374    aliasesStr.remove(QRegExp("\\t$")); // Remove last "\t"
    375     writeString("contact_" + QString::number(contact->id()), "aliases", aliasesStr);
    376 
    377     writeImage("contact_" + QString::number(contact->id()), "image", contact->image());
     375    if (!aliasesStr.isEmpty()) {
     376        writeString("contact_" + QString::number(contact->id()), "aliases", aliasesStr);
     377    } else {
     378        removeValue("contact_" + QString::number(contact->id()), "aliases");
     379    }
     380
     381    if (!contact->image().isNull()) {
     382        writeImage("contact_" + QString::number(contact->id()), "image", contact->image());
     383    } else {
     384        removeValue("contact_" + QString::number(contact->id()), "image");
     385    }
    378386}
    379387
  • src/ui/models/accounttreemodel.cpp

    r92 r95  
    2424    : QAbstractTableModel(parent)
    2525{
    26     connect(BCAccountManager::instance(), SIGNAL(accountAdded(IAccount*)),
     26    connect(BCAccountManager::instance()->eventMapper(), SIGNAL(accountAdded(IAccount*)),
    2727            this, SLOT(listAltered()));
    28     connect(BCAccountManager::instance(), SIGNAL(accountDataChanged(IAccount*, int)),
     28    connect(BCAccountManager::instance()->eventMapper(), SIGNAL(accountDataChanged(IAccount*, int)),
    2929            this, SLOT(accountUpdated(IAccount*)));
    30     connect(BCAccountManager::instance(), SIGNAL(accountInitStateChanged(IAccount*)),
     30    connect(BCAccountManager::instance()->eventMapper(), SIGNAL(accountInitStateChanged(IAccount*)),
    3131            this, SLOT(accountUpdated(IAccount*)));
    32     connect(BCAccountManager::instance(), SIGNAL(accountRemoved(IAccount*)),
     32    connect(BCAccountManager::instance()->eventMapper(), SIGNAL(accountRemoved(IAccount*)),
    3333            this, SLOT(listAltered()));
    3434
     
    3636}
    3737AccountTreeModel::~AccountTreeModel() {
    38     disconnect(BCAccountManager::instance(), 0, this, 0);
     38    disconnect(BCAccountManager::instance()->eventMapper(), 0, this, 0);
    3939}
    4040
  • src/ui/models/contactgroupmodel.cpp

    r92 r95  
    2424    : QAbstractListModel(parent)
    2525{
    26     connect(BCContactManager::instance(), SIGNAL(contactAdded(SContact*)),
    27             this, SLOT(listAltered()));
    28     connect(BCContactManager::instance(), SIGNAL(contactUpdated(SContact*)),
     26    connect(BCContactManager::instance()->eventMapper(), SIGNAL(contactAdded(SContact*)),
     27            this, SLOT(listAltered()));
     28    connect(BCContactManager::instance()->eventMapper(), SIGNAL(contactUpdated(SContact*)),
    2929            this, SLOT(dataUpdated(SContact*)));
    30     connect(BCContactManager::instance(), SIGNAL(contactRemoved(SContact*)),
    31             this, SLOT(listAltered()));
    32 
    33     connect(BCGroupManager::instance(), SIGNAL(groupAdded(SGroup*)),
    34             this, SLOT(listAltered()));
    35     connect(BCGroupManager::instance(), SIGNAL(groupUpdated(SGroup*)),
     30    connect(BCContactManager::instance()->eventMapper(), SIGNAL(contactRemoved(SContact*)),
     31            this, SLOT(listAltered()));
     32
     33    connect(BCGroupManager::instance()->eventMapper(), SIGNAL(groupAdded(SGroup*)),
     34            this, SLOT(listAltered()));
     35    connect(BCGroupManager::instance()->eventMapper(), SIGNAL(groupUpdated(SGroup*)),
    3636            this, SLOT(dataUpdated(SGroup*)));
    37     connect(BCGroupManager::instance(), SIGNAL(groupRemoved(SGroup*)),
     37    connect(BCGroupManager::instance()->eventMapper(), SIGNAL(groupRemoved(SGroup*)),
    3838            this, SLOT(listAltered()));
    3939
     
    4141}
    4242ContactGroupListModel::~ContactGroupListModel() {
    43     disconnect(BCContactManager::instance(), 0, this, 0);
    44     disconnect(BCGroupManager::instance(), 0, this, 0);
     43    disconnect(BCContactManager::instance()->eventMapper(), 0, this, 0);
     44    disconnect(BCGroupManager::instance()->eventMapper(), 0, this, 0);
    4545}
    4646
  • src/ui/models/contacttablemodel.cpp

    r92 r95  
    2727    : QAbstractTableModel(parent)
    2828{
    29     connect(BCContactManager::instance(), SIGNAL(contactAdded(SContact*)),
     29    connect(BCContactManager::instance()->eventMapper(), SIGNAL(contactAdded(SContact*)),
    3030            this, SLOT(contactAddRemove(SContact*)));
    31     connect(BCContactManager::instance(), SIGNAL(contactUpdated(SContact*)),
     31    connect(BCContactManager::instance()->eventMapper(), SIGNAL(contactUpdated(SContact*)),
    3232            this, SLOT(contactUpdated(SContact*)));
    33     connect(BCContactManager::instance(), SIGNAL(contactRemoved(SContact*)),
     33    connect(BCContactManager::instance()->eventMapper(), SIGNAL(contactRemoved(SContact*)),
    3434            this, SLOT(contactAddRemove(SContact*)));
    3535}
    3636ContactTableModel::~ContactTableModel() {
    37     disconnect(BCContactManager::instance(), 0, this, 0);
     37    disconnect(BCContactManager::instance()->eventMapper(), 0, this, 0);
    3838}
    3939
  • src/ui/models/grouptablemodel.cpp

    r92 r95  
    2626    : QAbstractTableModel(parent)
    2727{
    28     connect(BCGroupManager::instance(), SIGNAL(groupAdded(SGroup*)),
     28    connect(BCGroupManager::instance()->eventMapper(), SIGNAL(groupAdded(SGroup*)),
    2929            this, SLOT(groupAddRemove(SGroup*)));
    30     connect(BCGroupManager::instance(), SIGNAL(groupUpdated(SGroup*)),
     30    connect(BCGroupManager::instance()->eventMapper(), SIGNAL(groupUpdated(SGroup*)),
    3131            this, SLOT(groupUpdated(SGroup*)));
    32     connect(BCGroupManager::instance(), SIGNAL(groupRemoved(SGroup*)),
     32    connect(BCGroupManager::instance()->eventMapper(), SIGNAL(groupRemoved(SGroup*)),
    3333            this, SLOT(groupAddRemove(SGroup*)));
    3434}
    3535GroupTableModel::~GroupTableModel() {
    36     disconnect(BCGroupManager::instance(), 0, this, 0);
     36    disconnect(BCGroupManager::instance()->eventMapper(), 0, this, 0);
    3737}
    3838
  • src/ui/vcimportcontacts/vcimportcontacts_importedcontacttablemodel.cpp

    r94 r95  
    6161        return QVariant();
    6262
    63     const SContact* contact = importedContacts_.at(index.row());
     63    SContact* contact = importedContacts_.at(index.row());
    6464
    6565    if (role == Qt::DisplayRole) {
     
    8686        switch (index.column()) {
    8787            case ColDoImport:
    88                 return (!dataManager_->noimportContacts().contains(importedContacts_.at(index.row()))) ? Qt::Checked : Qt::Unchecked;
     88                return (!dataManager_->noimportContacts().contains(contact)) ? Qt::Checked : Qt::Unchecked;
    8989        }
    9090    }
  • src/ui/vcimportcontacts/vcimportcontacts_page_conclusion.cpp

    r94 r95  
    7777
    7878void ContactSaveThread::run() {
     79    QTimer::singleShot(0, this, SLOT(doSave()));
     80    exec();
     81}
     82void ContactSaveThread::doSave() {
    7983    QSet<SContact*> contacts = dataManager_->importedContacts();
    8084    contacts.subtract(dataManager_->noimportContacts());
     
    98102    }
    99103    emit progressChanged(100);
     104    quit();
    100105}
  • src/ui/vcimportcontacts/vcimportcontacts_page_conclusion.h

    r94 r95  
    6262private:
    6363    VCImportContactsDataManager* dataManager_;
     64
     65private slots:
     66    void doSave();
    6467};
    6568
  • src/ui/vcimportcontacts/vcimportcontacts_page_import.cpp

    r94 r95  
    174174
    175175void ImportThread::run() {
     176    QTimer::singleShot(0, this, SLOT(doImport()));
     177    exec();
     178}
     179void ImportThread::doImport() {
    176180    emit contactsImported(importer_->importContacts());
     181    quit();
    177182}
  • src/ui/vcimportcontacts/vcimportcontacts_page_import.h

    r94 r95  
    7575private:
    7676    IContactImporter* importer_;
     77
     78private slots:
     79    void doImport();
    7780};
    7881
  • src/ui/vcimportcontacts/vcimportcontactswizard.cpp

    r94 r95  
    4242
    4343    foreach (IContactImporter* importer, BCContactImporterManager::instance()->contactImporters()) {
     44        importer->init();
     45
    4446        foreach(QWizardPage* page, importer->getPreImportPages()) {
    45             addPage(page);
     47            preImportPageIds_.insertMulti(importer, addPage(page));
    4648        }
    4749    }
     
    5557    delete dataManager_;
    5658}
     59
     60int VCImportContactsWizard::nextId() const {
     61    int nextId = currentPage()->nextId();
     62
     63    while (preImportPageIds_.values().contains(nextId)) {
     64        if (dataManager_->activatedImporters().contains(preImportPageIds_.key(nextId))) {
     65            return nextId;
     66        }
     67        nextId = page(nextId)->nextId();
     68    }
     69    return nextId;
     70}
  • src/ui/vcimportcontacts/vcimportcontactswizard.h

    r94 r95  
    3131    virtual ~VCImportContactsWizard();
    3232
     33public: /* QWizard */
     34    int nextId() const;
     35
    3336private:
    3437    VCImportContactsDataManager* dataManager_;
     38    QMap<IContactImporter*, int> preImportPageIds_;
    3539};
    3640
  • src/ui/vcmain/vcmain.cpp

    r94 r95  
    9191            this, SLOT(on_lstContacts_completerActivated(const QString&)));
    9292
    93     connect(BCAccountInitManager::instance(), SIGNAL(accountInitStateChanged(IAccount*)),
     93    connect(BCAccountInitManager::instance()->eventMapper(), SIGNAL(accountInitStateChanged(IAccount*)),
    9494            this, SLOT(on_accountInitStateChanged(IAccount*)));
    95     connect(BCAccountInitManager::instance(), SIGNAL(accountInitDone(IAccount*, Account::InitializationResult)),
     95    connect(BCAccountInitManager::instance()->eventMapper(), SIGNAL(accountInitDone(IAccount*, Account::InitializationResult)),
    9696            this, SLOT(on_accountInitDone(IAccount*, Account::InitializationResult)));
    97     connect(BCAccountInitManager::instance(), SIGNAL(accountInitFailed(IAccount*, const EException&)),
     97    connect(BCAccountInitManager::instance()->eventMapper(), SIGNAL(accountInitFailed(IAccount*, const EException&)),
    9898            this, SLOT(on_accountInitFailed(IAccount*, const EException&)));
    9999
     
    350350void VCMain::on_lstContacts_returnPressed() {
    351351    if (ui.lstContacts->currentIndex() < 0) {
    352         // If nothing is selected in the completion, just use the topmost completion
    353         ui.lstContacts->completer()->setCurrentRow(0);
    354         ui.lstContacts->lineEdit()->setText(ui.lstContacts->completer()->currentCompletion());
     352        SNumber number = SNumber::fromString(ui.lstContacts->lineEdit()->text().trimmed(), SNumber::GuessFormat);
     353        if (!number.isValid()) {
     354            // If nothing is selected in the completion, just use the topmost completion
     355            ui.lstContacts->completer()->setCurrentRow(0);
     356            ui.lstContacts->lineEdit()->setText(ui.lstContacts->completer()->currentCompletion());
     357        } else {
     358            // There was entered a valid number, so do not select any completion but search after the number.
     359            on_btnAddRecipient_clicked();
     360        }
    355361    }
    356362}
     
    378384    } else {
    379385        SNumber number = SNumber::fromString(ui.lstContacts->lineEdit()->text().trimmed(), SNumber::GuessFormat);
    380         if (!number.isValid()) {
    381             number = SNumber::fromString("+41 " + ui.lstContacts->lineEdit()->text().trimmed(), SNumber::GuessFormat);
    382         }
    383386        if (number.isValid()) {
    384387            SContact* recipient = BCContactManager::instance()->getContactByNumber(number);
Note: See TracChangeset for help on using the changeset viewer.