void NetworkAccount::readConfig(/*const*/ KConfig/*Base*/ & config) { KMAccount::readConfig(config); setLogin(config.readEntry("login")); if(config.readNumEntry("store-passwd", false)) // ### s/Num/Bool/ { mStorePasswd = true; QString encpasswd = config.readEntry("pass"); if(encpasswd.isEmpty()) { encpasswd = config.readEntry("passwd"); if(!encpasswd.isEmpty()) encpasswd = importPassword(encpasswd); } if(!encpasswd.isEmpty()) { setPasswd(decryptStr(encpasswd), true); // migrate to KWallet if available if(Wallet::isEnabled()) { config.deleteEntry("pass"); config.deleteEntry("passwd"); mPasswdDirty = true; mStorePasswdInConfig = false; } else { mPasswdDirty = false; // set by setPasswd() on first read mStorePasswdInConfig = true; } } else { // read password if wallet is already open, otherwise defer to on-demand loading if(Wallet::isOpen(Wallet::NetworkWallet())) readPassword(); } } else { setPasswd("", false); } setHost(config.readEntry("host")); unsigned int port = config.readUnsignedNumEntry("port", defaultPort()); if(port > USHRT_MAX) port = defaultPort(); setPort(port); setAuth(config.readEntry("auth", "*")); setUseSSL(config.readBoolEntry("use-ssl", false)); setUseTLS(config.readBoolEntry("use-tls", false)); mSieveConfig.readConfig(config); }
QString NetworkAccount::passwd() const { if(storePasswd() && mPasswd.isEmpty()) mOwner->readPasswords(); return decryptStr(mPasswd); }
//----------------------------------------------------------------------------- bool KMAcctPop::authenticate(DwPopClient& client) { QString passwd; const char* msg=0; KMPasswdDialog* dlg; bool opened = FALSE; int replyCode; if(mPasswd.isEmpty() || mLogin.isEmpty()) msg = i18n("Please set Password and Username"); passwd = decryptStr(mPasswd); passwd.detach(); while (1) { if (msg) { dlg = new KMPasswdDialog(NULL, NULL, this, msg, mLogin, passwd); if (!dlg->exec()) return FALSE; delete dlg; msg = 0; } // Some POP servers close the connection upon failed // user/password. So we close the connection here to // be sure that everything below runs as we expect it. if (opened) { client.Quit(); client.Close(); } // Open connection to server if (client.Open(mHost,mPort) != '+') return popError("OPEN", client); opened = TRUE; app->processEvents(); // Send user name replyCode = client.User((const char*)mLogin); if (replyCode == '-') { msg = i18n("Incorrect Username"); continue; } else if (replyCode != '+') return popError("USER", client); app->processEvents(); // Send password passwd = decryptStr(mPasswd); passwd.detach(); replyCode = client.Pass((const char*)passwd); if (replyCode == '-') { msg = i18n("Incorrect Password"); continue; } else if (replyCode != '+') return popError("PASS", client); // Ok, we are done break; } return TRUE; }
//----------------------------------------------------------------------------- const QString KMAcctPop::passwd(void) const { return decryptStr(mPasswd); }