geary/src/engine/api/geary-credentials.vala
Jim Nelson 126378d85c Separate IMAP and SMTP credentials: Closes #5635, Closes #5208
This rather large patch allows separate IMAP and SMTP credentials
and separates the user's credential username from their email
address.  Additional work in this patch includes fixing some minor
protocol bugs in the SMTP stack to work with Postfix, refactoring
the Geary.Engine interface to stop issuing plain strings for
account names, and removing the Geary.EngineAccount abstract class
which was growing unnecessary with each passing day.
2012-08-27 12:11:26 -07:00

46 lines
1.6 KiB
Vala

/* Copyright 2011-2012 Yorba Foundation
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
*/
/**
* Credentials represent a username and a password authenticating a user for access to a resource.
* More sophisticated schemes exist; this suffices for now.
*
* Either property (user, pass) may be null. This indicates the Credentials are incomplete and
* need further information (i.e. prompt user for username, fetch password from keyring, etc.)
* Either field may be a non-null zero-length string; this is considered valid and is_complete()
* will return true in this case.
*
* Note that Geary will hold Credentials in memory for the long-term, usually the duration of the
* application. This is because network resources often have to be connected (or reconnected) to
* in the background and asking the user to reauthenticate each time is deemed inconvenient.
*/
public class Geary.Credentials {
public string? user { get; set; }
public string? pass { get; set; }
/**
* user and pass may be null here, but the properties will always be a non-null zero-length
* string. See is_empty().
*/
public Credentials(string? user, string? pass) {
this.user = user;
this.pass = pass;
}
public bool is_complete() {
return (user != null) && (pass != null);
}
public Credentials copy() {
return new Credentials(user, pass);
}
public string to_string() {
return user;
}
}