indexing
	description: "[
		Information about a network resource.		
		The structure is returned during enumeration of network resources. 
		It is also specified when making or querying a network connection
		with calls to various Windows Networking functions.
	]"
	legal: "See notice at end of class."
	status: "See notice at end of class."
	date: "$Date: 2006-03-22 23:29:03 -0800 (Wed, 22 Mar 2006) $"
	revision: "$Revision: 57641 $"

class interface
	WEL_NET_RESOURCE

create 
	make
		ensure
			scope_set: scope = resource_globalnet
			type_set: type = resource_type_disk
			display_type_set: display_type = resource_display_type_generic
			usage_set: usage = resource_usage_connectable
			local_name_set: local_name = Void
			remote_name_set: remote_name = Void
			comment_set: comment = Void
			provider_set: provider = Void

	make_by_pointer (a_pointer: POINTER)
			-- Set item with `a_pointer'.
			-- Since item is shared, it does not need
			-- to be freed.
			-- Caution: `a_pointer' must be a pointer
			-- coming from Windows.
			-- (from WEL_ANY)
		ensure -- from WEL_ANY
			item_set: item = a_pointer
			shared: shared

feature -- Access

	comment: STRING_32
			-- Comment supplied by the network provider.
			-- It can be Void if there is no supplied comment.

	display_type: INTEGER_32
			-- Value that indicates how the network object should be
			-- displayed in a network browsing user interface.
		ensure
			valid_result: Result = resource_display_type_domain or Result = resource_display_type_server or Result = resource_display_type_share or Result = resource_display_type_generic

	generating_type: STRING_8
			-- Name of current object's generating type
			-- (type of which it is a direct instance)
			-- (from ANY)

	generator: STRING_8
			-- Name of current object's generating class
			-- (base class of the type of which it is a direct instance)
			-- (from ANY)

	item: POINTER
			-- Generic Windows handle or structure pointer.
			-- Can be a HWND, HICON, RECT *, WNDCLASS *, etc...
			-- (from WEL_ANY)

	local_name: STRING_32
			-- If scope is equal to Resource_connected or 
			-- Resource_remembered, it specifies the name of a local
			-- device. It is Void if the connection does not use a device.
		ensure
			valid_result: (Result /= Void) = (scope = resource_connected or scope = resource_remembered)

	provider: STRING_32
			-- Name of the provider that owns the resource.
			-- It can be Void if the provider name is unknown.
			--
			-- To retrieve the provider name, you can call
			-- `WNetGetProviderName'.

	remote_name: STRING_32
			-- If the entry is a network resource, it specifies the remote
			-- network name.
			--
			-- If the entry is a current or persistent connection, it points
			-- to the network name associated with the name pointed to by
			-- local_name.
			--
			-- The string can be MAX_PATH characters in length, and it must
			-- follow the network provider's naming conventions.

	scope: INTEGER_32
			-- Value that contains the scope of the enumeration.
		ensure
			valid_result: Result = resource_connected or Result = resource_globalnet or Result = resource_remembered

	type: INTEGER_32
			-- Value that contains a set of bit flags identifying the 
			-- type of resource.
		ensure
			valid_result: Result = resource_type_any or Result = resource_type_disk or Result = resource_type_print

	usage: INTEGER_32
			-- Value that contains a set of bit flags describing how
			-- the resource can be used.
		ensure
			valid_result: Result = resource_usage_connectable or Result = resource_usage_container
	
feature -- Measurement

	structure_size: INTEGER_32
			-- Size to allocate (in bytes)
		ensure -- from WEL_STRUCTURE
			positive_result: Result > 0
	
feature -- Comparison

	frozen deep_equal (some: ANY; other: like arg #1): BOOLEAN
			-- Are `some' and `other' either both void
			-- or attached to isomorphic object structures?
			-- (from ANY)
		ensure -- from ANY
			shallow_implies_deep: standard_equal (some, other) implies Result
			both_or_none_void: (some = Void) implies (Result = (other = Void))
			same_type: (Result and (some /= Void)) implies some.same_type (other)
			symmetric: Result implies deep_equal (other, some)

	frozen equal (some: ANY; other: like arg #1): BOOLEAN
			-- Are `some' and `other' either both void or attached
			-- to objects considered equal?
			-- (from ANY)
		ensure -- from ANY
			definition: Result = (some = Void and other = Void) or else ((some /= Void and other /= Void) and then some.is_equal (other))

	frozen standard_equal (some: ANY; other: like arg #1): BOOLEAN
			-- Are `some' and `other' either both void or attached to
			-- field-by-field identical objects of the same type?
			-- Always uses default object comparison criterion.
			-- (from ANY)
		ensure -- from ANY
			definition: Result = (some = Void and other = Void) or else ((some /= Void and other /= Void) and then some.standard_is_equal (other))

	frozen standard_is_equal (other: like Current): BOOLEAN
			-- Is `other' attached to an object of the same type
			-- as current object, and field-by-field identical to it?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		ensure -- from ANY
			same_type: Result implies same_type (other)
			symmetric: Result implies other.standard_is_equal (Current)
	
feature -- Status report

	conforms_to (other: ANY): BOOLEAN
			-- Does type of current object conform to type
			-- of `other' (as per Eiffel: The Language, chapter 13)?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void

	exists: BOOLEAN
			-- Does the item exist?
			-- (from WEL_ANY)
		ensure -- from WEL_ANY
			Result = (item /= default_pointer)

	same_type (other: ANY): BOOLEAN
			-- Is type of current object identical to type of `other'?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		ensure -- from ANY
			definition: Result = (conforms_to (other) and other.conforms_to (Current))

	shared: BOOLEAN
			-- Is item shared by another object?
			-- If False (by default), item will
			-- be destroyed by destroy_item.
			-- If True, item will not be destroyed.
			-- (from WEL_ANY)
	
feature -- Status setting

	set_shared
			-- Set shared to True.
			-- (from WEL_ANY)
		ensure -- from WEL_ANY
			shared: shared

	set_unshared
			-- Set shared to False.
			-- (from WEL_ANY)
		ensure -- from WEL_ANY
			unshared: not shared
	
feature -- Element change

	set_comment (a_value: STRING_GENERAL)
			-- Set comment to `a_value'
		ensure
			value_set: equal (comment, a_value)

	set_display_type (a_value: INTEGER_32)
			-- Set display_type to `a_value'
		require
			valid_value: a_value = resource_display_type_domain or a_value = resource_display_type_server or a_value = resource_display_type_share or a_value = resource_display_type_generic
		ensure
			value_set: display_type = a_value

	set_item (an_item: POINTER)
			-- Set item with `an_item'
			-- (from WEL_ANY)
		ensure -- from WEL_ANY
			item_set: item = an_item

	set_local_name (a_value: STRING_GENERAL)
			-- Set local_name to `a_value'
			--
			-- Can only be set if scope is equal to Resource_connected
			-- or Resource_remembered.
		require
			connection_use_device: scope = resource_connected or scope = resource_remembered
		ensure
			value_set: equal (local_name, a_value)

	set_provider (a_value: STRING_GENERAL)
			-- Set provider to `a_value'
		ensure
			value_set: equal (provider, a_value)

	set_remote_name (a_value: STRING_GENERAL)
			-- Set remote_name to `a_value'
			--
			-- The string can be MAX_PATH characters in length, and it must
			-- follow the network provider's naming conventions.
		require
			valid_value: a_value.count <= max_path
		ensure
			value_set: equal (remote_name, a_value)

	set_scope (a_value: INTEGER_32)
			-- Set scope to `a_value'
		require
			valid_value: a_value = resource_connected or a_value = resource_globalnet or a_value = resource_remembered
		ensure
			value_set: scope = a_value

	set_type (a_value: INTEGER_32)
			-- Set type to `a_value'
		require
			valid_value: a_value = resource_type_any or a_value = resource_type_disk or a_value = resource_type_print
		ensure
			value_set: type = a_value

	set_usage (a_value: INTEGER_32)
			-- Set usage to `a_value'
			--
			-- Note that this member can be specified only if scope 
			-- is equal to Resource_globalnet
		require
			global_scope: scope = resource_globalnet
			valid_value: a_value = resource_usage_connectable or a_value = resource_usage_container
		ensure
			value_set: usage = a_value
	
feature -- Removal

	dispose
			-- Destroy the inner structure of `Current'.
			--
			-- This function should be called by the GC when the
			-- object is collected or by the user if `Current' is
			-- no more usefull. 
			-- (from WEL_ANY)
	
feature -- Duplication

	frozen deep_copy (other: like Current)
			-- Effect equivalent to that of:
			--		copy (`other' . deep_twin)
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		ensure -- from ANY
			deep_equal: deep_equal (Current, other)

	frozen deep_twin: like Current
			-- New object structure recursively duplicated from Current.
			-- (from ANY)
		ensure -- from ANY
			deep_equal: deep_equal (Current, Result)

	frozen standard_copy (other: like Current)
			-- Copy every field of `other' onto corresponding field
			-- of current object.
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
			type_identity: same_type (other)
		ensure -- from ANY
			is_standard_equal: standard_is_equal (other)

	frozen standard_twin: like Current
			-- New object field-by-field identical to `other'.
			-- Always uses default copying semantics.
			-- (from ANY)
		ensure -- from ANY
			standard_twin_not_void: Result /= Void
			equal: standard_equal (Result, Current)

	frozen twin: like Current
			-- New object equal to `Current'
			-- twin calls copy; to change copying/twining semantics, redefine copy.
			-- (from ANY)
		ensure -- from ANY
			twin_not_void: Result /= Void
			is_equal: Result.is_equal (Current)
	
feature -- Basic operations

	copy (other: like Current)
			-- Update current object using fields of object attached
			-- to `other', so as to yield equal objects.
			-- (from WEL_STRUCTURE)
		require -- from ANY
			other_not_void: other /= Void
			type_identity: same_type (other)
		ensure -- from ANY
			is_equal: is_equal (other)

	frozen default: like Current
			-- Default value of object's type
			-- (from ANY)

	frozen default_pointer: POINTER
			-- Default value of type `POINTER'
			-- (Avoid the need to write `p'.default for
			-- some `p' of type `POINTER'.)
			-- (from ANY)

	default_rescue
			-- Process exception for routines with no Rescue clause.
			-- (Default: do nothing.)
			-- (from ANY)

	frozen do_nothing
			-- Execute a null action.
			-- (from ANY)

	initialize
			-- Fill Current with zeros.
			-- (from WEL_STRUCTURE)
		require -- from WEL_STRUCTURE
			exists: exists

	initialize_with_character (a_character: CHARACTER_8)
			-- Fill current with `a_character'.
			-- (from WEL_STRUCTURE)
		require -- from WEL_STRUCTURE
			exists: exists

	is_equal (other: like Current): BOOLEAN
			-- Is `other' attached to an object considered
			-- equal to current object?
			-- (from WEL_STRUCTURE)
		require -- from ANY
			other_not_void: other /= Void
		ensure -- from ANY
			symmetric: Result implies other.is_equal (Current)
			consistent: standard_is_equal (other) implies Result

	memory_copy (source_pointer: POINTER; length: INTEGER_32)
			-- Copy `length' bytes from `source_pointer' to item.
			-- (from WEL_STRUCTURE)
		require -- from WEL_STRUCTURE
			length_small_enough: length <= structure_size
			length_large_enough: length > 0
			exists: exists
	
feature -- Connect constants

	connect_interactive: INTEGER_32 is 8
			-- If this flag is set, the operating system may interact with 
			-- the user for authentication purposes.
			--
			-- Declared in Windows as CONNECT_INTERACTIVE
			-- (from WEL_NETWORKING_CONSTANTS)

	connect_localdrive: INTEGER_32 is 256
			-- If this flag is set, the connection was made using a local
			-- device redirection. If the lpAccessName parameter points to a
			-- buffer, the local device name is copied to the buffer.
			--
			-- Declared in Windows as CONNECT_LOCALDRIVE
			-- (from WEL_NETWORKING_CONSTANTS)

	connect_prompt: INTEGER_32 is 16
			-- This flag instructs the system not to use any default settings
			-- for user names or passwords without offering the user the 
			-- opportunity to supply an alternative. This flag is ignored 
			-- unless CONNECT_INTERACTIVE is also set.
			--
			-- Declared in Windows as CONNECT_PROMPT
			-- (from WEL_NETWORKING_CONSTANTS)

	connect_redirect: INTEGER_32 is 128
			-- This flag forces the redirection of a local device when making
			-- the connection.
			--
			-- If the lpLocalName member of NETRESOURCE specifies a local
			-- device to redirect, this flag has no effect, because the
			-- operating system still attempts to redirect the specified 
			-- device. When the operating system automatically chooses a local
			-- device, the lpAccessName parameter must point to a return
			-- buffer and the dwType member must not be equal to 
			-- RESOURCETYPE_ANY.
			--
			-- If this flag is not set, a local device is automatically chosen
			-- for redirection only if the network requires a local device to
			-- be redirected.
			--
			-- Declared in Windows as CONNECT_REDIRECT
			-- (from WEL_NETWORKING_CONSTANTS)

	connect_update_profile: INTEGER_32 is 1
			-- This flag instructs the operating system to store the network
			-- resource connection. 
			--
			-- If this bit flag is set, the operating system automatically
			-- attempts to restore the connection when the user logs on. The
			-- system remembers only successful connections that redirect
			-- local devices. It does not remember connections that are
			-- unsuccessful or deviceless connections. (A deviceless
			-- connection occurs when lpLocalName is NULL or when it points
			-- to an empty string.)
			--
			-- If this bit flag is clear, the operating system does not
			-- automatically restore the connection at logon.
			--
			-- Declared in Windows as CONNECT_UPDATE_PROFILE
			-- (from WEL_NETWORKING_CONSTANTS)
	
feature -- Generic constants

	max_path: INTEGER_32 is 260
			-- Maximum number of characters in full path
			--
			-- Declared in Windows as MAX_PATH
			-- (from WEL_NETWORKING_CONSTANTS)
	
feature -- Net Errors

	error_access_denied: INTEGER_32 is 5
			-- Access to the network resource was denied.
			--
			-- Declared in Windows as ERROR_ACCESS_DENIED
			-- (from WEL_NETWORKING_CONSTANTS)

	error_already_assigned: INTEGER_32 is 85
			-- The local device specified by the lpLocalName member is 
			-- already connected to a network resource.
			--
			-- Declared in Windows as ERROR_ALREADY_ASSIGNED
			-- (from WEL_NETWORKING_CONSTANTS)

	error_bad_device: INTEGER_32 is 1200
			-- The value specified by lpLocalName is invalid.
			--
			-- Declared in Windows as ERROR_BAD_DEVICE
			-- (from WEL_NETWORKING_CONSTANTS)

	error_bad_net_name: INTEGER_32 is 67
			-- The value specified by the lpRemoteName member is not
			-- acceptable to any network resource provider because the
			-- resource name is invalid, or because the named resource
			-- cannot be located.
			--
			-- Declared in Windows as ERROR_BAD_NET_NAME
			-- (from WEL_NETWORKING_CONSTANTS)

	error_bad_provider: INTEGER_32 is 1204
			-- The value specified by the lpProvider member does not match
			-- any provider.
			--
			-- Declared in Windows as ERROR_BAD_PROVIDER
			-- (from WEL_NETWORKING_CONSTANTS)

	error_cancelled: INTEGER_32 is 1223
			-- The attempt to make the connection was canceled by the user
			-- through a dialog box from one of the network resource
			-- providers, or by a called resource.
			--
			-- Declared in Windows as ERROR_CANCELLED
			-- (from WEL_NETWORKING_CONSTANTS)

	error_extended_error: INTEGER_32 is 1208
			-- A network-specific error occurred. To obtain a description of
			-- the error, call the WNetGetLastError function.
			--
			-- Declared in Windows as ERROR_EXTENDED_ERROR
			-- (from WEL_NETWORKING_CONSTANTS)

	error_invalid_address: INTEGER_32 is 487
			-- The caller passed in a pointer to a buffer that could not be
			-- accessed.
			--
			-- Declared in Windows as ERROR_INVALID_ADDRESS
			-- (from WEL_NETWORKING_CONSTANTS)

	error_invalid_parameter: INTEGER_32 is 87
			-- This error is a result of one of the following conditions: 
			-- 1. The lpRemoteName member is NULL. In addition, lpAccessName
			--    is not NULL, but lpBufferSize is either NULL or points to
			--    zero. 
			-- 2. The dwType member is neither RESOURCETYPE_DISK nor
			--    RESOURCETYPE_PRINT. In addition, either CONNECT_REDIRECT
			--    is set in dwFlags and lpLocalName is NULL, or the
			--    connection is to a network that requires the redirecting
			--    of a local device. 
			--
			-- Declared in Windows as ERROR_INVALID_PARAMETER
			-- (from WEL_NETWORKING_CONSTANTS)

	error_invalid_password: INTEGER_32 is 86
			-- The specified password is invalid and the CONNECT_INTERACTIVE
			-- flag is not set.
			--
			-- Declared in Windows as ERROR_INVALID_PASSWORD
			-- (from WEL_NETWORKING_CONSTANTS)

	error_more_data: INTEGER_32 is 234
			-- The lpAccessName buffer is too small. 
			-- If a local device is redirected, the buffer needs to be large
			-- enough to contain the local device name. Otherwise, the
			-- buffer needs to be large enough to contain either the string
			-- pointed to by lpRemoteName, or the name of the connectable
			-- resource whose alias is pointed to by lpRemoteName. If this
			-- error is returned, then no connection has been made.
			--
			-- Declared in Windows as ERROR_MORE_DATA
			-- (from WEL_NETWORKING_CONSTANTS)

	error_no_more_items: INTEGER_32 is 259
			-- The operating system cannot automatically choose a local
			-- redirection because all the valid local devices are in use.
			--
			-- Declared in Windows as ERROR_NO_MORE_ITEMS
			-- (from WEL_NETWORKING_CONSTANTS)

	error_no_net_or_bad_path: INTEGER_32 is 1203
			-- The operation could not be completed, either because a
			-- network component is not started, or because the specified
			-- resource name is not recognized.
			--
			-- Declared in Windows as ERROR_NO_NET_OR_BAD_PATH
			-- (from WEL_NETWORKING_CONSTANTS)

	error_no_network: INTEGER_32 is 1222
			-- The network is unavailable.
			--
			-- Declared in Windows as ERROR_NO_NETWORK
			-- (from WEL_NETWORKING_CONSTANTS)
	
feature -- Net Resource constants

	resource_connected: INTEGER_32 is 1
			-- Enumerate currently connected resources.
			--
			-- Declared in Windows as RESOURCE_CONNECTED
			-- (from WEL_NETWORKING_CONSTANTS)

	resource_display_type_domain: INTEGER_32 is 1
			-- The object should be displayed as a domain.
			--
			-- Declared in Windows as RESOURCEDISPLAYTYPE_DOMAIN
			-- (from WEL_NETWORKING_CONSTANTS)

	resource_display_type_generic: INTEGER_32 is 0
			-- The method used to display the object does not matter.
			--
			-- Declared in Windows as RESOURCEDISPLAYTYPE_GENERIC
			-- (from WEL_NETWORKING_CONSTANTS)

	resource_display_type_server: INTEGER_32 is 2
			-- The object should be displayed as a server.
			--
			-- Declared in Windows as RESOURCEDISPLAYTYPE_SERVER
			-- (from WEL_NETWORKING_CONSTANTS)

	resource_display_type_share: INTEGER_32 is 3
			-- The object should be displayed as a share.
			--
			-- Declared in Windows as RESOURCEDISPLAYTYPE_SHARE
			-- (from WEL_NETWORKING_CONSTANTS)

	resource_globalnet: INTEGER_32 is 2
			-- Enumerate all resources on the network.
			--
			-- Declared in Windows as RESOURCE_GLOBALNET
			-- (from WEL_NETWORKING_CONSTANTS)

	resource_remembered: INTEGER_32 is 3
			-- Enumerate remembered (persistent) connections.
			--
			-- Declared in Windows as RESOURCE_REMEMBERED
			-- (from WEL_NETWORKING_CONSTANTS)

	resource_type_any: INTEGER_32 is 0
			-- All resources
			--
			-- Declared in Windows as RESOURCETYPE_ANY
			-- (from WEL_NETWORKING_CONSTANTS)

	resource_type_disk: INTEGER_32 is 1
			-- Disk resources
			--
			-- Declared in Windows as RESOURCETYPE_DISK
			-- (from WEL_NETWORKING_CONSTANTS)

	resource_type_print: INTEGER_32 is 2
			-- Print resources
			--
			-- Declared in Windows as RESOURCETYPE_PRINT
			-- (from WEL_NETWORKING_CONSTANTS)

	resource_usage_connectable: INTEGER_32 is 1
			-- The resource is a connectable resource
			--
			-- Declared in Windows as RESOURCEUSAGE_CONNECTABLE
			-- (from WEL_NETWORKING_CONSTANTS)

	resource_usage_container: INTEGER_32 is 2
			-- The resource is a container resource
			--
			-- Declared in Windows as RESOURCEUSAGE_CONTAINER
			-- (from WEL_NETWORKING_CONSTANTS)
	
feature -- Output

	io: STD_FILES
			-- Handle to standard file setup
			-- (from ANY)

	out: STRING_8
			-- New string containing terse printable representation
			-- of current object
			-- Was declared in ANY as synonym of tagged_out.
			-- (from ANY)

	print (some: ANY)
			-- Write terse external representation of `some'
			-- on standard output.
			-- (from ANY)

	frozen tagged_out: STRING_8
			-- New string containing terse printable representation
			-- of current object
			-- Was declared in ANY as synonym of out.
			-- (from ANY)
	
feature -- Platform

	operating_environment: OPERATING_ENVIRONMENT
			-- Objects available from the operating system
			-- (from ANY)
	
invariant
		-- from ANY
	reflexive_equality: standard_is_equal (Current)
	reflexive_conformance: conforms_to (Current)

indexing
	copyright: "Copyright (c) 1984-2006, Eiffel Software and others"
	license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
	source: "[
		Eiffel Software
		356 Storke Road, Goleta, CA 93117 USA
		Telephone 805-685-1006, Fax 805-685-6869
		Website http://www.eiffel.com
		Customer support http://support.eiffel.com
	]"

end -- class WEL_NET_RESOURCE