Mercurial > pidgin
annotate src/protocols/gg/utils.c @ 12278:25d7ef365dbf
[gaim-migrate @ 14582]
sf patch #1370473, from Sadrul Habib Chowdhury
"This patch fixes the idle time tracking for systems
that don't use xscreensaver."
Seems like it would just get rid of some warnings? But
whatever, definitely an improvement
committer: Tailor Script <tailor@pidgin.im>
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Thu, 01 Dec 2005 01:01:26 +0000 |
| parents | 078f39bdf3d4 |
| children | 508512caa22e |
| rev | line source |
|---|---|
| 11414 | 1 /** |
| 2 * @file utils.c | |
| 3 * | |
| 4 * gaim | |
| 5 * | |
| 6 * Copyright (C) 2005 Bartosz Oler <bartosz@bzimage.us> | |
| 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 | |
| 23 | |
| 24 #include "utils.h" | |
| 25 | |
| 26 | |
|
12224
e84fbd0be612
[gaim-migrate @ 14526]
Richard Laager <rlaager@wiktel.com>
parents:
12223
diff
changeset
|
27 /* uin_t ggp_str_to_uin(const char *str) {{{ */ |
|
e84fbd0be612
[gaim-migrate @ 14526]
Richard Laager <rlaager@wiktel.com>
parents:
12223
diff
changeset
|
28 uin_t ggp_str_to_uin(const char *str) |
| 11414 | 29 { |
| 30 char *tmp; | |
| 31 long num; | |
| 32 | |
|
12225
078f39bdf3d4
[gaim-migrate @ 14527]
Richard Laager <rlaager@wiktel.com>
parents:
12224
diff
changeset
|
33 if (!str) |
| 11414 | 34 return 0; |
| 35 | |
| 36 errno = 0; | |
|
12225
078f39bdf3d4
[gaim-migrate @ 14527]
Richard Laager <rlaager@wiktel.com>
parents:
12224
diff
changeset
|
37 num = strtol(str, &tmp, 10); |
| 11414 | 38 |
|
12225
078f39bdf3d4
[gaim-migrate @ 14527]
Richard Laager <rlaager@wiktel.com>
parents:
12224
diff
changeset
|
39 if (*str == '\0' || *tmp != '\0') |
| 11414 | 40 return 0; |
| 41 | |
|
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
42 if ((errno == ERANGE || (num == LONG_MAX || num == LONG_MIN)) |
|
12223
546c292b7f98
[gaim-migrate @ 14525]
Richard Laager <rlaager@wiktel.com>
parents:
12214
diff
changeset
|
43 #if (LONG_MAX > UINT_MAX) |
|
546c292b7f98
[gaim-migrate @ 14525]
Richard Laager <rlaager@wiktel.com>
parents:
12214
diff
changeset
|
44 || num > (long)UINT_MAX |
|
546c292b7f98
[gaim-migrate @ 14525]
Richard Laager <rlaager@wiktel.com>
parents:
12214
diff
changeset
|
45 #endif |
|
546c292b7f98
[gaim-migrate @ 14525]
Richard Laager <rlaager@wiktel.com>
parents:
12214
diff
changeset
|
46 || num < 0) |
| 11414 | 47 return 0; |
| 48 | |
| 49 return (uin_t) num; | |
| 50 } | |
| 51 /* }}} */ | |
| 52 | |
| 53 /* char *charset_convert(const gchar *locstr, const char *encsrc, const char *encdst) {{{ */ | |
| 54 char *charset_convert(const gchar *locstr, const char *encsrc, const char *encdst) | |
| 55 { | |
| 56 gchar *msg; | |
| 57 GError *err = NULL; | |
| 58 | |
| 59 if (locstr == NULL) | |
| 60 return NULL; | |
| 61 | |
|
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
62 msg = g_convert_with_fallback(locstr, strlen(locstr), encdst, encsrc, |
|
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
63 "?", NULL, NULL, &err); |
| 11414 | 64 if (err != NULL) { |
| 65 gaim_debug_error("gg", "Error converting from %s to %s: %s\n", | |
|
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
66 encsrc, encdst, err->message); |
| 11414 | 67 g_error_free(err); |
| 68 } | |
| 69 | |
| 70 /* Just in case? */ | |
| 71 if (msg == NULL) | |
| 72 msg = g_strdup(locstr); | |
| 73 | |
| 74 return msg; | |
| 75 } | |
| 76 /* }}} */ | |
| 77 | |
| 78 /* ggp_get_uin(GaimAccount *account) {{{ */ | |
| 79 uin_t ggp_get_uin(GaimAccount *account) | |
| 80 { | |
| 81 return ggp_str_to_uin(gaim_account_get_username(account)); | |
| 82 } | |
| 83 /* }}} */ | |
| 84 | |
| 85 /* const *char ggp_buddy_get_name(GaimConnection *gc, const uin_t uin) {{{ */ | |
| 86 const char *ggp_buddy_get_name(GaimConnection *gc, const uin_t uin) | |
| 87 { | |
| 88 GaimBuddy *buddy; | |
| 89 gchar *str_uin; | |
| 90 | |
| 91 str_uin = g_strdup_printf("%lu", (unsigned long int)uin); | |
| 92 | |
| 93 buddy = gaim_find_buddy(gaim_connection_get_account(gc), str_uin); | |
| 94 if (buddy != NULL) { | |
| 95 g_free(str_uin); | |
| 96 return gaim_buddy_get_alias(buddy); | |
| 97 } else { | |
| 98 return str_uin; | |
| 99 } | |
| 100 } | |
| 101 /* }}} */ | |
| 102 | |
| 103 | |
|
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
104 /* vim: set ts=8 sts=0 sw=8 noet: */ |
