![]() |
![]() |
![]() |
libinfinity-0.4 Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Prerequisites | Known Implementations | Signals |
#include <libinfinity/common/inf-discovery.h> InfDiscovery; InfDiscoveryIface; InfDiscoveryInfo; void (*InfDiscoveryResolvCompleteFunc) (InfDiscoveryInfo *info
,InfXmlConnection *connection
,gpointer user_data
); void (*InfDiscoveryResolvErrorFunc) (InfDiscoveryInfo *info
,const GError *error
,gpointer user_data
); void inf_discovery_discover (InfDiscovery *discovery
,const gchar *type
); GSList * inf_discovery_get_discovered (InfDiscovery *discovery
,const gchar *type
); void inf_discovery_resolve (InfDiscovery *discovery
,InfDiscoveryInfo *info
,InfDiscoveryResolvCompleteFunc complete_func
,InfDiscoveryResolvErrorFunc error_func
,gpointer user_data
); gchar * inf_discovery_info_get_service_name (InfDiscovery *discovery
,InfDiscoveryInfo *info
); const gchar * inf_discovery_info_get_service_type (InfDiscovery *discovery
,InfDiscoveryInfo *info
); void inf_discovery_discovered (InfDiscovery *discovery
,InfDiscoveryInfo *info
); void inf_discovery_undiscovered (InfDiscovery *discovery
,InfDiscoveryInfo *info
);
InfDiscovery provides a common interface for the discovery of services. Discovered services are represented by InfDiscoveryInfo objects and can be used to query the name of the discovered service.
To create a connection to the host providing a discovered service, use
inf_discovery_resolve()
.
typedef struct _InfDiscovery InfDiscovery;
InfDiscovery is an opaque data type. You should only access it via the public API functions.
typedef struct { void (*discover)(InfDiscovery* discovery, const gchar* type); GSList* (*get_discovered)(InfDiscovery* discovery, const gchar* type); void (*resolve)(InfDiscovery* discovery, InfDiscoveryInfo* info, InfDiscoveryResolvCompleteFunc complete_func, InfDiscoveryResolvErrorFunc error_func, gpointer user_data); gchar*(*info_get_service_name)(InfDiscovery* discovery, InfDiscoveryInfo* info); const gchar*(*info_get_service_type)(InfDiscovery* discovery, InfDiscoveryInfo* info); /* Signals */ void (*discovered)(InfDiscovery* discovery, InfDiscoveryInfo* info); void (*undiscovered)(InfDiscovery* discovery, InfDiscoveryInfo* info); } InfDiscoveryIface;
The virtual methods and default signal handlers of InfDiscovery. Implementing these allows discovering infinote servers.
Virtual function to start discovery of services of the given type. If the discovery was already started ealier, then this function does nothing. | |
Virtual function to retrieve a list of
InfDiscoveryInfos that represent discovered services.
It needs to be freed by the caller via g_slist_free() .
|
|
Virtual function that attempts to resolve the given discovery
info. It guarantees to either call complete_func or error_func when the
process has finished.
|
|
Returns the service name of the given
InfDiscoveryInfo as a new string, to be freed by the caller with g_free() .
|
|
Returns the type of the discovered service of the given InfDiscoveryInfo as a static string. | |
Default signal handler for the "discovered" signal. | |
Default signal handler for the "undiscovered" signal. |
typedef struct _InfDiscoveryInfo InfDiscoveryInfo;
InfDiscoveryInfo is an opaque data type. You should only access it via the public API functions.
void (*InfDiscoveryResolvCompleteFunc) (InfDiscoveryInfo *info
,InfXmlConnection *connection
,gpointer user_data
);
This callback is called when a call to inf_discovery_resolve()
finished
successfully.
|
The resolved InfDiscoveryInfo. |
|
The resulting InfXmlConnection. |
|
The user_data passed to inf_discovery_resolve() .
|
void (*InfDiscoveryResolvErrorFunc) (InfDiscoveryInfo *info
,const GError *error
,gpointer user_data
);
This callback is called when a call to inf_discovery_resolve()
failed.
|
The resolved InfDiscoveryInfo. |
|
Reason for the failure. |
|
The user_data passed to inf_discovery_resolve() .
|
void inf_discovery_discover (InfDiscovery *discovery
,const gchar *type
);
Starts the discovery of the given service type. Whenever a service of this type is discovered, the "discovered" signal is emitted. If the service disappears, the "undiscovered" signal is emitted. This can be called more than once for the same type, but only the first call has an effect.
Note also that implementations of InfDiscovery might restrict the service types that can be discovered.
|
A InfDiscovery. |
|
The service type to discover. |
GSList * inf_discovery_get_discovered (InfDiscovery *discovery
,const gchar *type
);
Returns a list of discovered InfDiscoveryInfo for the given type.
|
A InfDiscovery. |
|
The service type of which to get discovered infos for. |
Returns : |
A newly allocated list that needs to be freed with
g_slist_free() .
|
void inf_discovery_resolve (InfDiscovery *discovery
,InfDiscoveryInfo *info
,InfDiscoveryResolvCompleteFunc complete_func
,InfDiscoveryResolvErrorFunc error_func
,gpointer user_data
);
Attempts to resolve info
. Resolving a InfDiscoveryInfo means creating
a InfXmlConnection to the publisher. The connection might not be
open when complete_func
runs. This will call either complete_func
or error_func
, but not both.
|
A InfDiscovery. |
|
A InfDiscoveryInfo discovered by discovery .
|
|
A callback that will be called when the resolving process has completed. |
|
A callback that will be called when an error has occured. |
|
Extra data to pass to complete_func and error_func .
|
gchar * inf_discovery_info_get_service_name (InfDiscovery *discovery
,InfDiscoveryInfo *info
);
Returns the service name of the discovered info
.
|
A InfDiscovery. |
|
A InfDiscoveryInfo discovered by discovery .
|
Returns : |
A string owned by discovery .
|
const gchar * inf_discovery_info_get_service_type (InfDiscovery *discovery
,InfDiscoveryInfo *info
);
Returns the service type of the discovered info
.
|
A InfDiscovery. |
|
A InfDiscoveryInfo discovered by discovery .
|
Returns : |
A string owned by discovery .
|
void inf_discovery_discovered (InfDiscovery *discovery
,InfDiscoveryInfo *info
);
Emits the "discovered" signal on discovery
.
|
A InfDiscovery. |
|
The discovered InfDiscoveryInfo. |
void inf_discovery_undiscovered (InfDiscovery *discovery
,InfDiscoveryInfo *info
);
Emits the "undiscovered" signal on discovery
.
|
A InfDiscovery. |
|
The undiscovered InfDiscoveryInfo .
|
"discovered"
signalvoid user_function (InfDiscovery *discoverer, gpointer info, gpointer user_data) : Run Last / Has Details
This signal is detailed. The detail is the name of the service that has been discovered, so you can connect to "discovered::my-service-name" if you are only interested in a particular service.
|
The InfDiscovery object discovering something |
|
The InfDiscoveryInfo describing the discovered service |
|
user data set when the signal handler was connected. |
"undiscovered"
signalvoid user_function (InfDiscovery *discoverer, gpointer info, gpointer user_data) : Run Last / Has Details
This signal is emitted if a previously discovered service is no longer available.
This signal is detailed. The detail is the name of the service that has been undiscovered, so you can connect to "undiscovered::my-service-name" if you are only interested in a particular service.
|
The InfDiscovery object undiscovering something |
|
The InfDiscoveryInfo describing the undiscovered service |
|
user data set when the signal handler was connected. |