File: creddlg.h

package info (click to toggle)
wxpython4.0 4.2.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 221,752 kB
  • sloc: cpp: 962,555; python: 230,573; ansic: 170,731; makefile: 51,756; sh: 9,342; perl: 1,564; javascript: 584; php: 326; xml: 200
file content (114 lines) | stat: -rw-r--r-- 3,378 bytes parent folder | download | duplicates (4)
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/////////////////////////////////////////////////////////////////////////////
// Name:        creddlg.h
// Created:     2018-10-23
// Copyright:   (c) 2018 wxWidgets development team
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////

/**
    @class wxCredentialEntryDialog

    This class represents a dialog that requests a user name and a password
    from the user.

    Currently it is implemented as a generic wxWidgets dialog on all platforms.

    Simple example of using this dialog assuming @c MyFrame object has a member
    @c m_request of wxWebRequest type:
    @code
        void MyFrame::OnWebRequestState(wxWebRequestEvent& evt)
        {
            if ( evt.GetState() == wxWebRequest::State_Unauthorized )
            {
                wxCredentialEntryDialog dialog
                    (
                        this,
                        wxString::Format
                        (
                            "Please enter credentials for accessing "
                            "the web page at %s",
                            evt.GetResponse().GetURL()
                        ),
                        "My Application Title"
                    );
                if ( dialog.ShowModal() == wxID_OK )
                {
                    m_request.GetAuthChallenge().
                        SetCredentials(dialog.GetCredentials());
                }
                //else: the dialog was cancelled
            }
        }
    @endcode

    @note For secure saving and loading users and passwords, have a look at
        wxSecretStore.

    @since 3.1.5

    @library{wxcore}
    @category{cmndlg}

    @see @ref overview_cmndlg_cred
*/
class wxCredentialEntryDialog: public wxDialog
{
public:
    /**
        Default constructor.

        Call Create() to really create the dialog later.
    */
    wxCredentialEntryDialog();

    /**
        Constructor.

        Use ShowModal() to show the dialog.

        See Create() method for parameter description.
    */
    wxCredentialEntryDialog(wxWindow* parent, const wxString& message,
        const wxString& title,
        const wxWebCredentials& cred = wxWebCredentials());

    /**
        Create the dialog constructed using the default constructor.

        @param parent
            Parent window.
        @param message
            Message to show on the dialog.
        @param title
            Title of the dialog.
        @param cred
            The default username and password to use (optional).
    */
    bool Create(wxWindow* parent, const wxString& message,
        const wxString& title,
        const wxWebCredentials& cred = wxWebCredentials());

    /**
        Returns the credentials entered by the user.

        This should be called if ShowModal() returned ::wxID_OK.
    */
    wxWebCredentials GetCredentials() const;

    /**
        Sets the current user name.

        This function may be called before showing the dialog to provide the
        default value for the user name, if it's different from the one given
        at the creation time.
    */
    void SetUser(const wxString& user);

    /**
        Sets the current password.

        This function may be called before showing the dialog for the reasons
        similar to SetUser().
    */
    void SetPassword(const wxString& password);
};