Mercurial > pidgin
comparison src/prpl.c @ 13373:1ca4a579eb57
[gaim-migrate @ 15746]
Parts of sf patch #1438833, from Sadrul Habib Chowdhury
"This patch enables removing message-text from a status.
Currently when you have some status with a message, and
you remove the message from the statusbox-entry, the
new status with no message is not used (reported in a
number of bugs, like #1431289, #1431801)."
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 02 Mar 2006 04:51:09 +0000 |
parents | 99d081c638f6 |
children | 8bda65b88e49 |
comparison
equal
deleted
inserted
replaced
13372:fb178093e364 | 13373:1ca4a579eb57 |
---|---|
56 presence = gaim_account_get_presence(account); | 56 presence = gaim_account_get_presence(account); |
57 | 57 |
58 gaim_presence_set_login_time(presence, login_time); | 58 gaim_presence_set_login_time(presence, login_time); |
59 } | 59 } |
60 | 60 |
61 static gboolean | 61 void |
62 set_value_from_arg(GaimStatus *status, const char *id, va_list *args) | 62 gaim_prpl_got_account_status(GaimAccount *account, const char *status_id, ...) |
63 { | |
64 GaimValue *value; | |
65 | |
66 value = gaim_status_get_attr_value(status, id); | |
67 | |
68 if (value == NULL) | |
69 { | |
70 gaim_debug_error("prpl", | |
71 "Attempted to set an unknown attribute %s on " | |
72 "status %s\n", | |
73 id, gaim_status_get_id(status)); | |
74 return FALSE; | |
75 } | |
76 | |
77 switch (gaim_value_get_type(value)) | |
78 { | |
79 case GAIM_TYPE_CHAR: | |
80 gaim_value_set_char(value, (char)va_arg(*args, int)); | |
81 break; | |
82 | |
83 case GAIM_TYPE_UCHAR: | |
84 gaim_value_set_uchar(value, | |
85 (unsigned char)va_arg(*args, unsigned int)); | |
86 break; | |
87 | |
88 case GAIM_TYPE_BOOLEAN: | |
89 gaim_value_set_boolean(value, va_arg(*args, gboolean)); | |
90 break; | |
91 | |
92 case GAIM_TYPE_SHORT: | |
93 gaim_value_set_short(value, (short)va_arg(*args, int)); | |
94 break; | |
95 | |
96 case GAIM_TYPE_USHORT: | |
97 gaim_value_set_ushort(value, | |
98 (unsigned short)va_arg(*args, unsigned int)); | |
99 break; | |
100 | |
101 case GAIM_TYPE_INT: | |
102 gaim_value_set_int(value, va_arg(*args, int)); | |
103 break; | |
104 | |
105 case GAIM_TYPE_UINT: | |
106 gaim_value_set_uint(value, va_arg(*args, unsigned int)); | |
107 break; | |
108 | |
109 case GAIM_TYPE_LONG: | |
110 gaim_value_set_long(value, va_arg(*args, long)); | |
111 break; | |
112 | |
113 case GAIM_TYPE_ULONG: | |
114 gaim_value_set_ulong(value, va_arg(*args, unsigned long)); | |
115 break; | |
116 | |
117 case GAIM_TYPE_INT64: | |
118 gaim_value_set_int64(value, va_arg(*args, gint64)); | |
119 break; | |
120 | |
121 case GAIM_TYPE_UINT64: | |
122 gaim_value_set_uint64(value, va_arg(*args, guint64)); | |
123 break; | |
124 | |
125 case GAIM_TYPE_STRING: | |
126 gaim_value_set_string(value, va_arg(*args, char *)); | |
127 break; | |
128 | |
129 case GAIM_TYPE_OBJECT: | |
130 gaim_value_set_object(value, va_arg(*args, void *)); | |
131 break; | |
132 | |
133 case GAIM_TYPE_POINTER: | |
134 gaim_value_set_pointer(value, va_arg(*args, void *)); | |
135 break; | |
136 | |
137 case GAIM_TYPE_ENUM: | |
138 gaim_value_set_enum(value, va_arg(*args, int)); | |
139 break; | |
140 | |
141 case GAIM_TYPE_BOXED: | |
142 gaim_value_set_boxed(value, va_arg(*args, void *)); | |
143 break; | |
144 | |
145 default: | |
146 return FALSE; | |
147 } | |
148 | |
149 return TRUE; | |
150 } | |
151 | |
152 void | |
153 gaim_prpl_got_account_status(GaimAccount *account, const char *status_id, | |
154 const char *attr_id, ...) | |
155 { | 63 { |
156 GaimPresence *presence; | 64 GaimPresence *presence; |
157 GaimStatus *status; | 65 GaimStatus *status; |
66 va_list args; | |
158 | 67 |
159 g_return_if_fail(account != NULL); | 68 g_return_if_fail(account != NULL); |
160 g_return_if_fail(status_id != NULL); | 69 g_return_if_fail(status_id != NULL); |
161 g_return_if_fail(gaim_account_is_connected(account)); | 70 g_return_if_fail(gaim_account_is_connected(account)); |
162 | 71 |
163 presence = gaim_account_get_presence(account); | 72 presence = gaim_account_get_presence(account); |
164 status = gaim_presence_get_status(presence, status_id); | 73 status = gaim_presence_get_status(presence, status_id); |
165 | 74 |
166 g_return_if_fail(status != NULL); | 75 g_return_if_fail(status != NULL); |
167 | 76 |
168 if (attr_id != NULL) | 77 va_start(args, status_id); |
169 { | 78 gaim_status_set_active_with_attrs(status, TRUE, args); |
170 va_list args; | 79 va_end(args); |
171 | |
172 va_start(args, attr_id); | |
173 | |
174 while (attr_id != NULL) | |
175 { | |
176 set_value_from_arg(status, attr_id, &args); | |
177 | |
178 attr_id = va_arg(args, char *); | |
179 } | |
180 | |
181 va_end(args); | |
182 } | |
183 | |
184 gaim_presence_set_status_active(presence, status_id, TRUE); | |
185 } | 80 } |
186 | 81 |
187 void | 82 void |
188 gaim_prpl_got_user_idle(GaimAccount *account, const char *name, | 83 gaim_prpl_got_user_idle(GaimAccount *account, const char *name, |
189 gboolean idle, time_t idle_time) | 84 gboolean idle, time_t idle_time) |
224 gaim_presence_set_login_time(presence, login_time); | 119 gaim_presence_set_login_time(presence, login_time); |
225 } | 120 } |
226 | 121 |
227 void | 122 void |
228 gaim_prpl_got_user_status(GaimAccount *account, const char *name, | 123 gaim_prpl_got_user_status(GaimAccount *account, const char *name, |
229 const char *status_id, const char *attr_id, ...) | 124 const char *status_id, ...) |
230 { | 125 { |
231 GSList *list, *iter; | 126 GSList *list, *iter; |
232 GaimBuddy *buddy; | 127 GaimBuddy *buddy; |
233 GaimPresence *presence; | 128 GaimPresence *presence; |
234 GaimStatus *status; | 129 GaimStatus *status; |
235 GaimStatus *old_status; | 130 GaimStatus *old_status; |
131 va_list args; | |
236 | 132 |
237 g_return_if_fail(account != NULL); | 133 g_return_if_fail(account != NULL); |
238 g_return_if_fail(name != NULL); | 134 g_return_if_fail(name != NULL); |
239 g_return_if_fail(status_id != NULL); | 135 g_return_if_fail(status_id != NULL); |
240 g_return_if_fail(gaim_account_is_connected(account) || gaim_account_is_connecting(account)); | 136 g_return_if_fail(gaim_account_is_connected(account) || gaim_account_is_connecting(account)); |
245 presence = gaim_buddy_get_presence(buddy); | 141 presence = gaim_buddy_get_presence(buddy); |
246 status = gaim_presence_get_status(presence, status_id); | 142 status = gaim_presence_get_status(presence, status_id); |
247 | 143 |
248 g_return_if_fail(status != NULL); | 144 g_return_if_fail(status != NULL); |
249 | 145 |
250 if (attr_id != NULL) | |
251 { | |
252 va_list args; | |
253 | |
254 va_start(args, attr_id); | |
255 | |
256 while (attr_id != NULL) | |
257 { | |
258 set_value_from_arg(status, attr_id, &args); | |
259 | |
260 attr_id = va_arg(args, char *); | |
261 } | |
262 | |
263 va_end(args); | |
264 } | |
265 | |
266 old_status = gaim_presence_get_active_status(presence); | 146 old_status = gaim_presence_get_active_status(presence); |
267 gaim_presence_set_status_active(presence, status_id, TRUE); | 147 |
148 va_start(args, status_id); | |
149 gaim_status_set_active_with_attrs(status, TRUE, args); | |
150 va_end(args); | |
268 | 151 |
269 list = gaim_find_buddies(account, name); | 152 list = gaim_find_buddies(account, name); |
270 for (iter = list; iter != NULL; iter = iter->next) | 153 for (iter = list; iter != NULL; iter = iter->next) |
271 { | 154 { |
272 buddy = (GaimBuddy *)iter->data; | 155 buddy = (GaimBuddy *)iter->data; |