本文整理汇总了C++中ConnectionSettings::setServerGroup方法的典型用法代码示例。如果您正苦于以下问题:C++ ConnectionSettings::setServerGroup方法的具体用法?C++ ConnectionSettings::setServerGroup怎么用?C++ ConnectionSettings::setServerGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConnectionSettings
的用法示例。
在下文中一共展示了ConnectionSettings::setServerGroup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: connectTo
void ConnectionManager::connectTo(Konversation::ConnectionFlag flag, int serverGroupId)
{
ConnectionSettings settings;
Konversation::ServerGroupSettingsPtr serverGroup;
serverGroup = Preferences::serverGroupById(serverGroupId);
if (serverGroup)
{
settings.setServerGroup(serverGroup);
if (serverGroup->serverList().size() > 0)
settings.setServer(serverGroup->serverList()[0]);
}
connectTo(flag, settings);
}
示例2: decodeAddress
void ConnectionManager::decodeAddress(const QString& address, ConnectionSettings& settings,
bool checkIfServerGroup)
{
QString host;
QString port = "6667";
// Full-length IPv6 address with port
// Example: RFC 2732 notation: [2001:0DB8:0000:0000:0000:0000:1428:57ab]:6666
// Example: Non-RFC 2732 notation: 2001:0DB8:0000:0000:0000:0000:1428:57ab:6666
if (address.count(':')==8)
{
host = address.section(':',0,-2).remove('[').remove(']');
port = address.section(':',-1);
}
// Full-length IPv6 address without port or not-full-length IPv6 address with port
// Example: Without port, RFC 2732 notation: [2001:0DB8:0000:0000:0000:0000:1428:57ab]
// Example: Without port, Non-RFC 2732 notation: 2001:0DB8:0000:0000:0000:0000:1428:57ab
// Example: With port, RFC 2732 notation: [2001:0DB8::1428:57ab]:6666
else if (address.count(':')>=4)
{
// Last segment does not end with ], but the next to last does;
// Assume not-full-length IPv6 address with port
// Example: [2001:0DB8::1428:57ab]:6666
if (address.section(':',0,-2).endsWith(']') && !address.section(':',-1).endsWith(']'))
{
host = address.section(':',0,-2).remove('[').remove(']');
port = address.section(':',-1);
}
else
{
QString addressCopy = address;
host = addressCopy.remove('[').remove(']');
}
}
// IPv4 address or ordinary hostname with port
// Example: IPv4 address with port: 123.123.123.123:6666
// Example: Hostname with port: irc.bla.org:6666
else if (address.count(':')==1)
{
host = address.section(':',0,-2);
port = address.section(':',-1);
}
else
host = address;
// Try to assign server group.
if (checkIfServerGroup && Preferences::isServerGroup(host))
{
// If host is found to be the name of a server group.
int serverGroupId = Preferences::serverGroupIdsByName(host).first();
Konversation::ServerGroupSettingsPtr serverGroup;
serverGroup = Preferences::serverGroupById(serverGroupId);
settings.setServerGroup(serverGroup);
if (serverGroup->serverList().size() > 0)
settings.setServer(serverGroup->serverList()[0]);
}
else
{
QList<Konversation::ServerGroupSettingsPtr> groups = Preferences::serverGroupsByServer(host);
if (!groups.isEmpty())
{
// If the host is found to be part of a server group's server list.
Konversation::ServerGroupSettingsPtr serverGroup = groups.first();
settings.setServerGroup(serverGroup);
}
Konversation::ServerSettings server;
server.setHost(host);
server.setPort(port.toInt());
settings.setServer(server);
}
}