void MeanwhileSession::handleStorageLoad(struct mwServiceStorage * /* srvc */, guint32 result, struct mwStorageUnit *item, gpointer /* data */) { HERE; if (result != ERR_SUCCESS) { mwDebug() << "contact list load returned " << result << endl; return; } struct mwGetBuffer *buf = mwGetBuffer_wrap(mwStorageUnit_asOpaque(item)); struct mwSametimeList *list = mwSametimeList_new(); mwSametimeList_get(buf, list); GList *gl, *glf, *cl, *clf; Kopete::ContactList *contactlist = Kopete::ContactList::self(); for (glf = gl = mwSametimeList_getGroups(list); gl; gl = gl->next) { struct mwSametimeGroup *stgroup = (struct mwSametimeGroup *)gl->data; Kopete::Group *group = contactlist->findGroup(mwSametimeGroup_getName(stgroup)); group->setPluginData(account->protocol(), "alias", mwSametimeGroup_getAlias(stgroup)); for (clf = cl = mwSametimeGroup_getUsers(stgroup); cl; cl = cl->next) { struct mwSametimeUser *stuser = (struct mwSametimeUser *)cl->data; MeanwhileContact *contact = static_cast<MeanwhileContact *> (account->contacts().value(mwSametimeUser_getUser(stuser))); if (contact != 0L) continue; account->addContact(mwSametimeUser_getUser(stuser), mwSametimeUser_getAlias(stuser), group, Kopete::Account::ChangeKABC); } g_list_free(clf); } g_list_free(glf); mwSametimeList_free(list); }
void CSametimeProto::ImportContactsFromList(mwSametimeList* user_list, bool temporary) { debugLog(_T("CSametimeProto::ImportContactsFromList() start")); // add contacts mwSametimeGroup* stgroup; mwSametimeUser* stuser; GList *gl, *gtl, *ul, *utl; const char* group_name; const char* group_alias; mwSametimeGroupType group_type; bool group_open; gl = gtl = mwSametimeList_getGroups(user_list); for (; gl; gl = gl->next) { char buff[256]; stgroup = (mwSametimeGroup*)gl->data; group_name = mwSametimeGroup_getName(stgroup); group_alias = mwSametimeGroup_getAlias(stgroup); if (!group_alias) group_alias = group_name; group_type = mwSametimeGroup_getType(stgroup); group_open = (mwSametimeGroup_isOpen(stgroup) != 0); mir_snprintf(buff, "GN_%s", group_alias); db_set_utf(0, szProtoGroups, buff, group_name); mir_snprintf(buff, "GT_%s", group_alias); db_set_b(0, szProtoGroups, buff, (BYTE)group_type); mir_snprintf(buff, "GO_%s", group_alias); db_set_b(0, szProtoGroups, buff, (BYTE)(group_open ? 1 : 0)); // inverse mapping mir_snprintf(buff, "GA_%s", group_name); db_set_utf(0, szProtoGroups, buff, group_alias); AddGroup(group_alias, group_open); if (group_type == mwSametimeGroup_DYNAMIC) { mwAwareIdBlock id_block; id_block.type = mwAware_GROUP; id_block.user = (char*)group_name; id_block.community = 0; GList* gl = g_list_prepend(NULL, &id_block); mwAwareList_addAware(aware_list, gl); g_list_free(gl); } ul = utl = mwSametimeGroup_getUsers(stgroup); for (; ul; ul = ul->next) { stuser = (mwSametimeUser*)ul->data; MCONTACT hContact = AddContact(stuser, temporary); if (hContact && group_alias && mir_strcmp(group_alias, Translate("None")) != 0 && mir_strcmp(group_alias, "MetaContacts Hidden Group") != 0) { SetContactGroup(hContact, group_alias); // mark contact as belonging to dynamic group } } g_list_free(utl); } g_list_free(gtl); }