Changeset 275:fc4bfb4b9bc4 in SMSSender


Ignore:
Timestamp:
Jun 25, 2012 9:40:36 AM (8 years ago)
Author:
Sämy Zehnder <saemy.zehnder@…>
Branch:
default
Children:
276:c48ccb9d12d1, 277:6050201cc5f7
Message:
  • Corrected and centralized sms-counting for all gateways.
  • Synchronizing sms length with the post and sunrise gateways now.
  • Fixed bug in contact import where only already existing contact names were considered in duplicate name checking.
  • Showing the account name instead of the gateway name in the account list if no free sms count is there.
Files:
3 added
46 edited

Legend:

Unmodified
Added
Removed
  • gateways/ETHZ/src/business/bcaccount.h

    r217 r275  
    4545
    4646public: /* IAccount - costs */
    47     int               costsForText(const QString& message) const;
    48     QList<QString>    splitTextToLongSMS(const QString& text) const;
    49     int               shortSMSCount(const QString& text) const;
     47    int               costsForText(const QString &text) const;
     48    int               fragmentSize() const;
    5049
    5150protected: /* AbstractAccount */
  • gateways/ETHZ/src/business/bcaccount_costs.cpp

    r217 r275  
    2525
    2626/**
    27  * Splits the given text into a list of long-sms. <br/>
    28  * Since the long-sms-length is not limited at the ETHZ gateway
    29  * simply the text is given back as the only element in the list.
     27 * The long-sms-length is not limited at the ETHZ gateway.
    3028 *
    31  * @param QString text The text which should be splitted
    32  * @return The list of the long-sms texts
     29 * @return The fragment size
    3330 */
    34 QList<QString> BCAccount::splitTextToLongSMS(const QString& text) const {
    35     QList<QString> lst;
    36     lst.append(text);
    37     return lst;
     31int BCAccount::fragmentSize() const {
     32    return INT_MAX;
    3833}
    3934
    40 /**
    41  * Counts the short-sms count of the given text.
    42  *
    43  * @param QString text The text which should be splitted.
    44  * @return The short-sms count.
    45  */
    46 int BCAccount::shortSMSCount(const QString& text) const {
    47     QString txt(text);
    48     foreach (QChar doublePriceChar, gateway()->doublePriceChars()) {
    49         txt.replace(doublePriceChar, "++");
     35int BCAccount::costsForText(const QString &text) const {
     36    if (divideMessage(text, SHORTSMS_LENGTH).size() > 1) {
     37        return divideMessage(text, MULTISMS_SHORTSMS_LENGTH).size();
     38    } else {
     39        return 1;
    5040    }
    51 
    52     QList<QString> longSMSList = splitTextToLongSMS(txt);
    53 
    54     int count = 0;
    55     foreach (QString longSMSText, longSMSList) {
    56         if (longSMSText.length() <= SHORTSMS_LENGTH) {
    57             ++count;
    58         } else {
    59             count += ceil(longSMSText.length() / (double)MULTISMS_SHORTSMS_LENGTH);
    60         }
    61     }
    62 
    63     return count;
    64 }
    65 
    66 /**
    67  * Returns the costs of free sms of the given message.
    68  *
    69  * @param message The message
    70  * @return The costs
    71  */
    72 int BCAccount::costsForText(const QString& message) const {
    73     return shortSMSCount(message);
    7441}
    7542
  • gateways/ETHZ/src/business/bcaccount_task_sendsms.cpp

    r220 r275  
    5757            setProgress(10);
    5858
    59             QStringList longSMSList = account()->splitTextToLongSMS(message());
     59            QStringList longSMSList = account()->divideMessage(message());
    6060
    6161            int percent_per_sms = 70 / (longSMSList.size() * ceil(recipients().size() / (double)MAX_RECIPIENTS_PER_SMS));
  • gateways/Orange/src/business/bcaccount.h

    r270 r275  
    4646public: /* IAccount - costs */
    4747    int                costsForText(const QString& message) const;
    48     QList<QString>     splitTextToLongSMS(const QString& text) const;
    49     int                shortSMSCount(const QString& text) const;
     48    int                fragmentSize() const;
    5049
    5150protected: /* AbstractAccount */
  • gateways/Orange/src/business/bcaccount_costs.cpp

    r270 r275  
    2121namespace Orange {
    2222
    23 /**
    24  * Splits the given text into a list of long-sms. <br/>
    25  * Since the long-sms-length is synchronized with the gateway,
    26  * this list can be used to generate the different text parts
    27  * which then will be sent as their own long-sms via the gateway.
    28  *
    29  * @param QString text The text which should be splitted
    30  * @return Returns a list of the long-sms texts
    31  */
    32 QList<QString> BCAccount::splitTextToLongSMS(const QString& text) const {
    33     QList<QString> longSMSList;
    34     QString text_(text);
    35     text_.remove('\r'); // Only use \n
    36 
    37     while (text_ != "") {
    38         int realLength  = 0;
    39         QString longSMS = "";
    40 
    41         while ((text_ != "") && (realLength < smsLength())) {
    42             longSMS += text_.at(0);
    43             if (gateway()->doublePriceChars().contains(text_.at(0))) {
    44                 ++realLength;
    45             }
    46             ++realLength;
    47 
    48             text_.remove(0, 1);
    49         }
    50 
    51         longSMSList.append(longSMS);
    52     }
    53 
    54     return longSMSList;
     23int BCAccount::fragmentSize() const {
     24    return smsLength();
    5525}
    5626
    57 /**
    58  * Returns the short-sms count of the given text. <br/>
    59  * This is the same as {@link #splitTextToLongSMS(const QString&).
    60  *
    61  * @param QString text The text which should be splitted.
    62  * @return Returns a list of the short-sms texts
    63  */
    64 int BCAccount::shortSMSCount(const QString& text) const {
    65     return splitTextToLongSMS(text).length();
    66 }
    67 
    68 /**
    69  * Returns the costs of free sms of the given message.
    70  *
    71  * @param message The message
    72  * @return The costs
    73  */
    7427int BCAccount::costsForText(const QString& message) const {
    75     return shortSMSCount(message);
     28    return divideMessage(message).size();
    7629}
    7730
  • gateways/Orange/src/business/bcaccount_task_sendsms.cpp

    r270 r275  
    2323#include <snumber.h>
    2424
     25#include <abstractaccount_utils.h>
     26
    2527namespace Orange {
    2628
     
    4446            account()->reloadOnlineParams();
    4547
    46             QStringList longSMSList = account()->splitTextToLongSMS(message());
    47             int shortSMSCnt         = account()->shortSMSCount(message());
     48            CHECK_FREE_SMS_COUNT()
    4849
    49             if (shortSMSCnt * recipients().size() > account()->freeSMSCount()) {
    50                 EException(tr("You have only %1 SMS for free but you need at least %2 SMS left to send this message.")
    51                                .arg(account()->freeSMSCount()).arg(shortSMSCnt * recipients().size()))
    52                         .raise();
    53             }
     50            QStringList longSMSList = account()->divideMessage(message());
    5451            setProgress(20);
    5552
  • gateways/Post/src/business/bcaccount.cpp

    r220 r275  
    4343    : AbstractAccount(parent)
    4444    , networkHelper_(new SNetworkHelper(this))
    45     , adTextLength_(0)
     45    , longSMSLength_(435) // Default value from post.ch
    4646{
    4747    init(new DAAccountStorageOfficer(this, this, storage), new SStdAccountValidator(this, this));
     
    102102}
    103103
    104 void BCAccount::reloadOnlineParams() {
    105     reloadFreeSMSCount();
    106 }
    107 void BCAccount::reloadFreeSMSCount(QString html) {
    108     /*<td class="label">50 von 50 TextSMS im Monat xxx</td> */
    109 
     104void BCAccount::reloadOnlineParams(QString html) {
    110105    if (html.isEmpty()) {
    111106        html = networkHelper()->syncGet(URL_SMSFORM)->readAll();
    112107    }
     108
     109    reloadLongSMSLength(html);
     110    reloadFreeSMSCount(html);
     111}
     112void BCAccount::reloadLongSMSLength(QString html) {
     113    /*<textarea name="sms_body" style="width: 100%; height: 117px" cols=2 rows=2 maxlength="435" onKeyUp="left_char(this)"></textarea>*/
     114
     115    QRegExp rx("<textarea name=\"sms_body\"[^>]*maxlength=\"(\\d+)\"");
     116    rx.setMinimal(true);
     117    if (rx.indexIn(html) == -1) {
     118        EException(tr("Could not get the longSMSLength."))
     119                .raise();
     120    }
     121    setLongSMSLength(rx.cap(1).toInt());
     122    qDebug() << "  Long SMS length: " + rx.cap(1);
     123}
     124
     125void BCAccount::reloadFreeSMSCount(QString html) {
     126    /*<td class="label">50 von 50 TextSMS im Monat xxx</td> */
    113127
    114128    QRegExp rx("<td class=\"label\">(\\d+) von \\d+ TextSMS im Monat [a-zA-Zäöü]+</td>");
  • gateways/Post/src/business/bcaccount.h

    r217 r275  
    4646
    4747public: /* IAccount - costs */
    48     int                costsForText(const QString& message) const;
    49     QList<QString>     splitTextToLongSMS(const QString& text) const;
    50     int                shortSMSCount(const QString& text) const;
     48    int                costsForText(const QString &text) const;
     49    int                fragmentSize() const;
    5150
    5251public: /* Properties */
     
    6160
    6261private:
    63     int                adTextLength() const;
    64     void               setAdTextLength(int length);
    65 
    6662    int                longSMSLength() const;
    6763    void               setLongSMSLength(int longSMSLength);
     
    6965private:
    7066    SNetworkHelper*    networkHelper() const;
    71     void               reloadOnlineParams();
    72     void               reloadFreeSMSCount(QString html = QString());
     67    void               reloadOnlineParams(QString html = QString());
     68    void               reloadLongSMSLength(QString html);
     69    void               reloadFreeSMSCount(QString html);
    7370
    7471private:
     
    8077private:
    8178    SNetworkHelper*    networkHelper_;
    82     int                adTextLength_;
     79    int                longSMSLength_;
    8380};
    8481
  • gateways/Post/src/business/bcaccount_costs.cpp

    r217 r275  
    1616  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717*/
    18 
    1918#include "bcaccount.h"
    2019
     
    2322namespace Post {
    2423
    25 /**
    26  * Splits the given text into a list of long-sms. <br/>
    27  * Since the long-sms-length is synchronized with the gateway,
    28  * this list can be used to generate the different text parts
    29  * which then will be sent as their own long-sms via the gateway.
    30  *
    31  * @param QString text The text which should be splitted
    32  * @return Returns a list of the long-sms texts
    33  */
    34 QList<QString> BCAccount::splitTextToLongSMS(const QString& text) const {
    35     QList<QString> longSMSList;
    36     QString text_(text);
     24int BCAccount::fragmentSize() const {
     25    return longSMSLength();
     26}
    3727
    38     while (text_ != "") {
    39         int realLength  = 0;
    40         QString longSMS = "";
    41 
    42         while ((text_ != "") && (realLength < longSMSLength())) {
    43             longSMS += text_.at(0);
    44             if (gateway()->doublePriceChars().contains(text_.at(0))) {
    45                 ++realLength;
    46             }
    47             ++realLength;
    48 
    49             text_.remove(0, 1);
    50         }
    51 
    52         longSMSList.append(longSMS);
     28int BCAccount::costsForText(const QString &text) const {
     29    QList<QString> longSMSList = divideMessage(text);
     30    if (longSMSList.size() == 0) {
     31        return 0;
    5332    }
    5433
    55     return longSMSList;
    56 }
     34    // All full long-sms cost 3 short-sms
     35    int numShortSMSInLongSMS = 3;
     36    int count = (longSMSList.size() - 1) * numShortSMSInLongSMS;
    5737
    58 /**
    59  * Returns the short-sms count of the given text. <br/>
    60  * This is only a hypotetic list, but should not vary too much from the real splitting,
    61  * since splitTextToLongSMS returns the correct long-sms-list and the calculation of the
    62  * length is done as on the website.
    63  *
    64  * @param QString text The text which should be splitted.
    65  * @return Returns a list of the short-sms texts
    66  */
    67 int BCAccount::shortSMSCount(const QString& text) const {
    68     QString txt(text);
    69     foreach (QChar doublePriceChar, gateway()->doublePriceChars()) {
    70         txt.replace(doublePriceChar, "xx"); // Just for counting purpose
    71     }
    72 
    73     int count;
    74 
    75     QList<QString> longSMSList = splitTextToLongSMS(txt);
    76     count = (longSMSList.size() - 1) * 3; // All full long-sms cost 3 short-sms
    77 
     38    /* Last longSMS:
     39     * 1. sms = 160 chars
     40     * 2. sms = 153 chars
     41     * 3. sms = 122 chars */
    7842    QString lastSMS = longSMSList.last();
    7943
    80     int tailLen = adTextLength();
    81 
    82     if ((lastSMS.length() + tailLen) > 160) {
    83         count += ceil((lastSMS.length() + tailLen - 160) / (double)153) + 1;
    84     } else {
    85         ++count;
     44    ++count; // 1.sms
     45    if (lastSMS.length()  > 160) {
     46        count += ceil((lastSMS.length() - 160) / (double)153);
    8647    }
    8748
     
    8950}
    9051
    91 /**
    92  * Returns the costs of free sms of the given message.
    93  *
    94  * @param message The message
    95  * @return The costs
    96  */
    97 int BCAccount::costsForText(const QString& message) const {
    98     return shortSMSCount(message);
    99 }
    100 
    101 
    102 
    103 /**
    104  * Returns the length of the advertisement text.
    105  *
    106  * @return The length of the ad text
    107  */
    108 int BCAccount::adTextLength() const {
    109     return adTextLength_;
    110 }
    111 void BCAccount::setAdTextLength(int length) {
    112     adTextLength_ = length;
    113 }
    114 
    11552
    11653int BCAccount::longSMSLength() const {
    117     return LONGSMS_LENGTH;
     54    return longSMSLength_;
     55}
     56void BCAccount::setLongSMSLength(int longSMSLength) {
     57    longSMSLength_ = longSMSLength;
    11858}
    11959
  • gateways/Post/src/business/bcaccount_task_sendsms.cpp

    r220 r275  
    2222#include <snetworkreply.h>
    2323#include <snumber.h>
     24
     25#include <abstractaccount_utils.h>
    2426
    2527namespace Post {
     
    5456            account()->reloadOnlineParams();
    5557
    56             QStringList longSMSList = account()->splitTextToLongSMS(message());
    57             int shortSMSCnt         = account()->shortSMSCount(message());
     58            CHECK_FREE_SMS_COUNT()
    5859
    59             if (shortSMSCnt * recipients().size() > account()->freeSMSCount()) {
    60                 EException(tr("You have only %1 SMS for free but you need at least %2 SMS left to send this message.")
    61                                .arg(account()->freeSMSCount()).arg(shortSMSCnt * recipients().size()))
    62                         .raise();
    63             }
     60            QStringList longSMSList = account()->divideMessage(message());
    6461            setProgress(10);
    6562
  • gateways/Post/src/business/bcgateway.h

    r217 r275  
    3232
    3333const short   MAX_RECIPIENTS_PER_SMS = 10;
    34 const short   LONGSMS_LENGTH         = 435;
    3534
    3635class BCGateway : public AbstractGateway {
  • gateways/Schoolnet/src/business/bcaccount.h

    r217 r275  
    7272
    7373public: /* IAccount - costs */
    74     int              costsForText(const QString& message) const;
    75     QList<QString>   splitTextToLongSMS(const QString& text) const;
    76     int              shortSMSCount(const QString& text) const;
     74    int              costsForText(const QString &text) const;
     75    int              fragmentSize() const;
    7776
    7877public: /* Properties */
  • gateways/Schoolnet/src/business/bcaccount_costs.cpp

    r217 r275  
    2222namespace Schoolnet {
    2323
    24 /**
    25  * Splits the given text into a list of long-sms. <br/>
    26  * Since the long-sms-length is fixed at schoolnet,
    27  * this list can be used to generate the different text parts
    28  * which then will be sent as their own long-sms via the gateway.
    29  *
    30  * @param QString text The text which should be splitted
    31  * @return Returns a list of the long-sms texts
    32  */
    33 QList<QString> BCAccount::splitTextToLongSMS(const QString& text) const {
    34     QList<QString> longSMSList;
    35     QString text_(text);
     24int BCAccount::fragmentSize() const {
     25    return LONGSMS_LENGTH;
     26}
    3627
    37     while (text_ != "") {
    38         int realLength  = 0;
    39         QString longSMS = "";
    40 
    41         while ((text_ != "") && (realLength <= LONGSMS_LENGTH)) {
    42             longSMS += text_.at(0);
    43             if (gateway()->doublePriceChars().contains(text_.at(0))) {
    44                 ++realLength;
    45             }
    46             ++realLength;
    47 
    48             text_.remove(0, 1);
    49         }
    50 
    51         longSMSList.append(longSMS);
     28int BCAccount::costsForText(const QString &text) const {
     29    QList<QString> longSMSList = divideMessage(text);
     30    if (longSMSList.size() == 0) {
     31        return 0;
    5232    }
    5333
    54     return longSMSList;
    55 }
     34    // All full long-sms cost 4 short-sms
     35    int numShortSMSInLongSMS = 4;
     36    int count = (longSMSList.size() - 1) * numShortSMSInLongSMS;
    5637
    57 /**
    58  * Returns the short-sms count of the given text. <br/>
    59  * This is only a hypotetic list, since the short-sms-lenght could vary and SHORTSMS_LENGTH is a static value.<br/>
    60  * However, since the LONGSMS_LENGT is the correct value for splitting
    61  * the short-sms count is not totally wrong. (This is also the way it is calculated on the website.)
    62  *
    63  * @param QString text The text which should be splitted.
    64  * @return Returns a list of the short-sms texts
    65  */
    66 int BCAccount::shortSMSCount(const QString& text) const {
    67     QString txt(text);
    68     foreach (QChar doublePriceChar, gateway()->doublePriceChars()) {
    69         txt.replace(doublePriceChar, "++");
    70     }
     38    /* Last longSMS:
     39     * 1. sms = 160 chars
     40     * 2. sms = 149 chars
     41     * 3. sms = 160 chars
     42     * 4. sms = 131 chars */
     43    int lastLength = longSMSList.last().size();
    7144
    72     QList<QString> longSMSList = splitTextToLongSMS(txt);
    73 
    74     int count = 0;
    75     foreach (QString longSMSText, longSMSList) {
    76         if(longSMSText.length() <= SHORTSMS_LENGTH) {
    77             ++count;
    78         } else {
    79             count += ceil((longSMSText.length() + 10) / (double)SHORTSMS_LENGTH);
    80         }
     45    if(lastLength <= 160) { // from schoolnet.ch
     46        ++count;
     47    } else {
     48        count += floor((lastLength + 10) / 160.0) + 1;
    8149    }
    8250
     
    8452}
    8553
    86 /**
    87  * Returns the costs of free sms of the given message.
    88  *
    89  * @param message The message
    90  * @return The costs
    91  */
    92 int BCAccount::costsForText(const QString& message) const {
    93     return shortSMSCount(message);
    94 }
    9554
    9655}
  • gateways/Schoolnet/src/business/bcaccount_task_sendsms.cpp

    r220 r275  
    2121
    2222#include <snumber.h>
     23
     24#include <abstractaccount_utils.h>
    2325
    2426#include "business/bchttphelper.h"
     
    5557            account()->reloadOnlineParams();
    5658
    57             QStringList longSMSList = account()->splitTextToLongSMS(message());
    58             int shortSMSCnt         = account()->shortSMSCount(message());
     59            CHECK_FREE_SMS_COUNT()
    5960
    60             if (shortSMSCnt * recipients().size() > account()->freeSMSCount()) {
    61                 EException(tr("You have only %1 SMS for free but you need at least %2 SMS left to send this message.")
    62                                .arg(account()->freeSMSCount()).arg(shortSMSCnt * recipients().size()))
    63                         .raise();
    64             }
     61            QStringList longSMSList = account()->divideMessage(message());
    6562            setProgress(10);
    6663
  • gateways/Schoolnet/src/business/bcgateway.h

    r217 r275  
    3232
    3333const short   MAX_RECIPIENTS_PER_SMS = 10;
    34 const short   SHORTSMS_LENGTH        = 160;
    3534const short   LONGSMS_LENGTH         = 600;
    3635
  • gateways/Sunrise/src/business/bcaccount.cpp

    r220 r275  
    5050    , MAX_ANTICAPTCHA_TRY_COUNT(2)
    5151    , networkHelper_(new BCNetworkHelper(this))
     52    , shortSMSLength_(160)
     53    , longSMSLength_(3*shortSMSLength_)
     54    , mmsLength_(3000)
    5255{
    5356    init(new DAAccountStorageOfficer(this, this, storage), new SStdAccountValidator(this, this));
     
    121124}
    122125void BCAccount::parseOnlineStats(const QString& html) {
    123     /* Parse it */
     126    /** Free sms count **/
    124127    QRegExp rx("Gratis (\\d+)");
    125128    rx.setCaseSensitivity(Qt::CaseInsensitive);
    126129    if (rx.indexIn(html) == -1) {
    127         EParseException(tr("Could not get the free sms count."))
     130        EParseException("Could not get the free sms count.")
    128131                .addDebugInfo("html", html)
    129132                .raise();
     
    131134    setFreeSMSCount(rx.cap(1).toInt());
    132135
     136    /** msisDn **/
    133137    rx.setPattern("<input.*name=\"currentMsisdn\".*value=\"(\\d+)\".*/>");
    134138    rx.setMinimal(true);
    135139    if (rx.indexIn(html) == -1) {
    136         EParseException(tr("Could not get the msisDN field."))
     140        EParseException("Could not get the msisDN field.")
    137141                .addDebugInfo("html", html)
    138142                .raise();
    139143    }
    140144    setMsisdn(rx.cap(1));
     145
     146    /** Read the sms & mms length **/
     147    rx.setPattern("maxLength = (\\d+);");
     148    rx.setMinimal(false);
     149    int firstPos = rx.indexIn(html);
     150    if (firstPos == -1) {
     151        EParseException("Could not get the mms length.")
     152                .addDebugInfo("html", html)
     153                .raise();
     154    }
     155    int mmsLength = rx.cap(1).toInt();
     156
     157    int secondPos = rx.indexIn(html, firstPos + rx.matchedLength());
     158    if (secondPos == -1) {
     159        EParseException("Could not get the sms length.")
     160                .addDebugInfo("html", html)
     161                .raise();
     162    }
     163    int smsLength = rx.cap(1).toInt();
     164
     165    if (mmsLength < smsLength) {
     166        int tmp = smsLength;
     167        smsLength = mmsLength;
     168        mmsLength = tmp;
     169    }
     170    setShortSMSLength(smsLength);
     171    setMMSLength(mmsLength);
     172
     173    /** Max sms count **/
     174    rx.setPattern("var maxSms = (\\d+);");
     175    if (rx.indexIn(html) == -1) {
     176        EParseException("Could not get the long sms length.")
     177                .addDebugInfo("html", html)
     178                .raise();
     179    }
     180    setLongSMSLength(shortSMSLength() * rx.cap(1).toInt());
    141181}
    142182
  • gateways/Sunrise/src/business/bcaccount.h

    r217 r275  
    6060
    6161public: /* IAccount - costs */
    62     QList<QString>     splitTextToLongSMS(const QString& text) const;
    63     int                shortSMSCount(const QString& text) const;
    64     int                costsForText(const QString& message) const;
     62    int                fragmentSize() const;
     63    int                costsForText(const QString &text) const;
    6564
    6665protected: /* AbstractAccount */
     
    7776    void               parseOnlineStats(const QString& html);
    7877
     78    int                shortSMSLength() const;
     79    int                longSMSLength() const;
     80    int                mmsLength() const;
     81    void               setShortSMSLength(int shortSMSLength);
     82    void               setLongSMSLength(int longSMSLength);
     83    void               setMMSLength(int mmsLength);
     84
    7985    void               setMsisdn(const QString& msisdn);
    8086    QString            msisdn() const;
     
    9096
    9197    BCNetworkHelper* networkHelper_;
     98
     99    int shortSMSLength_;
     100    int longSMSLength_;
     101    int mmsLength_;
    92102
    93103    QString   recipientsStr_;
  • gateways/Sunrise/src/business/bcaccount_costs.cpp

    r217 r275  
    2323namespace Sunrise {
    2424
    25 /**
    26  * Splits the given text into a list of long-sms. <br/>
    27  * Since the long-sms-length is synchronized with the gateway,
    28  * this list can be used to generate the different text parts
    29  * which then will be sent as their own long-sms via the gateway.
    30  *
    31  * @param QString text The text which should be splitted
    32  * @return Returns a list of the long-sms texts
    33  */
    34 QList<QString> BCAccount::splitTextToLongSMS(const QString& text) const {
    35     QList<QString> longSMSList;
    36     QString text_(text);
    37 
    38     short msLength;
     25int BCAccount::fragmentSize() const {
    3926    switch (sendAs()) {
    4027        case saAsk:
    4128        case saSMS:
    42             msLength = LONGSMS_LENGTH;
    43             break;
     29            return longSMSLength();
    4430
    4531        case saMMS:
    46             msLength = MMS_LENGTH;
    47             break;
     32            return mmsLength();
     33
     34        default:
     35            Q_ASSERT(false);
     36            return INT_MAX;
     37    }
     38}
     39
     40int BCAccount::costsForText(const QString &text) const {
     41    QList<QString> longSMSList = divideMessage(text);
     42    if (longSMSList.size() == 0) {
     43        return 0;
    4844    }
    4945
    50     while (text_ != "") {
    51         int realLength  = 0;
    52         QString longSMS = "";
     46    switch (sendAs()) {
     47        case saAsk:
     48        case saSMS: {
     49            // All full long-sms cost 3 short-sms
     50            int numShortSMSInLongSMS = longSMSLength() / shortSMSLength();
     51            int count = (longSMSList.size() - 1) * numShortSMSInLongSMS;
    5352
    54         while ((text_ != "") && (realLength < msLength)) {
    55             longSMS += text_.at(0);
    56             if (gateway()->doublePriceChars().contains(text_.at(0))) {
    57                 ++realLength;
    58             }
    59             ++realLength;
     53            // Each sms 160 chars (from sunrise.ch)
     54            int lastLength = longSMSList.last().size();
     55            count += floor((lastLength - 1) / (double) shortSMSLength()) + 1;
    6056
    61             text_.remove(0, 1);
     57            return count;
    6258        }
    6359
    64         longSMSList.append(longSMS);
     60        case saMMS:
     61            return longSMSList.size();
     62
     63        default:
     64            Q_ASSERT(false);
     65            return 0;
    6566    }
    66 
    67     return longSMSList;
    6867}
    6968
    70 /**
    71  * Returns the short-sms count of the given text. <br/>
    72  * This is only a hypotetic list, since the short-sms-lenght could vary and SHORTSMS_LENGTH is a static value.<br/>
    73  * However, since the splitTextToLongSMS is the correct long-sms-list (which length is synchronized with the gateway)
    74  * the short-sms count is not totally wrong. (This is also the way it is calculated on the website.)
    75  *
    76  * @param QString text The text which should be splitted.
    77  * @return Returns a list of the short-sms texts
    78  */
    7969
    80 int BCAccount::shortSMSCount(const QString& text) const {
    81     QString txt(text);
    82     foreach (QChar doublePriceChar, gateway()->doublePriceChars()) {
    83         txt.replace(doublePriceChar, "xx"); // Just for counting purpose
    84     }
    85 
    86     QList<QString> longSMSList = splitTextToLongSMS(txt);
    87 
    88 
    89     short msLength;
    90     switch (sendAs()) {
    91         case saAsk:
    92         case saSMS:
    93             msLength = SHORTSMS_LENGTH;
    94             break;
    95 
    96         case saMMS:
    97             msLength = MMS_LENGTH;
    98             break;
    99     }
    100 
    101     int count = 0;
    102     foreach (QString longSMSText, longSMSList) {
    103         count += ceil(longSMSText.length() / (double)msLength);
    104     }
    105 
    106     return count;
     70int BCAccount::shortSMSLength() const {
     71    return shortSMSLength_;
     72}
     73int BCAccount::longSMSLength() const {
     74    return longSMSLength_;
     75}
     76int BCAccount::mmsLength() const {
     77    return mmsLength_;
    10778}
    10879
    109 /**
    110  * Returns the costs of free sms of the given message.
    111  *
    112  * @param message The message
    113  * @return The costs
    114  */
    115 int BCAccount::costsForText(const QString& message) const {
    116     return shortSMSCount(message);
     80void BCAccount::setShortSMSLength(int shortSMSLength) {
     81    shortSMSLength_ = shortSMSLength;
     82}
     83void BCAccount::setLongSMSLength(int longSMSLength) {
     84    longSMSLength_ = longSMSLength;
     85}
     86void BCAccount::setMMSLength(int mmsLength) {
     87    mmsLength_ = mmsLength;
    11788}
    11889
  • gateways/Sunrise/src/business/bcaccount_task_sendsms.cpp

    r220 r275  
    2626#include <snetworkreply.h>
    2727#include <snumber.h>
     28
     29#include <abstractaccount_utils.h>
    2830
    2931#include "bcnetworkhelper.h"
     
    105107            account()->parseOnlineStats(lastHtml_);
    106108
    107             QStringList longSMSList = account()->splitTextToLongSMS(message());
    108             int shortSMSCnt         = account()->shortSMSCount(message());
    109 
    110             if (shortSMSCnt * recipients().size() > account()->freeSMSCount()) {
    111                 EException(tr("You have only %1 SMS for free but you need at least %2 SMS left to send this message.")
    112                                .arg(account()->freeSMSCount()).arg(shortSMSCnt * recipients().size()))
    113                         .raise();
    114             }
     109            CHECK_FREE_SMS_COUNT()
     110
     111            QStringList longSMSList = account()->divideMessage(message());
    115112            setProgress(10);
    116113
  • gateways/Sunrise/src/business/bcgateway.cpp

    r217 r275  
    4949}
    5050QList<QChar> BCGateway::doublePriceChars() const {
    51     return QList<QChar>(); // TODO: Check this
     51    QList<QChar> dpc;
     52    dpc.append('\n');
     53    return dpc;
    5254}
    5355QList<QChar> BCGateway::disAllowedChars() const {
  • gateways/Sunrise/src/business/bcgateway.h

    r217 r275  
    3434
    3535const short   MAX_RECIPIENTS_PER_SMS = 10;
    36 const short   SHORTSMS_LENGTH        = 160;
    37 const short   LONGSMS_LENGTH         = 3*SHORTSMS_LENGTH;
    38 const short   MMS_LENGTH             = 3000;
    39 
    4036const int     MMS_PICTURE_MAX_SIZE   = 200*1024; // In bytes
    4137
  • gateways/SwisscomXtraZone/src/business/bcaccount.cpp

    r220 r275  
    4444BCAccount::BCAccount(QObject *parent, IStorage *storage)
    4545    : AbstractAccount(parent)
    46     , longSMSLength_(SHORTSMS_LENGTH*3) // Don't initialize it with 0 because splitTextToSMS would not work otherwise
     46    , longSMSLength_(440) // Don't initialize it with 0 because splitTextToSMS would not work otherwise; 440 is with the default adtext-length.
    4747    , networkHelper_(new SNetworkHelper(this))
    4848{
  • gateways/SwisscomXtraZone/src/business/bcaccount.h

    r217 r275  
    2424#include <snetworkhelper.h>
    2525
    26 #include "bcgateway.h"
    27 
    2826namespace SwisscomXtraZone {
    2927
     
    4644
    4745public: /* IAccount - costs */
    48     int                costsForText(const QString& message) const;
    49     QList<QString>     splitTextToLongSMS(const QString& text) const;
    50     int                shortSMSCount(const QString& text) const;
     46    int                costsForText(const QString &text) const;
     47    int                fragmentSize() const;
    5148
    5249public: /* Properties */
     
    6360
    6461private:
    65     int                adTextLength() const;
    6662    int                longSMSLength() const;
    6763    void               setLongSMSLength(int longSMSLength);
  • gateways/SwisscomXtraZone/src/business/bcaccount_costs.cpp

    r217 r275  
    1616  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717*/
    18 
    1918#include "bcaccount.h"
    2019
    2120#include "math.h"
    2221
     22#include "bcgateway.h"
     23
    2324namespace SwisscomXtraZone {
    2425
    25 /**
    26  * Splits the given text into a list of long-sms. <br/>
    27  * Since the long-sms-length is synchronized with the gateway,
    28  * this list can be used to generate the different text parts
    29  * which then will be sent as their own long-sms via the gateway.
    30  *
    31  * @param QString text The text which should be splitted
    32  * @return Returns a list of the long-sms texts
    33  */
    34 QList<QString> BCAccount::splitTextToLongSMS(const QString& text) const {
    35     QList<QString> longSMSList;
    36     QString text_(text);
     26int BCAccount::fragmentSize() const {
     27    return longSMSLength();
     28}
    3729
    38     while (text_ != "") {
    39         int realLength  = 0;
    40         QString longSMS = "";
    41 
    42         while ((text_ != "") && (realLength < longSMSLength())) {
    43             longSMS += text_.at(0);
    44             if (gateway()->doublePriceChars().contains(text_.at(0))) {
    45                 ++realLength;
    46             }
    47             ++realLength;
    48 
    49             text_.remove(0, 1);
    50         }
    51 
    52         longSMSList.append(longSMS);
     30int BCAccount::costsForText(const QString& text) const {
     31    QList<QString> longSMSList = divideMessage(text);
     32    if (longSMSList.size() == 0) {
     33        return 0;
    5334    }
    5435
    55     return longSMSList;
    56 }
     36    // All full long-sms cost 3 short-sms
     37    int numShortSMSInLongSMS = 3;
     38    int count = (longSMSList.size() - 1) * numShortSMSInLongSMS;
    5739
    58 /**
    59  * Returns the short-sms count of the given text. <br/>
    60  * This is only a hypotetic list, since the short-sms-lenght could vary and SHORTSMS_LENGTH is a static value.<br/>
    61  * However, since the splitTextToLongSMS is the correct long-sms-list (which length is synchronized with the gateway)
    62  * the short-sms count is not totally wrong. (This is also the way it is calculated on the website.)
    63  *
    64  * @param QString text The text which should be splitted.
    65  * @return Returns a list of the short-sms texts
    66  */
    67 int BCAccount::shortSMSCount(const QString& text) const {
    68     QString txt(text);
    69     foreach (QChar doublePriceChar, gateway()->doublePriceChars()) {
    70         txt.replace(doublePriceChar, "xx"); // Just for counting purpose
    71     }
     40    /* Last longSMS:
     41     * 1. sms = 153 chars
     42     * 2. sms = 160 chars
     43     * 3. sms = 160 chars */
     44    int adLength = (153+160+160) - longSMSLength();
     45    int lastLength = longSMSList.last().size() + adLength;
    7246
    73     //QList<QString> longSMSList = splitTextToLongSMS(txt);
    74     //longSMSList.last() += QString(adTextLength(), QChar('x')); // extend it by a hypotetical ad text
    75 
    76     QList<QString> longSMSList = splitTextToLongSMS(txt + QString(adTextLength(), QChar('x'))); // extend it by a hypotetical ad text
    77 
    78     int count = 0;
    79     foreach (QString longSMSText, longSMSList) {
    80         count += ceil(longSMSText.length() / (double)SHORTSMS_LENGTH);
     47    ++count; // 1. sms
     48    if (lastLength > 153) {
     49        count += ceil((lastLength - 153) / (double)160);
    8150    }
    8251
     
    8453}
    8554
    86 /**
    87  * Returns the costs of free sms of the given message.
    88  *
    89  * @param message The message
    90  * @return The costs
    91  */
    92 int BCAccount::costsForText(const QString& message) const {
    93     return shortSMSCount(message);
    94 }
    9555
    9656
    97 
    98 /**
    99  * Returns the length of the advertisement text of swisscom.
    100  *
    101  * @return The length of the ad text
    102  */
    103 int BCAccount::adTextLength() const {
    104     return 3*SHORTSMS_LENGTH - longSMSLength();
    105 }
    10657int BCAccount::longSMSLength() const {
    10758    return longSMSLength_;
     
    11061/**
    11162 * Sets the longSMSLength.
    112  * The given value has to be the length from which the length of the addon count is already
     63 * The given value has to be the length from which the length of the ad-length is already
    11364 * substracted.
    11465 *
  • gateways/SwisscomXtraZone/src/business/bcaccount_task_login.cpp

    r217 r275  
    2626#include <exceptions/eloginaccountloginexception.h>
    2727
     28#include "bcgateway.h"
    2829#include "ui/vccaptchadialog.h"
    2930#include "library.h"
  • gateways/SwisscomXtraZone/src/business/bcaccount_task_sendsms.cpp

    r220 r275  
    2323#include <snumber.h>
    2424
     25#include <abstractaccount_utils.h>
     26
     27#include "bcgateway.h"
     28
    2529namespace SwisscomXtraZone {
    2630
     
    3640    qDebug() << "Start sending SMS";
    3741
    38     /* PROGRESS:
    39      *
    40      * Login:    10%
    41      *
    42      * Send SMS: 80%
    43      *   - Remove recipients: 20%
    44      *   - Add recipients:    60%
    45      *   - Send SMS:          20%
    46      *
    47      * Logout:   10%
    48      *
    49      */
    50 
    5142    try {
    5243        setProgress(0);
     
    5445            account()->reloadOnlineParams();
    5546
    56             QStringList longSMSList = account()->splitTextToLongSMS(message());
    57             int shortSMSCnt         = account()->shortSMSCount(message());
     47            CHECK_FREE_SMS_COUNT()
    5848
    59             if (shortSMSCnt * recipients().size() > account()->freeSMSCount()) {
    60                 EException(tr("You have only %1 SMS for free but you need at least %2 SMS left to send this message.")
    61                                .arg(account()->freeSMSCount()).arg(shortSMSCnt * recipients().size()))
    62                         .raise();
    63             }
     49            QStringList longSMSList = account()->divideMessage(message());
    6450            setProgress(10);
    6551
  • gateways/SwisscomXtraZone/src/business/bcgateway.h

    r217 r275  
    3535const QString URL_ANTICAPTCHA = "http://captcha.smssender.gorrion.ch/";
    3636
    37 const short   MAX_RECIPIENTS_PER_SMS = 10;
    38 const short   SHORTSMS_LENGTH        = 160;
     37const short MAX_RECIPIENTS_PER_SMS  = 10;
    3938
    4039class BCGateway : public AbstractGateway {
  • gateways/SwisscomXtraZone/src/ui/vcsettingswidget.cpp

    r217 r275  
    2424
    2525#include "business/bcaccount.h"
     26#include "business/bcgateway.h"
    2627
    2728namespace SwisscomXtraZone {
  • lib/datatypes/datatypes.pro

    r256 r275  
    2626    src/scontact_p.h \
    2727    src/sdatatypes.h \
     28    src/datatypes_global.h \
    2829    src/sdummyaccount.h \
    2930    src/sgroup.h \
     
    3940    src/stask_p.h \
    4041    src/stask_predefined.h \
     42    src/sutils.h \
    4143    src/sversion.h \
    4244    src/abstract/abstractaccount.h \
    4345    src/abstract/abstractaccount_tasks.h \
     46    src/abstract/abstractaccount_utils.h
    4447    src/abstract/abstractgateway.h \
    4548    src/abstract/persistence/abstractaccountstorageofficer.h \
     
    8184    src/validation/sstdaccountvalidator.h \
    8285    src/validation/svalidationresult.h \
    83     src/datatypes_global.h
    8486SOURCES += src/scontact.cpp \
     87    src/sdatatypes.cpp \
    8588    src/sdummyaccount.cpp \
    8689    src/sgroup.cpp \
     
    9295    src/stask.cpp \
    9396    src/stask_predefined.cpp \
     97    src/sutils.cpp \
    9498    src/sversion.cpp \
    9599    src/abstract/abstractaccount.cpp \
     
    109113    src/interfaces/iaccount.cpp \
    110114    src/interfaces/iaccount_tasks.cpp \
     115    src/interfaces/icontactimporter.cpp
    111116    src/interfaces/ilibrary.cpp \
    112117    src/interfaces/persistence/iaccountlistmanager.cpp \
    113118    src/interfaces/persistence/istorage.cpp \
     119    src/interfaces/persistence/istorageofficer.cpp \
    114120    src/interfaces/ui/iclosepreventabledialog.cpp \
    115121    src/interfaces/ui/isendingdialog.cpp \
     
    117123    src/validation/sstdaccountvalidator.cpp \
    118124    src/validation/svalidationresult.cpp \
    119     src/interfaces/persistence/istorageofficer.cpp \
    120     src/interfaces/icontactimporter.cpp \
    121     src/sdatatypes.cpp
    122125RESOURCES = lib/datatypes.qrc
    123126unix {
  • lib/datatypes/src/abstract/abstractaccount.cpp

    r240 r275  
    2727
    2828#include "iaccount_tasks.h"
     29#include "igateway.h"
    2930
    3031#include "exceptions/eexception.h"
     
    149150    if (task) {
    150151        connect(task, SIGNAL(finished(STask*)), this, SLOT(onInitFinished(STask*)), Qt::DirectConnection);
     152    } else {
     153        setInitialized(true);
    151154    }
    152155
     
    270273    return doCreateSMSSendTask(message, recipients);
    271274}
     275
     276
     277/******** SMS SPLITTING ********/
     278
     279/**
     280 * Divide a message text into several fragments, none bigger than the
     281 * maximum SMS message size.
     282 *
     283 * @param QString text The text which should be divided
     284 * @return Returns a list of the sms fragments
     285 */
     286QStringList AbstractAccount::divideMessage(const QString& text) const {
     287    return divideMessage(text, fragmentSize());
     288}
     289QStringList AbstractAccount::divideMessage(const QString& text, int fragmentSize) const {
     290    QString text_ = text;
     291    QStringList ret;
     292
     293    int lastCut = 0;
     294    int pos = 0;
     295    while (pos < text_.length()) {
     296        int realLength  = 0;
     297
     298        while (pos < text_.length()) {
     299            if (gateway()->doublePriceChars().contains(text_.at(pos))) {
     300                ++realLength;
     301            }
     302            ++realLength;
     303
     304            if (realLength <= fragmentSize) {
     305                ++pos;
     306            } else {
     307                break;
     308            }
     309        }
     310
     311        ret.append(text.mid(lastCut, (pos - lastCut)));
     312        lastCut = pos;
     313    }
     314
     315    return ret;
     316}
  • lib/datatypes/src/abstract/abstractaccount.h

    r220 r275  
    8282
    8383protected:
     84    virtual QStringList        divideMessage(const QString& text) const;
     85    virtual QStringList        divideMessage(const QString& text, int fragmentSize) const;
     86    /**
     87     * Returns the number of chars that fit into one fragment.<br/>
     88     * Should be synchronized with the gateway since we relay on this count.
     89     */
     90    virtual int                fragmentSize() const =0;
     91
     92protected:
    8493    QMutex& mutex() const;
    8594
  • lib/datatypes/src/interfaces/iaccount.h

    r220 r275  
    7474
    7575public:
    76     virtual QList<QString> splitTextToLongSMS(const QString& text) const =0;
    77     virtual int            shortSMSCount(const QString& text) const =0;
    78     virtual int            costsForText(const QString& message) const =0;
     76    virtual QStringList divideMessage(const QString& text) const =0;
     77    virtual int         costsForText(const QString& message) const =0;
    7978
    8079public:
  • lib/datatypes/src/interfaces/imanagers.h

    r236 r275  
    8686    void accountRemoved(IAccount* account);
    8787    void accountInitStateChanged(IAccount* account);
     88    void accountLoginStateChanged(IAccount *account);
    8889
    8990public:
     
    211212Q_DECLARE_INTERFACE(IGuiManager, "ch.gorrion.smssender.IGuiManager/1.0")
    212213
     214
     215class IStorage;
    213216
    214217class DATATYPES_SHARED_EXPORT ISettingsManager : public QObject {
     
    263266    virtual void setSendShortCut(const QKeySequence& shortcut) =0;
    264267
     268public:
     269    virtual IStorage * storage() const =0;
     270
    265271signals:
    266272    void settingChanged(Settings::Setting setting);
  • lib/datatypes/src/interfaces/persistence/isettings.h

    r236 r275  
    2626
    2727#include "datatypes_global.h"
     28
     29class IStorage;
    2830
    2931class DATATYPES_SHARED_EXPORT ISettings : public QObject {
     
    7779
    7880public:
     81    virtual IStorage * storage() const =0;
     82
     83public:
    7984    ISettings(QObject *parent)
    8085        : QObject(parent)
  • lib/datatypes/src/interfaces/persistence/istorage.h

    r218 r275  
    4040    virtual bool         readBool(const QString& _namespace, const QString& key, bool defaultValue = false) =0;
    4141    virtual int          readInt(const QString& _namespace, const QString& key, int defaultValue = 0) =0;
    42     virtual QString      readString(const QString& _namespace, const QString& key, const QString& defaultValue = "") =0;
     42    virtual QString      readString(const QString& _namespace, const QString& key, const QString& defaultValue = QString()) =0;
    4343    virtual QString      readEncryptedString(const QString& _namespace, const QString& key, const QString& password, const QString& defaultValue = "") =0;
    4444    virtual QImage       readImage(const QString& _namespace, const QString& key, const QImage& defaultValue = QImage()) =0;
  • lib/datatypes/src/sdummyaccount.cpp

    r217 r275  
    4949}
    5050
    51 /*IOwn*/IAccount* SDummyGateway::createAccountInstance(IStorage* storage) {
     51IAccount* SDummyGateway::createAccountInstance(IStorage* storage) {
    5252    return new SDummyAccount(this, name(), storage);
    5353}
     
    136136/***** Costs *****/
    137137
    138 QList<QString> SDummyAccount::splitTextToLongSMS(const QString& text) const {
    139     QList<QString> msgs;
    140     msgs.append(text);
    141     return msgs;
    142 }
    143 int SDummyAccount::shortSMSCount(const QString& text) const {
    144     return splitTextToLongSMS(text).size();
     138int SDummyAccount::fragmentSize() const {
     139    return INT_MAX;
    145140}
    146141
  • lib/datatypes/src/sdummyaccount.h

    r218 r275  
    7070
    7171public: /* IAccount - costs */
    72     QList<QString>   splitTextToLongSMS(const QString& text) const;
    73     int              shortSMSCount(const QString& text) const;
    7472    int              costsForText(const QString& message) const;
     73    int              fragmentSize() const;
    7574
    7675public: /* AbstractAccount */
  • src/business/bcaccountmanager.cpp

    r217 r275  
    4040    connect(account, SIGNAL(dataChanged(IAccount*, int)),
    4141            this, SLOT(onAccountDataChanged(IAccount*, int)));
     42    connect(account, SIGNAL(loggedIn(IAccount*)), this, SIGNAL(accountLoginStateChanged(IAccount*)));
     43    connect(account, SIGNAL(loggedOut(IAccount*)), this, SIGNAL(accountLoginStateChanged(IAccount*)));
    4244
    4345    emit accountAdded(account);
  • src/business/bcsettings.cpp

    r217 r275  
    3434}
    3535
    36 ISettings* BCSettings::settings() {
     36ISettings* BCSettings::settings() const {
    3737    return PersistenceFactory::instance()->getSettings();
    3838}
     
    285285    emit settingChanged(Settings::ShortcutSend);
    286286}
     287
     288IStorage * BCSettings::storage() const {
     289    return settings()->storage();
     290}
  • src/business/bcsettings.h

    r217 r275  
    8282    void setSendShortCut(const QKeySequence& shortcut);
    8383
     84public:
     85    IStorage * storage() const;
     86
    8487protected:
    8588    QString getSMSSuffix();
     
    8790
    8891private:
    89     ISettings* settings();
     92    ISettings* settings() const;
    9093};
    9194
  • src/persistence/dasettings.cpp

    r236 r275  
    188188
    189189
    190 IStorage* DASettings::storage(){
     190IStorage * DASettings::storage() const{
    191191    return PersistenceFactory::instance()->storage();
    192192}
  • src/persistence/dasettings.h

    r236 r275  
    7878        void setSendShortCut(const QKeySequence& shortcut);
    7979
    80 protected:
    81     IStorage* storage();
     80public:
     81    IStorage * storage() const;
    8282
    8383private:
  • src/ui/models/accounttreemodel.cpp

    r217 r275  
    119119                    return QString("%1 (%2)").arg(account->name()).arg(account->freeSMSCount());
    120120                } else {
    121                     return account->gateway()->name();
     121                    return account->name();
    122122                }
    123123            case ColGatewayName:
  • src/ui/models/loadedaccountmodel.cpp

    r217 r275  
    2525    : QSortFilterProxyModel(parent)
    2626{
    27     connect(BCAccountManager::instance(), SIGNAL(accountInitStateChanged(IAccount*)),
    28             this, SLOT(onAccountInitStateChanged(IAccount*)));
     27    connect(BCAccountManager::instance(), SIGNAL(accountLoginStateChanged(IAccount*)),
     28            this, SLOT(onAccountLoginStateChanged(IAccount*)));
    2929}
    3030
     
    3636        IAccount* account = srcModel->dataObject(idx);
    3737
    38         return account && account->isInitialized() && account->isEnabled();
     38        return account && account->isLoggedIn() && account->isEnabled();
    3939    } else {
    4040        return false;
     
    6868}
    6969
    70 void LoadedAccountModel::onAccountInitStateChanged(IAccount* account) {
     70void LoadedAccountModel::onAccountLoginStateChanged(IAccount* account) {
    7171    AccountTreeModel* srcModel = qobject_cast<AccountTreeModel*>(sourceModel());
    7272    Q_ASSERT(srcModel);
  • src/ui/models/loadedaccountmodel.h

    r217 r275  
    3838
    3939private slots:
    40     void onAccountInitStateChanged(IAccount* account);
     40    void onAccountLoginStateChanged(IAccount* account);
    4141};
    4242
  • src/ui/vcimportcontacts/vcimportcontacts_page_import.cpp

    r242 r275  
    6161    }
    6262
     63    // TODO when cancelling also cancel the tasks!
    6364    wizard()->button(QWizard::BackButton)->hide();
    6465    wizard()->button(QWizard::CommitButton)->hide();
     
    190191    // List all used names
    191192    QStringList usedNames;
    192     foreach (SContact c, existingContacts_) {
     193    foreach (SContact c, contacts) {
    193194        if (contact.number() != c.number()) { // Do not check our own names
    194195            usedNames.append(c.name().toLower());
Note: See TracChangeset for help on using the changeset viewer.