comparison src/protocols/msn/user.c @ 5363:ebebc833cf77

[gaim-migrate @ 5739] You can now set your home, work, and mobile phone numbers. Trust me, I'm going somewhere with all this. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Tue, 13 May 2003 08:03:27 +0000
parents d5690ed70085
children ad9887c91a59
comparison
equal deleted inserted replaced
5362:a206742d470d 5363:ebebc833cf77
70 msn_users_remove(user->session->users, user); 70 msn_users_remove(user->session->users, user);
71 71
72 if (user->clientinfo != NULL) 72 if (user->clientinfo != NULL)
73 g_hash_table_destroy(user->clientinfo); 73 g_hash_table_destroy(user->clientinfo);
74 74
75 if (user->passport != NULL) g_free(user->passport);
76 if (user->name != NULL) g_free(user->name);
77
78 if (user->phone.home != NULL) g_free(user->phone.home);
79 if (user->phone.work != NULL) g_free(user->phone.work);
80 if (user->phone.mobile != NULL) g_free(user->phone.mobile);
81
82 g_free(user);
83 }
84
85 MsnUser *
86 msn_user_ref(MsnUser *user)
87 {
88 g_return_val_if_fail(user != NULL, NULL);
89
90 user->ref_count++;
91
92 return user;
93 }
94
95 MsnUser *
96 msn_user_unref(MsnUser *user)
97 {
98 g_return_val_if_fail(user != NULL, NULL);
99
100 if (user->ref_count <= 0)
101 return NULL;
102
103 user->ref_count--;
104
105 if (user->ref_count == 0) {
106 msn_user_destroy(user);
107
108 return NULL;
109 }
110
111 return user;
112 }
113
114 void
115 msn_user_set_passport(MsnUser *user, const char *passport)
116 {
117 g_return_if_fail(user != NULL);
118
75 if (user->passport != NULL) 119 if (user->passport != NULL)
76 g_free(user->passport); 120 g_free(user->passport);
77 121
122 user->passport = g_strdup(passport);
123 }
124
125 void
126 msn_user_set_name(MsnUser *user, const char *name)
127 {
128 g_return_if_fail(user != NULL);
129
78 if (user->name != NULL) 130 if (user->name != NULL)
79 g_free(user->name); 131 g_free(user->name);
80 132
81 g_free(user);
82 }
83
84 MsnUser *
85 msn_user_ref(MsnUser *user)
86 {
87 g_return_val_if_fail(user != NULL, NULL);
88
89 user->ref_count++;
90
91 return user;
92 }
93
94 MsnUser *
95 msn_user_unref(MsnUser *user)
96 {
97 g_return_val_if_fail(user != NULL, NULL);
98
99 if (user->ref_count <= 0)
100 return NULL;
101
102 user->ref_count--;
103
104 if (user->ref_count == 0) {
105 msn_user_destroy(user);
106
107 return NULL;
108 }
109
110 return user;
111 }
112
113 void
114 msn_user_set_passport(MsnUser *user, const char *passport)
115 {
116 g_return_if_fail(user != NULL);
117
118 if (user->passport != NULL)
119 g_free(user->passport);
120
121 user->passport = g_strdup(passport);
122 }
123
124 void
125 msn_user_set_name(MsnUser *user, const char *name)
126 {
127 g_return_if_fail(user != NULL);
128
129 if (user->name != NULL)
130 g_free(user->name);
131
132 user->name = g_strdup(name); 133 user->name = g_strdup(name);
133 } 134 }
134 135
135 void 136 void
136 msn_user_set_group_id(MsnUser *user, int id) 137 msn_user_set_group_id(MsnUser *user, int id)
137 { 138 {
138 g_return_if_fail(user != NULL); 139 g_return_if_fail(user != NULL);
139 140
140 user->group_id = id; 141 user->group_id = id;
141 } 142 }
143
144 void
145 msn_user_set_home_phone(MsnUser *user, const char *number)
146 {
147 g_return_if_fail(user != NULL);
148
149 if (user->phone.home != NULL)
150 g_free(user->phone.home);
151
152 user->phone.home = (number == NULL ? NULL : g_strdup(number));
153 }
154
155 void
156 msn_user_set_work_phone(MsnUser *user, const char *number)
157 {
158 g_return_if_fail(user != NULL);
159
160 if (user->phone.work != NULL)
161 g_free(user->phone.work);
162
163 user->phone.work = (number == NULL ? NULL : g_strdup(number));
164 }
165
166 void
167 msn_user_set_mobile_phone(MsnUser *user, const char *number)
168 {
169 g_return_if_fail(user != NULL);
170
171 if (user->phone.mobile != NULL)
172 g_free(user->phone.mobile);
173
174 user->phone.mobile = (number == NULL ? NULL : g_strdup(number));
175 }
176
142 177
143 const char * 178 const char *
144 msn_user_get_passport(const MsnUser *user) 179 msn_user_get_passport(const MsnUser *user)
145 { 180 {
146 g_return_val_if_fail(user != NULL, NULL); 181 g_return_val_if_fail(user != NULL, NULL);
160 msn_user_get_group_id(const MsnUser *user) 195 msn_user_get_group_id(const MsnUser *user)
161 { 196 {
162 g_return_val_if_fail(user != NULL, -1); 197 g_return_val_if_fail(user != NULL, -1);
163 198
164 return user->group_id; 199 return user->group_id;
200 }
201
202 const char *
203 msn_user_get_home_phone(const MsnUser *user)
204 {
205 g_return_val_if_fail(user != NULL, NULL);
206
207 return user->phone.home;
208 }
209
210 const char *
211 msn_user_get_work_phone(const MsnUser *user)
212 {
213 g_return_val_if_fail(user != NULL, NULL);
214
215 return user->phone.work;
216 }
217
218 const char *
219 msn_user_get_mobile_phone(const MsnUser *user)
220 {
221 g_return_val_if_fail(user != NULL, NULL);
222
223 return user->phone.mobile;
165 } 224 }
166 225
167 void 226 void
168 msn_user_set_client_info(MsnUser *user, GHashTable *info) 227 msn_user_set_client_info(MsnUser *user, GHashTable *info)
169 { 228 {