view finch/libgnt/pygnt/common.c @ 19649:c6f1f9971c4a

When doing oscar server-side list management, do deletions before additions because if it's done the other way then it's possible for Pidgin to try to add one buddy to two different groups, which isn't allowed for ICQ. Fixes schoen's comment at http://developer.pidgin.im/ticket/576 References #576.
author Mark Doliner <mark@kingant.net>
date Wed, 05 Sep 2007 05:43:08 +0000
parents 5e1412f4e67a
children
line wrap: on
line source

#include "common.h"

PyObject *
create_pyobject_from_string_list(GList *list)
{
	PyObject *py_list;
	if (list == NULL) {
		Py_INCREF(Py_None);
		return Py_None;
	}
	if ((py_list = PyList_New(0)) == NULL) {
		g_list_foreach(list, (GFunc)g_free, NULL);
		g_list_free(list);
		return NULL;
	}
	while (list) {
		PyObject *obj = PyString_FromString(list->data);
		PyList_Append(py_list, obj);
		Py_DECREF(obj);
		g_free(list->data);
		list = g_list_delete_link(list, list);
	}
	return py_list;
}