JNIEXPORT void JNICALL Java_org_embedded_browser_Chromium_browser_1new
  (JNIEnv *env, jobject jobj, jlong hwnd, jint id, jstring url, jobject chromiumset)
{
  const char* chr = env->GetStringUTFChars(url, 0);
  CefString wc = chr;

  GtkWidget* canvas = (GtkWidget*)hwnd;
  GtkWidget* vbox = gtk_vbox_new(FALSE, 0);
  gtk_fixed_put(GTK_FIXED(canvas), vbox, 0, 0);

  CefRefPtr<ClientHandler> gh = NewBrowser(vbox, wc);
  gh->id = id;
  gh->vbox = vbox;
  env->ReleaseStringUTFChars(url, chr);
  send_handler(env, jobj, (jlong)(void*)gh);
  get_browser_settings(env, chromiumset, gh->csettings);
}
Example #2
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(ipv6_process, ev, data)
{


  PROCESS_BEGIN();

  // Set the local address
  uip_ip6addr(&my_addr, 0, 0, 0, 0, 0, 0, 0, 0);
  uip_ds6_set_addr_iid(&my_addr, &uip_lladdr);
  uip_ds6_addr_add(&my_addr, 0, ADDR_MANUAL);

  // Setup the destination address
  uiplib_ipaddrconv(RECEIVER_ADDR, &dest_addr);

  // Add a "neighbor" for our custom route
  // Setup the default broadcast route
  uiplib_ipaddrconv(ADDR_ALL_ROUTERS, &bcast_ipaddr);
  uip_ds6_nbr_add(&bcast_ipaddr, &bcast_lladdr, 0, NBR_REACHABLE);
  uip_ds6_route_add(&dest_addr, 128, &bcast_ipaddr);

  // Setup a udp "connection"
  client_conn = udp_new(&dest_addr, UIP_HTONS(RECEIVER_PORT), NULL);
  if (client_conn == NULL) {
    // Too many udp connections
    // not sure how to exit...stupid contiki
  }
  udp_bind(client_conn, UIP_HTONS(3001));

  etimer_set(&periodic_timer, 10*CLOCK_SECOND);

  while(1) {
    PROCESS_YIELD();

    if (etimer_expired(&periodic_timer)) {
      send_handler(ev, data);
      etimer_restart(&periodic_timer);
    } else if (ev == tcpip_event) {
      recv_handler();
    }
  }

  PROCESS_END();
}
Example #3
0
/* A line of input (a command) is received.  Look at the first character to determine
 * the type and take it from there.
 */
static void handle_line(struct file_info *fi, char *line){
  switch (line[0]) {
  case 0:
    break;
  case 'C':
    connect_command(fi, &line[1]);
    break;
  case 'G':
    gossip_received(fi, &line[1]);
    break;
  case 'H':
    hello_received(fi, &line[1]);
    break;
  case 'E':
  case 'e':
    exit(0);
    break;
  case 'S':
    send_handler(fi, &line[1]);
    break;
  default:
    fprintf(stderr, "unknown command: '%s'\n", line);
  }
}
Example #4
0
        ip::udp::endpoint(ip::udp::v6(), 0), in_flags);
    socket1.send_to(buffer(mutable_char_buffer),
        ip::udp::endpoint(ip::udp::v4(), 0), in_flags, ec);
    socket1.send_to(buffer(mutable_char_buffer),
        ip::udp::endpoint(ip::udp::v6(), 0), in_flags, ec);
    socket1.send_to(buffer(const_char_buffer),
        ip::udp::endpoint(ip::udp::v4(), 0), in_flags, ec);
    socket1.send_to(buffer(const_char_buffer),
        ip::udp::endpoint(ip::udp::v6(), 0), in_flags, ec);
    socket1.send_to(null_buffers(),
        ip::udp::endpoint(ip::udp::v4(), 0), in_flags, ec);
    socket1.send_to(null_buffers(),
        ip::udp::endpoint(ip::udp::v6(), 0), in_flags, ec);

    socket1.async_send_to(buffer(mutable_char_buffer),
        ip::udp::endpoint(ip::udp::v4(), 0), send_handler());
    socket1.async_send_to(buffer(mutable_char_buffer),
        ip::udp::endpoint(ip::udp::v6(), 0), send_handler());
    socket1.async_send_to(buffer(const_char_buffer),
        ip::udp::endpoint(ip::udp::v4(), 0), send_handler());
    socket1.async_send_to(buffer(const_char_buffer),
        ip::udp::endpoint(ip::udp::v6(), 0), send_handler());
    socket1.async_send_to(null_buffers(),
        ip::udp::endpoint(ip::udp::v4(), 0), send_handler());
    socket1.async_send_to(null_buffers(),
        ip::udp::endpoint(ip::udp::v6(), 0), send_handler());
    socket1.async_send_to(buffer(mutable_char_buffer),
        ip::udp::endpoint(ip::udp::v4(), 0), in_flags, send_handler());
    socket1.async_send_to(buffer(mutable_char_buffer),
        ip::udp::endpoint(ip::udp::v6(), 0), in_flags, send_handler());
    socket1.async_send_to(buffer(const_char_buffer),
JNIEXPORT void JNICALL Java_org_embedded_browser_Chromium_browser_1init
  (JNIEnv *env, jobject jobj, jlong hwnd, jstring url, jobject chromiumset)
{
  // Make a simple argument.
  const int argc = 1;
  char** argv = (char**)malloc(argc * sizeof(*argv));
  argv[0] = strdup("java");

  CefMainArgs main_args(argc, argv);
  CefRefPtr<ClientApp> app(new ClientApp);

  // Retrieve the current working directory.
  szWorkingDir = getenv("WSO2_DEVELOPER_STUDIO_PATH");
  if (!szWorkingDir)
    szWorkingDir = (char*)calloc(1, sizeof(char));

  // Parse command line arguments. The passed in values are ignored on Windows.
  AppInitCommandLine(argc, argv);

  CefSettings settings;

  // Populate the settings based on command line arguments.
  AppGetSettings(settings);

  settings.multi_threaded_message_loop = message_loop;
  settings.log_severity = LOGSEVERITY_DISABLE;
  settings.no_sandbox = true;

  CefString path = CefString(szWorkingDir);

#ifndef __LP64__
  CefString(&settings.browser_subprocess_path) = path.ToString() + "/cef/cefclient";
  CefString(&settings.resources_dir_path) = path.ToString() + "/cef";
  CefString(&settings.locales_dir_path) = path.ToString() + "/cef/locales";
#else
  CefString(&settings.browser_subprocess_path) = path.ToString() + "/cef/cefclient";
  CefString(&settings.resources_dir_path) = path.ToString() + "/cef";
  CefString(&settings.locales_dir_path) = path.ToString() + "/cef/locales";
#endif

  BackupSignalHandlers();

  // Initialize CEF.
  CefInitialize(main_args, settings, app.get(), NULL);

  RestoreSignalHandlers();

  GtkWidget* canvas = (GtkWidget*)hwnd;
  GtkWidget* vbox = gtk_vbox_new(FALSE, 0);
  gtk_fixed_put(GTK_FIXED(canvas), vbox, 0, 0);

  const char* chr = env->GetStringUTFChars(url, 0);
  CefString wc = chr;

  CefRefPtr<ClientHandler> gh = InitBrowser(vbox, wc);
  gh->id = 1;
  gh->vbox = vbox;

  env->ReleaseStringUTFChars(url, chr);

  // NOTE: This function (browser_init) should only be called ONCE in one process,
  // which means to call CefInitialize in the first broswer creation, and call 
  // CefShutdown in the exit of the process. Repeated calls to this function will 
  // NOT work, because the web page will not render. Most probably a bug in cef.
  set_jvm(env, jobj);
  send_handler(env, jobj, (jlong)(void*)gh);

  // Have to be here and use own jnienv to avoid errors.
  get_browser_settings(env, chromiumset, gh->csettings);

  //CefRunMessageLoop();
  //CefShutdown();
}
Example #6
0
void
alltoall(int len)
{
    int cc;
    int i, n;
    int m;
    fd_set wfds, rfds;
    struct request send_req;

    send_req.rank = comm_rank;
    send_req.len  = len;

    for (i = 0; i < comm_size; i++) {
	if (i != comm_rank) {
	    recv_req[i].count = 0;
	} else {
	    recv_req[i].count = len;
	}
    }

    for (n = 0; n < comm_size - 1; n++) {
	/* send phase */
	send_req.rank = GET_RANK(send_req.rank + 1);
	send_req.fd = hosts[send_req.rank].sock;
	send_req.count = 0;
	send_handler(&send_req);

	assert(send_req.rank != comm_rank);

	for (;;) {
	    int nsel = 0;
	    m = -1;
	    FD_ZERO(&wfds);
	    FD_ZERO(&rfds);
	    if (send_req.count != send_req.len) {
		FD_SET(send_req.fd, &wfds);
		m = MAX(m, send_req.fd);
		nsel++;
	    } else {
		if (n + 1 != comm_size - 1)
		    break;	/* We have another pending send requests. */
	    }

	    for (i = 0; i < comm_size; i++) {
		if (recv_req[i].count == recv_req[i].len)
		    continue;
		FD_SET(recv_req[i].fd, &rfds);
		m = MAX(m, recv_req[i].fd);
		nsel++;
	    }

	    if (nsel == 0)
		break;
	    cc = select(m + 1, &rfds, &wfds, NULL, NULL);
	    nr_select++;
	    if (cc < 0)
		perror_exit("select", 1);

	    for (i = 0; i < comm_size; i++) {
		if (recv_req[i].count == recv_req[i].len)
		    continue;
		if (FD_ISSET(recv_req[i].fd, &rfds))
		    recv_handler(&recv_req[i]);
	    }
	    if (FD_ISSET(send_req.fd, &wfds))
		send_handler(&send_req);
	}
    }
}
JNIEXPORT jlong JNICALL Java_org_embedded_browser_Chromium_browser_1init
(JNIEnv *env, jobject jobj, jlong hwnd, jstring url, jobject chromiumset)
{
    // Make a simple argument.
    const int argc = 1;
    char** argv = (char**)malloc(argc * sizeof(*argv));
    argv[0] = strdup("java");

    CefMainArgs main_args(argc, argv);
    CefRefPtr<ClientApp> app(new ClientApp);
    CefSettings settings;

    // Execute the secondary process, if any.
    int exit_code = CefExecuteProcess(main_args, app.get());
    if (exit_code >= 0)
        return exit_code;

    // Parse command line arguments. The passed in values are ignored on Windows.
    AppInitCommandLine(argc, argv);

    // Populate the settings based on command line arguments.
    AppGetSettings(settings);

    // Initialize CEF.
    CefInitialize(main_args, settings, app.get());

    GtkWidget* canvas = (GtkWidget*)hwnd;
    GtkWidget* vbox = gtk_vbox_new(FALSE, 0);
    gtk_fixed_put(GTK_FIXED(canvas), vbox, 0, 0);

    //GtkWidget* scroll_window = gtk_scrolled_window_new(NULL, NULL);
    //GtkWidget* vbox = gtk_vbox_new(FALSE, 0);
    //gtk_container_add(GTK_CONTAINER(scroll_window), vbox);
    //gtk_fixed_put(GTK_FIXED(canvas), scroll_window, 0, 0);

    set_java_env(env, jobj);

    const char* chr = env->GetStringUTFChars(url, 0);
    CefString wc = chr;

    CefRefPtr<ClientHandler> gh = InitBrowser(vbox, wc);
    gh->id = 1;

    env->ReleaseStringUTFChars(url, chr);

    // NOTE: This function (browser_init) should only be called ONCE in one process,
    // which means to call CefInitialize in the first broswer creation, and call
    // CefShutdown in the exit of the process. Repeated calls to this function will
    // NOT work, because the web page will not render. Most probably a bug in cef.
    send_handler(env, jobj, (jlong)(void*)gh);

    // Have to be here and use own jnienv to avoid errors.
    get_browser_settings(env, chromiumset, gh->csettings);

    //signal(SIGINT, TerminationSignalHandler);
    //signal(SIGTERM, TerminationSignalHandler);

    //CefRunMessageLoop();
    //CefShutdown();
    return (jlong)vbox;
}