~cszikszoy/do-plugins/pastebin

« back to all changes in this revision

Viewing changes to GMailContacts/src/Configuration.cs

  • Committer: Alex Launi
  • Date: 2008-06-07 05:52:01 UTC
  • Revision ID: alex@eriktorvaldsonn-20080607055201-gip5v5ppp2emon37
Fix null error and config in GMail

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Configuration.cs
2
 
// 
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.
6
 
// 
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
10
 
// version.
11
 
// 
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
15
 
// details.
16
 
// 
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/>.
19
 
//
20
 
 
21
 
using System;
22
 
using System.Text.RegularExpressions;
23
 
 
24
 
using Gtk;
25
 
using Do.UI;
26
 
using Do.Addins;
27
 
 
28
 
namespace GMailContacts
29
 
{       
30
 
        public class Configuration : AbstractLoginWidget
31
 
        {
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])?";
35
 
            
36
 
        const string Uri = "https://www.google.com/accounts/NewAccount?service=cl";
37
 
                
38
 
                public Configuration () : 
39
 
                        base ("GMail")
40
 
                {
41
 
                        Build ();
42
 
                        GetAccountButton.Uri = Uri;
43
 
                }
44
 
                
45
 
                protected override bool Validate (string username, string password)
46
 
                {
47
 
                        if (ValidateUsername (username) && password.Length >= 8)
48
 
                                return GMail.TryConnect (username, password);
49
 
                        return false;
50
 
                }
51
 
                
52
 
                private bool ValidateUsername (string username)
53
 
                {                       
54
 
                        return new Regex (EmailPattern, 
55
 
                                RegexOptions.Compiled).IsMatch (username);
56
 
                }
57
 
        }
58
 
}