void KMail::ManageSieveScriptsDialog::slotRefresh()
{
    killAllJobs();
    mUrls.clear();
    mListView->clear();

    KMail::AccountManager *am = kmkernel->acctMgr();
    assert(am);
    QCheckListItem *last = 0;
    for(KMAccount *a = am->first() ; a ; a = am->next())
    {
        last = new QCheckListItem(mListView, last, a->name(), QCheckListItem::Controller);
        last->setPixmap(0, SmallIcon("server"));
        if(ImapAccountBase *iab = dynamic_cast<ImapAccountBase *>(a))
        {
            const KURL u = ::findUrlForAccount(iab);
            if(u.isEmpty())
                continue;
            SieveJob *job = SieveJob::list(u);
            connect(job, SIGNAL(item(KMail::SieveJob *, const QString &, bool)),
                    this, SLOT(slotItem(KMail::SieveJob *, const QString &, bool)));
            connect(job, SIGNAL(result(KMail::SieveJob *, bool, const QString &, bool)),
                    this, SLOT(slotResult(KMail::SieveJob *, bool, const QString &, bool)));
            mJobs.insert(job, last);
            mUrls.insert(last, u);
        }
        else
        {
            QListViewItem *item = new QListViewItem(last, i18n("No Sieve URL configured"));
            item->setEnabled(false);
            last->setOpen(true);
        }
    }
Ejemplo n.º 2
0
void SieveDebugDialog::slotDiagNextAccount()
{
    if(mAccountList.isEmpty())
        return;

    KMAccount *acc = mAccountList.first();
    mAccountList.pop_front();

    mEdit->append(i18n("Collecting data for account '%1'...\n").arg(acc->name()));
    mEdit->append(i18n("------------------------------------------------------------\n"));
    mAccountBase = dynamic_cast<KMail::ImapAccountBase *>(acc);
    if(mAccountBase)
    {
        // Detect URL for this IMAP account
        SieveConfig sieve = mAccountBase->sieveConfig();
        if(!sieve.managesieveSupported())
        {
            mEdit->append(i18n("(Account does not support Sieve)\n\n"));
        }
        else
        {
            if(sieve.reuseConfig())
            {
                // assemble Sieve url from the settings of the account:
                mUrl.setProtocol("sieve");
                mUrl.setHost(mAccountBase->host());
                mUrl.setUser(mAccountBase->login());
                mUrl.setPass(mAccountBase->passwd());
                mUrl.setPort(sieve.port());

                // Translate IMAP LOGIN to PLAIN:
                mUrl.setQuery("x-mech=" + (mAccountBase->auth() == "*" ? "PLAIN" : mAccountBase->auth()));
            }
            else
            {
                sieve.alternateURL();
                mUrl.setFileName(sieve.vacationFileName());
            }

            mSieveJob = SieveJob::list(mUrl);

            connect(mSieveJob, SIGNAL(gotList(KMail::SieveJob *, bool, const QStringList &, const QString &)),
                    SLOT(slotGetScriptList(KMail::SieveJob *, bool, const QStringList &, const QString &)));

            // Bypass the singleShot timer -- it's fired when we get our data
            return;
        }
    }
    else
    {
        mEdit->append(i18n("(Account is not an IMAP account)\n\n"));
    }

    // Handle next account async
    QTimer::singleShot(0, this, SLOT(slotDiagNextAccount()));
}
Ejemplo n.º 3
0
//-----------------------------------------------------------------------------
QStrList  KMAcctMgr::getAccounts() {
  
  KMAccount *cur;
  QStrList strList;
  for (cur=mAcctList.first(); cur; cur=mAcctList.next()) {
    strList.append(cur->name());
  }

  return strList;

}
Ejemplo n.º 4
0
//-----------------------------------------------------------------------------
KMAccount* KMAcctMgr::find(const QString aName) 
{
  KMAccount* cur;

  if (aName.isEmpty()) return NULL;

  for (cur=mAcctList.first(); cur; cur=mAcctList.next())
  {
    if (cur->name() == aName) return cur;
  }

  return NULL;
}
Ejemplo n.º 5
0
//-----------------------------------------------------------------------------
bool KMAcctMgr::intCheckMail(int item) {

  KMAccount* cur;
  bool hasNewMail = FALSE;

  if (mAcctList.isEmpty())
  {
    warning(i18n("You need to add an account in the network\n"
		 "section of the settings in order to\n"
		 "receive mail."));
    return FALSE;
  }
  debug ("checking mail, server busy");
  serverReady(false);
  
  KMIOStatusWdg *wid = new KMIOStatusWdg(0L,0L,KMIOStatus::RETRIEVE);
  wid->show();
  
  int x = 0;
  cur = mAcctList.first();
  for(x=0; x < item; x++)
  {
    cur=mAcctList.next();
  }

  if (cur->folder() == 0)
  {
    QString tmp(1024); // Unsafe
    tmp.sprintf(i18n("Account %s has no mailbox defined!\n"
                     "Mail checking aborted\n"
                     "Check your account settings!"), cur->name().data());
    warning(tmp.data());
  }
  else if (cur->processNewMail(wid))
  {
    hasNewMail = TRUE;
    emit newMail(cur);
  }

  delete wid;
  debug ("checked mail, server ready");
  serverReady(true);
  return hasNewMail;

}
void SieveDebugDialog::slotDiagNextAccount()
{
    if ( mAccountList.isEmpty() )
        return;

    KMAccount *acc = mAccountList.first();
    mAccountList.pop_front();

    mEdit->append( i18n( "Collecting data for account '%1'...\n", acc->name() ) );
    mEdit->append( i18n( "------------------------------------------------------------\n" ) );
    mAccountBase = dynamic_cast<KMail::ImapAccountBase *>( acc );
    if ( mAccountBase )
    {
        // Detect URL for this IMAP account
        const KUrl url = urlFromAccount( mAccountBase );
        if ( !url.isValid() )
        {
            mEdit->append( i18n( "(Account does not support Sieve)\n\n" ) );
        } else {
            mUrl = url;

            mSieveJob = SieveJob::list( mUrl );

            connect( mSieveJob, SIGNAL( gotList( KMail::SieveJob *, bool, const QStringList &, const QString & ) ),
                SLOT( slotGetScriptList( KMail::SieveJob *, bool, const QStringList &, const QString & ) ) );

            // Bypass the singleShot timer -- it's fired when we get our data
            return;
        }
    } else {
        mEdit->append( i18n( "(Account is not an IMAP account)\n\n" ) );
    }

    // Handle next account async
    QTimer::singleShot( 0, this, SLOT( slotDiagNextAccount() ) );
}
Ejemplo n.º 7
0
//-----------------------------------------------------------------------------
KMFolderDialog::KMFolderDialog(KMFolder* aFolder, QWidget *parent,
			       const char *name) :
  KMFolderDialogInherited(parent, name, TRUE)
{
  KMAccount* acct;
  QLabel *label;
  QString type;

  folder = (KMAcctFolder*)aFolder;

  label = new QLabel(this);
  label->setGeometry(20,20,60,25);
  label->setText(i18n("Name:"));
  label->setAlignment(290);

  nameEdit = new QLineEdit(this);
  nameEdit->setGeometry(90,20,320,25);
  nameEdit->setFocus();
  nameEdit->setText(folder ? folder->name().data() : i18n("unnamed"));

  if (folder)
  {
    type = folder->type();
    if (!type.isEmpty() && type!="plain")
      nameEdit->setEnabled(false);
  }

  label = new QLabel(this);
  label->setText(i18n("Associated with"));
  label->adjustSize();
  label->move(20,74);

  assocList = new QListBox(this);
  assocList->setGeometry(20,95,160,140);
  connect(assocList,SIGNAL(highlighted(int)),this,SLOT(doAssocHighlighted(int)));
  connect(assocList,SIGNAL(selected(int)),this,SLOT(doAssocSelected(int)));

  label = new QLabel(this);
  label->setText(i18n("Unassociated Accounts"));
  label->adjustSize();
  label->move(250,74);

  accountList = new QListBox(this);
  accountList->setGeometry(250,95,160,140);
  connect(accountList,SIGNAL(highlighted(int)),this,SLOT(doAccountHighlighted(int)));
  connect(accountList,SIGNAL(selected(int)),this,SLOT(doAccountSelected(int)));

  addButton = new QPushButton(this);
  addButton->setGeometry(190,115,50,40);
  addButton->setText("<<");
  addButton->setEnabled(FALSE);
  connect(addButton,SIGNAL(clicked()),this,SLOT(doAdd()));

  removeButton = new QPushButton(this);
  removeButton->setGeometry(190,175,50,40);
  removeButton->setText(">>");
  removeButton->setEnabled(FALSE);
  connect(removeButton,SIGNAL(clicked()),this,SLOT(doRemove()));

  QPushButton *button = new QPushButton(this);
  button->setGeometry(190,260,100,30);
  button->setText(i18n("OK"));
  connect(button,SIGNAL(clicked()),this,SLOT(doAccept()));

  if (type=="Out" || type=="St")
    button->setEnabled(false);

  button = new QPushButton(this);
  button->setGeometry(310,260,100,30);
  button->setText(i18n("Cancel"));
  connect(button,SIGNAL(clicked()),this,SLOT(reject()));

  resize(430,340);
  setFixedSize(430,340);

  if (folder)
  {
    // Grab the list of accounts associated with the given folder.
    for (acct=folder->account(); acct; acct=folder->nextAccount())
    {
      assocList->inSort(acct->name());
    }
  }

  // insert list of available accounts that are not associated with
  // any account
  for (acct=acctMgr->first(); acct; acct=acctMgr->next())
  {
    if (!acct->folder())
      accountList->inSort(acct->name());
  }
}