示例#1
0
static void
cb_user_stream_init (CbUserStream *self)
{
  self->receivers = g_ptr_array_new ();
  self->data = g_string_new (NULL);
  self->restarting = FALSE;
  self->state = STATE_STOPPED;

  if (self->stresstest)
    {
      self->proxy = oauth_proxy_new ("0rvHLdbzRULZd5dz6X1TUA",
                                     "oGrvd6654nWLhzLcJywSW3pltUfkhP4BnraPPVNhHtY",
                                     "https://stream.twitter.com/",
                                     FALSE);
    }
  else
    {
      /* TODO: We should be getting these from the settings */
      self->proxy = oauth_proxy_new ("0rvHLdbzRULZd5dz6X1TUA",
                                     "oGrvd6654nWLhzLcJywSW3pltUfkhP4BnraPPVNhHtY",
                                     "https://userstream.twitter.com/",
                                     FALSE);
    }
  self->proxy_data_set = FALSE;

  self->network_monitor = g_network_monitor_get_default ();
  self->network_available = g_network_monitor_get_network_available (self->network_monitor);
  self->network_changed_id = g_signal_connect (self->network_monitor,
                                               "network-changed",
                                               G_CALLBACK (network_changed_cb), self);

  if (!self->network_available)
    start_network_timeout (self);
}
示例#2
0
static void
get_network_available (GNetworkMonitor *monitor,
		       gboolean         available,
		       GeditApp        *app)
{
	gboolean enable;
	GList *windows, *w;

	enable = g_network_monitor_get_network_available (monitor);

	windows = gtk_application_get_windows (GTK_APPLICATION (app));

	for (w = windows; w != NULL; w = w->next)
	{
		GeditWindow *window = GEDIT_WINDOW (w->data);

		if (GEDIT_IS_WINDOW (window))
		{
			GList *tabs, *t;

			tabs = _gedit_window_get_all_tabs (window);

			for (t = tabs; t != NULL; t = t->next)
			{
				_gedit_tab_set_network_available (GEDIT_TAB (t->data),
					                          enable);
			}

			g_list_free (tabs);
		}
	}
}
void NetworkStateNotifier::updateState()
{	
	if(!m_monitor)
		return;

 	m_isOnLine = g_network_monitor_get_network_available(m_monitor); 	
 	notifyNetworkStateChange();
}
示例#4
0
文件: applet.c 项目: babycaseny/abrt
static void connectivity_changed_cb(GObject    *gobject,
                                    GParamSpec *pspec,
                                    gpointer    user_data)
{
    if (g_network_monitor_get_network_available(netmon) &&
        g_network_monitor_get_connectivity(netmon) == G_NETWORK_CONNECTIVITY_FULL)
    {
        if (g_deferred_timeout)
            g_source_remove(g_deferred_timeout);

        g_deferred_timeout = g_idle_add ((GSourceFunc)process_deferred_queue_timeout_fn, NULL);
    }
}
void
soundmenu_lastfm_init (SoundmenuLastfm *lastfm)
{
#if GLIB_CHECK_VERSION(2,32,0)
	if (g_network_monitor_get_network_available (g_network_monitor_get_default ()))
#else
	if(nm_is_online () == TRUE)
#endif
		g_idle_add (soundmenu_lastfm_connect_idle, lastfm);
	else
		g_timeout_add_seconds_full (G_PRIORITY_DEFAULT_IDLE, 30,
		                            soundmenu_lastfm_connect_idle, lastfm,
		                            NULL);
}
static void
sync_visibility (GisGoaPage *page)
{
  GisGoaPagePrivate *priv = gis_goa_page_get_instance_private (page);
  GisAssistant *assistant = gis_driver_get_assistant (GIS_PAGE (page)->driver);
  GNetworkMonitor *network_monitor = g_network_monitor_get_default ();
  gboolean visible;

  if (gis_assistant_get_current_page (assistant) == GIS_PAGE (page))
    return;

  visible = (priv->accounts_exist || g_network_monitor_get_network_available (network_monitor));
  gtk_widget_set_visible (GTK_WIDGET (page), visible);
}
示例#7
0
int
main(int argv, char **argc)
{
	GNetworkMonitor	       *nmon;
	gboolean		up;

	g_type_init();
	nmon = g_network_monitor_get_default();
	g_signal_connect(nmon, "network-changed", G_CALLBACK(network_status_changed_callback), NULL);

	printf("pkgng version: %s\n", PKGVERSION);
	printf("packagekit version: %i.%i.%i\n", PK_MAJOR_VERSION, PK_MINOR_VERSION, PK_MICRO_VERSION);
	printf("network: %s\n", ((g_network_monitor_get_network_available(nmon) == TRUE) ? "up" : "down"));
	
	for(;;)
		;
	return 0;
}
示例#8
0
void
gclue_locator_start (GClueLocator        *locator,
                     GCancellable        *cancellable,
                     GAsyncReadyCallback  callback,
                     gpointer             user_data)
{
        GSimpleAsyncResult *simple;
        GNetworkMonitor *monitor;

        g_return_if_fail (GCLUE_IS_LOCATOR (locator));

        if (locator->priv->network_changed_id)
                return; /* Already started */

        locator->priv->ipclient = gclue_ipclient_new ();
        g_object_set (locator->priv->ipclient,
                      "server", "http://freegeoip.net/json/",
                      "compatibility-mode", TRUE,
                      NULL);

        monitor = g_network_monitor_get_default ();
        locator->priv->network_changed_id =
                g_signal_connect (monitor,
                                  "network-changed",
                                  G_CALLBACK (on_network_changed),
                                  locator);

        if (g_network_monitor_get_network_available (monitor))
                on_network_changed (monitor, TRUE, locator);

        simple = g_simple_async_result_new (G_OBJECT (locator),
                                            callback,
                                            user_data,
                                            gclue_locator_start);
        g_simple_async_result_complete_in_idle (simple);

        g_object_unref (simple);
}
示例#9
0
static gboolean
network_cb (gpointer user_data)
{
  CbUserStream *self = user_data;
  gboolean available;

  if (self->state == STATE_RUNNING)
    {
      self->network_timeout_id = 0;
      return G_SOURCE_REMOVE;
    }

  available = g_network_monitor_get_network_available (self->network_monitor);

  if (available)
    {
      g_debug ("%u Restarting stream (reason: network available (timeout))", self->state);
      self->network_timeout_id = 0;
      cb_user_stream_restart (self);
      return G_SOURCE_REMOVE;
    }

  return G_SOURCE_CONTINUE;
}
示例#10
0
文件: applet.c 项目: babycaseny/abrt
static bool is_networking_enabled(void)
{
    if (!g_network_monitor_get_network_available(netmon))
        return FALSE;
    return g_network_monitor_get_connectivity(netmon) == G_NETWORK_CONNECTIVITY_FULL;
}
示例#11
0
static void
gbp_flatpak_download_stage_query (IdeBuildStage    *stage,
                                  IdeBuildPipeline *pipeline,
                                  GCancellable     *cancellable)
{
  GbpFlatpakDownloadStage *self = (GbpFlatpakDownloadStage *)stage;
  IdeConfiguration *config;
  GNetworkMonitor *monitor;
  g_autofree gchar *staging_dir = NULL;
  g_autofree gchar *manifest_path = NULL;
  g_autofree gchar *stop_at_option = NULL;
  const gchar *src_dir;
  const gchar *primary_module;

  g_assert (GBP_IS_FLATPAK_DOWNLOAD_STAGE (self));
  g_assert (IDE_IS_BUILD_PIPELINE (pipeline));
  g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));

  config = ide_build_pipeline_get_configuration (pipeline);
  if (!GBP_IS_FLATPAK_CONFIGURATION (config))
    {
      ide_build_stage_set_completed (stage, TRUE);
      return;
    }

  if (self->invalid)
    {
      g_autoptr(IdeSubprocessLauncher) launcher = NULL;

      primary_module = gbp_flatpak_configuration_get_primary_module (GBP_FLATPAK_CONFIGURATION (config));
      manifest_path = gbp_flatpak_configuration_get_manifest_path (GBP_FLATPAK_CONFIGURATION (config));
      staging_dir = gbp_flatpak_get_staging_dir (config);
      src_dir = ide_build_pipeline_get_srcdir (pipeline);

      launcher = ide_subprocess_launcher_new (G_SUBPROCESS_FLAGS_STDOUT_PIPE |
                                              G_SUBPROCESS_FLAGS_STDERR_PIPE);

      ide_subprocess_launcher_set_run_on_host (launcher, TRUE);
      ide_subprocess_launcher_set_clear_env (launcher, FALSE);
      ide_subprocess_launcher_set_cwd (launcher, src_dir);

      ide_subprocess_launcher_push_argv (launcher, "flatpak-builder");
      ide_subprocess_launcher_push_argv (launcher, "--ccache");
      ide_subprocess_launcher_push_argv (launcher, "--force-clean");
      if (!dzl_str_empty0 (self->state_dir))
        {
          ide_subprocess_launcher_push_argv (launcher, "--state-dir");
          ide_subprocess_launcher_push_argv (launcher, self->state_dir);
        }
      ide_subprocess_launcher_push_argv (launcher, "--download-only");
      if (!self->force_update)
        ide_subprocess_launcher_push_argv (launcher, "--disable-updates");
      stop_at_option = g_strdup_printf ("--stop-at=%s", primary_module);
      ide_subprocess_launcher_push_argv (launcher, stop_at_option);
      ide_subprocess_launcher_push_argv (launcher, staging_dir);
      ide_subprocess_launcher_push_argv (launcher, manifest_path);

      ide_build_stage_launcher_set_launcher (IDE_BUILD_STAGE_LAUNCHER (self), launcher);
      ide_build_stage_set_completed (stage, FALSE);

      self->invalid = FALSE;
      self->force_update = FALSE;
    }

  /* Ignore downloads if there is no connection */
  monitor = g_network_monitor_get_default ();
  if (!g_network_monitor_get_network_available (monitor))
    {
      ide_build_stage_log (stage,
                           IDE_BUILD_LOG_STDOUT,
                           _("Network is not available, skipping downloads"),
                           -1);
      ide_build_stage_set_completed (stage, TRUE);
    }
}