本文整理汇总了C++中QScopedPointer::Start方法的典型用法代码示例。如果您正苦于以下问题:C++ QScopedPointer::Start方法的具体用法?C++ QScopedPointer::Start怎么用?C++ QScopedPointer::Start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScopedPointer
的用法示例。
在下文中一共展示了QScopedPointer::Start方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
QCoreApplication qca(argc, argv);
QStringList args = QCoreApplication::arguments();
Settings settings = Settings::CommandLineParse(args);
if(settings.Help || !settings.IsValid()) {
QTextStream qtout(stdout, QIODevice::WriteOnly);
qtout << "usage: " << args[0] << " [options] [settings.conf]\n\n";
qtout << "options:\n";
qtout << Settings::GetUsage() << "\n";
if(!settings.Help) {
qtout << "error: " << settings.GetError() << "\n\n";
}
return -1;
}
Settings::ApplicationSettings = settings;
QList<QSharedPointer<Node> > nodes;
QSharedPointer<ISink> default_sink(new DummySink());
QSharedPointer<SinkMultiplexer> app_sink(new SinkMultiplexer());
QSharedPointer<CommandLine> commandline;
QSharedPointer<SignalSink> signal_sink(new SignalSink());
app_sink->AddSink(signal_sink.data());
QSharedPointer<KeyShare> keys(new KeyShare(settings.PublicKeys));
Hash hashalgo;
foreach(const Id &server, settings.ServerIds) {
QString serv = server.ToString();
if(!keys->Contains(serv)) {
qFatal("Missing key for %s", serv.toLatin1().data());
}
Q_ASSERT(Id(hashalgo.ComputeHash(keys->GetKey(serv)->GetByteArray())) == server);
}
QList<Address> local_end_points = settings.LocalEndPoints;
for(int idx = 0; idx < settings.LocalNodeCount; idx++) {
Id local_id = idx < settings.LocalId.count() ? settings.LocalId[idx] : Id();
QSharedPointer<AsymmetricKey> key;
QString key_path = settings.PrivateKeys + "/" + local_id.ToString();
QFile key_file(key_path);
if(key_file.exists()) {
key = QSharedPointer<AsymmetricKey>(new DsaPrivateKey(key_path));
} else {
QByteArray id = local_id.GetByteArray();
key = QSharedPointer<AsymmetricKey>(new DsaPrivateKey(id, true));
}
QSharedPointer<ISink> nsink = (idx == 0) ? app_sink.dynamicCast<ISink>() : default_sink;
QSharedPointer<Overlay> overlay(new Overlay(local_id, local_end_points,
settings.RemoteEndPoints, settings.ServerIds));
overlay->SetSharedPointer(overlay);
CreateRound create_round = RoundFactory::GetCreateRound(settings.RoundType);
QSharedPointer<Session> session;
if(settings.ServerIds.contains(local_id)) {
session = MakeSession<ServerSession>(overlay, key, keys, create_round);
} else {
session = MakeSession<ClientSession>(overlay, key, keys, create_round);
}
session->SetSink(nsink.data());
QSharedPointer<Node> node(new Node(key, keys, overlay, nsink, session));
nodes.append(node);
for(int idx = 0; idx < local_end_points.count(); idx++) {
local_end_points[idx] = AddressFactory::GetInstance().
CreateAny(local_end_points[idx].GetType());
}
}
QScopedPointer<WebServer> ws;
// QScopedPointer<SessionEntryTunnel> tun_entry;
// QScopedPointer<SessionExitTunnel> tun_exit;
if(settings.Console) {
commandline = QSharedPointer<CommandLine>(new CommandLine(nodes));
QObject::connect(&qca, SIGNAL(aboutToQuit()), commandline.data(), SLOT(Stop()));
commandline->Start();
app_sink->AddSink(commandline.data());
}
if(settings.WebServer) {
ws.reset(new WebServer(settings.WebServerUrl));
/* Stop Web server when application is about to quit */
QObject::connect(&qca, SIGNAL(aboutToQuit()), ws.data(), SLOT(Stop()));
/* When the web server stops, quit the application */
QObject::connect(ws.data(), SIGNAL(Stopped()), &qca, SLOT(quit()));
QSharedPointer<GetMessagesService> get_messages(new GetMessagesService());
QObject::connect(signal_sink.data(), SIGNAL(IncomingData(const QByteArray&)),
get_messages.data(), SLOT(HandleIncomingMessage(const QByteArray&)));
ws->AddRoute(QHttpRequest::HTTP_GET, "/session/messages", get_messages);
QSharedPointer<GetFileService> get_webpage(new GetFileService("index.html"));
//.........这里部分代码省略.........