Exemple #1
0
static GObject *
odccm_device_manager_constructor (GType type, guint n_props,
                                  GObjectConstructParam *props)
{
  GObject *obj;
  OdccmDeviceManagerPrivate *priv;

  obj = G_OBJECT_CLASS (odccm_device_manager_parent_class)->
    constructor (type, n_props, props);

  priv = ODCCM_DEVICE_MANAGER_GET_PRIVATE (obj);

  priv->server = gnet_server_new (NULL, 990, client_connected_cb, obj);
#ifdef ENABLE_LEGACY_SUPPORT
  priv->legacy_server = gnet_server_new (NULL, 5679, client_connected_cb, obj);
#endif

  dbus_g_connection_register_g_object (_odccm_get_dbus_conn (),
                                       DEVICE_MANAGER_OBJECT_PATH, obj);

  init_hal (ODCCM_DEVICE_MANAGER (obj));
  init_udev (ODCCM_DEVICE_MANAGER (obj));

  return obj;
}
Exemple #2
0
int run(void)
{
  int ret = 0;
  GMainLoop* main_loop;
  GInetAddr* addr;
  GServer* server;

  /* Create the main loop */
  main_loop = g_main_new(FALSE);

  /* Create the interface */
  addr = gnet_inetaddr_new_any ();
  gnet_inetaddr_set_port (addr, OPT_VALUE_LISTEN);

  /* Create the server */
  server = gnet_server_new (addr, TRUE, ob_server_func, "hallo");
  if (!server)
    {
      fprintf (stderr, "Error: Could not start server\n");
      return(0);
    }

  ob_server = server;
  signal (SIGTERM, ob_sig_term);

  /* Start the main loop */
  g_main_run(main_loop);

  return(1);
}
Exemple #3
0
void              remote_server_main_loop     (int        port_number,
					       gboolean   have_gtk,
					       gboolean   verbose)
{
    RemoteServer self;

    self.have_gtk = have_gtk;
    self.verbose = verbose;

    self.gserver = gnet_server_new(NULL, port_number,
				   remote_server_connect, &self);
    if (!self.gserver) {
	printf("Unable to listen on port %d!\n", port_number);
	exit(1);
    }

    self.command_hash = g_hash_table_new(g_str_hash, g_str_equal);
    self.gui_hash = g_hash_table_new(g_str_hash, g_str_equal);
    remote_server_init_commands(&self);

    if (self.verbose)
	printf("Fyre server listening on port %d\n", port_number);

    /* At this point, now that we've bound to the port and such,
     * make sure we aren't running as a privileged user. If so,
     * ditch all privileges permanently.
     */
    release_privileges(&self);

    if (have_gtk)
	gtk_main();
    else
	g_main_loop_run(g_main_loop_new(NULL, FALSE));

    if (self.verbose)
	printf("Fyre server shutting down.\n");

    gnet_server_delete(self.gserver);
    g_hash_table_destroy(self.command_hash);
    g_hash_table_destroy(self.gui_hash);
}
Exemple #4
0
int
main(int argc, char** argv)
{
  int port;
  GServer* server;
  GMainLoop* main_loop;

  gnet_init ();

  if (argc != 2)
    {
      fprintf (stderr, "usage: echoserver <port> \n");
      exit(EXIT_FAILURE);
    }

  fprintf (stderr, "NOTE: You can not use the standard echoclient with this server.\n");

  port = atoi(argv[argc - 1]);

  /* Create the main loop */
  main_loop = g_main_new (FALSE);

  /* Create the server */
  server = gnet_server_new (NULL, port, ob_server_func, NULL);
  if (!server)
    {
      fprintf (stderr, "Error: Could not start server\n");
      exit (EXIT_FAILURE);
    }

  ob_server = server;
  signal (SIGINT, ob_sig_int);

  /* Start the main loop */
  g_main_run(main_loop);

  exit (EXIT_SUCCESS);
  return 0;
}