navilocal 1.0.1 → 1.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb824d3e18e7b2d37ced625268b37279a9768668db6b5b82e6c9f01bbbac3f11
4
- data.tar.gz: fc3305d12b85df4c2d12cfdfd9fb79f7d500422f6ccd44aca7e3f2092b6dbb90
3
+ metadata.gz: 05a368e02f1bf323efd91ff2956334a344455f0aac36397e7f800fbdb81f1477
4
+ data.tar.gz: 2271622784a65fa90b8516dcbc22c310ff42947f839a017fcc41e41cd33b0fc4
5
5
  SHA512:
6
- metadata.gz: 89b2a9ac7a0174d934cde92eec53896b0066dfaf91184d2d8373e9597cda32991ddb572f68a5abf89ee8f26259c24813a1ec68c24af213877401c17133cd4e22
7
- data.tar.gz: 42ae809aa71c91248d371fe778969ca53d1c9ea7dcbe062e5da7cc083b817572d285fbbc53ffee03dfbcba72af069c349368c532159ef56d09e2acf30c030f29
6
+ metadata.gz: be1a74153f046cb2fd3152ac5b6192ebab4a9cb0d760d93f5c46ece94139ace561d72f1edf411f24971b0701ffd14ddf091176f4bb64db16904b969681f779bd
7
+ data.tar.gz: b624cc703a79d06c6acac23da9a8451697fe0217d05b0907e0f3f7a1da6facf6228fdfcf68a6424f76383f9f2681c2c372b6f4fa805c7931db77b8156d047a4f
@@ -3,7 +3,7 @@ require 'json'
3
3
 
4
4
  module NaviClientInstaller
5
5
  class Settings
6
- PROPERTIES = [:provider, :username, :password, :agreement, :location, :creation_datetime, :last_modified, :download_path, :install, :hash, :client_log_file, :common_words_file, :wikipedia_topic_file, :ai_log_file].freeze
6
+ PROPERTIES = [:provider, :username, :password, :agreement, :location, :creation_datetime, :last_modified, :download_path, :install, :hash, :client_log_file, :common_words_file, :wikipedia_topic_file, :ai_log_file, :logout].freeze
7
7
 
8
8
  PRIORITIES = ['high', 'medium', 'normal', 'low'].freeze
9
9
 
@@ -3,10 +3,11 @@ module NaviClientInstaller
3
3
  class AccountConfiguration
4
4
  attr_accessor :window_ui
5
5
  include CommonFunctions
6
+ attr_accessor :next_btn
6
7
 
7
8
 
8
9
 
9
- def initialize(settings, next_btn)
10
+ def initialize(settings, next_btn=nil)
10
11
  builder = Gtk::Builder.new(:resource => '/com/navi/navi-client/ui/account_configuration.ui')
11
12
  css_provider = Gtk::CssProvider.new
12
13
  css_provider.load(:resource_path => '/com/navi/navi-client/css/main.css')
@@ -16,6 +17,9 @@ module NaviClientInstaller
16
17
  @combo_text_provider = builder.get_object("combo_text_ac_provider")
17
18
  @entry_email = builder.get_object("entry_email")
18
19
  @entry_password = builder.get_object("entry_password")
20
+ @next_btn = next_btn.nil? ? builder.get_object("btn_change") : next_btn
21
+ @next_btn.visible = true
22
+
19
23
  # @settings = settings
20
24
  #
21
25
  @entry_email.set_text settings.username unless settings.username.nil?
@@ -26,6 +30,8 @@ module NaviClientInstaller
26
30
  @combo_text_provider.set_active item.path.to_s.to_i if (item.get_value 1) == settings.provider
27
31
  end
28
32
 
33
+ prepare_ui @next_btn
34
+
29
35
 
30
36
  view_info = builder.get_object("view_info")
31
37
 
@@ -35,17 +41,17 @@ module NaviClientInstaller
35
41
 
36
42
  @combo_text_provider.signal_connect "changed" do |widget|
37
43
  settings.provider = widget.active_iter.get_value(1)
38
- prepare_ui next_btn
44
+ prepare_ui @next_btn
39
45
  end
40
46
 
41
47
  @entry_password.signal_connect "changed" do |widget|
42
48
  settings.password= widget.text
43
- prepare_ui next_btn
49
+ prepare_ui @next_btn
44
50
  end
45
51
 
46
52
  @entry_email.signal_connect "changed" do |widget|
47
53
  settings.username = widget.text
48
- prepare_ui next_btn
54
+ prepare_ui @next_btn
49
55
  end
50
56
 
51
57
  white = Gdk::RGBA::new(1, 1, 1, 1.0)
@@ -61,7 +67,7 @@ module NaviClientInstaller
61
67
 
62
68
  def prepare_ui(nxt_btn, prev_btn = nil)
63
69
  valid = !@entry_email.text.empty? && !@entry_password.text.empty? && !@combo_text_provider.active_iter.get_value(1).nil?
64
- nxt_btn.set_sensitive valid
70
+ nxt_btn&.set_sensitive valid
65
71
  end
66
72
  end
67
73
  end
@@ -24,8 +24,8 @@ module NaviClientInstaller
24
24
  @rb_ac_agree.set_active(values.agreement == true)
25
25
 
26
26
  @rb_ac_agree.signal_connect("toggled") {|button|
27
- btn_next.set_sensitive(button.active?)
28
- values.agreement = button.active?
27
+ btn_next&.set_sensitive(button.active?)
28
+ values&.agreement = button.active?
29
29
  }
30
30
 
31
31
  agreementTextContent = Gio::Resources.lookup_data("/com/navi/navi-client/texts/agreement_main_content.html", 0)
@@ -26,12 +26,14 @@ module NaviClientInstaller
26
26
 
27
27
  css_provider = Gtk::CssProvider.new
28
28
  css_provider.load(:resource_path => '/com/navi/navi-client/css/main.css')
29
+ init_menus application
29
30
 
30
31
  @settings = NaviClientInstaller::Settings.new
31
32
  @settings.load_from_file_yaml(NaviClientInstaller::Settings::DEFAULT_STORAGE + '/config.yml')
32
33
  @settings.creation_datetime = Time.now.to_s if @settings.creation_datetime.nil?
33
34
 
34
35
  @splash = NaviClientInstaller::SplashWindow.new @settings
36
+ @application = application
35
37
  main_stack.add_named(@splash.window_ui, "splash")
36
38
 
37
39
  # setupMainApp
@@ -72,33 +74,86 @@ module NaviClientInstaller
72
74
  end
73
75
 
74
76
  def setupMainApp()
77
+ @runner_window = NaviClientInstaller::NaviRunner.new @settings, @application
78
+ main_stack.add_named(@runner_window.window_ui, "runner_main")
79
+ @signup_gauss = Proc.new do |token, *args|
80
+ if @settings.logout
81
+
82
+ main_stack.remove @runner_window.window_ui
83
+ @runner_window = NaviClientInstaller::NaviRunner.new @settings, @application
84
+ main_stack.add_named(@runner_window.window_ui, "runner_main")
85
+ @runner_window.set_logout_action @logout_control, @application
86
+ end
75
87
 
76
- @runner_window = NaviClientInstaller::NaviRunner.new @settings
77
- main_stack.add_named(@runner_window.window_ui, "signup")
78
-
79
- resp = @splash.validate_email( @settings.username, @settings.hash)
80
-
81
- if(resp && @settings.hash && resp.code == 200)
88
+ @settings.logout = false
89
+ @settings.save_settings
82
90
  @current_window = @runner_window
83
- @runner_window.set_token resp["access_token"]
91
+ @runner_window.set_token token
92
+ main_stack.set_transition_type(Gtk::Stack::TransitionType::SLIDE_RIGHT)
93
+ main_stack.set_visible_child(@current_window.window_ui)
94
+
84
95
  @runner_window.start
85
- endSplash
86
- # main_stack.set_visible_child(@splash.window_ui)
96
+ end
87
97
 
88
- else
89
- Thread.new do
90
- # duration for the splash screen
91
- gaussian = Proc.new do |token, *args|
92
- # @current_window.prepare_ui btn_next, btn_back
93
- @current_window = @runner_window
94
- @runner_window.set_token token
95
- main_stack.set_transition_type(Gtk::Stack::TransitionType::SLIDE_RIGHT)
96
- main_stack.set_visible_child(@current_window.window_ui)
97
- @runner_window.start
98
+
99
+ @logout_control = Proc.new do |arg|
100
+ # @current_window.prepare_ui btn_next, btn_back
101
+ #
102
+ main_stack.remove (@step_account_configuration.window_ui) if @step_account_configuration
103
+
104
+ @step_account_configuration = NaviClientInstaller::AccountConfiguration.new @settings
105
+
106
+ @step_account_configuration.next_btn.signal_connect 'clicked' do |button|
107
+
108
+ @settings.save_settings
109
+ main_stack.set_visible_child(@splash.window_ui)
110
+ # @initiate_login.call
111
+ @splash.initiate_signup @signup_gauss, @logout_control
112
+ end
113
+
114
+ main_stack.add_named(@step_account_configuration.window_ui, "account_configuration")
115
+
116
+
117
+ @current_window = @step_account_configuration
118
+
119
+ main_stack.set_transition_type(Gtk::Stack::TransitionType::SLIDE_RIGHT)
120
+
121
+ main_stack.set_visible_child(@current_window.window_ui)
122
+
123
+ end
124
+
125
+ @runner_window.set_logout_action @logout_control, @application
126
+
127
+ @initiate_login = Proc.new do |arg|
128
+ # main_stack.remove (@runner_window.window_ui) if @runner_window
129
+
130
+
131
+ resp = @splash.validate_email( @settings.username, @settings.hash)
132
+
133
+ if(resp && @settings.hash && resp.code == 200)
134
+ @settings.logout = false
135
+ @settings.save_settings
136
+ @current_window = @runner_window
137
+ @runner_window.set_token resp["access_token"]
138
+ @runner_window.start
139
+ endSplash
140
+ # main_stack.set_visible_child(@splash.window_ui)
141
+
142
+ else
143
+ Thread.new do
144
+ # duration for the splash screen
145
+
146
+ sleep 3
147
+ @splash.initiate_signup @signup_gauss, @logout_control
98
148
  end
99
- sleep 3
100
- @splash.initiate_signup gaussian
101
149
  end
150
+
151
+ end
152
+
153
+ if @settings.logout
154
+ @logout_control.call
155
+ else
156
+ @initiate_login.call
102
157
  end
103
158
 
104
159
  end
@@ -167,6 +222,18 @@ module NaviClientInstaller
167
222
  end
168
223
  end
169
224
 
225
+ def init_menus application
226
+ app_menu =Gtk::Builder.new(:resource => '/com/navi/navi-client/ui/menu.ui').get_object("appmenu")
227
+ application.set_app_menu(app_menu)
228
+
229
+ action_quit = Gio::SimpleAction.new("quit")
230
+ action_quit.signal_connect("activate") do |_action, parameter|
231
+ application.quit
232
+ end
233
+ application.add_action(action_quit)
234
+ # action_logout.set_enabled false
235
+ end
236
+
170
237
  end
171
238
 
172
239
  end
@@ -9,7 +9,7 @@ module NaviClientInstaller
9
9
 
10
10
  include CommonFunctions
11
11
 
12
- def initialize(settings, token=nil)
12
+ def initialize(settings, application)
13
13
  builder = Gtk::Builder.new(:resource => '/com/navi/navi-client/ui/main/main_runner.ui')
14
14
  css_provider = Gtk::CssProvider.new
15
15
  css_provider.load(:resource_path => '/com/navi/navi-client/css/main.css')
@@ -22,16 +22,20 @@ module NaviClientInstaller
22
22
  @stop_btn = builder.get_object("process_stop_btn")
23
23
  @refresh_btn = builder.get_object("process_refresh_btn")
24
24
  @email_display = builder.get_object("email_label_holder")
25
+ @settings = settings
25
26
 
26
- @email_display.label = settings&.username
27
+ @email_display.label = settings&.username if settings&.username
27
28
 
28
29
  image = builder.get_object("app_logo")
29
30
  image.set_from_resource('/com/navi/navi-client/images/navi-logo-small.png')
30
31
 
31
32
  stack = builder.get_object("app_stack")
32
33
 
34
+ @preferences = NaviClientInstaller::Prefs.new application
35
+
36
+ stack.add_titled(@preferences.window_ui, "Settings", "Settings")
37
+
33
38
  @settings = settings
34
- @token = token
35
39
  apply_css @window_ui, css_provider
36
40
 
37
41
  @iter_log = @log_display.buffer.get_iter_at(:offset => 0)
@@ -49,6 +53,7 @@ module NaviClientInstaller
49
53
  @notifier.label = "Terminated.."
50
54
  end
51
55
 
56
+
52
57
  @refresh_btn.signal_connect 'clicked' do |button|
53
58
  restart_process
54
59
  end
@@ -59,8 +64,34 @@ module NaviClientInstaller
59
64
 
60
65
  end
61
66
 
67
+ def set_logout_action logout_control, application
68
+ @action_logout = Gio::SimpleAction.new("logout")
69
+ @action_logout.signal_connect("activate") do |_action, parameter|
70
+ terminate_worker_thread
71
+ logout_control.call
72
+ @action_logout.set_enabled false
73
+ end
74
+
75
+
76
+ application.add_action(@action_logout)
77
+ @preferences.logout_btn.signal_connect 'clicked' do |button|
78
+ @settings.logout = true
79
+ @settings.username = nil
80
+ @settings.password = nil
81
+ @settings.hash = nil
82
+ @settings.save_settings
83
+ terminate_worker_thread
84
+ logout_control.call
85
+ @action_logout.set_enabled false
86
+ end
87
+
88
+ @action_logout.set_enabled false
89
+ end
90
+
62
91
 
63
92
  def start
93
+ @action_logout.set_enabled true
94
+
64
95
  @worker_thread = Thread.new do
65
96
  @spinner_indicator.active = true
66
97
  @refresh_btn.sensitive = true
@@ -98,6 +129,8 @@ module NaviClientInstaller
98
129
  @logger = CustomLogger.new @log_display.buffer, @iter_log, @client.logger
99
130
  @client.override_logger @logger
100
131
 
132
+ new_emails = false
133
+
101
134
  #logging to loggly
102
135
  logToLoggly = false
103
136
  if logToLoggly
@@ -129,6 +162,7 @@ module NaviClientInstaller
129
162
  total = @imap.uid_search(['ALL']).size
130
163
  downloaded = @client.getMessageUUIds("#{@settings.download_path}#{@settings.username}/meta/").size
131
164
  downloaded = downloaded - 2 if downloaded > 1
165
+ downloaded = [downloaded, total].min
132
166
 
133
167
  @email_indicator.label = "#{downloaded}/#{total}"
134
168
 
@@ -137,7 +171,7 @@ module NaviClientInstaller
137
171
  @notifier.label = "Checking for previous failures.."
138
172
 
139
173
  start_naviai
140
- @client.parse_prev_failed_emails
174
+ new_emails = @client.parse_prev_failed_emails
141
175
  stop_naviai
142
176
  @notifier.label = "Fetching emails..."
143
177
  @client.retrieve_emails(@imap, ['ALL'], folder) do |mail, index, isLast, id|
@@ -146,6 +180,7 @@ module NaviClientInstaller
146
180
 
147
181
  filenames << @client.process_email(mail, id)
148
182
  downloaded+=1
183
+ downloaded = [downloaded, total].min
149
184
  @email_indicator.label = "#{downloaded}/#{total}"
150
185
 
151
186
  @logger.debug "Processing Complete. OK..."
@@ -171,6 +206,7 @@ module NaviClientInstaller
171
206
 
172
207
  dateEnded = DateTime.now
173
208
  totalTimeInSecs = (dateEnded - dateStarted) * 24 * 60 * 60
209
+ new_emails = true
174
210
 
175
211
  @client.logToLoggly({event:"EMAIL_SYNC_FINISHED", env: env, storage: "local", email: @settings.username, emailCount: index + 1, time_elapsed: totalTimeInSecs.to_f.round(2)})
176
212
  @logger.debug "#{index + 1} emails from the #{folder} has been downloaded. OK"
@@ -184,7 +220,7 @@ module NaviClientInstaller
184
220
 
185
221
  @notifier.label = "Finalizing..."
186
222
 
187
- @client.initate_csv_generation(@settings.username)
223
+ @client.initate_csv_generation(@settings.username) if new_emails
188
224
 
189
225
  callback = Proc.new do |mail, index, id, complete|
190
226
  # complete = args.first || false
@@ -197,6 +233,7 @@ module NaviClientInstaller
197
233
  @logger.debug "processing email##{index + 1} with id #{mail.__id__.to_s} and uuid #{id}"
198
234
  total+=1
199
235
  end
236
+ downloaded = [downloaded, total].min
200
237
  @email_indicator.label = "#{downloaded}/#{total}"
201
238
 
202
239
  end
@@ -0,0 +1,32 @@
1
+ require 'yaml'
2
+ require_relative '../../lib/common_functions'
3
+
4
+ module NaviClientInstaller
5
+ class Prefs
6
+
7
+ include CommonFunctions
8
+
9
+ attr_accessor :logout_btn
10
+ attr_accessor :window_ui
11
+
12
+ def initialize application
13
+ builder = Gtk::Builder.new(:resource => '/com/navi/navi-client/ui/prefs.ui')
14
+ css_provider = Gtk::CssProvider.new
15
+ css_provider.load(:resource_path => '/com/navi/navi-client/css/main.css')
16
+ @window_ui = builder.get_object("box_prefs")
17
+
18
+ @logout_btn = builder.get_object("logout_btn")
19
+ close_btn = builder.get_object("close_btn")
20
+
21
+ close_btn.signal_connect 'clicked' do |button|
22
+ application&.quit
23
+ end
24
+
25
+
26
+
27
+ end
28
+
29
+
30
+ end
31
+
32
+ end
@@ -46,45 +46,60 @@ module NaviClientInstaller
46
46
  end
47
47
  end
48
48
 
49
- def initiate_signup callback
49
+ def initiate_signup callback, back_callback=nil
50
+
50
51
 
51
52
  login_info = @builder.get_object("view_splash_info")
52
- @spinner = @builder.get_object("spinner_splash_loader")
53
- @error_label = @builder.get_object("label_splash_error")
53
+ spinner = @builder.get_object("spinner_splash_loader")
54
+ error_label = @builder.get_object("label_splash_error")
54
55
  # @spinner.active = true
55
56
 
56
57
  email_entry = @builder.get_object("entry_splash_email")
57
- @password_entry = @builder.get_object("entry_splash_pass")
58
- @signup_control = @builder.get_object("box_splash_login")
59
- email_entry.set_text @settings.username
60
-
61
- @password_entry.signal_connect("activate") {|widget|
62
- unless widget.text.empty?
63
- @spinner.active = true
64
- @password_entry.sensitive = false
58
+ password_entry = @builder.get_object("entry_splash_pass")
59
+ back_btn = @builder.get_object("back")
65
60
 
61
+ email_entry.set_text @settings.username
62
+ password_entry.set_text ""
63
+
64
+ if login_info.buffer.text.to_s.empty?
65
+ back_btn.signal_connect("clicked") {|widget|
66
+ back_callback&.call
67
+ }
68
+
69
+ password_entry.signal_connect("activate") {|widget|
70
+ unless widget.text.empty?
71
+ spinner.active = true
72
+ password_entry.sensitive = false
73
+
74
+ response = validate_email @settings.username, widget.text
75
+
76
+ spinner.active = false
77
+ password_entry.sensitive = true
78
+
79
+ if response && response.code == 200
80
+ error_label.set_opacity 0
81
+ @settings.hash = widget.text
82
+ @settings.save_settings
83
+ callback.call response["access_token"]
84
+ else
85
+ error_label.set_opacity 1
86
+ end
87
+ end
88
+ }
66
89
 
67
- response = validate_email @settings.username, widget.text
90
+ create_tags(login_info.buffer)
91
+ login_info.buffer.insert(login_info.buffer.get_iter_at(:offset => 0), "We need you to connect to our app. Please sign in. If you donot have the account already, please sign up first.",
92
+ :tags => %w(double_spaced_line large))
68
93
 
69
- @spinner.active = false
70
- @password_entry.sensitive = true
94
+ end
71
95
 
72
- if response && response.code == 200
73
- @error_label.set_opacity 0
74
- @settings.hash = widget.text
75
- @settings.save_settings
76
- callback.call response["access_token"]
77
- else
78
- @error_label.set_opacity 1
79
- end
80
- end
81
- }
82
96
 
83
- create_tags(login_info.buffer)
84
- login_info.buffer.insert(login_info.buffer.get_iter_at(:offset => 0), "We need you to connect to our app. Please sign in. If you donot have the account already, please sign up first.",
85
- :tags => %w(double_spaced_line large))
97
+ show_signup
98
+ end
86
99
 
87
- @signup_control.visible = true
100
+ def show_signup
101
+ @signup_control = @builder.get_object("box_splash_login")
102
+ @signup_control&.visible = true
88
103
  end
89
104
 
90
105
  def add_timeout
@@ -17,15 +17,15 @@ resource_bin = File.join(application_root_path, 'gresource.bin')
17
17
 
18
18
  # the commented block below is required to generate resources folder or update if any changes
19
19
 
20
- # resource_xml = File.join(application_root_path, 'resources', 'gresources.xml')
21
- # # # Build the binary
22
- # system("glib-compile-resources",
23
- # "--target", resource_bin,
24
- # "--sourcedir", File.dirname(resource_xml),
25
- # resource_xml)
26
- #
27
- #
28
- #
20
+ resource_xml = File.join(application_root_path, 'resources', 'gresources.xml')
21
+ # # Build the binary
22
+ system("glib-compile-resources",
23
+ "--target", resource_bin,
24
+ "--sourcedir", File.dirname(resource_xml),
25
+ resource_xml)
26
+
27
+
28
+
29
29
  resource = Gio::Resource.load(resource_bin)
30
30
  Gio::Resources.register(resource)
31
31
 
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: navilocal
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Msanjib
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 1.4.2
47
+ version: 1.4.3
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 1.4.2
54
+ version: 1.4.3
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: httparty
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -83,6 +83,7 @@ files:
83
83
  - application/ui/navi/installer_assistant.rb
84
84
  - application/ui/navi/main_runner.rb
85
85
  - application/ui/navi/navi_install.rb
86
+ - application/ui/navi/prefs.rb
86
87
  - application/ui/navi/splash.rb
87
88
  - bin/navilocal
88
89
  - gresource.bin