void DataManager::start() { account_ = seafApplet->accountManager()->currentAccount(); connect(seafApplet->accountManager(), SIGNAL(accountsChanged()), this, SLOT(onAccountChanged())); }
bool AccountManager::clearAccountToken(const Account& account) { for (size_t i = 0; i < accounts_.size(); i++) { if (accounts_[i] == account) { accounts_[i].token = ""; break; } } char *zql = sqlite3_mprintf( "UPDATE Accounts " "SET token = NULL " "WHERE url = %Q " " AND username = %Q", // url account.serverUrl.toEncoded().data(), // username account.username.toUtf8().data() ); sqlite_query_exec(db, zql); sqlite3_free(zql); emit accountsChanged(); return true; }
RepoTreeView::RepoTreeView(QWidget *parent) : QTreeView(parent) { header()->hide(); createActions(); // We draw the indicator ourselves setIndentation(0); // We handle the click oursevles setExpandsOnDoubleClick(false); connect(this, SIGNAL(clicked(const QModelIndex&)), this, SLOT(onItemClicked(const QModelIndex&))); connect(this, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(onItemDoubleClicked(const QModelIndex&))); #ifdef Q_WS_MAC this->setAttribute(Qt::WA_MacShowFocusRect, 0); #endif loadExpandedCategries(); connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(saveExpandedCategries())); connect(seafApplet->accountManager(), SIGNAL(beforeAccountChanged()), this, SLOT(saveExpandedCategries())); connect(seafApplet->accountManager(), SIGNAL(accountsChanged()), this, SLOT(loadExpandedCategries())); }
void FedgeConfigAccounts::slotKmail() { KConfig config("kmailrc", true); QStringList list; QMap<QString, QString> configmap; int i = 1; while (config.hasGroup("Account " + QString::number(i))) { QString account = "Account " + QString::number(i++); configmap = config.entryMap(account); if (!configmap.empty()) list << account; } int accno = 1; if (list.empty()) return; if (list.size() > 1) { FedgeSelectDialog fsd(0, "Select Kmail Account:", list); accno = fsd.exec(); } KmailAccount account("Account " + QString::number(accno)); m_config->setGroup(newGroup()); addAccount(&account); m_changed = true; emit accountsChanged(); }
void AccountManager::serverInfoSuccess(const Account &account, const ServerInfo &info) { setServerInfoKeyValue(db, account, kVersionKeyName, info.getVersionString()); setServerInfoKeyValue(db, account, kFeaturesKeyName, info.getFeatureStrings().join(",")); setServerInfoKeyValue(db, account, kCustomLogoKeyName, info.customLogo); setServerInfoKeyValue(db, account, kCustomBrandKeyName, info.customBrand); QUrl url(account.serverUrl); url.setPath("/"); seafApplet->rpcClient()->setServerProperty( url.toString(), "is_pro", account.isPro() ? "true" : "false"); bool changed = account.serverInfo != info; if (!changed) return; for (size_t i = 0; i < accounts_.size(); i++) { if (accounts_[i] == account) { if (i == 0) emit beforeAccountChanged(); accounts_[i].serverInfo = info; if (i == 0) emit accountsChanged(); break; } } }
int AccountManager::start() { const char *errmsg; const char *sql; QString db_path = QDir(seafApplet->configurator()->seafileDir()).filePath("accounts.db"); if (sqlite3_open (toCStr(db_path), &db)) { errmsg = sqlite3_errmsg (db); qCritical("failed to open account database %s: %s", toCStr(db_path), errmsg ? errmsg : "no error given"); seafApplet->errorAndExit(tr("failed to open account database")); return -1; } // enabling foreign keys, it must be done manually from each connection // and this feature is only supported from sqlite 3.6.19 sql = "PRAGMA foreign_keys=ON;"; if (sqlite_query_exec (db, sql) < 0) { qCritical("sqlite version is too low to support foreign key feature\n"); sqlite3_close(db); db = NULL; return -1; } sql = "CREATE TABLE IF NOT EXISTS Accounts (url VARCHAR(24), " "username VARCHAR(15), token VARCHAR(40), lastVisited INTEGER, " "PRIMARY KEY(url, username))"; if (sqlite_query_exec (db, sql) < 0) { qCritical("failed to create accounts table\n"); sqlite3_close(db); db = NULL; return -1; } updateAccountDatabaseForColumnShibbolethUrl(db); // create ServerInfo table sql = "CREATE TABLE IF NOT EXISTS ServerInfo (" "key TEXT NOT NULL, value TEXT, " "url VARCHAR(24), username VARCHAR(15), " "PRIMARY KEY(url, username, key), " "FOREIGN KEY(url, username) REFERENCES Accounts(url, username) " "ON DELETE CASCADE ON UPDATE CASCADE )"; if (sqlite_query_exec (db, sql) < 0) { qCritical("failed to create server_info table\n"); sqlite3_close(db); db = NULL; return -1; } loadAccounts(); connect(this, SIGNAL(accountsChanged()), this, SLOT(onAccountsChanged())); return 0; }
void SeahubNotificationsMonitor::start() { resetStatus(); refresh_timer_->start(kRefreshSeahubMessagesInterval); connect(seafApplet->accountManager(), SIGNAL(accountsChanged()), this, SLOT(onAccountChanged())); refresh(); }
int AccountManager::saveAccount(const Account& account) { Account new_account = account; bool account_exist = false; { QMutexLocker lock(&accounts_mutex_); for (size_t i = 0; i < accounts_.size(); i++) { if (accounts_[i] == account) { accounts_.erase(accounts_.begin() + i); account_exist = true; break; } } accounts_.insert(accounts_.begin(), new_account); } updateServerInfo(0); qint64 timestamp = QDateTime::currentMSecsSinceEpoch(); char *zql; if (account_exist) { zql = sqlite3_mprintf( "UPDATE Accounts SET token = %Q, lastVisited = %Q, isShibboleth = %Q" "WHERE url = %Q AND username = %Q", // token new_account.token.toUtf8().data(), // lastVisited QString::number(timestamp).toUtf8().data(), // isShibboleth QString::number(new_account.isShibboleth).toUtf8().data(), // url new_account.serverUrl.toEncoded().data(), // username new_account.username.toUtf8().data()); } else { zql = sqlite3_mprintf( "INSERT INTO Accounts(url, username, token, lastVisited, isShibboleth) VALUES (%Q, %Q, %Q, %Q, %Q) ", // url new_account.serverUrl.toEncoded().data(), // username new_account.username.toUtf8().data(), // token new_account.token.toUtf8().data(), // lastVisited QString::number(timestamp).toUtf8().data(), // isShibboleth QString::number(new_account.isShibboleth).toUtf8().data()); } sqlite_query_exec(db, zql); sqlite3_free(zql); emit accountsChanged(); return 0; }
AvatarService::AvatarService(QObject *parent) : QObject(parent), get_avatar_req_(NULL) { queue_ = new PendingAvatarRequestQueue; timer_ = new QTimer(this); connect(timer_, SIGNAL(timeout()), this, SLOT(checkPendingRequests())); connect(seafApplet->accountManager(), SIGNAL(accountsChanged()), this, SLOT(onAccountChanged())); }
CloudView::CloudView(QWidget *parent) : QWidget(parent), clone_task_dialog_(NULL) { setupUi(this); // seahub_messages_monitor_ = new SeahubMessagesMonitor(this); // mSeahubMessagesBtn->setVisible(false); layout()->setContentsMargins(1, 0, 1, 0); // Setup widgets from top down setupHeader(); createAccountView(); createTabs(); // tool bar have to be created after tabs, since some of the toolbar // actions are provided by the tabs createToolBar(); setupDropArea(); setupFooter(); QVBoxLayout *vlayout = (QVBoxLayout *)layout(); vlayout->insertWidget(kIndexOfAccountView, account_view_); vlayout->insertWidget(kIndexOfToolBar, tool_bar_); vlayout->insertWidget(kIndexOfTabWidget, tabs_); resizer_ = new QSizeGrip(this); resizer_->resize(resizer_->sizeHint()); refresh_status_bar_timer_ = new QTimer(this); connect(refresh_status_bar_timer_, SIGNAL(timeout()), this, SLOT(refreshStatusBar())); AccountManager *account_mgr = seafApplet->accountManager(); connect(account_mgr, SIGNAL(accountsChanged()), this, SLOT(onAccountChanged())); #if defined(Q_OS_MAC) mHeader->setVisible(false); #endif connect(ServerStatusService::instance(), SIGNAL(serverStatusChanged()), this, SLOT(refreshServerStatus())); connect(CustomizationService::instance(), SIGNAL(serverLogoFetched(const QUrl&)), this, SLOT(onServerLogoFetched(const QUrl&))); QTimer::singleShot(0, this, SLOT(onAccountChanged())); }
AccountWindow::AccountWindow(QWidget* parent, const QString &name, Qt::WindowFlags wflags) :TableWindow(parent, name, wflags) { QStringList nameList; QTableWidget *pTable; QAction* pAction; pTable = TableWindow::getTable(); m_pDb = ISql::pInstance(); pAction = new QAction(tr("&New..."), this); connect(pAction, SIGNAL(triggered()), this, SLOT(file_new())); MDIWindow::addAction(pAction); pAction = new QAction(tr("&Edit..."), this); connect(pAction, SIGNAL(triggered()), this, SLOT(file_edit())); MDIWindow::addAction(pAction, true); pAction = new QAction(tr("&Delete"), this); connect(pAction, SIGNAL(triggered()), this, SLOT(file_delete())); MDIWindow::addAction(pAction); pAction = new QAction(this); pAction->setSeparator(true); MDIWindow::addAction(pAction); pAction = new QAction(tr("&Export all..."), this); connect(pAction, SIGNAL(triggered()), this, SLOT(exportTable())); MDIWindow::addAction(pAction); // configure the table TableWindow::setWindowIcon(QIcon(":/document.xpm")); pTable->setEditTriggers(QAbstractItemView::NoEditTriggers); pTable->setSelectionMode(QAbstractItemView::SingleSelection); // header nameList += tr("Username"); nameList += tr("Contest"); nameList += tr("Description"); setupHeader(nameList); pTable->setColumnWidth(Username, 100); pTable->setColumnWidth(Contest, 100); pTable->setColumnWidth(Description, 200); connect(m_pDb, SIGNAL(accountsChanged()), this, SLOT(file_update())); file_update(); }
int AccountManager::replaceAccount(const Account& old_account, const Account& new_account) { { QMutexLocker lock(&accounts_mutex_); for (size_t i = 0; i < accounts_.size(); i++) { if (accounts_[i] == old_account) { // TODO copy new_account and old_account before this operation // we might have invalid old_account or new_account after it accounts_[i] = new_account; updateServerInfo(i); break; } } } qint64 timestamp = QDateTime::currentMSecsSinceEpoch(); char *zql = sqlite3_mprintf( "UPDATE Accounts " "SET url = %Q, " " username = %Q, " " token = %Q, " " lastVisited = %Q, " " isShibboleth = %Q " "WHERE url = %Q " " AND username = %Q", // new_url new_account.serverUrl.toEncoded().data(), // username new_account.username.toUtf8().data(), // token new_account.token.toUtf8().data(), // lastvisited QString::number(timestamp).toUtf8().data(), // isShibboleth QString::number(new_account.isShibboleth).toUtf8().data(), // old_url old_account.serverUrl.toEncoded().data(), // username new_account.username.toUtf8().data() ); sqlite_query_exec(db, zql); sqlite3_free(zql); emit accountsChanged(); return 0; }
void FedgeConfigAccounts::slotRemove() { int i = accountsBox->index(accountsBox->selectedItem()); if (i == -1) { qWarning("Should not happen: Remove Account with none selected!"); return; } accountsBox->removeItem(i); removeAccount(i); m_changed = true; emit accountsChanged(); }
int AccountManager::removeAccount(const Account& account) { QString url = account.serverUrl.toEncoded().data(); QString sql = "DELETE FROM Accounts WHERE url = '%1' AND username = '******'"; sql = sql.arg(url).arg(account.username); sqlite_query_exec (db, toCStr(sql)); accounts_.erase(std::remove(accounts_.begin(), accounts_.end(), account), accounts_.end()); emit accountsChanged(); return 0; }
void ConfigurationManager::setTlsSettings(const std::map<std::string, std::string>& details) { const auto account = Manager::instance().getIP2IPAccount(); const auto sipaccount = static_cast<SIPAccount *>(account.get()); if (!sipaccount) { DEBUG("No valid account in set TLS settings"); return; } sipaccount->setTlsSettings(details); Manager::instance().saveConfig(); // Update account details to the client side accountsChanged(); }
void FedgeConfigAccounts::slotEnable() { int i = accountsBox->index(accountsBox->selectedItem()); if (i == -1) { qWarning("Should not happen: Toggle enable with none selected!"); return; } m_config->setGroup("Account " + QString::number(i)); m_config->writeEntry("enabled", (m_config->readEntry("enabled") == "true" ) ? "false" : "true"); accountsBox->changeItem((m_config->readEntry("enabled") == "true" ) ? m_config->readEntry("string") : m_config->readEntry("string") + i18n(" (disabled)"), i); accountsBox->setSelected(i, true); m_changed = true; emit accountsChanged(); }
int AccountManager::removeAccount(const Account& account) { char *zql = sqlite3_mprintf( "DELETE FROM Accounts WHERE url = %Q AND username = %Q", // url account.serverUrl.toEncoded().data(), // username account.username.toUtf8().data()); sqlite_query_exec(db, zql); sqlite3_free(zql); QMutexLocker lock(&accounts_mutex_); accounts_.erase(std::remove(accounts_.begin(), accounts_.end(), account), accounts_.end()); emit accountsChanged(); return 0; }
void AccountManager::serverInfoSuccess(const Account &account, const ServerInfo &info) { setServerInfoKeyValue(db, account, kVersionKeyName, info.getVersionString()); setServerInfoKeyValue(db, account, kFeaturesKeyName, info.getFeatureStrings().join(",")); setServerInfoKeyValue(db, account, kCustomLogoKeyName, info.customLogo); setServerInfoKeyValue(db, account, kCustomBrandKeyName, info.customBrand); bool changed = account.serverInfo != info; if (!changed) return; for (size_t i = 0; i < accounts_.size(); i++) { if (accounts_[i] == account) { if (i == 0) emit beforeAccountChanged(); accounts_[i].serverInfo = info; if (i == 0) emit accountsChanged(); break; } } }
int AccountManager::saveAccount(const Account& account) { for (size_t i = 0; i < accounts_.size(); i++) { if (accounts_[i].serverUrl == account.serverUrl && accounts_[i].username == account.username) { accounts_.erase(accounts_.begin() + i); break; } } accounts_.insert(accounts_.begin(), account); QString url = account.serverUrl.toEncoded().data(); qint64 timestamp = QDateTime::currentMSecsSinceEpoch(); QString sql = "REPLACE INTO Accounts VALUES ('%1', '%2', '%3', %4) "; sql = sql.arg(url).arg(account.username).arg(account.token).arg(QString::number(timestamp)); sqlite_query_exec (db, toCStr(sql)); emit accountsChanged(); return 0; }
int AccountManager::replaceAccount(const Account& old_account, const Account& new_account) { int i = 0; for (i = 0; i < accounts_.size(); i++) { if (accounts_[i].serverUrl == old_account.serverUrl && accounts_[i].username == old_account.username) { accounts_.erase(accounts_.begin() + i); break; } } accounts_.insert(accounts_.begin(), new_account); QString old_url = old_account.serverUrl.toEncoded().data(); QString new_url = new_account.serverUrl.toEncoded().data(); qint64 timestamp = QDateTime::currentMSecsSinceEpoch(); QString sql = "UPDATE Accounts " "SET url = '%1', " " username = '******', " " token = '%3', " " lastVisited = '%4' " "WHERE url = '%5' " " AND username = '******'"; sql = sql.arg(new_url).arg(new_account.username). \ arg(new_account.token).arg(QString::number(timestamp)) \ .arg(old_url); sqlite_query_exec (db, toCStr(sql)); emit accountsChanged(); return 0; }
CloudView::CloudView(QWidget* parent) : QWidget(parent), clone_task_dialog_(NULL) { setupUi(this); int marginTop = 0; if (shouldUseFramelessWindow()) { marginTop = 0; } #ifdef Q_OS_MAC marginTop = 0; #endif layout()->setContentsMargins(1, marginTop, 1, 0); // Setup widgets from top down setupHeader(); createAccountView(); createTabs(); // tool bar have to be created after tabs, since some of the toolbar // actions are provided by the tabs // createToolBar(); setupDropArea(); setupFooter(); QVBoxLayout* vlayout = (QVBoxLayout*)layout(); vlayout->insertWidget(kIndexOfAccountView, account_view_); vlayout->insertWidget(kIndexOfTabWidget, tabs_); if (shouldUseFramelessWindow()) { resizer_ = new QSizeGrip(this); resizer_->resize(resizer_->sizeHint()); } refresh_status_bar_timer_ = new QTimer(this); connect(refresh_status_bar_timer_, SIGNAL(timeout()), this, SLOT(refreshStatusBar())); AccountManager* account_mgr = seafApplet->accountManager(); connect(account_mgr, SIGNAL(accountsChanged()), this, SLOT(onAccountChanged())); connect(account_mgr, SIGNAL(accountInfoUpdated(const Account&)), this, SLOT(onAccountInfoUpdated(const Account&))); if (!shouldUseFramelessWindow()) { mHeader->setVisible(false); } connect(ServerStatusService::instance(), SIGNAL(serverStatusChanged()), this, SLOT(refreshServerStatus())); connect(CustomizationService::instance(), SIGNAL(serverLogoFetched(const QUrl&)), this, SLOT(onServerLogoFetched(const QUrl&))); QTimer::singleShot(0, this, SLOT(onAccountChanged())); }