Пример #1
0
int main(int argc, char *argv[])
{
    _argc = argc;
    _argv = argv;

    QApplication::setColorSpec( QApplication::ManyColor );
#if USE_KDE
    KAboutData aboutData(PACKAGE,
                         I18N_NOOP(PACKAGE),
                         VERSION,
                         I18N_NOOP("ICQ client"),
                         KAboutData::License_GPL,
                         "Copyright (C) 2002, Vladimir Shutoff",
                         0,
                         "http://sim.shutoff.spb.ru/",
                         "*****@*****.**");

    aboutData.addAuthor("Vladimir Shutoff",I18N_NOOP("Maintainer"),"*****@*****.**");

    KCmdLineArgs::init( argc, argv, &aboutData );
    KCmdLineOptions options[] =
        {
            { "b <dir>", i18n("Directory for files"), 0 },
            { "d <loglevel>", i18n("Loglevel"), 0 },
            { 0, 0, 0 }
        };
    KCmdLineArgs::addCmdLineOptions( options );
    KUniqueApplication::addCmdLineOptions();

    if (!KUniqueApplication::start())
        exit(-1);
    SimApp app;
    kApp = &app;
#else
    SimApp app(argc, argv);
#endif
    initIcons("");
    pMain = new MainWindow;
#if USE_KDE
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    if (args->isSet("b"))
        pMain->homeDir = strdup(args->getOption("b"));
    if (args->isSet("d"))
        log_level = atoi(args->getOption("d"));

#else
    for (int i = 0; i < argc; i++){
        if (!strcmp(argv[i], "-b") && argv[i+1])
            pMain->homeDir = argv[++i];
        if (!strcmp(argv[i], "-d") && argv[i+1])
            log_level = atoi(argv[++i]);
    }
#endif
    if (!pMain->init())
        return 0;
    app.setMainWidget(pMain);

    return app.exec();
}
Пример #2
0
int main(int argc, char *argv[])
{
    int res = 1;
#ifdef WIN32
    HANDLE hMutex = CreateMutexA(NULL, FALSE, "SIM_Mutex");
#endif
    QApplication::setColorSpec( QApplication::ManyColor );
#ifndef WIN32
    qInstallMsgHandler(simMessageOutput);
#endif
    KAboutData aboutData(PACKAGE,
                         I18N_NOOP("SIM"),
                         _VERSION,
                         I18N_NOOP("ICQ client"),
                         KAboutData::License_GPL,
                         "Copyright (C) 2002-2003, Vladimir Shutoff",
                         0,
                         "http://sim-icq.sourceforge.net/",
                         "*****@*****.**");
    aboutData.addAuthor("Vladimir Shutoff",I18N_NOOP("Maintainer"),"*****@*****.**");
    aboutData.addAuthor("Christian Ehrlicher",I18N_NOOP("Developer"),"*****@*****.**");
    setAboutData(&aboutData);
#ifndef WIN32
    int _argc = 0;
    char **_argv = new char*[argc + 1];
    _argv[_argc++] = argv[0];
    char **to = argv + 1;
    // check all parameters and sort them
    // _argc/v: parameter for KUnqiueApplication
    //  argc/v: plugin parameter
    for (char **p = argv + 1; *p; ++p){
        char *arg = *p;
        // check if "-" or "--"
        if (arg[0] != '-') {
            // wrong parameter :(
            argc--;
            continue;
        }
		arg++;
		if (arg[0] == '-')
			arg++;
        // if they are parameters with variable params we need
        // to skip the next param
        bool bSkip = false;
        const char **q;
        // check for qt or kde - parameters
        for (q = qt_args; *q; ++q){
            unsigned len = strlen(*q);
            bSkip = false;
            // variable parameter?
            if ((*q)[len-1] == ':'){
                len--;
                bSkip = true;
            }
            // copy them for KUnqiueApplication-args
            if ((strlen(arg) == len) && !memcmp(arg, *q, len))
                break;
        }
        // dunno know what to do here
        if (*q){
            _argv[_argc++] = *p;
            argc--;
            if (bSkip){
                ++p;
                if (*p == NULL) break;
                _argv[_argc++] = *p;
                argc--;
            }
        }else{
            *(to++) = *p;
        }
    }
    *to = NULL;
    _argv[_argc] = NULL;
#ifdef USE_KDE
    KCmdLineArgs::init( _argc, _argv, &aboutData );
    KCmdLineOptions options[] =
        {
            { 0, 0, 0 }
        };
    KCmdLineArgs::addCmdLineOptions( options );
    KUniqueApplication::addCmdLineOptions();
    if (!KUniqueApplication::start())
        exit(-1);
    SimApp app;
#else
    SimApp app(_argc, _argv);
#endif
    old_errhandler = XSetErrorHandler(x_errhandler);
#else
    SimApp app(argc, argv);
    QStyle* (WINAPI *createXpStyle)() = NULL;
    HINSTANCE hLib = LoadLibraryA("UxTheme.dll");
    if (hLib != NULL)
        hLib = LoadLibraryA(app_file("plugins\\styles\\xpstyle.dll").c_str());
    if (hLib != NULL)
        (DWORD&)createXpStyle = (DWORD)GetProcAddress(hLib,"_createXpStyle@0");
    if (createXpStyle){
        QStyle *xpStyle = createXpStyle();
        qApp->setStyle(xpStyle);
    }
#endif
    PluginManager p(argc, argv);
    if (p.isLoaded())
        res = app.exec();
#ifdef WIN32
    CloseHandle(hMutex);
#endif
    return res;
};
Пример #3
0
int main(int argc, char *argv[])
{
    int res = 1;
#ifdef WIN32
    HANDLE hMutex = CreateMutexA(NULL, FALSE, "SIM_Mutex");
#endif
    QApplication::setColorSpec( QApplication::ManyColor );
    qInstallMsgHandler(simMessageOutput);
    KAboutData aboutData(PACKAGE,
                         I18N_NOOP("SIM"),
                         _VERSION,
                         I18N_NOOP("Multiprotocol Instant Messenger"),
                         KAboutData::License_GPL,
                         "Copyright (C) 2002-2004, Vladimir Shutoff\n"
                         "2005-2006, SIM-IM Development Team",
                         0,
                         "http://sim-im.org/",
                         "https://mailman.dg.net.ua/listinfo/sim-im-main");
    aboutData.addAuthor("SIM-IM Development Team",I18N_NOOP("Current development"),0,"http://sim-im.org/");
    aboutData.addAuthor("Vladimir Shutoff",I18N_NOOP("Author"),"*****@*****.**");
    aboutData.addAuthor("Christian Ehrlicher",I18N_NOOP("Developer"),"*****@*****.**");
    setAboutData(&aboutData);
#ifndef WIN32
    int _argc = 0;
    char **_argv = new char*[argc + 1];
    _argv[_argc++] = argv[0];
    char **to = argv + 1;
    // check all parameters and sort them
    // _argc/v: parameter for KUnqiueApplication
    //  argc/v: plugin parameter
    for (char **p = argv + 1; *p; ++p){
        char *arg = *p;
        // check if "-" or "--"
        if (arg[0] != '-') {
            *(to++) = *p;
            continue;
        }
        arg++;
        if (arg[0] == '-')
            arg++;
        // if they are parameters with variable params we need
        // to skip the next param
        bool bSkip = false;
        const char **q;
        // check for qt or kde - parameters
        for (q = qt_args; *q; ++q){
            unsigned len = strlen(*q);
            bSkip = false;
            // variable parameter?
            if ((*q)[len-1] == ':'){
                len--;
                bSkip = true;
            }
            // copy them for KUnqiueApplication-args
            if ((strlen(arg) == len) && !memcmp(arg, *q, len))
                break;
        }
        // dunno know what to do here
        if (*q){
            _argv[_argc++] = *p;
            argc--;
            if (bSkip){
                ++p;
                if (*p == NULL) break;
                _argv[_argc++] = *p;
                argc--;
            }
        }else{
            *(to++) = *p;
        }
    }
    *to = NULL;
    _argv[_argc] = NULL;
#ifdef USE_KDE
    KCmdLineArgs::init( _argc, _argv, &aboutData );
    KCmdLineOptions options[] =
        {
            { 0, 0, 0 }
        };
    KCmdLineArgs::addCmdLineOptions( options );
    KUniqueApplication::addCmdLineOptions();
    if (!KUniqueApplication::start())
        exit(-1);
    SimApp app;
#else
    SimApp app(_argc, _argv);
#endif
#if !defined(QT_MACOSX_VERSION) && !defined(QT_MAC)
    old_errhandler = XSetErrorHandler(x_errhandler);
#endif
#else
    for (int i = 0; i < argc; i++){
        string arg = argv[i];
        if ((arg[0] == '/') || (arg[0] == '-'))
            arg = arg.substr(1);
        if ((arg == "reinstall") || (arg == "showicons") || (arg == "hideicons"))
            return 0;
    }
    SimApp app(argc, argv);
    StyleInfo*  (*getStyleInfo)() = NULL;
    HINSTANCE hLib = LoadLibraryA("UxTheme.dll");
    if (hLib != NULL)
        hLib = LoadLibraryA(app_file("plugins\\styles\\xpstyle.dll").c_str());
    if (hLib != NULL)
        (DWORD&)getStyleInfo = (DWORD)GetProcAddress(hLib,"GetStyleInfo");
    if (getStyleInfo){
        StyleInfo *info = getStyleInfo();
        if (info)
            qApp->setStyle(info->create());
    }
#endif
    PluginManager p(argc, argv);
	if (p.isLoaded())
        res = app.exec();
#ifdef WIN32
    CloseHandle(hMutex);
#endif
	return 0;
}