Ejemplo n.º 1
0
int main(int argc, char *argv[])
{
    AsemanApplication app(argc, argv);
    app.setApplicationName("Papyrus");
    app.setApplicationDisplayName("Papyrus");
    app.setOrganizationDomain("land.aseman");
    app.setOrganizationName("Aseman");
    app.setWindowIcon(QIcon(":/qml/Papyrus/files/papyrus.png"));

    // Kaqaz compability
    const QString &homePath = AsemanApplication::homePath();
    if(!QFileInfo::exists(homePath) && QFileInfo::exists(SIALAN_KAQAZ_HOME_PATH))
        AsemanTools::copyDirectory(SIALAN_KAQAZ_HOME_PATH, homePath);
#ifdef Q_OS_ANDROID
    else if(!QFileInfo::exists(homePath) && QFileInfo::exists(QString(SIALAN_KAQAZ_HOME_PATH).replace("sialan.kaqaz","sialan.kaqaz.free")) )
        AsemanTools::copyDirectory(QString(SIALAN_KAQAZ_HOME_PATH).replace("sialan.kaqaz","sialan.kaqaz.free"), homePath);
#endif
    const QString &backupPath = AsemanApplication::backupsPath();
    if(!QFileInfo::exists(backupPath) && QFileInfo::exists(SIALAN_KAQAZ_BACKUP_PATH))
        AsemanTools::copyDirectory(SIALAN_KAQAZ_BACKUP_PATH, backupPath);

#ifdef DESKTOP_DEVICE
    if( app.isRunning() )
    {
        app.sendMessage("show");
        return 0;
    }
#endif

    Papyrus *papyrus = Papyrus::instance();

#ifdef DESKTOP_DEVICE
#ifdef Q_OS_MAC
    if( !papyrus->settings()->value("General/uiselected",false).toBool() )
    {
        UiSelectorDialog dialog;
        dialog.exec();

        if( !dialog.isAccepted() )
            return 0;
        if( dialog.isDesktopTouch() )
            papyrus->setDesktopTouchMode(true);
        else
            papyrus->setDesktopTouchMode(false);

        papyrus->settings()->setValue("General/uiselected",true);
    }
#else
    if( app.arguments().contains("--touch") )
        papyrus->setDesktopTouchMode(true);
#endif
#endif

    if( !papyrus->start() )
        return 0;

#ifdef DESKTOP_DEVICE
    QObject::connect( &app, SIGNAL(messageReceived(QString)), papyrus, SLOT(incomingAppMessage(QString)) );
#endif

    return app.exec();
}
Ejemplo n.º 2
0
int main(int argc, char *argv[])
{
    AsemanApplication app(argc, argv);
    app.setApplicationName("Cutegram");
    app.setApplicationDisplayName("Cutegram");
    app.setApplicationVersion("2.4.0");
    app.setOrganizationDomain("land.aseman");
    app.setOrganizationName("Aseman");
    app.setWindowIcon(QIcon(":/qml/Cutegram/files/icon.png"));
    app.setQuitOnLastWindowClosed(false);

    QCommandLineOption verboseOption(QStringList() << "V" << "verbose",
            QCoreApplication::translate("main", "Verbose Mode."));
    QCommandLineOption forceOption(QStringList() << "f" << "force",
            QCoreApplication::translate("main", "Force to run multiple instance of Cutegram."));
    QCommandLineOption dcIdOption(QStringList() << "dc-id",
            QCoreApplication::translate("main", "Sets default DC ID to <id>"), "id");
    QCommandLineOption ipAdrsOption(QStringList() << "ip-address",
            QCoreApplication::translate("main", "Sets default IP Address to <ip>"), "ip");

    QCommandLineParser parser;
    parser.setApplicationDescription(ABOUT_TEXT);
    parser.addHelpOption();
    parser.addVersionOption();
    parser.addOption(forceOption);
    parser.addOption(verboseOption);
    parser.addOption(dcIdOption);
    parser.addOption(ipAdrsOption);
    parser.process(app);

    if(!parser.isSet(verboseOption))
        qputenv("QT_LOGGING_RULES", "tg.*=false");
    else
        qputenv("QT_LOGGING_RULES", "tg.core.settings=false\n"
                                    "tg.core.outboundpkt=false\n"
                                    "tg.core.inboundpkt=false");

    Telegram::setDefaultHostAddress( parser.isSet(ipAdrsOption)? parser.value(ipAdrsOption) : "149.154.167.50");
    Telegram::setDefaultHostPort(443);
    Telegram::setDefaultHostDcId(parser.isSet(dcIdOption)? parser.value(dcIdOption).toInt() : 2);
    Telegram::setAppId(13682);
    Telegram::setAppHash("de37bcf00f4688de900510f4f87384bb");

    if(app.readSetting("Proxy/enable",false).toBool())
    {
        const int type = app.readSetting("Proxy/type",QNetworkProxy::HttpProxy).toInt();
        const QString host = app.readSetting("Proxy/host").toString();
        const quint16 port = app.readSetting("Proxy/port").toInt();
        const QString user = app.readSetting("Proxy/user").toString();
        const QString pass = app.readSetting("Proxy/pass").toString();

        QNetworkProxy proxy;
        proxy.setType( static_cast<QNetworkProxy::ProxyType>(type) );
        proxy.setHostName(host);
        proxy.setPort(port);
        proxy.setUser(user);
        proxy.setPassword(pass);
        QNetworkProxy::setApplicationProxy(proxy);
    }

#ifdef Q_OS_MAC
    QPalette palette;
    palette.setColor(QPalette::Highlight, "#0d80ec");
    palette.setColor(QPalette::HighlightedText, "#ffffff");
    app.setPalette(palette);
#endif

#ifdef DESKTOP_DEVICE
    if( !parser.isSet(forceOption) && app.isRunning() )
    {
        app.sendMessage("show");
        return 0;
    }
#endif

    CompabilityTools::version1();

    Cutegram cutegram;
    cutegram.start( parser.isSet(forceOption) );

#ifdef DESKTOP_DEVICE
    QObject::connect( &app, SIGNAL(messageReceived(QString)), &cutegram, SLOT(incomingAppMessage(QString)) );
    QObject::connect( &app, SIGNAL(clickedOnDock())         , &cutegram, SLOT(incomingAppMessage())        );
#endif

    return app.exec();
}