1 #include "mainwindow.h"
2 #include "tmeditorwidget.h"
5 #include "httpserver.h"
8 #include "tmdatabase.h"
12 #include <QApplication>
13 #include <QStandardPaths>
15 #include <QDesktopServices>
18 #include <QLinkedList>
24 int main(int argc, char *argv[])
26 SetDebugMemoryLeaks();
27 QApplication a(argc, argv);
29 a.setOrganizationName("wordring");
30 a.setApplicationName("tm");
32 QString path = QStandardPaths::writableLocation(
33 QStandardPaths::ConfigLocation) + "/settings.ini";
34 Settings settings(path, QSettings::IniFormat);
35 QString app_path = QCoreApplication::applicationDirPath();
40 "Japanese/mecabdic", QString(PROXYSRCDIR) + "/../third-party/lib/ipadic");
42 if(!settings.contains("Japanese/mecabdic"))
44 QString mecabdic = app_path + "/ipadic";
46 mecabdic = dir.absolutePath();
47 settings.setValue("Japanese/mecabdic", mecabdic);
51 if(!settings.contains("HttpServer/port")) settings.setValue("HttpServer/port", 8080);
53 if(!settings.contains("SocketServer/port")) settings.setValue("SocketServer/port", 8081);
55 if(!settings.contains("ProxyModule/prefix")) settings.setValue("ProxyModule/prefix", "/?");
58 settings.setValue("ProxyHandler/jscode", QString(PROXYSRCDIR) + "/tm.js");
60 if(!settings.contains("ProxyHandler/jscode"))
61 settings.setValue("ProxyHandler/jscode", app_path + "/tm.js");
65 settings.setValue("DefaultHtmlModule/file", QString(PROXYSRCDIR) + "/index.html");
67 if(!settings.contains("DefaultHtmlModule/file"))
68 settings.setValue("DefaultHtmlModule/file", app_path + "/index.html");
71 if(!settings.contains("Database/root"))
73 QString path = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
74 settings.setValue("Database/root", path);
77 settings.setValue("WordringConnection/url", "ws://localhost:82/ws/tm");
79 // if(!settings.contains("WordringConnection/url"))
80 // settings.setValue("WordringConnection/url", "ws://tm.wordring.net:80/");
82 TM::Service *service = new TM::Service(&settings, &a);
83 MainWindow w(&settings, service);
84 w.setFont(QFont("Meiryo", 10.5));
85 service->load_languages(QApplication::applicationDirPath() + "/plugins");
87 HttpServer *server = new HttpServer(&settings, &w);
88 w.set_http_port(server->port());
90 TM::SocketServer *socket = new TM::SocketServer(&settings, service, w.editor_widget(), &w);
92 server->install(new TM::DefaultHtmlModule(&settings, server->port(), server));
93 server->install(new TM::ProxyModule(
94 &settings, server->port(), socket->port(), server));
96 QObject::connect(&w, SIGNAL(closing()), socket, SLOT(abort()));
98 int result = a.exec();