Exemplo n.º 1
0
guint
bst_choice_modal (GtkWidget *choice,
		  guint      mouse_button,
		  guint32    time)
{
  gpointer data = GUINT_TO_POINTER (0);
  
  if (GTK_IS_MENU (choice))
    {
      GtkMenu *menu = GTK_MENU (choice);
      
      gtk_object_set_data (GTK_OBJECT (menu), "BstChoice", data);
      
      if (bst_choice_selectable (choice))
	{
	  modal_loop_quit_on_menu_item_activate = TRUE;
	  modal_loop_running = TRUE;
	  current_popup_menu = GTK_WIDGET (menu);
	  gtk_menu_popup (menu, NULL, NULL, NULL, NULL, mouse_button, time);
	  while (modal_loop_running)
	    {
	      GDK_THREADS_LEAVE ();
	      g_main_iteration (TRUE);
	      GDK_THREADS_ENTER ();
	    }
	  current_popup_menu = NULL;
	  modal_loop_quit_on_menu_item_activate = FALSE;
	}
      
      data = gtk_object_get_data (GTK_OBJECT (menu), "BstChoice");
    }
  else if (GXK_IS_DIALOG (choice))
    {
      gtk_object_set_data (GTK_OBJECT (choice), "BstChoice", data);
      
      if (bst_choice_selectable (choice))
	{
	  gtk_widget_show (choice);
          
          while (GTK_WIDGET_VISIBLE (choice))
	    {
	      GDK_THREADS_LEAVE ();
	      g_main_iteration (TRUE);
	      GDK_THREADS_ENTER ();
	    }
	}
      
      data = gtk_object_get_data (GTK_OBJECT (choice), "BstChoice");
    }
  
  return GPOINTER_TO_UINT (data);
}
Exemplo n.º 2
0
gboolean my_main_iteration(gboolean may_block){
#ifdef USE_GTK2
  return(g_main_context_iteration(NULL, may_block));
#else
  return(g_main_iteration(may_block));
#endif
}
Exemplo n.º 3
0
Arquivo: rcd.c Projeto: joeshaw/rcd
static void
heartbeat_memory_monitor (gpointer user_data)
{
    int current_memory;
    int max_memory;

    max_memory = rcd_prefs_get_max_allowed_memory ();

    /* This feature is disabled */
    if (max_memory == 0)
        return;

    current_memory = get_vmsize ();
    rc_debug (RC_DEBUG_LEVEL_INFO, "Current VmSize: %d", current_memory);

    /* Convert to kilobytes */
    max_memory *= 1024;

    if (current_memory > max_memory) {
        rc_debug (RC_DEBUG_LEVEL_MESSAGE, "Memory limit reached, restarting");
        rcd_restart ();

        /* Wait here until the restart happens */
        while (g_main_pending ())
            g_main_iteration (TRUE);
    }
}
Exemplo n.º 4
0
int main(int argc, char **argv)
{
	static struct poptOption options[] = {
		{ "dummy", 'd', POPT_ARG_NONE, &dummy, 0, "Use the dummy terminal mode", NULL },
		{ NULL, '\0', 0, NULL }
	};

	dummy = FALSE;
	quitting = FALSE;
	core_init_paths(argc, argv);

	check_files();

#ifdef WIN32
        winsock_init();
#endif
#ifdef HAVE_SOCKS
	SOCKSinit(argv[0]);
#endif
#ifdef ENABLE_NLS
	/* initialize the i18n stuff */
	bindtextdomain(PACKAGE, LOCALEDIR);
	textdomain(PACKAGE);
#endif

	textui_init();
	args_register(options);
	args_execute(argc, argv);

	if (!dummy && !term_init()) {
		fprintf(stderr, "Can't initialize screen handling, quitting.\n");
		fprintf(stderr, "You can still use the dummy mode with -d parameter\n");
		return 1;
	}

	textui_finish_init();
	main_loop = g_main_new(TRUE);

	/* Does the same as g_main_run(main_loop), except we
	   can call our dirty-checker after each iteration */
	while (!quitting) {
		g_main_iteration(TRUE);

		if (reload_config) {
                        /* SIGHUP received, do /RELOAD */
			reload_config = FALSE;
                        signal_emit("command reload", 1, "");
		}

		dirty_check();
	}

	g_main_destroy(main_loop);
	textui_deinit();

        session_upgrade(); /* if we /UPGRADEd, start the new process */
	return 0;
}
Exemplo n.º 5
0
// simply executes one iteration of the event loop. used by xp code with
// non-gtk expectations.
// this method will be removed once xp eventloops are working.
NS_IMETHODIMP nsAppShell::DispatchNativeEvent(PRBool aRealEvent, void *aEvent)
{
  if (!mEventQueue)
    return NS_ERROR_NOT_INITIALIZED;

  g_main_iteration(PR_TRUE);

  return NS_OK;
}
Exemplo n.º 6
0
gboolean dialogGameFinderJoin(GtkWidget *widget,  GdkEventButton *event, gpointer user_data) {
  if (dialogGameFinderJoinTest() == TRUE) {
    gtk_widget_set_sensitive(dialogGameFindUs, FALSE);
    gdk_threads_leave();
    while(g_main_iteration(FALSE));
    gdk_threads_enter();
    if (gameFrontSetDlgState(dialogGameFindUs, openUdpJoin) == FALSE) {
    gtk_widget_set_sensitive(dialogGameFindUs, TRUE);
    }
  }
  return FALSE;
}
Exemplo n.º 7
0
gint xmlrpc_get_integer(gchar *addr,
                               gchar *method,
                               const gchar *param_types,
                               ...)
{
    gint integer;
    GValueArray *params;
    SoupMessage *msg;
    gchar *body;

    msg = soup_message_new("POST", addr);

    params = g_value_array_new(1);
    
    if (param_types && *param_types) {
        va_list ap;

        va_start(ap, param_types);
        while (*param_types) {
            switch (*param_types) {
            case '%':
              break;
            case 'i':
              soup_value_array_append(params, G_TYPE_INT, va_arg(ap, int));
              break;
            case 's':
            default:
              soup_value_array_append(params, G_TYPE_STRING, va_arg(ap, char *));
              break;
            }
            
            param_types++;
        }
        
        va_end(ap);
    }

    body = soup_xmlrpc_build_method_call(method, params->values, params->n_values);
    g_value_array_free(params);

    soup_message_set_request(msg, "text/xml",
			     SOUP_MEMORY_TAKE, body, strlen(body));
    
    while (lock)
      g_main_iteration(FALSE);

    lock = TRUE;
    soup_session_queue_message(session, msg, xmlrpc_response_get_integer, &integer);
    g_main_run(loop);
    
    return integer;
}
Exemplo n.º 8
0
static int
perform_one_op(os_handler_t   *os_hnd,
	       struct timeval *timeout)
{
    /* Note that this is not technically 100% correct in a
       multi-threaded environment, since another thread may run
       it, but it is pretty close, I guess. */
    int   time_ms = (timeout->tv_sec * 1000) + ((timeout->tv_usec+500) / 1000);
    guint guid = g_timeout_add(time_ms, timeout_callback, NULL);
    g_main_iteration(TRUE);
    g_source_remove(guid);
    return 0;
}
Exemplo n.º 9
0
void engine_poll ()
{
	static int poll_count = 0;
	if (++poll_count == 100)
	{
		poll_count = 0;
		// listen for input in the pipe
		while (g_main_iteration (FALSE))
			;
		// execute pending commands
		// we execute only ONE command so that if there is a CANCEL_MOVE followed by a MAKE_MOVE we won't start on the new move before finishing this one
		process_line ();
	}
}
Exemplo n.º 10
0
/*********************************************************
*NAME:          dialogGameFinderRefresh
*AUTHOR:        John Morrison
*Creation Date: 18/1/00
*Last Modified: 18/1/00
*PURPOSE:
* Refreshs the list of active games.
*
*ARGUMENTS:
*  hWnd   - Handle to the window
*********************************************************/
gboolean dialogGameFinderRefresh(GtkWidget *widget,  GdkEventButton *event, gpointer user_data) {
//  SetCursor(LoadCursor(NULL, IDC_WAIT));
  motd[0] = '\0';
 
  gtk_widget_set_sensitive (button4, FALSE);
  gtk_widget_set_sensitive (button2, FALSE);
  gtk_widget_set_sensitive (button7, FALSE);
  gtk_widget_set_sensitive (button6, FALSE);
  gtk_widget_set_sensitive (button1, FALSE);
  gtk_widget_set_sensitive (button9, FALSE);
  gtk_widget_set_sensitive (button8, FALSE);

  gdk_threads_leave();
  while(g_main_iteration(FALSE));
  gdk_threads_enter();
 
  dialogGameFinderClear();
  currentGamesDestroy(&cg);
  cg = currentGamesCreate();
  dialogGameFinderSearch();
//  SetCursor(LoadCursor(NULL, IDC_ARROW));


  gtk_widget_set_sensitive (button4, TRUE);
  gtk_widget_set_sensitive (button2, TRUE);
  gtk_widget_set_sensitive (button7, TRUE);
  gtk_widget_set_sensitive (button6, TRUE);
  gtk_widget_set_sensitive (button8, TRUE);
  
  if (useTracker == TRUE) {
    gtk_widget_set_sensitive (button1, TRUE);
    gtk_widget_set_sensitive (button9, TRUE);
  }

  
  
  
  return FALSE;
}
Exemplo n.º 11
0
static void
rcd_transaction_verification (RCDTransaction *transaction)
{
    RCPackman *packman = rc_packman_get_global ();
    GError *err = NULL;
    RCPackageSList *iter;

    if (rcd_transaction_is_locked ()) {
        g_set_error (&err,
                     RCD_TRANSACTION_ERROR_DOMAIN,
                     RCD_TRANSACTION_ERROR_TRANSACTION,
                     "Another transaction is already in progress");
        goto ERROR;
    }

    rcd_transaction_lock ();
    transaction->locked = TRUE;

    for (iter = transaction->install_packages; iter; iter = iter->next) {
        RCPackage *package = iter->data;
        char *msg;
        RCVerificationSList *vers;
        RCVerificationStatus worst_status = RC_VERIFICATION_STATUS_PASS;
        gboolean gpg_attempted = FALSE;
        GSList *v;
        
        if (rc_package_is_synthetic (package))
            continue;

        /* Flush the main loop queue for maximum responsivity */
        while (g_main_pending ())
            g_main_iteration (TRUE);

        msg = g_strconcat ("verify:", g_quark_to_string (package->spec.nameq),
                           NULL);
        rc_pending_add_message (transaction->transaction_pending, msg);
        g_free (msg);

        vers = rc_packman_verify (packman, package,
                                  RC_VERIFICATION_TYPE_ALL);

        if (rc_packman_get_error (packman)) {
            g_set_error (&err,
                         RCD_TRANSACTION_ERROR_DOMAIN,
                         RCD_TRANSACTION_ERROR_TRANSACTION,
                         "%s", rc_packman_get_reason (packman));
            goto ERROR;
        }

        for (v = vers; v; v = v->next) {
            RCVerification *ver = v->data;

            if (worst_status > ver->status)
                worst_status = ver->status;

            if (ver->type == RC_VERIFICATION_TYPE_GPG)
                gpg_attempted = TRUE;
        }

        rc_verification_slist_free (vers);

        if (worst_status == RC_VERIFICATION_STATUS_FAIL) {
            rc_debug (RC_DEBUG_LEVEL_MESSAGE,
                      "Verification of '%s' failed",
                      g_quark_to_string (package->spec.nameq));

            g_set_error (&err,
                         RCD_TRANSACTION_ERROR_DOMAIN,
                         RCD_TRANSACTION_ERROR_TRANSACTION,
                         "Verification of '%s' failed",
                         g_quark_to_string (package->spec.nameq));
            goto ERROR;
        }
        else if (worst_status == RC_VERIFICATION_STATUS_UNDEF ||
                 !gpg_attempted)
        {
            char *status_msg;
            gboolean is_trusted;

            if (!gpg_attempted) {
                msg =
                    g_strdup_printf ("Package '%s' is not signed",
                                     g_quark_to_string (package->spec.nameq));
            }
            else {
                msg =
                    g_strdup_printf ("Unable to verify package signature "
                                     "for '%s'",
                                     g_quark_to_string (package->spec.nameq));
            }

            rc_debug (RC_DEBUG_LEVEL_MESSAGE, msg);
        
            is_trusted = rcd_identity_approve_action (
                transaction->client_identity,
                rcd_privileges_from_string ("trusted"));

            if (is_trusted) {
                status_msg = g_strconcat (
                    gpg_attempted ? "verify-undef:" : "verify-nosig:",
                    g_quark_to_string (package->spec.nameq),
                    "; package will be installed because user is trusted",
                    NULL);
            }
            else {
                status_msg = g_strconcat (
                    gpg_attempted ? "verify-undef:" : "verify-nosig:",
                    g_quark_to_string (package->spec.nameq),
                    NULL);
            }

            rc_pending_add_message (transaction->transaction_pending,
                                     status_msg);
            g_free (status_msg);

            if (!is_trusted && rcd_prefs_get_require_signed_packages ()) {
                g_set_error (&err,
                             RCD_TRANSACTION_ERROR_DOMAIN,
                             RCD_TRANSACTION_ERROR_TRANSACTION,
                             "%s; verified package signatures are required "
                             "for installation",
                             msg);

                g_free (msg);
                goto ERROR;
            }

            g_free (msg);
        }
    }

    if (rcd_prefs_get_filesystem_check_timeout () > 0) {
        rcd_transaction_check_fs (transaction);
    } else {
        /* Skip the filesystem check and run the transaction directly.  */
        rcd_transaction_transaction (transaction);
    }
    
    return;

ERROR:
    rcd_transaction_failed (transaction, transaction->transaction_pending,
                            err->message);
    g_error_free (err);
}
Exemplo n.º 12
0
static void
operation_loop(os_handler_t *os_hnd)
{
    for (;;)
	g_main_iteration(TRUE);
}
Exemplo n.º 13
0
int main(int argc, char **argv)
{
	static int version = 0;
	static GOptionEntry options[] = {
		{ "dummy", 'd', 0, G_OPTION_ARG_NONE, &dummy, "Use the dummy terminal mode", NULL },
		{ "version", 'v', 0, G_OPTION_ARG_NONE, &version, "Display irssi version", NULL },
		{ NULL }
	};

#ifdef USE_GC
	g_mem_set_vtable(&gc_mem_table);
#endif

	core_register_options();
	fe_common_core_register_options();
	args_register(options);
	args_execute(argc, argv);

 	if (version) {
		printf(PACKAGE_TARNAME" " PACKAGE_VERSION" (%d %04d)\n",
		       IRSSI_VERSION_DATE, IRSSI_VERSION_TIME);
		return 0;
	}

	srand(time(NULL));

	dummy = FALSE;
	quitting = FALSE;
	core_preinit(argv[0]);

	check_files();

#ifdef WIN32
        winsock_init();
#endif
#ifdef HAVE_SOCKS
	SOCKSinit(argv[0]);
#endif

	/* setlocale() must be called at the beginning before any calls that
	   affect it, especially regexps seem to break if they're generated
	   before this call.

	   locales aren't actually used for anything else than autodetection
	   of UTF-8 currently..  

	   furthermore to get the users's charset with g_get_charset() properly 
	   you have to call setlocale(LC_ALL, "") */
	setlocale(LC_ALL, "");

	textui_init();

	if (!dummy && !term_init()) {
		fprintf(stderr, "Can't initialize screen handling, quitting.\n");
		fprintf(stderr, "You can still use the dummy mode with -d parameter\n");
		return 1;
	}

	textui_finish_init();
	main_loop = g_main_new(TRUE);

	/* Does the same as g_main_run(main_loop), except we
	   can call our dirty-checker after each iteration */
	while (!quitting) {
#ifdef USE_GC
		GC_collect_a_little();
#endif
		if (!dummy) term_refresh_freeze();
		g_main_iteration(TRUE);
                if (!dummy) term_refresh_thaw();

		if (reload_config) {
                        /* SIGHUP received, do /RELOAD */
			reload_config = FALSE;
                        signal_emit("command reload", 1, "");
		}

		dirty_check();
	}

	g_main_destroy(main_loop);
	textui_deinit();

        session_upgrade(); /* if we /UPGRADEd, start the new process */
	return 0;
}
Exemplo n.º 14
0
int main(int argc, char **argv)
{
	static int version = 0;
	static GOptionEntry options[] = {
		{ "version", 'v', 0, G_OPTION_ARG_NONE, &version, "Display Irssi version", NULL },
		{ NULL }
	};
	int loglev;

	core_register_options();
	fe_common_core_register_options();
	args_register(options);
	args_execute(argc, argv);

 	if (version) {
		printf(PACKAGE_TARNAME" " PACKAGE_VERSION" (%d %04d)\n",
		       IRSSI_VERSION_DATE, IRSSI_VERSION_TIME);
		return 0;
	}

	srand(time(NULL));

	quitting = FALSE;
	core_preinit(argv[0]);

	check_files();

#ifdef HAVE_SOCKS
	SOCKSinit(argv[0]);
#endif

	/* setlocale() must be called at the beginning before any calls that
	   affect it, especially regexps seem to break if they're generated
	   before this call.

	   locales aren't actually used for anything else than autodetection
	   of UTF-8 currently..

	   furthermore to get the users's charset with g_get_charset() properly
	   you have to call setlocale(LC_ALL, "") */
	setlocale(LC_ALL, "");

	/* Temporarily raise the fatal level to abort on config errors. */
	loglev = g_log_set_always_fatal(G_LOG_FATAL_MASK | G_LOG_LEVEL_CRITICAL);
	textui_init();

	if (!term_init()) {
		fprintf(stderr, "Can't initialize screen handling.\n");
		return 1;
	}

	g_log_set_always_fatal(loglev);
	textui_finish_init();
	main_loop = g_main_new(TRUE);

	/* Does the same as g_main_run(main_loop), except we
	   can call our dirty-checker after each iteration */
	while (!quitting) {
		if (reload_config) {
			/* SIGHUP received, do /RELOAD */
			reload_config = FALSE;
			signal_emit("command reload", 1, "");
		}

		dirty_check();

		term_refresh_freeze();
		g_main_iteration(TRUE);
		term_refresh_thaw();
	}

	g_main_destroy(main_loop);
	textui_deinit();

	session_upgrade(); /* if we /UPGRADEd, start the new process */
	return 0;
}
Exemplo n.º 15
0
int main(int argc, char **argv)
{
	static struct poptOption options[] = {
		{ "dummy", 'd', POPT_ARG_NONE, &dummy, 0, "Use the dummy terminal mode", NULL },
		{ NULL, '\0', 0, NULL }
	};

	dummy = FALSE;
	quitting = FALSE;
	core_init_paths(argc, argv);

	check_files();

#ifdef WIN32
        winsock_init();
#endif
#ifdef HAVE_SOCKS
	SOCKSinit(argv[0]);
#endif
#ifdef ENABLE_NLS
	/* initialize the i18n stuff */
	bindtextdomain(PACKAGE, LOCALEDIR);
	textdomain(PACKAGE);
#endif

	/* setlocale() must be called at the beginning before any calls that
	   affect it, especially regexps seem to break if they're generated
	   before t his call.

	   locales aren't actually used for anything else than autodetection
	   of UTF-8 currently.. */
	setlocale(LC_CTYPE, "");

	textui_init();
	args_register(options);
	args_execute(argc, argv);

	if (!dummy && !term_init()) {
		fprintf(stderr, "Can't initialize screen handling, quitting.\n");
		fprintf(stderr, "You can still use the dummy mode with -d parameter\n");
		return 1;
	}

	textui_finish_init();
	main_loop = g_main_new(TRUE);

	/* Does the same as g_main_run(main_loop), except we
	   can call our dirty-checker after each iteration */
	while (!quitting) {
                if (!dummy) term_refresh_freeze();
		g_main_iteration(TRUE);
                if (!dummy) term_refresh_thaw();

		if (reload_config) {
                        /* SIGHUP received, do /RELOAD */
			reload_config = FALSE;
                        signal_emit("command reload", 1, "");
		}

		dirty_check();
	}

	g_main_destroy(main_loop);
	textui_deinit();

        session_upgrade(); /* if we /UPGRADEd, start the new process */
	return 0;
}