Changeset 9b6eca57342f7056dda0aa56262a4b5c399c1a77
- Timestamp:
- 09/08/08 23:48:48 (5 years ago)
- Author:
- Armin Burgmeier <armin@…>
- Parents:
- 33c52287f29995de28e64ad9533a4d3455bb2c3f
- Children:
- e7981e590143ccddaf3c19fe3d9297f0ace08a0f
- git-committer:
- Armin Burgmeier <armin@arbur.net> / 2008-09-08T23:48:48Z+0200
- Message:
-
Use address from zeroconf for session connection, fixing link-local IPv6
2008-09-08 Armin Burgmeier <armin@…>
- inc/joindialog.hpp:
- src/joindialog.cpp: Added address column to zeroconf session list,
return on get_address() if host and port matches the selection.
- inc/joinprogressdialog.hpp:
- src/joinprogressdialog.cpp: Take a net6::address* that is used for
connection establishment when set (otherwise hostname/port).
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r33c5228
|
r9b6eca5
|
|
| | 1 | 2008-09-08 Armin Burgmeier <armin@0x539.de> |
| | 2 | |
| | 3 | * inc/joindialog.hpp: |
| | 4 | * src/joindialog.cpp: Added address column to zeroconf session list, |
| | 5 | return on get_address() if host and port matches the selection. |
| | 6 | |
| | 7 | * inc/joinprogressdialog.hpp: |
| | 8 | * src/joinprogressdialog.cpp: Take a net6::address* that is used for |
| | 9 | connection establishment when set (otherwise hostname/port). |
| | 10 | |
| | 11 | * inc/window.hpp: |
| | 12 | * src/window.cpp: Set address of JoinProgressDialog from JoinDialog. |
| | 13 | |
| 1 | 14 | 2008-09-08 Philipp Kern <phil@0x539.de> |
| 2 | 15 | |
-
|
rbe1b56b
|
r9b6eca5
|
|
| 28 | 28 | #include "features.hpp" |
| 29 | 29 | #include "colorsel.hpp" |
| | 30 | |
| | 31 | #include <net6/address.hpp> |
| | 32 | |
| 30 | 33 | #ifdef WITH_ZEROCONF |
| 31 | 34 | #include <gtkmm/box.h> |
| … |
… |
|
| 34 | 37 | #include <gtkmm/liststore.h> |
| 35 | 38 | #include <sigc++/connection.h> |
| 36 | | #include <net6/address.hpp> |
| 37 | 39 | #include <obby/zeroconf.hpp> |
| 38 | 40 | #endif |
| … |
… |
|
| 53 | 55 | Gtk::TreeModelColumn<Glib::ustring> host; |
| 54 | 56 | Gtk::TreeModelColumn<unsigned int> port; |
| | 57 | Gtk::TreeModelColumn<net6::address*> address; |
| 55 | 58 | }; |
| 56 | 59 | #endif |
| … |
… |
|
| 68 | 71 | Glib::ustring get_host() const; |
| 69 | 72 | unsigned int get_port() const; |
| | 73 | const net6::address* get_address(); |
| 70 | 74 | Glib::ustring get_name() const; |
| 71 | 75 | Gdk::Color get_color() const; |
-
|
re03285f
|
r9b6eca5
|
|
| 36 | 36 | Config::ParentEntry& config_entry, |
| 37 | 37 | const Glib::ustring& hostname, |
| 38 | | unsigned int port, |
| | 38 | unsigned int port, |
| | 39 | const net6::address* addr, |
| 39 | 40 | const Glib::ustring& username, |
| 40 | 41 | const Gdk::Color& color); |
| … |
… |
|
| 150 | 151 | Glib::ustring m_hostname; |
| 151 | 152 | unsigned int m_port; |
| | 153 | std::auto_ptr<net6::address> m_address; |
| 152 | 154 | Glib::ustring m_username; |
| 153 | 155 | Gdk::Color m_color; |
-
|
r88d9d5e
|
r9b6eca5
|
|
| 176 | 176 | bool session_join_impl(const Glib::ustring& host, |
| 177 | 177 | unsigned int port, |
| | 178 | const net6::address* addr, |
| 178 | 179 | const Glib::ustring& name, |
| 179 | 180 | const Gdk::Color& color); |
-
|
r33c5228
|
r9b6eca5
|
|
| 38 | 38 | add(host); |
| 39 | 39 | add(port); |
| | 40 | add(address); |
| 40 | 41 | } |
| 41 | 42 | #endif |
| … |
… |
|
| 185 | 186 | Gobby::JoinDialog::~JoinDialog() |
| 186 | 187 | { |
| | 188 | #ifdef WITH_ZEROCONF |
| | 189 | const Gtk::TreeModel::Children& children = m_session_list->children(); |
| | 190 | for(Gtk::TreeIter iter = children.begin(); |
| | 191 | iter != children.end(); ++ iter) |
| | 192 | { |
| | 193 | net6::address* addr = (*iter)[m_session_cols.address]; |
| | 194 | delete addr; |
| | 195 | } |
| | 196 | #endif |
| 187 | 197 | } |
| 188 | 198 | |
| … |
… |
|
| 195 | 205 | { |
| 196 | 206 | return static_cast<unsigned int>(m_ent_port.get_value() ); |
| | 207 | } |
| | 208 | |
| | 209 | const net6::address* Gobby::JoinDialog::get_address() |
| | 210 | { |
| | 211 | #ifdef WITH_ZEROCONF |
| | 212 | // m_session_view.get_selection() is not const, therefore this function |
| | 213 | // cannot be const. |
| | 214 | Gtk::TreeModel::iterator iter = |
| | 215 | m_session_view.get_selection()->get_selected(); |
| | 216 | if(iter != m_session_list->children().end()) |
| | 217 | { |
| | 218 | // Use address with port info if selected from zeroconf |
| | 219 | if(get_host() == (*iter)[m_session_cols.host] && |
| | 220 | get_port() == (*iter)[m_session_cols.port]) |
| | 221 | { |
| | 222 | return (*iter)[m_session_cols.address]; |
| | 223 | } |
| | 224 | } |
| | 225 | #endif |
| | 226 | return NULL; |
| 197 | 227 | } |
| 198 | 228 | |
| … |
… |
|
| 277 | 307 | // must implement get_port(). |
| 278 | 308 | row[m_session_cols.port] = addr.get_port(); |
| | 309 | row[m_session_cols.address] = addr.clone(); |
| 279 | 310 | |
| 280 | 311 | m_ep_discover.set_expanded(true); |
| … |
… |
|
| 285 | 316 | Gtk::TreeModel::iterator iter = find_entry(name); |
| 286 | 317 | if(iter == m_session_list->children().end() ) return; |
| | 318 | |
| | 319 | net6::address* addr = (*iter)[m_session_cols.address]; |
| | 320 | delete addr; |
| | 321 | |
| 287 | 322 | m_session_list->erase(iter); |
| 288 | 323 | } |
-
|
re03285f
|
r9b6eca5
|
|
| 301 | 301 | Gobby::JoinProgressDialog::JoinProgressDialog(Gtk::Window& parent, |
| 302 | 302 | Config::ParentEntry& config_entry, |
| 303 | | const Glib::ustring& hostname, |
| | 303 | const Glib::ustring& hostname, |
| 304 | 304 | unsigned int port, |
| | 305 | const net6::address* addr, |
| 305 | 306 | const Glib::ustring& username, |
| 306 | 307 | const Gdk::Color& color): |
| 307 | 308 | ProgressDialog(_("Joining obby session..."), parent), |
| 308 | 309 | m_config_entry(config_entry), m_hostname(hostname), m_port(port), |
| 309 | | m_username(username), m_color(color), m_got_welcome(false), |
| 310 | | m_got_done(false) |
| | 310 | m_address(addr ? addr->clone() : NULL), m_username(username), |
| | 311 | m_color(color), m_got_welcome(false), m_got_done(false) |
| 311 | 312 | { |
| 312 | 313 | obby::format_string str("Connecting to %0%..."); |
| … |
… |
|
| 329 | 330 | #endif |
| 330 | 331 | // Connection data |
| 331 | | Glib::ustring hostname = m_hostname; // Remote host name |
| 332 | | unsigned int port = m_port; // TCP port number |
| | 332 | const Glib::ustring hostname = m_hostname; |
| | 333 | unsigned int port = m_port; |
| | 334 | std::auto_ptr<net6::address> address( |
| | 335 | m_address.get() ? m_address->clone() : NULL); |
| 333 | 336 | |
| 334 | 337 | // Dialog may be closed now |
| … |
… |
|
| 364 | 367 | sigc::mem_fun(*this, &JoinProgressDialog::on_close) ); |
| 365 | 368 | |
| 366 | | // Establish connection |
| 367 | | buffer->connect(hostname, port); |
| | 369 | if(address.get()) |
| | 370 | // Establish connection |
| | 371 | buffer->connect(*address); |
| | 372 | else |
| | 373 | buffer->connect(hostname, port); |
| 368 | 374 | } |
| 369 | 375 | catch(net6::error& e) |
-
|
rea67c51
|
r9b6eca5
|
|
| 1239 | 1239 | Glib::ustring host = m_join_dlg->get_host(); |
| 1240 | 1240 | unsigned int port = m_join_dlg->get_port(); |
| | 1241 | const net6::address* addr = m_join_dlg->get_address(); |
| 1241 | 1242 | Glib::ustring name = m_join_dlg->get_name(); |
| 1242 | 1243 | Gdk::Color color = m_join_dlg->get_color(); |
| 1243 | 1244 | |
| 1244 | | if(session_join_impl(host, port, name, color) ) |
| | 1245 | if(session_join_impl(host, port, addr, name, color) ) |
| 1245 | 1246 | break; |
| 1246 | 1247 | else |
| … |
… |
|
| 1304 | 1305 | bool Gobby::Window::session_join_impl(const Glib::ustring& host, |
| 1305 | 1306 | unsigned int port, |
| | 1307 | const net6::address* addr, |
| 1306 | 1308 | const Glib::ustring& name, |
| 1307 | 1309 | const Gdk::Color& color) |
| … |
… |
|
| 1312 | 1314 | host, |
| 1313 | 1315 | port, |
| | 1316 | addr, |
| 1314 | 1317 | name, |
| 1315 | 1318 | color |