예제 #1
0
void UserProfileHandler::cleanupUserProfileDirectories() {

	StringList userProfiles = getUserProfileNames();
	StringList::iterator it;
	for (it = userProfiles.begin(); it != userProfiles.end(); it++) {

		if (String(*it).endsWith(".new") || String(*it).endsWith(".old")) {
			Config & config = ConfigManager::getInstance().getCurrentConfig();
			File profileDirectory(File::convertPathSeparators(config.getConfigDir() + "profiles/") + (*it));
			profileDirectory.remove();
		}
	}
}
예제 #2
0
파일: main.cpp 프로젝트: vogel/kadu
int main(int argc, char *argv[]) try
{
    WSAHandler wsaHandler;

    QApplication application{argc, argv};
    application.setApplicationName("Kadu");
    application.setQuitOnLastWindowClosed(false);

    auto executionArgumentsParser = ExecutionArgumentsParser{};
    // do not parse program name
    auto executionArguments = executionArgumentsParser.parse(QCoreApplication::arguments().mid(1));

    if (executionArguments.queryVersion())
    {
        printVersion();
        return 0;
    }

    if (executionArguments.queryUsage())
    {
        printUsage();
        return 0;
    }

    if (!executionArguments.debugMask().isEmpty())
    {
        bool ok;
        executionArguments.debugMask().toInt(&ok);
        if (ok)
            qputenv("DEBUG_MASK", executionArguments.debugMask().toUtf8());
        else
            fprintf(stderr, "Ignoring invalid debug mask '%s'\n", executionArguments.debugMask().toUtf8().constData());
    }

    qRegisterMetaType<Message>();

    auto profileDirectory = executionArguments.profileDirectory().isEmpty()
                            ? QString::fromUtf8(qgetenv("CONFIG_DIR"))
                            : executionArguments.profileDirectory();

    auto modules = std::vector<std::unique_ptr<injeqt::module>> {};
    modules.emplace_back(std::make_unique<AccountModule>());
    modules.emplace_back(std::make_unique<ActionsModule>());
    modules.emplace_back(std::make_unique<AvatarModule>());
    modules.emplace_back(std::make_unique<BuddyModule>());
    modules.emplace_back(std::make_unique<ChatModule>());
    modules.emplace_back(std::make_unique<ChatStyleModule>());
    modules.emplace_back(std::make_unique<ChatWidgetModule>());
    modules.emplace_back(std::make_unique<ChatWindowModule>());
    modules.emplace_back(std::make_unique<CoreModule>(std::move(profileDirectory)));
    modules.emplace_back(std::make_unique<ConfigurationModule>());
    modules.emplace_back(std::make_unique<ContactModule>());
    modules.emplace_back(std::make_unique<DomModule>());
    modules.emplace_back(std::make_unique<FileTransferModule>());
    modules.emplace_back(std::make_unique<FormattedStringModule>());
    modules.emplace_back(std::make_unique<GuiModule>());
    modules.emplace_back(std::make_unique<IconsModule>());
    modules.emplace_back(std::make_unique<IdentityModule>());
    modules.emplace_back(std::make_unique<MessageModule>());
    modules.emplace_back(std::make_unique<MultilogonModule>());
    modules.emplace_back(std::make_unique<NetworkModule>());
    modules.emplace_back(std::make_unique<NotificationModule>());
    modules.emplace_back(std::make_unique<OsModule>());
    modules.emplace_back(std::make_unique<ParserModule>());
    modules.emplace_back(std::make_unique<PluginModule>());
    modules.emplace_back(std::make_unique<RosterModule>());
    modules.emplace_back(std::make_unique<SslModule>());
    modules.emplace_back(std::make_unique<StatusModule>());
    modules.emplace_back(std::make_unique<TalkableModule>());
    modules.emplace_back(std::make_unique<ThemesModule>());

    auto injector = injeqt::injector{std::move(modules)};

    try
    {
        injector.instantiate<Application>(); // force creation of Application object

#ifndef Q_OS_WIN
        // Qt version is better on win32
        qInstallMsgHandler(kaduQtMessageHandler);
#endif

#ifdef DEBUG_OUTPUT_ENABLED
        showTimesInDebug = (0 != qgetenv("SHOW_TIMES").toInt());
#endif

        Core core{std::move(injector)};
        return core.executeSingle(executionArguments);
    }
    catch (ConfigurationUnusableException &)
    {
        auto profilePath = injector.get<ConfigurationPathProvider>()->configurationDirectoryPath();
        auto errorMessage = QCoreApplication::translate("@default", "We're sorry, but Kadu cannot be loaded. "
                            "Profile is inaccessible. Please check permissions in the '%1' directory.")
                            .arg(profilePath.left(profilePath.length() - 1));
        QMessageBox::critical(0, QCoreApplication::translate("@default", "Profile Inaccessible"), errorMessage, QMessageBox::Abort);

        throw;
    }
}
#if defined(Q_OS_WIN)
catch (WSAException &)
{
    return 2;
}
#endif
catch (ConfigurationUnusableException &)
{
    // already handled
}
catch (...)
{
    throw;
}