cremefraiche 1.1.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of cremefraiche might be problematic. Click here for more details.

Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/bin/cremefraiche +25 -0
  3. data/bin/cremefraicheGui +26 -0
  4. data/cremefraiche.gemspec +24 -0
  5. data/lib/LANG +1 -0
  6. data/lib/busy_indicator/busy_function_test.rb +56 -0
  7. data/lib/busy_indicator/busy_indicator.rb +95 -0
  8. data/lib/busy_indicator/color_output.rb +51 -0
  9. data/lib/cfprawn.rb +394 -0
  10. data/lib/confcheck.rb +112 -0
  11. data/lib/config +192 -0
  12. data/lib/configuration.rb +259 -0
  13. data/lib/cremefraiche.rb +341 -0
  14. data/lib/emlfile.rb +140 -0
  15. data/lib/file_checking.rb +87 -0
  16. data/lib/gui/AboutDialog.rb +64 -0
  17. data/lib/gui/ButtonLabel.rb +49 -0
  18. data/lib/gui/ConfDialog.rb +618 -0
  19. data/lib/gui/HowtoDialog.rb +184 -0
  20. data/lib/gui/conf_option.rb +279 -0
  21. data/lib/gui/conf_value.rb +65 -0
  22. data/lib/gui/cremefraicheGui.rb +625 -0
  23. data/lib/gui/gtk-about.xpm +90 -0
  24. data/lib/gui/gtk-close.xpm +90 -0
  25. data/lib/gui/gtk-execute.xpm +118 -0
  26. data/lib/gui/gtk-open.xpm +147 -0
  27. data/lib/gui/gtk-properties.xpm +378 -0
  28. data/lib/gui/gtk-quit.xpm +352 -0
  29. data/lib/gui/gtk-remove.xpm +123 -0
  30. data/lib/gui/gtk-save.xpm +214 -0
  31. data/lib/gui/gtk-stop.xpm +344 -0
  32. data/lib/gui/help.xpm +463 -0
  33. data/lib/gui/icon.xpm +300 -0
  34. data/lib/gui/message_dialog.rb +34 -0
  35. data/lib/gui/okay.xpm +49 -0
  36. data/lib/gui/preferences-color.xpm +252 -0
  37. data/lib/gui/view.xpm +75 -0
  38. data/lib/html2text.rb +177 -0
  39. data/lib/icon/icon.xpm +300 -0
  40. data/lib/icon/icon_big.xpm +661 -0
  41. data/lib/license.rb +705 -0
  42. data/lib/log.conf +65 -0
  43. data/lib/logging.rb +193 -0
  44. data/lib/tag_munging.rb +97 -0
  45. data/lib/translating.rb +78 -0
  46. data/lib/translations +598 -0
  47. data/lib/version.rb +26 -0
  48. metadata +213 -0
data/lib/emlfile.rb ADDED
@@ -0,0 +1,140 @@
1
+ #encoding: UTF-8
2
+ =begin
3
+ /***************************************************************************
4
+ * ©2011-2014 Michael Uplawski <michael.uplawski@uplawski.eu> *
5
+ * *
6
+ * This program is free software; you can redistribute it and/or modify *
7
+ * it under the terms of the GNU General Public License as published by *
8
+ * the Free Software Foundation; either version 3 of the License, or *
9
+ * (at your option) any later version. *
10
+ * *
11
+ * This program is distributed in the hope that it will be useful, *
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
+ * GNU General Public License for more details. *
15
+ * *
16
+ * You should have received a copy of the GNU General Public License *
17
+ * along with this program; if not, write to the *
18
+ * Free Software Foundation, Inc., *
19
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
20
+ ***************************************************************************/
21
+ =end
22
+
23
+ require_relative "file_checking"
24
+ require_relative "translating"
25
+ require_relative "logging"
26
+ require 'mail'
27
+
28
+
29
+ # A representation of an EML-file.
30
+ # Wraps the Mail-object (from the Mail-gem).
31
+ class EmlFile
32
+ include File_Checking
33
+ include Translating
34
+ include Logging
35
+ @@MAIL_INTRO = "From "
36
+ @@errors = []
37
+ attr_reader :headers, :body, :files, :filename, :msg
38
+
39
+ public
40
+
41
+ # create the representation of 1 eml-file
42
+ def initialize(filename)
43
+ init_logger($CONF.log_file ? $CONF.log_file : STDOUT, $CONF.log_level ? $CONF.log_level : Logger::UNKNOWN)
44
+ @attachments = nil
45
+ @body = nil
46
+ @headers = nil
47
+ msg = file_check(filename, :exist, :file, :readable)
48
+ @log.debug('file checked: ' << msg.to_s)
49
+ @@errors << msg if msg
50
+ # split the file into many, one for each e-mail
51
+ if(!msg)
52
+ split(filename)
53
+ else
54
+ @log.error(trl("Invalid file") << ": %s (%s)" %[filename,msg] )
55
+
56
+ end
57
+ end
58
+ # delegate messages, that this object cannot respond to to the Mail-object
59
+ def method_missing(method, *args)
60
+ if(@mail.respond_to?(method) )
61
+ @mail.send(method, *args)
62
+ else
63
+ @log.error(trl("method %s is undefined for objects of class %s") %[method, self.class.name])
64
+ end
65
+ end
66
+ # call the given block on each individual mail-file
67
+ def mails(&b)
68
+ if(@files)
69
+ @log.debug('working on the files: ' << @files.join(', '))
70
+ @files.each do |f|
71
+ parse(f)
72
+ @filename=f
73
+ yield(self)
74
+ end
75
+ end
76
+ end
77
+
78
+ private
79
+
80
+ # separate the components of each mail-file
81
+ def parse(filename)
82
+ if(filename)
83
+ @mail = Mail.read(filename)
84
+ if(@mail )
85
+ @headers = @mail.header_fields
86
+ # @log.debug('Parsed headers are ' << @headers.join(', ') )
87
+ @body = @mail.body
88
+ @log.debug('Parsed body is ' << @body.to_s )
89
+ @attachments = @mail.attachments if @mail.attachment?
90
+ end
91
+ end
92
+ end
93
+
94
+ # prefix the number num with a maximum of count_zero zeros
95
+ def prefix_number(num, count_zero = 2)
96
+ str = ''
97
+ if(num)
98
+ str = num.to_s
99
+ count_zero.times do
100
+ if(num % 10 == num)
101
+ str = ('0' << str )
102
+ @log.debug('str is now ' << str)
103
+ end
104
+ end
105
+ end
106
+ return str
107
+ end
108
+
109
+ # split the file 'filename' into separate files, each containing 1 mail
110
+ def split(filename)
111
+ dir = $CONF.temp_dir
112
+ @log.debug(trl("storing temporary files in %s") %dir.path)
113
+ index = 0
114
+ @files = []
115
+ begin
116
+ File.open(filename, 'r') do |ifl|
117
+ ofl = nil
118
+ ifl.each_line do |line|
119
+ if(line.start_with?(@@MAIL_INTRO))
120
+ ofl.close if ofl && !ofl.closed?
121
+ index += 1
122
+ ofl_name = format("%s/%s_%s" %[dir.path, prefix_number(index, 2), File.basename(filename)])
123
+ @log.debug(trl("storing a message in %s") %ofl_name)
124
+ ofl = File.open(ofl_name, 'w')
125
+ @files << ofl_name
126
+ end
127
+ ofl << line if ofl && !ofl.closed?
128
+ end
129
+ ofl.close if ofl && !ofl.closed?
130
+ end
131
+ rescue Exception => ex
132
+ @log.error(trl("Cannot open file '%s'") %filename << ': ' << ex.message )
133
+ end
134
+ # a single e-mail can be stored in its own file
135
+ if(@files.empty? && File::exist?(filename) && File::readable?(filename) )
136
+ @files << filename
137
+ end
138
+ end # END split()
139
+ end # END of class
140
+
@@ -0,0 +1,87 @@
1
+ #encoding: UTF-8
2
+ =begin
3
+ /***************************************************************************
4
+ * ©2011-2013 Michael Uplawski <michael.uplawski@uplawski.eu> *
5
+ * *
6
+ * This program is free software; you can redistribute it and/or modify *
7
+ * it under the terms of the GNU General Public License as published by *
8
+ * the Free Software Foundation; either version 3 of the License, or *
9
+ * (at your option) any later version. *
10
+ * *
11
+ * This program is distributed in the hope that it will be useful, *
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
+ * GNU General Public License for more details. *
15
+ * *
16
+ * You should have received a copy of the GNU General Public License *
17
+ * along with this program; if not, write to the *
18
+ * Free Software Foundation, Inc., *
19
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
20
+ ***************************************************************************/
21
+ =end
22
+
23
+ =begin
24
+ A module to facilitate frequently occuring checks on
25
+ file-system objects
26
+ =end
27
+ module File_Checking
28
+
29
+ @@text_messages = {
30
+ :exist? => "does not exist!",
31
+ :exist => "does not exist!",
32
+ :readable? => "is not readable!",
33
+ :readable => "is not readable!",
34
+ :executable? => "is not executable!",
35
+ :executable => "is not executable!",
36
+ :writable? => "is not writable!",
37
+ :writable => "is not writable!",
38
+ :directory? => "is not a directory!",
39
+ :directory => "is not a directory!",
40
+ :file? => "is not a file!",
41
+ :file => "is not a file!",
42
+ }
43
+
44
+ # Checks if the file with the name from the first
45
+ # parameter has the properties, listed in the second.
46
+ # The messages parameter is an array of one or several
47
+ # of :exist?, :readable?, :writable?, :directory? or
48
+ # their string-representations, respectively.
49
+ # Returns nil in case of success, otherwise an
50
+ # informative message, describing the first negative
51
+ # test-result.
52
+ def file_check(file, *messages)
53
+ File_Checking.file_check(file, *messages)
54
+ end
55
+
56
+ # Checks if the file with the name from the first
57
+ # parameter has the properties, listed in the second.
58
+ # The messages parameter is an array of one or all
59
+ # of :exist?, :readable?, :writable?, :directory? or
60
+ # their string-representations, respectively.
61
+ # Returns nil in case of success, otherwise an
62
+ # informative message, describing the first negative
63
+ # test-result.
64
+ def self.file_check(file, *messages)
65
+ msg = nil
66
+ if(file && messages.respond_to?(:to_ary) && !messages.empty?)
67
+ messages.each do |k|
68
+ if(! k.to_s.end_with?('?'))
69
+ k = (k.to_s << '?').to_sym
70
+ end
71
+ @log.debug ('checking ' << k.to_s) if @log
72
+ if(msg == nil && File.respond_to?(k) && ! File.send(k, file.to_s))
73
+ msg = "#{file} #{@@text_messages[k.to_sym]}"
74
+ end
75
+ end
76
+ end
77
+ msg
78
+ end
79
+ end
80
+
81
+ =begin
82
+ # example
83
+
84
+ include File_Checking
85
+ msg = file_check('some_file.txt', [:exist?, :readable?, 'writable'])
86
+ puts msg if msg
87
+ =end
@@ -0,0 +1,64 @@
1
+ #encoding: UTF-8
2
+ =begin
3
+ /***************************************************************************
4
+ * ©2011-2016 Michael Uplawski <michael.uplawski@uplawski.eu> *
5
+ * *
6
+ * This program is free software; you can redistribute it and/or modify *
7
+ * it under the terms of the GNU General Public License as published by *
8
+ * the Free Software Foundation; either version 3 of the License, or *
9
+ * (at your option) any later version. *
10
+ * *
11
+ * This program is distributed in the hope that it will be useful, *
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
+ * GNU General Public License for more details. *
15
+ * *
16
+ * You should have received a copy of the GNU General Public License *
17
+ * along with this program; if not, write to the *
18
+ * Free Software Foundation, Inc., *
19
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
20
+ ***************************************************************************/
21
+ =end
22
+
23
+ require 'gtk3'
24
+ require_relative '../cremefraiche'
25
+ require_relative '../translating'
26
+ require_relative '../file_checking'
27
+ require_relative '../license.rb'
28
+ require_relative '../logging.rb'
29
+
30
+ GD = File::expand_path(File::dirname(__FILE__) ) + File::Separator if !defined?(GD)
31
+
32
+ class AboutDialog
33
+ @@License_File = GD.dup << '../doc/license.txt'
34
+ include Translating
35
+ include Logging
36
+ def initialize( options = {})
37
+ init_logger($CONF.log_file ? $CONF.log_file : STDOUT, $CONF.log_level ? $CONF.log_level : Logger::UNKNOWN)
38
+ prog_info = CremeFraiche::prog_info
39
+
40
+ @adialog = Gtk::AboutDialog.new
41
+ @adialog.name = prog_info[:app_name]
42
+ @adialog.title = prog_info[:app_name]
43
+ @adialog.set_program_name prog_info[:app_name]
44
+ @adialog.version = prog_info[:version]
45
+ @adialog.copyright = "© #{prog_info[:years]} #{prog_info[:author]} #{prog_info[:author_mail]}"
46
+ @adialog.website = "#{prog_info[:web_page]}"
47
+ @adialog.website = trl("Project Homepage")
48
+ comment = trl('running with Ruby') << ' ' << RUBY_VERSION << ' (' << RUBY_RELEASE_DATE << ') ' << RUBY_PLATFORM.dup
49
+ comment << "\n\n" << trl('Current system') << ': ' << prog_info[:cur_system]
50
+ @adialog.comments = comment
51
+
52
+ @adialog.logo = Gdk::Pixbuf.new(GD + "icon.xpm")
53
+ @adialog.signal_connect('response') do |dlg, resp|
54
+ @log.debug("response %i emitted" %resp) if @log
55
+ @adialog.destroy if(Gtk::ResponseType::CANCEL == resp)
56
+ end
57
+ if(options && options.keys.include?(:on_destroy))
58
+ @adialog.signal_connect('destroy') {options[:on_destroy].call() }
59
+ end
60
+ @adialog.license = LICENSE_TEXT
61
+ @adialog.show
62
+ end
63
+ end
64
+
@@ -0,0 +1,49 @@
1
+ #encoding: UTF-8
2
+ =begin
3
+ /***************************************************************************
4
+ * ©2011-2016 Michael Uplawski <michael.uplawski@uplawski.eu> *
5
+ * *
6
+ * This program is free software; you can redistribute it and/or modify *
7
+ * it under the terms of the GNU General Public License as published by *
8
+ * the Free Software Foundation; either version 3 of the License, or *
9
+ * (at your option) any later version. *
10
+ * *
11
+ * This program is distributed in the hope that it will be useful, *
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
+ * GNU General Public License for more details. *
15
+ * *
16
+ * You should have received a copy of the GNU General Public License *
17
+ * along with this program; if not, write to the *
18
+ * Free Software Foundation, Inc., *
19
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
20
+ ***************************************************************************/
21
+ =end
22
+
23
+ require_relative '../logging'
24
+ require 'gtk3'
25
+ require_relative '../translating'
26
+
27
+ =begin
28
+ Meant to be used as label for push-buttons,
29
+ objects of this class combine a text-value
30
+ with a user-provided icon.
31
+ =end
32
+ class ButtonLabel < Gtk::Box
33
+ include Logging
34
+ def initialize(text, imagefile = nil)
35
+ init_logger($CONF.log_file ? $CONF.log_file : STDOUT, $CONF.log_level ? $CONF.log_level : Logger::UNKNOWN)
36
+ super(:horizontal, 5)
37
+ set_border_width(0)
38
+ pack_start(Gtk::Image.new(:file => imagefile)) if imagefile
39
+ @mlabel = Gtk::Label.new( text, :mnemonic => true)
40
+ @mlabel.markup_with_mnemonic=text
41
+ # @log.debug(@mlabel.mnemonic_keyval)
42
+ pack_start(@mlabel)
43
+ end
44
+
45
+ def mnemonic_widget=(wd)
46
+ @mlabel.mnemonic_widget=(wd)
47
+ end
48
+
49
+ end