openall_time_applet 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+ gem "knjrbfw"
6
+ gem "gtk2"
7
+ gem "sqlite3"
8
+ gem "gettext"
9
+ gem "json"
10
+
11
+ # Add dependencies to develop your gem here.
12
+ # Include everything needed to run rake, tests, features, etc.
13
+ group :development do
14
+ gem "rspec", "~> 2.8.0"
15
+ gem "rdoc", "~> 3.12"
16
+ gem "bundler", ">= 1.0.0"
17
+ gem "jeweler", "~> 1.8.3"
18
+ gem "rcov", ">= 0"
19
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,59 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ atk (1.1.3)
5
+ glib2 (>= 1.1.3)
6
+ cairo (1.12.1)
7
+ pkg-config
8
+ diff-lcs (1.1.3)
9
+ gdk_pixbuf2 (1.1.3)
10
+ glib2 (>= 1.1.3)
11
+ gettext (2.2.0)
12
+ locale
13
+ git (1.2.5)
14
+ glib2 (1.1.3)
15
+ pkg-config
16
+ gtk2 (1.1.3)
17
+ atk (>= 1.1.3)
18
+ gdk_pixbuf2 (>= 1.1.3)
19
+ pango (>= 1.1.3)
20
+ jeweler (1.8.3)
21
+ bundler (~> 1.0)
22
+ git (>= 1.2.5)
23
+ rake
24
+ rdoc
25
+ json (1.7.1)
26
+ knjrbfw (0.0.32)
27
+ locale (2.0.5)
28
+ pango (1.1.3)
29
+ cairo (>= 1.10.0)
30
+ glib2 (>= 1.1.3)
31
+ pkg-config (1.1.3)
32
+ rake (0.9.2.2)
33
+ rcov (0.9.11)
34
+ rdoc (3.12)
35
+ json (~> 1.4)
36
+ rspec (2.8.0)
37
+ rspec-core (~> 2.8.0)
38
+ rspec-expectations (~> 2.8.0)
39
+ rspec-mocks (~> 2.8.0)
40
+ rspec-core (2.8.0)
41
+ rspec-expectations (2.8.0)
42
+ diff-lcs (~> 1.1.2)
43
+ rspec-mocks (2.8.0)
44
+ sqlite3 (1.3.6)
45
+
46
+ PLATFORMS
47
+ ruby
48
+
49
+ DEPENDENCIES
50
+ bundler (>= 1.0.0)
51
+ gettext
52
+ gtk2
53
+ jeweler (~> 1.8.3)
54
+ json
55
+ knjrbfw
56
+ rcov
57
+ rdoc (~> 3.12)
58
+ rspec (~> 2.8.0)
59
+ sqlite3
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Kasper Johansen
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = openall_time_applet
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to openall_time_applet
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2012 Kasper Johansen. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "openall_time_applet"
18
+ gem.homepage = "http://github.com/kaspernj/openall_time_applet"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Time-tracking for OpenAll.}
21
+ gem.description = %Q{Off-line time-tracking for OpenAll with syncing when online.}
22
+ gem.email = "k@spernj.org"
23
+ gem.authors = ["Kasper Johansen"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rdoc/task'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "openall_time_applet #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby1.9
2
+
3
+ Dir.chdir(File.dirname(__FILE__))
4
+ require "../lib/openall_time_applet.rb"
5
+
6
+ GetText.bindtextdomain("default", "../locales", ENV["LANGUAGE"])
7
+
8
+ oata = Openall_time_applet.new
9
+ oata.update_db
10
+ oata.spawn_trayicon
11
+
12
+ Gtk.main
@@ -0,0 +1,45 @@
1
+ require "socket"
2
+ require "json"
3
+
4
+ #This class handels various operations with the Openall-installation. It uses HTTP and JSON.
5
+ class Openall_time_applet::Connection
6
+ def initialize(args)
7
+ @args = args
8
+ @http = Knj::Http2.new(
9
+ :host => @args[:host],
10
+ :port => @args[:port],
11
+ :follow_redirects => false,
12
+ :ssl => Knj::Strings.yn_str(@args[:ssl], true, false),
13
+ :debug => false,
14
+ :encoding_gzip => false
15
+ )
16
+
17
+ self.login
18
+ end
19
+
20
+ def login
21
+ #For some weird reason OpenAll seems to only accept multipart-post-requests??
22
+ @http.post_multipart("index.php?c=Auth&m=validateLogin", {"username" => @args[:username], "password" => @args[:password]})
23
+ @http.reconnect
24
+
25
+ #Verify login by reading dashboard HTML.
26
+ res = @http.get("index.php?c=Dashboard")
27
+ raise _("Could not log in.") if !res.body.match(/<ul id="webticker" >/)
28
+ end
29
+
30
+ def request(args)
31
+ args = {:url => args} if args.is_a?(String)
32
+ res = @http.get(args[:url])
33
+ parsed = JSON.parse(res.body)
34
+
35
+ return parsed
36
+ end
37
+
38
+ def task_list
39
+ return self.request("index.php?c=Jsonapi&m=task_list")
40
+ end
41
+
42
+ def destroy
43
+ @http.destroy if @http
44
+ end
45
+ end
data/conf/db_schema.rb ADDED
@@ -0,0 +1,25 @@
1
+ Openall_time_applet::DB_SCHEMA = {
2
+ "tables" => {
3
+ "Option" => {
4
+ "columns" => [
5
+ {"name" => "id", "type" => "int", "autoincr" => true, "primarykey" => true},
6
+ {"name" => "title", "type" => "varchar"},
7
+ {"name" => "value", "type" => "text"}
8
+ ]
9
+ },
10
+ "Timelog" => {
11
+ "columns" => [
12
+ {"name" => "id", "type" => "int", "autoincr" => true, "primarykey" => true},
13
+ {"name" => "openall_uid", "type" => "int"},
14
+ {"name" => "time", "type" => "int"},
15
+ {"name" => "time_transport", "type" => "int"},
16
+ {"name" => "descr", "type" => "text"},
17
+ {"name" => "sync_need", "type" => "enum", "maxlength" => "'0','1'", "default" => 0},
18
+ {"name" => "sync_last", "type" => "datetime"}
19
+ ],
20
+ "indexes" => [
21
+ "openall_uid"
22
+ ]
23
+ }
24
+ }
25
+ }
data/gfx/icon_time.png ADDED
Binary file
@@ -0,0 +1,67 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <interface>
3
+ <requires lib="gtk+" version="2.24"/>
4
+ <!-- interface-naming-policy project-wide -->
5
+ <object class="GtkWindow" id="window">
6
+ <property name="can_focus">False</property>
7
+ <property name="title" translatable="yes">Overview</property>
8
+ <property name="window_position">center</property>
9
+ <property name="default_width">640</property>
10
+ <property name="default_height">480</property>
11
+ <child>
12
+ <object class="GtkVBox" id="vbox1">
13
+ <property name="visible">True</property>
14
+ <property name="can_focus">False</property>
15
+ <child>
16
+ <object class="GtkFrame" id="frame1">
17
+ <property name="visible">True</property>
18
+ <property name="can_focus">False</property>
19
+ <property name="label_xalign">0</property>
20
+ <property name="shadow_type">none</property>
21
+ <child>
22
+ <object class="GtkAlignment" id="alignment1">
23
+ <property name="visible">True</property>
24
+ <property name="can_focus">False</property>
25
+ <property name="left_padding">12</property>
26
+ <child>
27
+ <object class="GtkViewport" id="viewport1">
28
+ <property name="visible">True</property>
29
+ <property name="can_focus">False</property>
30
+ <child>
31
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
32
+ <property name="visible">True</property>
33
+ <property name="can_focus">True</property>
34
+ <property name="hscrollbar_policy">automatic</property>
35
+ <property name="vscrollbar_policy">automatic</property>
36
+ <child>
37
+ <object class="GtkTreeView" id="tvTimelogs">
38
+ <property name="visible">True</property>
39
+ <property name="can_focus">True</property>
40
+ <signal name="row-activated" handler="on_tvTimelogs_row_activated" swapped="no"/>
41
+ </object>
42
+ </child>
43
+ </object>
44
+ </child>
45
+ </object>
46
+ </child>
47
+ </object>
48
+ </child>
49
+ <child type="label">
50
+ <object class="GtkLabel" id="label2">
51
+ <property name="visible">True</property>
52
+ <property name="can_focus">False</property>
53
+ <property name="label" translatable="yes">&lt;b&gt;Timelogs&lt;/b&gt;</property>
54
+ <property name="use_markup">True</property>
55
+ </object>
56
+ </child>
57
+ </object>
58
+ <packing>
59
+ <property name="expand">True</property>
60
+ <property name="fill">True</property>
61
+ <property name="position">0</property>
62
+ </packing>
63
+ </child>
64
+ </object>
65
+ </child>
66
+ </object>
67
+ </interface>
@@ -0,0 +1,257 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <interface>
3
+ <requires lib="gtk+" version="2.24"/>
4
+ <!-- interface-naming-policy project-wide -->
5
+ <object class="GtkWindow" id="window">
6
+ <property name="can_focus">False</property>
7
+ <property name="title" translatable="yes">Preferences</property>
8
+ <property name="window_position">center</property>
9
+ <property name="default_width">640</property>
10
+ <property name="default_height">480</property>
11
+ <child>
12
+ <object class="GtkVBox" id="vbox1">
13
+ <property name="visible">True</property>
14
+ <property name="can_focus">False</property>
15
+ <child>
16
+ <object class="GtkFrame" id="frame1">
17
+ <property name="visible">True</property>
18
+ <property name="can_focus">False</property>
19
+ <property name="label_xalign">0</property>
20
+ <property name="shadow_type">none</property>
21
+ <child>
22
+ <object class="GtkAlignment" id="alignment1">
23
+ <property name="visible">True</property>
24
+ <property name="can_focus">False</property>
25
+ <property name="left_padding">12</property>
26
+ <child>
27
+ <object class="GtkVBox" id="vbox2">
28
+ <property name="visible">True</property>
29
+ <property name="can_focus">False</property>
30
+ <child>
31
+ <object class="GtkTable" id="table1">
32
+ <property name="visible">True</property>
33
+ <property name="can_focus">False</property>
34
+ <property name="n_rows">5</property>
35
+ <property name="n_columns">2</property>
36
+ <property name="column_spacing">3</property>
37
+ <property name="row_spacing">3</property>
38
+ <child>
39
+ <object class="GtkLabel" id="label3">
40
+ <property name="visible">True</property>
41
+ <property name="can_focus">False</property>
42
+ <property name="xalign">0</property>
43
+ <property name="label" translatable="yes">Host</property>
44
+ </object>
45
+ <packing>
46
+ <property name="x_options">GTK_FILL</property>
47
+ </packing>
48
+ </child>
49
+ <child>
50
+ <object class="GtkLabel" id="label4">
51
+ <property name="visible">True</property>
52
+ <property name="can_focus">False</property>
53
+ <property name="xalign">0</property>
54
+ <property name="label" translatable="yes">Username</property>
55
+ </object>
56
+ <packing>
57
+ <property name="top_attach">3</property>
58
+ <property name="bottom_attach">4</property>
59
+ <property name="x_options">GTK_FILL</property>
60
+ <property name="y_options">GTK_FILL</property>
61
+ </packing>
62
+ </child>
63
+ <child>
64
+ <object class="GtkEntry" id="txtHost">
65
+ <property name="visible">True</property>
66
+ <property name="can_focus">True</property>
67
+ <property name="invisible_char">•</property>
68
+ <property name="primary_icon_activatable">False</property>
69
+ <property name="secondary_icon_activatable">False</property>
70
+ <property name="primary_icon_sensitive">True</property>
71
+ <property name="secondary_icon_sensitive">True</property>
72
+ </object>
73
+ <packing>
74
+ <property name="left_attach">1</property>
75
+ <property name="right_attach">2</property>
76
+ </packing>
77
+ </child>
78
+ <child>
79
+ <object class="GtkEntry" id="txtUsername">
80
+ <property name="visible">True</property>
81
+ <property name="can_focus">True</property>
82
+ <property name="invisible_char">•</property>
83
+ <property name="primary_icon_activatable">False</property>
84
+ <property name="secondary_icon_activatable">False</property>
85
+ <property name="primary_icon_sensitive">True</property>
86
+ <property name="secondary_icon_sensitive">True</property>
87
+ </object>
88
+ <packing>
89
+ <property name="left_attach">1</property>
90
+ <property name="right_attach">2</property>
91
+ <property name="top_attach">3</property>
92
+ <property name="bottom_attach">4</property>
93
+ </packing>
94
+ </child>
95
+ <child>
96
+ <object class="GtkLabel" id="label5">
97
+ <property name="visible">True</property>
98
+ <property name="can_focus">False</property>
99
+ <property name="xalign">0</property>
100
+ <property name="label" translatable="yes">Password</property>
101
+ </object>
102
+ <packing>
103
+ <property name="top_attach">4</property>
104
+ <property name="bottom_attach">5</property>
105
+ <property name="x_options">GTK_FILL</property>
106
+ </packing>
107
+ </child>
108
+ <child>
109
+ <object class="GtkEntry" id="txtPassword">
110
+ <property name="visible">True</property>
111
+ <property name="can_focus">True</property>
112
+ <property name="visibility">False</property>
113
+ <property name="invisible_char">•</property>
114
+ <property name="primary_icon_activatable">False</property>
115
+ <property name="secondary_icon_activatable">False</property>
116
+ <property name="primary_icon_sensitive">True</property>
117
+ <property name="secondary_icon_sensitive">True</property>
118
+ </object>
119
+ <packing>
120
+ <property name="left_attach">1</property>
121
+ <property name="right_attach">2</property>
122
+ <property name="top_attach">4</property>
123
+ <property name="bottom_attach">5</property>
124
+ </packing>
125
+ </child>
126
+ <child>
127
+ <object class="GtkLabel" id="label6">
128
+ <property name="visible">True</property>
129
+ <property name="can_focus">False</property>
130
+ <property name="xalign">0</property>
131
+ <property name="label" translatable="yes">Port</property>
132
+ </object>
133
+ <packing>
134
+ <property name="top_attach">1</property>
135
+ <property name="bottom_attach">2</property>
136
+ <property name="x_options">GTK_FILL</property>
137
+ <property name="y_options">GTK_FILL</property>
138
+ </packing>
139
+ </child>
140
+ <child>
141
+ <object class="GtkEntry" id="txtPort">
142
+ <property name="visible">True</property>
143
+ <property name="can_focus">True</property>
144
+ <property name="invisible_char">•</property>
145
+ <property name="primary_icon_activatable">False</property>
146
+ <property name="secondary_icon_activatable">False</property>
147
+ <property name="primary_icon_sensitive">True</property>
148
+ <property name="secondary_icon_sensitive">True</property>
149
+ </object>
150
+ <packing>
151
+ <property name="left_attach">1</property>
152
+ <property name="right_attach">2</property>
153
+ <property name="top_attach">1</property>
154
+ <property name="bottom_attach">2</property>
155
+ </packing>
156
+ </child>
157
+ <child>
158
+ <object class="GtkCheckButton" id="cbSSL">
159
+ <property name="label" translatable="yes">SSL</property>
160
+ <property name="visible">True</property>
161
+ <property name="can_focus">True</property>
162
+ <property name="receives_default">False</property>
163
+ <property name="use_action_appearance">False</property>
164
+ <property name="draw_indicator">True</property>
165
+ </object>
166
+ <packing>
167
+ <property name="right_attach">2</property>
168
+ <property name="top_attach">2</property>
169
+ <property name="bottom_attach">3</property>
170
+ </packing>
171
+ </child>
172
+ </object>
173
+ <packing>
174
+ <property name="expand">True</property>
175
+ <property name="fill">True</property>
176
+ <property name="position">0</property>
177
+ </packing>
178
+ </child>
179
+ </object>
180
+ </child>
181
+ </object>
182
+ </child>
183
+ <child type="label">
184
+ <object class="GtkLabel" id="label2">
185
+ <property name="visible">True</property>
186
+ <property name="can_focus">False</property>
187
+ <property name="xalign">0</property>
188
+ <property name="label" translatable="yes">&lt;b&gt;OpenAll&lt;/b&gt;</property>
189
+ <property name="use_markup">True</property>
190
+ </object>
191
+ </child>
192
+ </object>
193
+ <packing>
194
+ <property name="expand">False</property>
195
+ <property name="fill">True</property>
196
+ <property name="position">0</property>
197
+ </packing>
198
+ </child>
199
+ <child>
200
+ <object class="GtkHButtonBox" id="hbuttonbox1">
201
+ <property name="visible">True</property>
202
+ <property name="can_focus">False</property>
203
+ <property name="spacing">3</property>
204
+ <property name="layout_style">end</property>
205
+ <child>
206
+ <object class="GtkButton" id="btnTest">
207
+ <property name="label" translatable="yes">Test</property>
208
+ <property name="visible">True</property>
209
+ <property name="can_focus">True</property>
210
+ <property name="receives_default">True</property>
211
+ <property name="use_action_appearance">False</property>
212
+ <signal name="clicked" handler="on_btnTest_clicked" swapped="no"/>
213
+ </object>
214
+ <packing>
215
+ <property name="expand">False</property>
216
+ <property name="fill">False</property>
217
+ <property name="position">0</property>
218
+ </packing>
219
+ </child>
220
+ <child>
221
+ <object class="GtkButton" id="btnSave">
222
+ <property name="label">gtk-save</property>
223
+ <property name="visible">True</property>
224
+ <property name="can_focus">True</property>
225
+ <property name="receives_default">True</property>
226
+ <property name="use_action_appearance">False</property>
227
+ <property name="use_stock">True</property>
228
+ <signal name="clicked" handler="on_btnSave_clicked" swapped="no"/>
229
+ </object>
230
+ <packing>
231
+ <property name="expand">False</property>
232
+ <property name="fill">False</property>
233
+ <property name="position">1</property>
234
+ </packing>
235
+ </child>
236
+ </object>
237
+ <packing>
238
+ <property name="expand">False</property>
239
+ <property name="fill">True</property>
240
+ <property name="position">1</property>
241
+ </packing>
242
+ </child>
243
+ <child>
244
+ <object class="GtkLabel" id="label1">
245
+ <property name="visible">True</property>
246
+ <property name="can_focus">False</property>
247
+ </object>
248
+ <packing>
249
+ <property name="expand">True</property>
250
+ <property name="fill">True</property>
251
+ <property name="position">2</property>
252
+ </packing>
253
+ </child>
254
+ </object>
255
+ </child>
256
+ </object>
257
+ </interface>