~lifeograph-core/lifeograph/lifeograph

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/***********************************************************************************

	Copyright (C) 2007-2020 Ahmet Öztürk (aoz_2@yahoo.com)

    This file is part of Lifeograph.

    Lifeograph is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Lifeograph is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Lifeograph.  If not, see <http://www.gnu.org/licenses/>.

***********************************************************************************/


#ifndef LIFEOGRAPH_DIALOG_PASSWORD_HEADER
#define LIFEOGRAPH_DIALOG_PASSWORD_HEADER


#include <gtkmm/dialog.h>
#include <gtkmm/entry.h>

#include "helpers.hpp"


namespace LIFEO
{

// PASSWORD DIALOG =================================================================================
class DialogPassword : public Gtk::Popover
{
    public:
        enum OperationType
        {
            // components:
            OTC_CHECK = 1,
            OTC_SET = 2,
            OTC_CURRENT = 4,
            OTC_NEW = 8,
            // composites:
            OT_AUTHENTICATE = 5,
            OT_OPEN = 6,
            OT_ADD = 10,
            OT_CHANGE = 15,
        };

                                    DialogPassword( BaseObjectType*,
                                                    const Glib::RefPtr< Gtk::Builder >& );

        static void                 launch( OperationType, Diary*,
                                            const Gdk::Rectangle*,
                                            Gtk::Widget*,
                                            const sigc::slot< void >&,
                                            const sigc::slot< void >& );
        static void                 finish( const std::string& path );

    protected:
        void                        launch_internal();
        void                        handle_entry_changed();
        void                        process_wrong_password( int = 0 );
        void                        authenticate();
        void                        check_match();
        void                        handle_go();

        Gtk::Button*                m_B_go;
        EntryClear*                 m_E_current;
        Gtk::Label*                 m_L_msg;

        Gtk::Grid*                  m_G_new;
        Gtk::Box*                   m_Bx_authenticate;
        Gtk::Button*                m_B_authenticate;
        EntryClear*                 m_E_new;
        EntryClear*                 m_E_confirm;

        sigc::slot< void >          m_handler_go;
        sigc::slot< void >          m_handler_cancel;

        Diary*                      m_ptr2diary;
        OperationType               m_ot;
        std::string                 m_path_prev;

        static DialogPassword*      ptr;

        static constexpr int        PHASE_COUNT = 20;
};

} // end of namespace LIFEO

#endif