- Timestamp:
- Jul 15, 2016, 2:24:18 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormImportSource.lfm
r35 r46 1 1 object FormImportSource: TFormImportSource 2 2 Left = 492 3 Height = 4 033 Height = 444 4 4 Top = 313 5 5 Width = 604 6 6 Caption = 'Import source' 7 ClientHeight = 4 037 ClientHeight = 444 8 8 ClientWidth = 604 9 9 OnShow = FormShow … … 44 44 Left = 515 45 45 Height = 25 46 Top = 36546 Top = 406 47 47 Width = 75 48 48 Anchors = [akRight, akBottom] … … 54 54 Left = 413 55 55 Height = 25 56 Top = 36556 Top = 406 57 57 Width = 75 58 58 Anchors = [akRight, akBottom] … … 136 136 Left = 10 137 137 Height = 2 138 Top = 3 52138 Top = 393 139 139 Width = 580 140 140 Anchors = [akLeft, akBottom] 141 end 142 object Label5: TLabel 143 Left = 10 144 Height = 20 145 Top = 352 146 Width = 73 147 Caption = 'User name:' 148 ParentColor = False 149 end 150 object Label6: TLabel 151 Left = 305 152 Height = 20 153 Top = 351 154 Width = 65 155 Caption = 'Password:' 156 ParentColor = False 157 end 158 object EditUserName: TEdit 159 Left = 136 160 Height = 28 161 Top = 351 162 Width = 153 163 TabOrder = 10 164 end 165 object EditPassword: TEdit 166 Left = 436 167 Height = 28 168 Top = 351 169 Width = 153 170 EchoMode = emPassword 171 PasswordChar = '*' 172 TabOrder = 11 141 173 end 142 174 object ActionList1: TActionList -
trunk/Forms/UFormImportSource.lrt
r33 r46 8 8 TFORMIMPORTSOURCE.CHECKBOXENABLED.CAPTION=Enabled 9 9 TFORMIMPORTSOURCE.LABEL4.CAPTION=Categories: 10 TFORMIMPORTSOURCE.LABEL5.CAPTION=User name: 11 TFORMIMPORTSOURCE.LABEL6.CAPTION=Password: 10 12 TFORMIMPORTSOURCE.ACATEGORYREMOVE.CAPTION=Remove 11 13 TFORMIMPORTSOURCE.ACATEGORYADD.CAPTION=Add -
trunk/Forms/UFormImportSource.pas
r33 r46 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 ActnList, Menus, ExtCtrls, UAcronym;9 ActnList, Menus, ExtCtrls, MaskEdit, UAcronym; 10 10 11 11 type … … 25 25 CheckBoxEnabled: TCheckBox; 26 26 ComboBox1: TComboBox; 27 EditUserName: TEdit; 27 28 EditName: TEdit; 28 29 EditURL: TEdit; 30 EditPassword: TEdit; 29 31 Label1: TLabel; 30 32 Label2: TLabel; 31 33 Label3: TLabel; 32 34 Label4: TLabel; 35 Label5: TLabel; 36 Label6: TLabel; 33 37 ListBox1: TListBox; 34 38 MenuItem1: TMenuItem; … … 132 136 CheckBoxEnabled.Checked := ImportSource.Enabled; 133 137 ImportSource.Categories.AssignToStrings(ListBox1.Items); 138 EditUserName.Text := ImportSource.UserName; 139 EditPassword.Text := ImportSource.Password; 134 140 end; 135 141 … … 141 147 ImportSource.Enabled := CheckBoxEnabled.Checked; 142 148 ImportSource.Categories.AssignFromStrings(ListBox1.Items); 149 ImportSource.UserName := EditUserName.Text; 150 ImportSource.Password := EditPassword.Text; 143 151 end; 144 152 -
trunk/Languages/AcronymDecoder.cs.po
r45 r46 379 379 msgstr "Kategorie:" 380 380 381 #: tformimportsource.label5.caption 382 msgid "User name:" 383 msgstr "Jméno:" 384 385 #: tformimportsource.label6.caption 386 msgid "Password:" 387 msgstr "Heslo:" 388 381 389 #: tformimportsources.aadd.caption 382 390 msgctxt "tformimportsources.aadd.caption" … … 604 612 msgstr "Přeskočit" 605 613 614 #: uacronym.sunsupportedimportformat 615 msgid "Unsupported import format" 616 msgstr "Nepodporovaný formát importu" 617 606 618 #: uacronym.swrongfileformat 607 619 msgid "Wrong file format" -
trunk/Languages/AcronymDecoder.po
r45 r46 369 369 msgstr "" 370 370 371 #: tformimportsource.label5.caption 372 msgid "User name:" 373 msgstr "" 374 375 #: tformimportsource.label6.caption 376 msgid "Password:" 377 msgstr "" 378 371 379 #: tformimportsources.aadd.caption 372 380 msgctxt "TFORMIMPORTSOURCES.AADD.CAPTION" … … 594 602 msgstr "" 595 603 604 #: uacronym.sunsupportedimportformat 605 msgid "Unsupported import format" 606 msgstr "" 607 596 608 #: uacronym.swrongfileformat 597 609 msgid "Wrong file format" -
trunk/UAcronym.pas
r45 r46 170 170 TImportSource = class 171 171 private 172 ResponseStream: TMemoryStream; 172 173 procedure DoPassword(Sender: TObject; var RepeatRequest : Boolean); 173 174 public … … 180 181 ItemCount: Integer; 181 182 Categories: TAcronymCategories; 183 UserName: string; 184 Password: string; 182 185 function DownloadHTTP(URL: string; Stream: TStream): Boolean; 183 186 procedure Process; … … 235 238 resourcestring 236 239 SWrongFileFormat = 'Wrong file format'; 240 SUnsupportedImportFormat = 'Unsupported import format'; 237 241 SDescription = 'Description'; 238 242 SMeaning = 'Meaning'; … … 366 370 367 371 procedure TImportSource.DoPassword(Sender: TObject; var RepeatRequest: Boolean); 368 begin 369 if TFPHttpClient(Sender).Password = '' then begin 370 TFPHttpClient(Sender).UserName := 'test'; 371 TFPHttpClient(Sender).Password := 'test'; 372 RepeatRequest := True; 373 end else RepeatRequest := False; 374 end; 372 var 373 H: string; 374 P: Integer; 375 begin 376 with TFPHttpClient(Sender) do begin 377 H := GetHeader(ResponseHeaders, 'WWW-Authenticate'); 378 if Pos(' ', H) > 0 then H := Copy(H, 1, Pos(' ', H) - 1); 379 380 if H <> 'Basic' then 381 raise Exception.Create('Unsupported HTTP authorization method'); 382 383 if (Self.UserName <> '') and (UserName = '') then begin 384 UserName := Self.UserName; 385 Password := Self.Password; 386 ResponseStream.Clear; 387 RepeatRequest := True; 388 end else RepeatRequest := False; 389 end; 390 end; 391 375 392 376 393 function TImportSource.DownloadHTTP(URL: string; Stream: TStream): Boolean; … … 379 396 FormData: TStringList; 380 397 begin 398 Result := False; 381 399 HTTPClient := TFPHttpClient.Create(nil); 400 HTTPClient.AllowRedirect := True; 382 401 HTTPClient.OnPassword := DoPassword; 383 402 FormData := TStringList.Create; 384 (* 385 FormData.action=clientlogin 386 &loginreturnurl=http://example.com/& 387 logintoken=29590a3037d325be70b93fb8258ed29257448cfb%2B%5C& 388 username=Bob& 389 password=secret& 390 rememberMe=1 391 HTTPClient.FormPost(URL, FormData, Stream); 392 *) 393 HTTPClient.Get(URL, Stream); 394 FormData.Free; 395 HTTPClient.Free; 396 Result := True; 403 try 404 HTTPClient.Get(URL, Stream); 405 Result := True; 406 finally 407 FormData.Free; 408 HTTPClient.Free; 409 end; 397 410 end; 398 411 … … 402 415 ifkParse: ProcessTextParse; 403 416 ifkMSAccess: ProcessMSAccess; 404 else raise Exception.Create( 'Unsupported import format');417 else raise Exception.Create(SUnsupportedImportFormat); 405 418 end; 406 419 end; … … 603 616 procedure TImportSource.ProcessTextParse; 604 617 var 605 Stream: TMemoryStream;606 618 S: string; 607 619 SS: string; … … 616 628 begin 617 629 ItemCount := 0; 618 Stream := TMemoryStream.Create;619 630 NewAcronym := TAcronymEntry.Create; 620 631 try 621 if DownloadHTTP(URL, Stream) then begin622 Stream.Position := 0;623 SetLength(S, Stream.Size);624 Stream.Read(S[1], Length(S));632 if DownloadHTTP(URL, ResponseStream) then begin 633 ResponseStream.Position := 0; 634 SetLength(S, ResponseStream.Size); 635 ResponseStream.Read(S[1], Length(S)); 625 636 626 637 // Find main block … … 705 716 finally 706 717 NewAcronym.Free; 707 Stream.Free;708 718 end; 709 719 end; … … 718 728 ItemCount := Source.ItemCount; 719 729 Categories.Assign(Source.Categories); 730 UserName := Source.UserName; 731 Password := Source.Password; 720 732 end; 721 733 … … 730 742 WriteBoolean(Node, 'Enabled', Enabled); 731 743 WriteInteger(Node, 'ItemCount', ItemCount); 744 WriteString(Node, 'UserName', UserName); 732 745 733 746 NewNode := Node.OwnerDocument.CreateElement('Categories'); … … 745 758 Enabled := ReadBoolean(Node, 'Enabled', True); 746 759 ItemCount := ReadInteger(Node, 'ItemCount', 0); 760 UserName := ReadString(Node, 'UserName', ''); 747 761 748 762 Categories.Db := Sources.AcronymDb; … … 758 772 Categories := TAcronymCategories.Create; 759 773 Categories.OwnsObjects := False; 774 ResponseStream := TMemoryStream.Create; 760 775 end; 761 776 762 777 destructor TImportSource.Destroy; 763 778 begin 779 FreeAndNil(ResponseStream); 764 780 FreeAndNil(Categories); 765 781 inherited Destroy;
Note:
See TracChangeset
for help on using the changeset viewer.