Beispiel #1
0
static void
acc_manager_ready_cb (EmpathyAccountManager *am,
    GParamSpec *pspec,
    gpointer _user_data)
{
  if (!empathy_account_manager_is_ready (am))
    return;

  handle_account_manager_ready ();
}
Beispiel #2
0
static GObject *
empathy_chatroom_manager_constructor (GType type,
                                      guint n_props,
                                      GObjectConstructParam *props)
{
  GObject *obj;
  EmpathyChatroomManager *self;
  EmpathyChatroomManagerPriv *priv;

  if (chatroom_manager_singleton != NULL)
    return g_object_ref (chatroom_manager_singleton);

  /* Parent constructor chain */
  obj = G_OBJECT_CLASS (empathy_chatroom_manager_parent_class)->
        constructor (type, n_props, props);

  self = EMPATHY_CHATROOM_MANAGER (obj);
  priv = GET_PRIV (self);

  priv->ready = FALSE;

  chatroom_manager_singleton = self;
  g_object_add_weak_pointer (obj, (gpointer) &chatroom_manager_singleton);

  priv->account_manager = empathy_account_manager_dup_singleton ();

  priv->account_manager_ready_handler_id = 0;

  if (empathy_account_manager_is_ready (priv->account_manager))
    chatroom_manager_get_all (self);
  else
    priv->account_manager_ready_handler_id =  g_signal_connect (
        G_OBJECT (priv->account_manager), "notify::ready",
        G_CALLBACK (account_manager_ready_cb), self);

  if (priv->file == NULL)
    {
      /* Set the default file path */
      gchar *dir;

      dir = g_build_filename (g_get_user_config_dir (), PACKAGE_NAME, NULL);
      if (!g_file_test (dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))
        g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR);

      priv->file = g_build_filename (dir, CHATROOMS_XML_FILENAME, NULL);
      g_free (dir);
    }

  return obj;
}
Beispiel #3
0
static gboolean
init (NstPlugin *plugin)
{
  g_print ("Init %s plugin\n", plugin->info->id);

  empathy_gtk_init ();

  acc_manager = empathy_account_manager_dup_singleton ();

  if (empathy_account_manager_is_ready (acc_manager))
    handle_account_manager_ready ();
  else
    g_signal_connect (acc_manager, "notify::ready",
        G_CALLBACK (acc_manager_ready_cb), NULL);

  return TRUE;
}
Beispiel #4
0
static void
empathy_idle_init (EmpathyIdle *idle)
{
	EmpathyIdlePriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (idle,
		EMPATHY_TYPE_IDLE, EmpathyIdlePriv);

	idle->priv = priv;
	priv->is_idle = FALSE;

	priv->manager = empathy_account_manager_dup_singleton ();

	if (empathy_account_manager_is_ready (priv->manager)) {
		priv->state = empathy_account_manager_get_global_presence (priv->manager,
			NULL, &priv->status);
	} else {
		g_signal_connect (priv->manager, "notify::ready",
			G_CALLBACK (account_manager_ready_cb), idle);
	}


	g_signal_connect (priv->manager, "global-presence-changed",
		G_CALLBACK (idle_presence_changed_cb), idle);

	priv->gs_proxy = dbus_g_proxy_new_for_name (tp_get_bus (),
						    "org.gnome.SessionManager",
						    "/org/gnome/SessionManager/Presence",
						    "org.gnome.SessionManager.Presence");
	if (priv->gs_proxy) {
		dbus_g_proxy_add_signal (priv->gs_proxy, "StatusChanged",
					 G_TYPE_UINT, G_TYPE_INVALID);
		dbus_g_proxy_connect_signal (priv->gs_proxy, "StatusChanged",
					     G_CALLBACK (idle_session_status_changed_cb),
					     idle, NULL);
	} else {
		DEBUG ("Failed to get gs proxy");
	}

	priv->connectivity = empathy_connectivity_dup_singleton ();
	priv->state_change_signal_id = g_signal_connect (priv->connectivity,
	    "state-change", G_CALLBACK (idle_state_change_cb), idle);
}