## InfcBrowser InfcBrowser — Browse remote directories |

## Stability Level

Unstable, unless otherwise indicated

## Functions

InfcBrowser * | infc_browser_new ()
InfCommunicationManager * | infc_browser_get_communication_manager ()
InfXmlConnection * | infc_browser_get_connection ()
gboolean | infc_browser_add_plugin ()
const InfcNotePlugin * | infc_browser_lookup_plugin ()
InfRequest * | infc_browser_iter_save_session ()
InfcSessionProxy * | infc_browser_iter_get_sync_in ()
GSList * | infc_browser_iter_get_sync_in_requests ()
gboolean | infc_browser_iter_is_valid ()
InfRequest * | infc_browser_subscribe_chat ()
InfRequest * | infc_browser_get_subscribe_chat_request ()
InfcSessionProxy * | infc_browser_get_chat_session ()

## Properties

InfcSessionProxy * | chat-session | Read
InfCommunicationManager * | communication-manager | Read / Write / Construct Only
InfXmlConnection * | connection | Read / Write / Construct Only
InfIo * | io | Read / Write / Construct Only

## Types and Values

struct | InfcBrowser
struct | InfcBrowserClass

## Object Hierarchy

        GObject
        ╰── InfcBrowser

## Implemented Interfaces

InfcBrowser implements InfCommunicationObject and InfBrowser.

## Includes

    #include <libinfinity/client/infc-browser.h>

## Description

The InfcBrowser is used to browse a remote directory and can be used to subscribe to sessions. InfcBrowser implements the InfBrowser interface, through which most operations are performed.

## Functions

### infc_browser_new ()

    InfcBrowser *
    infc_browser_new (InfIo *io,
                      InfCommunicationManager *comm_manager,
                      InfXmlConnection *connection);

Creates a new InfcBrowser.

[constructor]

#### Parameters

io | A InfIo object used to schedule timeouts. |
comm_manager | A InfCommunicationManager to register the server connection and which forwards incoming data to the browser or running sessions. |
connection | Connection to the server. |

#### Returns

A new InfcBrowser.

[transfer full]

### infc_browser_get_communication_manager ()

    InfCommunicationManager *
    infc_browser_get_communication_manager
                                   (InfcBrowser *browser);

Returns the communication manager of this browser.

#### Parameters

browser | A InfcBrowser. |

#### Returns

A InfCommunicationManager.

[transfer none]

### infc_browser_get_connection ()

    InfXmlConnection *
    infc_browser_get_connection (InfcBrowser *browser);

Returns the connection to the server.

#### Parameters

browser | A InfcBrowser. |

#### Returns

A InfXmlConnection.

[transfer none]

### infc_browser_add_plugin ()

    gboolean
    infc_browser_add_plugin (InfcBrowser *browser,
                             const InfcNotePlugin *plugin);

Adds `plugin` to `browser` . This allows the browser to create sessions of the plugin's type. Only one plugin of each type can be added to the directory.

#### Parameters

browser | A InfcBrowser. |
plugin | A InfcNotePlugin. |

#### Returns

Whether the plugin was added successfully.

[transfer none]

### infc_browser_lookup_plugin ()

    const InfcNotePlugin *
    infc_browser_lookup_plugin (InfcBrowser *browser,
                                const gchar *note_type);

Returns a previously registered plugin (see `infc_browser_add_plugin()`) for the given note type, or `NULL` if there is no such plugin.

#### Parameters

browser | A InfcBrowser. |
note_type | A note type, such as "InfText". |

#### Returns

A InfcNotePlugin, or `NULL`.

[transfer none]

### infc_browser_iter_save_session ()

    InfRequest *
    infc_browser_iter_save_session (InfcBrowser *browser,
                                    const InfBrowserIter *iter,
                                    InfRequestFunc func,
                                    gpointer user_data);

Requests that the server saves the note pointed to by `iter` into its background storage. Normally, the server only does this when it is either shut down or when the there are no more subscriptions to the note. Note that this is merely a request and the server might decide not to save the session for whatever reason.

The request might either finish during the call to this function, in which case `func` will be called and `NULL` being returned. If the request does not finish within the function call, a InfRequest object is returned, where `func` has been installed for the “finished” signal, so that it is called as soon as the request finishes.

#### Parameters

browser | A InfcBrowser. |
iter | A InfBrowserIter pointing to a note in `browser` . |
func | The function to be called when the request finishes, or `NULL`. | [scope async]
user_data | Additional data to pass to `func` . |

#### Returns

A InfRequest that may be used to get notified when the request finishes or fails.

[transfer none][allow-none]

### infc_browser_iter_get_sync_in ()

    InfcSessionProxy *
    infc_browser_iter_get_sync_in (InfcBrowser *browser,
                                   const InfBrowserIter *iter);

Returns the InfcSessionProxy that is used to synchronize the note `iter` points to to the server. Such a node is created by `inf_browser_add_note()` with non-`NULL` `session` parameter. If the client is subscribed to this note, then this returns the same session as `inf_browser_get_session()`. However, it is possible that we synchronize this node to the server without being subscribed to it. In this case, this function returns the session that does the synchronization, while `inf_browser_get_session()` would return `NULL`.

#### Parameters

browser | A InfcBrowser. |
iter | A InfBrowserIter pointing to a note in `browser` . |

#### Returns

A InfcSessionProxy, or `NULL` if we are currently not synchronizing this node to the server.

[transfer none][allow-none]

### infc_browser_iter_get_sync_in_requests ()

    GSList *
    infc_browser_iter_get_sync_in_requests
                                   (InfcBrowser *browser,
                                    const InfBrowserIter *iter);

Returns a list of all InfRequests created with `inf_browser_add_note()` with the node `iter` points to as parent. Such requests begin a synchronization to the server when they have finished.

#### Parameters

browser | A InfcBrowser. |
iter | A InfBrowserIter pointing to a subdirectory node in `browser` . |

#### Returns

A list of InfRequests. Free with `g_slist_free()` when done.

[transfer container][element-type InfRequest]

### infc_browser_iter_is_valid ()

    gboolean
    infc_browser_iter_is_valid (InfcBrowser *browser,
                                const InfBrowserIter *iter);

Returns whether `iter` points to a valid node in `browser` . This is generally the case for any InfBrowserIter returned by one of the InfcBrowser functions, it gets invalid however as soon as the node it points to is removed.

#### Parameters

browser | A InfcBrowser. |
iter | A InfBrowserIter. |

#### Returns

Whether `iter` points to a node in `browser` .

### infc_browser_subscribe_chat ()

    InfRequest *
    infc_browser_subscribe_chat (InfcBrowser *browser,
                                 InfRequestFunc func,
                                 gpointer user_data);

Attempts to subscribe to the server's chat. When the operation finishes `infc_browser_get_chat_session()` will return a InfcSessionProxy representing the chat session. It can be used to read the chat's content. The request can fail in case the server chat is disabled.

The request might either finish during the call to this function, in which case `func` will be called and `NULL` being returned. If the request does not finish within the function call, a InfRequest object is returned, where `func` has been installed for the “finished” signal, so that it is called as soon as the request finishes.

#### Parameters

browser | A InfcBrowser. |
func | The function to be called when the request finishes, or `NULL`. | [scope async]
user_data | Additional data to pass to `func` . |

#### Returns

A InfRequest that may be used to get notified when the request finishes or fails.

[transfer none][allow-none]

### infc_browser_get_subscribe_chat_request ()

    InfRequest *
    infc_browser_get_subscribe_chat_request
                                   (InfcBrowser *browser);

Returns the InfRequest that represests the request sent to the server which attempts to subscribe to its chat. If there is no such request running, then the function returns `NULL`. After such a request finishes, call `infc_browser_get_chat_session()` to get the InfcSessionProxy for the chat session. To initiate the request, call `infc_browser_subscribe_chat()`.

#### Parameters

browser | A InfcBrowser. |

#### Returns

A InfRequest, or `NULL`.

[transfer none][allow-none]

### infc_browser_get_chat_session ()

    InfcSessionProxy *
    infc_browser_get_chat_session (InfcBrowser *browser);

Returns the InfcSessionProxy representing the running chat session if the local client is subscribed to it, or `NULL` otherwise.

#### Parameters

browser | A InfcBrowser. |

#### Returns

A InfcSessionProxy for the chat, or `NULL`.

[transfer none][allow-none]

## Types and Values

### struct InfcBrowser

    struct InfcBrowser;

InfcBrowser is an opaque data type. You should only access it via the public API functions.

### struct InfcBrowserClass

    struct InfcBrowserClass {
    };

This structure does not contain any public fields.

## Property Details

### The `“chat-session”` property

      “chat-session”             InfcSessionProxy *

Active chat session.

Owner: InfcBrowser

Flags: Read

### The `“communication-manager”` property

      “communication-manager”    InfCommunicationManager *

The communication manager for the browser.

Owner: InfcBrowser

Flags: Read / Write / Construct Only

### The `“connection”` property

      “connection”               InfXmlConnection *

Connection to the server exposing the directory to browse.

Owner: InfcBrowser

Flags: Read / Write / Construct Only

### The `“io”` property

      “io”                       InfIo *

The InfIo to schedule timeouts.

Owner: InfcBrowser

Flags: Read / Write / Construct Only

## See Also

InfdDirectory