本文整理汇总了C++中AccountHandler::constructBuddy方法的典型用法代码示例。如果您正苦于以下问题:C++ AccountHandler::constructBuddy方法的具体用法?C++ AccountHandler::constructBuddy怎么用?C++ AccountHandler::constructBuddy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AccountHandler
的用法示例。
在下文中一共展示了AccountHandler::constructBuddy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: constructBuddy
BuddyPtr AbiCollabSessionManager::constructBuddy(const std::string& identifier, BuddyPtr pBuddy)
{
UT_DEBUGMSG(("AbiCollabSessionManager::constructBuddy() - identifier: %s\n", identifier.c_str()));
// find an account hander to handle this identifier
for (UT_uint32 i = 0; i < m_vecAccounts.size(); i++)
{
AccountHandler* pHandler = m_vecAccounts[i];
UT_continue_if_fail(pHandler);
if (pHandler->recognizeBuddyIdentifier(identifier))
return pHandler->constructBuddy(identifier, pBuddy);
}
UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN);
return BuddyPtr();
}
示例2: loadProfile
void AbiCollabSessionManager::loadProfile()
{
UT_DEBUGMSG(("AbiCollabSessionManager::loadProfile()\n"));
gchar *s = g_build_filename(XAP_App::getApp()->getUserPrivateDirectory(),
"AbiCollab.Profile", (void*)0);
UT_UTF8String profile(s);
FREEP(s);
GsfInput* in = NULL;
char *uri = UT_go_filename_to_uri(profile.utf8_str());
UT_return_if_fail(uri);
in = UT_go_file_open(uri, NULL); // TODO: shouldn't use NULL here, but check for errors
FREEP(uri);
if (!in)
return;
guint8 const* contents = gsf_input_read(in, gsf_input_size(in), NULL);
if (contents)
{
xmlDocPtr reader = xmlReadMemory(reinterpret_cast<const char*>(contents),
strlen(reinterpret_cast<const char*>(contents)), 0, "UTF-8", 0);
if (reader)
{
xmlNode* node = xmlDocGetRootElement(reader);
if (node)
{
if (strcmp(reinterpret_cast<const char*>(node->name), "AbiCollabProfile") == 0)
{
for (xmlNode* accountNode = node->children; accountNode; accountNode = accountNode->next)
{
// TODO: check if this node is really an AccountHandler node
// find the account handler belonging to this type
xmlChar* prop = xmlGetProp(accountNode, BAD_CAST "type");
UT_UTF8String handlerType = reinterpret_cast<char *>(prop);
xmlFree(prop);
std::map<UT_UTF8String, AccountHandlerConstructor>::iterator handler_iter = m_regAccountHandlers.find(handlerType);
if (handler_iter == m_regAccountHandlers.end())
continue; // could happen for example when the sugar backend is found in the profile, which does not have a registered account handler belowing to it for now
AccountHandlerConstructor constructor = handler_iter->second;
AccountHandler* pHandler = constructor();
UT_continue_if_fail(pHandler);
for (xmlNode* accountProp = accountNode->children; accountProp; accountProp = accountProp->next)
{
if (accountProp->type == XML_ELEMENT_NODE)
{
// some node names are pre-defined...
if (strcmp(reinterpret_cast<const char*>(accountProp->name), "buddies") == 0)
{
for (xmlNode* buddyNode = accountProp->children; buddyNode; buddyNode = buddyNode->next)
{
if (buddyNode->type != XML_ELEMENT_NODE)
continue;
UT_continue_if_fail(strcmp(reinterpret_cast<const char*>(buddyNode->name), "buddy") == 0);
UT_continue_if_fail(buddyNode->children);
// read all buddy properties
PropertyMap vBuddyProps;
for (xmlNode* buddyPropertyNode = buddyNode->children; buddyPropertyNode; buddyPropertyNode = buddyPropertyNode->next)
{
UT_continue_if_fail(buddyPropertyNode->type == XML_ELEMENT_NODE);
UT_UTF8String buddyPropValue = reinterpret_cast<const char*>(xmlNodeGetContent(buddyPropertyNode));
UT_continue_if_fail(buddyPropertyNode->name && *buddyPropertyNode->name && buddyPropValue.size() > 0);
vBuddyProps.insert(PropertyMap::value_type(
reinterpret_cast<const char*>(buddyPropertyNode->name),
buddyPropValue.utf8_str())
);
}
// construct the buddy
BuddyPtr pBuddy = pHandler->constructBuddy(vBuddyProps);
if (pBuddy)
{
// add the buddy to the account handler
pHandler->addBuddy(pBuddy);
}
}
}
else
{
// ... the rest are generic properties
UT_UTF8String propValue = reinterpret_cast<const char*>(xmlNodeGetContent(accountProp));
pHandler->addProperty(reinterpret_cast<const char*>(accountProp->name), propValue.utf8_str());
}
}
}
// add the account to the account list if it is not a duplicate
if (addAccount(pHandler))
{
if (pHandler->autoConnect())
pHandler->connect();
}
else
//.........这里部分代码省略.........