Example #1
0
static void
infc_session_proxy_succeed_user_request(InfcSessionProxy* proxy,
                                        xmlNodePtr xml,
                                        InfUser* user)
{
  InfcSessionProxyPrivate* priv;
  xmlChar* seq_attr;
  guint seq;
  InfcRequest* request;

  priv = INFC_SESSION_PROXY_PRIVATE(proxy);
  seq_attr = xmlGetProp(xml, (const xmlChar*)"seq");

  if(seq_attr != NULL)
  {
    seq = strtoul((const char*)seq_attr, NULL, 0);
    xmlFree(seq_attr);

    request = infc_request_manager_get_request_by_seq(
      priv->request_manager,
      seq
    );

    /* TODO: Set error when invalid seq was set. Perhaps implement in
     * request manager. */
    if(INFC_IS_USER_REQUEST(request))
    {
      infc_user_request_finished(INFC_USER_REQUEST(request), user);
      infc_request_manager_remove_request(priv->request_manager, request);
    }
  }
}
static void
infc_user_request_init(GTypeInstance* instance,
                          gpointer g_class)
{
  InfcUserRequest* user_request;
  user_request = INFC_USER_REQUEST(instance);
}
static void
infc_user_request_finalize(GObject* object)
{
  InfcUserRequest* request;
  request = INFC_USER_REQUEST(object);

  if(G_OBJECT_CLASS(parent_class)->finalize != NULL)
    G_OBJECT_CLASS(parent_class)->finalize(object);
}
Example #4
0
/**
 * infc_session_proxy_join_user:
 * @proxy: A #InfcSessionProxy.
 * @params: Construction properties for the InfUser (or derived) object.
 * @n_params: Number of parameters.
 * @error: Location to store error information.
 *
 * Requests a user join for a user with the given properties (which must not
 * include ID and status since these are initially set by the server).
 *
 * Return Value: A #InfcUserRequest object that may be used to get notified
 * when the request succeeds or fails.
 **/
InfcUserRequest*
infc_session_proxy_join_user(InfcSessionProxy* proxy,
                             const GParameter* params,
                             guint n_params,
                             GError** error)
{
  InfcSessionProxyPrivate* priv;
  InfSessionClass* session_class;
  InfSessionStatus status;
  InfcRequest* request;
  xmlNodePtr xml;

  g_return_val_if_fail(INFC_IS_SESSION_PROXY(proxy), NULL);
  g_return_val_if_fail(params != NULL || n_params == 0, NULL);

  priv = INFC_SESSION_PROXY_PRIVATE(proxy);
  g_return_val_if_fail(priv->session != NULL, NULL);

  session_class = INF_SESSION_GET_CLASS(priv->session);

  /* Make sure we are subscribed */
  g_object_get(G_OBJECT(priv->session), "status", &status, NULL);
  g_return_val_if_fail(status == INF_SESSION_RUNNING, NULL);
  g_return_val_if_fail(priv->connection != NULL, NULL);

  /* TODO: Check params locally */

  request = infc_request_manager_add_request(
    priv->request_manager,
    INFC_TYPE_USER_REQUEST,
    "user-join",
    NULL
  );

  xml = infc_session_proxy_request_to_xml(INFC_REQUEST(request));

  g_assert(session_class->set_xml_user_props != NULL);
  session_class->set_xml_user_props(priv->session, params, n_params, xml);

  inf_connection_manager_group_send_to_connection(
    priv->subscription_group,
    priv->connection,
    xml
  );

  return INFC_USER_REQUEST(request);
}