void InsertProjectTester::testAccount()
{
    Part pp(0);
    MainDocument part( &pp );
    pp.setDocument( &part );

    addAccount( part );
    Project &p = part.getProject();
    QCOMPARE( p.accounts().accountCount(), 1 );

    Part pp2(0);
    MainDocument part2( &pp2 );
    pp2.setDocument( &part2 );

    part2.insertProject( p, 0, 0 );
    QCOMPARE( part2.getProject().accounts().accountCount(), 1 );

    part2.insertProject( part.getProject(), 0, 0 );
    QCOMPARE( part2.getProject().accounts().accountCount(), 1 );

    Part ppB(0);
    MainDocument partB( &ppB );
    ppB.setDocument( &partB );

    Account *parent = addAccount( partB );
    QCOMPARE( partB.getProject().accounts().accountCount(), 1 );
    addAccount( partB, parent );
    QCOMPARE( partB.getProject().accounts().accountCount(), 1 );
    QCOMPARE( parent->childCount(), 1 );

    part2.insertProject( partB.getProject(), 0, 0 );
    QCOMPARE( part2.getProject().accounts().accountCount(), 1 );
    QCOMPARE( part2.getProject().accounts().accountAt( 0 )->childCount(), 1 );
}
Exemple #2
0
void WSWindow::slotServiceChanged(int newService)
{

  if (currentService == newService)
    return;

  currentService = newService;
  
  //KConfig config("kipirc");
  //config.setGroup("WSExport Settings");
  //config.writeEntry("Service", currentService);

  if (service)
    {
      service->disconnect();
      delete service;
    }

  switch (newService)
    {
    case 0:
      service = new WSExport::WSSmugmug();
      break;

    default:
    case 1:
      service = new WSExport::WSPicasa();
      break;
    }


  service->setInterface(interface);

  // Replace account selector contents

  refreshAccounts();
  slotRefreshUI();
  
  connect(  dynamic_cast< QObject* >( widget->addAccount),
	    SIGNAL( clicked() ),
	    service,
	    SLOT( addAccount()));


  connect(  dynamic_cast< QObject* >( widget->accountSelector),
	    SIGNAL( activated(const QString& ) ), 
	    service,
	    SLOT( changeCurrentAccount(const QString&)));

  connect(  service,
	       SIGNAL( refreshUI() ), 
	       SLOT( slotRefreshUI()));

  connect(  service,
	       SIGNAL( status(const bool, const QString&) ), 
	       SLOT( slotStatus(const bool, const QString&)));


  service->doLogin();
}
Exemple #3
0
void SyncWindow::passwordManagerReady()
{
    mProcessedPasswordManager = true;
    // Look for accounts that already exist
    QDir configDir(mConfigDirectory);
    QStringList filters;
    filters << "*.db";
    QStringList files = configDir.entryList(filters);
    for( int i = 0; i < files.size(); i++ ) {
        QString name = files[i].replace(".db","");
        addAccount(name);
        syncDebug() << "Found account: " << name;
    }
    if( files.size() == 0 ) {
        on_buttonNewAccount_clicked();
    }
    rebuildAccountsTable();

    updateStatus();
    ui->actionEnable_Delete_Account->setVisible(false);

    if( mAccounts.size() > 0 && mHideOnStart ) {
        hide();
    } else {
        show();
    }
}
NewAccountDialog::NewAccountDialog(const PlatformStyle* platformStyle, QWidget* parent, WalletModel* model)
    : QFrame(parent)
    , ui(new Ui::NewAccountDialog)
    , platformStyle(platformStyle)
    , newAccount(NULL)
    , walletModel(model)
{
    ui->setupUi(this);

    setObjectName("newAccountDialog");
    ui->scanToConnectPage->setObjectName("scanToConnectPage");
    ui->newAccountPage->setObjectName("newAccountPage");

    ui->doneButton->setCursor(Qt::PointingHandCursor);
    ui->cancelButton->setCursor(Qt::PointingHandCursor);
    ui->doneButton2->setCursor(Qt::PointingHandCursor);
    ui->cancelButton2->setCursor(Qt::PointingHandCursor);
    ui->syncWithMobileButton->setCursor(Qt::PointingHandCursor);

    ui->stackedWidget->setCurrentIndex(0);
    setValid(ui->newAccountName, true);
    ui->cancelButton2->setVisible(false);

    ui->newAccountName->setFocus();

    connect(ui->doneButton, SIGNAL(clicked()), this, SLOT(addAccount()));
    connect(ui->doneButton2, SIGNAL(clicked()), this, SIGNAL(addAccountMobile()));
    connect(ui->cancelButton, SIGNAL(clicked()), this, SIGNAL(cancel()));
    connect(ui->cancelButton2, SIGNAL(clicked()), this, SLOT(cancelMobile()));
    connect(ui->syncWithMobileButton, SIGNAL(clicked()), this, SLOT(connectToMobile()));
    connect(ui->newAccountName, SIGNAL(textEdited(QString)), this, SLOT(valueChanged()));
}
void AccountManager::load()
{
    QSettings settings;

    int size = settings.beginReadArray("accounts/list/");

    for(int i=0; i<size; ++i) {
        settings.setArrayIndex(i);

        QString type = settings.value("type").toString();
        
        ProtocolPlugin *plugin = m_app->protocolPlugin(type);

        Account *account = plugin->createAccount();

        account->setId(settings.value("id").toString());
        account->load();

        account->initAccount();
        
        addAccount(account);
    }

    settings.endArray();
}
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 ManagerSettings::loadImpl()
{
    qDeleteAll(m_checkbox_list);
    m_checkbox_list.clear();
    foreach (Protocol *protocol,Protocol::all()) {
        foreach (Account *account,protocol->accounts())
            addAccount(account);
    }
bool AccountManager::restoreFromLegacySettings()
{
    // try to open the correctly themed settings
    auto settings = Account::settingsWithGroup(Theme::instance()->appName());

    bool migratedCreds = false;

    // if the settings file could not be opened, the childKeys list is empty
    // then try to load settings from a very old place
    if( settings->childKeys().isEmpty() ) {
        // Now try to open the original ownCloud settings to see if they exist.
        QString oCCfgFile = QDir::fromNativeSeparators( settings->fileName() );
        // replace the last two segments with ownCloud/owncloud.cfg
        oCCfgFile = oCCfgFile.left( oCCfgFile.lastIndexOf('/'));
        oCCfgFile = oCCfgFile.left( oCCfgFile.lastIndexOf('/'));
        oCCfgFile += QLatin1String("/ownCloud/owncloud.cfg");

        qDebug() << "Migrate: checking old config " << oCCfgFile;

        QFileInfo fi( oCCfgFile );
        if( fi.isReadable() ) {
            QSettings *oCSettings = new QSettings(oCCfgFile, QSettings::IniFormat);
            oCSettings->beginGroup(QLatin1String("ownCloud"));

            // Check the theme url to see if it is the same url that the oC config was for
            QString overrideUrl = Theme::instance()->overrideServerUrl();
            if( !overrideUrl.isEmpty() ) {
                if (overrideUrl.endsWith('/')) { overrideUrl.chop(1); }
                QString oCUrl = oCSettings->value(QLatin1String(urlC)).toString();
                if (oCUrl.endsWith('/')) { oCUrl.chop(1); }

                // in case the urls are equal reset the settings object to read from
                // the ownCloud settings object
                qDebug() << "Migrate oC config if " << oCUrl << " == " << overrideUrl << ":"
                         << (oCUrl == overrideUrl ? "Yes" : "No");
                if( oCUrl == overrideUrl ) {
                    migratedCreds = true;
                    settings.reset( oCSettings );
                } else {
                    delete oCSettings;
                }
            }
        }
    }

    // Try to load the single account.
    if (!settings->childKeys().isEmpty()) {
        if (auto acc = load(*settings)) {
            if (migratedCreds) {
                acc->setMigrated(true);
            }
            addAccount(acc);
            return true;
        }
    }
    return false;
}
AccountState *OwncloudSetupWizard::applyAccountChanges()
{
    AccountPtr newAccount = _ocWizard->account();
    auto manager = AccountManager::instance();

    auto newState = manager->addAccount(newAccount);
    manager->save();
    return newState;
}
Exemple #10
0
WelcomeDialog::WelcomeDialog(QWidget *parent) :
    QDialog(parent),
    m_ui(new Ui::WelcomeDialog)
{
  m_ui->setupUi(this);
  m_ui->continueButton->hide();
  connect( m_ui->addAccountButton, SIGNAL(clicked()), this, SIGNAL(addAccount()) );
  connect( m_ui->continueButton, SIGNAL(clicked()), this, SLOT(proceed()) );
}
Exemple #11
0
void AccountsModel::onGroupChatManagerChanged(qutim_sdk_0_3::GroupChatManager *manager)
{
	Q_ASSERT(qobject_cast<Account*>(sender()));
	Account *account = static_cast<Account*>(sender());
	if (manager)
		addAccount(account);
	else
		removeAccount(account, true);
}
Exemple #12
0
SettingsDialog::SettingsDialog(Application *app, QWidget *parent) :
    QDialog(parent),
    _ui(new Ui::SettingsDialog)
{
    _ui->setupUi(this);
    setObjectName("Settings"); // required as group for saveGeometry call

    setWindowTitle(tr("%1 Settings").arg(Theme::instance()->appNameGUI()));

    QIcon generalIcon(QLatin1String(":/mirall/resources/settings.png"));
    QListWidgetItem *general = new QListWidgetItem(generalIcon, tr("General"), _ui->labelWidget);
    general->setSizeHint(QSize(0, 32));
    _ui->labelWidget->addItem(general);
    GeneralSettings *generalSettings = new GeneralSettings;
    _ui->stack->addWidget(generalSettings);

    QIcon networkIcon(QLatin1String(":/mirall/resources/network.png"));
    QListWidgetItem *network = new QListWidgetItem(networkIcon, tr("Network"), _ui->labelWidget);
    network->setSizeHint(QSize(0, 32));
    _ui->labelWidget->addItem(network);
    NetworkSettings *networkSettings = new NetworkSettings;
    _ui->stack->addWidget(networkSettings);
    connect(networkSettings, SIGNAL(proxySettingsChanged()), app, SLOT(slotSetupProxy()));
    connect(networkSettings, SIGNAL(proxySettingsChanged()), FolderMan::instance(), SLOT(slotScheduleAllFolders()));

    //connect(generalSettings, SIGNAL(resizeToSizeHint()), SLOT(resizeToSizeHint()));

    _accountSettings = new AccountSettings(this);
    addAccount(tr("Account"), _accountSettings);
    slotUpdateAccountState();

    connect( app, SIGNAL(folderStateChanged(Folder*)), _accountSettings, SLOT(slotUpdateFolderState(Folder*)));
    connect( app, SIGNAL(folderStateChanged(Folder*)), SLOT(slotUpdateAccountState()));

    connect( _accountSettings, SIGNAL(addASync()), app, SLOT(slotFolderAdded()) );
    connect( _accountSettings, SIGNAL(folderChanged()), app, SLOT(slotFoldersChanged()));
    connect( _accountSettings, SIGNAL(openFolderAlias(const QString&)),
             app, SLOT(slotFolderOpenAction(QString)));
    connect( _accountSettings, SIGNAL(openProgressDialog()), app, SLOT(slotItemProgressDialog()));

    connect( ProgressDispatcher::instance(), SIGNAL(progressInfo(QString, Progress::Info)),
             _accountSettings, SLOT(slotSetProgress(QString, Progress::Info)) );
    connect( ProgressDispatcher::instance(), SIGNAL(progressSyncProblem(QString,Progress::SyncProblem)),
             _accountSettings, SLOT(slotProgressProblem(QString,Progress::SyncProblem)) );

    _ui->labelWidget->setCurrentRow(_ui->labelWidget->row(general));

    connect(_ui->labelWidget, SIGNAL(currentRowChanged(int)),
            _ui->stack, SLOT(setCurrentIndex(int)));

    QPushButton *closeButton = _ui->buttonBox->button(QDialogButtonBox::Close);
    connect(closeButton, SIGNAL(pressed()), SLOT(accept()));

    MirallConfigFile cfg;
    cfg.restoreGeometry(this);
}
void KNCollectionView::reloadAccounts()
{
    KNAccountManager *am = knGlobals.accountManager();
    QValueList<KNNntpAccount *>::Iterator it;
    for(it = am->begin(); it != am->end(); ++it)
    {
        removeAccount(*it);
        addAccount(*it);
    }
}
Exemple #14
0
void readFile(List* list,char* fileName){
    FILE* ifp = fopen(fileName, "r");
    while(!feof(ifp)){
        Account* a = newAccount();
        if(fscanf(ifp, "%s %d %d %f", a->name, &a->accountNum, &a->accountPin, &a->balance) != 4)
            break;
        addAccount(list, a);
    }
    fclose(ifp);
}
bool AbiCollabSessionManager::registerAccountHandlers()
{
	UT_DEBUGMSG(("AbiCollabSessionManager::registerAccountHandlers()\n"));

#ifdef ABICOLLAB_HANDLER_TELEPATHY
	UT_DEBUGMSG(("Registering the telepathy account handler!\n"));
	AccountHandler* pTelepathyHandler = new TelepathyAccountHandler();
	addAccount(pTelepathyHandler);
	// TODO: check if we really want to auto-connect this account
	pTelepathyHandler->connect();
#endif
#ifdef ABICOLLAB_HANDLER_XMPP
	m_regAccountHandlers[XMPPAccountHandler::getStaticStorageType()] = XMPPAccountHandlerConstructor;
#endif
#ifdef ABICOLLAB_HANDLER_TCP
	m_regAccountHandlers[TCPAccountHandler::getStaticStorageType()] = TCPAccountHandlerConstructor;
#endif
#ifdef ABICOLLAB_HANDLER_SUGAR
	// we don't want to register a sugar account handler here so
	// we can construct multiple sugar account handlers later: the 
	// sugar account handler is a singleton, that should always
	// be active if it is compiled in
	UT_DEBUGMSG(("Registering the sugar account handler!\n"));
	AccountHandler* pSugarHandler = new SugarAccountHandler();
	addAccount(pSugarHandler);
#endif
#ifdef ABICOLLAB_HANDLER_SERVICE
	if (tls_tunnel::Proxy::tls_tunnel_init())
		m_regAccountHandlers[ServiceAccountHandler::getStaticStorageType()] = ServiceAccountHandlerConstructor;
	IE_Imp_AbiCollabSniffer* pAbiCollabSniffer = new IE_Imp_AbiCollabSniffer();
	IE_Imp::registerImporter(pAbiCollabSniffer);
	m_vImpSniffers.push_back(pAbiCollabSniffer);
#endif
#ifdef ABICOLLAB_HANDLER_SIPSIMPLE
	m_regAccountHandlers[SIPSimpleAccountHandler::getStaticStorageType()] = SIPSimpleAccountHandlerConstructor;
#endif
#ifdef ABICOLLAB_HANDLER_FAKE
	AccountHandler *pFakeHandler = new FakeAccountHandler("FakeAbiCollabBackend", NULL);
	addAccount(pFakeHandler);
#endif
	return true;
}
Exemple #16
0
void AccountsModel::onAccountCreated(Account *account)
{
	connect(account, &Account::nameChanged, this, &AccountsModel::onAccountNameChanged);
	connect(account, &Account::statusChanged, this, &AccountsModel::onAccountStatusChanged);
	connect(account, &Account::interfaceChanged, this, [this] (const QByteArray &name, QObject *interface) {
		if (name == "GroupChatManager") {
			onGroupChatManagerChanged(qobject_cast<GroupChatManager *>(interface));
		}
	});
	if (account->groupChatManager())
		addAccount(account);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//  save edited account information to database
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void MainWindow::on_saveButton_clicked()
{
    //make sure linedits aren't enpty
    if (ui->accountEdit->text() == "" || ui->passEdit->text() == "")
    {
        invalidDialog("Please enter a valid username/password");
    }
    else
    {
        //open database
        QSqlDatabase db = QSqlDatabase::addDatabase( "QSQLITE" );
        db.setDatabaseName( "users.db3" );
        if( !db.open() )
        {
          qDebug() << db.lastError();
          qFatal( "Failed to connect." );
        }

        //look for acoount name in users table to check for duplicates
        QString queryString = "SELECT * FROM '" + QString::fromStdString(encryption::encrypt(username,29,41)) + "' WHERE username='******'";
        QSqlQuery query(db);
        query.prepare(queryString);

        if( !query.exec() )
          qDebug() << query.lastError();
        else
        {
            qDebug( "Selected!" );
            query.first();
            QSqlRecord rec = query.record();
            qDebug() << rec.value(0).toString();

            //if nothing was found then add fresh account
            if (rec.value(0).toString() == "")
            {
                db.close();
                addAccount();
            }//not in database
            else
            {
                //if account was already found update entry
                QString queryString = "UPDATE '" + QString::fromStdString(encryption::encrypt(username,29,41)) + "' SET password='******' " + "WHERE username='******'";
                qDebug() << queryString;
                query.prepare(queryString);
                query.exec();
                db.close();
            }
        }
        updateAccountList();
    }
}
Exemple #18
0
void SyncWindow::on_buttonSave_clicked()
{
    QFileInfo info(mConfigDirectory+"/"+ui->lineName->text()+".db");
    bool okToEdit = true;
    ui->buttonSave->setDisabled(true);
    QString host = ui->lineHost->text();
    host.replace("http://","");
    host.replace("https://","");
    host.replace("webdav://","");
    host.replace("webdavs://","");
    // clean up double or trailing slashes..
    QString remoteDir = QDir::cleanPath(ui->lineRemoteDir->text());
    QString localDir = QDir::cleanPath(ui->lineLocalDir->text());
    if( mEditingConfig >= 0 ) { // Editing an account
        // If we are renaming the account, make sure that the new name
        // does not already exist
        if( ui->lineName->text() != mAccounts[mEditingConfig]->getName() ) {
            if( info.exists() ) {
                syncDebug() << "New account name already taken!!";
                okToEdit = false;
            }
        }
        if( okToEdit ) {
            mAccounts[mEditingConfig]->initialize(
                ui->labelHttp->text()+host,
                ui->lineUser->text(),
                ui->linePassword->text(),
                remoteDir,
                localDir,
                ui->time->value());
        }
    } else { // New account
        // First, check to see if this name is already taken
        if(info.exists()) { // Account name taken!
            syncDebug() << "Account name already taken!!";
            ui->lineName->setFocus();
        } else { // Good, create a new account
            SyncQtOwnCloud *account = addAccount(ui->lineName->text());
            account->initialize(ui->labelHttp->text()+host,
                                ui->lineUser->text(),
                                ui->linePassword->text(),
                                remoteDir,
                                localDir,
                                ui->time->value());
        }
    }
    mEditingConfig = -1;
    ui->stackedWidget->setCurrentIndex(0);
    ui->actionEnable_Delete_Account->setVisible(false);
    rebuildAccountsTable();
}
Exemple #19
0
AccountModel::AccountModel(QObject* parent)
 : QAbstractListModel(parent)
 , m_sessions(new UserSession(this))
{
    m_dbus = new AccountsManager("org.freedesktop.Accounts", "/org/freedesktop/Accounts", QDBusConnection::systemBus(), this);
    QDBusPendingReply <QList <QDBusObjectPath > > reply = m_dbus->ListCachedUsers();
    reply.waitForFinished();

    if (reply.isError()) {
        qCDebug(USER_MANAGER_LOG) << reply.error().message();
        return;
    }

    QList<QDBusObjectPath> users = reply.value();
    Q_FOREACH(const QDBusObjectPath& path, users) {
        addAccount(path.path());
    }
Exemple #20
0
bool AccountManager::restore()
{
    auto settings = Account::settingsWithGroup(QLatin1String(accountsC));

    // If there are no accounts, check the old format.
    if (settings->childGroups().isEmpty()) {
        return restoreFromLegacySettings();
    }

    foreach (const auto& accountId, settings->childGroups()) {
        settings->beginGroup(accountId);
        if (auto acc = load(*settings)) {
            acc->_id = accountId;
            addAccount(acc);
        }
        settings->endGroup();
    }

    return true;
}
Exemple #21
0
string Account::executePostAddRequest(ptree & root)
{
	string ret = MPAO::DEFAULT_JSON_ID;

	MPA_LOG_TRIVIAL(trace,"Account name to add: " + argvals.find("name")->second );

	mpapo::Account account( MPA::getInstance()->getMPAPO() );
	account = addAccount( argvals.find("name")->second );

	// Get account ID
	ret = string( account.id );

	MPA_LOG_TRIVIAL(trace,"Account ID added: " + ret);

	// Generate Json output
	root.push_back(make_pair("version", account.version ));
	root.push_back(make_pair("balance", account.balance ));

	return ret;
}
void Settings::setAccount(
        QString _grid,
        QString _name,
        QString _icon,
        QString _jid,
        QString _pass,
        bool _connectOnStart,
        QString _resource,
        QString _host,
        QString _port,
        bool manuallyHostPort) //Q_INVOKABLE
{
    bool isNew = false;
    beginGroup( "accounts" );

    QVariant retList = value( "accounts", QStringList() );
    QStringList sl = retList.toStringList();
    if( sl.indexOf(_grid) < 0 )
        isNew = true;
    endGroup();

    sStr(_name,_grid,"name");
    sStr(_icon,_grid,"icon");
    sStr(_jid,_grid,"jid");
    sStr(_pass,_grid,"passwd");

    sStr(_resource,_grid,"resource");
    sStr(_host,_grid,"host");
    sBool(manuallyHostPort,_grid,"use_host_port");
    sBool(_connectOnStart,_grid,"connectOnStart");

    bool ok = false;
    int p = _port.toInt(&ok);
    if( ok ) { sInt( p, _jid, "port" ); }

    if (isNew) addAccount(_grid);
    else {
        initListOfAccounts();
        emit accountEdited(_grid);
    }
}
void InsertProjectTester::testResourceAccount()
{
    Part pp(0);
    MainDocument part( &pp );
    pp.setDocument( &part );

    addResourceGroup( part );
    Resource *r = addResource( part );
    Account *a = addAccount( part );
    part.addCommand( new ResourceModifyAccountCmd( *r, r->account(), a ) );

    Project &p = part.getProject();
    QVERIFY( p.resourceGroupAt( 0 )->numResources() == 1 );

    Part pp2(0);
    MainDocument part2( &pp2 );
    pp2.setDocument( &part2 );

    part2.insertProject( p, 0, 0 );
    QVERIFY( part2.getProject().resourceGroupAt( 0 )->numResources() == 1 );
    QVERIFY( part2.getProject().accounts().allAccounts().contains( a ) );
    QCOMPARE( part2.getProject().resourceGroupAt( 0 )->resourceAt( 0 )->account(), a );
}
FedgeConfigAccounts::FedgeConfigAccounts(QWidget *parent, const char *name, QPtrList<Account> *accounts)
 : ConfigAccounts(parent, name)
{
	m_changed = false;

	m_config = new KConfig("fedgerc");

	int i = 0;

	Account *account;
	for (account = accounts->first(); account; account = accounts->next()) {
			
		m_config->setGroup("Account " + QString::number(i));
		addAccount(account);
		i++;
	}

	kmailButton->setIconSet(KIconLoader().loadIcon("kmail", KIcon::Desktop));
	
	connect(kmailButton, SIGNAL(clicked()), SLOT(slotKmail()));
	connect(removeButton, SIGNAL(clicked()), SLOT(slotRemove()));
	connect(enableButton, SIGNAL(clicked()), SLOT(slotEnable()));
	connect(accountsBox, SIGNAL(selectionChanged()), SLOT(slotSelectionChanged()));
}
void InsertProjectTester::testExistingResourceAccount()
{
    Part pp(0);
    MainDocument part( &pp );
    pp.setDocument( &part );

    addResourceGroup( part );
    Resource *r = addResource( part );
    Account *a = addAccount( part );
    part.addCommand( new ResourceModifyAccountCmd( *r, r->account(), a ) );

    Project &p = part.getProject();
    QVERIFY( p.resourceGroupAt( 0 )->numResources() == 1 );

    QDomDocument doc = part.saveXML();

    Part pp2(0);
    MainDocument part2( &pp2 );
    pp2.setDocument( &part2 );

    part2.insertProject( p, 0, 0 );
    QVERIFY( part2.getProject().resourceGroupAt( 0 )->numResources() == 1 );
    QVERIFY( part2.getProject().accounts().allAccounts().contains( a ) );
    QCOMPARE( part2.getProject().resourceGroupAt( 0 )->resourceAt( 0 )->account(), a );

    part2.addCommand( new ResourceModifyAccountCmd( *(part2.getProject().resourceGroupAt( 0 )->resourceAt( 0 )), part2.getProject().resourceGroupAt( 0 )->resourceAt( 0 )->account(), 0 ) );

    KoXmlDocument xdoc;
    xdoc.setContent( doc.toString() );
    part.loadXML( xdoc, 0 );

    part2.insertProject( part.getProject(), 0, 0 );
    QVERIFY( part2.getProject().resourceGroupAt( 0 )->numResources() == 1 );
    QVERIFY( part2.getProject().accounts().allAccounts().contains( a ) );
    QVERIFY( part2.getProject().resourceGroupAt( 0 )->resourceAt( 0 )->account() == 0 );
}
void AccountListDialog::on_addAccountBtn_clicked()
{
	addAccount(tr("Please enter your Mojang or Minecraft account username and password to add your account."));
}
Exemple #27
0
int main(int argc, char **argv) {
  GWEN_DB_NODE *db;
  const char *cmd;
  const char *pinFile;
  int nonInteractive=0;
  const char *s;
  int rv;
  AB_BANKING *ab;
  GWEN_GUI *gui;
  const GWEN_ARGS args[]={
  {
    GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
    GWEN_ArgsType_Char,            /* type */
    "cfgfile",                    /* name */
    0,                            /* minnum */
    1,                            /* maxnum */
    "C",                          /* short option */
    "cfgfile",                    /* long option */
    "Specify the configuration file",     /* short description */
    "Specify the configuration file"      /* long description */
  },
  {
    GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
    GWEN_ArgsType_Char,           /* type */
    "pinfile",                    /* name */
    0,                            /* minnum */
    1,                            /* maxnum */
    "P",                          /* short option */
    "pinfile",                    /* long option */
    "Specify the PIN file",       /* short description */
    "Specify the PIN file"        /* long description */
  },
  {
    0,                            /* flags */
    GWEN_ArgsType_Int,            /* type */
    "nonInteractive",             /* name */
    0,                            /* minnum */
    1,                            /* maxnum */
    "n",                          /* short option */
    "noninteractive",             /* long option */
    "Select non-interactive mode",/* short description */
    "Select non-interactive mode.\n"        /* long description */
    "This automatically returns a confirmative answer to any non-critical\n"
    "message."
  },
  {
    0,                           
    GWEN_ArgsType_Int,           
    "verbosity",
    0,                           
    10,                          
    "v",                         
    0,                            
    "Increase the verbosity level",
    "Increase the verbosity level"
  },
  {
    GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
    GWEN_ArgsType_Char,           /* type */
    "charset",                    /* name */
    0,                            /* minnum */
    1,                            /* maxnum */
    0,                            /* short option */
    "charset",                    /* long option */
    "Specify the output character set",       /* short description */
    "Specify the output character set"        /* long description */
  },
  {
    GWEN_ARGS_FLAGS_HELP | GWEN_ARGS_FLAGS_LAST, /* flags */
    GWEN_ArgsType_Int,             /* type */
    "help",                       /* name */
    0,                            /* minnum */
    0,                            /* maxnum */
    "h",                          /* short option */
    "help",                       /* long option */
    "Show this help screen",      /* short description */
    "Show this help screen"       /* long description */
  }
  };

  rv=GWEN_Init();
  if (rv<0) {
    fprintf(stderr, "ERROR: Unable to init GWEN (%d).\n", rv);
    return 2;
  }

  GWEN_Logger_Open("aqpaypal-tool", "aqpaypal-tool", 0,
		   GWEN_LoggerType_Console,
                   GWEN_LoggerFacility_User);
  GWEN_Logger_SetLevel("aqpaypal-tool", GWEN_LoggerLevel_Warning);
  GWEN_Logger_SetLevel(0, GWEN_LoggerLevel_Warning);

  db=GWEN_DB_Group_new("arguments");
  rv=GWEN_Args_Check(argc, argv, 1,
		     GWEN_ARGS_MODE_ALLOW_FREEPARAM |
		     GWEN_ARGS_MODE_STOP_AT_FREEPARAM,
		     args,
		     db);
  if (rv==GWEN_ARGS_RESULT_ERROR) {
    fprintf(stderr, "ERROR: Could not parse arguments main\n");
    return -1;
  }
  else if (rv==GWEN_ARGS_RESULT_HELP) {
    GWEN_BUFFER *ubuf;

    ubuf=GWEN_Buffer_new(0, 1024, 0, 1);
    GWEN_Buffer_AppendString(ubuf,
                             I18N("Usage: "));
    GWEN_Buffer_AppendString(ubuf, argv[0]);
    GWEN_Buffer_AppendString(ubuf,
                             I18N(" [GLOBAL OPTIONS] COMMAND "
                                  "[LOCAL OPTIONS]\n"));
    GWEN_Buffer_AppendString(ubuf,
                             I18N("\nGlobal Options:\n"));
    if (GWEN_Args_Usage(args, ubuf, GWEN_ArgsOutType_Txt)) {
      fprintf(stderr, "ERROR: Could not create help string\n");
      return 1;
    }
    GWEN_Buffer_AppendString(ubuf,
                             I18N("\nCommands:\n\n"));
    GWEN_Buffer_AppendString(ubuf,
                             I18N("  listusers:\n"
                                  "    blurb "
                                  "file\n\n"));
   GWEN_Buffer_AppendString(ubuf,
                             I18N("  listaccounts:\n"
                                  "    blurb "
                                  "file\n\n"));
   GWEN_Buffer_AppendString(ubuf,
                             I18N("  adduser:\n"
                                  "    blurb "
                                  "file\n\n"));
   GWEN_Buffer_AppendString(ubuf,
                             I18N("  addaccount:\n"
                                  "    blurb "
                                  "file\n\n"));
   GWEN_Buffer_AppendString(ubuf,
                             I18N("  setsecret:\n"
                                  "    blurb "
                                  "file\n\n"));

    fprintf(stdout, "%s\n", GWEN_Buffer_GetStart(ubuf));
    GWEN_Buffer_free(ubuf);
    return 0;
  }
  if (rv) {
    argc-=rv-1;
    argv+=rv-1;
  }

  cmd=GWEN_DB_GetCharValue(db, "params", 0, 0);
  if (!cmd) {
    fprintf(stderr, "ERROR: Command needed.\n");
    return 1;
  }

  gui=GWEN_Gui_CGui_new();
  s=GWEN_DB_GetCharValue(db, "charset", 0, "ISO-8859-15");
  GWEN_Gui_SetCharSet(gui, s);
  nonInteractive=GWEN_DB_GetIntValue(db, "nonInteractive", 0, 0);
  if (nonInteractive)
    GWEN_Gui_AddFlags(gui, GWEN_GUI_FLAGS_NONINTERACTIVE);
  else
    GWEN_Gui_SubFlags(gui, GWEN_GUI_FLAGS_NONINTERACTIVE);
  pinFile=GWEN_DB_GetCharValue(db, "pinFile", 0, NULL);
  if (pinFile) {
    GWEN_DB_NODE *dbPins;

    dbPins=GWEN_DB_Group_new("pins");
    if (GWEN_DB_ReadFile(dbPins, pinFile,
			 GWEN_DB_FLAGS_DEFAULT |
			 GWEN_PATH_FLAGS_CREATE_GROUP)) {
      fprintf(stderr, "Error reading pinfile \"%s\"\n", pinFile);
      return 2;
    }
    /* set argument "persistent" to one in non-interactive mode */
    GWEN_Gui_CGui_SetPasswordDb(gui, dbPins, nonInteractive);
  }
  GWEN_Gui_SetGui(gui);

  ab=AB_Banking_new("aqpaypal-tool",
		    GWEN_DB_GetCharValue(db, "cfgfile", 0, 0),
		    0);
  AB_Gui_Extend(gui, ab);

  if (strcasecmp(cmd, "listusers")==0) {
    rv=listUsers(ab, db, argc, argv);
  }
  else if (strcasecmp(cmd, "listaccounts")==0) {
    rv=listAccounts(ab, db, argc, argv);
  }
  else if (strcasecmp(cmd, "adduser")==0) {
    rv=addUser(ab, db, argc, argv);
  }
  else if (strcasecmp(cmd, "addaccount")==0) {
    rv=addAccount(ab, db, argc, argv);
  }
  else if (strcasecmp(cmd, "setsecrets")==0) {
    rv=setSecrets(ab, db, argc, argv);
  }
  else {
    fprintf(stderr, "ERROR: Unknown command \"%s\".\n", cmd);
    rv=1;
  }

  return rv;
}
Exemple #28
0
bool executeCommand(sqlite3 *db, const char *command)
{
    char **params;
    int paramsCount;
    int i;

    int from, to;
    double sum;

    (void)db;   // unused


    // parse command
    paramsCount = countWords(command);
    params = malloc(sizeof(char*) * paramsCount);
    for (i=0; i<paramsCount; i++)
        params[i] = getWord(command, i);            

    if ((paramsCount >= 1) && (!strcmp(params[0], COMMAND_HELP)))
        commandHelp();

    if ((paramsCount >= 1) && (!strcmp(params[0], COMMAND_1)))
        command1();

    if ((paramsCount >= 1) && (!strcmp(params[0], COMMAND_2)))
        command2();

    if ((paramsCount >= 4) && (!strcmp(params[0], COMMAND_TRANSF)))
    {
        sscanf(params[1], "%i", &from);
        sscanf(params[3], "%lf", &sum);
        sscanf(params[2], "%i", &to);
        //transfer(db, from, to, sum);
        if (sum < 0 ) return false;
        debit(db, from, sum);
        credit(db, to, sum);
    }

    if ((paramsCount >= 3) && (!strcmp(params[0], COMMAND_DEB)))
    {
        sscanf(params[1], "%i", &from);
        sscanf(params[2], "%lf", &sum);
        if (sum < 0 ) return false;
        debit(db, from, sum);
    }

    if ((paramsCount >= 3) && (!strcmp(params[0], COMMAND_CRED)))
    {
        sscanf(params[1], "%i", &to);
        sscanf(params[2], "%lf", &sum);
        if (sum < 0) return false;
        credit(db, to, sum);
    }

    if ((paramsCount >= 2) && (!strcmp(params[0], COMMAND_CHCK)))
    {
        sscanf(params[1], "%i", &to);
        checkAccount(db, to);
    }

    if ((paramsCount >= 1) && (!strcmp(params[0], COMMAND_UNDO)))
        undo(db);

    if ((paramsCount >= 1) && (!strcmp(params[0], COMMAND_ADD)))
        createNewCustomer(db);

    if ((paramsCount >= 1) && (!strcmp(params[0], COMMAND_DEL)))
        deleteCustomer(db);

    if ((paramsCount >= 1) && (!strcmp(params[0], COMMAND_DELACC)))
        deleteAccount(db);

    if ((paramsCount >= 1) && (!strcmp(params[0], COMMAND_ADDACC)))
        addAccount(db);

    if ((paramsCount >= 1) && (!strcmp(params[0], COMMAND_COMMIT)))
        commit(db);

    if ((paramsCount >= 1) && (!strcmp(params[0], COMMAND_SHOW)))
        showAll(db);

    if ((paramsCount >= 1) && (!strcmp(params[0], COMMAND_LOGGER)))
        logger(db);

    for (i=0; i<paramsCount; i++)
        free(params[i]);
    free(params);

    return true;
}
Exemple #29
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
	ui->setupUi(this);
	setWindowIcon(QIcon(":icon.ico"));

	MainWindow::appPath = qApp->applicationDirPath();

	loadStyle();

	// member initialization
	dockWidget	 = new DockWidget;
	calWidget	= new BrowserWidget;
	crmWidget   = new BrowserWidget;

	toolBar		= new QToolBar(tr("Aktionen"));
	accountList = new AccountList(this);
	contactList = new ContactList(this);
	mainLayout	= new QStackedLayout();
	settings	= SugarSettings::getInstance();
	settingsDialog = new SettingsDialog;

	addDockWidget(Qt::BottomDockWidgetArea, dockWidget);
	dockWidget->hide();
	accountList->hide();
	calWidget->setAddress(QUrl(settings->calendarUrl));
	crmWidget->setAddress(QUrl(settings->crmUrl));
	mainLayout->addWidget(accountList);
	mainLayout->addWidget(contactList);
	//mainLayout->addWidget(projectList);
	mainLayout->addWidget(calWidget);
	mainLayout->addWidget(crmWidget);
	mainLayout->addWidget(settingsDialog);

	toolBar->setIconSize(QSize(14, 14));
	toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
	toolBar->setMovable(false);

	QAction *accountsAct = new QAction(QIcon(":accounts.png"), tr("Firmen"), this);
	QAction *contactsAct = new QAction(QIcon(":contacts.png"), tr("Kontakte"), this);
	QAction *projectsAct = new QAction(QIcon(":projects.png"), tr("Projekte"), this);
	openCalAct			 = new QAction(QIcon(":calendar.png"), tr("Kalender"), this);
	openCrmAct			 = new QAction(QIcon(":calendar.png"), tr("SugarCrm"), this);

	addAccountAct			= new QAction(QIcon(":add-account.png"), tr("Neue Firma"), this);
	QAction *addContactAct	= new QAction(QIcon(":add-contact.png"), tr("Neuer Kontakt"), this);
	QAction *addProjectAct	= new QAction(QIcon(":add-project.png"), tr("Neues Projekt"), this);
	QAction *addTaskAct		= new QAction(QIcon(":add-task.png"),    tr("Neue Aufgabe"), this);
	pressViewAct			= new QAction(QIcon(":news.png"), tr("Pressekontakte"), this);

	connect(addAccountAct, SIGNAL(triggered()),
			this, SLOT(addAccount()));
	connect(openCalAct, SIGNAL(triggered()),
			this, SLOT(displayCalendar()));
	connect(openCrmAct, SIGNAL(triggered()),
			this, SLOT(displayCrm()));
	//connect(pressViewAct, SIGNAL(triggered()),
	//		this, SLOT(displayPressList()));
	connect(accountsAct, SIGNAL(triggered()),
			this, SLOT(displayAccounts()));
	connect(contactsAct, SIGNAL(triggered()),
			this, SLOT(displayContacts()));

	toolBar->addWidget(new QLabel(tr("Ansichten")));
	toolBar->addAction(accountsAct);
	toolBar->addAction(contactsAct);
	toolBar->addAction(projectsAct);
	toolBar->addAction(openCalAct);
	toolBar->addAction(openCrmAct);
	toolBar->addWidget(new QLabel(tr("Aktionen")));
	// TODO: fix this
	toolBar->addAction(addAccountAct);
	toolBar->addAction(addContactAct);
	toolBar->addAction(addProjectAct);
	toolBar->addAction(addTaskAct);
	//toolBar->addAction(pressViewAct);

	addToolBar(Qt::LeftToolBarArea, toolBar);
	toolBar->hide();

	QPushButton *loginBtn = new QPushButton(QIcon(":login.png"), tr("Login"), this);
	connect(loginBtn, SIGNAL(pressed()),
			this, SLOT(login()));
	QGridLayout *l = new QGridLayout(this);
	QWidget *c = new QWidget(this);
	QWidget *w = new QWidget(this);

	l->addWidget(loginBtn, 1, 1, Qt::AlignCenter);
	c->setLayout(l);
	mainLayout->addWidget(c);
	mainLayout->setCurrentWidget(c);
	w->setLayout(mainLayout);
	setCentralWidget(w);

	// initialize dialogs
	loadingDialog = new LoadingDialog(this);
	loginDialog   = new LoginDialog(this);
	loadingDialog->setVisible(false);
	loginDialog->setVisible(false);

	crm = SugarCrm::getInstance();
	accountModel = AccountModel::getInstance();
	contactModel = ContactModel::getInstance();

	accountsFilterModel = new AccountProxyModel(this);
	contactsFilterModel = new ContactProxyModel(this);

	//filterModel = new AccountProxyModel(this);
	//filterModel->setSourceModel(accountModel);

	accountsFilterModel->setSourceModel(accountModel);
	contactsFilterModel->setSourceModel(contactModel);

	restoreGeometry(settings->windowGeometry);

	// QML display
	//centerView = new QmlView(this);

	//centerView->setUrl(QUrl("SugarCrm.qml"));
	//centerView->setAttribute(Qt::WA_OpaquePaintEvent);
	//centerView->setAttribute(Qt::WA_NoSystemBackground);
	//centerView->setFocus();

	//contx = centerView->rootContext();
	//contx->addDefaultObject(this);
	//contx->setContextProperty("qmlViewer", this);
	//contx->setContextProperty("accountModel", proxyModel);

	// connecting ui actions
	connect(ui->actionLogin, SIGNAL(triggered()),
			this, SLOT(login()));
	connect(ui->actionEinstellungen, SIGNAL(triggered()),
			this, SLOT(displaySettings()));
	connect(ui->actionLogout, SIGNAL(triggered()),
			qApp, SLOT(quit()));
	connect(ui->actionServer_Zeit, SIGNAL(triggered()),
			crm, SLOT(getServerTime()));
	connect(ui->actionSugarFlavor, SIGNAL(triggered()),
			crm, SLOT(getSugarFlavor()));
	connect(ui->actionReloadStyle, SIGNAL(triggered()),
			this, SLOT(loadStyle()));
	connect(ui->actionAboutQt, SIGNAL(triggered()),
			qApp, SLOT(aboutQt()));
	connect(ui->actionWebsite, SIGNAL(triggered()),
			this, SLOT(openProjectHomepage()));
	connect(ui->actionSpenden, SIGNAL(triggered()),
			this, SLOT(openDonationWebsite()));
	connect(qApp, SIGNAL(aboutToQuit()),
			this, SLOT(cleanup()));

	// DEBUG XML COMMUNICATION
	//connect(crm, SIGNAL(sendingMessage(QString)),
	//		this, SLOT(debug(QString)));
	//connect(crm->trans, SIGNAL(newSoapMessage(QString)),
	//		this, SLOT(debug(QString)));

	connect(crm, SIGNAL(unknownAction(QString)),
			this, SLOT(unknownAction(QString)));

	// login response
	connect(crm, SIGNAL(loginFailed()),
			this, SLOT(loginResponse()));

	connect(crm, SIGNAL(loginSuccessful()),
			this, SLOT(loginResponse()));

	// soap error handling
	// TODO: improve!
	connect(crm, SIGNAL(returnedFaultyMessage(QString)),
			loadingDialog, SLOT(hide()));

	connect(crm, SIGNAL(returnedFaultyMessage(QString)),
			this, SLOT(setStatusMsg(QString)));

	connect(accountModel, SIGNAL(dataReady()),
			this, SLOT(displayAccounts()));

	//TODO: change this when it works
	//setCentralWidget(centerView);
	//centerView->execute();

	//rootComponent = centerView->root();
	//QVariant *tmp = new QVariant(contx->property("authView"));
	//QmlComponent authComponent((QObject *) tmp);  // centerView->engine(), QUrl("content/AuthView.qml"));
	//authView = authComponent.create(contx);
	//qDebug() << authView->dynamicPropertyN();

	//connect(rootComponent, SIGNAL(loggingIn()),
	//		this, SLOT(login()));
	//connect(rootComponent, SIGNAL(searching()),
	//		this, SLOT(doSearch()));
	/*connect(accountModel, SIGNAL(dataReady()),
			this, SLOT(assignData()));
	connect(this, SIGNAL(listReady()),
			rootComponent, SLOT(displayAccounts()));*/
	//connect(accountModel, SIGNAL(dataReady()),
	//		rootComponent, SLOT(displayAccounts()));

	setStatusMsg(tr("Bereit"), 2500);
}
void EditServiceAccountDialog::submitAccount() {
    emit addAccount(m_nameLabel->text(), m_userEdit->text(), m_passEdit->text());
    this->accept();
}