TIdGopher
Implements a Gopher client.
Unit
Description
The TIdGopher is a client implementation of the Internet Gopher protocol (RFC 1436) as described in the Internet Standards document:
- RFC 1436- The Internet Gopher Protocol (http://www.rfc-editor.org/rfc/rfc1436.txt)
TIdGopher also implements partial support for the Gopher+ protocol as described in the document:
- Gopher+, Upward-Compatible Enhancements to the Internet Gopher protocol (http://boombox.micro.umn.edu/pub/gopher/gopher_protocol/Gopher+/Gopher+.txt)
Gopher is a distributed document system developed at the University of Minnesota as an attempt to make locating information resources intuitive for users through a series of structured menus leading to documents or pointers to other protocols such as Telnet and TN3270. While this has been succeeded by the World Wide Web, this is still useful for accessing legacy systems and has a low overhead due to its simplicity and structure.
Port number for the connection to the Gopher server.
Description
Port is an Integer property that identifies the port number used for connecting to a Gopher server.
TIdGopher overrides the definition of the Port property to assign the default value to
IdPORT_GOPHER, as required in the Gopher protocol specification.
constructor Create(AOwner: TComponent); override;
Parameters
AOwner: TComponent
Owner of the object instance.
Description
Create constructs a properly initialized instance of
TIdGopher using the inherited Create constructor, and initializes
Port to the constant value
IdPORT_GOPHER (Decimal
70) as required by the Gopher Protocol.
Gets the Gopher+ extended menu.
function GetExtendedMenu(ASelector: String; AView: String = ''): TIdGopherMenu;
Parameters
ASelector: String
the selector used to retrieve the gopher menu AView - alternative views listed for the item you are retrieving for a Gopher + server.
Return Value
Description
GetExtendedMenu is a
TIdGopherMenu function that gets an extended Gopher+ menu including additional Gopher+ information. GetExtendedMenu will also retrieve the standard Gopher menu if the server does not support Gopher+.
We do not recommend that you use this procedure unless you are sure the server supports Gopher+ because a constant used in the Gopher+ Protocol greeting will conflict with the menu item type constant IdGopherItem_Redundant which could appear in the menu as a first item. To determine if a Gopher Server supports Gopher+, use the TIdGopherMenuItem.GopherPlusItem property from the gopher menu which is referring to the item you want.
The application is responsible for freeing the TIdGopherMenu returned by this function.
Retrieve a Gopher Binary File.
procedure GetFile(ASelector: String; ADestStream: TStream; IsGopherPlus: Boolean = False; AView: String = '');
Parameters
ASelector: String
the selector used to retrieve the file.
ADestStream: TStream
DEstination for the retrieved file.
IsGopherPlus: Boolean = False
Server supports Gopher+. Default value is False.
AView: String = ''
Alternate view listed. Default value is ''.
Description
GetFile is a procedure used to retrieve a binary Gopher File and store its content in ADestStream. ISGopherPlus should be set to True for Gopher+ servers, or False for non-Gopher+ servers where a file name can start with "+". AView is an alternative view listed for the file you are retrieving with Gopher+.
If you are retrieving a text file, use the GetTextFile method because GetFile will include the "." end of text file marker.
Retrieves the Gopher menu.
function GetMenu(ASelector: String; IsGopherPlus: Boolean = False; AView: String = ''): TIdGopherMenu;
Parameters
ASelector: String
the selector for the Gopher item or an empty string to get the root item. IsGopherPlus - Server supports Gopher+. Default value is False.
AView: String = ''
Alternative view listed. Default value is ''.
Return Value
Description
GetMenu is a
TIdGopherMenu function used to retrieve a Gopher Menu. ISGopherPlus should be set to true for Gopher+ servers or false for non-gopher plus servers in case a menu starts with a "+". AView is an alternative view listed for the menu you are retrieving with Gopher+.
The application is responsible for freeing the TIdGopherMenu returned by this function.
Retrieve a Gopher text File.
procedure GetTextFile(ASelector: String; ADestStream: TStream; IsGopherPlus: Boolean = False; AView: String = '');
Parameters
ASelector: String
the selector used to retrieve the file.
ADestStream: TStream
DEstination for the retrieved file.
IsGopherPlus: Boolean = False
Server supports Gopher+. Default value is False.
AView: String = ''
Alternate view listed. Default value is ''.
Description
GetTextFile is a procedure used to retrieve a Gopher Text File and store its content in ADestStream. ISGopherPlus should be set to True for Gopher+ servers, or False for non-Gopher+ servers where a file name can start with "+". AView is an alternative view listed for the file you are retrieving with Gopher+.
If you are retrieving a text file, use the GetFile method because GetTextFile will stop reading if it encounters the "." end of text file marker.
Perform a Gopher search using a query.
function Search(ASelector: String; AQuery: String): TIdGopherMenu;
Parameters
ASelector: String
the selector for the gopher item AQuery - the Gopher query string.
Return Value
Description
Search is a
TIdGopherMenu function used to perform a Gopher search with the query specified by AQuery, and returns a Gopher Menu resulting from the search. Gopher+ syntax is not supported in AQuery.
The application is responsible for freeing the TIdGopherMenu returned by this function.
Event handler for retrieved Gopher menu items.
Parameters
MenuItem
The menu item retrieved from the server.
Sender
Gopher menu that own the menu item.
Description
OnMenuItem is a
TIdGopherMenuEvent event handler that is triggered for each menu item retrieved with the
GetMenu,
Search, and
GetExtendedMenu methods. OnMenuItem is used to display gopher menu items while the complete menu is downloaded.
An application must assign a procedure to the event handler in order to respond to the event notification.