Mercurial > pidgin.yaz
changeset 13626:fa7313d125ac
[gaim-migrate @ 16013]
utils.c / utils.h is a common name. Namespacing the gg prpl's utils files to gg-utils.c and gg-utils.h.
committer: Tailor Script <tailor@pidgin.im>
author | Evan Schoenberg <evan.s@dreskin.net> |
---|---|
date | Tue, 11 Apr 2006 21:48:11 +0000 |
parents | 880c956dd031 |
children | 3cfdf1653a64 |
files | src/protocols/gg/Makefile.am src/protocols/gg/Makefile.mingw src/protocols/gg/buddylist.c src/protocols/gg/confer.c src/protocols/gg/gg-utils.c src/protocols/gg/gg-utils.h src/protocols/gg/gg.c src/protocols/gg/search.c src/protocols/gg/utils.c src/protocols/gg/utils.h |
diffstat | 10 files changed, 197 insertions(+), 197 deletions(-) [+] |
line wrap: on
line diff
--- a/src/protocols/gg/Makefile.am Tue Apr 11 21:07:58 2006 +0000 +++ b/src/protocols/gg/Makefile.am Tue Apr 11 21:48:11 2006 +0000 @@ -3,8 +3,8 @@ pkgdir = $(libdir)/gaim GGSOURCES = \ - utils.h \ - utils.c \ + gg-utils.h \ + gg-utils.c \ confer.h \ confer.c \ search.h \
--- a/src/protocols/gg/Makefile.mingw Tue Apr 11 21:07:58 2006 +0000 +++ b/src/protocols/gg/Makefile.mingw Tue Apr 11 21:48:11 2006 +0000 @@ -81,7 +81,7 @@ confer.c \ gg.c \ search.c \ - utils.c + gg-utils.c OBJECTS = $(C_SRC:%.c=%.o)
--- a/src/protocols/gg/buddylist.c Tue Apr 11 21:07:58 2006 +0000 +++ b/src/protocols/gg/buddylist.c Tue Apr 11 21:48:11 2006 +0000 @@ -24,7 +24,7 @@ #include <libgadu.h> #include "gg.h" -#include "utils.h" +#include "gg-utils.h" #include "buddylist.h"
--- a/src/protocols/gg/confer.c Tue Apr 11 21:07:58 2006 +0000 +++ b/src/protocols/gg/confer.c Tue Apr 11 21:48:11 2006 +0000 @@ -23,7 +23,7 @@ #include <libgadu.h> #include "gg.h" -#include "utils.h" +#include "gg-utils.h" #include "confer.h" /* GaimConversation *ggp_confer_find_by_name(GaimConnection *gc, const gchar *name) {{{ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/protocols/gg/gg-utils.c Tue Apr 11 21:48:11 2006 +0000 @@ -0,0 +1,104 @@ +/** + * @file gg-utils.c + * + * gaim + * + * Copyright (C) 2005 Bartosz Oler <bartosz@bzimage.us> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include "gg-utils.h" + + +/* uin_t ggp_str_to_uin(const char *str) {{{ */ +uin_t ggp_str_to_uin(const char *str) +{ + char *tmp; + long num; + + if (!str) + return 0; + + errno = 0; + num = strtol(str, &tmp, 10); + + if (*str == '\0' || *tmp != '\0') + return 0; + + if ((errno == ERANGE || (num == LONG_MAX || num == LONG_MIN)) +#if (LONG_MAX > UINT_MAX) + || num > (long)UINT_MAX +#endif + || num < 0) + return 0; + + return (uin_t) num; +} +/* }}} */ + +/* char *charset_convert(const gchar *locstr, const char *encsrc, const char *encdst) {{{ */ +char *charset_convert(const gchar *locstr, const char *encsrc, const char *encdst) +{ + gchar *msg; + GError *err = NULL; + + if (locstr == NULL) + return NULL; + + msg = g_convert_with_fallback(locstr, strlen(locstr), encdst, encsrc, + "?", NULL, NULL, &err); + if (err != NULL) { + gaim_debug_error("gg", "Error converting from %s to %s: %s\n", + encsrc, encdst, err->message); + g_error_free(err); + } + + /* Just in case? */ + if (msg == NULL) + msg = g_strdup(locstr); + + return msg; +} +/* }}} */ + +/* ggp_get_uin(GaimAccount *account) {{{ */ +uin_t ggp_get_uin(GaimAccount *account) +{ + return ggp_str_to_uin(gaim_account_get_username(account)); +} +/* }}} */ + +/* char *ggp_buddy_get_name(GaimConnection *gc, const uin_t uin) {{{ */ +char *ggp_buddy_get_name(GaimConnection *gc, const uin_t uin) +{ + GaimBuddy *buddy; + gchar *str_uin; + + str_uin = g_strdup_printf("%lu", (unsigned long int)uin); + + buddy = gaim_find_buddy(gaim_connection_get_account(gc), str_uin); + if (buddy != NULL) { + g_free(str_uin); + return g_strdup(gaim_buddy_get_alias(buddy)); + } else { + return str_uin; + } +} +/* }}} */ + + +/* vim: set ts=8 sts=0 sw=8 noet: */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/protocols/gg/gg-utils.h Tue Apr 11 21:48:11 2006 +0000 @@ -0,0 +1,86 @@ +/** + * @file gg-utils.h + * + * gaim + * + * Copyright (C) 2005 Bartosz Oler <bartosz@bzimage.us> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _GAIM_GG_UTILS_H +#define _GAIM_GG_UTILS_H + +#include "internal.h" + +#include "plugin.h" +#include "version.h" +#include "notify.h" +#include "status.h" +#include "blist.h" +#include "accountopt.h" +#include "debug.h" +#include "util.h" +#include "request.h" + +#include "gg.h" + + +/* + * Convert a base 10 string to a UIN. + * + * @param str The string to convert + * @return UIN or 0 if an error occurred. + */ +uin_t +ggp_str_to_uin(const char *str); + +/** + * Convert enconding of a given string. + * + * @param locstr Input string. + * @param encsrc Current encoding of the string. + * @param encdst Target encoding of the string. + * + * @return Converted string (it must be g_free()ed when not used. Or NULL if + * locstr is NULL. + */ +char * +charset_convert(const gchar *locstr, const char *encsrc, const char *encdst); + +/** + * Get UIN of a given account. + * + * @param account Current account. + * + * @return UIN of an account. + */ +uin_t +ggp_get_uin(GaimAccount *account); + +/** + * Returns the best name of a buddy from the buddylist. + * + * @param gc GaimConnection instance. + * @param uin UIN of the buddy. + * + * @return Name of the buddy, or UIN converted to string. + */ +char * +ggp_buddy_get_name(GaimConnection *gc, const uin_t uin); + +#endif /* _GAIM_GG_UTILS_H */ + +/* vim: set ts=8 sts=0 sw=8 noet: */
--- a/src/protocols/gg/gg.c Tue Apr 11 21:07:58 2006 +0000 +++ b/src/protocols/gg/gg.c Tue Apr 11 21:48:11 2006 +0000 @@ -43,7 +43,7 @@ #include "confer.h" #include "search.h" #include "buddylist.h" -#include "utils.h" +#include "gg-utils.h" static GaimPlugin *my_protocol = NULL;
--- a/src/protocols/gg/search.c Tue Apr 11 21:07:58 2006 +0000 +++ b/src/protocols/gg/search.c Tue Apr 11 21:48:11 2006 +0000 @@ -23,7 +23,7 @@ #include <libgadu.h> -#include "utils.h" +#include "gg-utils.h" #include "search.h" /* GGPSearchForm *ggp_search_form_new() {{{ */
--- a/src/protocols/gg/utils.c Tue Apr 11 21:07:58 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,104 +0,0 @@ -/** - * @file utils.c - * - * gaim - * - * Copyright (C) 2005 Bartosz Oler <bartosz@bzimage.us> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include "utils.h" - - -/* uin_t ggp_str_to_uin(const char *str) {{{ */ -uin_t ggp_str_to_uin(const char *str) -{ - char *tmp; - long num; - - if (!str) - return 0; - - errno = 0; - num = strtol(str, &tmp, 10); - - if (*str == '\0' || *tmp != '\0') - return 0; - - if ((errno == ERANGE || (num == LONG_MAX || num == LONG_MIN)) -#if (LONG_MAX > UINT_MAX) - || num > (long)UINT_MAX -#endif - || num < 0) - return 0; - - return (uin_t) num; -} -/* }}} */ - -/* char *charset_convert(const gchar *locstr, const char *encsrc, const char *encdst) {{{ */ -char *charset_convert(const gchar *locstr, const char *encsrc, const char *encdst) -{ - gchar *msg; - GError *err = NULL; - - if (locstr == NULL) - return NULL; - - msg = g_convert_with_fallback(locstr, strlen(locstr), encdst, encsrc, - "?", NULL, NULL, &err); - if (err != NULL) { - gaim_debug_error("gg", "Error converting from %s to %s: %s\n", - encsrc, encdst, err->message); - g_error_free(err); - } - - /* Just in case? */ - if (msg == NULL) - msg = g_strdup(locstr); - - return msg; -} -/* }}} */ - -/* ggp_get_uin(GaimAccount *account) {{{ */ -uin_t ggp_get_uin(GaimAccount *account) -{ - return ggp_str_to_uin(gaim_account_get_username(account)); -} -/* }}} */ - -/* char *ggp_buddy_get_name(GaimConnection *gc, const uin_t uin) {{{ */ -char *ggp_buddy_get_name(GaimConnection *gc, const uin_t uin) -{ - GaimBuddy *buddy; - gchar *str_uin; - - str_uin = g_strdup_printf("%lu", (unsigned long int)uin); - - buddy = gaim_find_buddy(gaim_connection_get_account(gc), str_uin); - if (buddy != NULL) { - g_free(str_uin); - return g_strdup(gaim_buddy_get_alias(buddy)); - } else { - return str_uin; - } -} -/* }}} */ - - -/* vim: set ts=8 sts=0 sw=8 noet: */
--- a/src/protocols/gg/utils.h Tue Apr 11 21:07:58 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,86 +0,0 @@ -/** - * @file utils.h - * - * gaim - * - * Copyright (C) 2005 Bartosz Oler <bartosz@bzimage.us> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _GAIM_GG_UTILS_H -#define _GAIM_GG_UTILS_H - -#include "internal.h" - -#include "plugin.h" -#include "version.h" -#include "notify.h" -#include "status.h" -#include "blist.h" -#include "accountopt.h" -#include "debug.h" -#include "util.h" -#include "request.h" - -#include "gg.h" - - -/* - * Convert a base 10 string to a UIN. - * - * @param str The string to convert - * @return UIN or 0 if an error occurred. - */ -uin_t -ggp_str_to_uin(const char *str); - -/** - * Convert enconding of a given string. - * - * @param locstr Input string. - * @param encsrc Current encoding of the string. - * @param encdst Target encoding of the string. - * - * @return Converted string (it must be g_free()ed when not used. Or NULL if - * locstr is NULL. - */ -char * -charset_convert(const gchar *locstr, const char *encsrc, const char *encdst); - -/** - * Get UIN of a given account. - * - * @param account Current account. - * - * @return UIN of an account. - */ -uin_t -ggp_get_uin(GaimAccount *account); - -/** - * Returns the best name of a buddy from the buddylist. - * - * @param gc GaimConnection instance. - * @param uin UIN of the buddy. - * - * @return Name of the buddy, or UIN converted to string. - */ -char * -ggp_buddy_get_name(GaimConnection *gc, const uin_t uin); - -#endif /* _GAIM_GG_UTILS_H */ - -/* vim: set ts=8 sts=0 sw=8 noet: */