View Single Post
Posts: 246 | Thanked: 2,574 times | Joined on Jan 2010 @ Egypt, Cairo
#1
So I've been trying to access contacts using libosso-abook-1.0 and python

I've been following this tutorial PyMaemo/Accessing APIs Without Python Bindings
and I'm only trying to get the number of contacts, or get GList of them. I just want anything that shows it works (except for the example in the tutorial because it simple works and I need ways other than a widget).

Code:
import ctypes
import osso
import sys
import gtk
from pygobject import *

###### Initialization, got that from the tutorial #####

osso_ctx = osso.Context("test_abook", "0.1")
osso_abook = ctypes.CDLL('libosso-abook-1.0.so.0')
argv_type = ctypes.c_char_p * len(sys.argv)
argv = argv_type(*sys.argv)
argc = ctypes.c_int(len(sys.argv))
osso_abook.osso_abook_init(ctypes.byref(argc), ctypes.byref(argv), hash(osso_ctx))

##################################################


############### Get default aggregator ################

agg = osso_abook.osso_abook_aggregator_get_default(None)
print agg   ### Prints a memory address ### 

##################################################

############ Try to get count ##################

count = osso_abook.osso_abook_aggregator_get_master_contact_count(agg)

print count ### Prints 0 ###

############################################


########## Try to get glists of master and roster ########

masterList = osso_abook.osso_abook_aggregator_list_master_contacts(agg)
print masterList  ### Prints 0 ###
rosterList = osso_abook.osso_abook_aggregator_list_roster_contacts(agg)
print rosterList   ### Prints 0 ###

###########################################
So in that code, why do I receive a zero in any function that I try to call, except for getting the default aggregator? I've seen codes in C , that type cast the the default aggregator into OssoABookAggregator, because that function returns OssoABookRoster *

Code:
roster = (OssoABookAggregator *) osso_abook_aggregator_get_default (NULL);
Is that why my code is not working? If so, I don't know how to do that in python and ctypes and I would appreciate if someone points me out to how to do that.

Attached is the pygobject class
Attached Files
File Type: zip pygobject.py.zip (527 Bytes, 103 views)