From: <sa...@us...> - 2006-11-20 05:56:56
|
Revision: 17791 http://svn.sourceforge.net/gaim/?rev=17791&view=rev Author: sadrul Date: 2006-11-19 21:56:55 -0800 (Sun, 19 Nov 2006) Log Message: ----------- Fix bug#1580140: "getopt.h missing" libgaim doesn't use getopt functions at all. So it's not necessary to keep getopt* files in libgaim/. Modified Paths: -------------- trunk/libgaim/Makefile.am Removed Paths: ------------- trunk/libgaim/getopt.c trunk/libgaim/getopt.h trunk/libgaim/getopt1.c Modified: trunk/libgaim/Makefile.am =================================================================== --- trunk/libgaim/Makefile.am 2006-11-20 05:33:32 UTC (rev 17790) +++ trunk/libgaim/Makefile.am 2006-11-20 05:56:55 UTC (rev 17791) @@ -181,10 +181,9 @@ gaim_client_example_SOURCES = gaim-client-example.c -gaim_client_example_DEPENDENCIES = @LIBOBJS@ libgaim-client.la +gaim_client_example_DEPENDENCIES = libgaim-client.la gaim_client_example_LDADD = \ - @LIBOBJS@ \ libgaim-client.la \ $(GLIB_LIBS) \ $(DBUS_LIBS) @@ -214,10 +213,9 @@ $(gaim_coreheaders) \ $(dbus_headers) -libgaim_la_DEPENDENCIES = @LIBOBJS@ $(STATIC_LINK_LIBS) +libgaim_la_DEPENDENCIES = $(STATIC_LINK_LIBS) libgaim_la_LDFLAGS = -export-dynamic libgaim_la_LIBADD = \ - @LIBOBJS@ \ $(DBUS_LIBS) \ $(GLIB_LIBS) \ $(LIBXML_LIBS) \ Deleted: trunk/libgaim/getopt.c =================================================================== --- trunk/libgaim/getopt.c 2006-11-20 05:33:32 UTC (rev 17790) +++ trunk/libgaim/getopt.c 2006-11-20 05:56:55 UTC (rev 17791) @@ -1,737 +0,0 @@ -/* Getopt for GNU. - NOTE: getopt is now part of the C library, so if you don't know what - "Keep this file name-space clean" means, talk to ro...@gn... - before changing it! - - Gaim is the legal property of its developers, whose names are too numerous - to list here. Please refer to the COPYRIGHT file distributed with this - source distribution. - - 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, 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* NOTE!!! AIX requires this to be the first thing in the file. - Do not put ANYTHING before it! */ -#if !defined (__GNUC__) && defined (_AIX) - #pragma alloca -#endif - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -/* Alver says we need this for IRIX. */ -#if HAVE_STRING_H -#include "string.h" -#endif - -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else /* not __GNUC__ */ -#if defined (HAVE_ALLOCA_H) || (defined(sparc) && (defined(sun) || (!defined(USG) && !defined(SVR4) && !defined(__svr4__)))) -#include <alloca.h> -#else -#ifndef _AIX -char *alloca (); -#endif -#endif /* alloca.h */ -#endif /* not __GNUC__ */ - -#if !__STDC__ && !defined(const) && IN_GCC -#define const -#endif - -/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>. */ -#ifndef _NO_PROTO -#define _NO_PROTO -#endif - -#include <stdio.h> - -/* Comment out all this code if we are using the GNU C Library, and are not - actually compiling the library itself. This code is part of the GNU C - Library, but also included in many other GNU distributions. Compiling - and linking in this code is a waste when using the GNU C library - (especially if it is a shared library). Rather than having every GNU - program understand `configure --with-gnu-libc' and omit the object files, - it is simpler to just do this in the source for each such file. */ - -#if defined (_LIBC) || !defined (__GNU_LIBRARY__) - - -/* This needs to come after some library #include - to get __GNU_LIBRARY__ defined. */ -#ifdef __GNU_LIBRARY__ -#undef alloca -/* Don't include stdlib.h for non-GNU C libraries because some of them - contain conflicting prototypes for getopt. */ -#include <stdlib.h> -#else /* Not GNU C library. */ -#define __alloca alloca -#endif /* GNU C library. */ - -/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a - long-named option. Because this is not POSIX.2 compliant, it is - being phased out. */ -/* #define GETOPT_COMPAT */ - -/* This version of `getopt' appears to the caller like standard Unix `getopt' - but it behaves differently for the user, since it allows the user - to intersperse the options with the other arguments. - - As `getopt' works, it permutes the elements of ARGV so that, - when it is done, all the options precede everything else. Thus - all application programs are extended to handle flexible argument order. - - Setting the environment variable POSIXLY_CORRECT disables permutation. - Then the behavior is completely standard. - - GNU application programs can use a third alternative mode in which - they can distinguish the relative order of options and other arguments. */ - -#include "getopt.h" - -/* For communication from `getopt' to the caller. - When `getopt' finds an option that takes an argument, - the argument value is returned here. - Also, when `ordering' is RETURN_IN_ORDER, - each non-option ARGV-element is returned here. */ - -char *optarg = 0; - -/* Index in ARGV of the next element to be scanned. - This is used for communication to and from the caller - and for communication between successive calls to `getopt'. - - On entry to `getopt', zero means this is the first call; initialize. - - When `getopt' returns EOF, this is the index of the first of the - non-option elements that the caller should itself scan. - - Otherwise, `optind' communicates from one call to the next - how much of ARGV has been scanned so far. */ - -/* XXX 1003.2 says this must be 1 before any call. */ -int optind = 0; - -/* The next char to be scanned in the option-element - in which the last option character we returned was found. - This allows us to pick up the scan where we left off. - - If this is zero, or a null string, it means resume the scan - by advancing to the next ARGV-element. */ - -static char *nextchar; - -/* Callers store zero here to inhibit the error message - for unrecognized options. */ - -int opterr = 1; - -/* Set to an option character which was unrecognized. - This must be initialized on some systems to avoid linking in the - system's own getopt implementation. */ - -int optopt = '?'; - -/* Describe how to deal with options that follow non-option ARGV-elements. - - If the caller did not specify anything, - the default is REQUIRE_ORDER if the environment variable - POSIXLY_CORRECT is defined, PERMUTE otherwise. - - REQUIRE_ORDER means don't recognize them as options; - stop option processing when the first non-option is seen. - This is what Unix does. - This mode of operation is selected by either setting the environment - variable POSIXLY_CORRECT, or using `+' as the first character - of the list of option characters. - - PERMUTE is the default. We permute the contents of ARGV as we scan, - so that eventually all the non-options are at the end. This allows options - to be given in any order, even with programs that were not written to - expect this. - - RETURN_IN_ORDER is an option available to programs that were written - to expect options and other ARGV-elements in any order and that care about - the ordering of the two. We describe each non-option ARGV-element - as if it were the argument of an option with character code 1. - Using `-' as the first character of the list of option characters - selects this mode of operation. - - The special argument `--' forces an end of option-scanning regardless - of the value of `ordering'. In the case of RETURN_IN_ORDER, only - `--' can cause `getopt' to return EOF with `optind' != ARGC. */ - -static enum -{ - REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER -} ordering; - -#ifdef __GNU_LIBRARY__ -/* We want to avoid inclusion of string.h with non-GNU libraries - because there are many ways it can cause trouble. - On some systems, it contains special magic macros that don't work - in GCC. */ -#include <string.h> -#define my_index strchr -#define my_bcopy(src, dst, n) memcpy ((dst), (src), (n)) -#else - -/* Avoid depending on library functions or files - whose names are inconsistent. */ - -char *getenv (); - -static char * -my_index (str, chr) - const char *str; - int chr; -{ - while (*str) - { - if (*str == chr) - return (char *) str; - str++; - } - return 0; -} - -static void -my_bcopy (from, to, size) - const char *from; - char *to; - int size; -{ - int i; - for (i = 0; i < size; i++) - to[i] = from[i]; -} -#endif /* GNU C library. */ - -/* Handle permutation of arguments. */ - -/* Describe the part of ARGV that contains non-options that have - been skipped. `first_nonopt' is the index in ARGV of the first of them; - `last_nonopt' is the index after the last of them. */ - -static int first_nonopt; -static int last_nonopt; - -/* Exchange two adjacent subsequences of ARGV. - One subsequence is elements [first_nonopt,last_nonopt) - which contains all the non-options that have been skipped so far. - The other is elements [last_nonopt,optind), which contains all - the options processed since those non-options were skipped. - - `first_nonopt' and `last_nonopt' are relocated so that they describe - the new indices of the non-options in ARGV after they are moved. */ - -static void -exchange (argv) - char **argv; -{ - int nonopts_size = (last_nonopt - first_nonopt) * sizeof (char *); - char **temp = (char **) __alloca (nonopts_size); - - /* Interchange the two blocks of data in ARGV. */ - - my_bcopy ((char *) &argv[first_nonopt], (char *) temp, nonopts_size); - my_bcopy ((char *) &argv[last_nonopt], (char *) &argv[first_nonopt], - (optind - last_nonopt) * sizeof (char *)); - my_bcopy ((char *) temp, - (char *) &argv[first_nonopt + optind - last_nonopt], - nonopts_size); - - /* Update records for the slots the non-options now occupy. */ - - first_nonopt += (optind - last_nonopt); - last_nonopt = optind; -} - -/* Scan elements of ARGV (whose length is ARGC) for option characters - given in OPTSTRING. - - If an element of ARGV starts with '-', and is not exactly "-" or "--", - then it is an option element. The characters of this element - (aside from the initial '-') are option characters. If `getopt' - is called repeatedly, it returns successively each of the option characters - from each of the option elements. - - If `getopt' finds another option character, it returns that character, - updating `optind' and `nextchar' so that the next call to `getopt' can - resume the scan with the following option character or ARGV-element. - - If there are no more option characters, `getopt' returns `EOF'. - Then `optind' is the index in ARGV of the first ARGV-element - that is not an option. (The ARGV-elements have been permuted - so that those that are not options now come last.) - - OPTSTRING is a string containing the legitimate option characters. - If an option character is seen that is not listed in OPTSTRING, - return '?' after printing an error message. If you set `opterr' to - zero, the error message is suppressed but we still return '?'. - - If a char in OPTSTRING is followed by a colon, that means it wants an arg, - so the following text in the same ARGV-element, or the text of the following - ARGV-element, is returned in `optarg'. Two colons mean an option that - wants an optional arg; if there is text in the current ARGV-element, - it is returned in `optarg', otherwise `optarg' is set to zero. - - If OPTSTRING starts with `-' or `+', it requests different methods of - handling the non-option ARGV-elements. - See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. - - Long-named options begin with `--' instead of `-'. - Their names may be abbreviated as long as the abbreviation is unique - or is an exact match for some defined option. If they have an - argument, it follows the option name in the same ARGV-element, separated - from the option name by a `=', or else the in next ARGV-element. - When `getopt' finds a long-named option, it returns 0 if that option's - `flag' field is nonzero, the value of the option's `val' field - if the `flag' field is zero. - - The elements of ARGV aren't really const, because we permute them. - But we pretend they're const in the prototype to be compatible - with other systems. - - LONGOPTS is a vector of `struct option' terminated by an - element containing a name which is zero. - - LONGIND returns the index in LONGOPT of the long-named option found. - It is only valid when a long-named option has been found by the most - recent call. - - If LONG_ONLY is nonzero, '-' as well as '--' can introduce - long-named options. */ - -int -_getopt_internal (argc, argv, optstring, longopts, longind, long_only) - int argc; - char *const *argv; - const char *optstring; - const struct option *longopts; - int *longind; - int long_only; -{ - int option_index; - - optarg = 0; - - /* Initialize the internal data when the first call is made. - Start processing options with ARGV-element 1 (since ARGV-element 0 - is the program name); the sequence of previously skipped - non-option ARGV-elements is empty. */ - - if (optind == 0) - { - first_nonopt = last_nonopt = optind = 1; - - nextchar = NULL; - - /* Determine how to handle the ordering of options and nonoptions. */ - - if (optstring[0] == '-') - { - ordering = RETURN_IN_ORDER; - ++optstring; - } - else if (optstring[0] == '+') - { - ordering = REQUIRE_ORDER; - ++optstring; - } - else if (getenv ("POSIXLY_CORRECT") != NULL) - ordering = REQUIRE_ORDER; - else - ordering = PERMUTE; - } - - if (nextchar == NULL || *nextchar == '\0') - { - if (ordering == PERMUTE) - { - /* If we have just processed some options following some non-options, - exchange them so that the options come first. */ - - if (first_nonopt != last_nonopt && last_nonopt != optind) - exchange ((char **) argv); - else if (last_nonopt != optind) - first_nonopt = optind; - - /* Now skip any additional non-options - and extend the range of non-options previously skipped. */ - - while (optind < argc - && (argv[optind][0] != '-' || argv[optind][1] == '\0') -#ifdef GETOPT_COMPAT - && (longopts == NULL - || argv[optind][0] != '+' || argv[optind][1] == '\0') -#endif /* GETOPT_COMPAT */ - ) - optind++; - last_nonopt = optind; - } - - /* Special ARGV-element `--' means premature end of options. - Skip it like a null option, - then exchange with previous non-options as if it were an option, - then skip everything else like a non-option. */ - - if (optind != argc && !strcmp (argv[optind], "--")) - { - optind++; - - if (first_nonopt != last_nonopt && last_nonopt != optind) - exchange ((char **) argv); - else if (first_nonopt == last_nonopt) - first_nonopt = optind; - last_nonopt = argc; - - optind = argc; - } - - /* If we have done all the ARGV-elements, stop the scan - and back over any non-options that we skipped and permuted. */ - - if (optind == argc) - { - /* Set the next-arg-index to point at the non-options - that we previously skipped, so the caller will digest them. */ - if (first_nonopt != last_nonopt) - optind = first_nonopt; - return EOF; - } - - /* If we have come to a non-option and did not permute it, - either stop the scan or describe it to the caller and pass it by. */ - - if ((argv[optind][0] != '-' || argv[optind][1] == '\0') -#ifdef GETOPT_COMPAT - && (longopts == NULL - || argv[optind][0] != '+' || argv[optind][1] == '\0') -#endif /* GETOPT_COMPAT */ - ) - { - if (ordering == REQUIRE_ORDER) - return EOF; - optarg = argv[optind++]; - return 1; - } - - /* We have found another option-ARGV-element. - Start decoding its characters. */ - - nextchar = (argv[optind] + 1 - + (longopts != NULL && argv[optind][1] == '-')); - } - - if (longopts != NULL - && ((argv[optind][0] == '-' - && (argv[optind][1] == '-' || long_only)) -#ifdef GETOPT_COMPAT - || argv[optind][0] == '+' -#endif /* GETOPT_COMPAT */ - )) - { - const struct option *p; - char *s = nextchar; - int exact = 0; - int ambig = 0; - const struct option *pfound = NULL; - int indfound; - - while (*s && *s != '=') - s++; - - /* Test all options for either exact match or abbreviated matches. */ - for (p = longopts, option_index = 0; p->name; - p++, option_index++) - if (!strncmp (p->name, nextchar, s - nextchar)) - { - if (s - nextchar == strlen (p->name)) - { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } - else if (pfound == NULL) - { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } - else - /* Second nonexact match found. */ - ambig = 1; - } - - if (ambig && !exact) - { - if (opterr) - fprintf (stderr, "%s: option `%s' is ambiguous\n", - argv[0], argv[optind]); - nextchar += strlen (nextchar); - optind++; - return '?'; - } - - if (pfound != NULL) - { - option_index = indfound; - optind++; - if (*s) - { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - optarg = s + 1; - else - { - if (opterr) - { - if (argv[optind - 1][1] == '-') - /* --option */ - fprintf (stderr, - "%s: option `--%s' doesn't allow an argument\n", - argv[0], pfound->name); - else - /* +option or -option */ - fprintf (stderr, - "%s: option `%c%s' doesn't allow an argument\n", - argv[0], argv[optind - 1][0], pfound->name); - } - nextchar += strlen (nextchar); - return '?'; - } - } - else if (pfound->has_arg == 1) - { - if (optind < argc) - optarg = argv[optind++]; - else - { - if (opterr) - fprintf (stderr, "%s: option `%s' requires an argument\n", - argv[0], argv[optind - 1]); - nextchar += strlen (nextchar); - return optstring[0] == ':' ? ':' : '?'; - } - } - nextchar += strlen (nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - /* Can't find it as a long option. If this is not getopt_long_only, - or the option starts with '--' or is not a valid short - option, then it's an error. - Otherwise interpret it as a short option. */ - if (!long_only || argv[optind][1] == '-' -#ifdef GETOPT_COMPAT - || argv[optind][0] == '+' -#endif /* GETOPT_COMPAT */ - || my_index (optstring, *nextchar) == NULL) - { - if (opterr) - { - if (argv[optind][1] == '-') - /* --option */ - fprintf (stderr, "%s: unrecognized option `--%s'\n", - argv[0], nextchar); - else - /* +option or -option */ - fprintf (stderr, "%s: unrecognized option `%c%s'\n", - argv[0], argv[optind][0], nextchar); - } - nextchar = (char *) ""; - optind++; - return '?'; - } - } - - /* Look at and handle the next option-character. */ - - { - char c = *nextchar++; - char *temp = my_index (optstring, c); - - /* Increment `optind' when we start to process its last character. */ - if (*nextchar == '\0') - ++optind; - - if (temp == NULL || c == ':') - { - if (opterr) - { -#if 0 - if (c < 040 || c >= 0177) - fprintf (stderr, "%s: unrecognized option, character code 0%o\n", - argv[0], c); - else - fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c); -#else - /* 1003.2 specifies the format of this message. */ - fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c); -#endif - } - optopt = c; - return '?'; - } - if (temp[1] == ':') - { - if (temp[2] == ':') - { - /* This is an option that accepts an argument optionally. */ - if (*nextchar != '\0') - { - optarg = nextchar; - optind++; - } - else - optarg = 0; - nextchar = NULL; - } - else - { - /* This is an option that requires an argument. */ - if (*nextchar != '\0') - { - optarg = nextchar; - /* If we end this ARGV-element by taking the rest as an arg, - we must advance to the next element now. */ - optind++; - } - else if (optind == argc) - { - if (opterr) - { -#if 0 - fprintf (stderr, "%s: option `-%c' requires an argument\n", - argv[0], c); -#else - /* 1003.2 specifies the format of this message. */ - fprintf (stderr, "%s: option requires an argument -- %c\n", - argv[0], c); -#endif - } - optopt = c; - if (optstring[0] == ':') - c = ':'; - else - c = '?'; - } - else - /* We already incremented `optind' once; - increment it again when taking next ARGV-elt as argument. */ - optarg = argv[optind++]; - nextchar = NULL; - } - } - return c; - } -} - -int -getopt (argc, argv, optstring) - int argc; - char *const *argv; - const char *optstring; -{ - return _getopt_internal (argc, argv, optstring, - (const struct option *) 0, - (int *) 0, - 0); -} - -#endif /* _LIBC or not __GNU_LIBRARY__. */ - -#ifdef TEST - -/* Compile with -DTEST to make an executable for use in testing - the above definition of `getopt'. */ - -int -main (argc, argv) - int argc; - char **argv; -{ - int c; - int digit_optind = 0; - - while (1) - { - int this_option_optind = optind ? optind : 1; - - c = getopt (argc, argv, "abc:d:0123456789"); - if (c == EOF) - break; - - switch (c) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (digit_optind != 0 && digit_optind != this_option_optind) - printf ("digits occur in two different argv-elements.\n"); - digit_optind = this_option_optind; - printf ("option %c\n", c); - break; - - case 'a': - printf ("option a\n"); - break; - - case 'b': - printf ("option b\n"); - break; - - case 'c': - printf ("option c with value `%s'\n", optarg); - break; - - case '?': - break; - - default: - printf ("?? getopt returned character code 0%o ??\n", c); - } - } - - if (optind < argc) - { - printf ("non-option ARGV-elements: "); - while (optind < argc) - printf ("%s ", argv[optind++]); - printf ("\n"); - } - - exit (0); -} - -#endif /* TEST */ Deleted: trunk/libgaim/getopt.h =================================================================== --- trunk/libgaim/getopt.h 2006-11-20 05:33:32 UTC (rev 17790) +++ trunk/libgaim/getopt.h 2006-11-20 05:56:55 UTC (rev 17791) @@ -1,136 +0,0 @@ -/* Declarations for getopt. - - NOTE: getopt is now part of the C library, so if you don't know what - "Keep this file name-space clean" means, talk to ro...@gn... - before changing it! - - Gaim is the legal property of its developers, whose names are too numerous - to list here. Please refer to the COPYRIGHT file distributed with this - source distribution. - - 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, 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef _GETOPT_H -#define _GETOPT_H 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* For communication from `getopt' to the caller. - When `getopt' finds an option that takes an argument, - the argument value is returned here. - Also, when `ordering' is RETURN_IN_ORDER, - each non-option ARGV-element is returned here. */ - -extern char *optarg; - -/* Index in ARGV of the next element to be scanned. - This is used for communication to and from the caller - and for communication between successive calls to `getopt'. - - On entry to `getopt', zero means this is the first call; initialize. - - When `getopt' returns EOF, this is the index of the first of the - non-option elements that the caller should itself scan. - - Otherwise, `optind' communicates from one call to the next - how much of ARGV has been scanned so far. */ - -extern int optind; - -/* Callers store zero here to inhibit the error message `getopt' prints - for unrecognized options. */ - -extern int opterr; - -/* Set to an option character which was unrecognized. */ - -extern int optopt; - -/* Describe the long-named options requested by the application. - The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector - of `struct option' terminated by an element containing a name which is - zero. - - The field `has_arg' is: - no_argument (or 0) if the option does not take an argument, - required_argument (or 1) if the option requires an argument, - optional_argument (or 2) if the option takes an optional argument. - - If the field `flag' is not NULL, it points to a variable that is set - to the value given in the field `val' when the option is found, but - left unchanged if the option is not found. - - To have a long-named option do something other than set an `int' to - a compiled-in constant, such as set a value from `optarg', set the - option's `flag' field to zero and its `val' field to a nonzero - value (the equivalent single-letter option character, if there is - one). For long options that have a zero `flag' field, `getopt' - returns the contents of the `val' field. */ - -struct option -{ -#if __STDC__ - const char *name; -#else - char *name; -#endif - /* has_arg can't be an enum because some compilers complain about - type mismatches in all the code that assumes it is an int. */ - int has_arg; - int *flag; - int val; -}; - -/* Names for the values of the `has_arg' field of `struct option'. */ - -#define no_argument 0 -#define required_argument 1 -#define optional_argument 2 - -#if __STDC__ -#if defined(__GNU_LIBRARY__) -/* Many other libraries have conflicting prototypes for getopt, with - differences in the consts, in stdlib.h. To avoid compilation - errors, only prototype getopt for the GNU C library. */ -extern int getopt (int argc, char *const *argv, const char *shortopts); -#else /* not __GNU_LIBRARY__ */ -extern int getopt (); -#endif /* not __GNU_LIBRARY__ */ -extern int getopt_long (int argc, char *const *argv, const char *shortopts, - const struct option *longopts, int *longind); -extern int getopt_long_only (int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind); - -/* Internal only. Users should not call this directly. */ -extern int _getopt_internal (int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind, - int long_only); -#else /* not __STDC__ */ -extern int getopt (); -extern int getopt_long (); -extern int getopt_long_only (); - -extern int _getopt_internal (); -#endif /* not __STDC__ */ - -#ifdef __cplusplus -} -#endif - -#endif /* _GETOPT_H */ Deleted: trunk/libgaim/getopt1.c =================================================================== --- trunk/libgaim/getopt1.c 2006-11-20 05:33:32 UTC (rev 17790) +++ trunk/libgaim/getopt1.c 2006-11-20 05:56:55 UTC (rev 17791) @@ -1,177 +0,0 @@ -/* getopt_long and getopt_long_only entry points for GNU getopt. - Gaim is the legal property of its developers, whose names are too numerous - to list here. Please refer to the COPYRIGHT file distributed with this - source distribution. - - 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, 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "getopt.h" - -#if !__STDC__ && !defined(const) && IN_GCC -#define const -#endif - -#include <stdio.h> - -/* Comment out all this code if we are using the GNU C Library, and are not - actually compiling the library itself. This code is part of the GNU C - Library, but also included in many other GNU distributions. Compiling - and linking in this code is a waste when using the GNU C library - (especially if it is a shared library). Rather than having every GNU - program understand `configure --with-gnu-libc' and omit the object files, - it is simpler to just do this in the source for each such file. */ - -#if defined (_LIBC) || !defined (__GNU_LIBRARY__) - - -/* This needs to come after some library #include - to get __GNU_LIBRARY__ defined. */ -#ifdef __GNU_LIBRARY__ -#include <stdlib.h> -#else -char *getenv (); -#endif - -#ifndef NULL -#define NULL 0 -#endif - -int -getopt_long (argc, argv, options, long_options, opt_index) - int argc; - char *const *argv; - const char *options; - const struct option *long_options; - int *opt_index; -{ - return _getopt_internal (argc, argv, options, long_options, opt_index, 0); -} - -/* Like getopt_long, but '-' as well as '--' can indicate a long option. - If an option that starts with '-' (not '--') doesn't match a long option, - but does match a short option, it is parsed as a short option - instead. */ - -int -getopt_long_only (argc, argv, options, long_options, opt_index) - int argc; - char *const *argv; - const char *options; - const struct option *long_options; - int *opt_index; -{ - return _getopt_internal (argc, argv, options, long_options, opt_index, 1); -} - - -#endif /* _LIBC or not __GNU_LIBRARY__. */ - -#ifdef TEST - -#include <stdio.h> - -int -main (argc, argv) - int argc; - char **argv; -{ - int c; - int digit_optind = 0; - - while (1) - { - int this_option_optind = optind ? optind : 1; - int option_index = 0; - static struct option long_options[] = - { - {"add", 1, 0, 0}, - {"append", 0, 0, 0}, - {"delete", 1, 0, 0}, - {"verbose", 0, 0, 0}, - {"create", 0, 0, 0}, - {"file", 1, 0, 0}, - {0, 0, 0, 0} - }; - - c = getopt_long (argc, argv, "abc:d:0123456789", - long_options, &option_index); - if (c == EOF) - break; - - switch (c) - { - case 0: - printf ("option %s", long_options[option_index].name); - if (optarg) - printf (" with arg %s", optarg); - printf ("\n"); - break; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (digit_optind != 0 && digit_optind != this_option_optind) - printf ("digits occur in two different argv-elements.\n"); - digit_optind = this_option_optind; - printf ("option %c\n", c); - break; - - case 'a': - printf ("option a\n"); - break; - - case 'b': - printf ("option b\n"); - break; - - case 'c': - printf ("option c with value `%s'\n", optarg); - break; - - case 'd': - printf ("option d with value `%s'\n", optarg); - break; - - case '?': - break; - - default: - printf ("?? getopt returned character code 0%o ??\n", c); - } - } - - if (optind < argc) - { - printf ("non-option ARGV-elements: "); - while (optind < argc) - printf ("%s ", argv[optind++]); - printf ("\n"); - } - - exit (0); -} - -#endif /* TEST */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sea...@us...> - 2006-11-20 22:39:12
|
Revision: 17793 http://svn.sourceforge.net/gaim/?rev=17793&view=rev Author: seanegan Date: 2006-11-20 14:39:08 -0800 (Mon, 20 Nov 2006) Log Message: ----------- I think that setting info on connection is an AIM-specific thing. Jabber, at least, has the server save the vcard and you should only set it when it changes. Setting it on connection can break things. If you know another protocol that requires info to be set on connection, please add it to that prpl. Modified Paths: -------------- trunk/libgaim/connection.c trunk/libgaim/protocols/oscar/oscar.c Modified: trunk/libgaim/connection.c =================================================================== --- trunk/libgaim/connection.c 2006-11-20 22:00:31 UTC (rev 17792) +++ trunk/libgaim/connection.c 2006-11-20 22:39:08 UTC (rev 17793) @@ -309,9 +309,6 @@ serv_set_permit_deny(gc); update_keepalive(gc, TRUE); - - if (gaim_account_get_user_info(account) != NULL) - serv_set_info(gc, gaim_account_get_user_info(account)); } else if (gc->state == GAIM_DISCONNECTED) { GaimAccount *account = gaim_connection_get_account(gc); Modified: trunk/libgaim/protocols/oscar/oscar.c =================================================================== --- trunk/libgaim/protocols/oscar/oscar.c 2006-11-20 22:00:31 UTC (rev 17792) +++ trunk/libgaim/protocols/oscar/oscar.c 2006-11-20 22:39:08 UTC (rev 17793) @@ -3533,6 +3533,9 @@ aim_clientready(od, conn); + if (gaim_account_get_user_info(account) != NULL) + serv_set_info(gc, gaim_account_get_user_info(account)); + /* Set our available message based on the current status */ status = gaim_account_get_active_status(account); if (gaim_status_is_available(status)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-11-28 09:18:20
|
Revision: 17839 http://svn.sourceforge.net/gaim/?rev=17839&view=rev Author: thekingant Date: 2006-11-28 01:18:20 -0800 (Tue, 28 Nov 2006) Log Message: ----------- I find this to be slightly cleaner Modified Paths: -------------- trunk/libgaim/account.c trunk/libgaim/buddyicon.c Modified: trunk/libgaim/account.c =================================================================== --- trunk/libgaim/account.c 2006-11-28 09:05:34 UTC (rev 17838) +++ trunk/libgaim/account.c 2006-11-28 09:18:20 UTC (rev 17839) @@ -1232,9 +1232,8 @@ if (account->buddy_icon != NULL && (icon == NULL || strcmp(account->buddy_icon, icon))) { const char *dirname = gaim_buddy_icons_get_cache_dir(); - struct stat st; - if (g_stat(account->buddy_icon, &st) == 0) + if (g_file_test(account->buddy_icon, G_FILE_TEST_IS_REGULAR)) { /* The file exists. This is a full path. */ Modified: trunk/libgaim/buddyicon.c =================================================================== --- trunk/libgaim/buddyicon.c 2006-11-28 09:05:34 UTC (rev 17838) +++ trunk/libgaim/buddyicon.c 2006-11-28 09:18:20 UTC (rev 17839) @@ -492,12 +492,10 @@ } char *gaim_buddy_icons_get_full_path(const char *icon) { - struct stat st; - if (icon == NULL) return NULL; - if (g_stat(icon, &st) == 0) + if (g_file_test(icon, G_FILE_TEST_IS_REGULAR)) return g_strdup(icon); else return g_build_filename(gaim_buddy_icons_get_cache_dir(), icon, NULL); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dat...@us...> - 2006-12-04 01:52:12
|
Revision: 17885 http://svn.sourceforge.net/gaim/?rev=17885&view=rev Author: datallah Date: 2006-12-03 17:52:05 -0800 (Sun, 03 Dec 2006) Log Message: ----------- Fix wingaim file receiving. It turns out that _access() on win32 is really horrible and will fail on directories when checking any other mode than F_OK. Modified Paths: -------------- trunk/libgaim/ft.c trunk/libgaim/internal.h trunk/libgaim/win32/libc_interface.h Modified: trunk/libgaim/ft.c =================================================================== --- trunk/libgaim/ft.c 2006-12-03 21:49:17 UTC (rev 17884) +++ trunk/libgaim/ft.c 2006-12-04 01:52:05 UTC (rev 17885) @@ -219,9 +219,14 @@ if (g_stat(filename, &st) != 0) { /* File not found. */ if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { +#ifndef _WIN32 + int mode = W_OK; +#else + int mode = F_OK; +#endif dir = g_path_get_dirname(filename); - if (g_access(dir, W_OK) == 0) { + if (g_access(dir, mode) == 0) { gaim_xfer_request_accepted(xfer, filename); } else { gaim_xfer_ref(xfer); Modified: trunk/libgaim/internal.h =================================================================== --- trunk/libgaim/internal.h 2006-12-03 21:49:17 UTC (rev 17884) +++ trunk/libgaim/internal.h 2006-12-04 01:52:05 UTC (rev 17885) @@ -142,7 +142,7 @@ # define g_open open #endif -#if !GLIB_CHECK_VERSION(2,8,0) +#if !GLIB_CHECK_VERSION(2,8,0) && !defined _WIN32 # define g_access access #endif Modified: trunk/libgaim/win32/libc_interface.h =================================================================== --- trunk/libgaim/win32/libc_interface.h 2006-12-03 21:49:17 UTC (rev 17884) +++ trunk/libgaim/win32/libc_interface.h 2006-12-04 01:52:05 UTC (rev 17885) @@ -123,7 +123,6 @@ #if !GLIB_CHECK_VERSION(2,8,0) int wgaim_g_access(const gchar *filename, int mode); -#undef g_access #define g_access( filename, mode) \ wgaim_g_access( filename, mode ) #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2006-12-10 02:53:12
|
Revision: 17929 http://svn.sourceforge.net/gaim/?rev=17929&view=rev Author: evands Date: 2006-12-09 18:53:09 -0800 (Sat, 09 Dec 2006) Log Message: ----------- User Info and Tooltips now use the GaimNotifyUserInfo object and methods defined in notify.h. GaimNotifyUserInfo objects encapsulate a list of GaimNotifyUserInfoEntry objects, each of which may have a label, a value, and be specified to be a section header. This moves the burden of UI generation of user information from the various prpls to the UI. The UI can choose how to display the information rather than being fenced into a particular HTML formatting. Consistency across the prpls' information presentation is now enforced, as well. gaim_notify_user_info_get_text_with_newline() generates text in the: <b>label</b>: value <b>label</b>: value format as was passed by convention from prpls in the past. Modified Paths: -------------- trunk/libgaim/notify.c trunk/libgaim/notify.h trunk/libgaim/protocols/gg/gg.c trunk/libgaim/protocols/irc/msgs.c trunk/libgaim/protocols/jabber/buddy.c trunk/libgaim/protocols/jabber/jabber.c trunk/libgaim/protocols/msn/msn.c trunk/libgaim/protocols/novell/novell.c trunk/libgaim/protocols/oscar/oscar.c trunk/libgaim/protocols/oscar/oscarcommon.h trunk/libgaim/protocols/qq/buddy_info.c trunk/libgaim/protocols/qq/qq.c trunk/libgaim/protocols/sametime/sametime.c trunk/libgaim/protocols/yahoo/yahoo.c trunk/libgaim/protocols/yahoo/yahoo.h trunk/libgaim/protocols/yahoo/yahoo_profile.c trunk/libgaim/protocols/zephyr/zephyr.c trunk/libgaim/prpl.h trunk/libgaim/util.c trunk/libgaim/util.h Modified: trunk/libgaim/notify.c =================================================================== --- trunk/libgaim/notify.c 2006-12-09 20:20:17 UTC (rev 17928) +++ trunk/libgaim/notify.c 2006-12-10 02:53:09 UTC (rev 17929) @@ -36,6 +36,21 @@ gpointer cb_user_data; } GaimNotifyInfo; +/** + * Definition of a user info entry + */ +struct _GaimNotifyUserInfoEntry +{ + char *label; + char *value; + gboolean is_header; +}; + +struct _GaimNotifyUserInfo +{ + GList *user_info_entries; +}; + void * gaim_notify_message(void *handle, GaimNotifyMsgType type, const char *title, const char *primary, @@ -416,7 +431,7 @@ void * gaim_notify_userinfo(GaimConnection *gc, const char *who, - const char *text, GaimNotifyCloseCallback cb, gpointer user_data) + GaimNotifyUserInfo *user_info, GaimNotifyCloseCallback cb, gpointer user_data) { GaimNotifyUiOps *ops; @@ -426,21 +441,18 @@ if (ops != NULL && ops->notify_userinfo != NULL) { GaimNotifyInfo *info; - char *infotext = g_strdup(text); info = g_new0(GaimNotifyInfo, 1); info->type = GAIM_NOTIFY_USERINFO; info->handle = gc; gaim_signal_emit(gaim_notify_get_handle(), "displaying-userinfo", - gaim_connection_get_account(gc), who, &infotext); + gaim_connection_get_account(gc), who, user_info); - info->ui_handle = ops->notify_userinfo(gc, who, infotext); + info->ui_handle = ops->notify_userinfo(gc, who, user_info); info->cb = cb; info->cb_user_data = user_data; - g_free(infotext); - if (info->ui_handle != NULL) { handles = g_list_append(handles, info); @@ -463,6 +475,158 @@ return NULL; } +static GaimNotifyUserInfoEntry * +gaim_notify_user_info_entry_new(const char *label, const char *value) +{ + GaimNotifyUserInfoEntry *user_info_entry; + + user_info_entry = g_new0(GaimNotifyUserInfoEntry, 1); + user_info_entry->label = g_strdup(label); + user_info_entry->value = g_strdup(value); + user_info_entry->is_header = FALSE; + + return user_info_entry; +} + +static void +gaim_notify_user_info_entry_destroy(GaimNotifyUserInfoEntry *user_info_entry) +{ + g_return_if_fail(user_info_entry != NULL); + + g_free(user_info_entry->label); + g_free(user_info_entry->value); + g_free(user_info_entry); +} + +GaimNotifyUserInfo * +gaim_notify_user_info_new() +{ + GaimNotifyUserInfo *user_info; + + user_info = g_new0(GaimNotifyUserInfo, 1); + user_info->user_info_entries = NULL; + + return user_info; +} + +void +gaim_notify_user_info_destroy(GaimNotifyUserInfo *user_info) +{ + GList *l; + + for (l = user_info->user_info_entries; l != NULL; l = l->next) { + GaimNotifyUserInfoEntry *user_info_entry = l->data; + + gaim_notify_user_info_entry_destroy(user_info_entry); + } + + g_list_free(user_info->user_info_entries); +} + +GList * +gaim_notify_user_info_get_entries(GaimNotifyUserInfo *user_info) +{ + g_return_val_if_fail(user_info != NULL, NULL); + + return user_info->user_info_entries; +} + +char * +gaim_notify_user_info_get_text_with_newline(GaimNotifyUserInfo *user_info, const char *newline) +{ + GList *l; + GString *text; + + text = g_string_new(""); + + for (l = user_info->user_info_entries; l != NULL; l = l->next) { + GaimNotifyUserInfoEntry *user_info_entry = l->data; + if (user_info_entry->is_header) + g_string_append(text, newline); + + if (user_info_entry->label) + g_string_append_printf(text, "<b>%s</b>", user_info_entry->label); + if (user_info_entry->label && user_info_entry->value) + g_string_append(text, ": "); + if (user_info_entry->value) + g_string_append(text, user_info_entry->value); + + if (user_info_entry->is_header) + g_string_append(text, newline); + + if (l->next) + g_string_append(text, newline); + } + + return g_string_free(text, FALSE); +} + + +gchar * +gaim_notify_user_info_entry_get_label(GaimNotifyUserInfoEntry *user_info_entry) +{ + g_return_val_if_fail(user_info_entry != NULL, NULL); + + return user_info_entry->label; +} + +gchar * +gaim_notify_user_info_entry_get_value(GaimNotifyUserInfoEntry *user_info_entry) +{ + g_return_val_if_fail(user_info_entry != NULL, NULL); + + return user_info_entry->value; +} + +void +gaim_notify_user_info_add_pair(GaimNotifyUserInfo *user_info, const char *label, const char *value) +{ + GaimNotifyUserInfoEntry *entry; + + entry = gaim_notify_user_info_entry_new(label, value); + user_info->user_info_entries = g_list_append(user_info->user_info_entries, entry); +} + +void +gaim_notify_user_info_prepend_pair(GaimNotifyUserInfo *user_info, const char *label, const char *value) +{ + GaimNotifyUserInfoEntry *entry; + + entry = gaim_notify_user_info_entry_new(label, value); + user_info->user_info_entries = g_list_prepend(user_info->user_info_entries, entry); +} + +void +gaim_notify_user_info_add_section_header(GaimNotifyUserInfo *user_info, const char *label) +{ + GaimNotifyUserInfoEntry *entry; + + entry = gaim_notify_user_info_entry_new(label, NULL); + entry->is_header = TRUE; + + user_info->user_info_entries = g_list_append(user_info->user_info_entries, entry); +} + +/** + * Remove the last item which was added to user_info + * This is helpful for removing a section header if the section was empty. + */ +void +gaim_notify_user_info_remove_last_item(GaimNotifyUserInfo *user_info) +{ + user_info->user_info_entries = g_list_remove(user_info->user_info_entries, + g_list_last(user_info->user_info_entries)->data); +} + +void +gaim_notify_user_info_add_section_break(GaimNotifyUserInfo *user_info) +{ + /* This is for future expansion; section breaks should be marked as such so the UI + * can format them differently if desired. + */ + gaim_notify_user_info_add_pair(user_info, NULL, "<HR>"); +} + void * gaim_notify_uri(void *handle, const char *uri) { Modified: trunk/libgaim/notify.h =================================================================== --- trunk/libgaim/notify.h 2006-12-09 20:20:17 UTC (rev 17928) +++ trunk/libgaim/notify.h 2006-12-10 02:53:09 UTC (rev 17929) @@ -29,9 +29,11 @@ #include <glib-object.h> #include <glib.h> +typedef struct _GaimNotifyUserInfoEntry GaimNotifyUserInfoEntry; +typedef struct _GaimNotifyUserInfo GaimNotifyUserInfo; + #include "connection.h" - /** * Notification close callbacks. */ @@ -154,7 +156,7 @@ void *data); void *(*notify_userinfo)(GaimConnection *gc, const char *who, - const char *text); + GaimNotifyUserInfo *user_info); void *(*notify_uri)(const char *uri); @@ -403,20 +405,113 @@ * The text is essentially a stripped-down format of HTML, the same that * IMs may send. * - * @param gc The GaimConnection handle associated with the information. - * @param who The username associated with the information. - * @param text The formatted text. - * @param cb The callback to call when the user closes - * the notification. - * @param user_data The data to pass to the callback. + * @param gc The GaimConnection handle associated with the information. + * @param who The username associated with the information. + * @param user_info The GaimNotifyUserInfo which contains the information + * @param cb The callback to call when the user closes + * the notification. + * @param user_data The data to pass to the callback. * * @return A UI-specific handle. */ void *gaim_notify_userinfo(GaimConnection *gc, const char *who, - const char *text, GaimNotifyCloseCallback cb, + GaimNotifyUserInfo *user_info, GaimNotifyCloseCallback cb, gpointer user_data); /** + * Create a new GaimNotifyUserInfo which is suitable for passing to gaim_notify_userinfo() + * + * @return A new GaimNotifyUserInfo, which the caller must destroy when done + */ +GaimNotifyUserInfo *gaim_notify_user_info_new(); + +/** + * Destroy a GaimNotifyUserInfo + * + * @param user_info The GaimNotifyUserInfo + */ +void gaim_notify_user_info_destroy(GaimNotifyUserInfo *user_info); + +/** + * Retrieve the array of GaimNotifyUserInfoEntry objects from a GaimNotifyUserInfo + * + * @param user_info The GaimNotifyUserInfo + * + * @result A GList of GaimNotifyUserInfoEntry objects + */ +GList *gaim_notify_user_info_get_entries(GaimNotifyUserInfo *user_info); + +/** + * Create a textual representation of a GaimNotifyUserInfo, separating entries with newline + * + * @param user_info The GaimNotifyUserInfo + * @param newline The separation character + */ +char *gaim_notify_user_info_get_text_with_newline(GaimNotifyUserInfo *user_info, const char *newline); + +/** + * Add a label/value pair to a GaimNotifyUserInfo object. GaimNotifyUserInfo keeps track of the order in which pairs are added. + * + * @param user_info The GaimNotifyUserInfo + * @param label A label, which for example might be displayed by a UI with a colon after it ("Status:"). Do not include a colon. + * If NULL, value will be displayed without a label. + * @param value The value, which might be displayed by a UI after the label. + * If NULL, label will still be displayed; the UI should then treat label as independent + * and not include a colon if it would otherwise. + */ +void gaim_notify_user_info_add_pair(GaimNotifyUserInfo *user_info, const char *label, const char *value); + +/** + * Prepend a label/value pair to a GaimNotifyUserInfo object + * + * @param user_info The GaimNotifyUserInfo + * @param label A label, which for example might be displayed by a UI with a colon after it ("Status:"). Do not include a colon. + * If NULL, value will be displayed without a label. + * @param value The value, which might be displayed by a UI after the label. + * If NULL, label will still be displayed; the UI should then treat label as independent + * and not include a colon if it would otherwise. + */ +void gaim_notify_user_info_prepend_pair(GaimNotifyUserInfo *user_info, const char *label, const char *value); + +/** + * Add a section break. A UI might display this as a horizontal line. + * + * @param user_info The GaimNotifyUserInfo + */ +void gaim_notify_user_info_add_section_break(GaimNotifyUserInfo *user_info); + +/** + * Add a section header. A UI might display this in a different font from other text. + * + * @param user_info The GaimNotifyUserInfo + * @param label The name of the section + */ +void gaim_notify_user_info_add_section_header(GaimNotifyUserInfo *user_info, const char *label); + +/** + * Remove the last item which was added to a GaimNotifyUserInfo. This could be used to remove a section header which is not needed. + */ +void gaim_notify_user_info_remove_last_item(GaimNotifyUserInfo *user_info); + +/** + * Get the label for a GaimNotifyUserInfoEntry + * + * @param user_info_entry The GaimNotifyUserInfoEntry + * + * @result The label + */ +gchar *gaim_notify_user_info_entry_get_label(GaimNotifyUserInfoEntry *user_info_entry); + +/** + * Get the value for a GaimNotifyUserInfoEntry + * + * @param user_info_entry The GaimNotifyUserInfoEntry + * + * @result The value + */ +gchar *gaim_notify_user_info_entry_get_value(GaimNotifyUserInfoEntry *user_info_entry); + +/** * Opens a URI or somehow presents it to the user. * * @param handle The plugin or connection handle. Modified: trunk/libgaim/protocols/gg/gg.c =================================================================== --- trunk/libgaim/protocols/gg/gg.c 2006-12-09 20:20:17 UTC (rev 17928) +++ trunk/libgaim/protocols/gg/gg.c 2006-12-10 02:53:09 UTC (rev 17929) @@ -1013,56 +1013,47 @@ static void ggp_pubdir_handle_info(GaimConnection *gc, gg_pubdir50_t req, GGPSearchForm *form) { - GString *text; + GaimNotifyUserInfo *user_info; char *val, *who; - text = g_string_new(""); + user_info = gaim_notify_user_info_new(); val = ggp_search_get_result(req, 0, GG_PUBDIR50_STATUS); /* XXX: Use of ggp_str_to_uin() is an ugly hack! */ - g_string_append_printf(text, "<b>%s:</b> %s<br/>", - _("Status"), ggp_status_by_id(ggp_str_to_uin(val))); + gaim_notify_user_info_add_pair(user_info, _("Status"), ggp_status_by_id(ggp_str_to_uin(val))); g_free(val); who = ggp_search_get_result(req, 0, GG_PUBDIR50_UIN); - g_string_append_printf(text, "<b>%s:</b> %s<br/>", - _("UIN"), who); + gaim_notify_user_info_add_pair(user_info, _("UIN"), who); val = ggp_search_get_result(req, 0, GG_PUBDIR50_FIRSTNAME); - g_string_append_printf(text, "<b>%s:</b> %s<br/>", - _("First Name"), val); + gaim_notify_user_info_add_pair(user_info, _("First Name"), val); g_free(val); val = ggp_search_get_result(req, 0, GG_PUBDIR50_NICKNAME); - g_string_append_printf(text, "<b>%s:</b> %s<br/>", - _("Nickname"), val); + gaim_notify_user_info_add_pair(user_info, _("Nickname"), val); g_free(val); val = ggp_search_get_result(req, 0, GG_PUBDIR50_CITY); - g_string_append_printf(text, "<b>%s:</b> %s<br/>", - _("City"), val); + gaim_notify_user_info_add_pair(user_info, _("City"), val); g_free(val); val = ggp_search_get_result(req, 0, GG_PUBDIR50_BIRTHYEAR); - if (strncmp(val, "0", 1) == 0) { - g_free(val); - val = g_strdup(""); + if (strncmp(val, "0", 1)) { + gaim_notify_user_info_add_pair(user_info, _("Birth Year"), val); } - g_string_append_printf(text, "<b>%s:</b> %s<br/>", - _("Birth Year"), val); g_free(val); val = ggp_buddy_get_name(gc, ggp_str_to_uin(who)); g_free(who); who = val; - val = gaim_strdup_withhtml(text->str); +/* val = gaim_strdup_withhtml(text->str); */ - gaim_notify_userinfo(gc, who, val, ggp_sr_close_cb, form); - - g_string_free(text, TRUE); + gaim_notify_userinfo(gc, who, user_info, ggp_sr_close_cb, form); g_free(val); g_free(who); + gaim_notify_user_info_destroy(user_info); } /* }}} */ @@ -1558,11 +1549,11 @@ } /* }}} */ -/* static void ggp_tooltip_text(GaimBuddy *b, GString *str, gboolean full) {{{ */ -static void ggp_tooltip_text(GaimBuddy *b, GString *str, gboolean full) +/* static void ggp_tooltip_text(GaimBuddy *b, GaimNotifyUserInfo *user_info, gboolean full) {{{ */ +static void ggp_tooltip_text(GaimBuddy *b, GaimNotifyUserInfo *user_info, gboolean full) { GaimStatus *status; - char *text; + char *text, *tmp; const char *msg, *name; g_return_if_fail(b != NULL); @@ -1574,16 +1565,15 @@ if (msg != NULL) { text = g_markup_escape_text(msg, -1); if (GAIM_BUDDY_IS_ONLINE(b)) { - g_string_append_printf(str, "\n<b>%s:</b> %s: %s", - _("Status"), name, text); + tmp = g_strdup_printf("%s: %s", name, text); + gaim_notify_user_info_add_pair(user_info, _("Status"), tmp); + g_free(tmp); } else { - g_string_append_printf(str, "\n<b>%s:</b>: %s", - _("Message"), text); + gaim_notify_user_info_add_pair(user_info, _("Message"), text); } g_free(text); - } else if (GAIM_BUDDY_IS_ONLINE(b)) { - g_string_append_printf(str, "\n<b>%s:</b> %s", - _("Status"), name); + } else { + gaim_notify_user_info_add_pair(user_info, _("Status"), name); } } /* }}} */ Modified: trunk/libgaim/protocols/irc/msgs.c =================================================================== --- trunk/libgaim/protocols/irc/msgs.c 2006-12-09 20:20:17 UTC (rev 17928) +++ trunk/libgaim/protocols/irc/msgs.c 2006-12-10 02:53:09 UTC (rev 17929) @@ -199,7 +199,8 @@ { GaimConnection *gc; GString *info; - char *str, *tmp; + char *str, *tmp, *tmp2; + GaimNotifyUserInfo *user_info; if (!irc->whois.nick) { gaim_debug(GAIM_DEBUG_WARNING, "irc", "Unexpected End of WHOIS for %s\n", args[1]); @@ -210,55 +211,59 @@ return; } - info = g_string_new(""); - tmp = g_markup_escape_text(args[1], -1); - g_string_append_printf(info, _("<b>%s:</b> %s"), _("Nick"), tmp); + user_info = gaim_notify_user_info_new(); + + tmp2 = g_markup_escape_text(args[1], -1); + tmp = g_strdup_printf("%s%s%s", tmp2, + (irc->whois.ircop ? _(" <i>(ircop)</i>") : ""), + (irc->whois.identified ? _(" <i>(identified)</i>") : "")); + gaim_notify_user_info_add_pair(user_info, _("Nick"), tmp); + g_free(tmp2); g_free(tmp); - g_string_append_printf(info, "%s%s<br>", - irc->whois.ircop ? _(" <i>(ircop)</i>") : "", - irc->whois.identified ? _(" <i>(identified)</i>") : ""); + if (irc->whois.away) { tmp = g_markup_escape_text(irc->whois.away, strlen(irc->whois.away)); g_free(irc->whois.away); - g_string_append_printf(info, _("<b>%s:</b> %s<br>"), _("Away"), tmp); + gaim_notify_user_info_add_pair(user_info, _("Away"), tmp); g_free(tmp); } if (irc->whois.userhost) { tmp = g_markup_escape_text(irc->whois.name, strlen(irc->whois.name)); g_free(irc->whois.name); - g_string_append_printf(info, _("<b>%s:</b> %s<br>"), _("Username"), irc->whois.userhost); - g_string_append_printf(info, _("<b>%s:</b> %s<br>"), _("Real name"), tmp); + gaim_notify_user_info_add_pair(user_info, _("Username"), irc->whois.userhost); + gaim_notify_user_info_add_pair(user_info, _("Real name"), tmp); g_free(irc->whois.userhost); g_free(tmp); } if (irc->whois.server) { - g_string_append_printf(info, _("<b>%s:</b> %s"), _("Server"), irc->whois.server); - g_string_append_printf(info, " (%s)<br>", irc->whois.serverinfo); + tmp = g_strdup_printf("%s (%s)", irc->whois.server, irc->whois.serverinfo); + gaim_notify_user_info_add_pair(user_info, _("Server"), tmp); + g_free(tmp); g_free(irc->whois.server); g_free(irc->whois.serverinfo); } if (irc->whois.channels) { - g_string_append_printf(info, _("<b>%s:</b> %s<br>"), _("Currently on"), irc->whois.channels); + gaim_notify_user_info_add_pair(user_info, _("Currently on"), irc->whois.channels); g_free(irc->whois.channels); } if (irc->whois.idle) { gchar *timex = gaim_str_seconds_to_string(irc->whois.idle); - g_string_append_printf(info, _("<b>Idle for:</b> %s<br>"), timex); + gaim_notify_user_info_add_pair(user_info, _("Idle for"), timex); g_free(timex); - g_string_append_printf(info, _("<b>%s:</b> %s"), _("Online since"), - gaim_date_format_full(localtime(&irc->whois.signon))); + gaim_notify_user_info_add_pair(user_info, + _("Online since"), gaim_date_format_full(localtime(&irc->whois.signon))); } if (!strcmp(irc->whois.nick, "Paco-Paco")) { - g_string_append_printf(info, _("<br><b>Defining adjective:</b> Glorious<br>")); + gaim_notify_user_info_add_pair(user_info, + _("<b>Defining adjective:</b>"), _("Glorious")); } gc = gaim_account_get_connection(irc->account); - str = g_string_free(info, FALSE); - gaim_notify_userinfo(gc, irc->whois.nick, str, NULL, NULL); + gaim_notify_userinfo(gc, irc->whois.nick, user_info, NULL, NULL); + gaim_notify_user_info_destroy(user_info); g_free(irc->whois.nick); - g_free(str); memset(&irc->whois, 0, sizeof(irc->whois)); } Modified: trunk/libgaim/protocols/jabber/buddy.c =================================================================== --- trunk/libgaim/protocols/jabber/buddy.c 2006-12-09 20:20:17 UTC (rev 17928) +++ trunk/libgaim/protocols/jabber/buddy.c 2006-12-10 02:53:09 UTC (rev 17929) @@ -602,17 +602,17 @@ static void jabber_buddy_info_show_if_ready(JabberBuddyInfo *jbi) { - GString *info_text; - char *resource_name; + char *resource_name, *tmp; JabberBuddyResource *jbr; JabberBuddyInfoResource *jbir = NULL; GList *resources; + GaimNotifyUserInfo *user_info; /* not yet */ if(jbi->ids) return; - info_text = g_string_new(""); + user_info = gaim_notify_user_info_new(); resource_name = jabber_get_resource(jbi->jid); if(resource_name) { @@ -622,29 +622,29 @@ char *purdy = NULL; if(jbr->status) purdy = gaim_strdup_withhtml(jbr->status); - g_string_append_printf(info_text, "<b>%s:</b> %s%s%s<br/>", - _("Status"), jabber_buddy_state_get_name(jbr->state), - purdy ? ": " : "", - purdy ? purdy : ""); - if(purdy) - g_free(purdy); + tmp = g_strdup_printf("%s%s%s", jabber_buddy_state_get_name(jbr->state), + (purdy ? ": " : ""), + (purdy ? purdy : "")); + gaim_notify_user_info_add_pair(user_info, _("Status"), tmp); + g_free(tmp); + g_free(purdy); } else { - g_string_append_printf(info_text, "<b>%s:</b> %s<br/>", - _("Status"), _("Unknown")); + gaim_notify_user_info_add_pair(user_info, _("Status"), _("Unknown")); } if(jbir) { if(jbir->idle_seconds > 0) { - g_string_append_printf(info_text, "<b>%s:</b> %s<br/>", - _("Idle"), gaim_str_seconds_to_string(jbir->idle_seconds)); + gaim_notify_user_info_add_pair(user_info, _("Idle"), gaim_str_seconds_to_string(jbir->idle_seconds)); } } if(jbr && jbr->client.name) { - g_string_append_printf(info_text, "<b>%s:</b> %s %s<br/>", - _("Client:"), jbr->client.name, - jbr->client.version ? jbr->client.version : ""); + tmp = g_strdup_printf("%s%s%s", jbr->client.name, + (jbr->client.version ? " " : ""), + (jbr->client.version ? jbr->client.version : "")); + gaim_notify_user_info_add_pair(user_info, _("Client"), tmp); + g_free(tmp); + if(jbr->client.os) { - g_string_append_printf(info_text, "<b>%s:</b> %s<br/>", - _("Operating System"), jbr->client.os); + gaim_notify_user_info_add_pair(user_info, _("Operating System"), jbr->client.os); } } } else { @@ -654,54 +654,57 @@ if(jbr->status) purdy = gaim_strdup_withhtml(jbr->status); if(jbr->name) - g_string_append_printf(info_text, "<b>%s:</b> %s<br/>", - _("Resource"), jbr->name); - g_string_append_printf(info_text, "<b>%s:</b> %d<br/>", - _("Priority"), jbr->priority); - g_string_append_printf(info_text, "<b>%s:</b> %s%s%s<br/>", - _("Status"), jabber_buddy_state_get_name(jbr->state), - purdy ? ": " : "", - purdy ? purdy : ""); - if(purdy) - g_free(purdy); + gaim_notify_user_info_add_pair(user_info, _("Resource"), jbr->name); + tmp = g_strdup_printf("%d", jbr->priority); + gaim_notify_user_info_add_pair(user_info, _("Priority"), tmp); + g_free(tmp); + tmp = g_strdup_printf("%s%s%s", jabber_buddy_state_get_name(jbr->state), + (purdy ? ": " : ""), + (purdy ? purdy : "")); + gaim_notify_user_info_add_pair(user_info, _("Status"), tmp); + g_free(tmp); + g_free(purdy); + if(jbr->name) jbir = g_hash_table_lookup(jbi->resources, jbr->name); if(jbir) { if(jbir->idle_seconds > 0) { - g_string_append_printf(info_text, "<b>%s:</b> %s<br/>", - _("Idle"), gaim_str_seconds_to_string(jbir->idle_seconds)); + gaim_notify_user_info_add_pair(user_info, _("Idle"), gaim_str_seconds_to_string(jbir->idle_seconds)); } } - if(jbr->client.name) { - g_string_append_printf(info_text, "<b>%s:</b> %s %s<br/>", - _("Client"), jbr->client.name, - jbr->client.version ? jbr->client.version : ""); + if(jbr && jbr->client.name) { + tmp = g_strdup_printf("%s%s%s", jbr->client.name, + (jbr->client.version ? " " : ""), + (jbr->client.version ? jbr->client.version : "")); + gaim_notify_user_info_add_pair(user_info, + _("Client"), tmp); + g_free(tmp); + if(jbr->client.os) { - g_string_append_printf(info_text, "<b>%s:</b> %s<br/>", - _("Operating System"), jbr->client.os); + gaim_notify_user_info_add_pair(user_info, _("Operating System"), jbr->client.os); } } - - g_string_append_printf(info_text, "<br/>"); } } g_free(resource_name); - if (jbi->vcard_text != NULL) - info_text = g_string_append(info_text, jbi->vcard_text); + if (jbi->vcard_text != NULL) { + gaim_notify_user_info_add_section_break(user_info); + /* Should this have some sort of label? */ + gaim_notify_user_info_add_pair(user_info, NULL, jbi->vcard_text); + } - gaim_notify_userinfo(jbi->js->gc, jbi->jid, info_text->str, NULL, NULL); + gaim_notify_userinfo(jbi->js->gc, jbi->jid, user_info, NULL, NULL); + gaim_notify_user_info_destroy(user_info); while(jbi->vcard_imgids) { gaim_imgstore_unref(GPOINTER_TO_INT(jbi->vcard_imgids->data)); jbi->vcard_imgids = g_slist_delete_link(jbi->vcard_imgids, jbi->vcard_imgids); } - g_string_free(info_text, TRUE); - if (jbi->timeout_handle > 0) gaim_timeout_remove(jbi->timeout_handle); Modified: trunk/libgaim/protocols/jabber/jabber.c =================================================================== --- trunk/libgaim/protocols/jabber/jabber.c 2006-12-09 20:20:17 UTC (rev 17928) +++ trunk/libgaim/protocols/jabber/jabber.c 2006-12-10 02:53:09 UTC (rev 17929) @@ -1127,7 +1127,7 @@ return ret; } -static void jabber_tooltip_text(GaimBuddy *b, GString *str, gboolean full) +static void jabber_tooltip_text(GaimBuddy *b, GaimNotifyUserInfo *user_info, gboolean full) { JabberBuddy *jb; @@ -1160,12 +1160,14 @@ else sub = _("None"); } - g_string_append_printf(str, "\n<b>%s:</b> %s", _("Subscription"), sub); + + gaim_notify_user_info_add_pair(user_info, _("Subscription"), sub); } for(l=jb->resources; l; l = l->next) { char *text = NULL; char *res = NULL; + char *label, *value; const char *state; jbr = l->data; @@ -1188,20 +1190,23 @@ text = NULL; } - g_string_append_printf(str, "\n<b>%s%s:</b> %s%s%s", - _("Status"), - res ? res : "", - state, - text ? ": " : "", - text ? text : ""); + label = g_strdup_printf("%s%s", + _("Status"), (res ? res : "")); + value = g_strdup_printf("%s%s%s", + state, + (text ? ": " : ""), + (text ? text : "")); + gaim_notify_user_info_add_pair(user_info, label, value); + + g_free(label); + g_free(value); g_free(text); g_free(res); } if(!GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { - g_string_append_printf(str, "\n<b>%s:</b> %s", - _("Error"), jb->error_msg); + gaim_notify_user_info_add_pair(user_info, _("Error"), jb->error_msg); } } } Modified: trunk/libgaim/protocols/msn/msn.c =================================================================== --- trunk/libgaim/protocols/msn/msn.c 2006-12-09 20:20:17 UTC (rev 17928) +++ trunk/libgaim/protocols/msn/msn.c 2006-12-10 02:53:09 UTC (rev 17929) @@ -67,10 +67,8 @@ MsnGetInfoData *info_data; char *stripped; char *url_buffer; - GString *s; + GaimNotifyUserInfo *user_info; char *photo_url_text; - char *tooltip_text; - const char *title; } MsnGetInfoStepTwoData; @@ -533,7 +531,7 @@ } static void -msn_tooltip_text(GaimBuddy *buddy, GString *str, gboolean full) +msn_tooltip_text(GaimBuddy *buddy, GaimNotifyUserInfo *user_info, gboolean full) { MsnUser *user; GaimPresence *presence = gaim_buddy_get_presence(buddy); @@ -541,27 +539,27 @@ user = buddy->proto_data; + if (gaim_presence_is_online(presence)) { - g_string_append_printf(str, _("\n<b>%s:</b> %s"), _("Status"), - gaim_presence_is_idle(presence) ? - _("Idle") : gaim_status_get_name(status)); + gaim_notify_user_info_add_pair(user_info, _("Status"), + (gaim_presence_is_idle(presence) ? _("Idle") : gaim_status_get_name(status))); } - + if (full && user) { - g_string_append_printf(str, _("\n<b>%s:</b> %s"), _("Has you"), - (user->list_op & (1 << MSN_LIST_RL)) ? - _("Yes") : _("No")); + gaim_notify_user_info_add_pair(user_info, _("Has you"), + ((user->list_op & (1 << MSN_LIST_RL)) ? _("Yes") : _("No"))); + } /* XXX: This is being shown in non-full tooltips because the * XXX: blocked icon overlay isn't always accurate for MSN. * XXX: This can die as soon as gaim_privacy_check() knows that * XXX: this prpl always honors both the allow and deny lists. */ if (user) - g_string_append_printf(str, _("\n<b>%s:</b> %s"), _("Blocked"), - (user->list_op & (1 << MSN_LIST_BL)) ? - _("Yes") : _("No")); + { + gaim_notify_user_info_add_pair(user_info, _("Blocked"), + ((user->list_op & (1 << MSN_LIST_BL)) ? _("Yes") : _("No"))); } } @@ -1341,47 +1339,44 @@ } } -static char * -msn_tooltip_info_text(MsnGetInfoData *info_data) +/** + * Extract info text from info_data and add it to user_info + */ +static gboolean +msn_tooltip_extract_info_text(GaimNotifyUserInfo *user_info, MsnGetInfoData *info_data) { - GString *s; GaimBuddy *b; - s = g_string_sized_new(80); /* wild guess */ - b = gaim_find_buddy(gaim_connection_get_account(info_data->gc), info_data->name); if (b) { - GString *str = g_string_new(""); char *tmp; if (b->alias && b->alias[0]) { char *aliastext = g_markup_escape_text(b->alias, -1); - g_string_append_printf(s, _("<b>Alias:</b> %s<br>"), aliastext); + gaim_notify_user_info_add_pair(user_info, _("Alias"), aliastext); g_free(aliastext); } if (b->server_alias) { char *nicktext = g_markup_escape_text(b->server_alias, -1); - g_string_append_printf(s, _("<b>%s:</b> "), _("Nickname")); - g_string_append_printf(s, "<font sml=\"msn\">%s</font><br>", - nicktext); + tmp = g_strdup_printf("<font sml=\"msn\">%s</font><br>", nicktext); + gaim_notify_user_info_add_pair(user_info, _("Nickname"), tmp); + g_free(tmp); g_free(nicktext); } - msn_tooltip_text(b, str, TRUE); - tmp = gaim_strreplace((*str->str == '\n' ? str->str + 1 : str->str), - "\n", "<br>"); - g_string_free(str, TRUE); - g_string_append_printf(s, "%s<br>", tmp); - g_free(tmp); + /* Add the tooltip information */ + msn_tooltip_text(b, user_info, TRUE); + + return TRUE; } - return g_string_free(s, FALSE); + return FALSE; } #if PHOTO_SUPPORT @@ -1419,7 +1414,7 @@ #endif #define MSN_GOT_INFO_GET_FIELD(a, b) \ - found = gaim_markup_extract_info_field(stripped, stripped_len, s, \ + found = gaim_markup_extract_info_field(stripped, stripped_len, user_info, \ "\n" a ":", 0, "\n", 0, "Undisclosed", b, 0, NULL, NULL); \ if (found) \ sect_info = TRUE; @@ -1429,17 +1424,15 @@ const gchar *url_text, size_t len, const gchar *error_message) { MsnGetInfoData *info_data = (MsnGetInfoData *)data; - char *stripped, *p, *q; - char buf[1024]; - char *tooltip_text; + GaimNotifyUserInfo *user_info; + char *stripped, *p, *q, *tmp; char *user_url = NULL; gboolean found; + gboolean has_tooltip_text = FALSE; gboolean has_info = FALSE; gboolean sect_info = FALSE; - const char* title = NULL; + gboolean has_contact_info = FALSE; char *url_buffer; - char *personal = NULL; - char *business = NULL; GString *s, *s2; int stripped_len; #if PHOTO_SUPPORT @@ -1458,17 +1451,18 @@ return; } - tooltip_text = msn_tooltip_info_text(info_data); - title = _("MSN Profile"); + user_info = gaim_notify_user_info_new(); + has_tooltip_text = msn_tooltip_extract_info_text(user_info, info_data); if (error_message != NULL || url_text == NULL || strcmp(url_text, "") == 0) { - g_snprintf(buf, 1024, "<html><body>%s<b>%s</b></body></html>", - tooltip_text, _("Error retrieving profile")); + tmp = g_strdup_printf("<b>%s</b>", _("Error retrieving profile")); + gaim_notify_user_info_add_pair(user_info, NULL, tmp); + g_free(tmp); - gaim_notify_userinfo(info_data->gc, info_data->name, buf, NULL, NULL); + gaim_notify_userinfo(info_data->gc, info_data->name, user_info, NULL, NULL); + gaim_notify_user_info_destroy(user_info); - g_free(tooltip_text); g_free(info_data->name); g_free(info_data); return; @@ -1528,10 +1522,16 @@ /* No we're not. */ s = g_string_sized_new(strlen(url_buffer)); s2 = g_string_sized_new(strlen(url_buffer)); - + + /* General section header */ + if (has_tooltip_text) + gaim_notify_user_info_add_section_break(user_info); + + gaim_notify_user_info_add_section_header(user_info, _("General")); + /* Extract their Name and put it in */ - MSN_GOT_INFO_GET_FIELD("Name", _("Name")) - + MSN_GOT_INFO_GET_FIELD("Name", _("Name")); + /* General */ MSN_GOT_INFO_GET_FIELD("Nickname", _("Nickname")); MSN_GOT_INFO_GET_FIELD("Age", _("Age")); @@ -1540,7 +1540,7 @@ MSN_GOT_INFO_GET_FIELD("Location", _("Location")); /* Extract their Interests and put it in */ - found = gaim_markup_extract_info_field(stripped, stripped_len, s, + found = gaim_markup_extract_info_field(stripped, stripped_len, user_info, "\nInterests\t", 0, " (/default.aspx?page=searchresults", 0, "Undisclosed", _("Hobbies and Interests") /* _("Interests") */, 0, NULL, NULL); @@ -1549,20 +1549,24 @@ sect_info = TRUE; MSN_GOT_INFO_GET_FIELD("More about me", _("A Little About Me")); - + if (sect_info) { - /* trim off the trailing "<br>\n" */ - g_string_truncate(s, strlen(s->str) - 5); - g_string_append_printf(s2, _("%s<b>General</b><br>%s"), - (*tooltip_text) ? "<hr>" : "", s->str); - s = g_string_truncate(s, 0); has_info = TRUE; sect_info = FALSE; } - - + else + { + /* Remove the section header */ + gaim_notify_user_info_remove_last_item(user_info); + if (has_tooltip_text) + gaim_notify_user_info_remove_last_item(user_info); + } + /* Social */ + gaim_notify_user_info_add_section_break(user_info); + gaim_notify_user_info_add_section_header(user_info, _("Social")); + MSN_GOT_INFO_GET_FIELD("Marital status", _("Marital Status")); MSN_GOT_INFO_GET_FIELD("Interested in", _("Interests")); MSN_GOT_INFO_GET_FIELD("Pets", _("Pets")); @@ -1575,14 +1579,22 @@ if (sect_info) { - g_string_append_printf(s2, _("%s<b>Social</b><br>%s"), has_info ? "<br><hr>" : "", s->str); - s = g_string_truncate(s, 0); has_info = TRUE; sect_info = FALSE; } + else + { + /* Remove the section header */ + gaim_notify_user_info_remove_last_item(user_info); + gaim_notify_user_info_remove_last_item(user_info); + } /* Contact Info */ /* Personal */ + gaim_notify_user_info_add_section_break(user_info); + gaim_notify_user_info_add_section_header(user_info, _("Contact Info")); + gaim_notify_user_info_add_section_header(user_info, _("Personal")); + MSN_GOT_INFO_GET_FIELD("Name", _("Name")); MSN_GOT_INFO_GET_FIELD("Significant other", _("Significant Other")); MSN_GOT_INFO_GET_FIELD("Home phone", _("Home Phone")); @@ -1598,13 +1610,18 @@ if (sect_info) { - personal = g_strdup_printf(_("<br><b>Personal</b><br>%s"), s->str); - s = g_string_truncate(s, 0); - sect_info = FALSE; has_info = TRUE; + sect_info = FALSE; + has_contact_info = TRUE; } + else + { + /* Remove the section header */ + gaim_notify_user_info_remove_last_item(user_info); + } /* Business */ + gaim_notify_user_info_add_section_header(user_info, _("Work")); MSN_GOT_INFO_GET_FIELD("Name", _("Name")); MSN_GOT_INFO_GET_FIELD("Job title", _("Job Title")); MSN_GOT_INFO_GET_FIELD("Company", _("Company")); @@ -1623,27 +1640,22 @@ if (sect_info) { - business = g_strdup_printf(_("<br><b>Business</b><br>%s"), s->str); - s = g_string_truncate(s, 0); + has_info = TRUE; sect_info = FALSE; + has_contact_info = TRUE; } + else + { + /* Remove the section header */ + gaim_notify_user_info_remove_last_item(user_info); + } - if ((personal != NULL) || (business != NULL)) + if (!has_contact_info) { - /* trim off the trailing "<br>\n" */ - g_string_truncate(s, strlen(s->str) - 5); - - has_info = TRUE; - g_string_append_printf(s2, _("<hr><b>Contact Info</b>%s%s"), - personal ? personal : "", - business ? business : ""); + /* Remove the Contact Info section header */ + gaim_notify_user_info_remove_last_item(user_info); } - g_free(personal); - g_free(business); - g_string_free(s, TRUE); - s = s2; - #if 0 /* these probably don't show up any more */ /* * The fields, 'A Little About Me', 'Favorite Things', 'Hobbies @@ -1768,12 +1780,9 @@ /* If we were able to fetch a homepage url earlier, stick it in there */ if (user_url != NULL) { - g_snprintf(buf, sizeof(buf), - "<b>%s:</b><br><a href=\"%s\">%s</a><br>\n", - _("Homepage"), user_url, user_url); - - g_string_append(s, buf); - + tmp = g_strdup_printf("<a href=\"%s\">%s</a>", user_url, user_url); + gaim_notify_user_info_add_pair(user_info, _("Homepage"), tmp); + g_free(tmp); g_free(user_url); has_info = TRUE; @@ -1792,26 +1801,23 @@ char *p = strstr(url_buffer, "form id=\"SpacesSearch\" name=\"SpacesSearch\""); GaimBuddy *b = gaim_find_buddy (gaim_connection_get_account(info_data->gc), info_data->name); - g_string_append_printf(s, "<br><b>%s</b><br>%s<br><br>", - _("Error retrieving profile"), - ((p && b)? - _("The user has not created a public profile."): - p? _("MSN reported not being able to find the user's profile. " - "This either means that the user does not exist, " - "or that the user exists " - "but has not created a public profile."): - _("Gaim could not find " /* This should never happen */ - "any information in the user's profile. " - "The user most likely does not exist."))); + gaim_notify_user_info_add_pair(user_info, _("Error retrieving profile"), + ((p && b) ? _("The user has not created a public profile.") : + (p ? _("MSN reported not being able to find the user's profile. " + "This either means that the user does not exist, " + "or that the user exists " + "but has not created a public profile.") : + _("Gaim could not find " /* This should never happen */ + "any information in the user's profile. " + "The user most likely does not exist.")))); } + /* put a link to the actual profile URL */ - g_string_append_printf(s, _("<hr><b>%s:</b> "), _("Profile URL")); - g_string_append_printf(s, "<br><a href=\"%s%s\">%s%s</a><br>", - PROFILE_URL, info_data->name, PROFILE_URL, info_data->name); + tmp = g_strdup_printf("<a href=\"%s%s\">%s%s</a>", + PROFILE_URL, info_data->name, PROFILE_URL, info_data->name); + gaim_notify_user_info_add_pair(user_info, _("Profile URL"), tmp); + g_free(tmp); - /* Finish it off, and show it to them */ - g_string_append(s, "</body></html>\n"); - #if PHOTO_SUPPORT /* Find the URL to the photo; must be before the marshalling [Bug 994207] */ photo_url_text = msn_get_photo_url(url_text); @@ -1821,10 +1827,8 @@ info2_data->info_data = info_data; info2_data->stripped = stripped; info2_data->url_buffer = url_buffer; - info2_data->s = s; + info2_data->user_info = user_info; info2_data->photo_url_text = photo_url_text; - info2_data->tooltip_text = tooltip_text; - info2_data->title = title; /* Try to put the photo in there too, if there's one */ if (photo_url_text) @@ -1851,9 +1855,8 @@ MsnGetInfoData *info_data = info2_data->info_data; char *stripped = info2_data->stripped; char *url_buffer = info2_data->url_buffer; - GString *s = info2_data->s; + GaimNotifyUserInfo *user_info = info2_data->user_info; char *photo_url_text = info2_data->photo_url_text; - char *tooltip_text = info2_data->tooltip_text; /* Make sure the connection is still valid if we got here by fetching a photo url */ if (url_text && (error_message != NULL || @@ -1862,8 +1865,7 @@ gaim_debug_warning("msn", "invalid connection. ignoring buddy photo info.\n"); g_free(stripped); g_free(url_buffer); - g_string_free(s, TRUE); - g_free(tooltip_text); + g_free(user_info); g_free(info_data->name); g_free(info_data); g_free(photo_url_text); @@ -1889,20 +1891,17 @@ gaim_debug_info("msn", "%s is %d bytes\n", photo_url_text, len); id = gaim_imgstore_add(url_text, len, NULL); g_snprintf(buf, sizeof(buf), "<img id=\"%d\"><br>", id); - g_string_prepend(s, buf); + gaim_notify_user_info_prepend_pair(user_info, NULL, buf); } } /* We continue here from msn_got_info, as if nothing has happened */ #endif + gaim_notify_userinfo(info_data->gc, info_data->name, user_info, NULL, NULL); - g_string_prepend(s, tooltip_text); - gaim_notify_userinfo(info_data->gc, info_data->name, s->str, NULL, NULL); - g_free(stripped); g_free(url_buffer); - g_string_free(s, TRUE); - g_free(tooltip_text); + gaim_notify_user_info_destroy(user_info); g_free(info_data->name); g_free(info_data); #if PHOTO_SUPPORT Modified: trunk/libgaim/protocols/novell/novell.c =================================================================== --- trunk/libgaim/protocols/novell/novell.c 2006-12-09 20:20:17 UTC (rev 17928) +++ trunk/libgaim/protocols/novell/novell.c 2006-12-10 02:53:09 UTC (rev 17929) @@ -1494,6 +1494,7 @@ static void _show_info(GaimConnection * gc, NMUserRecord * user_record) { + GaimNotifyUserInfo *user_info = gaim_notify_user_info_new(); GString *info_text; int count, i; NMProperty *property; @@ -1504,21 +1505,20 @@ tag = _("User ID"); value = nm_user_record_get_userid(user_record); if (value) { - g_string_append_printf(info_text, "<b>%s:</b> %s<br>", tag, value); + gaim_notify_user_info_add_pair(user_info, tag, value); } /* tag = _("DN"); value = nm_user_record_get_dn(user_record); if (value) { - g_string_append_printf(info_text, "<b>%s:</b> %s<br>", - tag, value); + gaim_notify_user_info_add_pair(user_info, tag, value); } */ tag = _("Full name"); value = nm_user_record_get_full_name(user_record); if (value) { - g_string_append_printf(info_text, "<b>%s:</b> %s<br>", tag, value); + gaim_notify_user_info_add_pair(user_info, tag, value); } count = nm_user_record_get_property_count(user_record); @@ -1528,17 +1528,15 @@ tag = _map_property_tag(nm_property_get_tag(property)); value = nm_property_get_value(property); if (tag && value) { - g_string_append_printf(info_text, "<b>%s:</b> %s<br>", - tag, value); + gaim_notify_user_info_add_pair(user_info, tag, value); } nm_release_property(property); } } gaim_notify_userinfo(gc, nm_user_record_get_userid(user_record), - info_text->str, NULL, NULL); - - g_string_free(info_text, TRUE); + user_info, NULL, NULL); + gaim_notify_user_info_destroy(user_info); } /* Send a join conference, the first item in the parms list is the @@ -2826,7 +2824,7 @@ } static void -novell_tooltip_text(GaimBuddy * buddy, GString * str, gboolean full) +novell_tooltip_text(GaimBuddy * buddy, GaimNotifyUserInfo * user_info, gboolean full) { NMUserRecord *user_record = NULL; GaimConnection *gc; @@ -2869,14 +2867,10 @@ break; } + gaim_notify_user_info_add_pair(user_info, _("Status"), status_str); + if (text) - g_string_append_printf(str, "\n<b>%s:</b> %s" - "\n<b>%s:</b> %s", - _("Status"), status_str, - _("Message"), text); - else - g_string_append_printf(str, "\n<b>%s:</b> %s", - _("Status"), status_str); + gaim_notify_user_info_add_pair(user_info, _("Message"), text); } } } Modified: trunk/libgaim/protocols/oscar/oscar.c =================================================================== --- trunk/libgaim/protocols/oscar/oscar.c 2006-12-09 20:20:17 UTC (rev 17928) +++ trunk/libgaim/protocols/oscar/oscar.c 2006-12-10 02:53:09 UTC (rev 17929) @@ -705,15 +705,26 @@ } static void -oscar_string_append(GString *str, const char *newline, - const char *name, const char *value) +oscar_user_info_add_pair(GaimNotifyUserInfo *user_info, const char *name, const char *value) { if (value && value[0]) { - g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, value); + gaim_notify_user_info_add_pair(user_info, name, value); } } static void +oscar_user_info_convert_and_add_pair(GaimAccount *account, GaimNotifyUserInfo *user_info, + const char *name, const char *value) +{ + gchar *utf8; + + if (value && value[0] && (utf8 = oscar_utf8_try_convert(account, value))) { + gaim_notify_user_info_add_pair(user_info, name, utf8); + g_free(utf8); + } +} + +static void oscar_string_convert_and_append(GaimAccount *account, GString *str, const char *newline, const char *name, const char *value) { @@ -725,8 +736,20 @@ } } -static void oscar_string_append_info(GaimConnection *gc, GString *str, const char *newline, GaimBuddy *b, aim_userinfo_t *userinfo) +static void +oscar_user_info_convert_and_add(GaimAccount *account, GaimNotifyUserInfo *user_info, + const char *name, const char *value) { + gchar *utf8; + + if (value && value[0] && (utf8 = oscar_utf8_try_convert(account, value))) { + gaim_notify_user_info_add_pair(user_info, name, value); + g_free(utf8); + } +} + +static void oscar_string_append_info(GaimConnection *gc, GaimNotifyUserInfo *user_info, GaimBuddy *b, aim_userinfo_t *userinfo) +{ OscarData *od; GaimAccount *account; GaimPresence *presence = NULL; @@ -738,7 +761,7 @@ od = gc->proto_data; account = gaim_connection_get_account(gc); - if ((str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL))) + if ((user_info == NULL) || ((b == NULL) && (userinfo == NULL))) return; if (userinfo == NULL) @@ -760,17 +783,14 @@ if (gaim_presence_is_online(presence)) { if (aim_sn_is_icq(b->name)) { GaimStatus *status = gaim_presence_get_active_status(presence); - oscar_string_append(str, newline, _("Status"), - gaim_status_get_name(status)); + oscar_user_info_add_pair(user_info, _("Status"), gaim_status_get_name(status)); } } else { tmp = aim_ssi_itemlist_findparentname(od->ssi.local, b->name); if (aim_ssi_waitingforauth(od->ssi.local, tmp, b->name)) - oscar_string_append(str, newline, _("Status"), - _("Not Authorized")); + oscar_user_info_add_pair(user_info, _("Status"), _("Not Authorized")); else - oscar_string_append(str, newline, _("Status"), - _("Offline")); + oscar_user_info_add_pair(user_info, _("Status"), _("Offline")); } } @@ -780,14 +800,14 @@ (bi->ipaddr & 0x00ff0000) >> 16, (bi->ipaddr & 0x0000ff00) >> 8, (bi->ipaddr & 0x000000ff)); - oscar_string_append(str, newline, _("IP Address"), tmp); + oscar_user_info_add_pair(user_info, _("IP Address"), tmp); g_free(tmp); } if ((userinfo != NULL) && (userinfo->warnlevel != 0)) { tmp = g_strdup_printf("%d", (int)(userinfo->warnlevel/10.0 + .5)); - oscar_string_append(str, newline, _("Warning Level"), tmp); + oscar_user_info_add_pair(user_info, _("Warning Level"), tmp); g_free(tmp); } @@ -796,7 +816,8 @@ if (tmp != NULL) { char *tmp2 = g_markup_escape_text(tmp, strlen(tmp)); g_free(tmp); - oscar_string_convert_and_append(account, str, newline, _("Buddy Comment"), tmp2); + + oscar_user_info_convert_and_add_pair(account, user_info, _("Buddy Comment"), tmp2); g_free(tmp2); } } @@ -2581,21 +2602,25 @@ switch(reason) { case 0x0003: { /* Reply from an ICQ status message request */ - char *title, *statusmsg, **splitmsg, *dialogmsg; + char *statusmsg, **splitmsg; + GaimNotifyUserInfo *user_info; - title = g_strdup_printf(_("Info for %s"), who); - /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ statusmsg = oscar_icqstatus(state); splitmsg = g_strsplit(msg, "\r\n", 0); - dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg)); + + user_info = gaim_notify_user_info_new(); + + gaim_notify_user_info_add_pair(user_info, _("UIN"), who); + gaim_notify_user_info_add_pair(user_info, _("Status"), statusmsg); + gaim_notify_user_info_add_pair(user_info, NULL, g_strjoinv("<BR>", splitmsg)); + g_free(statusmsg); g_strfreev(splitmsg); - gaim_notify_userinfo(gc, who, dialogmsg, NULL, NULL); + gaim_notify_userinfo(gc, who, user_info, NULL, NULL); + gaim_notify_user_info_destroy(user_info); - g_free(title); - g_free(dialogmsg); } break; default: { @@ -2766,7 +2791,7 @@ static int gaim_parse_userinfo(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) { GaimConnection *gc = od->gc; GaimAccount *account = gaim_connection_get_account(gc); - GString *str; + GaimNotifyUserInfo *user_info; gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL; va_list ap; aim_userinfo_t *userinfo; @@ -2775,33 +2800,36 @@ userinfo = va_arg(ap, aim_userinfo_t *); va_end(ap); - str = g_string_new(""); - g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); - g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); + user_info = gaim_notify_user_info_new(); + gaim_notify_user_info_add_pair(user_info, _("Screen Name"), userinfo->sn); + tmp = g_strdup_printf("%d", (int)((userinfo->warnlevel/10.0) + 0.5)); + gaim_notify_user_info_add_pair(user_info, _("Warning Level"), tmp); + g_free(tmp); + if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) { time_t t = userinfo->onlinesince - od->timeoffset; - oscar_string_append(str, "\n<br>", _("Online Since"), gaim_date_format_full(localtime(&t))); + oscar_user_info_add_pair(user_info, _("Online Since"), gaim_date_format_full(localtime(&t))); } if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) { time_t t = userinfo->membersince - od->timeoffset; - oscar_string_append(str, "\n<br>", _("Member Since"), gaim_date_format_full(localtime(&t))); + oscar_user_info_add_pair(user_info, _("Member Since"), gaim_date_format_full(localtime(&t))); } if (userinfo->capabilities != 0) { tmp = oscar_caps_to_string(userinfo->capabilities); - oscar_string_append(str, "\n<br>", _("Capabilities"), tmp); + oscar_user_info_add_pair(user_info, _("Capabilities"), tmp); g_free(tmp); } if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { tmp = gaim_str_seconds_to_string(userinfo->idletime*60); - oscar_string_append(str, "\n<br>", _("Idle"), tmp); + oscar_user_info_add_pair(user_info, _("Idle"), tmp); g_free(tmp); } - oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); + oscar_string_append_info(gc, user_info, NULL, userinfo); /* Available message */ if ((userinfo->status != NULL) && !(userinfo->flags & AIM_FLAG_AWAY)) @@ -2809,7 +2837,7 @@ if (userinfo->status[0] != '\0') tmp = oscar_encoding_to_utf8(userinfo->status_encoding, userinfo->status, userinfo->status_len); - oscar_string_convert_and_append(account, str, "\n<br>", _("Available Message"), tmp); + oscar_user_info_add_pair(user_info, _("Available Message"), tmp); g_free(tmp); } @@ -2819,7 +2847,9 @@ away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); g_free(tmp); if (away_utf8 != NULL) { - g_string_append_printf(str, "\n<hr>%s", away_utf8); + tmp = gaim_str_sub_away_formatters(away_utf8, gaim_account_get_username(account)); + oscar_user_info_add_pair(user_info, NULL, tmp); + g_free(tmp); g_free(away_utf8); } } @@ -2830,16 +2860,15 @@ info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); g_free(tmp); if (info_utf8 != NULL) { - g_string_append_printf(str, "\n<hr>%s", info_utf8); + tmp = gaim_str_sub_away_formatters(info_utf8, gaim_account_get_username(account)); + oscar_user_info_add_pair(user_info, _("Profile"), tmp); + g_free(tmp); g_free(info_utf8); } } - tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); - g_string_free(str, TRUE); - gaim_str_strip_char(tmp, '\r'); - gaim_notify_userinfo(gc, userinfo->sn, tmp, NULL, NULL); - g_free(tmp); + gaim_notify_userinfo(gc, userinfo->sn, user_info, NULL, NULL); + gaim_notify_user_info_destroy(user_info); return 1; } @@ -3581,8 +3610,10 @@ GaimBuddy *buddy; struct buddyinfo *bi; gchar who[16]; - GString *str; + GaimNotifyUserInfo *user_info; + GString *tmp; gchar *utf8; + gchar *buf; const gchar *alias; va_list ap; struct aim_icq_info *info; @@ -3597,7 +3628,8 @@ if (!info->uin) return 0; - str = g_string_sized_new(100); + user_info = gaim_notify_user_info_new(); + g_snprintf(who, sizeof(who), "%u", info->uin); buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); if (buddy != NULL) @@ -3605,35 +3637,41 @@ else bi = NULL; - g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); - oscar_string_convert_and_append(account, str, "\n<br>", _("Nick"), info->nick); + gaim_notify_user_info_add_pair(user_info, _("UIN"), who); + oscar_user_info_convert_and_add(account, user_info, _("Nick"), info->nick); if ((bi != NULL) && (bi->ipaddr != 0)) { char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", (bi->ipaddr & 0xff000000) >> 24, (bi->ipaddr & 0x00ff0000) >> 16, (bi->ipaddr & 0x0000ff00) >> 8, (bi->ipaddr & 0x000000ff)); - oscar_string_append(str, "\n<br>", _("IP Address"), tstr); + gaim_notify_user_info_add_pair(user_info, _("IP Address"), tstr); g_free(tstr); } - oscar_string_convert_and_append(account, str, "\n<br>", _("First Name"), info->first); - oscar_string_convert_and_append(account, str, "\n<br>", _("Last Name"), info->last); + oscar_user_info_convert_and_add(account, user_info, _("First Name"), info->first); + oscar_user_info_convert_and_add(account, user_info, _("Last Name"), info->last); if (info->email && info->email[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->email))) { - g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("E-Mail Address"), utf8, utf8); + buf = g_strdup_printf("<a href=\"mailto:%s\">%s</a>", utf8, utf8); + gaim_notify_user_info_add_pair(user_info, _("E-Mail Address"), buf); + g_free(buf); g_free(utf8); } if (info->numaddresses && info->email2) { int i; for (i = 0; i < info->numaddresses; i++) { if (info->email2[i] && info->email2[i][0] && (utf8 = oscar_utf8_try_convert(gc->account, info->email2[i]))) { - g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("E-Mail Address"), utf8, utf8); + buf = g_strdup_printf("<a href=\"mailto:%s\">%s</a>", utf8, utf8); + gaim_notify_user_info_add_pair(user_info, _("E-Mail Address"), buf); + g_free(buf); g_free(utf8); } } } - oscar_string_convert_and_append(account, str, "\n<br>", _("Mobile Phone"), info->mobile); + oscar_user_info_convert_and_add(account, user_info, _("Mobile Phone"), info->mobile); + if (info->gender != 0) - oscar_string_append(str, "\n<br>", _("Gender"), info->gender == 1 ? _("Female") : _("Male")); + gaim_notify_user_info_add_pair(user_info, _("Gender"), (info->gender == 1 ? _("Female") : _("Male"))); + if ((info->birthyear > 1900) && (info->birthmonth > 0) && (info->birthday > 0)) { /* Initialize the struct properly or strftime() will crash * under some conditions (e.g. Debian sarge w/ LANG=en_HK). */ @@ -3649,57 +3687,68 @@ * feel free to remove it. --rlaager */ mktime(tm); - oscar_string_append(str, "\n<br>", _("Birthday"), - gaim_date_format_short(tm)); + oscar_user_info_convert_and_add(account, user_info, _("Birthday"), gaim_date_format_short(tm)); } if ((info->age > 0) && (info->age < 255)) { char age[5]; snprintf(age, sizeof(age), "%hhd", info->age); - oscar_string_append(str, "\n<br>", _("Age"), age); + gaim_notify_user_info_add_pair(user_info, + _("Age"), age); } if (info->personalwebpage && info->personalwebpage[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->personalwebpage))) { - g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); + buf = g_strdup_printf("<a href=\"%s\">%s</a>", utf8, utf8); + gaim_notify_user_info_add_pair(user_info, _("Personal Web Page"), buf); + g_free(buf); g_free(utf8); } - if (info->info && info->info[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->info))) { - g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); - g_free(utf8); - } - g_string_append_printf(str, "<hr>"); + + oscar_user_info_convert_and_add(account, user_info, _("Additional Information"), info->info); + +/* g_string_append_printf(str, "<hr>"); */ + if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { - g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); - oscar_string_convert_and_append(account, str, "\n<br>", _("Address"), info->homeaddr); - oscar_string_convert_and_append(account, str, "\n<br>", _("City"), info->homecity); - oscar_string_convert_and_append(account, str, "\n<br>", _("State"), info->homestate); - oscar_string_convert_and_append(account, str, "\n<br>", _("Zip Code"), info->homezip); - g_string_append_printf(str, "\n<hr>"); + tmp = g_string_sized_new(100); + oscar_string_convert_and_append(account, tmp, "\n<br>", _("Address"), info->homeaddr); + oscar_string_convert_and_append(account, tmp, "\n<br>", _("City"), info->homecity); + oscar_string_convert_and_append(account, tmp, "\n<br>", _("State"), info->homestate); + oscar_string_convert_and_append(account, tmp, "\n<br>", _("Zip Code"), info->homezip); + + gaim_notify_user_info_add_pair(user_info, _("Home Address"), tmp->str); + + g_string_free(tmp, TRUE); } if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { - g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); - oscar_string_convert_and_append(account, str, "\n<br>", _("Address"), info->workaddr); - oscar_string_convert_and_append(account, str, "\n<br>", _("City"), info->workcity); - oscar_string_convert_and_append(account, str, "\n<br>", _("State"), info->workstate); - oscar_string_convert_and_append(account, str, "\n<br>", _("Zip Code"), info->workzip); - g_string_append_printf(str, "\n<hr>"); + tmp = g_string_sized_new(100); + + oscar_string_convert_and_append(account, tmp, "\n<br>", _("Address"), info->workaddr); + oscar_string_convert_and_append(account, tmp, "\n<br>", _("City"), info->workcity); + oscar_string_convert_and_append(account, tmp, "\n<br>", _("State"), info->workstate); + oscar_string_convert_and_append(account, tmp, "\n<br>", _("Zip Code"), info->workzip); + + gaim_notify_user_info_add_pair(user_info, _("Work Address"), tmp->str); + + g_string_free(tmp, TRUE); } if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { - g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); - oscar_string_convert_and_append(account... [truncated message content] |
From: <ev...@us...> - 2006-12-10 05:06:11
|
Revision: 17935 http://svn.sourceforge.net/gaim/?rev=17935&view=rev Author: evands Date: 2006-12-09 21:06:01 -0800 (Sat, 09 Dec 2006) Log Message: ----------- Improved handling of GaimNotifyUserInfoEntry types; an enum now specifies them. Fixed gaim_notify_user_info_get_text() not to have newlines before and after the horizontal line for section breaks. Modified Paths: -------------- trunk/libgaim/notify.c trunk/libgaim/notify.h Modified: trunk/libgaim/notify.c =================================================================== --- trunk/libgaim/notify.c 2006-12-10 03:44:35 UTC (rev 17934) +++ trunk/libgaim/notify.c 2006-12-10 05:06:01 UTC (rev 17935) @@ -43,7 +43,7 @@ { char *label; char *value; - gboolean is_header; + GaimNotifyUserInfoEntryType type; }; struct _GaimNotifyUserInfo @@ -483,7 +483,7 @@ user_info_entry = g_new0(GaimNotifyUserInfoEntry, 1); user_info_entry->label = g_strdup(label); user_info_entry->value = g_strdup(value); - user_info_entry->is_header = FALSE; + user_info_entry->type = GAIM_NOTIFY_USER_INFO_ENTRY_PAIR; return user_info_entry; } @@ -541,9 +541,12 @@ for (l = user_info->user_info_entries; l != NULL; l = l->next) { GaimNotifyUserInfoEntry *user_info_entry = l->data; - if (user_info_entry->is_header) + /* Add a newline before a section header */ + if (user_info_entry->type == GAIM_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER) g_string_append(text, newline); + /* Handle the label/value pair itself */ + /* XXX Todo: Use a larger size for a section header? */ if (user_info_entry->label) g_string_append_printf(text, "<b>%s</b>", user_info_entry->label); if (user_info_entry->label && user_info_entry->value) @@ -551,11 +554,18 @@ if (user_info_entry->value) g_string_append(text, user_info_entry->value); - if (user_info_entry->is_header) - g_string_append(text, newline); + /* Display a section break as a horizontal line */ + if (user_info_entry->type == GAIM_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK) + g_string_append(text, "<HR>"); - if (l->next) + /* Don't insert a new line before or after a section break; <HR> does that for us */ + if ((user_info_entry->type != GAIM_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK) && + (l->next && ((((GaimNotifyUserInfoEntry *)(l->next->data))->type != GAIM_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK)))) g_string_append(text, newline); + + /* Add an extra newline after a section header */ + if (user_info_entry->type == GAIM_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER) + g_string_append(text, newline); } return g_string_free(text, FALSE); @@ -602,29 +612,27 @@ GaimNotifyUserInfoEntry *entry; entry = gaim_notify_user_info_entry_new(label, NULL); - entry->is_header = TRUE; + entry->type = GAIM_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER; user_info->user_info_entries = g_list_append(user_info->user_info_entries, entry); } -/** - * Remove the last item which was added to user_info - * This is helpful for removing a section header if the section was empty. - */ void -gaim_notify_user_info_remove_last_item(GaimNotifyUserInfo *user_info) +gaim_notify_user_info_add_section_break(GaimNotifyUserInfo *user_info) { - user_info->user_info_entries = g_list_remove(user_info->user_info_entries, - g_list_last(user_info->user_info_entries)->data); + GaimNotifyUserInfoEntry *entry; + + entry = gaim_notify_user_info_entry_new(NULL, NULL); + entry->type = GAIM_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK; + + user_info->user_info_entries = g_list_append(user_info->user_info_entries, entry); } void -gaim_notify_user_info_add_section_break(GaimNotifyUserInfo *user_info) +gaim_notify_user_info_remove_last_item(GaimNotifyUserInfo *user_info) { - /* This is for future expansion; section breaks should be marked as such so the UI - * can format them differently if desired. - */ - gaim_notify_user_info_add_pair(user_info, NULL, "<HR>"); + user_info->user_info_entries = g_list_remove(user_info->user_info_entries, + g_list_last(user_info->user_info_entries)->data); } void * Modified: trunk/libgaim/notify.h =================================================================== --- trunk/libgaim/notify.h 2006-12-10 03:44:35 UTC (rev 17934) +++ trunk/libgaim/notify.h 2006-12-10 05:06:01 UTC (rev 17935) @@ -94,6 +94,15 @@ } GaimNotifySearchResults; +/** + * Types of GaimNotifyUserInfoEntry objects + */ +typedef enum +{ + GAIM_NOTIFY_USER_INFO_ENTRY_PAIR = 0, + GAIM_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK, + GAIM_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER +} GaimNotifyUserInfoEntryType; /** * Single column of a search result. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-12-10 08:29:09
|
Revision: 17939 http://svn.sourceforge.net/gaim/?rev=17939&view=rev Author: thekingant Date: 2006-12-10 00:29:03 -0800 (Sun, 10 Dec 2006) Log Message: ----------- Compile warning fixes Modified Paths: -------------- trunk/libgaim/notify.h trunk/libgaim/protocols/irc/msgs.c trunk/libgaim/protocols/jabber/chat.c trunk/libgaim/protocols/yahoo/yahoo_profile.c Modified: trunk/libgaim/notify.h =================================================================== --- trunk/libgaim/notify.h 2006-12-10 08:18:49 UTC (rev 17938) +++ trunk/libgaim/notify.h 2006-12-10 08:29:03 UTC (rev 17939) @@ -432,7 +432,7 @@ * * @return A new GaimNotifyUserInfo, which the caller must destroy when done */ -GaimNotifyUserInfo *gaim_notify_user_info_new(); +GaimNotifyUserInfo *gaim_notify_user_info_new(void); /** * Destroy a GaimNotifyUserInfo Modified: trunk/libgaim/protocols/irc/msgs.c =================================================================== --- trunk/libgaim/protocols/irc/msgs.c 2006-12-10 08:18:49 UTC (rev 17938) +++ trunk/libgaim/protocols/irc/msgs.c 2006-12-10 08:29:03 UTC (rev 17939) @@ -198,8 +198,7 @@ void irc_msg_endwhois(struct irc_conn *irc, const char *name, const char *from, char **args) { GaimConnection *gc; - GString *info; - char *str, *tmp, *tmp2; + char *tmp, *tmp2; GaimNotifyUserInfo *user_info; if (!irc->whois.nick) { Modified: trunk/libgaim/protocols/jabber/chat.c =================================================================== --- trunk/libgaim/protocols/jabber/chat.c 2006-12-10 08:18:49 UTC (rev 17938) +++ trunk/libgaim/protocols/jabber/chat.c 2006-12-10 08:29:03 UTC (rev 17939) @@ -954,7 +954,7 @@ static void jabber_chat_disco_traffic_cb(JabberStream *js, xmlnode *packet, gpointer data) { JabberChat *chat; - xmlnode *query, *x; + xmlnode *query; int id = GPOINTER_TO_INT(data); if(!(chat = jabber_chat_find_by_id(js, id))) Modified: trunk/libgaim/protocols/yahoo/yahoo_profile.c =================================================================== --- trunk/libgaim/protocols/yahoo/yahoo_profile.c 2006-12-10 08:18:49 UTC (rev 17938) +++ trunk/libgaim/protocols/yahoo/yahoo_profile.c 2006-12-10 08:29:03 UTC (rev 17939) @@ -743,7 +743,6 @@ YahooGetInfoData *info_data = (YahooGetInfoData *)user_data; GaimNotifyUserInfo *user_info; char *p; - char buf[1024]; #if PHOTO_SUPPORT YahooGetInfoStepTwoData *info2_data; char *photo_url_text = NULL; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-12-11 19:44:41
|
Revision: 17963 http://svn.sourceforge.net/gaim/?rev=17963&view=rev Author: thekingant Date: 2006-12-11 11:44:35 -0800 (Mon, 11 Dec 2006) Log Message: ----------- Rename namespace to xmlns because namespace is a reserved word in C++ Modified Paths: -------------- trunk/libgaim/xmlnode.c trunk/libgaim/xmlnode.h Modified: trunk/libgaim/xmlnode.c =================================================================== --- trunk/libgaim/xmlnode.c 2006-12-11 19:32:52 UTC (rev 17962) +++ trunk/libgaim/xmlnode.c 2006-12-11 19:44:35 UTC (rev 17963) @@ -181,15 +181,15 @@ { g_return_if_fail(node != NULL); - g_free(node->namespace); - node->namespace = g_strdup(xmlns); + g_free(node->xmlns); + node->xmlns = g_strdup(xmlns); } const char *xmlnode_get_namespace(xmlnode *node) { g_return_val_if_fail(node != NULL, NULL); - return node->namespace; + return node->xmlns; } void @@ -208,7 +208,7 @@ g_free(node->name); g_free(node->data); - g_free(node->namespace); + g_free(node->xmlns); GAIM_DBUS_UNREGISTER_POINTER(node); g_free(node); @@ -293,12 +293,12 @@ node_name = g_markup_escape_text(node->name, -1); g_string_append_printf(text, "<%s", node_name); - if (node->namespace) { - if(!node->parent || !node->parent->namespace || strcmp(node->namespace, node->parent->namespace)) + if (node->xmlns) { + if(!node->parent || !node->parent->xmlns || strcmp(node->xmlns, node->parent->xmlns)) { - char *namespace = g_markup_escape_text(node->namespace, -1); - g_string_append_printf(text, " xmlns='%s'", namespace); - g_free(namespace); + char *xmlns = g_markup_escape_text(node->xmlns, -1); + g_string_append_printf(text, " xmlns='%s'", xmlns); + g_free(xmlns); } } for(c = node->child; c; c = c->next) @@ -377,7 +377,7 @@ static void xmlnode_parser_element_start_libxml(void *user_data, - const xmlChar *element_name, const xmlChar *prefix, const xmlChar *namespace, + const xmlChar *element_name, const xmlChar *prefix, const xmlChar *xmlns, int nb_namespaces, const xmlChar **namespaces, int nb_attributes, int nb_defaulted, const xmlChar **attributes) { @@ -393,7 +393,7 @@ else node = xmlnode_new((const char *) element_name); - xmlnode_set_namespace(node, (const char *) namespace); + xmlnode_set_namespace(node, (const char *) xmlns); for(i=0; i < nb_attributes * 5; i+=5) { char *txt; @@ -414,7 +414,7 @@ static void xmlnode_parser_element_end_libxml(void *user_data, const xmlChar *element_name, - const xmlChar *prefix, const xmlChar *namespace) + const xmlChar *prefix, const xmlChar *xmlns) { struct _xmlnode_parser_data *xpd = user_data; Modified: trunk/libgaim/xmlnode.h =================================================================== --- trunk/libgaim/xmlnode.h 2006-12-11 19:32:52 UTC (rev 17962) +++ trunk/libgaim/xmlnode.h 2006-12-11 19:44:35 UTC (rev 17963) @@ -46,7 +46,7 @@ struct _xmlnode { char *name; /**< The name of the node. */ - char *namespace; /**< The namespace of the node */ + char *xmlns; /**< The namespace of the node */ XMLNodeType type; /**< The type of the node. */ char *data; /**< The data for the node. */ size_t data_sz; /**< The size of the data. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sea...@us...> - 2006-12-14 04:58:37
|
Revision: 17993 http://svn.sourceforge.net/gaim/?rev=17993&view=rev Author: seanegan Date: 2006-12-13 20:56:54 -0800 (Wed, 13 Dec 2006) Log Message: ----------- Blocking on Google Talk. Our Privacy API sucks so bad that even with no prior support for blocking in Jabber, this has no interface changes. If someone wanted to implement the deprecated Jabber privacy lists API, though, that would be ok by me. Modified Paths: -------------- trunk/libgaim/protocols/jabber/disco.c trunk/libgaim/protocols/jabber/google.c trunk/libgaim/protocols/jabber/google.h trunk/libgaim/protocols/jabber/jabber.c trunk/libgaim/protocols/jabber/jabber.h trunk/libgaim/protocols/jabber/parser.c trunk/libgaim/protocols/jabber/roster.c trunk/libgaim/xmlnode.c trunk/libgaim/xmlnode.h Modified: trunk/libgaim/protocols/jabber/disco.c =================================================================== --- trunk/libgaim/protocols/jabber/disco.c 2006-12-14 04:17:02 UTC (rev 17992) +++ trunk/libgaim/protocols/jabber/disco.c 2006-12-14 04:56:54 UTC (rev 17993) @@ -27,8 +27,8 @@ #include "iq.h" #include "disco.h" #include "jabber.h" +#include "roster.h" - struct _jabber_disco_info_cb_data { gpointer data; JabberDiscoInfoCallback *callback; @@ -262,8 +262,14 @@ if (!strcmp("google:mail:notify", var)) { js->server_caps |= JABBER_CAP_GMAIL_NOTIFY; jabber_gmail_init(js); + } else if (!strcmp("google:roster", var)) { + js->server_caps |= JABBER_CAP_GOOGLE_ROSTER; + jabber_google_roster_init(js); } } + + if (!js->server_caps & JABBER_CAP_GOOGLE_ROSTER) + jabber_roster_request(js); } static void Modified: trunk/libgaim/protocols/jabber/google.c =================================================================== --- trunk/libgaim/protocols/jabber/google.c 2006-12-14 04:17:02 UTC (rev 17992) +++ trunk/libgaim/protocols/jabber/google.c 2006-12-14 04:56:54 UTC (rev 17993) @@ -21,8 +21,12 @@ #include "internal.h" #include "debug.h" +#include "privacy.h" + +#include "buddy.h" #include "google.h" #include "jabber.h" +#include "presence.h" #include "iq.h" static void @@ -167,3 +171,190 @@ jabber_iq_set_callback(iq, jabber_gmail_parse, NULL); jabber_iq_send(iq); } + +void jabber_google_roster_init(JabberStream *js) +{ + JabberIq *iq; + xmlnode *query; + + iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:roster"); + query = xmlnode_get_child(iq->node, "query"); + + xmlnode_set_attrib(query, "xmlns:gr", "google:roster"); + xmlnode_set_attrib(query, "gr:ext", "2"); + + jabber_iq_send(iq); +} + +void jabber_google_roster_outgoing(JabberStream *js, xmlnode *query, xmlnode *item) +{ + GaimAccount *account = gaim_connection_get_account(js->gc); + GSList *list = account->deny; + const char *jid = xmlnode_get_attrib(item, "jid"); + char *jid_norm = g_strdup(jabber_normalize(account, jid)); + + while (list) { + if (!strcmp(jid_norm, (char*)list->data)) { + xmlnode_set_attrib(query, "xmlns:gr", "google:roster"); + xmlnode_set_attrib(item, "gr:t", "B"); + xmlnode_set_attrib(query, "xmlns:gr", "google:roster"); + xmlnode_set_attrib(query, "gr:ext", "2"); + return; + } + list = list->next; + } + +} + +void jabber_google_roster_incoming(JabberStream *js, xmlnode *item) +{ + GaimAccount *account = gaim_connection_get_account(js->gc); + GSList *list = account->deny; + const char *jid = xmlnode_get_attrib(item, "jid"); + gboolean on_block_list = FALSE; + + char *jid_norm = g_strdup(jabber_normalize(account, jid)); + + const char *grt = xmlnode_get_attrib_with_namespace(item, "t", "google:roster"); + + while (list) { + if (!strcmp(jid_norm, (char*)list->data)) { + on_block_list = TRUE; + break; + } + list = list->next; + } + + if (!on_block_list && (grt && (*grt == 'B' || *grt == 'b'))) { + gaim_debug_info("jabber", "Blocking %s\n", jid_norm); + gaim_privacy_deny_add(account, jid_norm, TRUE); + } else if (on_block_list && (!grt || (*grt != 'B' && *grt != 'b' ))){ + gaim_debug_info("jabber", "Unblocking %s\n", jid_norm); + gaim_privacy_deny_remove(account, jid_norm, TRUE); + } +} + +void jabber_google_roster_add_deny(GaimConnection *gc, const char *who) +{ + JabberStream *js; + GSList *buddies; + JabberIq *iq; + xmlnode *query; + xmlnode *item; + xmlnode *group; + GaimBuddy *b; + JabberBuddy *jb; + + js = (JabberStream*)(gc->proto_data); + + if (!js || !js->server_caps & JABBER_CAP_GOOGLE_ROSTER) + return; + + jb = jabber_buddy_find(js, who, TRUE); + + buddies = gaim_find_buddies(js->gc->account, who); + if(!buddies) + return; + + b = buddies->data; + + iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:roster"); + + query = xmlnode_get_child(iq->node, "query"); + item = xmlnode_new_child(query, "item"); + + while(buddies) { + GaimGroup *g; + + b = buddies->data; + g = gaim_buddy_get_group(b); + + group = xmlnode_new_child(item, "group"); + xmlnode_insert_data(group, g->name, -1); + + buddies = buddies->next; + } + + iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:roster"); + + query = xmlnode_get_child(iq->node, "query"); + item = xmlnode_new_child(query, "item"); + + xmlnode_set_attrib(item, "jid", who); + xmlnode_set_attrib(item, "name", b->alias ? b->alias : ""); + xmlnode_set_attrib(item, "gr:t", "B"); + xmlnode_set_attrib(query, "xmlns:gr", "google:roster"); + xmlnode_set_attrib(query, "gr:ext", "2"); + + jabber_iq_send(iq); + + /* Synthesize a sign-off */ + if (jb) { + JabberBuddyResource *jbr; + GList *l = jb->resources; + while (l) { + jbr = l->data; + printf("ASDFA %s\n", jbr->name); + jabber_buddy_remove_resource(jb, jbr->name); + l = l->next; + } + } + gaim_prpl_got_user_status(gaim_connection_get_account(gc), who, "offline", NULL); +} + +void jabber_google_roster_rem_deny(GaimConnection *gc, const char *who) +{ + JabberStream *js; + GSList *buddies; + JabberIq *iq; + xmlnode *query; + xmlnode *item; + xmlnode *group; + GaimBuddy *b; + + g_return_if_fail(gc != NULL); + g_return_if_fail(who != NULL); + + js = (JabberStream*)(gc->proto_data); + + if (!js || !js->server_caps & JABBER_CAP_GOOGLE_ROSTER) + return; + + buddies = gaim_find_buddies(js->gc->account, who); + if(!buddies) + return; + + b = buddies->data; + + iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:roster"); + + query = xmlnode_get_child(iq->node, "query"); + item = xmlnode_new_child(query, "item"); + + while(buddies) { + GaimGroup *g; + + b = buddies->data; + g = gaim_buddy_get_group(b); + + group = xmlnode_new_child(item, "group"); + xmlnode_insert_data(group, g->name, -1); + + buddies = buddies->next; + } + + iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:roster"); + + query = xmlnode_get_child(iq->node, "query"); + item = xmlnode_new_child(query, "item"); + + xmlnode_set_attrib(item, "jid", who); + xmlnode_set_attrib(item, "name", b->alias ? b->alias : ""); + xmlnode_set_attrib(query, "xmlns:gr", "google:roster"); + xmlnode_set_attrib(query, "gr:ext", "2"); + + jabber_iq_send(iq); + + /* See if he's online */ + jabber_presence_subscription_set(js, who, "probe"); +} Modified: trunk/libgaim/protocols/jabber/google.h =================================================================== --- trunk/libgaim/protocols/jabber/google.h 2006-12-14 04:17:02 UTC (rev 17992) +++ trunk/libgaim/protocols/jabber/google.h 2006-12-14 04:56:54 UTC (rev 17993) @@ -29,4 +29,12 @@ void jabber_gmail_init(JabberStream *js); void jabber_gmail_poke(JabberStream *js, xmlnode *node); +void jabber_google_roster_init(JabberStream *js); +void jabber_google_roster_outgoing(JabberStream *js, xmlnode *query, xmlnode *item); +void jabber_google_roster_incoming(JabberStream *js, xmlnode *item); +void jabber_google_roster_add_deny(GaimConnection *gc, const char *who); +void jabber_google_roster_rem_deny(GaimConnection *gc, const char *who); + + + #endif /* _GAIM_GOOGLE_H_ */ Modified: trunk/libgaim/protocols/jabber/jabber.c =================================================================== --- trunk/libgaim/protocols/jabber/jabber.c 2006-12-14 04:17:02 UTC (rev 17992) +++ trunk/libgaim/protocols/jabber/jabber.c 2006-12-14 04:56:54 UTC (rev 17993) @@ -41,6 +41,7 @@ #include "buddy.h" #include "chat.h" #include "disco.h" +#include "google.h" #include "iq.h" #include "jutil.h" #include "message.h" @@ -1041,7 +1042,6 @@ break; case JABBER_STREAM_CONNECTED: - jabber_roster_request(js); gpresence = gaim_account_get_presence(js->gc->account); status = gaim_presence_get_active_status(gpresence); jabber_presence_send(js->gc->account, status); @@ -1875,9 +1875,9 @@ jabber_roster_remove_buddy, /* remove_buddy */ NULL, /* remove_buddies */ NULL, /* add_permit */ - NULL, /* add_deny */ + jabber_google_roster_add_deny, /* add_deny */ NULL, /* rem_permit */ - NULL, /* rem_deny */ + jabber_google_roster_rem_deny, /* rem_deny */ NULL, /* set_permit_deny */ jabber_chat_join, /* join_chat */ NULL, /* reject_chat */ Modified: trunk/libgaim/protocols/jabber/jabber.h =================================================================== --- trunk/libgaim/protocols/jabber/jabber.h 2006-12-14 04:17:02 UTC (rev 17992) +++ trunk/libgaim/protocols/jabber/jabber.h 2006-12-14 04:56:54 UTC (rev 17993) @@ -55,6 +55,7 @@ * http://code.google.com/apis/talk/jep_extensions/extensions.html */ JABBER_CAP_GMAIL_NOTIFY = 1 << 9, + JABBER_CAP_GOOGLE_ROSTER = 1 << 10, JABBER_CAP_RETRIEVED = 1 << 31 } JabberCapabilities; Modified: trunk/libgaim/protocols/jabber/parser.c =================================================================== --- trunk/libgaim/protocols/jabber/parser.c 2006-12-14 04:17:02 UTC (rev 17992) +++ trunk/libgaim/protocols/jabber/parser.c 2006-12-14 04:56:54 UTC (rev 17993) @@ -76,13 +76,21 @@ char *txt; int attrib_len = attributes[i+4] - attributes[i+3]; char *attrib = g_malloc(attrib_len + 1); + char *attrib_ns = NULL; + + if (attributes[i+2]) { + attrib_ns = g_strdup(attributes[i+2]);; + } + memcpy(attrib, attributes[i+3], attrib_len); attrib[attrib_len] = '\0'; + txt = attrib; attrib = gaim_unescape_html(txt); g_free(txt); - xmlnode_set_attrib(node, (const char*) attributes[i], attrib); + xmlnode_set_attrib_with_namespace(node, (const char*) attributes[i], attrib_ns, attrib); g_free(attrib); + g_free(attrib_ns); } js->current = node; Modified: trunk/libgaim/protocols/jabber/roster.c =================================================================== --- trunk/libgaim/protocols/jabber/roster.c 2006-12-14 04:17:02 UTC (rev 17992) +++ trunk/libgaim/protocols/jabber/roster.c 2006-12-14 04:56:54 UTC (rev 17993) @@ -24,6 +24,7 @@ #include "util.h" #include "buddy.h" +#include "google.h" #include "presence.h" #include "roster.h" #include "iq.h" @@ -224,6 +225,8 @@ if (g_slist_find_custom(groups, group_name, (GCompareFunc)gaim_utf8_strcasecmp) == NULL) groups = g_slist_append(groups, group_name); } + if (js->server_caps & JABBER_CAP_GOOGLE_ROSTER) + jabber_google_roster_incoming(js, item); add_gaim_buddies_in_groups(js, jid, name, groups); } } @@ -271,7 +274,12 @@ if(!grps) g_slist_free(groups); - + + if (js->server_caps & JABBER_CAP_GOOGLE_ROSTER) { + jabber_google_roster_outgoing(js, query, item); + xmlnode_set_attrib(query, "xmlns:gr", "google:roster"); + xmlnode_set_attrib(query, "gr:ext", "2"); + } jabber_iq_send(iq); } Modified: trunk/libgaim/xmlnode.c =================================================================== --- trunk/libgaim/xmlnode.c 2006-12-14 04:17:02 UTC (rev 17992) +++ trunk/libgaim/xmlnode.c 2006-12-14 04:56:54 UTC (rev 17993) @@ -142,7 +142,35 @@ } } + void +xmlnode_remove_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns) +{ + xmlnode *attr_node, *sibling = NULL; + + g_return_if_fail(node != NULL); + g_return_if_fail(attr != NULL); + + for(attr_node = node->child; attr_node; attr_node = attr_node->next) + { + if(attr_node->type == XMLNODE_TYPE_ATTRIB && + !strcmp(attr_node->name, attr) && + !strcmp(attr_node->xmlns, xmlns)) { + if(node->child == attr_node) { + node->child = attr_node->next; + } else if (node->lastchild == attr_node) { + node->lastchild = sibling; + } else { + sibling->next = attr_node->next; + } + xmlnode_free(attr_node); + return; + } + sibling = attr_node; + } +} + +void xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value) { xmlnode *attrib_node; @@ -160,6 +188,25 @@ xmlnode_insert_child(node, attrib_node); } +void +xmlnode_set_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns, const char *value) +{ + xmlnode *attrib_node; + + g_return_if_fail(node != NULL); + g_return_if_fail(attr != NULL); + g_return_if_fail(value != NULL); + + xmlnode_remove_attrib_with_namespace(node, attr, xmlns); + + attrib_node = new_node(attr, XMLNODE_TYPE_ATTRIB); + + attrib_node->data = g_strdup(value); + attrib_node->xmlns = g_strdup(xmlns); + + xmlnode_insert_child(node, attrib_node); +} + const char * xmlnode_get_attrib(xmlnode *node, const char *attr) { @@ -176,7 +223,24 @@ return NULL; } +const char * +xmlnode_get_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns) +{ + xmlnode *x; + g_return_val_if_fail(node != NULL, NULL); + + for(x = node->child; x; x = x->next) { + if(x->type == XMLNODE_TYPE_ATTRIB && + !strcmp(attr, x->name) && !strcmp(x->xmlns, xmlns)) { + return x->data; + } + } + + return NULL; +} + + void xmlnode_set_namespace(xmlnode *node, const char *xmlns) { g_return_if_fail(node != NULL); Modified: trunk/libgaim/xmlnode.h =================================================================== --- trunk/libgaim/xmlnode.h 2006-12-14 04:17:02 UTC (rev 17992) +++ trunk/libgaim/xmlnode.h 2006-12-14 04:56:54 UTC (rev 17993) @@ -143,6 +143,16 @@ void xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value); /** + * Sets a namespaced attribute for a node + * + * @param node The node to set an attribute for. + * @param attr The name of the attribute to set + * @param xmlns The namespace of the attribute to ste + * @param value The value of the attribute + */ +void xmlnode_set_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns, const char *value); + +/** * Gets an attribute from a node. * * @param node The node to get an attribute from. @@ -153,6 +163,17 @@ const char *xmlnode_get_attrib(xmlnode *node, const char *attr); /** + * Gets a namespaced attribute from a node + * + * @param node The node to get an attribute from. + * @param attr The attribute to get + * @param xmlns The namespace of the attribute to get + * + * @return The value of the attribute/ + */ +const char *xmlnode_get_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns); + +/** * Removes an attribute from a node. * * @param node The node to remove an attribute from. @@ -161,6 +182,15 @@ void xmlnode_remove_attrib(xmlnode *node, const char *attr); /** + * Removes a namespaced attribute from a node + * + * @param node The node to remove an attribute from + * @param attr The attribute to remove + * @param xmlns The namespace of the attribute to remove + */ +void xmlnode_remove_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns); + +/** * Sets the namespace of a node * * @param node The node to qualify This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-12-15 08:40:03
|
Revision: 18008 http://svn.sourceforge.net/gaim/?rev=18008&view=rev Author: thekingant Date: 2006-12-15 00:39:53 -0800 (Fri, 15 Dec 2006) Log Message: ----------- Patch from Graham Booker to slowly scale up the size of our read or write buffer when transfer files over fast networks. This should hopefully reduce CPU load a tiny bit when transfer large files over fast connections. Modified Paths: -------------- trunk/libgaim/ft.c trunk/libgaim/ft.h Modified: trunk/libgaim/ft.c =================================================================== --- trunk/libgaim/ft.c 2006-12-15 08:23:28 UTC (rev 18007) +++ trunk/libgaim/ft.c 2006-12-15 08:39:53 UTC (rev 18008) @@ -31,6 +31,9 @@ #include "request.h" #include "util.h" +#define FT_INITIAL_BUFFER_SIZE 4096 +#define FT_MAX_BUFFER_SIZE 65535 + static GaimXferUiOps *xfer_ui_ops = NULL; static int gaim_xfer_choose_file(GaimXfer *xfer); @@ -53,6 +56,7 @@ xfer->who = g_strdup(who); xfer->ui_ops = gaim_xfers_get_ui_ops(); xfer->message = NULL; + xfer->current_buffer_size = FT_INITIAL_BUFFER_SIZE; ui_ops = gaim_xfer_get_ui_ops(xfer); @@ -781,6 +785,13 @@ xfer->ops.cancel_recv = fnc; } +static void +gaim_xfer_increase_buffer_size(GaimXfer *xfer) +{ + xfer->current_buffer_size = MIN(xfer->current_buffer_size * 1.5, + FT_MAX_BUFFER_SIZE); +} + gssize gaim_xfer_read(GaimXfer *xfer, guchar **buffer) { @@ -790,9 +801,9 @@ g_return_val_if_fail(buffer != NULL, 0); if (gaim_xfer_get_size(xfer) == 0) - s = 4096; + s = xfer->current_buffer_size; else - s = MIN(gaim_xfer_get_bytes_remaining(xfer), 4096); + s = MIN(gaim_xfer_get_bytes_remaining(xfer), xfer->current_buffer_size); if (xfer->ops.read != NULL) r = (xfer->ops.read)(buffer, xfer); @@ -811,6 +822,14 @@ r = -1; } + if (r == xfer->current_buffer_size) + /* + * We managed to read the entire buffer. This means our this + * network is fast and our buffer is too small, so make it + * bigger. + */ + gaim_xfer_increase_buffer_size(xfer); + return r; } @@ -857,7 +876,7 @@ } if (condition & GAIM_INPUT_WRITE) { - size_t s = MIN(gaim_xfer_get_bytes_remaining(xfer), 4096); + size_t s = MIN(gaim_xfer_get_bytes_remaining(xfer), xfer->current_buffer_size); /* this is so the prpl can keep the connection open if it needs to for some odd reason. */ @@ -883,6 +902,13 @@ } else if (r < s) { /* We have to seek back in the file now. */ fseek(xfer->dest_fp, r - s, SEEK_CUR); + } else { + /* + * We managed to write the entire buffer. This means our + * network is fast and our buffer is too small, so make it + * bigger. + */ + gaim_xfer_increase_buffer_size(xfer); } } Modified: trunk/libgaim/ft.h =================================================================== --- trunk/libgaim/ft.h 2006-12-15 08:23:28 UTC (rev 18007) +++ trunk/libgaim/ft.h 2006-12-15 08:39:53 UTC (rev 18008) @@ -84,7 +84,7 @@ */ struct _GaimXfer { - guint ref; /**< The reference count. */ + guint ref; /**< The reference count. */ GaimXferType type; /**< The type of transfer. */ GaimAccount *account; /**< The account. */ @@ -111,6 +111,9 @@ time_t start_time; /**< When the transfer of data began. */ time_t end_time; /**< When the transfer of data ended. */ + size_t current_buffer_size; /**< This gradually increases for fast + network connections. */ + GaimXferStatusType status; /**< File Transfer's status. */ /* I/O operations. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-12-15 10:39:18
|
Revision: 18009 http://svn.sourceforge.net/gaim/?rev=18009&view=rev Author: thekingant Date: 2006-12-15 02:35:18 -0800 (Fri, 15 Dec 2006) Log Message: ----------- Add a max_filesize attribute to the icon_spec struct. It's not actually used yet--I'll update the UI to do that later. Modified Paths: -------------- trunk/libgaim/protocols/bonjour/bonjour.c trunk/libgaim/protocols/jabber/jabber.c trunk/libgaim/protocols/msn/msn.c trunk/libgaim/protocols/oscar/libaim.c trunk/libgaim/protocols/oscar/libicq.c trunk/libgaim/protocols/qq/qq.c trunk/libgaim/protocols/silc/silc.c trunk/libgaim/protocols/yahoo/yahoo.c trunk/libgaim/prpl.h Modified: trunk/libgaim/protocols/bonjour/bonjour.c =================================================================== --- trunk/libgaim/protocols/bonjour/bonjour.c 2006-12-15 08:39:53 UTC (rev 18008) +++ trunk/libgaim/protocols/bonjour/bonjour.c 2006-12-15 10:35:18 UTC (rev 18009) @@ -356,7 +356,7 @@ OPT_PROTO_NO_PASSWORD, NULL, /* user_splits */ NULL, /* protocol_options */ - /* {"png", 0, 0, 96, 96, GAIM_ICON_SCALE_DISPLAY}, */ /* icon_spec */ + /* {"png", 0, 0, 96, 96, 0, GAIM_ICON_SCALE_DISPLAY}, */ /* icon_spec */ NO_BUDDY_ICONS, /* not yet */ /* icon_spec */ bonjour_list_icon, /* list_icon */ bonjour_list_emblems, /* list_emblems */ Modified: trunk/libgaim/protocols/jabber/jabber.c =================================================================== --- trunk/libgaim/protocols/jabber/jabber.c 2006-12-15 08:39:53 UTC (rev 18008) +++ trunk/libgaim/protocols/jabber/jabber.c 2006-12-15 10:35:18 UTC (rev 18009) @@ -1852,7 +1852,7 @@ OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME | OPT_PROTO_MAIL_CHECK, NULL, /* user_splits */ NULL, /* protocol_options */ - {"png,gif,jpeg", 32, 32, 96, 96, GAIM_ICON_SCALE_SEND | GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ + {"png,gif,jpeg", 32, 32, 96, 96, 8191, GAIM_ICON_SCALE_SEND | GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ jabber_list_icon, /* list_icon */ jabber_list_emblems, /* list_emblems */ jabber_status_text, /* status_text */ Modified: trunk/libgaim/protocols/msn/msn.c =================================================================== --- trunk/libgaim/protocols/msn/msn.c 2006-12-15 08:39:53 UTC (rev 18008) +++ trunk/libgaim/protocols/msn/msn.c 2006-12-15 10:35:18 UTC (rev 18009) @@ -1954,7 +1954,7 @@ OPT_PROTO_MAIL_CHECK, NULL, /* user_splits */ NULL, /* protocol_options */ - {"png", 0, 0, 96, 96, GAIM_ICON_SCALE_SEND}, /* icon_spec */ + {"png", 0, 0, 96, 96, 0, GAIM_ICON_SCALE_SEND}, /* icon_spec */ msn_list_icon, /* list_icon */ msn_list_emblems, /* list_emblems */ msn_status_text, /* status_text */ Modified: trunk/libgaim/protocols/oscar/libaim.c =================================================================== --- trunk/libgaim/protocols/oscar/libaim.c 2006-12-15 08:39:53 UTC (rev 18008) +++ trunk/libgaim/protocols/oscar/libaim.c 2006-12-15 10:35:18 UTC (rev 18009) @@ -32,7 +32,7 @@ NULL, /* user_splits */ NULL, /* protocol_options */ /* The mimimum icon size below is not needed in AIM 6.0 */ - {"gif,jpeg,bmp,ico", 48, 48, 50, 50, + {"gif,jpeg,bmp,ico", 48, 48, 50, 50, 7168, GAIM_ICON_SCALE_SEND | GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ oscar_list_icon_aim, /* list_icon */ oscar_list_emblems, /* list_emblems */ Modified: trunk/libgaim/protocols/oscar/libicq.c =================================================================== --- trunk/libgaim/protocols/oscar/libicq.c 2006-12-15 08:39:53 UTC (rev 18008) +++ trunk/libgaim/protocols/oscar/libicq.c 2006-12-15 10:35:18 UTC (rev 18009) @@ -32,7 +32,7 @@ OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, NULL, /* user_splits */ NULL, /* protocol_options */ - {"gif,jpeg,bmp,ico", 48, 48, 50, 50, + {"gif,jpeg,bmp,ico", 48, 48, 50, 50, 7168, GAIM_ICON_SCALE_SEND | GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ oscar_list_icon_icq, /* list_icon */ oscar_list_emblems, /* list_emblems */ Modified: trunk/libgaim/protocols/qq/qq.c =================================================================== --- trunk/libgaim/protocols/qq/qq.c 2006-12-15 08:39:53 UTC (rev 18008) +++ trunk/libgaim/protocols/qq/qq.c 2006-12-15 10:35:18 UTC (rev 18009) @@ -653,7 +653,7 @@ OPT_PROTO_CHAT_TOPIC | OPT_PROTO_USE_POINTSIZE, NULL, /* user_splits */ NULL, /* protocol_options */ - {"png", 96, 96, 96, 96, GAIM_ICON_SCALE_SEND}, /* icon_spec */ + {"png", 96, 96, 96, 96, 0, GAIM_ICON_SCALE_SEND}, /* icon_spec */ _qq_list_icon, /* list_icon */ _qq_list_emblems, /* list_emblems */ _qq_status_text, /* status_text */ Modified: trunk/libgaim/protocols/silc/silc.c =================================================================== --- trunk/libgaim/protocols/silc/silc.c 2006-12-15 08:39:53 UTC (rev 18008) +++ trunk/libgaim/protocols/silc/silc.c 2006-12-15 10:35:18 UTC (rev 18009) @@ -1734,7 +1734,7 @@ NULL, /* user_splits */ NULL, /* protocol_options */ #ifdef SILC_ATTRIBUTE_USER_ICON - {"jpeg,gif,png,bmp", 0, 0, 96, 96, GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ + {"jpeg,gif,png,bmp", 0, 0, 96, 96, 0, GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ #else NO_BUDDY_ICONS, #endif Modified: trunk/libgaim/protocols/yahoo/yahoo.c =================================================================== --- trunk/libgaim/protocols/yahoo/yahoo.c 2006-12-15 08:39:53 UTC (rev 18008) +++ trunk/libgaim/protocols/yahoo/yahoo.c 2006-12-15 10:35:18 UTC (rev 18009) @@ -3821,7 +3821,7 @@ OPT_PROTO_MAIL_CHECK | OPT_PROTO_CHAT_TOPIC, NULL, /* user_splits */ NULL, /* protocol_options */ - {"png,gif,jpeg", 96, 96, 96, 96, GAIM_ICON_SCALE_SEND}, + {"png,gif,jpeg", 96, 96, 96, 96, 0, GAIM_ICON_SCALE_SEND}, yahoo_list_icon, yahoo_list_emblems, yahoo_status_text, Modified: trunk/libgaim/prpl.h =================================================================== --- trunk/libgaim/prpl.h 2006-12-15 08:39:53 UTC (rev 18008) +++ trunk/libgaim/prpl.h 2006-12-15 10:35:18 UTC (rev 18009) @@ -46,23 +46,16 @@ * it should give this prpl, and what kind of image file it should expect back. * Dimensions less than 1 should be ignored and the image not scaled. */ -typedef struct { - char *format; /**< This is a comma-delimited list of image formats or NULL if icons are not supported. - * Neither the core nor the prpl will actually check to see if the data it's given matches this; it's - * entirely up to the UI to do what it wants */ - int min_width; /**< The minimum width of this icon */ - int min_height; /**< The minimum height of this icon */ - int max_width; /**< The maximum width of this icon */ - int max_height; /**< The maximum height of this icon */ - GaimIconScaleRules scale_rules; /**< How to stretch this icon */ -} GaimBuddyIconSpec; +typedef struct _GaimBuddyIconSpec GaimBuddyIconSpec; /** * This \#define exists just to make it easier to fill out the buddy icon * field in the prpl info struct for protocols that couldn't care less. */ -#define NO_BUDDY_ICONS {NULL, 0, 0, 0, 0, 0} +#define NO_BUDDY_ICONS {NULL, 0, 0, 0, 0, 0, 0} +#include <unistd.h> + #include "blist.h" #include "conversation.h" #include "ft.h" @@ -73,6 +66,18 @@ #include "status.h" #include "whiteboard.h" +struct _GaimBuddyIconSpec { + char *format; /**< This is a comma-delimited list of image formats or NULL if icons are not supported. + * Neither the core nor the prpl will actually check to see if the data it's given matches this; it's + * entirely up to the UI to do what it wants */ + int min_width; /**< The minimum width of this icon */ + int min_height; /**< The minimum height of this icon */ + int max_width; /**< The maximum width of this icon */ + int max_height; /**< The maximum height of this icon */ + size_t max_filesize; /**< The maximum number of bytes */ + GaimIconScaleRules scale_rules; /**< How to stretch this icon */ +}; + struct proto_chat_entry { const char *label; const char *identifier; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2006-12-26 02:42:54
|
Revision: 18053 http://svn.sourceforge.net/gaim/?rev=18053&view=rev Author: evands Date: 2006-12-25 18:42:54 -0800 (Mon, 25 Dec 2006) Log Message: ----------- Added setters and manipulators for GaimNotifyUserInfo and GaimNotifyUserInfoEntry, and fixed the declared parameters to the 'displaying-userinfo' signal Modified Paths: -------------- trunk/libgaim/notify.c trunk/libgaim/notify.h Modified: trunk/libgaim/notify.c =================================================================== --- trunk/libgaim/notify.c 2006-12-26 02:01:15 UTC (rev 18052) +++ trunk/libgaim/notify.c 2006-12-26 02:42:54 UTC (rev 18053) @@ -580,6 +580,18 @@ return user_info_entry->label; } +void +gaim_notify_user_info_entry_set_label(GaimNotifyUserInfoEntry *user_info_entry, const char *label) +{ + g_return_if_fail(user_info_entry != NULL); + + if (label != user_info_entry->label) + { + g_free(user_info_entry->label); + user_info_entry->label = g_strdup(label); + } +} + gchar * gaim_notify_user_info_entry_get_value(GaimNotifyUserInfoEntry *user_info_entry) { @@ -589,6 +601,34 @@ } void +gaim_notify_user_info_entry_set_value(GaimNotifyUserInfoEntry *user_info_entry, const char *value) +{ + g_return_if_fail(user_info_entry != NULL); + + if (value != user_info_entry->value) + { + g_free(user_info_entry->value); + user_info_entry->value = g_strdup(value); + } +} + +GaimNotifyUserInfoEntryType +gaim_notify_user_info_entry_get_type(GaimNotifyUserInfoEntry *user_info_entry) +{ + g_return_val_if_fail(user_info_entry != NULL, NULL); + + return user_info_entry->type; +} + +void +gaim_notify_user_info_entry_set_value(GaimNotifyUserInfoEntry *user_info_entry, GaimNotifyUserInfoEntryType type) +{ + g_return_if_fail(user_info_entry != NULL); + + user_info_entry->type = type; +} + +void gaim_notify_user_info_add_pair(GaimNotifyUserInfo *user_info, const char *label, const char *value) { GaimNotifyUserInfoEntry *entry; @@ -755,7 +795,8 @@ gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_ACCOUNT), gaim_value_new(GAIM_TYPE_STRING), - gaim_value_new_outgoing(GAIM_TYPE_STRING)); + gaim_value_new(GAIM_TYPE_SUBTYPE, + GAIM_SUBTYPE_USERINFO)); } void Modified: trunk/libgaim/notify.h =================================================================== --- trunk/libgaim/notify.h 2006-12-26 02:01:15 UTC (rev 18052) +++ trunk/libgaim/notify.h 2006-12-26 02:42:54 UTC (rev 18053) @@ -444,6 +444,10 @@ /** * Retrieve the array of GaimNotifyUserInfoEntry objects from a GaimNotifyUserInfo * + * This GList may be manipulated directly with normal GList functions such as g_list_insert(). Only + * GaimNotifyUserInfoEntry are allowed in the list. If a GaimNotifyUserInfoEntry item is added to the list, + * it should not be g_free()'d by the caller; GaimNotifyUserInfo will g_free it when destroyed. + * * @param user_info The GaimNotifyUserInfo * * @result A GList of GaimNotifyUserInfoEntry objects @@ -483,6 +487,23 @@ void gaim_notify_user_info_prepend_pair(GaimNotifyUserInfo *user_info, const char *label, const char *value); /** + * Create a new GaimNotifyUserInfoEntry + * + * If added to a GaimNotifyUserInfo object, this should not be free()'d, as GaimNotifyUserInfo will do so + * when destroyed. gaim_notify_user_info_add_pair() and gaim_notify_user_info_prepend_pair() are convenience + * methods for creating entries and adding them to a GaimNotifyUserInfo. + * + * @param label A label, which for example might be displayed by a UI with a colon after it ("Status:"). Do not include a colon. + * If NULL, value will be displayed without a label. + * @param value The value, which might be displayed by a UI after the label. + * If NULL, label will still be displayed; the UI should then treat label as independent + * and not include a colon if it would otherwise. + * + * @result A new GaimNotifyUserInfoEntry + */ +GaimNotifyUserInfoEntry *gaim_notify_user_info_entry_new(const char *label, const char *value); + +/** * Add a section break. A UI might display this as a horizontal line. * * @param user_info The GaimNotifyUserInfo @@ -512,6 +533,14 @@ gchar *gaim_notify_user_info_entry_get_label(GaimNotifyUserInfoEntry *user_info_entry); /** + * Set the label for a GaimNotifyUserInfoEntry + * + * @param user_info_entry The GaimNotifyUserInfoEntry + * @param label The label + */ +void gaim_notify_user_info_entry_set_label(GaimNotifyUserInfoEntry *user_info_entry, const char *label); + +/** * Get the value for a GaimNotifyUserInfoEntry * * @param user_info_entry The GaimNotifyUserInfoEntry @@ -521,6 +550,33 @@ gchar *gaim_notify_user_info_entry_get_value(GaimNotifyUserInfoEntry *user_info_entry); /** + * Set the value for a GaimNotifyUserInfoEntry + * + * @param user_info_entry The GaimNotifyUserInfoEntry + * @param value The value + */ +void gaim_notify_user_info_entry_set_value(GaimNotifyUserInfoEntry *user_info_entry, const char *value); + + +/** + * Get the type of a GaimNotifyUserInfoEntry + * + * @param user_info_entry The GaimNotifyUserInfoEntry + * + * @result The GaimNotifyUserInfoEntryType + */ +GaimNotifyUserInfoEntryType gaim_notify_user_info_entry_get_type(GaimNotifyUserInfoEntry *user_info_entry); + +/** + * Set the type of a GaimNotifyUserInfoEntry + * + * @param user_info_entry The GaimNotifyUserInfoEntry + * @param The GaimNotifyUserInfoEntryType + */ +void gaim_notify_user_info_entry_set_type(GaimNotifyUserInfoEntry *user_info_entry, + GaimNotifyUserInfoEntryType type); + +/** * Opens a URI or somehow presents it to the user. * * @param handle The plugin or connection handle. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2006-12-26 03:15:09
|
Revision: 18056 http://svn.sourceforge.net/gaim/?rev=18056&view=rev Author: evands Date: 2006-12-25 19:15:08 -0800 (Mon, 25 Dec 2006) Log Message: ----------- Fix a problem with [18053] and add gaim_notify_user_info_remove_entry() Modified Paths: -------------- trunk/libgaim/notify.c trunk/libgaim/notify.h Modified: trunk/libgaim/notify.c =================================================================== --- trunk/libgaim/notify.c 2006-12-26 02:47:13 UTC (rev 18055) +++ trunk/libgaim/notify.c 2006-12-26 03:15:08 UTC (rev 18056) @@ -475,7 +475,7 @@ return NULL; } -static GaimNotifyUserInfoEntry * +GaimNotifyUserInfoEntry * gaim_notify_user_info_entry_new(const char *label, const char *value) { GaimNotifyUserInfoEntry *user_info_entry; @@ -621,7 +621,7 @@ } void -gaim_notify_user_info_entry_set_value(GaimNotifyUserInfoEntry *user_info_entry, GaimNotifyUserInfoEntryType type) +gaim_notify_user_info_entry_set_type(GaimNotifyUserInfoEntry *user_info_entry, GaimNotifyUserInfoEntryType type) { g_return_if_fail(user_info_entry != NULL); @@ -647,6 +647,15 @@ } void +gaim_notify_user_info_remove_entry(GaimNotifyUserInfo *user_info, GaimNotifyUserInfoEntry *user_info_entry) +{ + g_return_if_fail(user_info != NULL); + g_return_if_fail(user_info_entry != NULL); + + user_info->user_info_entries = g_list_remove(user_info->user_info_entries, entry); +} + +void gaim_notify_user_info_add_section_header(GaimNotifyUserInfo *user_info, const char *label) { GaimNotifyUserInfoEntry *entry; Modified: trunk/libgaim/notify.h =================================================================== --- trunk/libgaim/notify.h 2006-12-26 02:47:13 UTC (rev 18055) +++ trunk/libgaim/notify.h 2006-12-26 03:15:08 UTC (rev 18056) @@ -448,6 +448,8 @@ * GaimNotifyUserInfoEntry are allowed in the list. If a GaimNotifyUserInfoEntry item is added to the list, * it should not be g_free()'d by the caller; GaimNotifyUserInfo will g_free it when destroyed. * + * To remove a GaimNotifyUserInfoEntry, use gaim_notify_user_info_remove_entry(). Do not use the GList directly. + * * @param user_info The GaimNotifyUserInfo * * @result A GList of GaimNotifyUserInfoEntry objects @@ -463,7 +465,8 @@ char *gaim_notify_user_info_get_text_with_newline(GaimNotifyUserInfo *user_info, const char *newline); /** - * Add a label/value pair to a GaimNotifyUserInfo object. GaimNotifyUserInfo keeps track of the order in which pairs are added. + * Add a label/value pair to a GaimNotifyUserInfo object. + * GaimNotifyUserInfo keeps track of the order in which pairs are added. * * @param user_info The GaimNotifyUserInfo * @param label A label, which for example might be displayed by a UI with a colon after it ("Status:"). Do not include a colon. @@ -487,6 +490,13 @@ void gaim_notify_user_info_prepend_pair(GaimNotifyUserInfo *user_info, const char *label, const char *value); /** + * Remove a GaimNotifyUserInfoEntry from a GaimNotifyUserInfo object + * + * @param user_info The GaimNotifyUserInfo + * @param user_info_entry The GaimNotifyUserInfoEntry + */ +void gaim_notify_user_info_remove_entry(GaimNotifyUserInfo *user_info, GaimNotifyUserInfoEntry *user_info_entry); +/** * Create a new GaimNotifyUserInfoEntry * * If added to a GaimNotifyUserInfo object, this should not be free()'d, as GaimNotifyUserInfo will do so This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sa...@us...> - 2007-02-09 02:05:16
|
Revision: 18184 http://svn.sourceforge.net/gaim/?rev=18184&view=rev Author: sadrul Date: 2007-02-08 18:05:14 -0800 (Thu, 08 Feb 2007) Log Message: ----------- An example client for libgaim. It is called nullclient, for obvious reasons ;) Added Paths: ----------- trunk/libgaim/example/ trunk/libgaim/example/Makefile.am trunk/libgaim/example/defines.h trunk/libgaim/example/nullclient.c Added: trunk/libgaim/example/Makefile.am =================================================================== --- trunk/libgaim/example/Makefile.am (rev 0) +++ trunk/libgaim/example/Makefile.am 2007-02-09 02:05:14 UTC (rev 18184) @@ -0,0 +1,25 @@ +bin_PROGRAMS = nullclient + +nullclient_SOURCES = nullclient.c +nullclient_DEPENDENCIES = +nullclient_LDFLAGS = -export-dynamic +nullclient_LDADD = \ + $(DBUS_LIBS) \ + $(INTLLIBS) \ + $(GLIB_LIBS) \ + $(LIBXML_LIBS) \ + $(top_builddir)/libgaim/libgaim.la + +AM_CPPFLAGS = \ + -DSTANDALONE \ + -DBR_PTHREADS=0 \ + -DDATADIR=\"$(datadir)\" \ + -DLIBDIR=\"$(libdir)/gaim/\" \ + -DLOCALEDIR=\"$(datadir)/locale\" \ + -DSYSCONFDIR=\"$(sysconfdir)\" \ + -I$(top_srcdir)/libgaim/ \ + -I$(top_srcdir) \ + $(DEBUG_CFLAGS) \ + $(GLIB_CFLAGS) \ + $(DBUS_CFLAGS) \ + $(LIBXML_CFLAGS) Property changes on: trunk/libgaim/example/Makefile.am ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native Added: trunk/libgaim/example/defines.h =================================================================== --- trunk/libgaim/example/defines.h (rev 0) +++ trunk/libgaim/example/defines.h 2007-02-09 02:05:14 UTC (rev 18184) @@ -0,0 +1,3 @@ +#define CUSTOM_USER_DIRECTORY "/dev/null" +#define CUSTOM_PLUGIN_PATH "" +#define UI_ID "nullclient" Property changes on: trunk/libgaim/example/defines.h ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native Added: trunk/libgaim/example/nullclient.c =================================================================== --- trunk/libgaim/example/nullclient.c (rev 0) +++ trunk/libgaim/example/nullclient.c 2007-02-09 02:05:14 UTC (rev 18184) @@ -0,0 +1,255 @@ +#include "account.h" +#include "conversation.h" +#include "core.h" +#include "debug.h" +#include "eventloop.h" +#include "ft.h" +#include "log.h" +#include "notify.h" +#include "prefix.h" +#include "prefs.h" +#include "prpl.h" +#include "pounce.h" +#include "savedstatuses.h" +#include "sound.h" +#include "status.h" +#include "util.h" +#include "whiteboard.h" + +#include <glib.h> + +#include <string.h> +#include <unistd.h> + +#include "defines.h" + +/** + * The following eventloop functions are used in both gaim and gaim-text. If your + * application uses glib mainloop, you can safely use this verbatim. + */ +#define GAIM_GLIB_READ_COND (G_IO_IN | G_IO_HUP | G_IO_ERR) +#define GAIM_GLIB_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL) + +typedef struct _GaimGLibIOClosure { + GaimInputFunction function; + guint result; + gpointer data; +} GaimGLibIOClosure; + +static void gaim_glib_io_destroy(gpointer data) +{ + g_free(data); +} + +static gboolean gaim_glib_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data) +{ + GaimGLibIOClosure *closure = data; + GaimInputCondition gaim_cond = 0; + + if (condition & GAIM_GLIB_READ_COND) + gaim_cond |= GAIM_INPUT_READ; + if (condition & GAIM_GLIB_WRITE_COND) + gaim_cond |= GAIM_INPUT_WRITE; + + closure->function(closure->data, g_io_channel_unix_get_fd(source), + gaim_cond); + + return TRUE; +} + +static guint glib_input_add(gint fd, GaimInputCondition condition, GaimInputFunction function, + gpointer data) +{ + GaimGLibIOClosure *closure = g_new0(GaimGLibIOClosure, 1); + GIOChannel *channel; + GIOCondition cond = 0; + + closure->function = function; + closure->data = data; + + if (condition & GAIM_INPUT_READ) + cond |= GAIM_GLIB_READ_COND; + if (condition & GAIM_INPUT_WRITE) + cond |= GAIM_GLIB_WRITE_COND; + + channel = g_io_channel_unix_new(fd); + closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond, + gaim_glib_io_invoke, closure, gaim_glib_io_destroy); + + g_io_channel_unref(channel); + return closure->result; +} + +static GaimEventLoopUiOps glib_eventloops = +{ + g_timeout_add, + g_source_remove, + glib_input_add, + g_source_remove +}; +/*** End of the eventloop functions. ***/ + +/*** Conversation uiops ***/ +static void +null_write_conv(GaimConversation *conv, const char *who, const char *alias, + const char *message, GaimMessageFlags flags, time_t mtime) +{ + const char *name; + if (alias && *alias) + name = alias; + else if (who && *who) + name = who; + else + name = NULL; + + printf("(%s) %s %s: %s\n", gaim_conversation_get_name(conv), + gaim_utf8_strftime("(%H:%M:%S)", localtime(&mtime)), + name, message); +} + +static GaimConversationUiOps null_conv_uiops = +{ + .write_conv = null_write_conv +}; + +static void +null_ui_init() +{ + /** + * This should initialize the UI components for all the modules. Here we + * just initialize the UI for conversations. + */ + gaim_conversations_set_ui_ops(&null_conv_uiops); +} + +static GaimCoreUiOps null_core_uiops = +{ + NULL, + NULL, + null_ui_init, + NULL +}; + +static void +init_libgaim() +{ + /* Set a custom user directory (optional) */ + gaim_util_set_user_dir(CUSTOM_USER_DIRECTORY); + + /* We do not want any debugging for now to keep the noise to a minimum. */ + gaim_debug_set_enabled(FALSE); + + /* Set the core-uiops, which is used to + * - initialize the ui specific preferences. + * - initialize the debug ui. + * - initialize the ui components for all the modules. + * - uninitialize the ui components for all the modules when the core terminates. + */ + gaim_core_set_ui_ops(&null_core_uiops); + + /* Set the uiops for the eventloop. If your client is glib-based, you can safely + * copy this verbatim. */ + gaim_eventloop_set_ui_ops(&glib_eventloops); + + /* Set path to search for plugins. The core (libgaim) takes care of loading the + * core-plugins, which includes the protocol-plugins. So it is not essential to add + * any path here, but it might be desired, especially for ui-specific plugins. */ + gaim_plugins_add_search_path(CUSTOM_PLUGIN_PATH); + + /* Now that all the essential stuff has been set, let's try to init the core. It's + * necessary to provide a non-NULL name for the current ui to the core. This name + * is used by stuff that depends on this ui, for example the ui-specific plugins. */ + if (!gaim_core_init(UI_ID)) { + /* Initializing the core failed. Terminate. */ + fprintf(stderr, + "libgaim initialization failed. Dumping core.\n" + "Please report this!\n"); + abort(); + } + + /* Create and load the buddylist. */ + gaim_set_blist(gaim_blist_new()); + gaim_blist_load(); + + /* Load the preferences. */ + gaim_prefs_load(); + +#if 0 + /* Load the desired plugins. */ + gaim_plugins_load_saved("/"); +#endif + + /* Load the pounces. */ + gaim_pounces_load(); +} + +static void +signed_on(GaimConnection *gc, gpointer null) +{ + GaimAccount *account = gaim_connection_get_account(gc); + printf("Account connected: %s %s\n", account->username, account->protocol_id); +} + +static void +connect_to_signals_for_demonstration_purposes_only() +{ + static int handle; + gaim_signal_connect(gaim_connections_get_handle(), "signed-on", &handle, + GAIM_CALLBACK(signed_on), NULL); +} + +int main() +{ + GList *iter; + int i, num; + GList *names = NULL; + const char *prpl; + char name[128]; + char *password; + GMainLoop *loop = g_main_loop_new(NULL, FALSE); + GaimAccount *account; + GaimSavedStatus *status; + + init_libgaim(); + + printf("libgaim initialized.\n"); + + iter = gaim_plugins_get_protocols(); + for (i = 0; iter; iter = iter->next) { + GaimPlugin *plugin = iter->data; + GaimPluginInfo *info = plugin->info; + if (info && info->name) { + printf("\t%d: %s\n", i++, info->name); + names = g_list_append(names, info->id); + } + } + printf("Select the protocol [0-%d]: ", i-1); + fgets(name, sizeof(name), stdin); + sscanf(name, "%d", &num); + prpl = g_list_nth_data(names, num); + + printf("Username: "); + fgets(name, sizeof(name), stdin); + name[strlen(name) - 1] = 0; /* strip the \n at the end */ + + /* Create the account */ + account = gaim_account_new(name, prpl); + + /* Get the password for the account */ + password = getpass("Password: "); + gaim_account_set_password(account, password); + + /* It's necessary to enable the account first. */ + gaim_account_set_enabled(account, UI_ID, TRUE); + + /* Now, to connect the account(s), create a status and activate it. */ + status = gaim_savedstatus_new(NULL, GAIM_STATUS_AVAILABLE); + gaim_savedstatus_activate(status); + + connect_to_signals_for_demonstration_purposes_only(); + + g_main_loop_run(loop); + + return 0; +} + Property changes on: trunk/libgaim/example/nullclient.c ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2007-02-09 07:47:23
|
Revision: 18186 http://svn.sourceforge.net/gaim/?rev=18186&view=rev Author: thekingant Date: 2007-02-08 23:47:20 -0800 (Thu, 08 Feb 2007) Log Message: ----------- sf patch #1655057, from Peter Tang Fix a memory leak when signing off an account, I think. Peter Tang found it and suggested one fix. I suggested another, then Sadrul made it work. I like this change. We're now re-using GaimStatusType objects instead of making lots of copies of them. Modified Paths: -------------- trunk/libgaim/account.c trunk/libgaim/prpl.c Modified: trunk/libgaim/account.c =================================================================== --- trunk/libgaim/account.c 2007-02-09 07:28:34 UTC (rev 18185) +++ trunk/libgaim/account.c 2007-02-09 07:47:20 UTC (rev 18186) @@ -827,8 +827,6 @@ /* 0 is not a valid privacy setting */ account->perm_deny = GAIM_PRIVACY_ALLOW_ALL; - account->presence = gaim_presence_new_for_account(account); - prpl = gaim_find_prpl(protocol_id); if (prpl == NULL) @@ -838,6 +836,8 @@ if (prpl_info != NULL && prpl_info->status_types != NULL) gaim_account_set_status_types(account, prpl_info->status_types(account)); + account->presence = gaim_presence_new_for_account(account); + status_type = gaim_account_get_status_type_with_primitive(account, GAIM_STATUS_AVAILABLE); if (status_type != NULL) gaim_presence_set_status_active(account->presence, Modified: trunk/libgaim/prpl.c =================================================================== --- trunk/libgaim/prpl.c 2007-02-09 07:28:34 UTC (rev 18185) +++ trunk/libgaim/prpl.c 2007-02-09 07:47:20 UTC (rev 18186) @@ -221,31 +221,20 @@ GList * gaim_prpl_get_statuses(GaimAccount *account, GaimPresence *presence) { - GaimPlugin *prpl; - GaimPluginProtocolInfo *prpl_info; GList *statuses = NULL; - GList *l, *list; + const GList *l; GaimStatus *status; g_return_val_if_fail(account != NULL, NULL); g_return_val_if_fail(presence != NULL, NULL); - prpl = gaim_find_prpl(gaim_account_get_protocol_id(account)); - - if (prpl == NULL) - return NULL; - - prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); - if (prpl_info == NULL || prpl_info->status_types == NULL) - return NULL; - - for (l = list = prpl_info->status_types(account); l != NULL; l = l->next) + for (l = gaim_account_get_status_types(account); l != NULL; l = l->next) { status = gaim_status_new((GaimStatusType *)l->data, presence); - statuses = g_list_append(statuses, status); + statuses = g_list_prepend(statuses, status); } - g_list_free(list); + statuses = g_list_reverse(statuses); return statuses; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rl...@us...> - 2007-03-24 05:35:19
|
Revision: 18216 http://svn.sourceforge.net/gaim/?rev=18216&view=rev Author: rlaager Date: 2007-03-23 22:34:01 -0700 (Fri, 23 Mar 2007) Log Message: ----------- SF Patch #1686400 from Eoin Coffey ("ecoffey") ecoffey described the changes: 1) Small tweaks to the loader to bring it up to speed with new mono versions and API wrapper changes that grim had made. (was in original patch, just forgot about it :-P) 2) .NET Plugins are now required to define an Id as part of their info. 3) Modified gaim_probe_plugin to check for existence of info->id and to make sure it's not empty; Prints an error, stores an error in the plugin and sets plugin->unloadable = TRUE. Modified Paths: -------------- trunk/libgaim/plugin.c trunk/libgaim/plugins/mono/BooPlugin.boo trunk/libgaim/plugins/mono/GetBuddyBack.cs trunk/libgaim/plugins/mono/MPlugin.cs trunk/libgaim/plugins/mono/api/GaimPlugin.cs trunk/libgaim/plugins/mono/loader/mono-helper.c trunk/libgaim/plugins/mono/loader/mono-helper.h trunk/libgaim/plugins/mono/loader/mono.c Modified: trunk/libgaim/plugin.c =================================================================== --- trunk/libgaim/plugin.c 2007-03-23 06:58:04 UTC (rev 18215) +++ trunk/libgaim/plugin.c 2007-03-24 05:34:01 UTC (rev 18216) @@ -369,6 +369,20 @@ return plugin; } + /* + * Check to make sure a plugin has defined an id. + * Not having this check caused gaim_plugin_unload to + * enter an infinite loop in certain situations by passing + * gaim_find_plugin_by_id a NULL value. -- ecoffey + */ + if (!plugin->info->id || !strcmp(plugin->info->id, "")) + { + plugin->error = g_strdup_printf(_("This plugin has not defined an ID.")); + gaim_debug_error("plugins", "%s is not loadable: info->id is not defined.\n", plugin->path); + plugin->unloadable = TRUE; + return plugin; + } + /* Really old plugins. */ if (plugin->info->magic != GAIM_PLUGIN_MAGIC) { Modified: trunk/libgaim/plugins/mono/BooPlugin.boo =================================================================== --- trunk/libgaim/plugins/mono/BooPlugin.boo 2007-03-23 06:58:04 UTC (rev 18215) +++ trunk/libgaim/plugins/mono/BooPlugin.boo 2007-03-24 05:34:01 UTC (rev 18216) @@ -18,5 +18,5 @@ Debug.debug(Debug.INFO, "booplugin", "destroying...\n") override def Info(): - return GaimPluginInfo("Boo Plugin", "0.1", "Test Boo Plugin", "Longer Description", "Eoin Coffey", "urled") + return GaimPluginInfo("mono-boo", "Boo Plugin", "0.1", "Test Boo Plugin", "Longer Description", "Eoin Coffey", "urled") Modified: trunk/libgaim/plugins/mono/GetBuddyBack.cs =================================================================== --- trunk/libgaim/plugins/mono/GetBuddyBack.cs 2007-03-23 06:58:04 UTC (rev 18215) +++ trunk/libgaim/plugins/mono/GetBuddyBack.cs 2007-03-24 05:34:01 UTC (rev 18216) @@ -2,7 +2,7 @@ public class GetBuddyBack : Plugin { - private static PluginInfo info = new PluginInfo("C# Get Buddy Back", "0.1", "Prints when a Buddy returns", "Longer Description", "Eoin Coffey", "urled"); + private static PluginInfo info = new PluginInfo("mono-buddyback", "C# Get Buddy Back", "0.1", "Prints when a Buddy returns", "Longer Description", "Eoin Coffey", "urled"); public GetBuddyBack() : base (info) @@ -21,7 +21,7 @@ Debug.debug(Debug.INFO, "buddyback", "loading...\n"); /*Signal.connect(BuddyList.GetHandle(), this, "buddy-back", new Signal.Handler(HandleSig));*/ - /*BuddyList.OnBuddyBack.connect(this, new Signal.Handler(HandleSig));*/ + BuddyList.OnBuddyStatusChanged.connect(this, new Signal.Handler(HandleSig)); } public override void Unload() Modified: trunk/libgaim/plugins/mono/MPlugin.cs =================================================================== --- trunk/libgaim/plugins/mono/MPlugin.cs 2007-03-23 06:58:04 UTC (rev 18215) +++ trunk/libgaim/plugins/mono/MPlugin.cs 2007-03-24 05:34:01 UTC (rev 18216) @@ -2,7 +2,7 @@ public class MPlugin : Plugin { - private static PluginInfo info = new PluginInfo("C# Plugin", "0.1", "Test C# Plugin", "Longer Description", "Eoin Coffey", "urled"); + private static PluginInfo info = new PluginInfo("mono-mplugin", "C# Plugin", "0.1", "Test C# Plugin", "Longer Description", "Eoin Coffey", "urled"); public MPlugin() : base(info) Modified: trunk/libgaim/plugins/mono/api/GaimPlugin.cs =================================================================== --- trunk/libgaim/plugins/mono/api/GaimPlugin.cs 2007-03-23 06:58:04 UTC (rev 18215) +++ trunk/libgaim/plugins/mono/api/GaimPlugin.cs 2007-03-24 05:34:01 UTC (rev 18216) @@ -1,5 +1,6 @@ namespace Gaim { public class PluginInfo { + private string id; private string name; private string version; private string summary; @@ -7,9 +8,10 @@ private string author; private string homepage; - public PluginInfo(string name, string version, string summary, + public PluginInfo(string id, string name, string version, string summary, string description, string author, string homepage) { + this.id = id; this.name = name; this.version = version; this.summary = summary; @@ -18,6 +20,10 @@ this.homepage = homepage; } + public string Id { + get { return id; } + } + public string Name { get { return name; } } Modified: trunk/libgaim/plugins/mono/loader/mono-helper.c =================================================================== --- trunk/libgaim/plugins/mono/loader/mono-helper.c 2007-03-23 06:58:04 UTC (rev 18215) +++ trunk/libgaim/plugins/mono/loader/mono-helper.c 2007-03-24 05:34:01 UTC (rev 18216) @@ -84,10 +84,13 @@ total = mono_image_get_table_rows (image, MONO_TABLE_TYPEDEF); for (i = 1; i <= total; ++i) { klass = mono_class_get (image, MONO_TOKEN_TYPE_DEF | i); + pklass = mono_class_get_parent(klass); - if (pklass) - if (strcmp("GaimPlugin", mono_class_get_name(pklass)) == 0) + if (pklass) { + + if (strcmp("Plugin", mono_class_get_name(pklass)) == 0) return klass; + } } return NULL; @@ -126,6 +129,18 @@ return mono_string_to_utf8(str); } +MonoObject* ml_get_info_prop(MonoObject *obj) +{ + MonoClass *klass; + MonoProperty *prop; + + klass = mono_class_get_parent(mono_object_get_class(obj)); + + prop = mono_class_get_property_from_name(klass, "Info"); + + return mono_property_get_value(prop, obj, NULL, NULL); +} + gboolean ml_is_api_dll(MonoImage *image) { MonoClass *klass; Modified: trunk/libgaim/plugins/mono/loader/mono-helper.h =================================================================== --- trunk/libgaim/plugins/mono/loader/mono-helper.h 2007-03-23 06:58:04 UTC (rev 18215) +++ trunk/libgaim/plugins/mono/loader/mono-helper.h 2007-03-24 05:34:01 UTC (rev 18216) @@ -40,6 +40,8 @@ void ml_set_prop_string(MonoObject *obj, char *field, char *data); +MonoObject* ml_get_info_prop(MonoObject *obj); + gboolean ml_is_api_dll(MonoImage *image); MonoDomain* ml_get_domain(void); Modified: trunk/libgaim/plugins/mono/loader/mono.c =================================================================== --- trunk/libgaim/plugins/mono/loader/mono.c 2007-03-23 06:58:04 UTC (rev 18215) +++ trunk/libgaim/plugins/mono/loader/mono.c 2007-03-24 05:34:01 UTC (rev 18216) @@ -26,9 +26,8 @@ { MonoAssembly *assm; MonoMethod *m = NULL; - MonoMethod *info_method = NULL; MonoObject *plugin_info; - gboolean found_load = FALSE, found_unload = FALSE, found_destroy = FALSE, found_info = FALSE; + gboolean found_load = FALSE, found_unload = FALSE, found_destroy = FALSE; gpointer iter = NULL; GaimPluginInfo *info; @@ -71,6 +70,7 @@ mono_runtime_object_init(mplug->obj); while ((m = mono_class_get_methods(mplug->klass, &iter))) { + gaim_debug(GAIM_DEBUG_INFO, "mono", "plugin method: %s\n", mono_method_get_name(m)); if (strcmp(mono_method_get_name(m), "Load") == 0) { mplug->load = m; found_load = TRUE; @@ -80,22 +80,20 @@ } else if (strcmp(mono_method_get_name(m), "Destroy") == 0) { mplug->destroy = m; found_destroy = TRUE; - } else if (strcmp(mono_method_get_name(m), "Info") == 0) { - info_method = m; - found_info = TRUE; } } - if (!(found_load && found_unload && found_destroy && found_info)) { + if (!(found_load && found_unload && found_destroy)) { gaim_debug(GAIM_DEBUG_ERROR, "mono", "did not find the required methods\n"); return FALSE; } + + plugin_info = ml_get_info_prop(mplug->obj); - plugin_info = ml_invoke(info_method, mplug->obj, NULL); - /* now that the methods are filled out we can populate the info struct with all the needed info */ + info->id = ml_get_prop_string(plugin_info, "Id"); info->name = ml_get_prop_string(plugin_info, "Name"); info->version = ml_get_prop_string(plugin_info, "Version"); info->summary = ml_get_prop_string(plugin_info, "Summary"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |