Idea about emoticon cache

zhang kai kylerzhang11 at gmail.com
Sun Mar 18 13:47:24 EDT 2012


Hi,
This is my basic idea about pidgin emoticon cache.
I plan to divide the emoticon cache project into three stages.

Stage 1:

Implement a global permanent cache system. It includes:

   1. A set of functions to load(save, remove) emoticons in the cache
   system.
   2. A back-end to manage emoticons.

I consider to save all emotions into a single zip compressed file. The file
is formatted like this:

pidgin emoticon cache file tag
pidgin emoticon cache version
pidgin emoticon index offset
emoticon
...
emoticon
emoticon URI<CR><LF>offset<CR><LF>size<CR><LF>
...
emoticon URI<CR><LF>offset<CR><LF>size<CR><LF>

Explanation:

   - *pidgin emoticon cache file tag *is used to identify emoticon cache
   file
   - *pidgin emoticon cache version* is used to help extend and improve
   emoticon cache later.
   - *pidgin emoticon index offset* is the location of emoticon index in
   the cache file. The consideration of putting the index in the end will be
   explained later.
   - *emoticons* are stored sequentially.
   - *emoticon index* includes the emoticon URI, the correspond emoticon
   offset and size.

The reason why the emoticon index is located at the end of the cache file
is based on the assumption that load and save operation is frequent and
remove happens less often.
When a new emoticon is added into the cache system, the emoticon index and
emoticon list both need to extend. Put the index in the end avoids to
relocate - which means to rewrite - the original emoticons whose size is
large compare to the index.

At start up, pidgin find the cache file and load the index into memory.
When an emoticon is loaded pidgin check the URI in the index and use the
offset and size to load the emoticon from the cache file.
When a new emoticon is added pidgin append the emoticon at the end of the
emoticon list, add emoticon URI, offset, size to the index in memory,
change the pidgin emoticon index offset correspondingly.
When a emoticon is removed, the emoticons after it are relocated to its
offset, and change the pidgin emoticon index offset correspondingly.
When people quit pidgin the index is rewrite into cache file.

Stage 2:

Implement a permanent emoticon cache with more configuration options. It
includes:

   1. A set of functions to configure global cache including cache file
   location, maximum cache file size.
   2. A set of functions to configure per account cache include cache file
   location, maximum cache file size.
   3. A set of functions to load(save, remove) emoticons in the global
   cache.
   4. A set of functions to load(save, remove) emoticons in the per account
   cache.
   5. A back-end to manage emoticons.

There is still a single zip compressed file to save all global emoticon
cache. Each account has one zip compressed file to save per account
emoticon cache. The cache format is changed a little.

When a cache file's size hit the maximum limit, pidgin need to remove some
not so frequently used emoticons for new emoticon to be added. So in the
emoticon index, I consider add a count attribute to enable pidgin to choose
which emoticon to remove. Then the emoticon index is like this:


emoticon URI<CR><LF>offset<CR><LF>size<CR><LF>count<CR><LF>

Stage 3:

In stage 1 and stage 2, the emoticon cache system only work inside pidgin.
In stage 3 user can interact with the cache system. It includes:

   1. A set of functions to configure global cache including cache file
   location, maximum cache file size.
   2. A set of functions to configure per account cache include cache file
   location, maximum cache file size.
   3. A set of functions to load(save, remove) emoticons in the global
   cache.
   4. A set of functions to load(save, remove) emoticons in the per account
   cache.
   5. A feature makes user able to export chosen emoticons from cache
   system into a package file.
   6. A feature makes user able to import emoticon package file into cache
   system.
   7. A back-end to manage emoticons.

The emoticon package use the format described in stage 1. Import and export
feature can makes pidgin user share emoticons conveniently.

The main question is what kind of URI pidgin used to identify emoticon?
Does it vary from protocol to protocol? Where could I get the documents or
source code about it?

Thanks for reading and please let me know the mistakes I have made.
Regards.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://pidgin.im/pipermail/devel/attachments/20120319/91bda4e4/attachment-0002.html>


More information about the Devel mailing list