Changeset cd0ff9f24329c7de221bd7a72ae605afae4f759e

Show
Ignore:
Timestamp:
18/09/08 22:16:27 (5 years ago)
Author:
Armin Burgmeier <armin@…>
Parents:
ebd3ac7923390c60435abec25998db679fc50781
Children:
04fe422de37ab2581560c02d9fbb84e47b49f86e
git-committer:
Armin Burgmeier <armin@arbur.net> / 2008-09-18T22:16:27Z+0200
Message:

Added GOBBY_CONFIGDIR define, honor for config files

2008-09-18 Armin Burgmeier <armin@…>

  • configure.ac: Added a new define, GOBBY_CONFIGDIR, that specifies where Gobby shall store it's configuration files (preferences, known documents, known hosts)
  • inc/core/preferences.hpp:
  • src/core/preferences.cpp: Added a security section with trust file and security-policy entries, changed serialise to serialize for consistency.
  • src/window.cpp: Call preferences.serialize instead of serialise.
  • src/core/browser.cpp: Use the security policy to create new XMPP connections. Honor GOBBY_CONFIGDIR for known hosts file.
  • src/core/documentinfostorage: Honor GOBBY_CONFIGDIR for known documents file.
  • src/main.cpp: Honor GOBBY_CONFIGDIR for config file.
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • ChangeLog

    rebd3ac7 rcd0ff9f  
     12008-09-18  Armin Burgmeier  <armin@arbur.net> 
     2 
     3        * configure.ac: Added a new define, GOBBY_CONFIGDIR, that specifies 
     4        where Gobby shall store it's configuration files (preferences, known 
     5        documents, known hosts) 
     6 
     7        * inc/core/preferences.hpp: 
     8        * src/core/preferences.cpp: Added a security section with trust 
     9        file and security-policy entries, changed serialise to serialize for 
     10        consistency. 
     11 
     12        * src/window.cpp: Call preferences.serialize instead of serialise. 
     13 
     14        * src/core/browser.cpp: Use the security policy to create new XMPP 
     15        connections. Honor GOBBY_CONFIGDIR for known hosts file. 
     16 
     17        * src/core/documentinfostorage: Honor GOBBY_CONFIGDIR for known 
     18        documents file. 
     19 
     20        * src/main.cpp: Honor GOBBY_CONFIGDIR for config file. 
     21 
    1222008-09-17  Armin Burgmeier  <armin@arbur.net> 
    223 
  • configure.ac

    rebd3ac7 rcd0ff9f  
    7777AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], ["${GETTEXT_PACKAGE}"], [gettext domain]) 
    7878 
     79AC_DEFINE(GOBBY_CONFIGDIR, [".gobby-0.5"], 
     80          [where to store Gobby's config files, 
     81           relative to the user's home directory]) 
     82 
    7983AC_OUTPUT([ 
    8084        Makefile 
  • inc/core/preferences.hpp

    rfb634fc rcd0ff9f  
    2525 
    2626#include <gtkmm/toolbar.h> 
     27 
     28#include <libinfinity/common/inf-xmpp-connection.h> 
    2729 
    2830namespace Gobby 
     
    9092        /** Serialises preferences back to config. 
    9193         */ 
    92         void serialise(Config& config) const; 
     94        void serialize(Config& config) const; 
    9395 
    9496        class User 
     
    9698        public: 
    9799                User(Config::ParentEntry& entry); 
    98                 void serialise(Config::ParentEntry& entry) const; 
     100                void serialize(Config::ParentEntry& entry) const; 
    99101 
    100102                Option<Glib::ustring> name; 
     
    107109        public: 
    108110                Editor(Config::ParentEntry& entry); 
    109                 void serialise(Config::ParentEntry& entry) const; 
     111                void serialize(Config::ParentEntry& entry) const; 
    110112 
    111113                Option<unsigned int> tab_width; 
     
    119121        public: 
    120122                View(Config::ParentEntry& entry); 
    121                 void serialise(Config::ParentEntry& entry) const; 
     123                void serialize(Config::ParentEntry& entry) const; 
    122124 
    123125                Option<Gtk::WrapMode> wrap_mode; 
     
    133135        public: 
    134136                Appearance(Config::ParentEntry& entry); 
    135                 void serialise(Config::ParentEntry& entry) const; 
     137                void serialize(Config::ParentEntry& entry) const; 
    136138 
     139                // TODO: Option<bool> use_system_default_toolbar_style 
     140                // (sets toolbar_style by gconf). At least WITH_GNOME. 
    137141                Option<Gtk::ToolbarStyle> toolbar_style; 
    138142                Option<Pango::FontDescription> font; 
     
    146150        }; 
    147151 
     152        class Security 
     153        { 
     154        public: 
     155                Security(Config::ParentEntry& entry); 
     156                void serialize(Config::ParentEntry& entry) const; 
     157 
     158                Option<std::string> trust_file; 
     159                Option<InfXmppConnectionSecurityPolicy> policy; 
     160        }; 
     161 
    148162        User user; 
    149163        Editor editor; 
    150164        View view; 
    151165        Appearance appearance; 
     166        Security security; 
    152167}; 
    153168 
  • src/core/browser.cpp

    r8667620 rcd0ff9f  
    7272 
    7373        Glib::ustring known_hosts_file = Glib::build_filename( 
    74                 Glib::get_home_dir(), ".gobby/known_hosts"); 
     74                Glib::get_home_dir(), GOBBY_CONFIGDIR"/known_hosts"); 
    7575        m_cert_manager = inf_gtk_certificate_manager_new( 
    7676                parent.gobj(), m_xmpp_manager, 
     
    242242                        xmpp = inf_xmpp_connection_new( 
    243243                                connection, INF_XMPP_CONNECTION_CLIENT, 
    244                                 NULL, hostname.c_str(), NULL, NULL); 
     244                                NULL, hostname.c_str(), 
     245                                m_preferences.security.policy, NULL, NULL); 
    245246 
    246247                        inf_xmpp_manager_add_connection(m_xmpp_manager, xmpp); 
  • src/core/documentinfostorage.cpp

    r092ccc3 rcd0ff9f  
    2020#include "util/file.hpp" 
    2121 
     22#include "features.hpp" 
     23 
    2224#include <libxml++/nodes/textnode.h> 
    2325#include <libxml++/parsers/domparser.h> 
     
    8890                return Glib::build_filename( 
    8991                        Glib::get_home_dir(), 
    90                         Glib::build_filename(".gobby", "documents.xml")); 
     92                        Glib::build_filename( 
     93                                GOBBY_CONFIGDIR, 
     94                                "documents.xml")); 
    9195        } 
    9296} 
  • src/core/preferences.cpp

    rfb634fc rcd0ff9f  
    2323        name(entry.get_value<Glib::ustring>("name", Glib::get_user_name())), 
    2424        hue(entry.get_value<double>("hue", Glib::Rand().get_double())), 
    25         host_directory(entry.get_value<std::string>("host-directory", Glib::build_filename(Glib::get_home_dir(), ".infinote"))) 
     25        host_directory(entry.get_value<std::string>("host-directory", 
     26                Glib::build_filename(Glib::get_home_dir(), ".infinote"))) 
    2627{ 
    2728} 
    2829 
    29 void Gobby::Preferences::User::serialise(Config::ParentEntry& entry) const 
     30void Gobby::Preferences::User::serialize(Config::ParentEntry& entry) const 
    3031{ 
    3132        entry.set_value("name", name); 
     
    3536 
    3637Gobby::Preferences::Editor::Editor(Config::ParentEntry& entry): 
    37         tab_width(entry.get_value<unsigned int>("tab_width", 8)), 
    38         tab_spaces(entry.get_value<bool>("tab_insert_spaces", false)), 
    39         indentation_auto(entry.get_value<bool>("auto_indentation", true)), 
    40         homeend_smart(entry.get_value<bool>("smart_homeend", false) ) 
     38        tab_width(entry.get_value<unsigned int>("tab-width", 8)), 
     39        tab_spaces(entry.get_value<bool>("tab-insert-spaces", false)), 
     40        indentation_auto(entry.get_value<bool>("auto-indentation", true)), 
     41        homeend_smart(entry.get_value<bool>("smart-homeend", false) ) 
    4142{ 
    4243} 
    4344 
    44 void Gobby::Preferences::Editor::serialise(Config::ParentEntry& entry) const 
     45void Gobby::Preferences::Editor::serialize(Config::ParentEntry& entry) const 
    4546{ 
    46         entry.set_value("tab_width", tab_width); 
    47         entry.set_value("tab_insert_spaces", tab_spaces); 
    48         entry.set_value("auto_indentation", indentation_auto); 
    49         entry.set_value("smart_homeend", homeend_smart); 
     47        entry.set_value("tab-width", tab_width); 
     48        entry.set_value("tab-insert_spaces", tab_spaces); 
     49        entry.set_value("auto-indentation", indentation_auto); 
     50        entry.set_value("smart-homeend", homeend_smart); 
    5051} 
    5152 
    5253Gobby::Preferences::View::View(Config::ParentEntry& entry): 
    53         wrap_mode( 
    54                 static_cast<Gtk::WrapMode>( 
    55                         entry.get_value<int>( 
    56                                 "wrap_mode", 
    57                                 static_cast<int>(Gtk::WRAP_WORD_CHAR) 
    58                         ) 
    59                 ) 
    60         ), 
    61         linenum_display(entry.get_value<bool>("display_line_numbers", true)), 
    62         curline_highlight( 
    63                 entry.get_value<bool>("highlight_current_line", true) 
    64         ), 
    65         margin_display(entry.get_value<bool>("margin_display", true) ), 
    66         margin_pos(entry.get_value<unsigned int>("margin_position", 80) ), 
    67         bracket_highlight( 
    68                 entry.get_value<bool>("highlight_matching_brackets", true) 
    69         ) 
     54        wrap_mode(static_cast<Gtk::WrapMode>(entry.get_value<int>( 
     55                "wrap-mode", static_cast<int>(Gtk::WRAP_WORD_CHAR)))), 
     56        linenum_display(entry.get_value<bool>("display-line-numbers", true)), 
     57        curline_highlight(entry.get_value<bool>( 
     58                "highlight-current-line", true)), 
     59        margin_display(entry.get_value<bool>("margin-display", true) ), 
     60        margin_pos(entry.get_value<unsigned int>("margin-position", 80) ), 
     61        bracket_highlight(entry.get_value<bool>( 
     62                "highlight-matching-brackets", true)) 
    7063{ 
    7164} 
    7265 
    73 void Gobby::Preferences::View::serialise(Config::ParentEntry& entry) const 
     66void Gobby::Preferences::View::serialize(Config::ParentEntry& entry) const 
    7467{ 
    75         entry.set_value("wrap_mode", static_cast<int>(wrap_mode)); 
    76         entry.set_value("display_line_numbers", linenum_display); 
    77         entry.set_value("highlight_current_line", curline_highlight); 
    78         entry.set_value("margin_display", margin_display); 
    79         entry.set_value("margin_position", margin_pos); 
    80         entry.set_value("highlight_matching_brackets", bracket_highlight); 
     68        entry.set_value("wrap-mode", static_cast<int>(wrap_mode)); 
     69        entry.set_value("display-line-numbers", linenum_display); 
     70        entry.set_value("highlight-current-line", curline_highlight); 
     71        entry.set_value("margin-display", margin_display); 
     72        entry.set_value("margin-position", margin_pos); 
     73        entry.set_value("highlight-matching-brackets", bracket_highlight); 
    8174} 
    8275 
    8376Gobby::Preferences::Appearance::Appearance(Config::ParentEntry& entry): 
    84         toolbar_style( 
    85                 static_cast<Gtk::ToolbarStyle>( 
    86                         entry.get_value<int>( 
    87                                 "toolbar_style", 
    88                                 // TODO: Get default value from gconf 
    89                                 static_cast<int>(Gtk::TOOLBAR_BOTH) 
    90                         ) 
    91                 ) 
    92         ), 
     77        toolbar_style(static_cast<Gtk::ToolbarStyle>(entry.get_value<int>( 
     78                "toolbar-style", static_cast<int>(Gtk::TOOLBAR_BOTH)))), 
    9379        font(Pango::FontDescription(entry.get_value<Glib::ustring>( 
    9480                "font", "Monospace 10"))), 
    95         userlist_width(entry.get_value<unsigned int>("userlist_width", 150)), 
    96         show_toolbar(entry.get_value<bool>("show_toolbar", true)), 
    97         show_statusbar(entry.get_value<bool>("show_statusbar", true)), 
    98         show_browser(entry.get_value<bool>("show_browser", true)), 
    99         show_userlist(entry.get_value<bool>("show_userlist", true)) 
     81        userlist_width(entry.get_value<unsigned int>("userlist-width", 150)), 
     82        show_toolbar(entry.get_value<bool>("show-toolbar", true)), 
     83        show_statusbar(entry.get_value<bool>("show-statusbar", true)), 
     84        show_browser(entry.get_value<bool>("show-browser", true)), 
     85        show_userlist(entry.get_value<bool>("show-userlist", true)) 
    10086{ 
    10187} 
    10288 
    10389void Gobby::Preferences::Appearance:: 
    104         serialise(Config::ParentEntry& entry) const 
     90        serialize(Config::ParentEntry& entry) const 
    10591{ 
    106         entry.set_value("toolbar_style", static_cast<int>(toolbar_style) ); 
     92        entry.set_value("toolbar-style", static_cast<int>(toolbar_style) ); 
    10793 
    10894        entry.set_value( 
    10995                "font", 
    110                 static_cast<const Pango::FontDescription&>(font).to_string() 
    111         ); 
     96                static_cast<const Pango::FontDescription&>(font).to_string()); 
    11297 
    113         entry.set_value("userlist_width", userlist_width); 
     98        entry.set_value("userlist-width", userlist_width); 
    11499 
    115         entry.set_value("show_toolbar", show_toolbar); 
    116         entry.set_value("show_statusbar", show_statusbar); 
    117         entry.set_value("show_browser", show_browser); 
    118         entry.set_value("show_userlist", show_userlist); 
     100        entry.set_value("show-toolbar", show_toolbar); 
     101        entry.set_value("show-statusbar", show_statusbar); 
     102        entry.set_value("show-browser", show_browser); 
     103        entry.set_value("show-userlist", show_userlist); 
     104} 
     105 
     106Gobby::Preferences::Security::Security(Config::ParentEntry& entry): 
     107        trust_file(entry.get_value<std::string>("trust-file", "")), 
     108        policy(static_cast<InfXmppConnectionSecurityPolicy>( 
     109                entry.get_value<int>("policy", static_cast<int>( 
     110                        INF_XMPP_CONNECTION_SECURITY_BOTH_PREFER_TLS)))) 
     111{ 
     112} 
     113 
     114void Gobby::Preferences::Security::serialize(Config::ParentEntry& entry) const 
     115{ 
     116        entry.set_value("trust-file", trust_file); 
     117        entry.set_value("policy", static_cast<int>(policy)); 
    119118} 
    120119 
     
    123122        editor(config.get_root()["editor"]), 
    124123        view(config.get_root()["view"]), 
    125         appearance(config.get_root()["appearance"]) 
     124        appearance(config.get_root()["appearance"]), 
     125        security(config.get_root()["security"]) 
    126126{ 
    127127} 
    128128 
    129 void Gobby::Preferences::serialise(Config& config) const 
     129void Gobby::Preferences::serialize(Config& config) const 
    130130{ 
    131131        // Serialise into config 
    132         user.serialise(config.get_root()["user"]); 
    133         editor.serialise(config.get_root()["editor"]); 
    134         view.serialise(config.get_root()["view"]); 
    135         appearance.serialise(config.get_root()["appearance"]); 
     132        user.serialize(config.get_root()["user"]); 
     133        editor.serialize(config.get_root()["editor"]); 
     134        view.serialize(config.get_root()["view"]); 
     135        appearance.serialize(config.get_root()["appearance"]); 
     136        security.serialize(config.get_root()["security"]); 
    136137} 
    137138 
  • src/dialogs/preferencesdialog.cpp

    r1ad50d8 rcd0ff9f  
    325325        m_group_tab(_("Tab Stops") ), 
    326326        m_group_indentation(_("Indentation") ), 
    327         m_group_homeend(_("Home/End behaviour") ), 
     327        m_group_homeend(_("Home/End Behaviour") ), 
    328328        m_lbl_tab_width(_("Tab width:"), Gtk::ALIGN_RIGHT), 
    329329        m_btn_tab_spaces(_("Insert spaces instead of tabs") ), 
     
    381381 
    382382Gobby::PreferencesDialog::View::View(Preferences& preferences): 
    383         m_group_wrap(_("Text wrapping") ), 
    384         m_group_linenum(_("Line numbers") ), 
    385         m_group_curline(_("Current line") ), 
    386         m_group_margin(_("Right margin") ), 
    387         m_group_bracket(_("Bracket matching") ), 
     383        m_group_wrap(_("Text Wrapping") ), 
     384        m_group_linenum(_("Line Numbers") ), 
     385        m_group_curline(_("Current Line") ), 
     386        m_group_margin(_("Right Margin") ), 
     387        m_group_bracket(_("Bracket Matching") ), 
    388388        m_btn_wrap_text(_("Enable text wrapping") ), 
    389389        m_btn_wrap_words(_("Do not split words over two lines") ), 
  • src/main.cpp

    rebd3ac7 rcd0ff9f  
    8686 
    8787        // Read the configuration 
    88         Gobby::Config config(Glib::get_home_dir() + "/.gobby/config.xml"); 
     88        Gobby::Config config(Glib::build_filename( 
     89                Glib::get_home_dir(), 
     90                GOBBY_CONFIGDIR"/config.xml")); 
    8991 
    9092        // Create window 
  • src/window.cpp

    r5b59013 rcd0ff9f  
    8888{ 
    8989        // Serialise preferences into config 
    90         m_preferences.serialise(m_config); 
     90        m_preferences.serialize(m_config); 
    9191} 
    9292