| 35079:4fb1914491f1 | 35080:58bddd91956c |
|---|---|
| 22 * You should have received a copy of the GNU General Public License | 22 * You should have received a copy of the GNU General Public License |
| 23 * along with this program; if not, write to the Free Software | 23 * along with this program; if not, write to the Free Software |
| 24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA | 24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 25 */ | 25 */ |
| 26 #include "internal.h" | 26 #include "internal.h" |
| 27 #include "glibcompat.h" | |
| 28 | |
| 27 #include "accounts.h" | 29 #include "accounts.h" |
| 28 #include "core.h" | 30 #include "core.h" |
| 29 #include "dbus-maybe.h" | 31 #include "dbus-maybe.h" |
| 30 #include "debug.h" | 32 #include "debug.h" |
| 31 #include "network.h" | 33 #include "network.h" |
| 131 PROP_CHECK_MAIL, | 133 PROP_CHECK_MAIL, |
| 132 PROP_LAST | 134 PROP_LAST |
| 133 }; | 135 }; |
| 134 | 136 |
| 135 static GObjectClass *parent_class = NULL; | 137 static GObjectClass *parent_class = NULL; |
| 138 static GParamSpec *properties[PROP_LAST]; | |
| 136 static GList *handles = NULL; | 139 static GList *handles = NULL; |
| 137 | 140 |
| 138 void _purple_account_set_current_error(PurpleAccount *account, | 141 void _purple_account_set_current_error(PurpleAccount *account, |
| 139 PurpleConnectionErrorInfo *new_err); | 142 PurpleConnectionErrorInfo *new_err); |
| 140 | 143 |
| 740 priv = PURPLE_ACCOUNT_GET_PRIVATE(account); | 743 priv = PURPLE_ACCOUNT_GET_PRIVATE(account); |
| 741 | 744 |
| 742 g_free(priv->username); | 745 g_free(priv->username); |
| 743 priv->username = g_strdup(username); | 746 priv->username = g_strdup(username); |
| 744 | 747 |
| 745 g_object_notify(G_OBJECT(account), "username"); | 748 g_object_notify_by_pspec(G_OBJECT(account), properties[PROP_USERNAME]); |
| 746 | 749 |
| 747 purple_accounts_schedule_save(); | 750 purple_accounts_schedule_save(); |
| 748 | 751 |
| 749 /* if the name changes, we should re-write the buddy list | 752 /* if the name changes, we should re-write the buddy list |
| 750 * to disk with the new name */ | 753 * to disk with the new name */ |
| 800 g_utf8_collate(priv->alias, alias)) | 803 g_utf8_collate(priv->alias, alias)) |
| 801 { | 804 { |
| 802 char *old = priv->alias; | 805 char *old = priv->alias; |
| 803 | 806 |
| 804 priv->alias = g_strdup(alias); | 807 priv->alias = g_strdup(alias); |
| 805 g_object_notify(G_OBJECT(account), "private-alias"); | 808 g_object_notify_by_pspec(G_OBJECT(account), |
| 809 properties[PROP_PRIVATE_ALIAS]); | |
| 806 purple_signal_emit(purple_accounts_get_handle(), "account-alias-changed", | 810 purple_signal_emit(purple_accounts_get_handle(), "account-alias-changed", |
| 807 account, old); | 811 account, old); |
| 808 g_free(old); | 812 g_free(old); |
| 809 | 813 |
| 810 purple_accounts_schedule_save(); | 814 purple_accounts_schedule_save(); |
| 821 priv = PURPLE_ACCOUNT_GET_PRIVATE(account); | 825 priv = PURPLE_ACCOUNT_GET_PRIVATE(account); |
| 822 | 826 |
| 823 g_free(priv->user_info); | 827 g_free(priv->user_info); |
| 824 priv->user_info = g_strdup(user_info); | 828 priv->user_info = g_strdup(user_info); |
| 825 | 829 |
| 826 g_object_notify(G_OBJECT(account), "user-info"); | 830 g_object_notify_by_pspec(G_OBJECT(account), properties[PROP_USER_INFO]); |
| 827 | 831 |
| 828 purple_accounts_schedule_save(); | 832 purple_accounts_schedule_save(); |
| 829 } | 833 } |
| 830 | 834 |
| 831 void purple_account_set_buddy_icon_path(PurpleAccount *account, const char *path) | 835 void purple_account_set_buddy_icon_path(PurpleAccount *account, const char *path) |
| 837 priv = PURPLE_ACCOUNT_GET_PRIVATE(account); | 841 priv = PURPLE_ACCOUNT_GET_PRIVATE(account); |
| 838 | 842 |
| 839 g_free(priv->buddy_icon_path); | 843 g_free(priv->buddy_icon_path); |
| 840 priv->buddy_icon_path = g_strdup(path); | 844 priv->buddy_icon_path = g_strdup(path); |
| 841 | 845 |
| 842 g_object_notify(G_OBJECT(account), "buddy-icon-path"); | 846 g_object_notify_by_pspec(G_OBJECT(account), |
| 847 properties[PROP_BUDDY_ICON_PATH]); | |
| 843 | 848 |
| 844 purple_accounts_schedule_save(); | 849 purple_accounts_schedule_save(); |
| 845 } | 850 } |
| 846 | 851 |
| 847 void | 852 void |
| 855 priv = PURPLE_ACCOUNT_GET_PRIVATE(account); | 860 priv = PURPLE_ACCOUNT_GET_PRIVATE(account); |
| 856 | 861 |
| 857 g_free(priv->protocol_id); | 862 g_free(priv->protocol_id); |
| 858 priv->protocol_id = g_strdup(protocol_id); | 863 priv->protocol_id = g_strdup(protocol_id); |
| 859 | 864 |
| 860 g_object_notify(G_OBJECT(account), "protocol-id"); | 865 g_object_notify_by_pspec(G_OBJECT(account), properties[PROP_PROTOCOL_ID]); |
| 861 | 866 |
| 862 purple_accounts_schedule_save(); | 867 purple_accounts_schedule_save(); |
| 863 } | 868 } |
| 864 | 869 |
| 865 void | 870 void |
| 870 g_return_if_fail(PURPLE_IS_ACCOUNT(account)); | 875 g_return_if_fail(PURPLE_IS_ACCOUNT(account)); |
| 871 | 876 |
| 872 priv = PURPLE_ACCOUNT_GET_PRIVATE(account); | 877 priv = PURPLE_ACCOUNT_GET_PRIVATE(account); |
| 873 priv->gc = gc; | 878 priv->gc = gc; |
| 874 | 879 |
| 875 g_object_notify(G_OBJECT(account), "connection"); | 880 g_object_notify_by_pspec(G_OBJECT(account), properties[PROP_CONNECTION]); |
| 876 } | 881 } |
| 877 | 882 |
| 878 void | 883 void |
| 879 purple_account_set_remember_password(PurpleAccount *account, gboolean value) | 884 purple_account_set_remember_password(PurpleAccount *account, gboolean value) |
| 880 { | 885 { |
| 883 g_return_if_fail(PURPLE_IS_ACCOUNT(account)); | 888 g_return_if_fail(PURPLE_IS_ACCOUNT(account)); |
| 884 | 889 |
| 885 priv = PURPLE_ACCOUNT_GET_PRIVATE(account); | 890 priv = PURPLE_ACCOUNT_GET_PRIVATE(account); |
| 886 priv->remember_pass = value; | 891 priv->remember_pass = value; |
| 887 | 892 |
| 888 g_object_notify(G_OBJECT(account), "remember-password"); | 893 g_object_notify_by_pspec(G_OBJECT(account), |
| 894 properties[PROP_REMEMBER_PASSWORD]); | |
| 889 | 895 |
| 890 purple_accounts_schedule_save(); | 896 purple_accounts_schedule_save(); |
| 891 } | 897 } |
| 892 | 898 |
| 893 void | 899 void |
| 895 { | 901 { |
| 896 g_return_if_fail(PURPLE_IS_ACCOUNT(account)); | 902 g_return_if_fail(PURPLE_IS_ACCOUNT(account)); |
| 897 | 903 |
| 898 purple_account_set_bool(account, "check-mail", value); | 904 purple_account_set_bool(account, "check-mail", value); |
| 899 | 905 |
| 900 g_object_notify(G_OBJECT(account), "check-mail"); | 906 g_object_notify_by_pspec(G_OBJECT(account), properties[PROP_CHECK_MAIL]); |
| 901 } | 907 } |
| 902 | 908 |
| 903 void | 909 void |
| 904 purple_account_set_enabled(PurpleAccount *account, const char *ui, | 910 purple_account_set_enabled(PurpleAccount *account, const char *ui, |
| 905 gboolean value) | 911 gboolean value) |
| 919 if(was_enabled && !value) | 925 if(was_enabled && !value) |
| 920 purple_signal_emit(purple_accounts_get_handle(), "account-disabled", account); | 926 purple_signal_emit(purple_accounts_get_handle(), "account-disabled", account); |
| 921 else if(!was_enabled && value) | 927 else if(!was_enabled && value) |
| 922 purple_signal_emit(purple_accounts_get_handle(), "account-enabled", account); | 928 purple_signal_emit(purple_accounts_get_handle(), "account-enabled", account); |
| 923 | 929 |
| 924 g_object_notify(G_OBJECT(account), "enabled"); | 930 g_object_notify_by_pspec(G_OBJECT(account), properties[PROP_ENABLED]); |
| 925 | 931 |
| 926 if ((gc != NULL) && (_purple_connection_wants_to_die(gc))) | 932 if ((gc != NULL) && (_purple_connection_wants_to_die(gc))) |
| 927 wants_to_die = TRUE; | 933 wants_to_die = TRUE; |
| 928 | 934 |
| 929 priv = PURPLE_ACCOUNT_GET_PRIVATE(account); | 935 priv = PURPLE_ACCOUNT_GET_PRIVATE(account); |
| 3066 | 3072 |
| 3067 /* Setup properties */ | 3073 /* Setup properties */ |
| 3068 obj_class->get_property = purple_account_get_property; | 3074 obj_class->get_property = purple_account_get_property; |
| 3069 obj_class->set_property = purple_account_set_property; | 3075 obj_class->set_property = purple_account_set_property; |
| 3070 | 3076 |
| 3077 properties[PROP_USERNAME] = g_param_spec_string("username", "Username", | |
| 3078 "The username for the account.", NULL, | |
| 3079 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS); | |
| 3071 g_object_class_install_property(obj_class, PROP_USERNAME, | 3080 g_object_class_install_property(obj_class, PROP_USERNAME, |
| 3072 g_param_spec_string("username", "Username", | 3081 properties[PROP_USERNAME]); |
| 3073 "The username for the account.", NULL, | 3082 |
| 3074 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS) | 3083 properties[PROP_PRIVATE_ALIAS] = g_param_spec_string("private-alias", |
| 3075 ); | 3084 "Private Alias", |
| 3076 | 3085 "The private alias for the account.", NULL, |
| 3086 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); | |
| 3077 g_object_class_install_property(obj_class, PROP_PRIVATE_ALIAS, | 3087 g_object_class_install_property(obj_class, PROP_PRIVATE_ALIAS, |
| 3078 g_param_spec_string("private-alias", "Private Alias", | 3088 properties[PROP_PRIVATE_ALIAS]); |
| 3079 "The private alias for the account.", NULL, | 3089 |
| 3080 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS) | 3090 properties[PROP_USER_INFO] = g_param_spec_string("user-info", |
| 3081 ); | 3091 "User information", |
| 3082 | 3092 "Detailed user information for the account.", NULL, |
| 3093 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); | |
| 3083 g_object_class_install_property(obj_class, PROP_USER_INFO, | 3094 g_object_class_install_property(obj_class, PROP_USER_INFO, |
| 3084 g_param_spec_string("user-info", "User information", | 3095 properties[PROP_USER_INFO]); |
| 3085 "Detailed user information for the account.", NULL, | 3096 |
| 3086 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS) | 3097 properties[PROP_BUDDY_ICON_PATH] = g_param_spec_string("buddy-icon-path", |
| 3087 ); | 3098 "Buddy icon path", |
| 3088 | 3099 "Path to the buddyicon for the account.", NULL, |
| 3100 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); | |
| 3089 g_object_class_install_property(obj_class, PROP_BUDDY_ICON_PATH, | 3101 g_object_class_install_property(obj_class, PROP_BUDDY_ICON_PATH, |
| 3090 g_param_spec_string("buddy-icon-path", "Buddy icon path", | 3102 properties[PROP_BUDDY_ICON_PATH]); |
| 3091 "Path to the buddyicon for the account.", NULL, | 3103 |
| 3092 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS) | 3104 properties[PROP_ENABLED] = g_param_spec_boolean("enabled", "Enabled", |
| 3093 ); | 3105 "Whether the account is enabled or not.", FALSE, |
| 3094 | 3106 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
| 3095 g_object_class_install_property(obj_class, PROP_ENABLED, | 3107 g_object_class_install_property(obj_class, PROP_ENABLED, |
| 3096 g_param_spec_boolean("enabled", "Enabled", | 3108 properties[PROP_ENABLED]); |
| 3097 "Whether the account is enabled or not.", FALSE, | 3109 |
| 3098 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS) | 3110 properties[PROP_REMEMBER_PASSWORD] = g_param_spec_boolean( |
| 3099 ); | 3111 "remember-password", "Remember password", |
| 3100 | 3112 "Whether to remember and store the password for this account.", |
| 3113 FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); | |
| 3101 g_object_class_install_property(obj_class, PROP_REMEMBER_PASSWORD, | 3114 g_object_class_install_property(obj_class, PROP_REMEMBER_PASSWORD, |
| 3102 g_param_spec_boolean("remember-password", "Remember password", | 3115 properties[PROP_REMEMBER_PASSWORD]); |
| 3103 "Whether to remember and store the password for this account.", FALSE, | 3116 |
| 3104 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS) | 3117 properties[PROP_CHECK_MAIL] = g_param_spec_boolean("check-mail", |
| 3105 ); | 3118 "Check mail", |
| 3106 | 3119 "Whether to check mails for this account.", FALSE, |
| 3120 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); | |
| 3107 g_object_class_install_property(obj_class, PROP_CHECK_MAIL, | 3121 g_object_class_install_property(obj_class, PROP_CHECK_MAIL, |
| 3108 g_param_spec_boolean("check-mail", "Check mail", | 3122 properties[PROP_CHECK_MAIL]); |
| 3109 "Whether to check mails for this account.", FALSE, | 3123 |
| 3110 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS) | 3124 properties[PROP_CONNECTION] = g_param_spec_object("connection", |
| 3111 ); | 3125 "Connection", |
| 3112 | 3126 "The connection for the account.", PURPLE_TYPE_CONNECTION, |
| 3127 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); | |
| 3113 g_object_class_install_property(obj_class, PROP_CONNECTION, | 3128 g_object_class_install_property(obj_class, PROP_CONNECTION, |
| 3114 g_param_spec_object("connection", "Connection", | 3129 properties[PROP_CONNECTION]); |
| 3115 "The connection for the account.", PURPLE_TYPE_CONNECTION, | 3130 |
| 3116 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS) | 3131 properties[PROP_PROTOCOL_ID] = g_param_spec_string("protocol-id", |
| 3117 ); | 3132 "Protocol ID", |
| 3118 | |
| 3119 g_object_class_install_property(obj_class, PROP_PROTOCOL_ID, | |
| 3120 g_param_spec_string("protocol-id", "Protocol ID", | |
| 3121 "ID of the protocol that is responsible for the account.", NULL, | 3133 "ID of the protocol that is responsible for the account.", NULL, |
| 3122 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | | 3134 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | |
| 3123 G_PARAM_STATIC_STRINGS) | 3135 G_PARAM_STATIC_STRINGS); |
| 3124 ); | 3136 g_object_class_install_property(obj_class, PROP_PROTOCOL_ID, |
| 3137 properties[PROP_PROTOCOL_ID]); | |
| 3125 | 3138 |
| 3126 g_type_class_add_private(klass, sizeof(PurpleAccountPrivate)); | 3139 g_type_class_add_private(klass, sizeof(PurpleAccountPrivate)); |
| 3127 } | 3140 } |
| 3128 | 3141 |
| 3129 GType | 3142 GType |