Beispiel #1
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);
}
static void
mapped_external_port_cb (GUPnPSimpleIgd *igd, gchar *proto,
    gchar *external_ip, gchar *replaces_external_ip, guint external_port,
    gchar *local_ip, guint local_port, gchar *description, gpointer user_data)
{
  guint requested_external_port = GPOINTER_TO_UINT (user_data);

  g_assert (invalid_ip == NULL);

  if (requested_external_port)
    g_assert (external_port == requested_external_port);
  else if (return_conflict)
    g_assert (external_port != INTERNAL_PORT);
  else
    g_assert (external_port == INTERNAL_PORT);
  g_assert (proto && !strcmp (proto, "UDP"));
  g_assert (local_port == INTERNAL_PORT);
  g_assert (local_ip && !strcmp (local_ip, "192.168.4.22"));
  g_assert (description != NULL);
  g_assert (external_ip);

  if (replaces_external_ip)
  {
    g_assert ((!strcmp (replaces_external_ip, IP_ADDRESS_FIRST) &&
            !strcmp (external_ip, IP_ADDRESS_SECOND)) ||
        (!strcmp (replaces_external_ip, PPP_ADDRESS_FIRST) &&
            !strcmp (external_ip, PPP_ADDRESS_SECOND)));
    if (dispose_removes)
      g_object_unref (igd);
    else
      gupnp_simple_igd_remove_port (igd, "UDP", requested_external_port);
  }
  else
  {
    if (!strcmp (external_ip, IP_ADDRESS_FIRST))
      gupnp_service_notify (GUPNP_SERVICE (ipservice),
          "ExternalIPAddress", G_TYPE_STRING, IP_ADDRESS_SECOND, NULL);
    else if (!strcmp (external_ip, PPP_ADDRESS_FIRST))
      gupnp_service_notify (GUPNP_SERVICE (pppservice),
          "ExternalIPAddress", G_TYPE_STRING, PPP_ADDRESS_SECOND, NULL);
    else
      g_assert_not_reached ();
  }
}
Beispiel #3
0
void
notify_load_level_change (gint load_level)
{
        GList *network_lights;
        GList *nl_node;

        network_lights = g_hash_table_get_values (nl_hash);

        for (nl_node = network_lights;
             nl_node != NULL;
             nl_node = nl_node->next) {
                NetworkLight *nl = (NetworkLight *) nl_node->data;

                gupnp_service_notify (GUPNP_SERVICE (nl->dimming),
                                      "LoadLevelStatus",
                                      G_TYPE_UINT,
                                      load_level,
                                      NULL);
        }
}
Beispiel #4
0
void
notify_status_change (gboolean status)
{
        GList *network_lights;
        GList *nl_node;

        network_lights = g_hash_table_get_values (nl_hash);

        for (nl_node = network_lights;
             nl_node != NULL;
             nl_node = nl_node->next) {
                NetworkLight *nl = (NetworkLight *) nl_node->data;

                gupnp_service_notify (GUPNP_SERVICE (nl->switch_power),
                                      "Status",
                                      G_TYPE_BOOLEAN,
                                      status,
                                      NULL);
        }
}