~micahg/ubuntu/natty/pidgin/2.7.9-2

« back to all changes in this revision

Viewing changes to libpurple/plugins/perl/common/BuddyList.xs

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2010-11-05 19:44:21 UTC
  • mfrom: (62.1.1 maverick-security) (2.3.12 sid)
  • Revision ID: james.westby@ubuntu.com-20101105194421-8r8o4pzw2m5j4hiy
Tags: 1:2.7.5-1ubuntu1
Resync on Debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
#include "module.h"
3
3
#include "../perl-handlers.h"
4
4
 
 
5
static void
 
6
chat_components_foreach(gpointer key, gpointer value, gpointer user_data)
 
7
{
 
8
        HV *hv = user_data;
 
9
        hv_store(hv, key, strlen(key), newSVpv(value, 0), 0);
 
10
}
 
11
 
5
12
MODULE = Purple::BuddyList  PACKAGE = Purple  PREFIX = purple_
6
13
PROTOTYPES: ENABLE
7
14
 
331
338
purple_chat_get_name(chat)
332
339
        Purple::BuddyList::Chat chat
333
340
 
 
341
HV *
 
342
purple_chat_get_components(chat)
 
343
        Purple::BuddyList::Chat chat
 
344
INIT:
 
345
        HV * t_HV;
 
346
        GHashTable * t_GHash;
 
347
CODE:
 
348
        t_GHash = purple_chat_get_components(chat);
 
349
        RETVAL = t_HV = newHV();
 
350
        g_hash_table_foreach(t_GHash, chat_components_foreach, t_HV);
 
351
OUTPUT:
 
352
        RETVAL
 
353
 
334
354
Purple::BuddyList::Chat
335
355
purple_chat_new(account, alias, components)
336
356
        Purple::Account account
345
365
        char *t_key, *t_value;
346
366
CODE:
347
367
        t_HV =  (HV *)SvRV(components);
348
 
        t_GHash = g_hash_table_new(g_str_hash, g_str_equal);
 
368
        t_GHash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
349
369
 
350
370
        for (t_HE = hv_iternext(t_HV); t_HE != NULL; t_HE = hv_iternext(t_HV) ) {
351
371
                t_key = hv_iterkey(t_HE, &len);
352
372
                t_SV = *hv_fetch(t_HV, t_key, len, 0);
353
373
                t_value = SvPVutf8_nolen(t_SV);
354
374
 
355
 
                g_hash_table_insert(t_GHash, t_key, t_value);
 
375
                g_hash_table_insert(t_GHash, g_strdup(t_key), g_strdup(t_value));
356
376
        }
357
377
 
358
378
        RETVAL = purple_chat_new(account, alias, t_GHash);