3
// GNOME Do is the legal property of its developers, whose names are too
4
// numerous to list here. Please refer to the COPYRIGHT file distributed with
5
// this source distribution.
7
// This program is free software: you can redistribute it and/or modify it under
8
// the terms of the GNU General Public License as published by the Free Software
9
// Foundation, either version 3 of the License, or (at your option) any later
12
// This program is distributed in the hope that it will be useful, but WITHOUT
13
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17
// You should have received a copy of the GNU General Public License along with
18
// this program. If not, see <http://www.gnu.org/licenses/>.
22
using System.Text.RegularExpressions;
28
namespace GMailContacts
30
public class Configuration : AbstractLoginWidget
32
const string EmailPattern = @"[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\."
33
+ @"[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*"
34
+ @"[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?";
36
const string Uri = "https://www.google.com/accounts/NewAccount?service=cl";
38
public Configuration () :
42
GetAccountButton.Uri = Uri;
45
protected override bool Validate (string username, string password)
47
if (ValidateUsername (username) && password.Length >= 8)
48
return GMail.TryConnect (username, password);
52
private bool ValidateUsername (string username)
54
return new Regex (EmailPattern,
55
RegexOptions.Compiled).IsMatch (username);