File: MGConnectDialog.h

package info (click to toggle)
mysql-gui-tools 5.0r12-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 105,540 kB
  • ctags: 50,897
  • sloc: sql: 348,439; pascal: 285,780; cpp: 94,578; ansic: 90,768; objc: 33,761; sh: 25,629; xml: 10,924; yacc: 10,755; java: 9,986; php: 2,806; python: 2,068; makefile: 1,945; perl: 3
file content (126 lines) | stat: -rw-r--r-- 3,640 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
115
116
117
118
119
120
121
122
123
124
125
126
/* Copyright (C) 2003, 2004 MySQL AB

   This program 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 2 of the License, or
   (at your option) any later version.

   This program 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 this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

#ifndef _MGCONNECTDIALOG_H_
#define _MGCONNECTDIALOG_H_

#include <stdio.h>
#include <gtkmm.h>
#include <pthread.h>

#include <mysql.h>

#include "MGGladeXML.h"

#include "MYXInterface.h"

#include <myx_util_functions.h>
#include <myx_public_interface.h>
//#include <wmyx_public_interface.h>


class MGPreferences;

class MGConnectDialog : public Glib::ObjectBase {
  public:
    enum {
      MYG_FLAG_PICK_SCHEMA= (1<<0),
      MYG_FLAG_ALLOW_SKIP= (1<<1)
    };

 protected:
    MGPreferences *_prefs;
    
    MGGladeXML *_xml;

    MYSQL *_mysql;

    MYX::UserConnectionList *_connections;

    MYX::UserConnection _cur_conn;

    Glib::ustring _app_title;

    int _conn_result;
    pthread_t _conn_thread;

    Gtk::TextView *_ping_view;
    FILE *_ping_output;
    Gtk::MessageDialog *_ping_dialog;

    bool _advanced_shown;
    bool _pick_schema;
    bool _connecting;
    bool _ignore_connection_change;
    int _ignore_changes;
    
    bool _skip_connect;
    bool _cancel_clicked;

    int _current_selected_item;
 private:
    bool init(int flags, const std::string &header_image_file="");

    void load_connection_list(const std::string &clpath);

    Gtk::TextView *add_text_to_ping_dialog();
    void append_text_to_ping_view(const Glib::ustring &msg);

    void start_connection();
    void stop_connection();
    void update_connect_sensitivity();
    
    void show_connection_failed();

    void reset_connection_values();
    void display_connection_values(const MYX::UserConnection &conn);
    void fetch_connection_values(MYX::UserConnection &conn);

    static void* connection_thread(void *data);
    bool process_ping_output(Glib::IOCondition cond);

    void save_connection();
    void open_connection_editor();
    void preferences_changed();
    void preferences_closed();
    
    bool monitor_connection_thread();
    void on_connect_button_clicked();
    void on_clear_button_clicked();
    void on_cancel_button_clicked();
    void on_check_entry();
    void on_details_button_clicked();
    void on_connection_list_changed();

    bool on_window_close(GdkEventAny *ev);

    bool on_key_pressed(GdkEventKey *key);
    bool on_key_released(GdkEventKey *key);
public:
    MGConnectDialog(MGPreferences *prefs);
    ~MGConnectDialog();

    virtual bool run_with_defaults(const Glib::ustring &title,
                                   MYX::UserConnection *default_conn,
                                   int flags, const std::string &header_image_file="");
    virtual bool run(const Glib::ustring &title, int flags, const std::string &header_image_file="");

    MYSQL *get_connection() const { return _mysql; };
    MYX::UserConnection get_user_connection() const { return _cur_conn; };
};


#endif /* _MGCONNECTDIALOG_H_ */