Changeset 37d1c6c8b8138f6437b874300b99621b33b455a3

Show
Ignore:
Timestamp:
01/06/07 23:40:41 (6 years ago)
Author:
Philipp Kern <phil@…>
Parents:
8b539409d5a028ca07bf8e7f23329ad9731d79f4
Children:
b09b4b0883e0286cc03cc927822c658879604fc4
git-committer:
Philipp Kern <phil@0x539.de> / 2007-01-06T22:40:41Z+0000
Message:

[project @ User authentication stuff]

Original author: Armin Burgmeier <armin@…>
Date: 2005-07-17 13:17:52+00:00

Files:
5 modified

Legend:

Unmodified
Added
Removed
  • inc/header.hpp

    rf0556c4 r37d1c6c  
    5656        typedef sigc::signal<void> signal_document_save_type; 
    5757        typedef sigc::signal<void> signal_document_close_type; 
     58        typedef sigc::signal<void> signal_user_set_password_type; 
    5859        typedef sigc::signal<void> signal_document_word_wrap_type; 
    5960#ifdef WITH_GTKSOURCEVIEW 
     
    8485        signal_document_save_type document_save_event() const; 
    8586        signal_document_close_type document_close_event() const; 
     87        signal_user_set_password_type user_set_password_event() const; 
    8688        signal_document_word_wrap_type document_word_wrap_event() const; 
    8789#ifdef WITH_GTKSOURCEVIEW 
     
    108110        void on_app_document_save(); 
    109111        void on_app_document_close(); 
     112        void on_app_user_set_password(); 
    110113        void on_app_document_word_wrap(); 
    111114#ifdef WITH_GTKSOURCEVIEW 
     
    150153        signal_document_save_type m_signal_document_save; 
    151154        signal_document_close_type m_signal_document_close; 
     155        signal_user_set_password_type m_signal_user_set_password; 
    152156        signal_document_word_wrap_type m_signal_document_word_wrap; 
    153157#ifdef WITH_GTKSOURCEVIEW 
  • inc/window.hpp

    r8b53940 r37d1c6c  
    5959        void on_document_close(); 
    6060 
     61        void on_user_set_password(); 
     62 
    6163        void on_document_word_wrap(); 
    6264#ifdef WITH_GTKSOURCEVIEW 
     
    7577        void on_obby_login_failed(obby::login::error error); 
    7678        bool on_obby_global_password(std::string& password); 
     79        bool on_obby_user_password(std::string& password); 
    7780        void on_obby_close(); 
    7881        void on_obby_sync(); 
  • src/chat.cpp

    r3fa3653 r37d1c6c  
    120120        // Highlight the message if the user's nickname is found in it, 
    121121        // but not if the message is coming from the user itself. 
    122         if( (user != self) && 
     122        if( (&user != &self) && 
    123123            (message.find(self.get_name() ) != Glib::ustring::npos) ) 
    124124                colour = "darkred"; 
  • src/header.cpp

    rf0556c4 r37d1c6c  
    2222#include <obby/format_string.hpp> 
    2323#include <obby/local_buffer.hpp> 
     24#include <obby/client_buffer.hpp> 
    2425 
    2526#include "features.hpp" 
     
    4445                "      <menuitem action=\"CloseDocument\" />" 
    4546                "    </menu>" 
     47                "    <menu action=\"MenuUser\">" 
     48                "      <menuitem action=\"UserSetPassword\" />" 
     49                "    </menu>" 
    4650                "    <menu action=\"MenuView\">" 
    4751                "      <menuitem action=\"ViewWordWrap\" />" 
     
    241245                        *this, 
    242246                        &Header::on_app_document_close 
     247                ) 
     248        ); 
     249 
     250        // User menu 
     251        m_group_app->add(Gtk::Action::create("MenuUser", _("User")) ); 
     252 
     253        // Set password 
     254        m_group_app->add( 
     255                Gtk::Action::create( 
     256                        "UserSetPassword", 
     257                        Gtk::Stock::DIALOG_AUTHENTICATION, 
     258                        _("Set password"), 
     259                        _("Sets a password for this user") 
     260                ), 
     261                sigc::mem_fun( 
     262                        *this, 
     263                        &Header::on_app_user_set_password 
    243264                ) 
    244265        ); 
     
    395416        m_group_app->get_action("CloseDocument")->set_sensitive(false); 
    396417        m_group_app->get_action("QuitSession")->set_sensitive(false); 
    397 #ifdef WITH_GTKSOURCEVIEW 
     418 
     419        m_group_app->get_action("MenuUser")->set_sensitive(false); 
    398420        m_group_app->get_action("MenuView")->set_sensitive(false); 
    399 #endif 
    400421 
    401422        // Connect to folder's signals 
     
    422443        m_group_app->get_action("SaveDocument")->set_sensitive(false); 
    423444        m_group_app->get_action("CloseDocument")->set_sensitive(false); 
    424 #ifdef WITH_GTKSOURCEVIEW 
    425445        m_group_app->get_action("MenuView")->set_sensitive(false); 
    426 #endif 
    427446} 
    428447 
     
    467486{ 
    468487        return m_signal_document_close; 
     488} 
     489 
     490Gobby::Header::signal_user_set_password_type 
     491Gobby::Header::user_set_password_event() const 
     492{ 
     493        return m_signal_user_set_password; 
    469494} 
    470495 
     
    512537        m_group_app->get_action("OpenDocument")->set_sensitive(true); 
    513538 
     539        // Enable password button if we are client 
     540        m_group_app->get_action("MenuUser")->set_sensitive(true); 
     541        m_group_app->get_action("UserSetPassword")->set_sensitive( 
     542                dynamic_cast<obby::client_buffer*>(&buf) != NULL); 
     543 
    514544        // Document actions will be activated from the insert_document event 
    515545        m_group_app->get_action("SaveDocument")->set_sensitive(false); 
     
    526556        m_group_app->get_action("JoinSession")->set_sensitive(true); 
    527557        m_group_app->get_action("QuitSession")->set_sensitive(false); 
     558 
     559        // Disable user buttons 
     560        m_group_app->get_action("MenuUser")->set_sensitive(false); 
    528561 
    529562        // Disable document buttons 
     
    601634{ 
    602635        m_signal_document_close.emit(); 
     636} 
     637 
     638void Gobby::Header::on_app_user_set_password() 
     639{ 
     640        m_signal_user_set_password.emit(); 
    603641} 
    604642 
  • src/window.cpp

    r8b53940 r37d1c6c  
    2727#include <gtkmm/stock.h> 
    2828 
     29#include <obby/format_string.hpp> 
    2930#include <obby/client_buffer.hpp> 
    3031#include <obby/host_buffer.hpp> 
     
    6465                sigc::mem_fun(*this, &Window::on_document_close) ); 
    6566 
     67        m_header.user_set_password_event().connect( 
     68                sigc::mem_fun(*this, &Window::on_user_set_password) ); 
     69 
    6670        m_header.document_word_wrap_event().connect( 
    6771                sigc::mem_fun(*this, &Window::on_document_word_wrap) ); 
     
    229233                buffer->global_password_event().connect( 
    230234                        sigc::mem_fun(*this, &Window::on_obby_global_password)); 
     235                buffer->user_password_event().connect( 
     236                        sigc::mem_fun(*this, &Window::on_obby_user_password) ); 
    231237                buffer->close_event().connect( 
    232238                        sigc::mem_fun(*this, &Window::on_obby_close) ); 
     
    234240                        sigc::mem_fun(*this, &Window::on_obby_sync) ); 
    235241 
    236                 /* TODO: Connect to on_global_password to prompt for password */ 
    237242                /* TODO: Add password entry widget in join dialog */ 
    238243                /* TODO: Add password entry widget in host dialog */ 
     
    426431} 
    427432 
     433void Gobby::Window::on_user_set_password() 
     434{ 
     435        // TODO: Password dialog with second entry field to confirm password 
     436        EntryDialog dlg( 
     437                *this, 
     438                _("Set user password"), 
     439                _("Enter new password") 
     440        ); 
     441 
     442        dlg.get_entry().set_visibility(false); 
     443 
     444        if(dlg.run() == Gtk::RESPONSE_OK) 
     445        { 
     446                dynamic_cast<obby::client_buffer*>(m_buffer)->set_password( 
     447                        dlg.get_text() ); 
     448        } 
     449} 
     450 
    428451void Gobby::Window::on_document_word_wrap() 
    429452{ 
     
    499522                _("Password required"), 
    500523                _("Enter session password") 
     524        ); 
     525 
     526        // Disable view of typed characters (password input) 
     527        dlg.get_entry().set_visibility(false); 
     528        if(dlg.run() == Gtk::RESPONSE_OK) 
     529        { 
     530                // Use given text as password 
     531                password = dlg.get_text(); 
     532                return true; 
     533        } 
     534        else 
     535        { 
     536                // Close connection otherwise 
     537                on_session_quit(); 
     538                return false; 
     539        } 
     540} 
     541 
     542bool Gobby::Window::on_obby_user_password(std::string& password) 
     543{ 
     544        obby::format_string str(_("Enter user password for user %0") ); 
     545        str << m_buffer->get_name(); 
     546 
     547        // Prompt for password 
     548        EntryDialog dlg( 
     549                *this, 
     550                _("Password required"), 
     551                str.str() 
    501552        ); 
    502553