dragons_keep 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,238 @@
1
+ # To change this template, choose Tools | Templates
2
+ # and open the template in the editor.
3
+
4
+ require 'wx'
5
+ require 'dragons_keep/account_dialog'
6
+ require 'dragons_keep/account_controller'
7
+
8
+ module DragonsKeep
9
+ class KeepsMain < Wx::Frame
10
+ ID_FILE_NEW = 1001
11
+ ID_FILE_CONNECT = 1002
12
+ ID_FILE_DISCONNECT = 1003
13
+ ID_ACCOUNT_NEW = 3001
14
+ ID_ACCOUNT_EDIT = 3002
15
+ ID_ACCOUNT_DELETE = 3003
16
+ ID_EDIT_COPY = 2001
17
+ ID_TOOL_NEW_ACCOUNT = 101
18
+ ID_TOOL_EDIT_ACCOUNT = 102
19
+ ID_TOOL_DELETE_ACCOUNT = 103
20
+
21
+
22
+ def initialize(title)
23
+ #create an instance of frame
24
+ super(nil, :title => title, :size => [ 400, 300 ])
25
+ @account_controller = nil
26
+ create_menu_bar
27
+ # Create status bar with one cell
28
+ create_status_bar(1)
29
+ create_tb
30
+ create_contents
31
+ register_events
32
+
33
+ end
34
+
35
+ # End the application; it should finish automatically when the last
36
+ # window is closed.
37
+ def on_quit
38
+ close()
39
+ end
40
+ def on_new_database
41
+ file_dialog = Wx::FileDialog.new(self, "Choose File for new Database", :wildcard=>"Keep Files(*.keep)|*.keep", :style=>Wx::FD_SAVE)
42
+ file_dialog.center_on_screen(Wx::BOTH)
43
+ if file_dialog.show_modal == Wx::ID_OK
44
+ password_dialog = Wx::PasswordEntryDialog.new(self, "Please enter a password for this database")
45
+ if password_dialog.show_modal == Wx::ID_OK
46
+ password = password_dialog.get_value
47
+ file = file_dialog.get_path
48
+ if (file=~/.keep$/) == nil
49
+ file << ".keep"
50
+ end
51
+ #puts file
52
+ @account_controller = AccountController.new file, password
53
+ @account_controller.establish_connection
54
+ load_list
55
+ # update_ui
56
+ end
57
+ end
58
+ end
59
+ def on_connect_database
60
+ file_dialog = Wx::FileDialog.new(self, "Choose Keep File", :wildcard=>"Keep Files(*.keep)|*.keep")
61
+ file_dialog.center_on_screen(Wx::BOTH)
62
+ if file_dialog.show_modal == Wx::ID_OK
63
+ password_dialog = Wx::PasswordEntryDialog.new(self, "Please enter the password for this database")
64
+ if password_dialog.show_modal == Wx::ID_OK
65
+ password = password_dialog.get_value
66
+ file = file_dialog.get_path
67
+ #puts file
68
+ begin
69
+ @account_controller = AccountController.new file, password
70
+ @account_controller.establish_connection
71
+ load_list
72
+ rescue PasswordException
73
+ dlg = Wx::MessageDialog.new(self, "The Password you entered is invalid", "Password", Wx::OK | Wx::ICON_ERROR)
74
+ dlg.show_modal()
75
+ @account_controller = nil
76
+ end
77
+ end
78
+ end
79
+ end
80
+
81
+ def on_disconnect
82
+ @account_controller = nil
83
+ @list = nil
84
+ @account_list.clear
85
+ end
86
+
87
+ def on_new_account
88
+ account_dialog = AccountDialog.new(self, -1, "New Account")
89
+ account_dialog.center_on_screen(Wx::BOTH)
90
+ account_dialog.account = Account.new
91
+ if account_dialog.show_modal()== Wx::ID_OK
92
+ @account_controller.save!(account_dialog.account)
93
+ load_list
94
+ end
95
+ end
96
+ def on_edit_account
97
+ begin
98
+ account = @list[@account_list.get_selection]
99
+ @account_controller.decrypt!(account)
100
+ account_dialog = AccountDialog.new(self, -1, "Edit Account")
101
+ account_dialog.center_on_screen(Wx::BOTH)
102
+ account_dialog.account = account
103
+ if account_dialog.show_modal()== Wx::ID_OK
104
+ @account_controller.save!(account_dialog.account)
105
+ load_list
106
+ end
107
+ rescue PasswordException
108
+ dlg = Wx::MessageDialog.new(self, "The Password you entered is invalid", "Password", Wx::OK | Wx::ICON_ERROR)
109
+ dlg.show_modal()
110
+ end
111
+ end
112
+ def on_delete_account
113
+ account = @list[@account_list.get_selection]
114
+ dlg = Wx::MessageDialog.new(self, "Are you sure you wish to delete account #{account.name}", "Dragon's Keep", Wx::YES | Wx::NO | Wx::ICON_QUESTION)
115
+ if dlg.show_modal() == Wx::ID_YES
116
+ @account_controller.delete account
117
+ load_list
118
+ end
119
+ end
120
+ def on_copy_password
121
+ account = @list[@account_list.get_selection]
122
+ @account_controller.decrypt!(account)
123
+ Wx::Clipboard.open do | clip |
124
+ clip.data = Wx::TextDataObject.new(account.unencrypted_password)
125
+ end
126
+ end
127
+
128
+ private
129
+
130
+ def load_list
131
+ @list = @account_controller.list
132
+ @account_list.clear
133
+ @list.each {|ele| @account_list.append(ele.name) }
134
+ end
135
+
136
+ # helper to load png
137
+ def load_bitmap(base_name, mode)
138
+
139
+ png_file = File.join( File.dirname(__FILE__), 'icons', base_name )
140
+ #png_file = "dragons_keep/icons/#{base_name}"
141
+ # puts "image : #{png_file}"
142
+ Wx::Bitmap.new(png_file, mode ) # Wx::BITMAP_TYPE_PNG
143
+ end
144
+
145
+ # Create the Tool bar
146
+ def create_tb
147
+ tb = self.create_tool_bar(Wx::TB_HORIZONTAL | Wx::NO_BORDER | Wx::TB_FLAT ) #| Wx::TB_TEXT
148
+ tb.add_tool ID_TOOL_NEW_ACCOUNT, "New", load_bitmap("lock_add.png", Wx::BITMAP_TYPE_PNG), "New Account"
149
+ tb.add_tool ID_TOOL_EDIT_ACCOUNT, "Edit", load_bitmap("lock_edit.png", Wx::BITMAP_TYPE_PNG), "Edit Account"
150
+ tb.add_tool ID_TOOL_DELETE_ACCOUNT, "Delete", load_bitmap("lock_delete.png", Wx::BITMAP_TYPE_PNG), "Delete Account"
151
+ # needed to make the tool bar appear on windows
152
+ tb.realize()
153
+
154
+ end
155
+ def create_menu_bar
156
+ # create menu bar
157
+ menu_bar = Wx::MenuBar.new
158
+ # Create File menu
159
+ menu_file = Wx::Menu.new
160
+ # Create New option on File menu
161
+ menu_file.append ID_FILE_NEW, "&New Keep...", "Create New Keep File"
162
+ # Create Connect option on File menu
163
+ menu_file.append ID_FILE_CONNECT, "&Connect Keep...", "Connect to Existing Keep File"
164
+ # Create Disconnect menu option
165
+ menu_file.append ID_FILE_DISCONNECT, "Disconnect Keep", "Disconnect From the Keep File"
166
+ # add menu spacer to file menu
167
+ menu_file.append_separator()
168
+ # create Account menu
169
+ menu_account = Wx::Menu.new
170
+ # create new account menu item
171
+ menu_account.append ID_ACCOUNT_NEW, "New &Account...", "Create a new Account"
172
+ # Create Edit Account menu item
173
+ menu_account.append ID_ACCOUNT_EDIT, "Edit Account...", "Edit Selected Account"
174
+ menu_account.append ID_ACCOUNT_DELETE, "Delete Account", "Delete Selected Account"
175
+ # menu_file.append_separator()
176
+ #Create Exit option on File Menu
177
+ menu_file.append Wx::ID_EXIT, "E&xit\tAlt-X", "Quit this program"
178
+ # add the file to the menu bar
179
+ menu_bar.append menu_file, "&File"
180
+ # Create Edit menu
181
+ menu_edit = Wx::Menu.new
182
+ menu_edit.append ID_EDIT_COPY, "Copy Password", "Copy Password to Clipboard"
183
+ # add edit menu to menu bar
184
+ menu_bar.append menu_edit, "Edit"
185
+ # add the account menu to the menu bar
186
+ menu_bar.append menu_account, "Account"
187
+ # add Menu Bar to Frame
188
+ self.menu_bar = menu_bar
189
+ end
190
+
191
+ def create_contents
192
+ hbox = Wx::HBoxSizer.new
193
+ @account_list = Wx::ListBox.new self, 101, :style=>Wx::LB_SINGLE
194
+ hbox.add(@account_list,1, Wx::EXPAND | Wx::ALL)
195
+ self.set_sizer(hbox)
196
+ end
197
+
198
+ def register_events
199
+ evt_menu Wx::ID_EXIT, :on_quit
200
+ evt_menu ID_FILE_NEW, :on_new_database
201
+ evt_menu ID_FILE_CONNECT, :on_connect_database
202
+ evt_menu ID_FILE_DISCONNECT, :on_disconnect
203
+ evt_menu ID_EDIT_COPY, :on_copy_password
204
+ evt_menu ID_ACCOUNT_NEW, :on_new_account
205
+ evt_menu ID_ACCOUNT_EDIT, :on_edit_account
206
+ evt_menu ID_ACCOUNT_DELETE, :on_delete_account
207
+ evt_tool ID_TOOL_NEW_ACCOUNT, :on_new_account
208
+ evt_tool ID_TOOL_EDIT_ACCOUNT, :on_edit_account
209
+ evt_tool ID_TOOL_DELETE_ACCOUNT, :on_delete_account
210
+ update_ui
211
+ end
212
+
213
+ def update_ui
214
+ evt_update_ui(ID_ACCOUNT_NEW)do |evt|
215
+ evt.enable(! @account_controller.nil?)
216
+ end
217
+ evt_update_ui(ID_TOOL_NEW_ACCOUNT)do |evt|
218
+ evt.enable(! @account_controller.nil?)
219
+ end
220
+ evt_update_ui(ID_ACCOUNT_EDIT)do |evt|
221
+ evt.enable(!(@account_controller.nil? && @account_list.is_empty))
222
+ end
223
+ evt_update_ui(ID_TOOL_EDIT_ACCOUNT)do |evt|
224
+ evt.enable(!(@account_controller.nil? && @account_list.is_empty))
225
+ end
226
+ evt_update_ui(ID_ACCOUNT_DELETE) do |evt|
227
+ evt.enable(!(@account_controller.nil? && @account_list.is_empty))
228
+ end
229
+ evt_update_ui(ID_TOOL_DELETE_ACCOUNT)do |evt|
230
+ evt.enable(!(@account_controller.nil? && @account_list.is_empty))
231
+ end
232
+ evt_update_ui(ID_EDIT_COPY) do |evt|
233
+ evt.enable(!(@account_controller.nil? && @account_list.is_empty))
234
+ end
235
+ end
236
+
237
+ end
238
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dragons_keep
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 5
8
+ - 0
9
+ version: 0.5.0
10
+ platform: ruby
11
+ authors:
12
+ - Allan Davis
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-08-13 00:00:00 -04:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ segments:
26
+ - 0
27
+ version: "0"
28
+ requirement: *id001
29
+ prerelease: false
30
+ type: :runtime
31
+ name: ezcrypto
32
+ - !ruby/object:Gem::Dependency
33
+ version_requirements: &id002 !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ segments:
38
+ - 0
39
+ version: "0"
40
+ requirement: *id002
41
+ prerelease: false
42
+ type: :runtime
43
+ name: uuid
44
+ - !ruby/object:Gem::Dependency
45
+ version_requirements: &id003 !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "="
48
+ - !ruby/object:Gem::Version
49
+ segments:
50
+ - 0
51
+ - 10
52
+ - 2
53
+ version: 0.10.2
54
+ requirement: *id003
55
+ prerelease: false
56
+ type: :runtime
57
+ name: dm-core
58
+ - !ruby/object:Gem::Dependency
59
+ version_requirements: &id004 !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "="
62
+ - !ruby/object:Gem::Version
63
+ segments:
64
+ - 0
65
+ - 10
66
+ - 2
67
+ version: 0.10.2
68
+ requirement: *id004
69
+ prerelease: false
70
+ type: :runtime
71
+ name: do_sqlite3
72
+ - !ruby/object:Gem::Dependency
73
+ version_requirements: &id005 !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "="
76
+ - !ruby/object:Gem::Version
77
+ segments:
78
+ - 2
79
+ - 0
80
+ - 1
81
+ version: 2.0.1
82
+ requirement: *id005
83
+ prerelease: false
84
+ type: :runtime
85
+ name: wxruby
86
+ description: Secure Password Keeper Application
87
+ email: javaalley@gmail.com
88
+ executables:
89
+ - dragons_keep
90
+ extensions: []
91
+
92
+ extra_rdoc_files:
93
+ - README
94
+ - LICENSE
95
+ files:
96
+ - LICENSE
97
+ - README
98
+ - Rakefile
99
+ - Gemfile
100
+ - bin/dragons_keep
101
+ - bin/dragons_keep.bat
102
+ - lib/dragons_keep/account_dialog.rb
103
+ - lib/dragons_keep/icons/user_delete.png
104
+ - lib/dragons_keep/icons/lock_edit.xpm
105
+ - lib/dragons_keep/icons/lock_edit.png
106
+ - lib/dragons_keep/icons/lock_delete.png
107
+ - lib/dragons_keep/icons/user_add.png
108
+ - lib/dragons_keep/icons/lock_add.png
109
+ - lib/dragons_keep/icons/user_edit.png
110
+ - lib/dragons_keep/icons/lock_delete.xpm
111
+ - lib/dragons_keep/icons/lock_add.xpm
112
+ - lib/dragons_keep/keeps_main.rb
113
+ - lib/dragons_keep/generate_password_dialog.rb
114
+ - lib/dragons_keep/account_controller.rb
115
+ - lib/dragons_keep/account.rb
116
+ - lib/dragons_keep.rb
117
+ - db/migrations/201005101750_create_accounts.rb
118
+ has_rdoc: true
119
+ homepage: http://github.com/javaalley/dragons_keep
120
+ licenses: []
121
+
122
+ post_install_message:
123
+ rdoc_options: []
124
+
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ segments:
132
+ - 0
133
+ version: "0"
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ segments:
139
+ - 0
140
+ version: "0"
141
+ requirements: []
142
+
143
+ rubyforge_project:
144
+ rubygems_version: 1.3.6
145
+ signing_key:
146
+ specification_version: 3
147
+ summary: Secure Password Keeper Application
148
+ test_files: []
149
+