OSDN Git Service

未完成状態、コンパイルも通らない状態でコミット…
[gikomona/pnuts.git] / src / pnuts.cpp
1
2 #include "pnuts.hpp"
3
4 namespace GikoMona {
5 namespace pnuts {
6
7 bool application::OnInit() {
8     wxXmlResource::Get()->InitAllHandlers();
9     // init embedded resources.
10     InitXmlResources();
11     // init changeable resources.
12     wxXmlResource::Get()->LoadAllFiles("resource");
13     
14     config = new config;
15 #ifdef ENABLE_TWITTER
16     auto res = config.post_query<bool>("?:twitter/service=enable");
17     if(res) {
18         auto id_password
19             = config.post_query<mona_string, mona_string>(
20                 ">:twitter/user/{id & password}"
21             );
22         twitter::login(id_password<0>, id_password<1>);
23     }
24 #endif
25     
26     controller = new controller;
27     model = new model;
28     main_window = new main_window;
29     model.main_window = main_window;
30     main_window->PushEventHandler(controller);
31     
32     auto is_first_executation
33         = config.post_query<bool>(
34             "?:app/last-executation-time=inavailable"
35         );
36     
37     if(is_first_executation) {
38         show_welcome();
39         main_window->Show();
40         return true;
41     } else {
42         thread_window = new threaad_window;
43         model.thread_window = thread_window;
44         thread_window->PushEventHandler(controller);
45         
46         thread_window->Show();
47         return true;
48     }
49 }
50
51 int application::OnExit() {
52     config.post_query<void>(
53         "<:app/last-executation-time", "$:NOW"
54     );
55     return 0;
56 }
57
58 }
59 }