ashchan / gmail-notifr

A RubyCocoa Gmail Notifier for Mac OS X

This URL has Read+Write access

gmail-notifr / GNAccount.rb
100644 69 lines (53 sloc) 1.03 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#
# GNAccount.rb
# Gmail Notifr
#
# Created by James Chan on 1/3/09.
# Copyright (c) 2009 ashchan.com. All rights reserved.
#
 
require 'osx/cocoa'
 
# a normal gmail account, or a google hosted email account
class GNAccount < OSX::NSObject
 
def init
super_init
end
 
def initWithName(username)
a = init
 
@username = username
@password = GNKeychain.alloc.init.get_password(username)
@existing_account = true
return a
end
 
def username
@username
end
 
def password
@password
end
 
def username=(new_username)
@old_username ||= @username
@username = new_username
end
 
def password=(new_password)
@old_password ||= @password
@password = new_password
end
 
def new?
!@existing_account
end
 
def destroy
@deleted = true
end
 
def deleted?
@deleted
end
 
def username_changed?
@old_username && @old_username != @username
end
 
def password_changed?
@old_password && @old_password != @password
end
 
def changed?
username_changed? || password_changed? || deleted?
end
end