├── .gitignore
├── src
├── main.cpp
├── win_wao.cpp
├── win_wao.hpp
├── win_login.cpp
├── win_login.hpp
├── win_views.cpp
├── win_views.hpp
├── win_app_window.cpp
├── win_app_window.hpp
├── win_dialog_tags.cpp
├── win_dialog_tags.hpp
├── win_dialog_password.cpp
├── win_dialog_password.hpp
├── win_widget_tag_list.cpp
├── win_widget_tag_list.hpp
├── settings.hpp
├── strings.hpp
├── entry.hpp
├── settings.cpp
├── lifeograph.hpp
├── entry_parser.hpp
├── entry.cpp
├── win_richedit.hpp
├── lifeograph.cpp
├── diary.hpp
├── entry_parser.cpp
└── helpers.hpp
├── icons
├── tag-16.ico
├── tag-16.png
├── elem-16.bmp
├── entry-16.ico
├── entry-16.png
├── filter-16.ico
├── tag_theme-16.png
├── todo_done-16.ico
├── todo_done-16.png
├── todo_open-16.ico
├── todo_open-16.png
├── todo_canceled-16.ico
├── todo_canceled-16.png
├── lifeograph-16..64.ico
├── todo_progressed-16.ico
└── todo_progressed-16.png
├── rc
├── lifeograph.rc
└── resource.h
├── LifeographWine.ico
├── mingw
├── lib
│ ├── libgcrypt.dll.a
│ └── libgpg-error.dll.a
└── include
│ └── gpg-error.h
├── config
└── config.h
├── LifeographWine_private.rc
├── LifeographWine_private.h
├── NEWS
├── README
├── LifeographWine.layout
├── Makefile.win
└── LifeographWine.dev
/.gitignore:
--------------------------------------------------------------------------------
1 | bin
2 | o
3 |
--------------------------------------------------------------------------------
/src/main.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/src/main.cpp
--------------------------------------------------------------------------------
/icons/tag-16.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/icons/tag-16.ico
--------------------------------------------------------------------------------
/icons/tag-16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/icons/tag-16.png
--------------------------------------------------------------------------------
/rc/lifeograph.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/rc/lifeograph.rc
--------------------------------------------------------------------------------
/src/win_wao.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/src/win_wao.cpp
--------------------------------------------------------------------------------
/src/win_wao.hpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/src/win_wao.hpp
--------------------------------------------------------------------------------
/LifeographWine.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/LifeographWine.ico
--------------------------------------------------------------------------------
/icons/elem-16.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/icons/elem-16.bmp
--------------------------------------------------------------------------------
/icons/entry-16.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/icons/entry-16.ico
--------------------------------------------------------------------------------
/icons/entry-16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/icons/entry-16.png
--------------------------------------------------------------------------------
/icons/filter-16.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/icons/filter-16.ico
--------------------------------------------------------------------------------
/src/win_login.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/src/win_login.cpp
--------------------------------------------------------------------------------
/src/win_login.hpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/src/win_login.hpp
--------------------------------------------------------------------------------
/src/win_views.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/src/win_views.cpp
--------------------------------------------------------------------------------
/src/win_views.hpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/src/win_views.hpp
--------------------------------------------------------------------------------
/icons/tag_theme-16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/icons/tag_theme-16.png
--------------------------------------------------------------------------------
/icons/todo_done-16.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/icons/todo_done-16.ico
--------------------------------------------------------------------------------
/icons/todo_done-16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/icons/todo_done-16.png
--------------------------------------------------------------------------------
/icons/todo_open-16.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/icons/todo_open-16.ico
--------------------------------------------------------------------------------
/icons/todo_open-16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/icons/todo_open-16.png
--------------------------------------------------------------------------------
/src/win_app_window.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/src/win_app_window.cpp
--------------------------------------------------------------------------------
/src/win_app_window.hpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/src/win_app_window.hpp
--------------------------------------------------------------------------------
/src/win_dialog_tags.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/src/win_dialog_tags.cpp
--------------------------------------------------------------------------------
/src/win_dialog_tags.hpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/src/win_dialog_tags.hpp
--------------------------------------------------------------------------------
/icons/todo_canceled-16.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/icons/todo_canceled-16.ico
--------------------------------------------------------------------------------
/icons/todo_canceled-16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/icons/todo_canceled-16.png
--------------------------------------------------------------------------------
/mingw/lib/libgcrypt.dll.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/mingw/lib/libgcrypt.dll.a
--------------------------------------------------------------------------------
/icons/lifeograph-16..64.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/icons/lifeograph-16..64.ico
--------------------------------------------------------------------------------
/icons/todo_progressed-16.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/icons/todo_progressed-16.ico
--------------------------------------------------------------------------------
/icons/todo_progressed-16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/icons/todo_progressed-16.png
--------------------------------------------------------------------------------
/mingw/lib/libgpg-error.dll.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/mingw/lib/libgpg-error.dll.a
--------------------------------------------------------------------------------
/src/win_dialog_password.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/src/win_dialog_password.cpp
--------------------------------------------------------------------------------
/src/win_dialog_password.hpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/src/win_dialog_password.hpp
--------------------------------------------------------------------------------
/src/win_widget_tag_list.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/src/win_widget_tag_list.cpp
--------------------------------------------------------------------------------
/src/win_widget_tag_list.hpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/blhps/lifeograph-windows/HEAD/src/win_widget_tag_list.hpp
--------------------------------------------------------------------------------
/config/config.h:
--------------------------------------------------------------------------------
1 | #ifndef LIFEO_CONFIG_HEADER
2 | #define LIFEO_CONFIG_HEADER
3 |
4 |
5 |
6 |
7 | #endif
8 |
9 |
--------------------------------------------------------------------------------
/LifeographWine_private.rc:
--------------------------------------------------------------------------------
1 | /* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */
2 | /* DO NOT EDIT! */
3 |
4 | #include "rc/lifeograph.rc"
5 |
6 | A ICON "LifeographWine.ico"
7 |
--------------------------------------------------------------------------------
/LifeographWine_private.h:
--------------------------------------------------------------------------------
1 | /* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */
2 | /* DO NOT EDIT ! */
3 |
4 | #ifndef LIFEOGRAPHWINE_PRIVATE_H
5 | #define LIFEOGRAPHWINE_PRIVATE_H
6 |
7 | /* VERSION DEFINITIONS */
8 | #define VER_STRING "1.0.0.0"
9 | #define VER_MAJOR 1
10 | #define VER_MINOR 0
11 | #define VER_RELEASE 0
12 | #define VER_BUILD 0
13 | #define COMPANY_NAME ""
14 | #define FILE_VERSION "1.0.0.0"
15 | #define FILE_DESCRIPTION "Developed using the Dev-C++ IDE"
16 | #define INTERNAL_NAME ""
17 | #define LEGAL_COPYRIGHT ""
18 | #define LEGAL_TRADEMARKS ""
19 | #define ORIGINAL_FILENAME ""
20 | #define PRODUCT_NAME ""
21 | #define PRODUCT_VERSION "1.0.0.0"
22 |
23 | #endif /*LIFEOGRAPHWINE_PRIVATE_H*/
24 |
--------------------------------------------------------------------------------
/NEWS:
--------------------------------------------------------------------------------
1 | LIFEOGRAPH FOR WINDOWS RELEASE HISTORY
2 | ======================================
3 |
4 | 0.4.1 - 2016-11-01
5 |
6 | * Bug fixes
7 |
8 |
9 |
10 | 0.4.0 - 2016-09-03
11 |
12 | * Added preliminary support for parametric tags
13 | * Implemented renaming tags
14 | * Implemented dismissing tags
15 | * Added a basic read-only mode
16 |
17 |
18 |
19 | 0.3.0 - 2016-01-17
20 |
21 | * Added support for diary format 1030
22 | * Added support for todo lists in entries
23 | * Added support for numeric and bullet lists in entries
24 |
25 |
26 |
27 | 0.2.0 - 2015-02-16
28 |
29 | * Converted the entry list into a tree view
30 | * Added support for chapters
31 | * Implemented searching text within entries
32 | * Added filtering by status, being favorite, and tag
33 | * Implemented editing entry date/number
34 | * Implemented marking entries as favorite
35 | * Implemented setting entry completion status
36 | * Added a tag list to the tag dialog
37 |
38 |
39 |
40 | 0.1.1 - 2014-12-16
41 |
42 | * Fixed crash when dismissing entries
43 | * Added 32x32 and 64x64 versions of the main icon
44 |
45 |
46 |
47 | 0.1.0 - 2014-12-13
48 |
49 | * Initial release
50 |
51 |
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 | STARTING WITH v1.5 LIFEOGRAPH IS USING THE GTK+ INTERFACE ON WINDOWS, TOO. THIS BRANCH WILL NO LONGER BE UPDATED!
2 |
3 |
4 | Description
5 | ===========
6 |
7 | Lifeograph is an off-line and private journal and note taking application.
8 | It offers a rich feature set presented in a clean and simple user interface.
9 |
10 |
11 |
12 | Comparison to Linux Version
13 | ===========================
14 |
15 | Lifeograph for Windows is currently in early development phase and lacks many
16 | features provided by the Linux version. Main missing features are:
17 |
18 | * Statistical graphs
19 | * Printing
20 | * Links of any kind in entries
21 | * Spell checking
22 | * Creating and editing themes (existing themes can be used)
23 | * Importing diaries
24 |
25 |
26 |
27 | Building from Source
28 | ====================
29 |
30 | Lifeograph for Windows is developed in Orwell Dev-C++.
31 | (http://sourceforge.net/projects/orwelldevcpp/)
32 |
33 | Users interested in building from the source code are strongly recommended
34 | to use this software.
35 |
36 | Additionally, libgcrypt and libgpg-error dlls are needed to run
37 | Lifeograph. Full names of these libraries are listed below:
38 |
39 | * libgcrypt-20.dll
40 | * libgpg-error-0.dll
41 |
42 | These dlls can be obtained from MinGW, Cygwin or Gpg4win projects.
43 |
44 |
45 |
46 | Installation & Running
47 | ======================
48 |
49 | Lifeograph for Windows is completely portable and installation is not
50 | required. Just put the following files into the same folder and run the exe.
51 |
52 | * lifeograph.exe
53 | * lifeo.conf
54 | * The two dll files in the section above (if they are not already somewhere
55 | in the PATH)
56 |
57 |
--------------------------------------------------------------------------------
/LifeographWine.layout:
--------------------------------------------------------------------------------
1 | [Editor_3]
2 | CursorCol=1
3 | CursorRow=404
4 | TopLine=373
5 | LeftChar=1
6 | [Editors]
7 | Order=19,20,9,10,23,24,16,33,22,21,2,34,27,28
8 | Focused=27
9 | [Editor_0]
10 | CursorCol=1
11 | CursorRow=19
12 | TopLine=1
13 | LeftChar=1
14 | [Editor_1]
15 | CursorCol=2
16 | CursorRow=2360
17 | TopLine=2063
18 | LeftChar=1
19 | [Editor_2]
20 | CursorCol=49
21 | CursorRow=263
22 | TopLine=241
23 | LeftChar=1
24 | [Editor_4]
25 | CursorCol=1
26 | CursorRow=600
27 | TopLine=405
28 | LeftChar=1
29 | [Editor_8]
30 | CursorCol=1
31 | CursorRow=73
32 | TopLine=91
33 | LeftChar=1
34 | [Editor_6]
35 | CursorCol=1
36 | CursorRow=47
37 | TopLine=17
38 | LeftChar=1
39 | [Editor_12]
40 | CursorCol=1
41 | CursorRow=30
42 | TopLine=1
43 | LeftChar=1
44 | [Editor_15]
45 | CursorCol=31
46 | CursorRow=7
47 | TopLine=1
48 | LeftChar=1
49 | [Editor_5]
50 | CursorCol=8
51 | CursorRow=636
52 | TopLine=619
53 | LeftChar=1
54 | [Editor_7]
55 | CursorCol=8
56 | CursorRow=73
57 | TopLine=64
58 | LeftChar=1
59 | [Editor_9]
60 | CursorCol=88
61 | CursorRow=42
62 | TopLine=21
63 | LeftChar=1
64 | [Editor_10]
65 | CursorCol=9
66 | CursorRow=181
67 | TopLine=61
68 | LeftChar=1
69 | [Editor_16]
70 | CursorCol=28
71 | CursorRow=3
72 | TopLine=55
73 | LeftChar=1
74 | [Editor_11]
75 | CursorCol=28
76 | CursorRow=65
77 | TopLine=49
78 | LeftChar=1
79 | [Editor_13]
80 | CursorCol=1
81 | CursorRow=8
82 | TopLine=1
83 | LeftChar=1
84 | [Editor_14]
85 | CursorCol=7
86 | CursorRow=142
87 | TopLine=1
88 | LeftChar=1
89 | [Editor_17]
90 | CursorCol=60
91 | CursorRow=14
92 | TopLine=10
93 | LeftChar=1
94 | [Editor_18]
95 | CursorCol=1
96 | CursorRow=23
97 | TopLine=103
98 | LeftChar=1
99 | [Editor_19]
100 | CursorCol=45
101 | CursorRow=75
102 | TopLine=32
103 | LeftChar=1
104 | [Editor_20]
105 | CursorCol=31
106 | CursorRow=474
107 | TopLine=28
108 | LeftChar=1
109 | [Editor_21]
110 | CursorCol=52
111 | CursorRow=47
112 | TopLine=44
113 | LeftChar=1
114 | [Editor_22]
115 | CursorCol=24
116 | CursorRow=216
117 | TopLine=182
118 | LeftChar=1
119 | [Editor_23]
120 | CursorCol=1
121 | CursorRow=99
122 | TopLine=31
123 | LeftChar=1
124 | [Editor_24]
125 | CursorCol=59
126 | CursorRow=209
127 | TopLine=193
128 | LeftChar=1
129 | [Editor_25]
130 | CursorCol=1
131 | CursorRow=65
132 | TopLine=51
133 | LeftChar=1
134 | [Editor_26]
135 | CursorCol=55
136 | CursorRow=130
137 | TopLine=49
138 | LeftChar=1
139 | [Editor_27]
140 | CursorCol=1
141 | CursorRow=1418
142 | TopLine=1378
143 | LeftChar=1
144 | [Editor_28]
145 | CursorCol=13
146 | CursorRow=178
147 | TopLine=155
148 | LeftChar=1
149 | [Editor_29]
150 | CursorCol=8
151 | CursorRow=252
152 | TopLine=120
153 | LeftChar=1
154 | [Editor_30]
155 | CursorCol=1
156 | CursorRow=79
157 | TopLine=12
158 | LeftChar=1
159 | [Editor_31]
160 | CursorCol=72
161 | CursorRow=55
162 | TopLine=17
163 | LeftChar=1
164 | [Editor_32]
165 | CursorCol=1
166 | CursorRow=4
167 | TopLine=28
168 | LeftChar=1
169 | [Editor_33]
170 | CursorCol=13
171 | CursorRow=350
172 | TopLine=328
173 | LeftChar=1
174 | [Editor_34]
175 | CursorCol=76
176 | CursorRow=65
177 | TopLine=40
178 | LeftChar=1
179 |
--------------------------------------------------------------------------------
/src/settings.hpp:
--------------------------------------------------------------------------------
1 | /***********************************************************************************
2 |
3 | Copyright (C) 2010 Ahmet Öztürk (aoz_2@yahoo.com)
4 |
5 | This file is part of Lifeograph.
6 |
7 | Lifeograph is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | Lifeograph is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with Lifeograph. If not, see .
19 |
20 | ***********************************************************************************/
21 |
22 |
23 | #ifndef LIFEOGRAPH_SETTINGS_HEADER
24 | #define LIFEOGRAPH_SETTINGS_HEADER
25 |
26 |
27 | #include
28 | #include
29 |
30 | #include "helpers.hpp"
31 |
32 |
33 | namespace LIFEO
34 | {
35 |
36 | using namespace HELPERS;
37 |
38 | static const int IDLETIME_MIN = 30;
39 | static const int IDLETIME_MAX = 3600;
40 | static const int IDLETIME_DEFAULT = 90;
41 | static const int WIDTH_DEFAULT = 550;
42 | static const int HEIGHT_DEFAULT = 300;
43 | static const int POSITION_NOTSET = -0xFFFF;
44 | static const int PANEPOS_DEFAULT = 300;
45 | static const int PANEPOS_TAGS_DEFAULT = 100;
46 | static const char EXTENSION_DEFAULT[] = ".diary";
47 |
48 | class Settings
49 | {
50 | public:
51 | Settings() {}
52 | // FUNCTIONS
53 | bool read();
54 | bool write();
55 |
56 | void reset();
57 |
58 | void update_date_format();
59 |
60 | // VARIABLES FOR OPTIONS
61 | ListPaths recentfiles;
62 |
63 | bool autologout{ true };
64 | int idletime{ IDLETIME_DEFAULT };
65 |
66 | bool show_formatting_toolbar{ true };
67 |
68 | int date_format_order{ 0 };
69 | int date_format_separator{ 0 };
70 |
71 | std::string diary_extension{ EXTENSION_DEFAULT };
72 |
73 | bool flag_maiden_voyage{ false }; // whether or not the first run
74 | int width{ WIDTH_DEFAULT };
75 | int height{ HEIGHT_DEFAULT };
76 | bool state_maximized{ false };
77 | int position_x{ POSITION_NOTSET };
78 | int position_y{ POSITION_NOTSET };
79 | int position_pane{ PANEPOS_DEFAULT };
80 | int position_pane_tags{ PANEPOS_TAGS_DEFAULT };
81 |
82 | std::string icon_theme;
83 | bool small_lists{ true };
84 |
85 | protected:
86 | static const std::string s_date_format_orders[ 3 ];
87 | static const std::string s_date_format_separators;
88 |
89 | std::string m_path;
90 | };
91 |
92 | } // END OF NAMESPACE LIFEO
93 |
94 | #endif
95 |
96 |
--------------------------------------------------------------------------------
/Makefile.win:
--------------------------------------------------------------------------------
1 | # Project: LifeographWine
2 | # Makefile created by Dev-C++ 5.11
3 |
4 | CPP = g++.exe -D__DEBUG__
5 | CC = gcc.exe -D__DEBUG__
6 | WINDRES = windres.exe
7 | RES = o/LifeographWine_private.res
8 | OBJ = o/main.o o/diary.o o/diarydata.o o/helpers.o o/entry.o o/lifeograph.o o/settings.o o/win_login.o o/win_dialog_password.o o/win_app_window.o o/win_views.o o/entry_parser.o o/win_richedit.o o/win_widget_tag_list.o o/win_dialog_tags.o o/win_wao.o $(RES)
9 | LINKOBJ = o/main.o o/diary.o o/diarydata.o o/helpers.o o/entry.o o/lifeograph.o o/settings.o o/win_login.o o/win_dialog_password.o o/win_app_window.o o/win_views.o o/entry_parser.o o/win_richedit.o o/win_widget_tag_list.o o/win_dialog_tags.o o/win_wao.o $(RES)
10 | LIBS = -L"C:/Program Files/Dev-Cpp/MinGW64/lib32" -L"C:/Program Files/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib32" -static-libgcc -L"mingw/lib" -mwindows -lcomctl32 -lshlwapi -lgcrypt -lgpg-error -m32 -static-libgcc -m32 -g3 -s
11 | INCS = -I"C:/Program Files/Dev-Cpp/MinGW64/include" -I"C:/Program Files/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"C:/Program Files/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.8.1/include" -I"mingw/include"
12 | CXXINCS = -I"C:/Program Files/Dev-Cpp/MinGW64/include" -I"C:/Program Files/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"C:/Program Files/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.8.1/include" -I"C:/Program Files/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++" -I"mingw/include"
13 | BIN = bin/lifeograph.exe
14 | CXXFLAGS = $(CXXINCS) -O2 -m32 -Wall -g3 -DLIFEO_WINDOZE -DHAVE_CONFIG_H -DUNICODE -I config -std=c++11 -m32 -static-libgcc
15 | CFLAGS = $(INCS) -O2 -m32 -Wall -g3 -static-libgcc
16 | RM = rm.exe -f
17 |
18 | .PHONY: all all-before all-after clean clean-custom
19 |
20 | all: all-before $(BIN) all-after
21 |
22 | clean: clean-custom
23 | ${RM} $(OBJ) $(BIN)
24 |
25 | $(BIN): $(OBJ)
26 | $(CPP) $(LINKOBJ) -o $(BIN) $(LIBS)
27 |
28 | o/main.o: src/main.cpp
29 | $(CPP) -c src/main.cpp -o o/main.o $(CXXFLAGS)
30 |
31 | o/diary.o: src/diary.cpp
32 | $(CPP) -c src/diary.cpp -o o/diary.o $(CXXFLAGS)
33 |
34 | o/diarydata.o: src/diarydata.cpp
35 | $(CPP) -c src/diarydata.cpp -o o/diarydata.o $(CXXFLAGS)
36 |
37 | o/helpers.o: src/helpers.cpp
38 | $(CPP) -c src/helpers.cpp -o o/helpers.o $(CXXFLAGS)
39 |
40 | o/entry.o: src/entry.cpp
41 | $(CPP) -c src/entry.cpp -o o/entry.o $(CXXFLAGS)
42 |
43 | o/lifeograph.o: src/lifeograph.cpp
44 | $(CPP) -c src/lifeograph.cpp -o o/lifeograph.o $(CXXFLAGS)
45 |
46 | o/settings.o: src/settings.cpp
47 | $(CPP) -c src/settings.cpp -o o/settings.o $(CXXFLAGS)
48 |
49 | o/win_login.o: src/win_login.cpp
50 | $(CPP) -c src/win_login.cpp -o o/win_login.o $(CXXFLAGS)
51 |
52 | o/win_dialog_password.o: src/win_dialog_password.cpp
53 | $(CPP) -c src/win_dialog_password.cpp -o o/win_dialog_password.o $(CXXFLAGS)
54 |
55 | o/win_app_window.o: src/win_app_window.cpp
56 | $(CPP) -c src/win_app_window.cpp -o o/win_app_window.o $(CXXFLAGS)
57 |
58 | o/win_views.o: src/win_views.cpp
59 | $(CPP) -c src/win_views.cpp -o o/win_views.o $(CXXFLAGS)
60 |
61 | o/entry_parser.o: src/entry_parser.cpp
62 | $(CPP) -c src/entry_parser.cpp -o o/entry_parser.o $(CXXFLAGS)
63 |
64 | o/win_richedit.o: src/win_richedit.cpp
65 | $(CPP) -c src/win_richedit.cpp -o o/win_richedit.o $(CXXFLAGS)
66 |
67 | o/win_widget_tag_list.o: src/win_widget_tag_list.cpp
68 | $(CPP) -c src/win_widget_tag_list.cpp -o o/win_widget_tag_list.o $(CXXFLAGS)
69 |
70 | o/win_dialog_tags.o: src/win_dialog_tags.cpp
71 | $(CPP) -c src/win_dialog_tags.cpp -o o/win_dialog_tags.o $(CXXFLAGS)
72 |
73 | o/win_wao.o: src/win_wao.cpp
74 | $(CPP) -c src/win_wao.cpp -o o/win_wao.o $(CXXFLAGS)
75 |
76 | o/LifeographWine_private.res: LifeographWine_private.rc
77 | $(WINDRES) -i LifeographWine_private.rc -F pe-i386 --input-format=rc -o o/LifeographWine_private.res -O coff
78 |
79 |
--------------------------------------------------------------------------------
/src/strings.hpp:
--------------------------------------------------------------------------------
1 | /***********************************************************************************
2 |
3 | Copyright (C) 2007-2014 Ahmet Öztürk (aoz_2@yahoo.com)
4 |
5 | This file is part of Lifeograph.
6 |
7 | Lifeograph is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | Lifeograph is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with Lifeograph. If not, see .
19 |
20 | ***********************************************************************************/
21 |
22 |
23 | #ifndef LIFEOGRAPH_STRINGS_HEADER
24 | #define LIFEOGRAPH_STRINGS_HEADER
25 |
26 | #ifndef LIFEO_WINDOZE
27 | #include
28 | #endif
29 | // DEFINITIONS FOR LIBGETTEXT
30 | #ifndef LIFEO_WINDOZE
31 | #define _(String) gettext(String)
32 | #else
33 | #define _(String) String
34 | #endif
35 | #define gettext_noop(String) String
36 | #define N_(String) gettext_noop(String)
37 | // END OF LIBGETTEXT DEFINITIONS
38 |
39 |
40 | namespace LIFEO
41 | {
42 |
43 | namespace STRING
44 | {
45 |
46 | static const char SLOGAN[] =
47 | N_( "Personal, digital diary" );
48 |
49 | static const char CANNOT_WRITE[] =
50 | N_( "Changes could not be written to diary!" );
51 |
52 | static const char CANNOT_WRITE_SUB[] =
53 | N_( "Check if you have write permissions on "
54 | "the file and containing folder" );
55 |
56 | static const char OFF[] =
57 | N_( "Off" );
58 |
59 | static const char EMPTY_ENTRY_TITLE[] =
60 | // TRANSLATORS: title of an empty diary entry
61 | N_( "" );
62 |
63 | static const char ENTER_PASSWORD[] =
64 | N_( "Please enter password for selected diary..." );
65 |
66 | static const char ENTER_PASSWORD_TIMEOUT[] =
67 | N_( "Program logged out to protect your privacy. "
68 | "Please re-enter password..." );
69 |
70 | static const char INCOMPATIBLE_DIARY_OLD[] =
71 | N_( "Selected diary is in an older format which is "
72 | "not compatible with this version of Lifeograph. "
73 | "Please select another file..." );
74 |
75 | static const char INCOMPATIBLE_DIARY_NEW[] =
76 | N_( "Selected diary is in a newer format which is "
77 | "not compatible with this version of Lifeograph. "
78 | "Please consider upgrading your program." );
79 |
80 | static const char CORRUPT_DIARY[] =
81 | N_( "Selected file is not a valid "
82 | "Lifeograph diary. "
83 | "Please select another file..." );
84 |
85 | static const char DIARY_NOT_FOUND[] =
86 | N_( "Selected file is not found. "
87 | "Please select another file..." );
88 |
89 | static const char DIARY_NOT_READABLE[] =
90 | N_( "Selected file is not readable. "
91 | "Please check file permissions or select another file..." );
92 |
93 | static const char DIARY_LOCKED[] =
94 | N_( "Selected file is locked which means either it is "
95 | "being edited by another instance of Lifeograph or "
96 | "the last session with it did not finish correctly. "
97 | "This file cannot be opened as long as the lock file (%1) "
98 | "is there." );
99 |
100 | static const char UPGRADE_DIARY_CONFIRM[] =
101 | N_( "You are about to open an old diary that will be upgraded to the new format.\n\n"
102 | "Lifeograph will create a backup copy of the current diary for you "
103 | "in the same directory. Please keep that copy until you are sure that "
104 | "everything is all right." );
105 |
106 | static const char FAILED_TO_OPEN_DIARY[] =
107 | N_( "Failed to open diary. "
108 | "Please select another file..." );
109 |
110 | static const char DIARY_IS_NOT_ENCRYPTED[] =
111 | N_( "Press Open to continue" );
112 |
113 | static const char COLHEAD_BY_LAST_ACCESS[] =
114 | N_( "Last Read" );
115 |
116 | static const char COLHEAD_BY_LAST_SAVE[] =
117 | N_( "Last Saved" );
118 |
119 | static const char DROP_TAG_TO_FILTER[] =
120 | N_( "(Drop a tag here to filter)" );
121 |
122 | static const char CHANGE_PASSWORD[] =
123 | N_( "Change Password..." );
124 |
125 | static const char ELEM_WITH_ENTRIES[] =
126 | // TRANSLATORS: e.g. Tag with 5 entries
127 | N_( "%1 with %2 entrie(s)" );
128 |
129 | static const char NEW_CHAPTER_NAME[] =
130 | N_( "New chapter" );
131 |
132 | static const char NEW_CATEGORY_NAME[] =
133 | N_( "New category" );
134 |
135 | static const char DEFAULT_CHAPTER_CTG_NAME[] =
136 | N_( "Default" );
137 |
138 | } // namespace STRING
139 |
140 | } // namespace LIFO
141 |
142 | #endif
143 |
--------------------------------------------------------------------------------
/rc/resource.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************************
2 |
3 | Copyright (C) 2014-2015 Ahmet Ozturk (aoz_2@yahoo.com)
4 |
5 | This file is part of Lifeograph.
6 |
7 | Lifeograph is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | Lifeograph is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with Lifeograph. If not, see .
19 |
20 | ***********************************************************************************/
21 |
22 |
23 | #ifndef IDC_STATIC
24 | #define IDC_STATIC (-1)
25 | #endif
26 |
27 | #define IDM_DIARY 100
28 | #define IDM_DIARY_R 101 // right click menu
29 | #define IDM_ENTRY 102
30 | #define IDM_CHAPTER 104
31 | #define IDM_TOPIC 105
32 | #define IDM_FILTER 107
33 | #define IDM_TEXT_EDITOR 108
34 | #define IDTB_MAIN 111
35 |
36 | // DIALOGS
37 | #define IDD_PASSWORD 151
38 | #define IDD_NEW_PASSWORD 152
39 | #define IDD_TAGS 155
40 | #define WAO_IDD_INPUT 180
41 |
42 |
43 | // ICONS
44 | #define IDBM_ENTRY16 202
45 | #define IDI_ENTRY16 205
46 | #define IDI_TODO_OPEN16 206
47 | #define IDI_TODO_PROG16 207
48 | #define IDI_TODO_DONE16 208
49 | #define IDI_TODO_CANC16 209
50 |
51 | #define IDI_FILTER16 212
52 |
53 | #define IDI_TAG16 220
54 |
55 |
56 | // ACCELERATORS
57 | #define IDA_C_D 801
58 | #define IDA_C_E 802
59 | #define IDA_C_T 825
60 |
61 | #define IDA_A_I 908
62 | #define IDA_A_U 915
63 | #define IDA_A_UP 951
64 | #define IDA_A_DOWN 952
65 |
66 | // MENU ITEMS
67 | #define IDMI_DIARY_OPEN 40000
68 | #define IDMI_DIARY_CREATE 40001
69 | #define IDMI_DIARY_EXPORT 40003
70 | #define IDMI_DIARY_ENCRYPT 40005
71 | #define IDMI_DIARY_CHANGE_PASSWORD 40006
72 | #define IDMI_DIARY_ADD_DCHAPTER 40010
73 | #define IDMI_DIARY_ADD_NCHAPTER 40011
74 | #define IDMI_DIARY_ADD_FCHAPTER 40012
75 | #define IDMI_ENTRY_FAVORITE 40020
76 | #define IDMI_ENTRY_TODO_NOT 40022
77 | #define IDMI_ENTRY_TODO_OPEN 40023
78 | #define IDMI_ENTRY_TODO_PROGRESSED 40024
79 | #define IDMI_ENTRY_TODO_DONE 40025
80 | #define IDMI_ENTRY_TODO_CANCELED 40026
81 | #define IDMI_ENTRY_DISMISS 40028
82 | #define IDMI_CHAPTER_RENAME 40041
83 | #define IDMI_CHAPTER_ADD_ENTRY 40042
84 | #define IDMI_CHAPTER_DISMISS 40043
85 | #define IDMI_FILTER_RESET 40050
86 | #define IDMI_FILTER_SAVE 40051
87 | #define IDMI_FILTER_TODO_NOT 40052
88 | #define IDMI_FILTER_TODO_OPEN 40053
89 | #define IDMI_FILTER_TODO_PROGRESSED 40054
90 | #define IDMI_FILTER_TODO_DONE 40055
91 | #define IDMI_FILTER_TODO_CANCELED 40056
92 | #define IDMI_FILTER_FAVORITES 40057
93 | #define IDMI_FILTER_TAGS 40058
94 | #define IDMI_TEXT_NOT_LIST 40060
95 | #define IDMI_TEXT_TODO_OPEN 40061
96 | #define IDMI_TEXT_TODO_PROGRESSED 40062
97 | #define IDMI_TEXT_TODO_DONE 40063
98 | #define IDMI_TEXT_TODO_CANCELED 40064
99 | #define IDMI_TEXT_BULLET 40066
100 | #define IDMI_TAG_RENAME 40080
101 | #define IDMI_TAG_DISMISS 40081
102 |
103 | #define IDMI_QUIT_WO_SAVE 40098
104 | #define IDMI_QUIT 40099
105 |
106 | // BUTTONS
107 | #define IDB_ABOUT 44100
108 | #define IDB_DIARY 44101
109 | #define IDB_TODAY 44104
110 | #define IDB_ELEM 44107
111 | #define IDB_ELEM_TITLE 44108
112 | #define IDB_FILTER 44109
113 | #define IDB_TAG_THEME 44119
114 | #define IDB_TAG_ACTION 44120
115 | #define IDB_TAG_FILTER_CLEAR 44121
116 | #define IDB_TAG_FILTER_SET 44122
117 |
118 | // TEXT EDITS
119 | #define IDRT_MAIN 44200
120 | #define IDE_PASSWORD 44201
121 | #define IDE_PASSWORD2 44202
122 | #define IDE_SEARCH 44205
123 | #define IDE_ELEM_DATE 44211
124 | #define IDE_TAG_NAME 44222
125 | #define WAO_IDE_INPUT 44400
126 |
127 | // LABELS
128 | #define IDL_PASSWORD_MESSAGE 44801
129 | #define IDL_DIARY_NAME 44802
130 |
131 | // OTHERS
132 | #define IDCC_TAGS 44901
133 | #define IDLV_MAIN 44911
134 | #define IDTV_TAG_LIST 44921
135 | #define IDCAL_MAIN 44950
136 | #define ID_TIMER_BACKUP 46100
137 |
138 |
--------------------------------------------------------------------------------
/src/entry.hpp:
--------------------------------------------------------------------------------
1 | /***********************************************************************************
2 |
3 | Copyright (C) 2007-2011 Ahmet Öztürk (aoz_2@yahoo.com)
4 |
5 | This file is part of Lifeograph.
6 |
7 | Lifeograph is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | Lifeograph is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with Lifeograph. If not, see .
19 |
20 | ***********************************************************************************/
21 |
22 |
23 | #ifndef LIFEOGRAPH_ENTRY_HEADER
24 | #define LIFEOGRAPH_ENTRY_HEADER
25 |
26 |
27 | #include "diarydata.hpp"
28 |
29 |
30 | namespace LIFEO
31 | {
32 |
33 | static const char LANG_INHERIT_DIARY[] = "d";
34 |
35 |
36 | class Entry : virtual public DiaryElement
37 | {
38 | public:
39 | static ElementView< Entry >* shower;
40 |
41 | #ifndef LIFEO_WINDOZE
42 | typedef sigc::signal< void, Entry* >
43 | Signal_void_Entry;
44 | #endif
45 |
46 | Entry( Diary* const, const Date::date_t,
47 | const Ustring&, bool = false );
48 | Entry( Diary* const, const Date::date_t,
49 | bool = false );
50 | virtual ~Entry() {}
51 |
52 | void show() override;
53 | void prepare_for_hiding() override;
54 |
55 | const Ustring* get_text() const { return &m_text; }
56 | Ustring& get_text() { return m_text; }
57 | void set_text( const Ustring& text )
58 | { m_text = text; calculate_title( text ); }
59 | void append_text( const Ustring& text );
60 |
61 | Date get_date() const override { return m_date; }
62 | void set_date( Date::date_t date )
63 | { m_date.m_date = date; }
64 |
65 | time_t get_date_created() const { return m_date_created; }
66 | Ustring get_date_created_str() const;
67 |
68 | time_t get_date_edited() const { return m_date_edited; }
69 | Ustring get_date_edited_str() const;
70 | void set_date_edited( Date::date_t d ) { m_date_edited = d; }
71 |
72 | time_t get_date_status() const { return m_date_status; }
73 | Ustring get_date_status_str() const;
74 | void set_date_status( Date::date_t d ) { m_date_status = d; }
75 |
76 | int get_size() const override
77 | { return m_text.size(); }
78 | Type get_type() const override
79 | { return ET_ENTRY; }
80 |
81 | #ifndef LIFEO_WINDOZE
82 | const Icon& get_icon() const override;
83 | const Icon& get_icon32() const override;
84 | #else
85 | int get_icon() const;
86 | #endif
87 |
88 | void calculate_title( const Ustring& );
89 |
90 | Ustring get_list_str() const override;
91 |
92 | bool get_filtered_out() override;
93 | void set_filtered_out( bool filteredout = true )
94 | {
95 | if( filteredout )
96 | m_status |= ES::FILTERED_OUT;
97 | else if( m_status & ES::FILTERED_OUT )
98 | m_status -= ES::FILTERED_OUT;
99 | }
100 |
101 | bool is_favored() const override { return( m_status & ES::FAVORED ); }
102 | void set_favored( bool favored )
103 | {
104 | m_status -= ( m_status & ES::FILTER_FAVORED );
105 | m_status |= ( favored ? ES::FAVORED : ES::NOT_FAVORED );
106 | }
107 | void toggle_favored()
108 | { m_status ^= ES::FILTER_FAVORED; }
109 |
110 | std::string get_lang() const { return m_option_lang; }
111 | std::string get_lang_final() const;
112 | void set_lang( const std::string& lang ) { m_option_lang = lang; }
113 |
114 | bool is_empty() const
115 | {
116 | return( m_text.empty() && m_tags.empty() );
117 | }
118 |
119 | bool is_trashed() const { return( m_status & ES::TRASHED ); }
120 | void set_trashed( bool trashed )
121 | {
122 | m_status -= ( m_status & ES::FILTER_TRASHED );
123 | m_status |= ( trashed ? ES::TRASHED : ES::NOT_TRASHED );
124 | }
125 |
126 | void set_tags( const TagSet& tags )
127 | { m_tags = tags; }
128 | const TagSet& get_tags() const
129 | { return m_tags; }
130 | TagSet& get_tags()
131 | { return m_tags; }
132 | bool add_tag( Tag*, Value = 1.0 );
133 | bool remove_tag( Tag* );
134 | bool clear_tags();
135 |
136 | // THEMES
137 | const Theme* get_theme() const;
138 | const Tag* get_theme_tag() const
139 | { return m_ptr2theme_tag; }
140 | void set_theme_tag( const Tag* );
141 | bool get_theme_is_set() const
142 | { return( m_ptr2theme_tag != NULL ); }
143 | void update_theme(); // called when a tag gained or lost custom theme
144 |
145 | protected:
146 | Date m_date;
147 | time_t m_date_created;
148 | time_t m_date_edited;
149 | time_t m_date_status;
150 | Ustring m_text;
151 | TagSet m_tags;
152 | Ustring m_location;
153 | const Tag* m_ptr2theme_tag{ nullptr }; // nullptr means theme is not set
154 |
155 | std::string m_option_lang = LANG_INHERIT_DIARY; // empty means off
156 |
157 | friend class Diary; // TODO: remove this friendship too??
158 | };
159 |
160 | // ENTRY SET ===================================================================
161 | class PoolEntries : public std::map< Date::date_t, Entry*, FuncCompareDates >
162 | {
163 | public:
164 | PoolEntries()
165 | : std::map< Date::date_t, Entry*, FuncCompareDates >( compare_dates ) {}
166 | ~PoolEntries();
167 |
168 | void clear();
169 | };
170 |
171 | typedef PoolEntries::iterator EntryIter;
172 | typedef PoolEntries::reverse_iterator EntryIterReverse;
173 | typedef PoolEntries::const_iterator EntryIterConst;
174 | typedef PoolEntries::const_reverse_iterator EntryIterConstRev;
175 |
176 | } // end of namespace LIFEO
177 |
178 | #endif
179 |
180 |
--------------------------------------------------------------------------------
/LifeographWine.dev:
--------------------------------------------------------------------------------
1 | [Project]
2 | FileName=LifeographWine.dev
3 | Name=LifeographWine
4 | Type=0
5 | Ver=2
6 | ObjFiles=
7 | Includes=mingw\include
8 | Libs=mingw\lib
9 | PrivateResource=LifeographWine_private.rc
10 | ResourceIncludes=
11 | MakeIncludes=
12 | Compiler=-static-libgcc_@@_
13 | CppCompiler=-DLIFEO_WINDOZE_@@_-DHAVE_CONFIG_H_@@_-DUNICODE_@@_-I config_@@_-std=c++11_@@_-m32_@@_-static-libgcc_@@_
14 | Linker=-lcomctl32_@@_-lshlwapi_@@_-lgcrypt_@@_-lgpg-error_@@_-m32_@@_-static-libgcc_@@_
15 | IsCpp=1
16 | Icon=LifeographWine.ico
17 | ExeOutput=bin
18 | ObjectOutput=o
19 | LogOutput=
20 | LogOutputEnabled=0
21 | OverrideOutput=1
22 | OverrideOutputName=lifeograph.exe
23 | HostApplication=
24 | UseCustomMakefile=0
25 | CustomMakefile=
26 | CommandLine=--ignore-locks
27 | Folders=
28 | IncludeVersionInfo=0
29 | SupportXPThemes=0
30 | CompilerSet=3
31 | CompilerSettings=000000a100100000001001000
32 | UnitCount=35
33 |
34 | [VersionInfo]
35 | Major=1
36 | Minor=0
37 | Release=0
38 | Build=0
39 | LanguageID=1033
40 | CharsetID=1252
41 | CompanyName=
42 | FileVersion=1.0.0.0
43 | FileDescription=Developed using the Dev-C++ IDE
44 | InternalName=
45 | LegalCopyright=
46 | LegalTrademarks=
47 | OriginalFilename=
48 | ProductName=
49 | ProductVersion=1.0.0.0
50 | AutoIncBuildNr=0
51 | SyncProduct=1
52 |
53 | [Unit1]
54 | FileName=src\main.cpp
55 | CompileCpp=1
56 | Folder=
57 | Compile=1
58 | Link=1
59 | Priority=1000
60 | OverrideBuildCmd=0
61 | BuildCmd=
62 |
63 | [Unit3]
64 | FileName=src\diary.hpp
65 | Folder=
66 | Compile=1
67 | Link=1
68 | Priority=1000
69 | OverrideBuildCmd=0
70 | BuildCmd=
71 | CompileCpp=1
72 |
73 | [Unit4]
74 | FileName=src\diarydata.cpp
75 | CompileCpp=1
76 | Folder=
77 | Compile=1
78 | Link=1
79 | Priority=1000
80 | OverrideBuildCmd=0
81 | BuildCmd=
82 |
83 | [Unit5]
84 | FileName=src\diarydata.hpp
85 | CompileCpp=1
86 | Folder=
87 | Compile=1
88 | Link=1
89 | Priority=1000
90 | OverrideBuildCmd=0
91 | BuildCmd=
92 |
93 | [Unit6]
94 | FileName=src\helpers.cpp
95 | CompileCpp=1
96 | Folder=
97 | Compile=1
98 | Link=1
99 | Priority=1000
100 | OverrideBuildCmd=0
101 | BuildCmd=
102 |
103 | [Unit7]
104 | FileName=src\helpers.hpp
105 | CompileCpp=1
106 | Folder=
107 | Compile=1
108 | Link=1
109 | Priority=1000
110 | OverrideBuildCmd=0
111 | BuildCmd=
112 |
113 | [Unit8]
114 | FileName=src\entry.cpp
115 | CompileCpp=1
116 | Folder=
117 | Compile=1
118 | Link=1
119 | Priority=1000
120 | OverrideBuildCmd=0
121 | BuildCmd=
122 |
123 | [Unit9]
124 | FileName=src\entry.hpp
125 | CompileCpp=1
126 | Folder=
127 | Compile=1
128 | Link=1
129 | Priority=1000
130 | OverrideBuildCmd=0
131 | BuildCmd=
132 |
133 | [Unit10]
134 | FileName=src\lifeograph.cpp
135 | CompileCpp=1
136 | Folder=
137 | Compile=1
138 | Link=1
139 | Priority=1000
140 | OverrideBuildCmd=0
141 | BuildCmd=
142 |
143 | [Unit11]
144 | FileName=src\lifeograph.hpp
145 | CompileCpp=1
146 | Folder=
147 | Compile=1
148 | Link=1
149 | Priority=1000
150 | OverrideBuildCmd=0
151 | BuildCmd=
152 |
153 | [Unit12]
154 | FileName=src\settings.cpp
155 | CompileCpp=1
156 | Folder=
157 | Compile=1
158 | Link=1
159 | Priority=1000
160 | OverrideBuildCmd=0
161 | BuildCmd=
162 |
163 | [Unit13]
164 | FileName=src\settings.hpp
165 | CompileCpp=1
166 | Folder=
167 | Compile=1
168 | Link=1
169 | Priority=1000
170 | OverrideBuildCmd=0
171 | BuildCmd=
172 |
173 | [Unit14]
174 | FileName=config\config.h
175 | CompileCpp=1
176 | Folder=
177 | Compile=1
178 | Link=1
179 | Priority=1000
180 | OverrideBuildCmd=0
181 | BuildCmd=
182 |
183 | [Unit15]
184 | FileName=src\strings.hpp
185 | CompileCpp=1
186 | Folder=
187 | Compile=1
188 | Link=1
189 | Priority=1000
190 | OverrideBuildCmd=0
191 | BuildCmd=
192 |
193 | [Unit16]
194 | FileName=src\win_login.hpp
195 | CompileCpp=1
196 | Folder=
197 | Compile=1
198 | Link=1
199 | Priority=1000
200 | OverrideBuildCmd=0
201 | BuildCmd=
202 |
203 | [Unit17]
204 | FileName=src\win_login.cpp
205 | CompileCpp=1
206 | Folder=
207 | Compile=1
208 | Link=1
209 | Priority=1000
210 | OverrideBuildCmd=0
211 | BuildCmd=
212 |
213 | [Unit18]
214 | FileName=src\win_dialog_password.hpp
215 | CompileCpp=1
216 | Folder=
217 | Compile=1
218 | Link=1
219 | Priority=1000
220 | OverrideBuildCmd=0
221 | BuildCmd=
222 |
223 | [Unit19]
224 | FileName=src\win_dialog_password.cpp
225 | CompileCpp=1
226 | Folder=
227 | Compile=1
228 | Link=1
229 | Priority=1000
230 | OverrideBuildCmd=0
231 | BuildCmd=
232 |
233 | [Unit20]
234 | FileName=src\win_app_window.hpp
235 | CompileCpp=1
236 | Folder=
237 | Compile=1
238 | Link=1
239 | Priority=1000
240 | OverrideBuildCmd=0
241 | BuildCmd=
242 |
243 | [Unit21]
244 | FileName=src\win_app_window.cpp
245 | CompileCpp=1
246 | Folder=
247 | Compile=1
248 | Link=1
249 | Priority=1000
250 | OverrideBuildCmd=0
251 | BuildCmd=
252 |
253 | [Unit23]
254 | FileName=rc\lifeograph.rc
255 | CompileCpp=1
256 | Folder=Resources
257 | Compile=1
258 | Link=0
259 | Priority=1000
260 | OverrideBuildCmd=0
261 | BuildCmd=
262 |
263 | [Unit24]
264 | FileName=src\win_views.hpp
265 | Folder=
266 | Compile=1
267 | Link=1
268 | Priority=1000
269 | OverrideBuildCmd=0
270 | BuildCmd=
271 | CompileCpp=1
272 |
273 | [Unit2]
274 | FileName=src\diary.cpp
275 | CompileCpp=1
276 | Folder=
277 | Compile=1
278 | Link=1
279 | Priority=1000
280 | OverrideBuildCmd=0
281 | BuildCmd=
282 |
283 | [Unit22]
284 | FileName=rc\resource.h
285 | CompileCpp=1
286 | Folder=
287 | Compile=1
288 | Link=1
289 | Priority=1000
290 | OverrideBuildCmd=0
291 | BuildCmd=
292 |
293 | [Unit25]
294 | FileName=src\win_views.cpp
295 | CompileCpp=1
296 | Folder=
297 | Compile=1
298 | Link=1
299 | Priority=1000
300 | OverrideBuildCmd=0
301 | BuildCmd=
302 |
303 | [Unit26]
304 | FileName=src\entry_parser.cpp
305 | CompileCpp=1
306 | Folder=
307 | Compile=1
308 | Link=1
309 | Priority=1000
310 | OverrideBuildCmd=0
311 | BuildCmd=
312 |
313 | [Unit27]
314 | FileName=src\entry_parser.hpp
315 | CompileCpp=1
316 | Folder=
317 | Compile=1
318 | Link=1
319 | Priority=1000
320 | OverrideBuildCmd=0
321 | BuildCmd=
322 |
323 | [Unit28]
324 | FileName=src\win_richedit.cpp
325 | CompileCpp=1
326 | Folder=
327 | Compile=1
328 | Link=1
329 | Priority=1000
330 | OverrideBuildCmd=0
331 | BuildCmd=
332 |
333 | [Unit29]
334 | FileName=src\win_richedit.hpp
335 | CompileCpp=1
336 | Folder=
337 | Compile=1
338 | Link=1
339 | Priority=1000
340 | OverrideBuildCmd=0
341 | BuildCmd=
342 |
343 | [Unit30]
344 | FileName=src\win_widget_tag_list.cpp
345 | CompileCpp=1
346 | Folder=
347 | Compile=1
348 | Link=1
349 | Priority=1000
350 | OverrideBuildCmd=0
351 | BuildCmd=
352 |
353 | [Unit31]
354 | FileName=src\win_widget_tag_list.hpp
355 | CompileCpp=1
356 | Folder=
357 | Compile=1
358 | Link=1
359 | Priority=1000
360 | OverrideBuildCmd=0
361 | BuildCmd=
362 |
363 | [Unit32]
364 | FileName=src\win_dialog_tags.hpp
365 | CompileCpp=1
366 | Folder=
367 | Compile=1
368 | Link=1
369 | Priority=1000
370 | OverrideBuildCmd=0
371 | BuildCmd=
372 |
373 | [Unit33]
374 | FileName=src\win_dialog_tags.cpp
375 | CompileCpp=1
376 | Folder=
377 | Compile=1
378 | Link=1
379 | Priority=1000
380 | OverrideBuildCmd=0
381 | BuildCmd=
382 |
383 | [Unit34]
384 | FileName=src\win_wao.cpp
385 | CompileCpp=1
386 | Folder=
387 | Compile=1
388 | Link=1
389 | Priority=1000
390 | OverrideBuildCmd=0
391 | BuildCmd=
392 |
393 | [Unit35]
394 | FileName=src\win_wao.hpp
395 | CompileCpp=1
396 | Folder=
397 | Compile=1
398 | Link=1
399 | Priority=1000
400 | OverrideBuildCmd=0
401 | BuildCmd=
402 |
403 |
--------------------------------------------------------------------------------
/src/settings.cpp:
--------------------------------------------------------------------------------
1 | /***********************************************************************************
2 |
3 | Copyright (C) 2010 Ahmet Öztürk (aoz_2@yahoo.com)
4 |
5 | This file is part of Lifeograph.
6 |
7 | Lifeograph is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | Lifeograph is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with Lifeograph. If not, see .
19 |
20 | ***********************************************************************************/
21 |
22 |
23 | #include "settings.hpp"
24 |
25 | #include
26 | #ifndef LIFEO_WINDOZE
27 | #include // g_mkdir()
28 | #else
29 | #include
30 | #include
31 | #endif
32 |
33 |
34 | using namespace LIFEO;
35 |
36 |
37 | const std::string Settings::s_date_format_orders[ 3 ] = { "YMD", "DMY", "MDY" };
38 | const std::string Settings::s_date_format_separators = "./-";
39 |
40 | bool
41 | Settings::read()
42 | {
43 | #ifndef LIFEO_WINDOZE
44 | m_path = Glib::getenv( "LIFEOGRAPH_CONFIG_FILE" );
45 | #endif
46 | if( m_path.empty() )
47 | {
48 | flag_maiden_voyage = true; // maiden voyage is not used when custom config path is given
49 | #ifndef LIFEO_WINDOZE
50 | m_path = Glib::build_filename( Glib::get_user_config_dir(), "lifeograph", "lifeo.conf" );
51 | #else
52 | char exe_path[ MAX_PATH ];
53 | GetModuleFileNameA( NULL, exe_path, MAX_PATH );
54 | PathRemoveFileSpecA( exe_path );
55 | PathAppendA( exe_path, "lifeo.conf" );
56 | m_path = exe_path;
57 | #endif
58 | }
59 |
60 | std::ifstream file( m_path.c_str() );
61 |
62 | if( ! file.is_open() )
63 | {
64 | PRINT_DEBUG( "Configuration file does not exist!" );
65 | return false;
66 | }
67 | else
68 | flag_maiden_voyage = false;
69 |
70 | reset();
71 |
72 | std::string line;
73 |
74 | while( getline( file, line ) )
75 | {
76 | if( line.size() < 3 )
77 | continue;
78 |
79 | switch( line[ 0 ] )
80 | {
81 | case 'D':
82 | if( line[1] == 'o' )
83 | date_format_order = convert_string( line.substr( 2 ) );
84 | else
85 | date_format_separator = convert_string( line.substr( 2 ) );
86 | break;
87 | case 'E':
88 | // if only a dot (.) no extension will be added automatically
89 | diary_extension = line.substr( 2 );
90 | if( diary_extension[ 0 ] != '.' )
91 | diary_extension.insert( 0, "." );
92 | break;
93 | case 'F':
94 | show_formatting_toolbar = ( line[ 2 ] == 'y' || line[ 2 ] == 'Y' );
95 | break;
96 | // TODO: position & size settings may go to the diary
97 | // TODO: check if these are within screen boundaries
98 | case 'H':
99 | height = convert_string( line.substr( 2 ) );
100 | break;
101 | case 'I':
102 | idletime = convert_string( line.substr( 2 ) );
103 | if( idletime < IDLETIME_MIN || idletime > IDLETIME_MAX )
104 | idletime = IDLETIME_DEFAULT;
105 | break;
106 | case 'L':
107 | autologout = ( line[ 2 ] == 'y' || line[ 2 ] == 'Y' );
108 | break;
109 | case 'O': // special options
110 | if( line.find( "big lists" ) != std::string::npos )
111 | small_lists = false;
112 | break;
113 | case 'P': // uppercase
114 | position_pane = convert_string( line.substr( 2 ) );
115 | break;
116 | case 'p': // lowercase
117 | position_pane_tags = convert_string( line.substr( 2 ) );
118 | // zero width is not accepted by Gtk::Paned
119 | if( position_pane_tags == 0 )
120 | position_pane_tags = 1;
121 | break;
122 | case 'R':
123 | recentfiles.insert( line.substr( 2 ) );
124 | break;
125 | case 'S':
126 | state_maximized = ( line[ 2 ] == 'm' || line[ 2 ] == 'M' );
127 | break;
128 | case 'T':
129 | icon_theme = line.substr( 2 );
130 | break;
131 | case 'W':
132 | width = convert_string( line.substr( 2 ) );
133 | break;
134 | case 'X':
135 | position_x = convert_string( line.substr( 2 ) );
136 | break;
137 | case 'Y':
138 | position_y = convert_string( line.substr( 2 ) );
139 | break;
140 |
141 | case 0: // empty line
142 | case '#': // comment
143 | break;
144 | default:
145 | print_info( "unrecognized option:\n", line );
146 | break;
147 | }
148 | }
149 |
150 | update_date_format();
151 |
152 | file.close();
153 | return true;
154 | }
155 |
156 | bool
157 | Settings::write()
158 | {
159 | #ifndef LIFEO_WINDOZE
160 | if( access( m_path.c_str(), F_OK ) != 0 )
161 | {
162 | if( ! Glib::file_test( Glib::path_get_dirname( m_path ), Glib::FILE_TEST_IS_DIR ) )
163 | g_mkdir_with_parents( Glib::path_get_dirname( m_path ).c_str(), 0700 );
164 | }
165 | #endif
166 |
167 | std::ofstream file( m_path.c_str(), std::ios::out | std::ios::trunc );
168 |
169 | if( ! file.is_open() )
170 | {
171 | print_error( "Failed to save configuration!" );
172 | return false;
173 | }
174 |
175 | file << "W " << width;
176 | file << "\nH " << height;
177 | file << "\nX " << position_x;
178 | file << "\nY " << position_y;
179 | file << "\nS " << ( state_maximized ? 'm' : 'u' );
180 | file << "\nP " << position_pane;
181 | file << "\np " << position_pane_tags;
182 |
183 | // RECENT FILES
184 | for( const std::string& path : recentfiles )
185 | file << "\nR " << path;
186 |
187 | file << "\nL " << ( autologout ? 'y' : 'n' );
188 | file << "\nI " << idletime;
189 | file << "\nF " << ( show_formatting_toolbar ? 'y' : 'n' );
190 |
191 | file << "\nDo" << date_format_order;
192 | file << "\nDs" << date_format_separator;
193 |
194 | if( diary_extension != EXTENSION_DEFAULT )
195 | file << "\nE " << diary_extension;
196 |
197 | if( ! icon_theme.empty() )
198 | file << "\nT " << icon_theme;
199 |
200 | if( small_lists == false )
201 | file << "\nO big lists";
202 |
203 | file.close();
204 | return true;
205 | }
206 |
207 | void
208 | Settings::reset()
209 | {
210 | recentfiles.clear();
211 | autologout = true;
212 | idletime = IDLETIME_DEFAULT;
213 | show_formatting_toolbar = true;
214 | date_format_order = 0;
215 | date_format_separator = 0;
216 | icon_theme.clear();
217 | diary_extension = EXTENSION_DEFAULT;
218 | }
219 |
220 | void
221 | Settings::update_date_format()
222 | {
223 | Date::s_format_order = s_date_format_orders[ date_format_order ];
224 | Date::s_format_separator = s_date_format_separators[ date_format_separator ];
225 | }
226 |
227 | // maybe later:
228 | //bool
229 | //Settings::get_bool_opt( int i )
230 | //{
231 | // if( i >= m_bool_opts.size() )
232 | // throw LIFEO::Error( "Requested option is out of bounds" );
233 | // else
234 | // return m_bool_opts[ i ];
235 | //}
236 |
--------------------------------------------------------------------------------
/src/lifeograph.hpp:
--------------------------------------------------------------------------------
1 | /***********************************************************************************
2 |
3 | Copyright (C) 2007-2012 Ahmet Öztürk (aoz_2@yahoo.com)
4 |
5 | This file is part of Lifeograph.
6 |
7 | Lifeograph is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | Lifeograph is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with Lifeograph. If not, see .
19 |
20 | ***********************************************************************************/
21 |
22 |
23 | #ifndef LIFEOGRAPH_BASE_HEADER
24 | #define LIFEOGRAPH_BASE_HEADER
25 |
26 | #include "settings.hpp"
27 | #include "diary.hpp"
28 |
29 | #ifndef LIFEO_WINDOZE
30 | #include "panel_main.hpp"
31 | #include "panel_diary.hpp"
32 | #include "panel_extra.hpp"
33 | #include "view_entry.hpp"
34 | #endif
35 |
36 | namespace LIFEO
37 | {
38 |
39 | static const char PROGRAM_NAME[] = "Lifeograph";
40 |
41 | static const int BACKUP_INTERVAL = 30; // seconds
42 | static const int LOGOUT_COUNTDOWN = 10; // seconds
43 |
44 | static const char TARGET_ENTRY_TAG[] = "GTK_TREE_MODEL_ROW_TAG";
45 | static const char TARGET_ENTRY_ENTRY[] = "GTK_TREE_MODEL_ROW_ENTRY";
46 |
47 | struct Icons
48 | {
49 | Icon diary_16;
50 | Icon diary_32;
51 | Icon entry_16;
52 | Icon entry_32;
53 | Icon entry_favorite_16;
54 | Icon entry_favorite_32;
55 | Icon tag_16;
56 | Icon tag_32;
57 | Icon tag_theme_16;
58 | Icon tag_theme_32;
59 | Icon tag_category_16;
60 | Icon tag_category_32;
61 | Icon untagged_16;
62 | Icon untagged_32;
63 | Icon chapter_16;
64 | Icon chapter_32;
65 | Icon month_16;
66 | Icon month_32;
67 | Icon filter_16;
68 | Icon filter_32;
69 | Icon todo_open_16;
70 | Icon todo_open_32;
71 | Icon todo_progressed_16;
72 | Icon todo_progressed_32;
73 | Icon todo_done_16;
74 | Icon todo_done_32;
75 | Icon todo_canceled_16;
76 | Icon todo_canceled_32;
77 | };
78 |
79 | typedef std::set< std::string > LanguageList;
80 |
81 | // Lifeograph Application
82 | class Lifeograph
83 | #ifndef LIFEO_WINDOZE
84 | : public Gtk::Application
85 | #endif
86 | {
87 | public:
88 | static const char PROGRAM_VERSION_STRING[];
89 | // static const int PROGRAM_VERSION_INT = 100000;
90 |
91 | enum LoginStatus
92 | {
93 | LOGGED_OUT = 0, LOGGED_IN = 1, LOGGED_TIME_OUT = 2
94 | };
95 |
96 | #ifndef LIFEO_WINDOZE
97 | static Glib::RefPtr< Lifeograph >
98 | create();
99 | #endif
100 |
101 | static bool quit();
102 |
103 | Lifeograph();
104 | virtual ~Lifeograph();
105 | static Lifeograph* p; // static pointer
106 |
107 | void on_startup();
108 | void on_activate();
109 | #ifndef LIFEO_WINDOZE
110 | int on_command_line( const Glib::RefPtr< Gio::ApplicationCommandLine >& );
111 | #else
112 | int on_command_line( int argc, char** argv );
113 | #endif
114 |
115 | static Settings settings;
116 | static Icons* icons;
117 |
118 | #ifndef LIFEO_WINDOZE
119 | static Glib::RefPtr< Gtk::Builder >
120 | builder;
121 |
122 | static void create_action(
123 | bool,
124 | Glib::RefPtr< Gtk::Action >&,
125 | const Glib::ustring&,
126 | const Glib::ustring&,
127 | const Glib::ustring&,
128 | const Gtk::AccelKey&,
129 | const Glib::SignalProxy0< void >::SlotType&,
130 | Gtk::Activatable* = NULL );
131 |
132 | static void create_toggle_action(
133 | bool,
134 | Glib::RefPtr< Gtk::ToggleAction >&,
135 | const Glib::ustring&,
136 | const Glib::ustring&,
137 | const Glib::ustring&,
138 | const Gtk::AccelKey&,
139 | const Glib::SignalProxy0< void >::SlotType&,
140 | Gtk::Activatable* = NULL );
141 |
142 | bool load_gui( const std::string& );
143 |
144 | static SignalVoid s_signal_logout;
145 | #endif
146 |
147 | static int m_internaloperation;
148 |
149 | #ifndef LIFEO_WINDOZE
150 | // DRAG & DROP
151 | std::vector< Gtk::TargetEntry >
152 | drag_targets_tag;
153 | std::vector< Gtk::TargetEntry >
154 | drag_targets_entry;
155 | static DiaryElement* s_elem_dragged;
156 | static bool s_flag_dragging;
157 |
158 | // COLORS
159 | static std::string s_color_insensitive;
160 |
161 | // ENCHANT
162 | static EnchantBroker* s_enchant_broker;
163 | static LanguageList s_lang_list;
164 | #endif
165 |
166 | static std::set< std::string > stock_diaries;
167 |
168 | #ifndef LIFEO_WINDOZE
169 | static Icon get_thumbnail( const std::string&, int );
170 |
171 | static SignalVoid signal_logout()
172 | { return s_signal_logout; }
173 |
174 | static Glib::RefPtr< Gtk::ActionGroup >
175 | m_actions_read;
176 | static Glib::RefPtr< Gtk::ActionGroup >
177 | m_actions_edit;
178 | #else
179 | int run( HINSTANCE, LPSTR );
180 | static HINSTANCE hInst;
181 |
182 | #endif
183 |
184 | static LoginStatus loginstatus;
185 |
186 | //std::string m_program_path; // XXX NOT USED
187 |
188 | bool m_flag_force_welcome;
189 | bool m_flag_open_directly;
190 | bool m_flag_read_only; // for command-line supplied file
191 |
192 | protected:
193 | #ifndef LIFEO_WINDOZE
194 | static void fill_lang_list_cb( const char* const l, const char* const,
195 | const char* const, const char* const,
196 | void* )
197 | { s_lang_list.insert( l ); }
198 |
199 | // APPLICATION MENU
200 | Glib::RefPtr< Gio::Menu > m_menu;
201 |
202 | // POOL OF THUMBNAILS FOR IMAGE LINKS IN DIARY
203 | typedef std::map< std::string, Icon > MapPixbufs;
204 | MapPixbufs map_thumbnails;
205 | #endif
206 | };
207 |
208 | } // end of namespace LIFEO
209 |
210 | #endif
211 |
212 |
--------------------------------------------------------------------------------
/src/entry_parser.hpp:
--------------------------------------------------------------------------------
1 | /***********************************************************************************
2 |
3 | Copyright (C) 2007-2012 Ahmet Öztürk (aoz_2@yahoo.com)
4 |
5 | This file is part of Lifeograph.
6 |
7 | Lifeograph is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | Lifeograph is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with Lifeograph. If not, see .
19 |
20 | ***********************************************************************************/
21 |
22 |
23 | #ifndef LIFEOGRAPH_ENTRY_PARSER_HEADER
24 | #define LIFEOGRAPH_ENTRY_PARSER_HEADER
25 |
26 |
27 | #ifndef LIFEO_WINDOZE
28 | #include
29 | #else
30 | #include
31 | #endif
32 |
33 | #include "helpers.hpp"
34 |
35 |
36 | namespace LIFEO
37 | {
38 |
39 | using namespace HELPERS;
40 |
41 | enum CharFlag
42 | {
43 | CF_NOT_SET = 0,
44 | CF_NOTHING = 0x1,
45 | CF_NEWLINE = 0x2,
46 | CF_PUNCTUATION_RAW = 0x4,
47 | CF_SPACE = 0x8, // space that will come eventually
48 | CF_TAB = 0x10,
49 | CF_IMMEDIATE = 0x20, // indicates contiguity of chars
50 |
51 | CF_ASTERISK = 0x40, // bold
52 | CF_UNDERSCORE = 0x80, // italic
53 | CF_EQUALS = 0x100, // strikethrough
54 | CF_HASH = 0x400, // highlight
55 | CF_MARKUP = CF_ASTERISK|CF_UNDERSCORE|CF_EQUALS|CF_HASH,
56 |
57 | CF_SLASH = 0x800,
58 | CF_ALPHA = 0x1000,
59 | CF_NUMBER = 0x2000,
60 | CF_ALHANUM = CF_ALPHA|CF_NUMBER,
61 | CF_AT = 0x4000, // email
62 | CF_SPELLCHECK = 0x8000,
63 |
64 | CF_DOTYM = 0x10000,
65 | CF_DOTMD = 0x20000,
66 | CF_DOTDATE = CF_DOTMD|CF_DOTYM,
67 |
68 | CF_LESS = 0x80000, // tagging
69 | CF_MORE = 0x100000,
70 | CF_SBB = 0x200000, // square bracket begin: comments
71 | CF_SBE = 0x400000, // square bracket end: comments
72 |
73 | CF_TODO = 0x1000000, // ~,+,x
74 |
75 | CF_IGNORE = 0x40000000,
76 | CF_EOT = 0x80000000, // End of Text
77 |
78 | CF_ANY = 0xFFFFFFFF,
79 |
80 | CF_PUNCTUATION = CF_PUNCTUATION_RAW|CF_SLASH|CF_DOTDATE|CF_LESS|CF_MORE|CF_SBB|CF_SBE,
81 | CF_FORMATCHAR = CF_ASTERISK|CF_UNDERSCORE|CF_EQUALS|CF_HASH|CF_SBB|CF_SBE,
82 | CF_NUM_SLSH = CF_NUMBER|CF_SLASH,
83 | CF_NUM_CKBX = CF_NUMBER|CF_TODO,
84 | CF_NONSPACE = CF_PUNCTUATION|CF_MARKUP|CF_ALPHA|CF_NUMBER|CF_AT|CF_TODO,
85 | CF_NONTAB = CF_NONSPACE|CF_SPACE,
86 |
87 | CF_SEPARATOR = CF_SPACE|CF_TAB|CF_NEWLINE,
88 | CF_NOT_SEPARATOR = CF_ANY^CF_SEPARATOR,
89 |
90 | CF_ALPHASPELL = CF_ALPHA|CF_SPELLCHECK
91 | };
92 |
93 | class EntryParser
94 | {
95 | public:
96 | typedef void ( EntryParser::*FPtr_void )();
97 |
98 | struct AbsChar // abstract char
99 | {
100 | AbsChar( unsigned int f, FPtr_void a, bool j = false )
101 | : flags( f ), applier( a ), junction( j ) {}
102 | unsigned int flags;
103 | FPtr_void applier;
104 | bool junction;
105 | };
106 |
107 | //EntryParser() {}
108 | virtual ~EntryParser() {}
109 |
110 | void parse( Wstring::size_type,
111 | Wstring::size_type );
112 |
113 | void set_search_str( const Wstring& );
114 |
115 | protected:
116 | virtual Wchar get_char_at( int ) = 0;
117 |
118 | void process_char( unsigned int, unsigned int,
119 | unsigned int,
120 | FPtr_void );
121 |
122 | // TRIGGERERS
123 | void trigger_subheading();
124 | void trigger_markup( unsigned int, FPtr_void );
125 | void trigger_bold();
126 | void trigger_italic();
127 | void trigger_strikethrough();
128 | void trigger_highlight();
129 | void trigger_comment();
130 | void trigger_link();
131 | void trigger_link_at();
132 | void trigger_link_date();
133 | void trigger_list();
134 | void trigger_ignore();
135 | void junction_link_date();
136 | void junction_link_hidden_tab();
137 | void junction_list();
138 | void junction_list2();
139 | void junction_date_dotym(); // dot between year and month
140 | void junction_date_dotmd(); // dot between month and day
141 | void junction_ignore();
142 |
143 | // HELPERS
144 | void handle_number();
145 | void begin_apply()
146 | {
147 | apply_regular();
148 | pos_regular = pos_current + 1;
149 | }
150 |
151 | // APPLIERS (TO BE OVERRIDEN)
152 | virtual void apply_regular() { }
153 | virtual void apply_heading() { }
154 | void apply_subheading_0(); // a temporary solution
155 | virtual void apply_subheading() { }
156 | virtual void apply_bold() { }
157 | virtual void apply_italic() { }
158 | virtual void apply_strikethrough() { }
159 | virtual void apply_highlight() { }
160 | virtual void apply_comment() { }
161 | virtual void apply_ignore() { }
162 | virtual void apply_link() { }
163 | virtual void apply_link_date() { }
164 | virtual void apply_link_id() { }
165 | void apply_check_ccl_0(); // a temporary solution
166 | virtual void apply_check_ccl() { }
167 | virtual void apply_check_unf() { }
168 | virtual void apply_check_prg() { }
169 | virtual void apply_check_fin_0(); // a temporary solution
170 | virtual void apply_check_fin() { }
171 |
172 | virtual void apply_heading_end() { }
173 | virtual void apply_subheading_end() { }
174 | virtual void apply_check_ccl_end() { }
175 | // virtual void apply_check_unf_end() { } // maybe later..
176 | virtual void apply_check_fin_end() { }
177 | // virtual void apply_ignore_end() { }
178 |
179 | virtual void apply_indent() { }
180 | virtual void apply_match() { }
181 | virtual void handle_word() { } // for spell-checking
182 |
183 | void reset( Wstring::size_type, Wstring::size_type );
184 |
185 | Wstring::size_type m_pos_start; // position of first char to process
186 | Wstring::size_type m_pos_end; // position of last char (constant)
187 | Wstring::size_type pos_current;
188 | Wstring::size_type pos_word;
189 | Wstring::size_type pos_alpha;
190 | Wstring::size_type pos_regular; // start of current regular char array
191 | Wstring::size_type pos_tab; // position of invisible link tab
192 | Wstring::size_type pos_search;
193 |
194 | unsigned int m_cf_last;
195 | unsigned int m_cf_req; // required previous char
196 | Wchar char_current;
197 | Wstring m_word_last;
198 | unsigned int m_word_count{ 0 };
199 | Wstring alpha_last; // last word consisting purely of letters
200 | unsigned int int_last{ 0 };
201 | Date date_last{ 0 };
202 | unsigned long id_last;
203 | bool m_flag_hidden_link;
204 | bool m_flag_handle_word;
205 |
206 | Wstring m_search_str;
207 |
208 | std::deque< AbsChar > m_chars_looked_for;
209 | FPtr_void m_applier_nl;
210 |
211 | private:
212 | Wstring::size_type i_search;
213 | Wstring::size_type i_search_end;
214 | };
215 |
216 | } // end of namespace LIFEO
217 |
218 | #endif
219 |
--------------------------------------------------------------------------------
/src/entry.cpp:
--------------------------------------------------------------------------------
1 | /***********************************************************************************
2 |
3 | Copyright (C) 2007-2011 Ahmet Öztürk (aoz_2@yahoo.com)
4 |
5 | This file is part of Lifeograph.
6 |
7 | Lifeograph is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | Lifeograph is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with Lifeograph. If not, see .
19 |
20 | ***********************************************************************************/
21 |
22 |
23 | #include "entry.hpp"
24 | #include "diary.hpp"
25 | #include "lifeograph.hpp"
26 | #include "strings.hpp"
27 |
28 |
29 | using namespace LIFEO;
30 |
31 |
32 | // STATIC MEMBERS
33 | ElementView< Entry >* Entry::shower( nullptr );
34 |
35 | Entry::Entry( Diary* const d, const Date::date_t date, const Ustring& text, bool favored )
36 | : DiaryElement( d, "", favored ? ES::ENTRY_DEFAULT_FAV : ES::ENTRY_DEFAULT ), m_date( date ),
37 | m_date_created( time( NULL ) ),
38 | m_date_edited( m_date_created ), m_date_status( m_date_created ),
39 | m_text( text )
40 | {
41 | calculate_title( text );
42 | }
43 |
44 | Entry::Entry( Diary* const d, const Date::date_t date, bool favored )
45 | : DiaryElement( d, _( STRING::EMPTY_ENTRY_TITLE ),
46 | favored ? ES::ENTRY_DEFAULT_FAV : ES::ENTRY_DEFAULT ),
47 | m_date( date ),
48 | m_date_created( time( NULL ) ),
49 | m_date_edited( m_date_created ), m_date_status( m_date_created ),
50 | m_text( "" )
51 | {
52 | }
53 |
54 | #ifndef LIFEO_WINDOZE
55 | const Icon&
56 | Entry::get_icon() const
57 | {
58 | switch( get_todo_status() )
59 | {
60 | case ES::TODO:
61 | return Lifeograph::icons->todo_open_16;
62 | case ES::PROGRESSED:
63 | return Lifeograph::icons->todo_progressed_16;
64 | case ES::DONE:
65 | return Lifeograph::icons->todo_done_16;
66 | case ES::CANCELED:
67 | return Lifeograph::icons->todo_canceled_16;
68 | default: // 0
69 | return Lifeograph::icons->entry_16;
70 | }
71 | }
72 | const Icon&
73 | Entry::get_icon32() const
74 | {
75 | switch( get_todo_status() )
76 | {
77 | case ES::TODO:
78 | return Lifeograph::icons->todo_open_32;
79 | case ES::PROGRESSED:
80 | return Lifeograph::icons->todo_progressed_32;
81 | case ES::DONE:
82 | return Lifeograph::icons->todo_done_32;
83 | case ES::CANCELED:
84 | return Lifeograph::icons->todo_canceled_32;
85 | default: // 0
86 | return Lifeograph::icons->entry_32;
87 | }
88 | }
89 | #else
90 | int
91 | Entry::get_icon() const
92 | {
93 | switch( get_todo_status() )
94 | {
95 | case ES::TODO:
96 | return 2;
97 | case ES::PROGRESSED:
98 | return 3;
99 | case ES::DONE:
100 | return 4;
101 | case ES::CANCELED:
102 | return 5;
103 | default: // 0
104 | return 1;
105 | }
106 | }
107 | #endif
108 |
109 | Ustring
110 | Entry::get_list_str() const
111 | {
112 | #ifndef LIFEO_WINDOZE
113 | static const Ustring tpl[] = { "%2", "%1 - %2", "%2", "%1 - %2" };
114 |
115 | int i( m_date.is_hidden() ? 0 : 1 );
116 | if( m_status & ES::CANCELED ) i += 2;
117 |
118 | Ustring tpl2 = is_trashed() ?
119 | Glib::ustring::compose( "%2",
120 | Lifeograph::s_color_insensitive, tpl[ i ] ) :
121 | tpl[ i ];
122 |
123 | return Glib::ustring::compose( tpl2, m_date.format_string(),
124 | Glib::Markup::escape_text( m_name ) );
125 | #else
126 | return( m_date.is_hidden() ? m_name : STR::compose( m_date.format_string(), " - ", m_name ) );
127 | #endif
128 | }
129 |
130 | void
131 | Entry::calculate_title( const Ustring& text )
132 | {
133 | if( text.size() < 1 )
134 | {
135 | m_name = _( STRING::EMPTY_ENTRY_TITLE );
136 | return;
137 | }
138 | unsigned int l_pos = text.find( '\n', 0 );
139 | if( l_pos == std::string::npos )
140 | m_name = text;
141 | else
142 | m_name = text.substr( 0, l_pos );
143 | }
144 |
145 |
146 | void
147 | Entry::append_text( const Ustring& text )
148 | {
149 | if( text.empty() )
150 | return;
151 |
152 | if( text[ 0 ] != '\n' )
153 | m_text += '\n';
154 |
155 | m_text += text;
156 | calculate_title( m_text );
157 | set_date_edited( time( nullptr ) );
158 | }
159 |
160 | Ustring
161 | Entry::get_date_created_str() const
162 | {
163 | return Date::format_string_dt( m_date_created );
164 | }
165 |
166 | Ustring
167 | Entry::get_date_edited_str() const
168 | {
169 | return Date::format_string_dt( m_date_edited );
170 | }
171 |
172 | Ustring
173 | Entry::get_date_status_str() const
174 | {
175 | return Date::format_string_dt( m_date_status );
176 | }
177 |
178 | std::string
179 | Entry::get_lang_final() const
180 | {
181 | return m_option_lang == LANG_INHERIT_DIARY ?
182 | m_ptr2diary->get_lang() : m_option_lang;
183 | }
184 |
185 | bool
186 | Entry::add_tag( Tag* tag, Value value )
187 | {
188 | if( tag->get_type() == ET_UNTAGGED )
189 | {
190 | return clear_tags();
191 | }
192 | else if( m_tags.add( tag ) )
193 | {
194 | tag->add_entry( this, value );
195 | m_ptr2diary->get_untagged()->erase( this );
196 |
197 | if( m_ptr2theme_tag == NULL && tag->get_has_own_theme() )
198 | m_ptr2theme_tag = tag;
199 |
200 | return true;
201 | }
202 | else
203 | return false;
204 | }
205 |
206 | bool
207 | Entry::remove_tag( Tag* tag )
208 | {
209 | if( tag == nullptr )
210 | return false;
211 |
212 | if( ! m_tags.check_for_member( tag ) )
213 | return false;
214 |
215 | m_tags.erase( tag );
216 | tag->erase( this );
217 |
218 | if( m_tags.empty() )
219 | m_ptr2diary->get_untagged()->add_entry( this );
220 |
221 | // if this tag was the theme tag, re-adjust the theme tag
222 | if( m_ptr2theme_tag == tag )
223 | {
224 | for( Tag* tag2 : m_tags )
225 | {
226 | if( tag2->get_has_own_theme() )
227 | {
228 | m_ptr2theme_tag = tag2;
229 | return true;
230 | }
231 | }
232 |
233 | m_ptr2theme_tag = nullptr;
234 | }
235 |
236 | return true;
237 | }
238 |
239 | bool
240 | Entry::clear_tags()
241 | {
242 | if( m_tags.empty() )
243 | return false;
244 |
245 | for( Tag* tag : m_tags )
246 | tag->erase( this );
247 |
248 | m_tags.clear();
249 | m_ptr2theme_tag = nullptr;
250 | m_ptr2diary->get_untagged()->add_entry( this );
251 |
252 | return true;
253 | }
254 |
255 | const Theme*
256 | Entry::get_theme() const
257 | {
258 | return( m_ptr2theme_tag ?
259 | m_ptr2theme_tag->get_theme() : m_ptr2diary->get_untagged()->get_theme() );
260 | }
261 |
262 | void
263 | Entry::set_theme_tag( const Tag* tag )
264 | {
265 | // theme tag must be in the tag set
266 | if( m_tags.check_for_member( tag ) )
267 | m_ptr2theme_tag = tag;
268 | }
269 |
270 | void
271 | Entry::update_theme()
272 | {
273 | if( m_ptr2theme_tag ) // if there already was a theme tag set
274 | {
275 | if( m_ptr2theme_tag->get_has_own_theme() == false ) // if it is no longer a theme tag
276 | m_ptr2theme_tag = nullptr;
277 | }
278 |
279 | if( m_ptr2theme_tag == nullptr )
280 | {
281 | // check if a tag has its own theme now and set it
282 | for( Tag* tag : m_tags )
283 | {
284 | if( tag->get_has_own_theme() )
285 | {
286 | m_ptr2theme_tag = tag;
287 | break;
288 | }
289 | }
290 | }
291 | }
292 |
293 | bool
294 | Entry::get_filtered_out()
295 | {
296 | const Filter* filter = m_ptr2diary->get_filter();
297 | ElemStatus fs = filter->get_status();
298 |
299 | bool flag_filteredout( m_status & ES::FILTERED_OUT );
300 |
301 | while( fs & ES::FILTER_OUTSTANDING ) // this loop is meant for a single iteration
302 | // loop used instead of if to be able to break out
303 | {
304 | flag_filteredout = !( fs & ES::FILTER_TRASHED & m_status );
305 |
306 | // no need to continue if already filtered out
307 | if( flag_filteredout )
308 | break;
309 |
310 | flag_filteredout = !( fs & ES::FILTER_FAVORED & m_status );
311 | if( flag_filteredout )
312 | break;
313 |
314 | flag_filteredout = !( fs & ES::FILTER_TODO & m_status );
315 | if( flag_filteredout )
316 | break;
317 |
318 | if( fs & ES::FILTER_DATE_BEGIN )
319 | if( m_date.m_date < filter->get_date_begin() )
320 | {
321 | flag_filteredout = true;
322 | break;
323 | }
324 |
325 | if( fs & ES::FILTER_DATE_END )
326 | if( m_date.m_date > filter->get_date_end() )
327 | {
328 | flag_filteredout = true;
329 | break;
330 | }
331 |
332 | if( fs & ES::FILTER_TAG )
333 | {
334 | if( filter->get_tag()->get_type() == DiaryElement::ET_TAG )
335 | {
336 | if( ! m_tags.check_for_member( filter->get_tag() ) )
337 | {
338 | flag_filteredout = true;
339 | break;
340 | }
341 | }
342 | else // untagged
343 | {
344 | if( ! m_tags.empty() )
345 | {
346 | flag_filteredout = true;
347 | break;
348 | }
349 | }
350 | }
351 |
352 | if( fs & ES::FILTER_INDIVIDUAL )
353 | {
354 | if( filter->is_entry_filtered( this ) )
355 | {
356 | flag_filteredout = true;
357 | break;
358 | }
359 | }
360 |
361 | if( m_ptr2diary->is_search_active() )
362 | #ifndef LIFEO_WINDOZE
363 | flag_filteredout = ( m_text.lowercase().find( m_ptr2diary->get_search_text() )
364 | == std::string::npos );
365 | #else
366 | flag_filteredout = ( m_text.find( m_ptr2diary->get_search_text() )
367 | == std::string::npos );
368 | #endif
369 |
370 | break;
371 | }
372 |
373 | if( fs & ES::FILTER_OUTSTANDING )
374 | set_filtered_out( flag_filteredout );
375 |
376 | return flag_filteredout;
377 | }
378 |
379 | void
380 | Entry::show()
381 | {
382 | if( shower != NULL )
383 | shower->show( *this );
384 | else
385 | PRINT_DEBUG( "Entry has no graphical data!" );
386 | }
387 |
388 | void
389 | Entry::prepare_for_hiding()
390 | {
391 | if( shower != NULL )
392 | shower->prepare_for_hiding( *this );
393 | else
394 | PRINT_DEBUG( "Entry has no graphical data!" );
395 | }
396 |
397 | // ENTRY SET =======================================================================================
398 | PoolEntries::~PoolEntries()
399 | {
400 | for( iterator iter = begin(); iter != end(); ++iter )
401 | delete iter->second;
402 | }
403 |
404 | void
405 | PoolEntries::clear()
406 | {
407 | for( iterator iter = begin(); iter != end(); ++iter )
408 | delete iter->second;
409 |
410 | std::map< Date::date_t, Entry*, FuncCompareDates >::clear();
411 | }
412 |
--------------------------------------------------------------------------------
/src/win_richedit.hpp:
--------------------------------------------------------------------------------
1 | /***********************************************************************************
2 |
3 | Copyright (C) 2014-2016 Ahmet Ozturk (aoz_2@yahoo.com)
4 |
5 | This file is part of Lifeograph.
6 |
7 | Lifeograph is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | Lifeograph is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with Lifeograph. If not, see .
19 |
20 | ***********************************************************************************/
21 |
22 |
23 | #ifndef LIFEOGRAPH_WIN_RICHEDIT_HEADER
24 | #define LIFEOGRAPH_WIN_RICHEDIT_HEADER
25 |
26 |
27 | #include
28 | #include
29 |
30 | #include "helpers.hpp"
31 | #include "diarydata.hpp"
32 | #include "entry.hpp"
33 | #include "entry_parser.hpp"
34 |
35 |
36 | namespace LIFEO
37 | {
38 |
39 | const int UNDO_MERGE_TIMEOUT = 3;
40 |
41 | enum LinkStatus
42 | {
43 | LS_OK,
44 | LS_ENTRY_UNAVAILABLE,
45 | LS_INVALID, // separator: to check a valid entry link: linkstatus < LS_INVALID
46 | LS_CYCLIC,
47 |
48 | LS_FILE_OK,
49 | LS_FILE_INVALID,
50 | LS_FILE_UNAVAILABLE,
51 | LS_FILE_UNKNOWN
52 | };
53 |
54 | // LINKS ===========================================================================================
55 | /*class Link
56 | {
57 | public:
58 | enum LinkType
59 | {
60 | LT_NONE, LT_ID, LT_ENTRY, LT_URI, LT_CHECK, LT_IMAGE
61 | };
62 |
63 | virtual ~Link();
64 | virtual void go() = 0;
65 |
66 | // position of link in the buffer:
67 | Glib::RefPtr< Gtk::TextMark >
68 | m_mark_start;
69 | Glib::RefPtr< Gtk::TextMark >
70 | m_mark_end;
71 |
72 | const LinkType type;
73 |
74 | protected:
75 | Link( const Glib::RefPtr< Gtk::TextMark >&,
76 | const Glib::RefPtr< Gtk::TextMark >&,
77 | LinkType );
78 | };
79 |
80 | class LinkID : public Link
81 | {
82 | public:
83 | typedef sigc::signal< void, Date >
84 | Signal_void_Date;
85 |
86 | LinkID( const Glib::RefPtr< Gtk::TextMark >&,
87 | const Glib::RefPtr< Gtk::TextMark >&,
88 | DEID );
89 | void go();
90 |
91 | static Signal_void_Date signal_activated()
92 | { return m_signal_activated; }
93 |
94 | DEID m_id;
95 |
96 | protected:
97 | static Signal_void_Date m_signal_activated;
98 | };
99 |
100 | class LinkEntry : public Link
101 | {
102 | public:
103 | LinkEntry( const Glib::RefPtr< Gtk::TextMark >&,
104 | const Glib::RefPtr< Gtk::TextMark >&,
105 | Date );
106 | void go();
107 |
108 | Date m_date;
109 |
110 | protected:
111 | static Gtk::Menu* menu_link;
112 | };
113 |
114 | class LinkUri : public Link
115 | {
116 | public:
117 | LinkUri( const Glib::RefPtr< Gtk::TextMark >&,
118 | const Glib::RefPtr< Gtk::TextMark >&,
119 | const std::string& );
120 | void go();
121 |
122 | std::string m_url;
123 | static Gtk::TextBuffer* m_ptr2buffer;
124 | };
125 |
126 | class LinkCheck : public Link
127 | {
128 | public:
129 | LinkCheck( const Glib::RefPtr< Gtk::TextMark >&,
130 | const Glib::RefPtr< Gtk::TextMark >&,
131 | unsigned int = 0 );
132 | void go();
133 |
134 | static const Glib::ustring boxes;
135 | unsigned int m_state_index;
136 | };
137 |
138 | class InlineImage
139 | {
140 | public:
141 | InlineImage( const Glib::RefPtr< Gtk::TextMark >& );
142 | ~InlineImage();
143 |
144 | Glib::RefPtr< Gtk::TextMark > m_mark;
145 | };*/
146 |
147 | // TEXTBUFFER ======================================================================================
148 | class RichEdit : public EntryParser
149 | {
150 | public:
151 | static const int LEFT_MARGIN = 10;
152 |
153 |
154 | typedef void ( RichEdit::*ParsingApplierFn )();
155 |
156 | RichEdit();
157 |
158 | void handle_logout();
159 | void handle_login();
160 |
161 | // Link* get_link( LONG ) const;
162 | // Link* get_link( LONG ) const;
163 |
164 | void set_richtext( Entry* );
165 | LONG get_length();
166 | Wstring get_text();
167 |
168 | void set_search_str( const Wstring& );
169 | bool select_searchstr_previous();
170 | bool select_searchstr_next();
171 |
172 | void toggle_format( CHARFORMAT2&, const Wstring& );
173 | void toggle_bold();
174 | void toggle_italic();
175 | void toggle_highlight();
176 | void toggle_strikethrough();
177 |
178 | void calculate_para_bounds( const Wstring&,
179 | Wstring::size_type&,
180 | Wstring::size_type& );
181 | bool calculate_multi_para_bounds( Wstring::size_type&,
182 | Wstring::size_type& );
183 | void handle_indent();
184 | void handle_unindent();
185 |
186 | void set_list_item_mark( char );
187 | void add_empty_line_above();
188 | void remove_empty_line_above();
189 | void move_line_up();
190 | void move_line_down();
191 | void insert_link( DiaryElement* );
192 | void insert_time_stamp();
193 | std::string set_language( std::string );
194 |
195 | void set_theme( const Theme* );
196 |
197 | void reparse();
198 |
199 | COLORREF midcontrast( const Theme*, const COLORREF );
200 |
201 | void handle_right_click();
202 | void handle_change();
203 | bool handle_space();
204 | bool handle_new_line();
205 |
206 | HWND m_hwnd;
207 |
208 | protected:
209 | // PARSING
210 | void parse( LONG, LONG );
211 |
212 | void apply_heading();
213 | void apply_subheading();
214 | void apply_bold();
215 | void apply_italic();
216 | void apply_strikethrough();
217 | void apply_highlight();
218 | void apply_comment();
219 | void apply_ignore();
220 | /* void apply_link();
221 | void apply_link_date();
222 | void apply_link_id();*/
223 | void apply_check( CHARFORMAT2&, CHARFORMAT2*, int );
224 | void apply_check_ccl();
225 | void apply_check_unf();
226 | void apply_check_prg();
227 | void apply_check_fin();
228 | void apply_match();
229 | // void apply_indent();
230 |
231 | void apply_markup( CHARFORMAT2& );
232 |
233 | Wchar get_char_at( int );
234 |
235 | Wstring::size_type parser_open_tag_begin;
236 | Wstring::size_type parser_open_tag_end;
237 | bool parser_open_tag_is_link;
238 | Wstring::size_type parser_offset_insert_prev;
239 |
240 | // LINKS
241 | void clear_links( LONG, LONG );
242 | void clear_links();
243 |
244 | void clear_images( LONG, LONG& );
245 | void clear_images();
246 | //bool update_thumbnail_width( int );
247 |
248 | void apply_format( CHARFORMAT2&, LONG, LONG );
249 | void remove_all_formats( LONG, LONG );
250 |
251 | // FORMATS
252 | CHARFORMAT2 m_format_default;
253 | CHARFORMAT2 m_format_heading;
254 | CHARFORMAT2 m_format_subheading;
255 | CHARFORMAT2 m_format_match;
256 | CHARFORMAT2 m_format_markup;
257 | CHARFORMAT2 m_format_markup_link;
258 | CHARFORMAT2 m_format_hidden;
259 | CHARFORMAT2 m_format_bold;
260 | CHARFORMAT2 m_format_italic;
261 | CHARFORMAT2 m_format_strikethrough;
262 | CHARFORMAT2 m_format_highlight;
263 | CHARFORMAT2 m_format_comment;
264 | CHARFORMAT2 m_format_region;
265 | CHARFORMAT2 m_format_link;
266 | CHARFORMAT2 m_format_link_broken;
267 | CHARFORMAT2 m_format_link_hidden;
268 | CHARFORMAT2 m_format_checkbox;
269 | CHARFORMAT2 m_format_image;
270 | CHARFORMAT2 m_format_misspelled;
271 | CHARFORMAT2 m_format_done;
272 | CHARFORMAT2 m_format_checkbox_todo;
273 | CHARFORMAT2 m_format_checkbox_progressed;
274 | CHARFORMAT2 m_format_checkbox_done;
275 | CHARFORMAT2 m_format_checkbox_canceled;
276 |
277 | // OTHER VARIABLES
278 | bool m_flag_settextoperation;
279 | int m_flag_ongoing_operation; // Incremental to allow nesting
280 | bool m_flag_parsing;
281 | Entry* m_ptr2entry;
282 |
283 | private:
284 | //bool m_flag_size_allocated;
285 | //bool m_flag_set_text_queued;
286 | };
287 |
288 | } // end of namespace LIFEO
289 |
290 | #endif
291 |
--------------------------------------------------------------------------------
/src/lifeograph.cpp:
--------------------------------------------------------------------------------
1 | /***********************************************************************************
2 |
3 | Copyright (C) 2007-2015 Ahmet Öztürk (aoz_2@yahoo.com)
4 |
5 | This file is part of Lifeograph.
6 |
7 | Lifeograph is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | Lifeograph is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with Lifeograph. If not, see .
19 |
20 | ***********************************************************************************/
21 |
22 |
23 | #include
24 |
25 | #include "lifeograph.hpp"
26 | #include "win_app_window.hpp"
27 | #ifndef LIFEO_WINDOZE
28 | #include "dialog_preferences.hpp"
29 | #else
30 | #include "win_wao.hpp"
31 | #endif
32 | #include "helpers.hpp"
33 |
34 | #if LIFEOGRAPH_DEBUG_BUILD
35 | #include
36 | #endif
37 |
38 |
39 | using namespace LIFEO;
40 |
41 | // STATIC MEMBERS
42 | const char Lifeograph::PROGRAM_VERSION_STRING[] = "0.5.0.beta3"
43 | #if LIFEOGRAPH_DEBUG_BUILD
44 | "\n" BUILD_TIMESTAMP
45 | #endif
46 | ;
47 |
48 | Lifeograph* Lifeograph::p;
49 | Settings Lifeograph::settings;
50 | Icons* Lifeograph::icons = NULL;
51 | #ifndef LIFEO_WINDOZE
52 | Glib::RefPtr< Gtk::Builder > Lifeograph::builder;
53 | Glib::RefPtr< Gtk::ActionGroup > Lifeograph::m_actions_read;
54 | Glib::RefPtr< Gtk::ActionGroup > Lifeograph::m_actions_edit;
55 | EnchantBroker* Lifeograph::s_enchant_broker = NULL;
56 | SignalVoid Lifeograph::s_signal_logout;
57 | #endif
58 | Lifeograph::LoginStatus Lifeograph::loginstatus = Lifeograph::LOGGED_OUT;
59 | std::set< std::string > Lifeograph::stock_diaries;
60 | #ifndef LIFEO_WINDOZE
61 | DiaryElement* Lifeograph::s_elem_dragged = NULL;
62 | bool Lifeograph::s_flag_dragging = false;
63 | LanguageList Lifeograph::s_lang_list;
64 | std::string Lifeograph::s_color_insensitive;
65 | #else
66 | HINSTANCE Lifeograph::hInst = 0;
67 | #endif
68 | int Lifeograph::m_internaloperation = 0;
69 |
70 | // CONSTRUCTOR
71 | Lifeograph::Lifeograph()
72 | :
73 | #ifndef LIFEO_WINDOZE
74 | Gtk::Application( "lifeograph.app",
75 | Gio::APPLICATION_NON_UNIQUE | Gio::APPLICATION_HANDLES_COMMAND_LINE ),
76 | #endif
77 | m_flag_force_welcome( false ), m_flag_open_directly( false ),
78 | m_flag_read_only( false )
79 | {
80 | p = this;
81 |
82 | #ifndef LIFEO_WINDOZE
83 | Glib::set_application_name( LIFEO::PROGRAM_NAME );
84 | if( Glib::file_test( PIXMAPDIR "/lifeograph.png", Glib::FILE_TEST_EXISTS ) )
85 | Gtk::Window::set_default_icon_from_file( PIXMAPDIR "/lifeograph.png" );
86 |
87 | m_actions_read = Gtk::ActionGroup::create( "read actions" );
88 | m_actions_edit = Gtk::ActionGroup::create( "edit actions" );
89 |
90 | m_actions_read->set_sensitive( false );
91 | m_actions_edit->set_sensitive( false );
92 |
93 | drag_targets_tag.push_back( Gtk::TargetEntry( TARGET_ENTRY_TAG,
94 | Gtk::TARGET_SAME_APP,
95 | DiaryElement::ET_TAG ) );
96 | drag_targets_entry.push_back( Gtk::TargetEntry( TARGET_ENTRY_ENTRY,
97 | Gtk::TARGET_SAME_APP,
98 | DiaryElement::ET_ENTRY ) );
99 | #endif
100 |
101 | icons = new Icons;
102 | }
103 |
104 | Lifeograph::~Lifeograph()
105 | {
106 | #ifndef LIFEO_WINDOZE
107 | if( s_enchant_broker )
108 | {
109 | enchant_broker_free( s_enchant_broker );
110 | s_enchant_broker = NULL;
111 | }
112 | #endif
113 | }
114 |
115 | #ifndef LIFEO_WINDOZE
116 | Glib::RefPtr< Lifeograph >
117 | Lifeograph::create()
118 | {
119 | return Glib::RefPtr< Lifeograph >( new Lifeograph );
120 | }
121 | #else
122 | int
123 | Lifeograph::run( HINSTANCE hInstance, LPSTR cmdline )
124 | {
125 | int argc;
126 | char** argv = command_line_to_argvA( cmdline, &argc );
127 |
128 | on_startup();
129 | on_command_line( argc, argv );
130 |
131 | LocalFree( argv );
132 | new WinAppWindow;
133 | hInst = hInstance;
134 | return WinAppWindow::p->run();
135 | }
136 | #endif
137 |
138 | bool
139 | Lifeograph::quit()
140 | {
141 | PRINT_DEBUG( "Lifeograph::quit()" );
142 |
143 | if( loginstatus == LOGGED_IN )
144 | if( ! WinAppWindow::p->finish_editing() )
145 | return false;
146 |
147 | #ifndef LIFEO_WINDOZE
148 | // SAVE SETTINGS
149 | AppWindow::p->get_size( settings.width, settings.height );
150 | AppWindow::p->get_position( settings.position_x, settings.position_y );
151 | settings.state_maximized = (
152 | AppWindow::p->get_window()->get_state() & Gdk::WINDOW_STATE_MAXIMIZED );
153 |
154 | settings.write();
155 | #endif
156 | return true;
157 | }
158 |
159 | void
160 | Lifeograph::on_startup()
161 | {
162 | #ifndef LIFEO_WINDOZE
163 | Gtk::Application::on_startup();
164 | #else
165 | WAO_init();
166 | #endif
167 |
168 | // SETTINGS
169 | Lifeograph::settings.read();
170 |
171 | #ifndef LIFEO_WINDOZE
172 | // ENCHANT
173 | s_enchant_broker = enchant_broker_init();
174 | enchant_broker_list_dicts( s_enchant_broker, fill_lang_list_cb, NULL );
175 |
176 | // APP MENU
177 | Glib::RefPtr< Gio::SimpleAction > action_prefs = Gio::SimpleAction::create( "preferences" );
178 | action_prefs->signal_activate().connect( sigc::ptr_fun( &appmenu_preferences ) );
179 | add_action( action_prefs );
180 |
181 | Glib::RefPtr< Gio::SimpleAction > action_about = Gio::SimpleAction::create( "about" );
182 | action_about->signal_activate().connect( sigc::ptr_fun( &appmenu_about ) );
183 | add_action( action_about );
184 |
185 | Glib::RefPtr< Gio::SimpleAction > action_quit = Gio::SimpleAction::create( "quit" );
186 | action_quit->signal_activate().connect( sigc::ptr_fun( &appmenu_quit ) );
187 | add_action( action_quit );
188 |
189 | m_menu = Gio::Menu::create();
190 | m_menu->append( _( "Preferences" ), "app.preferences" );
191 | m_menu->append( _( "About Lifeograph" ), "app.about" );
192 | m_menu->append( _( "Quit" ), "app.quit" );
193 |
194 | set_app_menu( m_menu );
195 | #endif
196 | }
197 |
198 | #ifndef LIFEO_WINDOZE
199 | void
200 | Lifeograph::on_activate()
201 | {
202 | add_window( *( new AppWindow ) );
203 | AppWindow::p->show();
204 | }
205 | #endif
206 |
207 | int
208 | #ifndef LIFEO_WINDOZE
209 | Lifeograph::on_command_line( const Glib::RefPtr< Gio::ApplicationCommandLine >& cmd_line )
210 | {
211 | int argc;
212 | char** argv( cmd_line->get_arguments( argc ) );
213 |
214 | for( int i = 1; i < argc; i++ )
215 |
216 | #else
217 | Lifeograph::on_command_line( int argc, char** argv )
218 | {
219 | for( int i = 0; i < argc; i++ )
220 | #endif
221 |
222 | {
223 | if( ! strcmp( argv[ i ], "--open" ) || ! strcmp( argv[ i ], "-o" ) )
224 | {
225 | if( ( i + 1 ) < argc )
226 | {
227 | if( access( argv[ ++i ], F_OK ) == 0 ) // check existance
228 | {
229 | if( ! is_dir( argv[ i ] ) )
230 | {
231 | WinAppWindow::p->m_login->m_path_cur = argv[ i ];
232 | m_flag_open_directly = true;
233 | }
234 | }
235 | if( ! m_flag_open_directly )
236 | Error( "File cannot be opened" );
237 | }
238 | else
239 | Error( "No path provided" );
240 | }
241 | else
242 | if( ! strcmp( argv[ i ], "--force-welcome" ) )
243 | {
244 | m_flag_force_welcome = true;
245 | }
246 | else
247 | if( ! strcmp( argv[ i ], "--ignore-locks" ) )
248 | {
249 | Diary::s_flag_ignore_locks = true;
250 | }
251 | else
252 | if( ! strcmp( argv[ i ], "--read-only" ) || ! strcmp( argv[ i ], "-r" ) )
253 | {
254 | m_flag_read_only = true;
255 | }
256 | else
257 | if( access( argv[ i ], F_OK ) == 0 && ! is_dir( argv[ i ] ) )
258 | {
259 | WinAppWindow::p->m_login->m_path_cur = argv[ i ];
260 | m_flag_open_directly = true;
261 | }
262 | else
263 | {
264 | print_info( std::string( "Unrecognized argument: " ) + argv[ i ] );
265 | }
266 | }
267 |
268 | #ifndef LIFEO_WINDOZE
269 | activate();
270 | #endif
271 |
272 | return 0;
273 | }
274 |
275 | #ifndef LIFEO_WINDOZE
276 | bool
277 | Lifeograph::load_gui( const std::string& path )
278 | {
279 | builder = Gtk::Builder::create();
280 | try
281 | {
282 | builder->add_from_file( path );
283 | }
284 | catch( const Glib::FileError& ex )
285 | {
286 | print_error( "FileError: " + ex.what() );
287 | return false;
288 | }
289 | catch( const Gtk::BuilderError& ex )
290 | {
291 | print_error( "BuilderError: " + ex.what() );
292 | return false;
293 | }
294 |
295 | return true;
296 | }
297 |
298 | // ACTIONS
299 | void
300 | Lifeograph::create_action( bool flag_edit,
301 | Glib::RefPtr< Gtk::Action >& action,
302 | const Glib::ustring& name,
303 | const Glib::ustring& label,
304 | const Glib::ustring& tooltip,
305 | const Gtk::AccelKey& accelkey,
306 | const Glib::SignalProxy0< void >::SlotType&
307 | slot,
308 | Gtk::Activatable* widget_proxy )
309 | {
310 | action = Gtk::Action::create( name, label, tooltip );
311 |
312 | if( flag_edit )
313 | m_actions_edit->add( action, accelkey );
314 | else
315 | m_actions_read->add( action, accelkey );
316 | action->set_accel_group( AppWindow::p->get_accel_group() );
317 | action->connect_accelerator();
318 | if( widget_proxy != NULL )
319 | widget_proxy->set_related_action( action );
320 | action->signal_activate().connect( slot );
321 | }
322 |
323 | void
324 | Lifeograph::create_toggle_action( bool flag_edit,
325 | Glib::RefPtr< Gtk::ToggleAction >& action,
326 | const Glib::ustring& name,
327 | const Glib::ustring& label,
328 | const Glib::ustring& tooltip,
329 | const Gtk::AccelKey& accelkey,
330 | const Glib::SignalProxy0< void >::SlotType&
331 | slot,
332 | Gtk::Activatable* widget_proxy )
333 | {
334 | action = Gtk::ToggleAction::create( name, label, tooltip );
335 |
336 | if( flag_edit )
337 | m_actions_edit->add( action, accelkey );
338 | else
339 | m_actions_read->add( action, accelkey );
340 | action->set_accel_group( AppWindow::p->get_accel_group() );
341 | action->connect_accelerator();
342 | if( widget_proxy != NULL )
343 | widget_proxy->set_related_action( action );
344 | action->signal_activate().connect( slot );
345 | }
346 |
347 | Glib::RefPtr< Gdk::Pixbuf >
348 | Lifeograph::get_thumbnail( const std::string& path, int width )
349 | {
350 | Glib::RefPtr< Gdk::Pixbuf > buf;
351 | MapPixbufs::iterator iter( p->map_thumbnails.find( path ) );
352 |
353 | if( iter == p->map_thumbnails.end() )
354 | {
355 | buf = Gdk::Pixbuf::create_from_file( path );
356 | p->map_thumbnails[ path ] = buf;
357 | }
358 | else
359 | buf = iter->second;
360 |
361 | if( buf->get_width() > width )
362 | return buf->scale_simple( width,
363 | ( buf->get_height() * width ) / buf->get_width(),
364 | Gdk::INTERP_BILINEAR );
365 | else
366 | return buf;
367 | }
368 |
369 | // DIALOGEVENT =====================================================================================
370 | HELPERS::DialogEvent::DialogEvent( const Glib::ustring& title )
371 | : Gtk::Dialog( title )
372 | {
373 | set_transient_for( *AppWindow::p );
374 | Lifeograph::signal_logout().connect( sigc::mem_fun( this, &DialogEvent::handle_logout ) );
375 | }
376 |
377 | HELPERS::DialogEvent::DialogEvent( BaseObjectType* cobject,
378 | const Glib::RefPtr< Gtk::Builder >& )
379 | : Gtk::Dialog( cobject )
380 | {
381 | set_transient_for( * AppWindow::p );
382 | //Lifeograph::signal_logout().connect( sigc::mem_fun( this, &DialogEvent::handle_logout ) );
383 | }
384 |
385 | bool
386 | HELPERS::DialogEvent::on_event( GdkEvent* e )
387 | {
388 | AppWindow::p->on_event( e );
389 | return false;
390 | }
391 | #endif
392 |
--------------------------------------------------------------------------------
/src/diary.hpp:
--------------------------------------------------------------------------------
1 | /***********************************************************************************
2 |
3 | Copyright (C) 2007-2011 Ahmet Öztürk (aoz_2@yahoo.com)
4 |
5 | This file is part of Lifeograph.
6 |
7 | Lifeograph is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | Lifeograph is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with Lifeograph. If not, see .
19 |
20 | ***********************************************************************************/
21 |
22 |
23 | #ifndef LIFEOGRAPH_DIARY_HEADER
24 | #define LIFEOGRAPH_DIARY_HEADER
25 |
26 |
27 | #include "helpers.hpp" // i18n headers
28 | #include "diarydata.hpp"
29 | #include "entry.hpp"
30 |
31 |
32 | namespace LIFEO
33 | {
34 |
35 | const char DB_FILE_HEADER[] = "LIFEOGRAPHDB";
36 | const int DB_FILE_VERSION_INT{ 1040 };
37 | const int DB_FILE_VERSION_INT_MIN( 110 );
38 | const std::string::size_type PASSPHRASE_MIN_SIZE( 4 );
39 | const char LOCK_SUFFIX[] = ".~LOCK~";
40 |
41 |
42 | class Diary : public DiaryElement, public DiaryElementChart
43 | {
44 | public:
45 | static ElementView< Diary >* shower;
46 |
47 | enum SetPathType { SPT_NORMAL, SPT_READ_ONLY, SPT_NEW };
48 |
49 | Diary();
50 | ~Diary();
51 |
52 | static Diary* d;
53 |
54 | bool is_old()
55 | { return( m_read_version < DB_FILE_VERSION_INT ); }
56 |
57 | Result init_new( const std::string& );
58 |
59 | // DISK I/O
60 | LIFEO::Result read_body();
61 | LIFEO::Result read_header();
62 |
63 | LIFEO::Result write();
64 | LIFEO::Result write( const std::string& );
65 | LIFEO::Result write_copy( const std::string&, const std::string&, bool );
66 | LIFEO::Result write_txt( const std::string&, bool );
67 |
68 | virtual void clear();
69 |
70 | int get_size() const override
71 | { return m_entries.size(); }
72 | Type get_type() const override
73 | { return ET_DIARY; }
74 |
75 | #ifndef LIFEO_WINDOZE
76 | const Icon& get_icon() const override;
77 | const Icon& get_icon32() const override;
78 | #else
79 | int get_icon() const;
80 | #endif
81 |
82 | Ustring get_list_str() const override
83 | #ifndef LIFEO_WINDOZE
84 | { return Glib::ustring::compose( "%1", Glib::Markup::escape_text( m_name ) ); }
85 | #else
86 | { return m_name; }
87 | #endif
88 |
89 | LIFEO::Result set_path( const std::string&, SetPathType );
90 | const std::string& get_path() const;
91 | bool is_path_set() const;
92 |
93 | bool set_passphrase( const std::string& );
94 | void clear_passphrase();
95 | std::string get_passphrase() const;
96 | bool compare_passphrase( const std::string& ) const;
97 | bool is_passphrase_set() const;
98 |
99 | bool is_read_only() const
100 | { return m_flag_read_only; }
101 |
102 | DiaryElement* get_element( DEID ) const;
103 | DiaryElement* get_startup_elem() const;
104 | void set_startup_elem( const DEID );
105 | DiaryElement* get_most_current_elem() const;
106 | DiaryElement* get_prev_session_elem() const;
107 | void set_last_elem( const DiaryElement* );
108 |
109 | bool is_first( const Entry* const ) const;
110 | bool is_last( const Entry* const ) const;
111 | SortingCriteria get_sorting_criteria() const
112 | { return m_option_sorting_criteria; }
113 | void set_sorting_criteria( SortingCriteria sc )
114 | { m_option_sorting_criteria = sc; }
115 |
116 | std::string get_lang() const { return m_language; }
117 | void set_lang( const std::string& lang ) { m_language = lang; }
118 |
119 | DEID create_new_id( DiaryElement* element )
120 | {
121 | DEID retval;
122 | if( m_force_id == DEID_UNSET )
123 | retval = m_current_id;
124 | else
125 | {
126 | retval = m_force_id;
127 | m_force_id = DEID_UNSET;
128 | }
129 | m_ids[ retval ] = element;
130 |
131 | while( m_ids.find( m_current_id ) != m_ids.end() )
132 | m_current_id++;
133 |
134 | return retval;
135 | }
136 | void erase_id( DEID id ) { m_ids.erase( id ); }
137 | bool set_force_id( DEID id )
138 | {
139 | if( m_ids.find( id ) != m_ids.end() || id <= DEID_DIARY )
140 | return false;
141 | m_force_id = id;
142 | return true;
143 | }
144 |
145 | int get_time_span() const;
146 | void fill_up_chart_points( ChartPoints* ) const;
147 |
148 | // FILTERING
149 | void set_search_text( const Ustring& );
150 | Ustring get_search_text() const
151 | { return m_search_text; }
152 | bool is_search_active() const
153 | { return( m_search_text.empty() == false ); }
154 | int replace_text( const Ustring& );
155 |
156 | Filter* get_filter()
157 | { return m_filter_active; }
158 | Filter* get_filter_default()
159 | { return m_filter_default; }
160 | void set_filter_tag( const Tag* tag )
161 | { m_filter_active->set_tag( tag ); }
162 | const Tag* get_filter_tag() const
163 | { return m_filter_active->get_tag(); }
164 | Date::date_t get_filter_date_begin()
165 | { return m_filter_active->get_date_begin(); }
166 | Date::date_t get_filter_date_end()
167 | { return m_filter_active->get_date_end(); }
168 | void set_filter_date_begin( Date::date_t d )
169 | { m_filter_active->set_date_begin( d ); }
170 | void set_filter_date_end( Date::date_t d )
171 | { m_filter_active->set_date_end( d ); }
172 |
173 | ElemStatus get_filter_status() const
174 | { return m_filter_active->get_status(); }
175 |
176 | // ENTRIES
177 | Entry* get_entry( const Date::date_t, bool=false );
178 | EntryVector* get_entries( Date::date_t );
179 | PoolEntries& get_entries()
180 | { return m_entries; }
181 | bool get_day_has_multiple_entries( const Date& );
182 | Entry* get_entry_today();
183 | Entry* get_entry_next_in_day( const Date& );
184 | Entry* get_entry_first();
185 | Entry* get_entry_latest() const; // get last temporal entry
186 | void set_entry_date( Entry*, const Date& );
187 | Entry* create_entry( Date::date_t, const Ustring& = "",
188 | bool = false );
189 | // adds a new entry to today even if there is already one or more:
190 | Entry* add_today();
191 | virtual bool dismiss_entry( Entry* );
192 | bool make_free_entry_order( Date& ) const;
193 |
194 | // TAGS
195 | PoolTags* get_tags()
196 | { return &m_tags; }
197 | PoolCategoriesTags* get_tag_categories()
198 | { return &m_tag_categories; }
199 | CategoryTags* create_tag_ctg();
200 | CategoryTags* create_tag_ctg( const Ustring& );
201 | void dismiss_tag_ctg( CategoryTags*, bool = false );
202 | Tag* create_tag( const Ustring&, CategoryTags*,
203 | int = ChartPoints::MONTHLY|ChartPoints::BOOLEAN );
204 | void dismiss_tag( Tag*, bool = false );
205 | Untagged* get_untagged()
206 | { return &m_untagged; }
207 |
208 | // CHAPTERS
209 | CategoryChapters* get_current_chapter_ctg()
210 | { return m_ptr2chapter_ctg_cur; }
211 | void set_current_chapter_ctg( CategoryChapters* ctg )
212 | {
213 | m_ptr2chapter_ctg_cur = ctg;
214 | update_entries_in_chapters();
215 | }
216 | CategoryChapters* create_chapter_ctg();
217 | CategoryChapters* create_chapter_ctg( const Ustring& );
218 | void dismiss_chapter_ctg( CategoryChapters* );
219 | bool rename_chapter_ctg( CategoryChapters*, const Ustring& );
220 | void dismiss_chapter( Chapter*, bool = false );
221 | CategoryChapters* get_topics()
222 | { return m_topics; }
223 | CategoryChapters* get_groups()
224 | { return m_groups; }
225 | void update_entries_in_chapters();
226 | void add_entry_to_related_chapter( Entry* );
227 | void remove_entry_from_chapters( Entry* );
228 | void set_topic_order( Chapter*, Date::date_t );
229 | Chapter* get_orphans()
230 | { return &m_orphans; }
231 |
232 | //Date get_free_chapter_order_temporal();
233 |
234 | bool is_encrypted() const
235 | { return( ! m_passphrase.empty() ); }
236 |
237 | ChartPoints* create_chart_data() const override;
238 | void show() override;
239 |
240 | bool import_tag( Tag* );
241 | bool import_entries( const Diary&, bool, const Ustring& );
242 | bool import_chapters( const Diary& );
243 |
244 | static bool s_flag_ignore_locks;
245 |
246 | protected:
247 | // IDS (must be first)
248 | PoolDEIDs m_ids;
249 | DEID m_current_id = DEID_FIRST;
250 | DEID m_force_id = DEID_UNSET;
251 | DEID m_startup_elem_id = HOME_CURRENT_ELEM;
252 | DEID m_last_elem_id = DEID_DIARY;
253 | // PROPERTIES
254 | std::string m_path;
255 | std::string m_passphrase;
256 | std::string m_language;
257 | // CONTENT
258 | PoolEntries m_entries;
259 | Untagged m_untagged; // pseudo tag "untagged"
260 | PoolTags m_tags;
261 | PoolCategoriesTags m_tag_categories;
262 | PoolCategoriesChapters m_chapter_categories;
263 | CategoryChapters* m_ptr2chapter_ctg_cur{ nullptr };
264 | CategoryChapters* m_topics; // ordinal chapters
265 | CategoryChapters* m_groups; // chapters with invisible order
266 | // entries that remain out of defined chapters:
267 | Chapter m_orphans{ nullptr, "", Date::DATE_MAX };
268 | // OPTIONS & FLAGS
269 | SortingCriteria m_option_sorting_criteria{ SC_DATE};
270 | int m_read_version{ 0 };
271 | bool m_flag_only_save_filtered{ false };
272 | bool m_flag_read_only{ false };
273 | // FILTERING
274 | Ustring m_search_text;
275 | Filter* m_filter_active;
276 | Filter* m_filter_default;
277 | // TODO FilterVector m_filters; // user defined filters
278 |
279 | LIFEO::Result parse_db_body_text( std::istream& );
280 | LIFEO::Result parse_db_body_text_1040( std::istream& );
281 | LIFEO::Result parse_db_body_text_1010( std::istream& );
282 | LIFEO::Result parse_db_body_text_110( std::istream& );
283 |
284 | void upgrade_entries();
285 |
286 | void do_standard_checks_after_parse();
287 |
288 | bool create_db_body_text( std::stringstream& );
289 | //bool create_db_header_text( std::stringstream&, bool );
290 | //void create_db_tag_text( char, const Tag*, std::stringstream& );
291 |
292 | void close_file();
293 | LIFEO::Result read_plain();
294 | LIFEO::Result read_encrypted();
295 | LIFEO::Result write_plain( const std::string&, bool = false );
296 | LIFEO::Result write_encrypted( const std::string& );
297 |
298 | bool remove_lock();
299 |
300 | private:
301 | std::ifstream* m_ifstream{ nullptr };
302 |
303 | friend class EntryView;
304 | friend class DiaryView;
305 | friend class TagView;
306 | friend class CategoryTagsView;
307 | friend class ThemeView;
308 | friend class PanelDiary;
309 | friend class PanelExtra;
310 | friend class WidgetPanelExp;
311 | friend class DialogImport;
312 | };
313 |
314 | } // end of namespace LIFEO
315 |
316 | #endif
317 |
318 |
--------------------------------------------------------------------------------
/src/entry_parser.cpp:
--------------------------------------------------------------------------------
1 | /***********************************************************************************
2 |
3 | Copyright (C) 2007-2012 Ahmet Öztürk (aoz_2@yahoo.com)
4 |
5 | This file is part of Lifeograph.
6 |
7 | Lifeograph is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | Lifeograph is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with Lifeograph. If not, see .
19 |
20 | ***********************************************************************************/
21 |
22 |
23 | #include "entry_parser.hpp"
24 |
25 |
26 | using namespace LIFEO;
27 |
28 |
29 | void
30 | EntryParser::reset( Ustring::size_type start, Ustring::size_type end )
31 | {
32 | m_pos_start = start;
33 | m_pos_end = end;
34 | pos_current = pos_word = pos_alpha = pos_regular = start;
35 |
36 | m_cf_last = CF_NOT_SET;
37 | m_cf_req = CF_ANY;
38 | m_word_last.clear();
39 | m_word_count = 0;
40 | alpha_last.clear();
41 | int_last = 0;
42 | date_last = 0;
43 | id_last = 0;
44 | m_chars_looked_for.clear();
45 |
46 | if( start == 0 )
47 | {
48 | m_chars_looked_for.push_back( AbsChar( CF_IGNORE, NULL ) ); // to prevent formatting within title
49 | m_applier_nl = &EntryParser::apply_heading_end;
50 | if( end > 0 )
51 | apply_heading();
52 | }
53 | else
54 | {
55 | m_chars_looked_for.push_back( AbsChar( CF_NOTHING, NULL ) );
56 | m_applier_nl = NULL;
57 | }
58 | }
59 |
60 | void
61 | EntryParser::set_search_str( const Wstring& str )
62 | {
63 | m_search_str = str;
64 | i_search = 0;
65 | i_search_end = str.size() - 1;
66 | }
67 |
68 | void
69 | EntryParser::parse( Wstring::size_type start, Wstring::size_type end )
70 | {
71 | reset( start, end );
72 |
73 | for( ; pos_current < m_pos_end; ++pos_current )
74 | {
75 | char_current = get_char_at( pos_current );
76 |
77 | if( !m_search_str.empty() )
78 | {
79 | if( m_search_str[ i_search ] == char_lower( char_current ) )
80 | {
81 | if( i_search == 0 )
82 | pos_search = pos_current;
83 | if( i_search == i_search_end )
84 | {
85 | apply_match();
86 | i_search = 0;
87 | }
88 | else
89 | i_search++;
90 | }
91 | else
92 | {
93 | i_search = 0;
94 | }
95 | }
96 |
97 | // MARKUP PARSING
98 | switch( char_current )
99 | {
100 | case 0: // should never be the case
101 | case '\n':
102 | case '\r':
103 | process_char( CF_NEWLINE,
104 | CF_NUM_CKBX|CF_ALPHA|CF_FORMATCHAR|
105 | CF_SLASH|CF_DOTDATE|CF_MORE|CF_TAB|CF_IGNORE,
106 | 0, NULL );
107 | break;
108 | case ' ':
109 | process_char( CF_SPACE,
110 | CF_ALPHA|CF_NUMBER|CF_SLASH|CF_DOTDATE|CF_TODO,
111 | CF_NOTHING, &EntryParser::trigger_subheading );
112 | break;
113 | case '*': // SIGN
114 | process_char( CF_ASTERISK,
115 | CF_NUM_CKBX|CF_ALPHA|CF_SLASH|CF_DOTDATE,
116 | CF_NOTHING, &EntryParser::trigger_bold );
117 | break;
118 | case '_': // SIGN
119 | process_char( CF_UNDERSCORE,
120 | CF_NUM_CKBX|CF_SLASH|CF_DOTDATE,
121 | CF_NOTHING, &EntryParser::trigger_italic );
122 | break;
123 | case '=': // SIGN
124 | process_char( CF_EQUALS,
125 | CF_NUM_CKBX|CF_ALPHA|CF_SLASH|CF_DOTDATE,
126 | CF_NOTHING, &EntryParser::trigger_strikethrough );
127 | break;
128 | case '#': // SIGN
129 | process_char( CF_HASH,
130 | CF_NUM_CKBX|CF_ALPHA|CF_SLASH|CF_DOTDATE,
131 | CF_NOTHING, &EntryParser::trigger_highlight );
132 | break;
133 | case '[': // SIGN
134 | process_char( CF_SBB,
135 | CF_NUM_CKBX|CF_ALPHA|CF_SLASH|CF_DOTDATE,
136 | CF_NOTHING, &EntryParser::trigger_comment );
137 | break;
138 | case ']': // SIGN
139 | process_char( CF_SBE,
140 | CF_NUM_CKBX|CF_ALPHA|CF_SLASH|CF_DOTDATE,
141 | 0, NULL );
142 | break;
143 | case '0': case '1': case '2': case '3': case '4':
144 | case '5': case '6': case '7': case '8': case '9':
145 | handle_number(); // calculates numeric value
146 | process_char( CF_NUMBER,
147 | CF_SLASH|CF_ALPHA|CF_DOTDATE|CF_TODO,
148 | CF_NOTHING, &EntryParser::trigger_link_date );
149 | break;
150 | case '.': // SIGN
151 | process_char( CF_DOTDATE,
152 | CF_NUM_CKBX|CF_ALPHA|CF_SLASH,
153 | CF_NOTHING, &EntryParser::trigger_ignore );
154 | break;
155 | case '-': // SIGN - CF_SIGNSPELL does not seem to be necessary
156 | process_char( CF_DOTDATE,
157 | CF_NUM_CKBX|CF_ALPHA|CF_SLASH,
158 | 0, NULL );
159 | break;
160 | case '/': // SIGN
161 | process_char( CF_SLASH|CF_DOTDATE,
162 | CF_NUM_CKBX|CF_ALPHA,
163 | 0, NULL );
164 | break;
165 | case ':': // SIGN
166 | process_char( CF_PUNCTUATION_RAW,
167 | CF_NUM_CKBX|CF_ALPHA|CF_SLASH|CF_DOTDATE,
168 | CF_NOTHING, &EntryParser::trigger_link );
169 | break;
170 | case '@': // SIGN
171 | process_char( CF_AT,
172 | CF_NUM_CKBX|CF_ALPHA|CF_SLASH|CF_DOTDATE,
173 | CF_NOTHING, &EntryParser::trigger_link_at );
174 | break;
175 | case '>': // SIGN
176 | process_char( CF_MORE,
177 | CF_NUM_CKBX|CF_ALPHA|CF_SLASH|CF_DOTDATE,
178 | 0, NULL );
179 | break;
180 | case '\t':
181 | process_char( CF_TAB,
182 | CF_NUM_SLSH|CF_ALPHA|CF_DOTDATE,
183 | CF_NOTHING, &EntryParser::trigger_list );
184 | break;
185 | // LIST CHARS
186 | case '~':
187 | case '+':
188 | process_char( CF_TODO|CF_PUNCTUATION_RAW,
189 | CF_ALPHA|CF_NUM_CKBX|CF_DOTDATE|CF_SLASH,
190 | 0, NULL );
191 | break;
192 | case 'x':
193 | case 'X':
194 | process_char( CF_TODO|CF_ALPHA,
195 | CF_NUM_CKBX|CF_DOTDATE|CF_SLASH,
196 | 0, NULL );
197 | break;
198 | // MAYBE LATER:
199 | /*case '\'': // SIGN
200 | process_char( CF_PUNCTUATION_RAW,
201 | CF_ALPHA|CF_NUM_CKBX|CF_DOTDATE|CF_SLASH,
202 | 0, NULL,
203 | CC_SIGNSPELL );
204 | break;*/
205 | default:
206 | if( is_char_alpha( char_current ) )
207 | {
208 | process_char( CF_ALPHA,
209 | CF_NUM_CKBX|CF_DOTDATE|CF_SLASH,
210 | 0, NULL );
211 | }
212 | else // SIGN
213 | {
214 | process_char( CF_PUNCTUATION_RAW,
215 | CF_ALPHA|CF_NUM_CKBX|CF_DOTDATE|CF_SLASH,
216 | 0, NULL );
217 | }
218 | break;
219 | }
220 | }
221 | // end of the text -treated like new line
222 | if( m_pos_end > 0 ) // only when finish is not forced
223 | {
224 | char_current = '\n'; // treat end of text as new line for all means and purposes
225 |
226 | process_char( CF_NEWLINE|CF_EOT,
227 | CF_NUM_CKBX|CF_ALPHA|CF_FORMATCHAR|
228 | CF_SLASH|CF_DOTDATE|CF_MORE|CF_TAB|CF_IGNORE,
229 | 0, NULL );
230 | }
231 | }
232 |
233 | inline void
234 | EntryParser::process_char( unsigned int char_flags, unsigned int breaks,
235 | unsigned int triggers_on, FPtr_void triggerer )
236 | {
237 | // NOTE: m_cc_current *must* be set before calling this function
238 |
239 | // UPDATE ALPHA LAST
240 | if( m_flag_handle_word )
241 | {
242 | if( char_flags & CF_ALPHA ) // CF_SPELLCHECK may be used in the future
243 | {
244 | if( alpha_last.empty() )
245 | pos_alpha = pos_current;
246 | alpha_last += char_current;
247 | }
248 | else if( char_current == '\'' && !alpha_last.empty() ) // not so elegant
249 | alpha_last += char_current;
250 | else
251 | {
252 | if( !alpha_last.empty() )
253 | {
254 | // too hackish a solution:
255 | if( alpha_last[ alpha_last.size() - 1 ] == '\'' )
256 | alpha_last.erase( alpha_last.size() - 1, 1 );
257 | handle_word();
258 | alpha_last.clear();
259 | }
260 | }
261 | }
262 |
263 | // COLLECT INFORMATION ON WHAT TO DO
264 | unsigned int cf( m_chars_looked_for.front().flags );
265 | FPtr_void applier( m_chars_looked_for.front().applier );
266 | bool flag_clear_chars( false );
267 | bool flag_trigger( false );
268 | bool flag_apply( false );
269 |
270 | if( char_flags & cf )
271 | {
272 | if( applier != NULL )
273 | {
274 | if( m_chars_looked_for.front().junction )
275 | flag_apply = true;
276 | else if( m_cf_last & m_cf_req ) // not junction = final applier
277 | {
278 | flag_clear_chars = true;
279 | flag_apply = true;
280 | }
281 | }
282 | else
283 | {
284 | m_chars_looked_for.pop_front();
285 | if( triggers_on & cf )
286 | flag_trigger = true;
287 | }
288 | }
289 | else
290 | if( ( breaks & cf ) == cf || ( cf & CF_IMMEDIATE ) )
291 | {
292 | flag_clear_chars = true;
293 | if( triggers_on & CF_NOTHING )
294 | flag_trigger = true;
295 | }
296 | else
297 | if( triggers_on & cf )
298 | {
299 | flag_trigger = true;
300 | }
301 |
302 | if( char_flags & CF_NEWLINE )
303 | {
304 | flag_clear_chars = true;
305 |
306 | if( m_applier_nl != NULL )
307 | {
308 | ( this->*m_applier_nl )();
309 | m_applier_nl = NULL;
310 | }
311 | else if( ( char_flags & CF_EOT ) && !flag_apply )
312 | {
313 | m_pos_start = pos_current + 1;
314 | apply_regular();
315 | }
316 | }
317 |
318 | // DO AS COLLECTED INFORMATION REQUIRES
319 | if( flag_clear_chars )
320 | {
321 | m_chars_looked_for.clear();
322 | m_chars_looked_for.push_back( AbsChar( CF_NOTHING, NULL ) );
323 | }
324 | if( flag_trigger )
325 | ( this->*triggerer )();
326 | if( flag_apply )
327 | ( this->*applier )();
328 |
329 | // UPDATE WORD LAST
330 | if( char_flags & CF_SEPARATOR )
331 | m_word_last.clear();
332 | else
333 | {
334 | if( m_word_last.empty() )
335 | {
336 | pos_word = pos_current;
337 | m_word_count++;
338 | }
339 | m_word_last += char_current;
340 | }
341 |
342 | // UPDATE CHAR CLASS
343 | m_cf_last = char_flags;
344 | }
345 |
346 | // TRIGGERERS ======================================================================================
347 | void
348 | EntryParser::trigger_subheading()
349 | {
350 | if( m_cf_last == CF_NEWLINE )
351 | {
352 | m_chars_looked_for.clear();
353 | m_chars_looked_for.push_back( AbsChar( CF_NONSPACE, &EntryParser::apply_subheading_0 ) );
354 | m_cf_req = CF_ANY;
355 | m_pos_start = pos_current;
356 | }
357 | }
358 |
359 | void
360 | EntryParser::apply_subheading_0()
361 | {
362 | m_applier_nl = &EntryParser::apply_subheading_end;
363 | apply_subheading();
364 | }
365 |
366 | inline void
367 | EntryParser::trigger_markup( unsigned int lf, FPtr_void applier )
368 | {
369 | if( m_cf_last & CF_NOT_SEPARATOR )
370 | return;
371 |
372 | m_chars_looked_for.clear();
373 | m_chars_looked_for.push_back( AbsChar( CF_NONSPACE - lf, NULL ) );
374 | m_chars_looked_for.push_back( AbsChar( lf, applier ) );
375 | m_cf_req = CF_NOT_SEPARATOR;
376 | m_pos_start = pos_current;
377 | }
378 |
379 | void
380 | EntryParser::trigger_bold()
381 | {
382 | trigger_markup( CF_ASTERISK, &EntryParser::apply_bold );
383 | }
384 |
385 | void
386 | EntryParser::trigger_italic()
387 | {
388 | trigger_markup( CF_UNDERSCORE, &EntryParser::apply_italic );
389 | }
390 |
391 | void
392 | EntryParser::trigger_strikethrough()
393 | {
394 | trigger_markup( CF_EQUALS, &EntryParser::apply_strikethrough );
395 | }
396 |
397 | void
398 | EntryParser::trigger_highlight()
399 | {
400 | trigger_markup( CF_HASH, &EntryParser::apply_highlight );
401 | }
402 |
403 | void
404 | EntryParser::trigger_comment()
405 | {
406 | m_chars_looked_for.clear();
407 | m_chars_looked_for.push_back( AbsChar( CF_SBB|CF_IMMEDIATE, NULL ) );
408 | m_chars_looked_for.push_back( AbsChar( CF_SBE, NULL ) );
409 | m_chars_looked_for.push_back( AbsChar( CF_SBE|CF_IMMEDIATE, &EntryParser::apply_comment ) );
410 | m_cf_req = CF_ANY;
411 | m_pos_start = pos_current;
412 | }
413 |
414 | void
415 | EntryParser::trigger_link()
416 | {
417 | PRINT_DEBUG( "word_last: " + m_word_last );
418 | m_flag_hidden_link = m_word_last[ 0 ] == '<';
419 | if( m_flag_hidden_link )
420 | m_word_last.erase( 0, 1 );
421 |
422 | m_cf_req = CF_ANY;
423 |
424 | if( m_word_last == W( "http" ) || m_word_last == W( "https" ) ||
425 | m_word_last == W( "ftp" ) || m_word_last == W( "file" ) || m_word_last == W( "rel" ) )
426 | {
427 | m_chars_looked_for.clear();
428 | m_chars_looked_for.push_back( AbsChar( CF_SLASH, NULL ) );
429 | m_chars_looked_for.push_back( AbsChar( CF_SLASH, NULL ) );
430 | if( m_word_last == W( "file" ) )
431 | {
432 | m_chars_looked_for.push_back( AbsChar( CF_SLASH, NULL ) );
433 | m_chars_looked_for.push_back( AbsChar( CF_NONSPACE, NULL ) );
434 | }
435 | else
436 | m_chars_looked_for.push_back( AbsChar( CF_ALPHA|CF_NUMBER, NULL ) ); // TODO: add dash
437 | }
438 | else
439 | if( m_word_last == W( "mailto" ) )
440 | {
441 | m_chars_looked_for.clear();
442 | m_chars_looked_for.push_back( AbsChar( CF_UNDERSCORE|CF_ALPHA|CF_NUMBER, NULL ) );
443 | m_chars_looked_for.push_back( AbsChar( CF_AT, NULL ) );
444 | m_chars_looked_for.push_back( AbsChar( CF_ALPHA|CF_NUMBER, NULL ) ); // TODO: add dash
445 | }
446 | else
447 | if( m_word_last == W( "deid" ) && m_flag_hidden_link )
448 | {
449 | m_chars_looked_for.clear();
450 | m_chars_looked_for.push_back( AbsChar( CF_NUMBER, NULL ) );
451 | m_chars_looked_for.push_back( AbsChar( CF_TAB,
452 | &EntryParser::junction_link_hidden_tab,
453 | true ) ); // junction
454 | m_chars_looked_for.push_back( AbsChar( CF_NONSPACE - CF_MORE, NULL ) );
455 | m_chars_looked_for.push_back( AbsChar( CF_MORE, &EntryParser::apply_link_id ) );
456 | m_pos_start = pos_word;
457 | return;
458 | }
459 | else
460 | return;
461 |
462 | if( m_flag_hidden_link )
463 | {
464 | m_chars_looked_for.push_back( AbsChar( CF_TAB,
465 | &EntryParser::junction_link_hidden_tab,
466 | true ) ); // junction
467 | m_chars_looked_for.push_back( AbsChar( CF_NONSPACE - CF_MORE, NULL ) );
468 | m_chars_looked_for.push_back( AbsChar( CF_MORE, &EntryParser::apply_link ) );
469 | }
470 | else
471 | {
472 | m_chars_looked_for.push_back( AbsChar( CF_TAB|CF_NEWLINE|CF_SPACE,
473 | &EntryParser::apply_link ) );
474 | }
475 | m_pos_start = pos_word;
476 | }
477 |
478 | void
479 | EntryParser::trigger_link_at()
480 | {
481 | PRINT_DEBUG( "word_last [@]: " + m_word_last );
482 | if( m_cf_last & CF_SEPARATOR )
483 | return;
484 |
485 | m_flag_hidden_link = false;
486 | m_word_last.insert( 0, W( "mailto:" ) );
487 | m_chars_looked_for.clear();
488 | m_chars_looked_for.push_back( AbsChar( CF_ALPHA|CF_NUMBER, NULL ) ); // TODO: add dash
489 | m_chars_looked_for.push_back( AbsChar( CF_TAB|CF_NEWLINE|CF_SPACE,
490 | &EntryParser::apply_link ) );
491 | m_cf_req = CF_ANY;
492 | m_pos_start = pos_word;
493 | }
494 |
495 | void
496 | EntryParser::trigger_link_date()
497 | {
498 | m_cf_req = CF_ANY;
499 | m_chars_looked_for.clear();
500 | m_chars_looked_for.push_back( AbsChar( CF_NUMBER, NULL ) );
501 | m_chars_looked_for.push_back( AbsChar( CF_NUMBER, NULL ) );
502 | m_chars_looked_for.push_back( AbsChar( CF_NUMBER, NULL ) );
503 | m_chars_looked_for.push_back( AbsChar( CF_DOTYM, &EntryParser::junction_date_dotym, true ) );
504 | m_chars_looked_for.push_back( AbsChar( CF_NUMBER, NULL ) );
505 | m_chars_looked_for.push_back( AbsChar( CF_NUMBER, NULL ) );
506 | m_chars_looked_for.push_back( AbsChar( CF_DOTMD, &EntryParser::junction_date_dotmd, true ) );
507 | m_chars_looked_for.push_back( AbsChar( CF_NUMBER, NULL ) );
508 | m_chars_looked_for.push_back( AbsChar( CF_NUMBER, &EntryParser::junction_link_date, true ) );
509 |
510 | m_flag_hidden_link = ( m_word_last == W( "<" ) );
511 | if( m_flag_hidden_link )
512 | {
513 | m_chars_looked_for.push_back( AbsChar( CF_TAB,
514 | &EntryParser::junction_link_hidden_tab,
515 | true ) ); // junction
516 | m_chars_looked_for.push_back( AbsChar( CF_NONSPACE, NULL ) );
517 | m_chars_looked_for.push_back( AbsChar( CF_MORE, &EntryParser::apply_link_date ) );
518 | m_pos_start = pos_current - 1;
519 | }
520 | else
521 | {
522 | m_pos_start = pos_current;
523 | }
524 | }
525 |
526 | void
527 | EntryParser::trigger_list()
528 | {
529 | if( m_cf_last != CF_NEWLINE )
530 | return;
531 |
532 | m_chars_looked_for.clear();
533 | m_chars_looked_for.push_back( AbsChar( CF_NONTAB, &EntryParser::junction_list, true ) );
534 | m_cf_req = CF_ANY;
535 | m_pos_start = pos_current;
536 | }
537 |
538 | void
539 | EntryParser::trigger_ignore()
540 | {
541 | if( m_cf_last == CF_NEWLINE )
542 | {
543 | m_chars_looked_for.clear();
544 | m_chars_looked_for.push_back( AbsChar( CF_TAB|CF_IMMEDIATE,
545 | &EntryParser::junction_ignore,
546 | true ) ); // junction
547 | m_cf_req = CF_ANY;
548 | m_pos_start = pos_current;
549 | }
550 | }
551 |
552 | void
553 | EntryParser::junction_link_date()
554 | {
555 | date_last.set_day( int_last );
556 |
557 | if( date_last.is_valid() )
558 | {
559 | if( m_flag_hidden_link )
560 | {
561 | m_chars_looked_for.pop_front();
562 | return;
563 | }
564 | else
565 | apply_link_date();
566 | }
567 |
568 | m_chars_looked_for.clear();
569 | m_chars_looked_for.push_back( AbsChar( CF_NOTHING, NULL ) );
570 | }
571 |
572 | void
573 | EntryParser::junction_link_hidden_tab()
574 | {
575 | m_chars_looked_for.pop_front();
576 | pos_tab = pos_current;
577 | id_last = int_last; // if not id link assignment is in vain
578 | }
579 |
580 | void
581 | EntryParser::junction_list()
582 | {
583 | apply_indent();
584 | m_cf_req = CF_ANY;
585 |
586 | switch( char_current )
587 | {
588 | case '[':
589 | // reuse
590 | m_chars_looked_for.front().flags = CF_SPACE|CF_TODO|CF_IMMEDIATE;
591 | m_chars_looked_for.front().applier = &EntryParser::junction_list2;
592 |
593 | m_chars_looked_for.push_back( AbsChar( CF_SBE|CF_IMMEDIATE, NULL ) );
594 | m_chars_looked_for.push_back( AbsChar( CF_SPACE|CF_IMMEDIATE, NULL ) );
595 | break;
596 | default:
597 | m_chars_looked_for.clear();
598 | m_chars_looked_for.push_back( AbsChar( CF_NOTHING, NULL ) );
599 | break;
600 | }
601 | }
602 |
603 | void
604 | EntryParser::junction_list2()
605 | {
606 | m_cf_req = CF_ANY;
607 |
608 | switch( char_current )
609 | {
610 | case ' ':
611 | m_chars_looked_for.pop_front();
612 | m_chars_looked_for.back().applier = &EntryParser::apply_check_unf;
613 | break;
614 | case '~':
615 | m_chars_looked_for.pop_front();
616 | m_chars_looked_for.back().applier = &EntryParser::apply_check_prg;
617 | break;
618 | case '+':
619 | m_chars_looked_for.pop_front();
620 | m_chars_looked_for.back().applier = &EntryParser::apply_check_fin_0;
621 | break;
622 | case 'x':
623 | case 'X':
624 | m_chars_looked_for.pop_front();
625 | m_chars_looked_for.back().applier = &EntryParser::apply_check_ccl_0;
626 | break;
627 | default:
628 | m_chars_looked_for.clear();
629 | m_chars_looked_for.push_back( AbsChar( CF_NOTHING, NULL ) );
630 | break;
631 | }
632 | }
633 |
634 | void
635 | EntryParser::junction_date_dotym()
636 | {
637 | if( int_last >= Date::YEAR_MIN && int_last <= Date::YEAR_MAX )
638 | {
639 | date_last.set_year( int_last );
640 | m_chars_looked_for.pop_front();
641 | }
642 | else
643 | {
644 | m_chars_looked_for.clear();
645 | m_chars_looked_for.push_back( AbsChar( CF_NOTHING, NULL ) );
646 | }
647 | }
648 |
649 | void
650 | EntryParser::junction_date_dotmd()
651 | {
652 | if( int_last >= 1 && int_last <= 12 &&
653 | // two separators must be the same:
654 | char_current == m_word_last[ m_word_last.size() - 3 ] )
655 | {
656 | date_last.set_month( int_last );
657 | m_chars_looked_for.pop_front();
658 | }
659 | else
660 | {
661 | m_chars_looked_for.clear();
662 | m_chars_looked_for.push_back( AbsChar( CF_NOTHING, NULL ) );
663 | }
664 | }
665 |
666 | void
667 | EntryParser::junction_ignore()
668 | {
669 | // m_applier_nl = &EntryParser::apply_ignore_end;
670 | m_chars_looked_for.front().flags = CF_IGNORE;
671 | m_chars_looked_for.front().applier = NULL;
672 | apply_ignore();
673 | }
674 |
675 | // TODO: this is a temporary solution until begin and end appliers, and junction functions will
676 | // be bundled in a class also eliminating the need for separate deques for all of them:
677 | void
678 | EntryParser::apply_check_ccl_0()
679 | {
680 | m_applier_nl = &EntryParser::apply_check_ccl_end;
681 | apply_check_ccl();
682 | }
683 |
684 | void
685 | EntryParser::apply_check_fin_0()
686 | {
687 | m_applier_nl = &EntryParser::apply_check_fin_end;
688 | apply_check_fin();
689 | }
690 |
691 | // HELPERS =========================================================================================
692 | inline void
693 | EntryParser::handle_number()
694 | {
695 | if( m_cf_last == CF_NUMBER )
696 | {
697 | int_last *= 10;
698 | int_last += ( char_current - '0' );
699 | }
700 | else
701 | int_last = ( char_current - '0' );
702 | }
703 |
--------------------------------------------------------------------------------
/src/helpers.hpp:
--------------------------------------------------------------------------------
1 | /***********************************************************************************
2 |
3 | Copyright (C) 2007-2011 Ahmet Öztürk (aoz_2@yahoo.com)
4 |
5 | This file is part of Lifeograph.
6 |
7 | Lifeograph is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | Lifeograph is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with Lifeograph. If not, see .
19 |
20 | ***********************************************************************************/
21 |
22 |
23 | #ifndef LIFEOGRAPH_HELPERS_HEADER
24 | #define LIFEOGRAPH_HELPERS_HEADER
25 |
26 |
27 | #ifdef HAVE_CONFIG_H
28 | #include
29 | #endif
30 |
31 | #include
32 | #include
33 | #include
34 | #include
35 |
36 | #ifndef LIFEO_WINDOZE
37 | #include
38 | #else
39 | #include // to silence the compiler
40 | #include
41 | #endif
42 |
43 | #include
44 |
45 | #ifndef LIFEO_WINDOZE
46 | typedef Glib::ustring Ustring;
47 | typedef Glib::ustring Wstring;
48 | typedef gunichar Wchar;
49 | #define W(s) s
50 | typedef Glib::RefPtr< Gdk::Pixbuf > Icon;
51 | typedef Gdk::RGBA Color;
52 | #else
53 | // values are temporary
54 | typedef std::string Ustring;
55 | typedef std::wstring Wstring;
56 | typedef wchar_t Wchar;
57 | #define W(s) L##s
58 | typedef void* Icon;
59 | typedef std::string Color;
60 | #endif
61 |
62 | namespace HELPERS
63 | {
64 |
65 | class STR
66 | {
67 | private:
68 | static void print_internal( std::stringstream& ) {}
69 |
70 |
71 | template< typename Arg1, typename... Args >
72 | static void print_internal( std::stringstream& str, Arg1 arg1, Args... args )
73 | {
74 | str << arg1;
75 | print_internal( str, args... );
76 | }
77 |
78 | public:
79 | template< typename... Args >
80 | static Ustring compose( Args... args )
81 | {
82 | std::stringstream str;
83 | print_internal( str, args... );
84 |
85 | return str.str();
86 | }
87 | };
88 |
89 | class Error
90 | {
91 | public:
92 | Error( const Ustring& );
93 | };
94 |
95 | enum Result
96 | {
97 | OK,
98 | ABORTED,
99 | SUCCESS,
100 | FAILURE,
101 | COULD_NOT_START,
102 | COULD_NOT_FINISH,
103 | WRONG_PASSWORD,
104 | //APPARENTLY_ENCRYTED_FILE,
105 | //APPARENTLY_PLAIN_FILE,
106 | INCOMPATIBLE_FILE_OLD,
107 | INCOMPATIBLE_FILE_NEW,
108 | CORRUPT_FILE,
109 | // EMPTY_DATABASE, // not used anymore
110 |
111 | // RESULTS USED BY set_path():
112 | FILE_NOT_FOUND,
113 | FILE_NOT_READABLE,
114 | FILE_NOT_WRITABLE,
115 | FILE_LOCKED,
116 |
117 | // RESULTS USED BY Date
118 | OUT_OF_RANGE,
119 | INVALID
120 | };
121 |
122 | // RESPONSE IDS
123 | static const int RESPONSE_CANCEL = 0;
124 | static const int RESPONSE_GO = 1;
125 |
126 | // DATE ============================================================================================
127 | // order: 10 bits
128 | // day: 5 bits
129 | // month: 4 bits
130 | // year: 12 bits
131 | // ordinal flag: 1 bit (32nd bit)
132 |
133 | class Date
134 | {
135 | public:
136 | static const unsigned long NOT_APPLICABLE = 0x0;
137 | static const unsigned long NOT_SET = 0xFFFFFFFF;
138 | static const unsigned long DATE_MAX = 0xFFFFFFFF;
139 |
140 | static const unsigned int YEAR_MIN = 1900;
141 | static const unsigned int YEAR_MAX = 2199;
142 | static const unsigned int CHAPTER_MAX = 1024;
143 |
144 | static const unsigned int ORDER_FILTER = 0x3FF;
145 | static const unsigned long DAY_FILTER = 0x7C00;
146 | static const unsigned long MONTH_FILTER = 0x78000;
147 | static const unsigned long YEAR_FILTER = 0x7FF80000;
148 | static const unsigned long ORDER_FILTER_INV = DATE_MAX ^ ORDER_FILTER;
149 | static const unsigned long DAY_FILTER_INV = DATE_MAX ^ DAY_FILTER;
150 | static const unsigned long MONTH_FILTER_INV = DATE_MAX ^ MONTH_FILTER;
151 | static const unsigned long YEAR_FILTER_INV = DATE_MAX ^ YEAR_FILTER;
152 | static const unsigned long YEARMONTH_FILTER = YEAR_FILTER|MONTH_FILTER;
153 | static const unsigned int PURE_FILTER = DATE_MAX ^ ORDER_FILTER;
154 |
155 | // hidden elements' sequence numbers are not shown
156 | static const unsigned long VISIBLE_FLAG = 0x40000000; // only for ordinal items
157 |
158 | static const unsigned long ORDINAL_STEP = 0x400;
159 | static const unsigned long ORDINAL_FLAG = 0x80000000;
160 | static const unsigned long ORDINAL_FILTER = ORDINAL_STEP * ( CHAPTER_MAX - 1 );
161 | static const unsigned long ORDINAL_LAST = ORDINAL_FILTER;
162 |
163 | static const unsigned long ORDER_MAX = ORDER_FILTER;
164 |
165 | static const unsigned long TOPIC_NO_FLAGS_FILTER = ORDINAL_FILTER|ORDER_FILTER;
166 |
167 | static const unsigned long TOPIC_MIN = VISIBLE_FLAG|ORDINAL_FLAG;
168 | static const unsigned long GROUP_MIN = ORDINAL_FLAG;
169 |
170 | static std::string s_format_order;
171 | static char s_format_separator;
172 |
173 | typedef unsigned long date_t;
174 |
175 | void operator=( const Date& date )
176 | { m_date = date.m_date; }
177 | void operator=( const Date::date_t& date )
178 | { m_date = date; }
179 |
180 | bool operator>( const Date& date_r )
181 | { return( m_date > date_r.m_date ); }
182 | bool operator>=( const Date& date_r )
183 | { return( m_date >= date_r.m_date ); }
184 | bool operator<( const Date& date_r )
185 | { return( m_date < date_r.m_date ); }
186 |
187 | bool operator==( const Date& date )
188 | { return( m_date == date.m_date ); }
189 | bool operator==( const Date::date_t& date )
190 | { return( m_date == date ); }
191 |
192 | bool operator!=( const Date& date )
193 | { return( m_date != date.m_date ); }
194 |
195 | explicit Date( date_t date )
196 | : m_date( date ) {}
197 | Date( unsigned int y, unsigned int m, unsigned int d,
198 | unsigned int o = 0 )
199 | : m_date( ( y << 19 ) | ( m << 15 ) | ( d << 10 ) | o ) {}
200 | explicit Date( const std::string& );
201 | // TODO: later: explicit Date( time_t );
202 | // ORDINAL C'TOR
203 | Date( unsigned int o1, unsigned int o2 )
204 | : m_date( VISIBLE_FLAG | ORDINAL_FLAG | ( o1 << 10 ) | o2 ) {}
205 |
206 | static date_t get_today( int order = 0 )
207 | {
208 | time_t t = time( NULL );
209 | struct tm* ti = localtime( &t );
210 | return make_date( ti->tm_year + 1900, ti->tm_mon + 1, ti->tm_mday, order );
211 | }
212 |
213 | void set_now( int order = 0 )
214 | { m_date = get_today( order ); }
215 |
216 | date_t get_pure() const
217 | { return( m_date & PURE_FILTER ); }
218 | static date_t get_pure( const date_t d )
219 | { return( d & PURE_FILTER ); }
220 |
221 | date_t get_yearmonth() const
222 | { return( m_date & YEARMONTH_FILTER ); }
223 | static date_t get_yearmonth( const date_t d )
224 | { return( d & YEARMONTH_FILTER ); }
225 |
226 | unsigned int get_year() const
227 | { return ( ( m_date & YEAR_FILTER ) >> 19 ); }
228 | static unsigned int get_year( const date_t d )
229 | { return ( ( d & YEAR_FILTER ) >> 19 ); }
230 |
231 | int get_weekday() const;
232 |
233 | std::string get_year_str() const;
234 | Ustring get_month_str() const;
235 | //std::string get_day_str() const;
236 | Ustring get_weekday_str() const
237 | {
238 | struct tm ti;
239 | ti.tm_wday = get_weekday();
240 | char buf[ 32 ];
241 | strftime( buf, 32, "%A", &ti );
242 | return Ustring( buf );
243 | }
244 |
245 | unsigned int get_days_in_month() const;
246 |
247 | bool is_leap_year() const
248 | {
249 | int year( get_year() );
250 | if( ( year % 400 ) == 0 )
251 | return true;
252 | else if( ( year % 100 ) == 0 )
253 | return false;
254 |
255 | return( ( year % 4 ) == 0 );
256 | }
257 |
258 | unsigned int get_month() const
259 | { return( ( m_date & MONTH_FILTER ) >> 15 ); }
260 | static unsigned int get_month( const date_t d )
261 | { return( ( d & MONTH_FILTER ) >> 15 ); }
262 |
263 | #ifndef LIFEO_WINDOZE
264 | Glib::Date::Month get_month_glib() const;
265 | #endif
266 |
267 | unsigned int get_day() const
268 | { return( ( m_date & DAY_FILTER ) >> 10 ); }
269 | static unsigned int get_day( const date_t d )
270 | { return( ( d & DAY_FILTER ) >> 10 ); }
271 |
272 | unsigned int get_order() const
273 | { return( m_date & ORDER_FILTER ); }
274 | static unsigned int get_order( const date_t d )
275 | { return( d & ORDER_FILTER ); }
276 |
277 | unsigned int get_ordinal_order() const
278 | { return( ( m_date & ORDINAL_FILTER ) >> 10 ); }
279 | static unsigned int get_ordinal_order( const date_t d )
280 | { return( ( d & ORDINAL_FILTER ) >> 10 ); }
281 |
282 | static Date::date_t get_order_begin() {
283 | return ORDINAL_FLAG;
284 | }
285 |
286 | #ifndef LIFEO_WINDOZE
287 | Glib::Date get_glib() const
288 | { return Glib::Date( get_day(), get_month_glib(), get_year() ); }
289 | #endif
290 | time_t get_ctime() const
291 | { return get_ctime( m_date ); }
292 | static time_t get_ctime( const date_t );
293 |
294 | void set_year( unsigned int y )
295 | {
296 | if( y >= YEAR_MIN && y <= YEAR_MAX )
297 | {
298 | m_date &= YEAR_FILTER_INV;
299 | m_date |= ( y << 19 );
300 | }
301 | }
302 | void set_month( unsigned int m )
303 | {
304 | if( m < 13 )
305 | {
306 | m_date &= MONTH_FILTER_INV;
307 | m_date |= ( m << 15 );
308 | }
309 | }
310 | void set_day( unsigned int d )
311 | {
312 | if( d < 32 )
313 | {
314 | m_date &= DAY_FILTER_INV;
315 | m_date |= ( d << 10 );
316 | }
317 | }
318 | void reset_order_0()
319 | { m_date &= ORDER_FILTER_INV; }
320 | void reset_order_1()
321 | { m_date &= ORDER_FILTER_INV; m_date |= 0x1; }
322 | static void reset_order_1( date_t& date )
323 | { date &= ORDER_FILTER_INV; date |= 0x1; }
324 |
325 | static Result parse_string( Date::date_t*, const Ustring& );
326 |
327 | Ustring format_string() const
328 | { return format_string( m_date, s_format_order, s_format_separator ); }
329 | Ustring format_string( const std::string& format,
330 | const char separator = s_format_separator )
331 | { return format_string( m_date, format, separator ); }
332 | static Ustring format_string( const date_t date )
333 | { return format_string( date, s_format_order, s_format_separator ); }
334 | static Ustring format_string( const date_t, const std::string&, const char );
335 | static Ustring format_string_dt( const time_t );
336 | static Ustring format_string_d( const time_t );
337 |
338 | bool is_valid() const
339 | {
340 | return( get_day() > 0 && get_day() <= get_days_in_month() );
341 | }
342 | bool is_set() const
343 | { return( m_date != NOT_SET ); }
344 |
345 | bool is_ordinal() const
346 | { return( m_date & ORDINAL_FLAG ); }
347 | static bool is_ordinal( const date_t d )
348 | { return( d & ORDINAL_FLAG ); }
349 |
350 | bool is_hidden() const
351 | { return( is_ordinal() && !( m_date & VISIBLE_FLAG ) ); }
352 | static bool is_hidden( const date_t d )
353 | { return( is_ordinal( d ) && !( d & VISIBLE_FLAG ) ); }
354 |
355 | void forward_years( int years )
356 | { m_date += make_year( years ); }
357 | void forward_months( int months );
358 | void forward_day();
359 |
360 | void backward_ordinal_order()
361 | { if( get_ordinal_order() > 0 ) m_date -= ORDINAL_STEP; }
362 | static void backward_ordinal_order( Date::date_t& d )
363 | { if( get_ordinal_order( d ) > 0 ) d -= ORDINAL_STEP; }
364 | void forward_ordinal_order()
365 | { if( ( m_date & ORDINAL_FILTER ) < ORDINAL_LAST ) m_date += ORDINAL_STEP; }
366 | static void forward_ordinal_order( Date::date_t& d )
367 | { if( ( d & ORDINAL_FILTER ) != ORDINAL_LAST ) d += ORDINAL_STEP; }
368 |
369 | static date_t make_year( unsigned int y )
370 | { return( y << 19 ); }
371 | static date_t make_month( unsigned int m )
372 | { return( m << 15 ); }
373 | static date_t make_day( unsigned int m )
374 | { return( m << 10 ); }
375 | static date_t make_date( unsigned int y, unsigned int m, unsigned int d,
376 | unsigned int o = 0 )
377 | { return( ( y << 19 ) | ( m << 15 ) | ( d << 10 ) | o ); }
378 | static date_t make_date( unsigned int c, unsigned int o = 0 )
379 | { return( TOPIC_MIN | ( ( c - 1 ) * ORDINAL_STEP ) | o ); }
380 | static date_t make_date_from_ctime( const tm* timeinfo )
381 | {
382 | return make_date( timeinfo->tm_year + 1900, timeinfo->tm_mon + 1, timeinfo->tm_mday );
383 | }
384 | static date_t make_date_from_ctime( const time_t t )
385 | {
386 | struct tm* timeinfo = localtime( &t );
387 | return make_date( timeinfo->tm_year + 1900, timeinfo->tm_mon + 1, timeinfo->tm_mday );
388 | }
389 |
390 | unsigned int calculate_days_between( const Date& ) const;
391 | unsigned int calculate_months_between( Date::date_t ) const;
392 | static unsigned int calculate_months_between( Date::date_t, Date::date_t );
393 | static int calculate_months_between_neg( Date::date_t, Date::date_t );
394 |
395 | //protected:
396 | date_t m_date{ 0 };
397 | };
398 |
399 | /*
400 | inline int
401 | subtract_months( Date d1, Date d2 )
402 | {
403 | return ( ( isolate_month( d1 ) - isolate_month( d2 ) ) +
404 | ( ( isolate_year( d1 ) - isolate_year( d2 ) ) * 12 ) );
405 | }
406 | */
407 |
408 | inline bool
409 | compare_dates( const Date::date_t& date_l, const Date::date_t& date_r )
410 | {
411 | return( date_l > date_r );
412 | }
413 |
414 | typedef bool( *FuncCompareDates )( const Date::date_t&, const Date::date_t& ) ;
415 |
416 | // VALUES ==========================================================================================
417 | typedef double Value;
418 |
419 | // CONSOLE MESSAGES ================================================================================
420 | class Console
421 | {
422 | private:
423 | static void print( std::ostream& os )
424 | {
425 | os << std::endl;
426 | }
427 |
428 | template< typename Arg1, typename... Args >
429 | static void print( std::ostream& os, Arg1 arg1, Args... args )
430 | {
431 | os << arg1;
432 | print( os, args... );
433 | }
434 |
435 | template< typename... Args >
436 | friend void print_error( Args... );
437 |
438 | template< typename... Args >
439 | friend void print_info( Args... );
440 |
441 | template< typename... Args >
442 | friend void PRINT_DEBUG( Args... );
443 | };
444 |
445 | template< typename... Args >
446 | void print_info( Args... args )
447 | {
448 | Console::print( std::cout, "INFO: ", args... );
449 | }
450 |
451 | template< typename... Args >
452 | void print_error( Args... args )
453 | {
454 | Console::print( std::cerr, "ERROR: ", args... );
455 | }
456 |
457 | #ifdef LIFEOGRAPH_DEBUG_BUILD
458 | template< typename... Args >
459 | void PRINT_DEBUG( Args... args )
460 | {
461 | Console::print( std::cout, "* DBG * ", args... );
462 | }
463 | #else
464 | #define PRINT_DEBUG( ... ) ;
465 | #endif
466 |
467 | // COLOR OPERATIONS ================================================================================
468 | #ifndef LIFEO_WINDOZE
469 | Gdk::RGBA contrast2( const Gdk::RGBA&, const Gdk::RGBA&, const Gdk::RGBA& );
470 | Gdk::RGBA midtone( const Gdk::RGBA&, const Gdk::RGBA& );
471 | Gdk::RGBA midtone( const Gdk::RGBA&, const Gdk::RGBA&, float );
472 |
473 | inline Glib::ustring
474 | convert_gdkcolor_to_html( const Gdk::RGBA& gdkcolor )
475 | {
476 | // this function's source of inspiration is Geany
477 | char buffer[ 8 ];
478 |
479 | g_snprintf( buffer, 8, "#%02X%02X%02X",
480 | gdkcolor.get_red_u() >> 8,
481 | gdkcolor.get_green_u() >> 8,
482 | gdkcolor.get_blue_u() >> 8 );
483 | return buffer;
484 | }
485 |
486 | inline Glib::ustring
487 | convert_gdkrgba_to_string( const Gdk::RGBA& gdkcolor )
488 | {
489 | char buffer[ 14 ];
490 | g_snprintf( buffer, 14, "#%04X%04X%04X",
491 | int( gdkcolor.get_red() * 0xFFFF ),
492 | int( gdkcolor.get_green() * 0xFFFF ),
493 | int( gdkcolor.get_blue() * 0xFFFF ) );
494 | return buffer;
495 | }
496 |
497 | #else
498 |
499 | inline int
500 | parse_color_sub( const std::string& color, int begin, int end )
501 | {
502 | int ret_val = 0;
503 |
504 | for( int i = begin; i <= end; i++ )
505 | {
506 | char c = color[ i ];
507 | if( c >= '0' && c <= '9' )
508 | {
509 | ret_val *= 16;
510 | ret_val += ( c - '0' );
511 | }
512 | else if( c >= 'a' && c <= 'f' )
513 | {
514 | ret_val *= 16;
515 | ret_val += ( c - 'a' + 10 );
516 | }
517 | else if( c >= 'A' && c <= 'F' )
518 | {
519 | ret_val *= 16;
520 | ret_val += ( c - 'A' + 10 );
521 | }
522 | }
523 |
524 | return ret_val;
525 | }
526 |
527 | inline COLORREF
528 | parse_color( const std::string& color )
529 | {
530 | if( color.size() == 13 ) // #RRRRGGGGBBBB
531 | return RGB( parse_color_sub( color, 1, 2 ),
532 | parse_color_sub( color, 5, 6 ),
533 | parse_color_sub( color, 9, 10 ) );
534 | else // #RRGGBB
535 | return RGB( parse_color_sub( color, 1, 2 ),
536 | parse_color_sub( color, 3, 4 ),
537 | parse_color_sub( color, 5, 6 ) );
538 | }
539 |
540 | COLORREF
541 | contrast2( COLORREF, COLORREF, COLORREF );
542 |
543 | COLORREF
544 | midtone( COLORREF, COLORREF, float );
545 |
546 | #endif
547 |
548 | // FILE OPERATIONS =================================================================================
549 | std::ios::pos_type get_file_size( std::ifstream& );
550 |
551 | bool copy_file_suffix( const std::string&, const std::string&, int );
552 |
553 | bool is_dir( const char* );
554 |
555 | inline std::string
556 | get_filename_base( const std::string& path )
557 | {
558 | #ifndef LIFEO_WINDOZE
559 | return Glib::filename_display_basename( path );
560 | #else
561 | char* stripped_path = new char[ path.size() + 1 ];
562 | strcpy( stripped_path, path.c_str() );
563 | PathStripPathA( stripped_path );
564 | return std::string( stripped_path );
565 | #endif
566 | }
567 |
568 | typedef std::set< std::string > ListPaths;
569 |
570 | // TEXT OPERATIONS =================================================================================
571 | long convert_string( const std::string& );
572 | bool str_ends_with( const std::string&, const std::string& );
573 |
574 | #ifndef LIFEO_WINDOZE
575 | gunichar char_lower( gunichar );
576 | bool is_char_alpha( gunichar );
577 |
578 | std::string get_env_lang();
579 |
580 | #else
581 | wchar_t* convert_utf8_to_16( const Ustring& );
582 | char* convert_utf16_to_8( const wchar_t* );
583 |
584 | wchar_t char_lower( wchar_t );
585 | bool is_char_alpha( wchar_t );
586 |
587 | PCHAR* command_line_to_argvA( PCHAR, int* );
588 | #endif
589 |
590 | // ENCRYPTION ======================================================================================
591 | class Cipher
592 | {
593 | public:
594 | static const int cCIPHER_ALGORITHM = GCRY_CIPHER_AES256;
595 | static const int cCIPHER_MODE = GCRY_CIPHER_MODE_CFB;
596 | static const int cIV_SIZE = 16; // = 128 bits
597 | static const int cSALT_SIZE = 16; // = 128 bits
598 | static const int cKEY_SIZE = 32; // = 256 bits
599 | static const int cHASH_ALGORITHM = GCRY_MD_SHA256;
600 |
601 | static bool init();
602 |
603 | static void create_iv( unsigned char** );
604 | static void expand_key( char const*,
605 | const unsigned char*,
606 | unsigned char** );
607 | static void create_new_key( char const*,
608 | unsigned char**,
609 | unsigned char** );
610 | static void encrypt_buffer( unsigned char*,
611 | size_t&,
612 | const unsigned char*,
613 | const unsigned char* );
614 | static void decrypt_buffer( unsigned char*,
615 | size_t,
616 | const unsigned char*,
617 | const unsigned char* );
618 |
619 | protected:
620 |
621 | private:
622 |
623 | };
624 |
625 | struct CipherBuffers
626 | {
627 | CipherBuffers()
628 | : buffer( NULL ), salt( NULL ), iv( NULL ), key( NULL ) {}
629 |
630 | unsigned char* buffer;
631 | unsigned char* salt;
632 | unsigned char* iv;
633 | unsigned char* key;
634 |
635 | void clear()
636 | {
637 | if( buffer ) delete[] buffer;
638 | if( salt ) delete[] salt;
639 | if( iv ) delete[] iv;
640 | if( key ) delete[] key;
641 | }
642 | };
643 |
644 | #ifndef LIFEO_WINDOZE
645 | // ENTRY WIDGET WITH SELF-HANDLED CLEAR ICON =======================================================
646 | class EntryClear : public Gtk::Entry
647 | {
648 | public:
649 | EntryClear( BaseObjectType*, const Glib::RefPtr& );
650 |
651 | protected:
652 | void handle_icon_press( Gtk::EntryIconPosition, const GdkEventButton* );
653 | void handle_icon_release( Gtk::EntryIconPosition, const GdkEventButton* );
654 | virtual void on_changed();
655 | virtual bool on_key_release_event( GdkEventKey* );
656 | bool m_pressed;
657 | };
658 |
659 | // FILE FILTERS ====================================================================================
660 | //class FilefilterAny : public Gtk::FileFilter
661 | //{
662 | // public:
663 | // FilefilterAny()
664 | // {
665 | // set_name( _("All Files") );
666 | // add_pattern( "*" );
667 | // }
668 | //};
669 | //
670 | //class FilefilterDiary : public Gtk::FileFilter
671 | //{
672 | // public:
673 | // FilefilterDiary()
674 | // {
675 | // set_name( _("Diary Files (*.diary)") );
676 | // add_mime_type( "application/x-lifeographdiary" );
677 | // }
678 | //};
679 |
680 | // DIALOGEVENT =====================================================================================
681 | class DialogEvent : public Gtk::Dialog
682 | {
683 | public:
684 | DialogEvent( const Glib::ustring& );
685 | DialogEvent( BaseObjectType*,
686 | const Glib::RefPtr< Gtk::Builder >& );
687 |
688 | protected:
689 | bool on_event( GdkEvent* );
690 | void handle_logout();
691 |
692 | };
693 |
694 | // FRAME FOR PRINTING ==============================================================================
695 | Gtk::Frame* create_frame( const Glib::ustring&, Gtk::Widget& );
696 |
697 | // TREEVIEW ========================================================================================
698 | // scroll_to_row( Path& ) does not work for some reason. So, implemented our own
699 | bool is_treepath_less( const Gtk::TreePath&, const Gtk::TreePath& );
700 | bool is_treepath_more( const Gtk::TreePath&, const Gtk::TreePath& );
701 |
702 | // OTHER GTK HELPERS ===============================================================================
703 | Gtk::MenuItem* create_menuitem_markup( const Glib::ustring&,
704 | const Glib::SignalProxy0< void >::SlotType& );
705 |
706 | typedef sigc::signal< void > SignalVoid;
707 |
708 | #endif // ifndef LIFEO_WINDOZE
709 |
710 | } // end of namespace HELPERS
711 |
712 | #endif
713 |
714 |
--------------------------------------------------------------------------------
/mingw/include/gpg-error.h:
--------------------------------------------------------------------------------
1 | /* gpg-error.h - Public interface to libgpg-error. -*- c -*-
2 | Copyright (C) 2003, 2004, 2010, 2013, 2014 g10 Code GmbH
3 |
4 | This file is part of libgpg-error.
5 |
6 | libgpg-error is free software; you can redistribute it and/or
7 | modify it under the terms of the GNU Lesser General Public License
8 | as published by the Free Software Foundation; either version 2.1 of
9 | the License, or (at your option) any later version.
10 |
11 | libgpg-error is distributed in the hope that it will be useful, but
12 | WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | Lesser General Public License for more details.
15 |
16 | You should have received a copy of the GNU Lesser General Public
17 | License along with this program; if not, see .
18 |
19 | Do not edit. Generated from gpg-error.h.in for i686-w64-mingw32.
20 | */
21 |
22 |
23 | #ifndef GPG_ERROR_H
24 | #define GPG_ERROR_H 1
25 |
26 | #include
27 |
28 | #ifdef __GNUC__
29 | #define GPG_ERR_INLINE __inline__
30 | #elif _MSC_VER >= 1300
31 | #define GPG_ERR_INLINE __inline
32 | #elif __STDC_VERSION__ >= 199901L
33 | #define GPG_ERR_INLINE inline
34 | #else
35 | #ifndef GPG_ERR_INLINE
36 | #define GPG_ERR_INLINE
37 | #endif
38 | #endif
39 |
40 |
41 | #ifdef __cplusplus
42 | extern "C" {
43 | #if 0 /* just to make Emacs auto-indent happy */
44 | }
45 | #endif
46 | #endif /* __cplusplus */
47 |
48 | /* The GnuPG project consists of many components. Error codes are
49 | exchanged between all components. The common error codes and their
50 | user-presentable descriptions are kept into a shared library to
51 | allow adding new error codes and components without recompiling any
52 | of the other components. The interface will not change in a
53 | backward incompatible way.
54 |
55 | An error code together with an error source build up an error
56 | value. As the error value is been passed from one component to
57 | another, it preserver the information about the source and nature
58 | of the error.
59 |
60 | A component of the GnuPG project can define the following macros to
61 | tune the behaviour of the library:
62 |
63 | GPG_ERR_SOURCE_DEFAULT: Define to an error source of type
64 | gpg_err_source_t to make that source the default for gpg_error().
65 | Otherwise GPG_ERR_SOURCE_UNKNOWN is used as default.
66 |
67 | GPG_ERR_ENABLE_GETTEXT_MACROS: Define to provide macros to map the
68 | internal gettext API to standard names. This has only an effect on
69 | Windows platforms.
70 |
71 | In addition to the error codes, Libgpg-error also provides a set of
72 | functions used by most GnuPG components. */
73 |
74 |
75 | /* The error source type gpg_err_source_t.
76 |
77 | Where as the Poo out of a welle small
78 | Taketh his firste springing and his sours.
79 | --Chaucer. */
80 |
81 | /* Only use free slots, never change or reorder the existing
82 | entries. */
83 | typedef enum
84 | {
85 | GPG_ERR_SOURCE_UNKNOWN = 0,
86 | GPG_ERR_SOURCE_GCRYPT = 1,
87 | GPG_ERR_SOURCE_GPG = 2,
88 | GPG_ERR_SOURCE_GPGSM = 3,
89 | GPG_ERR_SOURCE_GPGAGENT = 4,
90 | GPG_ERR_SOURCE_PINENTRY = 5,
91 | GPG_ERR_SOURCE_SCD = 6,
92 | GPG_ERR_SOURCE_GPGME = 7,
93 | GPG_ERR_SOURCE_KEYBOX = 8,
94 | GPG_ERR_SOURCE_KSBA = 9,
95 | GPG_ERR_SOURCE_DIRMNGR = 10,
96 | GPG_ERR_SOURCE_GSTI = 11,
97 | GPG_ERR_SOURCE_GPA = 12,
98 | GPG_ERR_SOURCE_KLEO = 13,
99 | GPG_ERR_SOURCE_G13 = 14,
100 | GPG_ERR_SOURCE_ASSUAN = 15,
101 | GPG_ERR_SOURCE_ANY = 31,
102 | GPG_ERR_SOURCE_USER_1 = 32,
103 | GPG_ERR_SOURCE_USER_2 = 33,
104 | GPG_ERR_SOURCE_USER_3 = 34,
105 | GPG_ERR_SOURCE_USER_4 = 35,
106 |
107 | /* This is one more than the largest allowed entry. */
108 | GPG_ERR_SOURCE_DIM = 128
109 | } gpg_err_source_t;
110 |
111 |
112 | /* The error code type gpg_err_code_t. */
113 |
114 | /* Only use free slots, never change or reorder the existing
115 | entries. */
116 | typedef enum
117 | {
118 | GPG_ERR_NO_ERROR = 0,
119 | GPG_ERR_GENERAL = 1,
120 | GPG_ERR_UNKNOWN_PACKET = 2,
121 | GPG_ERR_UNKNOWN_VERSION = 3,
122 | GPG_ERR_PUBKEY_ALGO = 4,
123 | GPG_ERR_DIGEST_ALGO = 5,
124 | GPG_ERR_BAD_PUBKEY = 6,
125 | GPG_ERR_BAD_SECKEY = 7,
126 | GPG_ERR_BAD_SIGNATURE = 8,
127 | GPG_ERR_NO_PUBKEY = 9,
128 | GPG_ERR_CHECKSUM = 10,
129 | GPG_ERR_BAD_PASSPHRASE = 11,
130 | GPG_ERR_CIPHER_ALGO = 12,
131 | GPG_ERR_KEYRING_OPEN = 13,
132 | GPG_ERR_INV_PACKET = 14,
133 | GPG_ERR_INV_ARMOR = 15,
134 | GPG_ERR_NO_USER_ID = 16,
135 | GPG_ERR_NO_SECKEY = 17,
136 | GPG_ERR_WRONG_SECKEY = 18,
137 | GPG_ERR_BAD_KEY = 19,
138 | GPG_ERR_COMPR_ALGO = 20,
139 | GPG_ERR_NO_PRIME = 21,
140 | GPG_ERR_NO_ENCODING_METHOD = 22,
141 | GPG_ERR_NO_ENCRYPTION_SCHEME = 23,
142 | GPG_ERR_NO_SIGNATURE_SCHEME = 24,
143 | GPG_ERR_INV_ATTR = 25,
144 | GPG_ERR_NO_VALUE = 26,
145 | GPG_ERR_NOT_FOUND = 27,
146 | GPG_ERR_VALUE_NOT_FOUND = 28,
147 | GPG_ERR_SYNTAX = 29,
148 | GPG_ERR_BAD_MPI = 30,
149 | GPG_ERR_INV_PASSPHRASE = 31,
150 | GPG_ERR_SIG_CLASS = 32,
151 | GPG_ERR_RESOURCE_LIMIT = 33,
152 | GPG_ERR_INV_KEYRING = 34,
153 | GPG_ERR_TRUSTDB = 35,
154 | GPG_ERR_BAD_CERT = 36,
155 | GPG_ERR_INV_USER_ID = 37,
156 | GPG_ERR_UNEXPECTED = 38,
157 | GPG_ERR_TIME_CONFLICT = 39,
158 | GPG_ERR_KEYSERVER = 40,
159 | GPG_ERR_WRONG_PUBKEY_ALGO = 41,
160 | GPG_ERR_TRIBUTE_TO_D_A = 42,
161 | GPG_ERR_WEAK_KEY = 43,
162 | GPG_ERR_INV_KEYLEN = 44,
163 | GPG_ERR_INV_ARG = 45,
164 | GPG_ERR_BAD_URI = 46,
165 | GPG_ERR_INV_URI = 47,
166 | GPG_ERR_NETWORK = 48,
167 | GPG_ERR_UNKNOWN_HOST = 49,
168 | GPG_ERR_SELFTEST_FAILED = 50,
169 | GPG_ERR_NOT_ENCRYPTED = 51,
170 | GPG_ERR_NOT_PROCESSED = 52,
171 | GPG_ERR_UNUSABLE_PUBKEY = 53,
172 | GPG_ERR_UNUSABLE_SECKEY = 54,
173 | GPG_ERR_INV_VALUE = 55,
174 | GPG_ERR_BAD_CERT_CHAIN = 56,
175 | GPG_ERR_MISSING_CERT = 57,
176 | GPG_ERR_NO_DATA = 58,
177 | GPG_ERR_BUG = 59,
178 | GPG_ERR_NOT_SUPPORTED = 60,
179 | GPG_ERR_INV_OP = 61,
180 | GPG_ERR_TIMEOUT = 62,
181 | GPG_ERR_INTERNAL = 63,
182 | GPG_ERR_EOF_GCRYPT = 64,
183 | GPG_ERR_INV_OBJ = 65,
184 | GPG_ERR_TOO_SHORT = 66,
185 | GPG_ERR_TOO_LARGE = 67,
186 | GPG_ERR_NO_OBJ = 68,
187 | GPG_ERR_NOT_IMPLEMENTED = 69,
188 | GPG_ERR_CONFLICT = 70,
189 | GPG_ERR_INV_CIPHER_MODE = 71,
190 | GPG_ERR_INV_FLAG = 72,
191 | GPG_ERR_INV_HANDLE = 73,
192 | GPG_ERR_TRUNCATED = 74,
193 | GPG_ERR_INCOMPLETE_LINE = 75,
194 | GPG_ERR_INV_RESPONSE = 76,
195 | GPG_ERR_NO_AGENT = 77,
196 | GPG_ERR_AGENT = 78,
197 | GPG_ERR_INV_DATA = 79,
198 | GPG_ERR_ASSUAN_SERVER_FAULT = 80,
199 | GPG_ERR_ASSUAN = 81,
200 | GPG_ERR_INV_SESSION_KEY = 82,
201 | GPG_ERR_INV_SEXP = 83,
202 | GPG_ERR_UNSUPPORTED_ALGORITHM = 84,
203 | GPG_ERR_NO_PIN_ENTRY = 85,
204 | GPG_ERR_PIN_ENTRY = 86,
205 | GPG_ERR_BAD_PIN = 87,
206 | GPG_ERR_INV_NAME = 88,
207 | GPG_ERR_BAD_DATA = 89,
208 | GPG_ERR_INV_PARAMETER = 90,
209 | GPG_ERR_WRONG_CARD = 91,
210 | GPG_ERR_NO_DIRMNGR = 92,
211 | GPG_ERR_DIRMNGR = 93,
212 | GPG_ERR_CERT_REVOKED = 94,
213 | GPG_ERR_NO_CRL_KNOWN = 95,
214 | GPG_ERR_CRL_TOO_OLD = 96,
215 | GPG_ERR_LINE_TOO_LONG = 97,
216 | GPG_ERR_NOT_TRUSTED = 98,
217 | GPG_ERR_CANCELED = 99,
218 | GPG_ERR_BAD_CA_CERT = 100,
219 | GPG_ERR_CERT_EXPIRED = 101,
220 | GPG_ERR_CERT_TOO_YOUNG = 102,
221 | GPG_ERR_UNSUPPORTED_CERT = 103,
222 | GPG_ERR_UNKNOWN_SEXP = 104,
223 | GPG_ERR_UNSUPPORTED_PROTECTION = 105,
224 | GPG_ERR_CORRUPTED_PROTECTION = 106,
225 | GPG_ERR_AMBIGUOUS_NAME = 107,
226 | GPG_ERR_CARD = 108,
227 | GPG_ERR_CARD_RESET = 109,
228 | GPG_ERR_CARD_REMOVED = 110,
229 | GPG_ERR_INV_CARD = 111,
230 | GPG_ERR_CARD_NOT_PRESENT = 112,
231 | GPG_ERR_NO_PKCS15_APP = 113,
232 | GPG_ERR_NOT_CONFIRMED = 114,
233 | GPG_ERR_CONFIGURATION = 115,
234 | GPG_ERR_NO_POLICY_MATCH = 116,
235 | GPG_ERR_INV_INDEX = 117,
236 | GPG_ERR_INV_ID = 118,
237 | GPG_ERR_NO_SCDAEMON = 119,
238 | GPG_ERR_SCDAEMON = 120,
239 | GPG_ERR_UNSUPPORTED_PROTOCOL = 121,
240 | GPG_ERR_BAD_PIN_METHOD = 122,
241 | GPG_ERR_CARD_NOT_INITIALIZED = 123,
242 | GPG_ERR_UNSUPPORTED_OPERATION = 124,
243 | GPG_ERR_WRONG_KEY_USAGE = 125,
244 | GPG_ERR_NOTHING_FOUND = 126,
245 | GPG_ERR_WRONG_BLOB_TYPE = 127,
246 | GPG_ERR_MISSING_VALUE = 128,
247 | GPG_ERR_HARDWARE = 129,
248 | GPG_ERR_PIN_BLOCKED = 130,
249 | GPG_ERR_USE_CONDITIONS = 131,
250 | GPG_ERR_PIN_NOT_SYNCED = 132,
251 | GPG_ERR_INV_CRL = 133,
252 | GPG_ERR_BAD_BER = 134,
253 | GPG_ERR_INV_BER = 135,
254 | GPG_ERR_ELEMENT_NOT_FOUND = 136,
255 | GPG_ERR_IDENTIFIER_NOT_FOUND = 137,
256 | GPG_ERR_INV_TAG = 138,
257 | GPG_ERR_INV_LENGTH = 139,
258 | GPG_ERR_INV_KEYINFO = 140,
259 | GPG_ERR_UNEXPECTED_TAG = 141,
260 | GPG_ERR_NOT_DER_ENCODED = 142,
261 | GPG_ERR_NO_CMS_OBJ = 143,
262 | GPG_ERR_INV_CMS_OBJ = 144,
263 | GPG_ERR_UNKNOWN_CMS_OBJ = 145,
264 | GPG_ERR_UNSUPPORTED_CMS_OBJ = 146,
265 | GPG_ERR_UNSUPPORTED_ENCODING = 147,
266 | GPG_ERR_UNSUPPORTED_CMS_VERSION = 148,
267 | GPG_ERR_UNKNOWN_ALGORITHM = 149,
268 | GPG_ERR_INV_ENGINE = 150,
269 | GPG_ERR_PUBKEY_NOT_TRUSTED = 151,
270 | GPG_ERR_DECRYPT_FAILED = 152,
271 | GPG_ERR_KEY_EXPIRED = 153,
272 | GPG_ERR_SIG_EXPIRED = 154,
273 | GPG_ERR_ENCODING_PROBLEM = 155,
274 | GPG_ERR_INV_STATE = 156,
275 | GPG_ERR_DUP_VALUE = 157,
276 | GPG_ERR_MISSING_ACTION = 158,
277 | GPG_ERR_MODULE_NOT_FOUND = 159,
278 | GPG_ERR_INV_OID_STRING = 160,
279 | GPG_ERR_INV_TIME = 161,
280 | GPG_ERR_INV_CRL_OBJ = 162,
281 | GPG_ERR_UNSUPPORTED_CRL_VERSION = 163,
282 | GPG_ERR_INV_CERT_OBJ = 164,
283 | GPG_ERR_UNKNOWN_NAME = 165,
284 | GPG_ERR_LOCALE_PROBLEM = 166,
285 | GPG_ERR_NOT_LOCKED = 167,
286 | GPG_ERR_PROTOCOL_VIOLATION = 168,
287 | GPG_ERR_INV_MAC = 169,
288 | GPG_ERR_INV_REQUEST = 170,
289 | GPG_ERR_UNKNOWN_EXTN = 171,
290 | GPG_ERR_UNKNOWN_CRIT_EXTN = 172,
291 | GPG_ERR_LOCKED = 173,
292 | GPG_ERR_UNKNOWN_OPTION = 174,
293 | GPG_ERR_UNKNOWN_COMMAND = 175,
294 | GPG_ERR_NOT_OPERATIONAL = 176,
295 | GPG_ERR_NO_PASSPHRASE = 177,
296 | GPG_ERR_NO_PIN = 178,
297 | GPG_ERR_NOT_ENABLED = 179,
298 | GPG_ERR_NO_ENGINE = 180,
299 | GPG_ERR_MISSING_KEY = 181,
300 | GPG_ERR_TOO_MANY = 182,
301 | GPG_ERR_LIMIT_REACHED = 183,
302 | GPG_ERR_NOT_INITIALIZED = 184,
303 | GPG_ERR_MISSING_ISSUER_CERT = 185,
304 | GPG_ERR_NO_KEYSERVER = 186,
305 | GPG_ERR_INV_CURVE = 187,
306 | GPG_ERR_UNKNOWN_CURVE = 188,
307 | GPG_ERR_DUP_KEY = 189,
308 | GPG_ERR_AMBIGUOUS = 190,
309 | GPG_ERR_NO_CRYPT_CTX = 191,
310 | GPG_ERR_WRONG_CRYPT_CTX = 192,
311 | GPG_ERR_BAD_CRYPT_CTX = 193,
312 | GPG_ERR_CRYPT_CTX_CONFLICT = 194,
313 | GPG_ERR_BROKEN_PUBKEY = 195,
314 | GPG_ERR_BROKEN_SECKEY = 196,
315 | GPG_ERR_MAC_ALGO = 197,
316 | GPG_ERR_FULLY_CANCELED = 198,
317 | GPG_ERR_UNFINISHED = 199,
318 | GPG_ERR_BUFFER_TOO_SHORT = 200,
319 | GPG_ERR_SEXP_INV_LEN_SPEC = 201,
320 | GPG_ERR_SEXP_STRING_TOO_LONG = 202,
321 | GPG_ERR_SEXP_UNMATCHED_PAREN = 203,
322 | GPG_ERR_SEXP_NOT_CANONICAL = 204,
323 | GPG_ERR_SEXP_BAD_CHARACTER = 205,
324 | GPG_ERR_SEXP_BAD_QUOTATION = 206,
325 | GPG_ERR_SEXP_ZERO_PREFIX = 207,
326 | GPG_ERR_SEXP_NESTED_DH = 208,
327 | GPG_ERR_SEXP_UNMATCHED_DH = 209,
328 | GPG_ERR_SEXP_UNEXPECTED_PUNC = 210,
329 | GPG_ERR_SEXP_BAD_HEX_CHAR = 211,
330 | GPG_ERR_SEXP_ODD_HEX_NUMBERS = 212,
331 | GPG_ERR_SEXP_BAD_OCT_CHAR = 213,
332 | GPG_ERR_KEY_ON_CARD = 253,
333 | GPG_ERR_INV_LOCK_OBJ = 254,
334 | GPG_ERR_ASS_GENERAL = 257,
335 | GPG_ERR_ASS_ACCEPT_FAILED = 258,
336 | GPG_ERR_ASS_CONNECT_FAILED = 259,
337 | GPG_ERR_ASS_INV_RESPONSE = 260,
338 | GPG_ERR_ASS_INV_VALUE = 261,
339 | GPG_ERR_ASS_INCOMPLETE_LINE = 262,
340 | GPG_ERR_ASS_LINE_TOO_LONG = 263,
341 | GPG_ERR_ASS_NESTED_COMMANDS = 264,
342 | GPG_ERR_ASS_NO_DATA_CB = 265,
343 | GPG_ERR_ASS_NO_INQUIRE_CB = 266,
344 | GPG_ERR_ASS_NOT_A_SERVER = 267,
345 | GPG_ERR_ASS_NOT_A_CLIENT = 268,
346 | GPG_ERR_ASS_SERVER_START = 269,
347 | GPG_ERR_ASS_READ_ERROR = 270,
348 | GPG_ERR_ASS_WRITE_ERROR = 271,
349 | GPG_ERR_ASS_TOO_MUCH_DATA = 273,
350 | GPG_ERR_ASS_UNEXPECTED_CMD = 274,
351 | GPG_ERR_ASS_UNKNOWN_CMD = 275,
352 | GPG_ERR_ASS_SYNTAX = 276,
353 | GPG_ERR_ASS_CANCELED = 277,
354 | GPG_ERR_ASS_NO_INPUT = 278,
355 | GPG_ERR_ASS_NO_OUTPUT = 279,
356 | GPG_ERR_ASS_PARAMETER = 280,
357 | GPG_ERR_ASS_UNKNOWN_INQUIRE = 281,
358 | GPG_ERR_USER_1 = 1024,
359 | GPG_ERR_USER_2 = 1025,
360 | GPG_ERR_USER_3 = 1026,
361 | GPG_ERR_USER_4 = 1027,
362 | GPG_ERR_USER_5 = 1028,
363 | GPG_ERR_USER_6 = 1029,
364 | GPG_ERR_USER_7 = 1030,
365 | GPG_ERR_USER_8 = 1031,
366 | GPG_ERR_USER_9 = 1032,
367 | GPG_ERR_USER_10 = 1033,
368 | GPG_ERR_USER_11 = 1034,
369 | GPG_ERR_USER_12 = 1035,
370 | GPG_ERR_USER_13 = 1036,
371 | GPG_ERR_USER_14 = 1037,
372 | GPG_ERR_USER_15 = 1038,
373 | GPG_ERR_USER_16 = 1039,
374 | GPG_ERR_MISSING_ERRNO = 16381,
375 | GPG_ERR_UNKNOWN_ERRNO = 16382,
376 | GPG_ERR_EOF = 16383,
377 |
378 | /* The following error codes are used to map system errors. */
379 | #define GPG_ERR_SYSTEM_ERROR (1 << 15)
380 | GPG_ERR_E2BIG = GPG_ERR_SYSTEM_ERROR | 0,
381 | GPG_ERR_EACCES = GPG_ERR_SYSTEM_ERROR | 1,
382 | GPG_ERR_EADDRINUSE = GPG_ERR_SYSTEM_ERROR | 2,
383 | GPG_ERR_EADDRNOTAVAIL = GPG_ERR_SYSTEM_ERROR | 3,
384 | GPG_ERR_EADV = GPG_ERR_SYSTEM_ERROR | 4,
385 | GPG_ERR_EAFNOSUPPORT = GPG_ERR_SYSTEM_ERROR | 5,
386 | GPG_ERR_EAGAIN = GPG_ERR_SYSTEM_ERROR | 6,
387 | GPG_ERR_EALREADY = GPG_ERR_SYSTEM_ERROR | 7,
388 | GPG_ERR_EAUTH = GPG_ERR_SYSTEM_ERROR | 8,
389 | GPG_ERR_EBACKGROUND = GPG_ERR_SYSTEM_ERROR | 9,
390 | GPG_ERR_EBADE = GPG_ERR_SYSTEM_ERROR | 10,
391 | GPG_ERR_EBADF = GPG_ERR_SYSTEM_ERROR | 11,
392 | GPG_ERR_EBADFD = GPG_ERR_SYSTEM_ERROR | 12,
393 | GPG_ERR_EBADMSG = GPG_ERR_SYSTEM_ERROR | 13,
394 | GPG_ERR_EBADR = GPG_ERR_SYSTEM_ERROR | 14,
395 | GPG_ERR_EBADRPC = GPG_ERR_SYSTEM_ERROR | 15,
396 | GPG_ERR_EBADRQC = GPG_ERR_SYSTEM_ERROR | 16,
397 | GPG_ERR_EBADSLT = GPG_ERR_SYSTEM_ERROR | 17,
398 | GPG_ERR_EBFONT = GPG_ERR_SYSTEM_ERROR | 18,
399 | GPG_ERR_EBUSY = GPG_ERR_SYSTEM_ERROR | 19,
400 | GPG_ERR_ECANCELED = GPG_ERR_SYSTEM_ERROR | 20,
401 | GPG_ERR_ECHILD = GPG_ERR_SYSTEM_ERROR | 21,
402 | GPG_ERR_ECHRNG = GPG_ERR_SYSTEM_ERROR | 22,
403 | GPG_ERR_ECOMM = GPG_ERR_SYSTEM_ERROR | 23,
404 | GPG_ERR_ECONNABORTED = GPG_ERR_SYSTEM_ERROR | 24,
405 | GPG_ERR_ECONNREFUSED = GPG_ERR_SYSTEM_ERROR | 25,
406 | GPG_ERR_ECONNRESET = GPG_ERR_SYSTEM_ERROR | 26,
407 | GPG_ERR_ED = GPG_ERR_SYSTEM_ERROR | 27,
408 | GPG_ERR_EDEADLK = GPG_ERR_SYSTEM_ERROR | 28,
409 | GPG_ERR_EDEADLOCK = GPG_ERR_SYSTEM_ERROR | 29,
410 | GPG_ERR_EDESTADDRREQ = GPG_ERR_SYSTEM_ERROR | 30,
411 | GPG_ERR_EDIED = GPG_ERR_SYSTEM_ERROR | 31,
412 | GPG_ERR_EDOM = GPG_ERR_SYSTEM_ERROR | 32,
413 | GPG_ERR_EDOTDOT = GPG_ERR_SYSTEM_ERROR | 33,
414 | GPG_ERR_EDQUOT = GPG_ERR_SYSTEM_ERROR | 34,
415 | GPG_ERR_EEXIST = GPG_ERR_SYSTEM_ERROR | 35,
416 | GPG_ERR_EFAULT = GPG_ERR_SYSTEM_ERROR | 36,
417 | GPG_ERR_EFBIG = GPG_ERR_SYSTEM_ERROR | 37,
418 | GPG_ERR_EFTYPE = GPG_ERR_SYSTEM_ERROR | 38,
419 | GPG_ERR_EGRATUITOUS = GPG_ERR_SYSTEM_ERROR | 39,
420 | GPG_ERR_EGREGIOUS = GPG_ERR_SYSTEM_ERROR | 40,
421 | GPG_ERR_EHOSTDOWN = GPG_ERR_SYSTEM_ERROR | 41,
422 | GPG_ERR_EHOSTUNREACH = GPG_ERR_SYSTEM_ERROR | 42,
423 | GPG_ERR_EIDRM = GPG_ERR_SYSTEM_ERROR | 43,
424 | GPG_ERR_EIEIO = GPG_ERR_SYSTEM_ERROR | 44,
425 | GPG_ERR_EILSEQ = GPG_ERR_SYSTEM_ERROR | 45,
426 | GPG_ERR_EINPROGRESS = GPG_ERR_SYSTEM_ERROR | 46,
427 | GPG_ERR_EINTR = GPG_ERR_SYSTEM_ERROR | 47,
428 | GPG_ERR_EINVAL = GPG_ERR_SYSTEM_ERROR | 48,
429 | GPG_ERR_EIO = GPG_ERR_SYSTEM_ERROR | 49,
430 | GPG_ERR_EISCONN = GPG_ERR_SYSTEM_ERROR | 50,
431 | GPG_ERR_EISDIR = GPG_ERR_SYSTEM_ERROR | 51,
432 | GPG_ERR_EISNAM = GPG_ERR_SYSTEM_ERROR | 52,
433 | GPG_ERR_EL2HLT = GPG_ERR_SYSTEM_ERROR | 53,
434 | GPG_ERR_EL2NSYNC = GPG_ERR_SYSTEM_ERROR | 54,
435 | GPG_ERR_EL3HLT = GPG_ERR_SYSTEM_ERROR | 55,
436 | GPG_ERR_EL3RST = GPG_ERR_SYSTEM_ERROR | 56,
437 | GPG_ERR_ELIBACC = GPG_ERR_SYSTEM_ERROR | 57,
438 | GPG_ERR_ELIBBAD = GPG_ERR_SYSTEM_ERROR | 58,
439 | GPG_ERR_ELIBEXEC = GPG_ERR_SYSTEM_ERROR | 59,
440 | GPG_ERR_ELIBMAX = GPG_ERR_SYSTEM_ERROR | 60,
441 | GPG_ERR_ELIBSCN = GPG_ERR_SYSTEM_ERROR | 61,
442 | GPG_ERR_ELNRNG = GPG_ERR_SYSTEM_ERROR | 62,
443 | GPG_ERR_ELOOP = GPG_ERR_SYSTEM_ERROR | 63,
444 | GPG_ERR_EMEDIUMTYPE = GPG_ERR_SYSTEM_ERROR | 64,
445 | GPG_ERR_EMFILE = GPG_ERR_SYSTEM_ERROR | 65,
446 | GPG_ERR_EMLINK = GPG_ERR_SYSTEM_ERROR | 66,
447 | GPG_ERR_EMSGSIZE = GPG_ERR_SYSTEM_ERROR | 67,
448 | GPG_ERR_EMULTIHOP = GPG_ERR_SYSTEM_ERROR | 68,
449 | GPG_ERR_ENAMETOOLONG = GPG_ERR_SYSTEM_ERROR | 69,
450 | GPG_ERR_ENAVAIL = GPG_ERR_SYSTEM_ERROR | 70,
451 | GPG_ERR_ENEEDAUTH = GPG_ERR_SYSTEM_ERROR | 71,
452 | GPG_ERR_ENETDOWN = GPG_ERR_SYSTEM_ERROR | 72,
453 | GPG_ERR_ENETRESET = GPG_ERR_SYSTEM_ERROR | 73,
454 | GPG_ERR_ENETUNREACH = GPG_ERR_SYSTEM_ERROR | 74,
455 | GPG_ERR_ENFILE = GPG_ERR_SYSTEM_ERROR | 75,
456 | GPG_ERR_ENOANO = GPG_ERR_SYSTEM_ERROR | 76,
457 | GPG_ERR_ENOBUFS = GPG_ERR_SYSTEM_ERROR | 77,
458 | GPG_ERR_ENOCSI = GPG_ERR_SYSTEM_ERROR | 78,
459 | GPG_ERR_ENODATA = GPG_ERR_SYSTEM_ERROR | 79,
460 | GPG_ERR_ENODEV = GPG_ERR_SYSTEM_ERROR | 80,
461 | GPG_ERR_ENOENT = GPG_ERR_SYSTEM_ERROR | 81,
462 | GPG_ERR_ENOEXEC = GPG_ERR_SYSTEM_ERROR | 82,
463 | GPG_ERR_ENOLCK = GPG_ERR_SYSTEM_ERROR | 83,
464 | GPG_ERR_ENOLINK = GPG_ERR_SYSTEM_ERROR | 84,
465 | GPG_ERR_ENOMEDIUM = GPG_ERR_SYSTEM_ERROR | 85,
466 | GPG_ERR_ENOMEM = GPG_ERR_SYSTEM_ERROR | 86,
467 | GPG_ERR_ENOMSG = GPG_ERR_SYSTEM_ERROR | 87,
468 | GPG_ERR_ENONET = GPG_ERR_SYSTEM_ERROR | 88,
469 | GPG_ERR_ENOPKG = GPG_ERR_SYSTEM_ERROR | 89,
470 | GPG_ERR_ENOPROTOOPT = GPG_ERR_SYSTEM_ERROR | 90,
471 | GPG_ERR_ENOSPC = GPG_ERR_SYSTEM_ERROR | 91,
472 | GPG_ERR_ENOSR = GPG_ERR_SYSTEM_ERROR | 92,
473 | GPG_ERR_ENOSTR = GPG_ERR_SYSTEM_ERROR | 93,
474 | GPG_ERR_ENOSYS = GPG_ERR_SYSTEM_ERROR | 94,
475 | GPG_ERR_ENOTBLK = GPG_ERR_SYSTEM_ERROR | 95,
476 | GPG_ERR_ENOTCONN = GPG_ERR_SYSTEM_ERROR | 96,
477 | GPG_ERR_ENOTDIR = GPG_ERR_SYSTEM_ERROR | 97,
478 | GPG_ERR_ENOTEMPTY = GPG_ERR_SYSTEM_ERROR | 98,
479 | GPG_ERR_ENOTNAM = GPG_ERR_SYSTEM_ERROR | 99,
480 | GPG_ERR_ENOTSOCK = GPG_ERR_SYSTEM_ERROR | 100,
481 | GPG_ERR_ENOTSUP = GPG_ERR_SYSTEM_ERROR | 101,
482 | GPG_ERR_ENOTTY = GPG_ERR_SYSTEM_ERROR | 102,
483 | GPG_ERR_ENOTUNIQ = GPG_ERR_SYSTEM_ERROR | 103,
484 | GPG_ERR_ENXIO = GPG_ERR_SYSTEM_ERROR | 104,
485 | GPG_ERR_EOPNOTSUPP = GPG_ERR_SYSTEM_ERROR | 105,
486 | GPG_ERR_EOVERFLOW = GPG_ERR_SYSTEM_ERROR | 106,
487 | GPG_ERR_EPERM = GPG_ERR_SYSTEM_ERROR | 107,
488 | GPG_ERR_EPFNOSUPPORT = GPG_ERR_SYSTEM_ERROR | 108,
489 | GPG_ERR_EPIPE = GPG_ERR_SYSTEM_ERROR | 109,
490 | GPG_ERR_EPROCLIM = GPG_ERR_SYSTEM_ERROR | 110,
491 | GPG_ERR_EPROCUNAVAIL = GPG_ERR_SYSTEM_ERROR | 111,
492 | GPG_ERR_EPROGMISMATCH = GPG_ERR_SYSTEM_ERROR | 112,
493 | GPG_ERR_EPROGUNAVAIL = GPG_ERR_SYSTEM_ERROR | 113,
494 | GPG_ERR_EPROTO = GPG_ERR_SYSTEM_ERROR | 114,
495 | GPG_ERR_EPROTONOSUPPORT = GPG_ERR_SYSTEM_ERROR | 115,
496 | GPG_ERR_EPROTOTYPE = GPG_ERR_SYSTEM_ERROR | 116,
497 | GPG_ERR_ERANGE = GPG_ERR_SYSTEM_ERROR | 117,
498 | GPG_ERR_EREMCHG = GPG_ERR_SYSTEM_ERROR | 118,
499 | GPG_ERR_EREMOTE = GPG_ERR_SYSTEM_ERROR | 119,
500 | GPG_ERR_EREMOTEIO = GPG_ERR_SYSTEM_ERROR | 120,
501 | GPG_ERR_ERESTART = GPG_ERR_SYSTEM_ERROR | 121,
502 | GPG_ERR_EROFS = GPG_ERR_SYSTEM_ERROR | 122,
503 | GPG_ERR_ERPCMISMATCH = GPG_ERR_SYSTEM_ERROR | 123,
504 | GPG_ERR_ESHUTDOWN = GPG_ERR_SYSTEM_ERROR | 124,
505 | GPG_ERR_ESOCKTNOSUPPORT = GPG_ERR_SYSTEM_ERROR | 125,
506 | GPG_ERR_ESPIPE = GPG_ERR_SYSTEM_ERROR | 126,
507 | GPG_ERR_ESRCH = GPG_ERR_SYSTEM_ERROR | 127,
508 | GPG_ERR_ESRMNT = GPG_ERR_SYSTEM_ERROR | 128,
509 | GPG_ERR_ESTALE = GPG_ERR_SYSTEM_ERROR | 129,
510 | GPG_ERR_ESTRPIPE = GPG_ERR_SYSTEM_ERROR | 130,
511 | GPG_ERR_ETIME = GPG_ERR_SYSTEM_ERROR | 131,
512 | GPG_ERR_ETIMEDOUT = GPG_ERR_SYSTEM_ERROR | 132,
513 | GPG_ERR_ETOOMANYREFS = GPG_ERR_SYSTEM_ERROR | 133,
514 | GPG_ERR_ETXTBSY = GPG_ERR_SYSTEM_ERROR | 134,
515 | GPG_ERR_EUCLEAN = GPG_ERR_SYSTEM_ERROR | 135,
516 | GPG_ERR_EUNATCH = GPG_ERR_SYSTEM_ERROR | 136,
517 | GPG_ERR_EUSERS = GPG_ERR_SYSTEM_ERROR | 137,
518 | GPG_ERR_EWOULDBLOCK = GPG_ERR_SYSTEM_ERROR | 138,
519 | GPG_ERR_EXDEV = GPG_ERR_SYSTEM_ERROR | 139,
520 | GPG_ERR_EXFULL = GPG_ERR_SYSTEM_ERROR | 140,
521 |
522 | /* This is one more than the largest allowed entry. */
523 | GPG_ERR_CODE_DIM = 65536
524 | } gpg_err_code_t;
525 |
526 |
527 | /* The error value type gpg_error_t. */
528 |
529 | /* We would really like to use bit-fields in a struct, but using
530 | structs as return values can cause binary compatibility issues, in
531 | particular if you want to do it effeciently (also see
532 | -freg-struct-return option to GCC). */
533 | typedef unsigned int gpg_error_t;
534 |
535 | /* We use the lowest 16 bits of gpg_error_t for error codes. The 16th
536 | bit indicates system errors. */
537 | #define GPG_ERR_CODE_MASK (GPG_ERR_CODE_DIM - 1)
538 |
539 | /* Bits 17 to 24 are reserved. */
540 |
541 | /* We use the upper 7 bits of gpg_error_t for error sources. */
542 | #define GPG_ERR_SOURCE_MASK (GPG_ERR_SOURCE_DIM - 1)
543 | #define GPG_ERR_SOURCE_SHIFT 24
544 |
545 | /* The highest bit is reserved. It shouldn't be used to prevent
546 | potential negative numbers when transmitting error values as
547 | text. */
548 |
549 |
550 | /* GCC feature test. */
551 | #undef _GPG_ERR_HAVE_CONSTRUCTOR
552 | #if __GNUC__
553 | #define _GPG_ERR_GCC_VERSION (__GNUC__ * 10000 \
554 | + __GNUC_MINOR__ * 100 \
555 | + __GNUC_PATCHLEVEL__)
556 |
557 | #if _GPG_ERR_GCC_VERSION > 30100
558 | #define _GPG_ERR_CONSTRUCTOR __attribute__ ((__constructor__))
559 | #define _GPG_ERR_HAVE_CONSTRUCTOR
560 | #endif
561 | #endif
562 |
563 | #ifndef _GPG_ERR_CONSTRUCTOR
564 | #define _GPG_ERR_CONSTRUCTOR
565 | #endif
566 |
567 |
568 | /* Initialization function. */
569 |
570 | /* Initialize the library. This function should be run early. */
571 | gpg_error_t gpg_err_init (void) _GPG_ERR_CONSTRUCTOR;
572 |
573 | /* If this is defined, the library is already initialized by the
574 | constructor and does not need to be initialized explicitely. */
575 | #undef GPG_ERR_INITIALIZED
576 | #ifdef _GPG_ERR_HAVE_CONSTRUCTOR
577 | #define GPG_ERR_INITIALIZED 1
578 | #endif
579 |
580 | /* See the source on how to use the deinit function; it is usually not
581 | required. */
582 | void gpg_err_deinit (int mode);
583 |
584 |
585 | /* Constructor and accessor functions. */
586 |
587 | /* Construct an error value from an error code and source. Within a
588 | subsystem, use gpg_error. */
589 | static GPG_ERR_INLINE gpg_error_t
590 | gpg_err_make (gpg_err_source_t source, gpg_err_code_t code)
591 | {
592 | return code == GPG_ERR_NO_ERROR ? GPG_ERR_NO_ERROR
593 | : (((source & GPG_ERR_SOURCE_MASK) << GPG_ERR_SOURCE_SHIFT)
594 | | (code & GPG_ERR_CODE_MASK));
595 | }
596 |
597 |
598 | /* The user should define GPG_ERR_SOURCE_DEFAULT before including this
599 | file to specify a default source for gpg_error. */
600 | #ifndef GPG_ERR_SOURCE_DEFAULT
601 | #define GPG_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_UNKNOWN
602 | #endif
603 |
604 | static GPG_ERR_INLINE gpg_error_t
605 | gpg_error (gpg_err_code_t code)
606 | {
607 | return gpg_err_make (GPG_ERR_SOURCE_DEFAULT, code);
608 | }
609 |
610 |
611 | /* Retrieve the error code from an error value. */
612 | static GPG_ERR_INLINE gpg_err_code_t
613 | gpg_err_code (gpg_error_t err)
614 | {
615 | return (gpg_err_code_t) (err & GPG_ERR_CODE_MASK);
616 | }
617 |
618 |
619 | /* Retrieve the error source from an error value. */
620 | static GPG_ERR_INLINE gpg_err_source_t
621 | gpg_err_source (gpg_error_t err)
622 | {
623 | return (gpg_err_source_t) ((err >> GPG_ERR_SOURCE_SHIFT)
624 | & GPG_ERR_SOURCE_MASK);
625 | }
626 |
627 |
628 | /* String functions. */
629 |
630 | /* Return a pointer to a string containing a description of the error
631 | code in the error value ERR. This function is not thread-safe. */
632 | const char *gpg_strerror (gpg_error_t err);
633 |
634 | /* Return the error string for ERR in the user-supplied buffer BUF of
635 | size BUFLEN. This function is, in contrast to gpg_strerror,
636 | thread-safe if a thread-safe strerror_r() function is provided by
637 | the system. If the function succeeds, 0 is returned and BUF
638 | contains the string describing the error. If the buffer was not
639 | large enough, ERANGE is returned and BUF contains as much of the
640 | beginning of the error string as fits into the buffer. */
641 | int gpg_strerror_r (gpg_error_t err, char *buf, size_t buflen);
642 |
643 | /* Return a pointer to a string containing a description of the error
644 | source in the error value ERR. */
645 | const char *gpg_strsource (gpg_error_t err);
646 |
647 |
648 | /* Mapping of system errors (errno). */
649 |
650 | /* Retrieve the error code for the system error ERR. This returns
651 | GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report
652 | this). */
653 | gpg_err_code_t gpg_err_code_from_errno (int err);
654 |
655 |
656 | /* Retrieve the system error for the error code CODE. This returns 0
657 | if CODE is not a system error code. */
658 | int gpg_err_code_to_errno (gpg_err_code_t code);
659 |
660 |
661 | /* Retrieve the error code directly from the ERRNO variable. This
662 | returns GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped
663 | (report this) and GPG_ERR_MISSING_ERRNO if ERRNO has the value 0. */
664 | gpg_err_code_t gpg_err_code_from_syserror (void);
665 |
666 |
667 | /* Set the ERRNO variable. This function is the preferred way to set
668 | ERRNO due to peculiarities on WindowsCE. */
669 | void gpg_err_set_errno (int err);
670 |
671 | /* Return or check the version. */
672 | const char *gpg_error_check_version (const char *req_version);
673 |
674 | /* The version string of this header. */
675 | #define GPG_ERROR_VERSION "1.13"
676 |
677 | /* The version number of this header. */
678 | #define GPG_ERROR_VERSION_NUMBER 0x010d00
679 |
680 |
681 | /* Decide whether to use the format_arg attribute. */
682 | #if _GPG_ERR_GCC_VERSION > 20800
683 | # define _GPG_ERR_ATTR_FORMAT_ARG(a) __attribute__ ((__format_arg__ (a)))
684 | #else
685 | # define _GPG_ERR_ATTR_FORMAT_ARG(a)
686 | #endif
687 |
688 | /* A lean gettext implementation based on GNU style mo files which are
689 | required to be encoded in UTF-8. There is a limit on 65534 entries
690 | to save some RAM. Only Germanic plural rules are supported. */
691 | const char *_gpg_w32_bindtextdomain (const char *domainname,
692 | const char *dirname);
693 | const char *_gpg_w32_textdomain (const char *domainname);
694 | const char *_gpg_w32_gettext (const char *msgid)
695 | _GPG_ERR_ATTR_FORMAT_ARG (1);
696 | const char *_gpg_w32_dgettext (const char *domainname, const char *msgid)
697 | _GPG_ERR_ATTR_FORMAT_ARG (2);
698 | const char *_gpg_w32_dngettext (const char *domainname, const char *msgid1,
699 | const char *msgid2, unsigned long int n)
700 | _GPG_ERR_ATTR_FORMAT_ARG (2) _GPG_ERR_ATTR_FORMAT_ARG (3);
701 | const char *_gpg_w32_gettext_localename (void);
702 | int _gpg_w32_gettext_use_utf8 (int value);
703 |
704 | #ifdef GPG_ERR_ENABLE_GETTEXT_MACROS
705 | # define bindtextdomain(a,b) _gpg_w32_bindtextdomain ((a), (b))
706 | # define textdomain(a) _gpg_w32_textdomain ((a))
707 | # define gettext(a) _gpg_w32_gettext ((a))
708 | # define dgettext(a,b) _gpg_w32_dgettext ((a), (b))
709 | # define ngettext(a,b,c) _gpg_w32_dngettext (NULL, (a), (b), (c))
710 | # define dngettext(a,b,c,d) _gpg_w32_dngettext ((a), (b), (c), (d))
711 | # define gettext_localename() _gpg_w32_gettext_localename ()
712 | # define gettext_use_utf8(a) _gpg_w32_gettext_use_utf8 (a)
713 | #endif /*GPG_ERR_ENABLE_GETTEXT_MACROS*/
714 |
715 |
716 |
717 | /* Self-documenting convenience functions. */
718 |
719 | static GPG_ERR_INLINE gpg_error_t
720 | gpg_err_make_from_errno (gpg_err_source_t source, int err)
721 | {
722 | return gpg_err_make (source, gpg_err_code_from_errno (err));
723 | }
724 |
725 |
726 | static GPG_ERR_INLINE gpg_error_t
727 | gpg_error_from_errno (int err)
728 | {
729 | return gpg_error (gpg_err_code_from_errno (err));
730 | }
731 |
732 | static GPG_ERR_INLINE gpg_error_t
733 | gpg_error_from_syserror (void)
734 | {
735 | return gpg_error (gpg_err_code_from_syserror ());
736 | }
737 |
738 |
739 |
740 | /* Lock functions. */
741 |
742 |
743 | #ifdef _WIN64
744 |
745 | #pragma pack(push, 8)
746 | typedef struct
747 | {
748 | volatile char priv[56];
749 | } gpgrt_lock_t;
750 | #pragma pack(pop)
751 |
752 | #define GPGRT_LOCK_INITIALIZER {1,0,0,0,0,0,0,0,255,255,255,255, \
753 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \
754 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \
755 | 0,0,0,0,0,0,0,0,0,0,0,0}
756 |
757 | #else
758 |
759 | #pragma pack(push, 8)
760 | typedef struct
761 | {
762 | volatile char priv[36];
763 | } gpgrt_lock_t;
764 | #pragma pack(pop)
765 |
766 | #define GPGRT_LOCK_INITIALIZER {1,0,0,0,0,0,0,0,255,255,255,255, \
767 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \
768 | 0,0,0,0,0,0,0,0}
769 | #endif
770 |
771 | #define GPGRT_LOCK_DEFINE(name) \
772 | static gpgrt_lock_t name = GPGRT_LOCK_INITIALIZER
773 |
774 | /* NB: If GPGRT_LOCK_DEFINE is not used, zero out the lock variable
775 | before passing it to gpgrt_lock_init. */
776 | gpg_err_code_t gpgrt_lock_init (gpgrt_lock_t *lockhd);
777 | gpg_err_code_t gpgrt_lock_lock (gpgrt_lock_t *lockhd);
778 | gpg_err_code_t gpgrt_lock_unlock (gpgrt_lock_t *lockhd);
779 | gpg_err_code_t gpgrt_lock_destroy (gpgrt_lock_t *lockhd);
780 |
781 |
782 |
783 | /* Thread functions. */
784 |
785 | gpg_err_code_t gpgrt_yield (void);
786 |
787 |
788 |
789 |
790 | /* Estream */
791 |
792 |
793 |
794 | #ifdef __cplusplus
795 | }
796 | #endif
797 | #endif /* GPG_ERROR_H */
798 | /*
799 | Local Variables:
800 | buffer-read-only: t
801 | End:
802 | */
803 |
--------------------------------------------------------------------------------