Back to index

unity  6.0.0
Classes | Defines | Typedefs | Functions
ubus-server.h File Reference
#include <glib-object.h>
#include <glib.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _UBusServerClass
struct  _UBusServer

Defines

#define UBUS_TYPE_SERVER   (ubus_server_get_type ())
#define UBUS_SERVER(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), UBUS_TYPE_SERVER, UBusServer))
#define UBUS_SERVER_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), UBUS_TYPE_SERVER, UBusServerClass))
#define UBUS_IS_SERVER(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UBUS_TYPE_SERVER))
#define UBUS_IS_SERVER_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), UBUS_TYPE_SERVER))
#define UBUS_SERVER_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), UBUS_TYPE_SERVER, UBusServerClass))

Typedefs

typedef struct _UBusServerClass
typedef struct _UBusServer
typedef struct _UBusServerPrivate
typedef void(* UBusCallback )(GVariant *data, gpointer user_data)

Functions

GType ubus_server_get_type (void) G_GNUC_CONST
UBusServerubus_server_get_default ()
void ubus_server_prime_context (UBusServer *server, GMainContext *context)
guint ubus_server_register_interest (UBusServer *server, const gchar *message, UBusCallback callback, gpointer user_data)
void ubus_server_send_message (UBusServer *server, const gchar *message, GVariant *data)
void ubus_server_unregister_interest (UBusServer *server, guint handle)
void ubus_server_force_message_pump (UBusServer *server)

Class Documentation

struct _UBusServer

Definition at line 53 of file ubus-server.h.

Class Members
GObject parent_instance
UBusServerPrivate * priv

Define Documentation

#define UBUS_IS_SERVER (   obj)    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UBUS_TYPE_SERVER))

Definition at line 32 of file ubus-server.h.

#define UBUS_IS_SERVER_CLASS (   klass)    (G_TYPE_CHECK_CLASS_TYPE ((klass), UBUS_TYPE_SERVER))

Definition at line 33 of file ubus-server.h.

#define UBUS_SERVER (   obj)    (G_TYPE_CHECK_INSTANCE_CAST ((obj), UBUS_TYPE_SERVER, UBusServer))

Definition at line 30 of file ubus-server.h.

#define UBUS_SERVER_CLASS (   klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), UBUS_TYPE_SERVER, UBusServerClass))

Definition at line 31 of file ubus-server.h.

#define UBUS_SERVER_GET_CLASS (   obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), UBUS_TYPE_SERVER, UBusServerClass))

Definition at line 34 of file ubus-server.h.

Definition at line 29 of file ubus-server.h.


Typedef Documentation

typedef struct _UBusServer

Definition at line 37 of file ubus-server.h.

typedef struct _UBusServerClass

Definition at line 36 of file ubus-server.h.

typedef struct _UBusServerPrivate

Definition at line 38 of file ubus-server.h.

typedef void(* UBusCallback)(GVariant *data, gpointer user_data)

Definition at line 60 of file ubus-server.h.


Function Documentation

Definition at line 394 of file ubus-server.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 25 of file ubus-server-mock.cpp.

                                      {
  return &default_server;
}

Here is the caller graph for this function:

GType ubus_server_get_type ( void  )
void ubus_server_prime_context ( UBusServer server,
GMainContext *  context 
)
guint ubus_server_register_interest ( UBusServer server,
const gchar *  message,
UBusCallback  callback,
gpointer  user_data 
)

Definition at line 215 of file ubus-server.cpp.

{
  UBusServerPrivate* priv;
  GSequence*         dispatch_list;
  gchar*             interned_message;
  UBusDispatchInfo*  info;

  g_return_val_if_fail(UBUS_IS_SERVER(server), 0);
  g_return_val_if_fail(message != NULL, 0);

  priv = server->priv;
  interned_message = g_string_chunk_insert_const(priv->message_names, message);
  dispatch_list = (GSequence*)g_hash_table_lookup(priv->message_interest_table,
                                                  interned_message);

  if (dispatch_list == NULL)
  {
    // not had this message before so add a new entry to the message_interest table
    dispatch_list = g_sequence_new(NULL);  // we use a sequence because its a stable pointer
    g_hash_table_insert(priv->message_interest_table,
                        interned_message,
                        dispatch_list);
  }

  // add the callback to the dispatch table
  info = ubus_dispatch_info_new(server, message, callback, user_data);
  g_hash_table_insert(priv->dispatch_table, GUINT_TO_POINTER(info->id), info);

  // add the dispatch info to the dispatch list in the message interest table
  g_sequence_append(dispatch_list, info);

  return info->id;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ubus_server_send_message ( UBusServer server,
const gchar *  message,
GVariant *  data 
)

Definition at line 29 of file ubus-server-mock.cpp.

                                                  {
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ubus_server_unregister_interest ( UBusServer server,
guint  handle 
)

Definition at line 335 of file ubus-server.cpp.

{
  UBusServerPrivate* priv;
  GSequence*         dispatch_list;
  UBusDispatchInfo*  info;

  g_return_if_fail(UBUS_IS_SERVER(server));
  g_return_if_fail(handle > 0);

  priv = server->priv;
  info = (UBusDispatchInfo*)g_hash_table_lookup(priv->dispatch_table, GUINT_TO_POINTER(handle));

  if (info == NULL)
  {
    g_warning(G_STRLOC ": Handle %u does not exist", handle);
    return;
  }

  // now the slightly sucky bit, we have to remove from our message-interest
  // table, but we can only find it by itterating through a sequence
  // but this is not so bad because we know *which* sequence its in

  dispatch_list = (GSequence*)g_hash_table_lookup(priv->message_interest_table,
                                                  info->message);

  if (dispatch_list == NULL)
  {
    g_critical(G_STRLOC ": Handle exists but not dispatch list, ubus has "\
               "become unstable");
    return;
  }

  GSequenceIter* iter = g_sequence_get_begin_iter(dispatch_list);
  GSequenceIter* end = g_sequence_get_end_iter(dispatch_list);
  while (iter != end)
  {
    GSequenceIter* next = g_sequence_iter_next(iter);
    UBusDispatchInfo* info_test = (UBusDispatchInfo*)g_sequence_get(iter);

    if (info_test->id == handle)
    {
      g_sequence_remove(iter);
    }

    iter = next;
  }

  if (g_sequence_get_length(dispatch_list) == 0)
  {
    // free the key/value pair
    g_hash_table_remove(priv->message_interest_table, info->message);
  }

  // finally remove the dispatch_table hash table.
  g_hash_table_remove(priv->dispatch_table, &handle);

}

Here is the caller graph for this function: