"Fossies" - the Fresh Open Source Software Archive

Member "seafile-client-7.0.4/src/account-info-service.cpp" (19 Nov 2019, 1502 Bytes) of package /linux/www/seafile-client-7.0.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "account-info-service.cpp" see the Fossies "Dox" file reference documentation.

    1 #include <QTimer>
    2 
    3 #include "account-info-service.h"
    4 #include "account-mgr.h"
    5 #include "api/api-error.h"
    6 #include "api/requests.h"
    7 #include "seafile-applet.h"
    8 
    9 namespace
   10 {
   11 // const int kRefreshInterval = 3 * 60 * 1000; // 3 min
   12 }
   13 
   14 SINGLETON_IMPL(AccountInfoService)
   15 
   16 AccountInfoService::AccountInfoService(QObject* parent)
   17     : QObject(parent), request_(NULL)
   18 {
   19     refresh_timer_ = new QTimer(this);
   20     connect(refresh_timer_, SIGNAL(timeout()), this, SLOT(refresh()));
   21     refresh();
   22 }
   23 
   24 void AccountInfoService::start()
   25 {
   26     // refresh_timer_->start(kRefreshInterval);
   27 }
   28 
   29 void AccountInfoService::stop()
   30 {
   31     refresh_timer_->stop();
   32 }
   33 
   34 void AccountInfoService::refresh()
   35 {
   36     const Account account = seafApplet->accountManager()->currentAccount();
   37     if (!account.isValid()) {
   38         return;
   39     }
   40     if (request_) {
   41         request_->deleteLater();
   42     }
   43 
   44     request_ = new FetchAccountInfoRequest(account);
   45     connect(request_, SIGNAL(success(const AccountInfo&)), this,
   46             SLOT(onFetchAccountInfoSuccess(const AccountInfo&)));
   47     connect(request_, SIGNAL(failed(const ApiError&)), this,
   48             SLOT(onFetchAccountInfoFailed()));
   49     request_->send();
   50 }
   51 
   52 
   53 void AccountInfoService::onFetchAccountInfoSuccess(const AccountInfo& info)
   54 {
   55     seafApplet->accountManager()->updateAccountInfo(request_->account(), info);
   56     request_->deleteLater();
   57     request_ = NULL;
   58 }
   59 
   60 void AccountInfoService::onFetchAccountInfoFailed()
   61 {
   62     request_->deleteLater();
   63     request_ = NULL;
   64 }