source: SMSSender/gateways/SwisscomXtraZone/src/business/BCGateway.cpp @ 71:415b45c71663

3.0
Last change on this file since 71:415b45c71663 was 71:415b45c71663, checked in by Sämy Zehnder <saemy.zehnder@…>, 12 years ago
  • Reorganized all the libraries. libinterfaces and libgateways are removed now and libdatatypes contains now all these files.
File size: 2.8 KB
Line 
1/*
2 * BCGateway.cpp
3 *
4 *  Created on: Jul 9, 2009
5 *      Author: saemy
6 */
7
8#include "BCGateway.h"
9
10#include "BCAccount.h"
11#include "ui/vcsettingswidget.h"
12
13namespace SwisscomXtraZone {
14
15AbstractLoginGateway* BCGateway::instance_ = NULL;
16AbstractLoginGateway* BCGateway::instance(){
17    return instance_ ? instance_ : (instance_ = new BCGateway);
18}
19
20
21QString BCGateway::name() const {
22    return "SwisscomXtraZone";
23}
24
25QImage BCGateway::icon() const {
26    return QImage(":/images/SwisscomXtraZone.ico");
27}
28
29QSet<int> BCGateway::validRecipientCountryCodes() const {
30    QSet<int> result;
31    result.insert(41); // CH
32    return result;
33}
34
35IAccount* BCGateway::createAccountInstance(IStorage* storage) const {
36    return new BCAccount(storage);
37}
38
39IAccountSettingsWidget* BCGateway::getAccountSettingsWidget(QWidget* parent /* = 0 */) const {
40    return new VCSettingsWidget(parent);
41}
42
43
44
45QString BCGateway::addonText() const {
46    return addonText_;
47}
48void BCGateway::setAddonText(const QString& addonText) {
49    addonText_ = addonText;
50}
51
52int BCGateway::longSMSLength() const {
53    return longSMSLength_;
54}
55void BCGateway::setLongSMSLength(int longSMSLength) {
56    longSMSLength_ = longSMSLength;
57}
58
59
60
61/**
62 * Splits the given text into a list of long-sms. <br/>
63 * Since the long-sms-length is synchronized with the gateway, this list is as it will be splitted while sending.
64 *
65 * @param QString text The text which should be splitted
66 * @return Returns a list of the long-sms texts
67 */
68QList<QString> BCGateway::splitTextToLongSMS(const QString& text) const {
69    QList<QString> longSMSList;
70    QString text_(text);
71
72    int longSMSLengthWOAddonText = longSMSLength_ - addonText_.length();
73    while (text_ != "") {
74        longSMSList.append(text_.left(longSMSLengthWOAddonText));
75        text_.remove(0, longSMSLengthWOAddonText);
76    }
77
78    return longSMSList;
79}
80
81/**
82 * Splits the given text into a list of short-sms. <br/>
83 * This is only a hypotetic list, since the short-sms-count could vary and it that is not checked anywhere in here.
84 * The SHORTSMS_LENGTH is a static value.<br/>
85 * However, since the splitTextToLongSMS is the real value (that size is synchronized with the web page) the, short-sms size is
86 * not totally wrong.
87 *
88 * @param QString text The text which should be splitted.
89 * @return Returns a list of the short-sms texts
90 */
91QList<QString> BCGateway::splitTextToShortSMS(const QString& text) const {
92    QList<QString> shortSMSList;
93
94    QList<QString> longSMSList = splitTextToLongSMS(text);
95
96    QListIterator<QString> i(longSMSList);
97    while (i.hasNext()){
98        QString subText = i.next() + addonText_;
99        while (subText != "") {
100            shortSMSList.append(subText.left(SHORTSMS_LENGTH));
101            subText.remove(0, SHORTSMS_LENGTH);
102        }
103    }
104
105    return shortSMSList;
106}
107
108}
Note: See TracBrowser for help on using the repository browser.