Changeset 67:578192d6fe64 in SMSSender


Ignore:
Timestamp:
Feb 7, 2010 4:11:28 PM (8 years ago)
Author:
Sämy Zehnder <saemy.zehnder@…>
Branch:
3.0
Convert:
svn:3639001d-8e34-449c-bb86-3782b86c4877/branches/3.0@66
Message:
  • added synchttp
  • backup before removing these diamond interfaces...
Files:
1 added
17 edited

Legend:

Unmodified
Added
Removed
  • lib/libdatatypes/datatypes.pro

    r65 r67  
    55DESTDIR = ../
    66TARGET = datatypes
    7 QT += core
     7QT += core \
     8    network
    89LIBS += -L../
    910LIBS += -linterfaces \
     
    1819    src/business/BCGroup.h \
    1920    src/snumber.h \
    20     src/sshortcut.h
     21    src/sshortcut.h \
     22    src/synchttp.h
    2123SOURCES += src/business/BCBinary.cpp \
    2224    src/business/BCContact.cpp \
  • lib/libgateway/gateway.pro

    r65 r67  
    1111LIBS += -L../
    1212LIBS += -linterfaces \
    13     -lutils
     13    -lutils \
     14    -ldatatypes
    1415INCLUDEPATH += app \
    1516    ../libinterfaces/src/exceptions/ \
    1617    ../libinterfaces/src/business/ \
    1718    ../libinterfaces/src/ \
    18     ../libutils/src/
     19    ../libutils/src/ \
     20    ../libdatatypes/src \
     21    ../libdatatypes/src/business
    1922HEADERS += src/business/validation/BCLoginAccountValidator.h \
    2023    src/business/AbstractAccount.h \
  • lib/libgateway/src/business/AbstractAccount.cpp

    r43 r67  
    105105
    106106void AbstractAccount::initialize(){
    107     if (initializing_ || initialized_ || !isEnabled()) {
     107    if (isInitializing() || isInitialized() || !isEnabled()) {
    108108        return;
    109109    }
     
    120120
    121121        if (!stoppingInitialization_)
    122             initialized_ = true;
     122            setInitialized(true);
    123123    }catch (...) {
    124124        initializing_ = false;
     
    142142}
    143143
     144void AbstractAccount::setInitialized(bool initialized) {
     145    SET_IF_DIFFERENT(initialized_, initialized);
     146    emit accountEvents()->dataChanged();
     147}
     148
     149
    144150void AbstractAccount::unInitialize() {
    145151    if (isInitializing())
    146152        stopInitializing();
    147153
    148     initialized_ = false;
     154    setInitialized(false);
    149155}
    150156
  • lib/libgateway/src/business/AbstractAccount.h

    r43 r67  
    7979
    8080    IStorageOfficer* storageOfficer_;
    81     IValidator*            validator_;
     81    IValidator*      validator_;
     82
     83    void    setInitialized(bool initialized);
    8284};
    8385
  • lib/libgateway/src/business/HttpHelper.cpp

    r53 r67  
    146146}*/
    147147
    148 void HttpHelper::waitForRequest(bool createIfNotExisting /* = true */) {
    149     if (!requestLoop_.isRunning() && !createIfNotExisting){
     148void HttpHelper::waitForRequest(bool createLoopIfNotExisting) {
     149    if (!requestLoop_.isRunning() && !createLoopIfNotExisting){
    150150        return;
    151151    }
    152152
    153153    qDebug() << "Waiting for the request to finish...";
     154    while (!request_.finished && thread()->isRunning()) {
     155        thread()->wait(100);
     156    }
    154157/*    while (!request_.finished && thread()->isRunning()) {
    155158        thread()->wait(100);
    156159    }*/
    157     requestLoop_.exec(QEventLoop::ExcludeUserInputEvents|QEventLoop::ExcludeSocketNotifiers|QEventLoop::WaitForMoreEvents);
     160//    requestLoop_.exec(QEventLoop::ExcludeUserInputEvents|QEventLoop::ExcludeSocketNotifiers|QEventLoop::WaitForMoreEvents);
    158161    qDebug() << "The request finished -> continuing";
    159162/*    while (!request_.finished) {
  • lib/libgateway/src/business/HttpHelper.h

    r52 r67  
    99#define HTTPHELPER_H_
    1010
    11 #include <iaccount.h>
    12 
    13 #include "HttpCookieManager.h"
    14 
    1511#include <QBuffer>
    1612#include <QEventLoop>
     
    1814#include <QHttp>
    1915#include <QHttpResponseHeader>
     16
     17#include <iaccount.h>
     18
     19#include "HttpCookieManager.h"
     20
    2021
    2122class HttpRequest: public QObject {
  • src/business/BCAccountLoadThread.cpp

    r62 r67  
    11#include "BCAccountLoadThread.h"
    22
    3 /*short const AccountLoadThread::State::Unloaded   = 0;
    4 short const AccountLoadThread::State::Loading    = 1;
    5 short const AccountLoadThread::State::Loaded     = 2;
    6 short const AccountLoadThread::State::Cancelling = 3;
    7 short const AccountLoadThread::State::Cancelled  = 4;
    8 short const AccountLoadThread::State::Failed     = 5;*/
    9 
    10 BCAccountLoadThread::BCAccountLoadThread(IAccount* account, QObject* parent /* = 0 */)
     3BCAccountLoadThread::BCAccountLoadThread(IAccount* account, QObject* parent)
    114    : QThread(parent)
    125    , account_(account)
     
    2013        if (account_->isInitialized()) {
    2114            setLoadState(Loaded);
    22             loaded(account()); // Signal
    23             loadingFinished(account(), loadState()); // Signal
     15            emit loaded(account()); // Signal
     16            emit loadingFinished(account(), loadState()); // Signal
    2417
    2518            return;
     
    3225        } catch (EException* exception) {
    3326            setLoadState(Failed);
    34             loadingFailed(account(), exception); // Signal
     27            emit loadingFailed(account(), exception); // Signal
    3528        } catch (...) {
    3629        setLoadState(Failed);
    37             loadingFailed(account(), new EException("Unknown error occured while loading an account.")); // Signal
     30            emit loadingFailed(account(), new EException("Unknown error occured while loading an account.")); // Signal
    3831        }
    3932
     
    4740        default:
    4841            setLoadState(Loaded);
    49             loaded(account()); // Signal
     42            emit loaded(account()); // Signal
    5043            break;
    5144        }
    52         loadingFinished(account(), loadState()); // Signal
     45        emit loadingFinished(account(), loadState()); // Signal
    5346}
    5447
     
    6356        loadState_ = loadState;
    6457
    65         loadStateChanged(account(), this->loadState()); // Signal
     58        emit loadStateChanged(account(), this->loadState()); // Signal
    6659    }
    6760}
  • src/business/BCAccountManager.cpp

    r43 r67  
    6464
    6565QSet<IAccount*> BCAccountManager::getAccountList(){
    66     return QSet<IAccount*>::fromList(accountList_.values());
     66    return accountList_.values().toSet();
    6767}
    6868
     
    100100}
    101101void BCAccountManager::accountDataChanged() {
    102     IAccount* account = static_cast<AccountEventMapper*>(sender())->account();
     102    AccountEventMapper* eventMapper = qobject_cast<AccountEventMapper*>(sender());
     103    IAccount* account = eventMapper->account();
    103104    Q_ASSERT(account);
    104105    emit accountUpdated(account);
  • src/ui/VCMain/vcmain.cpp

    r60 r67  
    2828#include "../completers/bettercompleter.h"
    2929#include "../models/aliascompletionmodel.h"
     30#include "../models/loadedaccountmodel.h"
    3031
    3132#include "../delegates/aligndelegate.h"
     
    3738        /* Accounts */
    3839        accountModel_       = new AccountTreeModel(this);
    39         accountFilterModel_ = new QSortFilterProxyModel(this);
     40        accountFilterModel_ = new LoadedAccountModel(this);
    4041        accountFilterModel_->setSourceModel(accountModel_);
    4142        accountFilterModel_->setSortCaseSensitivity(Qt::CaseInsensitive);
    4243        accountFilterModel_->setDynamicSortFilter(true);
    43         accountFilterModel_->setFilterKeyColumn(AccountTreeModel::ColEnabled);
    44         accountFilterModel_->setFilterRole(Qt::CheckStateRole);
    45         accountFilterModel_->setFilterFixedString("1"); // Get only enabled ones
    4644        accountFilterModel_->sort(AccountTreeModel::ColName, Qt::AscendingOrder);
    4745        ui.lstAccounts->setModel(accountFilterModel_);
  • src/ui/models/accounttreemodel.cpp

    r56 r67  
    77{
    88    connect(BCAccountManager::instance(), SIGNAL(accountAdded(IAccount*)),
    9             this, SLOT(accountUpdated(IAccount*)));
     9            this, SLOT(listAltered()));
    1010    connect(BCAccountManager::instance(), SIGNAL(accountUpdated(IAccount*)),
    1111            this, SLOT(accountUpdated(IAccount*)));
    1212    connect(BCAccountManager::instance(), SIGNAL(accountRemoved(IAccount*)),
    13             this, SLOT(accountUpdated(IAccount*)));
     13            this, SLOT(listAltered()));
     14
     15    reloadList();
    1416}
    1517AccountTreeModel::~AccountTreeModel() {
    1618    disconnect(BCAccountManager::instance(), SIGNAL(accountAdded(IAccount*)),
    17                this, SLOT(accountUpdated(IAccount*)));
     19               this, SLOT(listAltered()));
    1820    disconnect(BCAccountManager::instance(), SIGNAL(accountUpdated(IAccount*)),
    1921               this, SLOT(accountUpdated(IAccount*)));
    2022    disconnect(BCAccountManager::instance(), SIGNAL(accountRemoved(IAccount*)),
    21                this, SLOT(accountUpdated(IAccount*)));
     23               this, SLOT(listAltered()));
     24}
     25
     26void AccountTreeModel::listAltered() {
     27    reloadList();
    2228}
    2329
    2430void AccountTreeModel::accountUpdated(IAccount* account) {
    25     int row = BCAccountManager::instance()->getAccountList().values().indexOf(account);
     31    int row = items_.indexOf(account);
    2632
    2733    QModelIndex idx_start = index(row, 0);
    28     QModelIndex idx_end   = index(row, MaxCol);
     34    QModelIndex idx_end   = index(row, columnCount());
    2935
    3036    if (idx_start.isValid() && idx_end.isValid()) {
    3137        emit dataChanged(idx_start, idx_end);
    32     } else {
    33         reset();
    3438    }
     39}
     40
     41void AccountTreeModel::reloadList() {
     42    items_.clear();
     43    foreach(IAccount* account, BCAccountManager::instance()->getAccountList()) {
     44        items_.append(account);
     45    }
     46    reset();
    3547}
    3648
     
    5264
    5365IAccount* AccountTreeModel::dataObject(const QModelIndex& index) const {
    54     return BCAccountManager::instance()->getAccountList().values().at(index.row());
     66    return items_.at(index.row());
    5567}
    5668
    5769QVariant AccountTreeModel::data(const QModelIndex& index, int role) const {
    58     QList<IAccount*> accounts = BCAccountManager::instance()->getAccountList().values();
    59     if (!index.isValid() || index.row() < 0 || index.row() >= accounts.size())
     70    if (!index.isValid() || index.row() < 0 || index.row() >= items_.size())
    6071        return QVariant();
    6172
    62     const IAccount* account = accounts.at(index.row());
     73    const IAccount* account = items_.at(index.row());
    6374
    6475    if (role == Qt::DisplayRole) {
     
    132143
    133144int AccountTreeModel::rowCount(const QModelIndex& parent) const {
    134     return (parent.isValid()) ? 0 : BCAccountManager::instance()->getAccountList().count();
     145    return (parent.isValid()) ? 0 : items_.count();
    135146}
    136147
     
    141152    int lastRow = row + count - 1;
    142153    beginRemoveRows(parent, row, lastRow);
    143     QList<IAccount*> accounts = BCAccountManager::instance()->getAccountList().values();
    144154    for (int i = lastRow; i >= row; --i) {
    145         BCAccountManager::instance()->removeAccount(accounts.at(i)->id());
     155        BCAccountManager::instance()->removeAccount(items_.at(i)->id());
    146156    }
    147157    endRemoveRows();
  • src/ui/models/accounttreemodel.h

    r56 r67  
    1010class AccountTreeModel: public QAbstractTableModel {
    1111    Q_OBJECT
    12 
    13 public slots:
    14     void accountUpdated(IAccount* account);
    1512
    1613public:
     
    3532
    3633    IAccount*     dataObject(const QModelIndex& index) const;
     34
     35public slots:
     36    void accountUpdated(IAccount* account);
     37    void listAltered();
     38
     39private:
     40    QList<IAccount*> items_;
     41
     42    void          reloadList();
    3743};
    3844
  • src/ui/models/contactgroupmodel.cpp

    r55 r67  
    99{
    1010    connect(BCContactManager::instance(), SIGNAL(contactAdded(IContact*)),
    11             this, SLOT(dataUpdated(IContact*)));
     11            this, SLOT(listAltered()));
    1212    connect(BCContactManager::instance(), SIGNAL(contactUpdated(IContact*)),
    1313            this, SLOT(dataUpdated(IContact*)));
    1414    connect(BCContactManager::instance(), SIGNAL(contactRemoved(IContact*)),
    15             this, SLOT(dataUpdated(IContact*)));
     15            this, SLOT(listAltered()));
    1616
    1717    connect(BCGroupManager::instance(), SIGNAL(groupAdded(IGroup*)),
    18             this, SLOT(dataUpdated(IGroup*)));
     18            this, SLOT(listAltered()));
    1919    connect(BCGroupManager::instance(), SIGNAL(groupUpdated(IGroup*)),
    2020            this, SLOT(dataUpdated(IGroup*)));
    2121    connect(BCGroupManager::instance(), SIGNAL(groupRemoved(IGroup*)),
    22             this, SLOT(dataUpdated(IGroup*)));
     22            this, SLOT(listAltered()));
    2323
    2424    reloadList();
     
    2626ContactGroupListModel::~ContactGroupListModel() {
    2727    disconnect(BCContactManager::instance(), SIGNAL(contactAdded(IContact*)),
    28                this, SLOT(dataUpdated(IContact*)));
     28               this, SLOT(listAltered()));
    2929    disconnect(BCContactManager::instance(), SIGNAL(contactUpdated(IContact*)),
    3030               this, SLOT(dataUpdated(IContact*)));
    3131    disconnect(BCContactManager::instance(), SIGNAL(contactRemoved(IContact*)),
    32                this, SLOT(dataUpdated(IContact*)));
     32               this, SLOT(listAltered()));
    3333
    3434    disconnect(BCGroupManager::instance(), SIGNAL(groupAdded(IGroup*)),
    35                this, SLOT(dataUpdated(IGroup*)));
     35               this, SLOT(listAltered()));
    3636    disconnect(BCGroupManager::instance(), SIGNAL(groupUpdated(IGroup*)),
    3737               this, SLOT(dataUpdated(IGroup*)));
    3838    disconnect(BCGroupManager::instance(), SIGNAL(groupRemoved(IGroup*)),
    39                this, SLOT(dataUpdated(IGroup*)));
     39               this, SLOT(listAltered()));
     40}
     41
     42void ContactGroupListModel::listAltered() {
     43    reloadList();
    4044}
    4145
     
    4852void ContactGroupListModel::dataUpdated(IInterface* contactOrGroup) {
    4953    int row = items_.indexOf(contactOrGroup);
     54
    5055    QModelIndex idx1 = index(row, 0);
    51 
    52     row = items_.indexOf(contactOrGroup);
    53 
    54     reloadList();
    55 
    56     if (row < 0) { // New contact/group added
    57         reset();
    58     } else {
    59         row = items_.indexOf(contactOrGroup);
    60 
    61         if (row < 0) { // Contact/group removed
    62             reset();
    63         } else {
    64             QModelIndex idx2 = index(row, 0);
    65 
    66             emit dataChanged(idx1, idx1);
    67             if (idx1 != idx2) {
    68                 emit dataChanged(idx2, idx2);
    69             }
    70         }
     56    QModelIndex idx2 = index(row, columnCount());
     57
     58    if (idx1.isValid() && idx2.isValid()) { // Contact/group in list
     59        emit dataChanged(idx1, idx2);
    7160    }
    7261}
     
    8069        items_.append(group);
    8170    }
     71
     72    reset();
    8273}
    8374
  • src/ui/models/contactgroupmodel.h

    r43 r67  
    3131    void dataUpdated(IContact* contact);
    3232    void dataUpdated(IGroup* group);
     33    void listAltered();
    3334
    3435private:
  • src/ui/models/grouptablemodel.cpp

    r61 r67  
    99{
    1010    connect(BCGroupManager::instance(), SIGNAL(groupAdded(IGroup*)),
    11             this, SLOT(groupUpdated(IGroup*)));
     11            this, SLOT(listAltered()));
    1212    connect(BCGroupManager::instance(), SIGNAL(groupUpdated(IGroup*)),
    1313            this, SLOT(groupUpdated(IGroup*)));
    1414    connect(BCGroupManager::instance(), SIGNAL(groupRemoved(IGroup*)),
    15             this, SLOT(groupUpdated(IGroup*)));
     15            this, SLOT(listAltered()));
    1616}
    1717GroupTableModel::~GroupTableModel() {
    1818    disconnect(BCGroupManager::instance(), SIGNAL(groupAdded(IGroup*)),
    19                this, SLOT(groupUpdated(IGroup*)));
     19               this, SLOT(listAltered()));
    2020    disconnect(BCGroupManager::instance(), SIGNAL(groupUpdated(IGroup*)),
    2121               this, SLOT(groupUpdated(IGroup*)));
    2222    disconnect(BCGroupManager::instance(), SIGNAL(groupRemoved(IGroup*)),
    23                this, SLOT(groupUpdated(IGroup*)));
     23               this, SLOT(listAltered()));
     24}
     25
     26void GroupTableModel::listAltered() {
     27    reloadList();
    2428}
    2529
    2630void GroupTableModel::groupUpdated(IGroup* group) {
    27     int row = BCGroupManager::instance()->getGroupList().values().indexOf(group);
     31    int row = items_.indexOf(group);
    2832
    2933    QModelIndex idx_start = index(row, 0);
     
    3539        reset();
    3640    }
     41}
     42
     43void GroupTableModel::reloadList() {
     44    items_.clear();
     45    foreach(IGroup* group, BCGroupManager::instance()->getGroupList()) {
     46        items_.append(group);
     47    }
     48    reset();
    3749}
    3850
     
    5466
    5567IGroup* GroupTableModel::dataObject(const QModelIndex& index) const {
    56     return BCGroupManager::instance()->getGroupList().values().at(index.row());
     68    return items_.at(index.row());
    5769}
    5870
    5971QVariant GroupTableModel::data(const QModelIndex& index, int role) const {
    60     QList<IGroup*> groups = BCGroupManager::instance()->getGroupList().values();
    61     if (!index.isValid() || index.row() < 0 || index.row() >= groups.size())
     72    if (!index.isValid() || index.row() < 0 || index.row() >= items_.size())
    6273        return QVariant();
    6374
    64     const IGroup* group = groups.at(index.row());
     75    const IGroup* group = dataObject(index);
    6576
    6677    if (role == Qt::DisplayRole) {
     
    89100
    90101int GroupTableModel::rowCount(const QModelIndex& parent) const {
    91     return (parent.isValid()) ? 0 : BCGroupManager::instance()->getGroupList().count();
     102    return (parent.isValid()) ? 0 : items_.count();
    92103}
    93104
     
    98109    int lastRow = row + count - 1;
    99110    beginRemoveRows(parent, row, lastRow);
    100     QList<IGroup*> groups = BCGroupManager::instance()->getGroupList().values();
    101111    for (int i = lastRow; i >= row; --i) {
    102         BCGroupManager::instance()->removeGroup(groups.at(i)->id());
     112        BCGroupManager::instance()->removeGroup(items_.at(i)->id());
    103113    }
    104114    endRemoveRows();
  • src/ui/models/grouptablemodel.h

    r55 r67  
    99class GroupTableModel: public QAbstractTableModel {
    1010    Q_OBJECT
    11 
    12 public slots:
    13     void groupUpdated(IGroup* contact);
    1411
    1512public:
     
    3330    IGroup*       dataObject(const QModelIndex& index) const;
    3431
     32public slots:
     33    void groupUpdated(IGroup* contact);
     34    void listAltered();
     35
    3536private:
    36     QString       getMembersStr(const IGroup* group) const;
     37    QList<IGroup*> items_;
     38
     39    QString        getMembersStr(const IGroup* group) const;
     40    void           reloadList();
    3741};
    3842
  • src/ui/models/loadedaccountmodel.cpp

    r57 r67  
    88#include "loadedaccountmodel.h"
    99
    10 LoadedAccountModel::LoadedAccountModel() {
    11     // TODO Auto-generated constructor stub
     10#include "accounttreemodel.h"
    1211
     12bool LoadedAccountModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const {
     13    AccountTreeModel* srcModel = static_cast<AccountTreeModel*>(sourceModel());
     14    const QModelIndex& idx     = srcModel->index(source_row, 0, source_parent);
     15    if (idx.isValid()) {
     16        IAccount* account          = srcModel->dataObject(idx);
     17
     18        return (account != NULL) && account->isInitialized() && account->isEnabled();
     19    } else
     20        return false;
    1321}
    14 
    15 LoadedAccountModel::~LoadedAccountModel() {
    16     // TODO Auto-generated destructor stub
    17 }
  • src/ui/models/loadedaccountmodel.h

    r57 r67  
    99#define LOADEDACCOUNTMODEL_H_
    1010
    11 class LoadedAccountModel {
     11#include <QSortFilterProxyModel>
     12
     13class LoadedAccountModel: public QSortFilterProxyModel {
    1214public:
    13     LoadedAccountModel();
    14     virtual ~LoadedAccountModel();
     15    LoadedAccountModel(QObject* parent = NULL)
     16      : QSortFilterProxyModel(parent)
     17    {};
     18
     19
     20protected:
     21    bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const;
    1522};
    1623
Note: See TracChangeset for help on using the changeset viewer.