OSDN Git Service

Initial commit
[wordring-tm/wordring-tm.git] / proxy / main.cpp
1 #include "mainwindow.h"
2
3 #include "tmsocket.h"
4 #include "httpserver.h"
5 #include "tmhttp.h"
6 #include "tmservice.h"
7
8
9 #include <QApplication>
10
11 #include <QDesktopServices>
12 #include <QSettings>
13
14 #include <QLinkedList>
15 #include <QFont>
16
17 #include "debug.h"
18
19 int main(int argc, char *argv[])
20 {
21         SetDebugMemoryLeaks();
22         QApplication a(argc, argv);
23
24         a.setOrganizationName("Wordring");
25         a.setApplicationName("TM");
26
27         QString path = QStandardPaths::writableLocation(
28                                         QStandardPaths::ConfigLocation) + "/settings.ini";
29         QSettings settings(path, QSettings::IniFormat);
30         QString apppath = QCoreApplication::applicationDirPath();
31         settings.setValue("language/japanese/mecabdic", "C:/Users/Kouichi/Documents/mecab ipadic");
32
33
34         TM::Service *service = new TM::Service(&settings, &a);
35         MainWindow w(service, &settings);
36         w.setFont(QFont("Meiryo", 10.5));
37         service->load_languages(QApplication::applicationDirPath() + "/plugins");
38
39         HttpServer *server = new HttpServer(&w);
40         if(!server->listen({ 80, 8080, 3128, 0 }, QHostAddress::LocalHost))
41                                 qFatal("Could not open http server.");
42         TM::SocketServer *socket = new TM::SocketServer(w.widget(), 0, &w);
43
44         server->install(new TM::ProxyModule(
45                                                 "/tm?", server->port(), socket->port(), server));
46
47         w.show();
48         int result = a.exec();
49
50         return result;
51 }