static void
delete_port_mapping_cb (GUPnPService *service,
    GUPnPServiceAction *action,
    gpointer user_data)
{
  guint requested_external_port = GPOINTER_TO_UINT (user_data);
  gchar *remote_host = NULL;
  guint external_port = 0;
  gchar *proto = NULL;

  gupnp_service_action_get (action,
      "NewRemoteHost", G_TYPE_STRING, &remote_host,
      "NewExternalPort", G_TYPE_UINT, &external_port,
      "NewProtocol", G_TYPE_STRING, &proto,
      NULL);

  g_assert (remote_host != NULL);
  if (requested_external_port || !return_conflict)
    g_assert (external_port == INTERNAL_PORT);
  else
    g_assert (external_port != INTERNAL_PORT);
  g_assert (proto && !strcmp (proto, "UDP"));

  gupnp_service_action_return (action);

  g_free (remote_host);
  g_free (proto);

  GSource* src = g_idle_source_new ();
  g_source_set_callback (src, loop_quit, NULL, NULL);
  g_source_attach (src, g_main_context_get_thread_default ());
}
Пример #2
0
G_END_DECLS
/*
 * Action handlers
 */

/* SetTarget */
G_MODULE_EXPORT void
set_target_cb (GUPnPService          *service,
               GUPnPServiceAction    *action,
               G_GNUC_UNUSED gpointer user_data)
{
  gboolean target;

  /* Get the new target value */
  gupnp_service_action_get (action,
                            "NewTargetValue", G_TYPE_BOOLEAN, &target,
                            NULL);

  /* If the new target doesn't match the current status, change the status and
     emit a notification that the status has changed. */
  if (target != status) {
    status = target;
    gupnp_service_notify (service,
                          "Status", G_TYPE_BOOLEAN, status,
                          NULL);

    if (!quiet)
    {
      g_print ("The light is now %s.\n", status ? "on" : "off");
    }
  }

  /* Return success to the client */
  gupnp_service_action_return (action);
}
Пример #3
0
//			<name>GetMediaInfo_Ext</name> ???
void
get_media_info_ext_cb (GUPnPService *service,
                       GUPnPServiceAction *action,
                       gpointer user_data)
{
    g_debug ("get_media_info_ext_cb");
    gupnp_service_action_return (action);    
}
Пример #4
0
/* GetStatus */
G_MODULE_EXPORT void
get_status_cb (G_GNUC_UNUSED GUPnPService *service,
               GUPnPServiceAction         *action,
               G_GNUC_UNUSED gpointer      user_data)
{
  gupnp_service_action_set (action,
                            "ResultStatus", G_TYPE_BOOLEAN, status,
                            NULL);
  gupnp_service_action_return (action);
}
G_MODULE_EXPORT void 
getCurrentConnectionIDs(GUPnPService *service, GUPnPServiceAction *action, gpointer userData) {
	UpnpConnectionManagerServicePrivate *priv = UPNP_CONNECTION_MANAGER_SERVICE_GET_PRIVATE(UPNP_CONNECTION_MANAGER_SERVICE(userData));
	gchar *CurrentConnectionIDs = priv->currentConnectionIDs;

	gupnp_service_action_set(action,
							 "ConnectionIDs", G_TYPE_STRING, CurrentConnectionIDs,
							 NULL);

	gupnp_service_action_return(action);
}
Пример #6
0
static void
get_external_ip_address_cb (GUPnPService *service,
    GUPnPServiceAction *action,
    gpointer user_data)
{
  gupnp_service_action_set (action,
      "NewExternalIPAddress", G_TYPE_STRING, "127.0.0.1",
      NULL);
  gupnp_service_action_return (action);
  got_address = TRUE;
}
Пример #7
0
G_MODULE_EXPORT
void
on_get_load_level_target (GUPnPService       *service,
                          GUPnPServiceAction *action,
                          gpointer            user_data)
{
        gupnp_service_action_set (action,
                                  "retLoadlevelTarget",
                                  G_TYPE_UINT,
                                  get_load_level (),
                                  NULL);

        gupnp_service_action_return (action);
}
Пример #8
0
G_MODULE_EXPORT
void
on_get_target (GUPnPService       *service,
               GUPnPServiceAction *action,
               gpointer            user_data)
{
        gupnp_service_action_set (action,
                                  "RetTargetValue",
                                  G_TYPE_BOOLEAN,
                                  get_status (),
                                  NULL);

        gupnp_service_action_return (action);
}
static void
add_port_mapping_cb (GUPnPService *service,
    GUPnPServiceAction *action,
    gpointer user_data)
{
  guint requested_external_port = GPOINTER_TO_UINT (user_data);
  gchar *remote_host = NULL;
  guint external_port = 0;
  gchar *proto = NULL;
  guint internal_port = 0;
  gchar *internal_client = NULL;
  gboolean enabled = -1;
  gchar *desc = NULL;
  guint lease = 0;

  gupnp_service_action_get (action,
      "NewRemoteHost", G_TYPE_STRING, &remote_host,
      "NewExternalPort", G_TYPE_UINT, &external_port,
      "NewProtocol", G_TYPE_STRING, &proto,
      "NewInternalPort", G_TYPE_UINT, &internal_port,
      "NewInternalClient", G_TYPE_STRING, &internal_client,
      "NewEnabled", G_TYPE_BOOLEAN, &enabled,
      "NewPortMappingDescription", G_TYPE_STRING, &desc,
      "NewLeaseDuration", G_TYPE_UINT, &lease,
      NULL);

  g_assert (external_port);
  g_assert (remote_host && !strcmp (remote_host, ""));
  g_assert (proto && (!strcmp (proto, "UDP") || !strcmp (proto, "TCP")));
  g_assert (internal_port == INTERNAL_PORT);
  g_assert (internal_client && !strcmp (internal_client, "192.168.4.22"));
  g_assert (enabled == TRUE);
  g_assert (desc != NULL);
  g_assert (lease == 10);

  g_free (remote_host);
  g_free (proto);
  g_free (internal_client);
  g_free (desc);

  if (requested_external_port)
    g_assert (external_port == requested_external_port);


  if (return_conflict && external_port == INTERNAL_PORT)
    gupnp_service_action_return_error (action, 718, "ConflictInMappingEntry");
  else
    gupnp_service_action_return (action);
}
Пример #10
0
//			<name>Seek</name>
void
seek_cb (GUPnPService *service,
         GUPnPServiceAction *action,
         gpointer user_data)
{
    g_debug ("seek_cb");
    if (!check_instance_id(action))
    {
        return;
    }

    // TODO:
    
    gupnp_service_action_return (action);    
}
G_MODULE_EXPORT void
getProtocolInfo(GUPnPService *service, GUPnPServiceAction *action, gpointer userData) {
	UpnpConnectionManagerServicePrivate *priv = UPNP_CONNECTION_MANAGER_SERVICE_GET_PRIVATE(UPNP_CONNECTION_MANAGER_SERVICE(userData));
	gchar *SourceProtocolInfo = priv->sourceProtocolInfo;
	gchar *SinkProtocolInfo = priv->sinkProtocolInfo;

	gupnp_service_action_set(action,
							 "Source", G_TYPE_STRING, SourceProtocolInfo,
							 NULL);
	gupnp_service_action_set(action,
							 "Sink", G_TYPE_STRING, SinkProtocolInfo,
							 NULL);

	gupnp_service_action_return(action);
}
Пример #12
0
//			<name>GetTransportSettings</name> OK: rygel
void
get_transport_settings_cb (GUPnPService *service,
                           GUPnPServiceAction *action,
                           gpointer user_data)
{
    g_debug ("get_transport_settings_cb");
    if (!check_instance_id(action))
    {
        return;
    }

    avtransport_get_transport_settings_action_set (action,
                                                   play_mode_to_string (sv_current_play_mode),
                                                   NOT_IMPLEMENTED);
    gupnp_service_action_return (action);    
}
Пример #13
0
G_MODULE_EXPORT
void
on_set_target (GUPnPService       *service,
               GUPnPServiceAction *action,
               gpointer            user_data)
{
        gboolean status;

        gupnp_service_action_get (action,
                                  "newTargetValue",
                                  G_TYPE_BOOLEAN,
                                  &status,
                                  NULL);
        gupnp_service_action_return (action);

        set_status (status);
}
Пример #14
0
// <name>GetDeviceCapabilities</name> OK: rygel
void
get_device_capabilities_cb (GUPnPService *service,
                            GUPnPServiceAction *action,
                            gpointer user_data)
{
    g_debug ("get_device_capabilities_cb");
    if (!check_instance_id(action))
    {
        return;
    }

    avtransport_get_device_capabilities_action_set (action,
                                                    NOT_IMPLEMENTED,
                                                    NOT_IMPLEMENTED,
                                                    NOT_IMPLEMENTED);

    gupnp_service_action_return (action);    
}
Пример #15
0
//			<name>Play</name>
void
play_cb (GUPnPService *service,
         GUPnPServiceAction *action,
         gpointer user_data)
{
    g_debug ("play_cb");
    if (!check_instance_id(action))
    {
        return;
    }

    gstreamer_play();

    GString *last_change = last_change_new ();
    set_transport_state (last_change, PLAYING);
    avtransport_notify_last_change(service, last_change);

    gupnp_service_action_return (action);    
}
Пример #16
0
//			<name>GetPositionInfo</name> ???
void
get_position_info_cb(GUPnPService *service,
                     GUPnPServiceAction *action,
                     gpointer user_data)
{
    g_debug ("get_position_info_cb");
    if (!check_instance_id(action))
    {
        return;
    }

    gint64 relative_time_position = 0;
    gint64 current_track_duration = 0;
    if (gstreamer_get_element_info (&relative_time_position, &current_track_duration))
    {
        // 2.3.1 Event Model
        // The following variables are therefore not evented via LastChange:
        //    RelativeTimePosition, AbsoluteTimePosition
        //    RelativeCounterPosition, AbsoluteCounterPosition
        set_relative_time_position (NULL, relative_time_position);
        set_absolute_time_position (NULL, relative_time_position);
        set_current_track_duration (NULL, current_track_duration);
    }
    
    g_debug ("\trelative_time_position=%s\n\ttrack_duration=%s\n\ttrack=%d\n\ttrack_uri=%s\n\ttrack_meta_data=%s\n",
             sv_relative_time_position_string->str, 
             sv_current_track_duration_string->str, 
             sv_current_track, 
             sv_current_track_uri->str, 
             sv_current_track_meta_data->str);

    avtransport_get_position_info_action_set (action, 
                                              sv_current_track, 
                                              sv_current_track_duration_string->str,
                                              sv_current_track_meta_data->str, 
                                              sv_current_track_uri->str, 
                                              sv_relative_time_position_string->str, 
                                              sv_absolute_time_position_string->str, 
                                              INT_MAX, 
                                              INT_MAX);
    gupnp_service_action_return (action);    
}
Пример #17
0
G_MODULE_EXPORT
void
on_set_load_level_target (GUPnPService       *service,
                          GUPnPServiceAction *action,
                          gpointer            user_data)
{
        guint load_level;

        gupnp_service_action_get (action,
                                  "newLoadlevelTarget",
                                  G_TYPE_UINT,
                                  &load_level,
                                  NULL);
        gupnp_service_action_return (action);

        if (load_level > 100)
                load_level = 100;

        set_load_level (load_level);
}
Пример #18
0
static void
delete_port_mapping_cb (GUPnPService *service,
    GUPnPServiceAction *action,
    gpointer user_data)
{
  gchar *remote_host = NULL;
  guint external_port = 0;
  gchar *proto = NULL;

  gupnp_service_action_get (action,
      "NewRemoteHost", G_TYPE_STRING, &remote_host,
      "NewExternalPort", G_TYPE_UINT, &external_port,
      "NewProtocol", G_TYPE_STRING, &proto,
      NULL);

  ts_fail_if (remote_host == NULL, "remote host NULL on remove");
  ts_fail_unless (external_port, "external port wrong on remove");
  ts_fail_unless (proto && !strcmp (proto, "UDP"), "proto wrong on remove");

  gupnp_service_action_return (action);
}
Пример #19
0
static void
add_port_mapping_cb (GUPnPService *service,
    GUPnPServiceAction *action,
    gpointer user_data)
{
  gchar *remote_host = NULL;
  guint external_port = 0;
  gchar *proto = NULL;
  guint internal_port = 0;
  gchar *internal_client = NULL;
  gboolean enabled = -1;
  gchar *desc = NULL;
  guint lease = 0;

  gupnp_service_action_get (action,
      "NewRemoteHost", G_TYPE_STRING, &remote_host,
      "NewExternalPort", G_TYPE_UINT, &external_port,
      "NewProtocol", G_TYPE_STRING, &proto,
      "NewInternalPort", G_TYPE_UINT, &internal_port,
      "NewInternalClient", G_TYPE_STRING, &internal_client,
      "NewEnabled", G_TYPE_BOOLEAN, &enabled,
      "NewPortMappingDescription", G_TYPE_STRING, &desc,
      "NewLeaseDuration", G_TYPE_UINT, &lease,
      NULL);

  ts_fail_unless (remote_host && !strcmp (remote_host, ""), "Remote host invalid");
  ts_fail_unless (external_port == internal_port, "External and internal ports different");
  ts_fail_unless (proto && (!strcmp (proto, "UDP") || !strcmp (proto, "TCP")));
  ts_fail_unless (enabled == TRUE, "enable is not true");
  ts_fail_unless (desc != NULL, "no desc");

  g_free (remote_host);
  g_free (proto);
  g_free (internal_client);
  g_free (desc);

  gupnp_service_action_return (action);
  added_mapping = TRUE;
}
G_MODULE_EXPORT void
getCurrentConnectionInfo(GUPnPService *service, GUPnPServiceAction *action, gpointer userData) {
	UpnpConnectionManagerServicePrivate *priv = UPNP_CONNECTION_MANAGER_SERVICE_GET_PRIVATE(UPNP_CONNECTION_MANAGER_SERVICE(userData));
	gchar *CurrentConnectionIDs;
	gint  RcsID = priv->rcsID;
	gint  AVTransportID = priv->avTransportID;
	gchar *ProtocolInfo = priv->protocolInfo;
	gchar *ConnectionManager = priv->connectionManager;
	gint  ConnectionID = priv->connectionID;
	gchar *Direction = priv->direction;
	gchar *Status = priv->connectionStatus;

	gupnp_service_action_get(action,
							 "ConnectionIDs", G_TYPE_STRING, &CurrentConnectionIDs,
							 NULL);
	gupnp_service_action_set(action,
							 "RcsID", G_TYPE_INT, RcsID,
							 NULL);
	gupnp_service_action_set(action,
							 "AVTransportID", G_TYPE_INT, AVTransportID,
							 NULL);
	gupnp_service_action_set(action,
							 "ProtocolInfo", G_TYPE_STRING, ProtocolInfo,
							 NULL);
	gupnp_service_action_set(action,
							 "ConnectionManager", G_TYPE_STRING, ConnectionManager,
							 NULL);
	gupnp_service_action_set(action,
							 "ConnectionID", G_TYPE_INT, ConnectionID,
							 NULL);
	gupnp_service_action_set(action,
							 "Direction", G_TYPE_STRING, Direction,
							 NULL);
	gupnp_service_action_set(action,
							 "Status", G_TYPE_STRING, Status,
							 NULL);
	gupnp_service_action_return(action);
}
Пример #21
0
//			<name>GetTransportInfo</name> OK: rygel
void
get_transport_info_cb (GUPnPService *service,
                       GUPnPServiceAction *action,
                       gpointer user_data)
{
    g_debug ("get_transport_info_cb");
    if (!check_instance_id(action))
    {
        return;
    }

    const gchar* tstate = transport_state_to_string (sv_transport_state);
    const gchar* tstatus = transport_status_to_string (sv_transport_status);

    g_debug ("\ttransport_state=%s\n\ttransport_status=%s\n\tcurrent_play_speed=%d\n", 
            tstate, tstatus, sv_current_play_speed);

    avtransport_get_transport_info_action_set (action,
                                               tstate,
                                               tstatus,
                                               sv_current_play_speed_string);
    gupnp_service_action_return (action);    
}
static void
get_external_ip_address_cb (GUPnPService *service,
    GUPnPServiceAction *action,
    gpointer user_data)
{
  ConnectionType ct = GPOINTER_TO_INT (user_data);

  if (invalid_ip)
    gupnp_service_action_set (action,
        "NewExternalIPAddress", G_TYPE_STRING, invalid_ip,
        NULL);
  else if (ct == CONNECTION_IP)
    gupnp_service_action_set (action,
        "NewExternalIPAddress", G_TYPE_STRING, IP_ADDRESS_FIRST,
        NULL);
  else if (ct == CONNECTION_PPP)
    gupnp_service_action_set (action,
        "NewExternalIPAddress", G_TYPE_STRING, PPP_ADDRESS_FIRST,
        NULL);
  else
    g_assert_not_reached ();
  gupnp_service_action_return (action);

}
Пример #23
0
//			<name>GetMediaInfo</name>: OK: rygel
void
get_media_info_cb (GUPnPService *service,
                   GUPnPServiceAction *action,
                   gpointer user_data)
{
    g_debug ("get_media_info_cb");
    if (!check_instance_id (action)) 
    {
        return;
    }

    avtransport_get_media_info_action_set (action,
                                           sv_number_of_tracks,
                                           sv_current_track_duration_string->str,
                                           sv_current_track_uri->str,
                                           sv_current_track_meta_data->str,
                                           NOT_IMPLEMENTED,
                                           NOT_IMPLEMENTED,
                                           NOT_IMPLEMENTED,
                                           NOT_IMPLEMENTED,
                                           NOT_IMPLEMENTED);

    gupnp_service_action_return (action);    
}
Пример #24
0
//			<name>SetAVTransportURI</name> OK: rygel
void
set_avtransport_uri_cb (GUPnPService *service,
                        GUPnPServiceAction *action,
                        gpointer user_data)
{
    g_debug ("set_avtransport_uri_cb");
    if (!check_instance_id (action)) 
    {
        return;
    }

    guint instance_id;
    gchar *current_track_uri = NULL;
    gchar *current_track_meta_data = NULL;
    avtransport_set_av_transport_uri_action_get (action, 
                                                 &instance_id, 
                                                 &current_track_uri, 
                                                 &current_track_meta_data);

    set_current_track_uri (NULL, current_track_uri);
    set_current_track_meta_data (NULL, current_track_meta_data);
    if (sv_transport_state == PLAYING)
    {
        // TODO: TRANSITIONING -> play new URI
    }
    else
    {
        set_transport_state (NULL, STOPPED);
    }

    g_debug ("\tcurrent_track_uri: %s\n\tcurrent_track_meta_data: %s\n", sv_current_track_uri->str, sv_current_track_meta_data->str);

    gstreamer_set_uri (sv_current_track_uri->str);

    gupnp_service_action_return (action);    
}