예제 #1
0
AppFrameworkDemoDialog::AppFrameworkDemoDialog(QWidget *parent) :
  QDialog(parent),
  ui(new Ui::AppFrameworkDemoDialog)
{
  ui->setupUi(this);

  connect(this, SIGNAL(accepted()), this, SLOT(configurationSelected()));
  connect(this, SIGNAL(rejected()), this, SLOT(dialogCanceled()));
  connect(ui->appList, SIGNAL(currentRowChanged(int)), this, SLOT(selectionChanged(int)));

  // Get all AppFrameworkDemo_*.provisioning files
  QDir appDir(QApplication::applicationDirPath());
#ifdef CMAKE_INTDIR
  appDir.cdUp();
#endif

  provisioningFiles =
      appDir.entryList(QStringList(QApplication::applicationName() + "_*.provisioning"),
                                   QDir::Files | QDir::Readable, QDir::Name);

  foreach(QString provFile, provisioningFiles)
  {
    int startIndex = provFile.indexOf('_');
    int endIndex = provFile.lastIndexOf('.');
    ui->appList->addItem(provFile.mid(startIndex+1, endIndex-startIndex-1));
  }
예제 #2
0
void PolkitListener::initiateAuthentication(
        const QString &actionId,
        const QString &message,
        const QString &iconName,
        const PolkitQt1::Details &details,
        const QString &cookie,
        const PolkitQt1::Identity::List &identities,
        PolkitQt1::Agent::AsyncResult* result){
#else
void PolkitListener::initiateAuthentication(
        const QString &actionId,
        const QString &message,
        const QString &iconName,
        PolkitQt1::Details *details,
        const QString &cookie,
        QList<PolkitQt1::Identity *> identities,
        PolkitQt1::Agent::AsyncResult* result){
#endif // LIBPOLKIT_QT
    syslog(LOG_DEBUG,"Initiating authentication");
    if(inProgress){
        syslog(LOG_ERR,"Another client is already authenticating, please try again later.");
        result->setError("Another client is already authenticating, please try again later.");
        result->setCompleted();
        return;
    }
    this->identities=identities;
    this->cookie=cookie;
    this->result=result;
#ifdef LIBPOLKIT_QT_1_1
    session.clear();
#else
    session=0;
#endif // LIBPOLKIT_QT
    if(identities.length()==1){
        this->selectedUser=identities[0];
    }
    else{
#ifdef LIBPOLKIT_QT_1_1
        selectedUser=PolkitQt1::Identity();
#else
        selectedUser=0;
#endif // LIBPOLKIT_QT
    }

    inProgress=true;
    // Create the polkit dialog
    dialog=new PolkitDialogImpl(actionId,message,iconName,details,identities);
    connect(dialog->okButton,SIGNAL(clicked()),this,SLOT(dialogAccepted()));
    connect(dialog->passwordEdit,SIGNAL(returnPressed()),this,SLOT(dialogAccepted()));
    connect(dialog->cancelButton,SIGNAL(clicked()),this,SLOT(dialogCanceled()));
    connect(dialog,SIGNAL(rejected()),this,SLOT(dialogCanceled()));
#ifdef LIBPOLKIT_QT_1_1
    connect(dialog,SIGNAL(adminUserSelected(PolkitQt1::Identity)),SLOT(userSelected(PolkitQt1::Identity)));
#else
    connect(dialog,SIGNAL(adminUserSelected(PolkitQt1::Identity *)),SLOT(userSelected(PolkitQt1::Identity *)));
#endif // LIBPOLKIT_QT

    dialog->setOptions();
    dialog->show();
    dialog->raise();
    numTries=0;
    wasCancelled=false;
    if(!dialog->preselectUser()){
        tryAgain();
    }
}