static void chatroom_set_property (GObject *object, guint param_id, const GValue *value, GParamSpec *pspec) { EmpathyChatroomPriv *priv; priv = GET_PRIV (object); switch (param_id) { case PROP_ACCOUNT: empathy_chatroom_set_account (EMPATHY_CHATROOM (object), g_value_get_object (value)); break; case PROP_ROOM: empathy_chatroom_set_room (EMPATHY_CHATROOM (object), g_value_get_string (value)); break; case PROP_NAME: empathy_chatroom_set_name (EMPATHY_CHATROOM (object), g_value_get_string (value)); break; case PROP_AUTO_CONNECT: empathy_chatroom_set_auto_connect (EMPATHY_CHATROOM (object), g_value_get_boolean (value)); break; case PROP_FAVORITE: empathy_chatroom_set_favorite (EMPATHY_CHATROOM (object), g_value_get_boolean (value)); break; case PROP_TP_CHAT: empathy_chatroom_set_tp_chat (EMPATHY_CHATROOM (object), g_value_get_object (value)); break; case PROP_SUBJECT: empathy_chatroom_set_subject (EMPATHY_CHATROOM (object), g_value_get_string (value)); break; case PROP_MEMBERS_COUNT: empathy_chatroom_set_members_count (EMPATHY_CHATROOM (object), g_value_get_uint (value)); break; case PROP_NEED_PASSWORD: empathy_chatroom_set_need_password (EMPATHY_CHATROOM (object), g_value_get_boolean (value)); break; case PROP_INVITE_ONLY: empathy_chatroom_set_invite_only (EMPATHY_CHATROOM (object), g_value_get_boolean (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; }; }
static void chatroom_manager_parse_chatroom (EmpathyChatroomManager *manager, xmlNodePtr node) { EmpathyChatroom *chatroom = NULL; TpAccount *account; xmlNodePtr child; gchar *str; gchar *name; gchar *room; gchar *account_id; gboolean auto_connect; gboolean always_urgent; EmpathyClientFactory *factory; GError *error = NULL; /* default values. */ name = NULL; room = NULL; auto_connect = TRUE; always_urgent = FALSE; account_id = NULL; for (child = node->children; child; child = child->next) { gchar *tag; if (xmlNodeIsText (child)) continue; tag = (gchar *) child->name; str = (gchar *) xmlNodeGetContent (child); if (strcmp (tag, "name") == 0) { name = g_strdup (str); } else if (strcmp (tag, "room") == 0) { room = g_strdup (str); } else if (strcmp (tag, "auto_connect") == 0) { if (strcmp (str, "yes") == 0) auto_connect = TRUE; else auto_connect = FALSE; } else if (!tp_strdiff (tag, "always_urgent")) { if (strcmp (str, "yes") == 0) always_urgent = TRUE; else always_urgent = FALSE; } else if (strcmp (tag, "account") == 0) { account_id = g_strdup (str); } xmlFree (str); } /* account has to be a valid Account object path */ if (!tp_dbus_check_valid_object_path (account_id, NULL) || !g_str_has_prefix (account_id, TP_ACCOUNT_OBJECT_PATH_BASE)) goto out; factory = empathy_client_factory_dup (); account = tp_simple_client_factory_ensure_account ( TP_SIMPLE_CLIENT_FACTORY (factory), account_id, NULL, &error); g_object_unref (factory); if (account == NULL) { DEBUG ("Failed to create account: %s", error->message); g_error_free (error); g_free (name); g_free (room); g_free (account_id); return; } chatroom = empathy_chatroom_new_full (account, room, name, auto_connect); empathy_chatroom_set_favorite (chatroom, TRUE); empathy_chatroom_set_always_urgent (chatroom, always_urgent); add_chatroom (manager, chatroom); g_signal_emit (manager, signals[CHATROOM_ADDED], 0, chatroom); out: g_free (name); g_free (room); g_free (account_id); tp_clear_object (&chatroom); }
static void chatroom_manager_parse_chatroom (EmpathyChatroomManager *manager, xmlNodePtr node) { EmpathyChatroomManagerPriv *priv; EmpathyChatroom *chatroom; EmpathyAccount *account; xmlNodePtr child; gchar *str; gchar *name; gchar *room; gchar *account_id; gboolean auto_connect; priv = GET_PRIV (manager); /* default values. */ name = NULL; room = NULL; auto_connect = TRUE; account_id = NULL; for (child = node->children; child; child = child->next) { gchar *tag; if (xmlNodeIsText (child)) { continue; } tag = (gchar *) child->name; str = (gchar *) xmlNodeGetContent (child); if (strcmp (tag, "name") == 0) { name = g_strdup (str); } else if (strcmp (tag, "room") == 0) { room = g_strdup (str); } else if (strcmp (tag, "auto_connect") == 0) { if (strcmp (str, "yes") == 0) { auto_connect = TRUE; } else { auto_connect = FALSE; } } else if (strcmp (tag, "account") == 0) { account_id = g_strdup (str); } xmlFree (str); } account = empathy_account_manager_get_account (priv->account_manager, account_id); if (!account) { g_free (name); g_free (room); g_free (account_id); return; } chatroom = empathy_chatroom_new_full (account, room, name, auto_connect); empathy_chatroom_set_favorite (chatroom, TRUE); add_chatroom (manager, chatroom); g_signal_emit (manager, signals[CHATROOM_ADDED], 0, chatroom); g_free (name); g_free (room); g_free (account_id); }