centralize legal-session-name-checkng and include : and ; in characters that we disal...
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 9 Dec 2011 03:06:58 +0000 (03:06 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 9 Dec 2011 03:06:58 +0000 (03:06 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@10943 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/ardour_ui.cc
libs/ardour/ardour/session.h
libs/ardour/session.cc

index 382d8b7ca4716a6ad48fc594b70dfd135b28789b..54a74884f94cf6bd91592b1e8ddd140d1740e801 100644 (file)
@@ -2280,15 +2280,11 @@ ARDOUR_UI::rename_session ()
                bool do_rename = (name.length() != 0);
 
                if (do_rename) {
-                       if (name.find ('/') != string::npos) {
-                               MessageDialog msg (_("To ensure compatibility with various systems\n"
-                                                    "session names may not contain a '/' character"));
-                               msg.run ();
-                               goto again;
-                       }
-                       if (name.find ('\\') != string::npos) {
-                               MessageDialog msg (_("To ensure compatibility with various systems\n"
-                                                    "session names may not contain a '\\' character"));
+                       char illegal = Session::session_name_is_legal (name);
+
+                       if (illegal) {
+                               MessageDialog msg (string_compose (_("To ensure compatibility with various systems\n"
+                                                                    "session names may not contain a '%1' character"), illegal));
                                msg.run ();
                                goto again;
                        }
@@ -2666,19 +2662,13 @@ ARDOUR_UI::get_session_parameters (bool quit_on_cancel, bool should_be_new, stri
 
                                session_path = _startup->session_folder();
 
-                               if (session_name.find ('/') != string::npos) {
-                                       MessageDialog msg (*_startup,
-                                                          _("To ensure compatibility with various systems\n"
-                                                            "session names may not contain a '/' character"));
-                                       msg.run ();
-                                       ARDOUR_COMMAND_LINE::session_name = ""; // cancel that
-                                       continue;
-                               }
+                               char illegal = Session::session_name_is_legal (session_name);
 
-                               if (session_name.find ('\\') != string::npos) {
+                               if (illegal) {
                                        MessageDialog msg (*_startup,
-                                                          _("To ensure compatibility with various systems\n"
-                                                            "session names may not contain a '\\' character"));
+                                                          string_compose (_("To ensure compatibility with various systems\n"
+                                                                            "session names may not contain a '%1' character"),
+                                                                          illegal));
                                        msg.run ();
                                        ARDOUR_COMMAND_LINE::session_name = ""; // cancel that
                                        continue;
index 5b87b5bc9b4ea158695cd1d3aab0e397810341ef..3c1c9b564b4f3f6ae1c2e127af3fab1debdb328a 100644 (file)
@@ -238,6 +238,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        template<class T> void foreach_route (T *obj, void (T::*func)(boost::shared_ptr<Route>));
        template<class T, class A> void foreach_route (T *obj, void (T::*func)(Route&, A), A arg);
 
+       static char session_name_is_legal (const std::string&);
        bool io_name_is_legal (const std::string&);
        boost::shared_ptr<Route> route_by_name (std::string);
        boost::shared_ptr<Route> route_by_id (PBD::ID);
index d0ca7657546a1c042d5e3d214e74a4084c3f4885..4f5e8093bb3a732d92e3a9a0d1ec073ed6913c6d 100644 (file)
@@ -4543,3 +4543,16 @@ Session::update_latency_compensation (bool force_whole_graph)
        }
 }
 
+char
+Session::session_name_is_legal (const string& path)
+{
+       char illegal_chars[] = { '/', '\\', ':', ';', '\0' };
+
+       for (int i = 0; illegal_chars[i]; ++i) {
+               if (path.find (illegal_chars[i]) != string::npos) {
+                       return illegal_chars[i];
+               }
+       }
+
+       return 0;
+}