Mercurial > pidgin
annotate src/protocols/msn/msnobject.c @ 8230:4e354776ae2a
[gaim-migrate @ 8953]
"Well sf seems to be in read only mode.
This patch makes the progress bar in the room list dialog pulse slower.
Previously it pulsed every time a new room was received, and had a pulse
step of 10 until 100 rooms were downloaded, and then switched to a pulse
step of 100.
Now it pulses every time a room is received but no more than once every
100ms. And the pulse step stays constant at 10. This should fix the "my
connection is so far the progress bar is sucking up all my cpu" problem
some lucky individuals have had. Since my connection isn't that fast,
I'm not completely sure how well it works, but it seems good to me.
Simguy tells me it's better.
If you want to test you'll need to download the list on undernet on irc,
or something like that. Other protocols tend to download it too fast to
really see the progress bar.
--Tim Ringenbach"
committer: Tailor Script <tailor@pidgin.im>
| author | Luke Schierer <lschiere@pidgin.im> |
|---|---|
| date | Wed, 11 Feb 2004 22:34:55 +0000 |
| parents | f0784ce8189a |
| children | 06f57183e29f |
| rev | line source |
|---|---|
| 6701 | 1 /** |
| 2 * @file msnobject.c MSNObject API | |
| 3 * | |
| 4 * gaim | |
| 5 * | |
| 6 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> | |
| 7 * | |
| 8 * This program is free software; you can redistribute it and/or modify | |
| 9 * it under the terms of the GNU General Public License as published by | |
| 10 * the Free Software Foundation; either version 2 of the License, or | |
| 11 * (at your option) any later version. | |
| 12 * | |
| 13 * This program is distributed in the hope that it will be useful, | |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 * GNU General Public License for more details. | |
| 17 * | |
| 18 * You should have received a copy of the GNU General Public License | |
| 19 * along with this program; if not, write to the Free Software | |
| 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 21 */ | |
| 22 #include "msnobject.h" | |
| 23 | |
| 24 #define GET_STRING_TAG(field, id) \ | |
| 25 if ((tag = strstr(str, id "=\"")) != NULL) \ | |
| 26 { \ | |
| 27 tag += strlen(id "=\""); \ | |
| 28 c = strchr(tag, '"'); \ | |
|
7933
f0784ce8189a
[gaim-migrate @ 8604]
Christian Hammond <chipx86@chipx86.com>
parents:
6790
diff
changeset
|
29 if (c != NULL) \ |
|
f0784ce8189a
[gaim-migrate @ 8604]
Christian Hammond <chipx86@chipx86.com>
parents:
6790
diff
changeset
|
30 obj->field = g_strndup(tag, c - tag); \ |
| 6701 | 31 } |
| 32 | |
| 33 #define GET_INT_TAG(field, id) \ | |
| 34 if ((tag = strstr(str, id "=\"")) != NULL) \ | |
| 35 { \ | |
| 36 char buf[16]; \ | |
| 37 tag += strlen(id "=\""); \ | |
| 38 c = strchr(tag, '"'); \ | |
|
7933
f0784ce8189a
[gaim-migrate @ 8604]
Christian Hammond <chipx86@chipx86.com>
parents:
6790
diff
changeset
|
39 if (c != NULL) \ |
|
f0784ce8189a
[gaim-migrate @ 8604]
Christian Hammond <chipx86@chipx86.com>
parents:
6790
diff
changeset
|
40 { \ |
|
f0784ce8189a
[gaim-migrate @ 8604]
Christian Hammond <chipx86@chipx86.com>
parents:
6790
diff
changeset
|
41 strncpy(buf, tag, c - tag); \ |
|
f0784ce8189a
[gaim-migrate @ 8604]
Christian Hammond <chipx86@chipx86.com>
parents:
6790
diff
changeset
|
42 obj->field = atoi(buf); \ |
|
f0784ce8189a
[gaim-migrate @ 8604]
Christian Hammond <chipx86@chipx86.com>
parents:
6790
diff
changeset
|
43 } \ |
| 6701 | 44 } |
| 45 | |
| 46 MsnObject * | |
| 47 msn_object_new(void) | |
| 48 { | |
| 49 MsnObject *obj; | |
| 50 | |
| 51 obj = g_new0(MsnObject, 1); | |
| 52 | |
| 53 msn_object_set_type(obj, MSN_OBJECT_UNKNOWN); | |
| 54 msn_object_set_friendly(obj, "AAA="); | |
| 55 | |
| 56 return obj; | |
| 57 } | |
| 58 | |
| 59 MsnObject * | |
| 60 msn_object_new_from_string(const char *str) | |
| 61 { | |
| 62 MsnObject *obj; | |
| 63 char *tag, *c; | |
| 64 | |
| 65 g_return_val_if_fail(str != NULL, NULL); | |
| 66 g_return_val_if_fail(!strncmp(str, "<msnobj ", 8), NULL); | |
| 67 | |
| 68 obj = msn_object_new(); | |
| 69 | |
| 70 GET_STRING_TAG(creator, "Creator"); | |
| 71 GET_INT_TAG(size, "Size"); | |
| 72 GET_INT_TAG(type, "Type"); | |
| 73 GET_STRING_TAG(location, "Location"); | |
| 74 GET_STRING_TAG(friendly, "Friendly"); | |
| 75 GET_STRING_TAG(sha1d, "SHA1D"); | |
| 76 GET_STRING_TAG(sha1c, "SHA1C"); | |
| 77 | |
| 78 return obj; | |
| 79 } | |
| 80 | |
|
6789
94b575afb77e
[gaim-migrate @ 7328]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
81 void |
|
94b575afb77e
[gaim-migrate @ 7328]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
82 msn_object_destroy(MsnObject *obj) |
|
94b575afb77e
[gaim-migrate @ 7328]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
83 { |
|
94b575afb77e
[gaim-migrate @ 7328]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
84 g_return_if_fail(obj != NULL); |
|
94b575afb77e
[gaim-migrate @ 7328]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
85 |
|
94b575afb77e
[gaim-migrate @ 7328]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
86 if (obj->creator != NULL) |
|
94b575afb77e
[gaim-migrate @ 7328]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
87 g_free(obj->creator); |
|
94b575afb77e
[gaim-migrate @ 7328]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
88 |
|
94b575afb77e
[gaim-migrate @ 7328]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
89 if (obj->location != NULL) |
|
94b575afb77e
[gaim-migrate @ 7328]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
90 g_free(obj->location); |
|
94b575afb77e
[gaim-migrate @ 7328]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
91 |
|
94b575afb77e
[gaim-migrate @ 7328]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
92 if (obj->friendly != NULL) |
|
94b575afb77e
[gaim-migrate @ 7328]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
93 g_free(obj->friendly); |
|
94b575afb77e
[gaim-migrate @ 7328]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
94 |
|
94b575afb77e
[gaim-migrate @ 7328]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
95 if (obj->sha1d != NULL) |
|
94b575afb77e
[gaim-migrate @ 7328]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
96 g_free(obj->sha1d); |
|
94b575afb77e
[gaim-migrate @ 7328]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
97 |
|
94b575afb77e
[gaim-migrate @ 7328]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
98 if (obj->sha1c != NULL) |
|
94b575afb77e
[gaim-migrate @ 7328]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
99 g_free(obj->sha1c); |
|
94b575afb77e
[gaim-migrate @ 7328]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
100 |
|
94b575afb77e
[gaim-migrate @ 7328]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
101 g_free(obj); |
|
94b575afb77e
[gaim-migrate @ 7328]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
102 } |
|
94b575afb77e
[gaim-migrate @ 7328]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
103 |
| 6701 | 104 char * |
| 105 msn_object_to_string(const MsnObject *obj) | |
| 106 { | |
| 107 char *str; | |
| 108 | |
| 109 g_return_val_if_fail(obj != NULL, NULL); | |
| 110 | |
| 111 str = g_strdup_printf("<msnobj Creator=\"%s\" Size=\"%d\" Type=\"%d\" " | |
| 112 "Location=\"%s\" Friendly=\"%s\" SHA1D=\"%s\" " | |
| 113 "SHA1C=\"%s\"/>", | |
| 114 msn_object_get_creator(obj), | |
| 115 msn_object_get_size(obj), | |
| 116 msn_object_get_type(obj), | |
| 117 msn_object_get_location(obj), | |
| 118 msn_object_get_friendly(obj), | |
| 119 msn_object_get_sha1d(obj), | |
| 120 msn_object_get_sha1c(obj)); | |
| 121 | |
| 122 return str; | |
| 123 } | |
| 124 | |
| 125 void | |
| 126 msn_object_set_creator(MsnObject *obj, const char *creator) | |
| 127 { | |
| 128 g_return_if_fail(obj != NULL); | |
| 129 | |
| 130 if (obj->creator != NULL) | |
| 131 g_free(obj->creator); | |
| 132 | |
| 133 obj->creator = (creator == NULL ? NULL : g_strdup(creator)); | |
| 134 } | |
| 135 | |
| 136 void | |
| 137 msn_object_set_size(MsnObject *obj, int size) | |
| 138 { | |
| 139 g_return_if_fail(obj != NULL); | |
| 140 | |
| 141 obj->size = size; | |
| 142 } | |
| 143 | |
| 144 void | |
| 145 msn_object_set_type(MsnObject *obj, MsnObjectType type) | |
| 146 { | |
| 147 g_return_if_fail(obj != NULL); | |
| 148 | |
| 149 obj->type = type; | |
| 150 } | |
| 151 | |
| 152 void | |
| 153 msn_object_set_location(MsnObject *obj, const char *location) | |
| 154 { | |
| 155 g_return_if_fail(obj != NULL); | |
| 156 | |
| 157 if (obj->location != NULL) | |
| 158 g_free(obj->location); | |
| 159 | |
| 160 obj->location = (location == NULL ? NULL : g_strdup(location)); | |
| 161 } | |
| 162 | |
| 163 void | |
| 164 msn_object_set_friendly(MsnObject *obj, const char *friendly) | |
| 165 { | |
| 166 g_return_if_fail(obj != NULL); | |
| 167 | |
| 168 if (obj->friendly != NULL) | |
| 169 g_free(obj->friendly); | |
| 170 | |
| 171 obj->friendly = (friendly == NULL ? NULL : g_strdup(friendly)); | |
| 172 } | |
| 173 | |
| 174 void | |
| 175 msn_object_set_sha1d(MsnObject *obj, const char *sha1d) | |
| 176 { | |
| 177 g_return_if_fail(obj != NULL); | |
| 178 | |
| 179 if (obj->sha1d != NULL) | |
| 180 g_free(obj->sha1d); | |
| 181 | |
| 182 obj->sha1d = (sha1d == NULL ? NULL : g_strdup(sha1d)); | |
| 183 } | |
| 184 | |
| 185 void | |
| 186 msn_object_set_sha1c(MsnObject *obj, const char *sha1c) | |
| 187 { | |
| 188 g_return_if_fail(obj != NULL); | |
| 189 | |
| 190 if (obj->sha1c != NULL) | |
| 191 g_free(obj->sha1c); | |
| 192 | |
| 193 obj->sha1c = (sha1c == NULL ? NULL : g_strdup(sha1c)); | |
| 194 } | |
| 195 | |
| 196 const char * | |
| 197 msn_object_get_creator(const MsnObject *obj) | |
| 198 { | |
| 199 g_return_val_if_fail(obj != NULL, NULL); | |
| 200 | |
| 201 return obj->creator; | |
| 202 } | |
| 203 | |
| 204 int | |
| 205 msn_object_get_size(const MsnObject *obj) | |
| 206 { | |
| 207 g_return_val_if_fail(obj != NULL, 0); | |
| 208 | |
| 209 return obj->size; | |
| 210 } | |
| 211 | |
| 212 MsnObjectType | |
| 213 msn_object_get_type(const MsnObject *obj) | |
| 214 { | |
| 215 g_return_val_if_fail(obj != NULL, MSN_OBJECT_UNKNOWN); | |
| 216 | |
| 217 return obj->type; | |
| 218 } | |
| 219 | |
| 220 const char * | |
| 221 msn_object_get_location(const MsnObject *obj) | |
| 222 { | |
| 223 g_return_val_if_fail(obj != NULL, NULL); | |
| 224 | |
| 225 return obj->location; | |
| 226 } | |
| 227 | |
| 228 const char * | |
| 229 msn_object_get_friendly(const MsnObject *obj) | |
| 230 { | |
| 231 g_return_val_if_fail(obj != NULL, NULL); | |
| 232 | |
| 233 return obj->friendly; | |
| 234 } | |
| 235 | |
| 236 const char * | |
| 237 msn_object_get_sha1d(const MsnObject *obj) | |
| 238 { | |
| 239 g_return_val_if_fail(obj != NULL, NULL); | |
| 240 | |
| 241 return obj->sha1d; | |
| 242 } | |
| 243 | |
| 244 const char * | |
| 245 msn_object_get_sha1c(const MsnObject *obj) | |
| 246 { | |
| 247 g_return_val_if_fail(obj != NULL, NULL); | |
| 248 | |
| 249 return obj->sha1c; | |
| 250 } |
