IdCoreDsnRegister.pas 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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.4 12/10/2004 15:36:40 HHariri
  18. Fix so it works with D8 too
  19. Rev 1.3 9/5/2004 2:08:14 PM JPMugaas
  20. Should work in D9 NET.
  21. Rev 1.2 2/3/2004 11:42:52 AM JPMugaas
  22. Fixed for new design.
  23. Rev 1.1 2/1/2004 2:44:20 AM JPMugaas
  24. Bindings editor should be fully functional including IPv6 support.
  25. Rev 1.0 11/13/2002 08:41:18 AM JPMugaas
  26. }
  27. unit IdCoreDsnRegister;
  28. interface
  29. {$I IdCompilerDefines.inc}
  30. uses
  31. {$IFDEF FPC}
  32. PropEdits,
  33. ComponentEditors
  34. {$ELSE}
  35. DesignIntf,
  36. DesignEditors
  37. {$ENDIF}
  38. ;
  39. type
  40. TIdBaseComponentEditor = class({$IFDEF FPC}TDefaultComponentEditor{$ELSE}TDefaultEditor{$ENDIF})
  41. public
  42. procedure ExecuteVerb(Index: Integer); override;
  43. function GetVerb(Index: Integer): string; override;
  44. function GetVerbCount: Integer; override;
  45. end;
  46. TIdPropEdBinding = class({$IFDEF FPC}TPropertyEditor{$ELSE}TClassProperty{$ENDIF})
  47. {$IFDEF FPC}
  48. protected
  49. FValue : String;
  50. property Value : String read FValue write FValue;
  51. {$ENDIF}
  52. public
  53. procedure Edit; override;
  54. function GetAttributes: TPropertyAttributes; override;
  55. function GetValue: string; override;
  56. procedure SetValue(const Value: string); override;
  57. end;
  58. // Procs
  59. procedure Register;
  60. implementation
  61. uses
  62. Classes,
  63. IdDsnPropEdBindingVCL,
  64. IdAboutVCL,
  65. {$IFDEF DCC}
  66. ToolsAPI,
  67. SysUtils,
  68. {$IFEND}
  69. IdDsnCoreResourceStrings,
  70. IdBaseComponent,
  71. IdComponent,
  72. IdGlobal,
  73. IdStack,
  74. IdSocketHandle;
  75. type
  76. TIdPropEdBindingEntry = TIdDsnPropEdBindingVCL;
  77. procedure TIdPropEdBinding.Edit;
  78. var
  79. pSockets: TIdSocketHandles;
  80. pEntry: TIdPropEdBindingEntry;
  81. begin
  82. inherited Edit;
  83. pSockets := TIdSocketHandles({$IFDEF CPU64}GetInt64Value{$ELSE}GetOrdValue{$ENDIF});
  84. pEntry := TIdPropEdBindingEntry.Create;
  85. try
  86. pEntry.Caption := TComponent(GetComponent(0)).Name;
  87. pEntry.DefaultPort := pSockets.DefaultPort;
  88. Value := GetListValues(pSockets);
  89. pEntry.SetList(Value);
  90. if pEntry.Execute then
  91. begin
  92. Value := pEntry.GetList;
  93. FillHandleList(Value, pSockets);
  94. end;
  95. finally
  96. pEntry.Free;
  97. end;
  98. end;
  99. function TIdPropEdBinding.GetAttributes: TPropertyAttributes;
  100. begin
  101. Result := inherited GetAttributes + [paDialog];
  102. end;
  103. function TIdPropEdBinding.GetValue: string;
  104. var
  105. pSockets: TIdSocketHandles;
  106. begin
  107. pSockets := TIdSocketHandles({$IFDEF CPU64}GetInt64Value{$ELSE}GetOrdValue{$ENDIF});
  108. Result := GetListValues(pSockets);
  109. end;
  110. procedure TIdPropEdBinding.SetValue(const Value: string);
  111. var
  112. pSockets: TIdSocketHandles;
  113. begin
  114. inherited SetValue(Value);
  115. pSockets := TIdSocketHandles({$IFDEF CPU64}GetInt64Value{$ELSE}GetOrdValue{$ENDIF});
  116. pSockets.BeginUpdate;
  117. try
  118. FillHandleList(Value, pSockets);
  119. finally
  120. pSockets.EndUpdate;
  121. end;
  122. end;
  123. { TIdBaseComponentEditor }
  124. procedure TIdBaseComponentEditor.ExecuteVerb(Index: Integer);
  125. begin
  126. case Index of
  127. 0 : TfrmAbout.ShowDlg;
  128. end;
  129. end;
  130. function TIdBaseComponentEditor.GetVerb(Index: Integer): string;
  131. begin
  132. case Index of
  133. 0: Result := IndyFormat(RSAAboutMenuItemName, [gsIdVersion]);
  134. end;
  135. end;
  136. function TIdBaseComponentEditor.GetVerbCount: Integer;
  137. begin
  138. Result := 1;
  139. end;
  140. procedure Register;
  141. begin
  142. RegisterPropertyEditor(TypeInfo(TIdSocketHandles), nil, '', TIdPropEdBinding); {Do not Localize}
  143. RegisterComponentEditor(TIdBaseComponent, TIdBaseComponentEditor);
  144. end;
  145. {$IFDEF DCC}
  146. var
  147. AboutBoxServices: IOTAAboutBoxServices = nil;
  148. AboutBoxIndex: Integer = -1;
  149. procedure RegisterAboutBox;
  150. begin
  151. if Supports(BorlandIDEServices, IOTAAboutBoxServices, AboutBoxServices) then
  152. begin
  153. AboutBoxIndex := AboutBoxServices.AddPluginInfo(
  154. RSAAboutBoxCompName + ' ' + gsIdVersion,
  155. RSAAboutBoxDescription + sLineBreak + sLineBreak
  156. + RSAAboutBoxCopyright + sLineBreak + sLineBreak
  157. + RSAAboutBoxPleaseVisit + sLineBreak + RSAAboutBoxIndyWebsite,
  158. 0,
  159. False,
  160. RSAAboutBoxLicences,
  161. '');
  162. end;
  163. end;
  164. procedure UnregisterAboutBox;
  165. begin
  166. if (AboutBoxIndex <> -1) and (AboutBoxServices <> nil) then
  167. begin
  168. AboutBoxServices.RemovePluginInfo(AboutBoxIndex);
  169. end;
  170. end;
  171. initialization
  172. RegisterAboutBox;
  173. finalization
  174. UnregisterAboutBox;
  175. {$ENDIF}
  176. end.