~ubuntu-branches/ubuntu/precise/topal/precise

« back to all changes in this revision

Viewing changes to configuration.adb

  • Committer: Bazaar Package Importer
  • Author(s): Phil Brooke
  • Date: 2008-07-18 07:57:38 UTC
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20080718075738-i1szqvmxz0evz32p
Tags: upstream-62
ImportĀ upstreamĀ versionĀ 62

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
--
2
 
--
3
 
--
4
 
--
 
1
-- Topal: GPG/GnuPG and Alpine/Pine integration
 
2
-- Copyright (C) 2001--2008  Phillip J. Brooke
 
3
--
 
4
-- This program is free software: you can redistribute it and/or modify
 
5
-- it under the terms of the GNU General Public License version 3 as
 
6
-- published by the Free Software Foundation.
 
7
--
 
8
-- This program is distributed in the hope that it will be useful,
 
9
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
-- GNU General Public License for more details.
 
12
--
 
13
-- You should have received a copy of the GNU General Public License
 
14
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
5
15
 
6
16
with Ada.IO_Exceptions;
7
17
with Ada.Strings.Fixed;
30
27
   procedure Parse_AKE (KE   : in  UBS;
31
28
                        Key   : out UBS;
32
29
                        Email  : out UBS) is
33
 
      KES : String := ToStr(KE);
 
30
      KES : constant String := ToStr(KE);
34
31
      Sep : Natural;
35
32
   begin
36
33
      Sep := Ada.Strings.Fixed.Index(Source => KES,
76
73
         raise;
77
74
   end Set_Two_Way;
78
75
 
 
76
   function Match_Binary_Path (N : String) return Boolean is
 
77
   begin
 
78
      for I in Binaries loop
 
79
         if ToStr(Binary_Name(I)) & "-binary" = N then
 
80
            return True;
 
81
         end if;
 
82
      end loop;
 
83
      return False;
 
84
   end Match_Binary_Path;
 
85
 
 
86
   No_Binary_Match : exception;
 
87
   function Get_Binary_Path (N : String) return Binaries is
 
88
   begin
 
89
      for I in Binaries loop
 
90
         if ToStr(Binary_Name(I)) & "-binary" = N then
 
91
            return I;
 
92
         end if;
 
93
      end loop;
 
94
      raise No_Binary_Match;
 
95
   end Get_Binary_Path;
 
96
 
79
97
   procedure Read_Config_File is
80
98
      use Ada.Text_IO;
81
99
      use Misc;
88
106
      loop
89
107
         begin
90
108
            declare
91
 
               The_Line : String := ToStr(Misc.Unbounded_Get_Line(CF));
 
109
               The_Line : constant String
 
110
                 := ToStr(Misc.Unbounded_Get_Line(CF));
92
111
               Name     : UBS;
93
112
               Value    : UBS;
94
113
            begin
95
 
               Parse_Config_Line(The_Line, Name, Value);
96
 
               declare
97
 
                  N : String := ToStr(Name);
98
 
                  V : UBS renames Value;
99
 
               begin
100
 
                  if N = "my-key" then
101
 
                     Config.my_key := V;
102
 
                  -- Binary command options.
103
 
                  elsif N = "cat-binary" then
104
 
                     null; -- Silently ignored.
105
 
                  elsif N = "chmod-binary" then
106
 
                     Config.chmod_binary := V;
107
 
                  elsif N = "clear-binary" then
108
 
                     Config.clear_binary := V;
109
 
                  elsif N = "date-binary" then
110
 
                     Config.date_binary := V;
111
 
                  elsif N = "diff-binary" then
112
 
                     Config.diff_binary := V;
113
 
                  elsif N = "dos2unix-binary" then
114
 
                     Config.Dos2Unix_binary := V;
115
 
                  elsif N = "echo-binary" then
116
 
                     null; -- Silently ignored.
117
 
                  elsif N = "formail-binary" then
118
 
                     Config.formail_binary := V;
119
 
                  elsif N = "gpg-binary" then
120
 
                     Config.gpg_binary := V;
121
 
                  elsif N = "grep-binary" then
122
 
                     Config.grep_binary := V;
123
 
                  elsif N = "less-binary" then
124
 
                     Config.less_binary := V;
125
 
                  elsif N = "md5sum-binary" then
126
 
                     Config.md5sum_binary := V;
127
 
                  elsif N = "metamail-binary" then
128
 
                     Config.metamail_binary := V;
129
 
                  elsif N = "mimeconstruct-binary" then
130
 
                     Config.mimeconstruct_binary := V;
131
 
                  elsif N = "mkdir-binary" then
132
 
                     Config.mkdir_binary := V;
133
 
                  elsif N = "mv-binary" then
134
 
                     Config.mv_binary := V;
135
 
                  elsif N = "rm-binary" then
136
 
                     Config.rm_binary := V;
137
 
                  elsif N = "sed-binary" then
138
 
                     Config.sed_binary := V;
139
 
                  elsif N = "stty-binary" then
140
 
                     Config.stty_binary := V;
141
 
                  elsif N = "tee-binary" then
142
 
                     Config.tee_binary := V;
143
 
                  elsif N = "test-binary" then
144
 
                     Config.test_binary := V;
145
 
                  elsif N = "general-options" then
146
 
                     Config.general_options := V;
147
 
                  elsif N = "gpg-options" then
148
 
                     Config.gpg_options := V;
149
 
                  elsif N = "receiving-options" then
150
 
                     Config.receiving_options := V;
151
 
                  elsif N = "sending-options" then
152
 
                     Config.sending_options := V;
153
 
                  elsif N = "decrypt-not-cached" then
154
 
                     Config.decrypt_not_cached :=  String_To_Integer(V);
155
 
                  elsif N = "decrypt-not-cached-use-cache" then
156
 
                     Config.decrypt_not_cached_use_cache :=  String_To_Integer(V);
157
 
                  elsif N = "decrypt-cached" then
158
 
                     Config.decrypt_cached := String_To_Integer(V);
159
 
                  elsif N = "decrypt-cached-use-cache" then
160
 
                     Config.decrypt_cached_use_cache := String_To_Integer(V);
161
 
                  elsif N = "verify-not-cached" then
162
 
                     Config.verify_not_cached := String_To_Integer(V);
163
 
                  elsif N = "verify-not-cached-use-cache" then
164
 
                     Config.verify_not_cached_use_cache := String_To_Integer(V);
165
 
                  elsif N = "verify-cached" then
166
 
                     Config.verify_cached := String_To_Integer(V);
167
 
                  elsif N = "verify-cached-use-cache" then
168
 
                     Config.verify_cached_use_cache := String_To_Integer(V);
169
 
                  elsif N = "decrypt-cached-fast-continue" then
170
 
                     Config.Decrypt_Cached_Fast_Continue := Set_Two_Way(ToStr(V));
171
 
                  elsif N = "verify-cached-fast-continue" then
172
 
                     Config.Verify_Cached_Fast_Continue := Set_Two_Way(ToStr(V));
173
 
                  elsif N = "verify-not-cached-fast-continue" then
174
 
                    Config.Verify_Not_Cached_Fast_Continue := Set_Two_Way(ToStr(V));
175
 
                  elsif N = "inline-separate-output" then
176
 
                     Config.Inline_Separate_Output := Set_Two_Way(ToStr(V));
177
 
                  elsif N = "fe-simple" then
178
 
                     Config.FE_Simple := Set_Two_Way(ToStr(V));
179
 
                  elsif N = "debug" then
180
 
                     Config.Debug := Set_Two_Way(ToStr(V));
181
 
                  elsif N = "ake" then
182
 
                     -- Break the up the key,email pair.
183
 
                     declare
184
 
                        K : UBS;
185
 
                        E : UBS;
186
 
                     begin
187
 
                        Parse_AKE(V, K, E);
188
 
                        Config.AKE_Count := Config.AKE_Count + 1;
189
 
                        UAP.Set(Config.AKE_Key, Config.AKE_Count, K);
190
 
                        UAP.Set(Config.AKE_Email, Config.AKE_Count, E);
191
 
                     end;
192
 
                  elsif N = "xk" then
193
 
                     -- This is a key to be excluded.
194
 
                     Config.XK_Count := Config.XK_Count + 1;
195
 
                     UAP.Set(Config.XK_Key, Config.XK_Count, V);
196
 
                  else
197
 
                     Put_Line("Bogus line: " & The_Line);
198
 
                     raise Config_Parse_Error;
199
 
                  end if;
200
 
               end;
 
114
               if The_Line'Length > 0
 
115
                 and then The_Line(The_Line'First) = '#' then
 
116
                  -- It's a comment.  Ignore it.
 
117
                  null;
 
118
               else
 
119
                  Parse_Config_Line(The_Line, Name, Value);
 
120
                  declare
 
121
                     N : constant String := ToStr(Name);
 
122
                     V : UBS renames Value;
 
123
                  begin
 
124
                     if N = "my-key" then
 
125
                        Config.my_key := V;
 
126
                        -- Binary command options.
 
127
                     elsif Match_Binary_Path(N)  then
 
128
                        Config.Binary(Get_Binary_Path(N)) := V;
 
129
                        -- General options.
 
130
                     elsif N = "general-options" then
 
131
                        Config.general_options := V;
 
132
                     elsif N = "gpg-options" then
 
133
                        Config.gpg_options := V;
 
134
                     elsif N = "receiving-options" then
 
135
                        Config.receiving_options := V;
 
136
                     elsif N = "sending-options" then
 
137
                        Config.sending_options := V;
 
138
                        -- Switches.
 
139
                     elsif N = "decrypt-not-cached" then
 
140
                        Config.decrypt_not_cached :=  String_To_Integer(V);
 
141
                     elsif N = "decrypt-not-cached-use-cache" then
 
142
                        Config.decrypt_not_cached_use_cache :=  String_To_Integer(V);
 
143
                     elsif N = "decrypt-cached" then
 
144
                        Config.decrypt_cached := String_To_Integer(V);
 
145
                     elsif N = "decrypt-cached-use-cache" then
 
146
                        Config.decrypt_cached_use_cache := String_To_Integer(V);
 
147
                     elsif N = "verify-not-cached" then
 
148
                        Config.verify_not_cached := String_To_Integer(V);
 
149
                     elsif N = "verify-not-cached-use-cache" then
 
150
                        Config.verify_not_cached_use_cache := String_To_Integer(V);
 
151
                     elsif N = "verify-cached" then
 
152
                        Config.verify_cached := String_To_Integer(V);
 
153
                     elsif N = "verify-cached-use-cache" then
 
154
                        Config.verify_cached_use_cache := String_To_Integer(V);
 
155
                     elsif N = "decrypt-cached-fast-continue" then
 
156
                        Config.Decrypt_Cached_Fast_Continue := Set_Two_Way(ToStr(V));
 
157
                     elsif N = "verify-cached-fast-continue" then
 
158
                        Config.Verify_Cached_Fast_Continue := Set_Two_Way(ToStr(V));
 
159
                     elsif N = "verify-not-cached-fast-continue" then
 
160
                        Config.Verify_Not_Cached_Fast_Continue := Set_Two_Way(ToStr(V));
 
161
                        -- Other oddities.
 
162
                     elsif N = "mime-viewer" then
 
163
                        Config.MIME_Viewer := String_To_Integer(V);
 
164
                     elsif N = "inline-separate-output" then
 
165
                        Config.Inline_Separate_Output := Set_Two_Way(ToStr(V));
 
166
                     elsif N = "fe-simple" then
 
167
                        Config.FE_Simple := Set_Two_Way(ToStr(V));
 
168
                     elsif N = "debug" then
 
169
                        Config.Debug := Set_Two_Way(ToStr(V));
 
170
                     elsif N = "ake" then
 
171
                        -- Break the up the key,email pair.
 
172
                        declare
 
173
                           K : UBS;
 
174
                           E : UBS;
 
175
                        begin
 
176
                           Parse_AKE(V, K, E);
 
177
                           Config.AKE_Count := Config.AKE_Count + 1;
 
178
                           UAP.Set(Config.AKE_Key, Config.AKE_Count, K);
 
179
                           UAP.Set(Config.AKE_Email, Config.AKE_Count, E);
 
180
                        end;
 
181
                     elsif N = "xk" then
 
182
                        -- This is a key to be excluded.
 
183
                        Config.XK_Count := Config.XK_Count + 1;
 
184
                        UAP.Set(Config.XK_Key, Config.XK_Count, V);
 
185
                     elsif N = "sake" then
 
186
                        -- Break the up the key,email pair.
 
187
                        declare
 
188
                           K : UBS;
 
189
                           E : UBS;
 
190
                        begin
 
191
                           Parse_AKE(V, K, E);
 
192
                           Config.SAKE_Count := Config.SAKE_Count + 1;
 
193
                           UAP.Set(Config.SAKE_Key, Config.SAKE_Count, K);
 
194
                           UAP.Set(Config.SAKE_Email, Config.SAKE_Count, E);
 
195
                        end;
 
196
                     elsif N = "sxk" then
 
197
                        -- This is a key to be excluded.
 
198
                        Config.SXK_Count := Config.SXK_Count + 1;
 
199
                        UAP.Set(Config.SXK_Key, Config.SXK_Count, V);
 
200
                     else
 
201
                        Put_Line("Bogus line: " & The_Line);
 
202
                        raise Config_Parse_Error;
 
203
                     end if;
 
204
                  end;
 
205
               end if;
201
206
            end;
202
207
         exception
203
208
            when Ada.IO_Exceptions.End_Error =>
215
220
         raise;
216
221
   end Read_Config_File;
217
222
 
 
223
   -- Given the current value (V) and default config (D), Put_Line if
 
224
   --  different or make it a comment if the same.
 
225
   procedure Dump_Bin (K : in String;
 
226
                       V : in UBS;
 
227
                       D : in UBS) is
 
228
      use type UBS;
 
229
   begin
 
230
      if V = D then
 
231
         Ada.Text_IO.Put("#");
 
232
      end if;
 
233
      Ada.Text_IO.Put_Line(K & "-binary=" & ToStr(V));
 
234
   end Dump_Bin;
 
235
 
218
236
   procedure Dump (Overwrite_Config : in Boolean := False) is
219
237
      use Ada.Text_IO;
220
238
      use Misc;
221
239
      F : File_Type;
 
240
      Default_Config : Config_Record;
222
241
   begin
223
242
      if Overwrite_Config then
224
243
         if Externals.Simple.Test_F(ToStr(Topal_Directory) & "/config") then
230
249
                Name => ToStr(Topal_Directory) & "/config");
231
250
         Set_Output(F);
232
251
      end if;
 
252
      Default_Configuration(Default_Config);
233
253
      Put_Line("my-key=" & ToStr(Config.My_Key));
234
 
      Put_Line("chmod-binary=" & ToStr(Config.Chmod_Binary));
235
 
      Put_Line("clear-binary=" & ToStr(Config.Clear_Binary));
236
 
      Put_Line("date-binary=" & ToStr(Config.Date_Binary));
237
 
      Put_Line("diff-binary=" & ToStr(Config.Diff_Binary));
238
 
      Put_Line("dos2unix-binary=" & ToStr(Config.Dos2Unix_Binary));
239
 
      Put_Line("formail-binary=" & ToStr(Config.Formail_Binary));
240
 
      Put_Line("gpg-binary=" & ToStr(Config.Gpg_Binary));
241
 
      Put_Line("grep-binary=" & ToStr(Config.Grep_Binary));
242
 
      Put_Line("less-binary=" & ToStr(Config.Less_Binary));
243
 
      Put_Line("md5sum-binary=" & ToStr(Config.Md5sum_Binary));
244
 
      Put_Line("metamail-binary=" & ToStr(Config.Metamail_Binary));
245
 
      Put_Line("mimeconstruct-binary=" & ToStr(Config.Mimeconstruct_Binary));
246
 
      Put_Line("mkdir-binary=" & ToStr(Config.Mkdir_Binary));
247
 
      Put_Line("mv-binary=" & ToStr(Config.Mv_Binary));
248
 
      Put_Line("rm-binary=" & ToStr(Config.Rm_Binary));
249
 
      Put_Line("sed-binary=" & ToStr(Config.Sed_Binary));
250
 
      Put_Line("stty-binary=" & ToStr(Config.Stty_Binary));
251
 
      Put_Line("tee-binary=" & ToStr(Config.Tee_Binary));
252
 
      Put_Line("test-binary=" & ToStr(Config.Test_Binary));
253
 
      Put_Line("general-options=" & ToStr(Config.General_Options));
 
254
      -- Binary paths.
 
255
      for I in Binaries loop
 
256
         Dump_Bin(ToStr(Binary_Name(I)), Config.Binary(I), Default_Config.Binary(I));
 
257
      end loop;
 
258
      -- Other options.
 
259
       Put_Line("general-options=" & ToStr(Config.General_Options));
254
260
      Put_Line("gpg-options=" & ToStr(Config.Gpg_Options));
255
261
      Put_Line("receiving-options=" & ToStr(Config.Receiving_Options));
256
262
      Put_Line("sending-options=" & ToStr(Config.Sending_Options));
276
282
               & ToStr(Two_Way(Config.Verify_Cached_Fast_Continue)));
277
283
      Put_Line("verify-not-cached-fast-continue="
278
284
               & ToStr(Two_Way(Config.Verify_Not_Cached_Fast_Continue)));
 
285
      Put_Line("mime-viewer="
 
286
               & Trim_Leading_Spaces(Integer'Image(Config.MIME_Viewer)));
279
287
      Put_Line("inline-separate-output=" & ToStr(Two_Way(Config.Inline_Separate_Output)));
280
288
      Put_Line("fe-simple=" & ToStr(Two_Way(Config.FE_Simple)));
281
289
      Put_Line("debug=" & ToStr(Two_Way(Config.Debug)));
289
297
         Put_Line("xk="
290
298
                  & ToStr(UAP.Value(Config.XK_Key, I)));
291
299
      end loop;
 
300
      for I in 1 .. Config.SAKE_Count loop
 
301
         Put_Line("sake="
 
302
                  & ToStr(UAP.Value(Config.SAKE_Key, I))
 
303
                  & ","
 
304
                  & ToStr(UAP.Value(Config.SAKE_Email, I)));
 
305
      end loop;
 
306
      for I in 1 .. Config.SXK_Count loop
 
307
         Put_Line("sxk="
 
308
                  & ToStr(UAP.Value(Config.SXK_Key, I)));
 
309
      end loop;
292
310
      if Overwrite_Config then
293
311
         Set_Output(Standard_Output);
294
312
         Close(F);
301
319
         raise;
302
320
   end Dump;
303
321
 
 
322
   procedure Edit_Own_Key is
 
323
      use Ada.Text_IO;
 
324
   begin
 
325
      New_Line(2);
 
326
      Put_Line("Signing key is currently: "
 
327
               & ToStr(Config.My_Key));
 
328
      Put_Line("Do you want to replace this key?");
 
329
      Put_Line("Answer Yes to replace it; No to keep the current key.");
 
330
      if YN_Menu = Yes then
 
331
         -- Now, find all secret keys and offer them as a `select 1' list.
 
332
         declare
 
333
            SKL            : Keys.Key_List;
 
334
            Pattern        : UBS;
 
335
            New_Secret_Key : UBS;
 
336
            Use_Old_Key    : Boolean;
 
337
         begin
 
338
            Keys.Empty_Keylist(SKL);
 
339
            Pattern := ToUBS(Readline.Get_String("Type GPG search pattern: "));
 
340
            Keys.Add_Secret_Keys(Pattern, SKL, Keys.Any);
 
341
            Keys.Select_Key_From_List(SKL, New_Secret_Key, Use_Old_Key);
 
342
            if not Use_Old_Key then
 
343
               Config.My_Key := New_Secret_Key;
 
344
            end if;
 
345
         end;
 
346
      end if;
 
347
   exception
 
348
      when others =>
 
349
         Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,
 
350
                              "Exception raised in Configuration.Edit_Own_Key");
 
351
         raise;
 
352
   end Edit_Own_Key;
 
353
 
304
354
   procedure Edit_Configuration is
305
355
      use Ada.Text_IO;
306
356
      use Misc;
315
365
            3 => ToUBS("Ask-replace"),
316
366
            4 => ToUBS("Ignore cache"),
317
367
            5 => ToUBS("Offer all"));
 
368
      MV_Str : constant array (Integer range 1..5) of UBS
 
369
        := (1 => ToUBS("Ask"),
 
370
            2 => ToUBS("Metamail"),
 
371
            3 => ToUBS("Run-Mailcap"),
 
372
            4 => ToUBS("Save"),
 
373
            5 => ToUBS("Skip"));
318
374
      Three_Values : constant array (Three_Way_Index) of Integer
319
375
        := (Always => 1,
320
376
            Ask    => 2,
332
388
      Default_Configuration(Default_Config);
333
389
  Edit_Loop:
334
390
      loop
 
391
         Ada.Text_IO.New_Line(5);
 
392
         Ada.Text_IO.Put_Line("** Configuration menu:");
335
393
         Put_Line("Configuration:             Debugging currently "
336
394
                  & ToStr(Two_Way(Config.Debug)));
337
395
         Put_Line("                           Inline separate output currently "
338
396
                  & ToStr(Two_Way(Config.Inline_Separate_Output)));
 
397
         Put_Line("                           MIME viewer is "
 
398
                  & ToStr(MV_Str(Config.MIME_Viewer)));
339
399
         Put_Line("Configuration is not saved beyond this session unless explicitly saved");
340
400
         Selection := Edit_Menu;
341
401
         case Selection is
352
412
               New_Line(3);
353
413
            when GPG_Options => -- GPG options.
354
414
               Options_Loop:
355
 
                 loop
356
 
                    Put_Line("Options submenu (all relevant options are concatenated together):");
357
 
                    Put_Line("  GPG options (all GPG operations): "
358
 
                             & NL & "    " & ToStr(Config.GPG_Options));
359
 
                    Put_Line("  General options (send & receive): "
360
 
                             & NL & "    " & ToStr(Config.General_Options));
361
 
                    Put_Line("  Receiving options (receive only): "
362
 
                             & NL & "    " & ToStr(Config.Receiving_Options));
363
 
                    Put_Line("  Sending options (send only): "
364
 
                             & NL & "    " & ToStr(Config.Sending_Options));
365
 
                    Selection2O := Options_Menu;
366
 
                    case Selection2O is
367
 
                       when Quit =>
368
 
                          New_Line(3);
369
 
                          exit Options_Loop;
370
 
                       when Change_General =>
371
 
                          Readline.Add_History(ToStr(Config.General_Options));
372
 
                          Config.General_Options := ToUBS(Readline.Get_String("General options: "));
373
 
                       when Change_GPG =>
374
 
                          Readline.Add_History(ToStr(Config.GPG_Options));
375
 
                          Config.GPG_Options := ToUBS(Readline.Get_String("GPG options: "));
376
 
                       when Change_Receiving =>
377
 
                          Readline.Add_History(ToStr(Config.Receiving_Options));
378
 
                          Config.Receiving_Options := ToUBS(Readline.Get_String("Receiving options: "));
379
 
                       when Change_Sending =>
380
 
                          Readline.Add_History(ToStr(Config.Sending_Options));
381
 
                          Config.Sending_Options := ToUBS(Readline.Get_String("Sending options: "));
382
 
                       when Default_General =>
383
 
                          Config.General_Options := Default_Config.General_Options;
384
 
                       when Default_GPG =>
385
 
                          Config.GPG_Options := Default_Config.GPG_Options;
386
 
                       when Default_Receiving =>
387
 
                          Config.Receiving_Options := Default_Config.Receiving_Options;
388
 
                       when Default_Sending =>
389
 
                          Config.Sending_Options := Default_Config.Sending_Options;
390
 
                       when Default_All =>
391
 
                          Config.General_Options := Default_Config.General_Options;
392
 
                          Config.GPG_Options := Default_Config.GPG_Options;
393
 
                          Config.Receiving_Options := Default_Config.Receiving_Options;
394
 
                          Config.Sending_Options := Default_Config.Sending_Options;
395
 
                    end case;
396
 
                 end loop Options_Loop;
 
415
               loop
 
416
               Put_Line("Options submenu (all relevant options are concatenated together):");
 
417
               Put_Line("  GPG options (all GPG operations): "
 
418
                        & NL & "    " & ToStr(Config.GPG_Options));
 
419
               Put_Line("  General options (send & receive): "
 
420
                        & NL & "    " & ToStr(Config.General_Options));
 
421
               Put_Line("  Receiving options (receive only): "
 
422
                        & NL & "    " & ToStr(Config.Receiving_Options));
 
423
               Put_Line("  Sending options (send only): "
 
424
                        & NL & "    " & ToStr(Config.Sending_Options));
 
425
               Selection2O := Options_Menu;
 
426
               case Selection2O is
 
427
                  when Quit =>
 
428
                     New_Line(3);
 
429
                     exit Options_Loop;
 
430
                  when Change_General =>
 
431
                     Readline.Add_History(ToStr(Config.General_Options));
 
432
                     Config.General_Options := ToUBS(Readline.Get_String("General options: "));
 
433
                  when Change_GPG =>
 
434
                     Readline.Add_History(ToStr(Config.GPG_Options));
 
435
                     Config.GPG_Options := ToUBS(Readline.Get_String("GPG options: "));
 
436
                  when Change_Receiving =>
 
437
                     Readline.Add_History(ToStr(Config.Receiving_Options));
 
438
                     Config.Receiving_Options := ToUBS(Readline.Get_String("Receiving options: "));
 
439
                  when Change_Sending =>
 
440
                     Readline.Add_History(ToStr(Config.Sending_Options));
 
441
                     Config.Sending_Options := ToUBS(Readline.Get_String("Sending options: "));
 
442
                  when Default_General =>
 
443
                     Config.General_Options := Default_Config.General_Options;
 
444
                  when Default_GPG =>
 
445
                     Config.GPG_Options := Default_Config.GPG_Options;
 
446
                  when Default_Receiving =>
 
447
                     Config.Receiving_Options := Default_Config.Receiving_Options;
 
448
                  when Default_Sending =>
 
449
                     Config.Sending_Options := Default_Config.Sending_Options;
 
450
                  when Default_All =>
 
451
                     Config.General_Options := Default_Config.General_Options;
 
452
                     Config.GPG_Options := Default_Config.GPG_Options;
 
453
                     Config.Receiving_Options := Default_Config.Receiving_Options;
 
454
                     Config.Sending_Options := Default_Config.Sending_Options;
 
455
               end case;
 
456
               end loop Options_Loop;
397
457
            when DV_Settings => -- Decrypt/verify settings.
398
458
               Settings_Loop:
399
 
                 loop
400
 
                    Put_Line("Decrypt/Verify settings submenu:");
401
 
                    Put_Line("  Decrypt/cached:                  " & ToStr(Three_Str(Config.Decrypt_Cached)));
402
 
                    Put_Line("  Decrypt/cached, cache usage:     " & ToStr(Five_Str(Config.Decrypt_Cached_Use_Cache)));
403
 
                    Put_Line("  Decrypt/not cached:              " & ToStr(Three_Str(Config.Decrypt_Not_Cached)));
404
 
                    Put_Line("  Decrypt/not cached, cache usage: " & ToStr(Three_Str(Config.Decrypt_Not_Cached_Use_Cache)));
405
 
                    Put_Line("  Verify/cached:                   " & ToStr(Three_Str(Config.Verify_Cached)));
406
 
                    Put_Line("  Verify/cached, cache usage:      " & ToStr(Five_Str(Config.Verify_Cached_Use_Cache)));
407
 
                    Put_Line("  Verify/not cached:               " & ToStr(Three_Str(Config.Verify_Not_Cached)));
408
 
                    Put_Line("  Verify/not cached, cache usage:  " & ToStr(Three_Str(Config.Verify_Not_Cached_Use_Cache)));
409
 
                    Put_Line("  Decrypt/cached fast continue:    " & ToStr(Two_Way(Config.Decrypt_Cached_Fast_Continue)));
410
 
                    Put_Line("  Verify/cached fast continue:     " & ToStr(Two_Way(Config.Verify_Cached_Fast_Continue)));
411
 
                    Put_Line("  Verify/not cached fast continue: " & ToStr(Two_Way(Config.Verify_Not_Cached_Fast_Continue)));
412
 
                    Selection2S := Settings_Menu;
413
 
                    case Selection2S is
414
 
                       when Decrypt_Cached =>
415
 
                          Config.Decrypt_Cached := Three_Values(Three_Way_Menu);
416
 
                       when Decrypt_Cached_Use =>
417
 
                          Config.Decrypt_Cached_Use_Cache := Five_Values(Five_Way_Menu);
418
 
                       when Decrypt_Not_Cached =>
419
 
                          Config.Decrypt_Not_Cached := Three_Values(Three_Way_Menu);
420
 
                       when Decrypt_Not_Cached_Use =>
421
 
                          Config.Decrypt_Not_Cached_Use_Cache := Three_Values(Three_Way_Menu);
422
 
                       when Verify_Cached =>
423
 
                          Config.Verify_Cached := Three_Values(Three_Way_Menu);
424
 
                       when Verify_Cached_Use =>
425
 
                          Config.Verify_Cached_Use_Cache := Five_Values(Five_Way_Menu);
426
 
                       when Verify_Not_Cached =>
427
 
                          Config.Verify_Not_Cached := Three_Values(Three_Way_Menu);
428
 
                       when Verify_Not_Cached_Use =>
429
 
                          Config.Verify_Not_Cached_Use_Cache := Three_Values(Three_Way_Menu);
430
 
                       when Quit =>
431
 
                          New_Line(3);
432
 
                          exit Settings_Loop;
433
 
                       when All_Defaults =>
434
 
                          Config.Decrypt_Cached := Default_Config.Decrypt_Cached;
435
 
                          Config.Decrypt_Cached_Use_Cache := Default_Config.Decrypt_Cached_Use_Cache;
436
 
                          Config.Decrypt_Not_Cached := Default_Config.Decrypt_Not_Cached;
437
 
                          Config.Decrypt_Not_Cached_Use_Cache := Default_Config.Decrypt_Not_Cached_Use_Cache;
438
 
                          Config.Verify_Cached := Default_Config.Verify_Cached;
439
 
                          Config.Verify_Cached_Use_Cache := Default_Config.Verify_Cached_Use_Cache;
440
 
                          Config.Verify_Not_Cached := Default_Config.Verify_Not_Cached;
441
 
                          Config.Verify_Not_Cached_Use_Cache := Default_Config.Verify_Not_Cached_Use_Cache;
442
 
                       when Toggle_Decrypt_Cached_Fast =>
443
 
                          Config.Decrypt_Cached_Fast_Continue := not Config.Decrypt_Cached_Fast_Continue;
444
 
                       when Toggle_Verify_Cached_Fast =>
445
 
                          Config.Verify_Cached_Fast_Continue := not Config.Verify_Cached_Fast_Continue;
446
 
                       when Toggle_Verify_Not_Cached_Fast =>
447
 
                          Config.Verify_Not_Cached_Fast_Continue := not Config.Verify_Not_Cached_Fast_Continue;
448
 
                    end case;
449
 
                 end loop Settings_Loop;
 
459
               loop
 
460
               Put_Line("Decrypt/Verify settings submenu:");
 
461
               Put_Line("  Decrypt/cached:                  " & ToStr(Three_Str(Config.Decrypt_Cached)));
 
462
               Put_Line("  Decrypt/cached, cache usage:     " & ToStr(Five_Str(Config.Decrypt_Cached_Use_Cache)));
 
463
               Put_Line("  Decrypt/not cached:              " & ToStr(Three_Str(Config.Decrypt_Not_Cached)));
 
464
               Put_Line("  Decrypt/not cached, cache usage: " & ToStr(Three_Str(Config.Decrypt_Not_Cached_Use_Cache)));
 
465
               Put_Line("  Verify/cached:                   " & ToStr(Three_Str(Config.Verify_Cached)));
 
466
               Put_Line("  Verify/cached, cache usage:      " & ToStr(Five_Str(Config.Verify_Cached_Use_Cache)));
 
467
               Put_Line("  Verify/not cached:               " & ToStr(Three_Str(Config.Verify_Not_Cached)));
 
468
               Put_Line("  Verify/not cached, cache usage:  " & ToStr(Three_Str(Config.Verify_Not_Cached_Use_Cache)));
 
469
               Put_Line("  Decrypt/cached fast continue:    " & ToStr(Two_Way(Config.Decrypt_Cached_Fast_Continue)));
 
470
               Put_Line("  Verify/cached fast continue:     " & ToStr(Two_Way(Config.Verify_Cached_Fast_Continue)));
 
471
               Put_Line("  Verify/not cached fast continue: " & ToStr(Two_Way(Config.Verify_Not_Cached_Fast_Continue)));
 
472
               Selection2S := Settings_Menu;
 
473
               case Selection2S is
 
474
                  when Decrypt_Cached =>
 
475
                     Config.Decrypt_Cached := Three_Values(Three_Way_Menu);
 
476
                  when Decrypt_Cached_Use =>
 
477
                     Config.Decrypt_Cached_Use_Cache := Five_Values(Five_Way_Menu);
 
478
                  when Decrypt_Not_Cached =>
 
479
                     Config.Decrypt_Not_Cached := Three_Values(Three_Way_Menu);
 
480
                  when Decrypt_Not_Cached_Use =>
 
481
                     Config.Decrypt_Not_Cached_Use_Cache := Three_Values(Three_Way_Menu);
 
482
                  when Verify_Cached =>
 
483
                     Config.Verify_Cached := Three_Values(Three_Way_Menu);
 
484
                  when Verify_Cached_Use =>
 
485
                     Config.Verify_Cached_Use_Cache := Five_Values(Five_Way_Menu);
 
486
                  when Verify_Not_Cached =>
 
487
                     Config.Verify_Not_Cached := Three_Values(Three_Way_Menu);
 
488
                  when Verify_Not_Cached_Use =>
 
489
                     Config.Verify_Not_Cached_Use_Cache := Three_Values(Three_Way_Menu);
 
490
                  when Quit =>
 
491
                     New_Line(3);
 
492
                     exit Settings_Loop;
 
493
                  when All_Defaults =>
 
494
                     Config.Decrypt_Cached := Default_Config.Decrypt_Cached;
 
495
                     Config.Decrypt_Cached_Use_Cache := Default_Config.Decrypt_Cached_Use_Cache;
 
496
                     Config.Decrypt_Not_Cached := Default_Config.Decrypt_Not_Cached;
 
497
                     Config.Decrypt_Not_Cached_Use_Cache := Default_Config.Decrypt_Not_Cached_Use_Cache;
 
498
                     Config.Verify_Cached := Default_Config.Verify_Cached;
 
499
                     Config.Verify_Cached_Use_Cache := Default_Config.Verify_Cached_Use_Cache;
 
500
                     Config.Verify_Not_Cached := Default_Config.Verify_Not_Cached;
 
501
                     Config.Verify_Not_Cached_Use_Cache := Default_Config.Verify_Not_Cached_Use_Cache;
 
502
                  when Toggle_Decrypt_Cached_Fast =>
 
503
                     Config.Decrypt_Cached_Fast_Continue := not Config.Decrypt_Cached_Fast_Continue;
 
504
                  when Toggle_Verify_Cached_Fast =>
 
505
                     Config.Verify_Cached_Fast_Continue := not Config.Verify_Cached_Fast_Continue;
 
506
                  when Toggle_Verify_Not_Cached_Fast =>
 
507
                     Config.Verify_Not_Cached_Fast_Continue := not Config.Verify_Not_Cached_Fast_Continue;
 
508
               end case;
 
509
               end loop Settings_Loop;
450
510
            when Own_Key => -- Own key.
451
 
               New_Line(2);
452
 
               Put_Line("Signing key is currently: "
453
 
                        & ToStr(Config.My_Key));
454
 
               if YN_Menu = Yes then
455
 
                  -- Now, find all secret keys and offer them as a `select 1' list.
456
 
                  declare
457
 
                     SKL            : Keys.Key_List;
458
 
                     Pattern        : UBS;
459
 
                     New_Secret_Key : UBS;
460
 
                     Use_Old_Key    : Boolean;
461
 
                  begin
462
 
                     Keys.Empty_Keylist(SKL);
463
 
                     Pattern := ToUBS(Readline.Get_String("Type GPG search pattern: "));
464
 
                     Keys.Add_Secret_Keys(Pattern, SKL);
465
 
                     Keys.Select_Key_From_List(SKL, New_Secret_Key, Use_Old_Key);
466
 
                     if not Use_Old_Key then
467
 
                        Config.My_Key := New_Secret_Key;
468
 
                     end if;
469
 
                  end;
470
 
               end if;
 
511
               Edit_Own_Key;
471
512
            when Key_Assoc => -- Key associations.
472
513
               New_Line(3);
473
514
               Put_Line("Currently not implemented.  Use topal -dump, then edit the configuration file.");
486
527
            when Toggle_ISO => -- Toggle inline separate output.
487
528
               New_Line(3);
488
529
               Config.Inline_Separate_Output := not Config.Inline_Separate_Output;
 
530
            when MV_Setting => -- Change MIME viewer setting.
 
531
               New_Line(3);
 
532
               Put_Line("MIME viewer is set to "
 
533
                  & ToStr(MV_Str(Config.MIME_Viewer)));
 
534
               Config.MIME_Viewer := MV_Values(MIME_Viewer_Menu1);
489
535
            when Reset => -- Restore to current saved file.
490
536
               New_Line(3);
491
537
               Copy_Configuration(Config, Default_Config);
504
550
   procedure Default_Configuration (C : in out Config_Record) is
505
551
   begin
506
552
      C.My_Key := ToUBS("");
507
 
      C.Chmod_Binary := ToUBS("/bin/chmod");
508
 
      C.Clear_Binary := ToUBS("/usr/bin/clear");
509
 
      C.Date_Binary := ToUBS("/bin/date");
510
 
      C.Diff_Binary := ToUBS("/usr/bin/diff");
511
 
      C.Dos2Unix_Binary := ToUBS("/usr/bin/dos2unix");
512
 
      C.Formail_Binary := ToUBS("/usr/bin/formail");
513
 
      C.Gpg_Binary := ToUBS("/usr/bin/gpg");
514
 
      C.Grep_Binary := ToUBS("/bin/grep");
515
 
      C.Less_Binary := ToUBS("/usr/bin/less");
516
 
      C.Md5sum_Binary := ToUBS("/usr/bin/md5sum");
517
 
      C.Metamail_Binary := ToUBS("/usr/bin/metamail");
518
 
      C.Mimeconstruct_Binary := ToUBS("/usr/bin/mime-construct");
519
 
      C.Mkdir_Binary := ToUBS("/bin/mkdir");
520
 
      C.Mv_Binary := ToUBS("/bin/mv");
521
 
      C.Rm_Binary := ToUBS("/bin/rm");
522
 
      C.Sed_Binary := ToUBS("/bin/sed");
523
 
      C.Stty_Binary := ToUBS("/bin/stty");
524
 
      C.Tee_Binary := ToUBS("/usr/bin/tee");
525
 
      C.Test_Binary := ToUBS("/usr/bin/test");
 
553
      C.Binary(Chmod) := ToUBS("chmod");
 
554
      C.Binary(Clear) := ToUBS("clear");
 
555
      C.Binary(Date) := ToUBS("date");
 
556
      C.Binary(Diff) := ToUBS("diff");
 
557
      C.Binary(Dos2Unix) := ToUBS("dos2unix");
 
558
      C.Binary(Formail) := ToUBS("formail");
 
559
      C.Binary(File) := ToUBS("file");
 
560
      C.Binary(Gpgop) := ToUBS("gpg");
 
561
      C.Binary(Gpgsm) := ToUBS("gpgsm");
 
562
      C.Binary(Grep) := ToUBS("grep");
 
563
      C.Binary(Iconv) := ToUBS("iconv");
 
564
      C.Binary(Less) := ToUBS("less");
 
565
      C.Binary(Locale) := ToUBS("locale");
 
566
      C.Binary(Md5sum) := ToUBS("md5sum");
 
567
      C.Binary(Metamail) := ToUBS("metamail");
 
568
      C.Binary(Mimeconstruct) := ToUBS("mime-construct");
 
569
      C.Binary(Mimetool) := ToUBS("mime-tool");
 
570
      C.Binary(Mkdir) := ToUBS("mkdir");
 
571
      C.Binary(Mkfifo) := ToUBS("mkfifo");
 
572
      C.Binary(Mv) := ToUBS("mv");
 
573
      C.Binary(openssl) := ToUBS("openssl");
 
574
      C.Binary(Rm) := ToUBS("rm");
 
575
      C.Binary(Runmailcap) := ToUBS("run-mailcap");
 
576
      C.Binary(Scp) := ToUBS("scp");
 
577
      C.Binary(Sed) := ToUBS("sed");
 
578
      C.Binary(Ssh) := ToUBS("ssh");
 
579
      C.Binary(Stty) := ToUBS("stty");
 
580
      C.Binary(Tee) := ToUBS("tee");
 
581
      C.Binary(Test) := ToUBS("test");
526
582
      C.General_Options := ToUBS("");
527
583
      C.Gpg_Options := ToUBS("--no-options");
528
584
      C.Receiving_Options := ToUBS("--keyserver=wwwkeys.uk.pgp.net");
538
594
      C.Decrypt_Cached_Fast_Continue := False;
539
595
      C.Verify_Cached_Fast_Continue := True;
540
596
      C.Verify_Not_Cached_Fast_Continue := False;
 
597
      C.MIME_Viewer := 1;
541
598
      C.Inline_Separate_Output := False;
542
599
      C.FE_Simple := False;
543
600
      C.No_Clean := False;
 
601
      C.All_Headers := False;
 
602
      C.Read_From := False;
 
603
      C.Ask_Charset := False;
544
604
      C.Debug := False;
545
605
      UAP.Create(C.AKE_Key, Initial_KL);
546
606
      UAP.Create(C.AKE_Email, Initial_KL);
547
607
      C.AKE_Count := 0;
548
608
      UAP.Create(C.XK_Key, Initial_KL);
549
609
      C.XK_Count := 0;
 
610
      UAP.Create(C.SAKE_Key, Initial_KL);
 
611
      UAP.Create(C.SAKE_Email, Initial_KL);
 
612
      C.SAKE_Count := 0;
 
613
      UAP.Create(C.SXK_Key, Initial_KL);
 
614
      C.SXK_Count := 0;
550
615
   exception
551
616
      when others =>
552
617
         Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,
558
623
                                Right : in     Config_Record) is
559
624
   begin
560
625
      Left.My_Key := Right.My_Key;
561
 
      Left.Chmod_Binary := Right.Chmod_Binary;
562
 
      Left.Clear_Binary := Right.Clear_Binary;
563
 
      Left.Date_Binary := Right.Date_Binary;
564
 
      Left.Diff_Binary := Right.Diff_Binary;
565
 
      Left.Dos2Unix_Binary := Right.Dos2Unix_Binary;
566
 
      Left.Formail_Binary := Right.Formail_Binary;
567
 
      Left.Gpg_Binary := Right.Gpg_Binary;
568
 
      Left.Grep_Binary := Right.Grep_Binary;
569
 
      Left.Less_Binary := Right.Less_Binary;
570
 
      Left.Md5sum_Binary := Right.Md5sum_Binary;
571
 
      Left.Metamail_Binary := Right.Metamail_Binary;
572
 
      Left.Mimeconstruct_Binary := Right.Mimeconstruct_Binary;
573
 
      Left.Mkdir_Binary := Right.Mkdir_Binary;
574
 
      Left.Mv_Binary := Right.Mv_Binary;
575
 
      Left.Rm_Binary := Right.Rm_Binary;
576
 
      Left.Sed_Binary := Right.Sed_Binary;
577
 
      Left.Stty_Binary := Right.Stty_Binary;
578
 
      Left.Tee_Binary := Right.Tee_Binary;
579
 
      Left.Test_Binary := Right.Test_Binary;
 
626
      for I in Binaries loop
 
627
         Left.Binary(I) := Right.Binary(I);
 
628
      end loop;
580
629
      Left.General_Options := Right.General_Options;
581
630
      Left.Gpg_Options := Right.Gpg_Options;
582
631
      Left.Receiving_Options := Right.Receiving_Options;
592
641
      Left.Decrypt_Cached_Fast_Continue := Right.Decrypt_Cached_Fast_Continue;
593
642
      Left.Verify_Cached_Fast_Continue := Right.Verify_Cached_Fast_Continue;
594
643
      Left.Verify_Not_Cached_Fast_Continue := Right.Verify_Not_Cached_Fast_Continue;
 
644
      Left.MIME_Viewer := Right.MIME_Viewer;
595
645
      Left.Inline_Separate_Output := Right.Inline_Separate_Output;
596
646
      Left.FE_Simple := Right.FE_Simple;
597
647
      Left.No_Clean := Right.No_Clean;
598
648
      Left.Debug := Right.Debug;
 
649
      Left.All_Headers := Right.All_Headers;
 
650
      Left.Read_From := Right.Read_From;
 
651
      Left.Ask_Charset := Right.Ask_Charset;
599
652
      UAP.Copy(Left.AKE_Key, Right.AKE_Key);
600
653
      UAP.Copy(Left.AKE_Email, Right.AKE_Email);
601
654
      Left.AKE_Count := Right.AKE_Count;
602
655
      UAP.Copy(Left.XK_Key, Right.XK_Key);
603
656
      Left.XK_Count := Right.XK_Count;
 
657
      UAP.Copy(Left.SAKE_Key, Right.SAKE_Key);
 
658
      UAP.Copy(Left.SAKE_Email, Right.SAKE_Email);
 
659
      Left.SAKE_Count := Right.SAKE_Count;
 
660
      UAP.Copy(Left.SXK_Key, Right.SXK_Key);
 
661
      Left.SXK_Count := Right.SXK_Count;
604
662
   exception
605
663
      when others =>
606
664
         Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,