Reply
Thread Tools
Posts: 7 | Thanked: 1 time | Joined on May 2010
#1
I am developing a app to import vcard who are in a qr code for maemo 5 in c++/qt.

I want to split the vcard and i have trouble to split the address field. I am doing at this way:

GList* address_list;
char* street;

address_list = (GList*)e_contact_get(contact,E_CONTACT_ADDRESS);

EContactAddress* addr = (EContactAddress*) address_list->data;
street = addr->street;

Is this way correct to access the street field in a EContactAddress ?
Can anyone tell me what is wrong at this code ?

I apreciate your help.

best regards
 
Posts: 4 | Thanked: 2 times | Joined on Mar 2010
#2
Unfortunately, e-contact seems to squash all the address elements together, losing the original context. It's rather keen on this and does it to telephone numbers also.

The only way I've found to maintain the integrity so far is to go directly to e-vcard to retrieve them.

Please excuse my code, I'm learning C++ at the moment!

Code:
const int NFIELDS = 7;
const char *FIELDS[] = {
    "po-box",
    "house",
    "street",
    "city",
    "county",
    "postcode",
    "country"
};
GList *attribs = g_list_last(
    e_vcard_get_attributes(
        E_VCARD( contact )
    )
);
while ( attribs ) {
    EVCardAttribute *attr = static_cast< EVCardAttribute* >( attribs -> data );
    if ( ! strcmp( EVC_ADR, e_vcard_attribute_get_name( attr ) ) ) {
        GList *values = e_vcard_attribute_get_values( attr );
        for (
            int i = 0;
            values && i < NFIELDS;
            i ++
        ) {
            std::cout
                << FIELDS[i]
                << " = "
                << static_cast< const char* >( values -> data )
                << std::endl;
            values = values -> next;
        }
        std::cout << std::endl;
    }
    attribs = attribs -> prev;
}
 
Reply


 
Forum Jump


All times are GMT. The time now is 11:05.