Custom emoticons receiving future ...

Jorge Villaseñor salinasv at gmail.com
Mon Nov 5 15:17:49 EST 2007


On 11/5/07, Mauro Sérgio Ferreira Brasil <mauro.brasil at tqi.com.br> wrote:
>
>  Fistly my excuses by the late to answer you message, but I was traveling this holiday (11/02) and weekend.
>
>  By "definitive cache" I mean that we will switch from a per-session basis cache to a cache that will persist the custom emoticons definitively.
>
>  One of my concerns is about exactly that...
>  If someone is already doing this, but let's consider that it's not.
>
>  Another concern is to take the option pointed by you and implement this as a patch internal to libpurple, and take too long to have the patch applied because I'm not aware of your programing patterns and by disagreements of the interfaces the custom emoticon cache must or not have.
>  I'm not aware too of the implications on conversation interfaces when a custom emoticon cache is available. How the invocation of "custom_smiley_add", "custom_smiley_write" and "custom_smiley_close" are supposed to work on "not on cache" and "already on cache" scenarios ?
>  If the cache is internal to libpurple, will "custom_smiley_write" still be called with the file content or will it be changed to pass only the file path of the emoticon already stored ?

please take a look at #1187 to do not use the same functions name in
different things.

Are you thinking in something to "send" the custom emoticon ?

>
>  I think when the custom emoticon is already on cache the only conversation interface called will be "custom_smiley_add" with the "remote" flag with "false". But, how the application will have access to the already downloaded custom emoticon?
>  In fact, all interfaces could be migrated from conversation API to this new API so the application can register methods to receive indications when a custom emoticon is created, updated, etc. (this sounds more acceptable to me)
>
>  Making things short, I'm sending a proposed "customemoticons.h" file that have the event's triggered by this API, the methods available and with some comments to help on understanding.
>  It will suffer some changes during development for sure, but it's just to get the initial idea.
>
>  I would like to make some considerations too:
>
>  1- I think is desirable to individualize the custom emoticon files per account and per contact, so this API will store a custom emoticon on: "<ROOT_PATH>/<ACCOUNT_ID>/<CONTACT_NAME>" where the "ROOT_PATH" is the default one or the informed on API initialization (see the file attached);
>  2- If we choose to migrate the emoticon interfaces from conversation API to custom emoticon one, they must be added to "_PurpleCustomEmoticonUiOps" structure;
>  3- I intend to organize the list of custom emoticons internally using just a GList to make things easier;
>  4- The custom emoticon XML sample is attached too.
>
>  This is just for a start.
>  And I'll thank you for any suggestions and considerations about what I exposed above.
>
>  Best regards,
>  Mauro.
>
>
>
>  lot's of changes being requested because of differences
>
>
>  Richard Laager wrote:
>    On Thu, 2007-11-01 at 17:49 -0200, Mauro Sérgio Ferreira Brasil wrote:
>
>
>      Now our customer want's us to make a definitive cache for these custom
> emoticons, but I've noticed that this will be made available on future
> versions of the API.
>
>       What do you mean by "definitive cache"? Are you talking about an on-disk
> cache instead of an in-memory cache? Or, are you saying they really
> (definitely) want you to implement it?
>
> Also, I don't know if anyone is currently implementing this cache. So,
> if you want this to be available in the future, you'll have to write
> it. ;)
>
>
>
>      To create a fully operational cache outside the libpurple API
>
>       I think this is where you've gone wrong. Why wouldn't you implement this
> cache in libpurple? The API already talks about a cache. It seems like
> you should just write a patch to cache this in libpurple and you'll be
> done, right?
>
> Richard
>
>
>
> --
>
>         At.,
>
>        Technology and Quality on Information
>        Mauro Sérgio Ferreira Brasil
>         Analista de Sistemas
>        +   mauro.brasil at tqi.com.br
>        :   www.tqi.com.br
>        ( + 55  (34)3291-1700
>        ( + 55  (34)9971-2572
> /**
>  * @file customemoticons.h Custom Emoticon API
>  * @ingroup core
>  */
>
> /* purple
>  *
>  * Purple 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 of the License, or
>  * (at your option) any later version.
>  *
>  * This program is distributed in the hope that it will be useful,
>  * but WITHOUT ANY WARRANTY; without even the implied warranty of
>  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>  * GNU General Public License for more details.
>  *
>  * You should have received a copy of the GNU General Public License
>  * along with this program; if not, write to the Free Software
>  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
>  *
>  */
>
>
> #ifndef _PURPLE_CUSTOM_EMOTICONS_H_
> #define _PURPLE_CUSTOM_EMOTICONS_H_
>
>
> #include <glib.h>
>
>
> typedef struct _PurpleCustomEmoticonUiOps PurpleCustomEmoticonUiOps;
>
> typedef struct _PurpleCustomEmoticon PurpleCustomEmoticon;
>
>
> #include "account.h"
> #include "blist.h"
> #include "imgstore.h"
> #include "util.h"
>
>
> /**
>  * Custom Emoticon UI operations.
>  *
>  * Any UI that wants to be aware of custom emoticon events must assign a
>  * filled-out PurpleCustomEmoticonUiOps structure to the custom emoticon
>  * core.
>  *
>  */
> struct _PurpleCustomEmoticonUiOps
> {
>         void (*added_to_list)(PurpleCustomEmoticon* customEmoticon);     /**< A custom emoticon was added to list. */
>         void (*remotely_updated)(PurpleCustomEmoticon* customEmoticon);   /**< An existent custom emoticon was changed (its image in fact). */
>
>         void (*_purple_reserved1)(void);
>         void (*_purple_reserved2)(void);
> };
>
>
> #ifdef __cplusplus
> extern "C" {
> #endif
>
>
> /**************************************************************************/
> /** @name Custom Emoticon API                                             */
> /**************************************************************************/
> /*@{*/
>
> /**
>  * Creates a new custom emoticon structure and populate it.
>  *
>  * If the custom emoticon already exists, you'll get a reference to that
>  * structure, which will have been updated with the data supplied.
>  *
>  * @param account        The account the user was using when received the
>  *                       custom emoticon.
>  * @param contact        The contact from whom the custom emoticon was
>  *                       received.
>  * @param smiley         The custom emoticon associated shortcut.
>  * @param emoticon_data  The custom emoticon data.
>  * @param emoticon_len   The custom emoticon data length.
>  * @param checksum       The custom emoticon data checksum.
>  *
>  * @return The custom emoticon structure filled up.
>  */
> PurpleCustomEmoticon*
> purple_custom_emoticon_new(PurpleAccount* account, const char* contact,
>                                                    const char* smiley, guchar* emoticon_data,
>                                                    size_t emoticon_len, const char* checksum);
>
> /**
>  * Updates every instance of this custom emoticon.
>  *
>  * @param customEmoticon  The custom emoticon.
>  */
> void purple_custom_emoticon_update(PurpleCustomEmoticon* customEmoticon);
>
> /**
>  * Sets the custom emoticon's data.
>  *
>  * @param customEmoticon  The custom emoticon.
>  * @param data            The custom emoticon data, which the buddy icon code
>  *                        takes ownership of and will free.
>  * @param len             The length of the data in @a data.
>  * @param checksum        The custom emoticon data checksum.
>  */
> void
> purple_custom_emoticon_set_data(PurpleCustomEmoticon* customEmoticon, guchar* data,
>                                 size_t len, const char* checksum);
>
> /**
>  * Returns the custom emoticon's account.
>  *
>  * @param icon The buddy icon.
>  *
>  * @return The account.
>  */
> PurpleAccount *purple_custom_emoticon_get_account(const PurpleCustomEmoticon* customEmoticon);
>
> /**
>  * Returns the custom emoticon's contact.
>  *
>  * @param customEmoticon  The custom emoticon.
>  *
>  * @return The contact.
>  */
> const char *purple_custom_emoticon_get_contact(const PurpleCustomEmoticon* customEmoticon);
>
> /**
>  * Returns the custom emoticon's checksum.
>  *
>  * @param customEmoticon  The custom emoticon.
>  *
>  * @return The checksum.
>  */
> const char *purple_custom_emoticon_get_checksum(const PurpleCustomEmoticon* customEmoticon);
>
> /**
>  * Returns the custom emoticon's data.
>  *
>  * @param customEmoticon  The custom emoticon.
>  * @param len             If not @c NULL, the length of the icon data
>  *                        returned will be set in the location pointed
>  *                        to by this.
>  *
>  * @return A pointer to the custom emoticon data.
>  */
> gconstpointer purple_custom_emoticon_get_data(const PurpleCustomEmoticon* customEmoticon, size_t* len);
>
> /**
>  * Returns a full path to an custom emoticon.
>  *
>  * If the custom emoticon has data and the file exists in the cache, this
>  * will return a full path to the cached file.
>  *
>  * In general, it is not appropriate to be poking in the icon cache
>  * directly.  If you find yourself wanting to use this function, think
>  * very long and hard about it, and then don't.
>  *
>  * @param customEmoticon  The custom emoticon.
>  *
>  * @return A full path to the file, or @c NULL under various conditions.
>  */
> char *purple_custom_emoticon_get_full_path(PurpleCustomEmoticon* customEmoticon);
>
> /*@}*/
>
> /**************************************************************************/
> /** @name Custom Emoticon Subsystem API                                   */
> /**************************************************************************/
> /*@{*/
>
> /**
>  * Adds a custom emoticon associated with a account and a contact to
>  * the list.
>  *
>  * @param account        The account the user was using when received the
>  *                       custom emoticon.
>  * @param contact        The contact from whom the custom emoticon was
>  *                       received.
>  * @param smiley         The custom emoticon associated shortcut.
>  * @param emoticon_data  The custom emoticon data.
>  * @param icon_len       The custom emoticon data length.
>  * @param checksum       The custom emoticon data checksum.
>  *
>  * @return The buddy icon set, or NULL if no icon was set.
>  */
> void
> purple_custom_emoticons_add(PurpleAccount* account, const char* contact,
>                             const char* smiley, void* emoticon_data,
>                                                         size_t emoticon_len, const char* checksum);
>
> /**
>  * Returns the custom emoticon considering the parameters.
>  *
>  * @param account     The account that received the custom emoticon.
>  * @param contact     The contact that sent the custom emoticon.
>  * @param smiley      The custom emoticon shortcut.
>  *
>  * @return The custom emoticon (with a reference for the caller) if found,
>  *         or @c NULL if not found.
>  */
> PurpleCustomEmoticon*
> purple_custom_emoticons_find(PurpleAccount *account, const char *contact,
>                                                          const char* smiley);
>
> /**
>  * Returns a boolean indicating if for a given account, contact and
>  * smiley the cache has a custom emoticon stored.
>  *
>  * @param account     The account that received the custom emoticon.
>  * @param contact     The contact that sent the custom emoticon.
>  * @param smiley      The custom emoticon shortcut.
>  *
>  * @return A boolean indicating if the custom emoticon associated
>  *         with the informed parameters is already cached.
>  */
> gboolean
> purple_custom_emoticons_has_custom_emoticon(PurpleAccount *account,
>                                                                                     const char *contact,
>                                                                                     const char* smiley);
>
> /**
>  * Sets whether or not custom emoticon caching is enabled.
>  *
>  * @param caching TRUE if custom emoticon caching should be enabled, or
>  *                FALSE otherwise.
>  */
> void purple_custom_emoticons_set_caching(gboolean caching);
>
> /**
>  * Returns whether or not custom emoticon caching should be enabled.
>  *
>  * The default is TRUE, unless otherwise specified by
>  * purple_custom_emoticons_set_caching().
>  *
>  * @return TRUE if custom emoticons caching is enabled, or FALSE otherwise.
>  */
> gboolean purple_custom_emoticons_is_caching(void);
>
> /**
>  * Returns the directory used to store custom emoticon cached files.
>  *
>  * The default directory is PURPLEDIR/custom_emoticons, unless
>  * otherwise specified by purple_custom_emoticons_init().
>  *
>  * @return The directory to store custom emoticon cached files to.
>  */
> const char* purple_custom_emoticons_get_cache_dir(void);
>
> /**
>  * Returns the custom emoticon subsystem handle.
>  *
>  * @return The subsystem handle.
>  */
> void* purple_custom_emoticons_get_handle(void);
>
> /**
>  * Initializes the custom emoticon subsystem.
>  *
>  * @param root_path  Path that will be used to store the custom
>  *                   emoticons, or NULL to keep the default one
>  *                   "PURPLEDIR/custom_emoticons".
>  */
> void purple_custom_emoticons_init(const guchar* root_path);
>
> /**
>  * Uninitializes the custom emoticon subsystem.
>  */
> void purple_custom_emoticons_uninit(void);
>
> /*@}*/
>
> #ifdef __cplusplus
> }
> #endif
>
> #endif /* _PURPLE_CUSTOM_EMOTICONS_H_ */
>
>
> _______________________________________________
> Devel mailing list
> Devel at pidgin.im
> http://pidgin.im/cgi-bin/mailman/listinfo/devel
>
>
>




More information about the Devel mailing list