IdDsnRegister.pas 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. {
  2. $Project$
  3. $Workfile$
  4. $Revision$
  5. $DateUTC$
  6. $Id$
  7. This file is part of the Indy (Internet Direct) project, and is offered
  8. under the dual-licensing agreement described on the Indy website.
  9. (http://www.indyproject.org/)
  10. Copyright:
  11. (c) 1993-2005, Chad Z. Hower and the Indy Pit Crew. All rights reserved.
  12. }
  13. {
  14. $Log$
  15. }
  16. {
  17. Rev 1.7 9/5/2004 3:16:58 PM JPMugaas
  18. Should work in D9 DotNET.
  19. Rev 1.6 3/8/2004 10:14:54 AM JPMugaas
  20. Property editor for SASL mechanisms now supports TIdDICT.
  21. Rev 1.5 2/26/2004 8:53:14 AM JPMugaas
  22. Hack to restore the property editor for SASL mechanisms.
  23. Rev 1.4 1/25/2004 4:28:42 PM JPMugaas
  24. Removed a discontinued Unit.
  25. Rev 1.3 1/25/2004 3:11:06 PM JPMugaas
  26. SASL Interface reworked to make it easier for developers to use.
  27. SSL and SASL reenabled components.
  28. Rev 1.2 10/12/2003 1:49:28 PM BGooijen
  29. Changed comment of last checkin
  30. Rev 1.1 10/12/2003 1:43:28 PM BGooijen
  31. Changed IdCompilerDefines.inc to Core\IdCompilerDefines.inc
  32. Rev 1.0 11/14/2002 02:18:56 PM JPMugaas
  33. }
  34. unit IdDsnRegister;
  35. interface
  36. {$I IdCompilerDefines.inc}
  37. uses
  38. Classes,
  39. {$IFDEF DOTNET}
  40. Borland.Vcl.Design.DesignIntF,
  41. Borland.Vcl.Design.DesignEditors
  42. {$ELSE}
  43. {$IFDEF FPC}
  44. PropEdits,
  45. ComponentEditors
  46. {$ELSE}
  47. {$IFDEF VCL_6_OR_ABOVE}
  48. DesignIntf,
  49. DesignEditors
  50. {$ELSE}
  51. Dsgnintf
  52. {$ENDIF}
  53. {$ENDIF}
  54. {$ENDIF}
  55. ;
  56. // Procs
  57. type
  58. TIdPropEdSASL = class(TClassProperty)
  59. public
  60. procedure Edit; override;
  61. function GetAttributes: TPropertyAttributes; override;
  62. function GetValue: string; override;
  63. procedure SetValue(const Value: string); override;
  64. end;
  65. {$IFDEF HAS_TSelectionEditor}
  66. {$IFDEF USE_OPENSSL}
  67. TIdOpenSSLSelectionEditor = class(TSelectionEditor)
  68. public
  69. procedure RequiresUnits(Proc: TGetStrProc); override;
  70. end;
  71. {$ENDIF}
  72. TIdFTPServerSelectionEditor = class(TSelectionEditor)
  73. public
  74. procedure RequiresUnits(Proc: TGetStrProc); override;
  75. end;
  76. {$ENDIF}
  77. procedure Register;
  78. implementation
  79. uses
  80. {$IFDEF WIDGET_WINFORMS}
  81. IdDsnSASLListEditorFormNET,
  82. {$R 'IdDsnSASLListEditorFormNET.TfrmSASLListEditor.resources' 'IdDsnSASLListEditorFormNET.resx'}
  83. {$ENDIF}
  84. {$IFDEF WIDGET_VCL_LIKE_OR_KYLIX}
  85. IdDsnSASLListEditorFormVCL,
  86. {$ENDIF}
  87. {$IFDEF HAS_TSelectionEditor}
  88. {$IFDEF USE_OPENSSL}
  89. IdSSLOpenSSL,
  90. {$ENDIF}
  91. IdFTPServer,
  92. {$ENDIF}
  93. IdSASL, IdSASLCollection,
  94. SysUtils, TypInfo;
  95. {Since we are removing New Design-Time part, we remove the "New Message Part Editor"}
  96. {IdDsnNewMessagePart, }
  97. type
  98. {$IFDEF WIDGET_WINFORMS}
  99. //we make a create here because I'm not sure how the Visual Designer for WinForms
  100. //we behave in a package. I know it can act weird if something is renamed
  101. TfrmSASLListEditor = class(IdDsnSASLListEditorFormNET.TfrmSASLListEditor)
  102. public
  103. constructor Create(AOwner : TComponent);
  104. end;
  105. {$ENDIF}
  106. {$IFDEF WIDGET_VCL_LIKE_OR_KYLIX}
  107. TfrmSASLListEditor = class(TfrmSASLListEditorVCL);
  108. {$ENDIF}
  109. { TfrmSASLListEditor }
  110. {$IFDEF WIDGET_WINFORMS}
  111. constructor TfrmSASLListEditor.Create(AOwner : TComponent);
  112. begin
  113. inherited Create;
  114. end;
  115. {$ENDIF}
  116. {$IFDEF HAS_TSelectionEditor}
  117. {$IFDEF USE_OPENSSL}
  118. {TIdOpenSSLSelectionEditor}
  119. procedure TIdOpenSSLSelectionEditor.RequiresUnits(Proc: TGetStrProc);
  120. begin
  121. inherited RequiresUnits(Proc);
  122. //for new callback event
  123. Proc('IdCTypes');
  124. Proc('IdSSLOpenSSLHeaders');
  125. end;
  126. {$ENDIF}
  127. {TIdFTPServerSelectionEditor}
  128. procedure TIdFTPServerSelectionEditor.RequiresUnits(Proc: TGetStrProc);
  129. begin
  130. inherited RequiresUnits(Proc);
  131. Proc('IdFTPListOutput');
  132. Proc('IdFTPList');
  133. end;
  134. {$ENDIF}
  135. { TIdPropEdSASL }
  136. procedure TIdPropEdSASL.Edit;
  137. var
  138. LF: TfrmSASLListEditor;
  139. LComp: TPersistent;
  140. LList: TIdSASLEntries;
  141. begin
  142. inherited Edit;
  143. LComp := GetComponent(0);
  144. //done this way to prevent invalid typecast error.
  145. {$IFDEF HAS_GetObjectProp}
  146. LList := TIdSASLEntries(GetObjectProp(LComp, GetPropInfo, TIdSASLEntries));
  147. {$ELSE}
  148. LList := TObject(GetOrdProp(LComp, GetPropInfo)) as TIdSASLEntries;
  149. {$ENDIF}
  150. LF := TfrmSASLListEditor.Create(nil);
  151. try
  152. if LComp is TComponent then begin
  153. LF.SetComponentName(TComponent(LComp).Name);
  154. end;
  155. LF.SetList(LList);
  156. if LF.Execute then begin
  157. LF.GetList(LList);
  158. end;
  159. finally
  160. FreeAndNil(LF);
  161. end;
  162. end;
  163. function TIdPropEdSASL.GetAttributes: TPropertyAttributes;
  164. begin
  165. Result := inherited GetAttributes + [paDialog];
  166. end;
  167. function TIdPropEdSASL.GetValue: string;
  168. begin
  169. Result := GetStrValue;
  170. end;
  171. procedure TIdPropEdSASL.SetValue(const Value: string);
  172. begin
  173. inherited SetValue(Value);
  174. end;
  175. procedure Register;
  176. begin
  177. RegisterPropertyEditor(TypeInfo(TIdSASLEntries), nil, '', TIdPropEdSASL);
  178. {$IFDEF HAS_TSelectionEditor}
  179. {$IFDEF USE_OPENSSL}
  180. RegisterSelectionEditor(TIdServerIOHandlerSSLOpenSSL, TIdOpenSSLSelectionEditor);
  181. RegisterSelectionEditor(TIdSSLIOHandlerSocketOpenSSL, TIdOpenSSLSelectionEditor);
  182. {$ENDIF}
  183. RegisterSelectionEditor(TIdFTPServer,TIdFTPServerSelectionEditor);
  184. {$ENDIF}
  185. end;
  186. end.